@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,206 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import { format } from 'date-fns';
|
|
3
|
+
import { render, screen, waitForElementToBeRemoved } from '@testing-library/react';
|
|
4
|
+
import MockDate from 'mockdate';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
|
|
7
|
+
import CalendarInput from './index';
|
|
8
|
+
|
|
9
|
+
describe('CalendarInput', () => {
|
|
10
|
+
it('should render', () => {
|
|
11
|
+
render(<CalendarInput name="lorem" />);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should render default', () => {
|
|
15
|
+
render(<CalendarInput name="lorem" />);
|
|
16
|
+
|
|
17
|
+
expect(screen.getByText(/^Select\.\.\.$/u)).toBeInTheDocument();
|
|
18
|
+
expect(screen.queryAllByRole('table')).toHaveLength(0);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should render label', () => {
|
|
22
|
+
render(<CalendarInput name="lorem" value="2020-09-19" />);
|
|
23
|
+
expect(screen.getByText(/^19\/09\/2020$/u)).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should render range label', () => {
|
|
27
|
+
render(<CalendarInput name="lorem" value="2020-09-19,2020-09-22" isRange />);
|
|
28
|
+
expect(screen.getByText(/^19\/09\/2020 - 22\/09\/2020$/u)).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should render non-range label', () => {
|
|
32
|
+
render(<CalendarInput name="lorem" value="2020-09-19,2020-09-19" isRange />);
|
|
33
|
+
expect(screen.getByText(/^19\/09\/2020$/u)).toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should have error', () => {
|
|
37
|
+
render(<CalendarInput name="lorem" value="2020-09-19" hasError />);
|
|
38
|
+
expect(screen.getByText('19/09/2020')).toHaveClass('root rootHasError');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should render panel only', () => {
|
|
42
|
+
render(<CalendarInput name="lorem" isPanelOnly />);
|
|
43
|
+
expect(screen.queryAllByRole('table')).toHaveLength(1);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should render panel only with value', () => {
|
|
47
|
+
render(<CalendarInput name="lorem" value="2020-09-19" isPanelOnly />);
|
|
48
|
+
|
|
49
|
+
expect(screen.queryAllByRole('table')).toHaveLength(1);
|
|
50
|
+
expect(screen.getByText('September 2020')).toBeDefined();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should disable dates', () => {
|
|
54
|
+
render(
|
|
55
|
+
<CalendarInput
|
|
56
|
+
disabledDates={['2020-09-20']}
|
|
57
|
+
name="lorem"
|
|
58
|
+
value="2020-09-19"
|
|
59
|
+
isPanelOnly
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
expect(screen.getByText('20')).toHaveAttribute('disabled');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should disable dates via function', () => {
|
|
67
|
+
MockDate.set('2020-09-19');
|
|
68
|
+
|
|
69
|
+
render(
|
|
70
|
+
<CalendarInput
|
|
71
|
+
disabledDates={(date): boolean => date === '2020-09-20'}
|
|
72
|
+
name="lorem"
|
|
73
|
+
isPanelOnly
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(screen.getByText('20')).toHaveAttribute('disabled');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should highlight dates', () => {
|
|
81
|
+
render(<CalendarInput name="lorem" value="2020-09-19,2020-09-21" isPanelOnly isRange />);
|
|
82
|
+
expect(screen.getByTestId('calendar-day-root-20')).toHaveClass('root rootIsHighlighted');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should render today', () => {
|
|
86
|
+
MockDate.set('2020-09-19');
|
|
87
|
+
render(<CalendarInput name="lorem" isPanelOnly />);
|
|
88
|
+
expect(screen.getByTestId('calendar-day-root-19')).toHaveClass('rootIsToday');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should handle open (and clickoutside)', async () => {
|
|
92
|
+
render(
|
|
93
|
+
<Fragment>
|
|
94
|
+
<CalendarInput name="lorem" value="lorem" />
|
|
95
|
+
<div>[DOM]</div>
|
|
96
|
+
</Fragment>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(screen.queryAllByRole('table')).toHaveLength(0);
|
|
100
|
+
|
|
101
|
+
userEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
102
|
+
expect(screen.queryAllByRole('table')).toHaveLength(1);
|
|
103
|
+
|
|
104
|
+
userEvent.click(screen.getByText('[DOM]'));
|
|
105
|
+
await waitForElementToBeRemoved(screen.queryAllByRole('table'));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should handle no onChange (just close datepanel)', () => {
|
|
109
|
+
render(<CalendarInput name="lorem" />);
|
|
110
|
+
|
|
111
|
+
userEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
112
|
+
expect(screen.queryAllByRole('table')).toHaveLength(1);
|
|
113
|
+
|
|
114
|
+
userEvent.click(screen.getByRole('button', { name: '15' }));
|
|
115
|
+
|
|
116
|
+
expect(screen.queryAllByRole('table')).toHaveLength(0);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should handle onChange', () => {
|
|
120
|
+
const mockFn = jest.fn();
|
|
121
|
+
const value = format(new Date(), 'Y-MM-15');
|
|
122
|
+
|
|
123
|
+
render(<CalendarInput name="lorem" onChange={mockFn} />);
|
|
124
|
+
|
|
125
|
+
userEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
126
|
+
|
|
127
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
128
|
+
userEvent.click(screen.getByRole('button', { name: '15' }));
|
|
129
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
130
|
+
expect(mockFn).toHaveBeenLastCalledWith({ target: { name: 'lorem', value } });
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should handle change with no onChange', () => {
|
|
134
|
+
const mockFn = jest.fn();
|
|
135
|
+
render(<CalendarInput name="lorem" />);
|
|
136
|
+
|
|
137
|
+
userEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
138
|
+
|
|
139
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
140
|
+
userEvent.click(screen.getByRole('button', { name: '15' }));
|
|
141
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('should navigate months', () => {
|
|
145
|
+
render(<CalendarInput name="lorem" value="2020-09-19" isPanelOnly />);
|
|
146
|
+
|
|
147
|
+
expect(screen.getByText('September 2020')).toBeInTheDocument();
|
|
148
|
+
|
|
149
|
+
userEvent.click(screen.getByText('Previous'));
|
|
150
|
+
expect(screen.getByText('August 2020')).toBeInTheDocument();
|
|
151
|
+
|
|
152
|
+
userEvent.click(screen.getByText('Next'));
|
|
153
|
+
userEvent.click(screen.getByText('Next'));
|
|
154
|
+
expect(screen.getByText('October 2020')).toBeInTheDocument();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('should pass value to datepanel', () => {
|
|
158
|
+
const value = format(new Date(), 'Y-MM-08');
|
|
159
|
+
render(<CalendarInput name="lorem" value={value} />);
|
|
160
|
+
|
|
161
|
+
userEvent.click(screen.getByRole('button', { name: 'Open' }));
|
|
162
|
+
|
|
163
|
+
expect(screen.getByTestId('calendar-day-root-7')).toHaveClass('root');
|
|
164
|
+
expect(screen.getByTestId('calendar-day-root-8')).toHaveClass('root rootIsSelected');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('should handle range selection', () => {
|
|
168
|
+
MockDate.set('2020-09-19');
|
|
169
|
+
|
|
170
|
+
const mockFn = jest.fn();
|
|
171
|
+
render(<CalendarInput name="lorem" onChange={mockFn} isPanelOnly isRange />);
|
|
172
|
+
|
|
173
|
+
userEvent.click(screen.getByRole('button', { name: '15' }));
|
|
174
|
+
expect(screen.getByTestId('calendar-day-root-15')).toHaveClass('rootIsSelected');
|
|
175
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
176
|
+
|
|
177
|
+
userEvent.click(screen.getByRole('button', { name: '20' }));
|
|
178
|
+
expect(screen.getByTestId('calendar-day-root-15')).toHaveClass('rootIsSelected');
|
|
179
|
+
expect(screen.getByTestId('calendar-day-root-20')).toHaveClass('rootIsSelected');
|
|
180
|
+
|
|
181
|
+
expect(screen.getByTestId('calendar-day-root-17')).toHaveClass('rootIsHighlighted');
|
|
182
|
+
|
|
183
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
184
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
185
|
+
target: {
|
|
186
|
+
name: 'lorem',
|
|
187
|
+
value: '2020-09-15,2020-09-20',
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
userEvent.click(screen.getByRole('button', { name: '12' }));
|
|
192
|
+
expect(screen.getByTestId('calendar-day-root-12')).toHaveClass('rootIsSelected');
|
|
193
|
+
expect(screen.getByTestId('calendar-day-root-15')).not.toHaveClass('rootIsSelected');
|
|
194
|
+
|
|
195
|
+
userEvent.click(screen.getByRole('button', { name: '30' }));
|
|
196
|
+
expect(screen.getByTestId('calendar-day-root-30')).toHaveClass('rootIsSelected');
|
|
197
|
+
|
|
198
|
+
expect(mockFn).toHaveBeenCalledTimes(2);
|
|
199
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
200
|
+
target: {
|
|
201
|
+
name: 'lorem',
|
|
202
|
+
value: '2020-09-12,2020-09-30',
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Story } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import CalendarInput from './index';
|
|
5
|
+
import type { CalendarInputProps } from './index';
|
|
6
|
+
|
|
7
|
+
import TestChangeHandler from '@utility/TestChangeHandler';
|
|
8
|
+
import StorybookPanel from '@utility/StorybookPanel';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Components/CalendarInput',
|
|
12
|
+
component: CalendarInput,
|
|
13
|
+
decorators: [
|
|
14
|
+
(storyFn: () => React.ReactElement): React.ReactElement => (
|
|
15
|
+
<StorybookPanel isDeep>
|
|
16
|
+
<TestChangeHandler>{storyFn()}</TestChangeHandler>
|
|
17
|
+
</StorybookPanel>
|
|
18
|
+
),
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const Template: Story<CalendarInputProps> = (props) => <CalendarInput {...props} />;
|
|
23
|
+
|
|
24
|
+
export const Basic = Template.bind({});
|
|
25
|
+
|
|
26
|
+
export const WithRange = Template.bind({});
|
|
27
|
+
|
|
28
|
+
WithRange.args = {
|
|
29
|
+
isRange: true,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const PanelOnly = Template.bind({});
|
|
33
|
+
|
|
34
|
+
PanelOnly.args = {
|
|
35
|
+
isPanelOnly: true,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const PanelOnlyWithRange = Template.bind({});
|
|
39
|
+
|
|
40
|
+
PanelOnlyWithRange.args = {
|
|
41
|
+
isPanelOnly: true,
|
|
42
|
+
isRange: true,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const Disabled = Template.bind({});
|
|
46
|
+
|
|
47
|
+
Disabled.args = {
|
|
48
|
+
isDisabled: true,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const WithValue = Template.bind({});
|
|
52
|
+
|
|
53
|
+
WithValue.args = {
|
|
54
|
+
value: '2020-09-19',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const WithRangeValue = Template.bind({});
|
|
58
|
+
|
|
59
|
+
WithRangeValue.args = {
|
|
60
|
+
isRange: true,
|
|
61
|
+
value: '2020-09-19,2020-09-23',
|
|
62
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import FormatService from '@services/FormatService';
|
|
6
|
+
|
|
7
|
+
import Calendar from '@core/Calendar';
|
|
8
|
+
import InputPanel from '@core/InputPanel';
|
|
9
|
+
import StaticTextInput from '@core/StaticTextInput';
|
|
10
|
+
|
|
11
|
+
import useClickOutside from '@hooks/useClickOutside';
|
|
12
|
+
|
|
13
|
+
import type { InputProps, InputValue, SimpleEvent } from '@utility/interfaces';
|
|
14
|
+
|
|
15
|
+
import styles from './CalendarInput.module.css';
|
|
16
|
+
|
|
17
|
+
export interface CalendarInputProps extends InputProps {
|
|
18
|
+
disabledDates?: string[] | ((date: string) => boolean);
|
|
19
|
+
isOptional?: boolean;
|
|
20
|
+
isPanelOnly?: boolean;
|
|
21
|
+
isRange?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const formatLabel = (value?: InputValue, isRange?: boolean): string => {
|
|
25
|
+
if (!value || typeof value !== 'string') {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!isRange) {
|
|
30
|
+
return FormatService.date(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const splitValues = value.split(',');
|
|
34
|
+
|
|
35
|
+
if (splitValues[0] === splitValues[1]) {
|
|
36
|
+
return FormatService.date(splitValues[0]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return splitValues.map((item) => FormatService.date(item)).join(' - ');
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const CalendarInput: React.FunctionComponent<CalendarInputProps> = ({
|
|
43
|
+
disabledDates,
|
|
44
|
+
hasError,
|
|
45
|
+
isDisabled,
|
|
46
|
+
isOptional,
|
|
47
|
+
isPanelOnly,
|
|
48
|
+
isRange,
|
|
49
|
+
name,
|
|
50
|
+
value,
|
|
51
|
+
onChange,
|
|
52
|
+
}) => {
|
|
53
|
+
const [isOpen, setIsOpen, node] = useClickOutside();
|
|
54
|
+
|
|
55
|
+
const toggleIsOpen = (): void => setIsOpen(!isOpen);
|
|
56
|
+
|
|
57
|
+
const handleChange = (event: SimpleEvent): void => {
|
|
58
|
+
if (onChange) {
|
|
59
|
+
onChange(event);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setIsOpen(false);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const label = formatLabel(value, isRange);
|
|
66
|
+
|
|
67
|
+
if (isPanelOnly) {
|
|
68
|
+
return (
|
|
69
|
+
<Calendar
|
|
70
|
+
disabledDates={disabledDates}
|
|
71
|
+
isRange={isRange}
|
|
72
|
+
name={name}
|
|
73
|
+
onChange={handleChange}
|
|
74
|
+
value={value ? value.toString() : ''}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div ref={node} className={classNames(styles.root, isOpen && styles.rootIsOpen)}>
|
|
81
|
+
<StaticTextInput
|
|
82
|
+
hasError={hasError}
|
|
83
|
+
icon="calendar"
|
|
84
|
+
isDisabled={isDisabled}
|
|
85
|
+
isOptional={isOptional}
|
|
86
|
+
label={label}
|
|
87
|
+
name={name}
|
|
88
|
+
onChange={handleChange}
|
|
89
|
+
onClick={toggleIsOpen}
|
|
90
|
+
value={value || ''}
|
|
91
|
+
/>
|
|
92
|
+
{isOpen && !isDisabled && (
|
|
93
|
+
<InputPanel>
|
|
94
|
+
<Calendar
|
|
95
|
+
disabledDates={disabledDates}
|
|
96
|
+
isRange={isRange}
|
|
97
|
+
name={name}
|
|
98
|
+
onChange={handleChange}
|
|
99
|
+
value={value ? value.toString() : ''}
|
|
100
|
+
/>
|
|
101
|
+
</InputPanel>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
CalendarInput.propTypes = {
|
|
108
|
+
name: PropTypes.string.isRequired,
|
|
109
|
+
disabledDates: PropTypes.oneOfType([
|
|
110
|
+
PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
111
|
+
PropTypes.func,
|
|
112
|
+
]),
|
|
113
|
+
hasError: PropTypes.bool,
|
|
114
|
+
isDisabled: PropTypes.bool,
|
|
115
|
+
isOptional: PropTypes.bool,
|
|
116
|
+
isPanelOnly: PropTypes.bool,
|
|
117
|
+
isRange: PropTypes.bool,
|
|
118
|
+
value: PropTypes.string,
|
|
119
|
+
onChange: PropTypes.func,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default CalendarInput;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
import CheckboxList from './index';
|
|
6
|
+
|
|
7
|
+
const mockData = [
|
|
8
|
+
{ label: 'Apple', value: 'apple' },
|
|
9
|
+
{ label: 'Banana', value: 'banana' },
|
|
10
|
+
{ label: 'Carrot', value: 'carrot', isDisabled: true },
|
|
11
|
+
{ label: 'Dog', value: 2 },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
describe('CheckboxList', () => {
|
|
15
|
+
it('should render', () => {
|
|
16
|
+
render(<CheckboxList data={mockData} name="lorem" />);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should handle onChange', () => {
|
|
20
|
+
const mockFn = jest.fn();
|
|
21
|
+
render(<CheckboxList data={mockData} name="lorem" onChange={mockFn} value={['banana']} />);
|
|
22
|
+
|
|
23
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
24
|
+
userEvent.click(screen.getAllByRole('checkbox')[0]);
|
|
25
|
+
|
|
26
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
27
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
28
|
+
item: { id: 'apple', name: 'Apple' },
|
|
29
|
+
target: { name: 'lorem', value: ['banana', 'apple'] },
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should handle onChange with numeric value', () => {
|
|
34
|
+
const mockFn = jest.fn();
|
|
35
|
+
render(<CheckboxList data={mockData} name="lorem" onChange={mockFn} value={['2']} />);
|
|
36
|
+
|
|
37
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
38
|
+
userEvent.click(screen.getAllByRole('checkbox')[3]);
|
|
39
|
+
|
|
40
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
41
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
42
|
+
item: { id: 2, name: 'Dog' },
|
|
43
|
+
target: { name: 'lorem', value: [] },
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should handle onChange without value', () => {
|
|
48
|
+
const mockFn = jest.fn();
|
|
49
|
+
render(<CheckboxList data={mockData} name="lorem" onChange={mockFn} />);
|
|
50
|
+
|
|
51
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
52
|
+
userEvent.click(screen.getAllByRole('checkbox')[0]);
|
|
53
|
+
|
|
54
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
55
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
56
|
+
item: { id: 'apple', name: 'Apple' },
|
|
57
|
+
target: { name: 'lorem', value: ['apple'] },
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should handle onChange (removing item)', () => {
|
|
62
|
+
const mockFn = jest.fn();
|
|
63
|
+
render(<CheckboxList data={mockData} name="lorem" onChange={mockFn} value={['banana']} />);
|
|
64
|
+
|
|
65
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
66
|
+
userEvent.click(screen.getAllByRole('checkbox')[1]);
|
|
67
|
+
|
|
68
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
69
|
+
expect(mockFn).toHaveBeenLastCalledWith({
|
|
70
|
+
item: { id: 'banana', name: 'Banana' },
|
|
71
|
+
target: { name: 'lorem', value: [] },
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should handle click if no onChange', () => {
|
|
76
|
+
const mockFn = jest.fn();
|
|
77
|
+
render(<CheckboxList data={mockData} name="lorem" />);
|
|
78
|
+
|
|
79
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
80
|
+
userEvent.click(screen.getAllByRole('checkbox')[0]);
|
|
81
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { toggleArrayItem } from '@sqrzro/utility';
|
|
5
|
+
|
|
6
|
+
import ChkRadList from '@core/ChkRadList';
|
|
7
|
+
import type { ChkRadListElementProps } from '@core/ChkRadList';
|
|
8
|
+
|
|
9
|
+
import type { SimpleEvent } from '@utility/interfaces';
|
|
10
|
+
|
|
11
|
+
const CheckboxList: React.FunctionComponent<ChkRadListElementProps> = ({
|
|
12
|
+
name,
|
|
13
|
+
onChange,
|
|
14
|
+
value,
|
|
15
|
+
...props
|
|
16
|
+
}) => {
|
|
17
|
+
const handleChange = (event: SimpleEvent<(number | string)[] | number | string>): void => {
|
|
18
|
+
if (
|
|
19
|
+
(typeof value !== 'undefined' && !Array.isArray(value)) ||
|
|
20
|
+
!onChange ||
|
|
21
|
+
(typeof event.target.value !== 'string' && typeof event.target.value !== 'number')
|
|
22
|
+
) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const newArray = toggleArrayItem(value || [], event.target.value);
|
|
27
|
+
|
|
28
|
+
const simpleEvent: SimpleEvent<(number | string)[]> = {
|
|
29
|
+
item: event.item,
|
|
30
|
+
target: { name, value: newArray },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
onChange(simpleEvent);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ChkRadList
|
|
38
|
+
{...props}
|
|
39
|
+
name={`${name}[]`}
|
|
40
|
+
onChange={handleChange}
|
|
41
|
+
type="checkbox"
|
|
42
|
+
value={value}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
CheckboxList.propTypes = {
|
|
48
|
+
name: PropTypes.string.isRequired,
|
|
49
|
+
value: PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
50
|
+
onChange: PropTypes.func,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default CheckboxList;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { ApiService } from '@sqrzro/utility';
|
|
5
|
+
|
|
6
|
+
import Dropdown from '@components/Dropdown';
|
|
7
|
+
import ErrorMessage from '@core/ErrorMessage';
|
|
8
|
+
|
|
9
|
+
import type { InputProps, Remote } from '@utility/interfaces';
|
|
10
|
+
|
|
11
|
+
interface ConnnectedDropdownProps extends InputProps {
|
|
12
|
+
isPanelOnly?: boolean;
|
|
13
|
+
remote: Remote;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const parseRemote = (remote: Remote): Remote => {
|
|
17
|
+
if (Array.isArray(remote)) {
|
|
18
|
+
return [remote[0], { ...remote[1], simpleview: '1' }];
|
|
19
|
+
}
|
|
20
|
+
return [remote, { simpleview: '1' }];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const ConnectedDropdown: React.FunctionComponent<ConnnectedDropdownProps> = ({
|
|
24
|
+
remote,
|
|
25
|
+
...props
|
|
26
|
+
}) => {
|
|
27
|
+
const [data, setData] = useState<Record<string, unknown>[]>();
|
|
28
|
+
const [isError, setIsError] = useState(false);
|
|
29
|
+
|
|
30
|
+
const getData = async (): Promise<void> => {
|
|
31
|
+
try {
|
|
32
|
+
const response = await ApiService.get<{ data: Record<string, unknown>[] }>(
|
|
33
|
+
parseRemote(remote)
|
|
34
|
+
);
|
|
35
|
+
setData(response.data.data);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
setIsError(true);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
void getData();
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
45
|
+
if (isError) {
|
|
46
|
+
return <ErrorMessage isMini />;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return <Dropdown data={data} isDisabled={!data} {...props} />;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
ConnectedDropdown.propTypes = {
|
|
53
|
+
name: PropTypes.string.isRequired,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default ConnectedDropdown;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import ConnectedRepeater from '@core/ConnectedRepeater';
|
|
4
|
+
import type { ConnectedRepeaterElementProps } from '@core/ConnectedRepeater';
|
|
5
|
+
|
|
6
|
+
import List from '@components/List';
|
|
7
|
+
|
|
8
|
+
const ConnectedList: React.FunctionComponent<ConnectedRepeaterElementProps> = (props) => (
|
|
9
|
+
<ConnectedRepeater
|
|
10
|
+
{...props}
|
|
11
|
+
render={(renderProps): React.ReactElement => <List {...renderProps} />}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export default ConnectedList;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, { Children, cloneElement, isValidElement, useEffect, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { ApiService, EventService } from '@sqrzro/utility';
|
|
5
|
+
|
|
6
|
+
import ErrorMessage from '@core/ErrorMessage';
|
|
7
|
+
import Loader from '@core/Loader';
|
|
8
|
+
import type { TabItem } from '@core/Tabs';
|
|
9
|
+
|
|
10
|
+
import Scene from '@components/Scene';
|
|
11
|
+
|
|
12
|
+
import type { Remote } from '@utility/interfaces';
|
|
13
|
+
|
|
14
|
+
interface ConnectedSceneProps {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
remote: Remote;
|
|
17
|
+
tabs?: TabItem[];
|
|
18
|
+
title: string | ((data: Record<string, unknown>) => string);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const ConnectedScene: React.FunctionComponent<ConnectedSceneProps> = ({
|
|
22
|
+
children,
|
|
23
|
+
remote,
|
|
24
|
+
tabs,
|
|
25
|
+
title,
|
|
26
|
+
}) => {
|
|
27
|
+
const [data, setData] = useState<Record<string, unknown>>();
|
|
28
|
+
const [error, setError] = useState('');
|
|
29
|
+
|
|
30
|
+
const getData = async (): Promise<void> => {
|
|
31
|
+
const [alias, params] = Array.isArray(remote) ? remote : [remote, {}];
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const response = await ApiService.get(alias, params);
|
|
35
|
+
EventService.publish('@scene/data', response.data);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
if (err instanceof Error) {
|
|
38
|
+
setError(err.toString());
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const sub = EventService.subscribe('@scene/data', (_key, responseData) => {
|
|
45
|
+
setData(responseData);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
void getData();
|
|
49
|
+
|
|
50
|
+
return (): void => {
|
|
51
|
+
EventService.unsubscribe(sub);
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
if (!isValidElement(children)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (error) {
|
|
60
|
+
return <ErrorMessage isScene>{error}</ErrorMessage>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!data) {
|
|
64
|
+
return <Loader />;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const childrenWithData = Children.map(children, (child: React.ReactElement) => {
|
|
68
|
+
if (!child) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return cloneElement(child, { data });
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const renderedTitle = typeof title === 'function' ? title(data) : title;
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Scene tabs={tabs} title={renderedTitle}>
|
|
78
|
+
{childrenWithData}
|
|
79
|
+
</Scene>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
ConnectedScene.propTypes = {
|
|
84
|
+
children: PropTypes.node.isRequired,
|
|
85
|
+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired,
|
|
86
|
+
tabs: PropTypes.arrayOf(
|
|
87
|
+
PropTypes.shape({
|
|
88
|
+
isDisabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]).isRequired,
|
|
89
|
+
label: PropTypes.string.isRequired,
|
|
90
|
+
route: PropTypes.string.isRequired,
|
|
91
|
+
}).isRequired
|
|
92
|
+
),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default ConnectedScene;
|