@economic/taco 2.63.2-combobox-search-no-sorting.0 → 2.64.1-table-flickering.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])",
@@ -18461,7 +18467,7 @@ const useCombobox = (props, ref) => {
18461
18467
  React.useEffect(() => {
18462
18468
  const isCurrentValue = value !== void 0 && value !== null && inputValue === String(value);
18463
18469
  if (inputValue && data.length && !isCurrentValue) {
18464
- setCurrentIndex(getIndexFromValue(data, inputValue) || 0);
18470
+ setCurrentIndex(0);
18465
18471
  if (!open) {
18466
18472
  setOpen(true);
18467
18473
  }
@@ -18945,6 +18951,9 @@ const Datepicker = React.forwardRef(function Datepicker2(props, ref) {
18945
18951
  const { texts } = useLocalization();
18946
18952
  const className = clsx("inline-flex w-full text-black font-normal", externalClassName);
18947
18953
  const popoverContentRef = React.useRef(null);
18954
+ const handlePopoverClick = React.useCallback((event) => {
18955
+ event.stopPropagation();
18956
+ }, []);
18948
18957
  const handleOpenAutofocus = React.useCallback(
18949
18958
  (e3) => {
18950
18959
  var _a;
@@ -18991,7 +19000,8 @@ const Datepicker = React.forwardRef(function Datepicker2(props, ref) {
18991
19000
  "div",
18992
19001
  {
18993
19002
  className: '[&_button[name="day"]:focus]:yt-focus -m-3 flex',
18994
- ref: popoverContentRef
19003
+ ref: popoverContentRef,
19004
+ onClick: handlePopoverClick
18995
19005
  },
18996
19006
  /* @__PURE__ */ React.createElement(
18997
19007
  Calendar,
@@ -29690,6 +29700,7 @@ const Content$2 = React.forwardRef(function MenuContent(props, ref) {
29690
29700
  align,
29691
29701
  className,
29692
29702
  "data-taco": "menu",
29703
+ hideWhenDetached: true,
29693
29704
  side,
29694
29705
  sideOffset: 3,
29695
29706
  style: { minWidth: menu == null ? void 0 : menu.minWidth },
@@ -38162,7 +38173,7 @@ function Header$2(context) {
38162
38173
  tableMeta.search.enableGlobalFilter ? table.getState().globalFilter : void 0
38163
38174
  );
38164
38175
  }
38165
- table.toggleAllRowsSelected(checked);
38176
+ setTimeout(() => table.toggleAllRowsSelected(checked), 1);
38166
38177
  };
38167
38178
  return /* @__PURE__ */ React__default.createElement(Tooltip$3, { title }, /* @__PURE__ */ React__default.createElement(
38168
38179
  Checkbox$2,
@@ -39117,7 +39128,9 @@ function Body(props) {
39117
39128
  const focusManager = useAugmentedFocusManager();
39118
39129
  const tableMeta = table.options.meta;
39119
39130
  const handleKeyDown = (event) => {
39120
- 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) {
39121
39134
  return;
39122
39135
  }
39123
39136
  if (tableMeta.rowActive.rowActiveIndex !== void 0) {
@@ -39287,20 +39300,14 @@ const MemoedFooter = React__default.memo(function MemoedFooter2(props) {
39287
39300
  );
39288
39301
  });
39289
39302
  function EmptyStateBody(props) {
39290
- var _a, _b;
39303
+ var _a;
39291
39304
  const { emptyState: Placeholder2, isReady, reason, ...attributes } = props;
39292
39305
  const ref = React__default.useRef(null);
39306
+ const rect = useBoundingClientRectListener({ current: (_a = ref.current) == null ? void 0 : _a.parentNode });
39293
39307
  if (!isReady) {
39294
39308
  return /* @__PURE__ */ React__default.createElement("tbody", { ...attributes, className: "!auto-rows-fr" });
39295
39309
  }
39296
- 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(
39297
- "td",
39298
- {
39299
- style: { maxWidth: (_b = (_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.clientWidth },
39300
- className: "col-span-full !border-0 !p-0 hover:!bg-white"
39301
- },
39302
- Placeholder2 ? /* @__PURE__ */ React__default.createElement(Placeholder2, { reason }) : void 0
39303
- )));
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)));
39304
39311
  }
39305
39312
  const SearchInput22 = React__default.forwardRef(function SearchInput222(props, ref) {
39306
39313
  const {
@@ -42927,67 +42934,6 @@ function useDroppable(_ref) {
42927
42934
  setNodeRef
42928
42935
  };
42929
42936
  }
42930
- const restrictToVerticalAxis = (_ref) => {
42931
- let {
42932
- transform
42933
- } = _ref;
42934
- return {
42935
- ...transform,
42936
- x: 0
42937
- };
42938
- };
42939
- function getContainerById(children, id2) {
42940
- var _a;
42941
- const lists = React__default.Children.toArray(children).filter(
42942
- (child) => child.type.displayName === "SortableList"
42943
- );
42944
- const list = lists.find(
42945
- (list2) => list2.props.id === id2
42946
- );
42947
- if (list) {
42948
- return list == null ? void 0 : list.props;
42949
- }
42950
- return (_a = lists.find((l2) => React__default.Children.toArray(l2.props.children).findIndex((child) => child.props.id === id2) > -1)) == null ? void 0 : _a.props;
42951
- }
42952
- function Container$1(externalProps) {
42953
- const { children, reorder, move } = externalProps;
42954
- function handleDragOver(event) {
42955
- const { active, over } = event;
42956
- if (!(active == null ? void 0 : active.id) || !(over == null ? void 0 : over.id)) {
42957
- return;
42958
- }
42959
- const activeList = getContainerById(children, active.id);
42960
- const overList = getContainerById(children, over.id);
42961
- if (!(activeList == null ? void 0 : activeList.id) || !(overList == null ? void 0 : overList.id) || activeList.id === overList.id) {
42962
- return;
42963
- }
42964
- move(active.id, activeList == null ? void 0 : activeList.id, overList.id);
42965
- }
42966
- function handleDragEnd(event) {
42967
- const { active, over } = event;
42968
- if (!(active == null ? void 0 : active.id) || !(over == null ? void 0 : over.id)) {
42969
- return;
42970
- }
42971
- const activeList = getContainerById(children, active.id);
42972
- const overList = getContainerById(children, over.id);
42973
- if (!(activeList == null ? void 0 : activeList.id) || !(overList == null ? void 0 : overList.id) || activeList.id !== overList.id) {
42974
- return;
42975
- }
42976
- reorder(active.id, over.id, overList.id);
42977
- }
42978
- return /* @__PURE__ */ React__default.createElement(
42979
- DndContext,
42980
- {
42981
- collisionDetection: closestCenter,
42982
- ...externalProps,
42983
- modifiers: [restrictToVerticalAxis],
42984
- onDragOver: handleDragOver,
42985
- onDragEnd: handleDragEnd
42986
- },
42987
- children
42988
- );
42989
- }
42990
- Container$1.displayName = "SortableContainer";
42991
42937
  function arrayMove(array2, from, to) {
42992
42938
  const newArray = array2.slice();
42993
42939
  newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
@@ -43456,6 +43402,74 @@ function normalizeLocalDisabled(localDisabled, globalDisabled) {
43456
43402
  };
43457
43403
  }
43458
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";
43459
43473
  const isFormElement = (element) => {
43460
43474
  const formElementNodeNames = ["BUTTON", "INPUT", "TEXTAREA", "SELECT", "FIELDSET"];
43461
43475
  return formElementNodeNames.includes(element.nodeName);
@@ -43479,13 +43493,6 @@ function Item(props) {
43479
43493
  return /* @__PURE__ */ React__default.createElement("div", { ...elProps }, children);
43480
43494
  }
43481
43495
  Item.displayName = "SortableListItem";
43482
- function List(externalProps) {
43483
- const { children, id: id2, ...props } = externalProps;
43484
- const { setNodeRef } = useDroppable({ id: id2 });
43485
- const items = React__default.Children.toArray(children).map((child) => child.props);
43486
- return /* @__PURE__ */ React__default.createElement(SortableContext, { id: id2, items, strategy: verticalListSortingStrategy }, /* @__PURE__ */ React__default.createElement("div", { ...props, ref: id2 ? setNodeRef : void 0 }, children));
43487
- }
43488
- List.displayName = "SortableList";
43489
43496
  const Column$3 = React__default.forwardRef(function Column2(props, ref) {
43490
43497
  var _a, _b, _c;
43491
43498
  const { column, draggable = false, ...dragAttributes } = props;
@@ -45390,6 +45397,7 @@ function ManageFiltersPopover(props) {
45390
45397
  const { locale: locale2, texts } = useLocalization();
45391
45398
  const allColumns = table.getAllLeafColumns().filter((column) => !isInternalColumn(column.id)).sort(sortByHeader);
45392
45399
  const columnFilters = table.getState().columnFilters;
45400
+ const tableMeta = table.options.meta;
45393
45401
  const [filters, setFilters] = React__default.useState(columnFilters.length ? columnFilters : [placeholderFilter]);
45394
45402
  React__default.useEffect(() => {
45395
45403
  setFilters(columnFilters.length === 0 ? [placeholderFilter] : columnFilters);
@@ -45449,7 +45457,9 @@ function ManageFiltersPopover(props) {
45449
45457
  };
45450
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(
45451
45459
  "[CURRENT]",
45452
- 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
+ )
45453
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(
45454
45464
  Filter,
45455
45465
  {
@@ -55500,7 +55510,7 @@ function useTableEditing(isEnabled = false, defaultToggleEditing = false, handle
55500
55510
  return;
55501
55511
  }
55502
55512
  }
55503
- const changeset = row ?? handleCreate();
55513
+ const changeset = row ?? await handleCreate();
55504
55514
  try {
55505
55515
  if (changeset) {
55506
55516
  const temporaryRows = tableMeta.editing.temporaryRows;
@@ -88385,19 +88395,16 @@ function useTableDataLoader2(fetchPage, fetchAll, options = { pageSize: DEFAULT_
88385
88395
  const _lastUsedSearch = React__default.useRef();
88386
88396
  async function loadPage(pageIndex, sorting, filters, hiddenColumns, search) {
88387
88397
  const hasDataChanged = JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) || JSON.stringify(hiddenColumns) !== JSON.stringify(_lastUsedHiddenColumns.current) || search !== _lastUsedSearch.current;
88398
+ const isAlreadyLoadedOrLoading = _pendingPageRequests.current[pageIndex] || data.cache[pageIndex] && data.cache[pageIndex][0];
88399
+ if (!hasDataChanged && isAlreadyLoadedOrLoading) {
88400
+ return;
88401
+ }
88388
88402
  if (hasDataChanged) {
88389
88403
  _lastUsedSorting.current = sorting;
88390
88404
  _lastUsedFilters.current = filters;
88391
88405
  _lastUsedSearch.current = search;
88392
88406
  _lastUsedHiddenColumns.current = hiddenColumns;
88393
88407
  _pendingPageRequests.current = {};
88394
- } else {
88395
- if (_pendingPageRequests.current[pageIndex]) {
88396
- return;
88397
- }
88398
- if (data.cache[pageIndex] && data.cache[pageIndex][0]) {
88399
- return;
88400
- }
88401
88408
  }
88402
88409
  const dataKey = getDataKey(sorting, filters, hiddenColumns, search);
88403
88410
  _pendingPageRequests.current[pageIndex] = dataKey;
@@ -88443,6 +88450,7 @@ function useTableDataLoader2(fetchPage, fetchAll, options = { pageSize: DEFAULT_
88443
88450
  delete _pendingPageRequests.current[pageIndex];
88444
88451
  });
88445
88452
  } catch {
88453
+ delete _pendingPageRequests.current[pageIndex];
88446
88454
  }
88447
88455
  }
88448
88456
  const loadAll = async (sorting, filters, hiddenColumns, search) => {
@@ -88552,12 +88560,14 @@ function getCurrentPage(currentPages) {
88552
88560
  return currentPages[middle];
88553
88561
  }
88554
88562
  function getDirection(pageIndex, currentPages) {
88555
- if (currentPages.length) {
88556
- if (pageIndex === currentPages[currentPages.length - 1] + 1) {
88557
- return "forward";
88558
- } else if (pageIndex === currentPages[0] - 1 || currentPages.length === 2 && currentPages[0] !== 0 && pageIndex === currentPages[0]) {
88559
- return "backward";
88560
- }
88563
+ if (!currentPages.length) {
88564
+ return void 0;
88565
+ }
88566
+ if (pageIndex === currentPages[currentPages.length - 1] + 1) {
88567
+ return "forward";
88568
+ }
88569
+ if (pageIndex === currentPages[0] - 1 || currentPages.length === 2 && currentPages[0] !== 0 && pageIndex === currentPages[0]) {
88570
+ return "backward";
88561
88571
  }
88562
88572
  return void 0;
88563
88573
  }