@easyvision/easyvision-ui 1.10.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import './easyvision.css';
2
2
  import './EasyVisionTable.css';
3
- import * as React9 from 'react';
4
- import { createContext, forwardRef, useMemo, useSyncExternalStore, useRef, useEffect, useCallback, useImperativeHandle, useState, useContext, createElement } from 'react';
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 = React9.forwardRef(
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 = React9.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
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 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
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 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
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 = React9.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
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 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
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 = React9.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
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 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
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 = React9.forwardRef(
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 = React9.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
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 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
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 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "ev-cmd-input-wrapper", "cmdk-input-wrapper": "", children: [
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 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
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 = React9.forwardRef((props, ref) => /* @__PURE__ */ jsx(
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 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
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 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
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 = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
429
+ var CommandItem = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
430
430
  Command$1.Item,
431
431
  {
432
432
  ref,
@@ -649,7 +649,7 @@ function SelectorWidget({ definition, value, onChange, onRemove }) {
649
649
  )
650
650
  ] });
651
651
  }
652
- var Checkbox = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
652
+ var Checkbox = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
653
653
  CheckboxPrimitive.Root,
654
654
  {
655
655
  ref,
@@ -1128,13 +1128,229 @@ function isDirty(input, lastConfirmed) {
1128
1128
  }
1129
1129
  return current !== lastConfirmed;
1130
1130
  }
1131
+ var EMPTY = { items: [], defaultName: null };
1132
+ var isSavedFilter = (v) => typeof v === "object" && v !== null && typeof v.name === "string" && typeof v.filters === "object" && v.filters !== null;
1133
+ function readSaved(storage, key) {
1134
+ try {
1135
+ const raw = storage?.getItem(key);
1136
+ if (!raw) return EMPTY;
1137
+ const parsed = JSON.parse(raw);
1138
+ const items = (Array.isArray(parsed.items) ? parsed.items : []).filter(isSavedFilter).map((item) => ({ ...item, search: Array.isArray(item.search) ? item.search : [] }));
1139
+ const defaultName = typeof parsed.defaultName === "string" && items.some((i) => i.name === parsed.defaultName) ? parsed.defaultName : null;
1140
+ return { items, defaultName };
1141
+ } catch {
1142
+ return EMPTY;
1143
+ }
1144
+ }
1145
+ function writeSaved(storage, key, store) {
1146
+ try {
1147
+ storage?.setItem(key, JSON.stringify(store));
1148
+ } catch {
1149
+ }
1150
+ }
1151
+ var pad = (n) => String(n).padStart(2, "0");
1152
+ function toDay(value) {
1153
+ if (value === void 0 || value === null || value === "") return void 0;
1154
+ const date = value instanceof Date ? value : new Date(String(value));
1155
+ if (Number.isNaN(date.getTime())) return void 0;
1156
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
1157
+ }
1158
+ function fromDay(value) {
1159
+ if (typeof value !== "string" || !value) return void 0;
1160
+ const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
1161
+ const date = m ? new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3])) : new Date(value);
1162
+ return Number.isNaN(date.getTime()) ? void 0 : date;
1163
+ }
1164
+ var savable = (fields) => new Map(fields.filter((f) => f.type !== "multifilter").map((f) => [f.id, f]));
1165
+ function toStored(values, fields) {
1166
+ const defs = savable(fields);
1167
+ const out = {};
1168
+ for (const [id, value] of Object.entries(values)) {
1169
+ const def = defs.get(id);
1170
+ if (!def || !isNonEmpty(value)) continue;
1171
+ if (def.type === "dateRange") {
1172
+ const range = value;
1173
+ const stored = {};
1174
+ const from = toDay(range.from);
1175
+ const to = toDay(range.to);
1176
+ if (from) stored.from = from;
1177
+ if (to) stored.to = to;
1178
+ if (Object.keys(stored).length > 0) out[id] = stored;
1179
+ } else {
1180
+ out[id] = value;
1181
+ }
1182
+ }
1183
+ return out;
1184
+ }
1185
+ function fromStored(filters, fields) {
1186
+ const defs = savable(fields);
1187
+ const out = {};
1188
+ for (const [id, value] of Object.entries(filters)) {
1189
+ const def = defs.get(id);
1190
+ if (!def) continue;
1191
+ if (def.type === "dateRange") {
1192
+ const range = value ?? {};
1193
+ const restored = {};
1194
+ const from = fromDay(range.from);
1195
+ const to = fromDay(range.to);
1196
+ if (from) restored.from = from;
1197
+ if (to) restored.to = to;
1198
+ if (restored.from || restored.to) out[id] = restored;
1199
+ } else if (def.type === "multiselect" && typeof value === "string") {
1200
+ out[id] = [value];
1201
+ } else {
1202
+ out[id] = value;
1203
+ }
1204
+ }
1205
+ return out;
1206
+ }
1207
+ function useSavedFilters(storageKey) {
1208
+ const storage = typeof window === "undefined" ? void 0 : window.localStorage;
1209
+ const [store, setStore] = useState(
1210
+ () => storageKey ? readSaved(storage, storageKey) : EMPTY
1211
+ );
1212
+ const update = useCallback(
1213
+ (next) => {
1214
+ setStore(next);
1215
+ if (storageKey) writeSaved(storage, storageKey, next);
1216
+ },
1217
+ [storage, storageKey]
1218
+ );
1219
+ const save = useCallback(
1220
+ (name, filters) => {
1221
+ const saved = { name, filters, search: [] };
1222
+ const known = store.items.some((i) => i.name === name);
1223
+ const items = known ? store.items.map((i) => i.name === name ? saved : i) : [...store.items, saved];
1224
+ update({ ...store, items });
1225
+ },
1226
+ [store, update]
1227
+ );
1228
+ const remove = useCallback(
1229
+ (name) => update({
1230
+ items: store.items.filter((i) => i.name !== name),
1231
+ defaultName: store.defaultName === name ? null : store.defaultName
1232
+ }),
1233
+ [store, update]
1234
+ );
1235
+ const setDefault = useCallback(
1236
+ (name) => update({ ...store, defaultName: name }),
1237
+ [store, update]
1238
+ );
1239
+ return {
1240
+ items: store.items,
1241
+ defaultName: store.defaultName,
1242
+ defaultFilter: store.items.find((i) => i.name === store.defaultName),
1243
+ save,
1244
+ remove,
1245
+ setDefault
1246
+ };
1247
+ }
1248
+ function SavedFiltersMenu({
1249
+ items,
1250
+ defaultName,
1251
+ canSave,
1252
+ labels,
1253
+ onApply,
1254
+ onSave,
1255
+ onDelete,
1256
+ onSetDefault
1257
+ }) {
1258
+ const [open, setOpen] = React10.useState(false);
1259
+ const [name, setName] = React10.useState("");
1260
+ const save = () => {
1261
+ const trimmed = name.trim();
1262
+ if (!trimmed || !canSave) return;
1263
+ onSave(trimmed);
1264
+ setName("");
1265
+ };
1266
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
1267
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "ev-mf-saved-btn", children: [
1268
+ /* @__PURE__ */ jsx(Bookmark, {}),
1269
+ labels.saved
1270
+ ] }) }),
1271
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "ev-mf-saved-popover", align: "start", children: [
1272
+ 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) => {
1273
+ const isDefault = saved.name === defaultName;
1274
+ return /* @__PURE__ */ jsxs("li", { className: "ev-mf-saved-item", children: [
1275
+ /* @__PURE__ */ jsx(
1276
+ "button",
1277
+ {
1278
+ type: "button",
1279
+ className: "ev-mf-saved-apply",
1280
+ onClick: () => {
1281
+ onApply(saved);
1282
+ setOpen(false);
1283
+ },
1284
+ children: saved.name
1285
+ }
1286
+ ),
1287
+ /* @__PURE__ */ jsx(
1288
+ "button",
1289
+ {
1290
+ type: "button",
1291
+ className: "ev-mf-saved-icon",
1292
+ "data-active": isDefault || void 0,
1293
+ "aria-pressed": isDefault,
1294
+ "aria-label": `${isDefault ? labels.unsetDefault : labels.setDefault}: ${saved.name}`,
1295
+ title: isDefault ? labels.unsetDefault : labels.setDefault,
1296
+ onClick: () => onSetDefault(isDefault ? null : saved.name),
1297
+ children: /* @__PURE__ */ jsx(Star, {})
1298
+ }
1299
+ ),
1300
+ /* @__PURE__ */ jsx(
1301
+ "button",
1302
+ {
1303
+ type: "button",
1304
+ className: "ev-mf-saved-icon",
1305
+ "aria-label": `${labels.deleteSaved}: ${saved.name}`,
1306
+ title: labels.deleteSaved,
1307
+ onClick: () => onDelete(saved.name),
1308
+ children: /* @__PURE__ */ jsx(Trash2, {})
1309
+ }
1310
+ )
1311
+ ] }, saved.name);
1312
+ }) }),
1313
+ /* @__PURE__ */ jsxs(
1314
+ "form",
1315
+ {
1316
+ className: "ev-mf-saved-form",
1317
+ onSubmit: (e) => {
1318
+ e.preventDefault();
1319
+ save();
1320
+ },
1321
+ children: [
1322
+ /* @__PURE__ */ jsx(
1323
+ Input,
1324
+ {
1325
+ value: name,
1326
+ onChange: (e) => setName(e.target.value),
1327
+ placeholder: canSave ? labels.saveNamePlaceholder : labels.nothingToSave,
1328
+ "aria-label": labels.saveNamePlaceholder,
1329
+ disabled: !canSave
1330
+ }
1331
+ ),
1332
+ /* @__PURE__ */ jsx(Button, { type: "submit", size: "sm", disabled: !canSave || !name.trim(), children: labels.save })
1333
+ ]
1334
+ }
1335
+ )
1336
+ ] })
1337
+ ] });
1338
+ }
1131
1339
  var DEFAULT_LABELS = {
1132
1340
  search: "Buscar",
1133
1341
  clear: "Limpiar",
1134
1342
  perform: "Buscar",
1135
1343
  addFilter: "A\xF1adir filtro",
1136
1344
  noOptions: "Sin opciones",
1137
- searchPlaceholder: "Buscar..."
1345
+ searchPlaceholder: "Buscar...",
1346
+ saved: "Guardados",
1347
+ noSaved: "A\xFAn no hay filtros guardados.",
1348
+ saveNamePlaceholder: "Nombre del filtro",
1349
+ nothingToSave: "Aplica una b\xFAsqueda para guardarla",
1350
+ save: "Guardar",
1351
+ setDefault: "Abrir siempre con este",
1352
+ unsetDefault: "Dejar de abrir con este",
1353
+ deleteSaved: "Borrar"
1138
1354
  };
