@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,128 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
import type { Columns } from '@core/TableCell';
|
|
6
|
+
import type { Transformer } from '@utility/interfaces';
|
|
7
|
+
|
|
8
|
+
import Table from './index';
|
|
9
|
+
|
|
10
|
+
const Lorem: React.FunctionComponent = () => <span>Lorem</span>;
|
|
11
|
+
|
|
12
|
+
const mockColumns = { name: 'Name', number: 'Number' };
|
|
13
|
+
|
|
14
|
+
const mockData = [
|
|
15
|
+
{
|
|
16
|
+
id: '1',
|
|
17
|
+
name: 'Lorem Ipsum',
|
|
18
|
+
number: 1312,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: '2',
|
|
22
|
+
name: 'Dolor Sit Amet',
|
|
23
|
+
number: 3934,
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const mockTotals = { number: 2131 };
|
|
28
|
+
|
|
29
|
+
describe('Table', () => {
|
|
30
|
+
it('should render', () => {
|
|
31
|
+
render(<Table columns={mockColumns} />);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should render empty message', () => {
|
|
35
|
+
render(<Table columns={mockColumns} />);
|
|
36
|
+
expect(screen.getByRole('heading')).toHaveTextContent(/^No results found$/u);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should render data', () => {
|
|
40
|
+
render(<Table columns={mockColumns} data={mockData} />);
|
|
41
|
+
expect(screen.queryAllByRole('cell')).toHaveLength(4);
|
|
42
|
+
expect(screen.queryAllByRole('cell')[0]).toHaveTextContent(/^Lorem Ipsum$/u);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should render transformer', () => {
|
|
46
|
+
const transformer: Transformer = (item) => ({
|
|
47
|
+
$id: item.id as string,
|
|
48
|
+
name: <Lorem>{item.name as string}</Lorem>,
|
|
49
|
+
number: parseInt(item.number as string, 10) * 2,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
render(<Table columns={mockColumns} data={mockData} transformer={transformer} />);
|
|
53
|
+
expect(screen.queryAllByRole('cell')).toHaveLength(4);
|
|
54
|
+
|
|
55
|
+
expect(screen.queryAllByRole('cell')[0]).toHaveTextContent(/^Lorem$/u);
|
|
56
|
+
expect(screen.queryAllByRole('cell')[1]).toHaveTextContent(/^2624$/u);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should align headers', () => {
|
|
60
|
+
const mockColumnsWithType: Columns = { name: 'Name', number: ['Number', true] };
|
|
61
|
+
render(<Table columns={mockColumnsWithType} data={mockData} />);
|
|
62
|
+
|
|
63
|
+
expect(screen.getByText('Number')).toHaveClass('rootIsRightAligned');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should render totals', () => {
|
|
67
|
+
render(<Table columns={mockColumns} data={mockData} totals={mockTotals} />);
|
|
68
|
+
expect(screen.queryAllByRole('cell')).toHaveLength(6);
|
|
69
|
+
expect(screen.queryAllByRole('cell')[5]).toHaveTextContent(/^2131$/u);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should render disabled', () => {
|
|
73
|
+
render(<Table columns={mockColumns} data={mockData} isDisabled />);
|
|
74
|
+
expect(screen.getByRole('table')).toHaveClass('tableIsDisabled');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should render an empty cell', () => {
|
|
78
|
+
const mockEmptyColumns = { name: 'Name' };
|
|
79
|
+
const mockEmptyData = [{ id: 1, name: '' }];
|
|
80
|
+
|
|
81
|
+
render(<Table columns={mockEmptyColumns} data={mockEmptyData} />);
|
|
82
|
+
expect(screen.queryAllByRole('cell')[0]).toHaveTextContent('');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should render actions', () => {
|
|
86
|
+
const mockFn = jest.fn();
|
|
87
|
+
|
|
88
|
+
const transformer: Transformer = (item) => ({
|
|
89
|
+
$id: item.id as string,
|
|
90
|
+
name: <Lorem>{item.name as string}</Lorem>,
|
|
91
|
+
number: parseInt(item.number as string, 10) * 2,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const actions = [
|
|
95
|
+
{
|
|
96
|
+
label: 'Lorem Action',
|
|
97
|
+
onClick: mockFn,
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
render(
|
|
102
|
+
<Table columns={mockColumns} data={mockData} transformer={[transformer, actions]} />
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const buttons = screen.queryAllByText('Lorem Action');
|
|
106
|
+
|
|
107
|
+
expect(buttons).toHaveLength(2);
|
|
108
|
+
expect(buttons[0]).toBeInstanceOf(HTMLButtonElement);
|
|
109
|
+
|
|
110
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
111
|
+
userEvent.click(buttons[0]);
|
|
112
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should have pagination', () => {
|
|
116
|
+
render(
|
|
117
|
+
<Table
|
|
118
|
+
columns={mockColumns}
|
|
119
|
+
data={mockData}
|
|
120
|
+
pagination={{ activePage: 1, pageCount: 2 }}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
expect(screen.queryAllByTestId('pagination-item-link')).toHaveLength(2);
|
|
125
|
+
expect(screen.queryAllByTestId('pagination-item-link')[0]).toHaveTextContent(/^1$/u);
|
|
126
|
+
expect(screen.getByText(/^1$/u)).toHaveClass('link linkIsActive');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Story } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import Tag from '@components/Tag';
|
|
5
|
+
import type { Columns } from '@core/TableCell';
|
|
6
|
+
|
|
7
|
+
import type { SimpleAction, TransformedObject } from '@utility/interfaces';
|
|
8
|
+
|
|
9
|
+
import Table from './index';
|
|
10
|
+
import type { TableProps } from './index';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'Components/Table',
|
|
14
|
+
component: Table,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const columns = { name: 'Name', number: 'Number' };
|
|
18
|
+
const columnsWithType: Columns = { name: 'Name', number: ['Number', true] };
|
|
19
|
+
const columnsWithTag = { name: 'Name', number: 'Number', tag: 'Tag' };
|
|
20
|
+
|
|
21
|
+
const data = [
|
|
22
|
+
{
|
|
23
|
+
id: '1',
|
|
24
|
+
name: 'Lorem Ipsum',
|
|
25
|
+
number: 1312,
|
|
26
|
+
isEnabled: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: '2',
|
|
30
|
+
name: 'Dolor Sit Amet',
|
|
31
|
+
number: 3934,
|
|
32
|
+
isEnabled: false,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const transformer = (item: Record<string, unknown>): TransformedObject => ({
|
|
37
|
+
...item,
|
|
38
|
+
$id: item.id as number,
|
|
39
|
+
name: `[[${item.name as string}]]`,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const transformerWithTags = (item: Record<string, unknown>): TransformedObject => ({
|
|
43
|
+
...transformer(item),
|
|
44
|
+
tag: (
|
|
45
|
+
<Tag variant={item.isEnabled ? 'success' : 'danger'}>
|
|
46
|
+
{item.isEnabled ? 'Enabled' : 'Disabled'}
|
|
47
|
+
</Tag>
|
|
48
|
+
),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const actions: SimpleAction[] = [
|
|
52
|
+
{
|
|
53
|
+
label: 'Lorem',
|
|
54
|
+
onClick: (): null => null,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: 'Ipsum',
|
|
58
|
+
onClick: (): null => null,
|
|
59
|
+
variant: 'danger',
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const Template: Story<TableProps> = (props) => <Table {...props} />;
|
|
64
|
+
|
|
65
|
+
export const Basic = Template.bind({});
|
|
66
|
+
|
|
67
|
+
Basic.args = {
|
|
68
|
+
columns,
|
|
69
|
+
data,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const RightAligned = Template.bind({});
|
|
73
|
+
|
|
74
|
+
RightAligned.args = {
|
|
75
|
+
columns: columnsWithType,
|
|
76
|
+
data,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const Transformed = Template.bind({});
|
|
80
|
+
|
|
81
|
+
Transformed.args = {
|
|
82
|
+
columns,
|
|
83
|
+
data,
|
|
84
|
+
transformer,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const WithActions = Template.bind({});
|
|
88
|
+
|
|
89
|
+
WithActions.args = {
|
|
90
|
+
columns,
|
|
91
|
+
data,
|
|
92
|
+
transformer: [transformer, actions],
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const WithTags = Template.bind({});
|
|
96
|
+
|
|
97
|
+
WithTags.args = {
|
|
98
|
+
columns: columnsWithTag,
|
|
99
|
+
data,
|
|
100
|
+
transformer: transformerWithTags,
|
|
101
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import { spliceArray } from '@sqrzro/utility';
|
|
6
|
+
|
|
7
|
+
import EmptyMessage from '@core/EmptyMessage';
|
|
8
|
+
import Pagination from '@core/Pagination';
|
|
9
|
+
import Panel from '@core/Panel';
|
|
10
|
+
import TableCell from '@core/TableCell';
|
|
11
|
+
import TableHead from '@core/TableHead';
|
|
12
|
+
import type { Columns } from '@core/TableCell';
|
|
13
|
+
import TableRow from '@core/TableRow';
|
|
14
|
+
import type { TransformedColumn } from '@core/TableRow';
|
|
15
|
+
|
|
16
|
+
import type { PaginationObject, TransformedObject, Transformer } from '@utility/interfaces';
|
|
17
|
+
|
|
18
|
+
import styles from './Table.module.css';
|
|
19
|
+
|
|
20
|
+
const DEFAULT_TRANSFORMER = (item: Record<string, unknown>): TransformedObject => ({
|
|
21
|
+
$id: item.id as number,
|
|
22
|
+
$original: item,
|
|
23
|
+
...item,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const transformData = (
|
|
27
|
+
data: Record<string, unknown>[],
|
|
28
|
+
transformer: Transformer
|
|
29
|
+
): TransformedObject[] => {
|
|
30
|
+
const [transformFn, actions] = Array.isArray(transformer) ? transformer : [transformer];
|
|
31
|
+
return data.map((item) => ({ ...transformFn(item), $actions: actions, $original: item }));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const transformColumns = (columns: Columns): TransformedColumn[] =>
|
|
35
|
+
Object.entries(columns).map(([key, item]) => ({
|
|
36
|
+
key,
|
|
37
|
+
title: Array.isArray(item) ? item[0] : item,
|
|
38
|
+
isRightAligned: Array.isArray(item) ? item[1] : false,
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
export interface TableProps {
|
|
42
|
+
columns: Columns;
|
|
43
|
+
data?: Record<string, unknown>[];
|
|
44
|
+
isDisabled?: boolean;
|
|
45
|
+
pagination?: PaginationObject;
|
|
46
|
+
totals?: Record<string, number> | null;
|
|
47
|
+
transformer?: Transformer;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const Table: React.FunctionComponent<TableProps> = ({
|
|
51
|
+
columns,
|
|
52
|
+
data,
|
|
53
|
+
isDisabled,
|
|
54
|
+
pagination,
|
|
55
|
+
totals,
|
|
56
|
+
transformer,
|
|
57
|
+
}) => {
|
|
58
|
+
if (!data || !data.length) {
|
|
59
|
+
return <EmptyMessage />;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const transformedColumns = transformColumns(columns);
|
|
63
|
+
const transformedData = transformData(data, transformer || DEFAULT_TRANSFORMER);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Fragment>
|
|
67
|
+
<Panel>
|
|
68
|
+
<div className={styles.root}>
|
|
69
|
+
<table
|
|
70
|
+
className={classNames(styles.table, isDisabled && styles.tableIsDisabled)}
|
|
71
|
+
>
|
|
72
|
+
<TableHead
|
|
73
|
+
columns={transformedColumns}
|
|
74
|
+
hasActions={Boolean(transformedData[0].$actions?.length)}
|
|
75
|
+
/>
|
|
76
|
+
<tbody>
|
|
77
|
+
{transformedData.map((item) => (
|
|
78
|
+
<TableRow key={item.$id} columns={transformedColumns} data={item} />
|
|
79
|
+
))}
|
|
80
|
+
</tbody>
|
|
81
|
+
{totals && (
|
|
82
|
+
<tfoot>
|
|
83
|
+
<tr>
|
|
84
|
+
<TableCell value="Totals:" />
|
|
85
|
+
{spliceArray(transformedColumns, 0, 1).map((item) => (
|
|
86
|
+
<TableCell
|
|
87
|
+
key={item.key}
|
|
88
|
+
isRightAligned={item.isRightAligned}
|
|
89
|
+
value={totals[item.key].toString()}
|
|
90
|
+
/>
|
|
91
|
+
))}
|
|
92
|
+
</tr>
|
|
93
|
+
</tfoot>
|
|
94
|
+
)}
|
|
95
|
+
</table>
|
|
96
|
+
</div>
|
|
97
|
+
</Panel>
|
|
98
|
+
{pagination ? <Pagination isDisabled={isDisabled} {...pagination} /> : null}
|
|
99
|
+
</Fragment>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
Table.propTypes = {
|
|
104
|
+
columns: PropTypes.shape({}).isRequired,
|
|
105
|
+
data: PropTypes.arrayOf(PropTypes.shape({}).isRequired),
|
|
106
|
+
isDisabled: PropTypes.bool,
|
|
107
|
+
pagination: PropTypes.shape({
|
|
108
|
+
activePage: PropTypes.number.isRequired,
|
|
109
|
+
pageCount: PropTypes.number.isRequired,
|
|
110
|
+
}),
|
|
111
|
+
totals: PropTypes.shape({}),
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default Table;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
background-color: var(--clr-grey700);
|
|
3
|
+
border: .1rem transparent solid;
|
|
4
|
+
border-radius: .3rem;
|
|
5
|
+
color: var(--clr-white);
|
|
6
|
+
display: inline-block;
|
|
7
|
+
font-weight: var(--fw-bold);
|
|
8
|
+
line-height: 2.8rem;
|
|
9
|
+
margin: -.5rem 0;
|
|
10
|
+
padding: 0 .8rem;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.rootPrimary {
|
|
14
|
+
background-color: var(--clr-primary);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.rootSecondary {
|
|
18
|
+
background-color: var(--clr-secondary);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rootSuccess {
|
|
22
|
+
background-color: var(--clr-success);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.rootWarning {
|
|
26
|
+
background-color: var(--clr-warning);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.rootDanger {
|
|
30
|
+
background-color: var(--clr-danger);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.rootBorderedDanger {
|
|
34
|
+
background-color: var(--clr-white);
|
|
35
|
+
border-color: var(--clr-danger);
|
|
36
|
+
color: var(--clr-danger);
|
|
37
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import type { Story } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
import Tag from './index';
|
|
7
|
+
import type { TagProps } from './index';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: 'Components/Tag',
|
|
11
|
+
component: Tag,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const Template: Story<TagProps> = (props) => <Tag {...props} />;
|
|
15
|
+
|
|
16
|
+
export const Basic = Template.bind({});
|
|
17
|
+
|
|
18
|
+
Basic.args = {
|
|
19
|
+
children: 'Lorem Ipsum',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const Primary = Template.bind({});
|
|
23
|
+
|
|
24
|
+
Primary.args = {
|
|
25
|
+
children: 'Lorem Ipsum',
|
|
26
|
+
variant: 'primary',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Success = Template.bind({});
|
|
30
|
+
|
|
31
|
+
Success.args = {
|
|
32
|
+
children: 'Lorem Ipsum',
|
|
33
|
+
variant: 'success',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Warning = Template.bind({});
|
|
37
|
+
|
|
38
|
+
Warning.args = {
|
|
39
|
+
children: 'Lorem Ipsum',
|
|
40
|
+
variant: 'warning',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const Danger = Template.bind({});
|
|
44
|
+
|
|
45
|
+
Danger.args = {
|
|
46
|
+
children: 'Lorem Ipsum',
|
|
47
|
+
variant: 'danger',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const BorderedDanger = Template.bind({});
|
|
51
|
+
|
|
52
|
+
BorderedDanger.args = {
|
|
53
|
+
children: 'Lorem Ipsum',
|
|
54
|
+
variant: ['bordered', 'danger'],
|
|
55
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import useVariant from '@hooks/useVariant';
|
|
6
|
+
|
|
7
|
+
import type { StyleVariant } from '@utility/interfaces';
|
|
8
|
+
import { StyleVariantPropType } from '@utility/prop-types';
|
|
9
|
+
|
|
10
|
+
import styles from './Tag.module.css';
|
|
11
|
+
|
|
12
|
+
export interface TagProps {
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
variant?: StyleVariant | StyleVariant[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const Tag: React.FunctionComponent<TagProps> = ({ children, variant }) => {
|
|
18
|
+
const { applyVariantClassName } = useVariant(variant);
|
|
19
|
+
return <div className={classNames(styles.root, applyVariantClassName(styles))}>{children}</div>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Tag.propTypes = {
|
|
23
|
+
children: PropTypes.node.isRequired,
|
|
24
|
+
variant: StyleVariantPropType,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default Tag;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
background-color: var(--clr-white);
|
|
3
|
+
border: .1rem var(--clr-grey400) solid;
|
|
4
|
+
border-radius: .3rem;
|
|
5
|
+
color: var(--clr-grey600);
|
|
6
|
+
display: block;
|
|
7
|
+
font-family: inherit;
|
|
8
|
+
font-size: var(--fs-med);
|
|
9
|
+
resize: vertical;
|
|
10
|
+
padding: 1rem 1.2rem;
|
|
11
|
+
transition: border-color .2s;
|
|
12
|
+
width: 100%;
|
|
13
|
+
|
|
14
|
+
&:focus {
|
|
15
|
+
border-color: var(--clr-primary);
|
|
16
|
+
color: var(--clr-grey700);
|
|
17
|
+
outline: none;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rootHasError {
|
|
22
|
+
border-color: var(--clr-error);
|
|
23
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
import TextArea from './index';
|
|
6
|
+
|
|
7
|
+
describe('TextArea', () => {
|
|
8
|
+
it('should render', () => {
|
|
9
|
+
render(<TextArea name="lorem" />);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should render defaults', () => {
|
|
13
|
+
render(<TextArea name="lorem" />);
|
|
14
|
+
|
|
15
|
+
const input = screen.getByRole('textbox');
|
|
16
|
+
|
|
17
|
+
expect(input).not.toBeDisabled();
|
|
18
|
+
expect(input).toHaveValue('');
|
|
19
|
+
expect(input).toHaveClass('root');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should have value', () => {
|
|
23
|
+
render(<TextArea name="lorem" value="lorem" />);
|
|
24
|
+
expect(screen.getByRole('textbox')).toHaveValue('lorem');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should handle onChange', () => {
|
|
28
|
+
const mockFn = jest.fn();
|
|
29
|
+
render(<TextArea name="lorem" onChange={mockFn} />);
|
|
30
|
+
|
|
31
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
32
|
+
|
|
33
|
+
const input = screen.getByRole('textbox');
|
|
34
|
+
userEvent.type(input, 'lorem');
|
|
35
|
+
|
|
36
|
+
expect(mockFn).toHaveBeenCalledTimes(5);
|
|
37
|
+
expect(mockFn).toHaveBeenLastCalledWith({ target: { name: 'lorem', value: 'lorem' } });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should handle onchange without onchange', () => {
|
|
41
|
+
const mockFn = jest.fn();
|
|
42
|
+
render(<TextArea name="lorem" />);
|
|
43
|
+
|
|
44
|
+
const input = screen.getByRole('textbox');
|
|
45
|
+
userEvent.type(input, 'lorem');
|
|
46
|
+
|
|
47
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should handle keydown', () => {
|
|
51
|
+
const mockFn = jest.fn();
|
|
52
|
+
render(<TextArea name="lorem" onKeyDown={mockFn} />);
|
|
53
|
+
|
|
54
|
+
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
55
|
+
userEvent.type(screen.getByRole('textbox'), 'a');
|
|
56
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should render error', () => {
|
|
60
|
+
render(<TextArea name="lorem" hasError />);
|
|
61
|
+
expect(screen.getByRole('textbox')).toHaveClass('root rootHasError');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should render disabled', () => {
|
|
65
|
+
render(<TextArea name="lorem" isDisabled />);
|
|
66
|
+
|
|
67
|
+
const input = screen.getByRole('textbox');
|
|
68
|
+
|
|
69
|
+
expect(input).toBeDisabled();
|
|
70
|
+
expect(input).toHaveClass('root rootIsDisabled');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should render placeholder', () => {
|
|
74
|
+
render(<TextArea name="lorem" placeholder="lorem" />);
|
|
75
|
+
expect(screen.getByRole('textbox')).toHaveAttribute('placeholder', 'lorem');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import type { TextInputProps } from '@components/TextInput';
|
|
6
|
+
|
|
7
|
+
import styles from './TextArea.module.css';
|
|
8
|
+
|
|
9
|
+
const TextArea: React.FunctionComponent<TextInputProps> = ({
|
|
10
|
+
name,
|
|
11
|
+
placeholder,
|
|
12
|
+
value,
|
|
13
|
+
hasError,
|
|
14
|
+
isDisabled,
|
|
15
|
+
onChange,
|
|
16
|
+
onKeyDown,
|
|
17
|
+
}) => {
|
|
18
|
+
const handleChange = (event: React.ChangeEvent): void => {
|
|
19
|
+
const target = event.target as HTMLInputElement;
|
|
20
|
+
const simpleEvent = { target: { name, value: target.value } };
|
|
21
|
+
|
|
22
|
+
if (onChange) {
|
|
23
|
+
onChange(simpleEvent);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<textarea
|
|
29
|
+
className={classNames(
|
|
30
|
+
styles.root,
|
|
31
|
+
hasError && styles.rootHasError,
|
|
32
|
+
isDisabled && styles.rootIsDisabled
|
|
33
|
+
)}
|
|
34
|
+
disabled={isDisabled}
|
|
35
|
+
id={`c_${name}`}
|
|
36
|
+
name={name}
|
|
37
|
+
onChange={handleChange}
|
|
38
|
+
onKeyDown={onKeyDown}
|
|
39
|
+
placeholder={placeholder}
|
|
40
|
+
rows={6}
|
|
41
|
+
value={value?.toString()}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
TextArea.propTypes = {
|
|
47
|
+
/** The name of the field. An ID is also generated from this (`c_${name}`). */
|
|
48
|
+
name: PropTypes.string.isRequired,
|
|
49
|
+
|
|
50
|
+
/** If set to trute, the `TextArea` will be styled to indicate this */
|
|
51
|
+
hasError: PropTypes.bool,
|
|
52
|
+
isDisabled: PropTypes.bool,
|
|
53
|
+
placeholder: PropTypes.string,
|
|
54
|
+
value: PropTypes.string,
|
|
55
|
+
onChange: PropTypes.func,
|
|
56
|
+
onKeyDown: PropTypes.func,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default TextArea;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
.rootHasPrefix {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row-reverse;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.rootHasSuffix {
|
|
7
|
+
display: flex;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.rootIsDisabled {
|
|
11
|
+
opacity: .3;
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.input {
|
|
16
|
+
appearance: none;
|
|
17
|
+
background-color: var(--clr-white);
|
|
18
|
+
border: .1rem var(--clr-grey400) solid;
|
|
19
|
+
border-radius: .3rem;
|
|
20
|
+
color: var(--clr-grey600);
|
|
21
|
+
display: block;
|
|
22
|
+
font-family: inherit;
|
|
23
|
+
font-size: var(--fs-med);
|
|
24
|
+
height: var(--input-height);
|
|
25
|
+
padding: 0 1.2rem;
|
|
26
|
+
transition: border-color .2s;
|
|
27
|
+
width: 100%;
|
|
28
|
+
|
|
29
|
+
&::-ms-reveal,
|
|
30
|
+
&::-ms-clear {
|
|
31
|
+
display: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&::-webkit-input-placeholder {
|
|
35
|
+
color: var(--clr-grey500);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:focus {
|
|
39
|
+
border-color: var(--clr-primary);
|
|
40
|
+
color: var(--clr-grey700);
|
|
41
|
+
outline: none;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.inputHasError {
|
|
46
|
+
border-color: var(--clr-error);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.inputHasPrefix {
|
|
50
|
+
border-left: 0;
|
|
51
|
+
border-radius: 0 .3rem .3rem 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.inputHasSuffix {
|
|
55
|
+
border-radius: .3rem 0 0 .3rem;
|
|
56
|
+
border-right: 0;
|
|
57
|
+
}
|