@economic/taco 2.63.2-combobox-search-no-sorting.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.cjs CHANGED
@@ -5396,12 +5396,31 @@ const Cancel = React__namespace.forwardRef(function AlertDialogCancel(props, ref
5396
5396
  const Action$1 = React__namespace.forwardRef(function AlertDialogAction(props, ref) {
5397
5397
  return /* @__PURE__ */ React__namespace.createElement($905f4ae918aab1aa$export$e19cd5f9376f8cee, { ...props, className: props.className, ref, asChild: true });
5398
5398
  });
5399
- const Backdrop = React__namespace.forwardRef(function Backdrop2(props, ref) {
5399
+ const useMergedRef = (ref) => {
5400
+ const internalRef = React.useRef(null);
5401
+ React.useEffect(() => {
5402
+ if (ref) {
5403
+ if (typeof ref === "function") {
5404
+ ref(internalRef.current);
5405
+ } else {
5406
+ ref.current = internalRef.current;
5407
+ }
5408
+ }
5409
+ }, [ref]);
5410
+ return internalRef;
5411
+ };
5412
+ const Backdrop = React__namespace.forwardRef(function Backdrop2(props, forwardedRef) {
5413
+ const ref = useMergedRef(forwardedRef);
5400
5414
  const className = clsx(
5401
5415
  "fixed inset-0 cursor-default overflow-y-auto bg-blue-900/[0.3] aria-hidden:invisible print:overflow-visible print:absolute",
5402
5416
  props.className
5403
5417
  );
5404
- return /* @__PURE__ */ React__namespace.createElement("div", { ...props, className, "data-taco": "backdrop", ref });
5418
+ const onPointerDown = (event) => {
5419
+ if (event.target === ref.current) {
5420
+ event.preventDefault();
5421
+ }
5422
+ };
5423
+ return /* @__PURE__ */ React__namespace.createElement("div", { ...props, className, onPointerDown, "data-taco": "backdrop", ref });
5405
5424
  });
5406
5425
  const getDialogSizeClassnames = (size2) => {
5407
5426
  switch (size2) {
@@ -9759,19 +9778,6 @@ const getBannerIcon = (type) => {
9759
9778
  }
9760
9779
  })());
9761
9780
  };
9762
- const useMergedRef = (ref) => {
9763
- const internalRef = React.useRef(null);
9764
- React.useEffect(() => {
9765
- if (ref) {
9766
- if (typeof ref === "function") {
9767
- ref(internalRef.current);
9768
- } else {
9769
- ref.current = internalRef.current;
9770
- }
9771
- }
9772
- }, [ref]);
9773
- return internalRef;
9774
- };
9775
9781
  const FOCUSABLE_ELEMENTS = [
9776
9782
  '[tabindex]:not([tabindex="-1"]):not([disabled])',
9777
9783
  "input:not([disabled])",
@@ -18479,7 +18485,7 @@ const useCombobox = (props, ref) => {
18479
18485
  React__namespace.useEffect(() => {
18480
18486
  const isCurrentValue = value !== void 0 && value !== null && inputValue === String(value);
18481
18487
  if (inputValue && data.length && !isCurrentValue) {
18482
- setCurrentIndex(getIndexFromValue(data, inputValue) || 0);
18488
+ setCurrentIndex(0);
18483
18489
  if (!open) {
18484
18490
  setOpen(true);
18485
18491
  }
@@ -18963,6 +18969,9 @@ const Datepicker = React__namespace.forwardRef(function Datepicker2(props, ref)
18963
18969
  const { texts } = useLocalization();
18964
18970
  const className = clsx("inline-flex w-full text-black font-normal", externalClassName);
18965
18971
  const popoverContentRef = React__namespace.useRef(null);
18972
+ const handlePopoverClick = React__namespace.useCallback((event) => {
18973
+ event.stopPropagation();
18974
+ }, []);
18966
18975
  const handleOpenAutofocus = React__namespace.useCallback(
18967
18976
  (e3) => {
18968
18977
  var _a;
@@ -19009,7 +19018,8 @@ const Datepicker = React__namespace.forwardRef(function Datepicker2(props, ref)
19009
19018
  "div",
19010
19019
  {
19011
19020
  className: '[&_button[name="day"]:focus]:yt-focus -m-3 flex',
19012
- ref: popoverContentRef
19021
+ ref: popoverContentRef,
19022
+ onClick: handlePopoverClick
19013
19023
  },
19014
19024
  /* @__PURE__ */ React__namespace.createElement(
19015
19025
  Calendar,
@@ -29708,6 +29718,7 @@ const Content$2 = React__namespace.forwardRef(function MenuContent(props, ref) {
29708
29718
  align,
29709
29719
  className,
29710
29720
  "data-taco": "menu",
29721
+ hideWhenDetached: true,
29711
29722
  side,
29712
29723
  sideOffset: 3,
29713
29724
  style: { minWidth: menu == null ? void 0 : menu.minWidth },
@@ -38180,7 +38191,7 @@ function Header$2(context) {
38180
38191
  tableMeta.search.enableGlobalFilter ? table.getState().globalFilter : void 0
38181
38192
  );
38182
38193
  }
38183
- table.toggleAllRowsSelected(checked);
38194
+ setTimeout(() => table.toggleAllRowsSelected(checked), 1);
38184
38195
  };
38185
38196
  return /* @__PURE__ */ React.createElement(Tooltip$3, { title }, /* @__PURE__ */ React.createElement(
38186
38197
  Checkbox$2,
@@ -39135,7 +39146,9 @@ function Body(props) {
39135
39146
  const focusManager = useAugmentedFocusManager();
39136
39147
  const tableMeta = table.options.meta;
39137
39148
  const handleKeyDown = (event) => {
39138
- if (event.isDefaultPrevented() || event.isPropagationStopped()) {
39149
+ var _a;
39150
+ const isEventTriggeredInsideTable = ((_a = event.target) == null ? void 0 : _a.closest("tbody")) === ref.current;
39151
+ if (event.isDefaultPrevented() || event.isPropagationStopped() || !isEventTriggeredInsideTable) {
39139
39152
  return;
39140
39153
  }
39141
39154
  if (tableMeta.rowActive.rowActiveIndex !== void 0) {
@@ -39305,20 +39318,14 @@ const MemoedFooter = React.memo(function MemoedFooter2(props) {
39305
39318
  );
39306
39319
  });
39307
39320
  function EmptyStateBody(props) {
39308
- var _a, _b;
39321
+ var _a;
39309
39322
  const { emptyState: Placeholder2, isReady, reason, ...attributes } = props;
39310
39323
  const ref = React.useRef(null);
39324
+ const rect = useBoundingClientRectListener({ current: (_a = ref.current) == null ? void 0 : _a.parentNode });
39311
39325
  if (!isReady) {
39312
39326
  return /* @__PURE__ */ React.createElement("tbody", { ...attributes, className: "!auto-rows-fr" });
39313
39327
  }
39314
- return /* @__PURE__ */ React.createElement("tbody", { ...attributes, ref, className: "!auto-rows-fr", "data-taco": "empty-state" }, /* @__PURE__ */ React.createElement("tr", { className: "!auto-rows-fr " }, /* @__PURE__ */ React.createElement(
39315
- "td",
39316
- {
39317
- style: { maxWidth: (_b = (_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.clientWidth },
39318
- className: "col-span-full !border-0 !p-0 hover:!bg-white"
39319
- },
39320
- Placeholder2 ? /* @__PURE__ */ React.createElement(Placeholder2, { reason }) : void 0
39321
- )));
39328
+ return /* @__PURE__ */ React.createElement("tbody", { ...attributes, ref, className: "!auto-rows-fr", "data-taco": "empty-state" }, /* @__PURE__ */ React.createElement("tr", { className: "!auto-rows-fr" }, /* @__PURE__ */ React.createElement("td", { style: { maxWidth: rect == null ? void 0 : rect.width }, className: "col-span-full !border-0 !p-0 hover:!bg-white" }, Placeholder2 ? /* @__PURE__ */ React.createElement(Placeholder2, { reason }) : void 0)));
39322
39329
  }
39323
39330
  const SearchInput22 = React.forwardRef(function SearchInput222(props, ref) {
39324
39331
  const {
@@ -42945,67 +42952,6 @@ function useDroppable(_ref) {
42945
42952
  setNodeRef
42946
42953
  };
42947
42954
  }
42948
- const restrictToVerticalAxis = (_ref) => {
42949
- let {
42950
- transform
42951
- } = _ref;
42952
- return {
42953
- ...transform,
42954
- x: 0
42955
- };
42956
- };
42957
- function getContainerById(children, id2) {
42958
- var _a;
42959
- const lists = React.Children.toArray(children).filter(
42960
- (child) => child.type.displayName === "SortableList"
42961
- );
42962
- const list = lists.find(
42963
- (list2) => list2.props.id === id2
42964
- );
42965
- if (list) {
42966
- return list == null ? void 0 : list.props;
42967
- }
42968
- return (_a = lists.find((l2) => React.Children.toArray(l2.props.children).findIndex((child) => child.props.id === id2) > -1)) == null ? void 0 : _a.props;
42969
- }
42970
- function Container$1(externalProps) {
42971
- const { children, reorder, move } = externalProps;
42972
- function handleDragOver(event) {
42973
- const { active, over } = event;
42974
- if (!(active == null ? void 0 : active.id) || !(over == null ? void 0 : over.id)) {
42975
- return;
42976
- }
42977
- const activeList = getContainerById(children, active.id);
42978
- const overList = getContainerById(children, over.id);
42979
- if (!(activeList == null ? void 0 : activeList.id) || !(overList == null ? void 0 : overList.id) || activeList.id === overList.id) {
42980
- return;
42981
- }
42982
- move(active.id, activeList == null ? void 0 : activeList.id, overList.id);
42983
- }
42984
- function handleDragEnd(event) {
42985
- const { active, over } = event;
42986
- if (!(active == null ? void 0 : active.id) || !(over == null ? void 0 : over.id)) {
42987
- return;
42988
- }
42989
- const activeList = getContainerById(children, active.id);
42990
- const overList = getContainerById(children, over.id);
42991
- if (!(activeList == null ? void 0 : activeList.id) || !(overList == null ? void 0 : overList.id) || activeList.id !== overList.id) {
42992
- return;
42993
- }
42994
- reorder(active.id, over.id, overList.id);
42995
- }
42996
- return /* @__PURE__ */ React.createElement(
42997
- DndContext,
42998
- {
42999
- collisionDetection: closestCenter,
43000
- ...externalProps,
43001
- modifiers: [restrictToVerticalAxis],
43002
- onDragOver: handleDragOver,
43003
- onDragEnd: handleDragEnd
43004
- },
43005
- children
43006
- );
43007
- }
43008
- Container$1.displayName = "SortableContainer";
43009
42955
  function arrayMove(array2, from, to) {
43010
42956
  const newArray = array2.slice();
43011
42957
  newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
@@ -43474,6 +43420,74 @@ function normalizeLocalDisabled(localDisabled, globalDisabled) {
43474
43420
  };
43475
43421
  }
43476
43422
  [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];
43423
+ function List(externalProps) {
43424
+ const { children, id: id2, ...props } = externalProps;
43425
+ const { setNodeRef } = useDroppable({ id: id2 });
43426
+ const items = React.Children.toArray(children).map((child) => child.props);
43427
+ return /* @__PURE__ */ React.createElement(SortableContext, { id: id2, items, strategy: verticalListSortingStrategy }, /* @__PURE__ */ React.createElement("div", { ...props, ref: id2 ? setNodeRef : void 0 }, children));
43428
+ }
43429
+ List.displayName = "SortableList";
43430
+ const restrictToVerticalAxis = (_ref) => {
43431
+ let {
43432
+ transform
43433
+ } = _ref;
43434
+ return {
43435
+ ...transform,
43436
+ x: 0
43437
+ };
43438
+ };
43439
+ function getContainerById(children, id2) {
43440
+ var _a;
43441
+ const lists = React.Children.toArray(children).filter(
43442
+ (child) => child.type === List
43443
+ );
43444
+ const list = lists.find(
43445
+ (list2) => list2.props.id === id2
43446
+ );
43447
+ if (list) {
43448
+ return list == null ? void 0 : list.props;
43449
+ }
43450
+ return (_a = lists.find((l2) => React.Children.toArray(l2.props.children).findIndex((child) => child.props.id === id2) > -1)) == null ? void 0 : _a.props;
43451
+ }
43452
+ function Container$1(externalProps) {
43453
+ const { children, reorder, move } = externalProps;
43454
+ function handleDragOver(event) {
43455
+ const { active, over } = event;
43456
+ if (!(active == null ? void 0 : active.id) || !(over == null ? void 0 : over.id)) {
43457
+ return;
43458
+ }
43459
+ const activeList = getContainerById(children, active.id);
43460
+ const overList = getContainerById(children, over.id);
43461
+ if (!(activeList == null ? void 0 : activeList.id) || !(overList == null ? void 0 : overList.id) || activeList.id === overList.id) {
43462
+ return;
43463
+ }
43464
+ move == null ? void 0 : move(active.id, activeList.id, overList.id);
43465
+ }
43466
+ function handleDragEnd(event) {
43467
+ const { active, over } = event;
43468
+ if (!(active == null ? void 0 : active.id) || !(over == null ? void 0 : over.id)) {
43469
+ return;
43470
+ }
43471
+ const activeList = getContainerById(children, active.id);
43472
+ const overList = getContainerById(children, over.id);
43473
+ if (!(activeList == null ? void 0 : activeList.id) || !(overList == null ? void 0 : overList.id) || activeList.id !== overList.id) {
43474
+ return;
43475
+ }
43476
+ reorder(active.id, over.id, overList.id);
43477
+ }
43478
+ return /* @__PURE__ */ React.createElement(
43479
+ DndContext,
43480
+ {
43481
+ collisionDetection: closestCenter,
43482
+ ...externalProps,
43483
+ modifiers: [restrictToVerticalAxis],
43484
+ onDragOver: handleDragOver,
43485
+ onDragEnd: handleDragEnd
43486
+ },
43487
+ children
43488
+ );
43489
+ }
43490
+ Container$1.displayName = "SortableContainer";
43477
43491
  const isFormElement = (element) => {
43478
43492
  const formElementNodeNames = ["BUTTON", "INPUT", "TEXTAREA", "SELECT", "FIELDSET"];
43479
43493
  return formElementNodeNames.includes(element.nodeName);
@@ -43497,13 +43511,6 @@ function Item(props) {
43497
43511
  return /* @__PURE__ */ React.createElement("div", { ...elProps }, children);
43498
43512
  }
43499
43513
  Item.displayName = "SortableListItem";
43500
- function List(externalProps) {
43501
- const { children, id: id2, ...props } = externalProps;
43502
- const { setNodeRef } = useDroppable({ id: id2 });
43503
- const items = React.Children.toArray(children).map((child) => child.props);
43504
- return /* @__PURE__ */ React.createElement(SortableContext, { id: id2, items, strategy: verticalListSortingStrategy }, /* @__PURE__ */ React.createElement("div", { ...props, ref: id2 ? setNodeRef : void 0 }, children));
43505
- }
43506
- List.displayName = "SortableList";
43507
43514
  const Column$3 = React.forwardRef(function Column2(props, ref) {
43508
43515
  var _a, _b, _c;
43509
43516
  const { column, draggable = false, ...dragAttributes } = props;
@@ -45408,6 +45415,7 @@ function ManageFiltersPopover(props) {
45408
45415
  const { locale: locale2, texts } = useLocalization();
45409
45416
  const allColumns = table.getAllLeafColumns().filter((column) => !isInternalColumn(column.id)).sort(sortByHeader);
45410
45417
  const columnFilters = table.getState().columnFilters;
45418
+ const tableMeta = table.options.meta;
45411
45419
  const [filters, setFilters] = React.useState(columnFilters.length ? columnFilters : [placeholderFilter]);
45412
45420
  React.useEffect(() => {
45413
45421
  setFilters(columnFilters.length === 0 ? [placeholderFilter] : columnFilters);
@@ -45467,7 +45475,9 @@ function ManageFiltersPopover(props) {
45467
45475
  };
45468
45476
  return /* @__PURE__ */ React.createElement(Popover, { ...popoverProps, onChange: handleClose }, /* @__PURE__ */ React.createElement(Popover.Content, null, /* @__PURE__ */ React.createElement(FilterContext.Provider, { value: filters }, /* @__PURE__ */ React.createElement("div", { className: "flex w-[40rem] flex-col gap-4" }, /* @__PURE__ */ React.createElement("div", { className: "flex h-8" }, /* @__PURE__ */ React.createElement("div", { className: "flex w-full items-center gap-2" }, /* @__PURE__ */ React.createElement("h4", { className: "mb-0 inline-flex" }, texts.table.filters.button), /* @__PURE__ */ React.createElement("p", { className: "text-grey-700 mb-0 mr-auto mt-px inline-flex" }, texts.table.filters.total.replace(
45469
45477
  "[CURRENT]",
45470
- new Intl.NumberFormat(locale2).format(table.getFilteredRowModel().rows.length)
45478
+ new Intl.NumberFormat(locale2).format(
45479
+ tableMeta.server._experimentalDataLoader2 ? length : table.getFilteredRowModel().rows.length
45480
+ )
45471
45481
  ).replace("[TOTAL]", new Intl.NumberFormat(locale2).format(length))))), /* @__PURE__ */ React.createElement("div", { className: "flex flex-col gap-2" }, filters.map((filter2, index2) => /* @__PURE__ */ React.createElement(
45472
45482
  Filter,
45473
45483
  {
@@ -55518,7 +55528,7 @@ function useTableEditing(isEnabled = false, defaultToggleEditing = false, handle
55518
55528
  return;
55519
55529
  }
55520
55530
  }
55521
- const changeset = row ?? handleCreate();
55531
+ const changeset = row ?? await handleCreate();
55522
55532
  try {
55523
55533
  if (changeset) {
55524
55534
  const temporaryRows = tableMeta.editing.temporaryRows;