@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
|
@@ -5,6 +5,6 @@ function DropdownFilter({ config, name, onChange, value, ...filterBarProps }) {
|
|
|
5
5
|
function handleChange(event) {
|
|
6
6
|
onChange?.({ target: { name, value: event.target.value || '' } });
|
|
7
7
|
}
|
|
8
|
-
return (_jsx(Filter, { ...filterBarProps, children: _jsx(Dropdown, { isPanelOnly: true, name: name, onChange: handleChange, options: config?.
|
|
8
|
+
return (_jsx(Filter, { ...filterBarProps, children: _jsx(Dropdown, { isPanelOnly: true, name: name, onChange: handleChange, options: config?.options, value: value }) }));
|
|
9
9
|
}
|
|
10
10
|
export default DropdownFilter;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ClientFilterObject, FilterType } from '../../../filters/interfaces';
|
|
3
|
-
import { ClassNameProps } from '../../../styles/interfaces';
|
|
3
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
4
|
+
import { SizeVariant } from '../../../utility/interfaces';
|
|
4
5
|
import { FilterPanelClassNames } from '../../components/FilterPanel';
|
|
5
|
-
import { FilterComponentSize } from '../interfaces';
|
|
6
6
|
interface FilterProps<F extends FilterType> extends ClassNameProps<FilterPanelClassNames>, ClientFilterObject<F> {
|
|
7
7
|
align?: 'left' | 'right';
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
icon?: React.ReactNode;
|
|
10
|
+
isDisabled?: boolean;
|
|
10
11
|
isOpen: boolean;
|
|
11
12
|
onApply: () => void;
|
|
12
|
-
size?:
|
|
13
|
+
size?: SizeVariant | null;
|
|
13
14
|
title?: string;
|
|
14
15
|
}
|
|
15
|
-
declare function Filter<F extends FilterType>({ align, children, classNameProps, classNames, icon, isOpen, label, onApply, size, title, }: Readonly<FilterProps<F>>): React.ReactElement;
|
|
16
|
+
declare function Filter<F extends FilterType>({ align, children, classNameProps, classNames, icon, isDisabled, isOpen, label, onApply, size, title, }: Readonly<FilterProps<F>>): React.ReactElement;
|
|
16
17
|
export default Filter;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import Button from '../../../components/buttons/Button';
|
|
4
4
|
import Popover from '../../../components/utility/Popover';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
return (_jsx(Popover, { align: align, isOpen: isOpen, children: _jsxs("div", { className:
|
|
5
|
+
import { useClassNames, useIcon } from '../../../styles/context';
|
|
6
|
+
import applySizes from '../../../styles/classnames/utility/apply-sizes';
|
|
7
|
+
function Filter({ align, children, classNameProps, classNames, icon, isDisabled, isOpen, label, onApply, size, title, }) {
|
|
8
|
+
const componentClassNames = useClassNames('filterPanel', { props: { ...classNameProps, ...applySizes(size) } }, classNames);
|
|
9
|
+
const DefaultIcon = useIcon('filter.panel');
|
|
10
|
+
const iconComponent = icon ?? (DefaultIcon ? _jsx(DefaultIcon, {}) : null);
|
|
11
|
+
return (_jsx(Popover, { align: align, isOpen: isOpen, children: _jsxs("div", { className: componentClassNames?.root, children: [_jsxs("p", { className: componentClassNames?.title, children: [iconComponent ? (_jsx("span", { className: componentClassNames?.icon, children: iconComponent })) : null, title || (label ? `Filter by ${label}` : 'Filter')] }), _jsx("div", { className: componentClassNames?.content, children: children }), _jsx("div", { className: componentClassNames?.footer, children: _jsx(Button, { isDisabled: isDisabled, isFullWidth: true, onClick: onApply, variant: "primary", children: "Apply" }) })] }) }));
|
|
12
12
|
}
|
|
13
13
|
export default Filter;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { InputProps } from '../../../forms/interfaces';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
3
|
+
export interface SearchFilterClassNames {
|
|
4
|
+
icon: string;
|
|
5
|
+
input: string;
|
|
6
|
+
}
|
|
7
|
+
type SearchFilterProps = ClassNameProps<SearchFilterClassNames> & Pick<InputProps<string>, 'onChange' | 'value'>;
|
|
8
|
+
declare function SearchFilter({ classNameProps, classNames, onChange, value, }: Readonly<SearchFilterProps>): React.ReactElement;
|
|
4
9
|
export default SearchFilter;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { Fragment, useState } from 'react';
|
|
3
4
|
import FilterClearButton from '../../../filters/components/FilterClearButton';
|
|
4
5
|
import TextInput from '../../../forms/components/TextInput';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
function SearchFilter({ onChange, value }) {
|
|
8
|
-
const
|
|
6
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
7
|
+
import { useClassNames, useIcon } from '../../../styles/context';
|
|
8
|
+
function SearchFilter({ classNameProps, classNames, onChange, value, }) {
|
|
9
|
+
const componentClassNames = useClassNames('filterSearch', { props: classNameProps }, classNames);
|
|
10
|
+
const Icon = useIcon('filter.search');
|
|
9
11
|
const [pendingValue, setPendingValue] = useState(value);
|
|
10
12
|
function handleChange(event) {
|
|
11
13
|
setPendingValue(event.target.value);
|
|
@@ -19,11 +21,9 @@ function SearchFilter({ onChange, value }) {
|
|
|
19
21
|
onChange?.({ target: { name: 'search', value: pendingValue } });
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
//h-8 w-56 rounded-full border border-slate-400 pl-7 pr-3 text-xs text-white placeholder:text-slate-300
|
|
24
|
-
return (_jsxs(Fragment, { children: [_jsx("div", { className: "", children: Icon ? _jsx(Icon, { className: "h-4 w-4 text-white" }) : null }), _jsx(TextInput, { classNames: {
|
|
24
|
+
return (_jsxs(Fragment, { children: [_jsx("div", { className: componentClassNames?.icon, children: Icon ? _jsx(Icon, {}) : null }), _jsx(TextInput, { classNames: {
|
|
25
25
|
root: {
|
|
26
|
-
default: tw(
|
|
26
|
+
default: tw(componentClassNames?.input, value ? 'bg-slate-700' : 'bg-transparent focus:bg-slate-700'),
|
|
27
27
|
},
|
|
28
28
|
}, name: "search", onChange: handleChange, onKeyDown: handleKeyDown, value: pendingValue }), value ? _jsx(FilterClearButton, { onClick: handleClear }) : null] }));
|
|
29
29
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { InputProps } from '../../forms/interfaces';
|
|
2
2
|
import { ClientFilterObject, FilterType } from '../interfaces';
|
|
3
|
-
export type FilterComponentSize = 'lg';
|
|
4
3
|
export interface FilterComponentProps<F extends FilterType> extends Omit<ClientFilterObject<F>, 'type'>, InputProps<string> {
|
|
5
4
|
icon?: React.ReactNode;
|
|
6
5
|
isOpen: boolean;
|
|
7
6
|
onApply: () => void;
|
|
8
|
-
size?: FilterComponentSize;
|
|
9
7
|
title?: string;
|
|
10
8
|
}
|
package/dist/filters/index.d.ts
CHANGED
package/dist/filters/index.js
CHANGED
|
@@ -6,10 +6,10 @@ export interface FilterConfig {
|
|
|
6
6
|
title?: string;
|
|
7
7
|
}
|
|
8
8
|
export interface FilterConfigWithBooleanData extends FilterConfig {
|
|
9
|
-
|
|
9
|
+
options?: [string, string];
|
|
10
10
|
}
|
|
11
11
|
export interface FilterConfigWithData extends FilterConfig {
|
|
12
|
-
|
|
12
|
+
options?: DropdownObject[];
|
|
13
13
|
url?: string;
|
|
14
14
|
}
|
|
15
15
|
export interface ClientFilterObject<F extends FilterType> {
|
|
@@ -21,8 +21,8 @@ export type ClientFilterMap<T> = {
|
|
|
21
21
|
[K in keyof T]?: ClientFilterObject<FilterType>;
|
|
22
22
|
};
|
|
23
23
|
export interface FilterObject<T, F extends FilterType> extends ClientFilterObject<F> {
|
|
24
|
-
transformer: (value: string) => T;
|
|
24
|
+
transformer: (value: string | null) => T | null;
|
|
25
25
|
}
|
|
26
26
|
export type FilterMap<T> = {
|
|
27
|
-
[K in keyof T]?: FilterObject<T[K], FilterType>;
|
|
27
|
+
[K in keyof T]?: FilterObject<T[K] | null, FilterType>;
|
|
28
28
|
};
|
|
@@ -6,8 +6,9 @@ function parseFilters(searchParams, map) {
|
|
|
6
6
|
for (const key in map) {
|
|
7
7
|
if (Object.hasOwn(map, key) && typeof map[key] !== 'undefined') {
|
|
8
8
|
const value = searchParams[key];
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const transformed = map[key].transformer(value);
|
|
10
|
+
if (transformed) {
|
|
11
|
+
out[key] = transformed;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
}
|
|
@@ -36,14 +36,14 @@ function renderValue(value, config) {
|
|
|
36
36
|
* If the config has data, extract the names from the data values
|
|
37
37
|
* This should work for boolean, dropdown, and multi filters
|
|
38
38
|
*/
|
|
39
|
-
if (config && '
|
|
40
|
-
// Try the entire value first (not array). See if it's in the
|
|
41
|
-
const [item] = getNamesFromIDs([value], config.
|
|
39
|
+
if (config && 'options' in config) {
|
|
40
|
+
// Try the entire value first (not array). See if it's in the options, a return the name if so:
|
|
41
|
+
const [item] = getNamesFromIDs([value], config.options);
|
|
42
42
|
if (item) {
|
|
43
43
|
return item;
|
|
44
44
|
}
|
|
45
45
|
// Now try the split values:
|
|
46
|
-
const items = getNamesFromIDs(values, config.
|
|
46
|
+
const items = getNamesFromIDs(values, config.options);
|
|
47
47
|
if (items.length) {
|
|
48
48
|
return formatMulti(items);
|
|
49
49
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function transformFromBoolean(value?: boolean): string;
|
|
2
|
-
export declare function transformToBoolean(value?: string): boolean;
|
|
2
|
+
export declare function transformToBoolean(value?: string | null): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function transformFromDate(value?: [Date, Date] | null): string;
|
|
2
|
-
export declare function transformToDate(value?: string): [Date, Date] | null;
|
|
2
|
+
export declare function transformToDate(value?: string | null): [Date, Date] | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function transformFromMulti(value?: string[] | null): string;
|
|
2
|
-
export declare function transformToMulti(value?: string): string[] | null;
|
|
2
|
+
export declare function transformToMulti(value?: string | null): string[] | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
import type { DropdownObject, InputProps } from '../../interfaces';
|
|
3
|
+
import { DropdownClassNames, DropdownComponentProps } from '../Dropdown';
|
|
4
|
+
export interface AutocompleteComponentProps<T> extends DropdownComponentProps<T> {
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
onSearch?: (search: string) => void;
|
|
7
|
+
selected?: DropdownObject<T> | null;
|
|
8
|
+
}
|
|
9
|
+
export type AutocompleteProps<T> = ClassNameProps<DropdownClassNames> & InputProps<T | null> & AutocompleteComponentProps<T>;
|
|
10
|
+
declare function Autocomplete<T>({ hasError, isDisabled, isLoading, isOptional, name, onChange, onSearch, options, selected, placeholder, value, }: Readonly<AutocompleteProps<T>>): React.ReactElement;
|
|
11
|
+
export default Autocomplete;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, useRef, useState } from 'react';
|
|
4
|
+
import Popover from '../../../components/utility/Popover';
|
|
5
|
+
import useClickOutside from '../../../hooks/useClickOutside';
|
|
6
|
+
import DropdownList from '../DropdownList';
|
|
7
|
+
import StaticTextInput from '../StaticTextInput';
|
|
8
|
+
import TextInput from '../TextInput';
|
|
9
|
+
function Autocomplete({ hasError, isDisabled, isLoading, isOptional, name, onChange, onSearch, options, selected, placeholder, value, }) {
|
|
10
|
+
const inputRef = useRef(null);
|
|
11
|
+
const [search, setSearch] = useState('');
|
|
12
|
+
const [isOpen, setIsOpen, ref] = useClickOutside();
|
|
13
|
+
function handleChange(event) {
|
|
14
|
+
if (onChange) {
|
|
15
|
+
onChange(event);
|
|
16
|
+
}
|
|
17
|
+
setIsOpen(false);
|
|
18
|
+
setSearch('');
|
|
19
|
+
}
|
|
20
|
+
function handleSearch(event) {
|
|
21
|
+
setSearch(event.target.value ?? '');
|
|
22
|
+
setIsOpen(true);
|
|
23
|
+
if (onSearch) {
|
|
24
|
+
onSearch(event.target.value ?? '');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function handleReset() {
|
|
28
|
+
if (onChange) {
|
|
29
|
+
onChange({ target: { name, value: null } });
|
|
30
|
+
}
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
inputRef.current?.focus();
|
|
33
|
+
}, 10);
|
|
34
|
+
}
|
|
35
|
+
return (_jsx("div", { ref: ref, className: "relative", children: selected ? (_jsx(StaticTextInput, { details: selected.details, hasError: hasError, isDisabled: isDisabled, isOptional: isOptional, label: selected.label, name: name, onClick: handleReset, placeholder: placeholder || 'Select...', value: value ? String(value) : '' })) : (_jsxs(Fragment, { children: [_jsx(TextInput, { ref: inputRef, hasError: hasError, isDisabled: isDisabled, name: `${name}_search`, onChange: handleSearch, onFocus: () => setIsOpen(Boolean(options?.length)), placeholder: "Start typing...", value: search }), _jsx(Popover, { align: "center", isOpen: isOpen, isScrollable: true, children: options?.length ? (_jsx(DropdownList, { name: name, onChange: handleChange, options: options ?? [], value: value })) : isLoading ? (_jsx("div", { children: "Loading..." })) : (_jsx("div", { children: "No results" })) })] })) }));
|
|
36
|
+
}
|
|
37
|
+
export default Autocomplete;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InputProps } from '../../../forms/interfaces';
|
|
2
|
+
import type { ClassNameProps, HighlightableClassName } from '../../../styles/classnames/interfaces';
|
|
3
|
+
export interface CSVInputClassNames {
|
|
4
|
+
root: string;
|
|
5
|
+
icon: HighlightableClassName;
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
}
|
|
9
|
+
export type CSVInputProps = ClassNameProps<CSVInputClassNames> & InputProps<string>;
|
|
10
|
+
declare function CSVInput({ classNames, classNameProps, id, isDisabled, name, onChange, value, }: Readonly<CSVInputProps>): React.ReactElement;
|
|
11
|
+
export default CSVInput;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { formatPlural } from '@sqrzro/utility';
|
|
5
|
+
import { useClassNames, useIcon } from '../../../styles/context';
|
|
6
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
7
|
+
import formatFileSize from '../../utility/format-file-size';
|
|
8
|
+
function CSVInput({ classNames, classNameProps, id, isDisabled, name, onChange, value, }) {
|
|
9
|
+
const UploadIcon = useIcon('csvInput.upload');
|
|
10
|
+
const SuccessIcon = useIcon('csvInput.success');
|
|
11
|
+
const [fileData, setFileData] = useState(null);
|
|
12
|
+
const componentClassNames = useClassNames('csvInput', { props: classNameProps, states: { isHighlighted: Boolean(fileData) } }, classNames);
|
|
13
|
+
function handleChange(event) {
|
|
14
|
+
const { files } = event.target;
|
|
15
|
+
const reader = new FileReader();
|
|
16
|
+
reader.addEventListener('load', () => {
|
|
17
|
+
const text = reader.result?.toString() || '';
|
|
18
|
+
const lines = text.split('\n').filter((item) => item.trim() !== '').length;
|
|
19
|
+
setFileData({
|
|
20
|
+
lines,
|
|
21
|
+
name: files?.[0].name || '',
|
|
22
|
+
size: files?.[0].size || 0,
|
|
23
|
+
});
|
|
24
|
+
onChange?.({ target: { name, value: text } });
|
|
25
|
+
}, false);
|
|
26
|
+
if (files?.[0]) {
|
|
27
|
+
reader.readAsText(files[0]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return (_jsxs("div", { className: tw('relative flex items-center justify-center', componentClassNames?.root), children: [_jsx("input", { name: name, type: "hidden", value: value || '' }), _jsx("input", { accept: "text/csv", className: "absolute left-0 top-0 h-full w-full cursor-pointer opacity-0", disabled: isDisabled, id: id || name, name: name, onChange: handleChange, type: "file" }), fileData ? (_jsxs("div", { className: tw('text-center', isDisabled ? 'pointer-events-none opacity-20' : null), children: [_jsx("i", { className: componentClassNames?.icon, children: SuccessIcon ? _jsx(SuccessIcon, {}) : null }), _jsx("p", { className: componentClassNames?.title, children: fileData.name }), _jsxs("p", { className: componentClassNames?.description, children: [formatFileSize(fileData.size), " \u2022", ' ', formatPlural('line', fileData.lines)] })] })) : (_jsxs("div", { className: "text-center", children: [_jsx("i", { className: componentClassNames?.icon, children: UploadIcon ? _jsx(UploadIcon, {}) : null }), _jsx("p", { className: componentClassNames?.title, children: "Click to Upload" }), _jsx("p", { className: componentClassNames?.description, children: "(or drag a CSV file over this box)" })] }))] }));
|
|
31
|
+
}
|
|
32
|
+
export default CSVInput;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps, ErrorableClassName, FocusableClassName, SelectableClassName } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps, ErrorableClassName, FocusableClassName, SelectableClassName } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import type { DropdownObject, InputProps } from '../../interfaces';
|
|
3
3
|
export interface DropdownClassNames {
|
|
4
4
|
root: ErrorableClassName & FocusableClassName;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import Popover from '../../../components/utility/Popover';
|
|
4
4
|
import useClickOutside from '../../../hooks/useClickOutside';
|
|
5
|
-
import tw from '../../../styles/tw';
|
|
6
|
-
import {
|
|
5
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
6
|
+
import { useClassNames, useIcon } from '../../../styles/context';
|
|
7
7
|
import DropdownList from '../DropdownList';
|
|
8
8
|
import StaticTextInput from '../StaticTextInput';
|
|
9
9
|
function findByValue(options, value) {
|
|
@@ -16,8 +16,12 @@ export function renderDetails(options, value) {
|
|
|
16
16
|
return findByValue(options, value)?.details || '';
|
|
17
17
|
}
|
|
18
18
|
function Dropdown({ classNames, classNameProps, hasError, isDisabled, isOptional, isPanelOnly, name, onChange, options = [], placeholder, value, }) {
|
|
19
|
-
const componentClassNames = classNames || getClassNames('dropdown')?.(classNameProps);
|
|
20
19
|
const [isOpen, setIsOpen, node] = useClickOutside({ shouldHandleEnterKey: true });
|
|
20
|
+
const componentClassNames = useClassNames('dropdown', {
|
|
21
|
+
props: classNameProps,
|
|
22
|
+
states: { isError: hasError ?? false, isFocused: isOpen && !isDisabled },
|
|
23
|
+
}, classNames);
|
|
24
|
+
const Icon = useIcon('dropdown.control');
|
|
21
25
|
function toggleIsOpen() {
|
|
22
26
|
setIsOpen(!isOpen);
|
|
23
27
|
}
|
|
@@ -33,9 +37,6 @@ function Dropdown({ classNames, classNameProps, hasError, isDisabled, isOptional
|
|
|
33
37
|
if (isPanelOnly) {
|
|
34
38
|
return _jsx(DropdownList, { name: name, onChange: handleChange, options: options, value: value });
|
|
35
39
|
}
|
|
36
|
-
return (_jsxs("div", { ref: node, className: tw('relative', componentClassNames?.root
|
|
37
|
-
clear: componentClassNames?.clear,
|
|
38
|
-
icon: componentClassNames?.icon,
|
|
39
|
-
}, details: renderDetails(options, value), hasError: hasError, isDisabled: isDisabled || !options?.length, isOpen: isOpen, isOptional: isOptional, label: renderLabel(options, value), name: name, onClear: handleClear, onClick: toggleIsOpen, placeholder: placeholder || 'Select...', value: value ? String(value) : '' }), _jsx(Popover, { align: "center", isOpen: isOpen ? !isDisabled : false, isScrollable: true, children: _jsx(DropdownList, { name: name, onChange: handleChange, options: options, value: value }) })] }));
|
|
40
|
+
return (_jsxs("div", { ref: node, className: tw('relative', componentClassNames?.root), children: [_jsx(StaticTextInput, { classNameProps: classNameProps, details: renderDetails(options, value), hasError: hasError, icon: Icon ? _jsx(Icon, {}) : null, isDisabled: isDisabled || !options?.length, isOptional: isOptional, label: renderLabel(options, value), name: name, onClear: handleClear, onClick: toggleIsOpen, placeholder: placeholder || 'Select...', value: value ? String(value) : '' }), _jsx(Popover, { align: "center", isOpen: isOpen ? !isDisabled : false, isScrollable: true, children: _jsx(DropdownList, { classNameProps: classNameProps, classNames: classNames, name: name, onChange: handleChange, options: options, value: value }) })] }));
|
|
40
41
|
}
|
|
41
42
|
export default Dropdown;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DropdownObject } from '../../../forms/interfaces';
|
|
2
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
3
|
+
import type { DropdownClassNames } from '../Dropdown';
|
|
4
|
+
interface DropdownItemProps<T> extends ClassNameProps<DropdownClassNames>, DropdownObject<T> {
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
onChange: (item: Pick<DropdownObject<T>, '$data' | 'value'>) => () => void;
|
|
7
|
+
}
|
|
8
|
+
declare function DropdownItem<T>({ $data, classNameProps, classNames, details, isDisabled, isSelected, label, onChange, value, }: DropdownItemProps<T>): React.ReactElement;
|
|
9
|
+
export default DropdownItem;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useClassNames } from '../../../styles/context';
|
|
4
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
5
|
+
function DropdownItem({ $data, classNameProps, classNames, details, isDisabled, isSelected, label, onChange, value, }) {
|
|
6
|
+
const componentClassNames = useClassNames('dropdown', { props: classNameProps, states: { isSelected } }, classNames);
|
|
7
|
+
return (_jsx("li", { "aria-selected": isSelected, role: "option", children: _jsxs("button", { className: tw('relative w-full text-left', componentClassNames?.item, isDisabled ? 'pointer-events-none opacity-30' : null), onClick: onChange({ $data, value }), tabIndex: -1, type: "button", children: [_jsx("span", { className: tw('whitespace-nowrap', componentClassNames?.title), children: label }), details ? (_jsx("small", { className: tw(componentClassNames?.details), children: details })) : null] }) }));
|
|
8
|
+
}
|
|
9
|
+
export default DropdownItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DropdownObject, InputProps } from '../../../forms/interfaces';
|
|
2
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
3
3
|
import type { DropdownClassNames } from '../Dropdown';
|
|
4
4
|
export interface DropdownListProps<T> extends ClassNameProps<DropdownClassNames>, InputProps<T | null> {
|
|
5
5
|
options: DropdownObject<T>[];
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
return Boolean(value) && value === id;
|
|
6
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useClassNames } from '../../../styles/context';
|
|
4
|
+
import DropdownItem from '../DropdownItem';
|
|
7
5
|
function DropdownList({ classNames, classNameProps, name, onChange, options, value, }) {
|
|
8
|
-
const componentClassNames =
|
|
9
|
-
// const checkboxClassNames =
|
|
6
|
+
const componentClassNames = useClassNames('dropdown', { props: classNameProps }, classNames);
|
|
7
|
+
// const checkboxClassNames = useClassNames('checkboxInput')?.(classNameProps);
|
|
10
8
|
function handleChange(item) {
|
|
11
9
|
return () => {
|
|
12
10
|
onChange?.({
|
|
@@ -15,6 +13,6 @@ function DropdownList({ classNames, classNameProps, name, onChange, options, val
|
|
|
15
13
|
});
|
|
16
14
|
};
|
|
17
15
|
}
|
|
18
|
-
return (_jsx("ul", { className: componentClassNames?.list, role: "listbox", children: options.map((item, index) => (_jsx(
|
|
16
|
+
return (_jsx("ul", { className: componentClassNames?.list, role: "listbox", children: options.map((item, index) => (_jsx(DropdownItem, { ...item, classNameProps: classNameProps, classNames: classNames, isSelected: Boolean(value) && value === item.value, onChange: handleChange }, index))) }));
|
|
19
17
|
}
|
|
20
18
|
export default DropdownList;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
-
import type {
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
import type { SimpleActionObject } from '../../../utility/interfaces';
|
|
3
3
|
import type { EditingStatus } from '../../interfaces';
|
|
4
4
|
import type { FormProps } from '../Form';
|
|
5
5
|
export interface EditableFormClassNames {
|
|
@@ -11,7 +11,7 @@ export interface EditableFormClassNames {
|
|
|
11
11
|
content: string;
|
|
12
12
|
}
|
|
13
13
|
export interface EditableFormProps extends ClassNameProps<EditableFormClassNames> {
|
|
14
|
-
actions?:
|
|
14
|
+
actions?: SimpleActionObject[] | false;
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
formProps: Omit<FormProps, 'children'>;
|
|
17
17
|
onCancel?: () => void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import ActionList from '../../../components/utility/ActionList';
|
|
3
|
-
import {
|
|
4
|
-
import tw from '../../../styles/tw';
|
|
4
|
+
import { useClassNames } from '../../../styles/context';
|
|
5
5
|
import Form from '../Form';
|
|
6
6
|
function EditableForm({ classNameProps, classNames, children, formProps, onCancel, onEdit, setStatus, status, title, }) {
|
|
7
|
-
const componentClassNames =
|
|
7
|
+
const componentClassNames = useClassNames('editableForm', { props: classNameProps }, classNames);
|
|
8
8
|
function setCancelled() {
|
|
9
9
|
onCancel?.();
|
|
10
10
|
setStatus?.('CANCELLED');
|
|
@@ -13,11 +13,11 @@ function EditableForm({ classNameProps, classNames, children, formProps, onCance
|
|
|
13
13
|
onEdit?.();
|
|
14
14
|
setStatus?.('EDITING');
|
|
15
15
|
}
|
|
16
|
-
return (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
return (_jsxs(Form, { ...formProps, classNames: { root: componentClassNames?.root }, children: [title ? (_jsx("header", { className: componentClassNames?.header, children: _jsx("legend", { className: componentClassNames?.title, children: title }) })) : null, _jsxs("div", { className: componentClassNames?.content, children: [children, _jsx("footer", { className: componentClassNames?.actions, children: _jsx(ActionList, { actions: status === 'EDITING'
|
|
17
|
+
? [
|
|
18
|
+
{ label: 'Cancel', onClick: setCancelled },
|
|
19
|
+
{ isSubmittable: true, label: 'Save' },
|
|
20
|
+
]
|
|
21
|
+
: [{ label: 'Edit', onClick: setEditing }] }) })] })] }));
|
|
22
22
|
}
|
|
23
23
|
export default EditableForm;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import { FormFieldProps } from '../FormField';
|
|
3
3
|
import { EditingStatus } from '../../interfaces';
|
|
4
4
|
export interface EditableFormFieldClassNames {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { isValidElement, useEffect, useRef } from 'react';
|
|
4
4
|
import FormField from '../FormField';
|
|
5
|
-
import {
|
|
5
|
+
import { useClassNames } from '../../../styles/context';
|
|
6
6
|
function getRenderedValue(value, renderValue) {
|
|
7
7
|
if (renderValue) {
|
|
8
8
|
if (typeof renderValue === 'function') {
|
|
@@ -19,7 +19,7 @@ function getRenderedValue(value, renderValue) {
|
|
|
19
19
|
return value ? String(value) : '-';
|
|
20
20
|
}
|
|
21
21
|
function EditableFormField({ classNameProps, classNames, renderValue, status, ...props }) {
|
|
22
|
-
const componentClassNames =
|
|
22
|
+
const componentClassNames = useClassNames('editableFormField', { props: classNameProps }, classNames);
|
|
23
23
|
const cachedValue = useRef(props.value);
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
if (status === 'CANCELLED') {
|
|
@@ -30,7 +30,7 @@ function EditableFormField({ classNameProps, classNames, renderValue, status, ..
|
|
|
30
30
|
}
|
|
31
31
|
}, [status]);
|
|
32
32
|
if (status === 'EDITING') {
|
|
33
|
-
return _jsx(FormField, { ...props });
|
|
33
|
+
return _jsx(FormField, { classNameProps: { ...classNameProps, isEditable: true }, ...props });
|
|
34
34
|
}
|
|
35
35
|
return (_jsxs("div", { className: componentClassNames?.root, children: [_jsx("div", { className: componentClassNames?.label, children: props.label }), _jsx("div", { className: componentClassNames?.field, children: getRenderedValue(props.value, renderValue) })] }));
|
|
36
36
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { EditableFormFieldComponentProps } from '../../interfaces';
|
|
2
2
|
import type { DropdownComponentProps } from '../Dropdown';
|
|
3
|
+
import type { TextAreaComponentProps } from '../TextArea';
|
|
3
4
|
import type { TextInputComponentProps } from '../TextInput';
|
|
4
5
|
export type EditableDropdownFormFieldProps<T> = EditableFormFieldComponentProps<T | null> & DropdownComponentProps<T>;
|
|
5
6
|
export declare function EditableDropdownFormField<T>(props: Readonly<EditableDropdownFormFieldProps<T>>): React.ReactElement;
|
|
7
|
+
export type EditableTextAreaFormFieldProps = EditableFormFieldComponentProps<string> & TextAreaComponentProps;
|
|
8
|
+
export declare function EditableTextAreaFormField(props: Readonly<EditableTextAreaFormFieldProps>): React.ReactElement;
|
|
6
9
|
export type EditableTextFormFieldProps = EditableFormFieldComponentProps<string> & TextInputComponentProps;
|
|
7
10
|
export declare function EditableTextFormField(props: Readonly<EditableTextFormFieldProps>): React.ReactElement;
|
|
@@ -3,6 +3,7 @@ import { useCallback } from 'react';
|
|
|
3
3
|
import extractEditableInputProps from '../../utility/extract-editable-input-props';
|
|
4
4
|
import Dropdown from '../Dropdown';
|
|
5
5
|
import EditableFormField from '../EditableFormField';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
6
7
|
import TextInput from '../TextInput';
|
|
7
8
|
export function EditableDropdownFormField(props) {
|
|
8
9
|
const { fieldProps, inputProps } = extractEditableInputProps(props);
|
|
@@ -13,6 +14,11 @@ export function EditableDropdownFormField(props) {
|
|
|
13
14
|
}, [inputProps]);
|
|
14
15
|
return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
|
|
15
16
|
}
|
|
17
|
+
export function EditableTextAreaFormField(props) {
|
|
18
|
+
const { fieldProps, inputProps } = extractEditableInputProps(props);
|
|
19
|
+
const renderInput = useCallback((renderProps) => (_jsx(TextArea, { ...renderProps, ...inputProps })), [inputProps]);
|
|
20
|
+
return _jsx(EditableFormField, { ...fieldProps, render: renderInput });
|
|
21
|
+
}
|
|
16
22
|
export function EditableTextFormField(props) {
|
|
17
23
|
const { fieldProps, inputProps } = extractEditableInputProps(props);
|
|
18
24
|
const renderInput = useCallback((renderProps) => (_jsx(TextInput, { ...renderProps, ...inputProps })), [inputProps]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
2
|
export interface FormClassNames {
|
|
3
3
|
root: string;
|
|
4
4
|
}
|
|
@@ -7,6 +7,7 @@ export interface FormProps extends ClassNameProps<FormClassNames> {
|
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
id?: string;
|
|
9
9
|
onSubmit?: React.FormEventHandler<HTMLFormElement>;
|
|
10
|
+
ref?: React.Ref<HTMLFormElement>;
|
|
10
11
|
}
|
|
11
|
-
declare function Form({ action, children, classNames, classNameProps, id, onSubmit, }: Readonly<FormProps>): React.ReactElement;
|
|
12
|
+
declare function Form({ action, children, classNames, classNameProps, id, onSubmit, ref, }: Readonly<FormProps>): React.ReactElement;
|
|
12
13
|
export default Form;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import tw from '../../../styles/tw';
|
|
5
|
-
function Form({ action, children, classNames, classNameProps, id, onSubmit, }) {
|
|
6
|
-
const componentClassNames =
|
|
7
|
-
return (_jsx("form", { action: action, className: tw(componentClassNames?.root), id: id, onSubmit: onSubmit, children: children }));
|
|
3
|
+
import { useClassNames } from '../../../styles/context';
|
|
4
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
5
|
+
function Form({ action, children, classNames, classNameProps, id, onSubmit, ref, }) {
|
|
6
|
+
const componentClassNames = useClassNames('form', { props: classNameProps }, classNames);
|
|
7
|
+
return (_jsx("form", { ref: ref, action: action, className: tw(componentClassNames?.root), id: id, onSubmit: onSubmit, children: children }));
|
|
8
8
|
}
|
|
9
9
|
export default Form;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import type { FormFieldClassNames } from '../FormField';
|
|
3
|
-
interface FormErrorProps extends ClassNameProps<FormFieldClassNames> {
|
|
3
|
+
export interface FormErrorProps extends ClassNameProps<FormFieldClassNames> {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
id: string;
|
|
6
6
|
isAssistive?: boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx } 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 FormError({ children, classNames, classNameProps, id, isAssistive, }) {
|
|
5
|
-
const componentClassNames =
|
|
6
|
+
const componentClassNames = useClassNames('formField', { props: classNameProps }, classNames);
|
|
6
7
|
return (_jsx("div", { className: tw(componentClassNames?.error, isAssistive ? 'sr-only' : null), id: `${id}_err`, children: children }));
|
|
7
8
|
}
|
|
8
9
|
export default FormError;
|