@sqrzro/ui 4.0.0-alpha.6 → 4.0.0-alpha.60
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 +3 -27
- 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 +7 -3
- package/dist/components/collections/Collection/index.js +9 -7
- 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 +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 -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 +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 +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 +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/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/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/ContentLink/index.d.ts +4 -0
- package/dist/components/elements/ContentLink/index.js +7 -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 +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 +17 -0
- package/dist/components/elements/MenuItem/index.d.ts +9 -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 +35 -6
- package/dist/components/index.js +17 -3
- 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 +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 +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 +2 -2
- 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 +3 -3
- 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/ColorInput/index.d.ts +16 -0
- package/dist/forms/components/ColorInput/index.js +13 -0
- package/dist/forms/components/Dropdown/index.d.ts +1 -1
- package/dist/forms/components/Dropdown/index.js +9 -8
- 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 -11
- 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 +6 -0
- package/dist/forms/components/EditableFormFields/index.js +22 -1
- package/dist/forms/components/Form/index.d.ts +4 -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 +7 -5
- package/dist/forms/components/FormField/index.js +15 -7
- package/dist/forms/components/FormFields/index.d.ts +19 -2
- package/dist/forms/components/FormFields/index.js +38 -2
- 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.d.ts +3 -2
- package/dist/forms/components/ModalForm/index.js +4 -3
- 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 +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/{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 +2 -2
- package/dist/forms/components/StaticTextInput/index.js +6 -7
- package/dist/forms/components/Switch/index.d.ts +9 -3
- 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 +1 -1
- package/dist/forms/components/TextInput/index.js +5 -4
- package/dist/forms/hooks/useAutocomplete.d.ts +8 -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.js +8 -1
- package/dist/forms/hooks/useForm.d.ts +6 -7
- package/dist/forms/hooks/useForm.js +25 -27
- package/dist/forms/hooks/useModalForm.d.ts +2 -2
- package/dist/forms/hooks/useModalForm.js +8 -1
- package/dist/forms/index.d.ts +22 -6
- package/dist/forms/index.js +9 -4
- package/dist/forms/interfaces.d.ts +1 -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/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/mail/Mail/index.d.ts +8 -0
- package/dist/mail/Mail/index.js +106 -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 +16 -0
- package/dist/mail/utility/get-mail-config.d.ts +4 -0
- package/dist/mail/utility/get-mail-config.js +34 -0
- package/dist/mail/utility/interfaces.d.ts +23 -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 +91 -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 +21 -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/package.json +31 -19
- 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/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,9 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import tw from '../../../styles/tw';
|
|
3
|
+
import { useClassNames } from '../../../styles/context';
|
|
4
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
4
5
|
import Assistive from '../Assistive';
|
|
5
6
|
function Loader({ classNameProps, classNames }) {
|
|
6
|
-
const componentClassNames =
|
|
7
|
-
return (_jsxs("div", { className: tw(componentClassNames?.root
|
|
7
|
+
const componentClassNames = useClassNames('loader', { props: classNameProps }, classNames);
|
|
8
|
+
return (_jsxs("div", { className: tw(componentClassNames?.root), children: [_jsx("div", { className: tw(componentClassNames?.inner) }), _jsx(Assistive, { children: "Loading..." })] }));
|
|
8
9
|
}
|
|
9
10
|
export default Loader;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import tw from '../../../styles/tw';
|
|
4
|
+
import { useClassNames } from '../../../styles/context';
|
|
5
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
6
6
|
const HORIZONTAL_THRESHOLD = 40;
|
|
7
7
|
const VERTICAL_THRESHOLD = 40;
|
|
8
8
|
function getPositionStyles(align = 'left', vAlign = 'top') {
|
|
@@ -22,7 +22,7 @@ function getPositionStyles(align = 'left', vAlign = 'top') {
|
|
|
22
22
|
: 'left-1/2 -translate-x-1/2 origin-top top-full';
|
|
23
23
|
}
|
|
24
24
|
function Popover({ align: initialAlign = 'left', children, classNames, classNameProps, isOpen, isScrollable, vAlign: initialVAlign = 'bottom', }) {
|
|
25
|
-
const componentClassNames =
|
|
25
|
+
const componentClassNames = useClassNames('popover', { props: classNameProps, states: { isFocused: isOpen ?? false } }, classNames);
|
|
26
26
|
const [align, setAlign] = useState(initialAlign);
|
|
27
27
|
const [vAlign, setVAlign] = useState(initialVAlign);
|
|
28
28
|
const ref = useRef(null);
|
|
@@ -36,7 +36,7 @@ function Popover({ align: initialAlign = 'left', children, classNames, className
|
|
|
36
36
|
shadowRef.current.style.height = `${ref.current?.offsetHeight}px`;
|
|
37
37
|
shadowRef.current.style.width = `${ref.current?.offsetWidth}px`;
|
|
38
38
|
shadowRef.current.style.pointerEvents = 'none';
|
|
39
|
-
ref.current?.parentElement?.appendChild(shadowRef.current);
|
|
39
|
+
// ref.current?.parentElement?.appendChild(shadowRef.current);
|
|
40
40
|
}
|
|
41
41
|
function handleResize() {
|
|
42
42
|
const rect = shadowRef.current?.getBoundingClientRect();
|
|
@@ -66,6 +66,6 @@ function Popover({ align: initialAlign = 'left', children, classNames, className
|
|
|
66
66
|
window.removeEventListener('scroll', handleResize);
|
|
67
67
|
};
|
|
68
68
|
}, []);
|
|
69
|
-
return (_jsx("div", { ref: ref, className: tw('absolute', getPositionStyles(align, vAlign), componentClassNames?.root
|
|
69
|
+
return (_jsx("div", { ref: ref, className: tw('absolute', getPositionStyles(align, vAlign), componentClassNames?.root), style: { display: isOpen ? 'block' : 'none' }, children: isScrollable ? (_jsx("div", { className: componentClassNames?.scroll, children: children })) : (children) }));
|
|
70
70
|
}
|
|
71
71
|
export default Popover;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps, StylableClassName } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps, StylableClassName } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import type { StyleVariant } from '../../../utility/interfaces';
|
|
3
3
|
export interface ToastClassNames {
|
|
4
4
|
root: StylableClassName;
|
|
@@ -7,5 +7,5 @@ export interface ToastProps extends ClassNameProps<ToastClassNames> {
|
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
variant?: StyleVariant | null;
|
|
9
9
|
}
|
|
10
|
-
declare function Toast({ children, classNames, classNameProps, }: Readonly<ToastProps>): React.ReactElement | null;
|
|
10
|
+
declare function Toast({ children, classNames, classNameProps, variant, }: Readonly<ToastProps>): React.ReactElement | null;
|
|
11
11
|
export default Toast;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { useClassNames } from '../../../styles/context';
|
|
4
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
5
|
+
import applyVariants from '../../../styles/classnames/utility/apply-variants';
|
|
6
|
+
function Toast({ children, classNames, classNameProps, variant, }) {
|
|
7
|
+
const componentClassNames = useClassNames('toast', { props: { ...classNameProps, ...applyVariants(variant) } }, classNames);
|
|
6
8
|
if (!children) {
|
|
7
9
|
return null;
|
|
8
10
|
}
|
|
9
|
-
return _jsx("dialog", { open: true, children: children });
|
|
11
|
+
return (_jsx("dialog", { className: tw('pointer-events-none fixed z-50', componentClassNames?.root), open: true, children: children }));
|
|
10
12
|
}
|
|
11
13
|
export default Toast;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/no-multi-comp */
|
|
2
2
|
'use client';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
4
|
+
import { Suspense, useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { usePathname } from 'next/navigation';
|
|
6
6
|
import Toast from '../Toast';
|
|
7
7
|
const TOAST_DURATION = 5000;
|
|
@@ -46,10 +46,10 @@ function ToasterComponent({ channel, duration, render = Toast, }) {
|
|
|
46
46
|
useEffect(() => {
|
|
47
47
|
hideToast();
|
|
48
48
|
}, [pathname]);
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
return render({
|
|
50
|
+
children: message,
|
|
51
|
+
variant,
|
|
52
|
+
});
|
|
53
53
|
}
|
|
54
54
|
function Toaster(props) {
|
|
55
55
|
return (_jsx(Suspense, { children: _jsx(ToasterComponent, { ...props }) }));
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { TableColumnObject } from '../../../components/collections/interfaces';
|
|
2
|
+
import { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
3
|
import type { FilterMap } from '../../interfaces';
|
|
3
|
-
export
|
|
4
|
-
|
|
4
|
+
export interface FilterBarClassNames {
|
|
5
|
+
root: string;
|
|
6
|
+
}
|
|
7
|
+
interface FilterBarProps<T> extends ClassNameProps<FilterBarClassNames> {
|
|
5
8
|
columns?: TableColumnObject[];
|
|
6
9
|
map?: FilterMap<T>;
|
|
7
10
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { TableColumnObject } from '../../../components/collections/interfaces';
|
|
2
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
3
3
|
import type { ClientFilterMap } from '../../interfaces';
|
|
4
|
-
|
|
5
|
-
root: string;
|
|
6
|
-
}
|
|
4
|
+
import type { FilterBarClassNames } from '../FilterBar';
|
|
7
5
|
interface FilterBarClientComponentProps<T> extends ClassNameProps<FilterBarClassNames> {
|
|
8
6
|
columns?: TableColumnObject[];
|
|
9
7
|
map?: ClientFilterMap<T>;
|
|
@@ -5,17 +5,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
// import type { InputEvent } from '@sqrzro/interfaces';
|
|
6
6
|
// import { getEntries } from '@sqrzro/utility';
|
|
7
7
|
// import { useRouter } from 'next/navigation';
|
|
8
|
-
// import {
|
|
8
|
+
// import { useClassNames } from '../../../styles/config';
|
|
9
9
|
// import type { TableColumnObject } from '../../../tables/TableClientComponent';
|
|
10
10
|
// import type { ClassNameProps } from '../../../utility/interfaces';
|
|
11
11
|
import { getEntries } from '@sqrzro/utility';
|
|
12
12
|
import useFilters from '../../../filters/hooks/useFilters';
|
|
13
|
-
import {
|
|
13
|
+
import { useClassNames } from '../../../styles/context';
|
|
14
14
|
import SearchFilter from '../../filters/SearchFilter';
|
|
15
15
|
import FilterItem from '../FilterItem';
|
|
16
16
|
const FILTERED_TYPES = ['assistive', 'search'];
|
|
17
17
|
function FilterBarClientComponent({ classNames, classNameProps, columns, map, }) {
|
|
18
|
-
const componentClassNames =
|
|
18
|
+
const componentClassNames = useClassNames('filterBar', { props: classNameProps }, classNames);
|
|
19
19
|
const [filters, setFilter] = useFilters();
|
|
20
20
|
const mapArray = map ? getEntries(map) : [];
|
|
21
21
|
const hasSearch = mapArray.some(([, item]) => item?.type === 'search');
|
|
@@ -24,45 +24,5 @@ function FilterBarClientComponent({ classNames, classNameProps, columns, map, })
|
|
|
24
24
|
setFilter(event.target.name, event.target.value);
|
|
25
25
|
}
|
|
26
26
|
return (_jsxs("ul", { className: componentClassNames?.root, children: [hasSearch ? (_jsx("li", { className: "relative", children: _jsx(SearchFilter, { onChange: handleChange, value: filters.get('search') || '' }) })) : null, filteredArray.map(([name, props]) => (_jsx("li", { className: "relative", children: _jsx(FilterItem, { name: String(name), onChange: handleChange, value: filters.get(String(name)) || '', ...props }, String(name)) }, String(name))))] }));
|
|
27
|
-
// const componentClassNames = classNames || getClassNames('filterBar')?.(classNameProps);
|
|
28
|
-
// const router = useRouter();
|
|
29
|
-
// const [filters, setFilter] = useFilters();
|
|
30
|
-
// const mapArray = map ? getEntries(map) : [];
|
|
31
|
-
// const hasSearch = mapArray.some(([, item]) => item.type === 'search');
|
|
32
|
-
// const filteredArray = mapArray.filter(([, item]) => !FILTERED_TYPES.includes(item.type));
|
|
33
|
-
// function handleChange(event: InputEvent<string>): void {
|
|
34
|
-
// setFilter(event.target.name, event.target.value);
|
|
35
|
-
// router.refresh();
|
|
36
|
-
// }
|
|
37
|
-
// return (
|
|
38
|
-
// <ul className={componentClassNames?.root}>
|
|
39
|
-
// {hasSearch ? (
|
|
40
|
-
// <li className="relative">
|
|
41
|
-
// <SearchFilter onChange={handleChange} value={filters.get('search') || ''} />
|
|
42
|
-
// </li>
|
|
43
|
-
// ) : null}
|
|
44
|
-
// {filteredArray.map(([name, props]) => (
|
|
45
|
-
// <li key={String(name)} className="relative">
|
|
46
|
-
// <FilterItem
|
|
47
|
-
// key={String(name)}
|
|
48
|
-
// name={String(name)}
|
|
49
|
-
// onChange={handleChange}
|
|
50
|
-
// value={filters.get(String(name)) || ''}
|
|
51
|
-
// {...props}
|
|
52
|
-
// />
|
|
53
|
-
// </li>
|
|
54
|
-
// ))}
|
|
55
|
-
// {columns?.length ? (
|
|
56
|
-
// <Fragment>
|
|
57
|
-
// <li className="relative ml-auto">
|
|
58
|
-
// <ColumnFilter columns={columns} filters={filters} onChange={handleChange} />
|
|
59
|
-
// </li>
|
|
60
|
-
// <li className="relative">
|
|
61
|
-
// <SortFilter columns={columns} filters={filters} onChange={handleChange} />
|
|
62
|
-
// </li>
|
|
63
|
-
// </Fragment>
|
|
64
|
-
// ) : null}
|
|
65
|
-
// </ul>
|
|
66
|
-
// );
|
|
67
27
|
}
|
|
68
28
|
export default FilterBarClientComponent;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
export interface FilterClearButtonClassNames {
|
|
3
|
+
root: string;
|
|
4
|
+
icon: string;
|
|
5
|
+
}
|
|
6
|
+
interface FilterClearButtonProps extends ClassNameProps<FilterClearButtonClassNames> {
|
|
2
7
|
onClick: () => void;
|
|
3
8
|
}
|
|
4
|
-
declare function FilterClearButton({ onClick }:
|
|
9
|
+
declare function FilterClearButton({ classNameProps, classNames, onClick, }: FilterClearButtonProps): React.ReactElement;
|
|
5
10
|
export default FilterClearButton;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment } from 'react';
|
|
4
|
+
import { useClassNames, useIcon } from '../../../styles/context';
|
|
5
|
+
function FilterClearButton({ classNameProps, classNames, onClick, }) {
|
|
6
|
+
const componentClassNames = useClassNames('filterClear', { props: classNameProps }, classNames);
|
|
7
|
+
const Icon = useIcon('filter.clear');
|
|
8
|
+
return (_jsx("button", { className: componentClassNames?.root, onClick: onClick, type: "button", children: Icon ? (_jsxs(Fragment, { children: [_jsx("span", { className: componentClassNames?.icon, children: _jsx(Icon, {}) }), _jsx("span", { className: "sr-only", children: "Clear" })] })) : ('Clear') }));
|
|
5
9
|
}
|
|
6
10
|
export default FilterClearButton;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClassNameProps } from '../../../styles/interfaces';
|
|
1
|
+
import { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import type { FilterItemClassNames } from '../FilterItem';
|
|
3
3
|
interface FilterControlProps extends ClassNameProps<FilterItemClassNames> {
|
|
4
4
|
children: React.ReactNode;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
// import FilterClearButton from '../FilterClearButton';
|
|
3
|
-
import {
|
|
4
|
-
import tw from '../../../styles/tw';
|
|
4
|
+
import { useClassNames } from '../../../styles/context';
|
|
5
|
+
import tw from '../../../styles/classnames/utility/tw';
|
|
5
6
|
import FilterClearButton from '../FilterClearButton';
|
|
6
7
|
function FilterControl({ classNameProps, classNames, children, isDisabled, isFocused, isHighlighted, onClear, onClick, }) {
|
|
7
|
-
const componentClassNames =
|
|
8
|
-
|
|
8
|
+
const componentClassNames = useClassNames('filterItem', {
|
|
9
|
+
props: {
|
|
10
|
+
...classNameProps,
|
|
11
|
+
isFocused: isFocused ?? false,
|
|
12
|
+
isHighlighted: isHighlighted ?? false,
|
|
13
|
+
},
|
|
14
|
+
}, classNames);
|
|
15
|
+
return (_jsxs("div", { className: tw(componentClassNames?.root, isDisabled ? 'pointer-events-none opacity-30' : null), children: [children, isFocused && onClear ? _jsx(FilterClearButton, { onClick: onClear }) : null, onClick ? (_jsx("button", { className: "absolute -inset-1 z-10 select-none text-transparent", disabled: isDisabled, onClick: onClick, type: "button", children: "Edit" })) : null] }));
|
|
9
16
|
}
|
|
10
17
|
export default FilterControl;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { InputProps } from '../../../forms/interfaces';
|
|
2
|
-
import { ClassNameProps, FocusableClassName, HighlightableClassName } from '../../../styles/interfaces';
|
|
2
|
+
import { ClassNameProps, FocusableClassName, HighlightableClassName } from '../../../styles/classnames/interfaces';
|
|
3
3
|
import { ClientFilterObject, FilterType } from '../../interfaces';
|
|
4
4
|
export interface FilterItemClassNames {
|
|
5
5
|
root: FocusableClassName & HighlightableClassName;
|
|
6
|
+
label: string;
|
|
6
7
|
value: string;
|
|
7
8
|
}
|
|
8
9
|
interface FilterItemProps<F extends FilterType> extends ClassNameProps<FilterItemClassNames>, ClientFilterObject<F>, InputProps<string> {
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
import useClickOutside from '../../../hooks/useClickOutside';
|
|
5
|
-
import {
|
|
5
|
+
import { useClassNames } from '../../../styles/context';
|
|
6
6
|
import renderValue from '../../utility/render-value';
|
|
7
7
|
import FilterControl from '../FilterControl';
|
|
8
8
|
import FilterPanel from '../FilterPanel';
|
|
9
9
|
function FilterItem({ align, classNameProps, classNames, config, icon, isDisabled, label, name, onChange, title, type, value, }) {
|
|
10
|
-
const componentClassNames =
|
|
10
|
+
const componentClassNames = useClassNames('filterItem', { props: classNameProps }, classNames);
|
|
11
11
|
const [isOpen, setIsOpen, node] = useClickOutside();
|
|
12
12
|
// const { dynamicConfig } = useDynamicData(config);
|
|
13
13
|
const [pendingValue, setPendingValue] = useState(value);
|
|
@@ -34,10 +34,6 @@ function FilterItem({ align, classNameProps, classNames, config, icon, isDisable
|
|
|
34
34
|
// if (type === 'switch') {
|
|
35
35
|
// return <SwitchFilter label={label} name={name} onChange={onChange} value={value || ''} />;
|
|
36
36
|
// }
|
|
37
|
-
return (_jsxs("div", { ref: node, children: [_jsxs(FilterControl
|
|
38
|
-
// isDisabled={isDisabled || (config?.data && config.data.length === 0)}
|
|
39
|
-
, {
|
|
40
|
-
// isDisabled={isDisabled || (config?.data && config.data.length === 0)}
|
|
41
|
-
isFocused: Boolean(value), isHighlighted: isOpen, onClear: handleClear, onClick: toggleIsOpen, children: [_jsx("p", { children: label }), value ? (_jsx("p", { className: componentClassNames?.value, children: renderValue(value, config) })) : null] }), _jsx(FilterPanel, { align: align, config: config, icon: icon, isOpen: isOpen, label: label, name: name, onApply: handleApply, onChange: handleChange, title: title, type: type, value: pendingValue })] }));
|
|
37
|
+
return (_jsxs("div", { ref: node, children: [_jsxs(FilterControl, { isDisabled: isDisabled || (config && 'options' in config && config.options?.length === 0), isFocused: Boolean(value), isHighlighted: isOpen, onClear: handleClear, onClick: toggleIsOpen, children: [_jsx("p", { className: componentClassNames?.label, children: label }), value ? (_jsx("p", { className: componentClassNames?.value, children: renderValue(value, config) })) : null] }), _jsx(FilterPanel, { align: align, config: config, icon: icon, isOpen: isOpen, label: label, name: name, onApply: handleApply, onChange: handleChange, title: title, type: type, value: pendingValue })] }));
|
|
42
38
|
}
|
|
43
39
|
export default FilterItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InputProps } from '../../../forms/interfaces';
|
|
2
|
-
import { SizableClassName } from '../../../styles/interfaces';
|
|
2
|
+
import { SizableClassName } from '../../../styles/classnames/interfaces';
|
|
3
3
|
import type { ClientFilterObject, FilterType } from '../../interfaces';
|
|
4
4
|
export interface FilterPanelClassNames {
|
|
5
5
|
content: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FilterConfig, FilterConfigWithBooleanData, FilterConfigWithData, FilterObject, FilterType } from '
|
|
1
|
+
import type { FilterConfig, FilterConfigWithBooleanData, FilterConfigWithData, FilterObject, FilterType } from './interfaces';
|
|
2
2
|
interface FilterReturn {
|
|
3
3
|
$dropdown: <T>(config: FilterConfigWithData, transformer: (value: string | null) => T) => FilterObject<T, 'dropdown'>;
|
|
4
4
|
$multi: <T>(config: FilterConfigWithData, transformer: (value: string | null) => T | null) => FilterObject<T[] | null, 'multi'>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { filterNull } from '@sqrzro/utility';
|
|
2
|
-
import getQuickDates from './get-quick-dates';
|
|
3
|
-
import { transformToBoolean } from './transform-boolean';
|
|
4
|
-
import { transformToDate } from './transform-date';
|
|
5
|
-
import { transformToMulti } from './transform-multi';
|
|
2
|
+
import getQuickDates from './utility/get-quick-dates';
|
|
3
|
+
import { transformToBoolean } from './utility/transform-boolean';
|
|
4
|
+
import { transformToDate } from './utility/transform-date';
|
|
5
|
+
import { transformToMulti } from './utility/transform-multi';
|
|
6
6
|
function defaultTransformer(value) {
|
|
7
7
|
return value ? value : null;
|
|
8
8
|
}
|
|
@@ -37,9 +37,9 @@ function filter() {
|
|
|
37
37
|
return {
|
|
38
38
|
config: {
|
|
39
39
|
...config,
|
|
40
|
-
|
|
41
|
-
{ label: config?.
|
|
42
|
-
{ label: config?.
|
|
40
|
+
options: [
|
|
41
|
+
{ label: config?.options?.[0] || 'No', value: '0' },
|
|
42
|
+
{ label: config?.options?.[1] || 'Yes', value: '1' },
|
|
43
43
|
],
|
|
44
44
|
},
|
|
45
45
|
label,
|
|
@@ -67,7 +67,7 @@ function filter() {
|
|
|
67
67
|
return {
|
|
68
68
|
config: {
|
|
69
69
|
...config,
|
|
70
|
-
|
|
70
|
+
options: [...getQuickDates(), { label: 'Custom...', value: 'custom' }],
|
|
71
71
|
},
|
|
72
72
|
label,
|
|
73
73
|
transformer: transformToDate,
|
|
@@ -5,6 +5,6 @@ function BooleanFilter({ 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 BooleanFilter;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import RangeCalendarInput from '../../../forms/components/RangeCalendarInput';
|
|
3
|
+
import { transformFromDate, transformToDate } from '../../utility/transform-date';
|
|
2
4
|
import Filter from '../Filter';
|
|
3
|
-
import { transformFromDate } from '../../utility/transform-date';
|
|
4
5
|
function CalendarFilter({ name, onChange, value, ...filterBarProps }) {
|
|
5
6
|
function handleChange(event) {
|
|
6
7
|
onChange?.({ target: { name, value: transformFromDate(event.target.value) } });
|
|
7
8
|
}
|
|
8
|
-
return (_jsx(Filter, { ...filterBarProps, size: "
|
|
9
|
+
return (_jsx(Filter, { ...filterBarProps, isDisabled: !value, size: "large", children: _jsx(RangeCalendarInput, { name: name, onChange: handleChange, value: transformToDate(value) }) }));
|
|
9
10
|
}
|
|
10
11
|
export default CalendarFilter;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { FilterComponentProps } from '../interfaces';
|
|
2
|
-
declare function DateFilter({ isOpen, onChange, ...filterBarProps }: Readonly<FilterComponentProps<'date'>>): React.ReactElement;
|
|
2
|
+
declare function DateFilter({ isOpen, onChange, value, ...filterBarProps }: Readonly<FilterComponentProps<'date'>>): React.ReactElement;
|
|
3
3
|
export default DateFilter;
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Fragment, useEffect, useState } from 'react';
|
|
4
|
+
import getQuickDates from '../../utility/get-quick-dates';
|
|
4
5
|
import CalendarFilter from '../CalendarFilter';
|
|
5
6
|
import DropdownFilter from '../DropdownFilter';
|
|
6
|
-
function DateFilter({ isOpen, onChange, ...filterBarProps }) {
|
|
7
|
+
function DateFilter({ isOpen, onChange, value, ...filterBarProps }) {
|
|
7
8
|
const [panel, setPanel] = useState('quick');
|
|
8
9
|
function handleDropdownChange(event) {
|
|
9
|
-
onChange?.(event);
|
|
10
10
|
if (event.target.value === 'custom') {
|
|
11
11
|
setPanel('calendar');
|
|
12
12
|
}
|
|
13
|
+
else {
|
|
14
|
+
onChange?.(event);
|
|
15
|
+
}
|
|
13
16
|
}
|
|
14
17
|
useEffect(() => {
|
|
15
18
|
if (isOpen) {
|
|
16
|
-
setPanel(
|
|
19
|
+
setPanel(!value || getQuickDates().some((date) => date.value === value)
|
|
20
|
+
? 'quick'
|
|
21
|
+
: 'calendar');
|
|
17
22
|
}
|
|
18
23
|
}, [isOpen]);
|
|
19
|
-
return (_jsxs(Fragment, { children: [_jsx(DropdownFilter, { ...filterBarProps, isOpen: Boolean(isOpen && panel === 'quick'), onChange: handleDropdownChange }), _jsx(CalendarFilter, { ...filterBarProps, isOpen: Boolean(isOpen && panel === 'calendar'), onChange: onChange })] }));
|
|
24
|
+
return (_jsxs(Fragment, { children: [_jsx(DropdownFilter, { ...filterBarProps, isOpen: Boolean(isOpen && panel === 'quick'), onChange: handleDropdownChange, value: value }), _jsx(CalendarFilter, { ...filterBarProps, isOpen: Boolean(isOpen && panel === 'calendar'), onChange: onChange, value: value })] }));
|
|
20
25
|
}
|
|
21
26
|
export default DateFilter;
|
|
@@ -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> {
|
|
@@ -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
|
}
|