@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,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import useLayout from './useLayout';
|
|
3
|
+
|
|
4
|
+
describe('useLayout', () => {
|
|
5
|
+
it('should return the layout', () => {
|
|
6
|
+
jest.spyOn(React, 'useContext').mockImplementationOnce(() => ({
|
|
7
|
+
style: { layout: 'lorem' },
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
const { layout } = useLayout();
|
|
11
|
+
expect(layout).toBe('lorem');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should apply classnames', () => {
|
|
15
|
+
jest.spyOn(React, 'useContext').mockImplementationOnce(() => ({
|
|
16
|
+
style: { layout: 'lorem' },
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const styles = { rootLorem: 'lorem' };
|
|
20
|
+
const { applyLayoutClassName } = useLayout();
|
|
21
|
+
|
|
22
|
+
expect(applyLayoutClassName(styles)).toEqual('lorem');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should not apply classnames if no style', () => {
|
|
26
|
+
jest.spyOn(React, 'useContext').mockImplementationOnce(() => ({}));
|
|
27
|
+
|
|
28
|
+
const styles = { rootLorem: 'lorem' };
|
|
29
|
+
const { applyLayoutClassName } = useLayout();
|
|
30
|
+
|
|
31
|
+
expect(applyLayoutClassName(styles)).toEqual(null);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should not apply classnames if no layout', () => {
|
|
35
|
+
jest.spyOn(React, 'useContext').mockImplementationOnce(() => ({
|
|
36
|
+
style: {},
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
const styles = { rootLorem: 'lorem' };
|
|
40
|
+
const { applyLayoutClassName } = useLayout();
|
|
41
|
+
|
|
42
|
+
expect(applyLayoutClassName(styles)).toEqual(null);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should not apply classnames if no styles', () => {
|
|
46
|
+
jest.spyOn(React, 'useContext').mockImplementationOnce(() => ({
|
|
47
|
+
style: { layout: 'lorem' },
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
const styles = {};
|
|
51
|
+
const { applyLayoutClassName } = useLayout();
|
|
52
|
+
|
|
53
|
+
expect(applyLayoutClassName(styles)).toEqual(null);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ucwords } from '@sqrzro/utility';
|
|
2
|
+
|
|
3
|
+
import useAppContext from '@hooks/useAppContext';
|
|
4
|
+
|
|
5
|
+
interface UseLayoutReturn {
|
|
6
|
+
layout: string | null;
|
|
7
|
+
applyLayoutClassName: (styles: Record<string, string>, prefix?: string) => string | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const useLayout = (): UseLayoutReturn => {
|
|
11
|
+
const { style } = useAppContext();
|
|
12
|
+
|
|
13
|
+
const applyLayoutClassName = (
|
|
14
|
+
styles: Record<string, string>,
|
|
15
|
+
prefix = 'root'
|
|
16
|
+
): string | null => {
|
|
17
|
+
const layout = style?.layout;
|
|
18
|
+
|
|
19
|
+
if (!layout) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return styles[`${prefix}${ucwords(layout)}`] || null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return { layout: style?.layout || null, applyLayoutClassName };
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default useLayout;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
import Button from '@components/Button';
|
|
6
|
+
|
|
7
|
+
import useModal from './useModal';
|
|
8
|
+
|
|
9
|
+
interface WrapProps {
|
|
10
|
+
options?: { onClose?: React.MouseEventHandler<HTMLButtonElement> };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Wrap: React.FunctionComponent<WrapProps> = ({ options }) => {
|
|
14
|
+
const { closeModal, Modal, openModal } = useModal(options);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div>
|
|
18
|
+
<Button onClick={openModal}>Open Modal</Button>
|
|
19
|
+
<Button onClick={closeModal}>Close Modal</Button>
|
|
20
|
+
<Modal>Modal Content</Modal>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe('useModal', () => {
|
|
26
|
+
it('should not render if not open', () => {
|
|
27
|
+
render(<Wrap />);
|
|
28
|
+
expect(screen.queryByText('Modal Content')).not.toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should render if open', () => {
|
|
32
|
+
render(<Wrap />);
|
|
33
|
+
userEvent.click(screen.getByRole('button', { name: 'Open Modal' }));
|
|
34
|
+
expect(screen.getByText('Modal Content')).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should handle closing from modal', () => {
|
|
38
|
+
const mockFn = jest.fn();
|
|
39
|
+
render(<Wrap options={{ onClose: mockFn }} />);
|
|
40
|
+
|
|
41
|
+
userEvent.click(screen.getByRole('button', { name: 'Open Modal' }));
|
|
42
|
+
userEvent.click(screen.getByRole('button', { name: 'Close' }));
|
|
43
|
+
|
|
44
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should handle closing from modal (empty options)', () => {
|
|
48
|
+
const mockFn = jest.fn();
|
|
49
|
+
render(<Wrap />);
|
|
50
|
+
|
|
51
|
+
userEvent.click(screen.getByRole('button', { name: 'Open Modal' }));
|
|
52
|
+
userEvent.click(screen.getByRole('button', { name: 'Close' }));
|
|
53
|
+
|
|
54
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should handle closing from outside modal', () => {
|
|
58
|
+
render(<Wrap />);
|
|
59
|
+
userEvent.click(screen.getByRole('button', { name: 'Open Modal' }));
|
|
60
|
+
userEvent.click(screen.getByRole('button', { name: 'Close Modal' }));
|
|
61
|
+
expect(screen.queryByText('Modal Content')).not.toBeInTheDocument();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createElement, useCallback, useLayoutEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import Modal from '@core/Modal';
|
|
4
|
+
import type { ModalProps } from '@core/Modal';
|
|
5
|
+
|
|
6
|
+
interface UseModalOptions {
|
|
7
|
+
onClose?: React.MouseEventHandler<HTMLButtonElement>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface UseModalReturn {
|
|
11
|
+
closeModal: () => void;
|
|
12
|
+
Modal: React.FunctionComponent<ModalProps>;
|
|
13
|
+
openModal: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const useModal = (options?: UseModalOptions): UseModalReturn => {
|
|
17
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
18
|
+
const [offset, setOffset] = useState(0);
|
|
19
|
+
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
/*
|
|
22
|
+
* Using document body in jest is complex. This can be ignored by test coverage for now.
|
|
23
|
+
*/
|
|
24
|
+
/* istanbul ignore next */
|
|
25
|
+
if (document.body.firstChild) {
|
|
26
|
+
const wrap = document.body.firstChild as HTMLDivElement;
|
|
27
|
+
setOffset(window.innerWidth - wrap.offsetWidth);
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
/*
|
|
33
|
+
* Using document body in jest is complex. This can be ignored by test coverage for now.
|
|
34
|
+
*/
|
|
35
|
+
/* istanbul ignore next */
|
|
36
|
+
if (document.body.firstChild) {
|
|
37
|
+
document.body.style.overflowY = isOpen ? 'hidden' : 'scroll';
|
|
38
|
+
const wrap = document.body.firstChild as HTMLDivElement;
|
|
39
|
+
wrap.style.marginRight = isOpen ? `${offset}px` : '0';
|
|
40
|
+
}
|
|
41
|
+
}, [isOpen]);
|
|
42
|
+
|
|
43
|
+
const handleClose = (event: React.MouseEvent<HTMLButtonElement>): void => {
|
|
44
|
+
setIsOpen(false);
|
|
45
|
+
|
|
46
|
+
if (options?.onClose) {
|
|
47
|
+
options.onClose(event);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const modalProps: ModalProps = { children: false, isOpen, onClose: handleClose };
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
closeModal: (): void => setIsOpen(false),
|
|
55
|
+
Modal: useCallback((props) => createElement(Modal, { ...modalProps, ...props }), [isOpen]),
|
|
56
|
+
openModal: (): void => setIsOpen(true),
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default useModal;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import useVariant from './useVariant';
|
|
2
|
+
|
|
3
|
+
describe('useVariant', () => {
|
|
4
|
+
it('should handle nullable variants', () => {
|
|
5
|
+
type NullableVariant = 'lorem' | null;
|
|
6
|
+
|
|
7
|
+
const styles = { rootLorem: 'lorem' };
|
|
8
|
+
const variant: NullableVariant[] = ['lorem', null];
|
|
9
|
+
const { applyVariantClassName } = useVariant<NullableVariant>(variant);
|
|
10
|
+
|
|
11
|
+
const className = applyVariantClassName(styles);
|
|
12
|
+
expect(className).toBe('lorem');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isString, isStringArray } from '@utility/interfaces';
|
|
2
|
+
import type { StyleVariant } from '@utility/interfaces';
|
|
3
|
+
|
|
4
|
+
import { ucwords } from '@sqrzro/utility';
|
|
5
|
+
|
|
6
|
+
interface UseVariantReturn {
|
|
7
|
+
applyVariantClassName: (styles: Record<string, string>, prefix?: string) => string | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const useVariant = <T = StyleVariant>(variant?: T | T[]): UseVariantReturn => {
|
|
11
|
+
const applyVariantClassName = (
|
|
12
|
+
styles: Record<string, string>,
|
|
13
|
+
prefix = 'root'
|
|
14
|
+
): string | null => {
|
|
15
|
+
if (!variant || (!isString(variant) && !isStringArray(variant))) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!Array.isArray(variant)) {
|
|
20
|
+
return styles[`${prefix}${ucwords(variant)}`];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const orderedVariant = variant
|
|
24
|
+
.map((item) => ucwords(isString(item) ? item : ''))
|
|
25
|
+
.sort((first, second) => first.localeCompare(second))
|
|
26
|
+
.join('');
|
|
27
|
+
|
|
28
|
+
return styles[`${prefix}${orderedVariant}`];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return { applyVariantClassName };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default useVariant;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file has been generated by 'scripts/create-exports'.
|
|
3
|
+
* Any changes made directly to this file will be overwritten.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import 'regenerator-runtime/runtime.js';
|
|
7
|
+
|
|
8
|
+
export * from './utility/interfaces';
|
|
9
|
+
export { default as createApp } from './utility/create-app';
|
|
10
|
+
|
|
11
|
+
export { ApiService, AuthService, EventService, StorageService } from '@sqrzro/utility';
|
|
12
|
+
export * from './components/Alert';
|
|
13
|
+
export { default as Alert } from './components/Alert';
|
|
14
|
+
export * from './components/Allow';
|
|
15
|
+
export { default as Allow } from './components/Allow';
|
|
16
|
+
export * from './components/App';
|
|
17
|
+
export { default as App } from './components/App';
|
|
18
|
+
export * from './components/AutoSuggest';
|
|
19
|
+
export { default as AutoSuggest } from './components/AutoSuggest';
|
|
20
|
+
export * from './components/Button';
|
|
21
|
+
export { default as Button } from './components/Button';
|
|
22
|
+
export * from './components/CalendarInput';
|
|
23
|
+
export { default as CalendarInput } from './components/CalendarInput';
|
|
24
|
+
export * from './components/CheckboxList';
|
|
25
|
+
export { default as CheckboxList } from './components/CheckboxList';
|
|
26
|
+
export * from './components/ConnectedDropdown';
|
|
27
|
+
export { default as ConnectedDropdown } from './components/ConnectedDropdown';
|
|
28
|
+
export * from './components/ConnectedList';
|
|
29
|
+
export { default as ConnectedList } from './components/ConnectedList';
|
|
30
|
+
export * from './components/ConnectedScene';
|
|
31
|
+
export { default as ConnectedScene } from './components/ConnectedScene';
|
|
32
|
+
export * from './components/ConnectedTable';
|
|
33
|
+
export { default as ConnectedTable } from './components/ConnectedTable';
|
|
34
|
+
export * from './components/ContentBlock';
|
|
35
|
+
export { default as ContentBlock } from './components/ContentBlock';
|
|
36
|
+
export * from './components/DateInput';
|
|
37
|
+
export { default as DateInput } from './components/DateInput';
|
|
38
|
+
export * from './components/Document';
|
|
39
|
+
export { default as Document } from './components/Document';
|
|
40
|
+
export * from './components/Dropdown';
|
|
41
|
+
export { default as Dropdown } from './components/Dropdown';
|
|
42
|
+
export * from './components/Fieldset';
|
|
43
|
+
export { default as Fieldset } from './components/Fieldset';
|
|
44
|
+
export * from './components/FileInput';
|
|
45
|
+
export { default as FileInput } from './components/FileInput';
|
|
46
|
+
export * from './components/FilterLink';
|
|
47
|
+
export { default as FilterLink } from './components/FilterLink';
|
|
48
|
+
export * from './components/Form';
|
|
49
|
+
export { default as Form } from './components/Form';
|
|
50
|
+
export * from './components/FormActions';
|
|
51
|
+
export { default as FormActions } from './components/FormActions';
|
|
52
|
+
export * from './components/FormField';
|
|
53
|
+
export { default as FormField } from './components/FormField';
|
|
54
|
+
export * from './components/FormRepeater';
|
|
55
|
+
export { default as FormRepeater } from './components/FormRepeater';
|
|
56
|
+
export * from './components/ImageInput';
|
|
57
|
+
export { default as ImageInput } from './components/ImageInput';
|
|
58
|
+
export * from './components/InfoPanel';
|
|
59
|
+
export { default as InfoPanel } from './components/InfoPanel';
|
|
60
|
+
export * from './components/Link';
|
|
61
|
+
export { default as Link } from './components/Link';
|
|
62
|
+
export * from './components/List';
|
|
63
|
+
export { default as List } from './components/List';
|
|
64
|
+
export * from './components/ListActions';
|
|
65
|
+
export { default as ListActions } from './components/ListActions';
|
|
66
|
+
export * from './components/LoginForm';
|
|
67
|
+
export { default as LoginForm } from './components/LoginForm';
|
|
68
|
+
export * from './components/Message';
|
|
69
|
+
export { default as Message } from './components/Message';
|
|
70
|
+
export * from './components/ModalActions';
|
|
71
|
+
export { default as ModalActions } from './components/ModalActions';
|
|
72
|
+
export * from './components/MoneyInput';
|
|
73
|
+
export { default as MoneyInput } from './components/MoneyInput';
|
|
74
|
+
export * from './components/PasswordForm';
|
|
75
|
+
export { default as PasswordForm } from './components/PasswordForm';
|
|
76
|
+
export * from './components/PasswordInput';
|
|
77
|
+
export { default as PasswordInput } from './components/PasswordInput';
|
|
78
|
+
export * from './components/RadioList';
|
|
79
|
+
export { default as RadioList } from './components/RadioList';
|
|
80
|
+
export * from './components/Scene';
|
|
81
|
+
export { default as Scene } from './components/Scene';
|
|
82
|
+
export * from './components/SummaryList';
|
|
83
|
+
export { default as SummaryList } from './components/SummaryList';
|
|
84
|
+
export * from './components/Switch';
|
|
85
|
+
export { default as Switch } from './components/Switch';
|
|
86
|
+
export * from './components/Table';
|
|
87
|
+
export { default as Table } from './components/Table';
|
|
88
|
+
export * from './components/Tag';
|
|
89
|
+
export { default as Tag } from './components/Tag';
|
|
90
|
+
export * from './components/TextArea';
|
|
91
|
+
export { default as TextArea } from './components/TextArea';
|
|
92
|
+
export * from './components/TextInput';
|
|
93
|
+
export { default as TextInput } from './components/TextInput';
|
|
94
|
+
export * from './components/WebsiteInput';
|
|
95
|
+
export { default as WebsiteInput } from './components/WebsiteInput';
|
|
96
|
+
export * from './components/WeekCalendar';
|
|
97
|
+
export { default as WeekCalendar } from './components/WeekCalendar';
|
|
98
|
+
export * from './core/AppHeader';
|
|
99
|
+
export * from './core/AppLogo';
|
|
100
|
+
export * from './core/AppLogoImage';
|
|
101
|
+
export * from './core/AppLogoPlaceholder';
|
|
102
|
+
export * from './core/Assistive';
|
|
103
|
+
export * from './core/Banner';
|
|
104
|
+
export * from './core/BuildModal';
|
|
105
|
+
export * from './core/Calendar';
|
|
106
|
+
export * from './core/CalendarDay';
|
|
107
|
+
export * from './core/CalendarMonth';
|
|
108
|
+
export * from './core/CalendarNavigation';
|
|
109
|
+
export * from './core/CalendarWeek';
|
|
110
|
+
export * from './core/ChkRad';
|
|
111
|
+
export * from './core/ChkRadIcon';
|
|
112
|
+
export * from './core/ChkRadList';
|
|
113
|
+
export * from './core/CloseButton';
|
|
114
|
+
export * from './core/ConfirmModal';
|
|
115
|
+
export * from './core/ConnectedRepeater';
|
|
116
|
+
export * from './core/ConnectedRepeaterComponent';
|
|
117
|
+
export * from './core/Container';
|
|
118
|
+
export * from './core/DropdownPanel';
|
|
119
|
+
export * from './core/EmptyMessage';
|
|
120
|
+
export * from './core/ErrorBoundary';
|
|
121
|
+
export * from './core/ErrorMessage';
|
|
122
|
+
export * from './core/FilterItem';
|
|
123
|
+
export * from './core/Filters';
|
|
124
|
+
export * from './core/FixedActions';
|
|
125
|
+
export * from './core/FormError';
|
|
126
|
+
export * from './core/FormLabel';
|
|
127
|
+
export * from './core/FormLegend';
|
|
128
|
+
export * from './core/Header';
|
|
129
|
+
export * from './core/Icon';
|
|
130
|
+
export * from './core/IconButton';
|
|
131
|
+
export * from './core/InputPanel';
|
|
132
|
+
export * from './core/ListItem';
|
|
133
|
+
export * from './core/ListItemAction';
|
|
134
|
+
export * from './core/ListItemActions';
|
|
135
|
+
export * from './core/ListItemMetaItem';
|
|
136
|
+
export * from './core/ListItemTitle';
|
|
137
|
+
export * from './core/Loader';
|
|
138
|
+
export * from './core/MeActions';
|
|
139
|
+
export * from './core/MePanel';
|
|
140
|
+
export * from './core/Modal';
|
|
141
|
+
export * from './core/Navigation';
|
|
142
|
+
export * from './core/NavigationDivider';
|
|
143
|
+
export * from './core/NavigationItem';
|
|
144
|
+
export * from './core/Pagination';
|
|
145
|
+
export * from './core/PaginationItem';
|
|
146
|
+
export * from './core/Panel';
|
|
147
|
+
export * from './core/RadialProgress';
|
|
148
|
+
export * from './core/StaticTextInput';
|
|
149
|
+
export * from './core/Styled';
|
|
150
|
+
export * from './core/SummaryListItem';
|
|
151
|
+
export * from './core/TableActionsCell';
|
|
152
|
+
export * from './core/TableCell';
|
|
153
|
+
export * from './core/TableHead';
|
|
154
|
+
export * from './core/TableRow';
|
|
155
|
+
export * from './core/Tabs';
|
|
156
|
+
export * from './core/TextInputAncillary';
|
|
157
|
+
export * from './core/Toast';
|
|
158
|
+
export * from './core/WeekCalendarDay';
|
|
159
|
+
export * from './hooks/useAccessiblePanel';
|
|
160
|
+
export { default as useAccessiblePanel } from './hooks/useAccessiblePanel';
|
|
161
|
+
export * from './hooks/useAppContext';
|
|
162
|
+
export { default as useAppContext } from './hooks/useAppContext';
|
|
163
|
+
export * from './hooks/useClickOutside';
|
|
164
|
+
export { default as useClickOutside } from './hooks/useClickOutside';
|
|
165
|
+
export * from './hooks/useConnectedList';
|
|
166
|
+
export { default as useConnectedList } from './hooks/useConnectedList';
|
|
167
|
+
export * from './hooks/useFilters';
|
|
168
|
+
export { default as useFilters } from './hooks/useFilters';
|
|
169
|
+
export * from './hooks/useForm';
|
|
170
|
+
export { default as useForm } from './hooks/useForm';
|
|
171
|
+
export * from './hooks/useFormData';
|
|
172
|
+
export { default as useFormData } from './hooks/useFormData';
|
|
173
|
+
export * from './hooks/useLayout';
|
|
174
|
+
export { default as useLayout } from './hooks/useLayout';
|
|
175
|
+
export * from './hooks/useModal';
|
|
176
|
+
export { default as useModal } from './hooks/useModal';
|
|
177
|
+
export * from './hooks/useVariant';
|
|
178
|
+
export { default as useVariant } from './hooks/useVariant';
|
|
179
|
+
export * from './services/BuildService';
|
|
180
|
+
export { default as BuildService } from './services/BuildService';
|
|
181
|
+
export * from './services/ConfirmService';
|
|
182
|
+
export { default as ConfirmService } from './services/ConfirmService';
|
|
183
|
+
export * from './services/DateService';
|
|
184
|
+
export { default as DateService } from './services/DateService';
|
|
185
|
+
export * from './services/DownloadService';
|
|
186
|
+
export { default as DownloadService } from './services/DownloadService';
|
|
187
|
+
export * from './services/FilterComponentService';
|
|
188
|
+
export { default as FilterComponentService } from './services/FilterComponentService';
|
|
189
|
+
export * from './services/FilterService';
|
|
190
|
+
export { default as FilterService } from './services/FilterService';
|
|
191
|
+
export * from './services/FormatService';
|
|
192
|
+
export { default as FormatService } from './services/FormatService';
|
|
193
|
+
export * from './services/ToastService';
|
|
194
|
+
export { default as ToastService } from './services/ToastService';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ApiService, EventService, StorageService } from '@sqrzro/utility';
|
|
2
|
+
|
|
3
|
+
import BuildService from './BuildService';
|
|
4
|
+
|
|
5
|
+
describe('BuildService', () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
(EventService.publish as jest.Mock).mockClear();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should open', () => {
|
|
11
|
+
expect(EventService.publish).toHaveBeenCalledTimes(0);
|
|
12
|
+
BuildService.open();
|
|
13
|
+
expect(EventService.publish).toHaveBeenCalledTimes(1);
|
|
14
|
+
expect(EventService.publish).toHaveBeenLastCalledWith('@build/open');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should start with hash error', async () => {
|
|
18
|
+
jest.spyOn(ApiService, 'get').mockImplementationOnce(() => {
|
|
19
|
+
throw new Error('lorem');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(EventService.publish).toHaveBeenCalledTimes(0);
|
|
23
|
+
await BuildService.start();
|
|
24
|
+
expect(EventService.publish).toHaveBeenCalledTimes(2);
|
|
25
|
+
expect(EventService.publish).toHaveBeenCalledWith('@build/status', 'PENDING');
|
|
26
|
+
expect(EventService.publish).toHaveBeenCalledWith('@build/status', 'ERROR');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should start with hash success, poll error', async () => {
|
|
30
|
+
// @ts-expect-error APIResponse not being available
|
|
31
|
+
jest.spyOn(ApiService, 'get').mockImplementationOnce(() => ({ data: { hash: 'lorem' } }));
|
|
32
|
+
|
|
33
|
+
jest.spyOn(ApiService, 'pollForResponse').mockImplementationOnce(() => {
|
|
34
|
+
throw new Error('lorem');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await BuildService.start();
|
|
38
|
+
expect(StorageService.set).toHaveBeenCalledTimes(1);
|
|
39
|
+
expect(StorageService.set).toHaveBeenLastCalledWith('build_hash', 'lorem');
|
|
40
|
+
|
|
41
|
+
expect(StorageService.remove).toHaveBeenCalledTimes(1);
|
|
42
|
+
expect(StorageService.remove).toHaveBeenLastCalledWith('build_hash');
|
|
43
|
+
|
|
44
|
+
expect(EventService.publish).toHaveBeenCalledTimes(2);
|
|
45
|
+
expect(EventService.publish).toHaveBeenCalledWith('@build/status', 'ERROR');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should start with success', async () => {
|
|
49
|
+
// @ts-expect-error APIResponse not being available
|
|
50
|
+
jest.spyOn(ApiService, 'get').mockImplementationOnce(() => ({ data: { hash: 'lorem' } }));
|
|
51
|
+
|
|
52
|
+
await BuildService.start();
|
|
53
|
+
expect(EventService.publish).toHaveBeenCalledTimes(2);
|
|
54
|
+
expect(EventService.publish).toHaveBeenCalledWith('@build/status', 'SUCCESS');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ApiService, EventService, StorageService } from '@sqrzro/utility';
|
|
2
|
+
|
|
3
|
+
const start = async (): Promise<void> => {
|
|
4
|
+
EventService.publish('@build/status', 'PENDING');
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
const response = await ApiService.get<{ hash: string }>('build');
|
|
8
|
+
|
|
9
|
+
StorageService.set('build_hash', response.data.hash);
|
|
10
|
+
} catch (err) {
|
|
11
|
+
EventService.publish('@build/status', 'ERROR');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
await ApiService.pollForResponse([
|
|
17
|
+
'build/status',
|
|
18
|
+
{
|
|
19
|
+
hash: StorageService.get('build_hash'),
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
EventService.publish('@build/status', 'SUCCESS');
|
|
23
|
+
} catch (err) {
|
|
24
|
+
EventService.publish('@build/status', 'ERROR');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
StorageService.remove('build_hash');
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const open = (): boolean => EventService.publish('@build/open');
|
|
31
|
+
|
|
32
|
+
const BuildService = { start, open };
|
|
33
|
+
|
|
34
|
+
export default BuildService;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { EventService } from '@sqrzro/utility';
|
|
3
|
+
|
|
4
|
+
export interface ConfirmModalData {
|
|
5
|
+
description: ReactNode;
|
|
6
|
+
label?: string;
|
|
7
|
+
onConfirm?: () => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ConfirmObject {
|
|
11
|
+
ask: (data: ConfirmModalData) => boolean;
|
|
12
|
+
close: () => boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const ask = (data: ConfirmModalData): boolean => EventService.publish('@confirm/send', data);
|
|
16
|
+
|
|
17
|
+
const close = (): boolean => EventService.publish('@confirm/send', null);
|
|
18
|
+
|
|
19
|
+
const ConfirmService: ConfirmObject = { ask, close };
|
|
20
|
+
|
|
21
|
+
export default ConfirmService;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import MockDate from 'mockdate';
|
|
2
|
+
|
|
3
|
+
import DateService from './DateService';
|
|
4
|
+
|
|
5
|
+
describe('DateService', () => {
|
|
6
|
+
it('should addMonths', () => {
|
|
7
|
+
expect(DateService.addMonths('2020-01', 4)).toBe('2020-05');
|
|
8
|
+
expect(DateService.addMonths('1946-07', 12)).toBe('1947-07');
|
|
9
|
+
expect(DateService.addMonths('2050-02', 1)).toBe('2050-03');
|
|
10
|
+
expect(DateService.addMonths('2021-02', 0)).toBe('2021-02');
|
|
11
|
+
expect(DateService.addMonths('lorem', 5)).toBe('');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should getDaysInMonth', () => {
|
|
15
|
+
expect(DateService.getDaysInMonth('2020-01')).toBe(31);
|
|
16
|
+
expect(DateService.getDaysInMonth('2020-02')).toBe(29);
|
|
17
|
+
expect(DateService.getDaysInMonth('1950-09')).toBe(30);
|
|
18
|
+
expect(DateService.getDaysInMonth('lorem')).toBe(-1);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should getDayOfWeek', () => {
|
|
22
|
+
expect(DateService.getDayOfWeek('1987-04-18')).toBe(5);
|
|
23
|
+
expect(DateService.getDayOfWeek('2018-06-17')).toBe(6);
|
|
24
|
+
expect(DateService.getDayOfWeek('2028-05-18')).toBe(3);
|
|
25
|
+
expect(DateService.getDayOfWeek('2045-08-07')).toBe(0);
|
|
26
|
+
expect(DateService.getDayOfWeek('2046-01-02')).toBe(1);
|
|
27
|
+
expect(DateService.getDayOfWeek('lorem')).toBe(-1);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should getDays', () => {
|
|
31
|
+
const days = DateService.getDays();
|
|
32
|
+
|
|
33
|
+
expect(days[0]).toEqual({ id: 1, name: '1' });
|
|
34
|
+
expect(days[17]).toEqual({ id: 18, name: '18' });
|
|
35
|
+
expect(days[40]).toBeUndefined();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should getMonths', () => {
|
|
39
|
+
const months = DateService.getMonths();
|
|
40
|
+
|
|
41
|
+
expect(months[0]).toEqual({ id: 1, name: 'January' });
|
|
42
|
+
expect(months[7]).toEqual({ id: 8, name: 'August' });
|
|
43
|
+
expect(months[14]).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should getQuickDates', () => {
|
|
47
|
+
MockDate.set('2000-11-22');
|
|
48
|
+
const dates = DateService.getQuickDates();
|
|
49
|
+
|
|
50
|
+
expect(dates[0]).toEqual({ id: '2000-11-22,2000-11-22', name: 'Today' });
|
|
51
|
+
expect(dates[1]).toEqual({ id: '2000-11-21,2000-11-21', name: 'Yesterday' });
|
|
52
|
+
expect(dates[2]).toEqual({ id: '2000-11-15,2000-11-22', name: 'Last 7 Days' });
|
|
53
|
+
expect(dates[3]).toEqual({ id: '2000-10-23,2000-11-22', name: 'Last 30 Days' });
|
|
54
|
+
expect(dates[4]).toEqual({ id: '2000-11-01,2000-11-22', name: 'This Month' });
|
|
55
|
+
expect(dates[5]).toEqual({ id: '2000-10-01,2000-10-31', name: 'Last Month' });
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('should getYears', () => {
|
|
59
|
+
it('should get default years', () => {
|
|
60
|
+
MockDate.set('2021-11-22');
|
|
61
|
+
const years = DateService.getYears();
|
|
62
|
+
|
|
63
|
+
expect(years[0]).toEqual({ id: 2021, name: '2021' });
|
|
64
|
+
expect(years[17]).toEqual({ id: 2004, name: '2004' });
|
|
65
|
+
expect(years[200]).toBeUndefined();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should get custom years', () => {
|
|
69
|
+
expect(DateService.getYears(2000, 2016)[3]).toEqual({ id: 2013, name: '2013' });
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe('should isToday', () => {
|
|
74
|
+
MockDate.set('2000-11-22');
|
|
75
|
+
expect(DateService.isToday('2000-11-22')).toBe(true);
|
|
76
|
+
expect(DateService.isToday('2001-11-22')).toBe(false);
|
|
77
|
+
expect(DateService.isToday('lorem')).toBe(false);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('should subMonths', () => {
|
|
81
|
+
expect(DateService.subMonths('2020-01', 4)).toBe('2019-09');
|
|
82
|
+
expect(DateService.subMonths('1946-07', 12)).toBe('1945-07');
|
|
83
|
+
expect(DateService.subMonths('2050-02', 1)).toBe('2050-01');
|
|
84
|
+
expect(DateService.subMonths('2021-02', 0)).toBe('2021-02');
|
|
85
|
+
expect(DateService.subMonths('lorem', 5)).toBe('');
|
|
86
|
+
});
|
|
87
|
+
});
|