@economic/taco 2.63.2-combobox-search.0 → 2.64.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/taco.d.ts CHANGED
@@ -3043,7 +3043,7 @@ export declare interface Table3CommonProps<TType = unknown> extends Table3Featur
3043
3043
 
3044
3044
  export declare type Table3EditingChangeHandler<TType = unknown> = (accessor: string, value: unknown, row: TType, prevRow: TType) => Promise<Partial<TType>> | undefined;
3045
3045
 
3046
- export declare type Table3EditingCreateHandler<TType = unknown> = () => Partial<TType>;
3046
+ export declare type Table3EditingCreateHandler<TType = unknown> = () => Promise<Partial<TType>>;
3047
3047
 
3048
3048
  declare type Table3EditingDiscardHandler = () => void;
3049
3049
 
@@ -3998,7 +3998,7 @@ export declare type useTableDataAllFetcher2<TType = unknown> = (sorting: TableCo
3998
3998
 
3999
3999
  export declare function useTableDataLoader<TType = unknown>(fetchPage: useTableDataPageFetcher<TType>, fetchAll: useTableDataAllFetcher<TType>, options?: useTableDataLoaderOptions): [useTableDataLoaderValues<TType>, () => void];
4000
4000
 
4001
- export declare function useTableDataLoader2<TType = unknown>(fetchPage: useTableDataPageFetcher2<TType>, fetchAll: useTableDataAllFetcher2<TType>, options?: useTableDataLoaderOptions): [useTableDataLoaderValues2<TType>, () => void];
4001
+ export declare function useTableDataLoader2<TType = unknown>(fetchPage: useTableDataPageFetcher2<TType>, fetchAll: useTableDataAllFetcher2<TType>, options?: useTableDataLoaderOptions): [useTableDataLoaderValues2<TType>, () => Promise<void>];
4002
4002
 
4003
4003
  export declare type useTableDataLoaderOptions = {
4004
4004
  pageSize: number;
package/dist/taco.js CHANGED
@@ -5378,12 +5378,31 @@ const Cancel = React.forwardRef(function AlertDialogCancel(props, ref) {
5378
5378
  const Action$1 = React.forwardRef(function AlertDialogAction(props, ref) {
5379
5379
  return /* @__PURE__ */ React.createElement($905f4ae918aab1aa$export$e19cd5f9376f8cee, { ...props, className: props.className, ref, asChild: true });
5380
5380
  });
5381
- const Backdrop = React.forwardRef(function Backdrop2(props, ref) {
5381
+ const useMergedRef = (ref) => {
5382
+ const internalRef = React__default.useRef(null);
5383
+ React__default.useEffect(() => {
5384
+ if (ref) {
5385
+ if (typeof ref === "function") {
5386
+ ref(internalRef.current);
5387
+ } else {
5388
+ ref.current = internalRef.current;
5389
+ }
5390
+ }
5391
+ }, [ref]);
5392
+ return internalRef;
5393
+ };
5394
+ const Backdrop = React.forwardRef(function Backdrop2(props, forwardedRef) {
5395
+ const ref = useMergedRef(forwardedRef);
5382
5396
  const className = clsx(
5383
5397
  "fixed inset-0 cursor-default overflow-y-auto bg-blue-900/[0.3] aria-hidden:invisible print:overflow-visible print:absolute",
5384
5398
  props.className
5385
5399
  );
5386
- return /* @__PURE__ */ React.createElement("div", { ...props, className, "data-taco": "backdrop", ref });
5400
+ const onPointerDown = (event) => {
5401
+ if (event.target === ref.current) {
5402
+ event.preventDefault();
5403
+ }
5404
+ };
5405
+ return /* @__PURE__ */ React.createElement("div", { ...props, className, onPointerDown, "data-taco": "backdrop", ref });
5387
5406
  });
5388
5407
  const getDialogSizeClassnames = (size2) => {
5389
5408
  switch (size2) {
@@ -9741,19 +9760,6 @@ const getBannerIcon = (type) => {
9741
9760
  }
9742
9761
  })());
9743
9762
  };
9744
- const useMergedRef = (ref) => {
9745
- const internalRef = React__default.useRef(null);
9746
- React__default.useEffect(() => {
9747
- if (ref) {
9748
- if (typeof ref === "function") {
9749
- ref(internalRef.current);
9750
- } else {
9751
- ref.current = internalRef.current;
9752
- }
9753
- }
9754
- }, [ref]);
9755
- return internalRef;
9756
- };
9757
9763
  const FOCUSABLE_ELEMENTS = [
9758
9764
  '[tabindex]:not([tabindex="-1"]):not([disabled])',
9759
9765
  "input:not([disabled])",
@@ -18368,7 +18374,7 @@ const filterData = (data, value = "") => {
18368
18374
  if (value === "" || value === null) {
18369
18375
  return data;
18370
18376
  }
18371
- const filteredOptions = [];
18377
+ const filteredOptionValues = /* @__PURE__ */ new Set();
18372
18378
  const shouldFilterOption = (option) => {
18373
18379
  if (option.disabled) {
18374
18380
  return false;
@@ -18378,22 +18384,13 @@ const filterData = (data, value = "") => {
18378
18384
  data.forEach((option) => {
18379
18385
  if (shouldFilterOption(option)) {
18380
18386
  const parents = getOptionParents(data, option.path);
18381
- const index2 = option.text.toString().toLocaleLowerCase().indexOf(value.toString().toLocaleLowerCase());
18382
- filteredOptions.push({ value: option.value, score: index2 });
18387
+ filteredOptionValues.add(option.value);
18383
18388
  if (parents !== null) {
18384
- parents.forEach((option2) => filteredOptions.push({ value: option2 == null ? void 0 : option2.value }));
18389
+ parents.forEach((option2) => filteredOptionValues.add(option2 == null ? void 0 : option2.value));
18385
18390
  }
18386
18391
  }
18387
18392
  });
18388
- return data.filter(({ value: value2 }) => filteredOptions.find((x2) => x2.value === value2)).toSorted((a2, b2) => {
18389
- var _a, _b;
18390
- const scoreA = (_a = filteredOptions.find((x2) => x2.value === a2.value)) == null ? void 0 : _a.score;
18391
- const scoreB = (_b = filteredOptions.find((x2) => x2.value === b2.value)) == null ? void 0 : _b.score;
18392
- if (scoreA !== void 0 && scoreB !== void 0) {
18393
- return scoreA - scoreB;
18394
- }
18395
- return 0;
18396
- });
18393
+ return data.filter(({ value: value2 }) => filteredOptionValues.has(value2));
18397
18394
  };
18398
18395
  const debouncer = debounce$1((f2) => f2(), 200);
18399
18396
  const convertToInputValue = (value) => String(value ?? "");
@@ -18954,6 +18951,9 @@ const Datepicker = React.forwardRef(function Datepicker2(props, ref) {
18954
18951
  const { texts } = useLocalization();
18955
18952
  const className = clsx("inline-flex w-full text-black font-normal", externalClassName);
18956
18953
  const popoverContentRef = React.useRef(null);
18954
+ const handlePopoverClick = React.useCallback((event) => {
18955
+ event.stopPropagation();
18956
+ }, []);
18957
18957
  const handleOpenAutofocus = React.useCallback(
18958
18958
  (e3) => {
18959
18959
  var _a;
@@ -19000,7 +19000,8 @@ const Datepicker = React.forwardRef(function Datepicker2(props, ref) {
19000
19000
  "div",
19001
19001
  {
19002
19002
  className: '[&_button[name="day"]:focus]:yt-focus -m-3 flex',
19003
- ref: popoverContentRef
19003
+ ref: popoverContentRef,
19004
+ onClick: handlePopoverClick
19004
19005
  },
19005
19006
  /* @__PURE__ */ React.createElement(
19006
19007
  Calendar,
@@ -29699,6 +29700,7 @@ const Content$2 = React.forwardRef(function MenuContent(props, ref) {
29699
29700
  align,
29700
29701
  className,
29701
29702
  "data-taco": "menu",
29703
+ hideWhenDetached: true,
29702
29704
  side,
29703
29705
  sideOffset: 3,
29704
29706
  style: { minWidth: menu == null ? void 0 : menu.minWidth },
@@ -38171,7 +38173,7 @@ function Header$2(context) {
38171
38173
  tableMeta.search.enableGlobalFilter ? table.getState().globalFilter : void 0
38172
38174
  );
38173
38175
  }
38174
- table.toggleAllRowsSelected(checked);
38176
+ setTimeout(() => table.toggleAllRowsSelected(checked), 1);
38175
38177
  };
38176
38178
  return /* @__PURE__ */ React__default.createElement(Tooltip$3, { title }, /* @__PURE__ */ React__default.createElement(
38177
38179
  Checkbox$2,
@@ -39126,7 +39128,9 @@ function Body(props) {
39126
39128
  const focusManager = useAugmentedFocusManager();
39127
39129
  const tableMeta = table.options.meta;
39128
39130
  const handleKeyDown = (event) => {
39129
- if (event.isDefaultPrevented() || event.isPropagationStopped()) {
39131
+ var _a;
39132
+ const isEventTriggeredInsideTable = ((_a = event.target) == null ? void 0 : _a.closest("tbody")) === ref.current;
39133
+ if (event.isDefaultPrevented() || event.isPropagationStopped() || !isEventTriggeredInsideTable) {
39130
39134
  return;
39131
39135
  }
39132
39136
  if (tableMeta.rowActive.rowActiveIndex !== void 0) {
@@ -39296,20 +39300,14 @@ const MemoedFooter = React__default.memo(function MemoedFooter2(props) {
39296
39300
  );
39297
39301
  });
39298
39302
  function EmptyStateBody(props) {
39299
- var _a, _b;
39303
+ var _a;
39300
39304
  const { emptyState: Placeholder2, isReady, reason, ...attributes } = props;
39301
39305
  const ref = React__default.useRef(null);
39306
+ const rect = useBoundingClientRectListener({ current: (_a = ref.current) == null ? void 0 : _a.parentNode });
39302
39307
  if (!isReady) {
39303
39308
  return /* @__PURE__ */ React__default.createElement("tbody", { ...attributes, className: "!auto-rows-fr" });
39304
39309
  }
39305
- return /* @__PURE__ */ React__default.createElement("tbody", { ...attributes, ref, className: "!auto-rows-fr", "data-taco": "empty-state" }, /* @__PURE__ */ React__default.createElement("tr", { className: "!auto-rows-fr " }, /* @__PURE__ */ React__default.createElement(
39306
- "td",
39307
- {
39308
- style: { maxWidth: (_b = (_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.clientWidth },
39309
- className: "col-span-full !border-0 !p-0 hover:!bg-white"
39310
- },
39311
- Placeholder2 ? /* @__PURE__ */ React__default.createElement(Placeholder2, { reason }) : void 0
39312
- )));
39310
+ return /* @__PURE__ */ React__default.createElement("tbody", { ...attributes, ref, className: "!auto-rows-fr", "data-taco": "empty-state" }, /* @__PURE__ */ React__default.createElement("tr", { className: "!auto-rows-fr" }, /* @__PURE__ */ React__default.createElement("td", { style: { maxWidth: rect == null ? void 0 : rect.width }, className: "col-span-full !border-0 !p-0 hover:!bg-white" }, Placeholder2 ? /* @__PURE__ */ React__default.createElement(Placeholder2, { reason }) : void 0)));
39313
39311
  }
39314
39312
  const SearchInput22 = React__default.forwardRef(function SearchInput222(props, ref) {
39315
39313
  const {
@@ -42936,67 +42934,6 @@ function useDroppable(_ref) {
42936
42934
  setNodeRef
42937
42935
  };
42938
42936
  }
42939
- const restrictToVerticalAxis = (_ref) => {
42940
- let {
42941
- transform
42942
- } = _ref;
42943
- return {
42944
- ...transform,
42945
- x: 0
42946
- };
42947
- };
42948
- function getContainerById(children, id2) {
42949
- var _a;
42950
- const lists = React__default.Children.toArray(children).filter(
42951
- (child) => child.type.displayName === "SortableList"
42952
- );
42953
- const list = lists.find(
42954
- (list2) => list2.props.id === id2
42955
- );
42956
- if (list) {
42957
- return list == null ? void 0 : list.props;
42958
- }
42959
- return (_a = lists.find((l2) => React__default.Children.toArray(l2.props.children).findIndex((child) => child.props.id === id2) > -1)) == null ? void 0 : _a.props;
42960
- }
42961
- function Container$1(externalProps) {
42962
- const { children, reorder, move } = externalProps;
42963
- function handleDragOver(event) {
42964
- const { active, over } = event;
42965
- if (!(active == null ? void 0 : active.id) || !(over == null ? void 0 : over.id)) {
42966
- return;
42967
- }
42968
- const activeList = getContainerById(children, active.id);
42969
- const overList = getContainerById(children, over.id);
42970
- if (!(activeList == null ? void 0 : activeList.id) || !(overList == null ? void 0 : overList.id) || activeList.id === overList.id) {
42971
- return;
42972
- }
42973
- move(active.id, activeList == null ? void 0 : activeList.id, overList.id);
42974
- }
42975
- function handleDragEnd(event) {
42976
- const { active, over } = event;
42977
- if (!(active == null ? void 0 : active.id) || !(over == null ? void 0 : over.id)) {
42978
- return;
42979
- }
42980
- const activeList = getContainerById(children, active.id);
42981
- const overList = getContainerById(children, over.id);
42982
- if (!(activeList == null ? void 0 : activeList.id) || !(overList == null ? void 0 : overList.id) || activeList.id !== overList.id) {
42983
- return;
42984
- }
42985
- reorder(active.id, over.id, overList.id);
42986
- }
42987
- return /* @__PURE__ */ React__default.createElement(
42988
- DndContext,
42989
- {
42990
- collisionDetection: closestCenter,
42991
- ...externalProps,
42992
- modifiers: [restrictToVerticalAxis],
42993
- onDragOver: handleDragOver,
42994
- onDragEnd: handleDragEnd
42995
- },
42996
- children
42997
- );
42998
- }
42999
- Container$1.displayName = "SortableContainer";
43000
42937
  function arrayMove(array2, from, to) {
43001
42938
  const newArray = array2.slice();
43002
42939
  newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
@@ -43465,6 +43402,74 @@ function normalizeLocalDisabled(localDisabled, globalDisabled) {
43465
43402
  };
43466
43403
  }
43467
43404
  [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];
43405
+ function List(externalProps) {
43406
+ const { children, id: id2, ...props } = externalProps;
43407
+ const { setNodeRef } = useDroppable({ id: id2 });
43408
+ const items = React__default.Children.toArray(children).map((child) => child.props);
43409
+ return /* @__PURE__ */ React__default.createElement(SortableContext, { id: id2, items, strategy: verticalListSortingStrategy }, /* @__PURE__ */ React__default.createElement("div", { ...props, ref: id2 ? setNodeRef : void 0 }, children));
43410
+ }
43411
+ List.displayName = "SortableList";
43412
+ const restrictToVerticalAxis = (_ref) => {
43413
+ let {
43414
+ transform
43415
+ } = _ref;
43416
+ return {
43417
+ ...transform,
43418
+ x: 0
43419
+ };
43420
+ };
43421
+ function getContainerById(children, id2) {
43422
+ var _a;
43423
+ const lists = React__default.Children.toArray(children).filter(
43424
+ (child) => child.type === List
43425
+ );
43426
+ const list = lists.find(
43427
+ (list2) => list2.props.id === id2
43428
+ );
43429
+ if (list) {
43430
+ return list == null ? void 0 : list.props;
43431
+ }
43432
+ return (_a = lists.find((l2) => React__default.Children.toArray(l2.props.children).findIndex((child) => child.props.id === id2) > -1)) == null ? void 0 : _a.props;
43433
+ }
43434
+ function Container$1(externalProps) {
43435
+ const { children, reorder, move } = externalProps;
43436
+ function handleDragOver(event) {
43437
+ const { active, over } = event;
43438
+ if (!(active == null ? void 0 : active.id) || !(over == null ? void 0 : over.id)) {
43439
+ return;
43440
+ }
43441
+ const activeList = getContainerById(children, active.id);
43442
+ const overList = getContainerById(children, over.id);
43443
+ if (!(activeList == null ? void 0 : activeList.id) || !(overList == null ? void 0 : overList.id) || activeList.id === overList.id) {
43444
+ return;
43445
+ }
43446
+ move == null ? void 0 : move(active.id, activeList.id, overList.id);
43447
+ }
43448
+ function handleDragEnd(event) {
43449
+ const { active, over } = event;
43450
+ if (!(active == null ? void 0 : active.id) || !(over == null ? void 0 : over.id)) {
43451
+ return;
43452
+ }
43453
+ const activeList = getContainerById(children, active.id);
43454
+ const overList = getContainerById(children, over.id);
43455
+ if (!(activeList == null ? void 0 : activeList.id) || !(overList == null ? void 0 : overList.id) || activeList.id !== overList.id) {
43456
+ return;
43457
+ }
43458
+ reorder(active.id, over.id, overList.id);
43459
+ }
43460
+ return /* @__PURE__ */ React__default.createElement(
43461
+ DndContext,
43462
+ {
43463
+ collisionDetection: closestCenter,
43464
+ ...externalProps,
43465
+ modifiers: [restrictToVerticalAxis],
43466
+ onDragOver: handleDragOver,
43467
+ onDragEnd: handleDragEnd
43468
+ },
43469
+ children
43470
+ );
43471
+ }
43472
+ Container$1.displayName = "SortableContainer";
43468
43473
  const isFormElement = (element) => {
43469
43474
  const formElementNodeNames = ["BUTTON", "INPUT", "TEXTAREA", "SELECT", "FIELDSET"];
43470
43475
  return formElementNodeNames.includes(element.nodeName);
@@ -43488,13 +43493,6 @@ function Item(props) {
43488
43493
  return /* @__PURE__ */ React__default.createElement("div", { ...elProps }, children);
43489
43494
  }
43490
43495
  Item.displayName = "SortableListItem";
43491
- function List(externalProps) {
43492
- const { children, id: id2, ...props } = externalProps;
43493
- const { setNodeRef } = useDroppable({ id: id2 });
43494
- const items = React__default.Children.toArray(children).map((child) => child.props);
43495
- return /* @__PURE__ */ React__default.createElement(SortableContext, { id: id2, items, strategy: verticalListSortingStrategy }, /* @__PURE__ */ React__default.createElement("div", { ...props, ref: id2 ? setNodeRef : void 0 }, children));
43496
- }
43497
- List.displayName = "SortableList";
43498
43496
  const Column$3 = React__default.forwardRef(function Column2(props, ref) {
43499
43497
  var _a, _b, _c;
43500
43498
  const { column, draggable = false, ...dragAttributes } = props;
@@ -45399,6 +45397,7 @@ function ManageFiltersPopover(props) {
45399
45397
  const { locale: locale2, texts } = useLocalization();
45400
45398
  const allColumns = table.getAllLeafColumns().filter((column) => !isInternalColumn(column.id)).sort(sortByHeader);
45401
45399
  const columnFilters = table.getState().columnFilters;
45400
+ const tableMeta = table.options.meta;
45402
45401
  const [filters, setFilters] = React__default.useState(columnFilters.length ? columnFilters : [placeholderFilter]);
45403
45402
  React__default.useEffect(() => {
45404
45403
  setFilters(columnFilters.length === 0 ? [placeholderFilter] : columnFilters);
@@ -45458,7 +45457,9 @@ function ManageFiltersPopover(props) {
45458
45457
  };
45459
45458
  return /* @__PURE__ */ React__default.createElement(Popover, { ...popoverProps, onChange: handleClose }, /* @__PURE__ */ React__default.createElement(Popover.Content, null, /* @__PURE__ */ React__default.createElement(FilterContext.Provider, { value: filters }, /* @__PURE__ */ React__default.createElement("div", { className: "flex w-[40rem] flex-col gap-4" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex h-8" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex w-full items-center gap-2" }, /* @__PURE__ */ React__default.createElement("h4", { className: "mb-0 inline-flex" }, texts.table.filters.button), /* @__PURE__ */ React__default.createElement("p", { className: "text-grey-700 mb-0 mr-auto mt-px inline-flex" }, texts.table.filters.total.replace(
45460
45459
  "[CURRENT]",
45461
- new Intl.NumberFormat(locale2).format(table.getFilteredRowModel().rows.length)
45460
+ new Intl.NumberFormat(locale2).format(
45461
+ tableMeta.server._experimentalDataLoader2 ? length : table.getFilteredRowModel().rows.length
45462
+ )
45462
45463
  ).replace("[TOTAL]", new Intl.NumberFormat(locale2).format(length))))), /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col gap-2" }, filters.map((filter2, index2) => /* @__PURE__ */ React__default.createElement(
45463
45464
  Filter,
45464
45465
  {
@@ -55509,7 +55510,7 @@ function useTableEditing(isEnabled = false, defaultToggleEditing = false, handle
55509
55510
  return;
55510
55511
  }
55511
55512
  }
55512
- const changeset = row ?? handleCreate();
55513
+ const changeset = row ?? await handleCreate();
55513
55514
  try {
55514
55515
  if (changeset) {
55515
55516
  const temporaryRows = tableMeta.editing.temporaryRows;