@economic/taco 2.26.11 → 2.26.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. package/dist/esm/index.css +1 -1
  2. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js +3 -1
  3. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
  4. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/util.js +9 -3
  5. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/util.js.map +1 -1
  6. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +9 -5
  7. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  8. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  9. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js +3 -1
  10. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js.map +1 -1
  11. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js +2 -1
  12. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js.map +1 -1
  13. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +2 -2
  14. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  15. package/dist/index.css +1 -1
  16. package/dist/primitives/Table/Core/components/Header/util.d.ts +1 -1
  17. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +1 -1
  18. package/dist/primitives/Table/Core/useTable.d.ts +1 -1
  19. package/dist/primitives/Table/useTableManager/util/settings.d.ts +0 -1
  20. package/dist/taco.cjs.development.js +28 -13
  21. package/dist/taco.cjs.development.js.map +1 -1
  22. package/dist/taco.cjs.production.min.js +1 -1
  23. package/dist/taco.cjs.production.min.js.map +1 -1
  24. package/package.json +3 -3
@@ -4,7 +4,7 @@ import { ScrollToOptions as ReactVirtualScrollToOptions } from '@tanstack/react-
4
4
  import { useTableRenderers } from '../types';
5
5
  import { TableRef } from '../../types';
6
6
  export declare function useTableRenderer<TType = unknown>(renderers: useTableRenderers<TType>, table: ReactTable<TType>, tableRef: React.RefObject<TableRef>, defaultRowActiveIndex?: number | undefined): {
7
- rows: JSX.Element[] | null;
7
+ rows: (JSX.Element | null)[] | null;
8
8
  style: React.CSSProperties;
9
9
  scrollToIndex: (index: number, options?: ReactVirtualScrollToOptions) => void;
10
10
  };
@@ -17,7 +17,7 @@ export declare type useTableReturnValue<TType = unknown> = {
17
17
  };
18
18
  ref: React.RefObject<TableRef>;
19
19
  renderer: {
20
- rows: JSX.Element[] | null;
20
+ rows: (JSX.Element | null)[] | null;
21
21
  style: React.CSSProperties;
22
22
  scrollToIndex: (index: number, options?: ReactVirtualScrollToOptions) => void;
23
23
  };
@@ -6,7 +6,6 @@ export declare function getSettings<TType = unknown>(table: ReactTable<TType>):
6
6
  columnVisibility: Record<string, boolean> | undefined;
7
7
  excludeUnmatchedRecordsInSearch: boolean | undefined;
8
8
  fontSize: "small" | "medium" | "large" | undefined;
9
- grouping: import("@tanstack/react-table").GroupingState | undefined;
10
9
  rowHeight: "medium" | "short" | "tall" | "extra-tall" | undefined;
11
10
  sorting: import("@tanstack/react-table").SortingState;
12
11
  };
@@ -9754,7 +9754,7 @@ function configureReactTableOptions(options, props) {
9754
9754
  }
