@economic/taco 2.64.1-test-1.0 → 2.65.0-alt-tab-popover-focus.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
@@ -3064,7 +3064,7 @@ export declare type Table3Ref = TableRef & {
3064
3064
  editing?: {
3065
3065
  toggleEditing: (enabled: boolean | undefined) => void;
3066
3066
  createRow?: (row: unknown) => Promise<void>;
3067
- save: (rowId: string) => Promise<boolean>;
3067
+ save: (rowId?: string) => Promise<boolean>;
3068
3068
  removeRowChanges: (rowId: string) => Promise<void>;
3069
3069
  };
3070
3070
  };
@@ -3295,6 +3295,7 @@ export declare type TableCommonProps<TType = unknown> = TableFeatureProps<TType>
3295
3295
  toolbarRight?: JSX.Element;
3296
3296
  toolbarPanel?: JSX.Element;
3297
3297
  onEvent?: TableEventHandler;
3298
+ onRowActive?: TableRowActiveHandler<TType>;
3298
3299
  onRowClick?: TableRowClickHandler<TType>;
3299
3300
  onRowDrag?: TableRowDragHandler<TType>;
3300
3301
  onRowDrop?: TableRowDropHandler<TType>;
@@ -3418,6 +3419,8 @@ export declare type TableRowActionRenderer<TType = unknown> = (row: TType, helpe
3418
3419
  };
3419
3420
  }) => JSX.Element | null;
3420
3421
 
3422
+ export declare type TableRowActiveHandler<TType = unknown> = (row: TType | undefined) => void;
3423
+
3421
3424
  export declare type TableRowClickHandler<TType = unknown> = (row: TType) => void;
3422
3425
 
3423
3426
  export declare type TableRowDragHandler<TType = unknown> = (rows: TType[], showPlaceholder: (text: string) => void, setDataTransfer: (data: string) => void) => void;
package/dist/taco.js CHANGED
@@ -9845,8 +9845,25 @@ function isElementTriggeredFromContainer(element, container) {
9845
9845
  }
9846
9846
  return false;
9847
9847
  }
9848
+ const isDialogOpenedFromContainer = (element, container) => {
9849
+ if (!container) {
9850
+ return false;
9851
+ }
9852
+ let currentDialog = element == null ? void 0 : element.closest('[role="dialog"]');
9853
+ while (currentDialog == null ? void 0 : currentDialog.id) {
9854
+ const opener = document.querySelector(`[aria-controls="${currentDialog.id}"]`);
9855
+ if (!opener) {
9856
+ return false;
9857
+ }
9858
+ if (container.contains(opener)) {
9859
+ return true;
9860
+ }
9861
+ currentDialog = opener.closest('[role="dialog"]');
9862
+ }
9863
+ return false;
9864
+ };
9848
9865
  function isElementInsideOrTriggeredFromContainer(element, container) {
9849
- return isElementTriggeredFromContainer(element, container) || !!(container == null ? void 0 : container.contains(element));
9866
+ return isElementTriggeredFromContainer(element, container) || !!(container == null ? void 0 : container.contains(element)) || isDialogOpenedFromContainer(element, container);
9850
9867
  }
