@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,114 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import Icon from '@core/Icon';
|
|
6
|
+
import IconButton from '@core/IconButton';
|
|
7
|
+
|
|
8
|
+
import type { InputProps, InputValue } from '@utility/interfaces';
|
|
9
|
+
|
|
10
|
+
import styles from './StaticTextInput.module.css';
|
|
11
|
+
|
|
12
|
+
interface StaticTextInputProps extends InputProps<InputValue, HTMLButtonElement> {
|
|
13
|
+
icon?: string;
|
|
14
|
+
isOpen?: boolean;
|
|
15
|
+
isOptional?: boolean;
|
|
16
|
+
label?: string | null;
|
|
17
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const hasValue = (value?: InputValue): boolean => {
|
|
22
|
+
if (Array.isArray(value)) {
|
|
23
|
+
return Boolean(value.filter((item) => Boolean(item)).length);
|
|
24
|
+
}
|
|
25
|
+
return Boolean(value);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const StaticTextInput: React.FunctionComponent<StaticTextInputProps> = ({
|
|
29
|
+
hasError,
|
|
30
|
+
icon,
|
|
31
|
+
isDisabled,
|
|
32
|
+
isOpen,
|
|
33
|
+
isOptional,
|
|
34
|
+
label,
|
|
35
|
+
name,
|
|
36
|
+
onChange,
|
|
37
|
+
onClick,
|
|
38
|
+
onKeyDown,
|
|
39
|
+
placeholder = 'Select...',
|
|
40
|
+
value,
|
|
41
|
+
}) => {
|
|
42
|
+
const handleNullChange = (): void => {
|
|
43
|
+
if (onChange) {
|
|
44
|
+
onChange({ target: { name, value: null } });
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
className={classNames(
|
|
51
|
+
styles.root,
|
|
52
|
+
hasError && styles.rootHasError,
|
|
53
|
+
isDisabled && styles.rootIsDisabled,
|
|
54
|
+
!hasValue(value) && styles.rootIsPlaceholder
|
|
55
|
+
)}
|
|
56
|
+
data-testid="static-text-input-root"
|
|
57
|
+
>
|
|
58
|
+
<input
|
|
59
|
+
className={styles.input}
|
|
60
|
+
name={name}
|
|
61
|
+
type="hidden"
|
|
62
|
+
value={value ? value.toString() : ''}
|
|
63
|
+
/>
|
|
64
|
+
|
|
65
|
+
{label || placeholder}
|
|
66
|
+
|
|
67
|
+
{icon && !isDisabled && (
|
|
68
|
+
<div className={styles.icon}>
|
|
69
|
+
<Icon icon={icon} />
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
|
|
73
|
+
{onClick && (
|
|
74
|
+
<button
|
|
75
|
+
className={styles.control}
|
|
76
|
+
disabled={isDisabled}
|
|
77
|
+
onClick={onClick}
|
|
78
|
+
onKeyDown={onKeyDown}
|
|
79
|
+
type="button"
|
|
80
|
+
>
|
|
81
|
+
{isOpen ? 'Close' : 'Open'}
|
|
82
|
+
</button>
|
|
83
|
+
)}
|
|
84
|
+
|
|
85
|
+
{isOptional && hasValue(value) && (
|
|
86
|
+
<span className={classNames(styles.icon, styles.iconClear)}>
|
|
87
|
+
<IconButton icon="x" onClick={handleNullChange} size="sm">
|
|
88
|
+
Clear
|
|
89
|
+
</IconButton>
|
|
90
|
+
</span>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
StaticTextInput.propTypes = {
|
|
97
|
+
name: PropTypes.string.isRequired,
|
|
98
|
+
hasError: PropTypes.bool,
|
|
99
|
+
icon: PropTypes.string,
|
|
100
|
+
isDisabled: PropTypes.bool,
|
|
101
|
+
isOpen: PropTypes.bool,
|
|
102
|
+
isOptional: PropTypes.bool,
|
|
103
|
+
label: PropTypes.string,
|
|
104
|
+
placeholder: PropTypes.string,
|
|
105
|
+
value: PropTypes.oneOfType([
|
|
106
|
+
PropTypes.string,
|
|
107
|
+
PropTypes.number,
|
|
108
|
+
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired),
|
|
109
|
+
]),
|
|
110
|
+
onChange: PropTypes.func,
|
|
111
|
+
onClick: PropTypes.func,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default StaticTextInput;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import Styled from './index';
|
|
5
|
+
|
|
6
|
+
describe('Styled', () => {
|
|
7
|
+
it('should render', () => {
|
|
8
|
+
render(<Styled>Lorem</Styled>);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should render without style', () => {
|
|
12
|
+
render(<Styled>Lorem</Styled>);
|
|
13
|
+
|
|
14
|
+
const root = screen.getByTestId('styled-root');
|
|
15
|
+
|
|
16
|
+
expect(root.nodeName).toBe('SPAN');
|
|
17
|
+
expect(root).toHaveTextContent('Lorem');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should render with style', () => {
|
|
21
|
+
render(<Styled>[primary]:Lorem</Styled>);
|
|
22
|
+
|
|
23
|
+
const root = screen.getByTestId('styled-root');
|
|
24
|
+
|
|
25
|
+
expect(root.nodeName).toBe('STRONG');
|
|
26
|
+
expect(root).toHaveTextContent('Lorem');
|
|
27
|
+
expect(root).toHaveStyle('color: var(--clr-primary)');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should render with no content', () => {
|
|
31
|
+
render(<Styled>{null}</Styled>);
|
|
32
|
+
|
|
33
|
+
const root = screen.getByTestId('styled-root');
|
|
34
|
+
|
|
35
|
+
expect(root.nodeName).toBe('SPAN');
|
|
36
|
+
expect(root).toHaveTextContent('');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Styled from './index';
|
|
3
|
+
|
|
4
|
+
export default { title: 'Core/Styled', component: Styled };
|
|
5
|
+
|
|
6
|
+
export const Default = (): React.ReactElement => <Styled>[primary]:Lorem Ipsum</Styled>;
|
|
7
|
+
|
|
8
|
+
export const Error = (): React.ReactElement => <Styled>[error]:Lorem Ipsum</Styled>;
|
|
9
|
+
|
|
10
|
+
export const Unstyled = (): React.ReactElement => <Styled>Lorem Ipsum</Styled>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
const formatStyle = (input: React.ReactNode): string | [string, string] => {
|
|
4
|
+
if (!input) {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const match = /^\[(?<style>[^]+)\]:(?<text>.+)/u.exec(input.toString());
|
|
9
|
+
|
|
10
|
+
if (!match) {
|
|
11
|
+
return input as string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { style, text } = match.groups as { style: string; text: string };
|
|
15
|
+
return [style, text];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
interface StyledComponentProps {
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A little utility component that allows strings to be styled with a colour. An example where this
|
|
24
|
+
* is used by a Square Zero Admin component is the `meta` prop of a `ListItem`. By using the
|
|
25
|
+
* following syntax:
|
|
26
|
+
*
|
|
27
|
+
* ```
|
|
28
|
+
* [style]:content
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* You are able to colour text that wouldn't otherwise be stylable. For example, the primary colour:
|
|
32
|
+
*
|
|
33
|
+
* ```
|
|
34
|
+
* [primary]:Lorem Ipsum Dolor
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* If a style is specified, the text is also emboldened in order to emphasize the colour. If a
|
|
38
|
+
* string is passed that does match the format, it is simply rendered as-is.
|
|
39
|
+
*
|
|
40
|
+
* React's forwardRef is required to handle situations where `Styled` is used with a `Link`, due to
|
|
41
|
+
* the way the Next.js link works under the hood.
|
|
42
|
+
*/
|
|
43
|
+
const StyledComponent: React.ForwardRefRenderFunction<HTMLButtonElement, StyledComponentProps> = (
|
|
44
|
+
{ children }: StyledComponentProps,
|
|
45
|
+
ref
|
|
46
|
+
) => {
|
|
47
|
+
const formatted = formatStyle(children);
|
|
48
|
+
|
|
49
|
+
return Array.isArray(formatted) ? (
|
|
50
|
+
<strong ref={ref} data-testid="styled-root" style={{ color: `var(--clr-${formatted[0]})` }}>
|
|
51
|
+
{formatted[1]}
|
|
52
|
+
</strong>
|
|
53
|
+
) : (
|
|
54
|
+
<span ref={ref} data-testid="styled-root">
|
|
55
|
+
{formatted}
|
|
56
|
+
</span>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const Styled = forwardRef<HTMLButtonElement, StyledComponentProps>(StyledComponent);
|
|
61
|
+
|
|
62
|
+
export default Styled;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
background: var(--clr-white);
|
|
3
|
+
border-radius: .5rem;
|
|
4
|
+
margin-bottom: 1rem;
|
|
5
|
+
padding: 1rem 1.5rem;
|
|
6
|
+
position: relative;
|
|
7
|
+
|
|
8
|
+
@media (--media-sml) {
|
|
9
|
+
width: calc(50% - 1rem);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@media (--media-med) {
|
|
13
|
+
width: 24%;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.term {
|
|
18
|
+
color: var(--clr-grey600);
|
|
19
|
+
font-size: var(--fs-xsml);
|
|
20
|
+
font-weight: var(--fw-bold);
|
|
21
|
+
letter-spacing: .1em;
|
|
22
|
+
text-transform: uppercase;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.definition {
|
|
26
|
+
font-size: var(--fs-med);
|
|
27
|
+
font-weight: var(--fw-bold);
|
|
28
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import Link from '@components/Link';
|
|
5
|
+
|
|
6
|
+
import Styled from '@core/Styled';
|
|
7
|
+
|
|
8
|
+
import styles from './SummaryListItem.module.css';
|
|
9
|
+
|
|
10
|
+
interface SummaryListItemDefinition {
|
|
11
|
+
key?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
render?: (key: string) => React.ReactNode;
|
|
14
|
+
to?: string | null;
|
|
15
|
+
type?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type SummaryListValue = SummaryListItemDefinition | number | string;
|
|
19
|
+
|
|
20
|
+
export interface SummaryListObject {
|
|
21
|
+
label: string;
|
|
22
|
+
value: SummaryListValue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const renderDefinition = (
|
|
26
|
+
definition: SummaryListItemDefinition | number | string
|
|
27
|
+
): React.ReactNode => {
|
|
28
|
+
if (typeof definition !== 'object') {
|
|
29
|
+
return definition;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (definition.render && typeof definition.render === 'function') {
|
|
33
|
+
return definition.render(definition.key || '');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (definition.type === 'link' && definition.to) {
|
|
37
|
+
return <Link to={definition.to}>{definition.label}</Link>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (definition.type === 'styled') {
|
|
41
|
+
return <Styled>{definition.label}</Styled>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return 'object';
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const SummaryListItem: React.FunctionComponent<SummaryListObject> = ({ label, value }) => (
|
|
48
|
+
<div className={styles.root}>
|
|
49
|
+
<dt className={styles.term}>{label}</dt>
|
|
50
|
+
<dd className={styles.definition}>{renderDefinition(value)}</dd>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
SummaryListItem.propTypes = {
|
|
55
|
+
label: PropTypes.string.isRequired,
|
|
56
|
+
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.shape({})])
|
|
57
|
+
.isRequired,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default SummaryListItem;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import ListItemActions from '@core/ListItemActions';
|
|
5
|
+
|
|
6
|
+
import type { SimpleAction } from '@utility/interfaces';
|
|
7
|
+
|
|
8
|
+
import cellStyles from '../TableCell/TableCell.module.css';
|
|
9
|
+
import styles from './TableActionsCell.module.css';
|
|
10
|
+
|
|
11
|
+
interface TableActionsCellProps {
|
|
12
|
+
actions: SimpleAction[] | ((data?: Record<string, unknown>) => SimpleAction[]);
|
|
13
|
+
data?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const TableActionsCell: React.FunctionComponent<TableActionsCellProps> = ({ actions, data }) => (
|
|
17
|
+
<td className={cellStyles.root}>
|
|
18
|
+
<div className={styles.inner}>
|
|
19
|
+
<ListItemActions actions={actions} data={data} />
|
|
20
|
+
</div>
|
|
21
|
+
</td>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
TableActionsCell.propTypes = {
|
|
25
|
+
actions: PropTypes.oneOfType([
|
|
26
|
+
PropTypes.arrayOf(
|
|
27
|
+
PropTypes.shape({
|
|
28
|
+
label: PropTypes.string.isRequired,
|
|
29
|
+
onClick: PropTypes.func.isRequired,
|
|
30
|
+
}).isRequired
|
|
31
|
+
),
|
|
32
|
+
PropTypes.func,
|
|
33
|
+
]).isRequired,
|
|
34
|
+
data: PropTypes.shape({}).isRequired,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default TableActionsCell;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
border: var(--clr-grey300) solid;
|
|
3
|
+
border-width: .1rem 0;
|
|
4
|
+
font-size: var(--fs-sml);
|
|
5
|
+
padding: 1.5rem 1rem;
|
|
6
|
+
text-align: left;
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
tr:nth-child(2n - 1) .root {
|
|
11
|
+
background-color: var(--clr-grey100);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.rootIsRightAligned {
|
|
15
|
+
text-align: right;
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { isValidElement } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import Styled from '@core/Styled';
|
|
6
|
+
|
|
7
|
+
import styles from './TableCell.module.css';
|
|
8
|
+
|
|
9
|
+
export type Columns = Record<string, string | [string, boolean?]>;
|
|
10
|
+
|
|
11
|
+
interface TableCellProps {
|
|
12
|
+
value?: React.ReactElement | string;
|
|
13
|
+
isRightAligned?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const renderCellValue = (value?: React.ReactElement | string): React.ReactNode => {
|
|
17
|
+
if (!value) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (isValidElement(value)) {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return <Styled>{value}</Styled>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const TableCell: React.FunctionComponent<TableCellProps> = ({ isRightAligned, value }) => (
|
|
29
|
+
<td className={classNames(styles.root, isRightAligned && styles.rootIsRightAligned)}>
|
|
30
|
+
{renderCellValue(value)}
|
|
31
|
+
</td>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
TableCell.propTypes = {
|
|
35
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,
|
|
36
|
+
isRightAligned: PropTypes.bool,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default TableCell;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import Assistive from '@core/Assistive';
|
|
6
|
+
import type { TransformedColumn } from '@core/TableRow';
|
|
7
|
+
|
|
8
|
+
import styles from './TableHead.module.css';
|
|
9
|
+
|
|
10
|
+
interface TableHeadProps {
|
|
11
|
+
hasActions?: boolean;
|
|
12
|
+
columns: TransformedColumn[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const TableHead: React.FunctionComponent<TableHeadProps> = ({ hasActions, columns }) => (
|
|
16
|
+
<thead>
|
|
17
|
+
<tr>
|
|
18
|
+
{columns.map((item) => (
|
|
19
|
+
<th
|
|
20
|
+
key={item.key}
|
|
21
|
+
className={classNames(
|
|
22
|
+
styles.root,
|
|
23
|
+
item.isRightAligned && styles.rootIsRightAligned
|
|
24
|
+
)}
|
|
25
|
+
>
|
|
26
|
+
{item.title}
|
|
27
|
+
</th>
|
|
28
|
+
))}
|
|
29
|
+
{hasActions && (
|
|
30
|
+
<th className={classNames(styles.root)}>
|
|
31
|
+
<Assistive>Actions</Assistive>
|
|
32
|
+
</th>
|
|
33
|
+
)}
|
|
34
|
+
</tr>
|
|
35
|
+
</thead>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
TableHead.propTypes = {
|
|
39
|
+
columns: PropTypes.arrayOf(
|
|
40
|
+
PropTypes.shape({
|
|
41
|
+
key: PropTypes.string.isRequired,
|
|
42
|
+
title: PropTypes.string.isRequired,
|
|
43
|
+
}).isRequired
|
|
44
|
+
).isRequired,
|
|
45
|
+
hasActions: PropTypes.bool,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default TableHead;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { isValidElement } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import TableActionsCell from '@core/TableActionsCell';
|
|
5
|
+
import TableCell from '@core/TableCell';
|
|
6
|
+
|
|
7
|
+
import type { TransformedObject } from '@utility/interfaces';
|
|
8
|
+
|
|
9
|
+
export interface TransformedColumn {
|
|
10
|
+
key: number | string;
|
|
11
|
+
title: string;
|
|
12
|
+
isRightAligned?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface TableRowProps {
|
|
16
|
+
columns: TransformedColumn[];
|
|
17
|
+
data: TransformedObject;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const parseValue = (value: unknown): React.ReactElement | string => {
|
|
21
|
+
if (!value) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (typeof value === 'object' && isValidElement(value)) {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (value as string).toString();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const TableRow: React.FunctionComponent<TableRowProps> = ({ columns, data }) => (
|
|
33
|
+
<tr>
|
|
34
|
+
{columns.map((item) => (
|
|
35
|
+
<TableCell
|
|
36
|
+
key={item.key}
|
|
37
|
+
isRightAligned={item.isRightAligned}
|
|
38
|
+
value={parseValue(data[item.key])}
|
|
39
|
+
/>
|
|
40
|
+
))}
|
|
41
|
+
{data.$actions?.length ? <TableActionsCell actions={data.$actions} data={data} /> : null}
|
|
42
|
+
</tr>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
TableRow.propTypes = {
|
|
46
|
+
columns: PropTypes.arrayOf(
|
|
47
|
+
PropTypes.shape({
|
|
48
|
+
key: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
49
|
+
title: PropTypes.string.isRequired,
|
|
50
|
+
}).isRequired
|
|
51
|
+
).isRequired,
|
|
52
|
+
data: PropTypes.shape({
|
|
53
|
+
$id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
54
|
+
$original: PropTypes.shape({}).isRequired,
|
|
55
|
+
$actions: PropTypes.arrayOf(
|
|
56
|
+
PropTypes.shape({
|
|
57
|
+
label: PropTypes.string.isRequired,
|
|
58
|
+
onClick: PropTypes.func.isRequired,
|
|
59
|
+
}).isRequired
|
|
60
|
+
),
|
|
61
|
+
}).isRequired,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default TableRow;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
background-color: var(--clr-white);
|
|
3
|
+
box-shadow: 0 .3rem .3rem rgba(0, 0, 0, .02), 0 1rem 1rem rgba(0, 0, 0, .02);
|
|
4
|
+
padding: 0 clamp(1rem, 2.5vw, 3rem);
|
|
5
|
+
position: sticky;
|
|
6
|
+
top: 8rem;
|
|
7
|
+
z-index: 3;
|
|
8
|
+
|
|
9
|
+
&::before {
|
|
10
|
+
border-top: .1rem var(--clr-grey300) solid;
|
|
11
|
+
content: '';
|
|
12
|
+
left: clamp(1rem, 2.5vw, 3rem);
|
|
13
|
+
position: absolute;
|
|
14
|
+
right: clamp(1rem, 2.5vw, 3rem);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.rootTopbar {
|
|
19
|
+
position: relative;
|
|
20
|
+
top: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.list {
|
|
24
|
+
display: flex;
|
|
25
|
+
padding: 1rem 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.item {
|
|
29
|
+
margin-right: 1rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.itemIsDisabled {
|
|
33
|
+
opacity: .3;
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.link {
|
|
38
|
+
color: var(--clr-grey700);
|
|
39
|
+
border-radius: .3rem;
|
|
40
|
+
display: block;
|
|
41
|
+
font-size: var(--fs-sml);
|
|
42
|
+
font-weight: var(--fw-bold);
|
|
43
|
+
line-height: 1;
|
|
44
|
+
padding: 1rem;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.linkIsActive {
|
|
48
|
+
background-color: var(--clr-grey200);
|
|
49
|
+
pointer-events: none;
|
|
50
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import type { NextRouter } from 'next/router';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
|
|
7
|
+
import { EventService } from '@sqrzro/utility';
|
|
8
|
+
|
|
9
|
+
import Link from '@components/Link';
|
|
10
|
+
import useLayout from '@hooks/useLayout';
|
|
11
|
+
|
|
12
|
+
import styles from './Tabs.module.css';
|
|
13
|
+
|
|
14
|
+
export interface TabItem {
|
|
15
|
+
label: string;
|
|
16
|
+
route: string;
|
|
17
|
+
isDisabled?: boolean | ((item: TabItem, sceneData: Record<string, unknown>) => boolean) | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const checkDisabled = (item: TabItem, sceneData: Record<string, unknown>): boolean => {
|
|
21
|
+
if (!item.isDisabled) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return typeof item.isDisabled === 'function'
|
|
26
|
+
? item.isDisabled(item, sceneData)
|
|
27
|
+
: item.isDisabled;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const checkActive = (router: NextRouter, route: string): boolean => {
|
|
31
|
+
if (!router) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return router.pathname === `/${route.replace(/^\//u, '')}`;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
interface TabsProps {
|
|
39
|
+
data: TabItem[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const Tabs: React.FunctionComponent<TabsProps> = ({ data }) => {
|
|
43
|
+
const { applyLayoutClassName } = useLayout();
|
|
44
|
+
const router = useRouter();
|
|
45
|
+
const [sceneData, setSceneData] = useState({});
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const sub = EventService.subscribe('@scene/data', (_key, responseData) => {
|
|
49
|
+
setSceneData(responseData);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return (): void => {
|
|
53
|
+
EventService.unsubscribe(sub);
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<nav className={classNames(styles.root, applyLayoutClassName(styles))}>
|
|
59
|
+
<ul className={styles.list}>
|
|
60
|
+
{data.map((item) => (
|
|
61
|
+
<li
|
|
62
|
+
key={item.label}
|
|
63
|
+
className={classNames(
|
|
64
|
+
styles.item,
|
|
65
|
+
checkDisabled(item, sceneData) && styles.itemIsDisabled
|
|
66
|
+
)}
|
|
67
|
+
>
|
|
68
|
+
<Link
|
|
69
|
+
className={classNames(
|
|
70
|
+
styles.link,
|
|
71
|
+
checkActive(router, item.route) && styles.linkIsActive
|
|
72
|
+
)}
|
|
73
|
+
to={item.route}
|
|
74
|
+
>
|
|
75
|
+
{item.label}
|
|
76
|
+
</Link>
|
|
77
|
+
</li>
|
|
78
|
+
))}
|
|
79
|
+
</ul>
|
|
80
|
+
</nav>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
Tabs.propTypes = {
|
|
85
|
+
data: PropTypes.arrayOf(
|
|
86
|
+
PropTypes.shape({
|
|
87
|
+
isDisabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
88
|
+
label: PropTypes.string.isRequired,
|
|
89
|
+
route: PropTypes.string.isRequired,
|
|
90
|
+
}).isRequired
|
|
91
|
+
).isRequired,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default Tabs;
|