@easyvision/easyvision-ui 1.12.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 +7 -3
- package/dist/index.cjs +207 -128
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +207 -128
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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,6 +652,7 @@ 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
|
}
|
|
@@ -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
|
}
|
|
@@ -1217,8 +1244,8 @@ function useSavedFilters(storageKey) {
|
|
|
1217
1244
|
[storage, storageKey]
|
|
1218
1245
|
);
|
|
1219
1246
|
const save = useCallback(
|
|
1220
|
-
(name, filters) => {
|
|
1221
|
-
const saved = { name, filters, search
|
|
1247
|
+
(name, filters, search = []) => {
|
|
1248
|
+
const saved = { name, filters, search };
|
|
1222
1249
|
const known = store.items.some((i) => i.name === name);
|
|
1223
1250
|
const items = known ? store.items.map((i) => i.name === name ? saved : i) : [...store.items, saved];
|
|
1224
1251
|
update({ ...store, items });
|
|
@@ -1350,7 +1377,9 @@ var DEFAULT_LABELS = {
|
|
|
1350
1377
|
save: "Guardar",
|
|
1351
1378
|
setDefault: "Abrir siempre con este",
|
|
1352
1379
|
unsetDefault: "Dejar de abrir con este",
|
|
1353
|
-
deleteSaved: "Borrar"
|
|
1380
|
+
deleteSaved: "Borrar",
|
|
1381
|
+
removeFilter: "Quitar filtro",
|
|
1382
|
+
removeValue: "Quitar"
|
|
1354
1383
|
};
|
|
1355
1384
|
function isFieldVisible(def, values) {
|
|
1356
1385
|
if (def.visible === void 0) return true;
|
|
@@ -1409,17 +1438,19 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
|
|
|
1409
1438
|
const savedState = useCallback(
|
|
1410
1439
|
(item) => {
|
|
1411
1440
|
const restored = fromStored(item.filters, config.fields);
|
|
1441
|
+
const searchId = savedFilters?.searchFieldId;
|
|
1442
|
+
if (searchId && item.search.length) restored[searchId] = item.search.join(" ");
|
|
1412
1443
|
return {
|
|
1413
1444
|
values: restored,
|
|
1414
1445
|
activeFields: [.../* @__PURE__ */ new Set([...initialActive, ...Object.keys(restored)])]
|
|
1415
1446
|
};
|
|
1416
1447
|
},
|
|
1417
|
-
[config.fields, initialActive]
|
|
1448
|
+
[config.fields, initialActive, savedFilters?.searchFieldId]
|
|
1418
1449
|
);
|
|
1419
1450
|
const openedWithDefaultRef = useRef(false);
|
|
1420
1451
|
const { slice, fullId, patch } = useEasyVisionSlice("multifilter", id, {
|
|
1421
1452
|
init: () => {
|
|
1422
|
-
if (saved.defaultFilter) {
|
|
1453
|
+
if (saved.defaultFilter && savedFilters?.openWithDefault !== false) {
|
|
1423
1454
|
openedWithDefaultRef.current = true;
|
|
1424
1455
|
return { kind: "multifilter", ...savedState(saved.defaultFilter), lastConfirmedSnapshotJSON: null };
|
|
1425
1456
|
}
|
|
@@ -1713,123 +1744,135 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
|
|
|
1713
1744
|
f.id
|
|
1714
1745
|
);
|
|
1715
1746
|
};
|
|
1716
|
-
return /* @__PURE__ */ jsx(NamespaceProvider, { fullId, children: /* @__PURE__ */ jsx(
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
"
|
|
1726
|
-
|
|
1727
|
-
className:
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
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
|
+
}
|
|
1771
|
+
}
|
|
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, {})
|
|
1734
1781
|
}
|
|
1735
|
-
|
|
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, {})
|
|
1736
1796
|
}
|
|
1737
|
-
),
|
|
1738
|
-
|
|
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(
|
|
1739
1799
|
"button",
|
|
1740
1800
|
{
|
|
1741
1801
|
type: "button",
|
|
1742
|
-
onClick: () =>
|
|
1743
|
-
"
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
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(
|
|
1754
1861
|
Button,
|
|
1755
1862
|
{
|
|
1756
|
-
variant: "outline",
|
|
1757
1863
|
size: "sm",
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
}
|
|
1762
|
-
) }),
|
|
1763
|
-
/* @__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(
|
|
1764
|
-
"button",
|
|
1765
|
-
{
|
|
1766
|
-
type: "button",
|
|
1767
|
-
onClick: () => addField(f.id),
|
|
1768
|
-
className: "ev-mf-add-item",
|
|
1864
|
+
onClick: performAction,
|
|
1865
|
+
disabled: !performEnabled,
|
|
1866
|
+
className: "ev-mf-perform",
|
|
1769
1867
|
children: [
|
|
1770
|
-
/* @__PURE__ */ jsx(
|
|
1771
|
-
|
|
1868
|
+
performIcon ?? /* @__PURE__ */ jsx(Search, {}),
|
|
1869
|
+
performLabelText
|
|
1772
1870
|
]
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
Button,
|
|
1779
|
-
{
|
|
1780
|
-
size: "sm",
|
|
1781
|
-
onClick: performAction,
|
|
1782
|
-
disabled: !performEnabled,
|
|
1783
|
-
className: "ev-mf-perform",
|
|
1784
|
-
children: [
|
|
1785
|
-
performIcon ?? /* @__PURE__ */ jsx(Search, {}),
|
|
1786
|
-
performLabelText
|
|
1787
|
-
]
|
|
1788
|
-
}
|
|
1789
|
-
),
|
|
1790
|
-
savedFilters && /* @__PURE__ */ jsx(
|
|
1791
|
-
SavedFiltersMenu,
|
|
1792
|
-
{
|
|
1793
|
-
items: saved.items,
|
|
1794
|
-
defaultName: saved.defaultName,
|
|
1795
|
-
canSave: Object.keys(appliedToSave).length > 0,
|
|
1796
|
-
labels,
|
|
1797
|
-
onApply: applySaved,
|
|
1798
|
-
onSave: (name) => saved.save(name, appliedToSave),
|
|
1799
|
-
onDelete: saved.remove,
|
|
1800
|
-
onSetDefault: saved.setDefault
|
|
1801
|
-
}
|
|
1802
|
-
),
|
|
1803
|
-
showClear && /* @__PURE__ */ jsxs(
|
|
1804
|
-
Button,
|
|
1805
|
-
{
|
|
1806
|
-
variant: "ghost",
|
|
1807
|
-
size: "sm",
|
|
1808
|
-
onClick: clearAll,
|
|
1809
|
-
className: "ev-mf-clear",
|
|
1810
|
-
children: [
|
|
1811
|
-
/* @__PURE__ */ jsx(X, {}),
|
|
1812
|
-
labels.clear
|
|
1813
|
-
]
|
|
1814
|
-
}
|
|
1815
|
-
)
|
|
1816
|
-
] }),
|
|
1817
|
-
pinnedFields.length > 0 && /* @__PURE__ */ jsx("div", { className: "ev-mf-row", children: pinnedFields.map(renderField) }),
|
|
1818
|
-
chipFields.length > 0 && /* @__PURE__ */ jsx("div", { className: "ev-mf-row", children: chipFields.map(renderField) }),
|
|
1819
|
-
performButton && performPosition === "belowRow" && /* @__PURE__ */ jsx("div", { className: "ev-mf-below-row", children: /* @__PURE__ */ jsxs(
|
|
1820
|
-
Button,
|
|
1821
|
-
{
|
|
1822
|
-
size: "sm",
|
|
1823
|
-
onClick: performAction,
|
|
1824
|
-
disabled: !performEnabled,
|
|
1825
|
-
className: "ev-mf-perform",
|
|
1826
|
-
children: [
|
|
1827
|
-
performIcon ?? /* @__PURE__ */ jsx(Search, {}),
|
|
1828
|
-
performLabelText
|
|
1829
|
-
]
|
|
1830
|
-
}
|
|
1831
|
-
) })
|
|
1832
|
-
] }) }) });
|
|
1871
|
+
}
|
|
1872
|
+
) })
|
|
1873
|
+
] }) })
|
|
1874
|
+
}
|
|
1875
|
+
) });
|
|
1833
1876
|
});
|
|
1834
1877
|
function buildChildQueryDirect(field, values) {
|
|
1835
1878
|
const where = {};
|
|
@@ -2032,7 +2075,19 @@ function shouldDisableSorting(col, orderingMode, defaultSorting = "nonNested") {
|
|
|
2032
2075
|
if (orderingMode === "api" && isNestedField(col.field)) return true;
|
|
2033
2076
|
return false;
|
|
2034
2077
|
}
|
|
2035
|
-
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()) {
|
|
2036
2091
|
return columns.map((c) => {
|
|
2037
2092
|
const widthCss = typeof c.width === "number" ? `${c.width}px` : c.width;
|
|
2038
2093
|
const numericWidth = typeof c.width === "number" ? c.width : typeof c.width === "string" && /^\d+px$/.test(c.width) ? parseInt(c.width, 10) : void 0;
|
|
@@ -2045,11 +2100,7 @@ function adaptColumns(columns, orderingMode, defaultSorting = "nonNested") {
|
|
|
2045
2100
|
};
|
|
2046
2101
|
const isUi = c.type === "ui";
|
|
2047
2102
|
const userCell = c.cell;
|
|
2048
|
-
const wrappedCell =
|
|
2049
|
-
"span",
|
|
2050
|
-
{ className: "text-sm text-foreground" },
|
|
2051
|
-
String(getValue() ?? "-")
|
|
2052
|
-
);
|
|
2103
|
+
const wrappedCell = stableCell(cellCache, c.field, userCell);
|
|
2053
2104
|
const base = {
|
|
2054
2105
|
id: c.field,
|
|
2055
2106
|
header: c.header,
|
|
@@ -2410,6 +2461,7 @@ function PaginationFooter({
|
|
|
2410
2461
|
className: "ev-table-footer-nav-btn",
|
|
2411
2462
|
disabled: currentPage <= 1,
|
|
2412
2463
|
onClick: () => onPageChange(currentPage - 1),
|
|
2464
|
+
"aria-label": labels.previousPage,
|
|
2413
2465
|
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "ev-table-footer-nav-icon" })
|
|
2414
2466
|
}
|
|
2415
2467
|
),
|
|
@@ -2421,6 +2473,7 @@ function PaginationFooter({
|
|
|
2421
2473
|
className: "ev-table-footer-nav-btn",
|
|
2422
2474
|
disabled: currentPage >= totalPages,
|
|
2423
2475
|
onClick: () => onPageChange(currentPage + 1),
|
|
2476
|
+
"aria-label": labels.nextPage,
|
|
2424
2477
|
children: /* @__PURE__ */ jsx(ChevronRight, { className: "ev-table-footer-nav-icon" })
|
|
2425
2478
|
}
|
|
2426
2479
|
)
|
|
@@ -2741,8 +2794,19 @@ var DEFAULT_LABELS2 = {
|
|
|
2741
2794
|
selectAllAll: "Seleccionar todo",
|
|
2742
2795
|
selectedAllBanner: (n) => `Todos los ${n} registros seleccionados`,
|
|
2743
2796
|
selectedCountBanner: (n) => `${n} ${n === 1 ? "registro seleccionado" : "registros seleccionados"}`,
|
|
2744
|
-
clearSelection: "Limpiar selecci\xF3n"
|
|
2797
|
+
clearSelection: "Limpiar selecci\xF3n",
|
|
2798
|
+
selectRow: "Seleccionar",
|
|
2799
|
+
previousPage: "P\xE1gina anterior",
|
|
2800
|
+
nextPage: "P\xE1gina siguiente"
|
|
2745
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
|
+
}
|
|
2746
2810
|
function EasyVisionTable(props) {
|
|
2747
2811
|
const {
|
|
2748
2812
|
id,
|
|
@@ -2754,6 +2818,10 @@ function EasyVisionTable(props) {
|
|
|
2754
2818
|
fetchData: fetchDataProp,
|
|
2755
2819
|
loopback,
|
|
2756
2820
|
ingot,
|
|
2821
|
+
defaultSort,
|
|
2822
|
+
reloadSignal,
|
|
2823
|
+
ariaLabel,
|
|
2824
|
+
getRowLabel,
|
|
2757
2825
|
onDataLoaded,
|
|
2758
2826
|
multifilter,
|
|
2759
2827
|
multifilterRef,
|
|
@@ -2877,7 +2945,7 @@ function EasyVisionTable(props) {
|
|
|
2877
2945
|
queueMicrotask(() => {
|
|
2878
2946
|
if (fetchSeqRef.current === seq) void runFetch();
|
|
2879
2947
|
});
|
|
2880
|
-
}, [isApi, page, itemsPerPage, sort, refetchSignal]);
|
|
2948
|
+
}, [isApi, page, itemsPerPage, sort, refetchSignal, reloadSignal]);
|
|
2881
2949
|
const resolveEagerAll = useCallback(async () => {
|
|
2882
2950
|
if (!fetchData) return;
|
|
2883
2951
|
const collectRows = selectAllResolution === "eager";
|
|
@@ -2941,8 +3009,9 @@ function EasyVisionTable(props) {
|
|
|
2941
3009
|
const rows = isApi ? apiRows : local.rows;
|
|
2942
3010
|
const totalCount = isApi ? apiTotalCount : local.totalCount;
|
|
2943
3011
|
const isLoading = isLoadingProp || apiLoading;
|
|
3012
|
+
const cellCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
2944
3013
|
const tanstackColumns = useMemo(
|
|
2945
|
-
() => adaptColumns(columns, orderingMode, defaultSorting),
|
|
3014
|
+
() => adaptColumns(columns, orderingMode, defaultSorting, cellCacheRef.current),
|
|
2946
3015
|
[columns, orderingMode, defaultSorting]
|
|
2947
3016
|
);
|
|
2948
3017
|
const allColumns = useMemo(() => {
|
|
@@ -2957,7 +3026,7 @@ function EasyVisionTable(props) {
|
|
|
2957
3026
|
checked: row.getIsSelected(),
|
|
2958
3027
|
onCheckedChange: (v) => row.toggleSelected(!!v),
|
|
2959
3028
|
onClick: (e) => e.stopPropagation(),
|
|
2960
|
-
"aria-label":
|
|
3029
|
+
"aria-label": getRowLabel ? `${labels.selectRow} ${getRowLabel(row.original)}` : labels.selectRow
|
|
2961
3030
|
}
|
|
2962
3031
|
),
|
|
2963
3032
|
enableSorting: false,
|
|
@@ -3033,7 +3102,9 @@ function EasyVisionTable(props) {
|
|
|
3033
3102
|
for (const id2 of Object.keys(selection.ids)) r[id2] = true;
|
|
3034
3103
|
return r;
|
|
3035
3104
|
}, [selection]);
|
|
3036
|
-
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;
|
|
3037
3108
|
const isEagerWildcard = (selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi && selection.scope === "all";
|
|
3038
3109
|
const tableInstance = useReactTable({
|
|
3039
3110
|
data: rows,
|
|
@@ -3069,7 +3140,12 @@ function EasyVisionTable(props) {
|
|
|
3069
3140
|
if (isEagerWildcard) return;
|
|
3070
3141
|
const next = typeof updater === "function" ? updater(sortingState) : updater;
|
|
3071
3142
|
const first = next[0];
|
|
3072
|
-
|
|
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
|
+
}
|
|
3073
3149
|
patch({ sort: newSort });
|
|
3074
3150
|
},
|
|
3075
3151
|
getCoreRowModel: getCoreRowModel(),
|
|
@@ -3330,7 +3406,7 @@ function EasyVisionTable(props) {
|
|
|
3330
3406
|
style: maxBodyHeight !== void 0 ? {
|
|
3331
3407
|
maxHeight: typeof maxBodyHeight === "number" ? `${maxBodyHeight}px` : maxBodyHeight
|
|
3332
3408
|
} : void 0,
|
|
3333
|
-
children: /* @__PURE__ */ jsxs("table", { className: "ev-table", children: [
|
|
3409
|
+
children: /* @__PURE__ */ jsxs("table", { className: "ev-table", "aria-label": ariaLabel, children: [
|
|
3334
3410
|
/* @__PURE__ */ jsx(
|
|
3335
3411
|
TableHeader,
|
|
3336
3412
|
{
|
|
@@ -3362,6 +3438,7 @@ function EasyVisionTable(props) {
|
|
|
3362
3438
|
TableHead,
|
|
3363
3439
|
{
|
|
3364
3440
|
style: headerWidthStyle,
|
|
3441
|
+
"aria-sort": header.column.getIsSorted() === "asc" ? "ascending" : header.column.getIsSorted() === "desc" ? "descending" : void 0,
|
|
3365
3442
|
className: colMeta.largeScreensOnly ? "ev-table-large-only" : void 0,
|
|
3366
3443
|
children: [
|
|
3367
3444
|
header.isPlaceholder ? null : sortable ? /* @__PURE__ */ jsxs(
|
|
@@ -3411,7 +3488,9 @@ function EasyVisionTable(props) {
|
|
|
3411
3488
|
"data-state": row.getIsSelected() || isAllSelected ? "selected" : void 0,
|
|
3412
3489
|
"data-highlighted": highlighted ? "true" : void 0,
|
|
3413
3490
|
className: onRowClick ? "ev-table-row-clickable" : void 0,
|
|
3414
|
-
onClick: () =>
|
|
3491
|
+
onClick: (e) => {
|
|
3492
|
+
if (onRowClick && !isFromWithinControl(e)) onRowClick(row.original);
|
|
3493
|
+
},
|
|
3415
3494
|
children: row.getVisibleCells().map((cell) => {
|
|
3416
3495
|
if (cell.column.id === "_select" && selection.scope === "all") {
|
|
3417
3496
|
return /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
|