@easyvision/easyvision-ui 1.10.0 → 1.12.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 +45 -0
- package/dist/EasyVisionTable.css +27 -27
- package/dist/easyvision.css +221 -129
- package/dist/index.cjs +438 -164
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +333 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require('./easyvision.css');
|
|
4
4
|
require('./EasyVisionTable.css');
|
|
5
|
-
var
|
|
5
|
+
var React10 = require('react');
|
|
6
6
|
var lucideReact = require('lucide-react');
|
|
7
7
|
var clsx = require('clsx');
|
|
8
8
|
var tailwindMerge = require('tailwind-merge');
|
|
@@ -39,7 +39,7 @@ function _interopNamespace(e) {
|
|
|
39
39
|
return Object.freeze(n);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
var
|
|
42
|
+
var React10__namespace = /*#__PURE__*/_interopNamespace(React10);
|
|
43
43
|
var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
|
|
44
44
|
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
45
45
|
var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
|
|
@@ -49,7 +49,7 @@ var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMe
|
|
|
49
49
|
function cn(...inputs) {
|
|
50
50
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
51
51
|
}
|
|
52
|
-
var Input =
|
|
52
|
+
var Input = React10__namespace.forwardRef(
|
|
53
53
|
({ className, type, ...props }, ref) => {
|
|
54
54
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
55
55
|
"input",
|
|
@@ -113,26 +113,26 @@ var KIND_SUFFIX = {
|
|
|
113
113
|
var fullIdOf = (id, kind) => `${id}${KIND_SUFFIX[kind]}`;
|
|
114
114
|
var childIdOf = (parentFullId, childLocalId) => `${parentFullId}.${childLocalId}`;
|
|
115
115
|
var childFullIdOf = (parentFullId, childLocalId, childKind) => parentFullId ? `${childIdOf(parentFullId, childLocalId)}${KIND_SUFFIX[childKind]}` : fullIdOf(childLocalId, childKind);
|
|
116
|
-
var NamespaceContext =
|
|
116
|
+
var NamespaceContext = React10.createContext(null);
|
|
117
117
|
function NamespaceProvider({
|
|
118
118
|
fullId,
|
|
119
119
|
children
|
|
120
120
|
}) {
|
|
121
121
|
return /* @__PURE__ */ jsxRuntime.jsx(NamespaceContext.Provider, { value: fullId, children });
|
|
122
122
|
}
|
|
123
|
-
var useParentFullId = () =>
|
|
123
|
+
var useParentFullId = () => React10.useContext(NamespaceContext);
|
|
124
124
|
|
|
125
125
|
// store/useEasyVisionSlice.ts
|
|
126
126
|
function useEasyVisionSlice(kind, localId, opts) {
|
|
127
127
|
const parentFullId = useParentFullId();
|
|
128
|
-
const fullId =
|
|
128
|
+
const fullId = React10.useMemo(
|
|
129
129
|
() => childFullIdOf(parentFullId, localId, kind),
|
|
130
130
|
[parentFullId, localId, kind]
|
|
131
131
|
);
|
|
132
132
|
if (!easyVisionRegistry.getState().slices[fullId]) {
|
|
133
133
|
easyVisionRegistry.getState().ensure(kind, fullId, opts.init);
|
|
134
134
|
}
|
|
135
|
-
const slice =
|
|
135
|
+
const slice = React10.useSyncExternalStore(
|
|
136
136
|
easyVisionRegistry.subscribe,
|
|
137
137
|
() => {
|
|
138
138
|
const s = easyVisionRegistry.getState().slices[fullId];
|
|
@@ -141,27 +141,27 @@ function useEasyVisionSlice(kind, localId, opts) {
|
|
|
141
141
|
},
|
|
142
142
|
() => easyVisionRegistry.getState().ensure(kind, fullId, opts.init)
|
|
143
143
|
);
|
|
144
|
-
|
|
144
|
+
React10.useEffect(() => {
|
|
145
145
|
if (opts.clearWhen && opts.clearWhen(slice)) {
|
|
146
146
|
easyVisionRegistry.getState().drop(fullId);
|
|
147
147
|
easyVisionRegistry.getState().ensure(kind, fullId, opts.init);
|
|
148
148
|
}
|
|
149
149
|
}, [slice, fullId, kind, opts]);
|
|
150
|
-
|
|
150
|
+
React10.useEffect(() => {
|
|
151
151
|
opts.onStateChange?.(slice);
|
|
152
152
|
}, [slice]);
|
|
153
|
-
|
|
153
|
+
React10.useEffect(() => {
|
|
154
154
|
return () => {
|
|
155
155
|
if (!opts.persist) {
|
|
156
156
|
easyVisionRegistry.getState().drop(fullId);
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
159
|
}, [fullId]);
|
|
160
|
-
const patch =
|
|
160
|
+
const patch = React10.useMemo(
|
|
161
161
|
() => (partial) => easyVisionRegistry.getState().patch(fullId, partial),
|
|
162
162
|
[fullId]
|
|
163
163
|
);
|
|
164
|
-
const reset =
|
|
164
|
+
const reset = React10.useMemo(
|
|
165
165
|
() => () => {
|
|
166
166
|
easyVisionRegistry.getState().drop(fullId);
|
|
167
167
|
easyVisionRegistry.getState().ensure(kind, fullId, opts.init);
|
|
@@ -171,8 +171,8 @@ function useEasyVisionSlice(kind, localId, opts) {
|
|
|
171
171
|
return { fullId, slice, patch, reset };
|
|
172
172
|
}
|
|
173
173
|
function useDebouncedValue(value, delayMs) {
|
|
174
|
-
const [debounced, setDebounced] =
|
|
175
|
-
|
|
174
|
+
const [debounced, setDebounced] = React10.useState(value);
|
|
175
|
+
React10.useEffect(() => {
|
|
176
176
|
if (delayMs <= 0) {
|
|
177
177
|
setDebounced(value);
|
|
178
178
|
return;
|
|
@@ -205,8 +205,8 @@ function EasyVisionInput({
|
|
|
205
205
|
onStateChange: onStateChange ? (s) => onStateChange(s.value) : void 0
|
|
206
206
|
});
|
|
207
207
|
const debounced = useDebouncedValue(slice.value, debounceMs);
|
|
208
|
-
const lastEmittedRef =
|
|
209
|
-
|
|
208
|
+
const lastEmittedRef = React10.useRef(slice.value);
|
|
209
|
+
React10.useEffect(() => {
|
|
210
210
|
if (debounced !== lastEmittedRef.current) {
|
|
211
211
|
lastEmittedRef.current = debounced;
|
|
212
212
|
onChange?.(debounced);
|
|
@@ -257,7 +257,7 @@ function EasyVisionInput({
|
|
|
257
257
|
}
|
|
258
258
|
var Select = SelectPrimitive__namespace.Root;
|
|
259
259
|
var SelectValue = SelectPrimitive__namespace.Value;
|
|
260
|
-
var SelectTrigger =
|
|
260
|
+
var SelectTrigger = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
261
261
|
SelectPrimitive__namespace.Trigger,
|
|
262
262
|
{
|
|
263
263
|
ref,
|
|
@@ -270,7 +270,7 @@ var SelectTrigger = React9__namespace.forwardRef(({ className, children, ...prop
|
|
|
270
270
|
}
|
|
271
271
|
));
|
|
272
272
|
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
|
|
273
|
-
var SelectScrollUpButton =
|
|
273
|
+
var SelectScrollUpButton = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
274
274
|
SelectPrimitive__namespace.ScrollUpButton,
|
|
275
275
|
{
|
|
276
276
|
ref,
|
|
@@ -280,7 +280,7 @@ var SelectScrollUpButton = React9__namespace.forwardRef(({ className, ...props }
|
|
|
280
280
|
}
|
|
281
281
|
));
|
|
282
282
|
SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
|
|
283
|
-
var SelectScrollDownButton =
|
|
283
|
+
var SelectScrollDownButton = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
284
284
|
SelectPrimitive__namespace.ScrollDownButton,
|
|
285
285
|
{
|
|
286
286
|
ref,
|
|
@@ -290,7 +290,7 @@ var SelectScrollDownButton = React9__namespace.forwardRef(({ className, ...props
|
|
|
290
290
|
}
|
|
291
291
|
));
|
|
292
292
|
SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
|
|
293
|
-
var SelectContent =
|
|
293
|
+
var SelectContent = React10__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
294
294
|
SelectPrimitive__namespace.Content,
|
|
295
295
|
{
|
|
296
296
|
ref,
|
|
@@ -314,7 +314,7 @@ var SelectContent = React9__namespace.forwardRef(({ className, children, positio
|
|
|
314
314
|
}
|
|
315
315
|
) }));
|
|
316
316
|
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
|
|
317
|
-
var SelectLabel =
|
|
317
|
+
var SelectLabel = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
318
318
|
SelectPrimitive__namespace.Label,
|
|
319
319
|
{
|
|
320
320
|
ref,
|
|
@@ -323,7 +323,7 @@ var SelectLabel = React9__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
323
323
|
}
|
|
324
324
|
));
|
|
325
325
|
SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
|
|
326
|
-
var SelectItem =
|
|
326
|
+
var SelectItem = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
327
327
|
SelectPrimitive__namespace.Item,
|
|
328
328
|
{
|
|
329
329
|
ref,
|
|
@@ -336,7 +336,7 @@ var SelectItem = React9__namespace.forwardRef(({ className, children, ...props }
|
|
|
336
336
|
}
|
|
337
337
|
));
|
|
338
338
|
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
|
|
339
|
-
var SelectSeparator =
|
|
339
|
+
var SelectSeparator = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
340
340
|
SelectPrimitive__namespace.Separator,
|
|
341
341
|
{
|
|
342
342
|
ref,
|
|
@@ -367,7 +367,7 @@ var buttonVariants = classVarianceAuthority.cva("ev-btn", {
|
|
|
367
367
|
size: "default"
|
|
368
368
|
}
|
|
369
369
|
});
|
|
370
|
-
var Button =
|
|
370
|
+
var Button = React10__namespace.forwardRef(
|
|
371
371
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
372
372
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
373
373
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -383,7 +383,7 @@ var Button = React9__namespace.forwardRef(
|
|
|
383
383
|
Button.displayName = "Button";
|
|
384
384
|
var Popover = PopoverPrimitive__namespace.Root;
|
|
385
385
|
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
386
|
-
var PopoverContent =
|
|
386
|
+
var PopoverContent = React10__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
387
387
|
PopoverPrimitive__namespace.Content,
|
|
388
388
|
{
|
|
389
389
|
ref,
|
|
@@ -394,7 +394,7 @@ var PopoverContent = React9__namespace.forwardRef(({ className, align = "center"
|
|
|
394
394
|
}
|
|
395
395
|
) }));
|
|
396
396
|
PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
|
|
397
|
-
var Command =
|
|
397
|
+
var Command = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
398
398
|
cmdk.Command,
|
|
399
399
|
{
|
|
400
400
|
ref,
|
|
@@ -403,7 +403,7 @@ var Command = React9__namespace.forwardRef(({ className, ...props }, ref) => /*
|
|
|
403
403
|
}
|
|
404
404
|
));
|
|
405
405
|
Command.displayName = cmdk.Command.displayName;
|
|
406
|
-
var CommandInput =
|
|
406
|
+
var CommandInput = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ev-cmd-input-wrapper", "cmdk-input-wrapper": "", children: [
|
|
407
407
|
/* @__PURE__ */ jsxRuntime.jsx(reactIcons.MagnifyingGlassIcon, { className: "ev-cmd-input-icon" }),
|
|
408
408
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
409
409
|
cmdk.Command.Input,
|
|
@@ -415,7 +415,7 @@ var CommandInput = React9__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
415
415
|
)
|
|
416
416
|
] }));
|
|
417
417
|
CommandInput.displayName = cmdk.Command.Input.displayName;
|
|
418
|
-
var CommandList =
|
|
418
|
+
var CommandList = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
419
419
|
cmdk.Command.List,
|
|
420
420
|
{
|
|
421
421
|
ref,
|
|
@@ -424,7 +424,7 @@ var CommandList = React9__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
424
424
|
}
|
|
425
425
|
));
|
|
426
426
|
CommandList.displayName = cmdk.Command.List.displayName;
|
|
427
|
-
var CommandEmpty =
|
|
427
|
+
var CommandEmpty = React10__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
428
428
|
cmdk.Command.Empty,
|
|
429
429
|
{
|
|
430
430
|
ref,
|
|
@@ -433,7 +433,7 @@ var CommandEmpty = React9__namespace.forwardRef((props, ref) => /* @__PURE__ */
|
|
|
433
433
|
}
|
|
434
434
|
));
|
|
435
435
|
CommandEmpty.displayName = cmdk.Command.Empty.displayName;
|
|
436
|
-
var CommandGroup =
|
|
436
|
+
var CommandGroup = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
437
437
|
cmdk.Command.Group,
|
|
438
438
|
{
|
|
439
439
|
ref,
|
|
@@ -442,7 +442,7 @@ var CommandGroup = React9__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
442
442
|
}
|
|
443
443
|
));
|
|
444
444
|
CommandGroup.displayName = cmdk.Command.Group.displayName;
|
|
445
|
-
var CommandSeparator =
|
|
445
|
+
var CommandSeparator = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
446
446
|
cmdk.Command.Separator,
|
|
447
447
|
{
|
|
448
448
|
ref,
|
|
@@ -451,7 +451,7 @@ var CommandSeparator = React9__namespace.forwardRef(({ className, ...props }, re
|
|
|
451
451
|
}
|
|
452
452
|
));
|
|
453
453
|
CommandSeparator.displayName = cmdk.Command.Separator.displayName;
|
|
454
|
-
var CommandItem =
|
|
454
|
+
var CommandItem = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
455
455
|
cmdk.Command.Item,
|
|
456
456
|
{
|
|
457
457
|
ref,
|
|
@@ -485,10 +485,10 @@ function EasyVisionSelector({
|
|
|
485
485
|
onStateChange: onStateChange ? (s) => onStateChange(s.value) : void 0
|
|
486
486
|
});
|
|
487
487
|
const value = slice.value;
|
|
488
|
-
const [resolved, setResolved] =
|
|
488
|
+
const [resolved, setResolved] = React10.useState(
|
|
489
489
|
Array.isArray(options) ? options : null
|
|
490
490
|
);
|
|
491
|
-
|
|
491
|
+
React10.useEffect(() => {
|
|
492
492
|
if (typeof options === "function" && resolved === null) {
|
|
493
493
|
void options().then(setResolved).catch(() => setResolved([]));
|
|
494
494
|
} else if (Array.isArray(options)) {
|
|
@@ -496,10 +496,10 @@ function EasyVisionSelector({
|
|
|
496
496
|
}
|
|
497
497
|
}, [options, resolved]);
|
|
498
498
|
const opts = resolved ?? [];
|
|
499
|
-
const [pending, setPending] =
|
|
500
|
-
|
|
501
|
-
const lastEmittedRef =
|
|
502
|
-
|
|
499
|
+
const [pending, setPending] = React10.useState(value);
|
|
500
|
+
React10.useEffect(() => setPending(value), [value]);
|
|
501
|
+
const lastEmittedRef = React10.useRef(value);
|
|
502
|
+
React10.useEffect(() => {
|
|
503
503
|
if (value !== lastEmittedRef.current) {
|
|
504
504
|
lastEmittedRef.current = value;
|
|
505
505
|
onChange?.(value);
|
|
@@ -618,11 +618,11 @@ function TextWidget({ definition, value, onChange, onRemove }) {
|
|
|
618
618
|
}
|
|
619
619
|
var SENTINEL = "__easyvision_undef__";
|
|
620
620
|
function SelectorWidget({ definition, value, onChange, onRemove }) {
|
|
621
|
-
const [open, setOpen] =
|
|
622
|
-
const [resolved, setResolved] =
|
|
621
|
+
const [open, setOpen] = React10.useState(false);
|
|
622
|
+
const [resolved, setResolved] = React10.useState(
|
|
623
623
|
Array.isArray(definition.options) ? definition.options : null
|
|
624
624
|
);
|
|
625
|
-
|
|
625
|
+
React10.useEffect(() => {
|
|
626
626
|
if (typeof definition.options === "function" && resolved === null) {
|
|
627
627
|
void definition.options().then((o) => setResolved(o)).catch(() => setResolved([]));
|
|
628
628
|
} else if (Array.isArray(definition.options)) {
|
|
@@ -674,7 +674,7 @@ function SelectorWidget({ definition, value, onChange, onRemove }) {
|
|
|
674
674
|
)
|
|
675
675
|
] });
|
|
676
676
|
}
|
|
677
|
-
var Checkbox =
|
|
677
|
+
var Checkbox = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
678
678
|
CheckboxPrimitive__namespace.Root,
|
|
679
679
|
{
|
|
680
680
|
ref,
|
|
@@ -690,22 +690,22 @@ function MultiSelectWidget({
|
|
|
690
690
|
onChange,
|
|
691
691
|
onRemove
|
|
692
692
|
}) {
|
|
693
|
-
const [search, setSearch] =
|
|
694
|
-
const [open, setOpen] =
|
|
693
|
+
const [search, setSearch] = React10.useState("");
|
|
694
|
+
const [open, setOpen] = React10.useState(false);
|
|
695
695
|
const searchFn = definition.searchOptions;
|
|
696
696
|
const hasSearchOptions = typeof searchFn === "function";
|
|
697
|
-
const [resolved, setResolved] =
|
|
697
|
+
const [resolved, setResolved] = React10.useState(
|
|
698
698
|
Array.isArray(definition.options) ? definition.options : null
|
|
699
699
|
);
|
|
700
|
-
|
|
700
|
+
React10.useEffect(() => {
|
|
701
701
|
if (typeof definition.options === "function" && resolved === null) {
|
|
702
702
|
void definition.options().then(setResolved).catch(() => setResolved([]));
|
|
703
703
|
} else if (Array.isArray(definition.options)) {
|
|
704
704
|
setResolved(definition.options);
|
|
705
705
|
}
|
|
706
706
|
}, [definition.options, resolved]);
|
|
707
|
-
const [searchResults, setSearchResults] =
|
|
708
|
-
|
|
707
|
+
const [searchResults, setSearchResults] = React10.useState([]);
|
|
708
|
+
React10.useEffect(() => {
|
|
709
709
|
if (!searchFn) return;
|
|
710
710
|
if (search.trim() === "") {
|
|
711
711
|
setSearchResults([]);
|
|
@@ -726,11 +726,11 @@ function MultiSelectWidget({
|
|
|
726
726
|
}, [search, searchFn]);
|
|
727
727
|
const selected = Array.isArray(value) ? value : [];
|
|
728
728
|
const baseOpts = resolved ?? [];
|
|
729
|
-
const labelCache =
|
|
730
|
-
|
|
729
|
+
const labelCache = React10.useRef(/* @__PURE__ */ new Map());
|
|
730
|
+
React10.useEffect(() => {
|
|
731
731
|
baseOpts.forEach((o) => labelCache.current.set(o.value, o.label));
|
|
732
732
|
}, [baseOpts]);
|
|
733
|
-
const listOpts =
|
|
733
|
+
const listOpts = React10.useMemo(() => {
|
|
734
734
|
if (hasSearchOptions) return searchResults;
|
|
735
735
|
return baseOpts.filter(
|
|
736
736
|
(o) => o.label.toLowerCase().includes(search.toLowerCase())
|
|
@@ -1073,7 +1073,7 @@ function buildCondition(def, value) {
|
|
|
1073
1073
|
}
|
|
1074
1074
|
}
|
|
1075
1075
|
function useBuildQuery(config, values, childQueries) {
|
|
1076
|
-
return
|
|
1076
|
+
return React10.useCallback(() => {
|
|
1077
1077
|
const where = {};
|
|
1078
1078
|
if (config.searchField) {
|
|
1079
1079
|
const c = buildCondition(config.searchField, values[config.searchField.id]);
|
|
@@ -1153,13 +1153,229 @@ function isDirty(input, lastConfirmed) {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
return current !== lastConfirmed;
|
|
1155
1155
|
}
|
|
1156
|
+
var EMPTY = { items: [], defaultName: null };
|
|
1157
|
+
var isSavedFilter = (v) => typeof v === "object" && v !== null && typeof v.name === "string" && typeof v.filters === "object" && v.filters !== null;
|
|
1158
|
+
function readSaved(storage, key) {
|
|
1159
|
+
try {
|
|
1160
|
+
const raw = storage?.getItem(key);
|
|
1161
|
+
if (!raw) return EMPTY;
|
|
1162
|
+
const parsed = JSON.parse(raw);
|
|
1163
|
+
const items = (Array.isArray(parsed.items) ? parsed.items : []).filter(isSavedFilter).map((item) => ({ ...item, search: Array.isArray(item.search) ? item.search : [] }));
|
|
1164
|
+
const defaultName = typeof parsed.defaultName === "string" && items.some((i) => i.name === parsed.defaultName) ? parsed.defaultName : null;
|
|
1165
|
+
return { items, defaultName };
|
|
1166
|
+
} catch {
|
|
1167
|
+
return EMPTY;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
function writeSaved(storage, key, store) {
|
|
1171
|
+
try {
|
|
1172
|
+
storage?.setItem(key, JSON.stringify(store));
|
|
1173
|
+
} catch {
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
var pad = (n) => String(n).padStart(2, "0");
|
|
1177
|
+
function toDay(value) {
|
|
1178
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
1179
|
+
const date = value instanceof Date ? value : new Date(String(value));
|
|
1180
|
+
if (Number.isNaN(date.getTime())) return void 0;
|
|
1181
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
1182
|
+
}
|
|
1183
|
+
function fromDay(value) {
|
|
1184
|
+
if (typeof value !== "string" || !value) return void 0;
|
|
1185
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
1186
|
+
const date = m ? new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3])) : new Date(value);
|
|
1187
|
+
return Number.isNaN(date.getTime()) ? void 0 : date;
|
|
1188
|
+
}
|
|
1189
|
+
var savable = (fields) => new Map(fields.filter((f) => f.type !== "multifilter").map((f) => [f.id, f]));
|
|
1190
|
+
function toStored(values, fields) {
|
|
1191
|
+
const defs = savable(fields);
|
|
1192
|
+
const out = {};
|
|
1193
|
+
for (const [id, value] of Object.entries(values)) {
|
|
1194
|
+
const def = defs.get(id);
|
|
1195
|
+
if (!def || !isNonEmpty(value)) continue;
|
|
1196
|
+
if (def.type === "dateRange") {
|
|
1197
|
+
const range = value;
|
|
1198
|
+
const stored = {};
|
|
1199
|
+
const from = toDay(range.from);
|
|
1200
|
+
const to = toDay(range.to);
|
|
1201
|
+
if (from) stored.from = from;
|
|
1202
|
+
if (to) stored.to = to;
|
|
1203
|
+
if (Object.keys(stored).length > 0) out[id] = stored;
|
|
1204
|
+
} else {
|
|
1205
|
+
out[id] = value;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
return out;
|
|
1209
|
+
}
|
|
1210
|
+
function fromStored(filters, fields) {
|
|
1211
|
+
const defs = savable(fields);
|
|
1212
|
+
const out = {};
|
|
1213
|
+
for (const [id, value] of Object.entries(filters)) {
|
|
1214
|
+
const def = defs.get(id);
|
|
1215
|
+
if (!def) continue;
|
|
1216
|
+
if (def.type === "dateRange") {
|
|
1217
|
+
const range = value ?? {};
|
|
1218
|
+
const restored = {};
|
|
1219
|
+
const from = fromDay(range.from);
|
|
1220
|
+
const to = fromDay(range.to);
|
|
1221
|
+
if (from) restored.from = from;
|
|
1222
|
+
if (to) restored.to = to;
|
|
1223
|
+
if (restored.from || restored.to) out[id] = restored;
|
|
1224
|
+
} else if (def.type === "multiselect" && typeof value === "string") {
|
|
1225
|
+
out[id] = [value];
|
|
1226
|
+
} else {
|
|
1227
|
+
out[id] = value;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
return out;
|
|
1231
|
+
}
|
|
1232
|
+
function useSavedFilters(storageKey) {
|
|
1233
|
+
const storage = typeof window === "undefined" ? void 0 : window.localStorage;
|
|
1234
|
+
const [store, setStore] = React10.useState(
|
|
1235
|
+
() => storageKey ? readSaved(storage, storageKey) : EMPTY
|
|
1236
|
+
);
|
|
1237
|
+
const update = React10.useCallback(
|
|
1238
|
+
(next) => {
|
|
1239
|
+
setStore(next);
|
|
1240
|
+
if (storageKey) writeSaved(storage, storageKey, next);
|
|
1241
|
+
},
|
|
1242
|
+
[storage, storageKey]
|
|
1243
|
+
);
|
|
1244
|
+
const save = React10.useCallback(
|
|
1245
|
+
(name, filters) => {
|
|
1246
|
+
const saved = { name, filters, search: [] };
|
|
1247
|
+
const known = store.items.some((i) => i.name === name);
|
|
1248
|
+
const items = known ? store.items.map((i) => i.name === name ? saved : i) : [...store.items, saved];
|
|
1249
|
+
update({ ...store, items });
|
|
1250
|
+
},
|
|
1251
|
+
[store, update]
|
|
1252
|
+
);
|
|
1253
|
+
const remove = React10.useCallback(
|
|
1254
|
+
(name) => update({
|
|
1255
|
+
items: store.items.filter((i) => i.name !== name),
|
|
1256
|
+
defaultName: store.defaultName === name ? null : store.defaultName
|
|
1257
|
+
}),
|
|
1258
|
+
[store, update]
|
|
1259
|
+
);
|
|
1260
|
+
const setDefault = React10.useCallback(
|
|
1261
|
+
(name) => update({ ...store, defaultName: name }),
|
|
1262
|
+
[store, update]
|
|
1263
|
+
);
|
|
1264
|
+
return {
|
|
1265
|
+
items: store.items,
|
|
1266
|
+
defaultName: store.defaultName,
|
|
1267
|
+
defaultFilter: store.items.find((i) => i.name === store.defaultName),
|
|
1268
|
+
save,
|
|
1269
|
+
remove,
|
|
1270
|
+
setDefault
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
function SavedFiltersMenu({
|
|
1274
|
+
items,
|
|
1275
|
+
defaultName,
|
|
1276
|
+
canSave,
|
|
1277
|
+
labels,
|
|
1278
|
+
onApply,
|
|
1279
|
+
onSave,
|
|
1280
|
+
onDelete,
|
|
1281
|
+
onSetDefault
|
|
1282
|
+
}) {
|
|
1283
|
+
const [open, setOpen] = React10__namespace.useState(false);
|
|
1284
|
+
const [name, setName] = React10__namespace.useState("");
|
|
1285
|
+
const save = () => {
|
|
1286
|
+
const trimmed = name.trim();
|
|
1287
|
+
if (!trimmed || !canSave) return;
|
|
1288
|
+
onSave(trimmed);
|
|
1289
|
+
setName("");
|
|
1290
|
+
};
|
|
1291
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
1292
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", size: "sm", className: "ev-mf-saved-btn", children: [
|
|
1293
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bookmark, {}),
|
|
1294
|
+
labels.saved
|
|
1295
|
+
] }) }),
|
|
1296
|
+
/* @__PURE__ */ jsxRuntime.jsxs(PopoverContent, { className: "ev-mf-saved-popover", align: "start", children: [
|
|
1297
|
+
items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "ev-mf-saved-empty", children: labels.noSaved }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "ev-mf-saved-list", "aria-label": labels.saved, children: items.map((saved) => {
|
|
1298
|
+
const isDefault = saved.name === defaultName;
|
|
1299
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "ev-mf-saved-item", children: [
|
|
1300
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1301
|
+
"button",
|
|
1302
|
+
{
|
|
1303
|
+
type: "button",
|
|
1304
|
+
className: "ev-mf-saved-apply",
|
|
1305
|
+
onClick: () => {
|
|
1306
|
+
onApply(saved);
|
|
1307
|
+
setOpen(false);
|
|
1308
|
+
},
|
|
1309
|
+
children: saved.name
|
|
1310
|
+
}
|
|
1311
|
+
),
|
|
1312
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1313
|
+
"button",
|
|
1314
|
+
{
|
|
1315
|
+
type: "button",
|
|
1316
|
+
className: "ev-mf-saved-icon",
|
|
1317
|
+
"data-active": isDefault || void 0,
|
|
1318
|
+
"aria-pressed": isDefault,
|
|
1319
|
+
"aria-label": `${isDefault ? labels.unsetDefault : labels.setDefault}: ${saved.name}`,
|
|
1320
|
+
title: isDefault ? labels.unsetDefault : labels.setDefault,
|
|
1321
|
+
onClick: () => onSetDefault(isDefault ? null : saved.name),
|
|
1322
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Star, {})
|
|
1323
|
+
}
|
|
1324
|
+
),
|
|
1325
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1326
|
+
"button",
|
|
1327
|
+
{
|
|
1328
|
+
type: "button",
|
|
1329
|
+
className: "ev-mf-saved-icon",
|
|
1330
|
+
"aria-label": `${labels.deleteSaved}: ${saved.name}`,
|
|
1331
|
+
title: labels.deleteSaved,
|
|
1332
|
+
onClick: () => onDelete(saved.name),
|
|
1333
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, {})
|
|
1334
|
+
}
|
|
1335
|
+
)
|
|
1336
|
+
] }, saved.name);
|
|
1337
|
+
}) }),
|
|
1338
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1339
|
+
"form",
|
|
1340
|
+
{
|
|
1341
|
+
className: "ev-mf-saved-form",
|
|
1342
|
+
onSubmit: (e) => {
|
|
1343
|
+
e.preventDefault();
|
|
1344
|
+
save();
|
|
1345
|
+
},
|
|
1346
|
+
children: [
|
|
1347
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1348
|
+
Input,
|
|
1349
|
+
{
|
|
1350
|
+
value: name,
|
|
1351
|
+
onChange: (e) => setName(e.target.value),
|
|
1352
|
+
placeholder: canSave ? labels.saveNamePlaceholder : labels.nothingToSave,
|
|
1353
|
+
"aria-label": labels.saveNamePlaceholder,
|
|
1354
|
+
disabled: !canSave
|
|
1355
|
+
}
|
|
1356
|
+
),
|
|
1357
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", size: "sm", disabled: !canSave || !name.trim(), children: labels.save })
|
|
1358
|
+
]
|
|
1359
|
+
}
|
|
1360
|
+
)
|
|
1361
|
+
] })
|
|
1362
|
+
] });
|
|
1363
|
+
}
|
|
1156
1364
|
var DEFAULT_LABELS = {
|
|
1157
1365
|
search: "Buscar",
|
|
1158
1366
|
clear: "Limpiar",
|
|
1159
1367
|
perform: "Buscar",
|
|
1160
1368
|
addFilter: "A\xF1adir filtro",
|
|
1161
1369
|
noOptions: "Sin opciones",
|
|
1162
|
-
searchPlaceholder: "Buscar..."
|
|
1370
|
+
searchPlaceholder: "Buscar...",
|
|
1371
|
+
saved: "Guardados",
|
|
1372
|
+
noSaved: "A\xFAn no hay filtros guardados.",
|
|
1373
|
+
saveNamePlaceholder: "Nombre del filtro",
|
|
1374
|
+
nothingToSave: "Aplica una b\xFAsqueda para guardarla",
|
|
1375
|
+
save: "Guardar",
|
|
1376
|
+
setDefault: "Abrir siempre con este",
|
|
1377
|
+
unsetDefault: "Dejar de abrir con este",
|
|
1378
|
+
deleteSaved: "Borrar"
|
|
1163
1379
|
};
|
|
1164
1380
|
function isFieldVisible(def, values) {
|
|
1165
1381
|
if (def.visible === void 0) return true;
|
|
@@ -1170,7 +1386,7 @@ function isMandatorySatisfied(def, value) {
|
|
|
1170
1386
|
if (!def.mandatory) return true;
|
|
1171
1387
|
return isNonEmpty(value);
|
|
1172
1388
|
}
|
|
1173
|
-
var EasyVisionMultifilter =
|
|
1389
|
+
var EasyVisionMultifilter = React10.forwardRef(function EasyVisionMultifilter2(props, ref) {
|
|
1174
1390
|
const {
|
|
1175
1391
|
id,
|
|
1176
1392
|
config,
|
|
@@ -1190,12 +1406,13 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1190
1406
|
labels: labelOverrides,
|
|
1191
1407
|
className,
|
|
1192
1408
|
persist = false,
|
|
1193
|
-
clearWhen
|
|
1409
|
+
clearWhen,
|
|
1410
|
+
savedFilters
|
|
1194
1411
|
} = props;
|
|
1195
1412
|
const resolvedPerformMode = performMode === "live" ? "live" : "manual";
|
|
1196
1413
|
const labels = { ...DEFAULT_LABELS, ...labelOverrides };
|
|
1197
1414
|
const showClear = showClearAll ?? editable;
|
|
1198
|
-
const initialActive =
|
|
1415
|
+
const initialActive = React10.useMemo(() => {
|
|
1199
1416
|
const ids = [];
|
|
1200
1417
|
if (config.searchField) ids.push(config.searchField.id);
|
|
1201
1418
|
for (const f of config.fields) {
|
|
@@ -1203,7 +1420,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1203
1420
|
}
|
|
1204
1421
|
return ids;
|
|
1205
1422
|
}, [config]);
|
|
1206
|
-
const initialValues =
|
|
1423
|
+
const initialValues = React10.useMemo(() => {
|
|
1207
1424
|
const v = {};
|
|
1208
1425
|
if (config.searchField?.defaultValue !== void 0) {
|
|
1209
1426
|
v[config.searchField.id] = config.searchField.defaultValue;
|
|
@@ -1213,13 +1430,31 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1213
1430
|
}
|
|
1214
1431
|
return v;
|
|
1215
1432
|
}, [config]);
|
|
1433
|
+
const saved = useSavedFilters(savedFilters?.storageKey);
|
|
1434
|
+
const savedState = React10.useCallback(
|
|
1435
|
+
(item) => {
|
|
1436
|
+
const restored = fromStored(item.filters, config.fields);
|
|
1437
|
+
return {
|
|
1438
|
+
values: restored,
|
|
1439
|
+
activeFields: [.../* @__PURE__ */ new Set([...initialActive, ...Object.keys(restored)])]
|
|
1440
|
+
};
|
|
1441
|
+
},
|
|
1442
|
+
[config.fields, initialActive]
|
|
1443
|
+
);
|
|
1444
|
+
const openedWithDefaultRef = React10.useRef(false);
|
|
1216
1445
|
const { slice, fullId, patch } = useEasyVisionSlice("multifilter", id, {
|
|
1217
|
-
init: () =>
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1446
|
+
init: () => {
|
|
1447
|
+
if (saved.defaultFilter) {
|
|
1448
|
+
openedWithDefaultRef.current = true;
|
|
1449
|
+
return { kind: "multifilter", ...savedState(saved.defaultFilter), lastConfirmedSnapshotJSON: null };
|
|
1450
|
+
}
|
|
1451
|
+
return {
|
|
1452
|
+
kind: "multifilter",
|
|
1453
|
+
activeFields: initialActive,
|
|
1454
|
+
values: initialValues,
|
|
1455
|
+
lastConfirmedSnapshotJSON: null
|
|
1456
|
+
};
|
|
1457
|
+
},
|
|
1223
1458
|
persist,
|
|
1224
1459
|
clearWhen: clearWhen ? (s) => clearWhen({
|
|
1225
1460
|
values: s.values,
|
|
@@ -1230,12 +1465,12 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1230
1465
|
}) : void 0
|
|
1231
1466
|
});
|
|
1232
1467
|
const { activeFields, values, lastConfirmedSnapshotJSON } = slice;
|
|
1233
|
-
const registryState =
|
|
1468
|
+
const registryState = React10.useSyncExternalStore(
|
|
1234
1469
|
easyVisionRegistry.subscribe,
|
|
1235
1470
|
easyVisionRegistry.getState,
|
|
1236
1471
|
easyVisionRegistry.getState
|
|
1237
1472
|
);
|
|
1238
|
-
const childSnapshots =
|
|
1473
|
+
const childSnapshots = React10.useMemo(() => {
|
|
1239
1474
|
const out = {};
|
|
1240
1475
|
for (const f of config.fields) {
|
|
1241
1476
|
if (f.type !== "multifilter") continue;
|
|
@@ -1250,7 +1485,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1250
1485
|
}
|
|
1251
1486
|
return out;
|
|
1252
1487
|
}, [fullId, config.fields, registryState]);
|
|
1253
|
-
const childQueries =
|
|
1488
|
+
const childQueries = React10.useMemo(() => {
|
|
1254
1489
|
const out = {};
|
|
1255
1490
|
for (const f of config.fields) {
|
|
1256
1491
|
if (f.type !== "multifilter") continue;
|
|
@@ -1261,7 +1496,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1261
1496
|
return out;
|
|
1262
1497
|
}, [config.fields, childSnapshots]);
|
|
1263
1498
|
const buildQuery = useBuildQuery(config, values, childQueries);
|
|
1264
|
-
const composedValues =
|
|
1499
|
+
const composedValues = React10.useMemo(() => {
|
|
1265
1500
|
const out = { ...values };
|
|
1266
1501
|
for (const f of config.fields) {
|
|
1267
1502
|
if (f.type === "multifilter") {
|
|
@@ -1270,7 +1505,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1270
1505
|
}
|
|
1271
1506
|
return out;
|
|
1272
1507
|
}, [values, config.fields, childSnapshots]);
|
|
1273
|
-
const isValid =
|
|
1508
|
+
const isValid = React10.useMemo(() => {
|
|
1274
1509
|
if (config.searchField && !isMandatorySatisfied(config.searchField, values[config.searchField.id])) {
|
|
1275
1510
|
return false;
|
|
1276
1511
|
}
|
|
@@ -1292,15 +1527,15 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1292
1527
|
}
|
|
1293
1528
|
return true;
|
|
1294
1529
|
}, [config, values, childSnapshots]);
|
|
1295
|
-
const snapshotKey =
|
|
1530
|
+
const snapshotKey = React10.useMemo(
|
|
1296
1531
|
() => buildSnapshotKey({ activeFields, values: composedValues }),
|
|
1297
1532
|
[activeFields, composedValues]
|
|
1298
1533
|
);
|
|
1299
|
-
const dirty =
|
|
1534
|
+
const dirty = React10.useMemo(
|
|
1300
1535
|
() => isDirty({ activeFields, values: composedValues }, lastConfirmedSnapshotJSON),
|
|
1301
1536
|
[activeFields, composedValues, lastConfirmedSnapshotJSON]
|
|
1302
1537
|
);
|
|
1303
|
-
const snapshot =
|
|
1538
|
+
const snapshot = React10.useMemo(
|
|
1304
1539
|
() => ({
|
|
1305
1540
|
values: composedValues,
|
|
1306
1541
|
activeFields,
|
|
@@ -1310,15 +1545,15 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1310
1545
|
}),
|
|
1311
1546
|
[composedValues, activeFields, isValid, dirty, buildQuery]
|
|
1312
1547
|
);
|
|
1313
|
-
const lastEmittedKeyRef =
|
|
1314
|
-
|
|
1548
|
+
const lastEmittedKeyRef = React10.useRef("");
|
|
1549
|
+
React10.useEffect(() => {
|
|
1315
1550
|
const key = `${snapshotKey}|${dirty}|${isValid}`;
|
|
1316
1551
|
if (key === lastEmittedKeyRef.current) return;
|
|
1317
1552
|
lastEmittedKeyRef.current = key;
|
|
1318
1553
|
onChange?.(snapshot);
|
|
1319
1554
|
onStateChange?.(snapshot);
|
|
1320
1555
|
}, [snapshotKey, dirty, isValid, snapshot, onChange, onStateChange]);
|
|
1321
|
-
const performAction =
|
|
1556
|
+
const performAction = React10.useCallback(() => {
|
|
1322
1557
|
const key = buildSnapshotKey({ activeFields, values: composedValues });
|
|
1323
1558
|
patch({ lastConfirmedSnapshotJSON: key });
|
|
1324
1559
|
if (onPerform) {
|
|
@@ -1326,16 +1561,19 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1326
1561
|
queueMicrotask(() => onPerform(emitted));
|
|
1327
1562
|
}
|
|
1328
1563
|
}, [activeFields, composedValues, patch, onPerform, snapshot]);
|
|
1329
|
-
const didPerformOnMountRef =
|
|
1330
|
-
|
|
1331
|
-
if (performOnMount && !didPerformOnMountRef.current && Object.values(composedValues).some(isNonEmpty)) {
|
|
1564
|
+
const didPerformOnMountRef = React10.useRef(false);
|
|
1565
|
+
React10.useEffect(() => {
|
|
1566
|
+
if ((performOnMount || openedWithDefaultRef.current) && !didPerformOnMountRef.current && Object.values(composedValues).some(isNonEmpty)) {
|
|
1332
1567
|
didPerformOnMountRef.current = true;
|
|
1333
1568
|
performAction();
|
|
1334
1569
|
}
|
|
1570
|
+
return () => {
|
|
1571
|
+
didPerformOnMountRef.current = false;
|
|
1572
|
+
};
|
|
1335
1573
|
}, [performOnMount]);
|
|
1336
|
-
const liveTimerRef =
|
|
1337
|
-
const livePrevKeyRef =
|
|
1338
|
-
|
|
1574
|
+
const liveTimerRef = React10.useRef(null);
|
|
1575
|
+
const livePrevKeyRef = React10.useRef(null);
|
|
1576
|
+
React10.useEffect(() => {
|
|
1339
1577
|
if (resolvedPerformMode !== "live") return;
|
|
1340
1578
|
if (livePrevKeyRef.current === null) {
|
|
1341
1579
|
livePrevKeyRef.current = snapshotKey;
|
|
@@ -1355,24 +1593,24 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1355
1593
|
}
|
|
1356
1594
|
};
|
|
1357
1595
|
}, [snapshotKey, resolvedPerformMode, performDebounceMs, performAction]);
|
|
1358
|
-
|
|
1596
|
+
React10.useImperativeHandle(ref, () => ({
|
|
1359
1597
|
perform: performAction,
|
|
1360
1598
|
getSnapshot: () => snapshot
|
|
1361
1599
|
}));
|
|
1362
|
-
const updateValue =
|
|
1600
|
+
const updateValue = React10.useCallback(
|
|
1363
1601
|
(fieldId, value) => {
|
|
1364
1602
|
patch({ values: { ...values, [fieldId]: value } });
|
|
1365
1603
|
},
|
|
1366
1604
|
[patch, values]
|
|
1367
1605
|
);
|
|
1368
|
-
const addField =
|
|
1606
|
+
const addField = React10.useCallback(
|
|
1369
1607
|
(fieldId) => {
|
|
1370
1608
|
if (activeFields.includes(fieldId)) return;
|
|
1371
1609
|
patch({ activeFields: [...activeFields, fieldId] });
|
|
1372
1610
|
},
|
|
1373
1611
|
[activeFields, patch]
|
|
1374
1612
|
);
|
|
1375
|
-
const removeField =
|
|
1613
|
+
const removeField = React10.useCallback(
|
|
1376
1614
|
(fieldId) => {
|
|
1377
1615
|
const nextValues = { ...values };
|
|
1378
1616
|
delete nextValues[fieldId];
|
|
@@ -1383,8 +1621,8 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1383
1621
|
},
|
|
1384
1622
|
[activeFields, values, patch]
|
|
1385
1623
|
);
|
|
1386
|
-
const [clearTick, setClearTick] =
|
|
1387
|
-
const clearAll =
|
|
1624
|
+
const [clearTick, setClearTick] = React10.useState(0);
|
|
1625
|
+
const clearAll = React10.useCallback(() => {
|
|
1388
1626
|
patch({
|
|
1389
1627
|
values: initialValues,
|
|
1390
1628
|
activeFields: initialActive,
|
|
@@ -1394,25 +1632,44 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1394
1632
|
setClearTick((n) => n + 1);
|
|
1395
1633
|
}
|
|
1396
1634
|
}, [patch, initialValues, initialActive, lastConfirmedSnapshotJSON, resolvedPerformMode]);
|
|
1397
|
-
|
|
1635
|
+
const applySaved = React10.useCallback(
|
|
1636
|
+
(item) => {
|
|
1637
|
+
patch({ ...savedState(item), lastConfirmedSnapshotJSON: null });
|
|
1638
|
+
if (resolvedPerformMode !== "live") setClearTick((n) => n + 1);
|
|
1639
|
+
},
|
|
1640
|
+
[patch, savedState, resolvedPerformMode]
|
|
1641
|
+
);
|
|
1642
|
+
const appliedValues = React10.useMemo(() => {
|
|
1643
|
+
if (!lastConfirmedSnapshotJSON) return {};
|
|
1644
|
+
try {
|
|
1645
|
+
return JSON.parse(lastConfirmedSnapshotJSON).values ?? {};
|
|
1646
|
+
} catch {
|
|
1647
|
+
return {};
|
|
1648
|
+
}
|
|
1649
|
+
}, [lastConfirmedSnapshotJSON]);
|
|
1650
|
+
const appliedToSave = React10.useMemo(
|
|
1651
|
+
() => toStored(appliedValues, config.fields),
|
|
1652
|
+
[appliedValues, config.fields]
|
|
1653
|
+
);
|
|
1654
|
+
React10.useEffect(() => {
|
|
1398
1655
|
if (clearTick > 0) performAction();
|
|
1399
1656
|
}, [clearTick]);
|
|
1400
|
-
const visibleConfigFields =
|
|
1657
|
+
const visibleConfigFields = React10.useMemo(
|
|
1401
1658
|
() => config.fields.filter((f) => isFieldVisible(f, composedValues)),
|
|
1402
1659
|
[config.fields, composedValues]
|
|
1403
1660
|
);
|
|
1404
1661
|
const isProminentTextField = (f) => f.type === "text" && f.prominent === true;
|
|
1405
|
-
const pinnedFields =
|
|
1662
|
+
const pinnedFields = React10.useMemo(
|
|
1406
1663
|
() => visibleConfigFields.filter((f) => f.pinned && !isProminentTextField(f)),
|
|
1407
1664
|
[visibleConfigFields]
|
|
1408
1665
|
);
|
|
1409
|
-
const chipFields =
|
|
1666
|
+
const chipFields = React10.useMemo(
|
|
1410
1667
|
() => visibleConfigFields.filter(
|
|
1411
1668
|
(f) => !f.pinned && !isProminentTextField(f) && activeFields.includes(f.id)
|
|
1412
1669
|
),
|
|
1413
1670
|
[visibleConfigFields, activeFields]
|
|
1414
1671
|
);
|
|
1415
|
-
const prominentSlots =
|
|
1672
|
+
const prominentSlots = React10.useMemo(() => {
|
|
1416
1673
|
const slots = [];
|
|
1417
1674
|
if (config.searchField) {
|
|
1418
1675
|
slots.push({
|
|
@@ -1433,7 +1690,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1433
1690
|
}
|
|
1434
1691
|
return slots;
|
|
1435
1692
|
}, [config.searchField, visibleConfigFields, activeFields, editable]);
|
|
1436
|
-
const availableToAdd =
|
|
1693
|
+
const availableToAdd = React10.useMemo(
|
|
1437
1694
|
() => visibleConfigFields.filter(
|
|
1438
1695
|
(f) => !f.pinned && !activeFields.includes(f.id)
|
|
1439
1696
|
),
|
|
@@ -1555,6 +1812,19 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1555
1812
|
]
|
|
1556
1813
|
}
|
|
1557
1814
|
),
|
|
1815
|
+
savedFilters && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1816
|
+
SavedFiltersMenu,
|
|
1817
|
+
{
|
|
1818
|
+
items: saved.items,
|
|
1819
|
+
defaultName: saved.defaultName,
|
|
1820
|
+
canSave: Object.keys(appliedToSave).length > 0,
|
|
1821
|
+
labels,
|
|
1822
|
+
onApply: applySaved,
|
|
1823
|
+
onSave: (name) => saved.save(name, appliedToSave),
|
|
1824
|
+
onDelete: saved.remove,
|
|
1825
|
+
onSetDefault: saved.setDefault
|
|
1826
|
+
}
|
|
1827
|
+
),
|
|
1558
1828
|
showClear && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1559
1829
|
Button,
|
|
1560
1830
|
{
|
|
@@ -1635,17 +1905,17 @@ function buildChildQueryDirect(field, values) {
|
|
|
1635
1905
|
return Object.keys(where).length > 0 ? { where } : {};
|
|
1636
1906
|
}
|
|
1637
1907
|
var join = (...parts) => parts.filter(Boolean).join(" ");
|
|
1638
|
-
var EasyVisionCard =
|
|
1908
|
+
var EasyVisionCard = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card", className), ...props }));
|
|
1639
1909
|
EasyVisionCard.displayName = "EasyVisionCard";
|
|
1640
|
-
var EasyVisionCardHeader =
|
|
1910
|
+
var EasyVisionCardHeader = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-header", className), ...props }));
|
|
1641
1911
|
EasyVisionCardHeader.displayName = "EasyVisionCardHeader";
|
|
1642
|
-
var EasyVisionCardTitle =
|
|
1912
|
+
var EasyVisionCardTitle = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h3", { ref, className: join("ev-card-title", className), ...props, children }));
|
|
1643
1913
|
EasyVisionCardTitle.displayName = "EasyVisionCardTitle";
|
|
1644
|
-
var EasyVisionCardDescription =
|
|
1914
|
+
var EasyVisionCardDescription = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("p", { ref, className: join("ev-card-description", className), ...props }));
|
|
1645
1915
|
EasyVisionCardDescription.displayName = "EasyVisionCardDescription";
|
|
1646
|
-
var EasyVisionCardContent =
|
|
1916
|
+
var EasyVisionCardContent = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-content", className), ...props }));
|
|
1647
1917
|
EasyVisionCardContent.displayName = "EasyVisionCardContent";
|
|
1648
|
-
var EasyVisionCardFooter =
|
|
1918
|
+
var EasyVisionCardFooter = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-footer", className), ...props }));
|
|
1649
1919
|
EasyVisionCardFooter.displayName = "EasyVisionCardFooter";
|
|
1650
1920
|
var join2 = (...parts) => parts.filter(Boolean).join(" ");
|
|
1651
1921
|
function EasyVisionAccordionItem(_props) {
|
|
@@ -1654,8 +1924,8 @@ function EasyVisionAccordionItem(_props) {
|
|
|
1654
1924
|
EasyVisionAccordionItem.displayName = "EasyVisionAccordionItem";
|
|
1655
1925
|
function normalizeFromChildren(children) {
|
|
1656
1926
|
const out = [];
|
|
1657
|
-
|
|
1658
|
-
if (!
|
|
1927
|
+
React10__namespace.Children.forEach(children, (child) => {
|
|
1928
|
+
if (!React10__namespace.isValidElement(child)) return;
|
|
1659
1929
|
if (child.type !== EasyVisionAccordionItem) return;
|
|
1660
1930
|
const p = child.props;
|
|
1661
1931
|
out.push({
|
|
@@ -1719,20 +1989,20 @@ function EasyVisionAccordion({
|
|
|
1719
1989
|
onOpenChange,
|
|
1720
1990
|
className
|
|
1721
1991
|
}) {
|
|
1722
|
-
const normalized =
|
|
1992
|
+
const normalized = React10__namespace.useMemo(
|
|
1723
1993
|
() => items ? normalizeFromItems(items) : normalizeFromChildren(children),
|
|
1724
1994
|
[items, children]
|
|
1725
1995
|
);
|
|
1726
1996
|
const isControlled = openIds !== void 0;
|
|
1727
|
-
const [internalOpen, setInternalOpen] =
|
|
1997
|
+
const [internalOpen, setInternalOpen] = React10__namespace.useState(() => {
|
|
1728
1998
|
if (defaultOpenIds) return new Set(defaultOpenIds);
|
|
1729
1999
|
return new Set(normalized.filter((it) => it.defaultOpen).map((it) => it.id));
|
|
1730
2000
|
});
|
|
1731
|
-
const openSet =
|
|
2001
|
+
const openSet = React10__namespace.useMemo(
|
|
1732
2002
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
1733
2003
|
[isControlled, openIds, internalOpen]
|
|
1734
2004
|
);
|
|
1735
|
-
const handleToggle =
|
|
2005
|
+
const handleToggle = React10__namespace.useCallback(
|
|
1736
2006
|
(id) => {
|
|
1737
2007
|
const next = new Set(openSet);
|
|
1738
2008
|
if (next.has(id)) {
|
|
@@ -1757,21 +2027,21 @@ function EasyVisionAccordion({
|
|
|
1757
2027
|
)) });
|
|
1758
2028
|
}
|
|
1759
2029
|
EasyVisionAccordion.displayName = "EasyVisionAccordion";
|
|
1760
|
-
var Table =
|
|
2030
|
+
var Table = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("table", { ref, className: cn("ev-table", className), ...props }));
|
|
1761
2031
|
Table.displayName = "Table";
|
|
1762
|
-
var TableHeader =
|
|
2032
|
+
var TableHeader = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className, ...props }));
|
|
1763
2033
|
TableHeader.displayName = "TableHeader";
|
|
1764
|
-
var TableBody =
|
|
2034
|
+
var TableBody = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { ref, className, ...props }));
|
|
1765
2035
|
TableBody.displayName = "TableBody";
|
|
1766
|
-
var TableFooter =
|
|
2036
|
+
var TableFooter = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tfoot", { ref, className, ...props }));
|
|
1767
2037
|
TableFooter.displayName = "TableFooter";
|
|
1768
|
-
var TableRow =
|
|
2038
|
+
var TableRow = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tr", { ref, className, ...props }));
|
|
1769
2039
|
TableRow.displayName = "TableRow";
|
|
1770
|
-
var TableHead =
|
|
2040
|
+
var TableHead = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("th", { ref, className, ...props }));
|
|
1771
2041
|
TableHead.displayName = "TableHead";
|
|
1772
|
-
var TableCell =
|
|
2042
|
+
var TableCell = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("td", { ref, className, ...props }));
|
|
1773
2043
|
TableCell.displayName = "TableCell";
|
|
1774
|
-
var TableCaption =
|
|
2044
|
+
var TableCaption = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("caption", { ref, className, ...props }));
|
|
1775
2045
|
TableCaption.displayName = "TableCaption";
|
|
1776
2046
|
var isNestedField = (field) => field.includes(".");
|
|
1777
2047
|
var resolvePath = (obj, path) => path.split(".").reduce(
|
|
@@ -1800,7 +2070,7 @@ function adaptColumns(columns, orderingMode, defaultSorting = "nonNested") {
|
|
|
1800
2070
|
};
|
|
1801
2071
|
const isUi = c.type === "ui";
|
|
1802
2072
|
const userCell = c.cell;
|
|
1803
|
-
const wrappedCell = userCell ? ({ row }) => userCell(row.original) : ({ getValue }) =>
|
|
2073
|
+
const wrappedCell = userCell ? ({ row }) => userCell(row.original) : ({ getValue }) => React10.createElement(
|
|
1804
2074
|
"span",
|
|
1805
2075
|
{ className: "text-sm text-foreground" },
|
|
1806
2076
|
String(getValue() ?? "-")
|
|
@@ -1890,7 +2160,7 @@ function useTableData({
|
|
|
1890
2160
|
paginationMode,
|
|
1891
2161
|
orderingMode
|
|
1892
2162
|
}) {
|
|
1893
|
-
return
|
|
2163
|
+
return React10.useMemo(() => {
|
|
1894
2164
|
let rows = data ?? [];
|
|
1895
2165
|
if (orderingMode === "local" && sort) {
|
|
1896
2166
|
rows = sortLocalRows(rows, columns, sort);
|
|
@@ -1963,7 +2233,7 @@ async function fetchAllRows({
|
|
|
1963
2233
|
var DropdownMenu = DropdownMenuPrimitive__namespace.Root;
|
|
1964
2234
|
var DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
|
|
1965
2235
|
var DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
|
|
1966
|
-
var DropdownMenuSubTrigger =
|
|
2236
|
+
var DropdownMenuSubTrigger = React10__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1967
2237
|
DropdownMenuPrimitive__namespace.SubTrigger,
|
|
1968
2238
|
{
|
|
1969
2239
|
ref,
|
|
@@ -1980,7 +2250,7 @@ var DropdownMenuSubTrigger = React9__namespace.forwardRef(({ className, inset, c
|
|
|
1980
2250
|
}
|
|
1981
2251
|
));
|
|
1982
2252
|
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
|
|
1983
|
-
var DropdownMenuSubContent =
|
|
2253
|
+
var DropdownMenuSubContent = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1984
2254
|
DropdownMenuPrimitive__namespace.SubContent,
|
|
1985
2255
|
{
|
|
1986
2256
|
ref,
|
|
@@ -1989,7 +2259,7 @@ var DropdownMenuSubContent = React9__namespace.forwardRef(({ className, ...props
|
|
|
1989
2259
|
}
|
|
1990
2260
|
));
|
|
1991
2261
|
DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
|
|
1992
|
-
var DropdownMenuContent =
|
|
2262
|
+
var DropdownMenuContent = React10__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1993
2263
|
DropdownMenuPrimitive__namespace.Content,
|
|
1994
2264
|
{
|
|
1995
2265
|
ref,
|
|
@@ -1999,7 +2269,7 @@ var DropdownMenuContent = React9__namespace.forwardRef(({ className, sideOffset
|
|
|
1999
2269
|
}
|
|
2000
2270
|
) }));
|
|
2001
2271
|
DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
|
|
2002
|
-
var DropdownMenuItem =
|
|
2272
|
+
var DropdownMenuItem = React10__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2003
2273
|
DropdownMenuPrimitive__namespace.Item,
|
|
2004
2274
|
{
|
|
2005
2275
|
ref,
|
|
@@ -2012,7 +2282,7 @@ var DropdownMenuItem = React9__namespace.forwardRef(({ className, inset, ...prop
|
|
|
2012
2282
|
}
|
|
2013
2283
|
));
|
|
2014
2284
|
DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
|
|
2015
|
-
var DropdownMenuCheckboxItem =
|
|
2285
|
+
var DropdownMenuCheckboxItem = React10__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2016
2286
|
DropdownMenuPrimitive__namespace.CheckboxItem,
|
|
2017
2287
|
{
|
|
2018
2288
|
ref,
|
|
@@ -2026,7 +2296,7 @@ var DropdownMenuCheckboxItem = React9__namespace.forwardRef(({ className, childr
|
|
|
2026
2296
|
}
|
|
2027
2297
|
));
|
|
2028
2298
|
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
|
|
2029
|
-
var DropdownMenuRadioItem =
|
|
2299
|
+
var DropdownMenuRadioItem = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2030
2300
|
DropdownMenuPrimitive__namespace.RadioItem,
|
|
2031
2301
|
{
|
|
2032
2302
|
ref,
|
|
@@ -2039,7 +2309,7 @@ var DropdownMenuRadioItem = React9__namespace.forwardRef(({ className, children,
|
|
|
2039
2309
|
}
|
|
2040
2310
|
));
|
|
2041
2311
|
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
|
|
2042
|
-
var DropdownMenuLabel =
|
|
2312
|
+
var DropdownMenuLabel = React10__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2043
2313
|
DropdownMenuPrimitive__namespace.Label,
|
|
2044
2314
|
{
|
|
2045
2315
|
ref,
|
|
@@ -2052,7 +2322,7 @@ var DropdownMenuLabel = React9__namespace.forwardRef(({ className, inset, ...pro
|
|
|
2052
2322
|
}
|
|
2053
2323
|
));
|
|
2054
2324
|
DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
|
|
2055
|
-
var DropdownMenuSeparator =
|
|
2325
|
+
var DropdownMenuSeparator = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2056
2326
|
DropdownMenuPrimitive__namespace.Separator,
|
|
2057
2327
|
{
|
|
2058
2328
|
ref,
|
|
@@ -2542,7 +2812,7 @@ function EasyVisionTable(props) {
|
|
|
2542
2812
|
const lbIncludeKey = JSON.stringify(loopback?.include ?? null);
|
|
2543
2813
|
const lbFieldsKey = JSON.stringify(loopback?.fields ?? null);
|
|
2544
2814
|
const lbOrderKey = JSON.stringify(loopback?.defaultOrder ?? null);
|
|
2545
|
-
const loopbackFetcher =
|
|
2815
|
+
const loopbackFetcher = React10.useMemo(
|
|
2546
2816
|
() => loopback ? createLoopbackTableFetcher(loopback) : void 0,
|
|
2547
2817
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2548
2818
|
[lbFetchPage, lbFetchCount, lbIncludeKey, lbFieldsKey, lbOrderKey]
|
|
@@ -2551,7 +2821,7 @@ function EasyVisionTable(props) {
|
|
|
2551
2821
|
const igIncludeKey = JSON.stringify(ingot?.include ?? null);
|
|
2552
2822
|
const igFieldsKey = JSON.stringify(ingot?.fields ?? null);
|
|
2553
2823
|
const igOrderKey = JSON.stringify(ingot?.defaultOrder ?? null);
|
|
2554
|
-
const ingotFetcher =
|
|
2824
|
+
const ingotFetcher = React10.useMemo(
|
|
2555
2825
|
() => ingot ? createIngotTableFetcher(ingot) : void 0,
|
|
2556
2826
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2557
2827
|
[igFetchPage, igIncludeKey, igFieldsKey, igOrderKey]
|
|
@@ -2560,7 +2830,7 @@ function EasyVisionTable(props) {
|
|
|
2560
2830
|
const apiShortcut = Boolean(loopback || ingot);
|
|
2561
2831
|
const paginationMode = apiShortcut ? "api" : paginationModeProp;
|
|
2562
2832
|
const orderingMode = apiShortcut ? "api" : orderingModeProp;
|
|
2563
|
-
const getRowId =
|
|
2833
|
+
const getRowId = React10.useMemo(
|
|
2564
2834
|
() => getRowIdProp ?? ((row) => String(row?.id ?? "")),
|
|
2565
2835
|
[getRowIdProp]
|
|
2566
2836
|
);
|
|
@@ -2583,10 +2853,10 @@ function EasyVisionTable(props) {
|
|
|
2583
2853
|
persist
|
|
2584
2854
|
});
|
|
2585
2855
|
const { page, itemsPerPage, sort, selection } = slice;
|
|
2586
|
-
const lastSnapshotRef =
|
|
2587
|
-
const [localFilterTick, setLocalFilterTick] =
|
|
2588
|
-
const innerMultifilterRef =
|
|
2589
|
-
const setMultifilterRef =
|
|
2856
|
+
const lastSnapshotRef = React10.useRef(null);
|
|
2857
|
+
const [localFilterTick, setLocalFilterTick] = React10.useState(0);
|
|
2858
|
+
const innerMultifilterRef = React10.useRef(null);
|
|
2859
|
+
const setMultifilterRef = React10.useCallback(
|
|
2590
2860
|
(handle) => {
|
|
2591
2861
|
innerMultifilterRef.current = handle;
|
|
2592
2862
|
if (typeof multifilterRef === "function") {
|
|
@@ -2597,16 +2867,16 @@ function EasyVisionTable(props) {
|
|
|
2597
2867
|
},
|
|
2598
2868
|
[multifilterRef]
|
|
2599
2869
|
);
|
|
2600
|
-
const [apiRows, setApiRows] =
|
|
2601
|
-
const [apiTotalCount, setApiTotalCount] =
|
|
2602
|
-
const [apiLoading, setApiLoading] =
|
|
2603
|
-
const fetchSeqRef =
|
|
2870
|
+
const [apiRows, setApiRows] = React10.useState([]);
|
|
2871
|
+
const [apiTotalCount, setApiTotalCount] = React10.useState(0);
|
|
2872
|
+
const [apiLoading, setApiLoading] = React10.useState(false);
|
|
2873
|
+
const fetchSeqRef = React10.useRef(0);
|
|
2604
2874
|
const isApi = paginationMode === "api" || orderingMode === "api";
|
|
2605
|
-
const [eagerAllIds, setEagerAllIds] =
|
|
2606
|
-
const [eagerAllRows, setEagerAllRows] =
|
|
2607
|
-
const [isResolvingEager, setIsResolvingEager] =
|
|
2608
|
-
const eagerSeqRef =
|
|
2609
|
-
const runFetch =
|
|
2875
|
+
const [eagerAllIds, setEagerAllIds] = React10.useState(null);
|
|
2876
|
+
const [eagerAllRows, setEagerAllRows] = React10.useState([]);
|
|
2877
|
+
const [isResolvingEager, setIsResolvingEager] = React10.useState(false);
|
|
2878
|
+
const eagerSeqRef = React10.useRef(0);
|
|
2879
|
+
const runFetch = React10.useCallback(async () => {
|
|
2610
2880
|
if (!fetchData) return;
|
|
2611
2881
|
const seq = ++fetchSeqRef.current;
|
|
2612
2882
|
setApiLoading(true);
|
|
@@ -2626,10 +2896,14 @@ function EasyVisionTable(props) {
|
|
|
2626
2896
|
if (seq === fetchSeqRef.current) setApiLoading(false);
|
|
2627
2897
|
}
|
|
2628
2898
|
}, [fetchData, page, itemsPerPage, sort, externalFilter, onDataLoaded]);
|
|
2629
|
-
|
|
2630
|
-
if (isApi
|
|
2899
|
+
React10.useEffect(() => {
|
|
2900
|
+
if (!isApi || !fetchData) return;
|
|
2901
|
+
const seq = fetchSeqRef.current;
|
|
2902
|
+
queueMicrotask(() => {
|
|
2903
|
+
if (fetchSeqRef.current === seq) void runFetch();
|
|
2904
|
+
});
|
|
2631
2905
|
}, [isApi, page, itemsPerPage, sort, refetchSignal]);
|
|
2632
|
-
const resolveEagerAll =
|
|
2906
|
+
const resolveEagerAll = React10.useCallback(async () => {
|
|
2633
2907
|
if (!fetchData) return;
|
|
2634
2908
|
const collectRows = selectAllResolution === "eager";
|
|
2635
2909
|
const seq = ++eagerSeqRef.current;
|
|
@@ -2658,8 +2932,8 @@ function EasyVisionTable(props) {
|
|
|
2658
2932
|
if (seq === eagerSeqRef.current) setIsResolvingEager(false);
|
|
2659
2933
|
}
|
|
2660
2934
|
}, [fetchData, externalFilter, sort, getRowId, selectAllResolution]);
|
|
2661
|
-
const prevRefetchRef =
|
|
2662
|
-
|
|
2935
|
+
const prevRefetchRef = React10.useRef(refetchSignal);
|
|
2936
|
+
React10.useEffect(() => {
|
|
2663
2937
|
if (prevRefetchRef.current !== refetchSignal && page !== 1) {
|
|
2664
2938
|
prevRefetchRef.current = refetchSignal;
|
|
2665
2939
|
patch({ page: 1 });
|
|
@@ -2671,7 +2945,7 @@ function EasyVisionTable(props) {
|
|
|
2671
2945
|
eagerSeqRef.current++;
|
|
2672
2946
|
setIsResolvingEager(false);
|
|
2673
2947
|
}, [refetchSignal]);
|
|
2674
|
-
const filteredData =
|
|
2948
|
+
const filteredData = React10.useMemo(() => {
|
|
2675
2949
|
if (paginationMode !== "local") return data;
|
|
2676
2950
|
if (!data || data.length === 0) return data;
|
|
2677
2951
|
const mfWhere = lastSnapshotRef.current?.query?.where;
|
|
@@ -2692,11 +2966,11 @@ function EasyVisionTable(props) {
|
|
|
2692
2966
|
const rows = isApi ? apiRows : local.rows;
|
|
2693
2967
|
const totalCount = isApi ? apiTotalCount : local.totalCount;
|
|
2694
2968
|
const isLoading = isLoadingProp || apiLoading;
|
|
2695
|
-
const tanstackColumns =
|
|
2969
|
+
const tanstackColumns = React10.useMemo(
|
|
2696
2970
|
() => adaptColumns(columns, orderingMode, defaultSorting),
|
|
2697
2971
|
[columns, orderingMode, defaultSorting]
|
|
2698
2972
|
);
|
|
2699
|
-
const allColumns =
|
|
2973
|
+
const allColumns = React10.useMemo(() => {
|
|
2700
2974
|
if (!enableRowSelection) return tanstackColumns;
|
|
2701
2975
|
const checkboxCol = {
|
|
2702
2976
|
id: "_select",
|
|
@@ -2716,11 +2990,11 @@ function EasyVisionTable(props) {
|
|
|
2716
2990
|
};
|
|
2717
2991
|
return [checkboxCol, ...tanstackColumns];
|
|
2718
2992
|
}, [enableRowSelection, tanstackColumns]);
|
|
2719
|
-
const columnVisibility =
|
|
2993
|
+
const columnVisibility = React10.useMemo(
|
|
2720
2994
|
() => resolveColumnVisibility(columns, slice.columnVisibility),
|
|
2721
2995
|
[columns, slice.columnVisibility]
|
|
2722
2996
|
);
|
|
2723
|
-
const exportStateRef =
|
|
2997
|
+
const exportStateRef = React10.useRef({
|
|
2724
2998
|
columns,
|
|
2725
2999
|
columnVisibility,
|
|
2726
3000
|
selection,
|
|
@@ -2742,7 +3016,7 @@ function EasyVisionTable(props) {
|
|
|
2742
3016
|
isApi,
|
|
2743
3017
|
getRowId
|
|
2744
3018
|
};
|
|
2745
|
-
|
|
3019
|
+
React10.useEffect(() => {
|
|
2746
3020
|
registerExportSource(fullId, {
|
|
2747
3021
|
sheetName: id,
|
|
2748
3022
|
getColumns: () => {
|
|
@@ -2772,13 +3046,13 @@ function EasyVisionTable(props) {
|
|
|
2772
3046
|
});
|
|
2773
3047
|
return () => unregisterExportSource(fullId);
|
|
2774
3048
|
}, [fullId, id]);
|
|
2775
|
-
const resizableFields =
|
|
3049
|
+
const resizableFields = React10.useMemo(() => {
|
|
2776
3050
|
const s = /* @__PURE__ */ new Set();
|
|
2777
3051
|
for (const c of columns) if (c.resizable) s.add(c.field);
|
|
2778
3052
|
return s;
|
|
2779
3053
|
}, [columns]);
|
|
2780
3054
|
const columnSizing = slice.columnSizing;
|
|
2781
|
-
const rowSelection =
|
|
3055
|
+
const rowSelection = React10.useMemo(() => {
|
|
2782
3056
|
if (selection.scope === "all") return {};
|
|
2783
3057
|
const r = {};
|
|
2784
3058
|
for (const id2 of Object.keys(selection.ids)) r[id2] = true;
|
|
@@ -2839,8 +3113,8 @@ function EasyVisionTable(props) {
|
|
|
2839
3113
|
pageCount: Math.ceil(totalCount / itemsPerPage),
|
|
2840
3114
|
getRowId
|
|
2841
3115
|
});
|
|
2842
|
-
const lastSelectionEmittedRef =
|
|
2843
|
-
|
|
3116
|
+
const lastSelectionEmittedRef = React10.useRef("");
|
|
3117
|
+
React10.useEffect(() => {
|
|
2844
3118
|
if (!enableRowSelection) return;
|
|
2845
3119
|
if (isEagerWildcard && (isResolvingEager || eagerAllIds === null)) return;
|
|
2846
3120
|
let event;
|
|
@@ -2922,11 +3196,11 @@ function EasyVisionTable(props) {
|
|
|
2922
3196
|
isResolvingEager,
|
|
2923
3197
|
isEagerWildcard
|
|
2924
3198
|
]);
|
|
2925
|
-
const rowIdOf =
|
|
3199
|
+
const rowIdOf = React10.useCallback(
|
|
2926
3200
|
(row) => getRowId(row),
|
|
2927
3201
|
[getRowId]
|
|
2928
3202
|
);
|
|
2929
|
-
const headerState =
|
|
3203
|
+
const headerState = React10.useMemo(() => {
|
|
2930
3204
|
if (selection.scope === "all") {
|
|
2931
3205
|
const except = Object.keys(selection.exceptIds ?? {}).length;
|
|
2932
3206
|
if (except === 0) return "checked";
|
|
@@ -2942,7 +3216,7 @@ function EasyVisionTable(props) {
|
|
|
2942
3216
|
if (selectedOnPage === visibleIds.length) return "checked";
|
|
2943
3217
|
return "indeterminate";
|
|
2944
3218
|
}, [selection, rows, rowIdOf]);
|
|
2945
|
-
const onHeaderToggle =
|
|
3219
|
+
const onHeaderToggle = React10.useCallback(
|
|
2946
3220
|
(checked) => {
|
|
2947
3221
|
if (selection.scope === "all") {
|
|
2948
3222
|
if (checked) {
|
|
@@ -2968,7 +3242,7 @@ function EasyVisionTable(props) {
|
|
|
2968
3242
|
},
|
|
2969
3243
|
[patch, selection, rows, rowIdOf]
|
|
2970
3244
|
);
|
|
2971
|
-
const onScopeChange =
|
|
3245
|
+
const onScopeChange = React10.useCallback(
|
|
2972
3246
|
(scope) => {
|
|
2973
3247
|
if (scope === "all") {
|
|
2974
3248
|
patch({ selection: { ids: {}, scope: "all", exceptIds: {} } });
|
|
@@ -2987,8 +3261,8 @@ function EasyVisionTable(props) {
|
|
|
2987
3261
|
},
|
|
2988
3262
|
[patch, selectAllResolution, isApi, resolveEagerAll]
|
|
2989
3263
|
);
|
|
2990
|
-
const firstPerformAfterMountRef =
|
|
2991
|
-
const handlePerform =
|
|
3264
|
+
const firstPerformAfterMountRef = React10.useRef(true);
|
|
3265
|
+
const handlePerform = React10.useCallback(
|
|
2992
3266
|
(snap) => {
|
|
2993
3267
|
const isFirstAfterMount = firstPerformAfterMountRef.current;
|
|
2994
3268
|
firstPerformAfterMountRef.current = false;
|
|
@@ -3008,8 +3282,8 @@ function EasyVisionTable(props) {
|
|
|
3008
3282
|
[isApi, multifilter, patch, runFetch, selection.scope]
|
|
3009
3283
|
);
|
|
3010
3284
|
const totalPages = Math.max(1, Math.ceil(totalCount / itemsPerPage));
|
|
3011
|
-
const hasResolvedDataRef =
|
|
3012
|
-
|
|
3285
|
+
const hasResolvedDataRef = React10.useRef(false);
|
|
3286
|
+
React10.useEffect(() => {
|
|
3013
3287
|
if (isApi) {
|
|
3014
3288
|
if (apiLoading) return;
|
|
3015
3289
|
if (!hasResolvedDataRef.current) {
|
|
@@ -3022,7 +3296,7 @@ function EasyVisionTable(props) {
|
|
|
3022
3296
|
}
|
|
3023
3297
|
if (page > totalPages) patch({ page: totalPages });
|
|
3024
3298
|
}, [page, totalPages, patch, isApi, apiLoading, apiTotalCount, apiRows.length]);
|
|
3025
|
-
|
|
3299
|
+
React10.useEffect(() => {
|
|
3026
3300
|
if (isApi) return;
|
|
3027
3301
|
if (paginationMode === "page") return;
|
|
3028
3302
|
if (page > 1 && page > Math.max(1, Math.ceil(totalCount / itemsPerPage))) {
|
|
@@ -3355,8 +3629,8 @@ function EasyVisionExportButton({
|
|
|
3355
3629
|
}) {
|
|
3356
3630
|
const labels = { ...DEFAULT_LABELS3, ...labelOverrides };
|
|
3357
3631
|
const parentFullId = useParentFullId();
|
|
3358
|
-
const [isExporting, setIsExporting] =
|
|
3359
|
-
const handleClick =
|
|
3632
|
+
const [isExporting, setIsExporting] = React10.useState(false);
|
|
3633
|
+
const handleClick = React10.useCallback(async () => {
|
|
3360
3634
|
setIsExporting(true);
|
|
3361
3635
|
try {
|
|
3362
3636
|
const resolved = tables.map((tableId) => ({
|