@easyvision/easyvision-ui 1.11.0 → 1.13.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 +38 -1
- package/dist/easyvision.css +84 -0
- package/dist/index.cjs +626 -273
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -1
- package/dist/index.d.ts +61 -1
- package/dist/index.js +522 -169
- 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);
|
|
@@ -589,7 +589,13 @@ function EasyVisionSelector({
|
|
|
589
589
|
] })
|
|
590
590
|
] });
|
|
591
591
|
}
|
|
592
|
+
var WidgetLabelsContext = React10.createContext({
|
|
593
|
+
removeFilter: "Quitar filtro",
|
|
594
|
+
removeValue: "Quitar"
|
|
595
|
+
});
|
|
596
|
+
var useWidgetLabels = () => React10.useContext(WidgetLabelsContext);
|
|
592
597
|
function TextWidget({ definition, value, onChange, onRemove }) {
|
|
598
|
+
const widgetLabels = useWidgetLabels();
|
|
593
599
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ev-mf-chip", children: [
|
|
594
600
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ev-mf-chip-label", children: [
|
|
595
601
|
definition.label,
|
|
@@ -601,6 +607,7 @@ function TextWidget({ definition, value, onChange, onRemove }) {
|
|
|
601
607
|
{
|
|
602
608
|
className: "ev-mf-chip-input",
|
|
603
609
|
placeholder: definition.placeholder,
|
|
610
|
+
"aria-label": definition.label,
|
|
604
611
|
value: value ?? "",
|
|
605
612
|
onChange: (e) => onChange(e.target.value)
|
|
606
613
|
}
|
|
@@ -610,6 +617,7 @@ function TextWidget({ definition, value, onChange, onRemove }) {
|
|
|
610
617
|
{
|
|
611
618
|
type: "button",
|
|
612
619
|
onClick: onRemove,
|
|
620
|
+
"aria-label": `${widgetLabels.removeFilter}: ${definition.label}`,
|
|
613
621
|
className: "ev-mf-chip-remove",
|
|
614
622
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {})
|
|
615
623
|
}
|
|
@@ -618,11 +626,12 @@ function TextWidget({ definition, value, onChange, onRemove }) {
|
|
|
618
626
|
}
|
|
619
627
|
var SENTINEL = "__easyvision_undef__";
|
|
620
628
|
function SelectorWidget({ definition, value, onChange, onRemove }) {
|
|
621
|
-
const
|
|
622
|
-
const [
|
|
629
|
+
const widgetLabels = useWidgetLabels();
|
|
630
|
+
const [open, setOpen] = React10.useState(false);
|
|
631
|
+
const [resolved, setResolved] = React10.useState(
|
|
623
632
|
Array.isArray(definition.options) ? definition.options : null
|
|
624
633
|
);
|
|
625
|
-
|
|
634
|
+
React10.useEffect(() => {
|
|
626
635
|
if (typeof definition.options === "function" && resolved === null) {
|
|
627
636
|
void definition.options().then((o) => setResolved(o)).catch(() => setResolved([]));
|
|
628
637
|
} else if (Array.isArray(definition.options)) {
|
|
@@ -668,13 +677,14 @@ function SelectorWidget({ definition, value, onChange, onRemove }) {
|
|
|
668
677
|
{
|
|
669
678
|
type: "button",
|
|
670
679
|
onClick: onRemove,
|
|
680
|
+
"aria-label": `${widgetLabels.removeFilter}: ${definition.label}`,
|
|
671
681
|
className: "ev-mf-chip-remove",
|
|
672
682
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {})
|
|
673
683
|
}
|
|
674
684
|
)
|
|
675
685
|
] });
|
|
676
686
|
}
|
|
677
|
-
var Checkbox =
|
|
687
|
+
var Checkbox = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
678
688
|
CheckboxPrimitive__namespace.Root,
|
|
679
689
|
{
|
|
680
690
|
ref,
|
|
@@ -690,22 +700,23 @@ function MultiSelectWidget({
|
|
|
690
700
|
onChange,
|
|
691
701
|
onRemove
|
|
692
702
|
}) {
|
|
693
|
-
const
|
|
694
|
-
const [
|
|
703
|
+
const widgetLabels = useWidgetLabels();
|
|
704
|
+
const [search, setSearch] = React10.useState("");
|
|
705
|
+
const [open, setOpen] = React10.useState(false);
|
|
695
706
|
const searchFn = definition.searchOptions;
|
|
696
707
|
const hasSearchOptions = typeof searchFn === "function";
|
|
697
|
-
const [resolved, setResolved] =
|
|
708
|
+
const [resolved, setResolved] = React10.useState(
|
|
698
709
|
Array.isArray(definition.options) ? definition.options : null
|
|
699
710
|
);
|
|
700
|
-
|
|
711
|
+
React10.useEffect(() => {
|
|
701
712
|
if (typeof definition.options === "function" && resolved === null) {
|
|
702
713
|
void definition.options().then(setResolved).catch(() => setResolved([]));
|
|
703
714
|
} else if (Array.isArray(definition.options)) {
|
|
704
715
|
setResolved(definition.options);
|
|
705
716
|
}
|
|
706
717
|
}, [definition.options, resolved]);
|
|
707
|
-
const [searchResults, setSearchResults] =
|
|
708
|
-
|
|
718
|
+
const [searchResults, setSearchResults] = React10.useState([]);
|
|
719
|
+
React10.useEffect(() => {
|
|
709
720
|
if (!searchFn) return;
|
|
710
721
|
if (search.trim() === "") {
|
|
711
722
|
setSearchResults([]);
|
|
@@ -726,11 +737,11 @@ function MultiSelectWidget({
|
|
|
726
737
|
}, [search, searchFn]);
|
|
727
738
|
const selected = Array.isArray(value) ? value : [];
|
|
728
739
|
const baseOpts = resolved ?? [];
|
|
729
|
-
const labelCache =
|
|
730
|
-
|
|
740
|
+
const labelCache = React10.useRef(/* @__PURE__ */ new Map());
|
|
741
|
+
React10.useEffect(() => {
|
|
731
742
|
baseOpts.forEach((o) => labelCache.current.set(o.value, o.label));
|
|
732
743
|
}, [baseOpts]);
|
|
733
|
-
const listOpts =
|
|
744
|
+
const listOpts = React10.useMemo(() => {
|
|
734
745
|
if (hasSearchOptions) return searchResults;
|
|
735
746
|
return baseOpts.filter(
|
|
736
747
|
(o) => o.label.toLowerCase().includes(search.toLowerCase())
|
|
@@ -764,13 +775,14 @@ function MultiSelectWidget({
|
|
|
764
775
|
{
|
|
765
776
|
type: "button",
|
|
766
777
|
onClick: () => removeOne(v),
|
|
778
|
+
"aria-label": `${widgetLabels.removeValue} ${labelOf(v)}`,
|
|
767
779
|
className: "ev-mf-chip-badge-x",
|
|
768
780
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {})
|
|
769
781
|
}
|
|
770
782
|
)
|
|
771
783
|
] }, String(v))),
|
|
772
784
|
/* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
773
|
-
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "ev-mf-chip-caret", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {}) }) }),
|
|
785
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "ev-mf-chip-caret", "aria-label": definition.label, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {}) }) }),
|
|
774
786
|
/* @__PURE__ */ jsxRuntime.jsxs(PopoverContent, { className: "ev-mf-ms-popover", align: "start", children: [
|
|
775
787
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
776
788
|
Input,
|
|
@@ -796,7 +808,16 @@ function MultiSelectWidget({
|
|
|
796
808
|
] })
|
|
797
809
|
] })
|
|
798
810
|
] }),
|
|
799
|
-
onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
811
|
+
onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
812
|
+
"button",
|
|
813
|
+
{
|
|
814
|
+
type: "button",
|
|
815
|
+
onClick: onRemove,
|
|
816
|
+
"aria-label": `${widgetLabels.removeFilter}: ${definition.label}`,
|
|
817
|
+
className: "ev-mf-chip-remove",
|
|
818
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {})
|
|
819
|
+
}
|
|
820
|
+
)
|
|
800
821
|
] });
|
|
801
822
|
}
|
|
802
823
|
function Calendar({
|
|
@@ -852,6 +873,7 @@ function DateRangeWidget({
|
|
|
852
873
|
onChange,
|
|
853
874
|
onRemove
|
|
854
875
|
}) {
|
|
876
|
+
const widgetLabels = useWidgetLabels();
|
|
855
877
|
const range = value ?? {};
|
|
856
878
|
const label = (() => {
|
|
857
879
|
if (range.from && range.to) {
|
|
@@ -888,6 +910,7 @@ function DateRangeWidget({
|
|
|
888
910
|
{
|
|
889
911
|
type: "button",
|
|
890
912
|
onClick: onRemove,
|
|
913
|
+
"aria-label": `${widgetLabels.removeFilter}: ${definition.label}`,
|
|
891
914
|
className: "ev-mf-chip-remove",
|
|
892
915
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {})
|
|
893
916
|
}
|
|
@@ -900,6 +923,7 @@ function NumberRangeWidget({
|
|
|
900
923
|
onChange,
|
|
901
924
|
onRemove
|
|
902
925
|
}) {
|
|
926
|
+
const widgetLabels = useWidgetLabels();
|
|
903
927
|
const range = value ?? {};
|
|
904
928
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ev-mf-chip", children: [
|
|
905
929
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ev-mf-chip-label", children: [
|
|
@@ -913,6 +937,7 @@ function NumberRangeWidget({
|
|
|
913
937
|
type: "number",
|
|
914
938
|
className: "ev-mf-chip-number",
|
|
915
939
|
placeholder: "Min",
|
|
940
|
+
"aria-label": `${definition.label} (min)`,
|
|
916
941
|
value: range.min ?? "",
|
|
917
942
|
onChange: (e) => onChange({ ...range, min: e.target.value ? Number(e.target.value) : void 0 })
|
|
918
943
|
}
|
|
@@ -924,6 +949,7 @@ function NumberRangeWidget({
|
|
|
924
949
|
type: "number",
|
|
925
950
|
className: "ev-mf-chip-number",
|
|
926
951
|
placeholder: "Max",
|
|
952
|
+
"aria-label": `${definition.label} (max)`,
|
|
927
953
|
value: range.max ?? "",
|
|
928
954
|
onChange: (e) => onChange({ ...range, max: e.target.value ? Number(e.target.value) : void 0 })
|
|
929
955
|
}
|
|
@@ -933,6 +959,7 @@ function NumberRangeWidget({
|
|
|
933
959
|
{
|
|
934
960
|
type: "button",
|
|
935
961
|
onClick: onRemove,
|
|
962
|
+
"aria-label": `${widgetLabels.removeFilter}: ${definition.label}`,
|
|
936
963
|
className: "ev-mf-chip-remove",
|
|
937
964
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {})
|
|
938
965
|
}
|
|
@@ -1073,7 +1100,7 @@ function buildCondition(def, value) {
|
|
|
1073
1100
|
}
|
|
1074
1101
|
}
|
|
1075
1102
|
function useBuildQuery(config, values, childQueries) {
|
|
1076
|
-
return
|
|
1103
|
+
return React10.useCallback(() => {
|
|
1077
1104
|
const where = {};
|
|
1078
1105
|
if (config.searchField) {
|
|
1079
1106
|
const c = buildCondition(config.searchField, values[config.searchField.id]);
|
|
@@ -1153,13 +1180,231 @@ function isDirty(input, lastConfirmed) {
|
|
|
1153
1180
|
}
|
|
1154
1181
|
return current !== lastConfirmed;
|
|
1155
1182
|
}
|
|
1183
|
+
var EMPTY = { items: [], defaultName: null };
|
|
1184
|
+
var isSavedFilter = (v) => typeof v === "object" && v !== null && typeof v.name === "string" && typeof v.filters === "object" && v.filters !== null;
|
|
1185
|
+
function readSaved(storage, key) {
|
|
1186
|
+
try {
|
|
1187
|
+
const raw = storage?.getItem(key);
|
|
1188
|
+
if (!raw) return EMPTY;
|
|
1189
|
+
const parsed = JSON.parse(raw);
|
|
1190
|
+
const items = (Array.isArray(parsed.items) ? parsed.items : []).filter(isSavedFilter).map((item) => ({ ...item, search: Array.isArray(item.search) ? item.search : [] }));
|
|
1191
|
+
const defaultName = typeof parsed.defaultName === "string" && items.some((i) => i.name === parsed.defaultName) ? parsed.defaultName : null;
|
|
1192
|
+
return { items, defaultName };
|
|
1193
|
+
} catch {
|
|
1194
|
+
return EMPTY;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
function writeSaved(storage, key, store) {
|
|
1198
|
+
try {
|
|
1199
|
+
storage?.setItem(key, JSON.stringify(store));
|
|
1200
|
+
} catch {
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
var pad = (n) => String(n).padStart(2, "0");
|
|
1204
|
+
function toDay(value) {
|
|
1205
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
1206
|
+
const date = value instanceof Date ? value : new Date(String(value));
|
|
1207
|
+
if (Number.isNaN(date.getTime())) return void 0;
|
|
1208
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
1209
|
+
}
|
|
1210
|
+
function fromDay(value) {
|
|
1211
|
+
if (typeof value !== "string" || !value) return void 0;
|
|
1212
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
1213
|
+
const date = m ? new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3])) : new Date(value);
|
|
1214
|
+
return Number.isNaN(date.getTime()) ? void 0 : date;
|
|
1215
|
+
}
|
|
1216
|
+
var savable = (fields) => new Map(fields.filter((f) => f.type !== "multifilter").map((f) => [f.id, f]));
|
|
1217
|
+
function toStored(values, fields) {
|
|
1218
|
+
const defs = savable(fields);
|
|
1219
|
+
const out = {};
|
|
1220
|
+
for (const [id, value] of Object.entries(values)) {
|
|
1221
|
+
const def = defs.get(id);
|
|
1222
|
+
if (!def || !isNonEmpty(value)) continue;
|
|
1223
|
+
if (def.type === "dateRange") {
|
|
1224
|
+
const range = value;
|
|
1225
|
+
const stored = {};
|
|
1226
|
+
const from = toDay(range.from);
|
|
1227
|
+
const to = toDay(range.to);
|
|
1228
|
+
if (from) stored.from = from;
|
|
1229
|
+
if (to) stored.to = to;
|
|
1230
|
+
if (Object.keys(stored).length > 0) out[id] = stored;
|
|
1231
|
+
} else {
|
|
1232
|
+
out[id] = value;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
return out;
|
|
1236
|
+
}
|
|
1237
|
+
function fromStored(filters, fields) {
|
|
1238
|
+
const defs = savable(fields);
|
|
1239
|
+
const out = {};
|
|
1240
|
+
for (const [id, value] of Object.entries(filters)) {
|
|
1241
|
+
const def = defs.get(id);
|
|
1242
|
+
if (!def) continue;
|
|
1243
|
+
if (def.type === "dateRange") {
|
|
1244
|
+
const range = value ?? {};
|
|
1245
|
+
const restored = {};
|
|
1246
|
+
const from = fromDay(range.from);
|
|
1247
|
+
const to = fromDay(range.to);
|
|
1248
|
+
if (from) restored.from = from;
|
|
1249
|
+
if (to) restored.to = to;
|
|
1250
|
+
if (restored.from || restored.to) out[id] = restored;
|
|
1251
|
+
} else if (def.type === "multiselect" && typeof value === "string") {
|
|
1252
|
+
out[id] = [value];
|
|
1253
|
+
} else {
|
|
1254
|
+
out[id] = value;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
return out;
|
|
1258
|
+
}
|
|
1259
|
+
function useSavedFilters(storageKey) {
|
|
1260
|
+
const storage = typeof window === "undefined" ? void 0 : window.localStorage;
|
|
1261
|
+
const [store, setStore] = React10.useState(
|
|
1262
|
+
() => storageKey ? readSaved(storage, storageKey) : EMPTY
|
|
1263
|
+
);
|
|
1264
|
+
const update = React10.useCallback(
|
|
1265
|
+
(next) => {
|
|
1266
|
+
setStore(next);
|
|
1267
|
+
if (storageKey) writeSaved(storage, storageKey, next);
|
|
1268
|
+
},
|
|
1269
|
+
[storage, storageKey]
|
|
1270
|
+
);
|
|
1271
|
+
const save = React10.useCallback(
|
|
1272
|
+
(name, filters, search = []) => {
|
|
1273
|
+
const saved = { name, filters, search };
|
|
1274
|
+
const known = store.items.some((i) => i.name === name);
|
|
1275
|
+
const items = known ? store.items.map((i) => i.name === name ? saved : i) : [...store.items, saved];
|
|
1276
|
+
update({ ...store, items });
|
|
1277
|
+
},
|
|
1278
|
+
[store, update]
|
|
1279
|
+
);
|
|
1280
|
+
const remove = React10.useCallback(
|
|
1281
|
+
(name) => update({
|
|
1282
|
+
items: store.items.filter((i) => i.name !== name),
|
|
1283
|
+
defaultName: store.defaultName === name ? null : store.defaultName
|
|
1284
|
+
}),
|
|
1285
|
+
[store, update]
|
|
1286
|
+
);
|
|
1287
|
+
const setDefault = React10.useCallback(
|
|
1288
|
+
(name) => update({ ...store, defaultName: name }),
|
|
1289
|
+
[store, update]
|
|
1290
|
+
);
|
|
1291
|
+
return {
|
|
1292
|
+
items: store.items,
|
|
1293
|
+
defaultName: store.defaultName,
|
|
1294
|
+
defaultFilter: store.items.find((i) => i.name === store.defaultName),
|
|
1295
|
+
save,
|
|
1296
|
+
remove,
|
|
1297
|
+
setDefault
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
function SavedFiltersMenu({
|
|
1301
|
+
items,
|
|
1302
|
+
defaultName,
|
|
1303
|
+
canSave,
|
|
1304
|
+
labels,
|
|
1305
|
+
onApply,
|
|
1306
|
+
onSave,
|
|
1307
|
+
onDelete,
|
|
1308
|
+
onSetDefault
|
|
1309
|
+
}) {
|
|
1310
|
+
const [open, setOpen] = React10__namespace.useState(false);
|
|
1311
|
+
const [name, setName] = React10__namespace.useState("");
|
|
1312
|
+
const save = () => {
|
|
1313
|
+
const trimmed = name.trim();
|
|
1314
|
+
if (!trimmed || !canSave) return;
|
|
1315
|
+
onSave(trimmed);
|
|
1316
|
+
setName("");
|
|
1317
|
+
};
|
|
1318
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
1319
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", size: "sm", className: "ev-mf-saved-btn", children: [
|
|
1320
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bookmark, {}),
|
|
1321
|
+
labels.saved
|
|
1322
|
+
] }) }),
|
|
1323
|
+
/* @__PURE__ */ jsxRuntime.jsxs(PopoverContent, { className: "ev-mf-saved-popover", align: "start", children: [
|
|
1324
|
+
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) => {
|
|
1325
|
+
const isDefault = saved.name === defaultName;
|
|
1326
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "ev-mf-saved-item", children: [
|
|
1327
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1328
|
+
"button",
|
|
1329
|
+
{
|
|
1330
|
+
type: "button",
|
|
1331
|
+
className: "ev-mf-saved-apply",
|
|
1332
|
+
onClick: () => {
|
|
1333
|
+
onApply(saved);
|
|
1334
|
+
setOpen(false);
|
|
1335
|
+
},
|
|
1336
|
+
children: saved.name
|
|
1337
|
+
}
|
|
1338
|
+
),
|
|
1339
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1340
|
+
"button",
|
|
1341
|
+
{
|
|
1342
|
+
type: "button",
|
|
1343
|
+
className: "ev-mf-saved-icon",
|
|
1344
|
+
"data-active": isDefault || void 0,
|
|
1345
|
+
"aria-pressed": isDefault,
|
|
1346
|
+
"aria-label": `${isDefault ? labels.unsetDefault : labels.setDefault}: ${saved.name}`,
|
|
1347
|
+
title: isDefault ? labels.unsetDefault : labels.setDefault,
|
|
1348
|
+
onClick: () => onSetDefault(isDefault ? null : saved.name),
|
|
1349
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Star, {})
|
|
1350
|
+
}
|
|
1351
|
+
),
|
|
1352
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1353
|
+
"button",
|
|
1354
|
+
{
|
|
1355
|
+
type: "button",
|
|
1356
|
+
className: "ev-mf-saved-icon",
|
|
1357
|
+
"aria-label": `${labels.deleteSaved}: ${saved.name}`,
|
|
1358
|
+
title: labels.deleteSaved,
|
|
1359
|
+
onClick: () => onDelete(saved.name),
|
|
1360
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, {})
|
|
1361
|
+
}
|
|
1362
|
+
)
|
|
1363
|
+
] }, saved.name);
|
|
1364
|
+
}) }),
|
|
1365
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1366
|
+
"form",
|
|
1367
|
+
{
|
|
1368
|
+
className: "ev-mf-saved-form",
|
|
1369
|
+
onSubmit: (e) => {
|
|
1370
|
+
e.preventDefault();
|
|
1371
|
+
save();
|
|
1372
|
+
},
|
|
1373
|
+
children: [
|
|
1374
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1375
|
+
Input,
|
|
1376
|
+
{
|
|
1377
|
+
value: name,
|
|
1378
|
+
onChange: (e) => setName(e.target.value),
|
|
1379
|
+
placeholder: canSave ? labels.saveNamePlaceholder : labels.nothingToSave,
|
|
1380
|
+
"aria-label": labels.saveNamePlaceholder,
|
|
1381
|
+
disabled: !canSave
|
|
1382
|
+
}
|
|
1383
|
+
),
|
|
1384
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", size: "sm", disabled: !canSave || !name.trim(), children: labels.save })
|
|
1385
|
+
]
|
|
1386
|
+
}
|
|
1387
|
+
)
|
|
1388
|
+
] })
|
|
1389
|
+
] });
|
|
1390
|
+
}
|
|
1156
1391
|
var DEFAULT_LABELS = {
|
|
1157
1392
|
search: "Buscar",
|
|
1158
1393
|
clear: "Limpiar",
|
|
1159
1394
|
perform: "Buscar",
|
|
1160
1395
|
addFilter: "A\xF1adir filtro",
|
|
1161
1396
|
noOptions: "Sin opciones",
|
|
1162
|
-
searchPlaceholder: "Buscar..."
|
|
1397
|
+
searchPlaceholder: "Buscar...",
|
|
1398
|
+
saved: "Guardados",
|
|
1399
|
+
noSaved: "A\xFAn no hay filtros guardados.",
|
|
1400
|
+
saveNamePlaceholder: "Nombre del filtro",
|
|
1401
|
+
nothingToSave: "Aplica una b\xFAsqueda para guardarla",
|
|
1402
|
+
save: "Guardar",
|
|
1403
|
+
setDefault: "Abrir siempre con este",
|
|
1404
|
+
unsetDefault: "Dejar de abrir con este",
|
|
1405
|
+
deleteSaved: "Borrar",
|
|
1406
|
+
removeFilter: "Quitar filtro",
|
|
1407
|
+
removeValue: "Quitar"
|
|
1163
1408
|
};
|
|
1164
1409
|
function isFieldVisible(def, values) {
|
|
1165
1410
|
if (def.visible === void 0) return true;
|
|
@@ -1170,7 +1415,7 @@ function isMandatorySatisfied(def, value) {
|
|
|
1170
1415
|
if (!def.mandatory) return true;
|
|
1171
1416
|
return isNonEmpty(value);
|
|
1172
1417
|
}
|
|
1173
|
-
var EasyVisionMultifilter =
|
|
1418
|
+
var EasyVisionMultifilter = React10.forwardRef(function EasyVisionMultifilter2(props, ref) {
|
|
1174
1419
|
const {
|
|
1175
1420
|
id,
|
|
1176
1421
|
config,
|
|
@@ -1190,12 +1435,13 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1190
1435
|
labels: labelOverrides,
|
|
1191
1436
|
className,
|
|
1192
1437
|
persist = false,
|
|
1193
|
-
clearWhen
|
|
1438
|
+
clearWhen,
|
|
1439
|
+
savedFilters
|
|
1194
1440
|
} = props;
|
|
1195
1441
|
const resolvedPerformMode = performMode === "live" ? "live" : "manual";
|
|
1196
1442
|
const labels = { ...DEFAULT_LABELS, ...labelOverrides };
|
|
1197
1443
|
const showClear = showClearAll ?? editable;
|
|
1198
|
-
const initialActive =
|
|
1444
|
+
const initialActive = React10.useMemo(() => {
|
|
1199
1445
|
const ids = [];
|
|
1200
1446
|
if (config.searchField) ids.push(config.searchField.id);
|
|
1201
1447
|
for (const f of config.fields) {
|
|
@@ -1203,7 +1449,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1203
1449
|
}
|
|
1204
1450
|
return ids;
|
|
1205
1451
|
}, [config]);
|
|
1206
|
-
const initialValues =
|
|
1452
|
+
const initialValues = React10.useMemo(() => {
|
|
1207
1453
|
const v = {};
|
|
1208
1454
|
if (config.searchField?.defaultValue !== void 0) {
|
|
1209
1455
|
v[config.searchField.id] = config.searchField.defaultValue;
|
|
@@ -1213,13 +1459,33 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1213
1459
|
}
|
|
1214
1460
|
return v;
|
|
1215
1461
|
}, [config]);
|
|
1462
|
+
const saved = useSavedFilters(savedFilters?.storageKey);
|
|
1463
|
+
const savedState = React10.useCallback(
|
|
1464
|
+
(item) => {
|
|
1465
|
+
const restored = fromStored(item.filters, config.fields);
|
|
1466
|
+
const searchId = savedFilters?.searchFieldId;
|
|
1467
|
+
if (searchId && item.search.length) restored[searchId] = item.search.join(" ");
|
|
1468
|
+
return {
|
|
1469
|
+
values: restored,
|
|
1470
|
+
activeFields: [.../* @__PURE__ */ new Set([...initialActive, ...Object.keys(restored)])]
|
|
1471
|
+
};
|
|
1472
|
+
},
|
|
1473
|
+
[config.fields, initialActive, savedFilters?.searchFieldId]
|
|
1474
|
+
);
|
|
1475
|
+
const openedWithDefaultRef = React10.useRef(false);
|
|
1216
1476
|
const { slice, fullId, patch } = useEasyVisionSlice("multifilter", id, {
|
|
1217
|
-
init: () =>
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1477
|
+
init: () => {
|
|
1478
|
+
if (saved.defaultFilter && savedFilters?.openWithDefault !== false) {
|
|
1479
|
+
openedWithDefaultRef.current = true;
|
|
1480
|
+
return { kind: "multifilter", ...savedState(saved.defaultFilter), lastConfirmedSnapshotJSON: null };
|
|
1481
|
+
}
|
|
1482
|
+
return {
|
|
1483
|
+
kind: "multifilter",
|
|
1484
|
+
activeFields: initialActive,
|
|
1485
|
+
values: initialValues,
|
|
1486
|
+
lastConfirmedSnapshotJSON: null
|
|
1487
|
+
};
|
|
1488
|
+
},
|
|
1223
1489
|
persist,
|
|
1224
1490
|
clearWhen: clearWhen ? (s) => clearWhen({
|
|
1225
1491
|
values: s.values,
|
|
@@ -1230,12 +1496,12 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1230
1496
|
}) : void 0
|
|
1231
1497
|
});
|
|
1232
1498
|
const { activeFields, values, lastConfirmedSnapshotJSON } = slice;
|
|
1233
|
-
const registryState =
|
|
1499
|
+
const registryState = React10.useSyncExternalStore(
|
|
1234
1500
|
easyVisionRegistry.subscribe,
|
|
1235
1501
|
easyVisionRegistry.getState,
|
|
1236
1502
|
easyVisionRegistry.getState
|
|
1237
1503
|
);
|
|
1238
|
-
const childSnapshots =
|
|
1504
|
+
const childSnapshots = React10.useMemo(() => {
|
|
1239
1505
|
const out = {};
|
|
1240
1506
|
for (const f of config.fields) {
|
|
1241
1507
|
if (f.type !== "multifilter") continue;
|
|
@@ -1250,7 +1516,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1250
1516
|
}
|
|
1251
1517
|
return out;
|
|
1252
1518
|
}, [fullId, config.fields, registryState]);
|
|
1253
|
-
const childQueries =
|
|
1519
|
+
const childQueries = React10.useMemo(() => {
|
|
1254
1520
|
const out = {};
|
|
1255
1521
|
for (const f of config.fields) {
|
|
1256
1522
|
if (f.type !== "multifilter") continue;
|
|
@@ -1261,7 +1527,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1261
1527
|
return out;
|
|
1262
1528
|
}, [config.fields, childSnapshots]);
|
|
1263
1529
|
const buildQuery = useBuildQuery(config, values, childQueries);
|
|
1264
|
-
const composedValues =
|
|
1530
|
+
const composedValues = React10.useMemo(() => {
|
|
1265
1531
|
const out = { ...values };
|
|
1266
1532
|
for (const f of config.fields) {
|
|
1267
1533
|
if (f.type === "multifilter") {
|
|
@@ -1270,7 +1536,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1270
1536
|
}
|
|
1271
1537
|
return out;
|
|
1272
1538
|
}, [values, config.fields, childSnapshots]);
|
|
1273
|
-
const isValid =
|
|
1539
|
+
const isValid = React10.useMemo(() => {
|
|
1274
1540
|
if (config.searchField && !isMandatorySatisfied(config.searchField, values[config.searchField.id])) {
|
|
1275
1541
|
return false;
|
|
1276
1542
|
}
|
|
@@ -1292,15 +1558,15 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1292
1558
|
}
|
|
1293
1559
|
return true;
|
|
1294
1560
|
}, [config, values, childSnapshots]);
|
|
1295
|
-
const snapshotKey =
|
|
1561
|
+
const snapshotKey = React10.useMemo(
|
|
1296
1562
|
() => buildSnapshotKey({ activeFields, values: composedValues }),
|
|
1297
1563
|
[activeFields, composedValues]
|
|
1298
1564
|
);
|
|
1299
|
-
const dirty =
|
|
1565
|
+
const dirty = React10.useMemo(
|
|
1300
1566
|
() => isDirty({ activeFields, values: composedValues }, lastConfirmedSnapshotJSON),
|
|
1301
1567
|
[activeFields, composedValues, lastConfirmedSnapshotJSON]
|
|
1302
1568
|
);
|
|
1303
|
-
const snapshot =
|
|
1569
|
+
const snapshot = React10.useMemo(
|
|
1304
1570
|
() => ({
|
|
1305
1571
|
values: composedValues,
|
|
1306
1572
|
activeFields,
|
|
@@ -1310,15 +1576,15 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1310
1576
|
}),
|
|
1311
1577
|
[composedValues, activeFields, isValid, dirty, buildQuery]
|
|
1312
1578
|
);
|
|
1313
|
-
const lastEmittedKeyRef =
|
|
1314
|
-
|
|
1579
|
+
const lastEmittedKeyRef = React10.useRef("");
|
|
1580
|
+
React10.useEffect(() => {
|
|
1315
1581
|
const key = `${snapshotKey}|${dirty}|${isValid}`;
|
|
1316
1582
|
if (key === lastEmittedKeyRef.current) return;
|
|
1317
1583
|
lastEmittedKeyRef.current = key;
|
|
1318
1584
|
onChange?.(snapshot);
|
|
1319
1585
|
onStateChange?.(snapshot);
|
|
1320
1586
|
}, [snapshotKey, dirty, isValid, snapshot, onChange, onStateChange]);
|
|
1321
|
-
const performAction =
|
|
1587
|
+
const performAction = React10.useCallback(() => {
|
|
1322
1588
|
const key = buildSnapshotKey({ activeFields, values: composedValues });
|
|
1323
1589
|
patch({ lastConfirmedSnapshotJSON: key });
|
|
1324
1590
|
if (onPerform) {
|
|
@@ -1326,16 +1592,19 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1326
1592
|
queueMicrotask(() => onPerform(emitted));
|
|
1327
1593
|
}
|
|
1328
1594
|
}, [activeFields, composedValues, patch, onPerform, snapshot]);
|
|
1329
|
-
const didPerformOnMountRef =
|
|
1330
|
-
|
|
1331
|
-
if (performOnMount && !didPerformOnMountRef.current && Object.values(composedValues).some(isNonEmpty)) {
|
|
1595
|
+
const didPerformOnMountRef = React10.useRef(false);
|
|
1596
|
+
React10.useEffect(() => {
|
|
1597
|
+
if ((performOnMount || openedWithDefaultRef.current) && !didPerformOnMountRef.current && Object.values(composedValues).some(isNonEmpty)) {
|
|
1332
1598
|
didPerformOnMountRef.current = true;
|
|
1333
1599
|
performAction();
|
|
1334
1600
|
}
|
|
1601
|
+
return () => {
|
|
1602
|
+
didPerformOnMountRef.current = false;
|
|
1603
|
+
};
|
|
1335
1604
|
}, [performOnMount]);
|
|
1336
|
-
const liveTimerRef =
|
|
1337
|
-
const livePrevKeyRef =
|
|
1338
|
-
|
|
1605
|
+
const liveTimerRef = React10.useRef(null);
|
|
1606
|
+
const livePrevKeyRef = React10.useRef(null);
|
|
1607
|
+
React10.useEffect(() => {
|
|
1339
1608
|
if (resolvedPerformMode !== "live") return;
|
|
1340
1609
|
if (livePrevKeyRef.current === null) {
|
|
1341
1610
|
livePrevKeyRef.current = snapshotKey;
|
|
@@ -1355,24 +1624,24 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1355
1624
|
}
|
|
1356
1625
|
};
|
|
1357
1626
|
}, [snapshotKey, resolvedPerformMode, performDebounceMs, performAction]);
|
|
1358
|
-
|
|
1627
|
+
React10.useImperativeHandle(ref, () => ({
|
|
1359
1628
|
perform: performAction,
|
|
1360
1629
|
getSnapshot: () => snapshot
|
|
1361
1630
|
}));
|
|
1362
|
-
const updateValue =
|
|
1631
|
+
const updateValue = React10.useCallback(
|
|
1363
1632
|
(fieldId, value) => {
|
|
1364
1633
|
patch({ values: { ...values, [fieldId]: value } });
|
|
1365
1634
|
},
|
|
1366
1635
|
[patch, values]
|
|
1367
1636
|
);
|
|
1368
|
-
const addField =
|
|
1637
|
+
const addField = React10.useCallback(
|
|
1369
1638
|
(fieldId) => {
|
|
1370
1639
|
if (activeFields.includes(fieldId)) return;
|
|
1371
1640
|
patch({ activeFields: [...activeFields, fieldId] });
|
|
1372
1641
|
},
|
|
1373
1642
|
[activeFields, patch]
|
|
1374
1643
|
);
|
|
1375
|
-
const removeField =
|
|
1644
|
+
const removeField = React10.useCallback(
|
|
1376
1645
|
(fieldId) => {
|
|
1377
1646
|
const nextValues = { ...values };
|
|
1378
1647
|
delete nextValues[fieldId];
|
|
@@ -1383,8 +1652,8 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1383
1652
|
},
|
|
1384
1653
|
[activeFields, values, patch]
|
|
1385
1654
|
);
|
|
1386
|
-
const [clearTick, setClearTick] =
|
|
1387
|
-
const clearAll =
|
|
1655
|
+
const [clearTick, setClearTick] = React10.useState(0);
|
|
1656
|
+
const clearAll = React10.useCallback(() => {
|
|
1388
1657
|
patch({
|
|
1389
1658
|
values: initialValues,
|
|
1390
1659
|
activeFields: initialActive,
|
|
@@ -1394,25 +1663,44 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1394
1663
|
setClearTick((n) => n + 1);
|
|
1395
1664
|
}
|
|
1396
1665
|
}, [patch, initialValues, initialActive, lastConfirmedSnapshotJSON, resolvedPerformMode]);
|
|
1397
|
-
|
|
1666
|
+
const applySaved = React10.useCallback(
|
|
1667
|
+
(item) => {
|
|
1668
|
+
patch({ ...savedState(item), lastConfirmedSnapshotJSON: null });
|
|
1669
|
+
if (resolvedPerformMode !== "live") setClearTick((n) => n + 1);
|
|
1670
|
+
},
|
|
1671
|
+
[patch, savedState, resolvedPerformMode]
|
|
1672
|
+
);
|
|
1673
|
+
const appliedValues = React10.useMemo(() => {
|
|
1674
|
+
if (!lastConfirmedSnapshotJSON) return {};
|
|
1675
|
+
try {
|
|
1676
|
+
return JSON.parse(lastConfirmedSnapshotJSON).values ?? {};
|
|
1677
|
+
} catch {
|
|
1678
|
+
return {};
|
|
1679
|
+
}
|
|
1680
|
+
}, [lastConfirmedSnapshotJSON]);
|
|
1681
|
+
const appliedToSave = React10.useMemo(
|
|
1682
|
+
() => toStored(appliedValues, config.fields),
|
|
1683
|
+
[appliedValues, config.fields]
|
|
1684
|
+
);
|
|
1685
|
+
React10.useEffect(() => {
|
|
1398
1686
|
if (clearTick > 0) performAction();
|
|
1399
1687
|
}, [clearTick]);
|
|
1400
|
-
const visibleConfigFields =
|
|
1688
|
+
const visibleConfigFields = React10.useMemo(
|
|
1401
1689
|
() => config.fields.filter((f) => isFieldVisible(f, composedValues)),
|
|
1402
1690
|
[config.fields, composedValues]
|
|
1403
1691
|
);
|
|
1404
1692
|
const isProminentTextField = (f) => f.type === "text" && f.prominent === true;
|
|
1405
|
-
const pinnedFields =
|
|
1693
|
+
const pinnedFields = React10.useMemo(
|
|
1406
1694
|
() => visibleConfigFields.filter((f) => f.pinned && !isProminentTextField(f)),
|
|
1407
1695
|
[visibleConfigFields]
|
|
1408
1696
|
);
|
|
1409
|
-
const chipFields =
|
|
1697
|
+
const chipFields = React10.useMemo(
|
|
1410
1698
|
() => visibleConfigFields.filter(
|
|
1411
1699
|
(f) => !f.pinned && !isProminentTextField(f) && activeFields.includes(f.id)
|
|
1412
1700
|
),
|
|
1413
1701
|
[visibleConfigFields, activeFields]
|
|
1414
1702
|
);
|
|
1415
|
-
const prominentSlots =
|
|
1703
|
+
const prominentSlots = React10.useMemo(() => {
|
|
1416
1704
|
const slots = [];
|
|
1417
1705
|
if (config.searchField) {
|
|
1418
1706
|
slots.push({
|
|
@@ -1433,7 +1721,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1433
1721
|
}
|
|
1434
1722
|
return slots;
|
|
1435
1723
|
}, [config.searchField, visibleConfigFields, activeFields, editable]);
|
|
1436
|
-
const availableToAdd =
|
|
1724
|
+
const availableToAdd = React10.useMemo(
|
|
1437
1725
|
() => visibleConfigFields.filter(
|
|
1438
1726
|
(f) => !f.pinned && !activeFields.includes(f.id)
|
|
1439
1727
|
),
|
|
@@ -1481,110 +1769,135 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1481
1769
|
f.id
|
|
1482
1770
|
);
|
|
1483
1771
|
};
|
|
1484
|
-
return /* @__PURE__ */ jsxRuntime.jsx(NamespaceProvider, { fullId, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
"
|
|
1494
|
-
|
|
1495
|
-
className:
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1772
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NamespaceProvider, { fullId, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1773
|
+
WidgetLabelsContext.Provider,
|
|
1774
|
+
{
|
|
1775
|
+
value: { removeFilter: labels.removeFilter, removeValue: labels.removeValue },
|
|
1776
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ev-mf-panel", children: [
|
|
1777
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ev-mf-row", children: [
|
|
1778
|
+
prominentSlots.map(({ def, removable, isLegacySearchField }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1779
|
+
"div",
|
|
1780
|
+
{
|
|
1781
|
+
className: "ev-mf-search-slot",
|
|
1782
|
+
children: [
|
|
1783
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "ev-mf-search-icon" }),
|
|
1784
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1785
|
+
"input",
|
|
1786
|
+
{
|
|
1787
|
+
className: ["ev-mf-search-input", removable ? "has-clear" : "no-clear"].filter(Boolean).join(" "),
|
|
1788
|
+
placeholder: def.placeholder ?? def.label ?? labels.searchPlaceholder,
|
|
1789
|
+
value: values[def.id] ?? "",
|
|
1790
|
+
onChange: (e) => updateValue(def.id, e.target.value),
|
|
1791
|
+
onKeyDown: (e) => {
|
|
1792
|
+
if (e.key === "Enter" && performButton && performEnabled) {
|
|
1793
|
+
performAction();
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1502
1796
|
}
|
|
1503
|
-
|
|
1797
|
+
),
|
|
1798
|
+
removable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1799
|
+
"button",
|
|
1800
|
+
{
|
|
1801
|
+
type: "button",
|
|
1802
|
+
onClick: () => removeField(def.id),
|
|
1803
|
+
"aria-label": labels.clear,
|
|
1804
|
+
className: "ev-mf-search-clear",
|
|
1805
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {})
|
|
1806
|
+
}
|
|
1807
|
+
)
|
|
1808
|
+
]
|
|
1809
|
+
},
|
|
1810
|
+
isLegacySearchField ? `__searchField__${def.id}` : def.id
|
|
1811
|
+
)),
|
|
1812
|
+
editable && availableToAdd.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
|
|
1813
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1814
|
+
Button,
|
|
1815
|
+
{
|
|
1816
|
+
variant: "outline",
|
|
1817
|
+
size: "sm",
|
|
1818
|
+
className: "ev-mf-add-btn",
|
|
1819
|
+
"aria-label": labels.addFilter,
|
|
1820
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, {})
|
|
1504
1821
|
}
|
|
1505
|
-
),
|
|
1506
|
-
|
|
1822
|
+
) }),
|
|
1823
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "ev-mf-add-popover", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ev-mf-add-list", children: availableToAdd.map((f) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1507
1824
|
"button",
|
|
1508
1825
|
{
|
|
1509
1826
|
type: "button",
|
|
1510
|
-
onClick: () =>
|
|
1511
|
-
"
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1827
|
+
onClick: () => addField(f.id),
|
|
1828
|
+
className: "ev-mf-add-item",
|
|
1829
|
+
children: [
|
|
1830
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, {}),
|
|
1831
|
+
f.label
|
|
1832
|
+
]
|
|
1833
|
+
},
|
|
1834
|
+
f.id
|
|
1835
|
+
)) }) })
|
|
1836
|
+
] }),
|
|
1837
|
+
performButton && performPosition === "inline" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1838
|
+
Button,
|
|
1839
|
+
{
|
|
1840
|
+
size: "sm",
|
|
1841
|
+
onClick: performAction,
|
|
1842
|
+
disabled: !performEnabled,
|
|
1843
|
+
className: "ev-mf-perform",
|
|
1844
|
+
children: [
|
|
1845
|
+
performIcon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, {}),
|
|
1846
|
+
performLabelText
|
|
1847
|
+
]
|
|
1848
|
+
}
|
|
1849
|
+
),
|
|
1850
|
+
savedFilters && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1851
|
+
SavedFiltersMenu,
|
|
1852
|
+
{
|
|
1853
|
+
items: saved.items,
|
|
1854
|
+
defaultName: saved.defaultName,
|
|
1855
|
+
canSave: Object.keys(appliedToSave).length > 0,
|
|
1856
|
+
labels,
|
|
1857
|
+
onApply: applySaved,
|
|
1858
|
+
onSave: (name) => {
|
|
1859
|
+
const searchId = savedFilters.searchFieldId;
|
|
1860
|
+
if (!searchId) return saved.save(name, appliedToSave);
|
|
1861
|
+
const { [searchId]: text, ...rest } = appliedToSave;
|
|
1862
|
+
const terms = typeof text === "string" && text.trim() ? [text.trim()] : [];
|
|
1863
|
+
saved.save(name, rest, terms);
|
|
1864
|
+
},
|
|
1865
|
+
onDelete: saved.remove,
|
|
1866
|
+
onSetDefault: saved.setDefault
|
|
1867
|
+
}
|
|
1868
|
+
),
|
|
1869
|
+
showClear && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1870
|
+
Button,
|
|
1871
|
+
{
|
|
1872
|
+
variant: "ghost",
|
|
1873
|
+
size: "sm",
|
|
1874
|
+
onClick: clearAll,
|
|
1875
|
+
className: "ev-mf-clear",
|
|
1876
|
+
children: [
|
|
1877
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}),
|
|
1878
|
+
labels.clear
|
|
1879
|
+
]
|
|
1880
|
+
}
|
|
1881
|
+
)
|
|
1882
|
+
] }),
|
|
1883
|
+
pinnedFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ev-mf-row", children: pinnedFields.map(renderField) }),
|
|
1884
|
+
chipFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ev-mf-row", children: chipFields.map(renderField) }),
|
|
1885
|
+
performButton && performPosition === "belowRow" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ev-mf-below-row", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1522
1886
|
Button,
|
|
1523
1887
|
{
|
|
1524
|
-
variant: "outline",
|
|
1525
1888
|
size: "sm",
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
}
|
|
1530
|
-
) }),
|
|
1531
|
-
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "ev-mf-add-popover", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ev-mf-add-list", children: availableToAdd.map((f) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1532
|
-
"button",
|
|
1533
|
-
{
|
|
1534
|
-
type: "button",
|
|
1535
|
-
onClick: () => addField(f.id),
|
|
1536
|
-
className: "ev-mf-add-item",
|
|
1889
|
+
onClick: performAction,
|
|
1890
|
+
disabled: !performEnabled,
|
|
1891
|
+
className: "ev-mf-perform",
|
|
1537
1892
|
children: [
|
|
1538
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.
|
|
1539
|
-
|
|
1893
|
+
performIcon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, {}),
|
|
1894
|
+
performLabelText
|
|
1540
1895
|
]
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
Button,
|
|
1547
|
-
{
|
|
1548
|
-
size: "sm",
|
|
1549
|
-
onClick: performAction,
|
|
1550
|
-
disabled: !performEnabled,
|
|
1551
|
-
className: "ev-mf-perform",
|
|
1552
|
-
children: [
|
|
1553
|
-
performIcon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, {}),
|
|
1554
|
-
performLabelText
|
|
1555
|
-
]
|
|
1556
|
-
}
|
|
1557
|
-
),
|
|
1558
|
-
showClear && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1559
|
-
Button,
|
|
1560
|
-
{
|
|
1561
|
-
variant: "ghost",
|
|
1562
|
-
size: "sm",
|
|
1563
|
-
onClick: clearAll,
|
|
1564
|
-
className: "ev-mf-clear",
|
|
1565
|
-
children: [
|
|
1566
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}),
|
|
1567
|
-
labels.clear
|
|
1568
|
-
]
|
|
1569
|
-
}
|
|
1570
|
-
)
|
|
1571
|
-
] }),
|
|
1572
|
-
pinnedFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ev-mf-row", children: pinnedFields.map(renderField) }),
|
|
1573
|
-
chipFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ev-mf-row", children: chipFields.map(renderField) }),
|
|
1574
|
-
performButton && performPosition === "belowRow" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ev-mf-below-row", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1575
|
-
Button,
|
|
1576
|
-
{
|
|
1577
|
-
size: "sm",
|
|
1578
|
-
onClick: performAction,
|
|
1579
|
-
disabled: !performEnabled,
|
|
1580
|
-
className: "ev-mf-perform",
|
|
1581
|
-
children: [
|
|
1582
|
-
performIcon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, {}),
|
|
1583
|
-
performLabelText
|
|
1584
|
-
]
|
|
1585
|
-
}
|
|
1586
|
-
) })
|
|
1587
|
-
] }) }) });
|
|
1896
|
+
}
|
|
1897
|
+
) })
|
|
1898
|
+
] }) })
|
|
1899
|
+
}
|
|
1900
|
+
) });
|
|
1588
1901
|
});
|
|
1589
1902
|
function buildChildQueryDirect(field, values) {
|
|
1590
1903
|
const where = {};
|
|
@@ -1635,17 +1948,17 @@ function buildChildQueryDirect(field, values) {
|
|
|
1635
1948
|
return Object.keys(where).length > 0 ? { where } : {};
|
|
1636
1949
|
}
|
|
1637
1950
|
var join = (...parts) => parts.filter(Boolean).join(" ");
|
|
1638
|
-
var EasyVisionCard =
|
|
1951
|
+
var EasyVisionCard = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card", className), ...props }));
|
|
1639
1952
|
EasyVisionCard.displayName = "EasyVisionCard";
|
|
1640
|
-
var EasyVisionCardHeader =
|
|
1953
|
+
var EasyVisionCardHeader = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-header", className), ...props }));
|
|
1641
1954
|
EasyVisionCardHeader.displayName = "EasyVisionCardHeader";
|
|
1642
|
-
var EasyVisionCardTitle =
|
|
1955
|
+
var EasyVisionCardTitle = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h3", { ref, className: join("ev-card-title", className), ...props, children }));
|
|
1643
1956
|
EasyVisionCardTitle.displayName = "EasyVisionCardTitle";
|
|
1644
|
-
var EasyVisionCardDescription =
|
|
1957
|
+
var EasyVisionCardDescription = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("p", { ref, className: join("ev-card-description", className), ...props }));
|
|
1645
1958
|
EasyVisionCardDescription.displayName = "EasyVisionCardDescription";
|
|
1646
|
-
var EasyVisionCardContent =
|
|
1959
|
+
var EasyVisionCardContent = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-content", className), ...props }));
|
|
1647
1960
|
EasyVisionCardContent.displayName = "EasyVisionCardContent";
|
|
1648
|
-
var EasyVisionCardFooter =
|
|
1961
|
+
var EasyVisionCardFooter = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-footer", className), ...props }));
|
|
1649
1962
|
EasyVisionCardFooter.displayName = "EasyVisionCardFooter";
|
|
1650
1963
|
var join2 = (...parts) => parts.filter(Boolean).join(" ");
|
|
1651
1964
|
function EasyVisionAccordionItem(_props) {
|
|
@@ -1654,8 +1967,8 @@ function EasyVisionAccordionItem(_props) {
|
|
|
1654
1967
|
EasyVisionAccordionItem.displayName = "EasyVisionAccordionItem";
|
|
1655
1968
|
function normalizeFromChildren(children) {
|
|
1656
1969
|
const out = [];
|
|
1657
|
-
|
|
1658
|
-
if (!
|
|
1970
|
+
React10__namespace.Children.forEach(children, (child) => {
|
|
1971
|
+
if (!React10__namespace.isValidElement(child)) return;
|
|
1659
1972
|
if (child.type !== EasyVisionAccordionItem) return;
|
|
1660
1973
|
const p = child.props;
|
|
1661
1974
|
out.push({
|
|
@@ -1719,20 +2032,20 @@ function EasyVisionAccordion({
|
|
|
1719
2032
|
onOpenChange,
|
|
1720
2033
|
className
|
|
1721
2034
|
}) {
|
|
1722
|
-
const normalized =
|
|
2035
|
+
const normalized = React10__namespace.useMemo(
|
|
1723
2036
|
() => items ? normalizeFromItems(items) : normalizeFromChildren(children),
|
|
1724
2037
|
[items, children]
|
|
1725
2038
|
);
|
|
1726
2039
|
const isControlled = openIds !== void 0;
|
|
1727
|
-
const [internalOpen, setInternalOpen] =
|
|
2040
|
+
const [internalOpen, setInternalOpen] = React10__namespace.useState(() => {
|
|
1728
2041
|
if (defaultOpenIds) return new Set(defaultOpenIds);
|
|
1729
2042
|
return new Set(normalized.filter((it) => it.defaultOpen).map((it) => it.id));
|
|
1730
2043
|
});
|
|
1731
|
-
const openSet =
|
|
2044
|
+
const openSet = React10__namespace.useMemo(
|
|
1732
2045
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
1733
2046
|
[isControlled, openIds, internalOpen]
|
|
1734
2047
|
);
|
|
1735
|
-
const handleToggle =
|
|
2048
|
+
const handleToggle = React10__namespace.useCallback(
|
|
1736
2049
|
(id) => {
|
|
1737
2050
|
const next = new Set(openSet);
|
|
1738
2051
|
if (next.has(id)) {
|
|
@@ -1757,21 +2070,21 @@ function EasyVisionAccordion({
|
|
|
1757
2070
|
)) });
|
|
1758
2071
|
}
|
|
1759
2072
|
EasyVisionAccordion.displayName = "EasyVisionAccordion";
|
|
1760
|
-
var Table =
|
|
2073
|
+
var Table = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("table", { ref, className: cn("ev-table", className), ...props }));
|
|
1761
2074
|
Table.displayName = "Table";
|
|
1762
|
-
var TableHeader =
|
|
2075
|
+
var TableHeader = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className, ...props }));
|
|
1763
2076
|
TableHeader.displayName = "TableHeader";
|
|
1764
|
-
var TableBody =
|
|
2077
|
+
var TableBody = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { ref, className, ...props }));
|
|
1765
2078
|
TableBody.displayName = "TableBody";
|
|
1766
|
-
var TableFooter =
|
|
2079
|
+
var TableFooter = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tfoot", { ref, className, ...props }));
|
|
1767
2080
|
TableFooter.displayName = "TableFooter";
|
|
1768
|
-
var TableRow =
|
|
2081
|
+
var TableRow = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tr", { ref, className, ...props }));
|
|
1769
2082
|
TableRow.displayName = "TableRow";
|
|
1770
|
-
var TableHead =
|
|
2083
|
+
var TableHead = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("th", { ref, className, ...props }));
|
|
1771
2084
|
TableHead.displayName = "TableHead";
|
|
1772
|
-
var TableCell =
|
|
2085
|
+
var TableCell = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("td", { ref, className, ...props }));
|
|
1773
2086
|
TableCell.displayName = "TableCell";
|
|
1774
|
-
var TableCaption =
|
|
2087
|
+
var TableCaption = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("caption", { ref, className, ...props }));
|
|
1775
2088
|
TableCaption.displayName = "TableCaption";
|
|
1776
2089
|
var isNestedField = (field) => field.includes(".");
|
|
1777
2090
|
var resolvePath = (obj, path) => path.split(".").reduce(
|
|
@@ -1787,7 +2100,19 @@ function shouldDisableSorting(col, orderingMode, defaultSorting = "nonNested") {
|
|
|
1787
2100
|
if (orderingMode === "api" && isNestedField(col.field)) return true;
|
|
1788
2101
|
return false;
|
|
1789
2102
|
}
|
|
1790
|
-
function
|
|
2103
|
+
function stableCell(cache, field, render) {
|
|
2104
|
+
let entry = cache.get(field);
|
|
2105
|
+
if (!entry) {
|
|
2106
|
+
const created = {
|
|
2107
|
+
Comp: ({ row, getValue }) => created.render ? created.render(row.original) : React10.createElement("span", { className: "text-sm text-foreground" }, String(getValue() ?? "-"))
|
|
2108
|
+
};
|
|
2109
|
+
cache.set(field, created);
|
|
2110
|
+
entry = created;
|
|
2111
|
+
}
|
|
2112
|
+
entry.render = render;
|
|
2113
|
+
return entry.Comp;
|
|
2114
|
+
}
|
|
2115
|
+
function adaptColumns(columns, orderingMode, defaultSorting = "nonNested", cellCache = /* @__PURE__ */ new Map()) {
|
|
1791
2116
|
return columns.map((c) => {
|
|
1792
2117
|
const widthCss = typeof c.width === "number" ? `${c.width}px` : c.width;
|
|
1793
2118
|
const numericWidth = typeof c.width === "number" ? c.width : typeof c.width === "string" && /^\d+px$/.test(c.width) ? parseInt(c.width, 10) : void 0;
|
|
@@ -1800,11 +2125,7 @@ function adaptColumns(columns, orderingMode, defaultSorting = "nonNested") {
|
|
|
1800
2125
|
};
|
|
1801
2126
|
const isUi = c.type === "ui";
|
|
1802
2127
|
const userCell = c.cell;
|
|
1803
|
-
const wrappedCell =
|
|
1804
|
-
"span",
|
|
1805
|
-
{ className: "text-sm text-foreground" },
|
|
1806
|
-
String(getValue() ?? "-")
|
|
1807
|
-
);
|
|
2128
|
+
const wrappedCell = stableCell(cellCache, c.field, userCell);
|
|
1808
2129
|
const base = {
|
|
1809
2130
|
id: c.field,
|
|
1810
2131
|
header: c.header,
|
|
@@ -1890,7 +2211,7 @@ function useTableData({
|
|
|
1890
2211
|
paginationMode,
|
|
1891
2212
|
orderingMode
|
|
1892
2213
|
}) {
|
|
1893
|
-
return
|
|
2214
|
+
return React10.useMemo(() => {
|
|
1894
2215
|
let rows = data ?? [];
|
|
1895
2216
|
if (orderingMode === "local" && sort) {
|
|
1896
2217
|
rows = sortLocalRows(rows, columns, sort);
|
|
@@ -1963,7 +2284,7 @@ async function fetchAllRows({
|
|
|
1963
2284
|
var DropdownMenu = DropdownMenuPrimitive__namespace.Root;
|
|
1964
2285
|
var DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
|
|
1965
2286
|
var DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
|
|
1966
|
-
var DropdownMenuSubTrigger =
|
|
2287
|
+
var DropdownMenuSubTrigger = React10__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1967
2288
|
DropdownMenuPrimitive__namespace.SubTrigger,
|
|
1968
2289
|
{
|
|
1969
2290
|
ref,
|
|
@@ -1980,7 +2301,7 @@ var DropdownMenuSubTrigger = React9__namespace.forwardRef(({ className, inset, c
|
|
|
1980
2301
|
}
|
|
1981
2302
|
));
|
|
1982
2303
|
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
|
|
1983
|
-
var DropdownMenuSubContent =
|
|
2304
|
+
var DropdownMenuSubContent = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1984
2305
|
DropdownMenuPrimitive__namespace.SubContent,
|
|
1985
2306
|
{
|
|
1986
2307
|
ref,
|
|
@@ -1989,7 +2310,7 @@ var DropdownMenuSubContent = React9__namespace.forwardRef(({ className, ...props
|
|
|
1989
2310
|
}
|
|
1990
2311
|
));
|
|
1991
2312
|
DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
|
|
1992
|
-
var DropdownMenuContent =
|
|
2313
|
+
var DropdownMenuContent = React10__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1993
2314
|
DropdownMenuPrimitive__namespace.Content,
|
|
1994
2315
|
{
|
|
1995
2316
|
ref,
|
|
@@ -1999,7 +2320,7 @@ var DropdownMenuContent = React9__namespace.forwardRef(({ className, sideOffset
|
|
|
1999
2320
|
}
|
|
2000
2321
|
) }));
|
|
2001
2322
|
DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
|
|
2002
|
-
var DropdownMenuItem =
|
|
2323
|
+
var DropdownMenuItem = React10__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2003
2324
|
DropdownMenuPrimitive__namespace.Item,
|
|
2004
2325
|
{
|
|
2005
2326
|
ref,
|
|
@@ -2012,7 +2333,7 @@ var DropdownMenuItem = React9__namespace.forwardRef(({ className, inset, ...prop
|
|
|
2012
2333
|
}
|
|
2013
2334
|
));
|
|
2014
2335
|
DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
|
|
2015
|
-
var DropdownMenuCheckboxItem =
|
|
2336
|
+
var DropdownMenuCheckboxItem = React10__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2016
2337
|
DropdownMenuPrimitive__namespace.CheckboxItem,
|
|
2017
2338
|
{
|
|
2018
2339
|
ref,
|
|
@@ -2026,7 +2347,7 @@ var DropdownMenuCheckboxItem = React9__namespace.forwardRef(({ className, childr
|
|
|
2026
2347
|
}
|
|
2027
2348
|
));
|
|
2028
2349
|
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
|
|
2029
|
-
var DropdownMenuRadioItem =
|
|
2350
|
+
var DropdownMenuRadioItem = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2030
2351
|
DropdownMenuPrimitive__namespace.RadioItem,
|
|
2031
2352
|
{
|
|
2032
2353
|
ref,
|
|
@@ -2039,7 +2360,7 @@ var DropdownMenuRadioItem = React9__namespace.forwardRef(({ className, children,
|
|
|
2039
2360
|
}
|
|
2040
2361
|
));
|
|
2041
2362
|
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
|
|
2042
|
-
var DropdownMenuLabel =
|
|
2363
|
+
var DropdownMenuLabel = React10__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2043
2364
|
DropdownMenuPrimitive__namespace.Label,
|
|
2044
2365
|
{
|
|
2045
2366
|
ref,
|
|
@@ -2052,7 +2373,7 @@ var DropdownMenuLabel = React9__namespace.forwardRef(({ className, inset, ...pro
|
|
|
2052
2373
|
}
|
|
2053
2374
|
));
|
|
2054
2375
|
DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
|
|
2055
|
-
var DropdownMenuSeparator =
|
|
2376
|
+
var DropdownMenuSeparator = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2056
2377
|
DropdownMenuPrimitive__namespace.Separator,
|
|
2057
2378
|
{
|
|
2058
2379
|
ref,
|
|
@@ -2165,6 +2486,7 @@ function PaginationFooter({
|
|
|
2165
2486
|
className: "ev-table-footer-nav-btn",
|
|
2166
2487
|
disabled: currentPage <= 1,
|
|
2167
2488
|
onClick: () => onPageChange(currentPage - 1),
|
|
2489
|
+
"aria-label": labels.previousPage,
|
|
2168
2490
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "ev-table-footer-nav-icon" })
|
|
2169
2491
|
}
|
|
2170
2492
|
),
|
|
@@ -2176,6 +2498,7 @@ function PaginationFooter({
|
|
|
2176
2498
|
className: "ev-table-footer-nav-btn",
|
|
2177
2499
|
disabled: currentPage >= totalPages,
|
|
2178
2500
|
onClick: () => onPageChange(currentPage + 1),
|
|
2501
|
+
"aria-label": labels.nextPage,
|
|
2179
2502
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "ev-table-footer-nav-icon" })
|
|
2180
2503
|
}
|
|
2181
2504
|
)
|
|
@@ -2496,8 +2819,19 @@ var DEFAULT_LABELS2 = {
|
|
|
2496
2819
|
selectAllAll: "Seleccionar todo",
|
|
2497
2820
|
selectedAllBanner: (n) => `Todos los ${n} registros seleccionados`,
|
|
2498
2821
|
selectedCountBanner: (n) => `${n} ${n === 1 ? "registro seleccionado" : "registros seleccionados"}`,
|
|
2499
|
-
clearSelection: "Limpiar selecci\xF3n"
|
|
2822
|
+
clearSelection: "Limpiar selecci\xF3n",
|
|
2823
|
+
selectRow: "Seleccionar",
|
|
2824
|
+
previousPage: "P\xE1gina anterior",
|
|
2825
|
+
nextPage: "P\xE1gina siguiente"
|
|
2500
2826
|
};
|
|
2827
|
+
function isFromWithinControl(e) {
|
|
2828
|
+
const target = e.target;
|
|
2829
|
+
if (!target || !e.currentTarget.contains(target)) return true;
|
|
2830
|
+
const control = target.closest(
|
|
2831
|
+
'a, button, input, select, textarea, label, [role="button"], [role="menuitem"], [role="checkbox"], [role="menu"]'
|
|
2832
|
+
);
|
|
2833
|
+
return !!control && e.currentTarget.contains(control) && control !== e.currentTarget;
|
|
2834
|
+
}
|
|
2501
2835
|
function EasyVisionTable(props) {
|
|
2502
2836
|
const {
|
|
2503
2837
|
id,
|
|
@@ -2509,6 +2843,10 @@ function EasyVisionTable(props) {
|
|
|
2509
2843
|
fetchData: fetchDataProp,
|
|
2510
2844
|
loopback,
|
|
2511
2845
|
ingot,
|
|
2846
|
+
defaultSort,
|
|
2847
|
+
reloadSignal,
|
|
2848
|
+
ariaLabel,
|
|
2849
|
+
getRowLabel,
|
|
2512
2850
|
onDataLoaded,
|
|
2513
2851
|
multifilter,
|
|
2514
2852
|
multifilterRef,
|
|
@@ -2542,7 +2880,7 @@ function EasyVisionTable(props) {
|
|
|
2542
2880
|
const lbIncludeKey = JSON.stringify(loopback?.include ?? null);
|
|
2543
2881
|
const lbFieldsKey = JSON.stringify(loopback?.fields ?? null);
|
|
2544
2882
|
const lbOrderKey = JSON.stringify(loopback?.defaultOrder ?? null);
|
|
2545
|
-
const loopbackFetcher =
|
|
2883
|
+
const loopbackFetcher = React10.useMemo(
|
|
2546
2884
|
() => loopback ? createLoopbackTableFetcher(loopback) : void 0,
|
|
2547
2885
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2548
2886
|
[lbFetchPage, lbFetchCount, lbIncludeKey, lbFieldsKey, lbOrderKey]
|
|
@@ -2551,7 +2889,7 @@ function EasyVisionTable(props) {
|
|
|
2551
2889
|
const igIncludeKey = JSON.stringify(ingot?.include ?? null);
|
|
2552
2890
|
const igFieldsKey = JSON.stringify(ingot?.fields ?? null);
|
|
2553
2891
|
const igOrderKey = JSON.stringify(ingot?.defaultOrder ?? null);
|
|
2554
|
-
const ingotFetcher =
|
|
2892
|
+
const ingotFetcher = React10.useMemo(
|
|
2555
2893
|
() => ingot ? createIngotTableFetcher(ingot) : void 0,
|
|
2556
2894
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2557
2895
|
[igFetchPage, igIncludeKey, igFieldsKey, igOrderKey]
|
|
@@ -2560,7 +2898,7 @@ function EasyVisionTable(props) {
|
|
|
2560
2898
|
const apiShortcut = Boolean(loopback || ingot);
|
|
2561
2899
|
const paginationMode = apiShortcut ? "api" : paginationModeProp;
|
|
2562
2900
|
const orderingMode = apiShortcut ? "api" : orderingModeProp;
|
|
2563
|
-
const getRowId =
|
|
2901
|
+
const getRowId = React10.useMemo(
|
|
2564
2902
|
() => getRowIdProp ?? ((row) => String(row?.id ?? "")),
|
|
2565
2903
|
[getRowIdProp]
|
|
2566
2904
|
);
|
|
@@ -2583,10 +2921,10 @@ function EasyVisionTable(props) {
|
|
|
2583
2921
|
persist
|
|
2584
2922
|
});
|
|
2585
2923
|
const { page, itemsPerPage, sort, selection } = slice;
|
|
2586
|
-
const lastSnapshotRef =
|
|
2587
|
-
const [localFilterTick, setLocalFilterTick] =
|
|
2588
|
-
const innerMultifilterRef =
|
|
2589
|
-
const setMultifilterRef =
|
|
2924
|
+
const lastSnapshotRef = React10.useRef(null);
|
|
2925
|
+
const [localFilterTick, setLocalFilterTick] = React10.useState(0);
|
|
2926
|
+
const innerMultifilterRef = React10.useRef(null);
|
|
2927
|
+
const setMultifilterRef = React10.useCallback(
|
|
2590
2928
|
(handle) => {
|
|
2591
2929
|
innerMultifilterRef.current = handle;
|
|
2592
2930
|
if (typeof multifilterRef === "function") {
|
|
@@ -2597,16 +2935,16 @@ function EasyVisionTable(props) {
|
|
|
2597
2935
|
},
|
|
2598
2936
|
[multifilterRef]
|
|
2599
2937
|
);
|
|
2600
|
-
const [apiRows, setApiRows] =
|
|
2601
|
-
const [apiTotalCount, setApiTotalCount] =
|
|
2602
|
-
const [apiLoading, setApiLoading] =
|
|
2603
|
-
const fetchSeqRef =
|
|
2938
|
+
const [apiRows, setApiRows] = React10.useState([]);
|
|
2939
|
+
const [apiTotalCount, setApiTotalCount] = React10.useState(0);
|
|
2940
|
+
const [apiLoading, setApiLoading] = React10.useState(false);
|
|
2941
|
+
const fetchSeqRef = React10.useRef(0);
|
|
2604
2942
|
const isApi = paginationMode === "api" || orderingMode === "api";
|
|
2605
|
-
const [eagerAllIds, setEagerAllIds] =
|
|
2606
|
-
const [eagerAllRows, setEagerAllRows] =
|
|
2607
|
-
const [isResolvingEager, setIsResolvingEager] =
|
|
2608
|
-
const eagerSeqRef =
|
|
2609
|
-
const runFetch =
|
|
2943
|
+
const [eagerAllIds, setEagerAllIds] = React10.useState(null);
|
|
2944
|
+
const [eagerAllRows, setEagerAllRows] = React10.useState([]);
|
|
2945
|
+
const [isResolvingEager, setIsResolvingEager] = React10.useState(false);
|
|
2946
|
+
const eagerSeqRef = React10.useRef(0);
|
|
2947
|
+
const runFetch = React10.useCallback(async () => {
|
|
2610
2948
|
if (!fetchData) return;
|
|
2611
2949
|
const seq = ++fetchSeqRef.current;
|
|
2612
2950
|
setApiLoading(true);
|
|
@@ -2626,10 +2964,14 @@ function EasyVisionTable(props) {
|
|
|
2626
2964
|
if (seq === fetchSeqRef.current) setApiLoading(false);
|
|
2627
2965
|
}
|
|
2628
2966
|
}, [fetchData, page, itemsPerPage, sort, externalFilter, onDataLoaded]);
|
|
2629
|
-
|
|
2630
|
-
if (isApi
|
|
2631
|
-
|
|
2632
|
-
|
|
2967
|
+
React10.useEffect(() => {
|
|
2968
|
+
if (!isApi || !fetchData) return;
|
|
2969
|
+
const seq = fetchSeqRef.current;
|
|
2970
|
+
queueMicrotask(() => {
|
|
2971
|
+
if (fetchSeqRef.current === seq) void runFetch();
|
|
2972
|
+
});
|
|
2973
|
+
}, [isApi, page, itemsPerPage, sort, refetchSignal, reloadSignal]);
|
|
2974
|
+
const resolveEagerAll = React10.useCallback(async () => {
|
|
2633
2975
|
if (!fetchData) return;
|
|
2634
2976
|
const collectRows = selectAllResolution === "eager";
|
|
2635
2977
|
const seq = ++eagerSeqRef.current;
|
|
@@ -2658,8 +3000,8 @@ function EasyVisionTable(props) {
|
|
|
2658
3000
|
if (seq === eagerSeqRef.current) setIsResolvingEager(false);
|
|
2659
3001
|
}
|
|
2660
3002
|
}, [fetchData, externalFilter, sort, getRowId, selectAllResolution]);
|
|
2661
|
-
const prevRefetchRef =
|
|
2662
|
-
|
|
3003
|
+
const prevRefetchRef = React10.useRef(refetchSignal);
|
|
3004
|
+
React10.useEffect(() => {
|
|
2663
3005
|
if (prevRefetchRef.current !== refetchSignal && page !== 1) {
|
|
2664
3006
|
prevRefetchRef.current = refetchSignal;
|
|
2665
3007
|
patch({ page: 1 });
|
|
@@ -2671,7 +3013,7 @@ function EasyVisionTable(props) {
|
|
|
2671
3013
|
eagerSeqRef.current++;
|
|
2672
3014
|
setIsResolvingEager(false);
|
|
2673
3015
|
}, [refetchSignal]);
|
|
2674
|
-
const filteredData =
|
|
3016
|
+
const filteredData = React10.useMemo(() => {
|
|
2675
3017
|
if (paginationMode !== "local") return data;
|
|
2676
3018
|
if (!data || data.length === 0) return data;
|
|
2677
3019
|
const mfWhere = lastSnapshotRef.current?.query?.where;
|
|
@@ -2692,11 +3034,12 @@ function EasyVisionTable(props) {
|
|
|
2692
3034
|
const rows = isApi ? apiRows : local.rows;
|
|
2693
3035
|
const totalCount = isApi ? apiTotalCount : local.totalCount;
|
|
2694
3036
|
const isLoading = isLoadingProp || apiLoading;
|
|
2695
|
-
const
|
|
2696
|
-
|
|
3037
|
+
const cellCacheRef = React10.useRef(/* @__PURE__ */ new Map());
|
|
3038
|
+
const tanstackColumns = React10.useMemo(
|
|
3039
|
+
() => adaptColumns(columns, orderingMode, defaultSorting, cellCacheRef.current),
|
|
2697
3040
|
[columns, orderingMode, defaultSorting]
|
|
2698
3041
|
);
|
|
2699
|
-
const allColumns =
|
|
3042
|
+
const allColumns = React10.useMemo(() => {
|
|
2700
3043
|
if (!enableRowSelection) return tanstackColumns;
|
|
2701
3044
|
const checkboxCol = {
|
|
2702
3045
|
id: "_select",
|
|
@@ -2708,7 +3051,7 @@ function EasyVisionTable(props) {
|
|
|
2708
3051
|
checked: row.getIsSelected(),
|
|
2709
3052
|
onCheckedChange: (v) => row.toggleSelected(!!v),
|
|
2710
3053
|
onClick: (e) => e.stopPropagation(),
|
|
2711
|
-
"aria-label":
|
|
3054
|
+
"aria-label": getRowLabel ? `${labels.selectRow} ${getRowLabel(row.original)}` : labels.selectRow
|
|
2712
3055
|
}
|
|
2713
3056
|
),
|
|
2714
3057
|
enableSorting: false,
|
|
@@ -2716,11 +3059,11 @@ function EasyVisionTable(props) {
|
|
|
2716
3059
|
};
|
|
2717
3060
|
return [checkboxCol, ...tanstackColumns];
|
|
2718
3061
|
}, [enableRowSelection, tanstackColumns]);
|
|
2719
|
-
const columnVisibility =
|
|
3062
|
+
const columnVisibility = React10.useMemo(
|
|
2720
3063
|
() => resolveColumnVisibility(columns, slice.columnVisibility),
|
|
2721
3064
|
[columns, slice.columnVisibility]
|
|
2722
3065
|
);
|
|
2723
|
-
const exportStateRef =
|
|
3066
|
+
const exportStateRef = React10.useRef({
|
|
2724
3067
|
columns,
|
|
2725
3068
|
columnVisibility,
|
|
2726
3069
|
selection,
|
|
@@ -2742,7 +3085,7 @@ function EasyVisionTable(props) {
|
|
|
2742
3085
|
isApi,
|
|
2743
3086
|
getRowId
|
|
2744
3087
|
};
|
|
2745
|
-
|
|
3088
|
+
React10.useEffect(() => {
|
|
2746
3089
|
registerExportSource(fullId, {
|
|
2747
3090
|
sheetName: id,
|
|
2748
3091
|
getColumns: () => {
|
|
@@ -2772,19 +3115,21 @@ function EasyVisionTable(props) {
|
|
|
2772
3115
|
});
|
|
2773
3116
|
return () => unregisterExportSource(fullId);
|
|
2774
3117
|
}, [fullId, id]);
|
|
2775
|
-
const resizableFields =
|
|
3118
|
+
const resizableFields = React10.useMemo(() => {
|
|
2776
3119
|
const s = /* @__PURE__ */ new Set();
|
|
2777
3120
|
for (const c of columns) if (c.resizable) s.add(c.field);
|
|
2778
3121
|
return s;
|
|
2779
3122
|
}, [columns]);
|
|
2780
3123
|
const columnSizing = slice.columnSizing;
|
|
2781
|
-
const rowSelection =
|
|
3124
|
+
const rowSelection = React10.useMemo(() => {
|
|
2782
3125
|
if (selection.scope === "all") return {};
|
|
2783
3126
|
const r = {};
|
|
2784
3127
|
for (const id2 of Object.keys(selection.ids)) r[id2] = true;
|
|
2785
3128
|
return r;
|
|
2786
3129
|
}, [selection]);
|
|
2787
|
-
const
|
|
3130
|
+
const shownSort = sort ?? defaultSort ?? null;
|
|
3131
|
+
const sortingState = shownSort ? [{ id: shownSort.column, desc: shownSort.descending }] : [];
|
|
3132
|
+
const isDefaultSort = (s) => !!s && !!defaultSort && s.column === defaultSort.column && s.descending === defaultSort.descending;
|
|
2788
3133
|
const isEagerWildcard = (selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi && selection.scope === "all";
|
|
2789
3134
|
const tableInstance = reactTable.useReactTable({
|
|
2790
3135
|
data: rows,
|
|
@@ -2820,7 +3165,12 @@ function EasyVisionTable(props) {
|
|
|
2820
3165
|
if (isEagerWildcard) return;
|
|
2821
3166
|
const next = typeof updater === "function" ? updater(sortingState) : updater;
|
|
2822
3167
|
const first = next[0];
|
|
2823
|
-
|
|
3168
|
+
let newSort = first ? { column: first.id, descending: !!first.desc } : null;
|
|
3169
|
+
if (!newSort && sort === null && defaultSort) {
|
|
3170
|
+
newSort = { column: defaultSort.column, descending: !defaultSort.descending };
|
|
3171
|
+
} else if (isDefaultSort(newSort)) {
|
|
3172
|
+
newSort = null;
|
|
3173
|
+
}
|
|
2824
3174
|
patch({ sort: newSort });
|
|
2825
3175
|
},
|
|
2826
3176
|
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
@@ -2839,8 +3189,8 @@ function EasyVisionTable(props) {
|
|
|
2839
3189
|
pageCount: Math.ceil(totalCount / itemsPerPage),
|
|
2840
3190
|
getRowId
|
|
2841
3191
|
});
|
|
2842
|
-
const lastSelectionEmittedRef =
|
|
2843
|
-
|
|
3192
|
+
const lastSelectionEmittedRef = React10.useRef("");
|
|
3193
|
+
React10.useEffect(() => {
|
|
2844
3194
|
if (!enableRowSelection) return;
|
|
2845
3195
|
if (isEagerWildcard && (isResolvingEager || eagerAllIds === null)) return;
|
|
2846
3196
|
let event;
|
|
@@ -2922,11 +3272,11 @@ function EasyVisionTable(props) {
|
|
|
2922
3272
|
isResolvingEager,
|
|
2923
3273
|
isEagerWildcard
|
|
2924
3274
|
]);
|
|
2925
|
-
const rowIdOf =
|
|
3275
|
+
const rowIdOf = React10.useCallback(
|
|
2926
3276
|
(row) => getRowId(row),
|
|
2927
3277
|
[getRowId]
|
|
2928
3278
|
);
|
|
2929
|
-
const headerState =
|
|
3279
|
+
const headerState = React10.useMemo(() => {
|
|
2930
3280
|
if (selection.scope === "all") {
|
|
2931
3281
|
const except = Object.keys(selection.exceptIds ?? {}).length;
|
|
2932
3282
|
if (except === 0) return "checked";
|
|
@@ -2942,7 +3292,7 @@ function EasyVisionTable(props) {
|
|
|
2942
3292
|
if (selectedOnPage === visibleIds.length) return "checked";
|
|
2943
3293
|
return "indeterminate";
|
|
2944
3294
|
}, [selection, rows, rowIdOf]);
|
|
2945
|
-
const onHeaderToggle =
|
|
3295
|
+
const onHeaderToggle = React10.useCallback(
|
|
2946
3296
|
(checked) => {
|
|
2947
3297
|
if (selection.scope === "all") {
|
|
2948
3298
|
if (checked) {
|
|
@@ -2968,7 +3318,7 @@ function EasyVisionTable(props) {
|
|
|
2968
3318
|
},
|
|
2969
3319
|
[patch, selection, rows, rowIdOf]
|
|
2970
3320
|
);
|
|
2971
|
-
const onScopeChange =
|
|
3321
|
+
const onScopeChange = React10.useCallback(
|
|
2972
3322
|
(scope) => {
|
|
2973
3323
|
if (scope === "all") {
|
|
2974
3324
|
patch({ selection: { ids: {}, scope: "all", exceptIds: {} } });
|
|
@@ -2987,8 +3337,8 @@ function EasyVisionTable(props) {
|
|
|
2987
3337
|
},
|
|
2988
3338
|
[patch, selectAllResolution, isApi, resolveEagerAll]
|
|
2989
3339
|
);
|
|
2990
|
-
const firstPerformAfterMountRef =
|
|
2991
|
-
const handlePerform =
|
|
3340
|
+
const firstPerformAfterMountRef = React10.useRef(true);
|
|
3341
|
+
const handlePerform = React10.useCallback(
|
|
2992
3342
|
(snap) => {
|
|
2993
3343
|
const isFirstAfterMount = firstPerformAfterMountRef.current;
|
|
2994
3344
|
firstPerformAfterMountRef.current = false;
|
|
@@ -3008,8 +3358,8 @@ function EasyVisionTable(props) {
|
|
|
3008
3358
|
[isApi, multifilter, patch, runFetch, selection.scope]
|
|
3009
3359
|
);
|
|
3010
3360
|
const totalPages = Math.max(1, Math.ceil(totalCount / itemsPerPage));
|
|
3011
|
-
const hasResolvedDataRef =
|
|
3012
|
-
|
|
3361
|
+
const hasResolvedDataRef = React10.useRef(false);
|
|
3362
|
+
React10.useEffect(() => {
|
|
3013
3363
|
if (isApi) {
|
|
3014
3364
|
if (apiLoading) return;
|
|
3015
3365
|
if (!hasResolvedDataRef.current) {
|
|
@@ -3022,7 +3372,7 @@ function EasyVisionTable(props) {
|
|
|
3022
3372
|
}
|
|
3023
3373
|
if (page > totalPages) patch({ page: totalPages });
|
|
3024
3374
|
}, [page, totalPages, patch, isApi, apiLoading, apiTotalCount, apiRows.length]);
|
|
3025
|
-
|
|
3375
|
+
React10.useEffect(() => {
|
|
3026
3376
|
if (isApi) return;
|
|
3027
3377
|
if (paginationMode === "page") return;
|
|
3028
3378
|
if (page > 1 && page > Math.max(1, Math.ceil(totalCount / itemsPerPage))) {
|
|
@@ -3081,7 +3431,7 @@ function EasyVisionTable(props) {
|
|
|
3081
3431
|
style: maxBodyHeight !== void 0 ? {
|
|
3082
3432
|
maxHeight: typeof maxBodyHeight === "number" ? `${maxBodyHeight}px` : maxBodyHeight
|
|
3083
3433
|
} : void 0,
|
|
3084
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "ev-table", children: [
|
|
3434
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "ev-table", "aria-label": ariaLabel, children: [
|
|
3085
3435
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3086
3436
|
TableHeader,
|
|
3087
3437
|
{
|
|
@@ -3113,6 +3463,7 @@ function EasyVisionTable(props) {
|
|
|
3113
3463
|
TableHead,
|
|
3114
3464
|
{
|
|
3115
3465
|
style: headerWidthStyle,
|
|
3466
|
+
"aria-sort": header.column.getIsSorted() === "asc" ? "ascending" : header.column.getIsSorted() === "desc" ? "descending" : void 0,
|
|
3116
3467
|
className: colMeta.largeScreensOnly ? "ev-table-large-only" : void 0,
|
|
3117
3468
|
children: [
|
|
3118
3469
|
header.isPlaceholder ? null : sortable ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3162,7 +3513,9 @@ function EasyVisionTable(props) {
|
|
|
3162
3513
|
"data-state": row.getIsSelected() || isAllSelected ? "selected" : void 0,
|
|
3163
3514
|
"data-highlighted": highlighted ? "true" : void 0,
|
|
3164
3515
|
className: onRowClick ? "ev-table-row-clickable" : void 0,
|
|
3165
|
-
onClick: () =>
|
|
3516
|
+
onClick: (e) => {
|
|
3517
|
+
if (onRowClick && !isFromWithinControl(e)) onRowClick(row.original);
|
|
3518
|
+
},
|
|
3166
3519
|
children: row.getVisibleCells().map((cell) => {
|
|
3167
3520
|
if (cell.column.id === "_select" && selection.scope === "all") {
|
|
3168
3521
|
return /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3355,8 +3708,8 @@ function EasyVisionExportButton({
|
|
|
3355
3708
|
}) {
|
|
3356
3709
|
const labels = { ...DEFAULT_LABELS3, ...labelOverrides };
|
|
3357
3710
|
const parentFullId = useParentFullId();
|
|
3358
|
-
const [isExporting, setIsExporting] =
|
|
3359
|
-
const handleClick =
|
|
3711
|
+
const [isExporting, setIsExporting] = React10.useState(false);
|
|
3712
|
+
const handleClick = React10.useCallback(async () => {
|
|
3360
3713
|
setIsExporting(true);
|
|
3361
3714
|
try {
|
|
3362
3715
|
const resolved = tables.map((tableId) => ({
|