@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,137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addMonths as fnsAddMonths,
|
|
3
|
+
getDay as fnsGetDay,
|
|
4
|
+
getDaysInMonth as fnsGetDaysInMonth,
|
|
5
|
+
set as fnsSet,
|
|
6
|
+
subDays as fnsSubDays,
|
|
7
|
+
subMonths as fnsSubMonths,
|
|
8
|
+
parseISO,
|
|
9
|
+
} from 'date-fns';
|
|
10
|
+
|
|
11
|
+
import FormatService from './FormatService';
|
|
12
|
+
|
|
13
|
+
import type { SimpleObject } from '@utility/interfaces';
|
|
14
|
+
|
|
15
|
+
const DAYS_IN_WEEK = 7;
|
|
16
|
+
const MONTHS_IN_YEAR = 12;
|
|
17
|
+
const DAYS_IN_30_DAYS = 30;
|
|
18
|
+
const DAYS_IN_MONTH = 31;
|
|
19
|
+
|
|
20
|
+
const FIRST_YEAR = 1900;
|
|
21
|
+
|
|
22
|
+
const SUNDAY = 6;
|
|
23
|
+
|
|
24
|
+
interface DateItem {
|
|
25
|
+
id: number;
|
|
26
|
+
name: string | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const getDays = (): DateItem[] =>
|
|
30
|
+
Array(DAYS_IN_MONTH)
|
|
31
|
+
.fill(0)
|
|
32
|
+
.map((_item, index: number) => ({ id: index + 1, name: `${index + 1}` }));
|
|
33
|
+
|
|
34
|
+
const getMonths = (): DateItem[] =>
|
|
35
|
+
Array(MONTHS_IN_YEAR)
|
|
36
|
+
.fill(0)
|
|
37
|
+
.map((_item, index: number) => ({
|
|
38
|
+
id: index + 1,
|
|
39
|
+
name: FormatService.date(new Date(FIRST_YEAR, index, 1), 'MMMM'),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
const getYears = (
|
|
43
|
+
startYear: number = FIRST_YEAR,
|
|
44
|
+
endYear: number = new Date().getFullYear()
|
|
45
|
+
): DateItem[] =>
|
|
46
|
+
Array(endYear - startYear + 1)
|
|
47
|
+
.fill(0)
|
|
48
|
+
.map((_item, index: number) => ({ id: endYear - index, name: `${endYear - index}` }));
|
|
49
|
+
|
|
50
|
+
const isToday = (date: string): boolean => FormatService.date(new Date(), 'y-MM-dd') === date;
|
|
51
|
+
|
|
52
|
+
// Most date libraries start the week on Sunday (US). We want to start on Monday (UK).
|
|
53
|
+
const adjustDayOfWeek = (num: number): number => (num === 0 ? SUNDAY : num - 1);
|
|
54
|
+
|
|
55
|
+
const getDayOfWeek = (date: string): number => {
|
|
56
|
+
const parsed = parseISO(date);
|
|
57
|
+
const num = adjustDayOfWeek(fnsGetDay(parsed));
|
|
58
|
+
|
|
59
|
+
return Number.isNaN(num) ? -1 : num;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const getDaysInMonth = (date: string): number => {
|
|
63
|
+
const parsed = parseISO(date);
|
|
64
|
+
const num = fnsGetDaysInMonth(parsed);
|
|
65
|
+
|
|
66
|
+
return Number.isNaN(num) ? -1 : num;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const addMonths = (date: string, amount: number): string => {
|
|
70
|
+
const parsed = parseISO(`${date}-01`);
|
|
71
|
+
return FormatService.date(fnsAddMonths(parsed, amount), 'y-MM');
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const subMonths = (date: string, amount: number): string => {
|
|
75
|
+
const parsed = parseISO(`${date}-01`);
|
|
76
|
+
return FormatService.date(fnsSubMonths(parsed, amount), 'y-MM');
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Quick Date
|
|
80
|
+
|
|
81
|
+
const QUICK_DATE_FORMAT = 'Y-MM-dd';
|
|
82
|
+
|
|
83
|
+
const getToday = (): Date => new Date();
|
|
84
|
+
|
|
85
|
+
const getYesterday = (): Date => fnsSubDays(new Date(), 1);
|
|
86
|
+
|
|
87
|
+
const getLast7Days = (): Date[] => [fnsSubDays(new Date(), DAYS_IN_WEEK), new Date()];
|
|
88
|
+
|
|
89
|
+
const getLast30Days = (): Date[] => [fnsSubDays(new Date(), DAYS_IN_30_DAYS), new Date()];
|
|
90
|
+
|
|
91
|
+
// Get the first day of this month, and today
|
|
92
|
+
const getThisMonth = (): Date[] => [fnsSet(new Date(), { date: 1 }), getToday()];
|
|
93
|
+
|
|
94
|
+
// Get the first day of last month, and the day before the first day of this month
|
|
95
|
+
const getLastMonth = (): Date[] => [
|
|
96
|
+
fnsSet(fnsSubMonths(new Date(), 1), { date: 1 }),
|
|
97
|
+
fnsSubDays(getThisMonth()[0], 1),
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
const getQuickDateId = (value: Date | Date[]): string => {
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
return value.map((item) => FormatService.date(item, QUICK_DATE_FORMAT)).join(',');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const formatted = FormatService.date(value, QUICK_DATE_FORMAT);
|
|
106
|
+
return `${formatted},${formatted}`;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const getQuickDates = (): SimpleObject[] => {
|
|
110
|
+
const dates = {
|
|
111
|
+
Today: getToday(),
|
|
112
|
+
Yesterday: getYesterday(),
|
|
113
|
+
'Last 7 Days': getLast7Days(),
|
|
114
|
+
'Last 30 Days': getLast30Days(),
|
|
115
|
+
'This Month': getThisMonth(),
|
|
116
|
+
'Last Month': getLastMonth(),
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
return Object.entries(dates).map(([key, value]) => ({
|
|
120
|
+
id: getQuickDateId(value),
|
|
121
|
+
name: key,
|
|
122
|
+
}));
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const DateService = {
|
|
126
|
+
addMonths,
|
|
127
|
+
getDaysInMonth,
|
|
128
|
+
getDayOfWeek,
|
|
129
|
+
getDays,
|
|
130
|
+
getMonths,
|
|
131
|
+
getQuickDates,
|
|
132
|
+
getYears,
|
|
133
|
+
isToday,
|
|
134
|
+
subMonths,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export default DateService;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import DownloadService from './DownloadService';
|
|
2
|
+
|
|
3
|
+
import { ApiService } from '@sqrzro/utility';
|
|
4
|
+
|
|
5
|
+
jest.mock('@services/FilterService', () => ({
|
|
6
|
+
getUrlForFilters: (): string => 'lorem',
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
describe('DownloadService', () => {
|
|
10
|
+
it('should make url', () => {
|
|
11
|
+
expect(ApiService.makeUrl).toHaveBeenCalledTimes(0);
|
|
12
|
+
const url = DownloadService.makeUrl('lorem');
|
|
13
|
+
expect(ApiService.makeUrl).toHaveBeenCalledTimes(1);
|
|
14
|
+
expect(ApiService.makeUrl).toHaveBeenLastCalledWith('lorem');
|
|
15
|
+
|
|
16
|
+
expect(url).toBe('lorem?lorem');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should download', () => {
|
|
20
|
+
jest.spyOn(window, 'open').mockImplementation(() => null);
|
|
21
|
+
|
|
22
|
+
expect(window.open).toHaveBeenCalledTimes(0);
|
|
23
|
+
DownloadService.download('lorem');
|
|
24
|
+
expect(window.open).toHaveBeenCalledTimes(1);
|
|
25
|
+
expect(window.open).toHaveBeenLastCalledWith('lorem?lorem');
|
|
26
|
+
|
|
27
|
+
(window.open as jest.Mock).mockClear();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApiService, AuthService } from '@sqrzro/utility';
|
|
2
|
+
|
|
3
|
+
import FilterService from '@services/FilterService';
|
|
4
|
+
|
|
5
|
+
const makeUrl = (alias: string): string => {
|
|
6
|
+
const query = FilterService.getUrlForFilters({ dl: '1', token: AuthService.getToken() }, false);
|
|
7
|
+
return `${ApiService.makeUrl(alias)}?${query}`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const download = (alias: string): void => {
|
|
11
|
+
window.open(makeUrl(alias));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default { download, makeUrl };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import type { FilterField, FilterOptions } from '@filters/interfaces';
|
|
6
|
+
|
|
7
|
+
import BooleanFilter, { renderSummary as renderBooleanSummary } from '@filters/BooleanFilter';
|
|
8
|
+
import DateFilter, { renderSummary as renderDateSummary } from '@filters/DateFilter';
|
|
9
|
+
import DropdownFilter, { renderSummary as renderDropdownSummary } from '@filters/DropdownFilter';
|
|
10
|
+
import QuickDateFilter, { renderSummary as renderQuickDateSummary } from '@filters/QuickDateFilter';
|
|
11
|
+
|
|
12
|
+
const booleanFilter = (options: FilterOptions): FilterField => ({
|
|
13
|
+
...options,
|
|
14
|
+
renderField: (props): React.ReactNode => <BooleanFilter {...props} />,
|
|
15
|
+
renderSummary: renderBooleanSummary,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const dateFilter = (options: FilterOptions): FilterField => ({
|
|
19
|
+
...options,
|
|
20
|
+
panelOptions: { size: 'lg' },
|
|
21
|
+
renderField: (props): React.ReactNode => <DateFilter {...props} />,
|
|
22
|
+
renderSummary: renderDateSummary,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const dropdownFilter = (options: FilterOptions): FilterField => ({
|
|
26
|
+
...options,
|
|
27
|
+
panelOptions: { isScrollable: true },
|
|
28
|
+
renderField: (props): React.ReactNode => <DropdownFilter {...props} />,
|
|
29
|
+
renderSummary: renderDropdownSummary,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const quickDateFilter = (options: FilterOptions): FilterField => ({
|
|
33
|
+
...options,
|
|
34
|
+
panelOptions: [{}, { size: 'lg' }],
|
|
35
|
+
renderField: (props): React.ReactNode => <QuickDateFilter {...props} />,
|
|
36
|
+
renderSummary: renderQuickDateSummary,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const FilterComponentService = {
|
|
40
|
+
boolean: booleanFilter,
|
|
41
|
+
date: dateFilter,
|
|
42
|
+
dropdown: dropdownFilter,
|
|
43
|
+
quickDate: quickDateFilter,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default FilterComponentService;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import FilterService from './FilterService';
|
|
2
|
+
|
|
3
|
+
describe('FilterService', () => {
|
|
4
|
+
describe('parseQuery', () => {
|
|
5
|
+
it('should handle no arguments', () => {
|
|
6
|
+
expect(FilterService.parseQuery()).toEqual(new Map());
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('should parse a value', () => {
|
|
10
|
+
const search = { lorem: 'ipsum' };
|
|
11
|
+
|
|
12
|
+
const result = new Map();
|
|
13
|
+
result.set('lorem', 'ipsum');
|
|
14
|
+
|
|
15
|
+
expect(FilterService.parseQuery(search)).toEqual(result);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should parse an array', () => {
|
|
19
|
+
const search = { lorem: ['1', '2'] };
|
|
20
|
+
|
|
21
|
+
const result = new Map();
|
|
22
|
+
result.set('lorem', ['1', '2']);
|
|
23
|
+
|
|
24
|
+
expect(FilterService.parseQuery(search)).toEqual(result);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should filter default keys', () => {
|
|
28
|
+
const search = { alias: 'lorem' };
|
|
29
|
+
const result = new Map();
|
|
30
|
+
|
|
31
|
+
expect(FilterService.parseQuery(search)).toEqual(result);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should filter no value', () => {
|
|
35
|
+
const search = { lorem: '' };
|
|
36
|
+
const result = new Map();
|
|
37
|
+
|
|
38
|
+
expect(FilterService.parseQuery(search)).toEqual(result);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should not filter page', () => {
|
|
42
|
+
const search = { page: '1' };
|
|
43
|
+
|
|
44
|
+
const result = new Map();
|
|
45
|
+
result.set('page', '1');
|
|
46
|
+
|
|
47
|
+
expect(FilterService.parseQuery(search)).toEqual(result);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should filter page', () => {
|
|
51
|
+
const search = { page: '1' };
|
|
52
|
+
const result = new Map();
|
|
53
|
+
|
|
54
|
+
expect(FilterService.parseQuery(search, { shouldFilterPage: true })).toEqual(result);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('makeUrl', () => {
|
|
59
|
+
it('should make url', () => {
|
|
60
|
+
const data = new Map<string, string>();
|
|
61
|
+
data.set('lorem', 'ipsum');
|
|
62
|
+
|
|
63
|
+
expect(FilterService.makeUrl(data)).toBe('/?lorem=ipsum');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should make url without pathname', () => {
|
|
67
|
+
const data = new Map<string, string>();
|
|
68
|
+
data.set('lorem', 'ipsum');
|
|
69
|
+
|
|
70
|
+
expect(FilterService.makeUrl(data, false)).toBe('lorem=ipsum');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should make url with array', () => {
|
|
74
|
+
const data = new Map<string, string[]>();
|
|
75
|
+
data.set('lorem', ['ipsum', 'dolor']);
|
|
76
|
+
|
|
77
|
+
expect(FilterService.makeUrl(data)).toBe(encodeURI('/?lorem[0]=ipsum&lorem[1]=dolor'));
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('getUrlForFilters', () => {
|
|
82
|
+
it('should get basic url', () => {
|
|
83
|
+
const url = FilterService.getUrlForFilters();
|
|
84
|
+
expect(url).toBe('/?');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { parseSearch, stringifySearch } from '@sqrzro/utility';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/consistent-indexed-object-style */
|
|
4
|
+
interface Query {
|
|
5
|
+
[key: string]: Query | Query[] | string[] | string;
|
|
6
|
+
}
|
|
7
|
+
/* eslint-enable */
|
|
8
|
+
|
|
9
|
+
export type FilterMap = Map<string, string[] | string | null>;
|
|
10
|
+
|
|
11
|
+
export interface FilterOptions {
|
|
12
|
+
shouldFilterPage?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const FILTERED_KEYS = ['id', 'alias'];
|
|
16
|
+
|
|
17
|
+
const parseQueryEntry = (entry: Query | Query[] | string[] | string): string[] | string => {
|
|
18
|
+
if (Array.isArray(entry)) {
|
|
19
|
+
return entry.map((item) => item.toString());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return entry.toString();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const parseQuery = (query?: Query, options?: FilterOptions): FilterMap => {
|
|
26
|
+
const map = new Map<string, string[] | string | null>();
|
|
27
|
+
|
|
28
|
+
const entries = Object.entries(query || {}).filter(([key, value]) => {
|
|
29
|
+
if (value === '') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (FILTERED_KEYS.includes(key)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (options?.shouldFilterPage && key === 'page') {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
for (const [key, value] of entries) {
|
|
42
|
+
map.set(key, parseQueryEntry(value));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return map;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const makeUrl = (data: FilterMap, includePathname = true): string =>
|
|
49
|
+
`${includePathname ? `${window.location.pathname}?` : ''}${stringifySearch(
|
|
50
|
+
Object.fromEntries(data)
|
|
51
|
+
)}`;
|
|
52
|
+
|
|
53
|
+
const getUrlForFilters = (data?: Query, includePathname: boolean = true): string => {
|
|
54
|
+
const filters = parseQuery({ ...parseSearch(window.location.search), ...(data || {}) });
|
|
55
|
+
return makeUrl(filters, includePathname);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default { getUrlForFilters, makeUrl, parseQuery };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import FormatService from './FormatService';
|
|
2
|
+
|
|
3
|
+
describe('Format Service', () => {
|
|
4
|
+
describe('formatDate', () => {
|
|
5
|
+
const conversions: Record<string, Date | string> = {
|
|
6
|
+
'': '',
|
|
7
|
+
'05/08/1990': new Date(1990, 7, 5),
|
|
8
|
+
'12/12/2012': '2012-12-12',
|
|
9
|
+
'25/12/1999': '1999-12-25 15:00',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const date = new Date(2000, 8, 16, 15, 23);
|
|
13
|
+
|
|
14
|
+
it('should format date corrrectly', () => {
|
|
15
|
+
Object.entries(conversions).map(([expected, actual]) =>
|
|
16
|
+
expect(FormatService.date(actual)).toBe(expected)
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should handle custom formats', () => {
|
|
21
|
+
expect(FormatService.date(date, 'do MMMM yyyy')).toBe('16th September 2000');
|
|
22
|
+
expect(FormatService.date(date, 'd-MMM-yy')).toBe('16-Sep-00');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should handle error', () => {
|
|
26
|
+
expect(FormatService.date('lorem-ipsum')).toBe('');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('formatDatetime', () => {
|
|
31
|
+
it('should format datetime correctly', () => {
|
|
32
|
+
const date = new Date(2000, 8, 16, 15, 23);
|
|
33
|
+
expect(FormatService.datetime(date)).toBe('16/09/2000 15:23');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('formatMoney', () => {
|
|
38
|
+
const conversions: Record<number | string, string> = {
|
|
39
|
+
'': '',
|
|
40
|
+
0: '£0.00',
|
|
41
|
+
100: '£100.00',
|
|
42
|
+
'-50': '-£50.00',
|
|
43
|
+
123.564: '£123.56',
|
|
44
|
+
123.567: '£123.57',
|
|
45
|
+
1000: '£1,000.00',
|
|
46
|
+
1000000: '£1,000,000.00',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
it('should format money correctly', () => {
|
|
50
|
+
Object.entries(conversions).map(([actual, expected]) =>
|
|
51
|
+
expect(FormatService.money(actual)).toBe(expected)
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should handle an array', () => {
|
|
56
|
+
expect(FormatService.money([])).toBe('');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('twoDigits', () => {
|
|
61
|
+
/* eslint-disable quote-props */
|
|
62
|
+
const conversions: Record<number | string, string> = {
|
|
63
|
+
'': '',
|
|
64
|
+
0: '00',
|
|
65
|
+
'10': '10',
|
|
66
|
+
'-5': '-05',
|
|
67
|
+
'6': '06',
|
|
68
|
+
7: '07',
|
|
69
|
+
1000: '1000',
|
|
70
|
+
};
|
|
71
|
+
/* eslint-enable */
|
|
72
|
+
|
|
73
|
+
it('should format two digits correctly', () => {
|
|
74
|
+
Object.entries(conversions).map(([actual, expected]) =>
|
|
75
|
+
expect(FormatService.twoDigits(actual)).toBe(expected)
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should handle an array', () => {
|
|
80
|
+
expect(FormatService.twoDigits([])).toBe('');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { format as fnsFormat, parseISO } from 'date-fns';
|
|
2
|
+
|
|
3
|
+
const TWO_DIGITS = 10;
|
|
4
|
+
|
|
5
|
+
const formatDate = (value?: unknown, formatString: string = 'dd/MM/Y'): string => {
|
|
6
|
+
if (!value || (typeof value !== 'string' && !(value instanceof Date))) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const parsed = typeof value === 'string' ? parseISO(value) : value;
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
return fnsFormat(parsed, formatString);
|
|
14
|
+
} catch (err) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const formatDatetime = (value?: unknown): string => formatDate(value, 'dd/MM/Y HH:mm');
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line prefer-named-capture-group
|
|
22
|
+
const addCommas = (value: string): string => value.replace(/(\d)(?=(\d{3})+(?!\d))/gu, '$1,');
|
|
23
|
+
|
|
24
|
+
const formatMoney = (value?: unknown): string => {
|
|
25
|
+
if (!value || (typeof value !== 'string' && typeof value !== 'number')) {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const isNegative = value.toString().startsWith('-');
|
|
30
|
+
const numberValue = isNegative ? value.toString().substring(1) : value.toString();
|
|
31
|
+
|
|
32
|
+
return `${isNegative ? '-' : ''}£${addCommas(parseFloat(numberValue).toFixed(2))}`;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const formatTwoDigits = (value?: unknown): string => {
|
|
36
|
+
if (!value || (typeof value !== 'string' && typeof value !== 'number')) {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const isNegative = value.toString().startsWith('-');
|
|
41
|
+
const numberValue = isNegative ? value.toString().substring(1) : value.toString();
|
|
42
|
+
|
|
43
|
+
return `${isNegative ? '-' : ''}${
|
|
44
|
+
parseInt(numberValue, 10) < TWO_DIGITS ? '0' : ''
|
|
45
|
+
}${numberValue}`;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const FormatService = {
|
|
49
|
+
date: formatDate,
|
|
50
|
+
datetime: formatDatetime,
|
|
51
|
+
money: formatMoney,
|
|
52
|
+
twoDigits: formatTwoDigits,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default FormatService;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { waitFor } from '@testing-library/react';
|
|
2
|
+
import ToastService from './ToastService';
|
|
3
|
+
|
|
4
|
+
import { EventService } from '@sqrzro/utility';
|
|
5
|
+
|
|
6
|
+
describe('ToastService', () => {
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
(EventService.publish as jest.Mock).mockClear();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should success', async () => {
|
|
12
|
+
expect(EventService.publish).toHaveBeenCalledTimes(0);
|
|
13
|
+
|
|
14
|
+
ToastService.success('lorem');
|
|
15
|
+
expect(EventService.publish).toHaveBeenCalledTimes(1);
|
|
16
|
+
expect(EventService.publish).toHaveBeenLastCalledWith('@toast/send', {});
|
|
17
|
+
|
|
18
|
+
await waitFor(() => {
|
|
19
|
+
expect(EventService.publish).toHaveBeenCalledTimes(2);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(EventService.publish).toHaveBeenLastCalledWith('@toast/send', {
|
|
23
|
+
type: 'success',
|
|
24
|
+
message: 'lorem',
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should error', async () => {
|
|
29
|
+
expect(EventService.publish).toHaveBeenCalledTimes(0);
|
|
30
|
+
|
|
31
|
+
ToastService.error('lorem');
|
|
32
|
+
expect(EventService.publish).toHaveBeenCalledTimes(1);
|
|
33
|
+
expect(EventService.publish).toHaveBeenLastCalledWith('@toast/send', {});
|
|
34
|
+
|
|
35
|
+
await waitFor(() => {
|
|
36
|
+
expect(EventService.publish).toHaveBeenCalledTimes(2);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
expect(EventService.publish).toHaveBeenLastCalledWith('@toast/send', {
|
|
40
|
+
type: 'error',
|
|
41
|
+
message: 'lorem',
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EventService } from '@sqrzro/utility';
|
|
2
|
+
|
|
3
|
+
const INTERVAL = 200;
|
|
4
|
+
|
|
5
|
+
const send = (type: string, message: string): void => {
|
|
6
|
+
EventService.publish('@toast/send', {});
|
|
7
|
+
|
|
8
|
+
setTimeout(() => {
|
|
9
|
+
EventService.publish('@toast/send', { type, message });
|
|
10
|
+
}, INTERVAL);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const success = (message: string): void => send('success', message);
|
|
14
|
+
|
|
15
|
+
const error = (message: string): void => send('error', message);
|
|
16
|
+
|
|
17
|
+
const ToastService = { success, error };
|
|
18
|
+
|
|
19
|
+
export default ToastService;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
*,
|
|
2
|
+
*::before,
|
|
3
|
+
*::after {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
html {
|
|
8
|
+
font-size: 62.5%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
body {
|
|
12
|
+
background-color: var(--clr-grey200);
|
|
13
|
+
color: var(--clr-grey800);
|
|
14
|
+
font-family: var(--ff-body);
|
|
15
|
+
font-size: var(--fs-med);
|
|
16
|
+
line-height: var(--lh-body);
|
|
17
|
+
overflow-y: scroll;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
h1,
|
|
21
|
+
h2,
|
|
22
|
+
h3,
|
|
23
|
+
h4,
|
|
24
|
+
h5,
|
|
25
|
+
h6,
|
|
26
|
+
p {
|
|
27
|
+
margin: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
ul,
|
|
31
|
+
ol,
|
|
32
|
+
dl {
|
|
33
|
+
list-style: none;
|
|
34
|
+
margin-bottom: 0;
|
|
35
|
+
margin-top: 0;
|
|
36
|
+
padding-left: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
dd {
|
|
40
|
+
margin-left: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
a {
|
|
44
|
+
color: var(--clr-link);
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
font-weight: var(--fw-bold);
|
|
47
|
+
text-decoration: none;
|
|
48
|
+
|
|
49
|
+
&:hover {
|
|
50
|
+
color: var(--clr-link-hover);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fieldset {
|
|
55
|
+
border: 0;
|
|
56
|
+
margin: 0;
|
|
57
|
+
padding: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
hr {
|
|
61
|
+
border: 0;
|
|
62
|
+
border-top: .1rem var(--clr-grey300) solid;
|
|
63
|
+
margin: 3rem 0;
|
|
64
|
+
}
|