@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.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import './easyvision.css';
|
|
2
2
|
import './EasyVisionTable.css';
|
|
3
|
-
import * as
|
|
4
|
-
import { createContext, forwardRef, useMemo,
|
|
5
|
-
import { ChevronDown, ChevronUp, Check, Search, X, Plus, ChevronRight, Circle, Calendar as Calendar$1, ChevronLeft, ChevronsUpDown, Loader2, ArrowUp, ArrowDown, ArrowUpDown, Download, Settings2 } from 'lucide-react';
|
|
3
|
+
import * as React10 from 'react';
|
|
4
|
+
import { createContext, forwardRef, useMemo, useCallback, useRef, useSyncExternalStore, useEffect, useImperativeHandle, useState, useContext, createElement } from 'react';
|
|
5
|
+
import { ChevronDown, ChevronUp, Check, Search, X, Plus, ChevronRight, Circle, Bookmark, Star, Trash2, Calendar as Calendar$1, ChevronLeft, ChevronsUpDown, Loader2, ArrowUp, ArrowDown, ArrowUpDown, Download, Settings2 } from 'lucide-react';
|
|
6
6
|
import { clsx } from 'clsx';
|
|
7
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -24,7 +24,7 @@ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
|
24
24
|
function cn(...inputs) {
|
|
25
25
|
return twMerge(clsx(inputs));
|
|
26
26
|
}
|
|
27
|
-
var Input =
|
|
27
|
+
var Input = React10.forwardRef(
|
|
28
28
|
({ className, type, ...props }, ref) => {
|
|
29
29
|
return /* @__PURE__ */ jsx(
|
|
30
30
|
"input",
|
|
@@ -232,7 +232,7 @@ function EasyVisionInput({
|
|
|
232
232
|
}
|
|
233
233
|
var Select = SelectPrimitive.Root;
|
|
234
234
|
var SelectValue = SelectPrimitive.Value;
|
|
235
|
-
var SelectTrigger =
|
|
235
|
+
var SelectTrigger = React10.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
236
236
|
SelectPrimitive.Trigger,
|
|
237
237
|
{
|
|
238
238
|
ref,
|
|
@@ -245,7 +245,7 @@ var SelectTrigger = React9.forwardRef(({ className, children, ...props }, ref) =
|
|
|
245
245
|
}
|
|
246
246
|
));
|
|
247
247
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
248
|
-
var SelectScrollUpButton =
|
|
248
|
+
var SelectScrollUpButton = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
249
249
|
SelectPrimitive.ScrollUpButton,
|
|
250
250
|
{
|
|
251
251
|
ref,
|
|
@@ -255,7 +255,7 @@ var SelectScrollUpButton = React9.forwardRef(({ className, ...props }, ref) => /
|
|
|
255
255
|
}
|
|
256
256
|
));
|
|
257
257
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
258
|
-
var SelectScrollDownButton =
|
|
258
|
+
var SelectScrollDownButton = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
259
259
|
SelectPrimitive.ScrollDownButton,
|
|
260
260
|
{
|
|
261
261
|
ref,
|
|
@@ -265,7 +265,7 @@ var SelectScrollDownButton = React9.forwardRef(({ className, ...props }, ref) =>
|
|
|
265
265
|
}
|
|
266
266
|
));
|
|
267
267
|
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
268
|
-
var SelectContent =
|
|
268
|
+
var SelectContent = React10.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
269
269
|
SelectPrimitive.Content,
|
|
270
270
|
{
|
|
271
271
|
ref,
|
|
@@ -289,7 +289,7 @@ var SelectContent = React9.forwardRef(({ className, children, position = "popper
|
|
|
289
289
|
}
|
|
290
290
|
) }));
|
|
291
291
|
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
292
|
-
var SelectLabel =
|
|
292
|
+
var SelectLabel = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
293
293
|
SelectPrimitive.Label,
|
|
294
294
|
{
|
|
295
295
|
ref,
|
|
@@ -298,7 +298,7 @@ var SelectLabel = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
298
298
|
}
|
|
299
299
|
));
|
|
300
300
|
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
301
|
-
var SelectItem =
|
|
301
|
+
var SelectItem = React10.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
302
302
|
SelectPrimitive.Item,
|
|
303
303
|
{
|
|
304
304
|
ref,
|
|
@@ -311,7 +311,7 @@ var SelectItem = React9.forwardRef(({ className, children, ...props }, ref) => /
|
|
|
311
311
|
}
|
|
312
312
|
));
|
|
313
313
|
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
314
|
-
var SelectSeparator =
|
|
314
|
+
var SelectSeparator = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
315
315
|
SelectPrimitive.Separator,
|
|
316
316
|
{
|
|
317
317
|
ref,
|
|
@@ -342,7 +342,7 @@ var buttonVariants = cva("ev-btn", {
|
|
|
342
342
|
size: "default"
|
|
343
343
|
}
|
|
344
344
|
});
|
|
345
|
-
var Button =
|
|
345
|
+
var Button = React10.forwardRef(
|
|
346
346
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
347
347
|
const Comp = asChild ? Slot : "button";
|
|
348
348
|
return /* @__PURE__ */ jsx(
|
|
@@ -358,7 +358,7 @@ var Button = React9.forwardRef(
|
|
|
358
358
|
Button.displayName = "Button";
|
|
359
359
|
var Popover = PopoverPrimitive.Root;
|
|
360
360
|
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
361
|
-
var PopoverContent =
|
|
361
|
+
var PopoverContent = React10.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
362
362
|
PopoverPrimitive.Content,
|
|
363
363
|
{
|
|
364
364
|
ref,
|
|
@@ -369,7 +369,7 @@ var PopoverContent = React9.forwardRef(({ className, align = "center", sideOffse
|
|
|
369
369
|
}
|
|
370
370
|
) }));
|
|
371
371
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
372
|
-
var Command =
|
|
372
|
+
var Command = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
373
373
|
Command$1,
|
|
374
374
|
{
|
|
375
375
|
ref,
|
|
@@ -378,7 +378,7 @@ var Command = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ *
|
|
|
378
378
|
}
|
|
379
379
|
));
|
|
380
380
|
Command.displayName = Command$1.displayName;
|
|
381
|
-
var CommandInput =
|
|
381
|
+
var CommandInput = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "ev-cmd-input-wrapper", "cmdk-input-wrapper": "", children: [
|
|
382
382
|
/* @__PURE__ */ jsx(MagnifyingGlassIcon, { className: "ev-cmd-input-icon" }),
|
|
383
383
|
/* @__PURE__ */ jsx(
|
|
384
384
|
Command$1.Input,
|
|
@@ -390,7 +390,7 @@ var CommandInput = React9.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
390
390
|
)
|
|
391
391
|
] }));
|
|
392
392
|
CommandInput.displayName = Command$1.Input.displayName;
|
|
393
|
-
var CommandList =
|
|
393
|
+
var CommandList = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
394
394
|
Command$1.List,
|
|
395
395
|
{
|
|
396
396
|
ref,
|
|
@@ -399,7 +399,7 @@ var CommandList = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
399
399
|
}
|
|
400
400
|
));
|
|
401
401
|
CommandList.displayName = Command$1.List.displayName;
|
|
402
|
-
var CommandEmpty =
|
|
402
|
+
var CommandEmpty = React10.forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
403
403
|
Command$1.Empty,
|
|
404
404
|
{
|
|
405
405
|
ref,
|
|
@@ -408,7 +408,7 @@ var CommandEmpty = React9.forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
|
408
408
|
}
|
|
409
409
|
));
|
|
410
410
|
CommandEmpty.displayName = Command$1.Empty.displayName;
|
|
411
|
-
var CommandGroup =
|
|
411
|
+
var CommandGroup = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
412
412
|
Command$1.Group,
|
|
413
413
|
{
|
|
414
414
|
ref,
|
|
@@ -417,7 +417,7 @@ var CommandGroup = React9.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
417
417
|
}
|
|
418
418
|
));
|
|
419
419
|
CommandGroup.displayName = Command$1.Group.displayName;
|
|
420
|
-
var CommandSeparator =
|
|
420
|
+
var CommandSeparator = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
421
421
|
Command$1.Separator,
|
|
422
422
|
{
|
|
423
423
|
ref,
|
|
@@ -426,7 +426,7 @@ var CommandSeparator = React9.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
426
426
|
}
|
|
427
427
|
));
|
|
428
428
|
CommandSeparator.displayName = Command$1.Separator.displayName;
|
|
429
|
-
var CommandItem =
|
|
429
|
+
var CommandItem = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
430
430
|
Command$1.Item,
|
|
431
431
|
{
|
|
432
432
|
ref,
|
|
@@ -564,7 +564,13 @@ function EasyVisionSelector({
|
|
|
564
564
|
] })
|
|
565
565
|
] });
|
|
566
566
|
}
|
|
567
|
+
var WidgetLabelsContext = createContext({
|
|
568
|
+
removeFilter: "Quitar filtro",
|
|
569
|
+
removeValue: "Quitar"
|
|
570
|
+
});
|
|
571
|
+
var useWidgetLabels = () => useContext(WidgetLabelsContext);
|
|
567
572
|
function TextWidget({ definition, value, onChange, onRemove }) {
|
|
573
|
+
const widgetLabels = useWidgetLabels();
|
|
568
574
|
return /* @__PURE__ */ jsxs("div", { className: "ev-mf-chip", children: [
|
|
569
575
|
/* @__PURE__ */ jsxs("span", { className: "ev-mf-chip-label", children: [
|
|
570
576
|
definition.label,
|
|
@@ -576,6 +582,7 @@ function TextWidget({ definition, value, onChange, onRemove }) {
|
|
|
576
582
|
{
|
|
577
583
|
className: "ev-mf-chip-input",
|
|
578
584
|
placeholder: definition.placeholder,
|
|
585
|
+
"aria-label": definition.label,
|
|
579
586
|
value: value ?? "",
|
|
580
587
|
onChange: (e) => onChange(e.target.value)
|
|
581
588
|
}
|
|
@@ -585,6 +592,7 @@ function TextWidget({ definition, value, onChange, onRemove }) {
|
|
|
585
592
|
{
|
|
586
593
|
type: "button",
|
|
587
594
|
onClick: onRemove,
|
|
595
|
+
"aria-label": `${widgetLabels.removeFilter}: ${definition.label}`,
|
|
588
596
|
className: "ev-mf-chip-remove",
|
|
589
597
|
children: /* @__PURE__ */ jsx(X, {})
|
|
590
598
|
}
|
|
@@ -593,6 +601,7 @@ function TextWidget({ definition, value, onChange, onRemove }) {
|
|
|
593
601
|
}
|
|
594
602
|
var SENTINEL = "__easyvision_undef__";
|
|
595
603
|
function SelectorWidget({ definition, value, onChange, onRemove }) {
|
|
604
|
+
const widgetLabels = useWidgetLabels();
|
|
596
605
|
const [open, setOpen] = useState(false);
|
|
597
606
|
const [resolved, setResolved] = useState(
|
|
598
607
|
Array.isArray(definition.options) ? definition.options : null
|
|
@@ -643,13 +652,14 @@ function SelectorWidget({ definition, value, onChange, onRemove }) {
|
|
|
643
652
|
{
|
|
644
653
|
type: "button",
|
|
645
654
|
onClick: onRemove,
|
|
655
|
+
"aria-label": `${widgetLabels.removeFilter}: ${definition.label}`,
|
|
646
656
|
className: "ev-mf-chip-remove",
|
|
647
657
|
children: /* @__PURE__ */ jsx(X, {})
|
|
648
658
|
}
|
|
649
659
|
)
|
|
650
660
|
] });
|
|
651
661
|
}
|
|
652
|
-
var Checkbox =
|
|
662
|
+
var Checkbox = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
653
663
|
CheckboxPrimitive.Root,
|
|
654
664
|
{
|
|
655
665
|
ref,
|
|
@@ -665,6 +675,7 @@ function MultiSelectWidget({
|
|
|
665
675
|
onChange,
|
|
666
676
|
onRemove
|
|
667
677
|
}) {
|
|
678
|
+
const widgetLabels = useWidgetLabels();
|
|
668
679
|
const [search, setSearch] = useState("");
|
|
669
680
|
const [open, setOpen] = useState(false);
|
|
670
681
|
const searchFn = definition.searchOptions;
|
|
@@ -739,13 +750,14 @@ function MultiSelectWidget({
|
|
|
739
750
|
{
|
|
740
751
|
type: "button",
|
|
741
752
|
onClick: () => removeOne(v),
|
|
753
|
+
"aria-label": `${widgetLabels.removeValue} ${labelOf(v)}`,
|
|
742
754
|
className: "ev-mf-chip-badge-x",
|
|
743
755
|
children: /* @__PURE__ */ jsx(X, {})
|
|
744
756
|
}
|
|
745
757
|
)
|
|
746
758
|
] }, String(v))),
|
|
747
759
|
/* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
748
|
-
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { type: "button", className: "ev-mf-chip-caret", children: /* @__PURE__ */ jsx(ChevronDown, {}) }) }),
|
|
760
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { type: "button", className: "ev-mf-chip-caret", "aria-label": definition.label, children: /* @__PURE__ */ jsx(ChevronDown, {}) }) }),
|
|
749
761
|
/* @__PURE__ */ jsxs(PopoverContent, { className: "ev-mf-ms-popover", align: "start", children: [
|
|
750
762
|
/* @__PURE__ */ jsx(
|
|
751
763
|
Input,
|
|
@@ -771,7 +783,16 @@ function MultiSelectWidget({
|
|
|
771
783
|
] })
|
|
772
784
|
] })
|
|
773
785
|
] }),
|
|
774
|
-
onRemove && /* @__PURE__ */ jsx(
|
|
786
|
+
onRemove && /* @__PURE__ */ jsx(
|
|
787
|
+
"button",
|
|
788
|
+
{
|
|
789
|
+
type: "button",
|
|
790
|
+
onClick: onRemove,
|
|
791
|
+
"aria-label": `${widgetLabels.removeFilter}: ${definition.label}`,
|
|
792
|
+
className: "ev-mf-chip-remove",
|
|
793
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
794
|
+
}
|
|
795
|
+
)
|
|
775
796
|
] });
|
|
776
797
|
}
|
|
777
798
|
function Calendar({
|
|
@@ -827,6 +848,7 @@ function DateRangeWidget({
|
|
|
827
848
|
onChange,
|
|
828
849
|
onRemove
|
|
829
850
|
}) {
|
|
851
|
+
const widgetLabels = useWidgetLabels();
|
|
830
852
|
const range = value ?? {};
|
|
831
853
|
const label = (() => {
|
|
832
854
|
if (range.from && range.to) {
|
|
@@ -863,6 +885,7 @@ function DateRangeWidget({
|
|
|
863
885
|
{
|
|
864
886
|
type: "button",
|
|
865
887
|
onClick: onRemove,
|
|
888
|
+
"aria-label": `${widgetLabels.removeFilter}: ${definition.label}`,
|
|
866
889
|
className: "ev-mf-chip-remove",
|
|
867
890
|
children: /* @__PURE__ */ jsx(X, {})
|
|
868
891
|
}
|
|
@@ -875,6 +898,7 @@ function NumberRangeWidget({
|
|
|
875
898
|
onChange,
|
|
876
899
|
onRemove
|
|
877
900
|
}) {
|
|
901
|
+
const widgetLabels = useWidgetLabels();
|
|
878
902
|
const range = value ?? {};
|
|
879
903
|
return /* @__PURE__ */ jsxs("div", { className: "ev-mf-chip", children: [
|
|
880
904
|
/* @__PURE__ */ jsxs("span", { className: "ev-mf-chip-label", children: [
|
|
@@ -888,6 +912,7 @@ function NumberRangeWidget({
|
|
|
888
912
|
type: "number",
|
|
889
913
|
className: "ev-mf-chip-number",
|
|
890
914
|
placeholder: "Min",
|
|
915
|
+
"aria-label": `${definition.label} (min)`,
|
|
891
916
|
value: range.min ?? "",
|
|
892
917
|
onChange: (e) => onChange({ ...range, min: e.target.value ? Number(e.target.value) : void 0 })
|
|
893
918
|
}
|
|
@@ -899,6 +924,7 @@ function NumberRangeWidget({
|
|
|
899
924
|
type: "number",
|
|
900
925
|
className: "ev-mf-chip-number",
|
|
901
926
|
placeholder: "Max",
|
|
927
|
+
"aria-label": `${definition.label} (max)`,
|
|
902
928
|
value: range.max ?? "",
|
|
903
929
|
onChange: (e) => onChange({ ...range, max: e.target.value ? Number(e.target.value) : void 0 })
|
|
904
930
|
}
|
|
@@ -908,6 +934,7 @@ function NumberRangeWidget({
|
|
|
908
934
|
{
|
|
909
935
|
type: "button",
|
|
910
936
|
onClick: onRemove,
|
|
937
|
+
"aria-label": `${widgetLabels.removeFilter}: ${definition.label}`,
|
|
911
938
|
className: "ev-mf-chip-remove",
|
|
912
939
|
children: /* @__PURE__ */ jsx(X, {})
|
|
913
940
|
}
|
|
@@ -1128,13 +1155,231 @@ function isDirty(input, lastConfirmed) {
|
|
|
1128
1155
|
}
|
|
1129
1156
|
return current !== lastConfirmed;
|
|
1130
1157
|
}
|
|
1158
|
+
var EMPTY = { items: [], defaultName: null };
|
|
1159
|
+
var isSavedFilter = (v) => typeof v === "object" && v !== null && typeof v.name === "string" && typeof v.filters === "object" && v.filters !== null;
|
|
1160
|
+
function readSaved(storage, key) {
|
|
1161
|
+
try {
|
|
1162
|
+
const raw = storage?.getItem(key);
|
|
1163
|
+
if (!raw) return EMPTY;
|
|
1164
|
+
const parsed = JSON.parse(raw);
|
|
1165
|
+
const items = (Array.isArray(parsed.items) ? parsed.items : []).filter(isSavedFilter).map((item) => ({ ...item, search: Array.isArray(item.search) ? item.search : [] }));
|
|
1166
|
+
const defaultName = typeof parsed.defaultName === "string" && items.some((i) => i.name === parsed.defaultName) ? parsed.defaultName : null;
|
|
1167
|
+
return { items, defaultName };
|
|
1168
|
+
} catch {
|
|
1169
|
+
return EMPTY;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
function writeSaved(storage, key, store) {
|
|
1173
|
+
try {
|
|
1174
|
+
storage?.setItem(key, JSON.stringify(store));
|
|
1175
|
+
} catch {
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
var pad = (n) => String(n).padStart(2, "0");
|
|
1179
|
+
function toDay(value) {
|
|
1180
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
1181
|
+
const date = value instanceof Date ? value : new Date(String(value));
|
|
1182
|
+
if (Number.isNaN(date.getTime())) return void 0;
|
|
1183
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
1184
|
+
}
|
|
1185
|
+
function fromDay(value) {
|
|
1186
|
+
if (typeof value !== "string" || !value) return void 0;
|
|
1187
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
1188
|
+
const date = m ? new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3])) : new Date(value);
|
|
1189
|
+
return Number.isNaN(date.getTime()) ? void 0 : date;
|
|
1190
|
+
}
|
|
1191
|
+
var savable = (fields) => new Map(fields.filter((f) => f.type !== "multifilter").map((f) => [f.id, f]));
|
|
1192
|
+
function toStored(values, fields) {
|
|
1193
|
+
const defs = savable(fields);
|
|
1194
|
+
const out = {};
|
|
1195
|
+
for (const [id, value] of Object.entries(values)) {
|
|
1196
|
+
const def = defs.get(id);
|
|
1197
|
+
if (!def || !isNonEmpty(value)) continue;
|
|
1198
|
+
if (def.type === "dateRange") {
|
|
1199
|
+
const range = value;
|
|
1200
|
+
const stored = {};
|
|
1201
|
+
const from = toDay(range.from);
|
|
1202
|
+
const to = toDay(range.to);
|
|
1203
|
+
if (from) stored.from = from;
|
|
1204
|
+
if (to) stored.to = to;
|
|
1205
|
+
if (Object.keys(stored).length > 0) out[id] = stored;
|
|
1206
|
+
} else {
|
|
1207
|
+
out[id] = value;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
return out;
|
|
1211
|
+
}
|
|
1212
|
+
function fromStored(filters, fields) {
|
|
1213
|
+
const defs = savable(fields);
|
|
1214
|
+
const out = {};
|
|
1215
|
+
for (const [id, value] of Object.entries(filters)) {
|
|
1216
|
+
const def = defs.get(id);
|
|
1217
|
+
if (!def) continue;
|
|
1218
|
+
if (def.type === "dateRange") {
|
|
1219
|
+
const range = value ?? {};
|
|
1220
|
+
const restored = {};
|
|
1221
|
+
const from = fromDay(range.from);
|
|
1222
|
+
const to = fromDay(range.to);
|
|
1223
|
+
if (from) restored.from = from;
|
|
1224
|
+
if (to) restored.to = to;
|
|
1225
|
+
if (restored.from || restored.to) out[id] = restored;
|
|
1226
|
+
} else if (def.type === "multiselect" && typeof value === "string") {
|
|
1227
|
+
out[id] = [value];
|
|
1228
|
+
} else {
|
|
1229
|
+
out[id] = value;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return out;
|
|
1233
|
+
}
|
|
1234
|
+
function useSavedFilters(storageKey) {
|
|
1235
|
+
const storage = typeof window === "undefined" ? void 0 : window.localStorage;
|
|
1236
|
+
const [store, setStore] = useState(
|
|
1237
|
+
() => storageKey ? readSaved(storage, storageKey) : EMPTY
|
|
1238
|
+
);
|
|
1239
|
+
const update = useCallback(
|
|
1240
|
+
(next) => {
|
|
1241
|
+
setStore(next);
|
|
1242
|
+
if (storageKey) writeSaved(storage, storageKey, next);
|
|
1243
|
+
},
|
|
1244
|
+
[storage, storageKey]
|
|
1245
|
+
);
|
|
1246
|
+
const save = useCallback(
|
|
1247
|
+
(name, filters, search = []) => {
|
|
1248
|
+
const saved = { name, filters, search };
|
|
1249
|
+
const known = store.items.some((i) => i.name === name);
|
|
1250
|
+
const items = known ? store.items.map((i) => i.name === name ? saved : i) : [...store.items, saved];
|
|
1251
|
+
update({ ...store, items });
|
|
1252
|
+
},
|
|
1253
|
+
[store, update]
|
|
1254
|
+
);
|
|
1255
|
+
const remove = useCallback(
|
|
1256
|
+
(name) => update({
|
|
1257
|
+
items: store.items.filter((i) => i.name !== name),
|
|
1258
|
+
defaultName: store.defaultName === name ? null : store.defaultName
|
|
1259
|
+
}),
|
|
1260
|
+
[store, update]
|
|
1261
|
+
);
|
|
1262
|
+
const setDefault = useCallback(
|
|
1263
|
+
(name) => update({ ...store, defaultName: name }),
|
|
1264
|
+
[store, update]
|
|
1265
|
+
);
|
|
1266
|
+
return {
|
|
1267
|
+
items: store.items,
|
|
1268
|
+
defaultName: store.defaultName,
|
|
1269
|
+
defaultFilter: store.items.find((i) => i.name === store.defaultName),
|
|
1270
|
+
save,
|
|
1271
|
+
remove,
|
|
1272
|
+
setDefault
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
function SavedFiltersMenu({
|
|
1276
|
+
items,
|
|
1277
|
+
defaultName,
|
|
1278
|
+
canSave,
|
|
1279
|
+
labels,
|
|
1280
|
+
onApply,
|
|
1281
|
+
onSave,
|
|
1282
|
+
onDelete,
|
|
1283
|
+
onSetDefault
|
|
1284
|
+
}) {
|
|
1285
|
+
const [open, setOpen] = React10.useState(false);
|
|
1286
|
+
const [name, setName] = React10.useState("");
|
|
1287
|
+
const save = () => {
|
|
1288
|
+
const trimmed = name.trim();
|
|
1289
|
+
if (!trimmed || !canSave) return;
|
|
1290
|
+
onSave(trimmed);
|
|
1291
|
+
setName("");
|
|
1292
|
+
};
|
|
1293
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
1294
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "ev-mf-saved-btn", children: [
|
|
1295
|
+
/* @__PURE__ */ jsx(Bookmark, {}),
|
|
1296
|
+
labels.saved
|
|
1297
|
+
] }) }),
|
|
1298
|
+
/* @__PURE__ */ jsxs(PopoverContent, { className: "ev-mf-saved-popover", align: "start", children: [
|
|
1299
|
+
items.length === 0 ? /* @__PURE__ */ jsx("p", { className: "ev-mf-saved-empty", children: labels.noSaved }) : /* @__PURE__ */ jsx("ul", { className: "ev-mf-saved-list", "aria-label": labels.saved, children: items.map((saved) => {
|
|
1300
|
+
const isDefault = saved.name === defaultName;
|
|
1301
|
+
return /* @__PURE__ */ jsxs("li", { className: "ev-mf-saved-item", children: [
|
|
1302
|
+
/* @__PURE__ */ jsx(
|
|
1303
|
+
"button",
|
|
1304
|
+
{
|
|
1305
|
+
type: "button",
|
|
1306
|
+
className: "ev-mf-saved-apply",
|
|
1307
|
+
onClick: () => {
|
|
1308
|
+
onApply(saved);
|
|
1309
|
+
setOpen(false);
|
|
1310
|
+
},
|
|
1311
|
+
children: saved.name
|
|
1312
|
+
}
|
|
1313
|
+
),
|
|
1314
|
+
/* @__PURE__ */ jsx(
|
|
1315
|
+
"button",
|
|
1316
|
+
{
|
|
1317
|
+
type: "button",
|
|
1318
|
+
className: "ev-mf-saved-icon",
|
|
1319
|
+
"data-active": isDefault || void 0,
|
|
1320
|
+
"aria-pressed": isDefault,
|
|
1321
|
+
"aria-label": `${isDefault ? labels.unsetDefault : labels.setDefault}: ${saved.name}`,
|
|
1322
|
+
title: isDefault ? labels.unsetDefault : labels.setDefault,
|
|
1323
|
+
onClick: () => onSetDefault(isDefault ? null : saved.name),
|
|
1324
|
+
children: /* @__PURE__ */ jsx(Star, {})
|
|
1325
|
+
}
|
|
1326
|
+
),
|
|
1327
|
+
/* @__PURE__ */ jsx(
|
|
1328
|
+
"button",
|
|
1329
|
+
{
|
|
1330
|
+
type: "button",
|
|
1331
|
+
className: "ev-mf-saved-icon",
|
|
1332
|
+
"aria-label": `${labels.deleteSaved}: ${saved.name}`,
|
|
1333
|
+
title: labels.deleteSaved,
|
|
1334
|
+
onClick: () => onDelete(saved.name),
|
|
1335
|
+
children: /* @__PURE__ */ jsx(Trash2, {})
|
|
1336
|
+
}
|
|
1337
|
+
)
|
|
1338
|
+
] }, saved.name);
|
|
1339
|
+
}) }),
|
|
1340
|
+
/* @__PURE__ */ jsxs(
|
|
1341
|
+
"form",
|
|
1342
|
+
{
|
|
1343
|
+
className: "ev-mf-saved-form",
|
|
1344
|
+
onSubmit: (e) => {
|
|
1345
|
+
e.preventDefault();
|
|
1346
|
+
save();
|
|
1347
|
+
},
|
|
1348
|
+
children: [
|
|
1349
|
+
/* @__PURE__ */ jsx(
|
|
1350
|
+
Input,
|
|
1351
|
+
{
|
|
1352
|
+
value: name,
|
|
1353
|
+
onChange: (e) => setName(e.target.value),
|
|
1354
|
+
placeholder: canSave ? labels.saveNamePlaceholder : labels.nothingToSave,
|
|
1355
|
+
"aria-label": labels.saveNamePlaceholder,
|
|
1356
|
+
disabled: !canSave
|
|
1357
|
+
}
|
|
1358
|
+
),
|
|
1359
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", size: "sm", disabled: !canSave || !name.trim(), children: labels.save })
|
|
1360
|
+
]
|
|
1361
|
+
}
|
|
1362
|
+
)
|
|
1363
|
+
] })
|
|
1364
|
+
] });
|
|
1365
|
+
}
|
|
1131
1366
|
var DEFAULT_LABELS = {
|
|
1132
1367
|
search: "Buscar",
|
|
1133
1368
|
clear: "Limpiar",
|
|
1134
1369
|
perform: "Buscar",
|
|
1135
1370
|
addFilter: "A\xF1adir filtro",
|
|
1136
1371
|
noOptions: "Sin opciones",
|
|
1137
|
-
searchPlaceholder: "Buscar..."
|
|
1372
|
+
searchPlaceholder: "Buscar...",
|
|
1373
|
+
saved: "Guardados",
|
|
1374
|
+
noSaved: "A\xFAn no hay filtros guardados.",
|
|
1375
|
+
saveNamePlaceholder: "Nombre del filtro",
|
|
1376
|
+
nothingToSave: "Aplica una b\xFAsqueda para guardarla",
|
|
1377
|
+
save: "Guardar",
|
|
1378
|
+
setDefault: "Abrir siempre con este",
|
|
1379
|
+
unsetDefault: "Dejar de abrir con este",
|
|
1380
|
+
deleteSaved: "Borrar",
|
|
1381
|
+
removeFilter: "Quitar filtro",
|
|
1382
|
+
removeValue: "Quitar"
|
|
1138
1383
|
};
|
|
1139
1384
|
function isFieldVisible(def, values) {
|
|
1140
1385
|
if (def.visible === void 0) return true;
|
|
@@ -1165,7 +1410,8 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
|
|
|
1165
1410
|
labels: labelOverrides,
|
|
1166
1411
|
className,
|
|
1167
1412
|
persist = false,
|
|
1168
|
-
clearWhen
|
|
1413
|
+
clearWhen,
|
|
1414
|
+
savedFilters
|
|
1169
1415
|
} = props;
|
|
1170
1416
|
const resolvedPerformMode = performMode === "live" ? "live" : "manual";
|
|
1171
1417
|
const labels = { ...DEFAULT_LABELS, ...labelOverrides };
|
|
@@ -1188,13 +1434,33 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
|
|
|
1188
1434
|
}
|
|
1189
1435
|
return v;
|
|
1190
1436
|
}, [config]);
|
|
1437
|
+
const saved = useSavedFilters(savedFilters?.storageKey);
|
|
1438
|
+
const savedState = useCallback(
|
|
1439
|
+
(item) => {
|
|
1440
|
+
const restored = fromStored(item.filters, config.fields);
|
|
1441
|
+
const searchId = savedFilters?.searchFieldId;
|
|
1442
|
+
if (searchId && item.search.length) restored[searchId] = item.search.join(" ");
|
|
1443
|
+
return {
|
|
1444
|
+
values: restored,
|
|
1445
|
+
activeFields: [.../* @__PURE__ */ new Set([...initialActive, ...Object.keys(restored)])]
|
|
1446
|
+
};
|
|
1447
|
+
},
|
|
1448
|
+
[config.fields, initialActive, savedFilters?.searchFieldId]
|
|
1449
|
+
);
|
|
1450
|
+
const openedWithDefaultRef = useRef(false);
|
|
1191
1451
|
const { slice, fullId, patch } = useEasyVisionSlice("multifilter", id, {
|
|
1192
|
-
init: () =>
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1452
|
+
init: () => {
|
|
1453
|
+
if (saved.defaultFilter && savedFilters?.openWithDefault !== false) {
|
|
1454
|
+
openedWithDefaultRef.current = true;
|
|
1455
|
+
return { kind: "multifilter", ...savedState(saved.defaultFilter), lastConfirmedSnapshotJSON: null };
|
|
1456
|
+
}
|
|
1457
|
+
return {
|
|
1458
|
+
kind: "multifilter",
|
|
1459
|
+
activeFields: initialActive,
|
|
1460
|
+
values: initialValues,
|
|
1461
|
+
lastConfirmedSnapshotJSON: null
|
|
1462
|
+
};
|
|
1463
|
+
},
|
|
1198
1464
|
persist,
|
|
1199
1465
|
clearWhen: clearWhen ? (s) => clearWhen({
|
|
1200
1466
|
values: s.values,
|
|
@@ -1303,10 +1569,13 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
|
|
|
1303
1569
|
}, [activeFields, composedValues, patch, onPerform, snapshot]);
|
|
1304
1570
|
const didPerformOnMountRef = useRef(false);
|
|
1305
1571
|
useEffect(() => {
|
|
1306
|
-
if (performOnMount && !didPerformOnMountRef.current && Object.values(composedValues).some(isNonEmpty)) {
|
|
1572
|
+
if ((performOnMount || openedWithDefaultRef.current) && !didPerformOnMountRef.current && Object.values(composedValues).some(isNonEmpty)) {
|
|
1307
1573
|
didPerformOnMountRef.current = true;
|
|
1308
1574
|
performAction();
|
|
1309
1575
|
}
|
|
1576
|
+
return () => {
|
|
1577
|
+
didPerformOnMountRef.current = false;
|
|
1578
|
+
};
|
|
1310
1579
|
}, [performOnMount]);
|
|
1311
1580
|
const liveTimerRef = useRef(null);
|
|
1312
1581
|
const livePrevKeyRef = useRef(null);
|
|
@@ -1369,6 +1638,25 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
|
|
|
1369
1638
|
setClearTick((n) => n + 1);
|
|
1370
1639
|
}
|
|
1371
1640
|
}, [patch, initialValues, initialActive, lastConfirmedSnapshotJSON, resolvedPerformMode]);
|
|
1641
|
+
const applySaved = useCallback(
|
|
1642
|
+
(item) => {
|
|
1643
|
+
patch({ ...savedState(item), lastConfirmedSnapshotJSON: null });
|
|
1644
|
+
if (resolvedPerformMode !== "live") setClearTick((n) => n + 1);
|
|
1645
|
+
},
|
|
1646
|
+
[patch, savedState, resolvedPerformMode]
|
|
1647
|
+
);
|
|
1648
|
+
const appliedValues = useMemo(() => {
|
|
1649
|
+
if (!lastConfirmedSnapshotJSON) return {};
|
|
1650
|
+
try {
|
|
1651
|
+
return JSON.parse(lastConfirmedSnapshotJSON).values ?? {};
|
|
1652
|
+
} catch {
|
|
1653
|
+
return {};
|
|
1654
|
+
}
|
|
1655
|
+
}, [lastConfirmedSnapshotJSON]);
|
|
1656
|
+
const appliedToSave = useMemo(
|
|
1657
|
+
() => toStored(appliedValues, config.fields),
|
|
1658
|
+
[appliedValues, config.fields]
|
|
1659
|
+
);
|
|
1372
1660
|
useEffect(() => {
|
|
1373
1661
|
if (clearTick > 0) performAction();
|
|
1374
1662
|
}, [clearTick]);
|
|
@@ -1456,110 +1744,135 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
|
|
|
1456
1744
|
f.id
|
|
1457
1745
|
);
|
|
1458
1746
|
};
|
|
1459
|
-
return /* @__PURE__ */ jsx(NamespaceProvider, { fullId, children: /* @__PURE__ */ jsx(
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
"
|
|
1469
|
-
|
|
1470
|
-
className:
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1747
|
+
return /* @__PURE__ */ jsx(NamespaceProvider, { fullId, children: /* @__PURE__ */ jsx(
|
|
1748
|
+
WidgetLabelsContext.Provider,
|
|
1749
|
+
{
|
|
1750
|
+
value: { removeFilter: labels.removeFilter, removeValue: labels.removeValue },
|
|
1751
|
+
children: /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsxs("div", { className: "ev-mf-panel", children: [
|
|
1752
|
+
/* @__PURE__ */ jsxs("div", { className: "ev-mf-row", children: [
|
|
1753
|
+
prominentSlots.map(({ def, removable, isLegacySearchField }) => /* @__PURE__ */ jsxs(
|
|
1754
|
+
"div",
|
|
1755
|
+
{
|
|
1756
|
+
className: "ev-mf-search-slot",
|
|
1757
|
+
children: [
|
|
1758
|
+
/* @__PURE__ */ jsx(Search, { className: "ev-mf-search-icon" }),
|
|
1759
|
+
/* @__PURE__ */ jsx(
|
|
1760
|
+
"input",
|
|
1761
|
+
{
|
|
1762
|
+
className: ["ev-mf-search-input", removable ? "has-clear" : "no-clear"].filter(Boolean).join(" "),
|
|
1763
|
+
placeholder: def.placeholder ?? def.label ?? labels.searchPlaceholder,
|
|
1764
|
+
value: values[def.id] ?? "",
|
|
1765
|
+
onChange: (e) => updateValue(def.id, e.target.value),
|
|
1766
|
+
onKeyDown: (e) => {
|
|
1767
|
+
if (e.key === "Enter" && performButton && performEnabled) {
|
|
1768
|
+
performAction();
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1477
1771
|
}
|
|
1478
|
-
|
|
1772
|
+
),
|
|
1773
|
+
removable && /* @__PURE__ */ jsx(
|
|
1774
|
+
"button",
|
|
1775
|
+
{
|
|
1776
|
+
type: "button",
|
|
1777
|
+
onClick: () => removeField(def.id),
|
|
1778
|
+
"aria-label": labels.clear,
|
|
1779
|
+
className: "ev-mf-search-clear",
|
|
1780
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
1781
|
+
}
|
|
1782
|
+
)
|
|
1783
|
+
]
|
|
1784
|
+
},
|
|
1785
|
+
isLegacySearchField ? `__searchField__${def.id}` : def.id
|
|
1786
|
+
)),
|
|
1787
|
+
editable && availableToAdd.length > 0 && /* @__PURE__ */ jsxs(Popover, { children: [
|
|
1788
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
1789
|
+
Button,
|
|
1790
|
+
{
|
|
1791
|
+
variant: "outline",
|
|
1792
|
+
size: "sm",
|
|
1793
|
+
className: "ev-mf-add-btn",
|
|
1794
|
+
"aria-label": labels.addFilter,
|
|
1795
|
+
children: /* @__PURE__ */ jsx(Plus, {})
|
|
1479
1796
|
}
|
|
1480
|
-
),
|
|
1481
|
-
|
|
1797
|
+
) }),
|
|
1798
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "ev-mf-add-popover", align: "start", children: /* @__PURE__ */ jsx("div", { className: "ev-mf-add-list", children: availableToAdd.map((f) => /* @__PURE__ */ jsxs(
|
|
1482
1799
|
"button",
|
|
1483
1800
|
{
|
|
1484
1801
|
type: "button",
|
|
1485
|
-
onClick: () =>
|
|
1486
|
-
"
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1802
|
+
onClick: () => addField(f.id),
|
|
1803
|
+
className: "ev-mf-add-item",
|
|
1804
|
+
children: [
|
|
1805
|
+
/* @__PURE__ */ jsx(Plus, {}),
|
|
1806
|
+
f.label
|
|
1807
|
+
]
|
|
1808
|
+
},
|
|
1809
|
+
f.id
|
|
1810
|
+
)) }) })
|
|
1811
|
+
] }),
|
|
1812
|
+
performButton && performPosition === "inline" && /* @__PURE__ */ jsxs(
|
|
1813
|
+
Button,
|
|
1814
|
+
{
|
|
1815
|
+
size: "sm",
|
|
1816
|
+
onClick: performAction,
|
|
1817
|
+
disabled: !performEnabled,
|
|
1818
|
+
className: "ev-mf-perform",
|
|
1819
|
+
children: [
|
|
1820
|
+
performIcon ?? /* @__PURE__ */ jsx(Search, {}),
|
|
1821
|
+
performLabelText
|
|
1822
|
+
]
|
|
1823
|
+
}
|
|
1824
|
+
),
|
|
1825
|
+
savedFilters && /* @__PURE__ */ jsx(
|
|
1826
|
+
SavedFiltersMenu,
|
|
1827
|
+
{
|
|
1828
|
+
items: saved.items,
|
|
1829
|
+
defaultName: saved.defaultName,
|
|
1830
|
+
canSave: Object.keys(appliedToSave).length > 0,
|
|
1831
|
+
labels,
|
|
1832
|
+
onApply: applySaved,
|
|
1833
|
+
onSave: (name) => {
|
|
1834
|
+
const searchId = savedFilters.searchFieldId;
|
|
1835
|
+
if (!searchId) return saved.save(name, appliedToSave);
|
|
1836
|
+
const { [searchId]: text, ...rest } = appliedToSave;
|
|
1837
|
+
const terms = typeof text === "string" && text.trim() ? [text.trim()] : [];
|
|
1838
|
+
saved.save(name, rest, terms);
|
|
1839
|
+
},
|
|
1840
|
+
onDelete: saved.remove,
|
|
1841
|
+
onSetDefault: saved.setDefault
|
|
1842
|
+
}
|
|
1843
|
+
),
|
|
1844
|
+
showClear && /* @__PURE__ */ jsxs(
|
|
1845
|
+
Button,
|
|
1846
|
+
{
|
|
1847
|
+
variant: "ghost",
|
|
1848
|
+
size: "sm",
|
|
1849
|
+
onClick: clearAll,
|
|
1850
|
+
className: "ev-mf-clear",
|
|
1851
|
+
children: [
|
|
1852
|
+
/* @__PURE__ */ jsx(X, {}),
|
|
1853
|
+
labels.clear
|
|
1854
|
+
]
|
|
1855
|
+
}
|
|
1856
|
+
)
|
|
1857
|
+
] }),
|
|
1858
|
+
pinnedFields.length > 0 && /* @__PURE__ */ jsx("div", { className: "ev-mf-row", children: pinnedFields.map(renderField) }),
|
|
1859
|
+
chipFields.length > 0 && /* @__PURE__ */ jsx("div", { className: "ev-mf-row", children: chipFields.map(renderField) }),
|
|
1860
|
+
performButton && performPosition === "belowRow" && /* @__PURE__ */ jsx("div", { className: "ev-mf-below-row", children: /* @__PURE__ */ jsxs(
|
|
1497
1861
|
Button,
|
|
1498
1862
|
{
|
|
1499
|
-
variant: "outline",
|
|
1500
1863
|
size: "sm",
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
}
|
|
1505
|
-
) }),
|
|
1506
|
-
/* @__PURE__ */ jsx(PopoverContent, { className: "ev-mf-add-popover", align: "start", children: /* @__PURE__ */ jsx("div", { className: "ev-mf-add-list", children: availableToAdd.map((f) => /* @__PURE__ */ jsxs(
|
|
1507
|
-
"button",
|
|
1508
|
-
{
|
|
1509
|
-
type: "button",
|
|
1510
|
-
onClick: () => addField(f.id),
|
|
1511
|
-
className: "ev-mf-add-item",
|
|
1864
|
+
onClick: performAction,
|
|
1865
|
+
disabled: !performEnabled,
|
|
1866
|
+
className: "ev-mf-perform",
|
|
1512
1867
|
children: [
|
|
1513
|
-
/* @__PURE__ */ jsx(
|
|
1514
|
-
|
|
1868
|
+
performIcon ?? /* @__PURE__ */ jsx(Search, {}),
|
|
1869
|
+
performLabelText
|
|
1515
1870
|
]
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
Button,
|
|
1522
|
-
{
|
|
1523
|
-
size: "sm",
|
|
1524
|
-
onClick: performAction,
|
|
1525
|
-
disabled: !performEnabled,
|
|
1526
|
-
className: "ev-mf-perform",
|
|
1527
|
-
children: [
|
|
1528
|
-
performIcon ?? /* @__PURE__ */ jsx(Search, {}),
|
|
1529
|
-
performLabelText
|
|
1530
|
-
]
|
|
1531
|
-
}
|
|
1532
|
-
),
|
|
1533
|
-
showClear && /* @__PURE__ */ jsxs(
|
|
1534
|
-
Button,
|
|
1535
|
-
{
|
|
1536
|
-
variant: "ghost",
|
|
1537
|
-
size: "sm",
|
|
1538
|
-
onClick: clearAll,
|
|
1539
|
-
className: "ev-mf-clear",
|
|
1540
|
-
children: [
|
|
1541
|
-
/* @__PURE__ */ jsx(X, {}),
|
|
1542
|
-
labels.clear
|
|
1543
|
-
]
|
|
1544
|
-
}
|
|
1545
|
-
)
|
|
1546
|
-
] }),
|
|
1547
|
-
pinnedFields.length > 0 && /* @__PURE__ */ jsx("div", { className: "ev-mf-row", children: pinnedFields.map(renderField) }),
|
|
1548
|
-
chipFields.length > 0 && /* @__PURE__ */ jsx("div", { className: "ev-mf-row", children: chipFields.map(renderField) }),
|
|
1549
|
-
performButton && performPosition === "belowRow" && /* @__PURE__ */ jsx("div", { className: "ev-mf-below-row", children: /* @__PURE__ */ jsxs(
|
|
1550
|
-
Button,
|
|
1551
|
-
{
|
|
1552
|
-
size: "sm",
|
|
1553
|
-
onClick: performAction,
|
|
1554
|
-
disabled: !performEnabled,
|
|
1555
|
-
className: "ev-mf-perform",
|
|
1556
|
-
children: [
|
|
1557
|
-
performIcon ?? /* @__PURE__ */ jsx(Search, {}),
|
|
1558
|
-
performLabelText
|
|
1559
|
-
]
|
|
1560
|
-
}
|
|
1561
|
-
) })
|
|
1562
|
-
] }) }) });
|
|
1871
|
+
}
|
|
1872
|
+
) })
|
|
1873
|
+
] }) })
|
|
1874
|
+
}
|
|
1875
|
+
) });
|
|
1563
1876
|
});
|
|
1564
1877
|
function buildChildQueryDirect(field, values) {
|
|
1565
1878
|
const where = {};
|
|
@@ -1610,17 +1923,17 @@ function buildChildQueryDirect(field, values) {
|
|
|
1610
1923
|
return Object.keys(where).length > 0 ? { where } : {};
|
|
1611
1924
|
}
|
|
1612
1925
|
var join = (...parts) => parts.filter(Boolean).join(" ");
|
|
1613
|
-
var EasyVisionCard =
|
|
1926
|
+
var EasyVisionCard = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card", className), ...props }));
|
|
1614
1927
|
EasyVisionCard.displayName = "EasyVisionCard";
|
|
1615
|
-
var EasyVisionCardHeader =
|
|
1928
|
+
var EasyVisionCardHeader = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card-header", className), ...props }));
|
|
1616
1929
|
EasyVisionCardHeader.displayName = "EasyVisionCardHeader";
|
|
1617
|
-
var EasyVisionCardTitle =
|
|
1930
|
+
var EasyVisionCardTitle = React10.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx("h3", { ref, className: join("ev-card-title", className), ...props, children }));
|
|
1618
1931
|
EasyVisionCardTitle.displayName = "EasyVisionCardTitle";
|
|
1619
|
-
var EasyVisionCardDescription =
|
|
1932
|
+
var EasyVisionCardDescription = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { ref, className: join("ev-card-description", className), ...props }));
|
|
1620
1933
|
EasyVisionCardDescription.displayName = "EasyVisionCardDescription";
|
|
1621
|
-
var EasyVisionCardContent =
|
|
1934
|
+
var EasyVisionCardContent = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card-content", className), ...props }));
|
|
1622
1935
|
EasyVisionCardContent.displayName = "EasyVisionCardContent";
|
|
1623
|
-
var EasyVisionCardFooter =
|
|
1936
|
+
var EasyVisionCardFooter = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card-footer", className), ...props }));
|
|
1624
1937
|
EasyVisionCardFooter.displayName = "EasyVisionCardFooter";
|
|
1625
1938
|
var join2 = (...parts) => parts.filter(Boolean).join(" ");
|
|
1626
1939
|
function EasyVisionAccordionItem(_props) {
|
|
@@ -1629,8 +1942,8 @@ function EasyVisionAccordionItem(_props) {
|
|
|
1629
1942
|
EasyVisionAccordionItem.displayName = "EasyVisionAccordionItem";
|
|
1630
1943
|
function normalizeFromChildren(children) {
|
|
1631
1944
|
const out = [];
|
|
1632
|
-
|
|
1633
|
-
if (!
|
|
1945
|
+
React10.Children.forEach(children, (child) => {
|
|
1946
|
+
if (!React10.isValidElement(child)) return;
|
|
1634
1947
|
if (child.type !== EasyVisionAccordionItem) return;
|
|
1635
1948
|
const p = child.props;
|
|
1636
1949
|
out.push({
|
|
@@ -1694,20 +2007,20 @@ function EasyVisionAccordion({
|
|
|
1694
2007
|
onOpenChange,
|
|
1695
2008
|
className
|
|
1696
2009
|
}) {
|
|
1697
|
-
const normalized =
|
|
2010
|
+
const normalized = React10.useMemo(
|
|
1698
2011
|
() => items ? normalizeFromItems(items) : normalizeFromChildren(children),
|
|
1699
2012
|
[items, children]
|
|
1700
2013
|
);
|
|
1701
2014
|
const isControlled = openIds !== void 0;
|
|
1702
|
-
const [internalOpen, setInternalOpen] =
|
|
2015
|
+
const [internalOpen, setInternalOpen] = React10.useState(() => {
|
|
1703
2016
|
if (defaultOpenIds) return new Set(defaultOpenIds);
|
|
1704
2017
|
return new Set(normalized.filter((it) => it.defaultOpen).map((it) => it.id));
|
|
1705
2018
|
});
|
|
1706
|
-
const openSet =
|
|
2019
|
+
const openSet = React10.useMemo(
|
|
1707
2020
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
1708
2021
|
[isControlled, openIds, internalOpen]
|
|
1709
2022
|
);
|
|
1710
|
-
const handleToggle =
|
|
2023
|
+
const handleToggle = React10.useCallback(
|
|
1711
2024
|
(id) => {
|
|
1712
2025
|
const next = new Set(openSet);
|
|
1713
2026
|
if (next.has(id)) {
|
|
@@ -1732,21 +2045,21 @@ function EasyVisionAccordion({
|
|
|
1732
2045
|
)) });
|
|
1733
2046
|
}
|
|
1734
2047
|
EasyVisionAccordion.displayName = "EasyVisionAccordion";
|
|
1735
|
-
var Table =
|
|
2048
|
+
var Table = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("table", { ref, className: cn("ev-table", className), ...props }));
|
|
1736
2049
|
Table.displayName = "Table";
|
|
1737
|
-
var TableHeader =
|
|
2050
|
+
var TableHeader = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className, ...props }));
|
|
1738
2051
|
TableHeader.displayName = "TableHeader";
|
|
1739
|
-
var TableBody =
|
|
2052
|
+
var TableBody = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tbody", { ref, className, ...props }));
|
|
1740
2053
|
TableBody.displayName = "TableBody";
|
|
1741
|
-
var TableFooter =
|
|
2054
|
+
var TableFooter = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tfoot", { ref, className, ...props }));
|
|
1742
2055
|
TableFooter.displayName = "TableFooter";
|
|
1743
|
-
var TableRow =
|
|
2056
|
+
var TableRow = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tr", { ref, className, ...props }));
|
|
1744
2057
|
TableRow.displayName = "TableRow";
|
|
1745
|
-
var TableHead =
|
|
2058
|
+
var TableHead = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("th", { ref, className, ...props }));
|
|
1746
2059
|
TableHead.displayName = "TableHead";
|
|
1747
|
-
var TableCell =
|
|
2060
|
+
var TableCell = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("td", { ref, className, ...props }));
|
|
1748
2061
|
TableCell.displayName = "TableCell";
|
|
1749
|
-
var TableCaption =
|
|
2062
|
+
var TableCaption = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("caption", { ref, className, ...props }));
|
|
1750
2063
|
TableCaption.displayName = "TableCaption";
|
|
1751
2064
|
var isNestedField = (field) => field.includes(".");
|
|
1752
2065
|
var resolvePath = (obj, path) => path.split(".").reduce(
|
|
@@ -1762,7 +2075,19 @@ function shouldDisableSorting(col, orderingMode, defaultSorting = "nonNested") {
|
|
|
1762
2075
|
if (orderingMode === "api" && isNestedField(col.field)) return true;
|
|
1763
2076
|
return false;
|
|
1764
2077
|
}
|
|
1765
|
-
function
|
|
2078
|
+
function stableCell(cache, field, render) {
|
|
2079
|
+
let entry = cache.get(field);
|
|
2080
|
+
if (!entry) {
|
|
2081
|
+
const created = {
|
|
2082
|
+
Comp: ({ row, getValue }) => created.render ? created.render(row.original) : createElement("span", { className: "text-sm text-foreground" }, String(getValue() ?? "-"))
|
|
2083
|
+
};
|
|
2084
|
+
cache.set(field, created);
|
|
2085
|
+
entry = created;
|
|
2086
|
+
}
|
|
2087
|
+
entry.render = render;
|
|
2088
|
+
return entry.Comp;
|
|
2089
|
+
}
|
|
2090
|
+
function adaptColumns(columns, orderingMode, defaultSorting = "nonNested", cellCache = /* @__PURE__ */ new Map()) {
|
|
1766
2091
|
return columns.map((c) => {
|
|
1767
2092
|
const widthCss = typeof c.width === "number" ? `${c.width}px` : c.width;
|
|
1768
2093
|
const numericWidth = typeof c.width === "number" ? c.width : typeof c.width === "string" && /^\d+px$/.test(c.width) ? parseInt(c.width, 10) : void 0;
|
|
@@ -1775,11 +2100,7 @@ function adaptColumns(columns, orderingMode, defaultSorting = "nonNested") {
|
|
|
1775
2100
|
};
|
|
1776
2101
|
const isUi = c.type === "ui";
|
|
1777
2102
|
const userCell = c.cell;
|
|
1778
|
-
const wrappedCell =
|
|
1779
|
-
"span",
|
|
1780
|
-
{ className: "text-sm text-foreground" },
|
|
1781
|
-
String(getValue() ?? "-")
|
|
1782
|
-
);
|
|
2103
|
+
const wrappedCell = stableCell(cellCache, c.field, userCell);
|
|
1783
2104
|
const base = {
|
|
1784
2105
|
id: c.field,
|
|
1785
2106
|
header: c.header,
|
|
@@ -1938,7 +2259,7 @@ async function fetchAllRows({
|
|
|
1938
2259
|
var DropdownMenu = DropdownMenuPrimitive.Root;
|
|
1939
2260
|
var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
1940
2261
|
var DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
1941
|
-
var DropdownMenuSubTrigger =
|
|
2262
|
+
var DropdownMenuSubTrigger = React10.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
1942
2263
|
DropdownMenuPrimitive.SubTrigger,
|
|
1943
2264
|
{
|
|
1944
2265
|
ref,
|
|
@@ -1955,7 +2276,7 @@ var DropdownMenuSubTrigger = React9.forwardRef(({ className, inset, children, ..
|
|
|
1955
2276
|
}
|
|
1956
2277
|
));
|
|
1957
2278
|
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
|
1958
|
-
var DropdownMenuSubContent =
|
|
2279
|
+
var DropdownMenuSubContent = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1959
2280
|
DropdownMenuPrimitive.SubContent,
|
|
1960
2281
|
{
|
|
1961
2282
|
ref,
|
|
@@ -1964,7 +2285,7 @@ var DropdownMenuSubContent = React9.forwardRef(({ className, ...props }, ref) =>
|
|
|
1964
2285
|
}
|
|
1965
2286
|
));
|
|
1966
2287
|
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
|
1967
|
-
var DropdownMenuContent =
|
|
2288
|
+
var DropdownMenuContent = React10.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
1968
2289
|
DropdownMenuPrimitive.Content,
|
|
1969
2290
|
{
|
|
1970
2291
|
ref,
|
|
@@ -1974,7 +2295,7 @@ var DropdownMenuContent = React9.forwardRef(({ className, sideOffset = 4, ...pro
|
|
|
1974
2295
|
}
|
|
1975
2296
|
) }));
|
|
1976
2297
|
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
1977
|
-
var DropdownMenuItem =
|
|
2298
|
+
var DropdownMenuItem = React10.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1978
2299
|
DropdownMenuPrimitive.Item,
|
|
1979
2300
|
{
|
|
1980
2301
|
ref,
|
|
@@ -1987,7 +2308,7 @@ var DropdownMenuItem = React9.forwardRef(({ className, inset, ...props }, ref) =
|
|
|
1987
2308
|
}
|
|
1988
2309
|
));
|
|
1989
2310
|
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
1990
|
-
var DropdownMenuCheckboxItem =
|
|
2311
|
+
var DropdownMenuCheckboxItem = React10.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
1991
2312
|
DropdownMenuPrimitive.CheckboxItem,
|
|
1992
2313
|
{
|
|
1993
2314
|
ref,
|
|
@@ -2001,7 +2322,7 @@ var DropdownMenuCheckboxItem = React9.forwardRef(({ className, children, checked
|
|
|
2001
2322
|
}
|
|
2002
2323
|
));
|
|
2003
2324
|
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
2004
|
-
var DropdownMenuRadioItem =
|
|
2325
|
+
var DropdownMenuRadioItem = React10.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2005
2326
|
DropdownMenuPrimitive.RadioItem,
|
|
2006
2327
|
{
|
|
2007
2328
|
ref,
|
|
@@ -2014,7 +2335,7 @@ var DropdownMenuRadioItem = React9.forwardRef(({ className, children, ...props }
|
|
|
2014
2335
|
}
|
|
2015
2336
|
));
|
|
2016
2337
|
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
2017
|
-
var DropdownMenuLabel =
|
|
2338
|
+
var DropdownMenuLabel = React10.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2018
2339
|
DropdownMenuPrimitive.Label,
|
|
2019
2340
|
{
|
|
2020
2341
|
ref,
|
|
@@ -2027,7 +2348,7 @@ var DropdownMenuLabel = React9.forwardRef(({ className, inset, ...props }, ref)
|
|
|
2027
2348
|
}
|
|
2028
2349
|
));
|
|
2029
2350
|
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
2030
|
-
var DropdownMenuSeparator =
|
|
2351
|
+
var DropdownMenuSeparator = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2031
2352
|
DropdownMenuPrimitive.Separator,
|
|
2032
2353
|
{
|
|
2033
2354
|
ref,
|
|
@@ -2140,6 +2461,7 @@ function PaginationFooter({
|
|
|
2140
2461
|
className: "ev-table-footer-nav-btn",
|
|
2141
2462
|
disabled: currentPage <= 1,
|
|
2142
2463
|
onClick: () => onPageChange(currentPage - 1),
|
|
2464
|
+
"aria-label": labels.previousPage,
|
|
2143
2465
|
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "ev-table-footer-nav-icon" })
|
|
2144
2466
|
}
|
|
2145
2467
|
),
|
|
@@ -2151,6 +2473,7 @@ function PaginationFooter({
|
|
|
2151
2473
|
className: "ev-table-footer-nav-btn",
|
|
2152
2474
|
disabled: currentPage >= totalPages,
|
|
2153
2475
|
onClick: () => onPageChange(currentPage + 1),
|
|
2476
|
+
"aria-label": labels.nextPage,
|
|
2154
2477
|
children: /* @__PURE__ */ jsx(ChevronRight, { className: "ev-table-footer-nav-icon" })
|
|
2155
2478
|
}
|
|
2156
2479
|
)
|
|
@@ -2471,8 +2794,19 @@ var DEFAULT_LABELS2 = {
|
|
|
2471
2794
|
selectAllAll: "Seleccionar todo",
|
|
2472
2795
|
selectedAllBanner: (n) => `Todos los ${n} registros seleccionados`,
|
|
2473
2796
|
selectedCountBanner: (n) => `${n} ${n === 1 ? "registro seleccionado" : "registros seleccionados"}`,
|
|
2474
|
-
clearSelection: "Limpiar selecci\xF3n"
|
|
2797
|
+
clearSelection: "Limpiar selecci\xF3n",
|
|
2798
|
+
selectRow: "Seleccionar",
|
|
2799
|
+
previousPage: "P\xE1gina anterior",
|
|
2800
|
+
nextPage: "P\xE1gina siguiente"
|
|
2475
2801
|
};
|
|
2802
|
+
function isFromWithinControl(e) {
|
|
2803
|
+
const target = e.target;
|
|
2804
|
+
if (!target || !e.currentTarget.contains(target)) return true;
|
|
2805
|
+
const control = target.closest(
|
|
2806
|
+
'a, button, input, select, textarea, label, [role="button"], [role="menuitem"], [role="checkbox"], [role="menu"]'
|
|
2807
|
+
);
|
|
2808
|
+
return !!control && e.currentTarget.contains(control) && control !== e.currentTarget;
|
|
2809
|
+
}
|
|
2476
2810
|
function EasyVisionTable(props) {
|
|
2477
2811
|
const {
|
|
2478
2812
|
id,
|
|
@@ -2484,6 +2818,10 @@ function EasyVisionTable(props) {
|
|
|
2484
2818
|
fetchData: fetchDataProp,
|
|
2485
2819
|
loopback,
|
|
2486
2820
|
ingot,
|
|
2821
|
+
defaultSort,
|
|
2822
|
+
reloadSignal,
|
|
2823
|
+
ariaLabel,
|
|
2824
|
+
getRowLabel,
|
|
2487
2825
|
onDataLoaded,
|
|
2488
2826
|
multifilter,
|
|
2489
2827
|
multifilterRef,
|
|
@@ -2602,8 +2940,12 @@ function EasyVisionTable(props) {
|
|
|
2602
2940
|
}
|
|
2603
2941
|
}, [fetchData, page, itemsPerPage, sort, externalFilter, onDataLoaded]);
|
|
2604
2942
|
useEffect(() => {
|
|
2605
|
-
if (isApi
|
|
2606
|
-
|
|
2943
|
+
if (!isApi || !fetchData) return;
|
|
2944
|
+
const seq = fetchSeqRef.current;
|
|
2945
|
+
queueMicrotask(() => {
|
|
2946
|
+
if (fetchSeqRef.current === seq) void runFetch();
|
|
2947
|
+
});
|
|
2948
|
+
}, [isApi, page, itemsPerPage, sort, refetchSignal, reloadSignal]);
|
|
2607
2949
|
const resolveEagerAll = useCallback(async () => {
|
|
2608
2950
|
if (!fetchData) return;
|
|
2609
2951
|
const collectRows = selectAllResolution === "eager";
|
|
@@ -2667,8 +3009,9 @@ function EasyVisionTable(props) {
|
|
|
2667
3009
|
const rows = isApi ? apiRows : local.rows;
|
|
2668
3010
|
const totalCount = isApi ? apiTotalCount : local.totalCount;
|
|
2669
3011
|
const isLoading = isLoadingProp || apiLoading;
|
|
3012
|
+
const cellCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
2670
3013
|
const tanstackColumns = useMemo(
|
|
2671
|
-
() => adaptColumns(columns, orderingMode, defaultSorting),
|
|
3014
|
+
() => adaptColumns(columns, orderingMode, defaultSorting, cellCacheRef.current),
|
|
2672
3015
|
[columns, orderingMode, defaultSorting]
|
|
2673
3016
|
);
|
|
2674
3017
|
const allColumns = useMemo(() => {
|
|
@@ -2683,7 +3026,7 @@ function EasyVisionTable(props) {
|
|
|
2683
3026
|
checked: row.getIsSelected(),
|
|
2684
3027
|
onCheckedChange: (v) => row.toggleSelected(!!v),
|
|
2685
3028
|
onClick: (e) => e.stopPropagation(),
|
|
2686
|
-
"aria-label":
|
|
3029
|
+
"aria-label": getRowLabel ? `${labels.selectRow} ${getRowLabel(row.original)}` : labels.selectRow
|
|
2687
3030
|
}
|
|
2688
3031
|
),
|
|
2689
3032
|
enableSorting: false,
|
|
@@ -2759,7 +3102,9 @@ function EasyVisionTable(props) {
|
|
|
2759
3102
|
for (const id2 of Object.keys(selection.ids)) r[id2] = true;
|
|
2760
3103
|
return r;
|
|
2761
3104
|
}, [selection]);
|
|
2762
|
-
const
|
|
3105
|
+
const shownSort = sort ?? defaultSort ?? null;
|
|
3106
|
+
const sortingState = shownSort ? [{ id: shownSort.column, desc: shownSort.descending }] : [];
|
|
3107
|
+
const isDefaultSort = (s) => !!s && !!defaultSort && s.column === defaultSort.column && s.descending === defaultSort.descending;
|
|
2763
3108
|
const isEagerWildcard = (selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi && selection.scope === "all";
|
|
2764
3109
|
const tableInstance = useReactTable({
|
|
2765
3110
|
data: rows,
|
|
@@ -2795,7 +3140,12 @@ function EasyVisionTable(props) {
|
|
|
2795
3140
|
if (isEagerWildcard) return;
|
|
2796
3141
|
const next = typeof updater === "function" ? updater(sortingState) : updater;
|
|
2797
3142
|
const first = next[0];
|
|
2798
|
-
|
|
3143
|
+
let newSort = first ? { column: first.id, descending: !!first.desc } : null;
|
|
3144
|
+
if (!newSort && sort === null && defaultSort) {
|
|
3145
|
+
newSort = { column: defaultSort.column, descending: !defaultSort.descending };
|
|
3146
|
+
} else if (isDefaultSort(newSort)) {
|
|
3147
|
+
newSort = null;
|
|
3148
|
+
}
|
|
2799
3149
|
patch({ sort: newSort });
|
|
2800
3150
|
},
|
|
2801
3151
|
getCoreRowModel: getCoreRowModel(),
|
|
@@ -3056,7 +3406,7 @@ function EasyVisionTable(props) {
|
|
|
3056
3406
|
style: maxBodyHeight !== void 0 ? {
|
|
3057
3407
|
maxHeight: typeof maxBodyHeight === "number" ? `${maxBodyHeight}px` : maxBodyHeight
|
|
3058
3408
|
} : void 0,
|
|
3059
|
-
children: /* @__PURE__ */ jsxs("table", { className: "ev-table", children: [
|
|
3409
|
+
children: /* @__PURE__ */ jsxs("table", { className: "ev-table", "aria-label": ariaLabel, children: [
|
|
3060
3410
|
/* @__PURE__ */ jsx(
|
|
3061
3411
|
TableHeader,
|
|
3062
3412
|
{
|
|
@@ -3088,6 +3438,7 @@ function EasyVisionTable(props) {
|
|
|
3088
3438
|
TableHead,
|
|
3089
3439
|
{
|
|
3090
3440
|
style: headerWidthStyle,
|
|
3441
|
+
"aria-sort": header.column.getIsSorted() === "asc" ? "ascending" : header.column.getIsSorted() === "desc" ? "descending" : void 0,
|
|
3091
3442
|
className: colMeta.largeScreensOnly ? "ev-table-large-only" : void 0,
|
|
3092
3443
|
children: [
|
|
3093
3444
|
header.isPlaceholder ? null : sortable ? /* @__PURE__ */ jsxs(
|
|
@@ -3137,7 +3488,9 @@ function EasyVisionTable(props) {
|
|
|
3137
3488
|
"data-state": row.getIsSelected() || isAllSelected ? "selected" : void 0,
|
|
3138
3489
|
"data-highlighted": highlighted ? "true" : void 0,
|
|
3139
3490
|
className: onRowClick ? "ev-table-row-clickable" : void 0,
|
|
3140
|
-
onClick: () =>
|
|
3491
|
+
onClick: (e) => {
|
|
3492
|
+
if (onRowClick && !isFromWithinControl(e)) onRowClick(row.original);
|
|
3493
|
+
},
|
|
3141
3494
|
children: row.getVisibleCells().map((cell) => {
|
|
3142
3495
|
if (cell.column.id === "_select" && selection.scope === "all") {
|
|
3143
3496
|
return /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
|