@sqrzro/ui 4.0.0-alpha.0 → 4.0.0-alpha.2
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 +7 -0
- package/dist/components/buttons/ActionButton/index.js +33 -0
- package/dist/components/buttons/Button/index.d.ts +65 -0
- package/dist/components/buttons/Button/index.js +50 -0
- package/dist/components/buttons/ConfirmableButton/index.d.ts +7 -0
- package/dist/components/buttons/ConfirmableButton/index.js +13 -0
- package/dist/components/buttons/TextButton/index.d.ts +5 -0
- package/dist/components/buttons/TextButton/index.js +6 -0
- package/dist/components/collections/Collection/index.d.ts +15 -0
- package/dist/components/collections/Collection/index.js +45 -0
- package/dist/components/collections/EmptyMessage/index.d.ts +26 -0
- package/dist/components/collections/EmptyMessage/index.js +17 -0
- package/dist/components/collections/EmptyMessageAction/index.d.ts +6 -0
- package/dist/components/collections/EmptyMessageAction/index.js +19 -0
- package/dist/components/collections/List/index.d.ts +6 -0
- package/dist/components/collections/List/index.js +13 -0
- package/dist/components/collections/ListClientComponent/index.d.ts +7 -0
- package/dist/components/collections/ListClientComponent/index.js +9 -0
- package/dist/components/collections/ListItem/index.d.ts +14 -0
- package/dist/components/collections/ListItem/index.js +28 -0
- package/dist/components/collections/ListItemMeta/index.d.ts +11 -0
- package/dist/components/collections/ListItemMeta/index.js +22 -0
- package/dist/components/collections/ListItemSecondary/index.d.ts +6 -0
- package/dist/components/collections/ListItemSecondary/index.js +16 -0
- package/dist/components/collections/Pagination/index.d.ts +19 -0
- package/dist/components/collections/Pagination/index.js +17 -0
- package/dist/components/collections/Table/index.d.ts +9 -0
- package/dist/components/collections/Table/index.js +13 -0
- package/dist/components/collections/TableClientComponent/index.d.ts +14 -0
- package/dist/components/collections/TableClientComponent/index.js +30 -0
- package/dist/components/collections/interfaces.d.ts +57 -0
- package/dist/components/collections/interfaces.js +1 -0
- package/dist/components/collections/lang.d.ts +4 -0
- package/dist/components/collections/lang.js +4 -0
- package/dist/components/collections/utility/filter-columns.d.ts +3 -0
- package/dist/components/collections/utility/filter-columns.js +8 -0
- package/dist/components/collections/utility/get-selected-from-search-params.d.ts +2 -0
- package/dist/components/collections/utility/get-selected-from-search-params.js +5 -0
- package/dist/components/collections/utility/is-paginated.d.ts +3 -0
- package/dist/components/collections/utility/is-paginated.js +4 -0
- package/dist/components/collections/utility/set-selected-to-search-params.d.ts +2 -0
- package/dist/components/collections/utility/set-selected-to-search-params.js +4 -0
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.js +9 -0
- package/dist/components/modals/ConfirmModal/index.d.ts +7 -0
- package/dist/components/modals/ConfirmModal/index.js +23 -0
- package/dist/components/modals/Modal/index.d.ts +19 -0
- package/dist/components/modals/Modal/index.js +17 -0
- package/dist/components/modals/ModalActions/index.d.ts +9 -0
- package/dist/components/modals/ModalActions/index.js +8 -0
- package/dist/components/modals/ModalLauncher/index.d.ts +5 -0
- package/dist/components/modals/ModalLauncher/index.js +14 -0
- package/dist/components/utility/ActionList/index.d.ts +12 -0
- package/dist/components/utility/ActionList/index.js +9 -0
- package/dist/components/utility/Assistive/index.d.ts +8 -0
- package/dist/components/utility/Assistive/index.js +8 -0
- package/dist/components/utility/ClassNames/index.d.ts +6 -0
- package/dist/components/utility/ClassNames/index.js +7 -0
- package/dist/components/utility/Container/index.d.ts +9 -0
- package/dist/components/utility/Container/index.js +8 -0
- package/dist/components/utility/Link/index.d.ts +19 -0
- package/dist/components/utility/Link/index.js +33 -0
- package/dist/components/utility/Loader/index.d.ts +8 -0
- package/dist/components/utility/Loader/index.js +9 -0
- package/dist/components/utility/Page/index.d.ts +18 -0
- package/dist/components/utility/Page/index.js +34 -0
- package/dist/components/utility/Popover/index.d.ts +14 -0
- package/dist/components/utility/Popover/index.js +71 -0
- package/dist/components/utility/RootLayout/index.d.ts +12 -0
- package/dist/components/utility/RootLayout/index.js +14 -0
- package/dist/components/utility/Toast/index.d.ts +11 -0
- package/dist/components/utility/Toast/index.js +11 -0
- package/dist/components/utility/Toaster/index.d.ts +8 -0
- package/dist/components/utility/Toaster/index.js +57 -0
- package/dist/filters/components/FilterBar/index.d.ts +9 -0
- package/dist/filters/components/FilterBar/index.js +9 -0
- package/dist/filters/components/FilterBarClientComponent/index.d.ts +12 -0
- package/dist/filters/components/FilterBarClientComponent/index.js +68 -0
- package/dist/filters/components/FilterClearButton/index.d.ts +5 -0
- package/dist/filters/components/FilterClearButton/index.js +6 -0
- package/dist/filters/components/FilterControl/index.d.ts +12 -0
- package/dist/filters/components/FilterControl/index.js +10 -0
- package/dist/filters/components/FilterItem/index.d.ts +14 -0
- package/dist/filters/components/FilterItem/index.js +43 -0
- package/dist/filters/components/FilterPanel/index.d.ts +19 -0
- package/dist/filters/components/FilterPanel/index.js +36 -0
- package/dist/filters/filters/BooleanFilter/index.d.ts +3 -0
- package/dist/filters/filters/BooleanFilter/index.js +10 -0
- package/dist/filters/filters/CalendarFilter/index.d.ts +3 -0
- package/dist/filters/filters/CalendarFilter/index.js +10 -0
- package/dist/filters/filters/DateFilter/index.d.ts +3 -0
- package/dist/filters/filters/DateFilter/index.js +21 -0
- package/dist/filters/filters/DropdownFilter/index.d.ts +3 -0
- package/dist/filters/filters/DropdownFilter/index.js +10 -0
- package/dist/filters/filters/Filter/index.d.ts +16 -0
- package/dist/filters/filters/Filter/index.js +13 -0
- package/dist/filters/filters/MultiFilter/index.d.ts +3 -0
- package/dist/filters/filters/MultiFilter/index.js +9 -0
- package/dist/filters/filters/SearchFilter/index.d.ts +4 -0
- package/dist/filters/filters/SearchFilter/index.js +30 -0
- package/dist/filters/filters/interfaces.d.ts +10 -0
- package/dist/filters/filters/interfaces.js +1 -0
- package/dist/filters/hooks/useFilters.d.ts +5 -0
- package/dist/filters/hooks/useFilters.js +25 -0
- package/dist/filters/index.d.ts +2 -0
- package/dist/filters/index.js +2 -0
- package/dist/filters/interfaces.d.ts +28 -0
- package/dist/filters/interfaces.js +1 -0
- package/dist/filters/lang.d.ts +1 -0
- package/dist/filters/lang.js +1 -0
- package/dist/filters/utility/check-has-filters.d.ts +2 -0
- package/dist/filters/utility/check-has-filters.js +8 -0
- package/dist/filters/utility/create-client-filter-map.d.ts +3 -0
- package/dist/filters/utility/create-client-filter-map.js +14 -0
- package/dist/filters/utility/filter.d.ts +16 -0
- package/dist/filters/utility/filter.js +120 -0
- package/dist/filters/utility/get-quick-dates.d.ts +3 -0
- package/dist/filters/utility/get-quick-dates.js +90 -0
- package/dist/filters/utility/parse-filters.d.ts +3 -0
- package/dist/filters/utility/parse-filters.js +16 -0
- package/dist/filters/utility/parse-page.d.ts +2 -0
- package/dist/filters/utility/parse-page.js +8 -0
- package/dist/filters/utility/render-value.d.ts +3 -0
- package/dist/filters/utility/render-value.js +57 -0
- package/dist/filters/utility/transform-boolean.d.ts +2 -0
- package/dist/filters/utility/transform-boolean.js +10 -0
- package/dist/filters/utility/transform-date.d.ts +2 -0
- package/dist/filters/utility/transform-date.js +29 -0
- package/dist/filters/utility/transform-multi.d.ts +2 -0
- package/dist/filters/utility/transform-multi.js +9 -0
- package/dist/forms/components/Dropdown/index.d.ts +22 -0
- package/dist/forms/components/Dropdown/index.js +41 -0
- package/dist/forms/components/DropdownList/index.d.ts +8 -0
- package/dist/forms/components/DropdownList/index.js +20 -0
- package/dist/forms/components/EditableForm/index.d.ts +24 -0
- package/dist/forms/components/EditableForm/index.js +23 -0
- package/dist/forms/components/EditableFormField/index.d.ts +14 -0
- package/dist/forms/components/EditableFormField/index.js +37 -0
- package/dist/forms/components/EditableFormFields/index.d.ts +7 -0
- package/dist/forms/components/EditableFormFields/index.js +20 -0
- package/dist/forms/components/Form/index.d.ts +12 -0
- package/dist/forms/components/Form/index.js +9 -0
- package/dist/forms/components/FormError/index.d.ts +9 -0
- package/dist/forms/components/FormError/index.js +8 -0
- package/dist/forms/components/FormField/index.d.ts +25 -0
- package/dist/forms/components/FormField/index.js +37 -0
- package/dist/forms/components/FormFields/index.d.ts +10 -0
- package/dist/forms/components/FormFields/index.js +22 -0
- package/dist/forms/components/FormLabel/index.d.ts +10 -0
- package/dist/forms/components/FormLabel/index.js +8 -0
- package/dist/forms/components/FormSubmit/index.d.ts +4 -0
- package/dist/forms/components/FormSubmit/index.js +9 -0
- package/dist/forms/components/ModalForm/index.d.ts +13 -0
- package/dist/forms/components/ModalForm/index.js +25 -0
- package/dist/forms/components/PasswordInput/index.d.ts +11 -0
- package/dist/forms/components/PasswordInput/index.js +17 -0
- package/dist/forms/components/StaticTextInput/index.d.ts +22 -0
- package/dist/forms/components/StaticTextInput/index.js +22 -0
- package/dist/forms/components/Switch/index.d.ts +11 -0
- package/dist/forms/components/Switch/index.js +17 -0
- package/dist/forms/components/TextInput/index.d.ts +34 -0
- package/dist/forms/components/TextInput/index.js +30 -0
- package/dist/forms/hooks/useDropdown.d.ts +10 -0
- package/dist/forms/hooks/useDropdown.js +14 -0
- package/dist/forms/hooks/useEditableForm.d.ts +24 -0
- package/dist/forms/hooks/useEditableForm.js +34 -0
- package/dist/forms/hooks/useForm.d.ts +136 -0
- package/dist/forms/hooks/useForm.js +209 -0
- package/dist/forms/hooks/useModalForm.d.ts +14 -0
- package/dist/forms/hooks/useModalForm.js +29 -0
- package/dist/forms/index.d.ts +27 -0
- package/dist/forms/index.js +17 -0
- package/dist/forms/interfaces.d.ts +32 -0
- package/dist/forms/interfaces.js +1 -0
- package/dist/forms/utility/extract-editable-input-props.d.ts +8 -0
- package/dist/forms/utility/extract-editable-input-props.js +19 -0
- package/dist/forms/utility/extract-input-props.d.ts +9 -0
- package/dist/forms/utility/extract-input-props.js +37 -0
- package/dist/hooks/index.d.ts +0 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useClickOutside.d.ts +93 -0
- package/dist/hooks/useClickOutside.js +124 -0
- package/dist/hooks/usePagination.d.ts +17 -0
- package/dist/hooks/usePagination.js +46 -0
- package/dist/hooks/useSearchParamsHref.d.ts +6 -0
- package/dist/hooks/useSearchParamsHref.js +33 -0
- package/dist/hooks/useToast.d.ts +18 -0
- package/dist/hooks/useToast.js +25 -0
- package/dist/navigation/components/AppNavigation/index.d.ts +13 -0
- package/dist/navigation/components/AppNavigation/index.js +15 -0
- package/dist/navigation/components/AppNavigationItem/index.d.ts +6 -0
- package/dist/navigation/components/AppNavigationItem/index.js +9 -0
- package/dist/navigation/components/Tabs/index.d.ts +7 -0
- package/dist/navigation/components/Tabs/index.js +9 -0
- package/dist/navigation/hooks/useNavigation.d.ts +10 -0
- package/dist/navigation/hooks/useNavigation.js +38 -0
- package/dist/navigation/index.d.ts +5 -0
- package/dist/navigation/index.js +3 -0
- package/dist/navigation/interfaces.d.ts +7 -0
- package/dist/navigation/interfaces.js +1 -0
- package/dist/styles/config.d.ts +64 -0
- package/dist/styles/config.js +43 -0
- package/dist/styles/icons.d.ts +15 -0
- package/dist/styles/icons.js +7 -0
- package/dist/styles/index.d.ts +2 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/interfaces.d.ts +41 -0
- package/dist/styles/interfaces.js +1 -0
- package/dist/styles/tw.d.ts +9 -0
- package/dist/styles/tw.js +15 -0
- package/dist/utility/index.d.ts +1 -0
- package/dist/utility/index.js +1 -0
- package/dist/utility/interfaces.d.ts +35 -0
- package/dist/utility/interfaces.js +1 -1
- package/package.json +55 -8
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -1
- package/dist/lists/List/index.d.ts +0 -5
- package/dist/lists/List/index.js +0 -6
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FilterConfig, FilterConfigWithBooleanData, FilterConfigWithData, FilterObject, FilterType } from '../interfaces';
|
|
2
|
+
interface FilterReturn {
|
|
3
|
+
$dropdown: <T>(config: FilterConfigWithData, transformer: (value: string | null) => T) => FilterObject<T, 'dropdown'>;
|
|
4
|
+
$multi: <T>(config: FilterConfigWithData, transformer: (value: string | null) => T | null) => FilterObject<T[] | null, 'multi'>;
|
|
5
|
+
assistive: <T>(transformer: (value: string | null) => T | null) => FilterObject<T | null, 'assistive'>;
|
|
6
|
+
boolean: (label: string, config?: FilterConfigWithBooleanData) => FilterObject<boolean | null, 'boolean'>;
|
|
7
|
+
calendar: (label: string, config?: FilterConfig) => FilterObject<[Date, Date] | null, 'calendar'>;
|
|
8
|
+
custom: <T, F extends FilterType>(label: string, object: FilterObject<T, F>) => FilterObject<T, F>;
|
|
9
|
+
date: (label: string, config?: FilterConfig) => FilterObject<[Date, Date] | null, 'date'>;
|
|
10
|
+
dropdown: (label: string, config: FilterConfigWithData) => FilterObject<string | null, 'dropdown'>;
|
|
11
|
+
multi: (label: string, config: FilterConfigWithData) => FilterObject<string[] | null, 'multi'>;
|
|
12
|
+
search: () => FilterObject<string | null, 'search'>;
|
|
13
|
+
switch: (label: string) => FilterObject<boolean, 'switch'>;
|
|
14
|
+
}
|
|
15
|
+
declare function filter(): FilterReturn;
|
|
16
|
+
export default filter;
|
|
@@ -0,0 +1,120 @@
|
|
|
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';
|
|
6
|
+
function defaultTransformer(value) {
|
|
7
|
+
return value ? value : null;
|
|
8
|
+
}
|
|
9
|
+
function filter() {
|
|
10
|
+
function $dropdown(config, transformer) {
|
|
11
|
+
return {
|
|
12
|
+
config,
|
|
13
|
+
transformer,
|
|
14
|
+
type: 'dropdown',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function $multi(config, transformer) {
|
|
18
|
+
return {
|
|
19
|
+
config,
|
|
20
|
+
transformer: (value) => {
|
|
21
|
+
const values = value ? transformToMulti(value) : null;
|
|
22
|
+
if (!values) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return filterNull(values.map(transformer));
|
|
26
|
+
},
|
|
27
|
+
type: 'multi',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function assistive(transformer) {
|
|
31
|
+
return {
|
|
32
|
+
transformer,
|
|
33
|
+
type: 'assistive',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function boolean(label, config) {
|
|
37
|
+
return {
|
|
38
|
+
config: {
|
|
39
|
+
...config,
|
|
40
|
+
data: [
|
|
41
|
+
{ label: config?.data?.[0] || 'No', value: '0' },
|
|
42
|
+
{ label: config?.data?.[1] || 'Yes', value: '1' },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
label,
|
|
46
|
+
transformer: transformToBoolean,
|
|
47
|
+
type: 'boolean',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function calendar(label, config) {
|
|
51
|
+
return {
|
|
52
|
+
config,
|
|
53
|
+
label,
|
|
54
|
+
transformer: transformToDate,
|
|
55
|
+
type: 'calendar',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function custom(label, object, config) {
|
|
59
|
+
return {
|
|
60
|
+
config: { ...object.config, ...config },
|
|
61
|
+
label,
|
|
62
|
+
transformer: object.transformer,
|
|
63
|
+
type: object.type,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function date(label, config) {
|
|
67
|
+
return {
|
|
68
|
+
config: {
|
|
69
|
+
...config,
|
|
70
|
+
data: [...getQuickDates(), { label: 'Custom...', value: 'custom' }],
|
|
71
|
+
},
|
|
72
|
+
label,
|
|
73
|
+
transformer: transformToDate,
|
|
74
|
+
type: 'date',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function dropdown(label, config) {
|
|
78
|
+
return {
|
|
79
|
+
config,
|
|
80
|
+
label,
|
|
81
|
+
transformer: defaultTransformer,
|
|
82
|
+
type: 'dropdown',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function multi(label, config) {
|
|
86
|
+
return {
|
|
87
|
+
config,
|
|
88
|
+
label,
|
|
89
|
+
transformer: transformToMulti,
|
|
90
|
+
type: 'multi',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function search() {
|
|
94
|
+
return {
|
|
95
|
+
transformer: defaultTransformer,
|
|
96
|
+
type: 'search',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function switchFn(label) {
|
|
100
|
+
return {
|
|
101
|
+
label,
|
|
102
|
+
transformer: transformToBoolean,
|
|
103
|
+
type: 'switch',
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
$dropdown,
|
|
108
|
+
$multi,
|
|
109
|
+
assistive,
|
|
110
|
+
boolean,
|
|
111
|
+
calendar,
|
|
112
|
+
custom,
|
|
113
|
+
date,
|
|
114
|
+
dropdown,
|
|
115
|
+
multi,
|
|
116
|
+
search,
|
|
117
|
+
switch: switchFn,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export default filter;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { transformFromDate } from './transform-date';
|
|
2
|
+
const DAYS_IN_WEEK = 7;
|
|
3
|
+
const DAYS_IN_30_DAYS = 30;
|
|
4
|
+
const DAYS_IN_MONTH = 31;
|
|
5
|
+
const NOON = 12;
|
|
6
|
+
/*
|
|
7
|
+
* We should set the time to noon everytime, to avoid weird things with timezones.
|
|
8
|
+
* (The date filter transformer ensures the final dates are 00:00:00 and 23:59:59, respectively.)
|
|
9
|
+
*/
|
|
10
|
+
function normalizeTime(date) {
|
|
11
|
+
date.setHours(NOON, 0, 0, 0);
|
|
12
|
+
return date;
|
|
13
|
+
}
|
|
14
|
+
function normalizeTimes(dates) {
|
|
15
|
+
return [normalizeTime(dates[0]), normalizeTime(dates[1])];
|
|
16
|
+
}
|
|
17
|
+
function getToday() {
|
|
18
|
+
const today = new Date();
|
|
19
|
+
return normalizeTimes([today, today]);
|
|
20
|
+
}
|
|
21
|
+
function getYesterday() {
|
|
22
|
+
const yesterday = new Date();
|
|
23
|
+
yesterday.setDate(yesterday.getDate() - 1);
|
|
24
|
+
return normalizeTimes([yesterday, yesterday]);
|
|
25
|
+
}
|
|
26
|
+
function getLast7Days() {
|
|
27
|
+
const today = new Date();
|
|
28
|
+
const firstDate = new Date();
|
|
29
|
+
firstDate.setDate(today.getDate() - DAYS_IN_WEEK);
|
|
30
|
+
return normalizeTimes([firstDate, today]);
|
|
31
|
+
}
|
|
32
|
+
function getLast30Days() {
|
|
33
|
+
const today = new Date();
|
|
34
|
+
const firstDate = new Date();
|
|
35
|
+
firstDate.setDate(today.getDate() - DAYS_IN_30_DAYS);
|
|
36
|
+
return normalizeTimes([firstDate, today]);
|
|
37
|
+
}
|
|
38
|
+
function getThisMonth() {
|
|
39
|
+
const today = new Date();
|
|
40
|
+
const firstDate = new Date(today.getFullYear(), today.getMonth(), 1);
|
|
41
|
+
return normalizeTimes([firstDate, today]);
|
|
42
|
+
}
|
|
43
|
+
function getLastMonth() {
|
|
44
|
+
const today = new Date();
|
|
45
|
+
const firstDate = new Date(today.getFullYear(), today.getMonth() - 1, 1);
|
|
46
|
+
const lastDate = new Date(today.getFullYear(), today.getMonth(), 0);
|
|
47
|
+
return normalizeTimes([firstDate, lastDate]);
|
|
48
|
+
}
|
|
49
|
+
function getQuickDates() {
|
|
50
|
+
const today = new Date();
|
|
51
|
+
const dates = [
|
|
52
|
+
{
|
|
53
|
+
label: 'Today',
|
|
54
|
+
value: getToday(),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
value: getYesterday(),
|
|
58
|
+
label: 'Yesterday',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: 'Last 7 Days',
|
|
62
|
+
value: getLast7Days(),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: 'Last 30 Days',
|
|
66
|
+
value: getLast30Days(),
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
/*
|
|
70
|
+
* If the date is the 8th or 31st of the month, it matches up with last 7 days or last 30 days,
|
|
71
|
+
* respectively, and causes duplicate key errors. So best just leave it out in these cases.
|
|
72
|
+
*/
|
|
73
|
+
if (today.getDate() !== 1 &&
|
|
74
|
+
today.getDate() !== DAYS_IN_WEEK + 1 &&
|
|
75
|
+
today.getDate() !== DAYS_IN_MONTH) {
|
|
76
|
+
dates.push({
|
|
77
|
+
label: 'This Month',
|
|
78
|
+
value: getThisMonth(),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
dates.push({
|
|
82
|
+
label: 'Last Month',
|
|
83
|
+
value: getLastMonth(),
|
|
84
|
+
});
|
|
85
|
+
return dates.map((item) => ({
|
|
86
|
+
label: item.label,
|
|
87
|
+
value: transformFromDate(item.value) || '-',
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
export default getQuickDates;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function parseFilters(searchParams, map) {
|
|
2
|
+
const out = {};
|
|
3
|
+
if (!searchParams || !map) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
for (const key in map) {
|
|
7
|
+
if (Object.hasOwn(map, key) && typeof map[key] !== 'undefined') {
|
|
8
|
+
const value = searchParams[key];
|
|
9
|
+
if (value) {
|
|
10
|
+
out[key] = map[key].transformer(value);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
}
|
|
16
|
+
export default parseFilters;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { formatMulti } from '@sqrzro/utility';
|
|
2
|
+
import { transformToMulti } from './transform-multi';
|
|
3
|
+
function getNamesFromIDs(ids, data) {
|
|
4
|
+
if (!data || !ids) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
const set = new Set(ids);
|
|
8
|
+
return data
|
|
9
|
+
.filter((item) => set.has(item.value))
|
|
10
|
+
.map((item) => item.$data?.label || item.label);
|
|
11
|
+
}
|
|
12
|
+
const LENGTH_OF_YEAR = 4;
|
|
13
|
+
const PAD = 2;
|
|
14
|
+
function renderDateString(value, noYear) {
|
|
15
|
+
const date = new Date(value);
|
|
16
|
+
if (Number.isNaN(date.getTime())) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
const day = date.getDate().toString().padStart(PAD, '0');
|
|
20
|
+
const month = (date.getMonth() + 1).toString().padStart(PAD, '0');
|
|
21
|
+
const year = date.getFullYear();
|
|
22
|
+
return `${day}/${month}${noYear ? '' : `/${year}`}`;
|
|
23
|
+
}
|
|
24
|
+
function renderDateValue(value) {
|
|
25
|
+
const years = value.map((item) => parseInt(item.substring(0, LENGTH_OF_YEAR), 10));
|
|
26
|
+
const isThisYear = years.every((item) => item === new Date().getFullYear());
|
|
27
|
+
if (value[0] === value[1]) {
|
|
28
|
+
return renderDateString(value[0], isThisYear);
|
|
29
|
+
}
|
|
30
|
+
return value.map((item) => renderDateString(item, isThisYear)).join(' - ');
|
|
31
|
+
}
|
|
32
|
+
function renderValue(value, config) {
|
|
33
|
+
// Split the value into a multi-value. This will make formatting multis easier later
|
|
34
|
+
const values = transformToMulti(value);
|
|
35
|
+
/*
|
|
36
|
+
* If the config has data, extract the names from the data values
|
|
37
|
+
* This should work for boolean, dropdown, and multi filters
|
|
38
|
+
*/
|
|
39
|
+
if (config && 'data' in config) {
|
|
40
|
+
// Try the entire value first (not array). See if it's in the data, a return the name if so:
|
|
41
|
+
const [item] = getNamesFromIDs([value], config.data);
|
|
42
|
+
if (item) {
|
|
43
|
+
return item;
|
|
44
|
+
}
|
|
45
|
+
// Now try the split values:
|
|
46
|
+
const items = getNamesFromIDs(values, config.data);
|
|
47
|
+
if (items.length) {
|
|
48
|
+
return formatMulti(items);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// If the value looks like dates, format them accordingly
|
|
52
|
+
if (values?.every((item) => /^\d{4}-\d{2}-\d{2}$/u.test(item))) {
|
|
53
|
+
return renderDateValue(values);
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
export default renderValue;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function transformFromBoolean(value) {
|
|
2
|
+
return value ? '1' : '0';
|
|
3
|
+
}
|
|
4
|
+
export function transformToBoolean(value) {
|
|
5
|
+
if (!value) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const normalized = value.trim().toLowerCase();
|
|
9
|
+
return !['false', '0', 'no', 'off', 'null', 'undefined', 'n'].includes(normalized);
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { formatDate } from '@sqrzro/utility';
|
|
2
|
+
export function transformFromDate(value) {
|
|
3
|
+
if (!value) {
|
|
4
|
+
return '';
|
|
5
|
+
}
|
|
6
|
+
return `${formatDate(value[0], 'YYYY-MM-DD')}|${formatDate(value[1], 'YYYY-MM-DD')}`;
|
|
7
|
+
}
|
|
8
|
+
function setToStartOfDay(date) {
|
|
9
|
+
date.setHours(0, 0, 0, 0);
|
|
10
|
+
return date;
|
|
11
|
+
}
|
|
12
|
+
function setToEndOfDay(date) {
|
|
13
|
+
date.setHours(23, 59, 59, 999); // eslint-disable-line @typescript-eslint/no-magic-numbers
|
|
14
|
+
return date;
|
|
15
|
+
}
|
|
16
|
+
function parseDate(value) {
|
|
17
|
+
const date = new Date(value);
|
|
18
|
+
return isNaN(date.getTime()) ? null : date;
|
|
19
|
+
}
|
|
20
|
+
export function transformToDate(value) {
|
|
21
|
+
if (!value?.includes('|')) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const [start, end] = value.split('|').map((item) => parseDate(item));
|
|
25
|
+
if (start === null || end === null) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return [setToStartOfDay(start), setToEndOfDay(end)];
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function transformFromMulti(value) {
|
|
2
|
+
if (!value) {
|
|
3
|
+
return '';
|
|
4
|
+
}
|
|
5
|
+
return value.filter(Boolean).join('|').replace(/^|/u, '').replace(/|$/u, '');
|
|
6
|
+
}
|
|
7
|
+
export function transformToMulti(value) {
|
|
8
|
+
return value ? value.split('|').filter(Boolean) : null;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ClassNameProps, ErrorableClassName, FocusableClassName, SelectableClassName } from '../../../styles/interfaces';
|
|
2
|
+
import type { DropdownObject, InputProps } from '../../interfaces';
|
|
3
|
+
export interface DropdownClassNames {
|
|
4
|
+
root: ErrorableClassName & FocusableClassName;
|
|
5
|
+
list: string;
|
|
6
|
+
item: SelectableClassName;
|
|
7
|
+
title: string;
|
|
8
|
+
details: string;
|
|
9
|
+
icon: string;
|
|
10
|
+
clear: string;
|
|
11
|
+
}
|
|
12
|
+
export interface DropdownComponentProps<T> {
|
|
13
|
+
isOptional?: boolean;
|
|
14
|
+
isPanelOnly?: boolean;
|
|
15
|
+
options?: DropdownObject<T>[];
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
}
|
|
18
|
+
export type DropdownProps<T> = ClassNameProps<DropdownClassNames> & InputProps<T | null> & DropdownComponentProps<T>;
|
|
19
|
+
export declare function renderLabel<T>(options: DropdownObject<T>[], value?: T | null): string;
|
|
20
|
+
export declare function renderDetails<T>(options: DropdownObject<T>[], value?: T | null): string;
|
|
21
|
+
declare function Dropdown<T>({ classNames, classNameProps, hasError, isDisabled, isOptional, isPanelOnly, name, onChange, options, placeholder, value, }: Readonly<DropdownProps<T>>): React.ReactElement;
|
|
22
|
+
export default Dropdown;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
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 { getClassNames } from '../../../styles/config';
|
|
7
|
+
import DropdownList from '../DropdownList';
|
|
8
|
+
import StaticTextInput from '../StaticTextInput';
|
|
9
|
+
function findByValue(options, value) {
|
|
10
|
+
return options.find((item) => item.value === value);
|
|
11
|
+
}
|
|
12
|
+
export function renderLabel(options, value) {
|
|
13
|
+
return findByValue(options, value)?.label || '';
|
|
14
|
+
}
|
|
15
|
+
export function renderDetails(options, value) {
|
|
16
|
+
return findByValue(options, value)?.details || '';
|
|
17
|
+
}
|
|
18
|
+
function Dropdown({ classNames, classNameProps, hasError, isDisabled, isOptional, isPanelOnly, name, onChange, options = [], placeholder, value, }) {
|
|
19
|
+
const componentClassNames = classNames || getClassNames('dropdown')?.(classNameProps);
|
|
20
|
+
const [isOpen, setIsOpen, node] = useClickOutside({ shouldHandleEnterKey: true });
|
|
21
|
+
function toggleIsOpen() {
|
|
22
|
+
setIsOpen(!isOpen);
|
|
23
|
+
}
|
|
24
|
+
function handleChange(event) {
|
|
25
|
+
if (onChange) {
|
|
26
|
+
onChange(event);
|
|
27
|
+
}
|
|
28
|
+
setIsOpen(false);
|
|
29
|
+
}
|
|
30
|
+
function handleClear() {
|
|
31
|
+
onChange?.({ $data: undefined, target: { name, value: null } }); // eslint-disable-line no-undefined
|
|
32
|
+
}
|
|
33
|
+
if (isPanelOnly) {
|
|
34
|
+
return _jsx(DropdownList, { name: name, onChange: handleChange, options: options, value: value });
|
|
35
|
+
}
|
|
36
|
+
return (_jsxs("div", { ref: node, className: tw('relative', componentClassNames?.root?.default, hasError ? componentClassNames?.root?.error : null, isOpen && !isDisabled ? componentClassNames?.root?.focused : null), children: [_jsx(StaticTextInput, { classNames: {
|
|
37
|
+
clear: componentClassNames?.clear,
|
|
38
|
+
icon: componentClassNames?.icon,
|
|
39
|
+
}, details: renderDetails(options, value), hasError: hasError, isDisabled: isDisabled || !options?.length, isOpen: isOpen, isOptional: isOptional, label: renderLabel(options, value), name: name, onClear: handleClear, onClick: toggleIsOpen, placeholder: placeholder || 'Select...', value: value ? String(value) : '' }), _jsx(Popover, { align: "center", isOpen: isOpen ? !isDisabled : false, isScrollable: true, children: _jsx(DropdownList, { name: name, onChange: handleChange, options: options, value: value }) })] }));
|
|
40
|
+
}
|
|
41
|
+
export default Dropdown;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DropdownObject, InputProps } from '../../../forms/interfaces';
|
|
2
|
+
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
3
|
+
import type { DropdownClassNames } from '../Dropdown';
|
|
4
|
+
export interface DropdownListProps<T> extends ClassNameProps<DropdownClassNames>, InputProps<T | null> {
|
|
5
|
+
options: DropdownObject<T>[];
|
|
6
|
+
}
|
|
7
|
+
declare function DropdownList<T>({ classNames, classNameProps, name, onChange, options, value, }: Readonly<DropdownListProps<T>>): React.ReactElement;
|
|
8
|
+
export default DropdownList;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassNames } from '../../../styles/config';
|
|
3
|
+
import tw from '../../../styles/tw';
|
|
4
|
+
function isSelected(id, value) {
|
|
5
|
+
return Boolean(value) && value === id;
|
|
6
|
+
}
|
|
7
|
+
function DropdownList({ classNames, classNameProps, name, onChange, options, value, }) {
|
|
8
|
+
const componentClassNames = classNames || getClassNames('dropdown')?.(classNameProps);
|
|
9
|
+
// const checkboxClassNames = getClassNames('checkboxInput')?.(classNameProps);
|
|
10
|
+
function handleChange(item) {
|
|
11
|
+
return () => {
|
|
12
|
+
onChange?.({
|
|
13
|
+
$data: item.$data,
|
|
14
|
+
target: { name, value: item.value },
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return (_jsx("ul", { className: componentClassNames?.list, role: "listbox", children: options.map((item, index) => (_jsx("li", { "aria-selected": isSelected(item.value, value), className: tw('relative', item.isDisabled ? 'pointer-events-none opacity-30' : null, componentClassNames?.item?.default, isSelected(item.value, value) ? componentClassNames?.item?.selected : null), role: "option", children: _jsxs("button", { 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))) }));
|
|
19
|
+
}
|
|
20
|
+
export default DropdownList;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
import type { Action } from '../../../utility/interfaces';
|
|
3
|
+
import type { EditingStatus } from '../../interfaces';
|
|
4
|
+
import type { FormProps } from '../Form';
|
|
5
|
+
export interface EditableFormClassNames {
|
|
6
|
+
actions: string;
|
|
7
|
+
root: string;
|
|
8
|
+
header: string;
|
|
9
|
+
title: string;
|
|
10
|
+
description: string;
|
|
11
|
+
content: string;
|
|
12
|
+
}
|
|
13
|
+
export interface EditableFormProps extends ClassNameProps<EditableFormClassNames> {
|
|
14
|
+
actions?: Action[] | false;
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
formProps: Omit<FormProps, 'children'>;
|
|
17
|
+
onCancel?: () => void;
|
|
18
|
+
onEdit?: () => void;
|
|
19
|
+
setStatus?: (status: EditingStatus | null) => void;
|
|
20
|
+
status?: EditingStatus | null;
|
|
21
|
+
title?: string;
|
|
22
|
+
}
|
|
23
|
+
declare function EditableForm({ classNameProps, classNames, children, formProps, onCancel, onEdit, setStatus, status, title, }: Readonly<EditableFormProps>): React.ReactElement;
|
|
24
|
+
export default EditableForm;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import ActionList from '../../../components/utility/ActionList';
|
|
3
|
+
import { getClassNames } from '../../../styles/config';
|
|
4
|
+
import tw from '../../../styles/tw';
|
|
5
|
+
import Form from '../Form';
|
|
6
|
+
function EditableForm({ classNameProps, classNames, children, formProps, onCancel, onEdit, setStatus, status, title, }) {
|
|
7
|
+
const componentClassNames = classNames || getClassNames('editableForm')?.(classNameProps);
|
|
8
|
+
function setCancelled() {
|
|
9
|
+
onCancel?.();
|
|
10
|
+
setStatus?.('CANCELLED');
|
|
11
|
+
}
|
|
12
|
+
function setEditing() {
|
|
13
|
+
onEdit?.();
|
|
14
|
+
setStatus?.('EDITING');
|
|
15
|
+
}
|
|
16
|
+
return (_jsx(Form, { ...formProps, children: _jsxs("fieldset", { className: componentClassNames?.root, children: [title ? _jsx("header", { className: tw(componentClassNames?.header), children: _jsx("legend", { className: componentClassNames?.title, children: title }) }) : null, _jsxs("div", { className: tw(componentClassNames?.content), children: [children, _jsx("footer", { className: componentClassNames?.actions, children: _jsx(ActionList, { actions: status === 'EDITING'
|
|
17
|
+
? [
|
|
18
|
+
{ label: 'Cancel', onClick: setCancelled },
|
|
19
|
+
{ isSubmittable: true, label: 'Save' },
|
|
20
|
+
]
|
|
21
|
+
: [{ label: 'Edit', onClick: setEditing }] }) })] })] }) }));
|
|
22
|
+
}
|
|
23
|
+
export default EditableForm;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
import { FormFieldProps } from '../FormField';
|
|
3
|
+
import { EditingStatus } from '../../interfaces';
|
|
4
|
+
export interface EditableFormFieldClassNames {
|
|
5
|
+
root: string;
|
|
6
|
+
label: string;
|
|
7
|
+
field: string;
|
|
8
|
+
}
|
|
9
|
+
export interface EditableFormFieldProps<T, V extends T = T> extends ClassNameProps<EditableFormFieldClassNames>, Omit<FormFieldProps<T, V>, 'classNames'> {
|
|
10
|
+
renderValue?: React.ReactNode | ((value?: T) => React.ReactNode);
|
|
11
|
+
status?: EditingStatus | null;
|
|
12
|
+
}
|
|
13
|
+
declare function EditableFormField<T, V extends T = T>({ classNameProps, classNames, renderValue, status, ...props }: Readonly<EditableFormFieldProps<T, V>>): React.ReactElement;
|
|
14
|
+
export default EditableFormField;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { isValidElement, useEffect, useRef } from 'react';
|
|
4
|
+
import FormField from '../FormField';
|
|
5
|
+
import { getClassNames } from '../../../styles/config';
|
|
6
|
+
function getRenderedValue(value, renderValue) {
|
|
7
|
+
if (renderValue) {
|
|
8
|
+
if (typeof renderValue === 'function') {
|
|
9
|
+
return getRenderedValue(renderValue(value));
|
|
10
|
+
}
|
|
11
|
+
return getRenderedValue(renderValue);
|
|
12
|
+
}
|
|
13
|
+
if (typeof value === 'boolean') {
|
|
14
|
+
return value ? 'Yes' : 'No';
|
|
15
|
+
}
|
|
16
|
+
if (isValidElement(value)) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
return value ? String(value) : '-';
|
|
20
|
+
}
|
|
21
|
+
function EditableFormField({ classNameProps, classNames, renderValue, status, ...props }) {
|
|
22
|
+
const componentClassNames = classNames || getClassNames('editableFormField')(classNameProps);
|
|
23
|
+
const cachedValue = useRef(props.value);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (status === 'CANCELLED') {
|
|
26
|
+
props.onChange?.({ target: { name: props.name, value: cachedValue.current } });
|
|
27
|
+
}
|
|
28
|
+
if (status === 'SAVED') {
|
|
29
|
+
cachedValue.current = props.value;
|
|
30
|
+
}
|
|
31
|
+
}, [status]);
|
|
32
|
+
if (status === 'EDITING') {
|
|
33
|
+
return _jsx(FormField, { ...props });
|
|
34
|
+
}
|
|
35
|
+
return (_jsxs("div", { className: componentClassNames?.root, children: [_jsx("div", { className: componentClassNames?.label, children: props.label }), _jsx("div", { className: componentClassNames?.field, children: getRenderedValue(props.value, renderValue) })] }));
|
|
36
|
+
}
|
|
37
|
+
export default EditableFormField;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EditableFormFieldComponentProps } from '../../interfaces';
|
|
2
|
+
import type { DropdownComponentProps } from '../Dropdown';
|
|
3
|
+
import type { TextInputComponentProps } from '../TextInput';
|
|
4
|
+
export type EditableDropdownFormFieldProps<T> = EditableFormFieldComponentProps<T | null> & DropdownComponentProps<T>;
|
|
5
|
+
export declare function EditableDropdownFormField<T>(props: Readonly<EditableDropdownFormFieldProps<T>>): React.ReactElement;
|
|
6
|
+
export type EditableTextFormFieldProps = EditableFormFieldComponentProps<string> & TextInputComponentProps;
|
|
7
|
+
export declare function EditableTextFormField(props: Readonly<EditableTextFormFieldProps>): React.ReactElement;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import extractEditableInputProps from '../../utility/extract-editable-input-props';
|
|
4
|
+
import Dropdown from '../Dropdown';
|
|
5
|
+
import EditableFormField from '../EditableFormField';
|
|
6
|
+
import TextInput from '../TextInput';
|
|
7
|
+
export function EditableDropdownFormField(props) {
|
|
8
|
+
const { fieldProps, inputProps } = extractEditableInputProps(props);
|
|
9
|
+
const renderInput = useCallback((renderProps) => (_jsx(Dropdown, { ...renderProps, ...inputProps })), [inputProps]);
|
|
10
|
+
const renderValue = useCallback((value) => {
|
|
11
|
+
const displayValue = inputProps.options?.find((option) => option.value === value)?.label;
|
|
12
|
+
return _jsx("div", { children: displayValue ?? '' });
|
|
13
|
+
}, [inputProps]);
|
|
14
|
+
return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
|
|
15
|
+
}
|
|
16
|
+
export function EditableTextFormField(props) {
|
|
17
|
+
const { fieldProps, inputProps } = extractEditableInputProps(props);
|
|
18
|
+
const renderInput = useCallback((renderProps) => (_jsx(TextInput, { ...renderProps, ...inputProps })), [inputProps]);
|
|
19
|
+
return _jsx(EditableFormField, { ...fieldProps, render: renderInput });
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
export interface FormClassNames {
|
|
3
|
+
root: string;
|
|
4
|
+
}
|
|
5
|
+
export interface FormProps extends ClassNameProps<FormClassNames> {
|
|
6
|
+
action?: (formData: FormData) => void;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
id?: string;
|
|
9
|
+
onSubmit?: React.FormEventHandler<HTMLFormElement>;
|
|
10
|
+
}
|
|
11
|
+
declare function Form({ action, children, classNames, classNameProps, id, onSubmit, }: Readonly<FormProps>): React.ReactElement;
|
|
12
|
+
export default Form;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { getClassNames } from '../../../styles/config';
|
|
4
|
+
import tw from '../../../styles/tw';
|
|
5
|
+
function Form({ action, children, classNames, classNameProps, id, onSubmit, }) {
|
|
6
|
+
const componentClassNames = classNames || getClassNames('form')?.(classNameProps);
|
|
7
|
+
return (_jsx("form", { action: action, className: tw(componentClassNames?.root), id: id, onSubmit: onSubmit, children: children }));
|
|
8
|
+
}
|
|
9
|
+
export default Form;
|