@sqrzro/admin 1.0.0-beta.7 → 2.0.0
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 +5 -1
- package/.storybook/main.js +6 -34
- package/.storybook/preview-head.html +3 -0
- package/.storybook/preview.js +1 -11
- package/.turbo/turbo-docs.log +0 -0
- package/.turbo/turbo-lint.log +112 -0
- package/.turbo/turbo-prettier.log +215 -0
- package/.turbo/turbo-test.log +6 -0
- package/LICENSE +1 -1
- package/dist/{types/components → components}/Alert/index.d.ts +4 -4
- package/dist/components/Alert/index.js +15 -0
- package/dist/{types/components → components}/Allow/index.d.ts +20 -13
- package/dist/components/Allow/index.js +29 -0
- package/dist/components/AppLayout/AppLayout.stories.d.ts +5 -0
- package/dist/components/AppLayout/AppLayout.stories.js +11 -0
- package/dist/components/AppLayout/index.d.ts +6 -0
- package/dist/components/AppLayout/index.js +18 -0
- package/dist/{types/components → components}/AutoSuggest/index.d.ts +74 -60
- package/dist/components/AutoSuggest/index.js +143 -0
- package/dist/components/Button/Button.stories.d.ts +11 -0
- package/{src/components/Button/Button.story.tsx → dist/components/Button/Button.stories.js} +16 -14
- package/dist/{types/components → components}/Button/index.d.ts +49 -36
- package/dist/components/Button/index.js +50 -0
- package/dist/components/CalendarInput/index.d.ts +24 -0
- package/dist/components/CalendarInput/index.js +54 -0
- package/dist/{types/components → components}/CheckboxList/index.d.ts +17 -17
- package/dist/components/CheckboxList/index.js +25 -0
- package/dist/components/CodeInput/index.d.ts +9 -0
- package/dist/components/CodeInput/index.js +51 -0
- package/dist/{types/components → components}/ConnectedDropdown/index.d.ts +14 -14
- package/dist/components/ConnectedDropdown/index.js +36 -0
- package/dist/{types/components → components}/ConnectedList/index.d.ts +5 -5
- package/dist/components/ConnectedList/index.js +7 -0
- package/dist/{types/components → components}/ConnectedTable/index.d.ts +5 -5
- package/dist/components/ConnectedTable/index.js +7 -0
- package/dist/{types/components → components}/ContentBlock/index.d.ts +16 -16
- package/dist/components/ContentBlock/index.js +13 -0
- package/dist/components/DataPanel/index.d.ts +8 -0
- package/dist/components/DataPanel/index.js +8 -0
- package/dist/components/DateInput/index.d.ts +18 -0
- package/dist/components/DateInput/index.js +81 -0
- package/dist/{types/components → components}/Dropdown/index.d.ts +36 -36
- package/dist/components/Dropdown/index.js +122 -0
- package/dist/components/ErrorMessage/index.d.ts +16 -0
- package/dist/components/ErrorMessage/index.js +17 -0
- package/dist/components/Fieldset/index.d.ts +18 -0
- package/dist/components/Fieldset/index.js +19 -0
- package/dist/{types/components → components}/FileInput/index.d.ts +10 -10
- package/dist/components/FileInput/index.js +26 -0
- package/dist/components/FilterLink/index.d.ts +14 -0
- package/dist/components/FilterLink/index.js +15 -0
- package/dist/components/Form/index.d.ts +14 -0
- package/dist/components/Form/index.js +15 -0
- package/dist/components/FormActions/index.d.ts +18 -0
- package/dist/components/FormActions/index.js +14 -0
- package/dist/{types/components → components}/FormField/index.d.ts +14 -14
- package/dist/components/FormField/index.js +40 -0
- package/dist/components/FormRepeater/index.d.ts +18 -0
- package/dist/components/FormRepeater/index.js +65 -0
- package/dist/{types/components → components}/ImageInput/index.d.ts +13 -13
- package/dist/components/ImageInput/index.js +45 -0
- package/dist/components/InfoPanel/index.d.ts +14 -0
- package/dist/components/InfoPanel/index.js +11 -0
- package/dist/{types/components → components}/Link/__mocks__/index.d.ts +6 -6
- package/dist/components/Link/__mocks__/index.js +12 -0
- package/dist/components/Link/index.d.ts +23 -0
- package/dist/components/Link/index.js +21 -0
- package/dist/{types/components → components}/List/index.d.ts +36 -36
- package/dist/components/List/index.js +46 -0
- package/dist/components/ListActions/index.d.ts +18 -0
- package/dist/components/ListActions/index.js +14 -0
- package/dist/components/LoginForm/index.d.ts +3 -0
- package/dist/components/LoginForm/index.js +47 -0
- package/dist/components/Message/index.d.ts +14 -0
- package/dist/components/Message/index.js +14 -0
- package/dist/{types/components → components}/Modal/index.d.ts +4 -4
- package/dist/components/Modal/index.js +18 -0
- package/dist/components/ModalActions/index.d.ts +21 -0
- package/dist/components/ModalActions/index.js +18 -0
- package/dist/{types/components → components}/MoneyInput/index.d.ts +10 -10
- package/dist/components/MoneyInput/index.js +13 -0
- package/dist/components/PasswordForm/index.d.ts +35 -0
- package/dist/components/PasswordForm/index.js +21 -0
- package/dist/components/PasswordInput/index.d.ts +4 -0
- package/dist/components/PasswordInput/index.js +12 -0
- package/dist/{types/components → components}/RadioList/index.d.ts +9 -9
- package/dist/components/RadioList/index.js +7 -0
- package/dist/components/RootLayout/index.d.ts +6 -0
- package/dist/components/RootLayout/index.js +7 -0
- package/dist/components/SummaryList/index.d.ts +18 -0
- package/dist/components/SummaryList/index.js +15 -0
- package/dist/components/Switch/index.d.ts +21 -0
- package/dist/components/Switch/index.js +31 -0
- package/dist/{types/components → components}/Table/index.d.ts +28 -28
- package/dist/components/Table/index.js +55 -0
- package/dist/components/Tag/index.d.ts +15 -0
- package/dist/components/Tag/index.js +13 -0
- package/dist/components/TextArea/index.d.ts +18 -0
- package/dist/components/TextArea/index.js +26 -0
- package/dist/{types/components → components}/TextInput/index.d.ts +14 -14
- package/dist/components/TextInput/index.js +27 -0
- package/dist/{types/components → components}/WebsiteInput/index.d.ts +10 -10
- package/dist/components/WebsiteInput/index.js +13 -0
- package/dist/components/WeekCalendar/index.d.ts +24 -0
- package/dist/components/WeekCalendar/index.js +48 -0
- package/dist/{types/core → core}/AlertComponent/index.d.ts +26 -26
- package/dist/core/AlertComponent/index.js +35 -0
- package/dist/{types/core → core}/AppHeader/index.d.ts +3 -3
- package/dist/core/AppHeader/index.js +17 -0
- package/dist/core/AppLogo/index.d.ts +12 -0
- package/dist/core/AppLogo/index.js +16 -0
- package/dist/{types/core → core}/AppLogoImage/index.d.ts +3 -3
- package/dist/core/AppLogoImage/index.js +11 -0
- package/dist/{types/core → core}/AppLogoPlaceholder/index.d.ts +3 -3
- package/dist/core/AppLogoPlaceholder/index.js +10 -0
- package/dist/core/Assistive/index.d.ts +12 -0
- package/dist/core/Assistive/index.js +9 -0
- package/dist/core/AuthForm/index.d.ts +10 -0
- package/dist/core/AuthForm/index.js +13 -0
- package/dist/{types/core → core}/Banner/index.d.ts +3 -3
- package/dist/core/Banner/index.js +14 -0
- package/dist/core/Calendar/index.d.ts +21 -0
- package/dist/core/Calendar/index.js +69 -0
- package/dist/core/CalendarDay/index.d.ts +30 -0
- package/dist/core/CalendarDay/index.js +30 -0
- package/dist/core/CalendarMonth/index.d.ts +23 -0
- package/dist/core/CalendarMonth/index.js +45 -0
- package/dist/core/CalendarNavigation/index.d.ts +17 -0
- package/dist/core/CalendarNavigation/index.js +24 -0
- package/dist/core/CalendarWeek/index.d.ts +28 -0
- package/dist/core/CalendarWeek/index.js +46 -0
- package/dist/core/ChkRad/index.d.ts +26 -0
- package/dist/core/ChkRad/index.js +33 -0
- package/dist/core/ChkRadIcon/index.d.ts +14 -0
- package/dist/core/ChkRadIcon/index.js +12 -0
- package/dist/{types/core → core}/ChkRadList/index.d.ts +32 -32
- package/dist/core/ChkRadList/index.js +37 -0
- package/dist/core/CloseButton/index.d.ts +17 -0
- package/dist/core/CloseButton/index.js +12 -0
- package/dist/{types/core → core}/ConfirmModal/index.d.ts +3 -3
- package/dist/core/ConfirmModal/index.js +38 -0
- package/dist/{types/core → core}/ConnectedRepeater/index.d.ts +50 -50
- package/dist/core/ConnectedRepeater/index.js +154 -0
- package/dist/{types/core → core}/ConnectedRepeaterComponent/index.d.ts +24 -24
- package/dist/core/ConnectedRepeaterComponent/index.js +25 -0
- package/dist/core/Container/index.d.ts +14 -0
- package/dist/core/Container/index.js +12 -0
- package/dist/core/DataPanelItem/index.d.ts +8 -0
- package/dist/core/DataPanelItem/index.js +7 -0
- package/dist/core/DropdownPanel/index.d.ts +31 -0
- package/dist/core/DropdownPanel/index.js +32 -0
- package/dist/{types/core → core}/EmptyMessage/index.d.ts +21 -14
- package/dist/core/EmptyMessage/index.js +21 -0
- package/dist/core/FilterItem/index.d.ts +25 -0
- package/dist/core/FilterItem/index.js +82 -0
- package/dist/core/Filters/index.d.ts +31 -0
- package/dist/core/Filters/index.js +85 -0
- package/dist/{types/core → core}/FixedActions/index.d.ts +24 -24
- package/dist/core/FixedActions/index.js +22 -0
- package/dist/core/FormError/index.d.ts +12 -0
- package/dist/core/FormError/index.js +9 -0
- package/dist/core/FormLabel/index.d.ts +16 -0
- package/dist/core/FormLabel/index.js +13 -0
- package/dist/core/FormLegend/index.d.ts +12 -0
- package/dist/core/FormLegend/index.js +9 -0
- package/dist/core/Header/Header.stories.d.ts +5 -0
- package/dist/core/Header/Header.stories.js +11 -0
- package/dist/core/Header/index.d.ts +14 -0
- package/dist/core/Header/index.js +12 -0
- package/dist/core/Icon/index.d.ts +14 -0
- package/dist/core/Icon/index.js +32 -0
- package/dist/core/IconButton/index.d.ts +22 -0
- package/dist/core/IconButton/index.js +20 -0
- package/dist/core/InputPanel/index.d.ts +16 -0
- package/dist/core/InputPanel/index.js +11 -0
- package/dist/{types/core → core}/ListItem/index.d.ts +39 -38
- package/dist/core/ListItem/index.js +44 -0
- package/dist/core/ListItemAction/index.d.ts +11 -0
- package/dist/core/ListItemAction/index.js +13 -0
- package/dist/{types/core → core}/ListItemActions/index.d.ts +8 -8
- package/dist/core/ListItemActions/index.js +16 -0
- package/dist/core/ListItemMetaItem/index.d.ts +19 -0
- package/dist/core/ListItemMetaItem/index.js +29 -0
- package/dist/core/ListItemTitle/index.d.ts +19 -0
- package/dist/core/ListItemTitle/index.js +44 -0
- package/dist/core/Loader/index.d.ts +15 -0
- package/dist/core/Loader/index.js +16 -0
- package/dist/core/MeActions/index.d.ts +3 -0
- package/dist/core/MeActions/index.js +48 -0
- package/dist/{types/core → core}/MePanel/index.d.ts +19 -19
- package/dist/core/MePanel/index.js +29 -0
- package/dist/core/ModalComponent/index.d.ts +22 -0
- package/dist/core/ModalComponent/index.js +29 -0
- package/dist/{types/core → core}/Navigation/index.d.ts +3 -3
- package/dist/core/Navigation/index.js +33 -0
- package/dist/{types/core → core}/NavigationDivider/index.d.ts +3 -3
- package/dist/core/NavigationDivider/index.js +8 -0
- package/dist/core/NavigationItem/index.d.ts +16 -0
- package/dist/core/NavigationItem/index.js +21 -0
- package/dist/core/Pagination/index.d.ts +15 -0
- package/{src/core/Pagination/index.tsx → dist/core/Pagination/index.js} +10 -46
- package/dist/core/PaginationItem/index.d.ts +10 -0
- package/dist/core/PaginationItem/index.js +17 -0
- package/dist/core/Panel/index.d.ts +17 -0
- package/dist/core/Panel/index.js +13 -0
- package/dist/{types/core → core}/PasswordForgotForm/index.d.ts +7 -7
- package/dist/core/PasswordForgotForm/index.js +40 -0
- package/dist/{types/core → core}/PasswordResetForm/index.d.ts +7 -7
- package/dist/core/PasswordResetForm/index.js +34 -0
- package/dist/core/RadialProgress/index.d.ts +16 -0
- package/dist/core/RadialProgress/index.js +23 -0
- package/dist/core/SettingsForm/index.d.ts +3 -0
- package/dist/core/SettingsForm/index.js +14 -0
- package/dist/core/StaticTextInput/index.d.ts +29 -0
- package/dist/core/StaticTextInput/index.js +39 -0
- package/dist/{types/core → core}/Styled/index.d.ts +6 -6
- package/{src/core/Styled/index.tsx → dist/core/Styled/index.js} +7 -30
- package/dist/core/SummaryListItem/index.d.ts +23 -0
- package/dist/core/SummaryListItem/index.js +31 -0
- package/dist/core/TabItem/index.d.ts +4 -0
- package/dist/core/TabItem/index.js +13 -0
- package/dist/{types/core → core}/TableActionsCell/index.d.ts +8 -8
- package/dist/core/TableActionsCell/index.js +8 -0
- package/dist/core/TableCell/index.d.ts +15 -0
- package/dist/core/TableCell/index.js +20 -0
- package/dist/core/TableHead/index.d.ts +18 -0
- package/dist/core/TableHead/index.js +18 -0
- package/dist/{types/core → core}/TableRow/index.d.ts +13 -13
- package/dist/core/TableRow/index.js +18 -0
- package/dist/core/Tabs/index.d.ts +7 -0
- package/dist/core/Tabs/index.js +13 -0
- package/dist/core/TextInputAncillary/index.d.ts +29 -0
- package/dist/core/TextInputAncillary/index.js +31 -0
- package/dist/{types/core → core}/Toast/index.d.ts +3 -3
- package/dist/core/Toast/index.js +47 -0
- package/dist/core/TwoFactor/index.d.ts +13 -0
- package/dist/core/TwoFactor/index.js +49 -0
- package/dist/{types/core/LoginFormAuthenticator → core/TwoFactorAuthenticator}/index.d.ts +10 -10
- package/dist/core/TwoFactorAuthenticator/index.js +9 -0
- package/dist/core/TwoFactorMethodList/index.d.ts +10 -0
- package/dist/core/TwoFactorMethodList/index.js +22 -0
- package/dist/core/TwoFactorSetup/index.d.ts +12 -0
- package/dist/core/TwoFactorSetup/index.js +43 -0
- package/dist/core/TwoFactorSetupAuthenticator/index.d.ts +20 -0
- package/dist/core/TwoFactorSetupAuthenticator/index.js +42 -0
- package/dist/core/TwoFactorSetupYubikey/index.d.ts +16 -0
- package/dist/core/TwoFactorSetupYubikey/index.js +14 -0
- package/dist/{types/core/LoginFormYubikey → core/TwoFactorYubikey}/index.d.ts +9 -9
- package/dist/core/TwoFactorYubikey/index.js +14 -0
- package/dist/core/WeekCalendarDay/index.d.ts +27 -0
- package/dist/core/WeekCalendarDay/index.js +35 -0
- package/dist/core/YubikeyInput/index.d.ts +4 -0
- package/dist/core/YubikeyInput/index.js +14 -0
- package/dist/filters/BooleanFilter/index.d.ts +14 -0
- package/dist/filters/BooleanFilter/index.js +35 -0
- package/dist/filters/DateFilter/index.d.ts +5 -0
- package/dist/filters/DateFilter/index.js +24 -0
- package/dist/filters/DropdownFilter/index.d.ts +17 -0
- package/dist/filters/DropdownFilter/index.js +32 -0
- package/dist/filters/QuickDateFilter/index.d.ts +13 -0
- package/dist/filters/QuickDateFilter/index.js +40 -0
- package/dist/{types/filters → filters}/interfaces.d.ts +35 -35
- package/dist/filters/interfaces.js +1 -0
- package/dist/{types/hooks → hooks}/useAlert.d.ts +12 -12
- package/dist/hooks/useAlert.js +18 -0
- package/dist/hooks/useAppConfig.d.ts +3 -0
- package/dist/hooks/useAppConfig.js +5 -0
- package/dist/{types/hooks → hooks}/useConnectedList.d.ts +7 -7
- package/dist/hooks/useConnectedList.js +6 -0
- package/dist/{types/hooks → hooks}/useConnectedRepeater.d.ts +7 -7
- package/dist/hooks/useConnectedRepeater.js +14 -0
- package/dist/{types/hooks → hooks}/useConnectedTable.d.ts +7 -7
- package/dist/hooks/useConnectedTable.js +6 -0
- package/dist/hooks/useFilters.d.ts +9 -0
- package/dist/hooks/useFilters.js +24 -0
- package/dist/{types/hooks → hooks}/useLayout.d.ts +7 -7
- package/dist/hooks/useLayout.js +10 -0
- package/dist/hooks/useLayout.spec.d.ts +1 -0
- package/dist/hooks/useLayout.spec.js +24 -0
- package/dist/{types/hooks → hooks}/useModal.d.ts +12 -12
- package/dist/hooks/useModal.js +39 -0
- package/dist/hooks/useModalOffset.d.ts +2 -0
- package/dist/hooks/useModalOffset.js +16 -0
- package/dist/hooks/useModalOffset.spec.d.ts +1 -0
- package/dist/hooks/useModalOffset.spec.js +19 -0
- package/dist/hooks/useNavigation.d.ts +7 -0
- package/dist/hooks/useNavigation.js +113 -0
- package/dist/hooks/useRemote.d.ts +7 -0
- package/dist/hooks/useRemote.js +29 -0
- package/dist/hooks/useVariant.d.ts +9 -0
- package/dist/hooks/useVariant.js +14 -0
- package/dist/{types/index.d.ts → index.d.ts} +209 -203
- package/dist/index.js +213 -5459
- package/dist/{types/scenes → scenes}/Error404Scene.d.ts +3 -3
- package/dist/scenes/Error404Scene.js +5 -0
- package/dist/services/AppService.d.ts +5 -0
- package/dist/services/AppService.js +11 -0
- package/dist/services/ConfigService.d.ts +42 -0
- package/dist/services/ConfigService.js +52 -0
- package/dist/{types/services → services}/ConfirmService.d.ts +12 -12
- package/dist/services/ConfirmService.js +10 -0
- package/dist/services/DateService.d.ts +26 -0
- package/dist/services/DateService.js +132 -0
- package/dist/services/DateService.spec.d.ts +1 -0
- package/dist/services/DateService.spec.js +83 -0
- package/dist/services/DownloadService.d.ts +7 -0
- package/dist/services/DownloadService.js +16 -0
- package/dist/services/DownloadService.spec.d.ts +1 -0
- package/dist/services/DownloadService.spec.js +18 -0
- package/dist/{types/services → services}/FilterComponentService.d.ts +25 -25
- package/dist/services/FilterComponentService.js +54 -0
- package/dist/services/FilterService.d.ts +34 -0
- package/dist/services/FilterService.js +58 -0
- package/dist/services/FilterService.spec.d.ts +1 -0
- package/dist/services/FilterService.spec.js +67 -0
- package/dist/services/FormatService.d.ts +11 -0
- package/dist/services/FormatService.js +45 -0
- package/dist/services/FormatService.spec.d.ts +1 -0
- package/dist/services/FormatService.spec.js +66 -0
- package/dist/services/ToastService.d.ts +7 -0
- package/dist/services/ToastService.js +17 -0
- package/dist/services/ToastService.spec.d.ts +1 -0
- package/dist/services/ToastService.spec.js +34 -0
- package/dist/styles.css +984 -0
- package/dist/utility/MockRouter/index.d.ts +2 -0
- package/dist/utility/MockRouter/index.js +37 -0
- package/dist/utility/StorybookPanel/index.d.ts +14 -0
- package/dist/utility/StorybookPanel/index.js +12 -0
- package/dist/utility/TestChangeHandler/index.d.ts +15 -0
- package/dist/utility/TestChangeHandler/index.js +30 -0
- package/dist/utility/icons.d.ts +3 -0
- package/dist/utility/icons.js +12 -0
- package/dist/{types/utility → utility}/interfaces.d.ts +79 -69
- package/dist/utility/interfaces.js +18 -0
- package/dist/utility/middleware.d.ts +4 -0
- package/dist/utility/middleware.js +9 -0
- package/dist/{types/utility → utility}/prop-types.d.ts +57 -55
- package/dist/utility/prop-types.js +77 -0
- package/dist/utility/register.d.ts +3 -0
- package/dist/utility/register.js +9 -0
- package/package.json +53 -88
- package/postcss.config.js +1 -1
- package/prettier.config.js +1 -0
- package/src/components/Alert/index.tsx +103 -13
- package/src/components/Allow/Allow.spec.tsx +2 -2
- package/src/components/Allow/index.tsx +8 -8
- package/src/components/AppLayout/AppLayout.stories.tsx +20 -0
- package/src/components/AppLayout/index.tsx +22 -0
- package/src/components/AutoSuggest/AutoSuggest.spec.tsx +38 -18
- package/src/components/AutoSuggest/AutoSuggest.story.tsx +8 -6
- package/src/components/AutoSuggest/index.tsx +30 -30
- package/src/components/Button/Button.spec.tsx +8 -0
- package/src/components/Button/Button.stories.tsx +62 -0
- package/src/components/Button/index.tsx +9 -93
- package/src/components/CalendarInput/CalendarInput.spec.tsx +38 -22
- package/src/components/CalendarInput/CalendarInput.story.tsx +2 -2
- package/src/components/CalendarInput/index.tsx +23 -19
- package/src/components/CheckboxList/CheckboxList.spec.tsx +20 -10
- package/src/components/CheckboxList/index.tsx +9 -12
- package/src/components/ConnectedDropdown/index.tsx +7 -5
- package/src/components/ConnectedList/index.tsx +13 -11
- package/src/components/ConnectedTable/index.tsx +15 -13
- package/src/components/ContentBlock/index.tsx +10 -8
- package/src/components/DataPanel/index.tsx +25 -0
- package/src/components/DateInput/DateInput.spec.tsx +10 -6
- package/src/components/DateInput/index.tsx +11 -12
- package/src/components/ErrorMessage/index.tsx +18 -20
- package/src/components/Fieldset/Fieldset.story.tsx +17 -13
- package/src/components/Fieldset/index.tsx +12 -10
- package/src/components/FileInput/FileInput.spec.tsx +9 -5
- package/src/components/FileInput/FileInput.story.tsx +3 -1
- package/src/components/FileInput/index.tsx +12 -10
- package/src/components/FilterLink/FilterLink.spec.tsx +18 -4
- package/src/components/FilterLink/index.tsx +19 -14
- package/src/components/Form/Form.spec.tsx +7 -5
- package/src/components/Form/index.tsx +5 -3
- package/src/components/FormActions/FormActions.story.tsx +19 -15
- package/src/components/FormActions/index.tsx +11 -7
- package/src/components/FormField/FormField.spec.tsx +28 -39
- package/src/components/FormField/FormField.stories.tsx +44 -0
- package/src/components/FormField/index.tsx +8 -103
- package/src/components/FormRepeater/FormRepeater.spec.tsx +26 -14
- package/src/components/FormRepeater/index.tsx +9 -7
- package/src/components/ImageInput/ImageInput.spec.tsx +3 -1
- package/src/components/ImageInput/ImageInput.story.tsx +3 -1
- package/src/components/ImageInput/index.tsx +16 -14
- package/src/components/InfoPanel/index.tsx +7 -7
- package/src/components/Link/Link.spec.tsx +4 -2
- package/src/components/Link/__mocks__/index.tsx +3 -3
- package/src/components/Link/index.tsx +6 -6
- package/src/components/List/List.spec.tsx +57 -20
- package/src/components/List/List.story.tsx +21 -2
- package/src/components/List/index.tsx +13 -13
- package/src/components/ListActions/ListActions.story.tsx +3 -1
- package/src/components/ListActions/index.tsx +10 -11
- package/src/components/LoginForm/LoginForm.spec.tsx +19 -7
- package/src/components/LoginForm/LoginForm.story.tsx +25 -0
- package/src/components/LoginForm/index.tsx +72 -171
- package/src/components/Message/index.tsx +12 -10
- package/src/components/Modal/index.tsx +18 -12
- package/src/components/ModalActions/ModalActions.spec.tsx +4 -2
- package/src/components/ModalActions/ModalActions.story.tsx +3 -1
- package/src/components/ModalActions/index.tsx +22 -18
- package/src/components/MoneyInput/MoneyInput.story.tsx +3 -1
- package/src/components/MoneyInput/index.tsx +7 -5
- package/src/components/PasswordForm/index.tsx +12 -24
- package/src/components/RadioList/RadioList.spec.tsx +4 -2
- package/src/components/RadioList/index.tsx +8 -6
- package/src/components/RootLayout/index.tsx +45 -0
- package/src/components/SummaryList/SummaryList.module.css +19 -4
- package/src/components/SummaryList/SummaryList.spec.tsx +14 -2
- package/src/components/SummaryList/SummaryList.story.tsx +3 -1
- package/src/components/SummaryList/index.tsx +16 -14
- package/src/components/Switch/Switch.spec.tsx +8 -4
- package/src/components/Switch/index.tsx +16 -14
- package/src/components/Table/Table.spec.tsx +11 -7
- package/src/components/Table/Table.story.tsx +3 -3
- package/src/components/Table/index.tsx +20 -22
- package/src/components/TextArea/TextArea.spec.tsx +12 -6
- package/src/components/TextArea/index.tsx +10 -8
- package/src/components/TextInput/TextInput.module.css +1 -0
- package/src/components/TextInput/TextInput.spec.tsx +12 -6
- package/src/components/TextInput/TextInput.stories.tsx +46 -0
- package/src/components/TextInput/index.tsx +6 -99
- package/src/components/WebsiteInput/index.tsx +7 -5
- package/src/components/WeekCalendar/index.tsx +8 -8
- package/src/core/AlertComponent/AlertComponent.spec.tsx +17 -4
- package/src/core/AlertComponent/AlertComponent.story.tsx +19 -15
- package/src/core/AlertComponent/index.tsx +30 -25
- package/src/core/AppHeader/index.tsx +5 -3
- package/src/core/AppLogo/index.tsx +9 -7
- package/src/core/AppLogoImage/index.tsx +6 -6
- package/src/core/AppLogoPlaceholder/index.tsx +28 -22
- package/src/core/Assistive/index.tsx +1 -18
- package/src/{components/LoginForm/LoginForm.module.css → core/AuthForm/AuthForm.module.css} +4 -0
- package/src/core/AuthForm/AuthForm.spec.tsx +72 -0
- package/src/core/AuthForm/index.tsx +63 -0
- package/src/core/Banner/index.tsx +11 -11
- package/src/core/Calendar/index.tsx +9 -7
- package/src/core/CalendarDay/index.tsx +12 -12
- package/src/core/CalendarMonth/index.tsx +14 -12
- package/src/core/CalendarNavigation/index.tsx +14 -14
- package/src/core/CalendarWeek/index.tsx +21 -19
- package/src/core/ChkRadList/index.tsx +25 -23
- package/src/core/CloseButton/CloseButton.spec.tsx +4 -2
- package/src/core/CloseButton/index.tsx +10 -8
- package/src/core/ConfirmModal/ConfirmModal.spec.tsx +10 -4
- package/src/core/ConfirmModal/index.tsx +9 -7
- package/src/core/ConnectedRepeater/index.tsx +46 -19
- package/src/core/ConnectedRepeaterComponent/index.tsx +13 -9
- package/src/core/Container/index.tsx +6 -12
- package/src/core/DataPanelItem/index.tsx +19 -0
- package/src/core/EmptyMessage/EmptyMessage.stories.tsx +33 -0
- package/src/core/EmptyMessage/index.tsx +9 -42
- package/src/core/FilterItem/index.tsx +41 -33
- package/src/core/Filters/Filters.spec.tsx +103 -69
- package/src/core/Filters/index.tsx +39 -31
- package/src/core/FixedActions/FixedActions.module.css +6 -0
- package/src/core/FixedActions/FixedActions.spec.tsx +8 -3
- package/src/core/FixedActions/index.tsx +9 -9
- package/src/core/FormLegend/index.tsx +4 -4
- package/src/core/Header/Header.stories.tsx +20 -0
- package/src/core/Header/index.tsx +8 -13
- package/src/core/Icon/Icon.spec.tsx +1 -3
- package/src/core/Icon/index.tsx +14 -10
- package/src/core/IconButton/index.tsx +18 -20
- package/src/core/ListItem/ListItem.story.tsx +23 -19
- package/src/core/ListItem/index.tsx +46 -37
- package/src/core/ListItemAction/index.tsx +7 -14
- package/src/core/ListItemActions/index.tsx +13 -12
- package/src/core/ListItemMetaItem/index.tsx +8 -8
- package/src/core/ListItemTitle/ListItemTitle.module.css +9 -1
- package/src/core/ListItemTitle/ListItemTitle.spec.tsx +24 -2
- package/src/core/ListItemTitle/index.tsx +20 -10
- package/src/core/Loader/Loader.module.css +3 -3
- package/src/core/Loader/Loader.stories.tsx +22 -0
- package/src/core/Loader/index.tsx +2 -27
- package/src/core/MeActions/index.tsx +28 -18
- package/src/core/MePanel/index.tsx +10 -10
- package/src/core/ModalComponent/ModalComponent.spec.tsx +8 -4
- package/src/core/ModalComponent/index.tsx +13 -13
- package/src/core/Navigation/Navigation.spec.tsx +47 -36
- package/src/core/Navigation/index.tsx +18 -58
- package/src/core/NavigationDivider/index.tsx +6 -6
- package/src/core/NavigationItem/index.tsx +12 -21
- package/src/core/Panel/Panel.module.css +11 -0
- package/src/core/Panel/Panel.spec.tsx +16 -0
- package/src/core/Panel/index.tsx +17 -13
- package/src/core/PasswordForgotForm/index.tsx +15 -12
- package/src/core/PasswordResetForm/index.tsx +15 -12
- package/src/core/RadialProgress/index.tsx +11 -14
- package/src/core/SettingsForm/index.tsx +9 -8
- package/src/core/SummaryListItem/SummaryListItem.module.css +3 -11
- package/src/core/SummaryListItem/index.tsx +19 -14
- package/src/core/TabItem/TabItem.module.css +28 -0
- package/src/core/TabItem/index.tsx +42 -0
- package/src/core/Tabs/Tabs.module.css +0 -24
- package/src/core/Tabs/Tabs.spec.tsx +30 -0
- package/src/core/Tabs/index.tsx +18 -76
- package/src/core/Toast/Toast.spec.tsx +4 -2
- package/src/core/Toast/index.tsx +16 -18
- package/src/core/TwoFactor/TwoFactor.spec.tsx +183 -0
- package/src/core/TwoFactor/index.tsx +102 -0
- package/src/core/TwoFactorAuthenticator/index.tsx +39 -0
- package/src/core/{LoginFormTwoFactor/LoginFormTwoFactor.module.css → TwoFactorMethodList/TwoFactorMethodList.module.css} +1 -1
- package/src/core/TwoFactorMethodList/index.tsx +49 -0
- package/src/core/TwoFactorSetup/index.tsx +91 -0
- package/src/core/TwoFactorSetupAuthenticator/TwoFactorSetupAuthenticator.module.css +6 -0
- package/src/core/TwoFactorSetupAuthenticator/index.tsx +100 -0
- package/src/core/TwoFactorSetupYubikey/index.tsx +49 -0
- package/src/core/TwoFactorYubikey/index.tsx +41 -0
- package/src/core/WeekCalendarDay/index.tsx +7 -7
- package/src/core/{LoginFormYubikey/LoginFormYubikey.module.css → YubikeyInput/YubikeyInput.module.css} +5 -0
- package/src/core/YubikeyInput/YubikeyInput.spec.tsx +77 -0
- package/src/core/YubikeyInput/index.tsx +76 -0
- package/src/filters/BooleanFilter/index.tsx +13 -12
- package/src/filters/DateFilter/index.tsx +8 -8
- package/src/filters/DropdownFilter/index.tsx +19 -17
- package/src/filters/QuickDateFilter/index.tsx +12 -12
- package/src/filters/interfaces.ts +2 -2
- package/src/hooks/useAlert.spec.tsx +72 -0
- package/src/hooks/useAlert.ts +7 -5
- package/src/hooks/useConfig.ts +31 -0
- package/src/hooks/useConnectedList.ts +4 -4
- package/src/hooks/useConnectedRepeater.ts +8 -6
- package/src/hooks/useConnectedTable.ts +4 -4
- package/src/hooks/useFilters.ts +21 -13
- package/src/hooks/useLayout.spec.ts +3 -11
- package/src/hooks/useLayout.ts +8 -7
- package/src/hooks/useModal.spec.tsx +23 -15
- package/src/hooks/useModal.ts +17 -17
- package/src/hooks/useModalOffset.ts +4 -2
- package/src/hooks/useNavigation.ts +160 -0
- package/src/hooks/useRemote.ts +43 -0
- package/src/index.ts +31 -26
- package/src/scenes/Error404Scene.tsx +3 -1
- package/src/services/AppService.ts +16 -0
- package/src/services/ConfigService.ts +93 -0
- package/src/services/ConfirmService.ts +7 -2
- package/src/services/DateService.ts +48 -32
- package/src/services/DownloadService.spec.ts +4 -10
- package/src/services/DownloadService.ts +16 -9
- package/src/services/FilterComponentService.tsx +9 -5
- package/src/services/FilterService.spec.ts +57 -39
- package/src/services/FilterService.ts +62 -40
- package/src/services/FormatService.spec.ts +2 -0
- package/src/services/FormatService.ts +13 -8
- package/src/services/ToastService.ts +9 -4
- package/src/styles/tailwind.css +57 -0
- package/src/typings.d.ts +2 -2
- package/src/utility/MockRouter/index.ts +1 -0
- package/src/utility/icons.tsx +46 -30
- package/src/utility/interfaces.ts +39 -21
- package/src/utility/middleware.ts +10 -0
- package/src/utility/prop-types.ts +6 -2
- package/src/utility/register.tsx +11 -0
- package/tailwind.config.js +11 -0
- package/tsconfig.eslint.json +4 -0
- package/tsconfig.json +7 -15
- package/.gitattributes +0 -1
- package/.github/workflows/development.yml +0 -47
- package/.prettierrc +0 -9
- package/.storybook/manager.js +0 -4
- package/.storybook/postcss.config.js +0 -3
- package/.storybook/theme.js +0 -7
- package/.stylelintrc +0 -9
- package/__mocks__/@sqrzro/utility.ts +0 -43
- package/assets/logo-horizontal-dark.svg +0 -21
- package/assets/logo-horizontal-white.svg +0 -21
- package/assets/logo-vertical-dark.svg +0 -21
- package/assets/logo-vertical-white.svg +0 -21
- package/dist/index.css +0 -3812
- package/dist/index.js.map +0 -1
- package/dist/types/components/App/index.d.ts +0 -18
- package/dist/types/components/CalendarInput/index.d.ts +0 -10
- package/dist/types/components/CodeInput/index.d.ts +0 -9
- package/dist/types/components/ConnectedListScene/index.d.ts +0 -7
- package/dist/types/components/ConnectedScene/index.d.ts +0 -11
- package/dist/types/components/DateInput/index.d.ts +0 -7
- package/dist/types/components/Document/index.d.ts +0 -3
- package/dist/types/components/ErrorMessage/index.d.ts +0 -8
- package/dist/types/components/Fieldset/index.d.ts +0 -11
- package/dist/types/components/FilterLink/index.d.ts +0 -7
- package/dist/types/components/Form/index.d.ts +0 -14
- package/dist/types/components/FormActions/index.d.ts +0 -9
- package/dist/types/components/FormRepeater/index.d.ts +0 -9
- package/dist/types/components/InfoPanel/index.d.ts +0 -8
- package/dist/types/components/Link/index.d.ts +0 -13
- package/dist/types/components/ListActions/index.d.ts +0 -9
- package/dist/types/components/LoginForm/index.d.ts +0 -3
- package/dist/types/components/Message/index.d.ts +0 -7
- package/dist/types/components/ModalActions/index.d.ts +0 -11
- package/dist/types/components/PasswordForm/index.d.ts +0 -3
- package/dist/types/components/PasswordInput/index.d.ts +0 -4
- package/dist/types/components/Scene/index.d.ts +0 -10
- package/dist/types/components/SummaryList/index.d.ts +0 -8
- package/dist/types/components/Switch/index.d.ts +0 -9
- package/dist/types/components/Tag/index.d.ts +0 -8
- package/dist/types/components/TextArea/index.d.ts +0 -4
- package/dist/types/components/WeekCalendar/index.d.ts +0 -12
- package/dist/types/core/App/index.d.ts +0 -19
- package/dist/types/core/AppLogo/index.d.ts +0 -6
- package/dist/types/core/Assistive/index.d.ts +0 -6
- package/dist/types/core/BuildModal/index.d.ts +0 -3
- package/dist/types/core/Calendar/index.d.ts +0 -11
- package/dist/types/core/CalendarDay/index.d.ts +0 -16
- package/dist/types/core/CalendarMonth/index.d.ts +0 -12
- package/dist/types/core/CalendarNavigation/index.d.ts +0 -9
- package/dist/types/core/CalendarWeek/index.d.ts +0 -14
- package/dist/types/core/ChkRad/index.d.ts +0 -13
- package/dist/types/core/ChkRadIcon/index.d.ts +0 -7
- package/dist/types/core/CloseButton/index.d.ts +0 -9
- package/dist/types/core/ConnectedList/index.d.ts +0 -4
- package/dist/types/core/ConnectedTable/index.d.ts +0 -4
- package/dist/types/core/Container/index.d.ts +0 -7
- package/dist/types/core/DropdownPanel/index.d.ts +0 -18
- package/dist/types/core/ErrorBoundary/index.d.ts +0 -15
- package/dist/types/core/ErrorMessage/index.d.ts +0 -8
- package/dist/types/core/FilterItem/index.d.ts +0 -10
- package/dist/types/core/Filters/index.d.ts +0 -15
- package/dist/types/core/Form/index.d.ts +0 -12
- package/dist/types/core/FormError/index.d.ts +0 -6
- package/dist/types/core/FormLabel/index.d.ts +0 -8
- package/dist/types/core/FormLegend/index.d.ts +0 -6
- package/dist/types/core/Header/index.d.ts +0 -8
- package/dist/types/core/Icon/index.d.ts +0 -7
- package/dist/types/core/IconButton/Icon/index.d.ts +0 -7
- package/dist/types/core/IconButton/index.d.ts +0 -11
- package/dist/types/core/InputPanel/index.d.ts +0 -8
- package/dist/types/core/ListItemAction/index.d.ts +0 -4
- package/dist/types/core/ListItemMetaItem/index.d.ts +0 -10
- package/dist/types/core/ListItemTitle/index.d.ts +0 -9
- package/dist/types/core/Loader/index.d.ts +0 -6
- package/dist/types/core/LoginFormTwoFactor/index.d.ts +0 -13
- package/dist/types/core/MeActions/index.d.ts +0 -3
- package/dist/types/core/Modal/index.d.ts +0 -12
- package/dist/types/core/ModalComponent/index.d.ts +0 -12
- package/dist/types/core/NavigationItem/index.d.ts +0 -7
- package/dist/types/core/Pagination/index.d.ts +0 -7
- package/dist/types/core/PaginationItem/index.d.ts +0 -7
- package/dist/types/core/Panel/index.d.ts +0 -8
- package/dist/types/core/RadialProgress/index.d.ts +0 -8
- package/dist/types/core/SettingsForm/index.d.ts +0 -3
- package/dist/types/core/StaticTextInput/index.d.ts +0 -13
- package/dist/types/core/SummaryListItem/index.d.ts +0 -15
- package/dist/types/core/TableCell/index.d.ts +0 -8
- package/dist/types/core/TableHead/index.d.ts +0 -8
- package/dist/types/core/Tabs/index.d.ts +0 -11
- package/dist/types/core/TextInputAncillary/index.d.ts +0 -12
- package/dist/types/core/WeekCalendarDay/index.d.ts +0 -14
- package/dist/types/filters/BooleanFilter/index.d.ts +0 -5
- package/dist/types/filters/DateFilter/index.d.ts +0 -5
- package/dist/types/filters/DropdownFilter/index.d.ts +0 -17
- package/dist/types/filters/QuickDateFilter/index.d.ts +0 -5
- package/dist/types/hooks/useAccessiblePanel.d.ts +0 -13
- package/dist/types/hooks/useAppContext.d.ts +0 -55
- package/dist/types/hooks/useClickOutside.d.ts +0 -3
- package/dist/types/hooks/useComponentId.d.ts +0 -2
- package/dist/types/hooks/useFilters.d.ts +0 -3
- package/dist/types/hooks/useForm.d.ts +0 -41
- package/dist/types/hooks/useFormData.d.ts +0 -12
- package/dist/types/hooks/useModalOffset.d.ts +0 -2
- package/dist/types/hooks/useVariant.d.ts +0 -6
- package/dist/types/services/BuildService.d.ts +0 -5
- package/dist/types/services/DateService.d.ts +0 -17
- package/dist/types/services/DownloadService.d.ts +0 -5
- package/dist/types/services/FilterService.d.ts +0 -13
- package/dist/types/services/FormatService.d.ts +0 -7
- package/dist/types/services/OLD_ApiService.d.ts +0 -19
- package/dist/types/services/ToastService.d.ts +0 -5
- package/dist/types/utility/MockRouter/index.d.ts +0 -2
- package/dist/types/utility/StorybookPanel/index.d.ts +0 -7
- package/dist/types/utility/TestChangeHandler/index.d.ts +0 -15
- package/dist/types/utility/create-app.d.ts +0 -4
- package/dist/types/utility/icons.d.ts +0 -3
- package/docs/guides/01-installation.story.mdx +0 -33
- package/docs/guides/02-configuration.story.mdx +0 -80
- package/docs/guides/03-pages.story.mdx +0 -18
- package/docs/guides/04-integration.story.mdx +0 -33
- package/docs/guides/a11y.story.mdx +0 -7
- package/docs/guides/theming.story.mdx +0 -7
- package/docs/introduction.story.mdx +0 -17
- package/jest.config.js +0 -19
- package/rollup.config.js +0 -36
- package/scripts/create-exports.js +0 -74
- package/scripts/update-license.js +0 -8
- package/squarezero.config.js +0 -5
- package/src/components/Button/Button.module.css +0 -100
- package/src/components/CodeInput/CodeInput.module.css +0 -33
- package/src/components/CodeInput/CodeInput.spec.tsx +0 -180
- package/src/components/CodeInput/index.tsx +0 -138
- package/src/components/ConnectedScene/index.tsx +0 -96
- package/src/components/Document/index.tsx +0 -14
- package/src/components/Dropdown/Dropdown.module.css +0 -8
- package/src/components/Dropdown/Dropdown.spec.tsx +0 -304
- package/src/components/Dropdown/Dropdown.story.tsx +0 -53
- package/src/components/Dropdown/index.tsx +0 -228
- package/src/components/FormField/FormField.story.tsx +0 -29
- package/src/components/PasswordForm/PasswordForm.module.css +0 -21
- package/src/components/PasswordInput/PasswordInput.module.css +0 -23
- package/src/components/PasswordInput/PasswordInput.spec.tsx +0 -28
- package/src/components/PasswordInput/PasswordInput.story.tsx +0 -16
- package/src/components/PasswordInput/index.tsx +0 -23
- package/src/components/Scene/Scene.spec.tsx +0 -123
- package/src/components/Scene/Scene.story.tsx +0 -6
- package/src/components/Scene/index.tsx +0 -58
- package/src/components/Tag/Tag.module.css +0 -37
- package/src/components/Tag/Tag.spec.tsx +0 -10
- package/src/components/Tag/Tag.story.tsx +0 -55
- package/src/components/Tag/index.tsx +0 -27
- package/src/components/TextInput/TextInput.story.tsx +0 -24
- package/src/core/App/App.module.css +0 -24
- package/src/core/App/App.spec.tsx +0 -265
- package/src/core/App/index.tsx +0 -115
- package/src/core/Assistive/Assistive.module.css +0 -10
- package/src/core/ChkRad/ChkRad.module.css +0 -31
- package/src/core/ChkRad/ChkRad.spec.tsx +0 -79
- package/src/core/ChkRad/index.tsx +0 -75
- package/src/core/ChkRadIcon/ChkRadIcon.module.css +0 -29
- package/src/core/ChkRadIcon/index.tsx +0 -33
- package/src/core/DropdownPanel/DropdownPanel.module.css +0 -68
- package/src/core/DropdownPanel/index.tsx +0 -93
- package/src/core/ErrorBoundary/ErrorBoundary.spec.tsx +0 -33
- package/src/core/ErrorBoundary/index.tsx +0 -42
- package/src/core/FormError/FormError.module.css +0 -7
- package/src/core/FormError/index.tsx +0 -18
- package/src/core/FormLabel/FormLabel.module.css +0 -15
- package/src/core/FormLabel/index.tsx +0 -25
- package/src/core/Header/Header.module.css +0 -28
- package/src/core/InputPanel/InputPanel.module.css +0 -70
- package/src/core/InputPanel/index.tsx +0 -28
- package/src/core/Loader/Loader.story.tsx +0 -8
- package/src/core/LoginFormAuthenticator/index.tsx +0 -36
- package/src/core/LoginFormTwoFactor/index.tsx +0 -133
- package/src/core/LoginFormYubikey/index.tsx +0 -59
- package/src/core/Pagination/Pagination.module.css +0 -15
- package/src/core/PaginationItem/PaginationItem.module.css +0 -33
- package/src/core/PaginationItem/index.tsx +0 -46
- package/src/core/StaticTextInput/StaticTextInput.module.css +0 -79
- package/src/core/StaticTextInput/StaticTextInput.spec.tsx +0 -126
- package/src/core/StaticTextInput/index.tsx +0 -112
- package/src/core/Styled/Styled.spec.tsx +0 -32
- package/src/core/Styled/Styled.story.tsx +0 -10
- package/src/core/TableActionsCell/TableActionsCell.module.css +0 -3
- package/src/core/TableActionsCell/index.tsx +0 -26
- package/src/core/TableCell/TableCell.module.css +0 -16
- package/src/core/TableCell/index.tsx +0 -39
- package/src/core/TableHead/TableHead.module.css +0 -12
- package/src/core/TableHead/index.tsx +0 -48
- package/src/core/TableRow/index.tsx +0 -49
- package/src/core/TextInputAncillary/TextInputAncillary.module.css +0 -69
- package/src/core/TextInputAncillary/index.tsx +0 -84
- package/src/hooks/useAccessiblePanel.spec.tsx +0 -88
- package/src/hooks/useAccessiblePanel.ts +0 -74
- package/src/hooks/useAppContext.spec.ts +0 -38
- package/src/hooks/useAppContext.ts +0 -110
- package/src/hooks/useClickOutside.ts +0 -49
- package/src/hooks/useComponentId.spec.ts +0 -19
- package/src/hooks/useComponentId.ts +0 -16
- package/src/hooks/useForm.spec.ts +0 -251
- package/src/hooks/useForm.ts +0 -179
- package/src/hooks/useVariant.spec.ts +0 -14
- package/src/hooks/useVariant.ts +0 -34
- package/src/styles/layout.css +0 -64
- package/src/styles/variables.css +0 -85
- package/src/utility/StorybookPanel/StorybookPanel.module.css +0 -9
- package/src/utility/StorybookPanel/index.tsx +0 -25
- package/src/utility/TestChangeHandler/TestChangeHandler.module.css +0 -7
- package/src/utility/TestChangeHandler/TestChangeHandler.spec.tsx +0 -24
- package/src/utility/TestChangeHandler/index.tsx +0 -51
- package/src/utility/create-app.tsx +0 -28
- package/tests/setupFilesAfterEnv.js +0 -16
- package/tsconfig.types.json +0 -9
|
@@ -1,31 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import React, { useState } from 'react';
|
|
2
|
-
import
|
|
4
|
+
import clsx from 'clsx';
|
|
3
5
|
import PropTypes from 'prop-types';
|
|
4
6
|
|
|
7
|
+
import { useAccessiblePanel, useClickOutside } from '@sqrzro/hooks';
|
|
5
8
|
import { ApiService } from '@sqrzro/utility';
|
|
6
9
|
|
|
7
|
-
import ErrorMessage from '
|
|
8
|
-
import TextInput from '
|
|
9
|
-
|
|
10
|
-
import DropdownPanel from '@core/DropdownPanel';
|
|
11
|
-
import type { DropdownItem } from '@core/DropdownPanel';
|
|
12
|
-
import InputPanel from '@core/InputPanel';
|
|
10
|
+
import ErrorMessage from '../ErrorMessage';
|
|
11
|
+
import TextInput from '../TextInput';
|
|
13
12
|
|
|
14
|
-
import
|
|
15
|
-
import
|
|
13
|
+
import DropdownList from '../../core/DropdownList';
|
|
14
|
+
import type { DropdownItem } from '../../core/DropdownList';
|
|
15
|
+
import InputPanel from '../../core/InputPanel';
|
|
16
16
|
|
|
17
|
-
import type { InputEvent, InputProps } from '
|
|
17
|
+
import type { InputEvent, InputProps } from '../../utility/interfaces';
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// Import styles from './AutoSuggest.module.css';
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
function transformSuggestions(data: (DropdownItem | string)[] | null): DropdownItem[] {
|
|
22
22
|
if (!data) {
|
|
23
23
|
return [];
|
|
24
24
|
}
|
|
25
25
|
return data.map((item) => (typeof item === 'object' ? item : { id: item, name: item }));
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
27
|
|
|
28
|
-
interface AutoSuggestProps extends InputProps<string> {
|
|
28
|
+
export interface AutoSuggestProps extends InputProps<string> {
|
|
29
29
|
/**
|
|
30
30
|
* An array of strings to filter for the suggestions. If a `remote` prop is specified, this is
|
|
31
31
|
* ignored.
|
|
@@ -39,7 +39,7 @@ interface AutoSuggestProps extends InputProps<string> {
|
|
|
39
39
|
/**
|
|
40
40
|
* As a user types, suggestions based on they've typed are displayed in a panel below. When a user
|
|
41
41
|
* clicks a suggestion, the value is updated. Under the hood, it is more or less a combination of a
|
|
42
|
-
* `TextInput` and a `
|
|
42
|
+
* `TextInput` and a `DropdownList`.
|
|
43
43
|
*
|
|
44
44
|
* ## Request Methods
|
|
45
45
|
*
|
|
@@ -82,22 +82,22 @@ interface AutoSuggestProps extends InputProps<string> {
|
|
|
82
82
|
* [{ id: 1, name: 'apple' }, { id: 2, name: 'banana' }, { id: 3, name: 'carrot' }]
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
function AutoSuggest({
|
|
86
86
|
data,
|
|
87
87
|
name,
|
|
88
88
|
remote,
|
|
89
89
|
value,
|
|
90
90
|
hasError,
|
|
91
91
|
onChange,
|
|
92
|
-
})
|
|
92
|
+
}: AutoSuggestProps): React.ReactElement {
|
|
93
93
|
const [suggestions, setSuggestions] = useState<(DropdownItem | string)[] | null>(null);
|
|
94
94
|
|
|
95
|
-
const [isOpen, setIsOpen, node] = useClickOutside();
|
|
95
|
+
const [isOpen, setIsOpen, node] = useClickOutside({ shouldHandleEnterKey: true });
|
|
96
96
|
const [isError, setIsError] = useState(false);
|
|
97
97
|
const [isLoading, setIsLoading] = useState(false);
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
if (!data
|
|
99
|
+
function getLocalData(search: string): void {
|
|
100
|
+
if (!data?.length) {
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -108,9 +108,9 @@ const AutoSuggest: React.FunctionComponent<AutoSuggestProps> = ({
|
|
|
108
108
|
|
|
109
109
|
setIsOpen(Boolean(response.length));
|
|
110
110
|
setSuggestions(response);
|
|
111
|
-
}
|
|
111
|
+
}
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
async function getData(search: string): Promise<void> {
|
|
114
114
|
if (!remote) {
|
|
115
115
|
getLocalData(search);
|
|
116
116
|
return;
|
|
@@ -130,9 +130,9 @@ const AutoSuggest: React.FunctionComponent<AutoSuggestProps> = ({
|
|
|
130
130
|
|
|
131
131
|
setIsLoading(false);
|
|
132
132
|
setIsOpen(true);
|
|
133
|
-
}
|
|
133
|
+
}
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
function handleChange(event: InputEvent<string>): void {
|
|
136
136
|
if (onChange) {
|
|
137
137
|
onChange(event);
|
|
138
138
|
}
|
|
@@ -143,9 +143,9 @@ const AutoSuggest: React.FunctionComponent<AutoSuggestProps> = ({
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
void getData(event.target.value);
|
|
146
|
-
}
|
|
146
|
+
}
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
function handleSuggest(item: DropdownItem): void {
|
|
149
149
|
const simpleEvent = {
|
|
150
150
|
target: { name, value: item.id },
|
|
151
151
|
};
|
|
@@ -155,7 +155,7 @@ const AutoSuggest: React.FunctionComponent<AutoSuggestProps> = ({
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
setIsOpen(false);
|
|
158
|
-
}
|
|
158
|
+
}
|
|
159
159
|
|
|
160
160
|
if (isError) {
|
|
161
161
|
return <ErrorMessage isMini />;
|
|
@@ -171,7 +171,7 @@ const AutoSuggest: React.FunctionComponent<AutoSuggestProps> = ({
|
|
|
171
171
|
});
|
|
172
172
|
|
|
173
173
|
return (
|
|
174
|
-
<div ref={node} className=
|
|
174
|
+
<div ref={node} className="/*clsx(styles.root, isOpen && styles.rootOpen)*/">
|
|
175
175
|
<TextInput
|
|
176
176
|
hasError={hasError}
|
|
177
177
|
isAutocomplete={false}
|
|
@@ -183,7 +183,7 @@ const AutoSuggest: React.FunctionComponent<AutoSuggestProps> = ({
|
|
|
183
183
|
/>
|
|
184
184
|
{isOpen && suggestions && suggestions.length ? (
|
|
185
185
|
<InputPanel isScrollable>
|
|
186
|
-
<
|
|
186
|
+
<DropdownList
|
|
187
187
|
data={transformed}
|
|
188
188
|
name={name}
|
|
189
189
|
onChange={({ item }): void => handleSuggest(item)}
|
|
@@ -193,7 +193,7 @@ const AutoSuggest: React.FunctionComponent<AutoSuggestProps> = ({
|
|
|
193
193
|
) : null}
|
|
194
194
|
</div>
|
|
195
195
|
);
|
|
196
|
-
}
|
|
196
|
+
}
|
|
197
197
|
|
|
198
198
|
AutoSuggest.propTypes = {
|
|
199
199
|
name: PropTypes.string.isRequired,
|
|
@@ -50,4 +50,12 @@ describe('Button', () => {
|
|
|
50
50
|
expect(screen.getByRole('button')).toHaveClass('root rootIsDisabled');
|
|
51
51
|
expect(screen.getByRole('button')).toBeDisabled();
|
|
52
52
|
});
|
|
53
|
+
|
|
54
|
+
it('should render loading', () => {
|
|
55
|
+
render(<Button isLoading>Lorem</Button>);
|
|
56
|
+
|
|
57
|
+
expect(screen.getByRole('button')).toHaveClass('root rootIsLoading');
|
|
58
|
+
expect(screen.getByRole('button')).toHaveTextContent(/^Loading.../u);
|
|
59
|
+
expect(screen.getByRole('button')).toBeDisabled();
|
|
60
|
+
});
|
|
53
61
|
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import Button from './index';
|
|
5
|
+
import type { ButtonProps } from './index';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/Button',
|
|
9
|
+
component: Button,
|
|
10
|
+
} as ComponentMeta<typeof Button>;
|
|
11
|
+
|
|
12
|
+
const Template: ComponentStory<typeof Button> = (args: ButtonProps): React.ReactElement => (
|
|
13
|
+
<Button {...args} />
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const Basic = Template.bind({});
|
|
17
|
+
|
|
18
|
+
Basic.args = {
|
|
19
|
+
children: 'Lorem Ipsum',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const Danger = Template.bind({});
|
|
23
|
+
|
|
24
|
+
Danger.args = {
|
|
25
|
+
children: 'Lorem Ipsum',
|
|
26
|
+
variant: 'danger',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Bordered = Template.bind({});
|
|
30
|
+
|
|
31
|
+
Bordered.args = {
|
|
32
|
+
children: 'Lorem Ipsum',
|
|
33
|
+
variant: 'bordered',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const BorderedDanger = Template.bind({});
|
|
37
|
+
|
|
38
|
+
BorderedDanger.args = {
|
|
39
|
+
children: 'Lorem Ipsum',
|
|
40
|
+
variant: ['bordered', 'danger'],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const FullWidth = Template.bind({});
|
|
44
|
+
|
|
45
|
+
FullWidth.args = {
|
|
46
|
+
children: 'Lorem Ipsum',
|
|
47
|
+
isFullWidth: true,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Disabled = Template.bind({});
|
|
51
|
+
|
|
52
|
+
Disabled.args = {
|
|
53
|
+
children: 'Lorem Ipsum',
|
|
54
|
+
isDisabled: true,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Loading = Template.bind({});
|
|
58
|
+
|
|
59
|
+
Loading.args = {
|
|
60
|
+
children: 'Lorem Ipsum',
|
|
61
|
+
isLoading: true,
|
|
62
|
+
};
|
|
@@ -1,99 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
import Link from '@components/Link';
|
|
6
|
-
|
|
7
|
-
import useVariant from '@hooks/useVariant';
|
|
8
|
-
|
|
9
|
-
import type { ButtonVariant } from '@utility/interfaces';
|
|
10
|
-
import { ButtonVariantPropType } from '@utility/prop-types';
|
|
11
|
-
|
|
12
|
-
import styles from './Button.module.css';
|
|
13
|
-
|
|
14
|
-
export interface ButtonProps {
|
|
15
|
-
/** Probably the button text, but could be any HTML element or React component */
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
|
|
18
|
-
/** If set to true, the Button will be greyed out and non-interactive */
|
|
19
|
-
isDisabled?: boolean | null;
|
|
20
|
-
isFullWidth?: boolean | null;
|
|
21
|
-
onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLButtonElement>;
|
|
1
|
+
'use client';
|
|
22
2
|
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ButtonComponent } from '@sqrzro/components';
|
|
5
|
+
import type { ButtonProps } from '@sqrzro/components';
|
|
25
6
|
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
function Button(props: ButtonProps): React.ReactElement {
|
|
8
|
+
const classNames = {
|
|
9
|
+
root: 'bg-blue-600 border-2 border-red-200',
|
|
10
|
+
};
|
|
28
11
|
|
|
29
|
-
|
|
30
|
-
variant?: ButtonVariant | ButtonVariant[];
|
|
12
|
+
return <ButtonComponent classNames={classNames} {...props} />;
|
|
31
13
|
}
|
|
32
14
|
|
|
33
|
-
/**
|
|
34
|
-
* Either a `Link` component or a `button` element, depending on whether a `to` prop is specified.
|
|
35
|
-
*
|
|
36
|
-
* As a `Link`, it provides navigation between pages, and as a `button` it will handle the
|
|
37
|
-
* `onClick` function when clicked (if one is specified).
|
|
38
|
-
*
|
|
39
|
-
* ## to & onClick
|
|
40
|
-
*
|
|
41
|
-
* Although it is possible to omit both the `to` and `onClick` props, there will
|
|
42
|
-
* be nearly zero situations where this would be useful. It is also possible to include both props.
|
|
43
|
-
* This will create a `Link` component, and handle the `onClick` function before navigation.
|
|
44
|
-
*
|
|
45
|
-
* ## Styles
|
|
46
|
-
*
|
|
47
|
-
* The `Button` will stretch to the full width of its parent element. If you wish to have a smaller
|
|
48
|
-
* width, you can wrap it in a `div`, and then wrap that `div` in a component with a flex property.
|
|
49
|
-
* Components like `ListActions` and `ModalActions` do this for you.
|
|
50
|
-
*/
|
|
51
|
-
const Button: React.FunctionComponent<ButtonProps> = ({
|
|
52
|
-
to,
|
|
53
|
-
children,
|
|
54
|
-
type,
|
|
55
|
-
variant,
|
|
56
|
-
isDisabled,
|
|
57
|
-
isFullWidth,
|
|
58
|
-
onClick,
|
|
59
|
-
}) => {
|
|
60
|
-
const { applyVariantClassName } = useVariant<ButtonVariant>(variant);
|
|
61
|
-
|
|
62
|
-
const className = classNames(
|
|
63
|
-
styles.root,
|
|
64
|
-
applyVariantClassName(styles),
|
|
65
|
-
isDisabled && styles.rootIsDisabled,
|
|
66
|
-
isFullWidth && styles.rootIsFullWidth
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
if (to) {
|
|
70
|
-
return (
|
|
71
|
-
<Link className={className} onClick={onClick} to={to}>
|
|
72
|
-
{children}
|
|
73
|
-
</Link>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<button
|
|
79
|
-
className={className}
|
|
80
|
-
disabled={isDisabled || false}
|
|
81
|
-
onClick={onClick}
|
|
82
|
-
type={type === 'submit' ? 'submit' : 'button'}
|
|
83
|
-
>
|
|
84
|
-
{children}
|
|
85
|
-
</button>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
Button.propTypes = {
|
|
90
|
-
children: PropTypes.node.isRequired,
|
|
91
|
-
isDisabled: PropTypes.bool,
|
|
92
|
-
isFullWidth: PropTypes.bool,
|
|
93
|
-
to: PropTypes.string,
|
|
94
|
-
type: PropTypes.oneOf(['button', 'submit']),
|
|
95
|
-
variant: ButtonVariantPropType,
|
|
96
|
-
onClick: PropTypes.func,
|
|
97
|
-
};
|
|
98
|
-
|
|
99
15
|
export default Button;
|
|
@@ -89,6 +89,8 @@ describe('CalendarInput', () => {
|
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
it('should handle open (and clickoutside)', async () => {
|
|
92
|
+
const user = userEvent.setup();
|
|
93
|
+
|
|
92
94
|
render(
|
|
93
95
|
<Fragment>
|
|
94
96
|
<CalendarInput name="lorem" value="lorem" />
|
|
@@ -98,83 +100,95 @@ describe('CalendarInput', () => {
|
|
|
98
100
|
|
|
99
101
|
expect(screen.queryByRole('table')).not.toBeInTheDocument();
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
await user.click(screen.getByRole('button', { name: 'Open' }));
|
|
102
104
|
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
103
105
|
|
|
104
|
-
|
|
106
|
+
await user.click(screen.getByText('[DOM]'));
|
|
105
107
|
await waitForElementToBeRemoved(screen.queryAllByRole('table'));
|
|
106
108
|
});
|
|
107
109
|
|
|
108
|
-
it('should handle no onChange (just close datepanel)', () => {
|
|
110
|
+
it('should handle no onChange (just close datepanel)', async () => {
|
|
111
|
+
const user = userEvent.setup();
|
|
112
|
+
|
|
109
113
|
render(<CalendarInput name="lorem" />);
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
await user.click(screen.getByRole('button', { name: 'Open' }));
|
|
112
116
|
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
113
117
|
|
|
114
|
-
|
|
118
|
+
await user.click(screen.getByRole('button', { name: '15' }));
|
|
115
119
|
|
|
116
120
|
expect(screen.queryByRole('table')).not.toBeInTheDocument();
|
|
117
121
|
});
|
|
118
122
|
|
|
119
|
-
it('should handle onChange', () => {
|
|
123
|
+
it('should handle onChange', async () => {
|
|
124
|
+
const user = userEvent.setup();
|
|
125
|
+
|
|
120
126
|
const mockFn = jest.fn();
|
|
121
127
|
const value = format(new Date(), 'Y-MM-15');
|
|
122
128
|
|
|
123
129
|
render(<CalendarInput name="lorem" onChange={mockFn} />);
|
|
124
130
|
|
|
125
|
-
|
|
131
|
+
await user.click(screen.getByRole('button', { name: 'Open' }));
|
|
126
132
|
|
|
127
133
|
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
128
|
-
|
|
134
|
+
await user.click(screen.getByRole('button', { name: '15' }));
|
|
129
135
|
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
130
136
|
expect(mockFn).toHaveBeenLastCalledWith({ target: { name: 'lorem', value } });
|
|
131
137
|
});
|
|
132
138
|
|
|
133
|
-
it('should handle change with no onChange', () => {
|
|
139
|
+
it('should handle change with no onChange', async () => {
|
|
140
|
+
const user = userEvent.setup();
|
|
141
|
+
|
|
134
142
|
const mockFn = jest.fn();
|
|
135
143
|
render(<CalendarInput name="lorem" />);
|
|
136
144
|
|
|
137
|
-
|
|
145
|
+
await user.click(screen.getByRole('button', { name: 'Open' }));
|
|
138
146
|
|
|
139
147
|
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
140
|
-
|
|
148
|
+
await user.click(screen.getByRole('button', { name: '15' }));
|
|
141
149
|
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
142
150
|
});
|
|
143
151
|
|
|
144
|
-
it('should navigate months', () => {
|
|
152
|
+
it('should navigate months', async () => {
|
|
153
|
+
const user = userEvent.setup();
|
|
154
|
+
|
|
145
155
|
render(<CalendarInput name="lorem" value="2020-09-19" isPanelOnly />);
|
|
146
156
|
|
|
147
157
|
expect(screen.getByText('September 2020')).toBeInTheDocument();
|
|
148
158
|
|
|
149
|
-
|
|
159
|
+
await user.click(screen.getByText('Previous'));
|
|
150
160
|
expect(screen.getByText('August 2020')).toBeInTheDocument();
|
|
151
161
|
|
|
152
|
-
|
|
153
|
-
|
|
162
|
+
await user.click(screen.getByText('Next'));
|
|
163
|
+
await user.click(screen.getByText('Next'));
|
|
154
164
|
expect(screen.getByText('October 2020')).toBeInTheDocument();
|
|
155
165
|
});
|
|
156
166
|
|
|
157
|
-
it('should pass value to datepanel', () => {
|
|
167
|
+
it('should pass value to datepanel', async () => {
|
|
168
|
+
const user = userEvent.setup();
|
|
169
|
+
|
|
158
170
|
const value = format(new Date(), 'Y-MM-08');
|
|
159
171
|
render(<CalendarInput name="lorem" value={value} />);
|
|
160
172
|
|
|
161
|
-
|
|
173
|
+
await user.click(screen.getByRole('button', { name: 'Open' }));
|
|
162
174
|
|
|
163
175
|
expect(screen.getByTestId('calendar-day-root-7')).toHaveClass('root');
|
|
164
176
|
expect(screen.getByTestId('calendar-day-root-8')).toHaveClass('root rootIsSelected');
|
|
165
177
|
});
|
|
166
178
|
|
|
167
|
-
it('should handle range selection', () => {
|
|
179
|
+
it('should handle range selection', async () => {
|
|
180
|
+
const user = userEvent.setup();
|
|
181
|
+
|
|
168
182
|
MockDate.set('2020-09-19');
|
|
169
183
|
|
|
170
184
|
const mockFn = jest.fn();
|
|
171
185
|
render(<CalendarInput name="lorem" onChange={mockFn} isPanelOnly isRange />);
|
|
172
186
|
|
|
173
|
-
|
|
187
|
+
await user.click(screen.getByRole('button', { name: '15' }));
|
|
174
188
|
expect(screen.getByTestId('calendar-day-root-15')).toHaveClass('rootIsSelected');
|
|
175
189
|
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
176
190
|
|
|
177
|
-
|
|
191
|
+
await user.click(screen.getByRole('button', { name: '20' }));
|
|
178
192
|
expect(screen.getByTestId('calendar-day-root-15')).toHaveClass('rootIsSelected');
|
|
179
193
|
expect(screen.getByTestId('calendar-day-root-20')).toHaveClass('rootIsSelected');
|
|
180
194
|
|
|
@@ -188,11 +202,13 @@ describe('CalendarInput', () => {
|
|
|
188
202
|
},
|
|
189
203
|
});
|
|
190
204
|
|
|
191
|
-
|
|
205
|
+
await user.click(screen.getByRole('button', { name: '12' }));
|
|
206
|
+
|
|
192
207
|
expect(screen.getByTestId('calendar-day-root-12')).toHaveClass('rootIsSelected');
|
|
193
208
|
expect(screen.getByTestId('calendar-day-root-15')).not.toHaveClass('rootIsSelected');
|
|
194
209
|
|
|
195
|
-
|
|
210
|
+
await user.click(screen.getByRole('button', { name: '30' }));
|
|
211
|
+
|
|
196
212
|
expect(screen.getByTestId('calendar-day-root-30')).toHaveClass('rootIsSelected');
|
|
197
213
|
|
|
198
214
|
expect(mockFn).toHaveBeenCalledTimes(2);
|
|
@@ -4,8 +4,8 @@ import type { Story } from '@storybook/react';
|
|
|
4
4
|
import CalendarInput from './index';
|
|
5
5
|
import type { CalendarInputProps } from './index';
|
|
6
6
|
|
|
7
|
-
import TestChangeHandler from '
|
|
8
|
-
import StorybookPanel from '
|
|
7
|
+
import TestChangeHandler from '../../utility/TestChangeHandler';
|
|
8
|
+
import StorybookPanel from '../../utility/StorybookPanel';
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
11
|
title: 'Components/CalendarInput',
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import React from 'react';
|
|
2
|
-
import
|
|
4
|
+
import clsx from 'clsx';
|
|
3
5
|
import PropTypes from 'prop-types';
|
|
4
6
|
|
|
5
|
-
import FormatService from '
|
|
7
|
+
import FormatService from '../../services/FormatService';
|
|
6
8
|
|
|
7
|
-
import Calendar from '
|
|
8
|
-
import InputPanel from '
|
|
9
|
-
import StaticTextInput from '
|
|
9
|
+
import Calendar from '../../core/Calendar';
|
|
10
|
+
import InputPanel from '../../core/InputPanel';
|
|
11
|
+
import StaticTextInput from '../../core/StaticTextInput';
|
|
10
12
|
|
|
11
|
-
import useClickOutside from '@hooks
|
|
13
|
+
import { useClickOutside } from '@sqrzro/hooks';
|
|
12
14
|
|
|
13
|
-
import type { InputEvent, InputProps, InputValue } from '
|
|
15
|
+
import type { InputEvent, InputProps, InputValue } from '../../utility/interfaces';
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
// Import styles from './CalendarInput.module.css';
|
|
16
18
|
|
|
17
19
|
export interface CalendarInputProps extends InputProps<string> {
|
|
18
20
|
disabledDates?: string[] | ((date: string) => boolean);
|
|
@@ -21,7 +23,7 @@ export interface CalendarInputProps extends InputProps<string> {
|
|
|
21
23
|
isRange?: boolean;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
function formatLabel(value?: InputValue, isRange?: boolean): string {
|
|
25
27
|
if (!value || typeof value !== 'string') {
|
|
26
28
|
return '';
|
|
27
29
|
}
|
|
@@ -37,9 +39,9 @@ const formatLabel = (value?: InputValue, isRange?: boolean): string => {
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
return splitValues.map((item) => FormatService.date(item)).join(' - ');
|
|
40
|
-
}
|
|
42
|
+
}
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
function CalendarInput({
|
|
43
45
|
disabledDates,
|
|
44
46
|
hasError,
|
|
45
47
|
isDisabled,
|
|
@@ -49,18 +51,20 @@ const CalendarInput: React.FunctionComponent<CalendarInputProps> = ({
|
|
|
49
51
|
name,
|
|
50
52
|
value,
|
|
51
53
|
onChange,
|
|
52
|
-
})
|
|
54
|
+
}: CalendarInputProps): React.ReactElement {
|
|
53
55
|
const [isOpen, setIsOpen, node] = useClickOutside();
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
function toggleIsOpen(): void {
|
|
58
|
+
setIsOpen(!isOpen);
|
|
59
|
+
}
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
function handleChange(event: InputEvent<string>): void {
|
|
58
62
|
if (onChange) {
|
|
59
63
|
onChange(event);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
setIsOpen(false);
|
|
63
|
-
}
|
|
67
|
+
}
|
|
64
68
|
|
|
65
69
|
const label = formatLabel(value, isRange);
|
|
66
70
|
|
|
@@ -77,7 +81,7 @@ const CalendarInput: React.FunctionComponent<CalendarInputProps> = ({
|
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
return (
|
|
80
|
-
<div ref={node} className=
|
|
84
|
+
<div ref={node} className="/*clsx(styles.root, isOpen && styles.rootIsOpen)*/">
|
|
81
85
|
<StaticTextInput
|
|
82
86
|
hasError={hasError}
|
|
83
87
|
icon="calendar"
|
|
@@ -89,7 +93,7 @@ const CalendarInput: React.FunctionComponent<CalendarInputProps> = ({
|
|
|
89
93
|
onClick={toggleIsOpen}
|
|
90
94
|
value={value || ''}
|
|
91
95
|
/>
|
|
92
|
-
{isOpen && !isDisabled
|
|
96
|
+
{isOpen && !isDisabled ? (
|
|
93
97
|
<InputPanel>
|
|
94
98
|
<Calendar
|
|
95
99
|
disabledDates={disabledDates}
|
|
@@ -99,10 +103,10 @@ const CalendarInput: React.FunctionComponent<CalendarInputProps> = ({
|
|
|
99
103
|
value={value || ''}
|
|
100
104
|
/>
|
|
101
105
|
</InputPanel>
|
|
102
|
-
)}
|
|
106
|
+
) : null}
|
|
103
107
|
</div>
|
|
104
108
|
);
|
|
105
|
-
}
|
|
109
|
+
}
|
|
106
110
|
|
|
107
111
|
CalendarInput.propTypes = {
|
|
108
112
|
name: PropTypes.string.isRequired,
|
|
@@ -16,12 +16,14 @@ describe('CheckboxList', () => {
|
|
|
16
16
|
render(<CheckboxList data={mockData} name="lorem" />);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it('should handle onChange', () => {
|
|
19
|
+
it('should handle onChange', async () => {
|
|
20
|
+
const user = userEvent.setup();
|
|
21
|
+
|
|
20
22
|
const mockFn = jest.fn();
|
|
21
23
|
render(<CheckboxList data={mockData} name="lorem" onChange={mockFn} value={['banana']} />);
|
|
22
24
|
|
|
23
25
|
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
24
|
-
|
|
26
|
+
await user.click(screen.getAllByRole('checkbox')[0]);
|
|
25
27
|
|
|
26
28
|
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
27
29
|
expect(mockFn).toHaveBeenLastCalledWith({
|
|
@@ -30,12 +32,14 @@ describe('CheckboxList', () => {
|
|
|
30
32
|
});
|
|
31
33
|
});
|
|
32
34
|
|
|
33
|
-
it('should handle onChange with numeric value', () => {
|
|
35
|
+
it('should handle onChange with numeric value', async () => {
|
|
36
|
+
const user = userEvent.setup();
|
|
37
|
+
|
|
34
38
|
const mockFn = jest.fn();
|
|
35
39
|
render(<CheckboxList data={mockData} name="lorem" onChange={mockFn} value={['2']} />);
|
|
36
40
|
|
|
37
41
|
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
38
|
-
|
|
42
|
+
await user.click(screen.getAllByRole('checkbox')[3]);
|
|
39
43
|
|
|
40
44
|
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
41
45
|
expect(mockFn).toHaveBeenLastCalledWith({
|
|
@@ -44,12 +48,14 @@ describe('CheckboxList', () => {
|
|
|
44
48
|
});
|
|
45
49
|
});
|
|
46
50
|
|
|
47
|
-
it('should handle onChange without value', () => {
|
|
51
|
+
it('should handle onChange without value', async () => {
|
|
52
|
+
const user = userEvent.setup();
|
|
53
|
+
|
|
48
54
|
const mockFn = jest.fn();
|
|
49
55
|
render(<CheckboxList data={mockData} name="lorem" onChange={mockFn} />);
|
|
50
56
|
|
|
51
57
|
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
52
|
-
|
|
58
|
+
await user.click(screen.getAllByRole('checkbox')[0]);
|
|
53
59
|
|
|
54
60
|
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
55
61
|
expect(mockFn).toHaveBeenLastCalledWith({
|
|
@@ -58,12 +64,14 @@ describe('CheckboxList', () => {
|
|
|
58
64
|
});
|
|
59
65
|
});
|
|
60
66
|
|
|
61
|
-
it('should handle onChange (removing item)', () => {
|
|
67
|
+
it('should handle onChange (removing item)', async () => {
|
|
68
|
+
const user = userEvent.setup();
|
|
69
|
+
|
|
62
70
|
const mockFn = jest.fn();
|
|
63
71
|
render(<CheckboxList data={mockData} name="lorem" onChange={mockFn} value={['banana']} />);
|
|
64
72
|
|
|
65
73
|
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
66
|
-
|
|
74
|
+
await user.click(screen.getAllByRole('checkbox')[1]);
|
|
67
75
|
|
|
68
76
|
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
69
77
|
expect(mockFn).toHaveBeenLastCalledWith({
|
|
@@ -72,12 +80,14 @@ describe('CheckboxList', () => {
|
|
|
72
80
|
});
|
|
73
81
|
});
|
|
74
82
|
|
|
75
|
-
it('should handle click if no onChange', () => {
|
|
83
|
+
it('should handle click if no onChange', async () => {
|
|
84
|
+
const user = userEvent.setup();
|
|
85
|
+
|
|
76
86
|
const mockFn = jest.fn();
|
|
77
87
|
render(<CheckboxList data={mockData} name="lorem" />);
|
|
78
88
|
|
|
79
89
|
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
80
|
-
|
|
90
|
+
await user.click(screen.getAllByRole('checkbox')[0]);
|
|
81
91
|
expect(mockFn).toHaveBeenCalledTimes(0);
|
|
82
92
|
});
|
|
83
93
|
});
|