@sqrzro/admin 2.0.0-beta.0 → 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/.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/dist/components/Alert/index.d.ts +4 -26
- package/dist/components/Alert/index.js +15 -54
- package/dist/components/Allow/index.d.ts +20 -20
- package/dist/components/Allow/index.js +29 -29
- package/dist/components/AppLayout/AppLayout.stories.d.ts +5 -5
- package/dist/components/AppLayout/AppLayout.stories.js +11 -11
- package/dist/components/AppLayout/index.d.ts +6 -6
- package/dist/components/AppLayout/index.js +18 -11
- package/dist/components/AutoSuggest/index.d.ts +74 -74
- package/dist/components/AutoSuggest/index.js +143 -143
- package/dist/components/Button/Button.stories.d.ts +11 -11
- package/dist/components/Button/Button.stories.js +41 -41
- package/dist/components/Button/index.d.ts +49 -50
- package/dist/components/Button/index.js +50 -50
- package/dist/components/CalendarInput/index.d.ts +24 -24
- package/dist/components/CalendarInput/index.js +54 -56
- package/dist/components/CheckboxList/index.d.ts +17 -17
- package/dist/components/CheckboxList/index.js +25 -25
- package/dist/components/CodeInput/index.d.ts +9 -9
- package/dist/components/CodeInput/index.js +51 -57
- package/dist/components/ConnectedDropdown/index.d.ts +14 -14
- package/dist/components/ConnectedDropdown/index.js +36 -36
- package/dist/components/ConnectedList/index.d.ts +5 -5
- package/dist/components/ConnectedList/index.js +7 -7
- package/dist/components/ConnectedTable/index.d.ts +5 -5
- package/dist/components/ConnectedTable/index.js +7 -7
- package/dist/components/ContentBlock/index.d.ts +16 -16
- package/dist/components/ContentBlock/index.js +13 -13
- package/dist/components/DataPanel/index.d.ts +8 -8
- package/dist/components/DataPanel/index.js +8 -8
- package/dist/components/DateInput/index.d.ts +18 -18
- package/dist/components/DateInput/index.js +81 -81
- package/dist/components/Dropdown/index.d.ts +36 -36
- package/dist/components/Dropdown/index.js +122 -122
- package/dist/components/ErrorMessage/index.d.ts +16 -16
- package/dist/components/ErrorMessage/index.js +17 -17
- package/dist/components/Fieldset/index.d.ts +18 -18
- package/dist/components/Fieldset/index.js +19 -19
- package/dist/components/FileInput/index.d.ts +10 -10
- package/dist/components/FileInput/index.js +26 -26
- package/dist/components/FilterLink/index.d.ts +14 -14
- package/dist/components/FilterLink/index.js +15 -15
- package/dist/components/Form/index.d.ts +14 -14
- package/dist/components/Form/index.js +15 -15
- package/dist/components/FormActions/index.d.ts +18 -18
- package/dist/components/FormActions/index.js +14 -14
- package/dist/components/FormField/index.d.ts +14 -14
- package/dist/components/FormField/index.js +40 -40
- package/dist/components/FormRepeater/index.d.ts +18 -18
- package/dist/components/FormRepeater/index.js +65 -65
- package/dist/components/ImageInput/index.d.ts +13 -13
- package/dist/components/ImageInput/index.js +45 -45
- package/dist/components/InfoPanel/index.d.ts +14 -14
- package/dist/components/InfoPanel/index.js +11 -11
- package/dist/components/Link/__mocks__/index.d.ts +6 -6
- package/dist/components/Link/__mocks__/index.js +12 -12
- package/dist/components/Link/index.d.ts +23 -23
- package/dist/components/Link/index.js +21 -21
- package/dist/components/List/index.d.ts +36 -36
- package/dist/components/List/index.js +46 -46
- package/dist/components/ListActions/index.d.ts +18 -18
- package/dist/components/ListActions/index.js +14 -14
- package/dist/components/LoginForm/index.d.ts +3 -3
- package/dist/components/LoginForm/index.js +47 -47
- package/dist/components/Message/index.d.ts +14 -14
- package/dist/components/Message/index.js +14 -14
- package/dist/components/Modal/index.d.ts +4 -4
- package/dist/components/Modal/index.js +18 -18
- package/dist/components/ModalActions/index.d.ts +21 -21
- package/dist/components/ModalActions/index.js +18 -18
- package/dist/components/MoneyInput/index.d.ts +10 -10
- package/dist/components/MoneyInput/index.js +13 -13
- package/dist/components/PasswordForm/index.d.ts +35 -35
- package/dist/components/PasswordForm/index.js +21 -21
- package/dist/components/PasswordInput/index.d.ts +4 -4
- package/dist/components/PasswordInput/index.js +12 -12
- package/dist/components/RadioList/index.d.ts +9 -9
- package/dist/components/RadioList/index.js +7 -7
- package/dist/components/RootLayout/index.d.ts +6 -8
- package/dist/components/RootLayout/index.js +7 -21
- package/dist/components/SummaryList/index.d.ts +18 -18
- package/dist/components/SummaryList/index.js +15 -15
- package/dist/components/Switch/index.d.ts +21 -21
- package/dist/components/Switch/index.js +31 -31
- package/dist/components/Table/index.d.ts +28 -28
- package/dist/components/Table/index.js +55 -55
- package/dist/components/Tag/index.d.ts +15 -15
- package/dist/components/Tag/index.js +13 -13
- package/dist/components/TextArea/index.d.ts +18 -18
- package/dist/components/TextArea/index.js +26 -26
- package/dist/components/TextInput/index.d.ts +14 -14
- package/dist/components/TextInput/index.js +27 -27
- package/dist/components/WebsiteInput/index.d.ts +10 -10
- package/dist/components/WebsiteInput/index.js +13 -13
- package/dist/components/WeekCalendar/index.d.ts +24 -24
- package/dist/components/WeekCalendar/index.js +48 -48
- package/dist/core/AlertComponent/index.d.ts +26 -26
- package/dist/core/AlertComponent/index.js +35 -45
- package/dist/core/AppHeader/index.d.ts +3 -3
- package/dist/core/AppHeader/index.js +17 -17
- package/dist/core/AppLogo/index.d.ts +12 -12
- package/dist/core/AppLogo/index.js +16 -17
- package/dist/core/AppLogoImage/index.d.ts +3 -3
- package/dist/core/AppLogoImage/index.js +11 -11
- package/dist/core/AppLogoPlaceholder/index.d.ts +3 -3
- package/dist/core/AppLogoPlaceholder/index.js +10 -10
- package/dist/core/Assistive/index.d.ts +12 -12
- package/dist/core/Assistive/index.js +9 -9
- package/dist/core/AuthForm/index.d.ts +10 -10
- package/dist/core/AuthForm/index.js +13 -26
- package/dist/core/Banner/index.d.ts +3 -3
- package/dist/core/Banner/index.js +14 -14
- package/dist/core/Calendar/index.d.ts +21 -21
- package/dist/core/Calendar/index.js +69 -69
- package/dist/core/CalendarDay/index.d.ts +30 -30
- package/dist/core/CalendarDay/index.js +30 -30
- package/dist/core/CalendarMonth/index.d.ts +23 -23
- package/dist/core/CalendarMonth/index.js +45 -45
- package/dist/core/CalendarNavigation/index.d.ts +17 -17
- package/dist/core/CalendarNavigation/index.js +24 -24
- package/dist/core/CalendarWeek/index.d.ts +28 -28
- package/dist/core/CalendarWeek/index.js +46 -46
- package/dist/core/ChkRad/index.d.ts +26 -26
- package/dist/core/ChkRad/index.js +33 -33
- package/dist/core/ChkRadIcon/index.d.ts +14 -14
- package/dist/core/ChkRadIcon/index.js +12 -12
- package/dist/core/ChkRadList/index.d.ts +32 -32
- package/dist/core/ChkRadList/index.js +37 -37
- package/dist/core/CloseButton/index.d.ts +17 -17
- package/dist/core/CloseButton/index.js +12 -12
- package/dist/core/ConfirmModal/index.d.ts +3 -3
- package/dist/core/ConfirmModal/index.js +38 -38
- package/dist/core/ConnectedRepeater/index.d.ts +50 -50
- package/dist/core/ConnectedRepeater/index.js +154 -154
- package/dist/core/ConnectedRepeaterComponent/index.d.ts +24 -24
- package/dist/core/ConnectedRepeaterComponent/index.js +25 -25
- package/dist/core/Container/index.d.ts +14 -14
- package/dist/core/Container/index.js +12 -12
- package/dist/core/DataPanelItem/index.d.ts +8 -8
- package/dist/core/DataPanelItem/index.js +7 -7
- package/dist/core/DropdownPanel/index.d.ts +31 -31
- package/dist/core/DropdownPanel/index.js +32 -32
- package/dist/core/EmptyMessage/index.d.ts +21 -21
- package/dist/core/EmptyMessage/index.js +21 -21
- package/dist/core/FilterItem/index.d.ts +25 -25
- package/dist/core/FilterItem/index.js +82 -84
- package/dist/core/Filters/index.d.ts +31 -31
- package/dist/core/Filters/index.js +85 -85
- package/dist/core/FixedActions/index.d.ts +24 -24
- package/dist/core/FixedActions/index.js +22 -22
- package/dist/core/FormError/index.d.ts +12 -12
- package/dist/core/FormError/index.js +9 -9
- package/dist/core/FormLabel/index.d.ts +16 -16
- package/dist/core/FormLabel/index.js +13 -13
- package/dist/core/FormLegend/index.d.ts +12 -12
- package/dist/core/FormLegend/index.js +9 -9
- package/dist/core/Header/Header.stories.d.ts +5 -5
- package/dist/core/Header/Header.stories.js +11 -11
- package/dist/core/Header/index.d.ts +14 -14
- package/dist/core/Header/index.js +12 -12
- package/dist/core/Icon/index.d.ts +14 -14
- package/dist/core/Icon/index.js +32 -32
- package/dist/core/IconButton/index.d.ts +22 -22
- package/dist/core/IconButton/index.js +20 -20
- package/dist/core/InputPanel/index.d.ts +16 -16
- package/dist/core/InputPanel/index.js +11 -11
- package/dist/core/ListItem/index.d.ts +39 -39
- package/dist/core/ListItem/index.js +44 -44
- package/dist/core/ListItemAction/index.d.ts +11 -11
- package/dist/core/ListItemAction/index.js +13 -13
- package/dist/core/ListItemActions/index.d.ts +8 -8
- package/dist/core/ListItemActions/index.js +16 -16
- package/dist/core/ListItemMetaItem/index.d.ts +19 -19
- package/dist/core/ListItemMetaItem/index.js +29 -29
- package/dist/core/ListItemTitle/index.d.ts +19 -19
- package/dist/core/ListItemTitle/index.js +44 -44
- package/dist/core/Loader/index.d.ts +15 -15
- package/dist/core/Loader/index.js +16 -16
- package/dist/core/MeActions/index.d.ts +3 -3
- package/dist/core/MeActions/index.js +48 -48
- package/dist/core/MePanel/index.d.ts +19 -19
- package/dist/core/MePanel/index.js +29 -29
- package/dist/core/ModalComponent/index.d.ts +22 -22
- package/dist/core/ModalComponent/index.js +29 -29
- package/dist/core/Navigation/index.d.ts +3 -3
- package/dist/core/Navigation/index.js +33 -33
- package/dist/core/NavigationDivider/index.d.ts +3 -3
- package/dist/core/NavigationDivider/index.js +8 -8
- package/dist/core/NavigationItem/index.d.ts +16 -16
- package/dist/core/NavigationItem/index.js +21 -21
- package/dist/core/Pagination/index.d.ts +15 -15
- package/dist/core/Pagination/index.js +64 -64
- package/dist/core/PaginationItem/index.d.ts +10 -10
- package/dist/core/PaginationItem/index.js +17 -17
- package/dist/core/Panel/index.d.ts +17 -17
- package/dist/core/Panel/index.js +13 -16
- package/dist/core/PasswordForgotForm/index.d.ts +7 -7
- package/dist/core/PasswordForgotForm/index.js +40 -40
- package/dist/core/PasswordResetForm/index.d.ts +7 -7
- package/dist/core/PasswordResetForm/index.js +34 -34
- package/dist/core/RadialProgress/index.d.ts +16 -16
- package/dist/core/RadialProgress/index.js +23 -23
- package/dist/core/SettingsForm/index.d.ts +3 -3
- package/dist/core/SettingsForm/index.js +14 -14
- package/dist/core/StaticTextInput/index.d.ts +29 -29
- package/dist/core/StaticTextInput/index.js +39 -39
- package/dist/core/Styled/index.d.ts +6 -6
- package/dist/core/Styled/index.js +39 -39
- package/dist/core/SummaryListItem/index.d.ts +23 -23
- package/dist/core/SummaryListItem/index.js +31 -31
- package/dist/core/TabItem/index.d.ts +4 -4
- package/dist/core/TabItem/index.js +13 -13
- package/dist/core/TableActionsCell/index.d.ts +8 -8
- package/dist/core/TableActionsCell/index.js +8 -8
- package/dist/core/TableCell/index.d.ts +15 -15
- package/dist/core/TableCell/index.js +20 -20
- package/dist/core/TableHead/index.d.ts +18 -18
- package/dist/core/TableHead/index.js +18 -18
- package/dist/core/TableRow/index.d.ts +13 -13
- package/dist/core/TableRow/index.js +18 -18
- package/dist/core/Tabs/index.d.ts +7 -7
- package/dist/core/Tabs/index.js +13 -13
- package/dist/core/TextInputAncillary/index.d.ts +29 -29
- package/dist/core/TextInputAncillary/index.js +31 -31
- package/dist/core/Toast/index.d.ts +3 -3
- package/dist/core/Toast/index.js +47 -47
- package/dist/core/TwoFactor/index.d.ts +13 -13
- package/dist/core/TwoFactor/index.js +49 -49
- package/dist/core/TwoFactorAuthenticator/index.d.ts +10 -10
- package/dist/core/TwoFactorAuthenticator/index.js +9 -9
- package/dist/core/TwoFactorMethodList/index.d.ts +10 -10
- package/dist/core/TwoFactorMethodList/index.js +22 -22
- package/dist/core/TwoFactorSetup/index.d.ts +12 -12
- package/dist/core/TwoFactorSetup/index.js +43 -43
- package/dist/core/TwoFactorSetupAuthenticator/index.d.ts +20 -20
- package/dist/core/TwoFactorSetupAuthenticator/index.js +42 -42
- package/dist/core/TwoFactorSetupYubikey/index.d.ts +16 -16
- package/dist/core/TwoFactorSetupYubikey/index.js +14 -14
- package/dist/core/TwoFactorYubikey/index.d.ts +9 -9
- package/dist/core/TwoFactorYubikey/index.js +14 -14
- package/dist/core/WeekCalendarDay/index.d.ts +27 -27
- package/dist/core/WeekCalendarDay/index.js +35 -35
- package/dist/core/YubikeyInput/index.d.ts +4 -4
- package/dist/core/YubikeyInput/index.js +14 -39
- package/dist/filters/BooleanFilter/index.d.ts +14 -14
- package/dist/filters/BooleanFilter/index.js +35 -35
- package/dist/filters/DateFilter/index.d.ts +5 -5
- package/dist/filters/DateFilter/index.js +24 -24
- package/dist/filters/DropdownFilter/index.d.ts +17 -17
- package/dist/filters/DropdownFilter/index.js +32 -32
- package/dist/filters/QuickDateFilter/index.d.ts +13 -13
- package/dist/filters/QuickDateFilter/index.js +40 -40
- package/dist/filters/interfaces.d.ts +35 -35
- package/dist/filters/interfaces.js +1 -1
- package/dist/hooks/useAlert.d.ts +12 -12
- package/dist/hooks/useAlert.js +18 -18
- package/dist/hooks/useAppConfig.d.ts +3 -0
- package/dist/hooks/useAppConfig.js +5 -0
- package/dist/hooks/useConnectedList.d.ts +7 -7
- package/dist/hooks/useConnectedList.js +6 -6
- package/dist/hooks/useConnectedRepeater.d.ts +7 -7
- package/dist/hooks/useConnectedRepeater.js +14 -14
- package/dist/hooks/useConnectedTable.d.ts +7 -7
- package/dist/hooks/useConnectedTable.js +6 -6
- package/dist/hooks/useFilters.d.ts +9 -9
- package/dist/hooks/useFilters.js +24 -24
- package/dist/hooks/useLayout.d.ts +7 -7
- package/dist/hooks/useLayout.js +10 -10
- package/dist/hooks/useLayout.spec.d.ts +1 -1
- package/dist/hooks/useLayout.spec.js +24 -24
- package/dist/hooks/useModal.d.ts +12 -12
- package/dist/hooks/useModal.js +39 -39
- package/dist/hooks/useModalOffset.d.ts +2 -2
- package/dist/hooks/useModalOffset.js +16 -16
- package/dist/hooks/useModalOffset.spec.d.ts +1 -1
- package/dist/hooks/useModalOffset.spec.js +19 -19
- package/dist/hooks/useNavigation.d.ts +7 -7
- package/dist/hooks/useNavigation.js +113 -113
- package/dist/hooks/useRemote.d.ts +7 -7
- package/dist/hooks/useRemote.js +29 -29
- package/dist/hooks/useVariant.d.ts +9 -9
- package/dist/hooks/useVariant.js +14 -14
- package/dist/index.d.ts +209 -208
- package/dist/index.js +213 -212
- package/dist/scenes/Error404Scene.d.ts +3 -3
- package/dist/scenes/Error404Scene.js +5 -5
- package/dist/services/AppService.d.ts +5 -5
- package/dist/services/AppService.js +11 -11
- package/dist/services/ConfigService.d.ts +42 -42
- package/dist/services/ConfigService.js +52 -55
- package/dist/services/ConfirmService.d.ts +12 -12
- package/dist/services/ConfirmService.js +10 -10
- package/dist/services/DateService.d.ts +26 -26
- package/dist/services/DateService.js +132 -132
- package/dist/services/DateService.spec.d.ts +1 -1
- package/dist/services/DateService.spec.js +83 -83
- package/dist/services/DownloadService.d.ts +7 -7
- package/dist/services/DownloadService.js +16 -16
- package/dist/services/DownloadService.spec.d.ts +1 -1
- package/dist/services/DownloadService.spec.js +18 -18
- package/dist/services/FilterComponentService.d.ts +25 -25
- package/dist/services/FilterComponentService.js +54 -54
- package/dist/services/FilterService.d.ts +34 -34
- package/dist/services/FilterService.js +58 -58
- package/dist/services/FilterService.spec.d.ts +1 -1
- package/dist/services/FilterService.spec.js +67 -67
- package/dist/services/FormatService.d.ts +11 -11
- package/dist/services/FormatService.js +45 -45
- package/dist/services/FormatService.spec.d.ts +1 -1
- package/dist/services/FormatService.spec.js +66 -66
- package/dist/services/ToastService.d.ts +7 -7
- package/dist/services/ToastService.js +17 -17
- package/dist/services/ToastService.spec.d.ts +1 -1
- package/dist/services/ToastService.spec.js +34 -34
- package/dist/styles.css +125 -67
- package/dist/utility/MockRouter/index.d.ts +2 -2
- package/dist/utility/MockRouter/index.js +37 -37
- package/dist/utility/StorybookPanel/index.d.ts +14 -14
- package/dist/utility/StorybookPanel/index.js +12 -12
- package/dist/utility/TestChangeHandler/index.d.ts +15 -15
- package/dist/utility/TestChangeHandler/index.js +30 -30
- package/dist/utility/icons.d.ts +3 -3
- package/dist/utility/icons.js +12 -12
- package/dist/utility/interfaces.d.ts +79 -80
- package/dist/utility/interfaces.js +18 -18
- package/dist/utility/middleware.d.ts +4 -4
- package/dist/utility/middleware.js +9 -4
- package/dist/utility/prop-types.d.ts +57 -57
- package/dist/utility/prop-types.js +77 -77
- package/dist/utility/register.d.ts +3 -3
- package/dist/utility/register.js +9 -7
- package/package.json +5 -5
- package/src/components/LoginForm/index.tsx +1 -1
- package/src/core/TwoFactor/TwoFactor.spec.tsx +4 -4
- package/src/core/TwoFactor/index.tsx +5 -5
- package/src/core/TwoFactorAuthenticator/index.tsx +1 -1
- package/src/core/TwoFactorSetup/index.tsx +1 -1
- package/src/core/TwoFactorYubikey/index.tsx +1 -1
- package/dist/hooks/useConfig.d.ts +0 -9
- package/dist/hooks/useConfig.js +0 -13
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import Link from '
|
|
6
|
-
import Loader from '../../core/Loader';
|
|
7
|
-
import useVariant from '../../hooks/useVariant';
|
|
8
|
-
import { ButtonVariantPropType } from '../../utility/prop-types';
|
|
9
|
-
/**
|
|
10
|
-
* Either a `Link` component or a `button` element, depending on whether a `to` prop is specified.
|
|
11
|
-
*
|
|
12
|
-
* As a `Link`, it provides navigation between pages, and as a `button` it will handle the
|
|
13
|
-
* `onClick` function when clicked (if one is specified).
|
|
14
|
-
*
|
|
15
|
-
* ## to & onClick
|
|
16
|
-
*
|
|
17
|
-
* Although it is possible to omit both the `to` and `onClick` props, there will
|
|
18
|
-
* be nearly zero situations where this would be useful. It is also possible to include both props.
|
|
19
|
-
* This will create a `Link` component, and handle the `onClick` function before navigation.
|
|
20
|
-
*
|
|
21
|
-
* ## Styles
|
|
22
|
-
*
|
|
23
|
-
* The `Button` will stretch to the full width of its parent element. If you wish to have a smaller
|
|
24
|
-
* width, you can wrap it in a `div`, and then wrap that `div` in a component with a flex property.
|
|
25
|
-
* Components like `ListActions` and `ModalActions` do this for you.
|
|
26
|
-
*/
|
|
27
|
-
function Button({ to, children, type, variant, isDisabled, isFullWidth, isLoading, onClick,
|
|
28
|
-
const { applyVariantClassName } = useVariant(variant);
|
|
29
|
-
const className = clsx('text-white bg-blue-500 focus:ring-4 focus:outline-none focus:ring-cyan-300 dark:focus:ring-cyan-800 font-medium rounded-md text-sm px-5 py-2.5 text-center mr-2 mb-2', {
|
|
30
|
-
'opacity-30 pointer-events-none': isDisabled || isLoading,
|
|
31
|
-
'w-full': isFullWidth,
|
|
32
|
-
}, applyVariantClassName({ danger: 'bg-red-900' }));
|
|
33
|
-
if (to) {
|
|
34
|
-
return (React.createElement(Link, { className: className, onClick: onClick, to: to }, children));
|
|
35
|
-
}
|
|
36
|
-
return (React.createElement("button", { className: className, disabled: isDisabled || isLoading || false, onClick: onClick, type: type === 'submit' ? 'submit' : 'button'
|
|
37
|
-
isLoading ? (React.createElement("div", { className: "absolute left-1/2 top-1/2 -translate-x-2/4 -translate-y-2/4" },
|
|
38
|
-
React.createElement(Loader, { isMini: true }))) : null,
|
|
39
|
-
children));
|
|
40
|
-
}
|
|
41
|
-
Button.propTypes = {
|
|
42
|
-
children: PropTypes.node.isRequired,
|
|
43
|
-
isDisabled: PropTypes.bool,
|
|
44
|
-
isFullWidth: PropTypes.bool,
|
|
45
|
-
to: PropTypes.string,
|
|
46
|
-
type: PropTypes.oneOf(['button', 'submit']),
|
|
47
|
-
variant: ButtonVariantPropType,
|
|
48
|
-
onClick: PropTypes.func,
|
|
49
|
-
};
|
|
50
|
-
export default Button;
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import Link from '../../components/Link';
|
|
6
|
+
import Loader from '../../core/Loader';
|
|
7
|
+
import useVariant from '../../hooks/useVariant';
|
|
8
|
+
import { ButtonVariantPropType } from '../../utility/prop-types';
|
|
9
|
+
/**
|
|
10
|
+
* Either a `Link` component or a `button` element, depending on whether a `to` prop is specified.
|
|
11
|
+
*
|
|
12
|
+
* As a `Link`, it provides navigation between pages, and as a `button` it will handle the
|
|
13
|
+
* `onClick` function when clicked (if one is specified).
|
|
14
|
+
*
|
|
15
|
+
* ## to & onClick
|
|
16
|
+
*
|
|
17
|
+
* Although it is possible to omit both the `to` and `onClick` props, there will
|
|
18
|
+
* be nearly zero situations where this would be useful. It is also possible to include both props.
|
|
19
|
+
* This will create a `Link` component, and handle the `onClick` function before navigation.
|
|
20
|
+
*
|
|
21
|
+
* ## Styles
|
|
22
|
+
*
|
|
23
|
+
* The `Button` will stretch to the full width of its parent element. If you wish to have a smaller
|
|
24
|
+
* width, you can wrap it in a `div`, and then wrap that `div` in a component with a flex property.
|
|
25
|
+
* Components like `ListActions` and `ModalActions` do this for you.
|
|
26
|
+
*/
|
|
27
|
+
function Button({ to, children, type, variant, isDisabled, isFullWidth, isLoading, onClick, }) {
|
|
28
|
+
const { applyVariantClassName } = useVariant(variant);
|
|
29
|
+
const className = clsx('text-white bg-blue-500 focus:ring-4 focus:outline-none focus:ring-cyan-300 dark:focus:ring-cyan-800 font-medium rounded-md text-sm px-5 py-2.5 text-center mr-2 mb-2', {
|
|
30
|
+
'opacity-30 pointer-events-none': isDisabled || isLoading,
|
|
31
|
+
'w-full': isFullWidth,
|
|
32
|
+
}, applyVariantClassName({ danger: 'bg-red-900' }));
|
|
33
|
+
if (to) {
|
|
34
|
+
return (React.createElement(Link, { className: className, onClick: onClick, to: to }, children));
|
|
35
|
+
}
|
|
36
|
+
return (React.createElement("button", { className: className, disabled: isDisabled || isLoading || false, onClick: onClick, type: type === 'submit' ? 'submit' : 'button' },
|
|
37
|
+
isLoading ? (React.createElement("div", { className: "absolute left-1/2 top-1/2 -translate-x-2/4 -translate-y-2/4" },
|
|
38
|
+
React.createElement(Loader, { isMini: true }))) : null,
|
|
39
|
+
children));
|
|
40
|
+
}
|
|
41
|
+
Button.propTypes = {
|
|
42
|
+
children: PropTypes.node.isRequired,
|
|
43
|
+
isDisabled: PropTypes.bool,
|
|
44
|
+
isFullWidth: PropTypes.bool,
|
|
45
|
+
to: PropTypes.string,
|
|
46
|
+
type: PropTypes.oneOf(['button', 'submit']),
|
|
47
|
+
variant: ButtonVariantPropType,
|
|
48
|
+
onClick: PropTypes.func,
|
|
49
|
+
};
|
|
50
|
+
export default Button;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import type { InputProps } from '../../utility/interfaces';
|
|
4
|
-
export interface CalendarInputProps extends InputProps<string> {
|
|
5
|
-
disabledDates?: string[] | ((date: string) => boolean);
|
|
6
|
-
isOptional?: boolean;
|
|
7
|
-
isPanelOnly?: boolean;
|
|
8
|
-
isRange?: boolean;
|
|
9
|
-
}
|
|
10
|
-
declare function CalendarInput({ disabledDates, hasError, isDisabled, isOptional, isPanelOnly, isRange, name, value, onChange, }: CalendarInputProps): React.ReactElement;
|
|
11
|
-
declare namespace CalendarInput {
|
|
12
|
-
var propTypes: {
|
|
13
|
-
name: PropTypes.Validator<string>;
|
|
14
|
-
disabledDates: PropTypes.Requireable<NonNullable<string[] | ((...args: any[]) => any) | null | undefined>>;
|
|
15
|
-
hasError: PropTypes.Requireable<boolean>;
|
|
16
|
-
isDisabled: PropTypes.Requireable<boolean>;
|
|
17
|
-
isOptional: PropTypes.Requireable<boolean>;
|
|
18
|
-
isPanelOnly: PropTypes.Requireable<boolean>;
|
|
19
|
-
isRange: PropTypes.Requireable<boolean>;
|
|
20
|
-
value: PropTypes.Requireable<string>;
|
|
21
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export default CalendarInput;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import type { InputProps } from '../../utility/interfaces';
|
|
4
|
+
export interface CalendarInputProps extends InputProps<string> {
|
|
5
|
+
disabledDates?: string[] | ((date: string) => boolean);
|
|
6
|
+
isOptional?: boolean;
|
|
7
|
+
isPanelOnly?: boolean;
|
|
8
|
+
isRange?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare function CalendarInput({ disabledDates, hasError, isDisabled, isOptional, isPanelOnly, isRange, name, value, onChange, }: CalendarInputProps): React.ReactElement;
|
|
11
|
+
declare namespace CalendarInput {
|
|
12
|
+
var propTypes: {
|
|
13
|
+
name: PropTypes.Validator<string>;
|
|
14
|
+
disabledDates: PropTypes.Requireable<NonNullable<string[] | ((...args: any[]) => any) | null | undefined>>;
|
|
15
|
+
hasError: PropTypes.Requireable<boolean>;
|
|
16
|
+
isDisabled: PropTypes.Requireable<boolean>;
|
|
17
|
+
isOptional: PropTypes.Requireable<boolean>;
|
|
18
|
+
isPanelOnly: PropTypes.Requireable<boolean>;
|
|
19
|
+
isRange: PropTypes.Requireable<boolean>;
|
|
20
|
+
value: PropTypes.Requireable<string>;
|
|
21
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export default CalendarInput;
|
|
@@ -1,56 +1,54 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import FormatService from '../../services/FormatService';
|
|
5
|
-
import Calendar from '../../core/Calendar';
|
|
6
|
-
import InputPanel from '../../core/InputPanel';
|
|
7
|
-
import StaticTextInput from '../../core/StaticTextInput';
|
|
8
|
-
import { useClickOutside } from '@sqrzro/hooks';
|
|
9
|
-
|
|
10
|
-
if (!value || typeof value !== 'string') {
|
|
11
|
-
return '';
|
|
12
|
-
}
|
|
13
|
-
if (!isRange) {
|
|
14
|
-
return FormatService.date(value);
|
|
15
|
-
}
|
|
16
|
-
const splitValues = value.split(',');
|
|
17
|
-
if (splitValues[0] === splitValues[1]) {
|
|
18
|
-
return FormatService.date(splitValues[0]);
|
|
19
|
-
}
|
|
20
|
-
return splitValues.map((item) => FormatService.date(item)).join(' - ');
|
|
21
|
-
}
|
|
22
|
-
function CalendarInput({ disabledDates, hasError, isDisabled, isOptional, isPanelOnly, isRange, name, value, onChange, }) {
|
|
23
|
-
const [isOpen, setIsOpen, node] = useClickOutside();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
export default CalendarInput;
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import FormatService from '../../services/FormatService';
|
|
5
|
+
import Calendar from '../../core/Calendar';
|
|
6
|
+
import InputPanel from '../../core/InputPanel';
|
|
7
|
+
import StaticTextInput from '../../core/StaticTextInput';
|
|
8
|
+
import { useClickOutside } from '@sqrzro/hooks';
|
|
9
|
+
const formatLabel = (value, isRange) => {
|
|
10
|
+
if (!value || typeof value !== 'string') {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
if (!isRange) {
|
|
14
|
+
return FormatService.date(value);
|
|
15
|
+
}
|
|
16
|
+
const splitValues = value.split(',');
|
|
17
|
+
if (splitValues[0] === splitValues[1]) {
|
|
18
|
+
return FormatService.date(splitValues[0]);
|
|
19
|
+
}
|
|
20
|
+
return splitValues.map((item) => FormatService.date(item)).join(' - ');
|
|
21
|
+
};
|
|
22
|
+
function CalendarInput({ disabledDates, hasError, isDisabled, isOptional, isPanelOnly, isRange, name, value, onChange, }) {
|
|
23
|
+
const [isOpen, setIsOpen, node] = useClickOutside();
|
|
24
|
+
const toggleIsOpen = () => setIsOpen(!isOpen);
|
|
25
|
+
const handleChange = (event) => {
|
|
26
|
+
if (onChange) {
|
|
27
|
+
onChange(event);
|
|
28
|
+
}
|
|
29
|
+
setIsOpen(false);
|
|
30
|
+
};
|
|
31
|
+
const label = formatLabel(value, isRange);
|
|
32
|
+
if (isPanelOnly) {
|
|
33
|
+
return (React.createElement(Calendar, { disabledDates: disabledDates, isRange: isRange, name: name, onChange: handleChange, value: value || '' }));
|
|
34
|
+
}
|
|
35
|
+
return (React.createElement("div", { ref: node, className: "/*clsx(styles.root, isOpen && styles.rootIsOpen)*/" },
|
|
36
|
+
React.createElement(StaticTextInput, { hasError: hasError, icon: "calendar", isDisabled: isDisabled, isOptional: isOptional, label: label, name: name, onChange: handleChange, onClick: toggleIsOpen, value: value || '' }),
|
|
37
|
+
isOpen && !isDisabled ? (React.createElement(InputPanel, null,
|
|
38
|
+
React.createElement(Calendar, { disabledDates: disabledDates, isRange: isRange, name: name, onChange: handleChange, value: value || '' }))) : null));
|
|
39
|
+
}
|
|
40
|
+
CalendarInput.propTypes = {
|
|
41
|
+
name: PropTypes.string.isRequired,
|
|
42
|
+
disabledDates: PropTypes.oneOfType([
|
|
43
|
+
PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
44
|
+
PropTypes.func,
|
|
45
|
+
]),
|
|
46
|
+
hasError: PropTypes.bool,
|
|
47
|
+
isDisabled: PropTypes.bool,
|
|
48
|
+
isOptional: PropTypes.bool,
|
|
49
|
+
isPanelOnly: PropTypes.bool,
|
|
50
|
+
isRange: PropTypes.bool,
|
|
51
|
+
value: PropTypes.string,
|
|
52
|
+
onChange: PropTypes.func,
|
|
53
|
+
};
|
|
54
|
+
export default CalendarInput;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import type { ChkRadDataItem } from '../../core/ChkRadList';
|
|
4
|
-
import type { InputProps } from '../../utility/interfaces';
|
|
5
|
-
interface CheckboxListProps extends InputProps<string[]> {
|
|
6
|
-
columns?: number;
|
|
7
|
-
data: ChkRadDataItem[];
|
|
8
|
-
}
|
|
9
|
-
declare function CheckboxList({ name, onChange, value, ...props }: CheckboxListProps): React.ReactElement;
|
|
10
|
-
declare namespace CheckboxList {
|
|
11
|
-
var propTypes: {
|
|
12
|
-
name: PropTypes.Validator<string>;
|
|
13
|
-
value: PropTypes.Requireable<string[]>;
|
|
14
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export default CheckboxList;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import type { ChkRadDataItem } from '../../core/ChkRadList';
|
|
4
|
+
import type { InputProps } from '../../utility/interfaces';
|
|
5
|
+
interface CheckboxListProps extends InputProps<string[]> {
|
|
6
|
+
columns?: number;
|
|
7
|
+
data: ChkRadDataItem[];
|
|
8
|
+
}
|
|
9
|
+
declare function CheckboxList({ name, onChange, value, ...props }: CheckboxListProps): React.ReactElement;
|
|
10
|
+
declare namespace CheckboxList {
|
|
11
|
+
var propTypes: {
|
|
12
|
+
name: PropTypes.Validator<string>;
|
|
13
|
+
value: PropTypes.Requireable<string[]>;
|
|
14
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export default CheckboxList;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { toggleArrayItem } from '@sqrzro/utility';
|
|
5
|
-
import ChkRadList from '../../core/ChkRadList';
|
|
6
|
-
function CheckboxList({ name, onChange, value, ...props }) {
|
|
7
|
-
|
|
8
|
-
if (!onChange) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const newArray = toggleArrayItem(value || [], event.target.value);
|
|
12
|
-
const simpleEvent = {
|
|
13
|
-
item: event.item,
|
|
14
|
-
target: { name, value: newArray },
|
|
15
|
-
};
|
|
16
|
-
onChange(simpleEvent);
|
|
17
|
-
}
|
|
18
|
-
return (React.createElement(ChkRadList, { ...props, name: `${name}[]`, onChange: handleChange, type: "checkbox", value: value }));
|
|
19
|
-
}
|
|
20
|
-
CheckboxList.propTypes = {
|
|
21
|
-
name: PropTypes.string.isRequired,
|
|
22
|
-
value: PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
23
|
-
onChange: PropTypes.func,
|
|
24
|
-
};
|
|
25
|
-
export default CheckboxList;
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { toggleArrayItem } from '@sqrzro/utility';
|
|
5
|
+
import ChkRadList from '../../core/ChkRadList';
|
|
6
|
+
function CheckboxList({ name, onChange, value, ...props }) {
|
|
7
|
+
const handleChange = (event) => {
|
|
8
|
+
if (!onChange) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const newArray = toggleArrayItem(value || [], event.target.value);
|
|
12
|
+
const simpleEvent = {
|
|
13
|
+
item: event.item,
|
|
14
|
+
target: { name, value: newArray },
|
|
15
|
+
};
|
|
16
|
+
onChange(simpleEvent);
|
|
17
|
+
};
|
|
18
|
+
return (React.createElement(ChkRadList, { ...props, name: `${name}[]`, onChange: handleChange, type: "checkbox", value: value }));
|
|
19
|
+
}
|
|
20
|
+
CheckboxList.propTypes = {
|
|
21
|
+
name: PropTypes.string.isRequired,
|
|
22
|
+
value: PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
23
|
+
onChange: PropTypes.func,
|
|
24
|
+
};
|
|
25
|
+
export default CheckboxList;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
interface CodeInputProps extends InputProps<string> {
|
|
4
|
-
isAutoFocus?: boolean;
|
|
5
|
-
onFinalChange?:
|
|
6
|
-
size?: number;
|
|
7
|
-
}
|
|
8
|
-
declare function CodeInput({ hasError, id, isAutoFocus, isDisabled, name, onChange, onFinalChange, size, value, }: CodeInputProps): React.ReactElement;
|
|
9
|
-
export default CodeInput;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { InputProps } from '../../utility/interfaces';
|
|
3
|
+
interface CodeInputProps extends InputProps<string> {
|
|
4
|
+
isAutoFocus?: boolean;
|
|
5
|
+
onFinalChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
6
|
+
size?: number;
|
|
7
|
+
}
|
|
8
|
+
declare function CodeInput({ hasError, id, isAutoFocus, isDisabled, name, onChange, onFinalChange, size, value, }: CodeInputProps): React.ReactElement;
|
|
9
|
+
export default CodeInput;
|
|
@@ -1,57 +1,51 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React, {
|
|
3
|
-
// Import styles from './CodeInput.module.css';
|
|
4
|
-
const DEFAULT_SIZE = 6;
|
|
5
|
-
function CodeInput({ hasError, id, isAutoFocus, isDisabled, name, onChange, onFinalChange, size = DEFAULT_SIZE, value, }) {
|
|
6
|
-
const inputs = useRef([]);
|
|
7
|
-
const values = (value || '').split('');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (ref) {
|
|
53
|
-
inputs.current[index] = ref;
|
|
54
|
-
}
|
|
55
|
-
}, autoComplete: "off", autoFocus: Boolean(isAutoFocus && index === 0), className: "/*clsx(styles.input, { [styles.rootHasError]: hasError)*/", disabled: isDisabled, id: index === 0 ? id || name : `${id || name}-${index}`, maxLength: 1, name: `${name}_${index}`, onChange: handleChange(index), onKeyDown: handleKeyDown(index), onPaste: handlePaste, value: values[index] || '' })))));
|
|
56
|
-
}
|
|
57
|
-
export default CodeInput;
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
// Import styles from './CodeInput.module.css';
|
|
4
|
+
const DEFAULT_SIZE = 6;
|
|
5
|
+
function CodeInput({ hasError, id, isAutoFocus, isDisabled, name, onChange, onFinalChange, size = DEFAULT_SIZE, value, }) {
|
|
6
|
+
const inputs = useRef([]);
|
|
7
|
+
const values = (value || '').split('');
|
|
8
|
+
const handleChange = (index) => (event) => {
|
|
9
|
+
const newValues = [...values];
|
|
10
|
+
newValues[index] = event.target.value;
|
|
11
|
+
if (onChange) {
|
|
12
|
+
onChange({ target: { name, value: newValues.join('') } });
|
|
13
|
+
}
|
|
14
|
+
if (inputs.current[index] && inputs.current[index].value.length === 1) {
|
|
15
|
+
inputs.current[index + 1]?.focus();
|
|
16
|
+
}
|
|
17
|
+
if (newValues.length === size) {
|
|
18
|
+
onFinalChange?.(event);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const handleKeyDown = (index) => (event) => {
|
|
22
|
+
if (event.key === 'Backspace' && !event.target.value) {
|
|
23
|
+
let prevInput = index - 1;
|
|
24
|
+
while (prevInput >= 0 && !values[prevInput]) {
|
|
25
|
+
prevInput -= 1;
|
|
26
|
+
}
|
|
27
|
+
if (inputs.current[prevInput]) {
|
|
28
|
+
inputs.current[prevInput].focus();
|
|
29
|
+
inputs.current[prevInput].value = '';
|
|
30
|
+
}
|
|
31
|
+
const newValues = [...values];
|
|
32
|
+
newValues[prevInput] = '';
|
|
33
|
+
if (onChange) {
|
|
34
|
+
onChange({ target: { name, value: newValues.join('') } });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const handlePaste = (event) => {
|
|
39
|
+
event.clipboardData.items[0].getAsString((string) => {
|
|
40
|
+
if (onChange) {
|
|
41
|
+
onChange({ target: { name, value: string.substring(0, size) } });
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
return (React.createElement("div", { className: "/*clsx(styles.root, { [styles.rootIsDisabled]: isDisabled)*/" }, Array.from({ length: size }, (item, index) => (React.createElement("input", { key: index, ref: (ref) => {
|
|
46
|
+
if (ref) {
|
|
47
|
+
inputs.current[index] = ref;
|
|
48
|
+
}
|
|
49
|
+
}, autoComplete: "off", autoFocus: Boolean(isAutoFocus && index === 0), className: "/*clsx(styles.input, { [styles.rootHasError]: hasError)*/", disabled: isDisabled, id: index === 0 ? id || name : `${id || name}-${index}`, maxLength: 1, name: `${name}_${index}`, onChange: handleChange(index), onKeyDown: handleKeyDown(index), onPaste: handlePaste, value: values[index] || '' })))));
|
|
50
|
+
}
|
|
51
|
+
export default CodeInput;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import type { InputProps, Remote } from '../../utility/interfaces';
|
|
4
|
-
interface ConnnectedDropdownProps extends InputProps<string[] | string> {
|
|
5
|
-
isPanelOnly?: boolean;
|
|
6
|
-
remote: Remote;
|
|
7
|
-
}
|
|
8
|
-
declare function ConnectedDropdown({ remote, ...props }: ConnnectedDropdownProps): React.ReactElement;
|
|
9
|
-
declare namespace ConnectedDropdown {
|
|
10
|
-
var propTypes: {
|
|
11
|
-
name: PropTypes.Validator<string>;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export default ConnectedDropdown;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import type { InputProps, Remote } from '../../utility/interfaces';
|
|
4
|
+
interface ConnnectedDropdownProps extends InputProps<string[] | string> {
|
|
5
|
+
isPanelOnly?: boolean;
|
|
6
|
+
remote: Remote;
|
|
7
|
+
}
|
|
8
|
+
declare function ConnectedDropdown({ remote, ...props }: ConnnectedDropdownProps): React.ReactElement;
|
|
9
|
+
declare namespace ConnectedDropdown {
|
|
10
|
+
var propTypes: {
|
|
11
|
+
name: PropTypes.Validator<string>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export default ConnectedDropdown;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { ApiService } from '@sqrzro/utility';
|
|
5
|
-
import Dropdown from '
|
|
6
|
-
import ErrorMessage from '
|
|
7
|
-
const parseRemote = (remote) => {
|
|
8
|
-
if (Array.isArray(remote)) {
|
|
9
|
-
return [remote[0], { ...remote[1], simpleview: '1' }];
|
|
10
|
-
}
|
|
11
|
-
return [remote, { simpleview: '1' }];
|
|
12
|
-
};
|
|
13
|
-
function ConnectedDropdown({ remote, ...props }) {
|
|
14
|
-
const [data, setData] = useState();
|
|
15
|
-
const [isError, setIsError] = useState(false);
|
|
16
|
-
const getData = async () => {
|
|
17
|
-
try {
|
|
18
|
-
const response = await ApiService.get(parseRemote(remote));
|
|
19
|
-
setData(response.data);
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
setIsError(true);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
void getData();
|
|
27
|
-
}, []);
|
|
28
|
-
if (isError) {
|
|
29
|
-
return React.createElement(ErrorMessage, { isMini: true });
|
|
30
|
-
}
|
|
31
|
-
return React.createElement(Dropdown, { data: data, isDisabled: !data, ...props });
|
|
32
|
-
}
|
|
33
|
-
ConnectedDropdown.propTypes = {
|
|
34
|
-
name: PropTypes.string.isRequired,
|
|
35
|
-
};
|
|
36
|
-
export default ConnectedDropdown;
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { ApiService } from '@sqrzro/utility';
|
|
5
|
+
import Dropdown from '../../components/Dropdown';
|
|
6
|
+
import ErrorMessage from '../../components/ErrorMessage';
|
|
7
|
+
const parseRemote = (remote) => {
|
|
8
|
+
if (Array.isArray(remote)) {
|
|
9
|
+
return [remote[0], { ...remote[1], simpleview: '1' }];
|
|
10
|
+
}
|
|
11
|
+
return [remote, { simpleview: '1' }];
|
|
12
|
+
};
|
|
13
|
+
function ConnectedDropdown({ remote, ...props }) {
|
|
14
|
+
const [data, setData] = useState();
|
|
15
|
+
const [isError, setIsError] = useState(false);
|
|
16
|
+
const getData = async () => {
|
|
17
|
+
try {
|
|
18
|
+
const response = await ApiService.get(parseRemote(remote));
|
|
19
|
+
setData(response.data);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
setIsError(true);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
void getData();
|
|
27
|
+
}, []);
|
|
28
|
+
if (isError) {
|
|
29
|
+
return React.createElement(ErrorMessage, { isMini: true });
|
|
30
|
+
}
|
|
31
|
+
return React.createElement(Dropdown, { data: data, isDisabled: !data, ...props });
|
|
32
|
+
}
|
|
33
|
+
ConnectedDropdown.propTypes = {
|
|
34
|
+
name: PropTypes.string.isRequired,
|
|
35
|
+
};
|
|
36
|
+
export default ConnectedDropdown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { ConnectedRepeaterElementProps } from '../../core/ConnectedRepeater';
|
|
3
|
-
import type { SimpleObject } from '../../utility/interfaces';
|
|
4
|
-
declare function ConnectedList<T extends SimpleObject>(props: ConnectedRepeaterElementProps<T>): React.ReactElement;
|
|
5
|
-
export default ConnectedList;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ConnectedRepeaterElementProps } from '../../core/ConnectedRepeater';
|
|
3
|
+
import type { SimpleObject } from '../../utility/interfaces';
|
|
4
|
+
declare function ConnectedList<T extends SimpleObject>(props: ConnectedRepeaterElementProps<T>): React.ReactElement;
|
|
5
|
+
export default ConnectedList;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ConnectedRepeater from '../../core/ConnectedRepeater';
|
|
3
|
-
import List from '
|
|
4
|
-
function ConnectedList(props) {
|
|
5
|
-
return (React.createElement(ConnectedRepeater, { ...props, render: (renderProps) => React.createElement(List, { ...renderProps }) }));
|
|
6
|
-
}
|
|
7
|
-
export default ConnectedList;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ConnectedRepeater from '../../core/ConnectedRepeater';
|
|
3
|
+
import List from '../../components/List';
|
|
4
|
+
function ConnectedList(props) {
|
|
5
|
+
return (React.createElement(ConnectedRepeater, { ...props, render: (renderProps) => React.createElement(List, { ...renderProps }) }));
|
|
6
|
+
}
|
|
7
|
+
export default ConnectedList;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { ConnectedRepeaterElementProps } from '../../core/ConnectedRepeater';
|
|
3
|
-
import type { SimpleObject } from '../../utility/interfaces';
|
|
4
|
-
declare function ConnectedTable<T extends SimpleObject>(props: ConnectedRepeaterElementProps<T>): React.ReactElement;
|
|
5
|
-
export default ConnectedTable;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ConnectedRepeaterElementProps } from '../../core/ConnectedRepeater';
|
|
3
|
+
import type { SimpleObject } from '../../utility/interfaces';
|
|
4
|
+
declare function ConnectedTable<T extends SimpleObject>(props: ConnectedRepeaterElementProps<T>): React.ReactElement;
|
|
5
|
+
export default ConnectedTable;
|