@sqrzro/ui 4.0.0-alpha.2 → 4.0.0-alpha.21
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/components/buttons/ActionButton/index.d.ts +6 -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 +6 -16
- package/dist/components/collections/Collection/index.d.ts +9 -3
- package/dist/components/collections/Collection/index.js +4 -4
- package/dist/components/collections/DataTable/index.d.ts +14 -0
- package/dist/components/collections/DataTable/index.js +9 -0
- package/dist/components/collections/EmptyMessage/index.d.ts +1 -1
- package/dist/components/collections/EmptyMessage/index.js +3 -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 +5 -3
- package/dist/components/collections/List/index.js +8 -2
- package/dist/components/collections/ListItem/index.d.ts +2 -2
- package/dist/components/collections/ListItem/index.js +6 -10
- package/dist/components/collections/ListItemMenu/index.d.ts +7 -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 +12 -7
- package/dist/components/collections/ListItemSecondary/index.d.ts +1 -1
- package/dist/components/collections/ListItemSecondary/index.js +3 -4
- package/dist/components/collections/Pagination/index.d.ts +1 -1
- package/dist/components/collections/Pagination/index.js +5 -6
- package/dist/components/collections/PaginationLink/index.d.ts +9 -0
- package/dist/components/collections/PaginationLink/index.js +8 -0
- package/dist/components/collections/Table/index.d.ts +3 -3
- package/dist/components/collections/Table/index.js +1 -1
- package/dist/components/collections/TableClientComponent/index.d.ts +4 -4
- package/dist/components/collections/TableClientComponent/index.js +5 -10
- package/dist/components/collections/TableRow/index.d.ts +13 -0
- package/dist/components/collections/TableRow/index.js +9 -0
- package/dist/components/collections/interfaces.d.ts +19 -17
- package/dist/components/collections/utility/is-data-table-array.d.ts +3 -0
- package/dist/components/collections/utility/is-data-table-array.js +5 -0
- package/dist/components/collections/utility/is-data-table-object.d.ts +3 -0
- package/dist/components/collections/utility/is-data-table-object.js +4 -0
- package/dist/components/errors/AppError/index.d.ts +19 -0
- package/dist/components/errors/AppError/index.js +8 -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 +19 -0
- package/dist/components/index.js +9 -0
- package/dist/components/modals/ConfirmModal/index.d.ts +3 -1
- 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 +3 -3
- package/dist/components/utility/Action/index.d.ts +11 -0
- package/dist/components/utility/Action/index.js +44 -0
- package/dist/components/utility/ActionList/index.d.ts +3 -3
- package/dist/components/utility/ActionList/index.js +3 -3
- package/dist/components/utility/ClassNamesClientComponent/index.d.ts +6 -0
- package/dist/components/utility/ClassNamesClientComponent/index.js +7 -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/Link/index.d.ts +1 -1
- package/dist/components/utility/Link/index.js +3 -3
- package/dist/components/utility/Loader/index.d.ts +1 -1
- package/dist/components/utility/Loader/index.js +4 -4
- package/dist/components/utility/Menu/index.d.ts +11 -0
- package/dist/components/utility/Menu/index.js +15 -0
- package/dist/components/utility/MenuItem/index.d.ts +4 -0
- package/dist/components/utility/MenuItem/index.js +9 -0
- package/dist/components/utility/Popover/index.d.ts +1 -1
- package/dist/components/utility/Popover/index.js +4 -4
- package/dist/components/utility/Reference/index.d.ts +9 -0
- package/dist/components/utility/Reference/index.js +15 -0
- package/dist/components/utility/RootLayout/index.d.ts +6 -3
- package/dist/components/utility/RootLayout/index.js +7 -6
- package/dist/components/utility/Toast/index.d.ts +1 -1
- package/dist/components/utility/Toast/index.js +2 -2
- package/dist/filters/components/FilterBarClientComponent/index.d.ts +1 -1
- package/dist/filters/components/FilterBarClientComponent/index.js +2 -2
- package/dist/filters/components/FilterControl/index.d.ts +1 -1
- package/dist/filters/components/FilterControl/index.js +7 -4
- package/dist/filters/components/FilterItem/index.d.ts +1 -1
- package/dist/filters/components/FilterItem/index.js +2 -2
- package/dist/filters/components/FilterPanel/index.d.ts +1 -1
- package/dist/filters/filters/Filter/index.d.ts +1 -1
- package/dist/filters/filters/Filter/index.js +3 -4
- package/dist/filters/filters/SearchFilter/index.js +1 -1
- package/dist/filters/index.d.ts +1 -0
- package/dist/filters/index.js +1 -0
- package/dist/filters/interfaces.d.ts +2 -2
- package/dist/filters/utility/parse-filters.d.ts +1 -1
- package/dist/filters/utility/parse-filters.js +3 -2
- 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/Dropdown/index.d.ts +1 -1
- package/dist/forms/components/Dropdown/index.js +8 -5
- package/dist/forms/components/DropdownItem/index.d.ts +9 -0
- package/dist/forms/components/DropdownItem/index.js +8 -0
- package/dist/forms/components/DropdownList/index.d.ts +1 -1
- package/dist/forms/components/DropdownList/index.js +5 -8
- package/dist/forms/components/EditableForm/index.d.ts +3 -3
- package/dist/forms/components/EditableForm/index.js +3 -4
- package/dist/forms/components/EditableFormField/index.d.ts +1 -1
- package/dist/forms/components/EditableFormField/index.js +2 -2
- 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 +1 -1
- package/dist/forms/components/FormError/index.js +3 -3
- package/dist/forms/components/FormField/index.d.ts +4 -4
- package/dist/forms/components/FormField/index.js +7 -6
- package/dist/forms/components/FormFields/index.d.ts +9 -0
- package/dist/forms/components/FormFields/index.js +18 -0
- package/dist/forms/components/FormLabel/index.d.ts +1 -1
- package/dist/forms/components/FormLabel/index.js +3 -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 +9 -0
- package/dist/forms/components/PasswordComplexity/index.js +10 -0
- package/dist/forms/components/PasswordInput/index.d.ts +1 -1
- package/dist/forms/components/PasswordInput/index.js +4 -5
- package/dist/forms/components/PointsInput/index.d.ts +5 -0
- package/dist/forms/components/PointsInput/index.js +22 -0
- package/dist/forms/components/StaticTextInput/index.d.ts +2 -3
- package/dist/forms/components/StaticTextInput/index.js +5 -8
- package/dist/forms/components/Switch/index.d.ts +1 -1
- package/dist/forms/components/Switch/index.js +4 -4
- package/dist/forms/components/TextInput/index.d.ts +2 -2
- package/dist/forms/components/TextInput/index.js +6 -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 +1 -1
- package/dist/forms/hooks/useForm.js +5 -4
- package/dist/forms/hooks/useModalForm.d.ts +2 -2
- package/dist/forms/index.d.ts +18 -2
- package/dist/forms/index.js +7 -2
- package/dist/forms/interfaces.d.ts +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/useConfirmable.d.ts +21 -0
- package/dist/hooks/useConfirmable.js +58 -0
- package/dist/hooks/usePopover.d.ts +11 -0
- package/dist/hooks/usePopover.js +17 -0
- package/dist/hooks/useServerAction.d.ts +9 -0
- package/dist/hooks/useServerAction.js +15 -0
- package/dist/navigation/components/AppNavigation/index.d.ts +2 -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 +13 -6
- 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/apply-variants.d.ts +3 -0
- package/dist/styles/classnames/apply-variants.js +25 -0
- package/dist/styles/classnames/config.d.ts +69 -0
- package/dist/styles/classnames/index.d.ts +7 -0
- package/dist/styles/classnames/index.js +37 -0
- package/dist/styles/classnames/interfaces.d.ts +56 -0
- package/dist/styles/classnames/interfaces.js +1 -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/icons/config.d.ts +9 -0
- package/dist/styles/icons/config.js +1 -0
- package/dist/styles/icons/index.d.ts +4 -0
- package/dist/styles/icons/interfaces.d.ts +4 -0
- package/dist/styles/icons/interfaces.js +1 -0
- package/dist/styles/index.d.ts +2 -2
- package/dist/styles/index.js +1 -1
- package/dist/styles/styles.css +59 -0
- package/dist/utility/interfaces.d.ts +19 -8
- package/package.json +9 -4
- package/dist/components/buttons/ConfirmableButton/index.d.ts +0 -7
- package/dist/components/buttons/ConfirmableButton/index.js +0 -13
- package/dist/components/collections/ListClientComponent/index.d.ts +0 -7
- package/dist/components/collections/ListClientComponent/index.js +0 -9
- package/dist/components/collections/utility/filter-columns.d.ts +0 -3
- package/dist/components/collections/utility/filter-columns.js +0 -8
- package/dist/components/utility/ClassNames/index.d.ts +0 -6
- package/dist/components/utility/ClassNames/index.js +0 -7
- 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/interfaces.d.ts +0 -41
- /package/dist/styles/{interfaces.js → classnames/config.js} +0 -0
- /package/dist/styles/{tw.d.ts → classnames/tw.d.ts} +0 -0
- /package/dist/styles/{tw.js → classnames/tw.js} +0 -0
- /package/dist/styles/{icons.js → icons/index.js} +0 -0
|
@@ -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 { getClassNames } from '../../../styles/
|
|
5
|
-
import tw from '../../../styles/tw';
|
|
4
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
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 = getClassNames('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) {
|
|
@@ -32,6 +33,6 @@ function FormField({ action, classNameProps, details, error, hasAssistiveError,
|
|
|
32
33
|
if (isContentOnly) {
|
|
33
34
|
return render(renderProps);
|
|
34
35
|
}
|
|
35
|
-
return (_jsxs("div", { className:
|
|
36
|
+
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
37
|
}
|
|
37
38
|
export default FormField;
|
|
@@ -1,9 +1,18 @@
|
|
|
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';
|
|
4
7
|
import type { TextInputComponentProps } from '../TextInput';
|
|
8
|
+
export type AutocompleteFormFieldProps<T> = FormFieldComponentProps<T | null> & AutocompleteComponentProps<T>;
|
|
9
|
+
export declare function AutocompleteFormField<T>(props: Readonly<AutocompleteFormFieldProps<T>>): React.ReactElement;
|
|
5
10
|
export type DropdownFormFieldProps<T> = FormFieldComponentProps<T | null> & DropdownComponentProps<T>;
|
|
6
11
|
export declare function DropdownFormField<T>(props: Readonly<DropdownFormFieldProps<T>>): React.ReactElement;
|
|
12
|
+
export type MoneyFormFieldProps = FormFieldComponentProps<number> & PointsInputComponentProps;
|
|
13
|
+
export declare function MoneyFormField(props: Readonly<MoneyFormFieldProps>): React.ReactElement;
|
|
14
|
+
export type NumberFormFieldProps = FormFieldComponentProps<number> & NumberInputComponentProps;
|
|
15
|
+
export declare function NumberFormField(props: Readonly<NumberFormFieldProps>): React.ReactElement;
|
|
7
16
|
export type PasswordFormFieldProps = FormFieldComponentProps<string> & PasswordInputComponentProps;
|
|
8
17
|
export declare function PasswordFormField(props: Readonly<PasswordFormFieldProps>): React.ReactElement;
|
|
9
18
|
export type TextFormFieldProps = FormFieldComponentProps<string> & TextInputComponentProps;
|
|
@@ -1,15 +1,33 @@
|
|
|
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';
|
|
4
5
|
import Dropdown from '../Dropdown';
|
|
5
6
|
import FormField from '../FormField';
|
|
7
|
+
import PointsInput from '../PointsInput';
|
|
8
|
+
import NumberInput from '../NumberInput';
|
|
6
9
|
import PasswordInput from '../PasswordInput';
|
|
7
10
|
import TextInput from '../TextInput';
|
|
11
|
+
export function AutocompleteFormField(props) {
|
|
12
|
+
const { fieldProps, inputProps } = extractInputProps(props);
|
|
13
|
+
const renderInput = useCallback((renderProps) => (_jsx(Autocomplete, { ...renderProps, ...inputProps })), [inputProps]);
|
|
14
|
+
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
15
|
+
}
|
|
8
16
|
export function DropdownFormField(props) {
|
|
9
17
|
const { fieldProps, inputProps } = extractInputProps(props);
|
|
10
18
|
const renderInput = useCallback((renderProps) => (_jsx(Dropdown, { ...renderProps, ...inputProps })), [inputProps]);
|
|
11
19
|
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
12
20
|
}
|
|
21
|
+
export function MoneyFormField(props) {
|
|
22
|
+
const { fieldProps, inputProps } = extractInputProps(props);
|
|
23
|
+
const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps })), [inputProps]);
|
|
24
|
+
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
25
|
+
}
|
|
26
|
+
export function NumberFormField(props) {
|
|
27
|
+
const { fieldProps, inputProps } = extractInputProps(props);
|
|
28
|
+
const renderInput = useCallback((renderProps) => (_jsx(NumberInput, { ...renderProps, ...inputProps })), [inputProps]);
|
|
29
|
+
return _jsx(FormField, { ...fieldProps, render: renderInput });
|
|
30
|
+
}
|
|
13
31
|
export function PasswordFormField(props) {
|
|
14
32
|
const { fieldProps, inputProps } = extractInputProps(props);
|
|
15
33
|
const renderInput = useCallback((renderProps) => (_jsx(PasswordInput, { ...renderProps, ...inputProps })), [inputProps]);
|
|
@@ -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,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getClassNames } from '../../../styles/
|
|
3
|
-
import tw from '../../../styles/tw';
|
|
2
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
3
|
+
import tw from '../../../styles/classnames/tw';
|
|
4
4
|
function FormLabel({ children, classNames, classNameProps, htmlFor, isAssistive, isOptional, }) {
|
|
5
|
-
const componentClassNames =
|
|
5
|
+
const componentClassNames = getClassNames('formField', { props: classNameProps }, classNames);
|
|
6
6
|
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
7
|
}
|
|
8
8
|
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,9 @@
|
|
|
1
|
+
export interface PasswordComplexityProps {
|
|
2
|
+
data: {
|
|
3
|
+
status: boolean;
|
|
4
|
+
value: string;
|
|
5
|
+
}[];
|
|
6
|
+
onComplexity?: (isValid: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
declare function PasswordComplexity({ data, onComplexity }: PasswordComplexityProps): React.ReactElement;
|
|
9
|
+
export default PasswordComplexity;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import useDeepCompareEffect from 'use-deep-compare-effect';
|
|
4
|
+
function PasswordComplexity({ data, onComplexity }) {
|
|
5
|
+
useDeepCompareEffect(() => {
|
|
6
|
+
onComplexity?.(data.every((item) => item.status));
|
|
7
|
+
}, [data]);
|
|
8
|
+
return (_jsx("aside", { children: _jsx("ul", { children: data.map((item) => (_jsx("li", { style: { color: item.status ? 'green' : 'red' }, children: item.value }, item.value))) }) }));
|
|
9
|
+
}
|
|
10
|
+
export default PasswordComplexity;
|
|
@@ -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,16 @@
|
|
|
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 { getClassNames } from '../../../styles/
|
|
4
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
5
5
|
import { getIcon } from '../../../styles/icons';
|
|
6
|
-
import tw from '../../../styles/tw';
|
|
7
6
|
import TextInput from '../TextInput';
|
|
8
7
|
function PasswordInput({ classNameProps, classNames, ...props }) {
|
|
9
|
-
const componentClassNames = classNames || getClassNames('passwordInput')?.(classNameProps);
|
|
10
|
-
const Icon = getIcon('password');
|
|
11
8
|
const [isVisible, setIsVisible] = useState(false);
|
|
9
|
+
const componentClassNames = getClassNames('passwordInput', { props: classNameProps, states: { isSelected: isVisible } }, classNames);
|
|
10
|
+
const Icon = getIcon('password');
|
|
12
11
|
function toggleVisible() {
|
|
13
12
|
setIsVisible(!isVisible);
|
|
14
13
|
}
|
|
15
|
-
return (_jsxs("div", { className: "relative", children: [_jsx(TextInput, { type: isVisible ? 'text' : 'password', ...props }), _jsx("div", { className: componentClassNames?.action, children: _jsxs("button", { className:
|
|
14
|
+
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
15
|
}
|
|
17
16
|
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;
|
|
@@ -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,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
3
|
import Assistive from '../../../components/utility/Assistive';
|
|
4
|
-
import { getClassNames } from '../../../styles/
|
|
5
|
-
import tw from '../../../styles/tw';
|
|
4
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
5
|
+
import tw from '../../../styles/classnames/tw';
|
|
6
6
|
function hasValue(value) {
|
|
7
7
|
if (Array.isArray(value)) {
|
|
8
8
|
return Boolean(value.filter((item) => Boolean(item)).length);
|
|
9
9
|
}
|
|
10
10
|
return Boolean(value);
|
|
11
11
|
}
|
|
12
|
-
function StaticTextInput({ classNames, classNameProps, details, hasError, icon, isDisabled,
|
|
13
|
-
const componentClassNames = {
|
|
14
|
-
...getClassNames('staticTextInput')?.(classNameProps),
|
|
15
|
-
...classNames,
|
|
16
|
-
};
|
|
12
|
+
function StaticTextInput({ classNames, classNameProps, details, hasError, icon, isDisabled, isOptional, label, name, onClear, onClick, onKeyDown, placeholder = 'Select...', value, }) {
|
|
13
|
+
const componentClassNames = getClassNames('staticTextInput', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
|
|
17
14
|
function handleClear() {
|
|
18
15
|
onClear?.();
|
|
19
16
|
}
|
|
20
|
-
return (_jsxs("div", { className: tw('relative', isDisabled ? 'pointer-events-none opacity-30' : null
|
|
17
|
+
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-0 top-0 flex w-0 items-center justify-end", children: [isOptional && hasValue(value) ? (_jsx("button", { className: tw('flex-none', componentClassNames?.clear), onClick: handleClear, type: "button", children: _jsx(Assistive, { children: "Clear" }) })) : null, icon && !isDisabled ? (_jsx("i", { className: tw('pointer-events-none flex-none', componentClassNames?.icon) })) : null] })] }));
|
|
21
18
|
}
|
|
22
19
|
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,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
|
-
import { getClassNames } from '../../../styles/
|
|
4
|
-
import tw from '../../../styles/tw';
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
4
|
+
import tw from '../../../styles/classnames/tw';
|
|
5
5
|
function Switch({ classNameProps, classNames, id, isDisabled, name, onChange, value, }) {
|
|
6
|
-
const componentClassNames =
|
|
6
|
+
const componentClassNames = getClassNames('switch', { props: classNameProps, states: { isChecked: Boolean(value) } }, classNames);
|
|
7
7
|
function handleChange(event) {
|
|
8
8
|
if (onChange) {
|
|
9
9
|
const inputEvent = {
|
|
@@ -12,6 +12,6 @@ function Switch({ classNameProps, classNames, id, isDisabled, name, onChange, va
|
|
|
12
12
|
onChange(inputEvent);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
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
|
|
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), disabled: isDisabled, id: id || name, name: name, onChange: handleChange, type: "checkbox", value: "true" }), _jsx("i", { className: componentClassNames?.icon })] }) })] }));
|
|
16
16
|
}
|
|
17
17
|
export default Switch;
|
|
@@ -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,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getClassNames } from '../../../styles/
|
|
3
|
-
import tw from '../../../styles/tw';
|
|
2
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
3
|
+
import tw from '../../../styles/classnames/tw';
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* ## ClassNames
|
|
@@ -13,18 +13,18 @@ import tw from '../../../styles/tw';
|
|
|
13
13
|
* | clear | The wrapper around the 'clear' button of the input, if one exists. The style of the
|
|
14
14
|
* button itself is handled by the `renderClear` prop. | `string` |
|
|
15
15
|
*/
|
|
16
|
-
function TextInput({ classNames, classNameProps, hasError, id, isAutocomplete, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, prefix, suffix, type, value, }) {
|
|
17
|
-
const componentClassNames =
|
|
16
|
+
function TextInput({ classNames, classNameProps, hasError, id, isAutocomplete, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, prefix, ref, suffix, type, value, }) {
|
|
17
|
+
const componentClassNames = getClassNames('textInput', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
|
|
18
18
|
function handleChange(event) {
|
|
19
19
|
if (onChange) {
|
|
20
20
|
const target = { name, value: event.target.value };
|
|
21
21
|
onChange({ target });
|
|
22
22
|
}
|
|
23
23
|
}
|
|
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
|
|
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", { ref: ref, "aria-invalid": hasError, "aria-labelledby": hasError
|
|
25
25
|
? `${id || name}_err`
|
|
26
26
|
: undefined /* eslint-disable-line no-undefined */, autoComplete: isAutocomplete === false
|
|
27
27
|
? '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
|
|
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), 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
29
|
}
|
|
30
30
|
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>;
|
|
@@ -37,7 +37,7 @@ export interface UseFormReturn<Request> {
|
|
|
37
37
|
isLoading: boolean;
|
|
38
38
|
resetForm: () => void;
|
|
39
39
|
setErrors: (errors: Record<string, string> | null) => void;
|
|
40
|
-
setFormData: (key:
|
|
40
|
+
setFormData: <K extends keyof Request>(key: K, value: Request[K]) => void;
|
|
41
41
|
submitForm: () => void;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -120,9 +120,9 @@ function getToastMessage(key, toasts) {
|
|
|
120
120
|
* handling additional form events or integrating with different server APIs.
|
|
121
121
|
*/
|
|
122
122
|
function useForm({ defaults = {}, onError, onSubmit, onSuccess, onValidation, redirectOnSuccess, refreshOnSuccess, toasts, }) {
|
|
123
|
-
const
|
|
123
|
+
const ref = useRef(null);
|
|
124
124
|
const router = useRouter();
|
|
125
|
-
const [isLoading
|
|
125
|
+
const [isLoading] = useTransition();
|
|
126
126
|
const [errors, setErrors] = useState(null);
|
|
127
127
|
const [data, setData] = useState(defaults);
|
|
128
128
|
const { toastError, toastSuccess } = useToast();
|
|
@@ -168,7 +168,7 @@ function useForm({ defaults = {}, onError, onSubmit, onSuccess, onValidation, re
|
|
|
168
168
|
if (fnReturn.validation) {
|
|
169
169
|
return handleValidation(fnReturn.validation);
|
|
170
170
|
}
|
|
171
|
-
if (fnReturn.data) {
|
|
171
|
+
if (fnReturn.data !== null) {
|
|
172
172
|
return handleSuccess(fnReturn.data);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -196,13 +196,14 @@ function useForm({ defaults = {}, onError, onSubmit, onSuccess, onValidation, re
|
|
|
196
196
|
formData: data,
|
|
197
197
|
formProps: {
|
|
198
198
|
action: handleSubmit,
|
|
199
|
+
ref,
|
|
199
200
|
},
|
|
200
201
|
isLoading,
|
|
201
202
|
resetForm,
|
|
202
203
|
setErrors,
|
|
203
204
|
setFormData,
|
|
204
205
|
submitForm: () => {
|
|
205
|
-
setTimeout(() =>
|
|
206
|
+
setTimeout(() => ref.current?.requestSubmit(), 1);
|
|
206
207
|
},
|
|
207
208
|
};
|
|
208
209
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ActionObject } from '../../utility/interfaces';
|
|
2
2
|
import type { ModalFormProps } from '../components/ModalForm';
|
|
3
3
|
import type { UseFormArgs, UseFormReturn } from './useForm';
|
|
4
4
|
export interface UseModalFormArgs<Request, Response> extends UseFormArgs<Request, Response> {
|
|
5
|
-
actions?:
|
|
5
|
+
actions?: ActionObject[];
|
|
6
6
|
icon?: React.ReactNode;
|
|
7
7
|
submitLabel?: string;
|
|
8
8
|
title?: string;
|
package/dist/forms/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from './interfaces';
|
|
2
|
+
export type { AutocompleteProps } from './components/Autocomplete';
|
|
3
|
+
export { default as Autocomplete } from './components/Autocomplete';
|
|
2
4
|
export type { DropdownClassNames, DropdownProps } from './components/Dropdown';
|
|
3
5
|
export { default as Dropdown } from './components/Dropdown';
|
|
4
6
|
export type { EditableFormClassNames, EditableFormProps } from './components/EditableForm';
|
|
@@ -13,15 +15,29 @@ export type { FormSubmitProps } from './components/FormSubmit';
|
|
|
13
15
|
export { default as FormSubmit } from './components/FormSubmit';
|
|
14
16
|
export type { ModalFormProps } from './components/ModalForm';
|
|
15
17
|
export { default as ModalForm } from './components/ModalForm';
|
|
18
|
+
export type { PasswordComplexityProps } from './components/PasswordComplexity';
|
|
19
|
+
export { default as PasswordComplexity } from './components/PasswordComplexity';
|
|
20
|
+
export type { NumberInputProps } from './components/NumberInput';
|
|
21
|
+
export { default as NumberInput } from './components/NumberInput';
|
|
16
22
|
export type { PasswordInputClassNames, PasswordInputProps } from './components/PasswordInput';
|
|
17
23
|
export { default as PasswordInput } from './components/PasswordInput';
|
|
24
|
+
export type { PointsInputProps } from './components/PointsInput';
|
|
25
|
+
export { default as PointsInput } from './components/PointsInput';
|
|
26
|
+
export type { StaticTextInputClassNames, StaticTextInputProps } from './components/StaticTextInput';
|
|
27
|
+
export { default as StaticTextInput } from './components/StaticTextInput';
|
|
18
28
|
export type { TextInputClassNames, TextInputProps } from './components/TextInput';
|
|
19
29
|
export { default as TextInput } from './components/TextInput';
|
|
20
30
|
export type { EditableDropdownFormFieldProps, EditableTextFormFieldProps, } from './components/EditableFormFields';
|
|
21
31
|
export { EditableDropdownFormField, EditableTextFormField } from './components/EditableFormFields';
|
|
22
|
-
export type { DropdownFormFieldProps, PasswordFormFieldProps, TextFormFieldProps, } from './components/FormFields';
|
|
23
|
-
export { DropdownFormField, PasswordFormField, TextFormField } from './components/FormFields';
|
|
32
|
+
export type { AutocompleteFormFieldProps, DropdownFormFieldProps, MoneyFormFieldProps, NumberFormFieldProps, PasswordFormFieldProps, TextFormFieldProps, } from './components/FormFields';
|
|
33
|
+
export { AutocompleteFormField, DropdownFormField, MoneyFormField, NumberFormField, PasswordFormField, TextFormField, } from './components/FormFields';
|
|
34
|
+
export type { UseAutocompleteArgs, UseAutocompleteReturn } from './hooks/useAutocomplete';
|
|
35
|
+
export { default as useAutocomplete } from './hooks/useAutocomplete';
|
|
36
|
+
export type { UseDropdownArgs, UseDropdownReturn } from './hooks/useDropdown';
|
|
24
37
|
export { default as useDropdown } from './hooks/useDropdown';
|
|
38
|
+
export type { UseEditableFormArgs, UseEditableFormReturn } from './hooks/useEditableForm';
|
|
25
39
|
export { default as useEditableForm } from './hooks/useEditableForm';
|
|
40
|
+
export type { UseFormArgs, UseFormReturn } from './hooks/useForm';
|
|
26
41
|
export { default as useForm } from './hooks/useForm';
|
|
42
|
+
export type { UseModalFormArgs, UseModalFormReturn } from './hooks/useModalForm';
|
|
27
43
|
export { default as useModalForm } from './hooks/useModalForm';
|
package/dist/forms/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './interfaces';
|
|
2
|
+
export { default as Autocomplete } from './components/Autocomplete';
|
|
2
3
|
export { default as Dropdown } from './components/Dropdown';
|
|
3
4
|
export { default as EditableForm } from './components/EditableForm';
|
|
4
5
|
export { default as EditableFormField } from './components/EditableFormField';
|
|
@@ -6,11 +7,15 @@ export { default as Form } from './components/Form';
|
|
|
6
7
|
export { default as FormField } from './components/FormField';
|
|
7
8
|
export { default as FormSubmit } from './components/FormSubmit';
|
|
8
9
|
export { default as ModalForm } from './components/ModalForm';
|
|
10
|
+
export { default as PasswordComplexity } from './components/PasswordComplexity';
|
|
11
|
+
export { default as NumberInput } from './components/NumberInput';
|
|
9
12
|
export { default as PasswordInput } from './components/PasswordInput';
|
|
13
|
+
export { default as PointsInput } from './components/PointsInput';
|
|
14
|
+
export { default as StaticTextInput } from './components/StaticTextInput';
|
|
10
15
|
export { default as TextInput } from './components/TextInput';
|
|
11
16
|
export { EditableDropdownFormField, EditableTextFormField } from './components/EditableFormFields';
|
|
12
|
-
export { DropdownFormField, PasswordFormField, TextFormField } from './components/FormFields';
|
|
13
|
-
|
|
17
|
+
export { AutocompleteFormField, DropdownFormField, MoneyFormField, NumberFormField, PasswordFormField, TextFormField, } from './components/FormFields';
|
|
18
|
+
export { default as useAutocomplete } from './hooks/useAutocomplete';
|
|
14
19
|
export { default as useDropdown } from './hooks/useDropdown';
|
|
15
20
|
export { default as useEditableForm } from './hooks/useEditableForm';
|
|
16
21
|
export { default as useForm } from './hooks/useForm';
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { default as useClickOutside } from './useClickOutside';
|
|
2
|
+
export { default as useServerAction } from './useServerAction';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ActionEvent } from '../utility/interfaces';
|
|
2
|
+
interface UseConfirmableArgs {
|
|
3
|
+
isLoading?: boolean;
|
|
4
|
+
onBeforeConfirm?: () => void;
|
|
5
|
+
onConfirm: (event: ActionEvent, currentRef: HTMLButtonElement | null) => void;
|
|
6
|
+
onSuccess?: () => Promise<void> | void;
|
|
7
|
+
redirectOnSuccess?: string | false | ((response: Response) => string | false);
|
|
8
|
+
refreshOnSuccess?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface UseConfirmableReturn {
|
|
11
|
+
handle: (event?: ActionEvent) => void;
|
|
12
|
+
isOpen: boolean;
|
|
13
|
+
modalProps: {
|
|
14
|
+
isLoading: boolean;
|
|
15
|
+
onCancel: () => void;
|
|
16
|
+
onConfirm: () => void;
|
|
17
|
+
};
|
|
18
|
+
ref: React.RefObject<HTMLButtonElement | null>;
|
|
19
|
+
}
|
|
20
|
+
declare function useConfirmable({ isLoading, onBeforeConfirm, onConfirm, onSuccess, redirectOnSuccess, refreshOnSuccess, }: Readonly<UseConfirmableArgs>): UseConfirmableReturn;
|
|
21
|
+
export default useConfirmable;
|