@economic/taco 2.70.2-search-race-condition.1 → 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.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)) {
@@ -36595,7 +36598,7 @@ function useTableShortcutsListener(table, tableRef, shortcuts, localShortcuts =
36595
36598
  }
36596
36599
  function useLazyDebouncedEffect(effect, deps, ms = 200) {
36597
36600
  const readyRef = React__default.useRef(false);
36598
- const timeoutRef = React__default.useRef();
36601
+ const timeoutRef = React__default.useRef(void 0);
36599
36602
  React__default.useEffect(() => {
36600
36603
  if (readyRef.current) {
36601
36604
  timeoutRef.current = setTimeout(effect, ms);
@@ -45026,7 +45029,7 @@ function Search$1(props) {
45026
45029
  const { scrollToIndex, table, tableRef } = props;
45027
45030
  const { texts } = useLocalization();
45028
45031
  const ref = React__default.useRef(null);
45029
- const lastResultQuery = React__default.useRef();
45032
+ const lastResultQuery = React__default.useRef(void 0);
45030
45033
  const tableMeta = table.options.meta;
45031
45034
  const query = table.getState().globalFilter;
45032
45035
  const scrollTo2 = (rowIndex) => scrollToIndex(rowIndex, { align: "center" });
@@ -45062,7 +45065,7 @@ function Search$1(props) {
45062
45065
  }
45063
45066
  };
45064
45067
  const [loading, setLoading] = React__default.useState(false);
45065
- const searchTimeoutRef = React__default.useRef();
45068
+ const searchTimeoutRef = React__default.useRef(void 0);
45066
45069
  const handleChange = (query2) => {
45067
45070
  table.setGlobalFilter(String(query2 ?? ""));
45068
45071
  if (tableMeta.search.enableGlobalFilter && tableMeta.search.handleSearch) {
@@ -49722,7 +49725,7 @@ const Option = React__default.forwardRef(function Select2Option(props, ref) {
49722
49725
  value: props.value
49723
49726
  }
49724
49727
  ) : void 0;
49725
- 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(
49726
49729
  IconButton,
49727
49730
  {
49728
49731
  icon: "ellipsis-vertical",
@@ -50337,20 +50340,18 @@ const Select22 = React__default.forwardRef(function Select222(props, ref) {
50337
50340
  (_a = listboxRef.current) == null ? void 0 : _a.dispatchEvent(createCustomKeyboardEvent(event));
50338
50341
  };
50339
50342
  const shouldFocusNextRef = React__default.useRef(void 0);
50340
- React__default.useEffect(() => {
50341
- const handleKeyDown2 = (event) => {
50342
- 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();
50343
50350
  shouldFocusNextRef.current = event.key === "ArrowLeft" ? -1 : 1;
50344
50351
  setOpen(false);
50345
50352
  }
50346
- };
50347
- if (isElementInsideTable3OrReport(internalRef.current)) {
50348
- document.addEventListener("keydown", handleKeyDown2);
50349
50353
  }
50350
- return () => {
50351
- document.removeEventListener("keydown", handleKeyDown2);
50352
- };
50353
- }, []);
50354
+ };
50354
50355
  const handleListboxKeyDown = (event) => {
50355
50356
  if (isAriaDirectionKey(event)) {
50356
50357
  setShouldPauseHoverState(true);
@@ -50361,6 +50362,11 @@ const Select22 = React__default.forwardRef(function Select222(props, ref) {
50361
50362
  setOpen(false);
50362
50363
  return;
50363
50364
  }
50365
+ if (!hasSearch && event.key === "Escape") {
50366
+ event.preventDefault();
50367
+ setOpen(false);
50368
+ return;
50369
+ }
50364
50370
  if (!hasSearch && /^[a-z0-9]$/i.test(event.key)) {
50365
50371
  setValueIfMatched(event.key);
50366
50372
  return;
@@ -50430,6 +50436,7 @@ const Select22 = React__default.forwardRef(function Select222(props, ref) {
50430
50436
  asChild: true,
50431
50437
  align: "start",
50432
50438
  onCloseAutoFocus: handleCloseAutoFocus,
50439
+ onKeyDown: handleHorizontalNavigation,
50433
50440
  onPointerDownOutside: otherProps.onBlur,
50434
50441
  sideOffset: 4,
50435
50442
  tabIndex: -1
@@ -50554,7 +50561,7 @@ function Print(props) {
50554
50561
  const { table, tableId, tableRef } = props;
50555
50562
  const { texts } = useLocalization();
50556
50563
  const ref = React__default.useRef(null);
50557
- const lastScrollTopRef = React__default.useRef();
50564
+ const lastScrollTopRef = React__default.useRef(void 0);
50558
50565
  const toast = useToast();
50559
50566
  const tableMeta = table.options.meta;
50560
50567
  const { allRows, orientation, size: size2, splitGroups } = tableMeta.printing.settings;
@@ -57167,7 +57174,7 @@ const useRowSelect = (onSelectedRows) => {
57167
57174
  row.toggleRowSelected = () => toggleRowSelected(row.id, !row.isSelected);
57168
57175
  };
57169
57176
  hooks.prepareRow.push(prepareRow2);
57170
- const lastSelectedSortedIndex = React__default.useRef();
57177
+ const lastSelectedSortedIndex = React__default.useRef(void 0);
57171
57178
  hooks.visibleColumns.push((columns) => [
57172
57179
  {
57173
57180
  id: "selection",
@@ -94086,7 +94093,7 @@ function useTableDataLoader2(fetchPage, fetchAll, options = { pageSize: DEFAULT_
94086
94093
  const _lastUsedSorting = React__default.useRef([]);
94087
94094
  const _lastUsedFilters = React__default.useRef([]);
94088
94095
  const _lastUsedHiddenColumns = React__default.useRef([]);
94089
- const _lastUsedSearch = React__default.useRef();
94096
+ const _lastUsedSearch = React__default.useRef(void 0);
94090
94097
  async function loadPage(pageIndex, sorting, filters, hiddenColumns, search) {
94091
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;
94092
94099
  if (hasDataChanged) {