9755
9755
  function useReactTableInitialState(props, columns, persistedSettings, defaults) {
9756
9756
  return React__default.useMemo(() => {
9757
- var _persistedSettings$co, _props$defaultSetting, _ref, _persistedSettings$co2, _props$defaultSetting2, _columnPinning$left, _ref2, _persistedSettings$co3, _props$defaultSetting3, _ref3, _ref4, _persistedSettings$co4, _props$defaultSetting4, _ref5, _ref6, _persistedSettings$co5, _props$defaultSetting5, _persistedSettings$se, _props$defaultSetting6, _props$defaultSetting7, _props$defaultSetting8, _ref7, _persistedSettings$gr, _persistedSettings$gr2, _props$defaultSetting9, _props$defaultSetting10;
9757
+ var _persistedSettings$co, _props$defaultSetting, _ref, _persistedSettings$co2, _props$defaultSetting2, _columnPinning$left, _ref2, _persistedSettings$co3, _props$defaultSetting3, _ref3, _ref4, _persistedSettings$co4, _props$defaultSetting4, _ref5, _ref6, _persistedSettings$co5, _props$defaultSetting5, _persistedSettings$se, _props$defaultSetting6, _props$defaultSetting7, _props$defaultSetting8;
9758
9758
  const ignoreNotDefinedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);
9759
9759
  const columnOrder = ensureOrdering(columns, (_persistedSettings$co = persistedSettings.columnOrder) !== null && _persistedSettings$co !== void 0 ? _persistedSettings$co : (_props$defaultSetting = props.defaultSettings) === null || _props$defaultSetting === void 0 ? void 0 : _props$defaultSetting.columnOrder);
9760
9760
  const columnPinning = (_ref = (_persistedSettings$co2 = persistedSettings.columnPinning) !== null && _persistedSettings$co2 !== void 0 ? _persistedSettings$co2 : (_props$defaultSetting2 = props.defaultSettings) === null || _props$defaultSetting2 === void 0 ? void 0 : _props$defaultSetting2.columnPinning) !== null && _ref !== void 0 ? _ref : {};
@@ -9775,7 +9775,7 @@ function useReactTableInitialState(props, columns, persistedSettings, defaults)
9775
9775
  globalFilter: (_persistedSettings$se = persistedSettings.searchQuery) !== null && _persistedSettings$se !== void 0 ? _persistedSettings$se : (_props$defaultSetting6 = props.defaultSettings) === null || _props$defaultSetting6 === void 0 ? void 0 : _props$defaultSetting6.searchQuery,
9776
9776
  sorting: persistedSettings.sorting ? persistedSettings.sorting.filter(ignoreNotDefinedColumns) : (_props$defaultSetting7 = (_props$defaultSetting8 = props.defaultSettings) === null || _props$defaultSetting8 === void 0 ? void 0 : _props$defaultSetting8.sorting) !== null && _props$defaultSetting7 !== void 0 ? _props$defaultSetting7 : defaults.defaultSorting
9777
9777
  };
9778
- if ((_ref7 = (_persistedSettings$gr = (_persistedSettings$gr2 = persistedSettings.grouping) === null || _persistedSettings$gr2 === void 0 ? void 0 : _persistedSettings$gr2.length) !== null && _persistedSettings$gr !== void 0 ? _persistedSettings$gr : (_props$defaultSetting9 = props.defaultSettings) === null || _props$defaultSetting9 === void 0 ? void 0 : (_props$defaultSetting10 = _props$defaultSetting9.grouping) === null || _props$defaultSetting10 === void 0 ? void 0 : _props$defaultSetting10.length) !== null && _ref7 !== void 0 ? _ref7 : props.defaultRowGroupColumnId) {
9778
+ if (props.defaultRowGroupColumnId) {
9779
9779
  state.grouping = [props.defaultRowGroupColumnId];
9780
9780
  // row groups should (all) always be expanded by default
9781
9781
  state.expanded = true;
@@ -10704,6 +10704,7 @@ function getSettings(table) {
10704
10704
  const meta = table.options.meta;
10705
10705
  const state = table.getState();
10706
10706
  return {
10707
+ // commented out properties are here to highlight things we explicitly don't want them saved
10707
10708
  //columnFilters: table.options.enableColumnFilters ? state.columnFilters : undefined,
10708
10709
  columnOrder: meta.columnOrdering.isEnabled ? state.columnOrder : undefined,
10709
10710
  columnPinning: state.columnPinning,
@@ -10711,7 +10712,7 @@ function getSettings(table) {
10711
10712
  columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,
10712
10713
  excludeUnmatchedRecordsInSearch: table.options.enableGlobalFilter,
10713
10714
  fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,
10714
- grouping: table.options.enableGrouping ? state.grouping : undefined,
10715
+ //grouping: table.options.enableGrouping ? state.grouping : undefined,
10715
10716
  rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,
10716
10717
  //searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,
10717
10718
  sorting: state.sorting
@@ -10732,7 +10733,9 @@ function useTableSettingsListener(table, onChangeSettings) {
10732
10733
  return () => clearTimeout(handler);
10733
10734
  }, [
10734
10735
  //state.columnFilters,
10735
- state.columnOrder, state.columnPinning, state.columnSizing, state.columnVisibility, table.options.enableGlobalFilter, meta.fontSize.size, state.grouping, meta.rowHeight.height,
10736
+ state.columnOrder, state.columnPinning, state.columnSizing, state.columnVisibility, table.options.enableGlobalFilter, meta.fontSize.size,
10737
+ //state.grouping,
10738
+ meta.rowHeight.height,
10736
10739
  //state.globalFilter,
10737
10740
  state.sorting]);
10738
10741
  }
@@ -11240,10 +11243,11 @@ function Row(props) {
11240
11243
  const TABLE_SCROLL_PADDING_BOTTOM = 36;
11241
11244
  const TABLE_PADDING_BOTTOM = 120;
11242
11245
  function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
11243
- var _table$getState$group, _virtualItems$;
11246
+ var _table$getState$group, _ref, _virtualItems$padding, _virtualItems$padding2, _ref2, _virtualItems;
11244
11247
  const tableMeta = table.options.meta;
11245
11248
  const rows = table.getRowModel().rows;
11246
11249
  const HEADER_OFFSET_TOTAL = HEADER_ROW_HEIGHT_ESTIMATE * table.getHeaderGroups().length;
11250
+ const isTableGrouped = !!((_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length);
11247
11251
  // expanded rows
11248
11252
  const {
11249
11253
  createRowMeasurer,
@@ -11257,7 +11261,7 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
11257
11261
  getScrollElement: () => tableRef.current,
11258
11262
  overscan: tableMeta.printing.isPrinting ? rows.length : undefined,
11259
11263
  rangeExtractor,
11260
- scrollPaddingStart: (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length ? HEADER_ROW_HEIGHT_ESTIMATE : undefined,
11264
+ scrollPaddingStart: isTableGrouped ? HEADER_ROW_HEIGHT_ESTIMATE : undefined,
11261
11265
  scrollPaddingEnd: HEADER_OFFSET_TOTAL + TABLE_SCROLL_PADDING_BOTTOM,
11262
11266
  paddingEnd: TABLE_PADDING_BOTTOM
11263
11267
  });
@@ -11290,10 +11294,9 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
11290
11294
  }
11291
11295
  }
11292
11296
  }, [virtualItems.length, tableRef.current]);
11293
- // styling for offsetting rows - this "is" the virtualisation
11294
- const [paddingTop, paddingBottom] = virtualItems.length > 0 ? [
11295
11297
  // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0
11296
- Math.max(0, ((_virtualItems$ = virtualItems[1]) !== null && _virtualItems$ !== void 0 ? _virtualItems$ : virtualItems[0]).start - virtualiser.options.scrollMargin - virtualItems[0].size), Math.max(0, virtualiser.getTotalSize() - virtualItems[virtualItems.length - 1].end)] : [0, 0];
11298
+ const paddingStartIndex = isTableGrouped && rows.length > 1 ? 1 : 0;
11299
+ const [paddingTop, paddingBottom] = virtualItems.length > 0 ? [Math.max(0, (_ref = ((_virtualItems$padding = virtualItems[paddingStartIndex]) === null || _virtualItems$padding === void 0 ? void 0 : _virtualItems$padding.start) - virtualiser.options.scrollMargin - ((_virtualItems$padding2 = virtualItems[paddingStartIndex]) === null || _virtualItems$padding2 === void 0 ? void 0 : _virtualItems$padding2.size)) !== null && _ref !== void 0 ? _ref : 0), Math.max(0, (_ref2 = virtualiser.getTotalSize() - ((_virtualItems = virtualItems[virtualItems.length - 1]) === null || _virtualItems === void 0 ? void 0 : _virtualItems.end)) !== null && _ref2 !== void 0 ? _ref2 : 0)] : [0, 0];
11297
11300
  // ensure default active rows are scrolled to
11298
11301
  React__default.useEffect(() => {
11299
11302
  if (defaultRowActiveIndex) {
@@ -11313,6 +11316,10 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
11313
11316
  paddingTop
11314
11317
  };
11315
11318
  content = virtualItems.map(virtualRow => {
11319
+ // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here
11320
+ if (!virtualRow) {
11321
+ return null;
11322
+ }
11316
11323
  const row = rows[virtualRow.index];
11317
11324
  const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);
11318
11325
  return /*#__PURE__*/React__default.createElement(Row, {
@@ -12460,16 +12467,22 @@ function HeaderMenu(props) {
12460
12467
  });
12461
12468
  }
12462
12469
 
12463
- function useSetInitialColumnSizing(id, width, element, canMeasureSize, setColumnSizing) {
12464
- React__default.useEffect(() => {
12470
+ function useSetInitialColumnSizing(id, defaultWidth, width, element, canMeasureSize, setColumnSizing) {
12471
+ React__default.useLayoutEffect(() => {
12465
12472
  // columns must set a pixel width...
12466
12473
  // otherwise when scrolling through the table, the column widths adjust based on the content
12467
12474
  // of the column, this is because to the virtualisation mounting new rows and unmounting old ones
12468
12475
  if (canMeasureSize && element && !Number.isInteger(width) && !isInternalColumn(id)) {
12469
- setColumnSizing(sizes => ({
12476
+ const setWidth = () => setColumnSizing(sizes => ({
12470
12477
  ...sizes,
12471
12478
  [id]: element.getBoundingClientRect().width
12472
12479
  }));
12480
+ // grow columns need to wait for auto layout to run, otherwise they register the incorrect size
12481
+ if (defaultWidth === 'grow') {
12482
+ requestAnimationFrame(setWidth);
12483
+ } else {
12484
+ setWidth();
12485
+ }
12473
12486
  }
12474
12487
  }, [element, canMeasureSize, width]);
12475
12488
  }
@@ -12520,6 +12533,7 @@ function Header$5(props) {
12520
12533
  children: reactTable.flexRender(header.column.columnDef.header, header.getContext()),
12521
12534
  colSpan: header.colSpan,
12522
12535
  customMenu: columnMeta.menu,
12536
+ defaultWidth: columnMeta.defaultWidth,
12523
12537
  hasMenu,
12524
12538
  id: header.id,
12525
12539
  isFiltered: header.column.getIsFiltered(),
@@ -12601,6 +12615,7 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
12601
12615
  className,
12602
12616
  colSpan,
12603
12617
  customMenu,
12618
+ defaultWidth,
12604
12619
  hasMenu,
12605
12620
  id,
12606
12621
  index,
@@ -12626,7 +12641,7 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
12626
12641
  } = props;
12627
12642
  const [ref, setRef] = React__default.useState(null);
12628
12643
  // save column width if none is set
12629
- useSetInitialColumnSizing(id, width, ref, canMeasureSize, setColumnSizing);
12644
+ useSetInitialColumnSizing(id, defaultWidth, width, ref, canMeasureSize, setColumnSizing);
12630
12645
  // feature specific styles
12631
12646
  const style = {};
12632
12647
  // column groups often span multiple columns