@sqrzro/ui 4.0.0-alpha.4 → 4.0.0-alpha.41
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/dist/addon/config.d.ts +5 -0
- package/dist/addon/config.js +12 -0
- package/dist/addon/defaults.d.ts +3 -0
- package/dist/addon/defaults.js +6 -0
- package/dist/addon/index.d.ts +5 -0
- package/dist/addon/index.js +8 -0
- package/dist/addon/interfaces.d.ts +8 -0
- package/dist/components/buttons/ActionButton/index.d.ts +8 -6
- package/dist/components/buttons/ActionButton/index.js +3 -27
- package/dist/components/buttons/Button/index.d.ts +5 -5
- package/dist/components/buttons/Button/index.js +7 -17
- package/dist/components/collections/Collection/index.d.ts +9 -3
- package/dist/components/collections/Collection/index.js +8 -7
- package/dist/components/collections/DataTable/index.d.ts +14 -0
- package/dist/components/collections/DataTable/index.js +14 -0
- package/dist/components/collections/EmptyMessage/index.d.ts +1 -1
- package/dist/components/collections/EmptyMessage/index.js +6 -4
- package/dist/components/collections/EmptyMessageAction/index.d.ts +2 -2
- package/dist/components/collections/EmptyMessageAction/index.js +1 -1
- package/dist/components/collections/List/index.d.ts +6 -4
- package/dist/components/collections/List/index.js +2 -2
- package/dist/components/collections/ListClientComponent/index.d.ts +7 -4
- package/dist/components/collections/ListClientComponent/index.js +8 -5
- package/dist/components/collections/ListItem/index.d.ts +10 -3
- package/dist/components/collections/ListItem/index.js +15 -23
- package/dist/components/collections/ListItemMenu/index.d.ts +8 -0
- package/dist/components/collections/ListItemMenu/index.js +7 -0
- package/dist/components/collections/ListItemMeta/index.d.ts +6 -4
- package/dist/components/collections/ListItemMeta/index.js +13 -7
- package/dist/components/collections/ListItemSecondary/index.d.ts +5 -3
- package/dist/components/collections/ListItemSecondary/index.js +5 -5
- package/dist/components/collections/Pagination/index.d.ts +1 -1
- package/dist/components/collections/Pagination/index.js +6 -7
- package/dist/components/collections/PaginationLink/index.d.ts +9 -0
- package/dist/components/collections/PaginationLink/index.js +9 -0
- package/dist/components/collections/Table/index.d.ts +4 -5
- package/dist/components/collections/Table/index.js +2 -8
- package/dist/components/collections/TableClientComponent/index.d.ts +7 -6
- package/dist/components/collections/TableClientComponent/index.js +11 -26
- package/dist/components/collections/TableRow/index.d.ts +13 -0
- package/dist/components/collections/TableRow/index.js +15 -0
- package/dist/components/collections/interfaces.d.ts +41 -34
- package/dist/components/collections/utility/is-right-aligned.d.ts +3 -0
- package/dist/components/collections/utility/is-right-aligned.js +11 -0
- package/dist/components/collections/utility/normalize-href.d.ts +2 -0
- package/dist/components/collections/utility/normalize-href.js +8 -0
- package/dist/components/collections/utility/render-cell.d.ts +5 -0
- package/dist/components/collections/utility/render-cell.js +33 -0
- package/dist/components/elements/Badge/index.d.ts +12 -0
- package/dist/components/elements/Badge/index.js +9 -0
- package/dist/components/elements/InfoPanel/index.d.ts +11 -0
- package/dist/components/elements/InfoPanel/index.js +9 -0
- package/dist/components/{utility → elements}/Link/index.d.ts +1 -1
- package/dist/components/{utility → elements}/Link/index.js +6 -7
- package/dist/components/elements/Menu/index.d.ts +19 -0
- package/dist/components/elements/Menu/index.js +17 -0
- package/dist/components/elements/MenuItem/index.d.ts +7 -0
- package/dist/components/elements/MenuItem/index.js +12 -0
- package/dist/components/elements/Page/index.d.ts +19 -0
- package/dist/components/elements/Page/index.js +18 -0
- package/dist/components/elements/Reference/index.d.ts +9 -0
- package/dist/components/elements/Reference/index.js +16 -0
- package/dist/components/elements/Summary/index.d.ts +13 -0
- package/dist/components/elements/Summary/index.js +22 -0
- package/dist/components/errors/AppError/index.d.ts +19 -0
- package/dist/components/errors/AppError/index.js +9 -0
- package/dist/components/errors/AppForbiddenError/index.d.ts +7 -0
- package/dist/components/errors/AppForbiddenError/index.js +6 -0
- package/dist/components/errors/AppNotFoundError/index.d.ts +7 -0
- package/dist/components/errors/AppNotFoundError/index.js +6 -0
- package/dist/components/errors/AppServerError/index.d.ts +8 -0
- package/dist/components/errors/AppServerError/index.js +17 -0
- package/dist/components/index.d.ts +37 -6
- package/dist/components/index.js +18 -3
- package/dist/components/mail/Mail/index.d.ts +7 -0
- package/dist/components/mail/Mail/index.js +113 -0
- package/dist/components/mail/MailBlock/index.d.ts +5 -0
- package/dist/components/mail/MailBlock/index.js +5 -0
- package/dist/components/mail/MailButton/index.d.ts +7 -0
- package/dist/components/mail/MailButton/index.js +38 -0
- package/dist/components/mail/MailTable/index.d.ts +9 -0
- package/dist/components/mail/MailTable/index.js +7 -0
- package/dist/components/modals/ConfirmModal/index.d.ts +5 -3
- package/dist/components/modals/ConfirmModal/index.js +3 -3
- package/dist/components/modals/Modal/index.d.ts +4 -4
- package/dist/components/modals/Modal/index.js +3 -3
- package/dist/components/modals/ModalActions/index.d.ts +3 -3
- package/dist/components/modals/ModalActions/index.js +4 -3
- package/dist/components/utility/Action/index.d.ts +11 -0
- package/dist/components/utility/Action/index.js +48 -0
- package/dist/components/utility/ActionList/index.d.ts +5 -5
- package/dist/components/utility/ActionList/index.js +5 -3
- package/dist/components/utility/AppBody/index.d.ts +5 -0
- package/dist/components/utility/AppBody/index.js +9 -0
- package/dist/components/utility/Calendar/index.d.ts +32 -0
- package/dist/components/utility/Calendar/index.js +67 -0
- package/dist/components/utility/CalendarDay/index.d.ts +11 -0
- package/dist/components/utility/CalendarDay/index.js +23 -0
- package/dist/components/utility/Confirmable/index.d.ts +9 -0
- package/dist/components/utility/Confirmable/index.js +14 -0
- package/dist/components/utility/Container/index.d.ts +1 -1
- package/dist/components/utility/Container/index.js +2 -2
- package/dist/components/utility/Loader/index.d.ts +1 -1
- package/dist/components/utility/Loader/index.js +5 -4
- package/dist/components/utility/Popover/index.d.ts +1 -1
- package/dist/components/utility/Popover/index.js +5 -5
- package/dist/components/utility/Toast/index.d.ts +2 -2
- package/dist/components/utility/Toast/index.js +6 -4
- package/dist/components/utility/Toaster/index.js +5 -5
- package/dist/filters/components/FilterBar/index.d.ts +5 -2
- package/dist/filters/components/FilterBarClientComponent/index.d.ts +2 -4
- package/dist/filters/components/FilterBarClientComponent/index.js +3 -43
- package/dist/filters/components/FilterClearButton/index.d.ts +7 -2
- package/dist/filters/components/FilterClearButton/index.js +8 -4
- package/dist/filters/components/FilterControl/index.d.ts +1 -1
- package/dist/filters/components/FilterControl/index.js +11 -4
- package/dist/filters/components/FilterItem/index.d.ts +2 -1
- package/dist/filters/components/FilterItem/index.js +3 -7
- package/dist/filters/components/FilterPanel/index.d.ts +1 -1
- package/dist/filters/{utility/filter.d.ts → filter.d.ts} +1 -1
- package/dist/filters/{utility/filter.js → filter.js} +8 -8
- package/dist/filters/filters/BooleanFilter/index.js +1 -1
- package/dist/filters/filters/CalendarFilter/index.js +3 -2
- package/dist/filters/filters/DateFilter/index.d.ts +1 -1
- package/dist/filters/filters/DateFilter/index.js +9 -4
- package/dist/filters/filters/DropdownFilter/index.js +1 -1
- package/dist/filters/filters/Filter/index.d.ts +5 -4
- package/dist/filters/filters/Filter/index.js +7 -7
- package/dist/filters/filters/SearchFilter/index.d.ts +7 -2
- package/dist/filters/filters/SearchFilter/index.js +8 -8
- package/dist/filters/filters/interfaces.d.ts +0 -2
- package/dist/filters/index.d.ts +2 -1
- package/dist/filters/index.js +2 -1
- package/dist/filters/interfaces.d.ts +4 -4
- package/dist/filters/utility/parse-filters.d.ts +1 -1
- package/dist/filters/utility/parse-filters.js +3 -2
- package/dist/filters/utility/render-value.js +4 -4
- package/dist/filters/utility/transform-boolean.d.ts +1 -1
- package/dist/filters/utility/transform-date.d.ts +1 -1
- package/dist/filters/utility/transform-multi.d.ts +1 -1
- package/dist/forms/components/Autocomplete/index.d.ts +11 -0
- package/dist/forms/components/Autocomplete/index.js +37 -0
- package/dist/forms/components/CSVInput/index.d.ts +11 -0
- package/dist/forms/components/CSVInput/index.js +32 -0
- package/dist/forms/components/Dropdown/index.d.ts +1 -1
- package/dist/forms/components/Dropdown/index.js +8 -7
- package/dist/forms/components/DropdownItem/index.d.ts +9 -0
- package/dist/forms/components/DropdownItem/index.js +9 -0
- package/dist/forms/components/DropdownList/index.d.ts +1 -1
- package/dist/forms/components/DropdownList/index.js +7 -9
- package/dist/forms/components/EditableForm/index.d.ts +3 -3
- package/dist/forms/components/EditableForm/index.js +9 -9
- package/dist/forms/components/EditableFormField/index.d.ts +1 -1
- package/dist/forms/components/EditableFormField/index.js +3 -3
- package/dist/forms/components/EditableFormFields/index.d.ts +3 -0
- package/dist/forms/components/EditableFormFields/index.js +6 -0
- package/dist/forms/components/Form/index.d.ts +3 -2
- package/dist/forms/components/Form/index.js +5 -5
- package/dist/forms/components/FormError/index.d.ts +2 -2
- package/dist/forms/components/FormError/index.js +4 -3
- package/dist/forms/components/FormField/index.d.ts +4 -4
- package/dist/forms/components/FormField/index.js +8 -6
- package/dist/forms/components/FormFields/index.d.ts +14 -0
- package/dist/forms/components/FormFields/index.js +30 -0
- package/dist/forms/components/FormLabel/index.d.ts +1 -1
- package/dist/forms/components/FormLabel/index.js +4 -3
- package/dist/forms/components/ModalForm/index.js +1 -1
- package/dist/forms/components/NumberInput/index.d.ts +7 -0
- package/dist/forms/components/NumberInput/index.js +27 -0
- package/dist/forms/components/PasswordComplexity/index.d.ts +16 -0
- package/dist/forms/components/PasswordComplexity/index.js +14 -0
- package/dist/forms/components/PasswordComplexityItem/index.d.ts +8 -0
- package/dist/forms/components/PasswordComplexityItem/index.js +10 -0
- package/dist/forms/components/PasswordInput/index.d.ts +1 -1
- package/dist/forms/components/PasswordInput/index.js +6 -6
- package/dist/forms/components/PointsInput/index.d.ts +5 -0
- package/dist/forms/components/PointsInput/index.js +22 -0
- package/dist/forms/components/RangeCalendarInput/index.d.ts +5 -0
- package/dist/forms/components/RangeCalendarInput/index.js +10 -0
- package/dist/forms/components/StaticTextInput/index.d.ts +2 -3
- package/dist/forms/components/StaticTextInput/index.js +8 -8
- package/dist/forms/components/Switch/index.d.ts +1 -1
- package/dist/forms/components/Switch/index.js +5 -4
- package/dist/forms/components/TextArea/index.d.ts +14 -0
- package/dist/forms/components/TextArea/index.js +15 -0
- package/dist/forms/components/TextInput/index.d.ts +2 -2
- package/dist/forms/components/TextInput/index.js +7 -6
- package/dist/forms/hooks/useAutocomplete.d.ts +9 -0
- package/dist/forms/hooks/useAutocomplete.js +31 -0
- package/dist/forms/hooks/useDropdown.d.ts +2 -2
- package/dist/forms/hooks/useForm.d.ts +3 -5
- package/dist/forms/hooks/useForm.js +14 -24
- package/dist/forms/hooks/useModalForm.d.ts +2 -2
- package/dist/forms/index.d.ts +26 -4
- package/dist/forms/index.js +11 -3
- package/dist/forms/interfaces.d.ts +1 -0
- package/dist/forms/utility/format-file-size.d.ts +2 -0
- package/dist/forms/utility/format-file-size.js +11 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/useConfirmable.d.ts +21 -0
- package/dist/hooks/useConfirmable.js +58 -0
- package/dist/hooks/useDownload.d.ts +2 -0
- package/dist/hooks/useDownload.js +18 -0
- package/dist/hooks/usePopover.d.ts +12 -0
- package/dist/hooks/usePopover.js +24 -0
- package/dist/hooks/useSelected.d.ts +12 -0
- package/dist/hooks/useSelected.js +35 -0
- package/dist/hooks/useServerAction.d.ts +10 -0
- package/dist/hooks/useServerAction.js +17 -0
- package/dist/hooks/useSuccess.d.ts +10 -0
- package/dist/hooks/useSuccess.js +22 -0
- package/dist/navigation/components/AppNavigation/index.d.ts +3 -1
- package/dist/navigation/components/AppNavigation/index.js +4 -4
- package/dist/navigation/components/AppNavigationItem/index.d.ts +5 -3
- package/dist/navigation/components/AppNavigationItem/index.js +16 -7
- package/dist/navigation/components/Tabs/index.js +1 -4
- package/dist/navigation/hooks/useNavigation.d.ts +3 -3
- package/dist/navigation/hooks/useNavigation.js +5 -5
- package/dist/styles/classnames/config.d.ts +87 -0
- package/dist/styles/classnames/config.js +1 -0
- package/dist/styles/classnames/interfaces.d.ts +56 -0
- package/dist/styles/classnames/interfaces.js +1 -0
- package/dist/styles/classnames/utility/apply-sizes.d.ts +3 -0
- package/dist/styles/classnames/utility/apply-sizes.js +21 -0
- package/dist/styles/classnames/utility/apply-variants.d.ts +3 -0
- package/dist/styles/classnames/utility/apply-variants.js +26 -0
- package/dist/styles/classnames/utility/is-classname-object.d.ts +3 -0
- package/dist/styles/classnames/utility/is-classname-object.js +7 -0
- package/dist/styles/classnames/utility/parse-classnames.d.ts +6 -0
- package/dist/styles/classnames/utility/parse-classnames.js +33 -0
- package/dist/styles/context.d.ts +28 -0
- package/dist/styles/context.js +19 -0
- package/dist/styles/icons/config.d.ts +20 -0
- package/dist/styles/icons/config.js +1 -0
- package/dist/styles/icons/interfaces.d.ts +4 -0
- package/dist/styles/icons/interfaces.js +1 -0
- package/dist/styles/index.d.ts +6 -2
- package/dist/styles/index.js +2 -1
- package/dist/styles/styles.css +60 -0
- package/dist/utility/compare-dates.d.ts +2 -0
- package/dist/utility/compare-dates.js +13 -0
- package/dist/utility/convert-to-datauri.d.ts +2 -0
- package/dist/utility/convert-to-datauri.js +16 -0
- package/dist/utility/get-days.d.ts +2 -0
- package/dist/utility/get-days.js +5 -0
- package/dist/utility/get-weeks.d.ts +2 -0
- package/dist/utility/get-weeks.js +31 -0
- package/dist/utility/index.d.ts +1 -1
- package/dist/utility/interfaces.d.ts +33 -17
- package/dist/utility/is-data-object-array.d.ts +3 -0
- package/dist/utility/is-data-object-array.js +5 -0
- package/dist/utility/is-data-object.d.ts +3 -0
- package/dist/utility/is-data-object.js +4 -0
- package/dist/utility/is-date-highlighted.d.ts +2 -0
- package/dist/utility/is-date-highlighted.js +8 -0
- package/dist/utility/is-date-selected.d.ts +2 -0
- package/dist/utility/is-date-selected.js +16 -0
- package/package.json +28 -16
- package/dist/components/buttons/ConfirmableButton/index.d.ts +0 -7
- package/dist/components/buttons/ConfirmableButton/index.js +0 -13
- package/dist/components/collections/utility/filter-columns.d.ts +0 -3
- package/dist/components/collections/utility/filter-columns.js +0 -8
- package/dist/components/collections/utility/get-selected-from-search-params.d.ts +0 -2
- package/dist/components/collections/utility/get-selected-from-search-params.js +0 -5
- package/dist/components/collections/utility/set-selected-to-search-params.d.ts +0 -2
- package/dist/components/collections/utility/set-selected-to-search-params.js +0 -4
- package/dist/components/utility/ClassNames/index.d.ts +0 -6
- package/dist/components/utility/ClassNames/index.js +0 -7
- package/dist/components/utility/Page/index.d.ts +0 -18
- package/dist/components/utility/Page/index.js +0 -34
- package/dist/components/utility/RootLayout/index.d.ts +0 -12
- package/dist/components/utility/RootLayout/index.js +0 -14
- package/dist/styles/config.d.ts +0 -64
- package/dist/styles/config.js +0 -43
- package/dist/styles/icons.d.ts +0 -15
- package/dist/styles/icons.js +0 -7
- package/dist/styles/interfaces.d.ts +0 -41
- /package/dist/{styles → addon}/interfaces.js +0 -0
- /package/dist/styles/{tw.d.ts → classnames/utility/tw.d.ts} +0 -0
- /package/dist/styles/{tw.js → classnames/utility/tw.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InputEvent, InputProps } from '../../../forms/interfaces';
|
|
2
|
-
import type { ClassNameProps, ErrorableClassName } from '../../../styles/interfaces';
|
|
3
|
-
import {
|
|
2
|
+
import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces';
|
|
3
|
+
import { SimpleActionObject } from '../../../utility/interfaces';
|
|
4
4
|
export interface FormFieldClassNames {
|
|
5
5
|
root: ErrorableClassName;
|
|
6
6
|
label: string;
|
|
@@ -10,7 +10,7 @@ export interface FormFieldClassNames {
|
|
|
10
10
|
error: string;
|
|
11
11
|
}
|
|
12
12
|
export interface FormFieldProps<T, V extends T> extends ClassNameProps<FormFieldClassNames>, InputProps<T, V> {
|
|
13
|
-
action?:
|
|
13
|
+
action?: SimpleActionObject | null;
|
|
14
14
|
details?: string | null;
|
|
15
15
|
error?: Record<string, string> | null;
|
|
16
16
|
hasAssistiveError?: boolean;
|
|
@@ -21,5 +21,5 @@ export interface FormFieldProps<T, V extends T> extends ClassNameProps<FormField
|
|
|
21
21
|
onChange?: (event: InputEvent<T>) => void;
|
|
22
22
|
render: (props: InputProps<T>) => React.ReactElement | null;
|
|
23
23
|
}
|
|
24
|
-
declare function FormField<T, V extends T>({ action, classNameProps, details, error, hasAssistiveError, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onKeyDown, render, value, }: Readonly<FormFieldProps<T, V>>): React.ReactElement | null;
|
|
24
|
+
declare function FormField<T, V extends T>({ action, classNameProps, classNames, details, error, hasAssistiveError, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onKeyDown, render, value, }: Readonly<FormFieldProps<T, V>>): React.ReactElement | null;
|
|
25
25
|
export default FormField;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import tw from '../../../styles/tw';
|
|
4
|
+
import { useClassNames } from '../../../styles/context';
|
|
6
5
|
import FormError from '../FormError';
|
|
7
6
|
import FormLabel from '../FormLabel';
|
|
8
7
|
import ActionButton from '../../../components/buttons/ActionButton';
|
|
9
8
|
function checkHasError(error) {
|
|
10
|
-
return Boolean(error &&
|
|
9
|
+
return Boolean(error &&
|
|
10
|
+
Object.keys(error).length > 0 &&
|
|
11
|
+
Object.values(error).some((item) => typeof item === 'string'));
|
|
11
12
|
}
|
|
12
|
-
function FormField({ action, classNameProps, details, error, hasAssistiveError, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onKeyDown, render, value, }) {
|
|
13
|
-
const
|
|
13
|
+
function FormField({ action, classNameProps, classNames, details, error, hasAssistiveError, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onKeyDown, render, value, }) {
|
|
14
|
+
const componentClassNames = useClassNames('formField', { props: classNameProps, states: { isError: checkHasError(error) } }, classNames);
|
|
14
15
|
const inputId = id || `ff_${name}`;
|
|
15
16
|
const [inputError, setInputError] = useState(null);
|
|
16
17
|
function handleError(message) {
|
|
@@ -22,6 +23,7 @@ function FormField({ action, classNameProps, details, error, hasAssistiveError,
|
|
|
22
23
|
hasError: checkHasError(error),
|
|
23
24
|
id: inputId,
|
|
24
25
|
isDisabled,
|
|
26
|
+
isOptional,
|
|
25
27
|
label,
|
|
26
28
|
name,
|
|
27
29
|
onChange,
|
|
@@ -32,6 +34,6 @@ function FormField({ action, classNameProps, details, error, hasAssistiveError,
|
|
|
32
34
|
if (isContentOnly) {
|
|
33
35
|
return render(renderProps);
|
|
34
36
|
}
|
|
35
|
-
return (_jsxs("div", { className:
|
|
37
|
+
return (_jsxs("div", { className: componentClassNames?.root, children: [label ? (_jsx(FormLabel, { classNameProps: classNameProps, htmlFor: inputId, isAssistive: hasAssistiveLabel, isOptional: isOptional, children: label })) : null, details && label ? (_jsx("div", { className: componentClassNames?.details, children: details })) : null, _jsx("div", { className: componentClassNames?.field, children: render(renderProps) }), action ? (_jsx("div", { children: _jsx(ActionButton, { ...action, isDisabled: Boolean(isDisabled || action.isDisabled) }) })) : null, inputError || error?.[name] ? (_jsx(FormError, { classNameProps: classNameProps, id: inputId, isAssistive: hasAssistiveError, children: inputError || error?.[name] })) : null] }));
|
|
36
38
|
}
|
|
37
39
|
export default FormField;
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import type { FormFieldComponentProps } from '../../interfaces';
|
|
2
|
+
import type { AutocompleteComponentProps } from '../Autocomplete';
|
|
2
3
|
import type { DropdownComponentProps } from '../Dropdown';
|
|
4
|
+
import type { PointsInputComponentProps } from '../PointsInput';
|
|
5
|
+
import type { NumberInputComponentProps } from '../NumberInput';
|
|
3
6
|
import type { PasswordInputComponentProps } from '../PasswordInput';
|
|
7
|
+
import type { TextAreaComponentProps } from '../TextArea';
|
|
4
8
|
import type { TextInputComponentProps } from '../TextInput';
|
|
9
|
+
export type AutocompleteFormFieldProps<T> = FormFieldComponentProps<T | null> & AutocompleteComponentProps<T>;
|
|
10
|
+
export declare function AutocompleteFormField<T>(props: Readonly<AutocompleteFormFieldProps<T>>): React.ReactElement;
|
|
11
|
+
export type CSVFormFieldProps = FormFieldComponentProps<string>;
|
|
12
|
+
export declare function CSVFormField(props: Readonly<CSVFormFieldProps>): React.ReactElement;
|
|
5
13
|
export type DropdownFormFieldProps<T> = FormFieldComponentProps<T | null> & DropdownComponentProps<T>;
|
|
6
14
|
export declare function DropdownFormField<T>(props: Readonly<DropdownFormFieldProps<T>>): React.ReactElement;
|
|
15
|
+
export type MoneyFormFieldProps = FormFieldComponentProps<number> & PointsInputComponentProps;
|
|
16
|
+
export declare function MoneyFormField(props: Readonly<MoneyFormFieldProps>): React.ReactElement;
|
|
17
|
+
export type NumberFormFieldProps = FormFieldComponentProps<number> & NumberInputComponentProps;
|
|
18
|
+
export declare function NumberFormField(props: Readonly<NumberFormFieldProps>): React.ReactElement;
|
|
7
19
|
export type PasswordFormFieldProps = FormFieldComponentProps<string> & PasswordInputComponentProps;
|
|
8
20
|
export declare function PasswordFormField(props: Readonly<PasswordFormFieldProps>): React.ReactElement;
|
|
9
21
|
export type TextFormFieldProps = FormFieldComponentProps<string> & TextInputComponentProps;
|
|
10
22
|
export declare function TextFormField(props: Readonly<TextFormFieldProps>): React.ReactElement;
|
|
23
|
+
export type TextAreaFormFieldProps = FormFieldComponentProps<string> & TextAreaComponentProps;
|
|
24
|
+
export declare function TextAreaFormField(props: Readonly<TextAreaFormFieldProps>): React.ReactElement;
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import extractInputProps from '../../utility/extract-input-props';
|
|
4
|
+
import Autocomplete from '../Autocomplete';
|
|
5
|
+
import CSVInput from '../CSVInput';
|
|
4
6
|
import Dropdown from '../Dropdown';
|
|
5
7
|
import FormField from '../FormField';
|
|
8
|
+
import PointsInput from '../PointsInput';
|
|
9
|
+
import NumberInput from '../NumberInput';
|
|
6
10
|
import PasswordInput from '../PasswordInput';
|
|
11
|
+
import TextArea from '../TextArea';
|
|
7
12
|
import TextInput from '../TextInput';
|
|
13
|
+
export function AutocompleteFormField(props) {
|
|
14
|
+
const { fieldProps, inputProps } = extractInputProps(props);
|
|
15
|
+
const renderInput = useCallback((renderProps) => (_jsx(Autocomplete, { ...renderProps, ...inputProps })), [inputProps]);
|
|
16
|
+
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
17
|
+
}
|
|
18
|
+
export function CSVFormField(props) {
|
|
19
|
+
const { fieldProps, inputProps } = extractInputProps(props);
|
|
20
|
+
const renderInput = useCallback((renderProps) => (_jsx(CSVInput, { ...renderProps, ...inputProps })), [inputProps]);
|
|
21
|
+
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
22
|
+
}
|
|
8
23
|
export function DropdownFormField(props) {
|
|
9
24
|
const { fieldProps, inputProps } = extractInputProps(props);
|
|
10
25
|
const renderInput = useCallback((renderProps) => (_jsx(Dropdown, { ...renderProps, ...inputProps })), [inputProps]);
|
|
11
26
|
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
12
27
|
}
|
|
28
|
+
export function MoneyFormField(props) {
|
|
29
|
+
const { fieldProps, inputProps } = extractInputProps(props);
|
|
30
|
+
const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps })), [inputProps]);
|
|
31
|
+
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
32
|
+
}
|
|
33
|
+
export function NumberFormField(props) {
|
|
34
|
+
const { fieldProps, inputProps } = extractInputProps(props);
|
|
35
|
+
const renderInput = useCallback((renderProps) => (_jsx(NumberInput, { ...renderProps, ...inputProps })), [inputProps]);
|
|
36
|
+
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
37
|
+
}
|
|
13
38
|
export function PasswordFormField(props) {
|
|
14
39
|
const { fieldProps, inputProps } = extractInputProps(props);
|
|
15
40
|
const renderInput = useCallback((renderProps) => (_jsx(PasswordInput, { ...renderProps, ...inputProps })), [inputProps]);
|
|
@@ -20,3 +45,8 @@ export function TextFormField(props) {
|
|
|
20
45
|
const renderInput = useCallback((renderProps) => (_jsx(TextInput, { ...renderProps, ...inputProps })), [inputProps]);
|
|
21
46
|
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
22
47
|
}
|
|
48
|
+
export function TextAreaFormField(props) {
|
|
49
|
+
const { fieldProps, inputProps } = extractInputProps(props);
|
|
50
|
+
const renderInput = useCallback((renderProps) => (_jsx(TextArea, { ...renderProps, ...inputProps })), [inputProps]);
|
|
51
|
+
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
52
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import type { FormFieldClassNames } from '../FormField';
|
|
3
3
|
interface FormLabelProps extends ClassNameProps<FormFieldClassNames> {
|
|
4
4
|
children: React.ReactNode;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import tw from '../../../styles/tw';
|
|
3
|
+
import { useClassNames } from '../../../styles/context';
|
|
4
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
4
5
|
function FormLabel({ children, classNames, classNameProps, htmlFor, isAssistive, isOptional, }) {
|
|
5
|
-
const componentClassNames =
|
|
6
|
+
const componentClassNames = useClassNames('formField', { props: classNameProps }, classNames);
|
|
6
7
|
return (_jsxs("label", { className: tw(componentClassNames?.label, isAssistive ? 'sr-only' : null), htmlFor: htmlFor, children: [children, isOptional ? _jsx("small", { className: componentClassNames?.optional, children: "Optional" }) : null] }));
|
|
7
8
|
}
|
|
8
9
|
export default FormLabel;
|
|
@@ -10,7 +10,7 @@ function ModalForm({ children, formProps, hasServerError, hasSubmit = true, isDi
|
|
|
10
10
|
setSearchParamsHref('action', null);
|
|
11
11
|
}
|
|
12
12
|
return (_jsx(Modal, { ...modalProps, children: _jsxs(Form, { ...formProps, children: [children, hasServerError ? _jsx("div", { children: "SERVER ERROR" }) : null, _jsx(ModalActions, { actions: [
|
|
13
|
-
{ label: 'Cancel', onClick: handleCancel
|
|
13
|
+
{ label: 'Cancel', onClick: handleCancel },
|
|
14
14
|
...(modalProps.actions || []),
|
|
15
15
|
hasSubmit
|
|
16
16
|
? {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
import type { InputProps } from '../../interfaces';
|
|
3
|
+
import type { TextInputClassNames, TextInputComponentProps } from '../TextInput';
|
|
4
|
+
export type NumberInputComponentProps = TextInputComponentProps;
|
|
5
|
+
export type NumberInputProps = ClassNameProps<TextInputClassNames> & InputProps<number> & NumberInputComponentProps;
|
|
6
|
+
declare function NumberInput({ onChange, value, ...props }: Readonly<NumberInputProps>): React.ReactElement;
|
|
7
|
+
export default NumberInput;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import TextInput from '../TextInput';
|
|
5
|
+
function NumberInput({ onChange, value, ...props }) {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
function handleChange(event) {
|
|
8
|
+
onChange?.({ target: { name: event.target.name, value: Number(event.target.value) } });
|
|
9
|
+
}
|
|
10
|
+
function disableScroll() {
|
|
11
|
+
if (ref.current) {
|
|
12
|
+
ref.current.blur();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (ref.current) {
|
|
17
|
+
ref.current.addEventListener('wheel', disableScroll, { passive: false });
|
|
18
|
+
}
|
|
19
|
+
return () => {
|
|
20
|
+
if (ref.current) {
|
|
21
|
+
ref.current.removeEventListener('wheel', disableScroll);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
return (_jsx(TextInput, { ...props, ref: ref, onChange: handleChange, type: "number", value: value ? String(value) : '' }));
|
|
26
|
+
}
|
|
27
|
+
export default NumberInput;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ClassNameProps } from '../../../styles';
|
|
2
|
+
export interface PasswordComplexityClassNames {
|
|
3
|
+
root: string;
|
|
4
|
+
list: string;
|
|
5
|
+
item: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PasswordComplexityProps extends ClassNameProps<PasswordComplexityClassNames> {
|
|
9
|
+
data: {
|
|
10
|
+
status: boolean;
|
|
11
|
+
value: string;
|
|
12
|
+
}[];
|
|
13
|
+
onComplexity?: (isValid: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
declare function PasswordComplexity({ classNameProps, classNames, data, onComplexity, }: PasswordComplexityProps): React.ReactElement;
|
|
16
|
+
export default PasswordComplexity;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useClassNames } from '../../../styles';
|
|
4
|
+
import useDeepCompareEffect from 'use-deep-compare-effect';
|
|
5
|
+
import PasswordComplexityItem from '../PasswordComplexityItem';
|
|
6
|
+
function PasswordComplexity({ classNameProps, classNames, data, onComplexity, }) {
|
|
7
|
+
useDeepCompareEffect(() => {
|
|
8
|
+
onComplexity?.(data.every((item) => item.status));
|
|
9
|
+
}, [data]);
|
|
10
|
+
const isValid = data.every((item) => item.status);
|
|
11
|
+
const componentClassNames = useClassNames('passwordComplexity', { props: { ...classNameProps, isValid } }, classNames);
|
|
12
|
+
return (_jsx("aside", { className: componentClassNames?.root, children: _jsx("ul", { className: componentClassNames?.list, children: data.map((item) => (_jsx(PasswordComplexityItem, { classNameProps: classNameProps, classNames: classNames, isValid: item.status, value: item.value }, item.value))) }) }));
|
|
13
|
+
}
|
|
14
|
+
export default PasswordComplexity;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ClassNameProps } from '../../../styles';
|
|
2
|
+
import type { PasswordComplexityClassNames } from '../PasswordComplexity';
|
|
3
|
+
interface PasswordComplexityItemProps extends ClassNameProps<PasswordComplexityClassNames> {
|
|
4
|
+
isValid: boolean;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
declare function PasswordComplexityItem({ classNameProps, classNames, isValid, value, }: PasswordComplexityItemProps): React.ReactElement;
|
|
8
|
+
export default PasswordComplexityItem;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useClassNames, useIcon } from '../../../styles';
|
|
3
|
+
function PasswordComplexityItem({ classNameProps, classNames, isValid, value, }) {
|
|
4
|
+
const componentClassNames = useClassNames('passwordComplexity', { props: { ...classNameProps, isValid } }, classNames);
|
|
5
|
+
const InvalidIcon = useIcon('passwordComplexity.invalid');
|
|
6
|
+
const ValidIcon = useIcon('passwordComplexity.valid');
|
|
7
|
+
const Icon = isValid ? ValidIcon : InvalidIcon;
|
|
8
|
+
return (_jsxs("li", { className: componentClassNames?.item, children: [Icon ? (_jsx("div", { className: componentClassNames?.icon, children: _jsx(Icon, {}) })) : null, value] }));
|
|
9
|
+
}
|
|
10
|
+
export default PasswordComplexityItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InputProps } from '../../../forms/interfaces';
|
|
2
|
-
import type { ClassNameProps, SelectableClassName } from '../../../styles/interfaces';
|
|
2
|
+
import type { ClassNameProps, SelectableClassName } from '../../../styles/classnames/interfaces';
|
|
3
3
|
import type { TextInputComponentProps } from '../TextInput';
|
|
4
4
|
export interface PasswordInputClassNames {
|
|
5
5
|
action: string;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { getIcon } from '../../../styles/icons';
|
|
6
|
-
import tw from '../../../styles/tw';
|
|
4
|
+
import { useClassNames, useIcon } from '../../../styles/context';
|
|
7
5
|
import TextInput from '../TextInput';
|
|
8
6
|
function PasswordInput({ classNameProps, classNames, ...props }) {
|
|
9
|
-
const componentClassNames = classNames || getClassNames('passwordInput')?.(classNameProps);
|
|
10
|
-
const Icon = getIcon('password');
|
|
11
7
|
const [isVisible, setIsVisible] = useState(false);
|
|
8
|
+
const componentClassNames = useClassNames('passwordInput', { props: classNameProps, states: { isSelected: isVisible } }, classNames);
|
|
9
|
+
const HiddenIcon = useIcon('passwordInput.hidden');
|
|
10
|
+
const VisibleIcon = useIcon('passwordInput.visible');
|
|
11
|
+
const Icon = isVisible ? VisibleIcon : HiddenIcon;
|
|
12
12
|
function toggleVisible() {
|
|
13
13
|
setIsVisible(!isVisible);
|
|
14
14
|
}
|
|
15
|
-
return (_jsxs("div", { className: "relative", children: [_jsx(TextInput, { type: isVisible ? 'text' : 'password', ...props }), _jsx("div", { className: componentClassNames?.action, children: _jsxs("button", { className:
|
|
15
|
+
return (_jsxs("div", { className: "relative", children: [_jsx(TextInput, { type: isVisible ? 'text' : 'password', ...props }), _jsx("div", { className: componentClassNames?.action, children: _jsxs("button", { className: componentClassNames?.icon, onClick: toggleVisible, type: "button", children: [Icon ? _jsx(Icon, {}) : null, isVisible ? 'Hide' : 'Show'] }) })] }));
|
|
16
16
|
}
|
|
17
17
|
export default PasswordInput;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NumberInputComponentProps, NumberInputProps } from '../NumberInput';
|
|
2
|
+
export type PointsInputComponentProps = NumberInputComponentProps;
|
|
3
|
+
export type PointsInputProps = NumberInputProps;
|
|
4
|
+
declare function PointsInput({ name, onChange, value, ...props }: Readonly<PointsInputProps>): React.ReactElement;
|
|
5
|
+
export default PointsInput;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import NumberInput from '../NumberInput';
|
|
3
|
+
const FACTOR = 100;
|
|
4
|
+
function setValue(value) {
|
|
5
|
+
if (typeof value === 'undefined') {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
return Math.round(value * FACTOR);
|
|
9
|
+
}
|
|
10
|
+
function getValue(value) {
|
|
11
|
+
if (typeof value === 'undefined') {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
return value / FACTOR;
|
|
15
|
+
}
|
|
16
|
+
function PointsInput({ name, onChange, value, ...props }) {
|
|
17
|
+
function handleChange(event) {
|
|
18
|
+
onChange?.({ target: { name, value: setValue(event.target.value) } });
|
|
19
|
+
}
|
|
20
|
+
return _jsx(NumberInput, { ...props, name: name, onChange: handleChange, value: getValue(value) });
|
|
21
|
+
}
|
|
22
|
+
export default PointsInput;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import Calendar from '../../../components/utility/Calendar';
|
|
4
|
+
function RangeCalendarInput(props) {
|
|
5
|
+
function handleChange(value) {
|
|
6
|
+
props.onChange?.({ target: { name: props.name, value } });
|
|
7
|
+
}
|
|
8
|
+
return _jsx(Calendar, { isRange: true, onChange: handleChange, value: props.value });
|
|
9
|
+
}
|
|
10
|
+
export default RangeCalendarInput;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InputProps } from '../../../forms/interfaces';
|
|
2
|
-
import type { ClassNameProps, ErrorableClassName } from '../../../styles/interfaces';
|
|
2
|
+
import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces';
|
|
3
3
|
export interface StaticTextInputClassNames {
|
|
4
4
|
root: ErrorableClassName;
|
|
5
5
|
placeholder: string;
|
|
@@ -12,11 +12,10 @@ export interface StaticTextInputProps extends ClassNameProps<StaticTextInputClas
|
|
|
12
12
|
details?: string | null;
|
|
13
13
|
label: string;
|
|
14
14
|
icon?: React.ReactNode;
|
|
15
|
-
isOpen?: boolean;
|
|
16
15
|
isOptional?: boolean;
|
|
17
16
|
onClear?: () => void;
|
|
18
17
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
19
18
|
placeholder?: string;
|
|
20
19
|
}
|
|
21
|
-
declare function StaticTextInput({ classNames, classNameProps, details, hasError, icon, isDisabled,
|
|
20
|
+
declare function StaticTextInput({ classNames, classNameProps, details, hasError, icon, isDisabled, isOptional, label, name, onClear, onClick, onKeyDown, placeholder, value, }: Readonly<StaticTextInputProps>): React.ReactElement;
|
|
22
21
|
export default StaticTextInput;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { Fragment } from 'react';
|
|
3
4
|
import Assistive from '../../../components/utility/Assistive';
|
|
4
|
-
import {
|
|
5
|
-
import tw from '../../../styles/tw';
|
|
5
|
+
import { useClassNames, useIcon } from '../../../styles/context';
|
|
6
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
6
7
|
function hasValue(value) {
|
|
7
8
|
if (Array.isArray(value)) {
|
|
8
9
|
return Boolean(value.filter((item) => Boolean(item)).length);
|
|
9
10
|
}
|
|
10
11
|
return Boolean(value);
|
|
11
12
|
}
|
|
12
|
-
function StaticTextInput({ classNames, classNameProps, details, hasError, icon, isDisabled,
|
|
13
|
-
const componentClassNames = {
|
|
14
|
-
|
|
15
|
-
...classNames,
|
|
16
|
-
};
|
|
13
|
+
function StaticTextInput({ classNames, classNameProps, details, hasError, icon, isDisabled, isOptional, label, name, onClear, onClick, onKeyDown, placeholder = 'Select...', value, }) {
|
|
14
|
+
const componentClassNames = useClassNames('staticTextInput', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
|
|
15
|
+
const ClearIcon = useIcon('staticTextInput.clear');
|
|
17
16
|
function handleClear() {
|
|
18
17
|
onClear?.();
|
|
19
18
|
}
|
|
20
|
-
|
|
19
|
+
console.log(isOptional, value, hasValue(value));
|
|
20
|
+
return (_jsxs("div", { className: tw('relative', componentClassNames?.root, isDisabled ? 'pointer-events-none opacity-30' : null), children: [_jsx("input", { name: name, type: "hidden", value: value ? value.toString() : '' }), label ? (_jsxs(Fragment, { children: [_jsx("span", { className: componentClassNames?.label, children: label }), details ? (_jsx("small", { className: componentClassNames?.details, children: details })) : null] })) : (_jsx("span", { className: componentClassNames?.placeholder, children: placeholder })), onClick ? (_jsx("button", { className: "absolute -bottom-px -left-px -right-px -top-px", disabled: isDisabled, onClick: onClick, onKeyDown: onKeyDown, tabIndex: 0, type: "button", children: _jsx(Assistive, { children: "Toggle" }) })) : null, _jsxs("div", { className: "absolute bottom-0 right-1 top-0 flex w-0 items-center justify-end", children: [isOptional && hasValue(value) ? (_jsxs("button", { className: tw('flex-none', componentClassNames?.clear), onClick: handleClear, type: "button", children: [ClearIcon ? _jsx(ClearIcon, {}) : null, _jsx(Assistive, { children: "Clear" })] })) : null, icon && !isDisabled ? (_jsx("div", { className: tw('pointer-events-none flex-none bg-red-300', componentClassNames?.icon), children: icon })) : null] })] }));
|
|
21
21
|
}
|
|
22
22
|
export default StaticTextInput;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InputProps } from '../../../forms/interfaces';
|
|
2
|
-
import { CheckableClassName, ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
import { CheckableClassName, ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
3
3
|
export interface SwitchClassNames {
|
|
4
4
|
root: string;
|
|
5
5
|
control: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { Fragment } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import tw from '../../../styles/tw';
|
|
4
|
+
import { useClassNames } from '../../../styles/context';
|
|
5
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
5
6
|
function Switch({ classNameProps, classNames, id, isDisabled, name, onChange, value, }) {
|
|
6
|
-
const componentClassNames =
|
|
7
|
+
const componentClassNames = useClassNames('switch', { props: classNameProps, states: { isChecked: Boolean(value) } }, classNames);
|
|
7
8
|
function handleChange(event) {
|
|
8
9
|
if (onChange) {
|
|
9
10
|
const inputEvent = {
|
|
@@ -12,6 +13,6 @@ function Switch({ classNameProps, classNames, id, isDisabled, name, onChange, va
|
|
|
12
13
|
onChange(inputEvent);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
return (_jsxs(Fragment, { children: [_jsx("input", { name: name, type: "hidden", value: "false" }), _jsx("div", { className: tw('block', componentClassNames?.root), children: _jsxs("div", { className: tw('relative', componentClassNames?.control), children: [_jsx("input", { "aria-checked": Boolean(value), checked: Boolean(value), className: tw('appearance-none', componentClassNames?.input
|
|
16
|
+
return (_jsxs(Fragment, { children: [_jsx("input", { name: name, type: "hidden", value: "false" }), _jsx("div", { className: tw('block', componentClassNames?.root), children: _jsxs("div", { className: tw('relative', componentClassNames?.control), children: [_jsx("input", { "aria-checked": Boolean(value), checked: Boolean(value), className: tw('appearance-none', componentClassNames?.input), disabled: isDisabled, id: id || name, name: name, onChange: handleChange, type: "checkbox", value: "true" }), _jsx("i", { className: componentClassNames?.icon })] }) })] }));
|
|
16
17
|
}
|
|
17
18
|
export default Switch;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InputProps } from '../../../forms/interfaces';
|
|
2
|
+
import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces';
|
|
3
|
+
export interface TextAreaClassNames {
|
|
4
|
+
root: ErrorableClassName;
|
|
5
|
+
}
|
|
6
|
+
export interface TextAreaComponentProps {
|
|
7
|
+
onBlur?: React.EventHandler<React.FocusEvent>;
|
|
8
|
+
onFocus?: React.EventHandler<React.FocusEvent>;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
rows?: number;
|
|
11
|
+
}
|
|
12
|
+
export type TextAreaProps = ClassNameProps<TextAreaClassNames> & InputProps<string> & TextAreaComponentProps;
|
|
13
|
+
declare function TextArea({ classNames, classNameProps, hasError, id, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, rows, value, }: Readonly<TextAreaProps>): React.ReactElement;
|
|
14
|
+
export default TextArea;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useClassNames } from '../../../styles/context';
|
|
4
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
5
|
+
function TextArea({ classNames, classNameProps, hasError, id, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, rows = 4, value, }) {
|
|
6
|
+
const componentClassNames = useClassNames('textArea', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
|
|
7
|
+
function handleChange(event) {
|
|
8
|
+
if (onChange) {
|
|
9
|
+
const target = { name, value: event.target.value };
|
|
10
|
+
onChange({ target });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return (_jsx("textarea", { "aria-invalid": hasError, "aria-labelledby": hasError ? `${id || name}_err` : undefined /* eslint-disable-line no-undefined */, className: tw('w-full focus-visible:outline-0', isDisabled ? 'pointer-events-none opacity-30' : null, componentClassNames?.root), disabled: isDisabled, id: id || name, name: name, onBlur: onBlur, onChange: handleChange, onFocus: onFocus, onKeyDown: onKeyDown, placeholder: placeholder, rows: rows, value: value || '' }));
|
|
14
|
+
}
|
|
15
|
+
export default TextArea;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InputProps } from '../../../forms/interfaces';
|
|
2
|
-
import type { ClassNameProps, ErrorableClassName } from '../../../styles/interfaces';
|
|
2
|
+
import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces';
|
|
3
3
|
export interface TextInputClassNames {
|
|
4
4
|
loading: string;
|
|
5
5
|
prefix: ErrorableClassName;
|
|
@@ -30,5 +30,5 @@ export type TextInputProps = ClassNameProps<TextInputClassNames> & InputProps<st
|
|
|
30
30
|
* | clear | The wrapper around the 'clear' button of the input, if one exists. The style of the
|
|
31
31
|
* button itself is handled by the `renderClear` prop. | `string` |
|
|
32
32
|
*/
|
|
33
|
-
declare function TextInput({ classNames, classNameProps, hasError, id, isAutocomplete, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, prefix, suffix, type, value, }: Readonly<TextInputProps>): React.ReactElement;
|
|
33
|
+
declare function TextInput({ classNames, classNameProps, hasError, id, isAutocomplete, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, prefix, ref, suffix, type, value, }: Readonly<TextInputProps>): React.ReactElement;
|
|
34
34
|
export default TextInput;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import tw from '../../../styles/tw';
|
|
3
|
+
import { useClassNames } from '../../../styles/context';
|
|
4
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
6
7
|
* ## ClassNames
|
|
@@ -13,18 +14,18 @@ import tw from '../../../styles/tw';
|
|
|
13
14
|
* | clear | The wrapper around the 'clear' button of the input, if one exists. The style of the
|
|
14
15
|
* button itself is handled by the `renderClear` prop. | `string` |
|
|
15
16
|
*/
|
|
16
|
-
function TextInput({ classNames, classNameProps, hasError, id, isAutocomplete, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, prefix, suffix, type, value, }) {
|
|
17
|
-
const componentClassNames =
|
|
17
|
+
function TextInput({ classNames, classNameProps, hasError, id, isAutocomplete, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, prefix, ref, suffix, type, value, }) {
|
|
18
|
+
const componentClassNames = useClassNames('textInput', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
|
|
18
19
|
function handleChange(event) {
|
|
19
20
|
if (onChange) {
|
|
20
21
|
const target = { name, value: event.target.value };
|
|
21
22
|
onChange({ target });
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
return (_jsxs("div", { className: tw('relative', prefix ? 'flex flex-row-reverse' : null, (!prefix && suffix) || value ? 'flex' : null, isDisabled ? 'pointer-events-none opacity-30' : null), children: [prefix ? _jsx("div", { children: prefix }) : null, _jsx("input", { "aria-invalid": hasError, "aria-labelledby": hasError
|
|
25
|
+
return (_jsxs("div", { className: tw('relative', prefix ? 'flex flex-row-reverse' : null, (!prefix && suffix) || value ? 'flex' : null, isDisabled ? 'pointer-events-none opacity-30' : null), children: [prefix ? _jsx("div", { children: prefix }) : null, _jsx("input", { ref: ref, "aria-invalid": hasError, "aria-labelledby": hasError
|
|
25
26
|
? `${id || name}_err`
|
|
26
27
|
: undefined /* eslint-disable-line no-undefined */, autoComplete: isAutocomplete === false
|
|
27
28
|
? 'one-time-code'
|
|
28
|
-
: undefined /* eslint-disable-line no-undefined */, className: tw('peer w-full focus-visible:outline-0', prefix ? 'border-l-0' : null, (!prefix && suffix) || value ? 'border-r-0' : null, componentClassNames?.root
|
|
29
|
+
: undefined /* eslint-disable-line no-undefined */, className: tw('peer w-full focus-visible:outline-0', prefix ? 'border-l-0' : null, (!prefix && suffix) || value ? 'border-r-0' : null, componentClassNames?.root), disabled: isDisabled, formNoValidate: true, id: id || name, name: name, onBlur: onBlur, onChange: handleChange, onFocus: onFocus, onKeyDown: onKeyDown, placeholder: placeholder, type: type, value: value || '' }), suffix ? _jsx("div", { children: suffix }) : null] }));
|
|
29
30
|
}
|
|
30
31
|
export default TextInput;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DropdownObject } from '../interfaces';
|
|
2
|
+
import { AutocompleteFormFieldProps } from '../components/FormFields';
|
|
3
|
+
export interface UseAutocompleteArgs<T extends string> {
|
|
4
|
+
searchFn: (search: string) => Promise<DropdownObject<T>[]>;
|
|
5
|
+
selectFn: (id: T) => Promise<DropdownObject<T> | null>;
|
|
6
|
+
}
|
|
7
|
+
export type UseAutocompleteReturn<T extends string> = AutocompleteFormFieldProps<T>;
|
|
8
|
+
declare function useAutocomplete<T extends string>(props: AutocompleteFormFieldProps<T>, { searchFn, selectFn }: UseAutocompleteArgs<T>): UseAutocompleteReturn<T>;
|
|
9
|
+
export default useAutocomplete;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
function useAutocomplete(props, { searchFn, selectFn }) {
|
|
4
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
5
|
+
const [options, setOptions] = useState([]);
|
|
6
|
+
const [selected, setSelected] = useState(null);
|
|
7
|
+
async function handleSelect(value) {
|
|
8
|
+
if (!value) {
|
|
9
|
+
setSelected(null);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const response = await selectFn(value);
|
|
13
|
+
setOptions([]);
|
|
14
|
+
setSelected(response);
|
|
15
|
+
}
|
|
16
|
+
async function handleSearch(search) {
|
|
17
|
+
if (search.length < 3) {
|
|
18
|
+
setOptions([]);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
setIsLoading(true);
|
|
22
|
+
const response = await searchFn(search);
|
|
23
|
+
setOptions(response);
|
|
24
|
+
setIsLoading(false);
|
|
25
|
+
}
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
void handleSelect(props.value);
|
|
28
|
+
}, [props.value]);
|
|
29
|
+
return { ...props, isLoading, onSearch: handleSearch, options, selected };
|
|
30
|
+
}
|
|
31
|
+
export default useAutocomplete;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DropdownObject } from '../interfaces';
|
|
2
|
-
interface UseDropdownArgs<T extends string> {
|
|
2
|
+
export interface UseDropdownArgs<T extends string> {
|
|
3
3
|
deps?: unknown[];
|
|
4
4
|
fn: (...args: unknown[]) => Promise<DropdownObject<T>[]>;
|
|
5
5
|
}
|
|
6
|
-
interface UseDropdownReturn<T extends string> {
|
|
6
|
+
export interface UseDropdownReturn<T extends string> {
|
|
7
7
|
data: DropdownObject<T>[];
|
|
8
8
|
}
|
|
9
9
|
declare function useDropdown<T extends string>({ deps, fn }: UseDropdownArgs<T>): UseDropdownReturn<T>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Default, InputEvent } from '../../forms/interfaces';
|
|
2
|
+
import type { UseSuccessArgs } from '../../hooks/useSuccess';
|
|
2
3
|
import type { FormProps } from '../components/Form';
|
|
3
4
|
interface AwaitedFormResponse<M> {
|
|
4
5
|
data: M | null;
|
|
@@ -19,14 +20,11 @@ export interface ToastsArgs {
|
|
|
19
20
|
success?: string | false;
|
|
20
21
|
validation?: string | false;
|
|
21
22
|
}
|
|
22
|
-
export interface UseFormArgs<Request, Response> {
|
|
23
|
+
export interface UseFormArgs<Request, Response> extends UseSuccessArgs<Response> {
|
|
23
24
|
defaults?: Default<Request>;
|
|
24
25
|
onError?: (message: string) => void;
|
|
25
26
|
onSubmit?: (formData: Request) => FormResponse<Response>;
|
|
26
|
-
onSuccess?: (response: Response) => Promise<void> | void;
|
|
27
27
|
onValidation?: (errors: Record<string, string>) => void;
|
|
28
|
-
redirectOnSuccess?: string | false | ((response: Response) => string | false);
|
|
29
|
-
refreshOnSuccess?: boolean;
|
|
30
28
|
toasts?: ToastsArgs | false;
|
|
31
29
|
}
|
|
32
30
|
export interface UseFormReturn<Request> {
|
|
@@ -37,7 +35,7 @@ export interface UseFormReturn<Request> {
|
|
|
37
35
|
isLoading: boolean;
|
|
38
36
|
resetForm: () => void;
|
|
39
37
|
setErrors: (errors: Record<string, string> | null) => void;
|
|
40
|
-
setFormData: (key:
|
|
38
|
+
setFormData: <K extends keyof Request>(key: K, value: Request[K]) => void;
|
|
41
39
|
submitForm: () => void;
|
|
42
40
|
}
|
|
43
41
|
/**
|