@easyvision/easyvision-ui 1.7.6 → 1.9.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.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require('./easyvision.css');
4
4
  require('./EasyVisionTable.css');
5
- var React8 = require('react');
5
+ var React9 = require('react');
6
6
  var lucideReact = require('lucide-react');
7
7
  var clsx = require('clsx');
8
8
  var tailwindMerge = require('tailwind-merge');
@@ -20,6 +20,9 @@ var locale = require('date-fns/locale');
20
20
  var reactDayPicker = require('react-day-picker');
21
21
  var reactTable = require('@tanstack/react-table');
22
22
  var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
23
+ var ExcelJS = require('exceljs');
24
+
25
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
23
26
 
24
27
  function _interopNamespace(e) {
25
28
  if (e && e.__esModule) return e;
@@ -39,17 +42,18 @@ function _interopNamespace(e) {
39
42
  return Object.freeze(n);
40
43
  }
41
44
 
42
- var React8__namespace = /*#__PURE__*/_interopNamespace(React8);
45
+ var React9__namespace = /*#__PURE__*/_interopNamespace(React9);
43
46
  var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
44
47
  var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
45
48
  var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
46
49
  var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
50
+ var ExcelJS__default = /*#__PURE__*/_interopDefault(ExcelJS);
47
51
 
48
52
  // index.ts
49
53
  function cn(...inputs) {
50
54
  return tailwindMerge.twMerge(clsx.clsx(inputs));
51
55
  }
52
- var Input = React8__namespace.forwardRef(
56
+ var Input = React9__namespace.forwardRef(
53
57
  ({ className, type, ...props }, ref) => {
54
58
  return /* @__PURE__ */ jsxRuntime.jsx(
55
59
  "input",
@@ -113,26 +117,26 @@ var KIND_SUFFIX = {
113
117
  var fullIdOf = (id, kind) => `${id}${KIND_SUFFIX[kind]}`;
114
118
  var childIdOf = (parentFullId, childLocalId) => `${parentFullId}.${childLocalId}`;
115
119
  var childFullIdOf = (parentFullId, childLocalId, childKind) => parentFullId ? `${childIdOf(parentFullId, childLocalId)}${KIND_SUFFIX[childKind]}` : fullIdOf(childLocalId, childKind);
116
- var NamespaceContext = React8.createContext(null);
120
+ var NamespaceContext = React9.createContext(null);
117
121
  function NamespaceProvider({
118
122
  fullId,
119
123
  children
120
124
  }) {
121
125
  return /* @__PURE__ */ jsxRuntime.jsx(NamespaceContext.Provider, { value: fullId, children });
122
126
  }
123
- var useParentFullId = () => React8.useContext(NamespaceContext);
127
+ var useParentFullId = () => React9.useContext(NamespaceContext);
124
128
 
125
129
  // store/useEasyVisionSlice.ts
126
130
  function useEasyVisionSlice(kind, localId, opts) {
127
131
  const parentFullId = useParentFullId();
128
- const fullId = React8.useMemo(
132
+ const fullId = React9.useMemo(
129
133
  () => childFullIdOf(parentFullId, localId, kind),
130
134
  [parentFullId, localId, kind]
131
135
  );
132
136
  if (!easyVisionRegistry.getState().slices[fullId]) {
133
137
  easyVisionRegistry.getState().ensure(kind, fullId, opts.init);
134
138
  }
135
- const slice = React8.useSyncExternalStore(
139
+ const slice = React9.useSyncExternalStore(
136
140
  easyVisionRegistry.subscribe,
137
141
  () => {
138
142
  const s = easyVisionRegistry.getState().slices[fullId];
@@ -141,27 +145,27 @@ function useEasyVisionSlice(kind, localId, opts) {
141
145
  },
142
146
  () => easyVisionRegistry.getState().ensure(kind, fullId, opts.init)
143
147
  );
144
- React8.useEffect(() => {
148
+ React9.useEffect(() => {
145
149
  if (opts.clearWhen && opts.clearWhen(slice)) {
146
150
  easyVisionRegistry.getState().drop(fullId);
147
151
  easyVisionRegistry.getState().ensure(kind, fullId, opts.init);
148
152
  }
149
153
  }, [slice, fullId, kind, opts]);
150
- React8.useEffect(() => {
154
+ React9.useEffect(() => {
151
155
  opts.onStateChange?.(slice);
152
156
  }, [slice]);
153
- React8.useEffect(() => {
157
+ React9.useEffect(() => {
154
158
  return () => {
155
159
  if (!opts.persist) {
156
160
  easyVisionRegistry.getState().drop(fullId);
157
161
  }
158
162
  };
159
163
  }, [fullId]);
160
- const patch = React8.useMemo(
164
+ const patch = React9.useMemo(
161
165
  () => (partial) => easyVisionRegistry.getState().patch(fullId, partial),
162
166
  [fullId]
163
167
  );
164
- const reset = React8.useMemo(
168
+ const reset = React9.useMemo(
165
169
  () => () => {
166
170
  easyVisionRegistry.getState().drop(fullId);
167
171
  easyVisionRegistry.getState().ensure(kind, fullId, opts.init);
@@ -171,8 +175,8 @@ function useEasyVisionSlice(kind, localId, opts) {
171
175
  return { fullId, slice, patch, reset };
172
176
  }
173
177
  function useDebouncedValue(value, delayMs) {
174
- const [debounced, setDebounced] = React8.useState(value);
175
- React8.useEffect(() => {
178
+ const [debounced, setDebounced] = React9.useState(value);
179
+ React9.useEffect(() => {
176
180
  if (delayMs <= 0) {
177
181
  setDebounced(value);
178
182
  return;
@@ -205,8 +209,8 @@ function EasyVisionInput({
205
209
  onStateChange: onStateChange ? (s) => onStateChange(s.value) : void 0
206
210
  });
207
211
  const debounced = useDebouncedValue(slice.value, debounceMs);
208
- const lastEmittedRef = React8.useRef(slice.value);
209
- React8.useEffect(() => {
212
+ const lastEmittedRef = React9.useRef(slice.value);
213
+ React9.useEffect(() => {
210
214
  if (debounced !== lastEmittedRef.current) {
211
215
  lastEmittedRef.current = debounced;
212
216
  onChange?.(debounced);
@@ -257,7 +261,7 @@ function EasyVisionInput({
257
261
  }
258
262
  var Select = SelectPrimitive__namespace.Root;
259
263
  var SelectValue = SelectPrimitive__namespace.Value;
260
- var SelectTrigger = React8__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
264
+ var SelectTrigger = React9__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
261
265
  SelectPrimitive__namespace.Trigger,
262
266
  {
263
267
  ref,
@@ -270,7 +274,7 @@ var SelectTrigger = React8__namespace.forwardRef(({ className, children, ...prop
270
274
  }
271
275
  ));
272
276
  SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
273
- var SelectScrollUpButton = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
277
+ var SelectScrollUpButton = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
274
278
  SelectPrimitive__namespace.ScrollUpButton,
275
279
  {
276
280
  ref,
@@ -280,7 +284,7 @@ var SelectScrollUpButton = React8__namespace.forwardRef(({ className, ...props }
280
284
  }
281
285
  ));
282
286
  SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
283
- var SelectScrollDownButton = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
287
+ var SelectScrollDownButton = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
284
288
  SelectPrimitive__namespace.ScrollDownButton,
285
289
  {
286
290
  ref,
@@ -290,7 +294,7 @@ var SelectScrollDownButton = React8__namespace.forwardRef(({ className, ...props
290
294
  }
291
295
  ));
292
296
  SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
293
- var SelectContent = React8__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
297
+ var SelectContent = React9__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
294
298
  SelectPrimitive__namespace.Content,
295
299
  {
296
300
  ref,
@@ -314,7 +318,7 @@ var SelectContent = React8__namespace.forwardRef(({ className, children, positio
314
318
  }
315
319
  ) }));
316
320
  SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
317
- var SelectLabel = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
321
+ var SelectLabel = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
318
322
  SelectPrimitive__namespace.Label,
319
323
  {
320
324
  ref,
@@ -323,7 +327,7 @@ var SelectLabel = React8__namespace.forwardRef(({ className, ...props }, ref) =>
323
327
  }
324
328
  ));
325
329
  SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
326
- var SelectItem = React8__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
330
+ var SelectItem = React9__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
327
331
  SelectPrimitive__namespace.Item,
328
332
  {
329
333
  ref,
@@ -336,7 +340,7 @@ var SelectItem = React8__namespace.forwardRef(({ className, children, ...props }
336
340
  }
337
341
  ));
338
342
  SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
339
- var SelectSeparator = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
343
+ var SelectSeparator = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
340
344
  SelectPrimitive__namespace.Separator,
341
345
  {
342
346
  ref,
@@ -367,7 +371,7 @@ var buttonVariants = classVarianceAuthority.cva("ev-btn", {
367
371
  size: "default"
368
372
  }
369
373
  });
370
- var Button = React8__namespace.forwardRef(
374
+ var Button = React9__namespace.forwardRef(
371
375
  ({ className, variant, size, asChild = false, ...props }, ref) => {
372
376
  const Comp = asChild ? reactSlot.Slot : "button";
373
377
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -383,7 +387,7 @@ var Button = React8__namespace.forwardRef(
383
387
  Button.displayName = "Button";
384
388
  var Popover = PopoverPrimitive__namespace.Root;
385
389
  var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
386
- var PopoverContent = React8__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
390
+ var PopoverContent = React9__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
387
391
  PopoverPrimitive__namespace.Content,
388
392
  {
389
393
  ref,
@@ -394,7 +398,7 @@ var PopoverContent = React8__namespace.forwardRef(({ className, align = "center"
394
398
  }
395
399
  ) }));
396
400
  PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
397
- var Command = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
401
+ var Command = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
398
402
  cmdk.Command,
399
403
  {
400
404
  ref,
@@ -403,7 +407,7 @@ var Command = React8__namespace.forwardRef(({ className, ...props }, ref) => /*
403
407
  }
404
408
  ));
405
409
  Command.displayName = cmdk.Command.displayName;
406
- var CommandInput = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ev-cmd-input-wrapper", "cmdk-input-wrapper": "", children: [
410
+ var CommandInput = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ev-cmd-input-wrapper", "cmdk-input-wrapper": "", children: [
407
411
  /* @__PURE__ */ jsxRuntime.jsx(reactIcons.MagnifyingGlassIcon, { className: "ev-cmd-input-icon" }),
408
412
  /* @__PURE__ */ jsxRuntime.jsx(
409
413
  cmdk.Command.Input,
@@ -415,7 +419,7 @@ var CommandInput = React8__namespace.forwardRef(({ className, ...props }, ref) =
415
419
  )
416
420
  ] }));
417
421
  CommandInput.displayName = cmdk.Command.Input.displayName;
418
- var CommandList = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
422
+ var CommandList = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
419
423
  cmdk.Command.List,
420
424
  {
421
425
  ref,
@@ -424,7 +428,7 @@ var CommandList = React8__namespace.forwardRef(({ className, ...props }, ref) =>
424
428
  }
425
429
  ));
426
430
  CommandList.displayName = cmdk.Command.List.displayName;
427
- var CommandEmpty = React8__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
431
+ var CommandEmpty = React9__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
428
432
  cmdk.Command.Empty,
429
433
  {
430
434
  ref,
@@ -433,7 +437,7 @@ var CommandEmpty = React8__namespace.forwardRef((props, ref) => /* @__PURE__ */
433
437
  }
434
438
  ));
435
439
  CommandEmpty.displayName = cmdk.Command.Empty.displayName;
436
- var CommandGroup = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
440
+ var CommandGroup = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
437
441
  cmdk.Command.Group,
438
442
  {
439
443
  ref,
@@ -442,7 +446,7 @@ var CommandGroup = React8__namespace.forwardRef(({ className, ...props }, ref) =
442
446
  }
443
447
  ));
444
448
  CommandGroup.displayName = cmdk.Command.Group.displayName;
445
- var CommandSeparator = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
449
+ var CommandSeparator = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
446
450
  cmdk.Command.Separator,
447
451
  {
448
452
  ref,
@@ -451,7 +455,7 @@ var CommandSeparator = React8__namespace.forwardRef(({ className, ...props }, re
451
455
  }
452
456
  ));
453
457
  CommandSeparator.displayName = cmdk.Command.Separator.displayName;
454
- var CommandItem = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
458
+ var CommandItem = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
455
459
  cmdk.Command.Item,
456
460
  {
457
461
  ref,
@@ -485,10 +489,10 @@ function EasyVisionSelector({
485
489
  onStateChange: onStateChange ? (s) => onStateChange(s.value) : void 0
486
490
  });
487
491
  const value = slice.value;
488
- const [resolved, setResolved] = React8.useState(
492
+ const [resolved, setResolved] = React9.useState(
489
493
  Array.isArray(options) ? options : null
490
494
  );
491
- React8.useEffect(() => {
495
+ React9.useEffect(() => {
492
496
  if (typeof options === "function" && resolved === null) {
493
497
  void options().then(setResolved).catch(() => setResolved([]));
494
498
  } else if (Array.isArray(options)) {
@@ -496,10 +500,10 @@ function EasyVisionSelector({
496
500
  }
497
501
  }, [options, resolved]);
498
502
  const opts = resolved ?? [];
499
- const [pending, setPending] = React8.useState(value);
500
- React8.useEffect(() => setPending(value), [value]);
501
- const lastEmittedRef = React8.useRef(value);
502
- React8.useEffect(() => {
503
+ const [pending, setPending] = React9.useState(value);
504
+ React9.useEffect(() => setPending(value), [value]);
505
+ const lastEmittedRef = React9.useRef(value);
506
+ React9.useEffect(() => {
503
507
  if (value !== lastEmittedRef.current) {
504
508
  lastEmittedRef.current = value;
505
509
  onChange?.(value);
@@ -618,11 +622,11 @@ function TextWidget({ definition, value, onChange, onRemove }) {
618
622
  }
619
623
  var SENTINEL = "__easyvision_undef__";
620
624
  function SelectorWidget({ definition, value, onChange, onRemove }) {
621
- const [open, setOpen] = React8.useState(false);
622
- const [resolved, setResolved] = React8.useState(
625
+ const [open, setOpen] = React9.useState(false);
626
+ const [resolved, setResolved] = React9.useState(
623
627
  Array.isArray(definition.options) ? definition.options : null
624
628
  );
625
- React8.useEffect(() => {
629
+ React9.useEffect(() => {
626
630
  if (typeof definition.options === "function" && resolved === null) {
627
631
  void definition.options().then((o) => setResolved(o)).catch(() => setResolved([]));
628
632
  } else if (Array.isArray(definition.options)) {
@@ -674,7 +678,7 @@ function SelectorWidget({ definition, value, onChange, onRemove }) {
674
678
  )
675
679
  ] });
676
680
  }
677
- var Checkbox = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
681
+ var Checkbox = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
678
682
  CheckboxPrimitive__namespace.Root,
679
683
  {
680
684
  ref,
@@ -690,22 +694,22 @@ function MultiSelectWidget({
690
694
  onChange,
691
695
  onRemove
692
696
  }) {
693
- const [search, setSearch] = React8.useState("");
694
- const [open, setOpen] = React8.useState(false);
697
+ const [search, setSearch] = React9.useState("");
698
+ const [open, setOpen] = React9.useState(false);
695
699
  const searchFn = definition.searchOptions;
696
700
  const hasSearchOptions = typeof searchFn === "function";
697
- const [resolved, setResolved] = React8.useState(
701
+ const [resolved, setResolved] = React9.useState(
698
702
  Array.isArray(definition.options) ? definition.options : null
699
703
  );
700
- React8.useEffect(() => {
704
+ React9.useEffect(() => {
701
705
  if (typeof definition.options === "function" && resolved === null) {
702
706
  void definition.options().then(setResolved).catch(() => setResolved([]));
703
707
  } else if (Array.isArray(definition.options)) {
704
708
  setResolved(definition.options);
705
709
  }
706
710
  }, [definition.options, resolved]);
707
- const [searchResults, setSearchResults] = React8.useState([]);
708
- React8.useEffect(() => {
711
+ const [searchResults, setSearchResults] = React9.useState([]);
712
+ React9.useEffect(() => {
709
713
  if (!searchFn) return;
710
714
  if (search.trim() === "") {
711
715
  setSearchResults([]);
@@ -726,11 +730,11 @@ function MultiSelectWidget({
726
730
  }, [search, searchFn]);
727
731
  const selected = Array.isArray(value) ? value : [];
728
732
  const baseOpts = resolved ?? [];
729
- const labelCache = React8.useRef(/* @__PURE__ */ new Map());
730
- React8.useEffect(() => {
733
+ const labelCache = React9.useRef(/* @__PURE__ */ new Map());
734
+ React9.useEffect(() => {
731
735
  baseOpts.forEach((o) => labelCache.current.set(o.value, o.label));
732
736
  }, [baseOpts]);
733
- const listOpts = React8.useMemo(() => {
737
+ const listOpts = React9.useMemo(() => {
734
738
  if (hasSearchOptions) return searchResults;
735
739
  return baseOpts.filter(
736
740
  (o) => o.label.toLowerCase().includes(search.toLowerCase())
@@ -1063,7 +1067,7 @@ function buildCondition(def, value) {
1063
1067
  }
1064
1068
  }
1065
1069
  function useBuildQuery(config, values, childQueries) {
1066
- return React8.useCallback(() => {
1070
+ return React9.useCallback(() => {
1067
1071
  const where = {};
1068
1072
  if (config.searchField) {
1069
1073
  const c = buildCondition(config.searchField, values[config.searchField.id]);
@@ -1160,7 +1164,7 @@ function isMandatorySatisfied(def, value) {
1160
1164
  if (!def.mandatory) return true;
1161
1165
  return isNonEmpty(value);
1162
1166
  }
1163
- var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(props, ref) {
1167
+ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(props, ref) {
1164
1168
  const {
1165
1169
  id,
1166
1170
  config,
@@ -1185,7 +1189,7 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1185
1189
  const resolvedPerformMode = performMode === "live" ? "live" : "manual";
1186
1190
  const labels = { ...DEFAULT_LABELS, ...labelOverrides };
1187
1191
  const showClear = showClearAll ?? editable;
1188
- const initialActive = React8.useMemo(() => {
1192
+ const initialActive = React9.useMemo(() => {
1189
1193
  const ids = [];
1190
1194
  if (config.searchField) ids.push(config.searchField.id);
1191
1195
  for (const f of config.fields) {
@@ -1193,7 +1197,7 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1193
1197
  }
1194
1198
  return ids;
1195
1199
  }, [config]);
1196
- const initialValues = React8.useMemo(() => {
1200
+ const initialValues = React9.useMemo(() => {
1197
1201
  const v = {};
1198
1202
  if (config.searchField?.defaultValue !== void 0) {
1199
1203
  v[config.searchField.id] = config.searchField.defaultValue;
@@ -1220,12 +1224,12 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1220
1224
  }) : void 0
1221
1225
  });
1222
1226
  const { activeFields, values, lastConfirmedSnapshotJSON } = slice;
1223
- const registryState = React8.useSyncExternalStore(
1227
+ const registryState = React9.useSyncExternalStore(
1224
1228
  easyVisionRegistry.subscribe,
1225
1229
  easyVisionRegistry.getState,
1226
1230
  easyVisionRegistry.getState
1227
1231
  );
1228
- const childSnapshots = React8.useMemo(() => {
1232
+ const childSnapshots = React9.useMemo(() => {
1229
1233
  const out = {};
1230
1234
  for (const f of config.fields) {
1231
1235
  if (f.type !== "multifilter") continue;
@@ -1240,7 +1244,7 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1240
1244
  }
1241
1245
  return out;
1242
1246
  }, [fullId, config.fields, registryState]);
1243
- const childQueries = React8.useMemo(() => {
1247
+ const childQueries = React9.useMemo(() => {
1244
1248
  const out = {};
1245
1249
  for (const f of config.fields) {
1246
1250
  if (f.type !== "multifilter") continue;
@@ -1251,7 +1255,7 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1251
1255
  return out;
1252
1256
  }, [config.fields, childSnapshots]);
1253
1257
  const buildQuery = useBuildQuery(config, values, childQueries);
1254
- const composedValues = React8.useMemo(() => {
1258
+ const composedValues = React9.useMemo(() => {
1255
1259
  const out = { ...values };
1256
1260
  for (const f of config.fields) {
1257
1261
  if (f.type === "multifilter") {
@@ -1260,7 +1264,7 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1260
1264
  }
1261
1265
  return out;
1262
1266
  }, [values, config.fields, childSnapshots]);
1263
- const isValid = React8.useMemo(() => {
1267
+ const isValid = React9.useMemo(() => {
1264
1268
  if (config.searchField && !isMandatorySatisfied(config.searchField, values[config.searchField.id])) {
1265
1269
  return false;
1266
1270
  }
@@ -1282,15 +1286,15 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1282
1286
  }
1283
1287
  return true;
1284
1288
  }, [config, values, childSnapshots]);
1285
- const snapshotKey = React8.useMemo(
1289
+ const snapshotKey = React9.useMemo(
1286
1290
  () => buildSnapshotKey({ activeFields, values: composedValues }),
1287
1291
  [activeFields, composedValues]
1288
1292
  );
1289
- const dirty = React8.useMemo(
1293
+ const dirty = React9.useMemo(
1290
1294
  () => isDirty({ activeFields, values: composedValues }, lastConfirmedSnapshotJSON),
1291
1295
  [activeFields, composedValues, lastConfirmedSnapshotJSON]
1292
1296
  );
1293
- const snapshot = React8.useMemo(
1297
+ const snapshot = React9.useMemo(
1294
1298
  () => ({
1295
1299
  values: composedValues,
1296
1300
  activeFields,
@@ -1300,15 +1304,15 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1300
1304
  }),
1301
1305
  [composedValues, activeFields, isValid, dirty, buildQuery]
1302
1306
  );
1303
- const lastEmittedKeyRef = React8.useRef("");
1304
- React8.useEffect(() => {
1307
+ const lastEmittedKeyRef = React9.useRef("");
1308
+ React9.useEffect(() => {
1305
1309
  const key = `${snapshotKey}|${dirty}|${isValid}`;
1306
1310
  if (key === lastEmittedKeyRef.current) return;
1307
1311
  lastEmittedKeyRef.current = key;
1308
1312
  onChange?.(snapshot);
1309
1313
  onStateChange?.(snapshot);
1310
1314
  }, [snapshotKey, dirty, isValid, snapshot, onChange, onStateChange]);
1311
- const performAction = React8.useCallback(() => {
1315
+ const performAction = React9.useCallback(() => {
1312
1316
  const key = buildSnapshotKey({ activeFields, values: composedValues });
1313
1317
  patch({ lastConfirmedSnapshotJSON: key });
1314
1318
  if (onPerform) {
@@ -1316,16 +1320,16 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1316
1320
  queueMicrotask(() => onPerform(emitted));
1317
1321
  }
1318
1322
  }, [activeFields, composedValues, patch, onPerform, snapshot]);
1319
- const didPerformOnMountRef = React8.useRef(false);
1320
- React8.useEffect(() => {
1323
+ const didPerformOnMountRef = React9.useRef(false);
1324
+ React9.useEffect(() => {
1321
1325
  if (performOnMount && !didPerformOnMountRef.current && Object.values(composedValues).some(isNonEmpty)) {
1322
1326
  didPerformOnMountRef.current = true;
1323
1327
  performAction();
1324
1328
  }
1325
1329
  }, [performOnMount]);
1326
- const liveTimerRef = React8.useRef(null);
1327
- const livePrevKeyRef = React8.useRef(null);
1328
- React8.useEffect(() => {
1330
+ const liveTimerRef = React9.useRef(null);
1331
+ const livePrevKeyRef = React9.useRef(null);
1332
+ React9.useEffect(() => {
1329
1333
  if (resolvedPerformMode !== "live") return;
1330
1334
  if (livePrevKeyRef.current === null) {
1331
1335
  livePrevKeyRef.current = snapshotKey;
@@ -1345,24 +1349,24 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1345
1349
  }
1346
1350
  };
1347
1351
  }, [snapshotKey, resolvedPerformMode, performDebounceMs, performAction]);
1348
- React8.useImperativeHandle(ref, () => ({
1352
+ React9.useImperativeHandle(ref, () => ({
1349
1353
  perform: performAction,
1350
1354
  getSnapshot: () => snapshot
1351
1355
  }));
1352
- const updateValue = React8.useCallback(
1356
+ const updateValue = React9.useCallback(
1353
1357
  (fieldId, value) => {
1354
1358
  patch({ values: { ...values, [fieldId]: value } });
1355
1359
  },
1356
1360
  [patch, values]
1357
1361
  );
1358
- const addField = React8.useCallback(
1362
+ const addField = React9.useCallback(
1359
1363
  (fieldId) => {
1360
1364
  if (activeFields.includes(fieldId)) return;
1361
1365
  patch({ activeFields: [...activeFields, fieldId] });
1362
1366
  },
1363
1367
  [activeFields, patch]
1364
1368
  );
1365
- const removeField = React8.useCallback(
1369
+ const removeField = React9.useCallback(
1366
1370
  (fieldId) => {
1367
1371
  const nextValues = { ...values };
1368
1372
  delete nextValues[fieldId];
@@ -1373,7 +1377,7 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1373
1377
  },
1374
1378
  [activeFields, values, patch]
1375
1379
  );
1376
- const clearAll = React8.useCallback(() => {
1380
+ const clearAll = React9.useCallback(() => {
1377
1381
  const seed = {};
1378
1382
  if (config.searchField?.defaultValue !== void 0) {
1379
1383
  seed[config.searchField.id] = config.searchField.defaultValue;
@@ -1387,22 +1391,22 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1387
1391
  lastConfirmedSnapshotJSON: null
1388
1392
  });
1389
1393
  }, [config, patch, initialActive]);
1390
- const visibleConfigFields = React8.useMemo(
1394
+ const visibleConfigFields = React9.useMemo(
1391
1395
  () => config.fields.filter((f) => isFieldVisible(f, composedValues)),
1392
1396
  [config.fields, composedValues]
1393
1397
  );
1394
1398
  const isProminentTextField = (f) => f.type === "text" && f.prominent === true;
1395
- const pinnedFields = React8.useMemo(
1399
+ const pinnedFields = React9.useMemo(
1396
1400
  () => visibleConfigFields.filter((f) => f.pinned && !isProminentTextField(f)),
1397
1401
  [visibleConfigFields]
1398
1402
  );
1399
- const chipFields = React8.useMemo(
1403
+ const chipFields = React9.useMemo(
1400
1404
  () => visibleConfigFields.filter(
1401
1405
  (f) => !f.pinned && !isProminentTextField(f) && activeFields.includes(f.id)
1402
1406
  ),
1403
1407
  [visibleConfigFields, activeFields]
1404
1408
  );
1405
- const prominentSlots = React8.useMemo(() => {
1409
+ const prominentSlots = React9.useMemo(() => {
1406
1410
  const slots = [];
1407
1411
  if (config.searchField) {
1408
1412
  slots.push({
@@ -1423,7 +1427,7 @@ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(pr
1423
1427
  }
1424
1428
  return slots;
1425
1429
  }, [config.searchField, visibleConfigFields, activeFields, editable]);
1426
- const availableToAdd = React8.useMemo(
1430
+ const availableToAdd = React9.useMemo(
1427
1431
  () => visibleConfigFields.filter(
1428
1432
  (f) => !f.pinned && !activeFields.includes(f.id)
1429
1433
  ),
@@ -1628,33 +1632,143 @@ function buildChildQueryDirect(field, values) {
1628
1632
  return Object.keys(where).length > 0 ? { where } : {};
1629
1633
  }
1630
1634
  var join = (...parts) => parts.filter(Boolean).join(" ");
1631
- var EasyVisionCard = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card", className), ...props }));
1635
+ var EasyVisionCard = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card", className), ...props }));
1632
1636
  EasyVisionCard.displayName = "EasyVisionCard";
1633
- var EasyVisionCardHeader = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-header", className), ...props }));
1637
+ var EasyVisionCardHeader = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-header", className), ...props }));
1634
1638
  EasyVisionCardHeader.displayName = "EasyVisionCardHeader";
1635
- var EasyVisionCardTitle = React8__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h3", { ref, className: join("ev-card-title", className), ...props, children }));
1639
+ var EasyVisionCardTitle = React9__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h3", { ref, className: join("ev-card-title", className), ...props, children }));
1636
1640
  EasyVisionCardTitle.displayName = "EasyVisionCardTitle";
1637
- var EasyVisionCardDescription = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("p", { ref, className: join("ev-card-description", className), ...props }));
1641
+ var EasyVisionCardDescription = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("p", { ref, className: join("ev-card-description", className), ...props }));
1638
1642
  EasyVisionCardDescription.displayName = "EasyVisionCardDescription";
1639
- var EasyVisionCardContent = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-content", className), ...props }));
1643
+ var EasyVisionCardContent = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-content", className), ...props }));
1640
1644
  EasyVisionCardContent.displayName = "EasyVisionCardContent";
1641
- var EasyVisionCardFooter = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-footer", className), ...props }));
1645
+ var EasyVisionCardFooter = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("ev-card-footer", className), ...props }));
1642
1646
  EasyVisionCardFooter.displayName = "EasyVisionCardFooter";
1643
- var Table = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("table", { ref, className: cn("ev-table", className), ...props }));
1647
+ var join2 = (...parts) => parts.filter(Boolean).join(" ");
1648
+ function EasyVisionAccordionItem(_props) {
1649
+ return null;
1650
+ }
1651
+ EasyVisionAccordionItem.displayName = "EasyVisionAccordionItem";
1652
+ function normalizeFromChildren(children) {
1653
+ const out = [];
1654
+ React9__namespace.Children.forEach(children, (child) => {
1655
+ if (!React9__namespace.isValidElement(child)) return;
1656
+ if (child.type !== EasyVisionAccordionItem) return;
1657
+ const p = child.props;
1658
+ out.push({
1659
+ id: p.id,
1660
+ question: p.question,
1661
+ content: p.children,
1662
+ defaultOpen: p.defaultOpen,
1663
+ disabled: p.disabled,
1664
+ className: p.className
1665
+ });
1666
+ });
1667
+ return out;
1668
+ }
1669
+ function normalizeFromItems(items) {
1670
+ return items.map((it) => ({
1671
+ id: it.id,
1672
+ question: it.question,
1673
+ content: it.content,
1674
+ defaultOpen: it.defaultOpen,
1675
+ disabled: it.disabled
1676
+ }));
1677
+ }
1678
+ function AccordionRow({ item, open, onToggle }) {
1679
+ const panelId = `ev-accordion-panel-${item.id}`;
1680
+ const triggerId = `ev-accordion-trigger-${item.id}`;
1681
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: join2("ev-accordion-item", item.className), children: [
1682
+ /* @__PURE__ */ jsxRuntime.jsxs(
1683
+ "button",
1684
+ {
1685
+ type: "button",
1686
+ id: triggerId,
1687
+ className: join2("ev-accordion-trigger", open && "ev-accordion-trigger-open"),
1688
+ "aria-expanded": open,
1689
+ "aria-controls": panelId,
1690
+ disabled: item.disabled,
1691
+ onClick: () => onToggle(item.id),
1692
+ children: [
1693
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ev-accordion-question", children: item.question }),
1694
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "ev-accordion-icon", "aria-hidden": "true" })
1695
+ ]
1696
+ }
1697
+ ),
1698
+ open && /* @__PURE__ */ jsxRuntime.jsx(
1699
+ "div",
1700
+ {
1701
+ id: panelId,
1702
+ role: "region",
1703
+ "aria-labelledby": triggerId,
1704
+ className: "ev-accordion-panel",
1705
+ children: item.content
1706
+ }
1707
+ )
1708
+ ] });
1709
+ }
1710
+ function EasyVisionAccordion({
1711
+ items,
1712
+ children,
1713
+ mode = "single",
1714
+ openIds,
1715
+ defaultOpenIds,
1716
+ onOpenChange,
1717
+ className
1718
+ }) {
1719
+ const normalized = React9__namespace.useMemo(
1720
+ () => items ? normalizeFromItems(items) : normalizeFromChildren(children),
1721
+ [items, children]
1722
+ );
1723
+ const isControlled = openIds !== void 0;
1724
+ const [internalOpen, setInternalOpen] = React9__namespace.useState(() => {
1725
+ if (defaultOpenIds) return new Set(defaultOpenIds);
1726
+ return new Set(normalized.filter((it) => it.defaultOpen).map((it) => it.id));
1727
+ });
1728
+ const openSet = React9__namespace.useMemo(
1729
+ () => isControlled ? new Set(openIds) : internalOpen,
1730
+ [isControlled, openIds, internalOpen]
1731
+ );
1732
+ const handleToggle = React9__namespace.useCallback(
1733
+ (id) => {
1734
+ const next = new Set(openSet);
1735
+ if (next.has(id)) {
1736
+ next.delete(id);
1737
+ } else {
1738
+ if (mode === "single") next.clear();
1739
+ next.add(id);
1740
+ }
1741
+ if (!isControlled) setInternalOpen(next);
1742
+ onOpenChange?.(Array.from(next));
1743
+ },
1744
+ [openSet, mode, isControlled, onOpenChange]
1745
+ );
1746
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: join2("ev-accordion", className), children: normalized.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
1747
+ AccordionRow,
1748
+ {
1749
+ item,
1750
+ open: openSet.has(item.id),
1751
+ onToggle: handleToggle
1752
+ },
1753
+ item.id
1754
+ )) });
1755
+ }
1756
+ EasyVisionAccordion.displayName = "EasyVisionAccordion";
1757
+ var Table = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("table", { ref, className: cn("ev-table", className), ...props }));
1644
1758
  Table.displayName = "Table";
1645
- var TableHeader = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className, ...props }));
1759
+ var TableHeader = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className, ...props }));
1646
1760
  TableHeader.displayName = "TableHeader";
1647
- var TableBody = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { ref, className, ...props }));
1761
+ var TableBody = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { ref, className, ...props }));
1648
1762
  TableBody.displayName = "TableBody";
1649
- var TableFooter = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tfoot", { ref, className, ...props }));
1763
+ var TableFooter = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tfoot", { ref, className, ...props }));
1650
1764
  TableFooter.displayName = "TableFooter";
1651
- var TableRow = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tr", { ref, className, ...props }));
1765
+ var TableRow = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tr", { ref, className, ...props }));
1652
1766
  TableRow.displayName = "TableRow";
1653
- var TableHead = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("th", { ref, className, ...props }));
1767
+ var TableHead = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("th", { ref, className, ...props }));
1654
1768
  TableHead.displayName = "TableHead";
1655
- var TableCell = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("td", { ref, className, ...props }));
1769
+ var TableCell = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("td", { ref, className, ...props }));
1656
1770
  TableCell.displayName = "TableCell";
1657
- var TableCaption = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("caption", { ref, className, ...props }));
1771
+ var TableCaption = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("caption", { ref, className, ...props }));
1658
1772
  TableCaption.displayName = "TableCaption";
1659
1773
  var isNestedField = (field) => field.includes(".");
1660
1774
  var resolvePath = (obj, path) => path.split(".").reduce(
@@ -1683,7 +1797,7 @@ function adaptColumns(columns, orderingMode, defaultSorting = "nonNested") {
1683
1797
  };
1684
1798
  const isUi = c.type === "ui";
1685
1799
  const userCell = c.cell;
1686
- const wrappedCell = userCell ? ({ row }) => userCell(row.original) : ({ getValue }) => React8.createElement(
1800
+ const wrappedCell = userCell ? ({ row }) => userCell(row.original) : ({ getValue }) => React9.createElement(
1687
1801
  "span",
1688
1802
  { className: "text-sm text-foreground" },
1689
1803
  String(getValue() ?? "-")
@@ -1753,6 +1867,16 @@ function compareByPath(a, b, path, descending) {
1753
1867
  return descending ? bs.localeCompare(as) : as.localeCompare(bs);
1754
1868
  }
1755
1869
 
1870
+ // table/sortLocalRows.ts
1871
+ function sortLocalRows(rows, columns, sort) {
1872
+ if (!sort) return rows;
1873
+ const col = columns.find((c) => c.field === sort.column);
1874
+ if (!col || col.type === "ui") return rows;
1875
+ const next = [...rows];
1876
+ next.sort((a, b) => compareByPath(a, b, col.field, sort.descending));
1877
+ return next;
1878
+ }
1879
+
1756
1880
  // table/useTableData.ts
1757
1881
  function useTableData({
1758
1882
  data,
@@ -1763,15 +1887,10 @@ function useTableData({
1763
1887
  paginationMode,
1764
1888
  orderingMode
1765
1889
  }) {
1766
- return React8.useMemo(() => {
1890
+ return React9.useMemo(() => {
1767
1891
  let rows = data ?? [];
1768
1892
  if (orderingMode === "local" && sort) {
1769
- const col = columns.find((c) => c.field === sort.column);
1770
- if (col && col.type !== "ui") {
1771
- const next = [...rows];
1772
- next.sort((a, b) => compareByPath(a, b, col.field, sort.descending));
1773
- rows = next;
1774
- }
1893
+ rows = sortLocalRows(rows, columns, sort);
1775
1894
  }
1776
1895
  const totalCount = rows.length;
1777
1896
  if (paginationMode === "local") {
@@ -1781,10 +1900,67 @@ function useTableData({
1781
1900
  return { rows, totalCount };
1782
1901
  }, [data, columns, page, itemsPerPage, sort, paginationMode, orderingMode]);
1783
1902
  }
1903
+
1904
+ // table/applySelection.ts
1905
+ function applySelection(rows, selection, getRowId) {
1906
+ if (selection.scope === "all") {
1907
+ const except = selection.exceptIds;
1908
+ if (!except || Object.keys(except).length === 0) return rows;
1909
+ return rows.filter((row) => !except[getRowId(row)]);
1910
+ }
1911
+ const ids = selection.ids;
1912
+ if (!ids || Object.keys(ids).length === 0) return rows;
1913
+ return rows.filter((row) => ids[getRowId(row)]);
1914
+ }
1915
+
1916
+ // table/columnVisibility.ts
1917
+ function resolveColumnVisibility(columns, sliceVisibility) {
1918
+ const defaults = {};
1919
+ for (const column of columns) {
1920
+ if (column.initiallyHidden) defaults[column.field] = false;
1921
+ }
1922
+ return { ...defaults, ...sliceVisibility };
1923
+ }
1924
+ var isColumnVisible = (visibility, field) => visibility[field] !== false;
1925
+
1926
+ // table/fetchAllRows.ts
1927
+ var FETCH_ALL_PAGE_SIZE = 200;
1928
+ var mergeFilters = (externalFilter, multifilterQuery) => externalFilter || multifilterQuery ? {
1929
+ ...multifilterQuery,
1930
+ where: {
1931
+ ...externalFilter?.where ?? {},
1932
+ ...multifilterQuery?.where ?? {}
1933
+ }
1934
+ } : void 0;
1935
+ async function fetchAllRows({
1936
+ fetchData,
1937
+ filter,
1938
+ sort,
1939
+ idsOnly = false,
1940
+ pageSize = FETCH_ALL_PAGE_SIZE,
1941
+ shouldContinue
1942
+ }) {
1943
+ const collected = [];
1944
+ let knownTotal = Infinity;
1945
+ for (let page = 1; collected.length < knownTotal; page++) {
1946
+ const result = await fetchData({
1947
+ page,
1948
+ itemsPerPage: pageSize,
1949
+ sort,
1950
+ filter,
1951
+ idsOnly
1952
+ });
1953
+ if (shouldContinue && !shouldContinue()) return null;
1954
+ knownTotal = result.totalCount;
1955
+ collected.push(...result.rows);
1956
+ if (result.rows.length < pageSize) break;
1957
+ }
1958
+ return collected;
1959
+ }
1784
1960
  var DropdownMenu = DropdownMenuPrimitive__namespace.Root;
1785
1961
  var DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
1786
1962
  var DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
1787
- var DropdownMenuSubTrigger = React8__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1963
+ var DropdownMenuSubTrigger = React9__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1788
1964
  DropdownMenuPrimitive__namespace.SubTrigger,
1789
1965
  {
1790
1966
  ref,
@@ -1801,7 +1977,7 @@ var DropdownMenuSubTrigger = React8__namespace.forwardRef(({ className, inset, c
1801
1977
  }
1802
1978
  ));
1803
1979
  DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
1804
- var DropdownMenuSubContent = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1980
+ var DropdownMenuSubContent = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1805
1981
  DropdownMenuPrimitive__namespace.SubContent,
1806
1982
  {
1807
1983
  ref,
@@ -1810,7 +1986,7 @@ var DropdownMenuSubContent = React8__namespace.forwardRef(({ className, ...props
1810
1986
  }
1811
1987
  ));
1812
1988
  DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
1813
- var DropdownMenuContent = React8__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1989
+ var DropdownMenuContent = React9__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1814
1990
  DropdownMenuPrimitive__namespace.Content,
1815
1991
  {
1816
1992
  ref,
@@ -1820,7 +1996,7 @@ var DropdownMenuContent = React8__namespace.forwardRef(({ className, sideOffset
1820
1996
  }
1821
1997
  ) }));
1822
1998
  DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
1823
- var DropdownMenuItem = React8__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1999
+ var DropdownMenuItem = React9__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1824
2000
  DropdownMenuPrimitive__namespace.Item,
1825
2001
  {
1826
2002
  ref,
@@ -1833,7 +2009,7 @@ var DropdownMenuItem = React8__namespace.forwardRef(({ className, inset, ...prop
1833
2009
  }
1834
2010
  ));
1835
2011
  DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
1836
- var DropdownMenuCheckboxItem = React8__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
2012
+ var DropdownMenuCheckboxItem = React9__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1837
2013
  DropdownMenuPrimitive__namespace.CheckboxItem,
1838
2014
  {
1839
2015
  ref,
@@ -1847,7 +2023,7 @@ var DropdownMenuCheckboxItem = React8__namespace.forwardRef(({ className, childr
1847
2023
  }
1848
2024
  ));
1849
2025
  DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
1850
- var DropdownMenuRadioItem = React8__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
2026
+ var DropdownMenuRadioItem = React9__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1851
2027
  DropdownMenuPrimitive__namespace.RadioItem,
1852
2028
  {
1853
2029
  ref,
@@ -1860,7 +2036,7 @@ var DropdownMenuRadioItem = React8__namespace.forwardRef(({ className, children,
1860
2036
  }
1861
2037
  ));
1862
2038
  DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
1863
- var DropdownMenuLabel = React8__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
2039
+ var DropdownMenuLabel = React9__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1864
2040
  DropdownMenuPrimitive__namespace.Label,
1865
2041
  {
1866
2042
  ref,
@@ -1873,7 +2049,7 @@ var DropdownMenuLabel = React8__namespace.forwardRef(({ className, inset, ...pro
1873
2049
  }
1874
2050
  ));
1875
2051
  DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
1876
- var DropdownMenuSeparator = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
2052
+ var DropdownMenuSeparator = React9__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1877
2053
  DropdownMenuPrimitive__namespace.Separator,
1878
2054
  {
1879
2055
  ref,
@@ -2172,6 +2348,48 @@ function matchLeaf(value, condition) {
2172
2348
  }
2173
2349
  return true;
2174
2350
  }
2351
+
2352
+ // export/sources.ts
2353
+ var sources = /* @__PURE__ */ new Map();
2354
+ var registerExportSource = (fullId, source) => {
2355
+ sources.set(fullId, source);
2356
+ };
2357
+ var unregisterExportSource = (fullId) => {
2358
+ sources.delete(fullId);
2359
+ };
2360
+ var getExportSource = (fullId) => sources.get(fullId);
2361
+ var resolveExportSource = (parentFullId, tableId) => getExportSource(childFullIdOf(parentFullId, tableId, "table")) ?? getExportSource(tableId);
2362
+
2363
+ // export/exportColumns.ts
2364
+ var toExportCellValue = (raw) => {
2365
+ if (raw == null) return null;
2366
+ if (Array.isArray(raw)) return raw.join(", ");
2367
+ if (raw instanceof Date) return raw;
2368
+ const kind = typeof raw;
2369
+ if (kind === "string" || kind === "number" || kind === "boolean") {
2370
+ return raw;
2371
+ }
2372
+ return String(raw);
2373
+ };
2374
+ var isExportable = (column) => column.exportable ?? column.type !== "ui";
2375
+ var exportHeaderOf = (column) => column.exportHeader ?? (typeof column.header === "string" ? column.header : column.field);
2376
+ function toExportColumns(columns, isVisible) {
2377
+ return columns.filter((column) => isExportable(column) && isVisible(column.field)).map((column) => {
2378
+ const exportValue = column.exportValue;
2379
+ const exportStyle = column.exportStyle;
2380
+ const field = column.field;
2381
+ const isUi = column.type === "ui";
2382
+ return {
2383
+ header: exportHeaderOf(column),
2384
+ getValue: (item) => {
2385
+ if (exportValue) return toExportCellValue(exportValue(item));
2386
+ if (isUi) return null;
2387
+ return toExportCellValue(getByPath(item, field));
2388
+ },
2389
+ getStyle: exportStyle ? (value, item) => exportStyle(value, item) : void 0
2390
+ };
2391
+ });
2392
+ }
2175
2393
  var DEFAULT_LABELS2 = {
2176
2394
  rowsPerPage: "Resultados por p\xE1gina:",
2177
2395
  results: "Resultados",
@@ -2229,7 +2447,7 @@ function EasyVisionTable(props) {
2229
2447
  const lbIncludeKey = JSON.stringify(loopback?.include ?? null);
2230
2448
  const lbFieldsKey = JSON.stringify(loopback?.fields ?? null);
2231
2449
  const lbOrderKey = JSON.stringify(loopback?.defaultOrder ?? null);
2232
- const loopbackFetcher = React8.useMemo(
2450
+ const loopbackFetcher = React9.useMemo(
2233
2451
  () => loopback ? createLoopbackTableFetcher(loopback) : void 0,
2234
2452
  // eslint-disable-next-line react-hooks/exhaustive-deps
2235
2453
  [lbFetchPage, lbFetchCount, lbIncludeKey, lbFieldsKey, lbOrderKey]
@@ -2237,7 +2455,7 @@ function EasyVisionTable(props) {
2237
2455
  const fetchData = fetchDataProp ?? loopbackFetcher;
2238
2456
  const paginationMode = loopback ? "api" : paginationModeProp;
2239
2457
  const orderingMode = loopback ? "api" : orderingModeProp;
2240
- const getRowId = React8.useMemo(
2458
+ const getRowId = React9.useMemo(
2241
2459
  () => getRowIdProp ?? ((row) => String(row?.id ?? "")),
2242
2460
  [getRowIdProp]
2243
2461
  );
@@ -2260,10 +2478,10 @@ function EasyVisionTable(props) {
2260
2478
  persist
2261
2479
  });
2262
2480
  const { page, itemsPerPage, sort, selection } = slice;
2263
- const lastSnapshotRef = React8.useRef(null);
2264
- const [localFilterTick, setLocalFilterTick] = React8.useState(0);
2265
- const innerMultifilterRef = React8.useRef(null);
2266
- const setMultifilterRef = React8.useCallback(
2481
+ const lastSnapshotRef = React9.useRef(null);
2482
+ const [localFilterTick, setLocalFilterTick] = React9.useState(0);
2483
+ const innerMultifilterRef = React9.useRef(null);
2484
+ const setMultifilterRef = React9.useCallback(
2267
2485
  (handle) => {
2268
2486
  innerMultifilterRef.current = handle;
2269
2487
  if (typeof multifilterRef === "function") {
@@ -2274,28 +2492,21 @@ function EasyVisionTable(props) {
2274
2492
  },
2275
2493
  [multifilterRef]
2276
2494
  );
2277
- const [apiRows, setApiRows] = React8.useState([]);
2278
- const [apiTotalCount, setApiTotalCount] = React8.useState(0);
2279
- const [apiLoading, setApiLoading] = React8.useState(false);
2280
- const fetchSeqRef = React8.useRef(0);
2495
+ const [apiRows, setApiRows] = React9.useState([]);
2496
+ const [apiTotalCount, setApiTotalCount] = React9.useState(0);
2497
+ const [apiLoading, setApiLoading] = React9.useState(false);
2498
+ const fetchSeqRef = React9.useRef(0);
2281
2499
  const isApi = paginationMode === "api" || orderingMode === "api";
2282
- const [eagerAllIds, setEagerAllIds] = React8.useState(null);
2283
- const [eagerAllRows, setEagerAllRows] = React8.useState([]);
2284
- const [isResolvingEager, setIsResolvingEager] = React8.useState(false);
2285
- const eagerSeqRef = React8.useRef(0);
2286
- const runFetch = React8.useCallback(async () => {
2500
+ const [eagerAllIds, setEagerAllIds] = React9.useState(null);
2501
+ const [eagerAllRows, setEagerAllRows] = React9.useState([]);
2502
+ const [isResolvingEager, setIsResolvingEager] = React9.useState(false);
2503
+ const eagerSeqRef = React9.useRef(0);
2504
+ const runFetch = React9.useCallback(async () => {
2287
2505
  if (!fetchData) return;
2288
2506
  const seq = ++fetchSeqRef.current;
2289
2507
  setApiLoading(true);
2290
2508
  try {
2291
- const mfQuery = lastSnapshotRef.current?.query;
2292
- const merged = externalFilter || mfQuery ? {
2293
- ...mfQuery,
2294
- where: {
2295
- ...externalFilter?.where ?? {},
2296
- ...mfQuery?.where ?? {}
2297
- }
2298
- } : void 0;
2509
+ const merged = mergeFilters(externalFilter, lastSnapshotRef.current?.query);
2299
2510
  const result = await fetchData({
2300
2511
  page,
2301
2512
  itemsPerPage,
@@ -2310,55 +2521,40 @@ function EasyVisionTable(props) {
2310
2521
  if (seq === fetchSeqRef.current) setApiLoading(false);
2311
2522
  }
2312
2523
  }, [fetchData, page, itemsPerPage, sort, externalFilter, onDataLoaded]);
2313
- React8.useEffect(() => {
2524
+ React9.useEffect(() => {
2314
2525
  if (isApi && fetchData) void runFetch();
2315
2526
  }, [isApi, page, itemsPerPage, sort, refetchSignal]);
2316
- const resolveEagerAll = React8.useCallback(async () => {
2527
+ const resolveEagerAll = React9.useCallback(async () => {
2317
2528
  if (!fetchData) return;
2318
2529
  const collectRows = selectAllResolution === "eager";
2319
2530
  const seq = ++eagerSeqRef.current;
2320
2531
  setIsResolvingEager(true);
2321
2532
  try {
2322
- const mfQuery = lastSnapshotRef.current?.query;
2323
- const merged = externalFilter || mfQuery ? {
2324
- ...mfQuery,
2325
- where: {
2326
- ...externalFilter?.where ?? {},
2327
- ...mfQuery?.where ?? {}
2328
- }
2329
- } : void 0;
2330
- const PAGE_SIZE = 200;
2533
+ const fetched = await fetchAllRows({
2534
+ fetchData,
2535
+ filter: mergeFilters(externalFilter, lastSnapshotRef.current?.query),
2536
+ sort,
2537
+ idsOnly: !collectRows,
2538
+ shouldContinue: () => seq === eagerSeqRef.current
2539
+ });
2540
+ if (fetched === null || seq !== eagerSeqRef.current) return;
2331
2541
  const ids = [];
2332
2542
  const rowsAcc = [];
2333
- let knownTotal = Infinity;
2334
- for (let p = 1; ids.length < knownTotal; p++) {
2335
- const result = await fetchData({
2336
- page: p,
2337
- itemsPerPage: PAGE_SIZE,
2338
- sort,
2339
- filter: merged,
2340
- idsOnly: !collectRows
2341
- });
2342
- if (seq !== eagerSeqRef.current) return;
2343
- knownTotal = result.totalCount;
2344
- for (const row of result.rows) {
2345
- const rid = getRowId(row);
2346
- if (rid) {
2347
- ids.push(rid);
2348
- if (collectRows) rowsAcc.push(row);
2349
- }
2543
+ for (const row of fetched) {
2544
+ const rid = getRowId(row);
2545
+ if (rid) {
2546
+ ids.push(rid);
2547
+ if (collectRows) rowsAcc.push(row);
2350
2548
  }
2351
- if (result.rows.length < PAGE_SIZE) break;
2352
2549
  }
2353
- if (seq !== eagerSeqRef.current) return;
2354
2550
  setEagerAllIds(ids);
2355
2551
  if (collectRows) setEagerAllRows(rowsAcc);
2356
2552
  } finally {
2357
2553
  if (seq === eagerSeqRef.current) setIsResolvingEager(false);
2358
2554
  }
2359
2555
  }, [fetchData, externalFilter, sort, getRowId, selectAllResolution]);
2360
- const prevRefetchRef = React8.useRef(refetchSignal);
2361
- React8.useEffect(() => {
2556
+ const prevRefetchRef = React9.useRef(refetchSignal);
2557
+ React9.useEffect(() => {
2362
2558
  if (prevRefetchRef.current !== refetchSignal && page !== 1) {
2363
2559
  prevRefetchRef.current = refetchSignal;
2364
2560
  patch({ page: 1 });
@@ -2370,7 +2566,7 @@ function EasyVisionTable(props) {
2370
2566
  eagerSeqRef.current++;
2371
2567
  setIsResolvingEager(false);
2372
2568
  }, [refetchSignal]);
2373
- const filteredData = React8.useMemo(() => {
2569
+ const filteredData = React9.useMemo(() => {
2374
2570
  if (paginationMode !== "local") return data;
2375
2571
  if (!data || data.length === 0) return data;
2376
2572
  const mfWhere = lastSnapshotRef.current?.query?.where;
@@ -2391,11 +2587,11 @@ function EasyVisionTable(props) {
2391
2587
  const rows = isApi ? apiRows : local.rows;
2392
2588
  const totalCount = isApi ? apiTotalCount : local.totalCount;
2393
2589
  const isLoading = isLoadingProp || apiLoading;
2394
- const tanstackColumns = React8.useMemo(
2590
+ const tanstackColumns = React9.useMemo(
2395
2591
  () => adaptColumns(columns, orderingMode, defaultSorting),
2396
2592
  [columns, orderingMode, defaultSorting]
2397
2593
  );
2398
- const allColumns = React8.useMemo(() => {
2594
+ const allColumns = React9.useMemo(() => {
2399
2595
  if (!enableRowSelection) return tanstackColumns;
2400
2596
  const checkboxCol = {
2401
2597
  id: "_select",
@@ -2415,24 +2611,69 @@ function EasyVisionTable(props) {
2415
2611
  };
2416
2612
  return [checkboxCol, ...tanstackColumns];
2417
2613
  }, [enableRowSelection, tanstackColumns]);
2418
- const visibilityDefaults = React8.useMemo(() => {
2419
- const v = {};
2420
- for (const c of columns) {
2421
- if (c.initiallyHidden) v[c.field] = false;
2422
- }
2423
- return v;
2424
- }, [columns]);
2425
- const columnVisibility = React8.useMemo(
2426
- () => ({ ...visibilityDefaults, ...slice.columnVisibility }),
2427
- [visibilityDefaults, slice.columnVisibility]
2614
+ const columnVisibility = React9.useMemo(
2615
+ () => resolveColumnVisibility(columns, slice.columnVisibility),
2616
+ [columns, slice.columnVisibility]
2428
2617
  );
2429
- const resizableFields = React8.useMemo(() => {
2618
+ const exportStateRef = React9.useRef({
2619
+ columns,
2620
+ columnVisibility,
2621
+ selection,
2622
+ fetchData,
2623
+ externalFilter,
2624
+ sort,
2625
+ filteredData,
2626
+ isApi,
2627
+ getRowId
2628
+ });
2629
+ exportStateRef.current = {
2630
+ columns,
2631
+ columnVisibility,
2632
+ selection,
2633
+ fetchData,
2634
+ externalFilter,
2635
+ sort,
2636
+ filteredData,
2637
+ isApi,
2638
+ getRowId
2639
+ };
2640
+ React9.useEffect(() => {
2641
+ registerExportSource(fullId, {
2642
+ sheetName: id,
2643
+ getColumns: () => {
2644
+ const state = exportStateRef.current;
2645
+ return toExportColumns(
2646
+ state.columns,
2647
+ (field) => isColumnVisible(state.columnVisibility, field)
2648
+ );
2649
+ },
2650
+ getRows: async () => {
2651
+ const state = exportStateRef.current;
2652
+ let all;
2653
+ if (state.isApi && state.fetchData) {
2654
+ all = await fetchAllRows({
2655
+ fetchData: state.fetchData,
2656
+ filter: mergeFilters(
2657
+ state.externalFilter,
2658
+ lastSnapshotRef.current?.query
2659
+ ),
2660
+ sort: state.sort
2661
+ }) ?? [];
2662
+ } else {
2663
+ all = sortLocalRows(state.filteredData ?? [], state.columns, state.sort);
2664
+ }
2665
+ return applySelection(all, state.selection, state.getRowId);
2666
+ }
2667
+ });
2668
+ return () => unregisterExportSource(fullId);
2669
+ }, [fullId, id]);
2670
+ const resizableFields = React9.useMemo(() => {
2430
2671
  const s = /* @__PURE__ */ new Set();
2431
2672
  for (const c of columns) if (c.resizable) s.add(c.field);
2432
2673
  return s;
2433
2674
  }, [columns]);
2434
2675
  const columnSizing = slice.columnSizing;
2435
- const rowSelection = React8.useMemo(() => {
2676
+ const rowSelection = React9.useMemo(() => {
2436
2677
  if (selection.scope === "all") return {};
2437
2678
  const r = {};
2438
2679
  for (const id2 of Object.keys(selection.ids)) r[id2] = true;
@@ -2480,13 +2721,21 @@ function EasyVisionTable(props) {
2480
2721
  getCoreRowModel: reactTable.getCoreRowModel(),
2481
2722
  manualPagination: true,
2482
2723
  manualSorting: true,
2724
+ // TanStack picks the first sort direction per column by sniffing row 0 of
2725
+ // the *current* page (`getAutoSortDir`: string → asc, anything else → desc).
2726
+ // With server-side data that row changes between clicks, so the asc/desc/off
2727
+ // cycle collapses — e.g. a nullable date column whose page-1 ASC result leads
2728
+ // with a null row flips firstSortDir to 'desc' and the next click removes the
2729
+ // sort instead of going descending. Pin it so the cycle is always off → asc
2730
+ // → desc → off, on every page.
2731
+ sortDescFirst: false,
2483
2732
  enableColumnResizing: true,
2484
2733
  columnResizeMode: "onChange",
2485
2734
  pageCount: Math.ceil(totalCount / itemsPerPage),
2486
2735
  getRowId
2487
2736
  });
2488
- const lastSelectionEmittedRef = React8.useRef("");
2489
- React8.useEffect(() => {
2737
+ const lastSelectionEmittedRef = React9.useRef("");
2738
+ React9.useEffect(() => {
2490
2739
  if (!enableRowSelection) return;
2491
2740
  if (isEagerWildcard && (isResolvingEager || eagerAllIds === null)) return;
2492
2741
  let event;
@@ -2568,11 +2817,11 @@ function EasyVisionTable(props) {
2568
2817
  isResolvingEager,
2569
2818
  isEagerWildcard
2570
2819
  ]);
2571
- const rowIdOf = React8.useCallback(
2820
+ const rowIdOf = React9.useCallback(
2572
2821
  (row) => getRowId(row),
2573
2822
  [getRowId]
2574
2823
  );
2575
- const headerState = React8.useMemo(() => {
2824
+ const headerState = React9.useMemo(() => {
2576
2825
  if (selection.scope === "all") {
2577
2826
  const except = Object.keys(selection.exceptIds ?? {}).length;
2578
2827
  if (except === 0) return "checked";
@@ -2588,7 +2837,7 @@ function EasyVisionTable(props) {
2588
2837
  if (selectedOnPage === visibleIds.length) return "checked";
2589
2838
  return "indeterminate";
2590
2839
  }, [selection, rows, rowIdOf]);
2591
- const onHeaderToggle = React8.useCallback(
2840
+ const onHeaderToggle = React9.useCallback(
2592
2841
  (checked) => {
2593
2842
  if (selection.scope === "all") {
2594
2843
  if (checked) {
@@ -2614,7 +2863,7 @@ function EasyVisionTable(props) {
2614
2863
  },
2615
2864
  [patch, selection, rows, rowIdOf]
2616
2865
  );
2617
- const onScopeChange = React8.useCallback(
2866
+ const onScopeChange = React9.useCallback(
2618
2867
  (scope) => {
2619
2868
  if (scope === "all") {
2620
2869
  patch({ selection: { ids: {}, scope: "all", exceptIds: {} } });
@@ -2633,8 +2882,8 @@ function EasyVisionTable(props) {
2633
2882
  },
2634
2883
  [patch, selectAllResolution, isApi, resolveEagerAll]
2635
2884
  );
2636
- const firstPerformAfterMountRef = React8.useRef(true);
2637
- const handlePerform = React8.useCallback(
2885
+ const firstPerformAfterMountRef = React9.useRef(true);
2886
+ const handlePerform = React9.useCallback(
2638
2887
  (snap) => {
2639
2888
  const isFirstAfterMount = firstPerformAfterMountRef.current;
2640
2889
  firstPerformAfterMountRef.current = false;
@@ -2654,8 +2903,8 @@ function EasyVisionTable(props) {
2654
2903
  [isApi, multifilter, patch, runFetch, selection.scope]
2655
2904
  );
2656
2905
  const totalPages = Math.max(1, Math.ceil(totalCount / itemsPerPage));
2657
- const hasResolvedDataRef = React8.useRef(false);
2658
- React8.useEffect(() => {
2906
+ const hasResolvedDataRef = React9.useRef(false);
2907
+ React9.useEffect(() => {
2659
2908
  if (isApi) {
2660
2909
  if (apiLoading) return;
2661
2910
  if (!hasResolvedDataRef.current) {
@@ -2668,7 +2917,7 @@ function EasyVisionTable(props) {
2668
2917
  }
2669
2918
  if (page > totalPages) patch({ page: totalPages });
2670
2919
  }, [page, totalPages, patch, isApi, apiLoading, apiTotalCount, apiRows.length]);
2671
- React8.useEffect(() => {
2920
+ React9.useEffect(() => {
2672
2921
  if (isApi) return;
2673
2922
  if (paginationMode === "page") return;
2674
2923
  if (page > 1 && page > Math.max(1, Math.ceil(totalCount / itemsPerPage))) {
@@ -2885,22 +3134,195 @@ function EasyVisionTable(props) {
2885
3134
  ] })
2886
3135
  ] }) });
2887
3136
  }
3137
+ var HEADER_FILL_ARGB = "FFCCCCCC";
3138
+ var MIN_COLUMN_WIDTH = 10;
3139
+ var COLUMN_WIDTH_PADDING = 2;
3140
+ var XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
3141
+ var INVALID_SHEET_CHARS = /[*?:\\/[\]]/g;
3142
+ var MAX_SHEET_NAME = 31;
3143
+ var FALLBACK_SHEET_NAME = "Hoja";
3144
+ var sanitizeSheetName = (name) => name.replace(INVALID_SHEET_CHARS, "-").substring(0, MAX_SHEET_NAME) || FALLBACK_SHEET_NAME;
3145
+ var uniqueSheetName = (raw, taken) => {
3146
+ const base = sanitizeSheetName(raw);
3147
+ if (!taken.has(base)) {
3148
+ taken.add(base);
3149
+ return base;
3150
+ }
3151
+ for (let n = 2; ; n++) {
3152
+ const suffix = `_${n}`;
3153
+ const candidate = base.substring(0, MAX_SHEET_NAME - suffix.length) + suffix;
3154
+ if (!taken.has(candidate)) {
3155
+ taken.add(candidate);
3156
+ return candidate;
3157
+ }
3158
+ }
3159
+ };
3160
+ var downloadBlob = (blob, filename) => {
3161
+ const url = URL.createObjectURL(blob);
3162
+ const anchor = document.createElement("a");
3163
+ anchor.href = url;
3164
+ anchor.download = filename;
3165
+ document.body.appendChild(anchor);
3166
+ anchor.click();
3167
+ anchor.remove();
3168
+ setTimeout(() => URL.revokeObjectURL(url), 0);
3169
+ };
3170
+ var autoFitColumns = (worksheet) => {
3171
+ worksheet.columns.forEach((column) => {
3172
+ let longest = 0;
3173
+ column.eachCell?.({ includeEmpty: false }, (cell) => {
3174
+ const length = cell.value instanceof Date ? cell.value.toISOString().length : cell.text.length;
3175
+ if (length > longest) longest = length;
3176
+ });
3177
+ column.width = Math.max(MIN_COLUMN_WIDTH, longest + COLUMN_WIDTH_PADDING);
3178
+ });
3179
+ };
3180
+ async function buildWorkbook(sheets) {
3181
+ const usable = sheets.filter(
3182
+ (sheet) => sheet.rows.length > 0 && sheet.columns.length > 0
3183
+ );
3184
+ if (usable.length === 0) return null;
3185
+ const workbook = new ExcelJS__default.default.Workbook();
3186
+ const takenNames = /* @__PURE__ */ new Set();
3187
+ for (const sheet of usable) {
3188
+ const worksheet = workbook.addWorksheet(uniqueSheetName(sheet.name, takenNames));
3189
+ const headerRow = worksheet.addRow(sheet.columns.map((c) => c.header));
3190
+ headerRow.eachCell((cell) => {
3191
+ cell.fill = {
3192
+ type: "pattern",
3193
+ pattern: "solid",
3194
+ fgColor: { argb: HEADER_FILL_ARGB }
3195
+ };
3196
+ cell.font = { bold: true };
3197
+ });
3198
+ for (const item of sheet.rows) {
3199
+ const values = sheet.columns.map((column) => column.getValue(item));
3200
+ const row = worksheet.addRow(values);
3201
+ sheet.columns.forEach((column, index) => {
3202
+ const style = column.getStyle?.(values[index], item);
3203
+ if (!style) return;
3204
+ const cell = row.getCell(index + 1);
3205
+ if (style.fill) {
3206
+ cell.fill = {
3207
+ type: "pattern",
3208
+ pattern: "solid",
3209
+ fgColor: { argb: style.fill }
3210
+ };
3211
+ }
3212
+ if (style.fontColor || style.bold) {
3213
+ cell.font = {
3214
+ bold: !!style.bold,
3215
+ ...style.fontColor ? { color: { argb: style.fontColor } } : {}
3216
+ };
3217
+ }
3218
+ });
3219
+ }
3220
+ autoFitColumns(worksheet);
3221
+ }
3222
+ return workbook;
3223
+ }
3224
+ async function exportSheets(sheets, options) {
3225
+ const workbook = await buildWorkbook(sheets);
3226
+ if (!workbook) return false;
3227
+ const buffer = await workbook.xlsx.writeBuffer();
3228
+ const blob = new Blob([buffer], { type: XLSX_MIME });
3229
+ const filename = `${options.filename}_${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`;
3230
+ (options.download ?? downloadBlob)(blob, filename);
3231
+ return true;
3232
+ }
3233
+ var DEFAULT_LABELS3 = {
3234
+ export: "Exportar",
3235
+ exporting: "Exportando..."
3236
+ };
3237
+ function EasyVisionExportButton({
3238
+ tables,
3239
+ filename,
3240
+ sheetNames,
3241
+ labels: labelOverrides,
3242
+ onError,
3243
+ onEmpty,
3244
+ disabled = false,
3245
+ className,
3246
+ icon
3247
+ }) {
3248
+ const labels = { ...DEFAULT_LABELS3, ...labelOverrides };
3249
+ const parentFullId = useParentFullId();
3250
+ const [isExporting, setIsExporting] = React9.useState(false);
3251
+ const handleClick = React9.useCallback(async () => {
3252
+ setIsExporting(true);
3253
+ try {
3254
+ const resolved = tables.map((tableId) => ({
3255
+ tableId,
3256
+ source: resolveExportSource(parentFullId, tableId)
3257
+ }));
3258
+ const unresolved = resolved.filter((r) => !r.source).map((r) => r.tableId);
3259
+ if (unresolved.length > 0 && unresolved.length < tables.length) {
3260
+ onError?.(
3261
+ new Error(
3262
+ `EasyVisionExportButton: could not resolve table id(s): ${unresolved.join(", ")}`
3263
+ )
3264
+ );
3265
+ return;
3266
+ }
3267
+ const sheets = [];
3268
+ for (const { tableId, source } of resolved) {
3269
+ if (!source) continue;
3270
+ const columns = source.getColumns();
3271
+ if (columns.length === 0) continue;
3272
+ sheets.push({
3273
+ name: sheetNames?.[tableId] ?? source.sheetName,
3274
+ columns,
3275
+ rows: await source.getRows()
3276
+ });
3277
+ }
3278
+ const written = await exportSheets(sheets, { filename });
3279
+ if (!written) onEmpty?.();
3280
+ } catch (error) {
3281
+ onError?.(error);
3282
+ } finally {
3283
+ setIsExporting(false);
3284
+ }
3285
+ }, [tables, parentFullId, sheetNames, filename, onEmpty, onError]);
3286
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3287
+ Button,
3288
+ {
3289
+ type: "button",
3290
+ variant: "outline",
3291
+ size: "sm",
3292
+ className,
3293
+ disabled: disabled || isExporting,
3294
+ onClick: handleClick,
3295
+ children: [
3296
+ isExporting ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "ev-export-icon animate-spin" }) : icon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "ev-export-icon" }),
3297
+ isExporting ? labels.exporting : labels.export
3298
+ ]
3299
+ }
3300
+ );
3301
+ }
2888
3302
  var defaultCell = (content, title) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-foreground", title, children: content });
2889
3303
 
3304
+ exports.EasyVisionAccordion = EasyVisionAccordion;
3305
+ exports.EasyVisionAccordionItem = EasyVisionAccordionItem;
2890
3306
  exports.EasyVisionCard = EasyVisionCard;
2891
3307
  exports.EasyVisionCardContent = EasyVisionCardContent;
2892
3308
  exports.EasyVisionCardDescription = EasyVisionCardDescription;
2893
3309
  exports.EasyVisionCardFooter = EasyVisionCardFooter;
2894
3310
  exports.EasyVisionCardHeader = EasyVisionCardHeader;
2895
3311
  exports.EasyVisionCardTitle = EasyVisionCardTitle;
3312
+ exports.EasyVisionExportButton = EasyVisionExportButton;
2896
3313
  exports.EasyVisionInput = EasyVisionInput;
2897
3314
  exports.EasyVisionMultifilter = EasyVisionMultifilter;
2898
3315
  exports.EasyVisionSelector = EasyVisionSelector;
2899
3316
  exports.EasyVisionTable = EasyVisionTable;
3317
+ exports.buildWorkbook = buildWorkbook;
2900
3318
  exports.createLoopbackTableFetcher = createLoopbackTableFetcher;
2901
3319
  exports.defaultCell = defaultCell;
3320
+ exports.downloadBlob = downloadBlob;
2902
3321
  exports.easyVisionRegistry = easyVisionRegistry;
3322
+ exports.exportSheets = exportSheets;
2903
3323
  exports.getSlice = getSlice;
2904
3324
  exports.matchLoopbackWhere = matchLoopbackWhere;
3325
+ exports.sanitizeSheetName = sanitizeSheetName;
3326
+ exports.toExportColumns = toExportColumns;
2905
3327
  //# sourceMappingURL=index.cjs.map
2906
3328
  //# sourceMappingURL=index.cjs.map