@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,311 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
import { EventService } from '@sqrzro/utility';
|
|
6
|
+
|
|
7
|
+
import Tag from '@components/Tag';
|
|
8
|
+
|
|
9
|
+
import type { SimpleAction, TransformedObject } from '@utility/interfaces';
|
|
10
|
+
|
|
11
|
+
import List from './index';
|
|
12
|
+
|
|
13
|
+
jest.mock('@components/Link');
|
|
14
|
+
|
|
15
|
+
const mockData = [
|
|
16
|
+
{
|
|
17
|
+
id: 1,
|
|
18
|
+
title: 'Lorem Ipsum',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 2,
|
|
22
|
+
title: 'Adiscit Exceptor',
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const mockDataWithMeta = [
|
|
27
|
+
{
|
|
28
|
+
id: 1,
|
|
29
|
+
title: 'Lorem Ipsum',
|
|
30
|
+
meta: ['Lorem', 'Ipsum'],
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
describe('List', () => {
|
|
35
|
+
const { location } = window;
|
|
36
|
+
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
window.location = location;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should render', () => {
|
|
42
|
+
render(<List />);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should render defaults', () => {
|
|
46
|
+
render(<List data={mockData} />);
|
|
47
|
+
expect(screen.getByRole('list')).toHaveClass('root');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should render no data', () => {
|
|
51
|
+
render(<List />);
|
|
52
|
+
expect(screen.getByRole('heading')).toHaveTextContent(/^No results found$/u);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should render with empty data', () => {
|
|
56
|
+
render(<List data={[]} />);
|
|
57
|
+
expect(screen.getByRole('heading')).toHaveTextContent(/^No results found$/u);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should render list items', () => {
|
|
61
|
+
render(<List data={mockData} />);
|
|
62
|
+
|
|
63
|
+
const listItems = screen.queryAllByRole('listitem');
|
|
64
|
+
const [firstTitle] = screen.queryAllByRole('heading');
|
|
65
|
+
|
|
66
|
+
expect(listItems).toHaveLength(2);
|
|
67
|
+
expect(firstTitle).toHaveTextContent(/^Lorem Ipsum$/u);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should be disabled', () => {
|
|
71
|
+
render(<List data={mockData} isDisabled />);
|
|
72
|
+
expect(screen.getByRole('list')).toHaveClass('root rootIsDisabled');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should use transformer', () => {
|
|
76
|
+
const transformer = (item: Record<string, unknown>): TransformedObject => ({
|
|
77
|
+
$id: item.id as number,
|
|
78
|
+
title: `[[${item.title as string}]]`,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
render(<List data={mockData} transformer={transformer} />);
|
|
82
|
+
|
|
83
|
+
const listItems = screen.queryAllByRole('listitem');
|
|
84
|
+
const [firstTitle] = screen.queryAllByRole('heading');
|
|
85
|
+
|
|
86
|
+
expect(listItems).toHaveLength(2);
|
|
87
|
+
expect(firstTitle).toHaveTextContent(/^\[\[Lorem Ipsum\]\]$/u);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should use transformer with actions', () => {
|
|
91
|
+
const transformer = (item: Record<string, unknown>): TransformedObject => ({
|
|
92
|
+
$id: item.id as number,
|
|
93
|
+
title: item.title as string,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const mockFn = jest.fn();
|
|
97
|
+
const actions = [{ label: 'Lorem', onClick: mockFn }];
|
|
98
|
+
|
|
99
|
+
render(<List data={mockData} transformer={[transformer, actions]} />);
|
|
100
|
+
|
|
101
|
+
const buttons = screen.queryAllByText('Lorem');
|
|
102
|
+
|
|
103
|
+
expect(buttons).toHaveLength(2);
|
|
104
|
+
expect(buttons[0]).toBeInstanceOf(HTMLButtonElement);
|
|
105
|
+
|
|
106
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
107
|
+
userEvent.click(buttons[0]);
|
|
108
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should use transformer with actions function', () => {
|
|
112
|
+
const transformer = (item: Record<string, unknown>): TransformedObject => ({
|
|
113
|
+
$id: item.id as number,
|
|
114
|
+
title: item.title as string,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const mockFn = jest.fn();
|
|
118
|
+
const actions = (): SimpleAction[] => [{ label: 'Lorem', onClick: mockFn }];
|
|
119
|
+
|
|
120
|
+
render(<List data={mockData} transformer={[transformer, actions]} />);
|
|
121
|
+
|
|
122
|
+
const buttons = screen.queryAllByText('Lorem');
|
|
123
|
+
|
|
124
|
+
expect(buttons).toHaveLength(2);
|
|
125
|
+
expect(buttons[0]).toBeInstanceOf(HTMLButtonElement);
|
|
126
|
+
|
|
127
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
128
|
+
userEvent.click(buttons[0]);
|
|
129
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should handle toggle actions', () => {
|
|
133
|
+
const transformer = (item: Record<string, unknown>): TransformedObject => ({
|
|
134
|
+
$id: item.id as number,
|
|
135
|
+
title: item.title as string,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const mockFn = jest.fn();
|
|
139
|
+
const actions = [{ label: 'Lorem', onClick: mockFn }];
|
|
140
|
+
|
|
141
|
+
render(<List data={mockData} transformer={[transformer, actions]} />);
|
|
142
|
+
|
|
143
|
+
userEvent.click(screen.queryAllByText('Open')[0]);
|
|
144
|
+
expect(screen.queryAllByRole('list')[1]).toHaveClass('listIsOpen');
|
|
145
|
+
|
|
146
|
+
userEvent.click(screen.queryAllByText('Close')[0]);
|
|
147
|
+
expect(screen.queryAllByRole('list')[1]).not.toHaveClass('listIsOpen');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should handle onclick', () => {
|
|
151
|
+
const mockFn = jest.fn();
|
|
152
|
+
const data = mockDataWithMeta.map((item) => ({ ...item, onClick: mockFn }));
|
|
153
|
+
render(<List data={data} />);
|
|
154
|
+
|
|
155
|
+
expect(screen.getByRole('button')).toHaveTextContent(/^Lorem Ipsum$/u);
|
|
156
|
+
|
|
157
|
+
userEvent.click(screen.getByRole('button'));
|
|
158
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('should have a to prop', () => {
|
|
162
|
+
const mockFn = jest.fn();
|
|
163
|
+
const data = mockDataWithMeta.map((item) => ({ ...item, onClick: mockFn, to: 'lorem' }));
|
|
164
|
+
render(<List data={data} />);
|
|
165
|
+
|
|
166
|
+
expect(screen.getByRole('link')).toHaveAttribute('href', '/lorem');
|
|
167
|
+
|
|
168
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
169
|
+
userEvent.click(screen.getByRole('link'));
|
|
170
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('should render no title', () => {
|
|
174
|
+
const data = [{ $id: 1 }, { $id: 2 }];
|
|
175
|
+
render(<List data={data} />);
|
|
176
|
+
expect(screen.queryByRole('heading')).not.toBeInTheDocument();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('should handle preloadtitle', () => {
|
|
180
|
+
const data = mockDataWithMeta.map((item) => ({
|
|
181
|
+
...item,
|
|
182
|
+
to: 'lorem',
|
|
183
|
+
$shouldPreloadTitle: true,
|
|
184
|
+
}));
|
|
185
|
+
render(<List data={data} />);
|
|
186
|
+
|
|
187
|
+
expect(EventService.publish).toHaveBeenCalledTimes(0);
|
|
188
|
+
userEvent.click(screen.getByRole('link'));
|
|
189
|
+
expect(EventService.publish).toHaveBeenCalledTimes(1);
|
|
190
|
+
expect(EventService.publish).toHaveBeenCalledWith('@app/title', 'Lorem Ipsum');
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('should handle preloadtitle with onclick', () => {
|
|
194
|
+
const mockFn = jest.fn();
|
|
195
|
+
const data = mockDataWithMeta.map((item) => ({
|
|
196
|
+
...item,
|
|
197
|
+
onClick: mockFn,
|
|
198
|
+
to: 'lorem',
|
|
199
|
+
$shouldPreloadTitle: true,
|
|
200
|
+
}));
|
|
201
|
+
render(<List data={data} />);
|
|
202
|
+
|
|
203
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
204
|
+
userEvent.click(screen.getByRole('link'));
|
|
205
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('should render secondary title', () => {
|
|
209
|
+
const data = mockDataWithMeta.map((item) => ({
|
|
210
|
+
...item,
|
|
211
|
+
secondary: { title: 'Secondary' },
|
|
212
|
+
}));
|
|
213
|
+
render(<List data={data} />);
|
|
214
|
+
expect(screen.getByText('Secondary')).toBeInTheDocument();
|
|
215
|
+
expect(screen.getByText('Secondary')).toHaveClass('title');
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('should render content', () => {
|
|
219
|
+
const data = mockDataWithMeta.map((item) => ({ ...item, content: 'Content' }));
|
|
220
|
+
render(<List data={data} />);
|
|
221
|
+
expect(screen.getByText('Content')).toBeInTheDocument();
|
|
222
|
+
expect(screen.getByText('Content')).toHaveClass('content');
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('should have meta items', () => {
|
|
226
|
+
render(<List data={mockDataWithMeta} />);
|
|
227
|
+
expect(screen.getByText(/^Lorem$/u)).toBeInTheDocument();
|
|
228
|
+
expect(screen.getByText(/^Ipsum$/u)).toBeInTheDocument();
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('should have meta items with link', () => {
|
|
232
|
+
const data = mockDataWithMeta.map((item) => ({
|
|
233
|
+
...item,
|
|
234
|
+
meta: [{ label: 'Lorem', to: 'lorem' }],
|
|
235
|
+
}));
|
|
236
|
+
render(<List data={data} />);
|
|
237
|
+
|
|
238
|
+
expect(screen.getByText(/^Lorem$/u)).toBeInTheDocument();
|
|
239
|
+
expect(screen.getByText(/^Lorem$/u)).toHaveAttribute('href', '/lorem');
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('should have meta with null', () => {
|
|
243
|
+
const data = mockDataWithMeta.map((item) => ({ ...item, meta: [null, 'Ipsum'] }));
|
|
244
|
+
render(<List data={data} />);
|
|
245
|
+
|
|
246
|
+
expect(screen.queryByText(/^Lorem$/u)).not.toBeInTheDocument();
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('should have meta with react element', () => {
|
|
250
|
+
const data = mockDataWithMeta.map((item) => ({
|
|
251
|
+
...item,
|
|
252
|
+
meta: [<Tag key={0}>Lorem</Tag>],
|
|
253
|
+
}));
|
|
254
|
+
render(<List data={data} />);
|
|
255
|
+
|
|
256
|
+
expect(screen.getByText(/^Lorem$/u)).toBeInTheDocument();
|
|
257
|
+
expect(screen.getByText(/^Lorem$/u)).toHaveClass('root');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('should have pagination', () => {
|
|
261
|
+
render(<List data={mockData} pagination={{ activePage: 1, pageCount: 2 }} />);
|
|
262
|
+
|
|
263
|
+
expect(screen.queryAllByTestId('pagination-item-link')).toHaveLength(2);
|
|
264
|
+
expect(screen.queryAllByTestId('pagination-item-link')[0]).toHaveTextContent(/^1$/u);
|
|
265
|
+
expect(screen.getByText(/^1$/u)).toHaveClass('link linkIsActive');
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('should not have if pagination only has one page', () => {
|
|
269
|
+
render(<List data={mockData} pagination={{ activePage: 1, pageCount: 1 }} />);
|
|
270
|
+
expect(screen.queryByTestId('pagination-item-link')).not.toBeInTheDocument();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('should have pagination with lots of pages', () => {
|
|
274
|
+
render(<List data={mockData} pagination={{ activePage: 20, pageCount: 56 }} />);
|
|
275
|
+
|
|
276
|
+
const links = screen.queryAllByTestId('pagination-item-link');
|
|
277
|
+
|
|
278
|
+
expect(screen.queryAllByTestId('pagination-item-link')).toHaveLength(5);
|
|
279
|
+
expect(links[0]).toHaveTextContent(/^1$/u);
|
|
280
|
+
expect(links[1]).toHaveTextContent(/^19$/u);
|
|
281
|
+
expect(links[2]).toHaveTextContent(/^20$/u);
|
|
282
|
+
expect(links[3]).toHaveTextContent(/^21$/u);
|
|
283
|
+
expect(links[4]).toHaveTextContent(/^56$/u);
|
|
284
|
+
|
|
285
|
+
expect(screen.getByText(/^20$/u)).toHaveClass('linkIsActive');
|
|
286
|
+
|
|
287
|
+
expect(screen.queryAllByTestId('pagination-item-gap')).toHaveLength(2);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('should have pagination on the last page', () => {
|
|
291
|
+
render(<List data={mockData} pagination={{ activePage: 10, pageCount: 10 }} />);
|
|
292
|
+
|
|
293
|
+
expect(screen.queryAllByTestId('pagination-item-link')).toHaveLength(4);
|
|
294
|
+
expect(screen.queryAllByTestId('pagination-item-link')[3]).toHaveTextContent(/^10$/u);
|
|
295
|
+
expect(screen.getByText(/^10$/u)).toHaveClass('linkIsActive');
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('should create correct pagination link url', () => {
|
|
299
|
+
render(<List data={mockData} pagination={{ activePage: 10, pageCount: 10 }} />);
|
|
300
|
+
expect(screen.getByText(/^1$/u)).toHaveAttribute('href', '/?page=1');
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('should create correct pagination link url with existing query', () => {
|
|
304
|
+
// @ts-expect-error The operand of a 'delete' operator must be optional.
|
|
305
|
+
delete window.location;
|
|
306
|
+
window.location = { ...location, search: '?lorem=ipsum' };
|
|
307
|
+
|
|
308
|
+
render(<List data={mockData} pagination={{ activePage: 10, pageCount: 10 }} />);
|
|
309
|
+
expect(screen.getByText(/^1$/u)).toHaveAttribute('href', '/?lorem=ipsum&page=1');
|
|
310
|
+
});
|
|
311
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Story } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import Tag from '@components/Tag';
|
|
5
|
+
import type { SimpleAction, TransformedObject } from '@utility/interfaces';
|
|
6
|
+
|
|
7
|
+
import List from './index';
|
|
8
|
+
import type { ListProps } from './index';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Components/List',
|
|
12
|
+
component: List,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const meta = ['Dolor', 'Adiscit'];
|
|
16
|
+
const secondary = { title: 'Exceptor' };
|
|
17
|
+
const to = 'http://example.com';
|
|
18
|
+
|
|
19
|
+
const basicData = [
|
|
20
|
+
{ $id: 1, title: 'Lorem Ipsum' },
|
|
21
|
+
{ $id: 2, title: 'Dolor Sit Amet' },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const data: TransformedObject[] = basicData.map((item) => ({ ...item, meta, secondary, to }));
|
|
25
|
+
|
|
26
|
+
const transformer = (item: Record<string, unknown>): TransformedObject => ({
|
|
27
|
+
...item,
|
|
28
|
+
$id: item.$id as number,
|
|
29
|
+
title: `[[${item.title as string}]]`,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const transformerWithTag = (item: Record<string, unknown>): TransformedObject => ({
|
|
33
|
+
...transformer(item),
|
|
34
|
+
meta: [
|
|
35
|
+
<Tag key="dolor" variant="success">
|
|
36
|
+
Dolor
|
|
37
|
+
</Tag>,
|
|
38
|
+
'Dolor',
|
|
39
|
+
'Adiscit',
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const actions: SimpleAction[] = [
|
|
44
|
+
{
|
|
45
|
+
label: 'Lorem',
|
|
46
|
+
onClick: (): null => null,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
label: 'Ipsum',
|
|
50
|
+
onClick: (): null => null,
|
|
51
|
+
variant: 'danger',
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const Template: Story<ListProps> = (props) => <List {...props} />;
|
|
56
|
+
|
|
57
|
+
export const Default = Template.bind({});
|
|
58
|
+
|
|
59
|
+
Default.args = {
|
|
60
|
+
data,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const Basic = Template.bind({});
|
|
64
|
+
|
|
65
|
+
Basic.args = {
|
|
66
|
+
data: basicData,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Transformed = Template.bind({});
|
|
70
|
+
|
|
71
|
+
Transformed.args = {
|
|
72
|
+
data,
|
|
73
|
+
transformer,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const Empty = Template.bind({});
|
|
77
|
+
|
|
78
|
+
Empty.args = {};
|
|
79
|
+
|
|
80
|
+
export const WithActions = Template.bind({});
|
|
81
|
+
|
|
82
|
+
WithActions.args = {
|
|
83
|
+
data,
|
|
84
|
+
transformer: [transformer, actions],
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const WithTagMeta = Template.bind({});
|
|
88
|
+
|
|
89
|
+
WithTagMeta.args = {
|
|
90
|
+
data,
|
|
91
|
+
transformer: transformerWithTag,
|
|
92
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import EmptyMessage from '@core/EmptyMessage';
|
|
6
|
+
import ListItem from '@core/ListItem';
|
|
7
|
+
import Pagination from '@core/Pagination';
|
|
8
|
+
|
|
9
|
+
import type { TransformedObject, Transformer } from '@utility/interfaces';
|
|
10
|
+
|
|
11
|
+
import styles from './List.module.css';
|
|
12
|
+
|
|
13
|
+
const DEFAULT_TRANSFORMER = (item: Record<string, unknown>): TransformedObject => ({
|
|
14
|
+
$id: item.id as number,
|
|
15
|
+
$original: item,
|
|
16
|
+
...item,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const transformData = (
|
|
20
|
+
data: Record<string, unknown>[],
|
|
21
|
+
transformer: Transformer
|
|
22
|
+
): TransformedObject[] => {
|
|
23
|
+
const [transformFn, actions] = Array.isArray(transformer) ? transformer : [transformer];
|
|
24
|
+
return data.map((item) => ({ ...transformFn(item), $actions: actions, $original: item }));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export interface ListProps {
|
|
28
|
+
data?: Record<string, unknown>[];
|
|
29
|
+
isDisabled?: boolean;
|
|
30
|
+
pagination?: { activePage: number; pageCount: number } | null;
|
|
31
|
+
transformer?: Transformer;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Displays a list of items. Each item in the `data` prop is passed through the `transformer`
|
|
36
|
+
* function and then displayed. For more information about what `transformer` options are
|
|
37
|
+
* available, take a look at the `ListItem` documentation.
|
|
38
|
+
*
|
|
39
|
+
* The only value that is required for each transformed item is an `$id` as this is used for the
|
|
40
|
+
* `key` prop.
|
|
41
|
+
*
|
|
42
|
+
* If there is no data, an `EmptyMessage` is displayed.
|
|
43
|
+
*/
|
|
44
|
+
const List: React.FunctionComponent<ListProps> = ({
|
|
45
|
+
data,
|
|
46
|
+
pagination,
|
|
47
|
+
transformer,
|
|
48
|
+
isDisabled,
|
|
49
|
+
}) => {
|
|
50
|
+
if (!data || !data.length) {
|
|
51
|
+
return <EmptyMessage />;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const transformed = transformData(data, transformer || DEFAULT_TRANSFORMER);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Fragment>
|
|
58
|
+
<ul className={classNames(styles.root, isDisabled && styles.rootIsDisabled)}>
|
|
59
|
+
{transformed.map((item) => (
|
|
60
|
+
<li key={item.$id}>
|
|
61
|
+
<ListItem {...item} />
|
|
62
|
+
</li>
|
|
63
|
+
))}
|
|
64
|
+
</ul>
|
|
65
|
+
{pagination && <Pagination isDisabled={isDisabled} {...pagination} />}
|
|
66
|
+
</Fragment>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
List.propTypes = {
|
|
71
|
+
data: PropTypes.arrayOf(PropTypes.shape({}).isRequired),
|
|
72
|
+
isDisabled: PropTypes.bool,
|
|
73
|
+
pagination: PropTypes.shape({
|
|
74
|
+
activePage: PropTypes.number.isRequired,
|
|
75
|
+
pageCount: PropTypes.number.isRequired,
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default List;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import FixedActions from '@core/FixedActions';
|
|
5
|
+
|
|
6
|
+
interface ListActionsProps {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
label: string;
|
|
9
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
10
|
+
to?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const ListActions: React.FunctionComponent<ListActionsProps> = ({
|
|
14
|
+
children,
|
|
15
|
+
label,
|
|
16
|
+
to,
|
|
17
|
+
onClick,
|
|
18
|
+
}) => (
|
|
19
|
+
<FixedActions label={label} onClick={onClick} to={to}>
|
|
20
|
+
{children}
|
|
21
|
+
</FixedActions>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
ListActions.propTypes = {
|
|
25
|
+
label: PropTypes.string.isRequired,
|
|
26
|
+
children: PropTypes.node,
|
|
27
|
+
to: PropTypes.string,
|
|
28
|
+
onClick: PropTypes.func,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default ListActions;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
align-items: center;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
height: 80vh;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
margin: 0 auto;
|
|
8
|
+
max-width: 48rem;
|
|
9
|
+
padding: 4rem clamp(2rem, 3.5vw, 5rem);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.logo {
|
|
13
|
+
background-color: var(--clr-brand);
|
|
14
|
+
border-radius: 0 0 .5rem .5rem;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
height: 10rem;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
margin: -3rem auto 3rem;
|
|
20
|
+
width: 6rem;
|
|
21
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
import { ApiService, AuthService } from '@sqrzro/utility';
|
|
6
|
+
|
|
7
|
+
import { createMockRouter } from '@utility/MockRouter';
|
|
8
|
+
|
|
9
|
+
import LoginForm from './index';
|
|
10
|
+
|
|
11
|
+
const router = createMockRouter('lorem');
|
|
12
|
+
const routerWithQuery = createMockRouter('lorem', { username: 'ipsum' });
|
|
13
|
+
|
|
14
|
+
describe('LoginForm', () => {
|
|
15
|
+
it('should render', () => {
|
|
16
|
+
render(<LoginForm router={router} />);
|
|
17
|
+
expect(screen.getByRole('button', { name: 'Log In' })).toHaveTextContent('Log In');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should have reverse logo', () => {
|
|
21
|
+
render(<LoginForm router={router} />);
|
|
22
|
+
expect(screen.getByTestId('app-logo-placeholder')).toHaveClass(
|
|
23
|
+
'placeholder placeholderIsReverse'
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should have predefined username', () => {
|
|
28
|
+
render(<LoginForm router={routerWithQuery} />);
|
|
29
|
+
expect(screen.getByRole('textbox', { name: 'Username' })).toHaveValue('ipsum');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should handle submit success', async () => {
|
|
33
|
+
// @ts-expect-error APIResponse not being available
|
|
34
|
+
jest.spyOn(ApiService, 'request').mockImplementationOnce(() => ({
|
|
35
|
+
data: { token: 'lorem' },
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
render(<LoginForm router={router} />);
|
|
39
|
+
userEvent.click(screen.getByRole('button', { name: 'Log In' }));
|
|
40
|
+
|
|
41
|
+
await waitFor(() => {
|
|
42
|
+
expect(AuthService.login).toHaveBeenCalledTimes(1);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(AuthService.login).toHaveBeenLastCalledWith('lorem');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should handle submit success via keyboard', async () => {
|
|
49
|
+
// @ts-expect-error APIResponse not being available
|
|
50
|
+
jest.spyOn(ApiService, 'request').mockImplementationOnce(() => ({
|
|
51
|
+
data: { token: 'lorem' },
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
render(<LoginForm router={router} />);
|
|
55
|
+
userEvent.type(screen.getByRole('textbox', { name: 'Username' }), '{enter}');
|
|
56
|
+
|
|
57
|
+
await waitFor(() => {
|
|
58
|
+
expect(AuthService.login).toHaveBeenCalledTimes(1);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(AuthService.login).toHaveBeenLastCalledWith('lorem');
|
|
62
|
+
});
|
|
63
|
+
});
|