1139
1355
  function isFieldVisible(def, values) {
1140
1356
  if (def.visible === void 0) return true;
@@ -1165,7 +1381,8 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
1165
1381
  labels: labelOverrides,
1166
1382
  className,
1167
1383
  persist = false,
1168
- clearWhen
1384
+ clearWhen,
1385
+ savedFilters
1169
1386
  } = props;
1170
1387
  const resolvedPerformMode = performMode === "live" ? "live" : "manual";
1171
1388
  const labels = { ...DEFAULT_LABELS, ...labelOverrides };
@@ -1188,13 +1405,31 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
1188
1405
  }
1189
1406
  return v;
1190
1407
  }, [config]);
1408
+ const saved = useSavedFilters(savedFilters?.storageKey);
1409
+ const savedState = useCallback(
1410
+ (item) => {
1411
+ const restored = fromStored(item.filters, config.fields);
1412
+ return {
1413
+ values: restored,
1414
+ activeFields: [.../* @__PURE__ */ new Set([...initialActive, ...Object.keys(restored)])]
1415
+ };
1416
+ },
1417
+ [config.fields, initialActive]
1418
+ );
1419
+ const openedWithDefaultRef = useRef(false);
1191
1420
  const { slice, fullId, patch } = useEasyVisionSlice("multifilter", id, {
1192
- init: () => ({
1193
- kind: "multifilter",
1194
- activeFields: initialActive,
1195
- values: initialValues,
1196
- lastConfirmedSnapshotJSON: null
1197
- }),
1421
+ init: () => {
1422
+ if (saved.defaultFilter) {
1423
+ openedWithDefaultRef.current = true;
1424
+ return { kind: "multifilter", ...savedState(saved.defaultFilter), lastConfirmedSnapshotJSON: null };
1425
+ }
1426
+ return {
1427
+ kind: "multifilter",
1428
+ activeFields: initialActive,
1429
+ values: initialValues,
1430
+ lastConfirmedSnapshotJSON: null
1431
+ };
1432
+ },
1198
1433
  persist,
1199
1434
  clearWhen: clearWhen ? (s) => clearWhen({
1200
1435
  values: s.values,
@@ -1303,10 +1538,13 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
1303
1538
  }, [activeFields, composedValues, patch, onPerform, snapshot]);
1304
1539
  const didPerformOnMountRef = useRef(false);
1305
1540
  useEffect(() => {
1306
- if (performOnMount && !didPerformOnMountRef.current && Object.values(composedValues).some(isNonEmpty)) {
1541
+ if ((performOnMount || openedWithDefaultRef.current) && !didPerformOnMountRef.current && Object.values(composedValues).some(isNonEmpty)) {
1307
1542
  didPerformOnMountRef.current = true;
1308
1543
  performAction();
1309
1544
  }
1545
+ return () => {
1546
+ didPerformOnMountRef.current = false;
1547
+ };
1310
1548
  }, [performOnMount]);
1311
1549
  const liveTimerRef = useRef(null);
1312
1550
  const livePrevKeyRef = useRef(null);
@@ -1369,6 +1607,25 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
1369
1607
  setClearTick((n) => n + 1);
1370
1608
  }
1371
1609
  }, [patch, initialValues, initialActive, lastConfirmedSnapshotJSON, resolvedPerformMode]);
