@sqrzro/ui 4.0.0-alpha.8 → 4.0.0-alpha.80
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 +8 -6
- package/dist/components/buttons/ActionButton/index.js +5 -29
- package/dist/components/buttons/Button/index.d.ts +7 -6
- package/dist/components/buttons/Button/index.js +9 -19
- package/dist/components/collections/Collection/index.d.ts +9 -5
- package/dist/components/collections/Collection/index.js +14 -12
- package/dist/components/collections/DataTable/index.d.ts +14 -0
- package/dist/components/collections/DataTable/index.js +14 -0
- package/dist/components/collections/DefinitionList/index.d.ts +13 -0
- package/dist/components/collections/DefinitionList/index.js +13 -0
- package/dist/components/collections/EmptyMessage/index.d.ts +2 -2
- 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 +3 -3
- package/dist/components/collections/List/index.d.ts +6 -3
- 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 -17
- package/dist/components/collections/ListItemSecondary/index.d.ts +5 -3
- package/dist/components/collections/ListItemSecondary/index.js +12 -8
- package/dist/components/collections/Pagination/index.d.ts +1 -1
- package/dist/components/collections/Pagination/index.js +7 -8
- 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 +3 -4
- 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 +12 -27
- 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/lang.js +1 -1
- package/dist/components/collections/utility/is-paginated.d.ts +1 -1
- 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/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/ContentLink/index.d.ts +4 -0
- package/dist/components/elements/ContentLink/index.js +7 -0
- package/dist/components/elements/InfoPanel/index.d.ts +13 -0
- package/dist/components/elements/InfoPanel/index.js +20 -0
- package/dist/components/{utility → elements}/Link/index.d.ts +3 -2
- package/dist/components/{utility → elements}/Link/index.js +10 -9
- package/dist/components/elements/Menu/index.d.ts +19 -0
- package/dist/components/elements/Menu/index.js +20 -0
- package/dist/components/elements/MenuItem/index.d.ts +9 -0
- package/dist/components/elements/MenuItem/index.js +14 -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 +35 -6
- package/dist/components/index.js +17 -3
- package/dist/components/modals/ConfirmModal/index.d.ts +6 -4
- package/dist/components/modals/ConfirmModal/index.js +4 -4
- 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 +5 -4
- 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 +6 -4
- 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 +66 -0
- package/dist/components/utility/CalendarDay/index.d.ts +11 -0
- package/dist/components/utility/CalendarDay/index.js +22 -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 +3 -3
- 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 +6 -3
- package/dist/filters/components/FilterBarClientComponent/index.d.ts +3 -5
- package/dist/filters/components/FilterBarClientComponent/index.js +4 -44
- 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 +3 -2
- package/dist/filters/components/FilterItem/index.js +4 -8
- package/dist/filters/components/FilterPanel/index.d.ts +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/filters/filters/Filter/index.d.ts +6 -5
- package/dist/filters/filters/Filter/index.js +9 -9
- package/dist/filters/filters/SearchFilter/index.d.ts +8 -3
- package/dist/filters/filters/SearchFilter/index.js +10 -10
- package/dist/filters/filters/interfaces.d.ts +1 -3
- package/dist/filters/index.d.ts +2 -1
- package/dist/filters/index.js +2 -1
- package/dist/filters/interfaces.d.ts +3 -3
- package/dist/filters/utility/get-quick-dates.d.ts +1 -1
- package/dist/filters/utility/render-value.js +5 -5
- package/dist/forms/components/Autocomplete/index.d.ts +2 -2
- package/dist/forms/components/Autocomplete/index.js +5 -5
- package/dist/forms/components/AutocompleteList/index.d.ts +7 -0
- package/dist/forms/components/AutocompleteList/index.js +15 -0
- package/dist/forms/components/BaseCalendarInput/index.d.ts +11 -0
- package/dist/forms/components/BaseCalendarInput/index.js +22 -0
- package/dist/forms/components/CSVInput/index.d.ts +11 -0
- package/dist/forms/components/CSVInput/index.js +32 -0
- package/dist/forms/components/CalendarInput/index.d.ts +6 -0
- package/dist/forms/components/CalendarInput/index.js +14 -0
- package/dist/forms/components/CheckboxInput/index.d.ts +12 -0
- package/dist/forms/components/CheckboxInput/index.js +15 -0
- package/dist/forms/components/ChkRad/index.d.ts +19 -0
- package/dist/forms/components/ChkRad/index.js +25 -0
- package/dist/forms/components/ColorInput/index.d.ts +16 -0
- package/dist/forms/components/ColorInput/index.js +14 -0
- package/dist/forms/components/Dropdown/index.d.ts +1 -1
- package/dist/forms/components/Dropdown/index.js +11 -10
- 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 +2 -2
- package/dist/forms/components/DropdownList/index.js +7 -11
- package/dist/forms/components/EditableForm/index.d.ts +7 -5
- package/dist/forms/components/EditableForm/index.js +19 -15
- 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 +23 -0
- package/dist/forms/components/EditableFormFields/index.js +78 -1
- package/dist/forms/components/Form/index.d.ts +5 -2
- package/dist/forms/components/Form/index.js +7 -6
- package/dist/forms/components/FormError/index.d.ts +2 -2
- package/dist/forms/components/FormError/index.js +7 -5
- package/dist/forms/components/FormField/index.d.ts +8 -6
- package/dist/forms/components/FormField/index.js +16 -8
- package/dist/forms/components/FormFields/index.d.ts +27 -2
- package/dist/forms/components/FormFields/index.js +55 -2
- package/dist/forms/components/FormLabel/index.d.ts +1 -1
- package/dist/forms/components/FormLabel/index.js +4 -3
- package/dist/forms/components/FormSubmit/index.d.ts +1 -1
- package/dist/forms/components/FormSubmit/index.js +1 -1
- package/dist/forms/components/ImageInput/index.d.ts +20 -0
- package/dist/forms/components/ImageInput/index.js +51 -0
- package/dist/forms/components/ImageInputPanel/index.d.ts +10 -0
- package/dist/forms/components/ImageInputPanel/index.js +34 -0
- package/dist/forms/components/ModalForm/index.d.ts +4 -3
- package/dist/forms/components/ModalForm/index.js +8 -7
- package/dist/forms/components/NumberInput/index.d.ts +1 -1
- 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 +2 -2
- package/dist/forms/components/PasswordInput/index.js +6 -6
- package/dist/forms/components/PointsInput/index.d.ts +5 -0
- package/dist/forms/components/{MoneyInput → PointsInput}/index.js +3 -3
- package/dist/forms/components/RangeCalendarInput/index.d.ts +6 -0
- package/dist/forms/components/RangeCalendarInput/index.js +14 -0
- package/dist/forms/components/StaticTextInput/index.d.ts +3 -3
- package/dist/forms/components/StaticTextInput/index.js +7 -8
- package/dist/forms/components/Switch/index.d.ts +10 -4
- package/dist/forms/components/Switch/index.js +7 -5
- 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 +5 -4
- package/dist/forms/hooks/useAutocomplete.d.ts +7 -6
- package/dist/forms/hooks/useAutocomplete.js +4 -4
- package/dist/forms/hooks/useDropdown.d.ts +5 -7
- package/dist/forms/hooks/useDropdown.js +5 -5
- package/dist/forms/hooks/useEditableDropdown.d.ts +4 -0
- package/dist/forms/hooks/useEditableDropdown.js +6 -0
- package/dist/forms/hooks/useEditableForm.d.ts +2 -1
- package/dist/forms/hooks/useEditableForm.js +21 -9
- package/dist/forms/hooks/useForm.d.ts +7 -14
- package/dist/forms/hooks/useForm.js +27 -28
- package/dist/forms/hooks/useModalForm.d.ts +2 -2
- package/dist/forms/hooks/useModalForm.js +10 -3
- package/dist/forms/index.d.ts +18 -7
- package/dist/forms/index.js +9 -3
- package/dist/forms/interfaces.d.ts +9 -1
- package/dist/forms/utility/extract-input-props.js +1 -0
- package/dist/forms/utility/format-date-value.d.ts +2 -0
- package/dist/forms/utility/format-date-value.js +13 -0
- package/dist/forms/utility/format-file-size.d.ts +2 -0
- package/dist/forms/utility/format-file-size.js +11 -0
- package/dist/forms/utility/preprocess-image.d.ts +9 -0
- package/dist/forms/utility/preprocess-image.js +61 -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 +14 -0
- package/dist/hooks/useServerAction.js +30 -0
- package/dist/hooks/useSuccess.d.ts +10 -0
- package/dist/hooks/useSuccess.js +24 -0
- package/dist/mail/Mail/index.d.ts +8 -0
- package/dist/mail/Mail/index.js +108 -0
- package/dist/mail/MailBlock/index.d.ts +5 -0
- package/dist/mail/MailBlock/index.js +5 -0
- package/dist/mail/MailButton/index.d.ts +8 -0
- package/dist/mail/MailButton/index.js +28 -0
- package/dist/mail/MailTable/index.d.ts +9 -0
- package/dist/mail/MailTable/index.js +7 -0
- package/dist/mail/index.d.ts +8 -0
- package/dist/mail/index.js +4 -0
- package/dist/mail/utility/convert-to-datauri.d.ts +2 -0
- package/dist/mail/utility/convert-to-datauri.js +37 -0
- package/dist/mail/utility/interfaces.d.ts +23 -0
- package/dist/mail/utility/mail-config.d.ts +4 -0
- package/dist/mail/utility/mail-config.js +42 -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 +6 -4
- 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 +97 -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 +29 -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/get-date-state.d.ts +8 -0
- package/dist/utility/get-date-state.js +63 -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/normalize-href.d.ts +2 -0
- package/dist/utility/normalize-href.js +8 -0
- package/package.json +37 -25
- 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 -15
- package/dist/components/utility/RootLayout/index.js +0 -14
- package/dist/forms/components/MoneyInput/index.d.ts +0 -5
- 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 → mail/utility}/interfaces.js +0 -0
- /package/dist/styles/{tw.d.ts → classnames/utility/tw.d.ts} +0 -0
- /package/dist/styles/{tw.js → classnames/utility/tw.js} +0 -0
|
@@ -1,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
|
-
import FilterClearButton from '
|
|
4
|
-
import TextInput from '../../../forms/components/TextInput';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
function SearchFilter({ onChange, value }) {
|
|
8
|
-
const
|
|
4
|
+
import FilterClearButton from '../../components/FilterClearButton/index.js';
|
|
5
|
+
import TextInput from '../../../forms/components/TextInput/index.js';
|
|
6
|
+
import tw from '../../../styles/classnames/utility/tw.js';
|
|
7
|
+
import { useClassNames, useIcon } from '../../../styles/context.js';
|
|
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
|
-
import { InputProps } from '../../forms/interfaces';
|
|
1
|
+
import { InputProps } from '../../forms/interfaces.js';
|
|
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DropdownObject } from '../forms/interfaces';
|
|
1
|
+
import type { DropdownObject } from '../forms/interfaces.js';
|
|
2
2
|
export type FilterType = 'assistive' | 'boolean' | 'calendar' | 'column' | 'date' | 'dropdown' | 'money' | 'multi' | 'range' | 'search' | 'sort' | 'switch';
|
|
3
3
|
export interface FilterConfig {
|
|
4
4
|
align?: 'left' | 'right';
|
|
@@ -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> {
|
|
@@ -7,7 +7,7 @@ function getNamesFromIDs(ids, data) {
|
|
|
7
7
|
const set = new Set(ids);
|
|
8
8
|
return data
|
|
9
9
|
.filter((item) => set.has(item.value))
|
|
10
|
-
.map((item) => item.$data?.label || item.label);
|
|
10
|
+
.map((item) => item.$data?.label || String(item.label));
|
|
11
11
|
}
|
|
12
12
|
const LENGTH_OF_YEAR = 4;
|
|
13
13
|
const PAD = 2;
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import { ClassNameProps } from '../../../styles/interfaces';
|
|
1
|
+
import { ClassNameProps } from '../../../styles/classnames/interfaces.js';
|
|
2
2
|
import type { DropdownObject, InputProps } from '../../interfaces';
|
|
3
3
|
import { DropdownClassNames, DropdownComponentProps } from '../Dropdown';
|
|
4
4
|
export interface AutocompleteComponentProps<T> extends DropdownComponentProps<T> {
|
|
@@ -7,5 +7,5 @@ export interface AutocompleteComponentProps<T> extends DropdownComponentProps<T>
|
|
|
7
7
|
selected?: DropdownObject<T> | null;
|
|
8
8
|
}
|
|
9
9
|
export type AutocompleteProps<T> = ClassNameProps<DropdownClassNames> & InputProps<T | null> & AutocompleteComponentProps<T>;
|
|
10
|
-
declare function Autocomplete<T>({ hasError, isDisabled,
|
|
10
|
+
declare function Autocomplete<T>({ hasError, isDisabled, name, onChange, onSearch, options, selected, placeholder, value, }: Readonly<AutocompleteProps<T>>): React.ReactElement;
|
|
11
11
|
export default Autocomplete;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
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';
|
|
4
|
+
import Popover from '../../../components/utility/Popover/index.js';
|
|
5
|
+
import useClickOutside from '../../../hooks/useClickOutside.js';
|
|
7
6
|
import StaticTextInput from '../StaticTextInput';
|
|
8
7
|
import TextInput from '../TextInput';
|
|
9
|
-
|
|
8
|
+
import AutocompleteList from '../AutocompleteList';
|
|
9
|
+
function Autocomplete({ hasError, isDisabled, name, onChange, onSearch, options, selected, placeholder, value, }) {
|
|
10
10
|
const inputRef = useRef(null);
|
|
11
11
|
const [search, setSearch] = useState('');
|
|
12
12
|
const [isOpen, setIsOpen, ref] = useClickOutside();
|
|
@@ -32,6 +32,6 @@ function Autocomplete({ hasError, isDisabled, isLoading, isOptional, name, onCha
|
|
|
32
32
|
inputRef.current?.focus();
|
|
33
33
|
}, 10);
|
|
34
34
|
}
|
|
35
|
-
return (_jsx("div", { ref: ref, className: "relative", children: selected ? (_jsx(StaticTextInput, { details: selected.details, hasError: hasError, isDisabled: isDisabled, isOptional:
|
|
35
|
+
return (_jsx("div", { ref: ref, className: "relative", children: selected ? (_jsx(StaticTextInput, { details: selected.details, hasError: hasError, isDisabled: isDisabled, isOptional: true, label: selected.label, name: name, onClear: 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(true), placeholder: "Start typing...", value: search }), _jsx(Popover, { align: "center", isOpen: isOpen && search.length >= 3, isScrollable: true, children: _jsx(AutocompleteList, { name: name, onChange: handleChange, options: options, search: search, value: value }) })] })) }));
|
|
36
36
|
}
|
|
37
37
|
export default Autocomplete;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DropdownObject, InputProps } from '../../interfaces';
|
|
2
|
+
interface AutocompleteListProps<T> extends InputProps<T | null> {
|
|
3
|
+
options?: DropdownObject<T>[];
|
|
4
|
+
search: string;
|
|
5
|
+
}
|
|
6
|
+
declare function AutocompleteList<T>({ name, onChange, options, search, value, }: AutocompleteListProps<T>): React.ReactElement | null;
|
|
7
|
+
export default AutocompleteList;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import DropdownList from '../DropdownList';
|
|
4
|
+
function AutocompleteList({ name, onChange, options, search, value, }) {
|
|
5
|
+
if (!options?.length) {
|
|
6
|
+
return (_jsx(DropdownList, { name: name, options: [
|
|
7
|
+
{
|
|
8
|
+
label: (_jsxs(Fragment, { children: ["No results found for ", _jsx("strong", { children: search })] })),
|
|
9
|
+
value: null,
|
|
10
|
+
},
|
|
11
|
+
] }));
|
|
12
|
+
}
|
|
13
|
+
return _jsx(DropdownList, { name: name, onChange: onChange, options: options, value: value });
|
|
14
|
+
}
|
|
15
|
+
export default AutocompleteList;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InputProps } from '../../interfaces';
|
|
2
|
+
export interface BaseCalendarInputComponentProps {
|
|
3
|
+
isOptional?: boolean;
|
|
4
|
+
isPanelOnly?: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface BaseCalendarInputProps extends InputProps<Date | [Date, Date] | null>, BaseCalendarInputComponentProps {
|
|
7
|
+
children: React.ReactElement;
|
|
8
|
+
onClear?: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare function BaseCalendarInput({ children, hasError, isDisabled, isOptional, isPanelOnly, name, onClear, value, }: BaseCalendarInputProps): React.ReactElement;
|
|
11
|
+
export default BaseCalendarInput;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import Popover from '../../../components/utility/Popover/index.js';
|
|
5
|
+
import usePopover from '../../../hooks/usePopover.js';
|
|
6
|
+
import formatDateValue from '../../utility/format-date-value';
|
|
7
|
+
import StaticTextInput from '../StaticTextInput';
|
|
8
|
+
function BaseCalendarInput({ children, hasError, isDisabled, isOptional, isPanelOnly, name, onClear, value, }) {
|
|
9
|
+
const [oldValue, setOldValue] = useState(value);
|
|
10
|
+
const { controlProps, ref, targetProps } = usePopover();
|
|
11
|
+
if (isPanelOnly) {
|
|
12
|
+
return children;
|
|
13
|
+
}
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if ((value && !oldValue) || (value && oldValue)) {
|
|
16
|
+
controlProps.onClick();
|
|
17
|
+
}
|
|
18
|
+
setOldValue(value);
|
|
19
|
+
}, [value]);
|
|
20
|
+
return (_jsxs("div", { ref: ref, className: "relative", children: [_jsx(StaticTextInput, { hasError: hasError, isDisabled: isDisabled, label: formatDateValue(value), name: name, isOptional: isOptional, onClear: onClear, onClick: controlProps.onClick, value: value?.toString() }), _jsx(Popover, { ...targetProps, align: "center", children: children })] }));
|
|
21
|
+
}
|
|
22
|
+
export default BaseCalendarInput;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InputProps } from '../../interfaces.js';
|
|
2
|
+
import type { ClassNameProps, HighlightableClassName } from '../../../styles/classnames/interfaces.js';
|
|
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.js';
|
|
6
|
+
import tw from '../../../styles/classnames/utility/tw.js';
|
|
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;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InputProps } from '../../interfaces';
|
|
2
|
+
import { BaseCalendarInputComponentProps } from '../BaseCalendarInput';
|
|
3
|
+
export type CalendarInputComponentProps = BaseCalendarInputComponentProps;
|
|
4
|
+
export type CalendarInputProps = InputProps<Date | null> & CalendarInputComponentProps;
|
|
5
|
+
declare function CalendarInput({ name, onChange, value, ...baseProps }: CalendarInputProps): React.ReactElement;
|
|
6
|
+
export default CalendarInput;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import Calendar from '../../../components/utility/Calendar/index.js';
|
|
4
|
+
import BaseCalendarInput from '../BaseCalendarInput';
|
|
5
|
+
function CalendarInput({ name, onChange, value, ...baseProps }) {
|
|
6
|
+
function handleChange(eventValue) {
|
|
7
|
+
onChange?.({ target: { name, value: eventValue } });
|
|
8
|
+
}
|
|
9
|
+
function handleClear() {
|
|
10
|
+
onChange?.({ target: { name, value: null } });
|
|
11
|
+
}
|
|
12
|
+
return (_jsx(BaseCalendarInput, { ...baseProps, name: name, onClear: handleClear, value: value, children: _jsx(Calendar, { onChange: handleChange, value: value }) }));
|
|
13
|
+
}
|
|
14
|
+
export default CalendarInput;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DropdownObject, InputProps } from '../../interfaces.js';
|
|
2
|
+
import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces.js';
|
|
3
|
+
export interface CheckboxInputClassNames {
|
|
4
|
+
root: ErrorableClassName;
|
|
5
|
+
item: ErrorableClassName;
|
|
6
|
+
}
|
|
7
|
+
export interface CheckboxInputComponentProps<T> {
|
|
8
|
+
options?: DropdownObject<T>[];
|
|
9
|
+
}
|
|
10
|
+
export type CheckboxInputProps<T> = ClassNameProps<CheckboxInputClassNames> & InputProps<T[]> & CheckboxInputComponentProps<T>;
|
|
11
|
+
declare function CheckboxInput<T>({ classNames, classNameProps, hasError, name, onChange, options, value, }: CheckboxInputProps<T>): React.ReactElement;
|
|
12
|
+
export default CheckboxInput;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { toggleArrayItem } from '@sqrzro/utility';
|
|
4
|
+
import { useClassNames } from '../../../styles/context.js';
|
|
5
|
+
import ChkRad from '../ChkRad';
|
|
6
|
+
function CheckboxInput({ classNames, classNameProps, hasError, name, onChange, options = [], value, }) {
|
|
7
|
+
const componentClassNames = useClassNames('checkboxInput', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
|
|
8
|
+
function handleChange(id) {
|
|
9
|
+
return () => {
|
|
10
|
+
onChange?.({ target: { name, value: toggleArrayItem(value || [], id) } });
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return (_jsx("ul", { className: componentClassNames?.root, role: "listbox", children: options.map((item) => (_jsx("li", { children: _jsx(ChkRad, { classNameProps: classNameProps, label: item.label, name: `${name}[]`, onChange: handleChange(item.value), value: value?.includes(item.value) ?? false }) }, String(item.value)))) }));
|
|
14
|
+
}
|
|
15
|
+
export default CheckboxInput;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InputProps } from '../../interfaces.js';
|
|
2
|
+
import { CheckableClassName, ClassNameProps } from '../../../styles/classnames/interfaces.js';
|
|
3
|
+
export interface ChkRadClassNames {
|
|
4
|
+
details: string;
|
|
5
|
+
icon: CheckableClassName;
|
|
6
|
+
label: string;
|
|
7
|
+
root: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ChkRadProps extends ClassNameProps<ChkRadClassNames>, InputProps<boolean> {
|
|
10
|
+
details?: React.ReactNode;
|
|
11
|
+
label: React.ReactNode;
|
|
12
|
+
type?: 'checkbox' | 'radio';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Either a checkbox or a radio button. The onChange event will return a string of the value of
|
|
16
|
+
* the checked item.
|
|
17
|
+
*/
|
|
18
|
+
declare function ChkRad({ classNames, classNameProps, details, id, isDisabled, isReadOnly, name, label, onChange, type, value, }: Readonly<ChkRadProps>): React.ReactElement;
|
|
19
|
+
export default ChkRad;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
import { useClassNames, useIcon } from '../../../styles/context.js';
|
|
5
|
+
import tw from '../../../styles/classnames/utility/tw.js';
|
|
6
|
+
import Assistive from '../../../components/utility/Assistive/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Either a checkbox or a radio button. The onChange event will return a string of the value of
|
|
9
|
+
* the checked item.
|
|
10
|
+
*/
|
|
11
|
+
function ChkRad({ classNames, classNameProps, details, id, isDisabled, isReadOnly, name, label, onChange, type = 'checkbox', value, }) {
|
|
12
|
+
const componentClassNames = useClassNames('chkrad', {
|
|
13
|
+
props: { ...classNameProps, isReadOnly: isReadOnly ?? false },
|
|
14
|
+
states: { isChecked: value ?? false },
|
|
15
|
+
}, classNames);
|
|
16
|
+
const CheckedIcon = useIcon('chkrad.checked');
|
|
17
|
+
const ref = useRef(null);
|
|
18
|
+
function handleChange(event) {
|
|
19
|
+
if (onChange) {
|
|
20
|
+
onChange({ target: { name, value: event.target.checked } });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return (_jsxs("label", { className: tw(componentClassNames?.root, isDisabled ? 'pointer-events-none opacity-30' : null), children: [_jsx(Assistive, { children: _jsx("input", { checked: Boolean(value), disabled: isDisabled, id: id || name, name: name, readOnly: isReadOnly, onChange: handleChange, type: type }) }), _jsx("span", { className: componentClassNames?.icon, children: CheckedIcon && value ? _jsx(CheckedIcon, {}) : null }), _jsxs("div", { ref: ref, className: tw(componentClassNames?.label), children: [label, details ? _jsx("div", { className: tw(componentClassNames?.details), children: details }) : null] })] }));
|
|
24
|
+
}
|
|
25
|
+
export default ChkRad;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InputProps } from '../../interfaces.js';
|
|
2
|
+
import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces.js';
|
|
3
|
+
export interface ColorInputClassNames {
|
|
4
|
+
root: ErrorableClassName;
|
|
5
|
+
input: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
label: string;
|
|
8
|
+
placeholder: string;
|
|
9
|
+
clear: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ColorInputComponentProps {
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
}
|
|
14
|
+
export type ColorInputProps = ClassNameProps<ColorInputClassNames> & InputProps<string | undefined, string> & ColorInputComponentProps;
|
|
15
|
+
declare function ColorInput({ classNames, classNameProps, hasError, name, onChange, placeholder, value, }: Readonly<ColorInputProps>): React.ReactElement;
|
|
16
|
+
export default ColorInput;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import Assistive from '../../../components/utility/Assistive/index.js';
|
|
4
|
+
import { useClassNames, useIcon } from '../../../styles/context.js';
|
|
5
|
+
import tw from '../../../styles/classnames/utility/tw.js';
|
|
6
|
+
function ColorInput({ classNames, classNameProps, hasError, name, onChange, placeholder, value, }) {
|
|
7
|
+
const componentClassNames = useClassNames('colorInput', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
|
|
8
|
+
const ClearIcon = useIcon('colorInput.clear');
|
|
9
|
+
function handleClear() {
|
|
10
|
+
onChange?.({ target: { name, value: '' } });
|
|
11
|
+
}
|
|
12
|
+
return (_jsxs("div", { className: tw('relative', componentClassNames?.root), children: [_jsx("input", { className: tw('absolute inset-0 h-full w-full cursor-pointer opacity-0', componentClassNames?.input), name: name, onChange: onChange, type: "color", value: value || '' }), _jsx("i", { className: tw(componentClassNames?.icon), style: { backgroundColor: value || 'transparent' } }), value ? (_jsx("span", { className: tw(componentClassNames?.label), children: value.toUpperCase() })) : (_jsx("span", { className: tw(componentClassNames?.placeholder), children: placeholder || 'Select...' })), _jsx("span", { className: "absolute bottom-0 right-0 top-0 flex w-0 items-center justify-end", children: value ? (_jsxs("button", { className: tw('flex-none', componentClassNames?.clear), onClick: handleClear, type: "button", children: [ClearIcon ? _jsx(ClearIcon, {}) : null, _jsx(Assistive, { children: "Clear" })] })) : null })] }));
|
|
13
|
+
}
|
|
14
|
+
export default ColorInput;
|
|
@@ -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.js';
|
|
2
2
|
import type { DropdownObject, InputProps } from '../../interfaces';
|
|
3
3
|
export interface DropdownClassNames {
|
|
4
4
|
root: ErrorableClassName & FocusableClassName;
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import Popover from '../../../components/utility/Popover';
|
|
4
|
-
import useClickOutside from '../../../hooks/useClickOutside';
|
|
5
|
-
import tw from '../../../styles/tw';
|
|
6
|
-
import {
|
|
3
|
+
import Popover from '../../../components/utility/Popover/index.js';
|
|
4
|
+
import useClickOutside from '../../../hooks/useClickOutside.js';
|
|
5
|
+
import tw from '../../../styles/classnames/utility/tw.js';
|
|
6
|
+
import { useClassNames, useIcon } from '../../../styles/context.js';
|
|
7
7
|
import DropdownList from '../DropdownList';
|
|
8
8
|
import StaticTextInput from '../StaticTextInput';
|
|
9
9
|
function findByValue(options, value) {
|
|
10
10
|
return options.find((item) => item.value === value);
|
|
11
11
|
}
|
|
12
12
|
export function renderLabel(options, value) {
|
|
13
|
-
return findByValue(options, value)?.label || '';
|
|
13
|
+
return String(findByValue(options, value)?.label || '');
|
|
14
14
|
}
|
|
15
15
|
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, 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 '../../interfaces.js';
|
|
2
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces.js';
|
|
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.js';
|
|
4
|
+
import tw from '../../../styles/classnames/utility/tw.js';
|
|
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
|
-
import type { DropdownObject, InputProps } from '
|
|
2
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
1
|
+
import type { DropdownObject, InputProps } from '../../interfaces.js';
|
|
2
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces.js';
|
|
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.js';
|
|
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,8 +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(
|
|
19
|
-
? componentClassNames?.item?.selected
|
|
20
|
-
: null), onClick: handleChange(item), tabIndex: -1, type: "button", children: [_jsx("span", { className: tw('whitespace-nowrap' /*componentClassNames?.label*/), children: item.label }), item.details ? (_jsx("small", { className: tw(componentClassNames?.details), children: item.details })) : null] }) }, index))) }));
|
|
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))) }));
|
|
21
17
|
}
|
|
22
18
|
export default DropdownList;
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
-
import type {
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces.js';
|
|
2
|
+
import type { SimpleActionObject } from '../../../utility/interfaces.js';
|
|
3
3
|
import type { EditingStatus } from '../../interfaces';
|
|
4
4
|
import type { FormProps } from '../Form';
|
|
5
5
|
export interface EditableFormClassNames {
|
|
6
|
-
actions: string;
|
|
7
6
|
root: string;
|
|
7
|
+
errors: string;
|
|
8
|
+
actions: string;
|
|
8
9
|
header: string;
|
|
9
10
|
title: string;
|
|
10
11
|
description: string;
|
|
11
12
|
content: string;
|
|
12
13
|
}
|
|
13
14
|
export interface EditableFormProps extends ClassNameProps<EditableFormClassNames> {
|
|
14
|
-
actions?:
|
|
15
|
+
actions?: SimpleActionObject[] | false;
|
|
15
16
|
children: React.ReactNode;
|
|
16
17
|
formProps: Omit<FormProps, 'children'>;
|
|
18
|
+
isEditable?: boolean;
|
|
17
19
|
onCancel?: () => void;
|
|
18
20
|
onEdit?: () => void;
|
|
19
21
|
setStatus?: (status: EditingStatus | null) => void;
|
|
20
22
|
status?: EditingStatus | null;
|
|
21
23
|
title?: string;
|
|
22
24
|
}
|
|
23
|
-
declare function EditableForm({ classNameProps, classNames, children, formProps, onCancel, onEdit, setStatus, status, title, }: Readonly<EditableFormProps>): React.ReactElement;
|
|
25
|
+
declare function EditableForm({ classNameProps, classNames, children, formProps, isEditable, onCancel, onEdit, setStatus, status, title, }: Readonly<EditableFormProps>): React.ReactElement;
|
|
24
26
|
export default EditableForm;
|
|
@@ -1,23 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import ActionList from '../../../components/utility/ActionList';
|
|
3
|
-
import {
|
|
4
|
-
import tw from '../../../styles/tw';
|
|
3
|
+
import ActionList from '../../../components/utility/ActionList/index.js';
|
|
4
|
+
import { useClassNames } from '../../../styles/context.js';
|
|
5
5
|
import Form from '../Form';
|
|
6
|
-
function EditableForm({ classNameProps, classNames, children, formProps, onCancel, onEdit, setStatus, status, title, }) {
|
|
7
|
-
const componentClassNames =
|
|
6
|
+
function EditableForm({ classNameProps, classNames, children, formProps, isEditable = true, onCancel, onEdit, setStatus, status, title, }) {
|
|
7
|
+
const componentClassNames = useClassNames('editableForm', { props: { ...classNameProps, hasTitle: Boolean(title), isEditable } }, classNames);
|
|
8
8
|
function setCancelled() {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if (isEditable) {
|
|
10
|
+
onCancel?.();
|
|
11
|
+
setStatus?.('CANCELLED');
|
|
12
|
+
}
|
|
11
13
|
}
|
|
12
14
|
function setEditing() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
if (isEditable) {
|
|
16
|
+
onEdit?.();
|
|
17
|
+
setStatus?.('EDITING');
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
|
-
return (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
return (_jsxs(Form, { ...formProps, classNames: { root: componentClassNames?.root, errors: componentClassNames?.errors }, children: [title ? (_jsx("header", { className: componentClassNames?.header, children: _jsx("legend", { className: componentClassNames?.title, children: title }) })) : null, _jsxs("div", { className: componentClassNames?.content, children: [children, isEditable ? (_jsx("footer", { className: componentClassNames?.actions, children: _jsx(ActionList, { actions: status === 'EDITING'
|
|
21
|
+
? [
|
|
22
|
+
{ label: 'Cancel', onClick: setCancelled },
|
|
23
|
+
{ isSubmittable: true, label: 'Save' },
|
|
24
|
+
]
|
|
25
|
+
: [{ label: 'Edit', onClick: setEditing }] }) })) : null] })] }));
|
|
22
26
|
}
|
|
23
27
|
export default EditableForm;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces.js';
|
|
2
2
|
import { FormFieldProps } from '../FormField';
|
|
3
3
|
import { EditingStatus } from '../../interfaces';
|
|
4
4
|
export interface EditableFormFieldClassNames {
|