@povio/ui 3.3.0-rc.4 → 3.3.0
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/README.md +15 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +55 -206
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +9 -34
- package/dist/components/buttons/shared/ButtonContent.js +22 -80
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +10 -24
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +93 -227
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +84 -202
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +60 -132
- package/dist/components/inputs/DateTime/shared/Calendar.js +139 -339
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +114 -308
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +35 -150
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +95 -229
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +115 -296
- package/dist/components/inputs/DateTime/shared/DateField.js +135 -306
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +140 -338
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +10 -59
- package/dist/components/inputs/File/FileUpload.js +1 -1
- package/dist/components/inputs/File/InputUpload.js +65 -261
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +48 -180
- package/dist/components/inputs/File/shared/FileUploadContentError.js +95 -265
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +99 -261
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +56 -234
- package/dist/components/inputs/File/shared/ProgressBar.js +15 -102
- package/dist/components/inputs/FormField/FormField.js +34 -47
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +75 -313
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +23 -83
- package/dist/components/inputs/Selection/Select/QuerySelect.js +30 -96
- package/dist/components/inputs/Selection/Select/Select.js +3 -3
- package/dist/components/inputs/Selection/shared/SelectInput.js +1 -0
- package/dist/components/inputs/Selection/shared/SelectListBox.js +51 -163
- package/dist/components/inputs/Selection/shared/useSelectItems.js +48 -108
- package/dist/components/inputs/Skeleton/InputFrame.js +177 -552
- package/dist/components/inputs/TextEditor/TextEditor.js +87 -389
- package/dist/components/inputs/shared/InputClear.js +24 -40
- package/dist/components/navigation/Accordion/Accordion.js +22 -69
- package/dist/components/navigation/Accordion/AccordionItem.js +41 -86
- package/dist/components/navigation/Stepper/Stepper.js +22 -67
- package/dist/components/overlays/ActionModal/ActionModal.js +35 -169
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +29 -110
- package/dist/components/shared/pagination/Pagination.js +22 -108
- package/dist/components/status/Alert/Alert.js +30 -97
- package/dist/components/table/InfiniteTable.js +16 -67
- package/dist/components/table/Table.d.ts +2 -8
- package/dist/components/table/Table.js +33 -55
- package/dist/components/text/Typography/Typography.js +8 -23
- package/dist/config/confirmation.context.js +1 -1
- package/dist/config/theme.context.js +45 -98
- package/dist/config/uiConfig.context.js +8 -39
- package/dist/config/uiOverrides.context.d.ts +0 -1
- package/dist/hooks/useDebounceCallback.js +17 -51
- package/dist/hooks/useFormAutosave.js +33 -120
- package/dist/hooks/useLongPressRepeat.js +20 -55
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -2
- package/package.json +2 -2
- package/dist/components/inputs/FormField/formField.cva.d.ts +0 -11
- package/dist/components/inputs/FormField/formField.cva.js +0 -16
- package/dist/components/table/TableColumnFilterInput.d.ts +0 -9
- package/dist/components/table/TableColumnFilterInput.js +0 -108
- package/dist/components/table/TableColumnFilterPlaceholder.d.ts +0 -5
- package/dist/components/table/TableColumnFilterPlaceholder.js +0 -41
- package/dist/components/table/TableColumnFilterRow.d.ts +0 -16
- package/dist/components/table/TableColumnFilterRow.js +0 -68
|
@@ -8,7 +8,6 @@ import { tableDataDefinition, tableHeadDataDefinition, tableHeadRowDefinition, t
|
|
|
8
8
|
import { CellText } from "./CellText.js";
|
|
9
9
|
import { DragIndicatorIcon } from "../../assets/icons/DragIndicator.js";
|
|
10
10
|
import { HeaderText } from "./HeaderText.js";
|
|
11
|
-
import { TableColumnFilterRow } from "./TableColumnFilterRow.js";
|
|
12
11
|
import { useTableNav } from "../../hooks/useTableNav.js";
|
|
13
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
13
|
import { clsx } from "clsx";
|
|
@@ -75,7 +74,7 @@ var DraggableRow = ({ row, showCellBorder, onRowClick, onDoubleClick, tableRowCv
|
|
|
75
74
|
})
|
|
76
75
|
});
|
|
77
76
|
};
|
|
78
|
-
var Table = ({ items, showCellBorder, columns, onRowClick, onDoubleClick, className, sorting, setSorting, columnOrder, setColumnOrder, columnVisibility, setColumnVisibility, bulkSelectionActions: ActionHeader, enableDragDrop = false, onDragEnd, onReorder, getRowId, enableRowSelection, enableMultiRowSelection = false, defaultSelectedRows, onRowSelectionChange,
|
|
77
|
+
var Table = ({ items, showCellBorder, columns, onRowClick, onDoubleClick, className, sorting, setSorting, columnOrder, setColumnOrder, columnVisibility, setColumnVisibility, bulkSelectionActions: ActionHeader, enableDragDrop = false, onDragEnd, onReorder, getRowId, enableRowSelection, enableMultiRowSelection = false, defaultSelectedRows, onRowSelectionChange, ...props }) => {
|
|
79
78
|
const tableRowCva = UIOverrides.useCva("table.rowCva", tableRowDefinition);
|
|
80
79
|
const theadCva = UIOverrides.useCva("table.theadCva", theadDefinition);
|
|
81
80
|
const tableHeadRowCva = UIOverrides.useCva("table.headRowCva", tableHeadRowDefinition);
|
|
@@ -173,71 +172,50 @@ var Table = ({ items, showCellBorder, columns, onRowClick, onDoubleClick, classN
|
|
|
173
172
|
const selectedRows = table.getSelectedRowModel().rows;
|
|
174
173
|
const columnCount = table.getHeaderGroups()[0].headers.length;
|
|
175
174
|
const isAnyRowSelected = selectedRows.length > 0 && !!ActionHeader;
|
|
176
|
-
const showFilterRow = !!filterForm && !!filterDefs?.length && !isAnyRowSelected;
|
|
177
175
|
const hasOnClick = !!onRowClick || !!onDoubleClick;
|
|
178
176
|
const tableElement = /* @__PURE__ */ jsxs("table", {
|
|
179
|
-
className: clsx("w-full",
|
|
177
|
+
className: clsx("w-full", className),
|
|
180
178
|
...listeners,
|
|
181
179
|
children: [/* @__PURE__ */ jsxs("thead", {
|
|
182
180
|
className: clsx(theadCva({})),
|
|
183
181
|
"data-is-sticky": isSticky || void 0,
|
|
184
|
-
children: [
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
return /* @__PURE__ */ jsx("
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}),
|
|
212
|
-
desc: /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
213
|
-
width: 18,
|
|
214
|
-
height: 18
|
|
215
|
-
})
|
|
216
|
-
}[header_0.column.getIsSorted()] ?? null]
|
|
182
|
+
children: [/* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("th", {
|
|
183
|
+
ref: stickyRef,
|
|
184
|
+
className: "-mt-px block"
|
|
185
|
+
}) }), table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx("tr", {
|
|
186
|
+
className: clsx(tableHeadRowCva({})),
|
|
187
|
+
children: headerGroup.headers.filter((header) => {
|
|
188
|
+
if (isAnyRowSelected && header.index > 0) return false;
|
|
189
|
+
return header.column.getIsVisible();
|
|
190
|
+
}).map((header_0, index) => {
|
|
191
|
+
const columnMeta = header_0.column.columnDef.meta ?? {};
|
|
192
|
+
return /* @__PURE__ */ jsx("th", {
|
|
193
|
+
colSpan: isAnyRowSelected ? columnCount : header_0.colSpan,
|
|
194
|
+
tabIndex: -1,
|
|
195
|
+
className: clsx(tableHeadDataCva({ hasRightBorder: index > 0 && showCellBorder }), columnMeta.headerClass, columnMeta.width),
|
|
196
|
+
children: isAnyRowSelected ? /* @__PURE__ */ jsx(ActionHeader, { table }) : /* @__PURE__ */ jsxs("button", {
|
|
197
|
+
type: "button",
|
|
198
|
+
"aria-label": "Sort column",
|
|
199
|
+
className: clsx("flex select-none items-center gap-1 text-text-default-1", header_0.column.getCanSort() ? "h-6 cursor-pointer rounded-xs px-1 hover:bg-elevation-fill-default-2" : "cursor-default", columnMeta.sortClass),
|
|
200
|
+
onClick: header_0.column.getToggleSortingHandler(),
|
|
201
|
+
children: [typeof header_0.column.columnDef.header === "function" ? flexRender(header_0.column.columnDef.header, header_0.getContext()) : /* @__PURE__ */ jsx(HeaderText, { children: header_0.column.columnDef.header }), {
|
|
202
|
+
asc: /* @__PURE__ */ jsx(ChevronUpIcon, {
|
|
203
|
+
width: 18,
|
|
204
|
+
height: 18
|
|
205
|
+
}),
|
|
206
|
+
desc: /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
207
|
+
width: 18,
|
|
208
|
+
height: 18
|
|
217
209
|
})
|
|
218
|
-
}
|
|
210
|
+
}[header_0.column.getIsSorted()] ?? null]
|
|
219
211
|
})
|
|
220
|
-
},
|
|
221
|
-
}),
|
|
222
|
-
showFilterRow && table.getHeaderGroups().map((headerGroup_0) => {
|
|
223
|
-
return /* @__PURE__ */ jsx(TableColumnFilterRow, {
|
|
224
|
-
headers: headerGroup_0.headers.filter((header_1) => header_1.column.getIsVisible()),
|
|
225
|
-
filterForm,
|
|
226
|
-
filterDefs,
|
|
227
|
-
tableHeadDataCva,
|
|
228
|
-
rowClassName: clsx(tableHeadRowCva({})),
|
|
229
|
-
cellClassName: headerFilterCellClassName,
|
|
230
|
-
showCellBorder
|
|
231
|
-
}, `${headerGroup_0.id}-filters`);
|
|
212
|
+
}, header_0.id);
|
|
232
213
|
})
|
|
233
|
-
]
|
|
214
|
+
}, headerGroup.id))]
|
|
234
215
|
}), /* @__PURE__ */ jsx("tbody", {
|
|
235
216
|
ref,
|
|
236
217
|
className: "relative",
|
|
237
|
-
children:
|
|
238
|
-
colSpan: columnCount,
|
|
239
|
-
children: emptyContent
|
|
240
|
-
}) }) : enableDragDrop ? /* @__PURE__ */ jsx(SortableContext, {
|
|
218
|
+
children: enableDragDrop ? /* @__PURE__ */ jsx(SortableContext, {
|
|
241
219
|
items: dataIds,
|
|
242
220
|
strategy: verticalListSortingStrategy,
|
|
243
221
|
children: table.getRowModel().rows.map((row_0) => /* @__PURE__ */ jsx(DraggableRow, {
|
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
import { UIOverrides } from "../../../config/uiOverrides.context.js";
|
|
2
2
|
import { typographyDefinition } from "./typography.cva.js";
|
|
3
|
-
import { c } from "react/compiler-runtime";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
//#region src/components/text/Typography/Typography.tsx
|
|
6
|
-
var Typography = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
...props
|
|
14
|
-
sizeMobile: props.sizeMobile ?? props.size,
|
|
15
|
-
className
|
|
5
|
+
var Typography = ({ as = "p", className, ...props }) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(as, {
|
|
7
|
+
className: UIOverrides.useCva("typography.cva", typographyDefinition)({
|
|
8
|
+
...props,
|
|
9
|
+
sizeMobile: props.sizeMobile ?? props.size,
|
|
10
|
+
className
|
|
11
|
+
}),
|
|
12
|
+
...props
|
|
16
13
|
});
|
|
17
|
-
let t3;
|
|
18
|
-
if ($[0] !== Tag || $[1] !== props || $[2] !== t2) {
|
|
19
|
-
t3 = /* @__PURE__ */ jsx(Tag, {
|
|
20
|
-
className: t2,
|
|
21
|
-
...props
|
|
22
|
-
});
|
|
23
|
-
$[0] = Tag;
|
|
24
|
-
$[1] = props;
|
|
25
|
-
$[2] = t2;
|
|
26
|
-
$[3] = t3;
|
|
27
|
-
} else t3 = $[3];
|
|
28
|
-
return t3;
|
|
29
14
|
};
|
|
30
15
|
//#endregion
|
|
31
16
|
export { Typography };
|
|
@@ -24,7 +24,7 @@ var Confirmation;
|
|
|
24
24
|
const [state, setState] = useState(DEFAULT_STATE);
|
|
25
25
|
const { t } = useTranslation("ui");
|
|
26
26
|
const onCancel = () => setState(DEFAULT_STATE);
|
|
27
|
-
const confirm = useCallback(async ({ heading, description, buttonSize, textAlign, modalClassName, cancelLabel = t(($) => $.ui.confirmation.cancel), confirmLabel = t(($
|
|
27
|
+
const confirm = useCallback(async ({ heading, description, buttonSize, textAlign, modalClassName, cancelLabel = t(($) => $.ui.confirmation.cancel), confirmLabel = t(($) => $.ui.confirmation.confirm), confirmVariant, confirmColor, cancelVariant, cancelColor }) => {
|
|
28
28
|
return new Promise((resolve) => {
|
|
29
29
|
setState({
|
|
30
30
|
heading,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useLocalStorage } from "../hooks/useLocalStorage.js";
|
|
2
|
-
import { c } from "react/compiler-runtime";
|
|
3
2
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { createContext, use, useEffect, useState } from "react";
|
|
3
|
+
import { createContext, use, useCallback, useEffect, useMemo, useState } from "react";
|
|
5
4
|
import { z } from "zod";
|
|
6
5
|
//#region src/config/theme.context.tsx
|
|
7
6
|
var ThemeContext;
|
|
@@ -13,108 +12,56 @@ var ThemeContext;
|
|
|
13
12
|
"system"
|
|
14
13
|
]);
|
|
15
14
|
const ThemeContext = createContext(null);
|
|
16
|
-
_ThemeContext.ThemeContextProvider = (
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
_ThemeContext.ThemeContextProvider = ({ children, storageKey = DEFAULT_STORAGE_KEY }) => {
|
|
16
|
+
const [systemTheme, setSystemTheme] = useState(() => {
|
|
17
|
+
if (typeof window === "undefined") return;
|
|
18
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
19
|
+
});
|
|
20
|
+
const { value: theme, set } = useLocalStorage({
|
|
21
|
+
key: storageKey,
|
|
22
|
+
schema: ThemeSchema
|
|
23
|
+
});
|
|
24
|
+
const updateTheme = useCallback((theme_0) => {
|
|
25
|
+
set(theme_0);
|
|
26
|
+
}, [set]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (typeof window === "undefined") return;
|
|
29
|
+
const onChange = (event) => {
|
|
30
|
+
setSystemTheme(event.matches ? "dark" : "light");
|
|
26
31
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
let t3;
|
|
32
|
-
if ($[2] !== set) {
|
|
33
|
-
t3 = (theme_0) => {
|
|
34
|
-
set(theme_0);
|
|
32
|
+
const media_0 = window.matchMedia("(prefers-color-scheme: dark)");
|
|
33
|
+
media_0.addEventListener("change", onChange);
|
|
34
|
+
return () => {
|
|
35
|
+
media_0.removeEventListener("change", onChange);
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
useEffect(t4, t5);
|
|
62
|
-
let t6;
|
|
63
|
-
let t7;
|
|
64
|
-
if ($[6] !== systemTheme || $[7] !== theme) {
|
|
65
|
-
t6 = () => {
|
|
66
|
-
document.documentElement.classList.remove("dark");
|
|
67
|
-
if ((!theme || theme === "system") && systemTheme === "dark" || theme === "dark") {
|
|
68
|
-
document.documentElement.classList.add("dark");
|
|
69
|
-
document.documentElement.style.colorScheme = "dark";
|
|
70
|
-
} else if (theme === "light") {
|
|
71
|
-
document.documentElement.classList.add("light");
|
|
72
|
-
document.documentElement.style.colorScheme = "light";
|
|
73
|
-
} else document.documentElement.style.colorScheme = "light";
|
|
74
|
-
};
|
|
75
|
-
t7 = [theme, systemTheme];
|
|
76
|
-
$[6] = systemTheme;
|
|
77
|
-
$[7] = theme;
|
|
78
|
-
$[8] = t6;
|
|
79
|
-
$[9] = t7;
|
|
80
|
-
} else {
|
|
81
|
-
t6 = $[8];
|
|
82
|
-
t7 = $[9];
|
|
83
|
-
}
|
|
84
|
-
useEffect(t6, t7);
|
|
85
|
-
const t8 = theme ?? "system";
|
|
86
|
-
let t9;
|
|
87
|
-
if ($[10] !== systemTheme || $[11] !== t8 || $[12] !== updateTheme) {
|
|
88
|
-
t9 = {
|
|
89
|
-
theme: t8,
|
|
90
|
-
systemTheme,
|
|
91
|
-
updateTheme
|
|
92
|
-
};
|
|
93
|
-
$[10] = systemTheme;
|
|
94
|
-
$[11] = t8;
|
|
95
|
-
$[12] = updateTheme;
|
|
96
|
-
$[13] = t9;
|
|
97
|
-
} else t9 = $[13];
|
|
98
|
-
const contextValue = t9;
|
|
99
|
-
let t10;
|
|
100
|
-
if ($[14] !== children || $[15] !== contextValue) {
|
|
101
|
-
t10 = /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
102
|
-
value: contextValue,
|
|
103
|
-
children
|
|
104
|
-
});
|
|
105
|
-
$[14] = children;
|
|
106
|
-
$[15] = contextValue;
|
|
107
|
-
$[16] = t10;
|
|
108
|
-
} else t10 = $[16];
|
|
109
|
-
return t10;
|
|
37
|
+
}, []);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
document.documentElement.classList.remove("dark");
|
|
40
|
+
if ((!theme || theme === "system") && systemTheme === "dark" || theme === "dark") {
|
|
41
|
+
document.documentElement.classList.add("dark");
|
|
42
|
+
document.documentElement.style.colorScheme = "dark";
|
|
43
|
+
} else if (theme === "light") {
|
|
44
|
+
document.documentElement.classList.add("light");
|
|
45
|
+
document.documentElement.style.colorScheme = "light";
|
|
46
|
+
} else document.documentElement.style.colorScheme = "light";
|
|
47
|
+
}, [theme, systemTheme]);
|
|
48
|
+
const contextValue = useMemo(() => ({
|
|
49
|
+
theme: theme ?? "system",
|
|
50
|
+
systemTheme,
|
|
51
|
+
updateTheme
|
|
52
|
+
}), [
|
|
53
|
+
theme,
|
|
54
|
+
systemTheme,
|
|
55
|
+
updateTheme
|
|
56
|
+
]);
|
|
57
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
58
|
+
value: contextValue,
|
|
59
|
+
children
|
|
60
|
+
});
|
|
110
61
|
};
|
|
111
62
|
_ThemeContext.useTheme = () => {
|
|
112
63
|
return use(ThemeContext);
|
|
113
64
|
};
|
|
114
65
|
})(ThemeContext || (ThemeContext = {}));
|
|
115
|
-
function _temp() {
|
|
116
|
-
if (typeof window === "undefined") return;
|
|
117
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
118
|
-
}
|
|
119
66
|
//#endregion
|
|
120
67
|
export { ThemeContext };
|
|
@@ -3,7 +3,6 @@ import { ClockIcon } from "../assets/icons/Clock.js";
|
|
|
3
3
|
import { DateTimeIcon } from "../assets/icons/DateTime.js";
|
|
4
4
|
import { ObjectUtils } from "../utils/object.utils.js";
|
|
5
5
|
import { useDeepCompareMemo } from "../hooks/useDeepCompare.js";
|
|
6
|
-
import { c } from "react/compiler-runtime";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
8
7
|
import { createContext, use } from "react";
|
|
9
8
|
//#region src/config/uiConfig.context.tsx
|
|
@@ -115,42 +114,15 @@ var UIConfig;
|
|
|
115
114
|
}
|
|
116
115
|
};
|
|
117
116
|
const Context = createContext(DEFAULT_CONFIG);
|
|
118
|
-
_UIConfig.Provider = (
|
|
119
|
-
const $ = c(9);
|
|
120
|
-
const { config: t1, children } = t0;
|
|
121
|
-
let t2;
|
|
122
|
-
if ($[0] !== t1) {
|
|
123
|
-
t2 = t1 === void 0 ? {} : t1;
|
|
124
|
-
$[0] = t1;
|
|
125
|
-
$[1] = t2;
|
|
126
|
-
} else t2 = $[1];
|
|
127
|
-
const config = t2;
|
|
117
|
+
_UIConfig.Provider = ({ config = {}, children }) => {
|
|
128
118
|
const parentConfig = use(Context) || DEFAULT_CONFIG;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
$[4] = t3;
|
|
137
|
-
$[5] = t4;
|
|
138
|
-
} else {
|
|
139
|
-
t3 = $[4];
|
|
140
|
-
t4 = $[5];
|
|
141
|
-
}
|
|
142
|
-
const value = useDeepCompareMemo(t3, t4);
|
|
143
|
-
let t5;
|
|
144
|
-
if ($[6] !== children || $[7] !== value) {
|
|
145
|
-
t5 = /* @__PURE__ */ jsx(Context.Provider, {
|
|
146
|
-
value,
|
|
147
|
-
children
|
|
148
|
-
});
|
|
149
|
-
$[6] = children;
|
|
150
|
-
$[7] = value;
|
|
151
|
-
$[8] = t5;
|
|
152
|
-
} else t5 = $[8];
|
|
153
|
-
return t5;
|
|
119
|
+
const value = useDeepCompareMemo(() => {
|
|
120
|
+
return ObjectUtils.deepConditionalMerge(parentConfig, config, (val) => val !== null && val !== void 0);
|
|
121
|
+
}, [config, parentConfig]);
|
|
122
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
123
|
+
value,
|
|
124
|
+
children
|
|
125
|
+
});
|
|
154
126
|
};
|
|
155
127
|
_UIConfig.useConfig = () => {
|
|
156
128
|
const context = use(Context);
|
|
@@ -158,8 +130,5 @@ var UIConfig;
|
|
|
158
130
|
return context;
|
|
159
131
|
};
|
|
160
132
|
})(UIConfig || (UIConfig = {}));
|
|
161
|
-
function _temp(val) {
|
|
162
|
-
return val !== null && val !== void 0;
|
|
163
|
-
}
|
|
164
133
|
//#endregion
|
|
165
134
|
export { UIConfig };
|
|
@@ -1,59 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
2
|
//#region src/hooks/useDebounceCallback.ts
|
|
4
|
-
function useDebounceCallback(callback,
|
|
5
|
-
const $ = c(10);
|
|
6
|
-
let t1;
|
|
7
|
-
if ($[0] !== t0) {
|
|
8
|
-
t1 = t0 === void 0 ? {} : t0;
|
|
9
|
-
$[0] = t0;
|
|
10
|
-
$[1] = t1;
|
|
11
|
-
} else t1 = $[1];
|
|
12
|
-
const { delay: t2 } = t1;
|
|
13
|
-
const delay = t2 === void 0 ? 500 : t2;
|
|
3
|
+
function useDebounceCallback(callback, { delay = 500 } = {}) {
|
|
14
4
|
const timeoutRef = useRef(null);
|
|
15
5
|
const [isDebouncing, setIsDebouncing] = useState(false);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
const debouncedCallback = useCallback((...args) => {
|
|
7
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
8
|
+
setIsDebouncing(true);
|
|
9
|
+
timeoutRef.current = setTimeout(() => {
|
|
10
|
+
setIsDebouncing(false);
|
|
11
|
+
callback?.(...args);
|
|
12
|
+
}, delay);
|
|
13
|
+
}, [callback, delay]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
return () => {
|
|
20
16
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
21
|
-
setIsDebouncing(true);
|
|
22
|
-
timeoutRef.current = setTimeout(() => {
|
|
23
|
-
setIsDebouncing(false);
|
|
24
|
-
callback?.(...args);
|
|
25
|
-
}, delay);
|
|
26
17
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
let t4;
|
|
33
|
-
let t5;
|
|
34
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
35
|
-
t4 = () => () => {
|
|
36
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
37
|
-
};
|
|
38
|
-
t5 = [];
|
|
39
|
-
$[5] = t4;
|
|
40
|
-
$[6] = t5;
|
|
41
|
-
} else {
|
|
42
|
-
t4 = $[5];
|
|
43
|
-
t5 = $[6];
|
|
44
|
-
}
|
|
45
|
-
useEffect(t4, t5);
|
|
46
|
-
let t6;
|
|
47
|
-
if ($[7] !== debouncedCallback || $[8] !== isDebouncing) {
|
|
48
|
-
t6 = {
|
|
49
|
-
callback: debouncedCallback,
|
|
50
|
-
isDebouncing
|
|
51
|
-
};
|
|
52
|
-
$[7] = debouncedCallback;
|
|
53
|
-
$[8] = isDebouncing;
|
|
54
|
-
$[9] = t6;
|
|
55
|
-
} else t6 = $[9];
|
|
56
|
-
return t6;
|
|
18
|
+
}, []);
|
|
19
|
+
return {
|
|
20
|
+
callback: debouncedCallback,
|
|
21
|
+
isDebouncing
|
|
22
|
+
};
|
|
57
23
|
}
|
|
58
24
|
//#endregion
|
|
59
25
|
export { useDebounceCallback };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ObjectUtils } from "../utils/object.utils.js";
|
|
2
2
|
import { useAutosave } from "./useAutosave.js";
|
|
3
3
|
import { useForm } from "./useForm.js";
|
|
4
|
-
import {
|
|
5
|
-
import { useEffect, useRef } from "react";
|
|
4
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
6
5
|
//#region src/hooks/useFormAutosave.ts
|
|
7
6
|
var getResetTimeoutErrorMessage = (resetTimeout) => `Form Reset Timeout (${resetTimeout}ms) - Action Required
|
|
8
7
|
Problem: Form values weren't reset after submission.
|
|
@@ -16,130 +15,44 @@ Solutions:
|
|
|
16
15
|
1. Ensure reset dependencies include all relevant state variables
|
|
17
16
|
2. Confirm your submission handler updates state properly (check query invalidation)
|
|
18
17
|
3. For slower operations, consider increasing the timeout threshold`;
|
|
19
|
-
function useFormAutosave(
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
let normalizeAutosaveData;
|
|
25
|
-
let onAutosave;
|
|
26
|
-
let props;
|
|
27
|
-
let resetDeps;
|
|
28
|
-
let t1;
|
|
29
|
-
let t2;
|
|
30
|
-
if ($[0] !== t0) {
|
|
31
|
-
({autosaveDelay, enableAutosave, autosaveOn: t1, normalizeAutosaveData, onAutosave, getResetValues, resetDeps, resetTimeout: t2, ...props} = t0);
|
|
32
|
-
$[0] = t0;
|
|
33
|
-
$[1] = autosaveDelay;
|
|
34
|
-
$[2] = enableAutosave;
|
|
35
|
-
$[3] = getResetValues;
|
|
36
|
-
$[4] = normalizeAutosaveData;
|
|
37
|
-
$[5] = onAutosave;
|
|
38
|
-
$[6] = props;
|
|
39
|
-
$[7] = resetDeps;
|
|
40
|
-
$[8] = t1;
|
|
41
|
-
$[9] = t2;
|
|
42
|
-
} else {
|
|
43
|
-
autosaveDelay = $[1];
|
|
44
|
-
enableAutosave = $[2];
|
|
45
|
-
getResetValues = $[3];
|
|
46
|
-
normalizeAutosaveData = $[4];
|
|
47
|
-
onAutosave = $[5];
|
|
48
|
-
props = $[6];
|
|
49
|
-
resetDeps = $[7];
|
|
50
|
-
t1 = $[8];
|
|
51
|
-
t2 = $[9];
|
|
52
|
-
}
|
|
53
|
-
const autosaveOn = t1 === void 0 ? "change" : t1;
|
|
54
|
-
const resetTimeout = t2 === void 0 ? 5e3 : t2;
|
|
55
|
-
let t3;
|
|
56
|
-
if ($[10] !== getResetValues) {
|
|
57
|
-
t3 = getResetValues();
|
|
58
|
-
$[10] = getResetValues;
|
|
59
|
-
$[11] = t3;
|
|
60
|
-
} else t3 = $[11];
|
|
61
|
-
let t4;
|
|
62
|
-
if ($[12] !== props || $[13] !== t3) {
|
|
63
|
-
t4 = {
|
|
64
|
-
...props,
|
|
65
|
-
defaultValues: t3
|
|
66
|
-
};
|
|
67
|
-
$[12] = props;
|
|
68
|
-
$[13] = t3;
|
|
69
|
-
$[14] = t4;
|
|
70
|
-
} else t4 = $[14];
|
|
71
|
-
const form = useForm(t4);
|
|
18
|
+
function useFormAutosave({ autosaveDelay, enableAutosave, autosaveOn = "change", normalizeAutosaveData, onAutosave, getResetValues, resetDeps, resetTimeout = 5e3, ...props }) {
|
|
19
|
+
const form = useForm({
|
|
20
|
+
...props,
|
|
21
|
+
defaultValues: getResetValues()
|
|
22
|
+
});
|
|
72
23
|
const shouldResetFormValuesRef = useRef(false);
|
|
73
24
|
const resetFormValuesTimeoutRef = useRef(void 0);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (ObjectUtils.isFunction(resetValues)) values = await resetValues();
|
|
84
|
-
form.reset(values, keepStateOptions);
|
|
85
|
-
};
|
|
86
|
-
resetFormValues();
|
|
87
|
-
};
|
|
88
|
-
$[15] = form;
|
|
89
|
-
$[16] = getResetValues;
|
|
90
|
-
$[17] = t5;
|
|
91
|
-
} else t5 = $[17];
|
|
92
|
-
let t6;
|
|
93
|
-
if ($[18] !== resetDeps) {
|
|
94
|
-
t6 = [...resetDeps];
|
|
95
|
-
$[18] = resetDeps;
|
|
96
|
-
$[19] = t6;
|
|
97
|
-
} else t6 = $[19];
|
|
98
|
-
useEffect(t5, t6);
|
|
99
|
-
let t7;
|
|
100
|
-
if ($[20] !== resetTimeout) {
|
|
101
|
-
t7 = () => {
|
|
102
|
-
shouldResetFormValuesRef.current = true;
|
|
103
|
-
if (resetFormValuesTimeoutRef.current) clearTimeout(resetFormValuesTimeoutRef.current);
|
|
104
|
-
resetFormValuesTimeoutRef.current = setTimeout(() => {
|
|
105
|
-
if (shouldResetFormValuesRef.current) throw new Error(getResetTimeoutErrorMessage(resetTimeout));
|
|
106
|
-
}, resetTimeout);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const resetValues = getResetValues();
|
|
27
|
+
if (resetValues === void 0) return;
|
|
28
|
+
const resetFormValues = async () => {
|
|
29
|
+
const keepStateOptions = shouldResetFormValuesRef.current ? { keepDirtyValues: true } : void 0;
|
|
30
|
+
shouldResetFormValuesRef.current = false;
|
|
31
|
+
let values = resetValues;
|
|
32
|
+
if (ObjectUtils.isFunction(resetValues)) values = await resetValues();
|
|
33
|
+
form.reset(values, keepStateOptions);
|
|
107
34
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
35
|
+
resetFormValues();
|
|
36
|
+
}, [...resetDeps]);
|
|
37
|
+
const onSaveSuccess = () => {
|
|
38
|
+
shouldResetFormValuesRef.current = true;
|
|
39
|
+
if (resetFormValuesTimeoutRef.current) clearTimeout(resetFormValuesTimeoutRef.current);
|
|
40
|
+
resetFormValuesTimeoutRef.current = setTimeout(() => {
|
|
41
|
+
if (shouldResetFormValuesRef.current) throw new Error(getResetTimeoutErrorMessage(resetTimeout));
|
|
42
|
+
}, resetTimeout);
|
|
43
|
+
};
|
|
44
|
+
useAutosave({
|
|
45
|
+
form,
|
|
46
|
+
delay: autosaveDelay,
|
|
47
|
+
enabled: enableAutosave,
|
|
48
|
+
trigger: autosaveOn,
|
|
49
|
+
onSave: useCallback((data) => {
|
|
115
50
|
const normalizedData = normalizeAutosaveData ? normalizeAutosaveData(data) : data;
|
|
116
51
|
if (!normalizedData || ObjectUtils.isEmpty(normalizedData)) return Promise.resolve(void 0);
|
|
117
52
|
return onAutosave(normalizedData);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
$[24] = t8;
|
|
122
|
-
} else t8 = $[24];
|
|
123
|
-
const onSave = t8;
|
|
124
|
-
let t9;
|
|
125
|
-
if ($[25] !== autosaveDelay || $[26] !== autosaveOn || $[27] !== enableAutosave || $[28] !== form || $[29] !== onSave || $[30] !== onSaveSuccess) {
|
|
126
|
-
t9 = {
|
|
127
|
-
form,
|
|
128
|
-
delay: autosaveDelay,
|
|
129
|
-
enabled: enableAutosave,
|
|
130
|
-
trigger: autosaveOn,
|
|
131
|
-
onSave,
|
|
132
|
-
onSaveSuccess
|
|
133
|
-
};
|
|
134
|
-
$[25] = autosaveDelay;
|
|
135
|
-
$[26] = autosaveOn;
|
|
136
|
-
$[27] = enableAutosave;
|
|
137
|
-
$[28] = form;
|
|
138
|
-
$[29] = onSave;
|
|
139
|
-
$[30] = onSaveSuccess;
|
|
140
|
-
$[31] = t9;
|
|
141
|
-
} else t9 = $[31];
|
|
142
|
-
useAutosave(t9);
|
|
53
|
+
}, [normalizeAutosaveData, onAutosave]),
|
|
54
|
+
onSaveSuccess
|
|
55
|
+
});
|
|
143
56
|
return form;
|
|
144
57
|
}
|
|
145
58
|
//#endregion
|