@economic/taco 3.0.1 → 3.0.2-row-active-search.1

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
@@ -23927,7 +23927,7 @@ const Card = React.forwardRef(function Card2(props, ref) {
23927
23927
  const { title, menu, children, className, ...otherProps } = props;
23928
23928
  const localization = useLocalization();
23929
23929
  const cardClassName = clsx(
23930
- "bg-white flex flex-col rounded-xl border border-solid border-radius-[12px] border-grey-300 hover:border-grey-500",
23930
+ "bg-white flex flex-col rounded-xl border border-solid border-radius-[12px] border-grey-300",
23931
23931
  className
23932
23932
  );
23933
23933
  return /* @__PURE__ */ React.createElement("div", { ...otherProps, className: cardClassName, "data-taco": "card", ref }, /* @__PURE__ */ React.createElement("div", { className: "flex justify-between px-4 pb-2 pt-4" }, title && /* @__PURE__ */ React.createElement(Truncate, { tooltip: title }, /* @__PURE__ */ React.createElement("h4", { className: "mb-0 flex-grow truncate text-left" }, title)), menu ? /* @__PURE__ */ React.createElement(
@@ -43888,6 +43888,23 @@ const useIsHoverStatePaused = () => {
43888
43888
  }, [shouldPauseHoverState]);
43889
43889
  return [shouldPauseHoverState, setShouldPauseHoverState];
43890
43890
  };
43891
+ function focusActiveRow(tableRef) {
43892
+ var _a;
43893
+ const activeRow = ((_a = (tableRef == null ? void 0 : tableRef.current) ?? document) == null ? void 0 : _a.querySelector('tbody tr[data-row-active="true"]')) ?? null;
43894
+ if (activeRow) {
43895
+ if (!isElementInsideOrTriggeredFromContainer(document.activeElement, activeRow) && !isElementInteractive(document.activeElement)) {
43896
+ activeRow.focus({ preventScroll: true });
43897
+ }
43898
+ }
43899
+ }
43900
+ function useTableRowActiveListener$1(table, tableRef) {
43901
+ const tableMeta = table.options.meta;
43902
+ React__default.useEffect(() => {
43903
+ if (tableMeta.rowActive.rowActiveIndex !== void 0) {
43904
+ focusActiveRow(tableRef);
43905
+ }
43906
+ }, [tableMeta.rowActive.rowActiveIndex, tableRef]);
43907
+ }
43891
43908
  function useTableRowActive$1(isEnabled = false, initialRowActiveIndex) {
43892
43909
  const [rowActiveIndex, setRowActiveIndex] = React__default.useState(initialRowActiveIndex);
43893
43910
  const [rowHoverIndex, setRowHoverIndex] = React__default.useState(void 0);
@@ -43895,7 +43912,11 @@ function useTableRowActive$1(isEnabled = false, initialRowActiveIndex) {
43895
43912
  const move = (direction, length, scrollToIndex) => {
43896
43913
  const nextIndex = rowActiveIndex === void 0 ? 0 : getNextIndex(direction, rowActiveIndex, length);
43897
43914
  scrollToIndex(nextIndex);
43898
- setTimeout(() => setRowActiveIndex(nextIndex), 50);
43915
+ if (nextIndex === rowActiveIndex) {
43916
+ setTimeout(() => focusActiveRow(), 0);
43917
+ } else {
43918
+ setTimeout(() => setRowActiveIndex(nextIndex), 50);
43919
+ }
43899
43920
  };
43900
43921
  const onKeyDown = React__default.useCallback(
43901
43922
  (event, length, scrollToIndex) => {
@@ -44612,7 +44633,7 @@ function useTableRowDrop(isEnabled = false, onRowDrop) {
44612
44633
  handleDrop: isEnabled ? onRowDrop : void 0
44613
44634
  };
44614
44635
  }
44615
- function useTableRowActiveListener$1(table, onRowActive) {
44636
+ function useTableRowActiveListener(table, onRowActive) {
44616
44637
  var _a;
44617
44638
  const meta = table.options.meta;
44618
44639
  const rows = table.getRowModel().flatRows;
@@ -44724,7 +44745,7 @@ function useTableManager(props, ref, meta, internalColumns) {
44724
44745
  useTableDataListener(instance, length);
44725
44746
  useTableFilterListener(instance, props.onChangeFilter);
44726
44747
  useTableFontSizeListener(instance);
44727
- useTableRowActiveListener$1(instance, props.onRowActive);
44748
+ useTableRowActiveListener(instance, props.onRowActive);
44728
44749
  useTableRowHeightListener(instance);
44729
44750
  useTableRowSelectionListener(instance, props.onRowSelect);
44730
44751
  useTableSearchListener(instance);
@@ -44926,6 +44947,11 @@ function getCellWidthPadding(fontSize) {
44926
44947
  return "16px";
44927
44948
  }
44928
44949
  }
44950
+ function getReachableRowCount(table) {
44951
+ const tableMeta = table.options.meta;
44952
+ const isFilteringActive = table.options.enableGlobalFilter && table.getState().globalFilter;
44953
+ return isFilteringActive ? table.getRowModel().rows.length + table.getBottomRows().length : tableMeta.length + table.getBottomRows().length;
44954
+ }
44929
44955
  function useTableGlobalShortcuts(table, tableRef, scrollToIndex, localShortcuts = false) {
44930
44956
  const tableMeta = table.options.meta;
44931
44957
  const rows = table.getRowModel().rows;
@@ -44938,7 +44964,7 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex, localShortcuts
44938
44964
  if (isElementInsideExternalRelatedOverlay(trigger, tableRef)) {
44939
44965
  return;
44940
44966
  }
44941
- const reachableRows = tableMeta.length + table.getBottomRows().length;
44967
+ const reachableRows = getReachableRowCount(table);
44942
44968
  tableMeta.rowActive.handleKeyDown(event, reachableRows, scrollToIndex);
44943
44969
  tableMeta.rowSelection.handleKeyDown(event, table);
44944
44970
  if (tableMeta.rowActive.rowActiveIndex !== void 0) {
@@ -45904,18 +45930,6 @@ function useRowGroupVirtualisation(table) {
45904
45930
  );
45905
45931
  return isTableGrouped ? rangeExtractor : void 0;
45906
45932
  }
45907
- function useTableRowActiveListener(table, tableRef) {
45908
- const tableMeta = table.options.meta;
45909
- React__default.useEffect(() => {
45910
- var _a, _b;
45911
- if (tableMeta.rowActive.rowActiveIndex !== void 0) {
45912
- const activeRow = ((_a = tableRef.current) == null ? void 0 : _a.querySelector('tbody tr[data-row-active="true"]')) ?? null;
45913
- if (!isElementInsideOrTriggeredFromContainer(document.activeElement, activeRow) && !isElementInteractive(document.activeElement)) {
45914
- (_b = activeRow == null ? void 0 : activeRow.focus) == null ? void 0 : _b.call(activeRow, { preventScroll: true });
45915
- }
45916
- }
45917
- }, [tableMeta.rowActive.rowActiveIndex]);
45918
- }
45919
45933
  function Actions(props) {
45920
45934
  var _a, _b;
45921
45935
  const { actions, actionsLength, data, isActiveRow, rowId, table } = props;
@@ -46250,7 +46264,7 @@ function useTable$1(props, externalRef, renderers, meta) {
46250
46264
  const { style, stylesheet } = useTableStyle(manager.id, manager.instance);
46251
46265
  useTableGlobalShortcuts(manager.instance, ref, renderer2.scrollToIndex, props.enableLocalKeyboardShortcuts);
46252
46266
  useTableRef(manager.instance, ref);
46253
- useTableRowActiveListener(manager.instance, ref);
46267
+ useTableRowActiveListener$1(manager.instance, ref);
46254
46268
  return {
46255
46269
  ...manager,
46256
46270
  props: {
@@ -47133,7 +47147,7 @@ function Body(props) {
47133
47147
  }
47134
47148
  if (tableMeta.rowActive.rowActiveIndex !== void 0) {
47135
47149
  const isFirstRow = tableMeta.rowActive.rowActiveIndex === 0;
47136
- const reachableRows = tableMeta.length + table.getBottomRows().length;
47150
+ const reachableRows = getReachableRowCount(table);
47137
47151
  const isLastRow = tableMeta.rowActive.rowActiveIndex === reachableRows - 1;
47138
47152
  if (event.key === "Tab" || enableHorizontalArrowKeyNavigation && (event.key === "ArrowLeft" || event.key === "ArrowRight")) {
47139
47153
  if (event.key === "Tab" && !hasFocusableElement(event.target.closest("tr[data-row-id]"))) {
@@ -96722,7 +96736,7 @@ const getLinkClasses = (icon = void 0) => clsx(
96722
96736
  "flex h-8 flex-shrink-0 flex-grow-0 cursor-pointer items-center justify-center ",
96723
96737
  "focus:!shadow-none focus:!outline-none focus-visible:!yt-focus-dark",
96724
96738
  "bg-transparent hover:bg-white/[.08] focus:bg-white/[.08] aria-current-page:bg-white/[.08]",
96725
- "text-white hover:text-white focus:text-white",
96739
+ "!text-white hover:text-white focus:text-white",
96726
96740
  {
96727
96741
  "!rounded-full !h-9 !w-9": icon,
96728
96742
  "whitespace-nowrap px-3 rounded text-sm hidden lg:flex": !icon