1610
+ const applySaved = useCallback(
1611
+ (item) => {
1612
+ patch({ ...savedState(item), lastConfirmedSnapshotJSON: null });
1613
+ if (resolvedPerformMode !== "live") setClearTick((n) => n + 1);
1614
+ },
1615
+ [patch, savedState, resolvedPerformMode]
1616
+ );
1617
+ const appliedValues = useMemo(() => {
1618
+ if (!lastConfirmedSnapshotJSON) return {};
1619
+ try {
1620
+ return JSON.parse(lastConfirmedSnapshotJSON).values ?? {};
1621
+ } catch {
1622
+ return {};
1623
+ }
1624
+ }, [lastConfirmedSnapshotJSON]);
1625
+ const appliedToSave = useMemo(
1626
+ () => toStored(appliedValues, config.fields),
1627
+ [appliedValues, config.fields]
1628
+ );
1372
1629
  useEffect(() => {
1373
1630
  if (clearTick > 0) performAction();
1374
1631
  }, [clearTick]);
@@ -1530,6 +1787,19 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
1530
1787
  ]
1531
1788
  }
1532
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
+ ),
1533
1803
  showClear && /* @__PURE__ */ jsxs(
1534
1804
  Button,
1535
1805
  {
@@ -1610,17 +1880,17 @@ function buildChildQueryDirect(field, values) {
1610
1880
  return Object.keys(where).length > 0 ? { where } : {};
1611
1881
  }
1612
1882
  var join = (...parts) => parts.filter(Boolean).join(" ");
1613
- var EasyVisionCard = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card", className), ...props }));
1883
+ var EasyVisionCard = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card", className), ...props }));
1614
1884
  EasyVisionCard.displayName = "EasyVisionCard";
1615
- var EasyVisionCardHeader = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card-header", className), ...props }));
1885
+ var EasyVisionCardHeader = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card-header", className), ...props }));
1616
1886
  EasyVisionCardHeader.displayName = "EasyVisionCardHeader";
1617
- var EasyVisionCardTitle = React9.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx("h3", { ref, className: join("ev-card-title", className), ...props, children }));
1887
+ var EasyVisionCardTitle = React10.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx("h3", { ref, className: join("ev-card-title", className), ...props, children }));
1618
1888
  EasyVisionCardTitle.displayName = "EasyVisionCardTitle";
