@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,248 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
|
|
3
|
+
import React, { Fragment, useEffect, useState } from 'react';
|
|
4
|
+
import useDeepCompareEffect from 'use-deep-compare-effect';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
|
|
7
|
+
import { ApiService } from '@sqrzro/utility';
|
|
8
|
+
|
|
9
|
+
import SummaryList from '@components/SummaryList';
|
|
10
|
+
import type { SummaryListObject, SummaryListValue } from '@core/SummaryListItem';
|
|
11
|
+
import ConnectedRepeaterComponent from '@core/ConnectedRepeaterComponent';
|
|
12
|
+
import type { ConnectedRepeaterRenderProps } from '@core/ConnectedRepeaterComponent';
|
|
13
|
+
import Filters from '@core/Filters';
|
|
14
|
+
import type { Columns } from '@core/TableCell';
|
|
15
|
+
|
|
16
|
+
import useFilters from '@hooks/useFilters';
|
|
17
|
+
|
|
18
|
+
import type { FilterField } from '@filters/interfaces';
|
|
19
|
+
import type { PaginationObject, Remote, SimpleAction, Transformer } from '@utility/interfaces';
|
|
20
|
+
|
|
21
|
+
import type { FilterMap } from '@services/FilterService';
|
|
22
|
+
|
|
23
|
+
interface ResponseData {
|
|
24
|
+
data?: Record<string, unknown>[];
|
|
25
|
+
totals?: Record<string, number> | null;
|
|
26
|
+
meta?: { current_page: string; last_page: string };
|
|
27
|
+
summary?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ListFunctions {
|
|
31
|
+
reloadList: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ConnectedRepeaterElementProps {
|
|
35
|
+
actions?: SimpleAction[];
|
|
36
|
+
columns?: Columns;
|
|
37
|
+
filters?: FilterField[];
|
|
38
|
+
hasSearch?: boolean;
|
|
39
|
+
hasSummaryToggle?: boolean;
|
|
40
|
+
isDisabled?: boolean;
|
|
41
|
+
remote: Remote;
|
|
42
|
+
setFunctions?: (functions: ListFunctions) => void;
|
|
43
|
+
summary?: SummaryListObject[];
|
|
44
|
+
transformer?: Transformer;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface ConnectedRepeaterProps extends ConnectedRepeaterElementProps {
|
|
48
|
+
render: (props: ConnectedRepeaterRenderProps) => React.ReactElement;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const parseRemote = (remote: Remote, filterData: FilterMap): Remote => {
|
|
52
|
+
if (typeof remote === 'string') {
|
|
53
|
+
return [remote, Object.fromEntries(filterData)];
|
|
54
|
+
}
|
|
55
|
+
return [remote[0], { ...remote[1], ...Object.fromEntries(filterData) }];
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const transformPagination = (data: {
|
|
59
|
+
current_page: string;
|
|
60
|
+
last_page: string;
|
|
61
|
+
}): PaginationObject => ({
|
|
62
|
+
activePage: parseInt(data.current_page, 10),
|
|
63
|
+
pageCount: parseInt(data.last_page, 10),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Note: There are two ways the data for `<SummaryList>` can be defined - either just passed
|
|
68
|
+
* through as a normal `SummaryListItem` or via a `Record<string, string>` from the remote
|
|
69
|
+
* response. If that's the case, the Record needs to be converted to a SummaryListItem, using the
|
|
70
|
+
* `value` of the Record as the key. For example, take a remote response with a `summary` object of
|
|
71
|
+
* the following:
|
|
72
|
+
*
|
|
73
|
+
* ```
|
|
74
|
+
* { lorem: 'ipsum' }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* In this instance, you would pass a `summary` prop like so:
|
|
78
|
+
*
|
|
79
|
+
* ```
|
|
80
|
+
* { label: 'Lorem', value: 'lorem' }
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* The parser function would then take the value of 'lorem' and replace it with the remote value
|
|
84
|
+
* with the matching key, which would leave you with the following:
|
|
85
|
+
*
|
|
86
|
+
* ```
|
|
87
|
+
* { label: 'Lorem', value: 'ipsum' }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
const parseSummaryValue = (
|
|
92
|
+
value: SummaryListValue,
|
|
93
|
+
remoteSummary: Record<string, string>
|
|
94
|
+
): SummaryListValue => {
|
|
95
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
96
|
+
return remoteSummary[value];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (typeof value.key === 'undefined') {
|
|
100
|
+
return '';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return { ...value, key: remoteSummary[value.key] };
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const parseSummary = (
|
|
107
|
+
summary: SummaryListObject[],
|
|
108
|
+
remoteSummary: Record<string, string>
|
|
109
|
+
): SummaryListObject[] =>
|
|
110
|
+
summary.map((item) => ({ ...item, value: parseSummaryValue(item.value, remoteSummary) }));
|
|
111
|
+
|
|
112
|
+
const ConnectedRepeater: React.FunctionComponent<ConnectedRepeaterProps> = ({
|
|
113
|
+
actions,
|
|
114
|
+
columns,
|
|
115
|
+
filters,
|
|
116
|
+
hasSearch,
|
|
117
|
+
hasSummaryToggle,
|
|
118
|
+
isDisabled,
|
|
119
|
+
remote,
|
|
120
|
+
render,
|
|
121
|
+
setFunctions,
|
|
122
|
+
summary,
|
|
123
|
+
transformer,
|
|
124
|
+
}) => {
|
|
125
|
+
const [filterData] = useFilters();
|
|
126
|
+
|
|
127
|
+
const [data, setData] = useState<Record<string, unknown>[]>();
|
|
128
|
+
const [pagination, setPagination] = useState<PaginationObject>();
|
|
129
|
+
const [totals, setTotals] = useState<Record<string, number> | null>();
|
|
130
|
+
|
|
131
|
+
const [error, setError] = useState('');
|
|
132
|
+
|
|
133
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
134
|
+
const [isRefreshing, setIsRefreshing] = useState(true);
|
|
135
|
+
|
|
136
|
+
const [isSummaryOpen, setIsSummaryOpen] = useState(false);
|
|
137
|
+
const [remoteSummary, setRemoteSummary] = useState<SummaryListObject[]>([]);
|
|
138
|
+
|
|
139
|
+
const toggleIsSummaryOpen = (): void => setIsSummaryOpen(!isSummaryOpen);
|
|
140
|
+
|
|
141
|
+
const getData = async (): Promise<void> => {
|
|
142
|
+
setIsRefreshing(true);
|
|
143
|
+
|
|
144
|
+
if (summary) {
|
|
145
|
+
setRemoteSummary(summary.map((item) => ({ ...item, value: '-' })));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
const response = await ApiService.get<ResponseData>(parseRemote(remote, filterData));
|
|
150
|
+
setIsLoading(false);
|
|
151
|
+
setIsRefreshing(false);
|
|
152
|
+
|
|
153
|
+
setData(response.data.data);
|
|
154
|
+
setTotals(response.data.totals);
|
|
155
|
+
|
|
156
|
+
if (response.data.summary) {
|
|
157
|
+
setRemoteSummary(parseSummary(summary || [], response.data.summary));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (response.data.meta) {
|
|
161
|
+
setPagination(transformPagination(response.data.meta));
|
|
162
|
+
}
|
|
163
|
+
} catch (err) {
|
|
164
|
+
if (err instanceof Error) {
|
|
165
|
+
setError(err.toString());
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
setIsLoading(false);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
if (setFunctions) {
|
|
174
|
+
const functions: ListFunctions = { reloadList: async () => getData() };
|
|
175
|
+
setFunctions(functions);
|
|
176
|
+
}
|
|
177
|
+
}, [filterData]);
|
|
178
|
+
|
|
179
|
+
useDeepCompareEffect(() => {
|
|
180
|
+
void getData();
|
|
181
|
+
}, [filterData]);
|
|
182
|
+
|
|
183
|
+
const summaryAction = {
|
|
184
|
+
label: isSummaryOpen ? 'Hide Summary' : 'Show Summary',
|
|
185
|
+
onClick: toggleIsSummaryOpen,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const parsedActions =
|
|
189
|
+
summary && hasSummaryToggle ? [...(actions || []), summaryAction] : actions;
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<Fragment>
|
|
193
|
+
{(hasSearch || filters?.length) && (
|
|
194
|
+
<Filters
|
|
195
|
+
actions={parsedActions}
|
|
196
|
+
fields={filters}
|
|
197
|
+
hasSearch={hasSearch}
|
|
198
|
+
isDisabled={!data || !data.length}
|
|
199
|
+
/>
|
|
200
|
+
)}
|
|
201
|
+
{summary && (!hasSummaryToggle || (hasSummaryToggle && isSummaryOpen)) ? (
|
|
202
|
+
<SummaryList data={remoteSummary} isDisabled={isDisabled || isRefreshing} />
|
|
203
|
+
) : null}
|
|
204
|
+
<ConnectedRepeaterComponent
|
|
205
|
+
columns={columns}
|
|
206
|
+
data={data}
|
|
207
|
+
error={error}
|
|
208
|
+
isDisabled={isDisabled || isRefreshing}
|
|
209
|
+
isLoading={isLoading}
|
|
210
|
+
pagination={pagination}
|
|
211
|
+
render={render}
|
|
212
|
+
totals={totals}
|
|
213
|
+
transformer={transformer}
|
|
214
|
+
/>
|
|
215
|
+
</Fragment>
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
ConnectedRepeater.propTypes = {
|
|
220
|
+
render: PropTypes.func.isRequired,
|
|
221
|
+
actions: PropTypes.arrayOf(
|
|
222
|
+
PropTypes.shape({
|
|
223
|
+
label: PropTypes.string.isRequired,
|
|
224
|
+
onClick: PropTypes.func.isRequired,
|
|
225
|
+
}).isRequired
|
|
226
|
+
),
|
|
227
|
+
columns: PropTypes.shape({}),
|
|
228
|
+
filters: PropTypes.arrayOf(
|
|
229
|
+
PropTypes.shape({
|
|
230
|
+
label: PropTypes.string.isRequired,
|
|
231
|
+
name: PropTypes.string.isRequired,
|
|
232
|
+
renderField: PropTypes.func.isRequired,
|
|
233
|
+
}).isRequired
|
|
234
|
+
),
|
|
235
|
+
hasSearch: PropTypes.bool,
|
|
236
|
+
hasSummaryToggle: PropTypes.bool,
|
|
237
|
+
isDisabled: PropTypes.bool,
|
|
238
|
+
setFunctions: PropTypes.func,
|
|
239
|
+
summary: PropTypes.arrayOf(
|
|
240
|
+
PropTypes.shape({
|
|
241
|
+
label: PropTypes.string.isRequired,
|
|
242
|
+
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.shape({})])
|
|
243
|
+
.isRequired,
|
|
244
|
+
}).isRequired
|
|
245
|
+
),
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export default ConnectedRepeater;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import EmptyMessage from '@core/EmptyMessage';
|
|
4
|
+
import ErrorMessage from '@core/ErrorMessage';
|
|
5
|
+
import Loader from '@core/Loader';
|
|
6
|
+
|
|
7
|
+
import type { Columns } from '@core/TableCell';
|
|
8
|
+
import type { PaginationObject, Transformer } from '@utility/interfaces';
|
|
9
|
+
|
|
10
|
+
export interface ConnectedRepeaterRenderProps {
|
|
11
|
+
columns?: Columns;
|
|
12
|
+
data?: Record<string, unknown>[];
|
|
13
|
+
isDisabled?: boolean;
|
|
14
|
+
pagination?: PaginationObject;
|
|
15
|
+
totals?: Record<string, number> | null;
|
|
16
|
+
transformer?: Transformer;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface ConnectedRepeaterComponentProps {
|
|
20
|
+
columns?: Columns;
|
|
21
|
+
data?: Record<string, unknown>[];
|
|
22
|
+
error?: string;
|
|
23
|
+
isDisabled?: boolean;
|
|
24
|
+
isLoading?: boolean;
|
|
25
|
+
pagination?: PaginationObject;
|
|
26
|
+
render: (props: ConnectedRepeaterRenderProps) => React.ReactElement;
|
|
27
|
+
totals?: Record<string, number> | null;
|
|
28
|
+
transformer?: Transformer;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const ConnectedRepeaterComponent: React.FunctionComponent<ConnectedRepeaterComponentProps> = ({
|
|
32
|
+
columns,
|
|
33
|
+
data,
|
|
34
|
+
error,
|
|
35
|
+
isDisabled,
|
|
36
|
+
isLoading,
|
|
37
|
+
pagination,
|
|
38
|
+
render,
|
|
39
|
+
totals,
|
|
40
|
+
transformer,
|
|
41
|
+
}) => {
|
|
42
|
+
if (error) {
|
|
43
|
+
return <ErrorMessage>{error}</ErrorMessage>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (isLoading) {
|
|
47
|
+
return <Loader />;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!data || !data.length) {
|
|
51
|
+
return <EmptyMessage />;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const props: ConnectedRepeaterRenderProps = {
|
|
55
|
+
columns,
|
|
56
|
+
data,
|
|
57
|
+
isDisabled,
|
|
58
|
+
pagination,
|
|
59
|
+
totals,
|
|
60
|
+
transformer,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return render(props);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default ConnectedRepeaterComponent;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import useLayout from '@hooks/useLayout';
|
|
6
|
+
|
|
7
|
+
import styles from './Container.module.css';
|
|
8
|
+
|
|
9
|
+
interface ContainerProps {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
isWide?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Container: React.FunctionComponent<ContainerProps> = ({ children, isWide }) => {
|
|
15
|
+
const { applyLayoutClassName } = useLayout();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
className={classNames(
|
|
20
|
+
styles.root,
|
|
21
|
+
isWide && styles.rootIsWide,
|
|
22
|
+
applyLayoutClassName(styles)
|
|
23
|
+
)}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Container.propTypes = {
|
|
31
|
+
children: PropTypes.node.isRequired,
|
|
32
|
+
isWide: PropTypes.bool,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default Container;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
.item {
|
|
2
|
+
align-items: center;
|
|
3
|
+
border-top: .1rem var(--clr-grey200) solid;
|
|
4
|
+
color: var(--clr-grey700);
|
|
5
|
+
display: flex;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
padding: 1.3rem;
|
|
8
|
+
position: relative;
|
|
9
|
+
|
|
10
|
+
&:first-child {
|
|
11
|
+
border-top: 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.itemIsActive {
|
|
16
|
+
background-color: var(--clr-primary10);
|
|
17
|
+
|
|
18
|
+
&::before {
|
|
19
|
+
border: .4rem var(--clr-white) solid;
|
|
20
|
+
bottom: 0;
|
|
21
|
+
content: '';
|
|
22
|
+
left: 0;
|
|
23
|
+
position: absolute;
|
|
24
|
+
right: 0;
|
|
25
|
+
top: 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.itemIsDisabled {
|
|
30
|
+
opacity: .3;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.icon {
|
|
35
|
+
padding-right: 1rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.title {
|
|
39
|
+
display: block;
|
|
40
|
+
font-size: var(--fs-sml);
|
|
41
|
+
padding-bottom: .1rem;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.meta {
|
|
45
|
+
color: var(--clr-grey500);
|
|
46
|
+
display: block;
|
|
47
|
+
font-size: var(--fs-xsml);
|
|
48
|
+
height: 2rem;
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
text-overflow: ellipsis;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.control {
|
|
54
|
+
background-color: transparent;
|
|
55
|
+
border: 0;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
height: 100%;
|
|
58
|
+
left: 0;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
position: absolute;
|
|
61
|
+
top: 0;
|
|
62
|
+
text-indent: -999em;
|
|
63
|
+
width: 100%;
|
|
64
|
+
|
|
65
|
+
&:focus {
|
|
66
|
+
outline: none;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import ChkRadIcon from '@core/ChkRadIcon';
|
|
6
|
+
import type { SimpleEvent, SimpleEventHandler, SimpleObject } from '@utility/interfaces';
|
|
7
|
+
|
|
8
|
+
import styles from './DropdownPanel.module.css';
|
|
9
|
+
|
|
10
|
+
export interface DropdownItem extends SimpleObject {
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
meta?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface DropdownEvent extends SimpleEvent {
|
|
16
|
+
item: DropdownItem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface DropdownPanelProps {
|
|
20
|
+
data: DropdownItem[];
|
|
21
|
+
isMultiple?: boolean;
|
|
22
|
+
name: string;
|
|
23
|
+
onChange: SimpleEventHandler<boolean | number | string | null, DropdownEvent>;
|
|
24
|
+
value?: (number | string)[] | number | string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const isActive = (id: number | string, value?: (number | string)[] | number | string): boolean => {
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
return value.includes(id);
|
|
30
|
+
}
|
|
31
|
+
return value === id;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const DropdownPanel: React.FunctionComponent<DropdownPanelProps> = ({
|
|
35
|
+
data,
|
|
36
|
+
isMultiple,
|
|
37
|
+
name,
|
|
38
|
+
onChange,
|
|
39
|
+
value,
|
|
40
|
+
}) => (
|
|
41
|
+
<ul role="listbox">
|
|
42
|
+
{data.map((item: DropdownItem) => (
|
|
43
|
+
<li
|
|
44
|
+
key={item.id}
|
|
45
|
+
className={classNames(
|
|
46
|
+
styles.item,
|
|
47
|
+
isActive(item.id, value) && styles.itemIsActive,
|
|
48
|
+
item.isDisabled && styles.itemIsDisabled
|
|
49
|
+
)}
|
|
50
|
+
role="option"
|
|
51
|
+
>
|
|
52
|
+
{isMultiple && (
|
|
53
|
+
<span className={styles.icon}>
|
|
54
|
+
<ChkRadIcon isChecked={isActive(item.id, value)} />
|
|
55
|
+
</span>
|
|
56
|
+
)}
|
|
57
|
+
<span className={styles.content}>
|
|
58
|
+
<span className={styles.title}>{item.name}</span>
|
|
59
|
+
{item.meta && <small className={styles.meta}>{item.meta}</small>}
|
|
60
|
+
</span>
|
|
61
|
+
<button
|
|
62
|
+
className={styles.control}
|
|
63
|
+
data-testid={`dropdown-panel-control-${item.id}`}
|
|
64
|
+
onClick={(): void => onChange({ item, target: { name, value: item.id } })}
|
|
65
|
+
tabIndex={-1}
|
|
66
|
+
type="button"
|
|
67
|
+
>
|
|
68
|
+
Select
|
|
69
|
+
</button>
|
|
70
|
+
</li>
|
|
71
|
+
))}
|
|
72
|
+
</ul>
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
DropdownPanel.propTypes = {
|
|
76
|
+
data: PropTypes.arrayOf(
|
|
77
|
+
PropTypes.shape({
|
|
78
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
79
|
+
name: PropTypes.string.isRequired,
|
|
80
|
+
}).isRequired
|
|
81
|
+
).isRequired,
|
|
82
|
+
name: PropTypes.string.isRequired,
|
|
83
|
+
onChange: PropTypes.func.isRequired,
|
|
84
|
+
isMultiple: PropTypes.bool,
|
|
85
|
+
value: PropTypes.oneOfType([
|
|
86
|
+
PropTypes.string,
|
|
87
|
+
PropTypes.number,
|
|
88
|
+
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired),
|
|
89
|
+
]),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default DropdownPanel;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
align-items: center;
|
|
3
|
+
color: var(--clr-grey600);
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
height: 20rem;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.title {
|
|
11
|
+
font-size: var(--fs-xlrg);
|
|
12
|
+
font-weight: var(--fs-body);
|
|
13
|
+
margin-bottom: 1rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.description {
|
|
17
|
+
margin-bottom: 3rem;
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import styles from './EmptyMessage.module.css';
|
|
5
|
+
|
|
6
|
+
interface EmptyMessageProps {
|
|
7
|
+
description?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const DEFAULT_TITLE = 'No results found';
|
|
12
|
+
const DEFAULT_DESCRIPTION = 'If you think this is an error, please contact the site administrator';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* By default, `EmptyMessage` simply displays a message to the user when no results have been found
|
|
16
|
+
* in a particular list. However, the `title` and `description` can be customised, allowing the
|
|
17
|
+
* component to be used for any situation where a standout message is required.
|
|
18
|
+
*/
|
|
19
|
+
const EmptyMessage: React.FunctionComponent<EmptyMessageProps> = ({ description, title }) => (
|
|
20
|
+
<section className={styles.root}>
|
|
21
|
+
<h1 className={styles.title}>{title || DEFAULT_TITLE}</h1>
|
|
22
|
+
<p className={styles.description}>{description || DEFAULT_DESCRIPTION}</p>
|
|
23
|
+
</section>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
EmptyMessage.propTypes = {
|
|
27
|
+
description: PropTypes.string,
|
|
28
|
+
title: PropTypes.string,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default EmptyMessage;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import ErrorBoundary from './index';
|
|
5
|
+
|
|
6
|
+
describe('ErrorBoundary', () => {
|
|
7
|
+
it('should render if no children', () => {
|
|
8
|
+
render(
|
|
9
|
+
<ErrorBoundary>
|
|
10
|
+
<div>Lorem</div>
|
|
11
|
+
</ErrorBoundary>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
expect(screen.getByText('Lorem')).toBeInTheDocument();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should render and error', () => {
|
|
18
|
+
const spy = jest.spyOn(console, 'error').mockImplementation(() => null);
|
|
19
|
+
|
|
20
|
+
const ErroringComponent: React.FunctionComponent = () => {
|
|
21
|
+
throw new Error('Lorem Ipsum');
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
render(
|
|
25
|
+
<ErrorBoundary>
|
|
26
|
+
<ErroringComponent />
|
|
27
|
+
</ErrorBoundary>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
expect(screen.getByText('Error: Lorem Ipsum')).toBeInTheDocument();
|
|
31
|
+
spy.mockRestore();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import ErrorMessage from '@core/ErrorMessage';
|
|
5
|
+
|
|
6
|
+
interface ErrorBoundaryState {
|
|
7
|
+
error: Error | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class ErrorBoundary extends Component<Record<string, unknown>, ErrorBoundaryState> {
|
|
11
|
+
public static propTypes = {
|
|
12
|
+
children: PropTypes.node.isRequired,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
public constructor(props: Record<string, unknown>) {
|
|
16
|
+
super(props);
|
|
17
|
+
this.state = { error: null };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static getDerivedStateFromError(error: Error): ErrorBoundaryState {
|
|
21
|
+
return { error };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* eslint-disable class-methods-use-this, no-console */
|
|
25
|
+
public shouldComponentUpdate(): boolean {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/* eslint-enable */
|
|
29
|
+
|
|
30
|
+
public render(): React.ReactNode {
|
|
31
|
+
const { error } = this.state;
|
|
32
|
+
const { children } = this.props;
|
|
33
|
+
|
|
34
|
+
if (error) {
|
|
35
|
+
return <ErrorMessage>{error.toString()}</ErrorMessage>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return children;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default ErrorBoundary;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
color: var(--clr-error);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.rootIsScene {
|
|
6
|
+
padding: 3rem;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.title {
|
|
10
|
+
font-size: var(--fs-xlrg);
|
|
11
|
+
font-weight: var(--fw-bold);
|
|
12
|
+
margin-bottom: 1rem;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.description {
|
|
16
|
+
margin-bottom: 3rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.descriptionIsMini {
|
|
20
|
+
font-size: var(--fs-xsml);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.meta {
|
|
24
|
+
font-size: var(--fs-sml);
|
|
25
|
+
}
|