@sqrzro/admin 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +4 -0
- package/.gitattributes +1 -0
- package/.prettierrc +9 -0
- package/.storybook/main.js +40 -0
- package/.storybook/manager.js +4 -0
- package/.storybook/postcss.config.js +3 -0
- package/.storybook/preview.js +11 -0
- package/.storybook/theme.js +7 -0
- package/.stylelintrc +9 -0
- package/LICENSE +5 -0
- package/README.md +9 -0
- package/__mocks__/squarezero-utility.ts +40 -0
- package/assets/logo-horizontal-dark.svg +21 -0
- package/assets/logo-horizontal-white.svg +21 -0
- package/assets/logo-vertical-dark.svg +21 -0
- package/assets/logo-vertical-white.svg +21 -0
- package/dist/index.css +3554 -0
- package/dist/index.js +5099 -0
- package/dist/index.js.map +1 -0
- package/dist/types/components/Alert/index.d.ts +10 -0
- package/dist/types/components/Allow/index.d.ts +13 -0
- package/dist/types/components/App/index.d.ts +19 -0
- package/dist/types/components/AutoSuggest/index.d.ts +60 -0
- package/dist/types/components/Button/index.d.ts +36 -0
- package/dist/types/components/CalendarInput/index.d.ts +10 -0
- package/dist/types/components/CheckboxList/index.d.ts +4 -0
- package/dist/types/components/ConnectedDropdown/index.d.ts +8 -0
- package/dist/types/components/ConnectedList/index.d.ts +4 -0
- package/dist/types/components/ConnectedScene/index.d.ts +11 -0
- package/dist/types/components/ConnectedTable/index.d.ts +4 -0
- package/dist/types/components/ContentBlock/index.d.ts +6 -0
- package/dist/types/components/DateInput/index.d.ts +7 -0
- package/dist/types/components/Document/index.d.ts +6 -0
- package/dist/types/components/Dropdown/index.d.ts +14 -0
- package/dist/types/components/Fieldset/index.d.ts +11 -0
- package/dist/types/components/FileInput/index.d.ts +4 -0
- package/dist/types/components/FilterLink/index.d.ts +7 -0
- package/dist/types/components/Form/index.d.ts +11 -0
- package/dist/types/components/FormActions/index.d.ts +9 -0
- package/dist/types/components/FormField/index.d.ts +27 -0
- package/dist/types/components/FormRepeater/index.d.ts +8 -0
- package/dist/types/components/ImageInput/index.d.ts +4 -0
- package/dist/types/components/InfoPanel/index.d.ts +8 -0
- package/dist/types/components/Link/__mocks__/index.d.ts +6 -0
- package/dist/types/components/Link/index.d.ts +13 -0
- package/dist/types/components/List/index.d.ts +23 -0
- package/dist/types/components/ListActions/index.d.ts +9 -0
- package/dist/types/components/LoginForm/index.d.ts +3 -0
- package/dist/types/components/Message/index.d.ts +7 -0
- package/dist/types/components/ModalActions/index.d.ts +11 -0
- package/dist/types/components/MoneyInput/index.d.ts +10 -0
- package/dist/types/components/PasswordForm/index.d.ts +3 -0
- package/dist/types/components/PasswordInput/index.d.ts +8 -0
- package/dist/types/components/RadioList/index.d.ts +4 -0
- package/dist/types/components/Scene/index.d.ts +10 -0
- package/dist/types/components/SummaryList/index.d.ts +8 -0
- package/dist/types/components/Switch/index.d.ts +9 -0
- package/dist/types/components/Table/index.d.ts +13 -0
- package/dist/types/components/Tag/index.d.ts +8 -0
- package/dist/types/components/TextArea/index.d.ts +4 -0
- package/dist/types/components/TextInput/index.d.ts +17 -0
- package/dist/types/components/WebsiteInput/index.d.ts +10 -0
- package/dist/types/components/WeekCalendar/index.d.ts +12 -0
- package/dist/types/core/AppHeader/index.d.ts +3 -0
- package/dist/types/core/AppLogo/index.d.ts +6 -0
- package/dist/types/core/AppLogoImage/index.d.ts +3 -0
- package/dist/types/core/AppLogoPlaceholder/index.d.ts +3 -0
- package/dist/types/core/Assistive/index.d.ts +6 -0
- package/dist/types/core/Banner/index.d.ts +3 -0
- package/dist/types/core/BuildModal/index.d.ts +3 -0
- package/dist/types/core/Calendar/index.d.ts +11 -0
- package/dist/types/core/CalendarDay/index.d.ts +16 -0
- package/dist/types/core/CalendarMonth/index.d.ts +12 -0
- package/dist/types/core/CalendarNavigation/index.d.ts +9 -0
- package/dist/types/core/CalendarWeek/index.d.ts +14 -0
- package/dist/types/core/ChkRad/index.d.ts +10 -0
- package/dist/types/core/ChkRadIcon/index.d.ts +7 -0
- package/dist/types/core/ChkRadList/index.d.ts +15 -0
- package/dist/types/core/CloseButton/index.d.ts +9 -0
- package/dist/types/core/ConfirmModal/index.d.ts +3 -0
- package/dist/types/core/ConnectedRepeater/index.d.ts +26 -0
- package/dist/types/core/ConnectedRepeaterComponent/index.d.ts +24 -0
- package/dist/types/core/Container/index.d.ts +7 -0
- package/dist/types/core/DropdownPanel/index.d.ts +18 -0
- package/dist/types/core/EmptyMessage/index.d.ts +12 -0
- package/dist/types/core/ErrorBoundary/index.d.ts +15 -0
- package/dist/types/core/ErrorMessage/index.d.ts +8 -0
- package/dist/types/core/FilterItem/index.d.ts +10 -0
- package/dist/types/core/Filters/index.d.ts +11 -0
- package/dist/types/core/FixedActions/index.d.ts +12 -0
- package/dist/types/core/FormError/index.d.ts +6 -0
- package/dist/types/core/FormLabel/index.d.ts +8 -0
- package/dist/types/core/FormLegend/index.d.ts +6 -0
- package/dist/types/core/Header/index.d.ts +8 -0
- package/dist/types/core/Icon/index.d.ts +7 -0
- package/dist/types/core/IconButton/Icon/index.d.ts +7 -0
- package/dist/types/core/IconButton/index.d.ts +11 -0
- package/dist/types/core/InputPanel/index.d.ts +8 -0
- package/dist/types/core/ListItem/index.d.ts +16 -0
- package/dist/types/core/ListItemAction/index.d.ts +4 -0
- package/dist/types/core/ListItemActions/index.d.ts +8 -0
- package/dist/types/core/ListItemMetaItem/index.d.ts +10 -0
- package/dist/types/core/ListItemTitle/index.d.ts +9 -0
- package/dist/types/core/Loader/index.d.ts +6 -0
- package/dist/types/core/MeActions/index.d.ts +3 -0
- package/dist/types/core/MePanel/index.d.ts +9 -0
- package/dist/types/core/Modal/index.d.ts +12 -0
- package/dist/types/core/Navigation/index.d.ts +3 -0
- package/dist/types/core/NavigationDivider/index.d.ts +3 -0
- package/dist/types/core/NavigationItem/index.d.ts +7 -0
- package/dist/types/core/Pagination/index.d.ts +7 -0
- package/dist/types/core/PaginationItem/index.d.ts +7 -0
- package/dist/types/core/Panel/index.d.ts +8 -0
- package/dist/types/core/RadialProgress/index.d.ts +8 -0
- package/dist/types/core/StaticTextInput/index.d.ts +12 -0
- package/dist/types/core/Styled/index.d.ts +6 -0
- package/dist/types/core/SummaryListItem/index.d.ts +15 -0
- package/dist/types/core/TableActionsCell/index.d.ts +8 -0
- package/dist/types/core/TableCell/index.d.ts +8 -0
- package/dist/types/core/TableHead/index.d.ts +8 -0
- package/dist/types/core/TableRow/index.d.ts +13 -0
- package/dist/types/core/Tabs/index.d.ts +11 -0
- package/dist/types/core/TextInputAncillary/index.d.ts +11 -0
- package/dist/types/core/Toast/index.d.ts +3 -0
- package/dist/types/core/WeekCalendarDay/index.d.ts +14 -0
- package/dist/types/filters/BooleanFilter/index.d.ts +5 -0
- package/dist/types/filters/DateFilter/index.d.ts +5 -0
- package/dist/types/filters/DropdownFilter/index.d.ts +5 -0
- package/dist/types/filters/QuickDateFilter/index.d.ts +5 -0
- package/dist/types/filters/interfaces.d.ts +36 -0
- package/dist/types/hooks/useAccessiblePanel.d.ts +13 -0
- package/dist/types/hooks/useAppContext.d.ts +37 -0
- package/dist/types/hooks/useClickOutside.d.ts +3 -0
- package/dist/types/hooks/useConnectedList.d.ts +7 -0
- package/dist/types/hooks/useFilters.d.ts +3 -0
- package/dist/types/hooks/useForm.d.ts +26 -0
- package/dist/types/hooks/useFormData.d.ts +9 -0
- package/dist/types/hooks/useLayout.d.ts +6 -0
- package/dist/types/hooks/useModal.d.ts +12 -0
- package/dist/types/hooks/useVariant.d.ts +6 -0
- package/dist/types/index.d.ts +187 -0
- package/dist/types/scenes/Error404Scene.d.ts +3 -0
- package/dist/types/services/BuildService.d.ts +5 -0
- package/dist/types/services/ConfirmService.d.ts +12 -0
- package/dist/types/services/DateService.d.ts +17 -0
- package/dist/types/services/DownloadService.d.ts +5 -0
- package/dist/types/services/FilterComponentService.d.ts +8 -0
- package/dist/types/services/FilterService.d.ts +13 -0
- package/dist/types/services/FormatService.d.ts +7 -0
- package/dist/types/services/ToastService.d.ts +5 -0
- package/dist/types/utility/MockRouter/index.d.ts +2 -0
- package/dist/types/utility/StorybookPanel/index.d.ts +7 -0
- package/dist/types/utility/TestChangeHandler/index.d.ts +8 -0
- package/dist/types/utility/create-app.d.ts +4 -0
- package/dist/types/utility/interfaces.d.ts +72 -0
- package/dist/types/utility/prop-types.d.ts +40 -0
- package/docs/guides/01-installation.story.mdx +33 -0
- package/docs/guides/02-configuration.story.mdx +80 -0
- package/docs/guides/03-pages.story.mdx +18 -0
- package/docs/guides/04-integration.story.mdx +33 -0
- package/docs/guides/a11y.story.mdx +7 -0
- package/docs/guides/theming.story.mdx +7 -0
- package/docs/introduction.story.mdx +17 -0
- package/jest.config.js +19 -0
- package/package.json +101 -0
- package/postcss.config.js +3 -0
- package/rollup.config.js +36 -0
- package/scripts/create-exports.js +74 -0
- package/scripts/update-license.js +8 -0
- package/squarezero.config.js +5 -0
- package/src/components/Alert/Alert.module.css +50 -0
- package/src/components/Alert/Alert.spec.tsx +63 -0
- package/src/components/Alert/Alert.story.tsx +23 -0
- package/src/components/Alert/index.tsx +67 -0
- package/src/components/Allow/Allow.spec.tsx +37 -0
- package/src/components/Allow/index.tsx +42 -0
- package/src/components/App/App.module.css +22 -0
- package/src/components/App/App.spec.tsx +128 -0
- package/src/components/App/index.tsx +108 -0
- package/src/components/AutoSuggest/AutoSuggest.module.css +8 -0
- package/src/components/AutoSuggest/AutoSuggest.spec.tsx +211 -0
- package/src/components/AutoSuggest/AutoSuggest.story.tsx +30 -0
- package/src/components/AutoSuggest/index.tsx +216 -0
- package/src/components/Button/Button.module.css +95 -0
- package/src/components/Button/Button.spec.tsx +69 -0
- package/src/components/Button/Button.story.tsx +39 -0
- package/src/components/Button/index.tsx +99 -0
- package/src/components/CalendarInput/CalendarInput.module.css +8 -0
- package/src/components/CalendarInput/CalendarInput.spec.tsx +206 -0
- package/src/components/CalendarInput/CalendarInput.story.tsx +62 -0
- package/src/components/CalendarInput/index.tsx +122 -0
- package/src/components/CheckboxList/CheckboxList.spec.tsx +83 -0
- package/src/components/CheckboxList/index.tsx +53 -0
- package/src/components/ConnectedDropdown/index.tsx +56 -0
- package/src/components/ConnectedList/index.tsx +15 -0
- package/src/components/ConnectedScene/index.tsx +95 -0
- package/src/components/ConnectedTable/index.tsx +17 -0
- package/src/components/ContentBlock/ContentBlock.module.css +8 -0
- package/src/components/ContentBlock/ContentBlock.spec.tsx +15 -0
- package/src/components/ContentBlock/index.tsx +16 -0
- package/src/components/DateInput/DateInput.module.css +15 -0
- package/src/components/DateInput/DateInput.spec.tsx +91 -0
- package/src/components/DateInput/index.tsx +149 -0
- package/src/components/Document/index.tsx +20 -0
- package/src/components/Dropdown/Dropdown.module.css +8 -0
- package/src/components/Dropdown/Dropdown.spec.tsx +286 -0
- package/src/components/Dropdown/Dropdown.story.tsx +53 -0
- package/src/components/Dropdown/index.tsx +224 -0
- package/src/components/Fieldset/Fieldset.spec.tsx +22 -0
- package/src/components/Fieldset/Fieldset.story.tsx +21 -0
- package/src/components/Fieldset/index.tsx +30 -0
- package/src/components/FileInput/FileInput.module.css +18 -0
- package/src/components/FileInput/FileInput.spec.tsx +42 -0
- package/src/components/FileInput/FileInput.story.tsx +6 -0
- package/src/components/FileInput/index.tsx +72 -0
- package/src/components/FilterLink/FilterLink.module.css +9 -0
- package/src/components/FilterLink/FilterLink.spec.tsx +20 -0
- package/src/components/FilterLink/index.tsx +31 -0
- package/src/components/Form/Form.spec.tsx +68 -0
- package/src/components/Form/index.tsx +87 -0
- package/src/components/FormActions/FormActions.spec.tsx +10 -0
- package/src/components/FormActions/FormActions.story.tsx +23 -0
- package/src/components/FormActions/index.tsx +31 -0
- package/src/components/FormField/FormField.module.css +71 -0
- package/src/components/FormField/FormField.spec.tsx +137 -0
- package/src/components/FormField/FormField.story.tsx +22 -0
- package/src/components/FormField/index.tsx +162 -0
- package/src/components/FormRepeater/FormRepeater.module.css +3 -0
- package/src/components/FormRepeater/FormRepeater.spec.tsx +127 -0
- package/src/components/FormRepeater/index.tsx +118 -0
- package/src/components/ImageInput/ImageInput.module.css +74 -0
- package/src/components/ImageInput/ImageInput.spec.tsx +45 -0
- package/src/components/ImageInput/ImageInput.story.tsx +6 -0
- package/src/components/ImageInput/index.tsx +91 -0
- package/src/components/InfoPanel/InfoPanel.module.css +18 -0
- package/src/components/InfoPanel/InfoPanel.spec.tsx +15 -0
- package/src/components/InfoPanel/InfoPanel.story.tsx +32 -0
- package/src/components/InfoPanel/index.tsx +25 -0
- package/src/components/Link/Link.spec.tsx +62 -0
- package/src/components/Link/__mocks__/index.tsx +24 -0
- package/src/components/Link/index.tsx +51 -0
- package/src/components/List/List.module.css +9 -0
- package/src/components/List/List.spec.tsx +311 -0
- package/src/components/List/List.story.tsx +92 -0
- package/src/components/List/index.tsx +79 -0
- package/src/components/ListActions/ListActions.spec.tsx +10 -0
- package/src/components/ListActions/ListActions.story.tsx +6 -0
- package/src/components/ListActions/index.tsx +31 -0
- package/src/components/LoginForm/LoginForm.module.css +21 -0
- package/src/components/LoginForm/LoginForm.spec.tsx +63 -0
- package/src/components/LoginForm/index.tsx +102 -0
- package/src/components/Message/Message.module.css +14 -0
- package/src/components/Message/Message.spec.tsx +20 -0
- package/src/components/Message/index.tsx +27 -0
- package/src/components/ModalActions/ModalActions.module.css +5 -0
- package/src/components/ModalActions/ModalActions.spec.tsx +53 -0
- package/src/components/ModalActions/ModalActions.story.tsx +6 -0
- package/src/components/ModalActions/index.tsx +47 -0
- package/src/components/MoneyInput/MoneyInput.spec.tsx +17 -0
- package/src/components/MoneyInput/MoneyInput.story.tsx +6 -0
- package/src/components/MoneyInput/index.tsx +16 -0
- package/src/components/PasswordForm/PasswordForm.module.css +21 -0
- package/src/components/PasswordForm/index.tsx +94 -0
- package/src/components/PasswordInput/PasswordInput.module.css +23 -0
- package/src/components/PasswordInput/PasswordInput.spec.tsx +31 -0
- package/src/components/PasswordInput/PasswordInput.story.tsx +16 -0
- package/src/components/PasswordInput/index.tsx +27 -0
- package/src/components/RadioList/RadioList.spec.tsx +45 -0
- package/src/components/RadioList/index.tsx +10 -0
- package/src/components/Scene/Scene.spec.tsx +123 -0
- package/src/components/Scene/Scene.story.tsx +6 -0
- package/src/components/Scene/index.tsx +58 -0
- package/src/components/SummaryList/SummaryList.module.css +16 -0
- package/src/components/SummaryList/SummaryList.spec.tsx +77 -0
- package/src/components/SummaryList/SummaryList.story.tsx +11 -0
- package/src/components/SummaryList/index.tsx +37 -0
- package/src/components/Switch/Switch.module.css +86 -0
- package/src/components/Switch/Switch.spec.tsx +64 -0
- package/src/components/Switch/index.tsx +85 -0
- package/src/components/Table/Table.module.css +14 -0
- package/src/components/Table/Table.spec.tsx +128 -0
- package/src/components/Table/Table.story.tsx +101 -0
- package/src/components/Table/index.tsx +114 -0
- package/src/components/Tag/Tag.module.css +37 -0
- package/src/components/Tag/Tag.spec.tsx +10 -0
- package/src/components/Tag/Tag.story.tsx +55 -0
- package/src/components/Tag/index.tsx +27 -0
- package/src/components/TextArea/TextArea.module.css +23 -0
- package/src/components/TextArea/TextArea.spec.tsx +77 -0
- package/src/components/TextArea/index.tsx +59 -0
- package/src/components/TextInput/TextInput.module.css +57 -0
- package/src/components/TextInput/TextInput.spec.tsx +134 -0
- package/src/components/TextInput/TextInput.story.tsx +24 -0
- package/src/components/TextInput/index.tsx +146 -0
- package/src/components/WebsiteInput/WebsiteInput.spec.tsx +17 -0
- package/src/components/WebsiteInput/index.tsx +16 -0
- package/src/components/WeekCalendar/WeekCalendar.module.css +19 -0
- package/src/components/WeekCalendar/index.tsx +80 -0
- package/src/core/AppHeader/index.tsx +23 -0
- package/src/core/AppLogo/AppLogo.module.css +19 -0
- package/src/core/AppLogo/index.tsx +33 -0
- package/src/core/AppLogoImage/index.tsx +19 -0
- package/src/core/AppLogoPlaceholder/index.tsx +26 -0
- package/src/core/Assistive/Assistive.module.css +10 -0
- package/src/core/Assistive/index.tsx +18 -0
- package/src/core/Banner/Banner.module.css +36 -0
- package/src/core/Banner/index.tsx +25 -0
- package/src/core/BuildModal/index.tsx +119 -0
- package/src/core/Calendar/index.tsx +116 -0
- package/src/core/CalendarDay/CalendarDay.module.css +61 -0
- package/src/core/CalendarDay/index.tsx +82 -0
- package/src/core/CalendarMonth/CalendarMonth.module.css +13 -0
- package/src/core/CalendarMonth/index.tsx +101 -0
- package/src/core/CalendarNavigation/CalendarNavigation.module.css +26 -0
- package/src/core/CalendarNavigation/index.tsx +56 -0
- package/src/core/CalendarWeek/index.tsx +95 -0
- package/src/core/ChkRad/ChkRad.module.css +31 -0
- package/src/core/ChkRad/ChkRad.spec.tsx +72 -0
- package/src/core/ChkRad/index.tsx +80 -0
- package/src/core/ChkRadIcon/ChkRadIcon.module.css +28 -0
- package/src/core/ChkRadIcon/index.tsx +33 -0
- package/src/core/ChkRadList/ChkRadList.module.css +10 -0
- package/src/core/ChkRadList/index.tsx +85 -0
- package/src/core/CloseButton/CloseButton.spec.tsx +36 -0
- package/src/core/CloseButton/index.tsx +31 -0
- package/src/core/ConfirmModal/ConfirmModal.spec.tsx +88 -0
- package/src/core/ConfirmModal/index.tsx +51 -0
- package/src/core/ConnectedRepeater/index.tsx +248 -0
- package/src/core/ConnectedRepeaterComponent/index.tsx +66 -0
- package/src/core/Container/Container.module.css +12 -0
- package/src/core/Container/index.tsx +35 -0
- package/src/core/DropdownPanel/DropdownPanel.module.css +68 -0
- package/src/core/DropdownPanel/index.tsx +92 -0
- package/src/core/EmptyMessage/EmptyMessage.module.css +18 -0
- package/src/core/EmptyMessage/index.tsx +31 -0
- package/src/core/ErrorBoundary/ErrorBoundary.spec.tsx +33 -0
- package/src/core/ErrorBoundary/index.tsx +42 -0
- package/src/core/ErrorMessage/ErrorMessage.module.css +25 -0
- package/src/core/ErrorMessage/ErrorMessage.spec.tsx +31 -0
- package/src/core/ErrorMessage/index.tsx +37 -0
- package/src/core/FilterItem/FilterItem.module.css +104 -0
- package/src/core/FilterItem/index.tsx +164 -0
- package/src/core/Filters/Filters.module.css +86 -0
- package/src/core/Filters/Filters.spec.tsx +533 -0
- package/src/core/Filters/index.tsx +158 -0
- package/src/core/FixedActions/FixedActions.module.css +24 -0
- package/src/core/FixedActions/index.tsx +52 -0
- package/src/core/FormError/FormError.module.css +7 -0
- package/src/core/FormError/index.tsx +18 -0
- package/src/core/FormLabel/FormLabel.module.css +15 -0
- package/src/core/FormLabel/index.tsx +25 -0
- package/src/core/FormLegend/FormLegend.module.css +13 -0
- package/src/core/FormLegend/index.tsx +18 -0
- package/src/core/Header/Header.module.css +35 -0
- package/src/core/Header/index.tsx +37 -0
- package/src/core/Icon/Icon.spec.tsx +31 -0
- package/src/core/Icon/index.tsx +64 -0
- package/src/core/IconButton/Icon/Icon.spec.tsx +31 -0
- package/src/core/IconButton/Icon/index.tsx +64 -0
- package/src/core/IconButton/IconButton.module.css +32 -0
- package/src/core/IconButton/index.tsx +55 -0
- package/src/core/InputPanel/InputPanel.module.css +70 -0
- package/src/core/InputPanel/index.tsx +28 -0
- package/src/core/ListItem/ListItem.module.css +28 -0
- package/src/core/ListItem/ListItem.story.tsx +28 -0
- package/src/core/ListItem/index.tsx +99 -0
- package/src/core/ListItemAction/ListItemAction.module.css +28 -0
- package/src/core/ListItemAction/index.tsx +30 -0
- package/src/core/ListItemActions/ListItemActions.module.css +94 -0
- package/src/core/ListItemActions/index.tsx +55 -0
- package/src/core/ListItemMetaItem/ListItemMetaItem.module.css +18 -0
- package/src/core/ListItemMetaItem/index.tsx +54 -0
- package/src/core/ListItemTitle/ListItemTitle.module.css +14 -0
- package/src/core/ListItemTitle/ListItemTitle.spec.tsx +33 -0
- package/src/core/ListItemTitle/index.tsx +72 -0
- package/src/core/Loader/Loader.module.css +57 -0
- package/src/core/Loader/Loader.story.tsx +8 -0
- package/src/core/Loader/index.tsx +27 -0
- package/src/core/MeActions/MeActions.module.css +45 -0
- package/src/core/MeActions/index.tsx +46 -0
- package/src/core/MePanel/MePanel.module.css +75 -0
- package/src/core/MePanel/index.tsx +45 -0
- package/src/core/Modal/Modal.module.css +84 -0
- package/src/core/Modal/Modal.spec.tsx +51 -0
- package/src/core/Modal/index.tsx +66 -0
- package/src/core/Navigation/Navigation.module.css +83 -0
- package/src/core/Navigation/Navigation.spec.tsx +101 -0
- package/src/core/Navigation/index.tsx +109 -0
- package/src/core/NavigationDivider/NavigationDivider.module.css +18 -0
- package/src/core/NavigationDivider/index.tsx +13 -0
- package/src/core/NavigationItem/NavigationItem.module.css +51 -0
- package/src/core/NavigationItem/index.tsx +59 -0
- package/src/core/Pagination/Pagination.module.css +15 -0
- package/src/core/Pagination/index.tsx +100 -0
- package/src/core/PaginationItem/PaginationItem.module.css +33 -0
- package/src/core/PaginationItem/index.tsx +46 -0
- package/src/core/Panel/Panel.module.css +15 -0
- package/src/core/Panel/index.tsx +31 -0
- package/src/core/RadialProgress/RadialProgress.module.css +78 -0
- package/src/core/RadialProgress/index.tsx +52 -0
- package/src/core/StaticTextInput/StaticTextInput.module.css +79 -0
- package/src/core/StaticTextInput/StaticTextInput.spec.tsx +133 -0
- package/src/core/StaticTextInput/index.tsx +114 -0
- package/src/core/Styled/Styled.spec.tsx +38 -0
- package/src/core/Styled/Styled.story.tsx +10 -0
- package/src/core/Styled/index.tsx +62 -0
- package/src/core/SummaryListItem/SummaryListItem.module.css +28 -0
- package/src/core/SummaryListItem/index.tsx +60 -0
- package/src/core/TableActionsCell/TableActionsCell.module.css +3 -0
- package/src/core/TableActionsCell/index.tsx +37 -0
- package/src/core/TableCell/TableCell.module.css +16 -0
- package/src/core/TableCell/index.tsx +39 -0
- package/src/core/TableHead/TableHead.module.css +12 -0
- package/src/core/TableHead/index.tsx +48 -0
- package/src/core/TableRow/index.tsx +64 -0
- package/src/core/Tabs/Tabs.module.css +50 -0
- package/src/core/Tabs/index.tsx +94 -0
- package/src/core/TextInputAncillary/TextInputAncillary.module.css +64 -0
- package/src/core/TextInputAncillary/index.tsx +72 -0
- package/src/core/Toast/Toast.module.css +55 -0
- package/src/core/Toast/Toast.spec.tsx +78 -0
- package/src/core/Toast/index.tsx +81 -0
- package/src/core/WeekCalendarDay/WeekCalendarDay.module.css +32 -0
- package/src/core/WeekCalendarDay/index.tsx +68 -0
- package/src/filters/BooleanFilter/index.tsx +46 -0
- package/src/filters/DateFilter/index.tsx +36 -0
- package/src/filters/DropdownFilter/index.tsx +53 -0
- package/src/filters/QuickDateFilter/index.tsx +74 -0
- package/src/filters/interfaces.ts +40 -0
- package/src/hooks/useAccessiblePanel.spec.tsx +88 -0
- package/src/hooks/useAccessiblePanel.ts +74 -0
- package/src/hooks/useAppContext.ts +77 -0
- package/src/hooks/useClickOutside.ts +49 -0
- package/src/hooks/useConnectedList.ts +26 -0
- package/src/hooks/useFilters.ts +26 -0
- package/src/hooks/useForm.spec.ts +126 -0
- package/src/hooks/useForm.ts +99 -0
- package/src/hooks/useFormData.spec.ts +40 -0
- package/src/hooks/useFormData.ts +27 -0
- package/src/hooks/useLayout.spec.ts +55 -0
- package/src/hooks/useLayout.ts +29 -0
- package/src/hooks/useModal.spec.tsx +63 -0
- package/src/hooks/useModal.ts +60 -0
- package/src/hooks/useVariant.spec.ts +14 -0
- package/src/hooks/useVariant.ts +34 -0
- package/src/index.ts +194 -0
- package/src/scenes/Error404Scene.tsx +5 -0
- package/src/services/BuildService.spec.ts +56 -0
- package/src/services/BuildService.ts +34 -0
- package/src/services/ConfirmService.ts +21 -0
- package/src/services/DateService.spec.ts +87 -0
- package/src/services/DateService.ts +137 -0
- package/src/services/DownloadService.spec.ts +29 -0
- package/src/services/DownloadService.ts +14 -0
- package/src/services/FilterComponentService.tsx +46 -0
- package/src/services/FilterService.spec.ts +87 -0
- package/src/services/FilterService.ts +58 -0
- package/src/services/FormatService.spec.ts +83 -0
- package/src/services/FormatService.ts +55 -0
- package/src/services/ToastService.spec.ts +44 -0
- package/src/services/ToastService.ts +19 -0
- package/src/styles/layout.css +64 -0
- package/src/styles/variables.css +85 -0
- package/src/typings.d.ts +4 -0
- package/src/utility/MockRouter/index.ts +45 -0
- package/src/utility/StorybookPanel/StorybookPanel.module.css +9 -0
- package/src/utility/StorybookPanel/index.tsx +25 -0
- package/src/utility/TestChangeHandler/TestChangeHandler.module.css +7 -0
- package/src/utility/TestChangeHandler/TestChangeHandler.spec.tsx +24 -0
- package/src/utility/TestChangeHandler/index.tsx +54 -0
- package/src/utility/create-app.tsx +29 -0
- package/src/utility/interfaces.ts +119 -0
- package/src/utility/prop-types.ts +67 -0
- package/tests/setupFilesAfterEnv.js +10 -0
- package/tsconfig.json +26 -0
- package/tsconfig.types.json +9 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
background-color: var(--clr-white);
|
|
3
|
+
border: .1rem var(--clr-grey400) solid;
|
|
4
|
+
border-radius: .3rem;
|
|
5
|
+
height: 30rem;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
padding: 2rem;
|
|
8
|
+
position: relative;
|
|
9
|
+
transition: border-color .2s;
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.rootIsDisabled {
|
|
14
|
+
opacity: .3;
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.rootIsError {
|
|
19
|
+
border-color: var(--clr-error);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.rootIsDragTarget {
|
|
23
|
+
background-color: var(--clr-primary5);
|
|
24
|
+
border-color: var(--clr-primary);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.placeholder {
|
|
28
|
+
align-items: center;
|
|
29
|
+
bottom: 5%;
|
|
30
|
+
display: flex;
|
|
31
|
+
fill: var(--clr-grey600);
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
left: 0;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
position: absolute;
|
|
36
|
+
right: 0;
|
|
37
|
+
text-align: center;
|
|
38
|
+
top: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.placeholderTitle {
|
|
42
|
+
color: var(--clr-grey600);
|
|
43
|
+
font-size: var(--fs-lrg);
|
|
44
|
+
font-weight: var(--fw-bold);
|
|
45
|
+
line-height: 1;
|
|
46
|
+
margin-bottom: 1rem;
|
|
47
|
+
margin-top: 1rem;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.placeholderDescription {
|
|
51
|
+
color: var(--clr-grey600);
|
|
52
|
+
font-size: var(--fs-sml);
|
|
53
|
+
line-height: 1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.input {
|
|
57
|
+
bottom: 0;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
font-size: .1rem;
|
|
60
|
+
height: 200%;
|
|
61
|
+
left: 0;
|
|
62
|
+
position: absolute;
|
|
63
|
+
width: 100%;
|
|
64
|
+
|
|
65
|
+
&:focus {
|
|
66
|
+
outline: none;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.preview {
|
|
71
|
+
height: 100%;
|
|
72
|
+
object-fit: contain;
|
|
73
|
+
width: 100%;
|
|
74
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
import ImageInput from './index';
|
|
6
|
+
|
|
7
|
+
describe('ImageInput', () => {
|
|
8
|
+
it('should render', () => {
|
|
9
|
+
render(<ImageInput name="lorem" />);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should render defaults', () => {
|
|
13
|
+
render(<ImageInput name="lorem" />);
|
|
14
|
+
expect(screen.getByText('Click to Upload')).toBeInTheDocument();
|
|
15
|
+
expect(screen.getByText('(or drop an image here)')).toBeInTheDocument();
|
|
16
|
+
expect(screen.queryByRole('img')).not.toBeInTheDocument();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should render error', () => {
|
|
20
|
+
render(<ImageInput name="lorem" hasError />);
|
|
21
|
+
expect(screen.getByTestId('image-input-root')).toHaveClass('rootHasError');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should render disabled', () => {
|
|
25
|
+
render(<ImageInput name="lorem" isDisabled />);
|
|
26
|
+
expect(screen.getByTestId('image-input-root')).toHaveClass('rootIsDisabled');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should handle onchange', async () => {
|
|
30
|
+
const image = new File(['lorem'], 'lorem.png', { type: 'image/png' });
|
|
31
|
+
const mockFn = jest.fn();
|
|
32
|
+
|
|
33
|
+
render(<ImageInput name="lorem" onChange={mockFn} />);
|
|
34
|
+
|
|
35
|
+
userEvent.upload(screen.getByTestId('image-input-input'), image);
|
|
36
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
37
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
38
|
+
target: { name: 'lorem', value: image },
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
await waitFor(() => {
|
|
42
|
+
expect(screen.getByRole('img')).toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import Icon from '@core/Icon';
|
|
6
|
+
|
|
7
|
+
import type { InputProps } from '@utility/interfaces';
|
|
8
|
+
|
|
9
|
+
import styles from './ImageInput.module.css';
|
|
10
|
+
|
|
11
|
+
interface HTMLFileElement extends HTMLInputElement {
|
|
12
|
+
files: FileList;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const ImageInput: React.FunctionComponent<InputProps> = ({
|
|
16
|
+
name,
|
|
17
|
+
isDisabled,
|
|
18
|
+
hasError,
|
|
19
|
+
onChange,
|
|
20
|
+
}) => {
|
|
21
|
+
const reader = useRef(new FileReader());
|
|
22
|
+
const [preview, setPreview] = useState('');
|
|
23
|
+
|
|
24
|
+
const handleReaderLoad = (): void => {
|
|
25
|
+
/*
|
|
26
|
+
* `reader.result` can technically be null, but there's no way to set it to null via a file
|
|
27
|
+
* input, so we can 'handle' the possibility of null to keep typescript happy, but ignore
|
|
28
|
+
* this line in code coverage
|
|
29
|
+
*/
|
|
30
|
+
/* istanbul ignore next */
|
|
31
|
+
setPreview(reader.current.result?.toString() || '');
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const handleChange = (event: React.ChangeEvent<HTMLFileElement>): void => {
|
|
35
|
+
const { target } = event;
|
|
36
|
+
|
|
37
|
+
if (target.files.length) {
|
|
38
|
+
reader.current.readAsDataURL(target.files[0]);
|
|
39
|
+
|
|
40
|
+
if (onChange) {
|
|
41
|
+
onChange({ target: { name, value: target.files[0] } });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
reader.current.addEventListener('load', handleReaderLoad);
|
|
48
|
+
|
|
49
|
+
return (): void => {
|
|
50
|
+
reader.current.removeEventListener('load', handleReaderLoad);
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div
|
|
56
|
+
className={classNames(
|
|
57
|
+
styles.root,
|
|
58
|
+
hasError && styles.rootHasError,
|
|
59
|
+
isDisabled && styles.rootIsDisabled
|
|
60
|
+
)}
|
|
61
|
+
data-testid="image-input-root"
|
|
62
|
+
>
|
|
63
|
+
{preview ? (
|
|
64
|
+
<img className={styles.preview} src={preview} />
|
|
65
|
+
) : (
|
|
66
|
+
<div className={styles.placeholder}>
|
|
67
|
+
<Icon icon="upload" size={30} />
|
|
68
|
+
<span className={styles.placeholderTitle}>Click to Upload</span>
|
|
69
|
+
<em className={styles.placeholderDescription}>(or drop an image here)</em>
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
|
|
73
|
+
<input
|
|
74
|
+
className={styles.input}
|
|
75
|
+
data-testid="image-input-input"
|
|
76
|
+
name={name}
|
|
77
|
+
onChange={handleChange}
|
|
78
|
+
type="file"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
ImageInput.propTypes = {
|
|
85
|
+
name: PropTypes.string.isRequired,
|
|
86
|
+
hasError: PropTypes.bool,
|
|
87
|
+
isDisabled: PropTypes.bool,
|
|
88
|
+
onChange: PropTypes.func,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default ImageInput;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
background-color: var(--clr-primary5);
|
|
3
|
+
border: .1rem var(--clr-primary) solid;
|
|
4
|
+
border-radius: .3rem;
|
|
5
|
+
font-size: var(--fs-sml);
|
|
6
|
+
margin-bottom: 3rem;
|
|
7
|
+
padding: 1.5rem;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.rootDanger {
|
|
11
|
+
background-color: var(--clr-error5);
|
|
12
|
+
border: .1rem var(--clr-error) solid;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.rootWarning {
|
|
16
|
+
background-color: var(--clr-warning5);
|
|
17
|
+
border: .1rem var(--clr-warning) solid;
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import InfoPanel from './index';
|
|
5
|
+
|
|
6
|
+
describe('InfoPanel', () => {
|
|
7
|
+
it('should render', () => {
|
|
8
|
+
render(<InfoPanel>Lorem</InfoPanel>);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should render default', () => {
|
|
12
|
+
render(<InfoPanel>Lorem</InfoPanel>);
|
|
13
|
+
expect(screen.queryAllByText('Lorem')).toHaveLength(1);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Story } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import InfoPanel from './index';
|
|
5
|
+
import type { InfoPanelProps } from './index';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/InfoPanel',
|
|
9
|
+
component: InfoPanel,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const Template: Story<InfoPanelProps> = (props) => <InfoPanel {...props} />;
|
|
13
|
+
|
|
14
|
+
export const Basic = Template.bind({});
|
|
15
|
+
|
|
16
|
+
Basic.args = {
|
|
17
|
+
children: 'Lorem Ipsum',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Danger = Template.bind({});
|
|
21
|
+
|
|
22
|
+
Danger.args = {
|
|
23
|
+
children: 'Lorem Ipsum',
|
|
24
|
+
variant: 'danger',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Warning = Template.bind({});
|
|
28
|
+
|
|
29
|
+
Warning.args = {
|
|
30
|
+
children: 'Lorem Ipsum',
|
|
31
|
+
variant: 'warning',
|
|
32
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import useVariant from '@hooks/useVariant';
|
|
6
|
+
|
|
7
|
+
import type { StyleVariant } from '@utility/interfaces';
|
|
8
|
+
|
|
9
|
+
import styles from './InfoPanel.module.css';
|
|
10
|
+
|
|
11
|
+
export interface InfoPanelProps {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
variant?: StyleVariant;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const InfoPanel: React.FunctionComponent<InfoPanelProps> = ({ children, variant }) => {
|
|
17
|
+
const { applyVariantClassName } = useVariant(variant);
|
|
18
|
+
return <div className={classNames(styles.root, applyVariantClassName(styles))}>{children}</div>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
InfoPanel.propTypes = {
|
|
22
|
+
children: PropTypes.node.isRequired,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default InfoPanel;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
import Link from './index';
|
|
6
|
+
|
|
7
|
+
describe('Link', () => {
|
|
8
|
+
it('should render', () => {
|
|
9
|
+
render(<Link to="lorem">Lorem</Link>);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should render defaults', () => {
|
|
13
|
+
render(<Link to="lorem">Lorem</Link>);
|
|
14
|
+
expect(screen.getByRole('link')).toHaveAttribute('href', '/lorem');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should handle forward slash properly', () => {
|
|
18
|
+
render(<Link to="/lorem">Lorem</Link>);
|
|
19
|
+
expect(screen.getByRole('link')).toHaveAttribute('href', '/lorem');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should render external', () => {
|
|
23
|
+
render(<Link to="http://lorem">Lorem</Link>);
|
|
24
|
+
expect(screen.getByRole('link')).toHaveAttribute('href', 'http://lorem');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should render telephone', () => {
|
|
28
|
+
render(<Link to="tel://0123456">Lorem</Link>);
|
|
29
|
+
expect(screen.getByRole('link')).toHaveAttribute('href', 'tel://0123456');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should render mailto', () => {
|
|
33
|
+
render(<Link to="mailto://lorem">Lorem</Link>);
|
|
34
|
+
expect(screen.getByRole('link')).toHaveAttribute('href', 'mailto://lorem');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should render in new window', () => {
|
|
38
|
+
render(
|
|
39
|
+
<Link to="lorem" isNewWindow>
|
|
40
|
+
Lorem
|
|
41
|
+
</Link>
|
|
42
|
+
);
|
|
43
|
+
expect(screen.getByRole('link')).toHaveAttribute('rel', 'noopener noreferrer');
|
|
44
|
+
expect(screen.getByRole('link')).toHaveAttribute('target', '_blank');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should handle onclick', () => {
|
|
48
|
+
const mockFn = jest.fn().mockImplementation((event: MouseEvent) => {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
render(
|
|
53
|
+
<Link onClick={mockFn} to="lorem">
|
|
54
|
+
Lorem
|
|
55
|
+
</Link>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
59
|
+
userEvent.click(screen.getByRole('link'));
|
|
60
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface LinkProps {
|
|
4
|
+
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface LinkRequire {
|
|
8
|
+
default: React.FunctionComponent<LinkProps>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Link: React.FunctionComponent<LinkProps> = ({ onClick, ...props }) => {
|
|
12
|
+
const { default: ActualLink } = jest.requireActual<LinkRequire>('@components/Link');
|
|
13
|
+
|
|
14
|
+
const handleClick = (event: React.MouseEvent<HTMLAnchorElement>): void => {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
if (onClick) {
|
|
17
|
+
onClick(event);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return <ActualLink {...props} onClick={handleClick} />;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default Link;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import NextLink from 'next/link';
|
|
4
|
+
|
|
5
|
+
interface DataProps {
|
|
6
|
+
'data-test-id'?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface LinkProps extends DataProps {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
isNewWindow?: boolean;
|
|
13
|
+
to: string;
|
|
14
|
+
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const Link: React.FunctionComponent<LinkProps> = ({
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
isNewWindow,
|
|
21
|
+
onClick,
|
|
22
|
+
to,
|
|
23
|
+
...dataProps
|
|
24
|
+
}) => {
|
|
25
|
+
const newWindowProps = isNewWindow ? { target: '_blank', rel: 'noopener noreferrer' } : {};
|
|
26
|
+
const props = { ...newWindowProps, ...dataProps, className, onClick };
|
|
27
|
+
|
|
28
|
+
if (/^http/u.exec(to) || /^mailto:/u.exec(to) || /^tel:/u.exec(to)) {
|
|
29
|
+
return (
|
|
30
|
+
<a href={to} {...props}>
|
|
31
|
+
{children}
|
|
32
|
+
</a>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<NextLink href={/^\//u.exec(to) ? to : `/${to}`}>
|
|
38
|
+
<a {...props}>{children}</a>
|
|
39
|
+
</NextLink>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
Link.propTypes = {
|
|
44
|
+
children: PropTypes.node.isRequired,
|
|
45
|
+
to: PropTypes.string.isRequired,
|
|
46
|
+
className: PropTypes.string,
|
|
47
|
+
isNewWindow: PropTypes.bool,
|
|
48
|
+
onClick: PropTypes.func,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default Link;
|