1619
- var EasyVisionCardDescription = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { ref, className: join("ev-card-description", className), ...props }));
1889
+ var EasyVisionCardDescription = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { ref, className: join("ev-card-description", className), ...props }));
1620
1890
  EasyVisionCardDescription.displayName = "EasyVisionCardDescription";
1621
- var EasyVisionCardContent = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card-content", className), ...props }));
1891
+ var EasyVisionCardContent = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card-content", className), ...props }));
1622
1892
  EasyVisionCardContent.displayName = "EasyVisionCardContent";
1623
- var EasyVisionCardFooter = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card-footer", className), ...props }));
1893
+ var EasyVisionCardFooter = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: join("ev-card-footer", className), ...props }));
1624
1894
  EasyVisionCardFooter.displayName = "EasyVisionCardFooter";
1625
1895
  var join2 = (...parts) => parts.filter(Boolean).join(" ");
1626
1896
  function EasyVisionAccordionItem(_props) {
@@ -1629,8 +1899,8 @@ function EasyVisionAccordionItem(_props) {
1629
1899
  EasyVisionAccordionItem.displayName = "EasyVisionAccordionItem";
1630
1900
  function normalizeFromChildren(children) {
1631
1901
  const out = [];
1632
- React9.Children.forEach(children, (child) => {
1633
- if (!React9.isValidElement(child)) return;
1902
+ React10.Children.forEach(children, (child) => {
1903
+ if (!React10.isValidElement(child)) return;
1634
1904
  if (child.type !== EasyVisionAccordionItem) return;
1635
1905
  const p = child.props;
1636
1906
  out.push({
@@ -1694,20 +1964,20 @@ function EasyVisionAccordion({
1694
1964
  onOpenChange,
1695
1965
  className
1696
1966
  }) {
1697
- const normalized = React9.useMemo(
1967
+ const normalized = React10.useMemo(
1698
1968
  () => items ? normalizeFromItems(items) : normalizeFromChildren(children),
1699
1969
  [items, children]
1700
1970
  );
1701
1971
  const isControlled = openIds !== void 0;
1702
- const [internalOpen, setInternalOpen] = React9.useState(() => {
1972
+ const [internalOpen, setInternalOpen] = React10.useState(() => {
1703
1973
  if (defaultOpenIds) return new Set(defaultOpenIds);
1704
1974
  return new Set(normalized.filter((it) => it.defaultOpen).map((it) => it.id));
1705
1975
  });
1706
- const openSet = React9.useMemo(
1976
+ const openSet = React10.useMemo(
1707
1977
  () => isControlled ? new Set(openIds) : internalOpen,
1708
1978
  [isControlled, openIds, internalOpen]
1709
1979
  );
1710
- const handleToggle = React9.useCallback(
1980
+ const handleToggle = React10.useCallback(
1711
1981
  (id) => {
1712
1982
  const next = new Set(openSet);
1713
1983
  if (next.has(id)) {
@@ -1732,21 +2002,21 @@ function EasyVisionAccordion({
1732
2002
  )) });
1733
2003
  }
1734
2004
  EasyVisionAccordion.displayName = "EasyVisionAccordion";
1735
- var Table = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("table", { ref, className: cn("ev-table", className), ...props }));
2005
+ var Table = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("table", { ref, className: cn("ev-table", className), ...props }));
1736
2006
  Table.displayName = "Table";
1737
- var TableHeader = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className, ...props }));
2007
+ var TableHeader = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className, ...props }));
1738
2008
  TableHeader.displayName = "TableHeader";
1739
- var TableBody = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tbody", { ref, className, ...props }));
2009
+ var TableBody = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tbody", { ref, className, ...props }));
1740
2010
  TableBody.displayName = "TableBody";
1741
- var TableFooter = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tfoot", { ref, className, ...props }));
2011
+ var TableFooter = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tfoot", { ref, className, ...props }));
1742
2012
  TableFooter.displayName = "TableFooter";
1743
- var TableRow = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tr", { ref, className, ...props }));
2013
+ var TableRow = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tr", { ref, className, ...props }));
1744
2014
  TableRow.displayName = "TableRow";
1745
- var TableHead = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("th", { ref, className, ...props }));
2015
+ var TableHead = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("th", { ref, className, ...props }));
1746
2016
  TableHead.displayName = "TableHead";
1747
- var TableCell = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("td", { ref, className, ...props }));
2017
+ var TableCell = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("td", { ref, className, ...props }));
1748
2018
  TableCell.displayName = "TableCell";
1749
- var TableCaption = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("caption", { ref, className, ...props }));
2019
+ var TableCaption = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("caption", { ref, className, ...props }));
1750
2020
  TableCaption.displayName = "TableCaption";
1751
2021
  var isNestedField = (field) => field.includes(".");
1752
2022
  var resolvePath = (obj, path) => path.split(".").reduce(
@@ -1938,7 +2208,7 @@ async function fetchAllRows({
1938
2208
  var DropdownMenu = DropdownMenuPrimitive.Root;
1939
2209
  var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
1940
2210
  var DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
1941
- var DropdownMenuSubTrigger = React9.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
2211
+ var DropdownMenuSubTrigger = React10.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1942
2212
  DropdownMenuPrimitive.SubTrigger,
1943
2213
  {
1944
2214
  ref,
@@ -1955,7 +2225,7 @@ var DropdownMenuSubTrigger = React9.forwardRef(({ className, inset, children, ..
1955
2225
  }
1956
2226
  ));
1957
2227
  DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
1958
- var DropdownMenuSubContent = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2228
+ var DropdownMenuSubContent = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1959
2229
  DropdownMenuPrimitive.SubContent,
1960
2230
  {
1961
2231
  ref,
@@ -1964,7 +2234,7 @@ var DropdownMenuSubContent = React9.forwardRef(({ className, ...props }, ref) =>
1964
2234
  }
1965
2235
  ));
1966
2236
  DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
1967
- var DropdownMenuContent = React9.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
2237
+ var DropdownMenuContent = React10.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
1968
2238
  DropdownMenuPrimitive.Content,
1969
2239
  {
1970
2240
  ref,
@@ -1974,7 +2244,7 @@ var DropdownMenuContent = React9.forwardRef(({ className, sideOffset = 4, ...pro
1974
2244
  }
1975
2245
  ) }));
1976
2246
  DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
1977
- var DropdownMenuItem = React9.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
2247
+ var DropdownMenuItem = React10.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1978
2248
  DropdownMenuPrimitive.Item,
1979
2249
  {
1980
2250
  ref,
@@ -1987,7 +2257,7 @@ var DropdownMenuItem = React9.forwardRef(({ className, inset, ...props }, ref) =
1987
2257
  }
1988
2258
  ));
1989
2259
  DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
1990
- var DropdownMenuCheckboxItem = React9.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
2260
+ var DropdownMenuCheckboxItem = React10.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
1991
2261
  DropdownMenuPrimitive.CheckboxItem,
1992
2262
  {
1993
2263
  ref,
@@ -2001,7 +2271,7 @@ var DropdownMenuCheckboxItem = React9.forwardRef(({ className, children, checked
2001
2271
  }
2002
2272
  ));
2003
2273
  DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
2004
- var DropdownMenuRadioItem = React9.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
2274
+ var DropdownMenuRadioItem = React10.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
2005
2275
  DropdownMenuPrimitive.RadioItem,
2006
2276
  {
2007
2277
  ref,
@@ -2014,7 +2284,7 @@ var DropdownMenuRadioItem = React9.forwardRef(({ className, children, ...props }
2014
2284
  }
2015
2285
  ));
2016
2286
  DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
2017
- var DropdownMenuLabel = React9.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
2287
+ var DropdownMenuLabel = React10.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
2018
2288
  DropdownMenuPrimitive.Label,
2019
2289
  {
2020
2290
  ref,
@@ -2027,7 +2297,7 @@ var DropdownMenuLabel = React9.forwardRef(({ className, inset, ...props }, ref)
2027
2297
  }
2028
2298
  ));
2029
2299
  DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
2030
- var DropdownMenuSeparator = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2300
+ var DropdownMenuSeparator = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2031
2301
  DropdownMenuPrimitive.Separator,
2032
2302
  {
2033
2303
  ref,
@@ -2602,7 +2872,11 @@ function EasyVisionTable(props) {
2602
2872
  }
2603
2873
  }, [fetchData, page, itemsPerPage, sort, externalFilter, onDataLoaded]);
2604
2874
  useEffect(() => {
2605
- if (isApi && fetchData) void runFetch();
2875
+ if (!isApi || !fetchData) return;
2876
+ const seq = fetchSeqRef.current;
2877
+ queueMicrotask(() => {
2878
+ if (fetchSeqRef.current === seq) void runFetch();
2879
+ });
2606
2880
  }, [isApi, page, itemsPerPage, sort, refetchSignal]);
2607
2881
  const resolveEagerAll = useCallback(async () => {
2608
2882
  if (!fetchData) return;