9851
9868
  function isElementInsideOverlay(element) {
9852
9869
  return !!(element == null ? void 0 : element.closest("[role=dialog],[role=menu]"));
@@ -18467,7 +18484,7 @@ const useCombobox = (props, ref) => {
18467
18484
  React.useEffect(() => {
18468
18485
  const isCurrentValue = value !== void 0 && value !== null && inputValue === String(value);
18469
18486
  if (inputValue && data.length && !isCurrentValue) {
18470
- setCurrentIndex(0);
18487
+ setCurrentIndex(getIndexFromValue(data, inputValue) || 0);
18471
18488
  if (!open) {
18472
18489
  setOpen(true);
18473
18490
  }
@@ -25731,6 +25748,13 @@ const Dialog = React.forwardRef(function Dialog2(props, ref) {
25731
25748
  }),
25732
25749
  [closeOnEscape, drawerOpen, draggable, drawer, extra, open, otherProps, showCloseButton]
25733
25750
  );
25751
+ React.useEffect(() => {
25752
+ const onFocusOut = (event) => {
25753
+ event.stopImmediatePropagation();
25754
+ };
25755
+ document.addEventListener("focusout", onFocusOut);
25756
+ return () => document.removeEventListener("focusout", onFocusOut);
25757
+ }, []);
25734
25758
  return /* @__PURE__ */ React.createElement(DialogContext.Provider, { value: context }, /* @__PURE__ */ React.createElement($5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, { defaultOpen, open, onOpenChange: onChange }, trigger && /* @__PURE__ */ React.createElement(Trigger$4, null, trigger), children));
25735
25759
  });
25736
25760
  Dialog.Trigger = Trigger$4;
@@ -36605,6 +36629,17 @@ function useTableRowDrop(isEnabled = false, onRowDrop) {
36605
36629
  handleDrop: isEnabled ? onRowDrop : void 0
36606
36630
  };
36607
36631
  }
36632
+ function useTableRowActiveListener$1(table, onRowActive) {
36633
+ var _a;
36634
+ const meta = table.options.meta;
36635
+ const rows = table.getRowModel().flatRows;
36636
+ const currentRow = meta.rowActive.rowActiveIndex !== void 0 ? (_a = rows[meta.rowActive.rowActiveIndex]) == null ? void 0 : _a.original : void 0;
36637
+ React__default.useEffect(() => {
36638
+ if (meta.rowActive.isEnabled && onRowActive) {
36639
+ onRowActive(currentRow);
36640
+ }
36641
+ }, [meta.rowActive.isEnabled, currentRow, onRowActive]);
36642
+ }
36608
36643
  const DEFAULT_EMPTY_ARRAY = [];
36609
36644
  function useTableManager(props, ref, meta, internalColumns) {
36610
36645
  var _a;
@@ -36705,6 +36740,7 @@ function useTableManager(props, ref, meta, internalColumns) {
36705
36740
  useTableDataListener(instance, length);
36706
36741
  useTableFilterListener(instance, props.onChangeFilter);
36707
36742
  useTableFontSizeListener(instance);
36743
+ useTableRowActiveListener$1(instance, props.onRowActive);
36708
36744
  useTableRowHeightListener(instance);
36709
36745
  useTableRowSelectionListener(instance, props.onRowSelect);
36710
36746
  useTableSearchListener(instance);
@@ -37818,15 +37854,6 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
37818
37854
  virtualiser.measure();
37819
37855
  }
37820
37856
  }, [expandedState]);
37821
- React__default.useEffect(() => {
37822
- const totalSize2 = virtualiser.getTotalSize();
37823
- console.log("before measuring totalSize", totalSize2);
37824
- virtualiser.measure();
37825
- setTimeout(() => {
37826
- const totalSize3 = virtualiser.getTotalSize();
37827
- console.log("after measuring totalSize", totalSize3);
37828
- }, 1e3);
37829
- }, [tableMeta.fontSize.size, tableMeta.rowHeight.height, JSON.stringify(table.getState().sorting), rows.length]);
37830
37857
  const totalSize = virtualiser.getTotalSize();
37831
37858
  const virtualItems = virtualiser.getVirtualItems();
