@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,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import ConnectedRepeater from '@core/ConnectedRepeater';
|
|
4
|
+
import type { ConnectedRepeaterElementProps } from '@core/ConnectedRepeater';
|
|
5
|
+
|
|
6
|
+
import Table from '@components/Table';
|
|
7
|
+
|
|
8
|
+
const ConnectedTable: React.FunctionComponent<ConnectedRepeaterElementProps> = (props) => (
|
|
9
|
+
<ConnectedRepeater
|
|
10
|
+
{...props}
|
|
11
|
+
render={({ columns, ...renderProps }): React.ReactElement => (
|
|
12
|
+
<Table columns={columns || {}} {...renderProps} />
|
|
13
|
+
)}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export default ConnectedTable;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import ContentBlock from './index';
|
|
5
|
+
|
|
6
|
+
describe('ContentBlock', () => {
|
|
7
|
+
it('should render', () => {
|
|
8
|
+
render(<ContentBlock>Lorem</ContentBlock>);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should render children', () => {
|
|
12
|
+
render(<ContentBlock>Lorem</ContentBlock>);
|
|
13
|
+
expect(screen.getAllByText('Lorem')).toHaveLength(1);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import styles from './ContentBlock.module.css';
|
|
5
|
+
|
|
6
|
+
interface ContentBlockProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const ContentBlock: React.FunctionComponent<ContentBlockProps> = ({ children }) => (
|
|
11
|
+
<div className={styles.root}>{children}</div>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
ContentBlock.propTypes = { children: PropTypes.node.isRequired };
|
|
15
|
+
|
|
16
|
+
export default ContentBlock;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
import DateInput from './index';
|
|
6
|
+
|
|
7
|
+
describe('DateInput', () => {
|
|
8
|
+
it('should render', () => {
|
|
9
|
+
render(<DateInput name="lorem" />);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should render defaults', () => {
|
|
13
|
+
render(<DateInput name="lorem" />);
|
|
14
|
+
|
|
15
|
+
expect(screen.getAllByRole('textbox')[0]).not.toBeDisabled();
|
|
16
|
+
expect(screen.getAllByRole('textbox')[0]).toHaveClass('input');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should have format', () => {
|
|
20
|
+
render(<DateInput name="lorem" />);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should have error', () => {
|
|
24
|
+
render(<DateInput name="lorem" hasError />);
|
|
25
|
+
expect(screen.getAllByRole('textbox')[0]).toHaveClass('input inputHasError');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should be disabled', () => {
|
|
29
|
+
render(<DateInput name="lorem" isDisabled />);
|
|
30
|
+
expect(screen.getAllByRole('textbox')[0]).toBeDisabled();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should handle onchange', () => {
|
|
34
|
+
const mockFn = jest.fn();
|
|
35
|
+
render(<DateInput name="lorem" onChange={mockFn} />);
|
|
36
|
+
|
|
37
|
+
const inputs = screen.getAllByRole('textbox');
|
|
38
|
+
|
|
39
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
40
|
+
|
|
41
|
+
userEvent.type(inputs[0], '17');
|
|
42
|
+
expect(mockFn).toHaveBeenCalledTimes(2);
|
|
43
|
+
expect(mockFn).toHaveBeenLastCalledWith({ target: { name: 'lorem', value: '--17' } });
|
|
44
|
+
|
|
45
|
+
userEvent.type(inputs[1], '01');
|
|
46
|
+
expect(mockFn).toHaveBeenCalledTimes(4);
|
|
47
|
+
expect(mockFn).toHaveBeenLastCalledWith({ target: { name: 'lorem', value: '-01-17' } });
|
|
48
|
+
|
|
49
|
+
userEvent.type(inputs[2], '2000');
|
|
50
|
+
expect(mockFn).toHaveBeenCalledTimes(8);
|
|
51
|
+
expect(mockFn).toHaveBeenLastCalledWith({ target: { name: 'lorem', value: '2000-01-17' } });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should handle if no onchange', () => {
|
|
55
|
+
const mockFn = jest.fn();
|
|
56
|
+
render(<DateInput name="lorem" />);
|
|
57
|
+
|
|
58
|
+
userEvent.type(screen.getAllByRole('textbox')[0], '17');
|
|
59
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should have value', () => {
|
|
63
|
+
render(<DateInput name="lorem" value="2020-01-17" />);
|
|
64
|
+
|
|
65
|
+
const inputs = screen.getAllByRole('textbox');
|
|
66
|
+
|
|
67
|
+
expect(inputs[0]).toHaveValue('17');
|
|
68
|
+
expect(inputs[1]).toHaveValue('01');
|
|
69
|
+
expect(inputs[2]).toHaveValue('2020');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should have partial value', () => {
|
|
73
|
+
render(<DateInput name="lorem" value="2020--" />);
|
|
74
|
+
|
|
75
|
+
const inputs = screen.getAllByRole('textbox');
|
|
76
|
+
|
|
77
|
+
expect(inputs[0]).toHaveValue('');
|
|
78
|
+
expect(inputs[1]).toHaveValue('');
|
|
79
|
+
expect(inputs[2]).toHaveValue('2020');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should have invalid value', () => {
|
|
83
|
+
render(<DateInput name="lorem" value="lorem" />);
|
|
84
|
+
|
|
85
|
+
const inputs = screen.getAllByRole('textbox');
|
|
86
|
+
|
|
87
|
+
expect(inputs[0]).toHaveValue('');
|
|
88
|
+
expect(inputs[1]).toHaveValue('');
|
|
89
|
+
expect(inputs[2]).toHaveValue('');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import TextInput from '@components/TextInput';
|
|
6
|
+
|
|
7
|
+
import type { InputProps, InputValue, SimpleEvent } from '@utility/interfaces';
|
|
8
|
+
|
|
9
|
+
import styles from './DateInput.module.css';
|
|
10
|
+
|
|
11
|
+
type FieldDataItem = ['day' | 'month' | 'year', string, 'DD' | 'MM' | 'YYYY'];
|
|
12
|
+
|
|
13
|
+
interface DateReducerState {
|
|
14
|
+
day: string;
|
|
15
|
+
month: string;
|
|
16
|
+
year: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface DateReducerAction {
|
|
20
|
+
name?: string;
|
|
21
|
+
value?: InputValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const DEFAULT_DATE: DateReducerState = {
|
|
25
|
+
day: '',
|
|
26
|
+
month: '',
|
|
27
|
+
year: '',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Take an input, and either return an empty default date, or a properly parsed DateReducerState.
|
|
32
|
+
* This function ensures that no matter what value is passed into the DateInput, it will only ever
|
|
33
|
+
* return a correctly formatted DateReducerState.
|
|
34
|
+
*
|
|
35
|
+
* @param input Any InputValue that has been sent to the DateInput
|
|
36
|
+
* @returns A properly formatted DateReducerState, which will be 'empty' if the input is invalid
|
|
37
|
+
*/
|
|
38
|
+
const parseDateString = (input?: InputValue): DateReducerState => {
|
|
39
|
+
if (!input || typeof input !== 'string' || !/.*-.*-.*/u.exec(input)) {
|
|
40
|
+
return { ...DEFAULT_DATE };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const [year, month, day] = input.split('-');
|
|
44
|
+
return { day, month, year };
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* This function takes an existing 'state' (an object of strings for the day, month, and year), and
|
|
49
|
+
* applies an 'action' on it, to return an updated state.
|
|
50
|
+
*
|
|
51
|
+
* The action can either contain a name (either 'day', 'month' or 'year'), or no name.
|
|
52
|
+
*
|
|
53
|
+
* @param state
|
|
54
|
+
* @param action
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
const dateReducer = (state: DateReducerState, action: DateReducerAction): DateReducerState => {
|
|
59
|
+
if (!action.name) {
|
|
60
|
+
return parseDateString(action.value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return { ...state, [action.name]: action.value };
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
interface DateInputProps extends InputProps {
|
|
67
|
+
format?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const DateInput: React.FunctionComponent<DateInputProps> = ({
|
|
71
|
+
format = 'DMY',
|
|
72
|
+
hasError,
|
|
73
|
+
isDisabled,
|
|
74
|
+
name,
|
|
75
|
+
onChange,
|
|
76
|
+
value,
|
|
77
|
+
}) => {
|
|
78
|
+
const [date, setDate] = useState<DateReducerState>(dateReducer(DEFAULT_DATE, { value }));
|
|
79
|
+
const { day, month, year } = date;
|
|
80
|
+
|
|
81
|
+
/* eslint-disable id-length */
|
|
82
|
+
const fieldData = useMemo(
|
|
83
|
+
(): Record<string, FieldDataItem> => ({
|
|
84
|
+
D: ['day', day, 'DD'],
|
|
85
|
+
M: ['month', month, 'MM'],
|
|
86
|
+
Y: ['year', year, 'YYYY'],
|
|
87
|
+
}),
|
|
88
|
+
[day, month, year]
|
|
89
|
+
);
|
|
90
|
+
/* eslint-enable */
|
|
91
|
+
|
|
92
|
+
const handleChange = (event: SimpleEvent, fieldName: string): void => {
|
|
93
|
+
const target = event.target as HTMLInputElement;
|
|
94
|
+
const newDate = dateReducer(date, { value: target.value, name: fieldName });
|
|
95
|
+
|
|
96
|
+
setDate(newDate);
|
|
97
|
+
|
|
98
|
+
const simpleEvent = {
|
|
99
|
+
target: {
|
|
100
|
+
name,
|
|
101
|
+
value: `${newDate.year}-${newDate.month}-${newDate.day}`,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
if (onChange) {
|
|
106
|
+
onChange(simpleEvent);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const newDate = dateReducer(date, { value });
|
|
112
|
+
setDate(newDate);
|
|
113
|
+
}, [value]);
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div className={styles.root}>
|
|
117
|
+
{format.split('').map((field) => {
|
|
118
|
+
const [fieldName, fieldValue, fieldPlaceholder] = fieldData[field];
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<div
|
|
122
|
+
key={fieldName}
|
|
123
|
+
className={classNames(styles.input, styles[`input${field}`])}
|
|
124
|
+
>
|
|
125
|
+
<TextInput
|
|
126
|
+
hasError={hasError}
|
|
127
|
+
isDisabled={isDisabled}
|
|
128
|
+
name={`${name}_${field.toLowerCase()}`}
|
|
129
|
+
onChange={(event): void => handleChange(event, fieldName)}
|
|
130
|
+
placeholder={fieldPlaceholder}
|
|
131
|
+
value={fieldValue}
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
})}
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
DateInput.propTypes = {
|
|
141
|
+
name: PropTypes.string.isRequired,
|
|
142
|
+
format: PropTypes.string,
|
|
143
|
+
hasError: PropTypes.bool,
|
|
144
|
+
isDisabled: PropTypes.bool,
|
|
145
|
+
value: PropTypes.string,
|
|
146
|
+
onChange: PropTypes.func,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default DateInput;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import NextDocument, { Head, Html, Main, NextScript } from 'next/document';
|
|
3
|
+
|
|
4
|
+
class Document extends NextDocument {
|
|
5
|
+
/* eslint-disable class-methods-use-this */
|
|
6
|
+
public render(): JSX.Element {
|
|
7
|
+
return (
|
|
8
|
+
<Html lang="en">
|
|
9
|
+
<Head />
|
|
10
|
+
<body>
|
|
11
|
+
<Main />
|
|
12
|
+
<NextScript />
|
|
13
|
+
</body>
|
|
14
|
+
</Html>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
/* eslint-enable */
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default Document;
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, waitForElementToBeRemoved } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
import Dropdown from './index';
|
|
6
|
+
|
|
7
|
+
import type { DropdownTransformer } from './index';
|
|
8
|
+
|
|
9
|
+
const mockData = [
|
|
10
|
+
{
|
|
11
|
+
id: 1,
|
|
12
|
+
name: 'Lorem Ipsum',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: '2',
|
|
16
|
+
name: 'Dolor Sit Amet',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'lorem',
|
|
20
|
+
name: 'Another Lorem Ipsum',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const mockExtendedData = [...mockData, { id: 4, name: 'Adiscit' }];
|
|
25
|
+
|
|
26
|
+
const mockBooleanData = [
|
|
27
|
+
{
|
|
28
|
+
id: 0,
|
|
29
|
+
name: 'Lorem False',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 1,
|
|
33
|
+
name: 'Ipsum True',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const mockDisabledData = [
|
|
38
|
+
{
|
|
39
|
+
id: 1,
|
|
40
|
+
name: 'Lorem Ipsum',
|
|
41
|
+
isDisabled: true,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 2,
|
|
45
|
+
name: 'Dolor Sit Amet',
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
describe('Dropdown', () => {
|
|
50
|
+
it('should handle no data', () => {
|
|
51
|
+
render(<Dropdown name="lorem" />);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should handle opening and closing', () => {
|
|
55
|
+
render(<Dropdown data={mockData} name="lorem" />);
|
|
56
|
+
|
|
57
|
+
expect(screen.queryAllByRole('option')).toHaveLength(0);
|
|
58
|
+
expect(screen.getByRole('button', { name: 'Open' })).toHaveTextContent(/^Open$/u);
|
|
59
|
+
|
|
60
|
+
userEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
61
|
+
expect(screen.queryAllByRole('option')).toHaveLength(3);
|
|
62
|
+
expect(screen.getByRole('button', { name: 'Close' })).toHaveTextContent(/^Close$/u);
|
|
63
|
+
|
|
64
|
+
expect(screen.queryAllByRole('option')[0]).toHaveTextContent(/^Lorem IpsumSelect$/u);
|
|
65
|
+
|
|
66
|
+
userEvent.click(screen.getByRole('button', { name: 'Close' }));
|
|
67
|
+
expect(screen.queryAllByRole('option')).toHaveLength(0);
|
|
68
|
+
expect(screen.getByRole('button', { name: 'Open' })).toHaveTextContent(/^Open$/u);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should have value', () => {
|
|
72
|
+
render(<Dropdown data={mockData} name="lorem" value="1" isPanelOnly />);
|
|
73
|
+
expect(screen.queryAllByRole('option')[0]).toHaveClass('item itemIsActive');
|
|
74
|
+
expect(screen.queryAllByRole('option')[1]).toHaveClass('item');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should have value array', () => {
|
|
78
|
+
render(<Dropdown data={mockData} name="lorem" value={[1, 2]} isMultiple isPanelOnly />);
|
|
79
|
+
expect(screen.queryAllByRole('option')[0]).toHaveClass('item itemIsActive');
|
|
80
|
+
expect(screen.queryAllByRole('option')[1]).toHaveClass('item itemIsActive');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should render label (1 item)', () => {
|
|
84
|
+
render(<Dropdown data={mockData} name="lorem" value="1" />);
|
|
85
|
+
expect(screen.getByText('Lorem Ipsum')).toBeInTheDocument();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('should render label (1 item, multiple)', () => {
|
|
89
|
+
render(<Dropdown data={mockData} name="lorem" value={[1]} isMultiple />);
|
|
90
|
+
expect(screen.getByText('Lorem Ipsum')).toBeInTheDocument();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should render label (2 items)', () => {
|
|
94
|
+
render(<Dropdown data={mockData} name="lorem" value={[1, 2]} isMultiple />);
|
|
95
|
+
expect(screen.getByText('Lorem Ipsum & Dolor Sit Amet')).toBeInTheDocument();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should render label (3 items)', () => {
|
|
99
|
+
render(<Dropdown data={mockExtendedData} name="lorem" value={[1, 2, 4]} isMultiple />);
|
|
100
|
+
expect(screen.getByText('Lorem Ipsum & 2 more')).toBeInTheDocument();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should have error', () => {
|
|
104
|
+
render(<Dropdown data={mockData} name="lorem" value="1" hasError />);
|
|
105
|
+
expect(screen.getByText('Lorem Ipsum')).toHaveClass('root rootHasError');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should be disabled', () => {
|
|
109
|
+
render(<Dropdown data={mockData} name="lorem" value="1" isDisabled />);
|
|
110
|
+
expect(screen.getByText('Lorem Ipsum')).toHaveClass('root rootIsDisabled');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should have disabled options', () => {
|
|
114
|
+
render(<Dropdown data={mockDisabledData} name="lorem" isPanelOnly />);
|
|
115
|
+
expect(screen.queryAllByRole('option')[0]).toHaveClass('item itemIsDisabled');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should be optional', () => {
|
|
119
|
+
render(<Dropdown data={mockData} name="lorem" value="1" isOptional />);
|
|
120
|
+
expect(screen.queryAllByRole('button')[1]).toHaveTextContent(/^Clear$/u);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should be panel only', () => {
|
|
124
|
+
render(<Dropdown name="lorem" isPanelOnly />);
|
|
125
|
+
expect(screen.queryAllByRole('listbox')).toHaveLength(1);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should have placeholder', () => {
|
|
129
|
+
render(<Dropdown name="lorem" />);
|
|
130
|
+
expect(screen.getByText('Select...')).toBeDefined();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should have multiple placeholder', () => {
|
|
134
|
+
render(<Dropdown name="lorem" isMultiple />);
|
|
135
|
+
expect(screen.getByText('Select one or more...')).toBeDefined();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should have custom placeholder', () => {
|
|
139
|
+
render(<Dropdown name="lorem" placeholder="Lorem" />);
|
|
140
|
+
expect(screen.getByText('Lorem')).toBeDefined();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('should use transformer', () => {
|
|
144
|
+
const transformer: DropdownTransformer = (item) => ({
|
|
145
|
+
id: item.id as number,
|
|
146
|
+
name: `[[${item.name as string}]]`,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
render(<Dropdown data={mockData} name="lorem" transformer={transformer} isPanelOnly />);
|
|
150
|
+
expect(screen.getByText('[[Lorem Ipsum]]')).toBeInTheDocument();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should error if array value & not isMultiple', () => {
|
|
154
|
+
jest.spyOn(console, 'error').mockImplementation(() => jest.fn());
|
|
155
|
+
|
|
156
|
+
expect(() =>
|
|
157
|
+
render(<Dropdown data={mockData} name="lorem" value={[1, 2]} />)
|
|
158
|
+
).toThrowError();
|
|
159
|
+
|
|
160
|
+
// eslint-disable-next-line no-console
|
|
161
|
+
(console.error as jest.Mock).mockClear();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('should error if not array value & isMultiple', () => {
|
|
165
|
+
jest.spyOn(console, 'error').mockImplementation(() => jest.fn());
|
|
166
|
+
|
|
167
|
+
expect(() =>
|
|
168
|
+
render(<Dropdown data={mockData} name="lorem" value="1" isMultiple />)
|
|
169
|
+
).toThrowError();
|
|
170
|
+
|
|
171
|
+
// eslint-disable-next-line no-console
|
|
172
|
+
(console.error as jest.Mock).mockClear();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should handle change', () => {
|
|
176
|
+
const mockFn = jest.fn();
|
|
177
|
+
render(<Dropdown data={mockData} name="lorem" onChange={mockFn} isPanelOnly />);
|
|
178
|
+
|
|
179
|
+
userEvent.click(screen.queryAllByRole('button')[0]);
|
|
180
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
181
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
182
|
+
item: { id: 1, name: 'Lorem Ipsum' },
|
|
183
|
+
target: { name: 'lorem', value: 1 },
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should handle multiple change', () => {
|
|
188
|
+
const mockFn = jest.fn();
|
|
189
|
+
render(<Dropdown data={mockData} name="lorem" onChange={mockFn} isMultiple isPanelOnly />);
|
|
190
|
+
|
|
191
|
+
userEvent.click(screen.queryAllByRole('button')[0]);
|
|
192
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
193
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
194
|
+
item: { id: 1, name: 'Lorem Ipsum' },
|
|
195
|
+
target: { name: 'lorem', value: [1] },
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should handle multiple change with value', () => {
|
|
200
|
+
const mockFn = jest.fn();
|
|
201
|
+
render(
|
|
202
|
+
<Dropdown
|
|
203
|
+
data={mockData}
|
|
204
|
+
name="lorem"
|
|
205
|
+
onChange={mockFn}
|
|
206
|
+
value={[1]}
|
|
207
|
+
isMultiple
|
|
208
|
+
isPanelOnly
|
|
209
|
+
/>
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
userEvent.click(screen.queryAllByRole('button')[0]);
|
|
213
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
214
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
215
|
+
item: { id: 1, name: 'Lorem Ipsum' },
|
|
216
|
+
target: { name: 'lorem', value: [] },
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('should handle 0 value', () => {
|
|
221
|
+
render(<Dropdown data={mockBooleanData} name="lorem" value={0} isPanelOnly />);
|
|
222
|
+
expect(screen.queryAllByRole('option')[0]).toHaveClass('item itemIsActive');
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('should handle change with boolean', () => {
|
|
226
|
+
const mockFn = jest.fn();
|
|
227
|
+
render(
|
|
228
|
+
<Dropdown data={mockBooleanData} name="lorem" onChange={mockFn} value={0} isPanelOnly />
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
userEvent.click(screen.queryAllByRole('button')[0]);
|
|
232
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
233
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
234
|
+
item: { id: 0, name: 'Lorem False' },
|
|
235
|
+
target: { name: 'lorem', value: 0 },
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('should handle multiple 0 value', () => {
|
|
240
|
+
const mockFn = jest.fn();
|
|
241
|
+
render(
|
|
242
|
+
<Dropdown
|
|
243
|
+
data={mockBooleanData}
|
|
244
|
+
name="lorem"
|
|
245
|
+
onChange={mockFn}
|
|
246
|
+
value={[]}
|
|
247
|
+
isMultiple
|
|
248
|
+
isPanelOnly
|
|
249
|
+
/>
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
userEvent.click(screen.queryAllByRole('button')[0]);
|
|
253
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
254
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
255
|
+
item: { id: 0, name: 'Lorem False' },
|
|
256
|
+
target: { name: 'lorem', value: [0] },
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('should handle keyboard controls', async () => {
|
|
261
|
+
const mockFn = jest.fn();
|
|
262
|
+
render(<Dropdown data={mockData} name="lorem" onChange={mockFn} />);
|
|
263
|
+
userEvent.tab();
|
|
264
|
+
expect(screen.getByText('Open')).toHaveFocus();
|
|
265
|
+
|
|
266
|
+
userEvent.keyboard('{Enter}');
|
|
267
|
+
expect(screen.queryAllByRole('option')).toHaveLength(3);
|
|
268
|
+
|
|
269
|
+
userEvent.keyboard('{ArrowDown}');
|
|
270
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
271
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
272
|
+
item: { id: 1, name: 'Lorem Ipsum' },
|
|
273
|
+
target: { name: 'lorem', value: 1 },
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
userEvent.keyboard('{ArrowUp}');
|
|
277
|
+
expect(mockFn).toHaveBeenCalledTimes(2);
|
|
278
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
279
|
+
item: { id: 'lorem', name: 'Another Lorem Ipsum' },
|
|
280
|
+
target: { name: 'lorem', value: 'lorem' },
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
userEvent.keyboard('{Escape}');
|
|
284
|
+
await waitForElementToBeRemoved(screen.queryAllByRole('option')[0]);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Dropdown from './index';
|
|
3
|
+
|
|
4
|
+
import TestChangeHandler from '@utility/TestChangeHandler';
|
|
5
|
+
import StorybookPanel from '@utility/StorybookPanel';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/Dropdown',
|
|
9
|
+
component: Dropdown,
|
|
10
|
+
decorators: [
|
|
11
|
+
(storyFn: () => React.ReactElement): React.ReactElement => (
|
|
12
|
+
<StorybookPanel isDeep>
|
|
13
|
+
<TestChangeHandler defaultValue={null}>{storyFn()}</TestChangeHandler>
|
|
14
|
+
</StorybookPanel>
|
|
15
|
+
),
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const data = [
|
|
20
|
+
{ id: 1, name: 'Apple' },
|
|
21
|
+
{ id: 2, name: 'Banana' },
|
|
22
|
+
{ id: 3, name: 'Carrot' },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const scrollData = [
|
|
26
|
+
{ id: 1, name: 'Apple' },
|
|
27
|
+
{ id: 2, name: 'Banana' },
|
|
28
|
+
{ id: 3, name: 'Carrot' },
|
|
29
|
+
{ id: 4, name: 'Date' },
|
|
30
|
+
{ id: 5, name: 'Elephant' },
|
|
31
|
+
{ id: 6, name: 'Fruit' },
|
|
32
|
+
{ id: 7, name: 'Grape' },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const dataWithMeta = data.map((item) => ({ ...item, meta: 'Lorem ipsum dolor' }));
|
|
36
|
+
|
|
37
|
+
export const Basic = (): React.ReactElement => <Dropdown data={data} name="lorem" />;
|
|
38
|
+
|
|
39
|
+
export const WithScroll = (): React.ReactElement => <Dropdown data={scrollData} name="lorem" />;
|
|
40
|
+
|
|
41
|
+
export const Multiple = (): React.ReactElement => (
|
|
42
|
+
<Dropdown data={scrollData} name="lorem" isMultiple />
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const Optional = (): React.ReactElement => <Dropdown data={data} name="lorem" isOptional />;
|
|
46
|
+
|
|
47
|
+
export const WithMeta = (): React.ReactElement => <Dropdown data={dataWithMeta} name="lorem" />;
|
|
48
|
+
|
|
49
|
+
export const NoData = (): React.ReactElement => <Dropdown data={[]} name="lorem" />;
|
|
50
|
+
|
|
51
|
+
export const Disabled = (): React.ReactElement => <Dropdown data={data} name="lorem" isDisabled />;
|
|
52
|
+
|
|
53
|
+
export const WithError = (): React.ReactElement => <Dropdown data={data} name="lorem" hasError />;
|