Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix application component issue in next.js #2101

Merged
1 change: 1 addition & 0 deletions src/components/ActivityTimeline/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface onToggleSectionEventShape {

export interface ActivityTimelineProps extends BaseProps {
children?: ReactNode;
variant?: 'default' | 'accordion';
multiple?: boolean;
onToggleSection?: (value: onToggleSectionEventShape) => void;
activeSectionNames?: Names;
Expand Down
3 changes: 2 additions & 1 deletion src/components/FileSelector/icon.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { ErrorIcon, FileIcon, FilesIcon, UploadIcon } from './icons';
import { FileListType } from './types';

export default function Icon({ files, error, isDragOver, value, uploadIcon }) {
if (value !== null) {
Expand All @@ -19,7 +20,7 @@ export default function Icon({ files, error, isDragOver, value, uploadIcon }) {
return uploadIcon || <UploadIcon />;
}
Icon.propTypes = {
files: PropTypes.instanceOf(FileList),
files: PropTypes.instanceOf(FileListType),
error: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
isDragOver: PropTypes.bool,
value: PropTypes.object,
Expand Down
4 changes: 4 additions & 0 deletions src/components/FileSelector/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { isServer } from '../../libs/utils';

// eslint-disable-next-line import/prefer-default-export
export const FileListType = isServer ? Object : window.FileList;
12 changes: 6 additions & 6 deletions src/libs/utils/getBrowserLocale.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import isServer from './isServer';

export default function getBrowserLocale() {
return (
(navigator.languages && navigator.languages[0]) ||
navigator.language ||
navigator.userLanguage ||
'en-US'
);
if (isServer) return 'en-US';
if (navigator.languages && navigator.languages.length > 0) return navigator.languages[0];
if (navigator.language) return navigator.language;
return 'en-US';
}
3 changes: 2 additions & 1 deletion src/libs/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import uniqueId from './uniqueId';
import getLocale from './getLocale';
import getBrowserLocale from './getBrowserLocale';
import getSuffixSI from './getSuffixSI';
import isServer from './isServer';

export { uniqueId, getLocale, getBrowserLocale, getSuffixSI };
export { uniqueId, getLocale, getBrowserLocale, getSuffixSI, isServer };
11 changes: 11 additions & 0 deletions src/libs/utils/isServer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const isBrowser = !!(
typeof window !== 'undefined' &&
window.document &&
window.document.createElement
);

const isNative = typeof navigator !== 'undefined' && navigator.product === 'ReactNative';

const isServer = !(isBrowser || isNative);

export default isServer;
3 changes: 3 additions & 0 deletions src/styles/helpers/color/isValidColor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { isServer } from '../../../libs/utils';

export default function isValidColor(color) {
if (isServer) return true;
const element = document.createElement('a');
element.style.color = color;
return element.style.color !== '';
Expand Down