@economic/taco 2.70.2-search-race-condition.0 → 2.70.2

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
@@ -3492,7 +3492,7 @@ export declare type TableSettings = {
3492
3492
 
3493
3493
  export declare type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;
3494
3494
 
3495
- export declare type TableShortcutHandlerFn<TType = unknown> = (row: TType | undefined) => void;
3495
+ export declare type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;
3496
3496
 
3497
3497
  export declare type TableShortcutHandlerObject<TType = unknown> = {
3498
3498
  handler: TableShortcutHandlerFn<TType>;
package/dist/taco.js CHANGED
@@ -11450,7 +11450,7 @@ const Base$1 = React.forwardRef(function IconButtonBase(props, ref) {
11450
11450
  return null;
11451
11451
  }
11452
11452
  return createButtonWithTooltip(
11453
- { ...otherProps, children: /* @__PURE__ */ React.createElement(Icon$1, { name: icon, className: "m-0 p-0" }), "data-taco": "icon-button" },
11453
+ { "data-taco": "icon-button", ...otherProps, children: /* @__PURE__ */ React.createElement(Icon$1, { name: icon, className: "m-0 p-0" }) },
11454
11454
  className,
11455
11455
  ref
11456
11456
  );
@@ -16963,7 +16963,7 @@ const Navbar = React.memo(({ onMonthChange, value = /* @__PURE__ */ new Date() }
16963
16963
  "aria-label": actions.previousMonth,
16964
16964
  onClick: onPreviousClick,
16965
16965
  rounded: true,
16966
- "data-action": "prev-month"
16966
+ "data-taco": "calendar-prev-month-button"
16967
16967
  }
16968
16968
  )), /* @__PURE__ */ React.createElement(Tooltip$3, { title: actions.nextMonth }, /* @__PURE__ */ React.createElement(
16969
16969
  IconButton,
@@ -16973,7 +16973,7 @@ const Navbar = React.memo(({ onMonthChange, value = /* @__PURE__ */ new Date() }
16973
16973
  "aria-label": actions.nextMonth,
16974
16974
  onClick: onNextClick,
16975
16975
  rounded: true,
16976
- "data-action": "next-month"
16976
+ "data-taco": "calendar-next-month-button"
16977
16977
  }
16978
16978
  ))));
16979
16979
  });
@@ -16991,7 +16991,7 @@ const TodayButton = ({ handleChange }) => {
16991
16991
  {
16992
16992
  className: "cursor-pointer border-none bg-transparent text-xs text-blue-500 hover:text-blue-300",
16993
16993
  onClick: handleCalendarClickToday,
16994
- "data-action": "today"
16994
+ "data-taco": "calendar-today-button"
16995
16995
  },
16996
16996
  texts.calendar.actions.today
16997
16997
  );