37832
37859
  const scrollToIndex = React__default.useCallback(
@@ -38546,14 +38573,13 @@ const DisplayRow = React__default.memo(function DisplayRow2(props) {
38546
38573
  }
38547
38574
  const ref = React__default.useRef(null);
38548
38575
  const expansionRef = React__default.useRef(null);
38549
- const rowSize = useResizeObserver$1(ref, true);
38550
38576
  const expandedRowSize = useResizeObserver$1(expansionRef, !!expandedRow);
38551
38577
  React__default.useEffect(() => {
38552
38578
  var _a2, _b2;
38553
38579
  const rowHeight = ((_a2 = ref.current) == null ? void 0 : _a2.getBoundingClientRect().height) ?? 0;
38554
38580
  const expansionHeight = ((_b2 = expansionRef.current) == null ? void 0 : _b2.getBoundingClientRect().height) ?? 0;
38555
38581
  measureRow(rowHeight + expansionHeight);
38556
- }, [rowSize, expandedRowSize, measureRow]);
38582
+ }, [expansionRef.current, expandedRowSize == null ? void 0 : expandedRowSize.height]);
38557
38583
  const className = clsx("group/row", otherAttributes.className, {
38558
38584
  "hover:cursor-grab": tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== "function",
38559
38585
  "hover:cursor-pointer": typeof attributes.onClick === "function"
@@ -45169,11 +45195,11 @@ function guessComparatorsBasedOnControl(column) {
45169
45195
  }
45170
45196
  const FilterContext = React__default.createContext([]);
45171
45197
  const FilterColumn = React__default.forwardRef((props, ref) => {
45172
- const { allColumns, onChange: handleChange, value = null, ...attributes } = props;
45198
+ const { allHeaders, onChange: handleChange, value = null, ...attributes } = props;
45173
45199
  const { texts } = useLocalization();
45174
45200
  const filters = React__default.useContext(FilterContext);
45175
- const selectedColumn = allColumns.find((column) => column.id === value);
45176
- const warning2 = selectedColumn && !selectedColumn.getIsVisible();
45201
+ const selectedColumn = allHeaders.find((header) => header.id === value);
45202
+ const warning2 = selectedColumn && !selectedColumn.column.getIsVisible();
45177
45203
  return /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col" }, /* @__PURE__ */ React__default.createElement(
45178
45204
  Field,
45179
45205
  {
@@ -45191,23 +45217,23 @@ const FilterColumn = React__default.forwardRef((props, ref) => {
45191
45217
  onChange: handleChange,
45192
45218
  value
45193
45219
  },
45194
- allColumns.map((column) => {
45195
- var _a, _b, _c;
45220
+ allHeaders.map((header) => {
45221
+ var _a, _b;
45196
45222
  return /* @__PURE__ */ React__default.createElement(
45197
45223
  Select22.Option,
45198
45224
  {
45199
- key: column.id,
45200
- value: column.id,
45201
- postfix: !column.getIsVisible() || column.getIsGrouped() ? /* @__PURE__ */ React__default.createElement(
45225
+ key: header.column.id,
45226
+ value: header.column.id,
45227
+ postfix: !header.column.getIsVisible() || header.column.getIsGrouped() ? /* @__PURE__ */ React__default.createElement(
45202
45228
  Tooltip$3,
45203
45229
  {
45204
- title: column.getIsGrouped() ? texts.table.filters.hiddenGroupedColumn : texts.table.filters.hiddenColumn
45230
+ title: header.column.getIsGrouped() ? texts.table.filters.hiddenGroupedColumn : texts.table.filters.hiddenColumn
45205
45231
  },
45206
45232
  /* @__PURE__ */ React__default.createElement(Icon$1, { name: "eye-off", className: "text-grey-500 !h-5 !w-5" })
45207
45233
  ) : void 0,
45208
- disabled: column.id !== value && (!column.getCanFilter() || !!filters.find((f2) => f2.id === column.id))
45234
+ disabled: header.column.id !== value && (!header.column.getCanFilter() || !!filters.find((f2) => f2.id === header.column.id))
45209
45235
  },
45210
- ((_a = column.columnDef.meta) == null ? void 0 : _a.header) + (column.parent ? ` (${(_c = (_b = column.parent) == null ? void 0 : _b.columnDef.meta) == null ? void 0 : _c.header})` : "")
45236
+ /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, flexRender(header.column.columnDef.header, header.getContext()), header.column.parent ? ` (${flexRender((_b = (_a = header.column.parent) == null ? void 0 : _a.columnDef.meta) == null ? void 0 : _b.header, header.getContext())})` : "")
45211
45237
  );
45212
45238
  })
45213
45239
  )
@@ -45376,9 +45402,9 @@ function Control(props) {
45376
45402
  );
45377
45403
  }
45378
45404
  function Filter(props) {
45379
- const { allColumns, filter: filter2, onChange: handleChange, onRemove, position } = props;
45405
+ const { allHeaders, filter: filter2, onChange: handleChange, onRemove, position } = props;
45380
45406
  const { texts } = useLocalization();
45381
- const column = allColumns.find((c2) => c2.id === filter2.id);
45407
+ const column = allHeaders.find((header) => header.column.id === filter2.id);
45382
45408
  const ref = React__default.useRef(null);
45383
45409
  const {
45384
45410
  id: id2,
@@ -45386,13 +45412,13 @@ function Filter(props) {
45386
45412
  } = filter2;
45387
45413
  const handleChangeColumn = (columnId) => {
45388
45414
  var _a, _b, _c;
45389
- const previousColumn = allColumns.find((column2) => column2.id === id2);
45390
- const nextColumn = allColumns.find((column2) => column2.id === columnId);
45391
- if (((_a = previousColumn == null ? void 0 : previousColumn.columnDef.meta) == null ? void 0 : _a.dataType) && ((_b = previousColumn == null ? void 0 : previousColumn.columnDef.meta) == null ? void 0 : _b.dataType) === ((_c = nextColumn == null ? void 0 : nextColumn.columnDef.meta) == null ? void 0 : _c.dataType)) {
45415
+ const previousColumn = allHeaders.find((header) => header.column.id === id2);
45416
+ const nextColumn = allHeaders.find((header) => header.column.id === columnId);
45417
+ if (((_a = previousColumn == null ? void 0 : previousColumn.column.columnDef.meta) == null ? void 0 : _a.dataType) && ((_b = previousColumn == null ? void 0 : previousColumn.column.columnDef.meta) == null ? void 0 : _b.dataType) === ((_c = nextColumn == null ? void 0 : nextColumn.column.columnDef.meta) == null ? void 0 : _c.dataType)) {
45392
45418
  handleChange(position, { id: columnId, value: filter2.value });
45393
45419
  return;
45394
45420
  }
45395
- const validComparators = guessComparatorsBasedOnControl(nextColumn);
45421
+ const validComparators = guessComparatorsBasedOnControl(nextColumn == null ? void 0 : nextColumn.column);
45396
45422
  const value2 = {
45397
45423
  comparator: validComparators[0],
45398
45424
  value: void 0
@@ -45415,13 +45441,13 @@ function Filter(props) {
45415
45441
  ref.current.focus();
45416
45442
  }
45417
45443
  }, [id2]);
45418
- return /* @__PURE__ */ React__default.createElement("div", { className: "flex items-start gap-2" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right" }, position > 0 ? texts.table.filters.conditions.and : texts.table.filters.conditions.where), /* @__PURE__ */ React__default.createElement(FilterColumn, { allColumns, onChange: handleChangeColumn, value: id2, ref }), /* @__PURE__ */ React__default.createElement(FilterComparator, { column, onChange: handleChangeComparator, value: comparator }), /* @__PURE__ */ React__default.createElement(FilterValue, { column, comparator, onChange: handleChangeValue, value }), onRemove ? /* @__PURE__ */ React__default.createElement(IconButton, { appearance: "discrete", className: "ml-auto", icon: "close", onClick: handleRemove }) : null);
45444
+ return /* @__PURE__ */ React__default.createElement("div", { className: "flex items-start gap-2" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right" }, position > 0 ? texts.table.filters.conditions.and : texts.table.filters.conditions.where), /* @__PURE__ */ React__default.createElement(FilterColumn, { allHeaders, onChange: handleChangeColumn, value: id2, ref }), /* @__PURE__ */ React__default.createElement(FilterComparator, { column: column == null ? void 0 : column.column, onChange: handleChangeComparator, value: comparator }), /* @__PURE__ */ React__default.createElement(FilterValue, { column: column == null ? void 0 : column.column, comparator, onChange: handleChangeValue, value }), onRemove ? /* @__PURE__ */ React__default.createElement(IconButton, { appearance: "discrete", className: "ml-auto", icon: "close", onClick: handleRemove }) : null);
45419
45445
  }
45420
45446
  const placeholderFilter = { id: "", value: { comparator: TableFilterComparator.Contains, value: void 0 } };
45421
45447
  function ManageFiltersPopover(props) {
45422
45448
  const { length, table, ...popoverProps } = props;
45423
45449
  const { locale: locale2, texts } = useLocalization();
45424
- const allColumns = table.getAllLeafColumns().filter((column) => !isInternalColumn(column.id)).sort(sortByHeader);
45450
+ const allHeaders = table.getLeafHeaders().filter((column) => !isInternalColumn(column.id)).sort((headerA, headerB) => sortByHeader(headerA.column, headerB.column));
45425
45451
  const columnFilters = table.getState().columnFilters;
45426
45452
  const tableMeta = table.options.meta;
45427
45453
  const [filters, setFilters] = React__default.useState(columnFilters.length ? columnFilters : [placeholderFilter]);
@@ -45460,7 +45486,7 @@ function ManageFiltersPopover(props) {
45460
45486
  if (f2.id === null || f2.id === "") {
45461
45487
  return false;
45462
45488
  }
45463
- const controlRenderer = (_b = (_a = allColumns.find((c2) => c2.id === f2.id)) == null ? void 0 : _a.columnDef.meta) == null ? void 0 : _b.control;
45489
+ const controlRenderer = (_b = (_a = allHeaders.find((header) => header.column.id === f2.id)) == null ? void 0 : _a.column.columnDef.meta) == null ? void 0 : _b.control;
45464
45490
  if (f2.value.comparator === TableFilterComparator.IsEmpty || f2.value.comparator === TableFilterComparator.IsNotEmpty || controlRenderer === "switch") {
45465
45491
  return true;
45466
45492
  }
@@ -45490,7 +45516,7 @@ function ManageFiltersPopover(props) {
45490
45516
  Filter,
45491
45517
  {
45492
45518
  key: `filter_${index2}`,
45493
- allColumns,
45519
+ allHeaders,
45494
45520
  filter: filter2,
45495
45521
  position: index2,
45496
45522
  onChange: handleChangeFilter,
@@ -53930,14 +53956,6 @@ function isTableScrolled(ref) {
53930
53956
  function useTableEditingListener(table, tableRef, scrollToIndex) {
53931
53957
  const tableMeta = table.options.meta;
53932
53958
  const localization = useLocalization();
53933
- useLazyEffect(() => {
53934
- return () => {
53935
- var _a;
53936
- if (tableMeta.editing.isEditing && tableMeta.rowActive.rowActiveIndex !== void 0) {
53937
- tableMeta.editing.saveChanges(table, (_a = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex]) == null ? void 0 : _a.id);
53938
- }
53939
- };
53940
- }, [tableMeta.rowActive.rowActiveIndex, tableMeta.editing.isEditing]);
53941
53959
  const hasChanges = tableMeta.editing.hasChanges();
53942
53960
  React__default.useEffect(() => {
53943
53961
  function showUnsavedChangesWarning(event) {
@@ -55282,7 +55300,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55282
55300
  var _a, _b, _c;
55283
55301
  return (_c = (_b = (_a = state.changes.errors) == null ? void 0 : _a[cell.row.id]) == null ? void 0 : _b.cells) == null ? void 0 : _c[cell.column.id];
55284
55302
  }
55285
- async function onCellChanged(cell, rowIndex, nextValue, shouldRunUpdaters = true) {
55303
+ async function onCellChanged(cell, rowIndex, nextValue, shouldRunUpdaters = true, shouldRunValidation = true) {
55286
55304
  var _a;
55287
55305
  const tableMeta = cell.getContext().table.options.meta;
55288
55306
  const state2 = tableMeta.editing.getState();
@@ -55312,7 +55330,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55312
55330
  const nextMoveReasons = { ...state2.changes.moveReasons[cell.row.id] };
55313
55331
  const nextCellErrors = { ...(_a = state2.changes.errors[cell.row.id]) == null ? void 0 : _a.cells };
55314
55332
  let validationErrors = {};
55315
- if (validator && Object.keys(nextChanges).length && original) {
55333
+ if (validator && Object.keys(nextChanges).length && original && shouldRunValidation) {
55316
55334
  const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };
55317
55335
  validationErrors = await validator(nextRowValue) ?? {};
55318
55336
  }
@@ -55440,7 +55458,9 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55440
55458
  return completed;
55441
55459
  }
55442
55460
  async function discardChanges(rowId, table) {
55443
- table.resetRowPinning(true);
55461
+ if (rowId.startsWith(TEMPORARY_ROW_ID_PREFIX)) {
55462
+ table.resetRowPinning(true);
55463
+ }
55444
55464
  dispatch({
55445
55465
  type: "removeRow",
55446
55466
  rowId,
@@ -55794,7 +55814,7 @@ function EditingControlCell(props) {
55794
55814
  if (hasChanged) {
55795
55815
  tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
55796
55816
  if (hasNonTextControl) {
55797
- requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
55817
+ requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue, true, false));
55798
55818
  }
55799
55819
  }
55800
55820
  },
@@ -55807,7 +55827,7 @@ function EditingControlCell(props) {
55807
55827
  }
55808
55828
  requestAnimationFrame(() => {
55809
55829
  tableMeta.editing.toggleDetailedMode(false);
55810
- tableMeta.editing.onCellChanged(cell, rowIndex, void 0, !hasNonTextControl);
55830
+ tableMeta.editing.onCellChanged(cell, rowIndex, void 0, !hasNonTextControl, true);
55811
55831
  });
55812
55832
  },
55813
55833
  [hasNonTextControl, cell.row.id, JSON.stringify(rowChanges), rowIndex, cell.column.id, cell.row.original]
@@ -56103,6 +56123,11 @@ function Row(props) {
56103
56123
  }
56104
56124
  }
56105
56125
  }, [tableMeta.editing.isEditing, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.lastFocusedCellIndex]);
56126
+ useLazyEffect(() => {
56127
+ if (tableMeta.editing.isEditing && !isActiveRow) {
56128
+ tableMeta.editing.saveChanges(table, row.id);
56129
+ }
56130
+ }, [isActiveRow]);
56106
56131
  const handleFocus = React__default.useCallback(
56107
56132
  (event) => {
56108
56133
  var _a;