@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,119 @@
|
|
|
1
|
+
import React, { Fragment, useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { EventService } from '@sqrzro/utility';
|
|
4
|
+
|
|
5
|
+
import useAppContext from '@hooks/useAppContext';
|
|
6
|
+
|
|
7
|
+
import BuildService from '@services/BuildService';
|
|
8
|
+
|
|
9
|
+
import Loader from '@core/Loader';
|
|
10
|
+
import Modal from '@core/Modal';
|
|
11
|
+
|
|
12
|
+
import type { SimpleAction } from '@utility/interfaces';
|
|
13
|
+
|
|
14
|
+
interface BuildStatus {
|
|
15
|
+
title: string;
|
|
16
|
+
content: React.ReactNode;
|
|
17
|
+
actions: SimpleAction[] | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface BuildConfig {
|
|
21
|
+
name: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const getStatusMap = (
|
|
25
|
+
config: BuildConfig,
|
|
26
|
+
setOpen: (boolean: boolean) => void
|
|
27
|
+
): Record<string, BuildStatus> => ({
|
|
28
|
+
REQUESTED: {
|
|
29
|
+
title: `Build ${config.name}`,
|
|
30
|
+
content: (
|
|
31
|
+
<Fragment>
|
|
32
|
+
Changes you've made won't appear on the site until you've built them.
|
|
33
|
+
<br />
|
|
34
|
+
<strong>This can take up to a couple of minutes.</strong>
|
|
35
|
+
</Fragment>
|
|
36
|
+
),
|
|
37
|
+
actions: [
|
|
38
|
+
{
|
|
39
|
+
label: 'Build',
|
|
40
|
+
onClick: BuildService.start,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
variant: 'bordered',
|
|
44
|
+
label: 'Cancel',
|
|
45
|
+
onClick: (): void => setOpen(false),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
PENDING: {
|
|
50
|
+
title: `Building ${config.name}...`,
|
|
51
|
+
content: <Loader />,
|
|
52
|
+
actions: null,
|
|
53
|
+
},
|
|
54
|
+
ERROR: {
|
|
55
|
+
title: 'Build Failed',
|
|
56
|
+
content: (
|
|
57
|
+
<Fragment>
|
|
58
|
+
Unfortunately the build has failed. Please try again, and if the problem continues,
|
|
59
|
+
contact the site administrator.
|
|
60
|
+
</Fragment>
|
|
61
|
+
),
|
|
62
|
+
actions: [
|
|
63
|
+
{
|
|
64
|
+
label: 'Try Again',
|
|
65
|
+
onClick: BuildService.start,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
variant: 'bordered',
|
|
69
|
+
label: 'Cancel',
|
|
70
|
+
onClick: (): void => setOpen(false),
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
SUCCESS: {
|
|
75
|
+
title: 'Build Complete',
|
|
76
|
+
content: <Fragment>The build has completed successfully.</Fragment>,
|
|
77
|
+
actions: [
|
|
78
|
+
{
|
|
79
|
+
label: 'Close',
|
|
80
|
+
onClick: (): void => setOpen(false),
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const BuildModal: React.FunctionComponent = () => {
|
|
87
|
+
const config = useAppContext();
|
|
88
|
+
|
|
89
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
90
|
+
const [status, setStatus] = useState('REQUESTED');
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const openSub = EventService.subscribe('@build/open', () => {
|
|
94
|
+
setStatus('REQUESTED');
|
|
95
|
+
setIsOpen(true);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const statusSub = EventService.subscribe<string>('@build/status', (_key, data) => {
|
|
99
|
+
setStatus(data);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return (): void => {
|
|
103
|
+
EventService.unsubscribe(openSub);
|
|
104
|
+
EventService.unsubscribe(statusSub);
|
|
105
|
+
};
|
|
106
|
+
}, []);
|
|
107
|
+
|
|
108
|
+
if (!isOpen) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const statusMap = getStatusMap(config, setIsOpen);
|
|
113
|
+
|
|
114
|
+
const activeStatus: BuildStatus = statusMap[status];
|
|
115
|
+
|
|
116
|
+
return <Modal title={activeStatus.title}>{activeStatus.content}</Modal>;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export default BuildModal;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { Fragment, useEffect, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import CalendarMonth from '@core/CalendarMonth';
|
|
5
|
+
import CalendarNavigation from '@core/CalendarNavigation';
|
|
6
|
+
|
|
7
|
+
import FormatService from '@services/FormatService';
|
|
8
|
+
|
|
9
|
+
import type { SimpleEvent, SimpleEventHandler } from '@utility/interfaces';
|
|
10
|
+
|
|
11
|
+
const getMonthFromDate = (date?: string): string => {
|
|
12
|
+
const dt = new Date();
|
|
13
|
+
const currentMonth = `${dt.getFullYear()}-${FormatService.twoDigits(dt.getMonth() + 1)}`;
|
|
14
|
+
|
|
15
|
+
if (!date) {
|
|
16
|
+
return currentMonth;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// If the date is a range, just use the first date in the range
|
|
20
|
+
|
|
21
|
+
if (/,/u.exec(date)) {
|
|
22
|
+
return getMonthFromDate(date.split(',')[0]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const match = /^(?<month>[0-9]{4}-[0-9]{2})-[0-9]{2}$/u.exec(date);
|
|
26
|
+
|
|
27
|
+
if (!match) {
|
|
28
|
+
return currentMonth;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* istanbul ignore next: No way to test that there is a match, but without any groups */
|
|
32
|
+
return match.groups?.month || currentMonth;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
interface CalendarProps {
|
|
36
|
+
disabledDates?: string[] | ((date: string) => boolean);
|
|
37
|
+
isRange?: boolean;
|
|
38
|
+
name: string;
|
|
39
|
+
onChange: SimpleEventHandler;
|
|
40
|
+
value?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const transformValue = (pendingValue: string, targetValue: string): string =>
|
|
44
|
+
[pendingValue, targetValue].sort((first, second) => first.localeCompare(second)).join(',');
|
|
45
|
+
|
|
46
|
+
const getPendingValue = (pendingValue: string, targetValue: string): string => {
|
|
47
|
+
if (!pendingValue) {
|
|
48
|
+
return targetValue;
|
|
49
|
+
}
|
|
50
|
+
if (!/,/u.exec(pendingValue)) {
|
|
51
|
+
return transformValue(pendingValue, targetValue);
|
|
52
|
+
}
|
|
53
|
+
return targetValue;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const Calendar: React.FunctionComponent<CalendarProps> = ({
|
|
57
|
+
disabledDates,
|
|
58
|
+
isRange,
|
|
59
|
+
name,
|
|
60
|
+
value,
|
|
61
|
+
onChange,
|
|
62
|
+
}) => {
|
|
63
|
+
const [activeMonth, setActiveMonth] = useState(getMonthFromDate(value));
|
|
64
|
+
const [pendingValue, setPendingValue] = useState('');
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
setActiveMonth(getMonthFromDate(value));
|
|
68
|
+
}, [value]);
|
|
69
|
+
|
|
70
|
+
const handleNavigation = (event: SimpleEvent<string>): void => {
|
|
71
|
+
setActiveMonth(event.target.value);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleChange = (event: SimpleEvent<string>): void => {
|
|
75
|
+
if (!isRange) {
|
|
76
|
+
onChange(event);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const pValue = getPendingValue(pendingValue, event.target.value);
|
|
81
|
+
setPendingValue(pValue);
|
|
82
|
+
|
|
83
|
+
if (!/,/u.exec(pValue)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
onChange({ target: { name, value: pValue } });
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<Fragment>
|
|
92
|
+
<CalendarNavigation month={activeMonth} name={name} onChange={handleNavigation} />
|
|
93
|
+
<CalendarMonth
|
|
94
|
+
disabledDates={disabledDates}
|
|
95
|
+
month={activeMonth}
|
|
96
|
+
name={name}
|
|
97
|
+
onClick={handleChange}
|
|
98
|
+
pendingValue={pendingValue}
|
|
99
|
+
value={value}
|
|
100
|
+
/>
|
|
101
|
+
</Fragment>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
Calendar.propTypes = {
|
|
106
|
+
name: PropTypes.string.isRequired,
|
|
107
|
+
onChange: PropTypes.func.isRequired,
|
|
108
|
+
disabledDates: PropTypes.oneOfType([
|
|
109
|
+
PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
110
|
+
PropTypes.func,
|
|
111
|
+
]),
|
|
112
|
+
isRange: PropTypes.bool,
|
|
113
|
+
value: PropTypes.string,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default Calendar;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
color: var(--clr-grey700);
|
|
3
|
+
height: 4rem;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.rootIsHighlighted {
|
|
7
|
+
background-color: var(--clr-primary10);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.rootIsSelected {
|
|
11
|
+
background-color: var(--clr-primary20);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.rootIsToday {
|
|
15
|
+
font-weight: var(--fw-bold);
|
|
16
|
+
position: relative;
|
|
17
|
+
|
|
18
|
+
&::before {
|
|
19
|
+
border: .2rem var(--clr-grey600) solid;
|
|
20
|
+
border-radius: 50%;
|
|
21
|
+
content: '';
|
|
22
|
+
height: 3rem;
|
|
23
|
+
left: calc(50% - 1.5rem);
|
|
24
|
+
position: absolute;
|
|
25
|
+
top: calc(50% - 1.5rem);
|
|
26
|
+
width: 3rem;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.rootIsDisabled {
|
|
31
|
+
background-color: transparent;
|
|
32
|
+
color: var(--clr-grey300);
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.control {
|
|
37
|
+
background: none;
|
|
38
|
+
border: 0;
|
|
39
|
+
color: inherit;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
font-family: inherit;
|
|
42
|
+
font-size: var(--fs-sml);
|
|
43
|
+
font-weight: inherit;
|
|
44
|
+
height: 100%;
|
|
45
|
+
position: relative;
|
|
46
|
+
width: 100%;
|
|
47
|
+
|
|
48
|
+
&:focus {
|
|
49
|
+
outline: none;
|
|
50
|
+
|
|
51
|
+
&::before {
|
|
52
|
+
border: .1rem var(--clr-grey400) solid;
|
|
53
|
+
bottom: .1rem;
|
|
54
|
+
content: '';
|
|
55
|
+
left: .1rem;
|
|
56
|
+
position: absolute;
|
|
57
|
+
right: .1rem;
|
|
58
|
+
top: .1rem;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import type { SimpleEventHandler } from '@utility/interfaces';
|
|
6
|
+
|
|
7
|
+
import DateService from '@services/DateService';
|
|
8
|
+
|
|
9
|
+
import styles from './CalendarDay.module.css';
|
|
10
|
+
|
|
11
|
+
export interface DayObject {
|
|
12
|
+
label: number;
|
|
13
|
+
date: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface CalendarDayProps {
|
|
17
|
+
data: DayObject | number;
|
|
18
|
+
name: string;
|
|
19
|
+
onClick?: SimpleEventHandler<string>;
|
|
20
|
+
isDisabled?: boolean;
|
|
21
|
+
isHighlighted?: boolean;
|
|
22
|
+
isSelected?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const CalendarDay: React.FunctionComponent<CalendarDayProps> = ({
|
|
26
|
+
data,
|
|
27
|
+
isDisabled,
|
|
28
|
+
isHighlighted,
|
|
29
|
+
isSelected,
|
|
30
|
+
name,
|
|
31
|
+
onClick,
|
|
32
|
+
}) => {
|
|
33
|
+
if (typeof data === 'number') {
|
|
34
|
+
return <td className={styles.root} />;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const handleClick = (): void => {
|
|
38
|
+
if (onClick) {
|
|
39
|
+
const simpleEvent = { target: { name, value: data.date } };
|
|
40
|
+
onClick(simpleEvent);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<td
|
|
46
|
+
className={classNames(
|
|
47
|
+
styles.root,
|
|
48
|
+
isHighlighted && styles.rootIsHighlighted,
|
|
49
|
+
isSelected && styles.rootIsSelected,
|
|
50
|
+
DateService.isToday(data.date) && styles.rootIsToday,
|
|
51
|
+
isDisabled && styles.rootIsDisabled
|
|
52
|
+
)}
|
|
53
|
+
data-testid={`calendar-day-root-${data.label}`}
|
|
54
|
+
>
|
|
55
|
+
<button
|
|
56
|
+
className={styles.control}
|
|
57
|
+
disabled={isDisabled}
|
|
58
|
+
onClick={handleClick}
|
|
59
|
+
type="button"
|
|
60
|
+
>
|
|
61
|
+
{data.label}
|
|
62
|
+
</button>
|
|
63
|
+
</td>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
CalendarDay.propTypes = {
|
|
68
|
+
data: PropTypes.oneOfType([
|
|
69
|
+
PropTypes.number.isRequired,
|
|
70
|
+
PropTypes.shape({
|
|
71
|
+
date: PropTypes.string.isRequired,
|
|
72
|
+
label: PropTypes.number.isRequired,
|
|
73
|
+
}).isRequired,
|
|
74
|
+
]).isRequired,
|
|
75
|
+
name: PropTypes.string.isRequired,
|
|
76
|
+
isDisabled: PropTypes.bool,
|
|
77
|
+
isHighlighted: PropTypes.bool,
|
|
78
|
+
isSelected: PropTypes.bool,
|
|
79
|
+
onClick: PropTypes.func,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default CalendarDay;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import DateService from '@services/DateService';
|
|
5
|
+
|
|
6
|
+
import CalendarWeek from '@core/CalendarWeek';
|
|
7
|
+
import type { WeekObject } from '@core/CalendarWeek';
|
|
8
|
+
|
|
9
|
+
import type { SimpleEventHandler } from '@utility/interfaces';
|
|
10
|
+
|
|
11
|
+
import styles from './CalendarMonth.module.css';
|
|
12
|
+
|
|
13
|
+
const DECIMAL = 10;
|
|
14
|
+
const DAYS_IN_WEEK = 7;
|
|
15
|
+
|
|
16
|
+
const DAYS = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
|
|
17
|
+
|
|
18
|
+
const getWeeks = (month: string): WeekObject[] => {
|
|
19
|
+
const firstDay = `${month}-01`;
|
|
20
|
+
|
|
21
|
+
const firstDayofMonth = DateService.getDayOfWeek(firstDay);
|
|
22
|
+
const daysInMonth = DateService.getDaysInMonth(firstDay);
|
|
23
|
+
const lastDayofMonth = DateService.getDayOfWeek(`${month}-${daysInMonth}`);
|
|
24
|
+
|
|
25
|
+
const beforeDays = Array(firstDayofMonth).fill(0) as 0[];
|
|
26
|
+
const afterDays = Array(DAYS_IN_WEEK - 1 - lastDayofMonth).fill(0) as 0[];
|
|
27
|
+
|
|
28
|
+
const monthDays = Array.from({ length: daysInMonth }).map((_item, index) => ({
|
|
29
|
+
label: index + 1,
|
|
30
|
+
date: `${month}-${index + 1 < DECIMAL ? '0' : ''}${index + 1}`,
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
const days = [...beforeDays, ...monthDays, ...afterDays];
|
|
34
|
+
const weeks = [];
|
|
35
|
+
|
|
36
|
+
for (let index = 0; index < days.length; index += DAYS_IN_WEEK) {
|
|
37
|
+
weeks.push(days.slice(index, index + DAYS_IN_WEEK));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return weeks.filter((week) => JSON.stringify(week) !== '[0,0,0,0,0,0,0]');
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
interface CalendarMonthProps {
|
|
44
|
+
disabledDates?: string[] | ((date: string) => boolean);
|
|
45
|
+
name: string;
|
|
46
|
+
month: string;
|
|
47
|
+
onClick?: SimpleEventHandler<string>;
|
|
48
|
+
pendingValue: string;
|
|
49
|
+
value?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const CalendarMonth: React.FunctionComponent<CalendarMonthProps> = ({
|
|
53
|
+
disabledDates,
|
|
54
|
+
name,
|
|
55
|
+
month,
|
|
56
|
+
onClick,
|
|
57
|
+
pendingValue,
|
|
58
|
+
value,
|
|
59
|
+
}) => {
|
|
60
|
+
const weeks = getWeeks(month);
|
|
61
|
+
return (
|
|
62
|
+
<table className={styles.root}>
|
|
63
|
+
<thead>
|
|
64
|
+
<tr>
|
|
65
|
+
{DAYS.map((item) => (
|
|
66
|
+
<th key={item} className={styles.head}>
|
|
67
|
+
{item}
|
|
68
|
+
</th>
|
|
69
|
+
))}
|
|
70
|
+
</tr>
|
|
71
|
+
</thead>
|
|
72
|
+
<tbody>
|
|
73
|
+
{weeks.map((item) => (
|
|
74
|
+
<CalendarWeek
|
|
75
|
+
key={typeof item[0] === 'number' ? item[0] : item[0].date}
|
|
76
|
+
data={item}
|
|
77
|
+
disabledDates={disabledDates}
|
|
78
|
+
name={name}
|
|
79
|
+
onClick={onClick}
|
|
80
|
+
pendingValue={pendingValue}
|
|
81
|
+
value={value}
|
|
82
|
+
/>
|
|
83
|
+
))}
|
|
84
|
+
</tbody>
|
|
85
|
+
</table>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
CalendarMonth.propTypes = {
|
|
90
|
+
month: PropTypes.string.isRequired,
|
|
91
|
+
name: PropTypes.string.isRequired,
|
|
92
|
+
pendingValue: PropTypes.string.isRequired,
|
|
93
|
+
disabledDates: PropTypes.oneOfType([
|
|
94
|
+
PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
95
|
+
PropTypes.func,
|
|
96
|
+
]),
|
|
97
|
+
value: PropTypes.string,
|
|
98
|
+
onClick: PropTypes.func,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default CalendarMonth;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
border-bottom: .1rem var(--clr-grey300) solid;
|
|
3
|
+
margin-bottom: 2rem;
|
|
4
|
+
padding: 1rem 0;
|
|
5
|
+
position: relative;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.title {
|
|
9
|
+
font-size: var(--fs-sml);
|
|
10
|
+
font-weight: var(--fw-bold);
|
|
11
|
+
line-height: 4rem;
|
|
12
|
+
text-align: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.control {
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: 1.5rem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.controlPrevious {
|
|
21
|
+
left: .6rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.controlNext {
|
|
25
|
+
right: .6rem;
|
|
26
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import DateService from '@services/DateService';
|
|
6
|
+
import FormatService from '@services/FormatService';
|
|
7
|
+
|
|
8
|
+
import IconButton from '@core/IconButton';
|
|
9
|
+
|
|
10
|
+
import type { SimpleEventHandler } from '@utility/interfaces';
|
|
11
|
+
|
|
12
|
+
import styles from './CalendarNavigation.module.css';
|
|
13
|
+
|
|
14
|
+
interface CalendarNavigationProps {
|
|
15
|
+
month: string;
|
|
16
|
+
name: string;
|
|
17
|
+
onChange: SimpleEventHandler<string>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const CalendarNavigation: React.FunctionComponent<CalendarNavigationProps> = ({
|
|
21
|
+
month,
|
|
22
|
+
name,
|
|
23
|
+
onChange,
|
|
24
|
+
}) => {
|
|
25
|
+
const handleChange = (value: string): void => {
|
|
26
|
+
const simpleEvent = { target: { name, value } };
|
|
27
|
+
onChange(simpleEvent);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const handlePrevious = (): void => handleChange(DateService.subMonths(month, 1));
|
|
31
|
+
const handleNext = (): void => handleChange(DateService.addMonths(month, 1));
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className={styles.root}>
|
|
35
|
+
<p className={styles.title}>{FormatService.date(`${month}-01`, 'MMMM y')}</p>
|
|
36
|
+
<i className={classNames(styles.control, styles.controlPrevious)}>
|
|
37
|
+
<IconButton icon="arrowLeft" onClick={handlePrevious} size="sm">
|
|
38
|
+
Previous
|
|
39
|
+
</IconButton>
|
|
40
|
+
</i>
|
|
41
|
+
<i className={classNames(styles.control, styles.controlNext)}>
|
|
42
|
+
<IconButton icon="arrowRight" onClick={handleNext} size="sm">
|
|
43
|
+
Next
|
|
44
|
+
</IconButton>
|
|
45
|
+
</i>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
CalendarNavigation.propTypes = {
|
|
51
|
+
month: PropTypes.string.isRequired,
|
|
52
|
+
name: PropTypes.string.isRequired,
|
|
53
|
+
onChange: PropTypes.func.isRequired,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default CalendarNavigation;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import CalendarDay from '@core/CalendarDay';
|
|
5
|
+
import type { DayObject } from '@core/CalendarDay';
|
|
6
|
+
|
|
7
|
+
import type { SimpleEventHandler } from '@utility/interfaces';
|
|
8
|
+
|
|
9
|
+
export type WeekObject = (DayObject | number)[];
|
|
10
|
+
|
|
11
|
+
interface CalendarWeekProps {
|
|
12
|
+
data: WeekObject;
|
|
13
|
+
disabledDates?: string[] | ((date: string) => boolean);
|
|
14
|
+
name: string;
|
|
15
|
+
onClick?: SimpleEventHandler<string>;
|
|
16
|
+
pendingValue: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const isDisabled = (
|
|
21
|
+
item: DayObject | number,
|
|
22
|
+
disabledDates?: string[] | ((date: string) => boolean)
|
|
23
|
+
): boolean => {
|
|
24
|
+
if (typeof item === 'number' || !disabledDates) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof disabledDates === 'function') {
|
|
29
|
+
return disabledDates(item.date);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return disabledDates.includes(item.date);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const isSelected = (item: DayObject | number, pendingValue: string, value?: string): boolean => {
|
|
36
|
+
if (typeof item === 'number') {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (pendingValue || value || '').split(',').includes(item.date);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const isHighlighted = (item: DayObject | number, pendingValue: string, value?: string): boolean => {
|
|
44
|
+
if (typeof item === 'number') {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const [lower, upper] = (pendingValue || value || '').split(',');
|
|
49
|
+
return item.date > lower && item.date < upper;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const CalendarWeek: React.FunctionComponent<CalendarWeekProps> = ({
|
|
53
|
+
data,
|
|
54
|
+
disabledDates,
|
|
55
|
+
name,
|
|
56
|
+
onClick,
|
|
57
|
+
pendingValue,
|
|
58
|
+
value,
|
|
59
|
+
}) => (
|
|
60
|
+
<tr>
|
|
61
|
+
{data.map((item, index) => (
|
|
62
|
+
<CalendarDay
|
|
63
|
+
key={typeof item === 'number' ? index : item.date}
|
|
64
|
+
data={item}
|
|
65
|
+
isDisabled={isDisabled(item, disabledDates)}
|
|
66
|
+
isHighlighted={isHighlighted(item, pendingValue, value)}
|
|
67
|
+
isSelected={isSelected(item, pendingValue, value)}
|
|
68
|
+
name={name}
|
|
69
|
+
onClick={onClick}
|
|
70
|
+
/>
|
|
71
|
+
))}
|
|
72
|
+
</tr>
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
CalendarWeek.propTypes = {
|
|
76
|
+
data: PropTypes.arrayOf(
|
|
77
|
+
PropTypes.oneOfType([
|
|
78
|
+
PropTypes.number.isRequired,
|
|
79
|
+
PropTypes.shape({
|
|
80
|
+
date: PropTypes.string.isRequired,
|
|
81
|
+
label: PropTypes.number.isRequired,
|
|
82
|
+
}).isRequired,
|
|
83
|
+
]).isRequired
|
|
84
|
+
).isRequired,
|
|
85
|
+
name: PropTypes.string.isRequired,
|
|
86
|
+
pendingValue: PropTypes.string.isRequired,
|
|
87
|
+
disabledDates: PropTypes.oneOfType([
|
|
88
|
+
PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
89
|
+
PropTypes.func,
|
|
90
|
+
]),
|
|
91
|
+
value: PropTypes.string,
|
|
92
|
+
onClick: PropTypes.func,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default CalendarWeek;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
align-items: center;
|
|
3
|
+
cursor: pointer;
|
|
4
|
+
display: flex;
|
|
5
|
+
position: relative;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.rootIsDisabled {
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.label {
|
|
13
|
+
color: var(--clr-grey600);
|
|
14
|
+
display: block;
|
|
15
|
+
font-size: var(--fs-sml);
|
|
16
|
+
font-weight: var(--fw-bold);
|
|
17
|
+
padding-left: 1.5rem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
input[disabled] ~ .label {
|
|
21
|
+
opacity: .3;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.input {
|
|
26
|
+
left: 0;
|
|
27
|
+
opacity: 0;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 0;
|
|
31
|
+
}
|