Skip to content

Commit

Permalink
fix: window is not defined in SSR and throws error
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonC committed Jun 5, 2024
1 parent beff66b commit 0070089
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
15 changes: 15 additions & 0 deletions localNodeModulesSync.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ for (const target of targets) {
for (const folder of folders) {
const root = path.join(systemDir, folder);
const packageName = fs.readJsonSync(path.join(root, 'package.json')).name;
if (packageName === '@tablecheck/tablekit-css') {
const dest = path.join(target, 'node_modules', packageName);
if (!fs.existsSync(dest)) {
continue;
}
console.log(`Copying ${packageName} to ${target}`);
fs.readdirSync(dest, { withFileTypes: true }).forEach((dirent) => {
if (dirent.isDirectory()) return;
if (!dirent.name.endsWith('.css')) return;
fs.copyFileSync(
path.join(root, dirent.name),
path.join(dest, dirent.name)
);
});
}
const dest = path.join(target, 'node_modules', packageName, 'lib');
if (!fs.existsSync(dest)) {
continue;
Expand Down
6 changes: 4 additions & 2 deletions system/react-css/src/structuredComponents/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { TextAreaWithPrefix } from '../components/TextAreaWithPrefix';
import { TextAreaWithSuffix } from '../components/TextAreaWithSuffix';
import { getConfigDefault } from '../config';

const hasFieldSizingSupport = window.CSS?.supports?.('field-sizing', 'content');
const hasFieldSizingSupport =
typeof window === 'undefined'
? true
: window.CSS?.supports?.('field-sizing', 'content');

export type Props = textAreaCore.DefaultedProps &
Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'rows' | 'prefix'> & {
Expand Down Expand Up @@ -68,7 +71,6 @@ export const TextArea = React.forwardRef<HTMLTextAreaElement, Props>(
}, [iconBefore, iconAfter, suffix, prefix]);
return (
<Component
data-content={hasFieldSizingSupport ? undefined : props.defaultValue}
style={style}
className={className}
data-variant={variant}
Expand Down
6 changes: 4 additions & 2 deletions system/react/src/structuredComponents/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { TextAreaWithPrefix } from '../components/TextAreaWithPrefix';
import { TextAreaWithSuffix } from '../components/TextAreaWithSuffix';
import { getConfigDefault } from '../config';

const hasFieldSizingSupport = window.CSS?.supports?.('field-sizing', 'content');
const hasFieldSizingSupport =
typeof window === 'undefined'
? true
: window.CSS?.supports?.('field-sizing', 'content');

export type Props = textAreaCore.DefaultedProps &
Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'rows' | 'prefix'> & {
Expand Down Expand Up @@ -68,7 +71,6 @@ export const TextArea = React.forwardRef<HTMLTextAreaElement, Props>(
}, [iconBefore, iconAfter, suffix, prefix]);
return (
<Component
data-content={hasFieldSizingSupport ? undefined : props.defaultValue}
style={style}
className={className}
data-variant={variant}
Expand Down

0 comments on commit 0070089

Please sign in to comment.