@@ -19030,6 +19030,7 @@ const Datepicker = React.forwardRef(function Datepicker2(props, ref) {
19030
19030
  {
19031
19031
  type: "button",
19032
19032
  className: "hover:wcag-grey-200 flex w-full items-start px-4 py-1 text-xs",
19033
+ "data-taco": "datepicker-shortcut",
19033
19034
  onClick: (event) => {
19034
19035
  event.persist();
19035
19036
  shortcut2.onClick(event);
@@ -19042,6 +19043,7 @@ const Datepicker = React.forwardRef(function Datepicker2(props, ref) {
19042
19043
  {
19043
19044
  type: "button",
19044
19045
  className: "mx-auto my-4 mt-auto inline-flex cursor-pointer border-none bg-transparent text-xs text-blue-500 hover:text-blue-300",
19046
+ "data-taco": "datepicker-clear-button",
19045
19047
  onClick: (event) => {
19046
19048
  event.persist();
19047
19049
  handleReset(event);
@@ -19052,7 +19054,8 @@ const Datepicker = React.forwardRef(function Datepicker2(props, ref) {
19052
19054
  ))
19053
19055
  )
19054
19056
  )),
19055
- tooltip: texts.datepicker.calendar
19057
+ tooltip: texts.datepicker.calendar,
19058
+ "data-taco": "toggle-calendar-button"
19056
19059
  }
19057
19060
  )
19058
19061
  }
@@ -28027,7 +28030,7 @@ List$1.Switch = Switch;
28027
28030
  List$1.Checkbox = Checkbox$1;
28028
28031
  List$1.Group = Group$5;
28029
28032
  function useTimer(duration = 0, callback) {
28030
- const timer = React.useRef();
28033
+ const timer = React.useRef(void 0);
28031
28034
  const [tracker, setTracker] = React.useState({
28032
28035
  remaining: duration,
28033
28036
  started: null
@@ -28071,7 +28074,7 @@ function useTimer(duration = 0, callback) {
28071
28074
  };
28072
28075
  }
28073
28076
  const useTypeahead = ({ data, currentIndex }) => {
28074
- const typeaheadQuery = React.useRef();
28077
+ const typeaheadQuery = React.useRef(void 0);
28075
28078
  const typeaheadQueryTimer = useTimer(1e3, () => {
28076
28079
  typeaheadQuery.current = void 0;
28077
28080
  });
@@ -36075,7 +36078,7 @@ function useTableRowHeight(isEnabled = false, defaultRowHeight = "medium") {
36075
36078
  };
36076
36079
  }
36077
36080
  function useTableRowSelection(isEnabled = false) {
36078
- const lastSelectedRowIndex = React__default.useRef();
36081
+ const lastSelectedRowIndex = React__default.useRef(void 0);
36079
36082
  const onKeyDown = React__default.useCallback(
36080
36083
  (event, table) => {
36081
36084
  var _a, _b, _c;
@@ -36143,9 +36146,9 @@ function useTableDataLoader(fetchPage, fetchAll, options = { pageSize: DEFAULT_P
36143
36146
  const _pendingPageRequests = React__default.useRef({});
36144
36147
  const _lastUsedSorting = React__default.useRef([]);
36145
36148
  const _lastUsedFilters = React__default.useRef([]);
36146
- const _lastUsedSearch = React__default.useRef();
36149
+ const _lastUsedSearch = React__default.useRef(void 0);
36147
36150
  const _lastUsedHiddenColumns = React__default.useRef([]);
36148
- const _lastUsedPageIndex = React__default.useRef();
36151
+ const _lastUsedPageIndex = React__default.useRef(void 0);
36149
36152
  const loadPage = async (pageIndex, sorting, filters, hiddenColumns) => {
36150
36153
  let reset = false;
36151
36154
  if (JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)) {
@@ -36555,31 +36558,33 @@ function useTableShortcutsListener(table, tableRef, shortcuts, localShortcuts =
36555
36558
  const globalHandlers = [];
36556
36559
  if (shortcuts && shortcutKeys.length && meta.rowActive.rowActiveIndex !== void 0) {
36557
36560
  const rowActive = rows[meta.rowActive.rowActiveIndex];
36558
- shortcutKeys.forEach((key) => {
36559
- const handler = shortcuts[key];
36560
- let keyDownHandler;
36561
- let keyDownHandlerOptions;
36562
- if (typeof handler === "function") {
36563
- keyDownHandler = handler;
36564
- keyDownHandlerOptions = {
36565
- key
36566
- };
36567
- } else {
36568
- const handlerObject = handler;
36569
- keyDownHandler = handlerObject.handler;
36570
- keyDownHandlerOptions = {
36571
- key,
36572
- meta: handlerObject.meta,
36573
- shift: handlerObject.shift
36574
- };
36575
- }
36576
- globalHandlers.push(
36577
- createShortcutKeyDownHandler(keyDownHandlerOptions, (event) => {
36578
- event.preventDefault();
36579
- keyDownHandler(rowActive == null ? void 0 : rowActive.original);
36580
- })
36581
- );
36582
- });
36561
+ if (rowActive) {
36562
+ shortcutKeys.forEach((key) => {
36563
+ const handler = shortcuts[key];
36564
+ let keyDownHandler;
36565
+ let keyDownHandlerOptions;
36566
+ if (typeof handler === "function") {
36567
+ keyDownHandler = handler;
36568
+ keyDownHandlerOptions = {
36569
+ key
36570
+ };
36571
+ } else {
36572
+ const handlerObject = handler;
36573
+ keyDownHandler = handlerObject.handler;
36574
+ keyDownHandlerOptions = {
36575
+ key,
36576
+ meta: handlerObject.meta,
36577
+ shift: handlerObject.shift
36578
+ };
36579
+ }
36580
+ globalHandlers.push(
36581
+ createShortcutKeyDownHandler(keyDownHandlerOptions, (event) => {
36582
+ event.preventDefault();
36583
+ keyDownHandler(rowActive.original);
36584
+ })
36585
+ );
36586
+ });
36587
+ }
36583
36588
  }
36584
36589
  globalHandlers.forEach((handler) => {
36585
36590
  listenerTarget == null ? void 0 : listenerTarget.addEventListener("keydown", handler);
@@ -36593,7 +36598,7 @@ function useTableShortcutsListener(table, tableRef, shortcuts, localShortcuts =
36593
36598
  }
36594
36599
  function useLazyDebouncedEffect(effect, deps, ms = 200) {
36595
36600
  const readyRef = React__default.useRef(false);
36596
- const timeoutRef = React__default.useRef();
36601
+ const timeoutRef = React__default.useRef(void 0);
36597
36602
  React__default.useEffect(() => {
36598
36603
  if (readyRef.current) {
36599
36604
  timeoutRef.current = setTimeout(effect, ms);
@@ -45024,7 +45029,7 @@ function Search$1(props) {
45024
45029
  const { scrollToIndex, table, tableRef } = props;
45025
45030
  const { texts } = useLocalization();
45026
45031
  const ref = React__default.useRef(null);
45027
- const lastResultQuery = React__default.useRef();
45032
+ const lastResultQuery = React__default.useRef(void 0);
45028
45033
  const tableMeta = table.options.meta;
45029
45034
  const query = table.getState().globalFilter;
45030
45035
  const scrollTo2 = (rowIndex) => scrollToIndex(rowIndex, { align: "center" });
@@ -45060,7 +45065,7 @@ function Search$1(props) {
45060
45065
  }
45061
45066
  };
45062
45067
  const [loading, setLoading] = React__default.useState(false);
45063
- const searchTimeoutRef = React__default.useRef();
45068
+ const searchTimeoutRef = React__default.useRef(void 0);
45064
45069
  const handleChange = (query2) => {
45065
45070
  table.setGlobalFilter(String(query2 ?? ""));
45066
45071
  if (tableMeta.search.enableGlobalFilter && tableMeta.search.handleSearch) {
@@ -49720,7 +49725,7 @@ const Option = React__default.forwardRef(function Select2Option(props, ref) {
49720
49725
  value: props.value
49721
49726
  }
49722
49727
  ) : void 0;
49723
- return /* @__PURE__ */ React__default.createElement(Option$1, { ...otherProps, className, onClick: handleClick, onKeyDown: handleKeyDown, ref }, hasValue2 ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: "tick", className: "pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible" }) : null, typeof children === "string" ? isTag ? /* @__PURE__ */ React__default.createElement(Tag, { className: "pointer-events-none my-1", color: color2, icon: prefix2 }, children) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, prefix2 ? typeof prefix2 === "string" ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: prefix2, className: "!h-5 !w-5" }) : prefix2 : null, /* @__PURE__ */ React__default.createElement("span", { className: "flex w-full justify-between" }, /* @__PURE__ */ React__default.createElement("span", { className: "flex flex-col" }, /* @__PURE__ */ React__default.createElement("span", null, children), description ? /* @__PURE__ */ React__default.createElement("span", { className: "text-grey-700 -mt-1.5 mb-1.5 text-xs", "data-taco": "description" }, description) : null), /* @__PURE__ */ React__default.createElement("span", { className: "flex flex-col self-center" }, postfix ? typeof postfix === "string" ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: postfix, className: "!h-5 !w-5" }) : postfix : null))) : /* @__PURE__ */ React__default.createElement("span", { className: "w-full" }, children), popover ? /* @__PURE__ */ React__default.createElement(
49728
+ return /* @__PURE__ */ React__default.createElement(Option$1, { ...otherProps, className, onClick: handleClick, onKeyDown: handleKeyDown, ref }, hasValue2 ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: "tick", className: "pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible" }) : /* @__PURE__ */ React__default.createElement("span", { className: "-mx-0.5 inline-flex h-4 w-4 flex-shrink-0", "aria-hidden": true }), typeof children === "string" ? isTag ? /* @__PURE__ */ React__default.createElement(Tag, { className: "pointer-events-none my-1", color: color2, icon: prefix2 }, children) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, prefix2 ? typeof prefix2 === "string" ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: prefix2, className: "!h-5 !w-5" }) : prefix2 : null, /* @__PURE__ */ React__default.createElement("span", { className: "flex w-full justify-between" }, /* @__PURE__ */ React__default.createElement("span", { className: "flex flex-col" }, /* @__PURE__ */ React__default.createElement("span", null, children), description ? /* @__PURE__ */ React__default.createElement("span", { className: "text-grey-700 -mt-1.5 mb-1.5 text-xs", "data-taco": "description" }, description) : null), /* @__PURE__ */ React__default.createElement("span", { className: "flex flex-col self-center" }, postfix ? typeof postfix === "string" ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: postfix, className: "!h-5 !w-5" }) : postfix : null))) : /* @__PURE__ */ React__default.createElement("span", { className: "w-full" }, children), popover ? /* @__PURE__ */ React__default.createElement(
49724
49729
  IconButton,
49725
49730
  {
49726
49731
  icon: "ellipsis-vertical",
@@ -50335,20 +50340,18 @@ const Select22 = React__default.forwardRef(function Select222(props, ref) {
50335
50340
  (_a = listboxRef.current) == null ? void 0 : _a.dispatchEvent(createCustomKeyboardEvent(event));
50336
50341
  };
50337
50342
  const shouldFocusNextRef = React__default.useRef(void 0);
50338
- React__default.useEffect(() => {
50339
- const handleKeyDown2 = (event) => {
50340
- if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
50343
+ const handleHorizontalNavigation = (event) => {
50344
+ var _a, _b;
50345
+ if (isElementInsideTable3OrReport(internalRef.current)) {
50346
+ const isTriggeredFromPopover = (_b = (_a = event.currentTarget).contains) == null ? void 0 : _b.call(_a, event.target);
50347
+ if ((event.key === "ArrowLeft" || event.key === "ArrowRight") && isTriggeredFromPopover) {
50348
+ event.preventDefault();
50349
+ event.stopPropagation();
50341
50350
  shouldFocusNextRef.current = event.key === "ArrowLeft" ? -1 : 1;
50342
50351
  setOpen(false);
50343
50352
  }
50344
- };
50345
- if (isElementInsideTable3OrReport(internalRef.current)) {
50346
- document.addEventListener("keydown", handleKeyDown2);
50347
50353
  }
50348
- return () => {
50349
- document.removeEventListener("keydown", handleKeyDown2);
50350
- };
50351
- }, []);
50354
+ };
50352
50355
  const handleListboxKeyDown = (event) => {
50353
50356
  if (isAriaDirectionKey(event)) {
50354
50357
  setShouldPauseHoverState(true);
@@ -50359,6 +50362,11 @@ const Select22 = React__default.forwardRef(function Select222(props, ref) {
50359
50362
  setOpen(false);
50360
50363
  return;
50361
50364
  }
50365
+ if (!hasSearch && event.key === "Escape") {
50366
+ event.preventDefault();
50367
+ setOpen(false);
50368
+ return;
50369
+ }
50362
50370
  if (!hasSearch && /^[a-z0-9]$/i.test(event.key)) {
50363
50371
  setValueIfMatched(event.key);
50364
50372
  return;
@@ -50428,6 +50436,7 @@ const Select22 = React__default.forwardRef(function Select222(props, ref) {
50428
50436
  asChild: true,
50429
50437
  align: "start",
50430
50438
  onCloseAutoFocus: handleCloseAutoFocus,
50439
+ onKeyDown: handleHorizontalNavigation,
50431
50440
  onPointerDownOutside: otherProps.onBlur,
50432
50441
  sideOffset: 4,
50433
50442
  tabIndex: -1
@@ -50552,7 +50561,7 @@ function Print(props) {
50552
50561
  const { table, tableId, tableRef } = props;
50553
50562
  const { texts } = useLocalization();
50554
50563
  const ref = React__default.useRef(null);
50555
- const lastScrollTopRef = React__default.useRef();
50564
+ const lastScrollTopRef = React__default.useRef(void 0);
50556
50565
  const toast = useToast();
50557
50566
  const tableMeta = table.options.meta;
50558
50567
  const { allRows, orientation, size: size2, splitGroups } = tableMeta.printing.settings;
@@ -57165,7 +57174,7 @@ const useRowSelect = (onSelectedRows) => {
57165
57174
  row.toggleRowSelected = () => toggleRowSelected(row.id, !row.isSelected);
57166
57175
  };
57167
57176
  hooks.prepareRow.push(prepareRow2);
57168
- const lastSelectedSortedIndex = React__default.useRef();
57177
+ const lastSelectedSortedIndex = React__default.useRef(void 0);
57169
57178
  hooks.visibleColumns.push((columns) => [
57170
57179
  {
57171
57180
  id: "selection",
@@ -94084,7 +94093,7 @@ function useTableDataLoader2(fetchPage, fetchAll, options = { pageSize: DEFAULT_
94084
94093
  const _lastUsedSorting = React__default.useRef([]);
94085
94094
  const _lastUsedFilters = React__default.useRef([]);
94086
94095
  const _lastUsedHiddenColumns = React__default.useRef([]);
94087
- const _lastUsedSearch = React__default.useRef();
94096
+ const _lastUsedSearch = React__default.useRef(void 0);
94088
94097
  async function loadPage(pageIndex, sorting, filters, hiddenColumns, search) {
94089
94098
  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;
94090
94099
  if (hasDataChanged) {