@economic/taco 2.26.3 → 2.26.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +2 -2
  2. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
  3. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +4 -2
  4. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  5. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js +2 -2
  6. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
  7. package/dist/esm/packages/taco/src/primitives/Table/Core/features/{useStylesheet.js → useTableStyle.js} +24 -15
  8. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyle.js.map +1 -0
  9. package/dist/esm/packages/taco/src/primitives/Table/Core/features/{useStylesheetColumnFreezing.js → useTableStyleColumnFreezing.js} +6 -4
  10. package/dist/esm/packages/taco/src/primitives/Table/Core/features/{useStylesheetColumnFreezing.js.map → useTableStyleColumnFreezing.js.map} +1 -1
  11. package/dist/esm/packages/taco/src/primitives/Table/Core/features/{useStylesheetCssGrid.js → useTableStyleGrid.js} +12 -5
  12. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleGrid.js.map +1 -0
  13. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +6 -2
  14. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  15. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js +25 -5
  16. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js.map +1 -1
  17. package/dist/primitives/Table/Core/features/useTableStyle.d.ts +797 -0
  18. package/dist/primitives/Table/Core/features/useTableStyleColumnFreezing.d.ts +4 -0
  19. package/dist/primitives/Table/Core/features/useTableStyleGrid.d.ts +7 -0
  20. package/dist/primitives/Table/Core/useTable.d.ts +2 -1
  21. package/dist/primitives/Table/useTableManager/features/useTableServerLoading.d.ts +1 -0
  22. package/dist/taco.cjs.development.js +72 -27
  23. package/dist/taco.cjs.development.js.map +1 -1
  24. package/dist/taco.cjs.production.min.js +1 -1
  25. package/dist/taco.cjs.production.min.js.map +1 -1
  26. package/package.json +2 -2
  27. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useStylesheet.js.map +0 -1
  28. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useStylesheetCssGrid.js.map +0 -1
  29. package/dist/primitives/Table/Core/features/useStylesheet.d.ts +0 -3
  30. package/dist/primitives/Table/Core/features/useStylesheetColumnFreezing.d.ts +0 -2
  31. package/dist/primitives/Table/Core/features/useStylesheetCssGrid.d.ts +0 -3
@@ -0,0 +1,4 @@
1
+ import { Table as ReactTable } from '@tanstack/react-table';
2
+ export declare function useTableStyleColumnFreezing<TType = unknown>(tableId: string, table: ReactTable<TType>): {
3
+ stylesheet: string;
4
+ };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { Table as ReactTable } from '@tanstack/react-table';
3
+ import { TableFontSize } from '../../types';
4
+ export declare function useTableStyleGrid<TType = unknown>(tableId: string, table: ReactTable<TType>, fontSize: TableFontSize): {
5
+ style: React.CSSProperties;
6
+ stylesheet: string;
7
+ };
@@ -21,7 +21,8 @@ export declare type useTableReturnValue<TType = unknown> = {
21
21
  style: React.CSSProperties;
22
22
  scrollToIndex: (index: number, options?: ReactVirtualScrollToOptions) => void;
23
23
  };
24
- stylesheet: JSX.Element;
24
+ style: React.CSSProperties;
25
+ stylesheet: string;
25
26
  state: ReactTableState;
26
27
  };
27
28
  export declare function useTable<TType = unknown, TMeta = {}>(props: TableProps<TType>, externalRef: React.Ref<TableRef>, renderers: useTableRenderers<TType>, meta?: Partial<ReactTableMeta<TType>> & TMeta): useTableReturnValue<TType>;
@@ -1,6 +1,7 @@
1
1
  import { TableServerLoadAllHandler, TableServerLoadAllState, TableServerLoadPageHandler } from '../../types';
2
2
  export declare function useTableServerLoading(loadPage?: TableServerLoadPageHandler, loadAll?: TableServerLoadAllHandler, pageSize?: number): {
3
3
  isEnabled: boolean;
4
+ isReady: boolean;
4
5
  loadPage: TableServerLoadPageHandler | undefined;
5
6
  loadAll: TableServerLoadAllHandler | undefined;
6
7
  loadAllIfNeeded: TableServerLoadAllHandler | undefined;
@@ -10413,34 +10413,53 @@ function useTableDataLoader(fetch, fetchAll, options = {
10413
10413
 
10414
10414
  function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
10415
10415
  const isEnabled = !!loadPage && !!loadAll;
10416
+ const [isReady, setReady] = React__default.useState(false);
10416
10417
  const [loadAllStatus, setLoadedStatus] = React__default.useState(exports.TableServerLoadAllState.Incomplete);
10418
+ let _loadPage;
10417
10419
  let _loadAll;
10418
10420
  let _loadAllIfNeeded;
10421
+ if (typeof loadPage === 'function') {
10422
+ _loadPage = function (...args) {
10423
+ try {
10424
+ const _temp = function () {
10425
+ if (typeof loadPage === 'function') {
10426
+ return Promise.resolve(loadPage(...args)).then(function () {
10427
+ setReady(true);
10428
+ });
10429
+ }
10430
+ }();
10431
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
10432
+ } catch (e) {
10433
+ return Promise.reject(e);
10434
+ }
10435
+ };
10436
+ }
10419
10437
  if (typeof loadAll === 'function') {
10420
10438
  _loadAll = function (...args) {
10421
10439
  try {
10422
- const _temp = function () {
10440
+ const _temp2 = function () {
10423
10441
  if (typeof loadAll === 'function') {
10424
10442
  setLoadedStatus(exports.TableServerLoadAllState.Loading);
10425
10443
  return Promise.resolve(loadAll(...args)).then(function () {
10426
10444
  setLoadedStatus(exports.TableServerLoadAllState.Completed);
10445
+ setReady(true);
10427
10446
  });
10428
10447
  }
10429
10448
  }();
10430
- return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
10449
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
10431
10450
  } catch (e) {
10432
10451
  return Promise.reject(e);
10433
10452
  }
10434
10453
  };
10435
10454
  _loadAllIfNeeded = function (...args) {
10436
10455
  try {
10437
- const _temp2 = function () {
10456
+ const _temp3 = function () {
10438
10457
  if (loadAllStatus === exports.TableServerLoadAllState.Incomplete) {
10439
10458
  var _loadAll2;
10440
10459
  return Promise.resolve((_loadAll2 = _loadAll) === null || _loadAll2 === void 0 ? void 0 : _loadAll2(...args)).then(function () {});
10441
10460
  }
10442
10461
  }();
10443
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
10462
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
10444
10463
  } catch (e) {
10445
10464
  return Promise.reject(e);
10446
10465
  }
@@ -10448,7 +10467,8 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
10448
10467
  }
10449
10468
  return {
10450
10469
  isEnabled,
10451
- loadPage,
10470
+ isReady,
10471
+ loadPage: _loadPage,
10452
10472
  loadAll: _loadAll,
10453
10473
  loadAllIfNeeded: _loadAllIfNeeded,
10454
10474
  loadAllStatus,
@@ -10896,7 +10916,7 @@ function useTableManager(props, meta, internalColumns) {
10896
10916
  };
10897
10917
  }
10898
10918
 
10899
- function useStylesheetCssGrid(tableId, table, fontSize) {
10919
+ function useTableStyleGrid(tableId, table, fontSize) {
10900
10920
  const tableMeta = table.options.meta;
10901
10921
  const allVisibleColumns = table.getVisibleLeafColumns();
10902
10922
  const columnSizing = table.getState().columnSizing;
@@ -10944,12 +10964,19 @@ function useStylesheetCssGrid(tableId, table, fontSize) {
10944
10964
  }, '');
10945
10965
  // we have to be specific so that nested tables don't inherit the same css
10946
10966
  const hiddenColumns = printHiddenColumns.map(id => `table[data-taco^='table']#${tableId} > thead > tr > th[data-cell-id='${id}']\n,table[data-taco^='table']#${tableId} > tbody > tr > td[data-cell-id='${id}']\n`).join(',');
10947
- return `table[data-taco^='table']#${tableId} { grid-template-columns: ${gridTemplateColumns}; grid-template-rows: ${gridTemplateRows}; }
10948
- @media print { table[data-taco^='table']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''} }`;
10967
+ const style = {
10968
+ gridTemplateColumns,
10969
+ gridTemplateRows
10970
+ };
10971
+ const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''}}`;
10972
+ return {
10973
+ style,
10974
+ stylesheet
10975
+ };
10949
10976
  }, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);
10950
10977
  }
10951
10978
 
10952
- function useStylesheetColumnFreezing(tableId, table) {
10979
+ function useTableStyleColumnFreezing(tableId, table) {
10953
10980
  const {
10954
10981
  columnPinning
10955
10982
  } = table.getState();
@@ -10986,20 +11013,32 @@ function useStylesheetColumnFreezing(tableId, table) {
10986
11013
  }
10987
11014
  return styles.join('\n');
10988
11015
  }, [columnPinning]);
10989
- return stylesheet;
11016
+ return {
11017
+ stylesheet
11018
+ };
10990
11019
  }
10991
11020
 
10992
- function useStylesheet(tableId, table) {
11021
+ function useTableStyle(tableId, table) {
10993
11022
  const tableMeta = table.options.meta;
10994
- const cssGridStylesheet = useStylesheetCssGrid(tableId, table, tableMeta.fontSize.size);
10995
- const columnFreezingStylesheet = useStylesheetColumnFreezing(tableId, table);
10996
- const genericStylesheet = `table[data-taco^='table']#${tableId} {
10997
- --table-header-group-depth: ${table.getHeaderGroups().length};
10998
- --table-cell-padding-x: ${getCellWidthPadding(tableMeta.fontSize.size)};
10999
- --table-cell-padding-y: ${getCellHeightPadding(tableMeta.rowHeight.height, tableMeta.fontSize.size)};
11000
- }`;
11001
- const css = [genericStylesheet, cssGridStylesheet, columnFreezingStylesheet].filter(s => !!s).join('\n');
11002
- return /*#__PURE__*/React__default.createElement("style", null, css);
11023
+ const {
11024
+ style: cssGridStyle,
11025
+ stylesheet: cssGridStylesheet
11026
+ } = useTableStyleGrid(tableId, table, tableMeta.fontSize.size);
11027
+ const {
11028
+ stylesheet: columnFreezingStylesheet
11029
+ } = useTableStyleColumnFreezing(tableId, table);
11030
+ const style = {
11031
+ // css vars required by children of table
11032
+ '--table-header-group-depth': table.getHeaderGroups().length,
11033
+ '--table-cell-padding-x': getCellWidthPadding(tableMeta.fontSize.size),
11034
+ '--table-cell-padding-y': getCellHeightPadding(tableMeta.rowHeight.height, tableMeta.fontSize.size),
11035
+ ...cssGridStyle
11036
+ };
11037
+ const stylesheet = [cssGridStylesheet, columnFreezingStylesheet].filter(s => !!s).join('\n');
11038
+ return {
11039
+ style,
11040
+ stylesheet
11041
+ };
11003
11042
  }
11004
11043
  // we cannot just use a fixed height because our rows need to grow in height (images, edit mode validation etc)
11005
11044
  function getCellHeightPadding(height, fontSize) {
@@ -11758,7 +11797,10 @@ function useTable(props, externalRef, renderers, meta) {
11758
11797
  // configure the virtualised renderer
11759
11798
  const renderer = useTableRenderer(renderers, manager.instance, ref, props.defaultRowActiveIndex);
11760
11799
  // configure dynamic styling
11761
- const stylesheet = useStylesheet(manager.id, manager.instance);
11800
+ const {
11801
+ style,
11802
+ stylesheet
11803
+ } = useTableStyle(manager.id, manager.instance);
11762
11804
  // configure global keyboard shortcuts
11763
11805
  useTableGlobalShortcuts(manager.instance, ref, renderer.scrollToIndex);
11764
11806
  // augment the ref with some helper functions
@@ -11775,6 +11817,7 @@ function useTable(props, externalRef, renderers, meta) {
11775
11817
  toolbarRight: props.toolbarRight
11776
11818
  },
11777
11819
  renderer,
11820
+ style,
11778
11821
  stylesheet,
11779
11822
  ref
11780
11823
  };
@@ -12361,11 +12404,11 @@ function HeaderMenu(props) {
12361
12404
  // can't use display: none because the button needs to be focusable
12362
12405
  const className = cn(
12363
12406
  // positioning
12364
- 'justify-end -mr-1 overflow-hidden',
12407
+ 'justify-end overflow-hidden',
12365
12408
  // sizing
12366
12409
  '!h-6 !w-0 !min-h-[theme(spacing.6)] !min-w-0',
12367
12410
  // visible - hover
12368
- 'group-hover/header:!w-6 group-hover/header:!min-w-[theme(spacing.6)]',
12411
+ 'group-hover/header:!w-6 group-hover/header:!min-w-[theme(spacing.6)] group-hover/header:-mr-1',
12369
12412
  // visible - expanded
12370
12413
  'aria-expanded:!w-6 aria-expanded:!min-w-[theme(spacing.6)]',
12371
12414
  // visible - focus
@@ -15709,17 +15752,19 @@ function TableGrid(props) {
15709
15752
  const handleFocus = table.meta.rowActive.rowActiveIndex === undefined ? event => {
15710
15753
  table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);
15711
15754
  } : undefined;
15712
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, table.stylesheet, /*#__PURE__*/React__default.createElement(focus.FocusScope, null, /*#__PURE__*/React__default.createElement("table", Object.assign({}, attributes, {
15755
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("style", null, table.stylesheet), /*#__PURE__*/React__default.createElement(focus.FocusScope, null, /*#__PURE__*/React__default.createElement("table", Object.assign({}, attributes, {
15713
15756
  id: table.id,
15714
15757
  "data-table-font-size": table.meta.fontSize.size,
15758
+ "data-table-grouped": !!((_table$state$grouping = table.state.grouping) !== null && _table$state$grouping !== void 0 && _table$state$grouping.length),
15715
15759
  "data-table-horizontally-scrolled": table.meta.columnFreezing.isHorizontallyScrolled ? true : undefined,
15760
+ "data-table-status": table.meta.server.isEnabled ? table.meta.server.isReady ? 'ready' : undefined : 'ready',
15716
15761
  "data-table-pause-hover": table.meta.rowActive.isHoverStatePaused ? true : undefined,
15717
15762
  "data-table-resizing": table.state.columnSizingInfo.isResizingColumn ? true : undefined,
15718
15763
  "data-table-row-height": table.meta.rowHeight.height,
15719
- "data-table-grouped": !!((_table$state$grouping = table.state.grouping) !== null && _table$state$grouping !== void 0 && _table$state$grouping.length),
15720
15764
  onFocus: handleFocus,
15721
15765
  onScroll: table.meta.columnFreezing.handleScroll,
15722
15766
  ref: table.ref,
15767
+ style: table.style,
15723
15768
  tabIndex: -1
15724
15769
  }), /*#__PURE__*/React__default.createElement("thead", null, table.instance.getHeaderGroups().map(headerGroup => ( /*#__PURE__*/React__default.createElement("tr", {
15725
15770
  key: headerGroup.id
@@ -18251,8 +18296,8 @@ function Row$2(props) {
18251
18296
  }
18252
18297
  }, [tableMeta.editing.isEditing, isActiveRow]);
18253
18298
  const attributes = {
18254
- 'data-row-editing-invalid': tableMeta.editing.hasRowErrors(row.id) ? !tableMeta.editing.hasRowErrorsSeen(row.id) ? 'unseen' : true : undefined,
18255
- 'data-row-editing-status': tableMeta.editing.getRowSaveStatus(row.id),
18299
+ 'data-row-editing-invalid': tableMeta.editing.isEnabled && tableMeta.editing.hasRowErrors(row.id) ? !tableMeta.editing.hasRowErrorsSeen(row.id) ? 'unseen' : true : undefined,
18300
+ 'data-row-editing-status': tableMeta.editing.isEnabled && tableMeta.editing.getRowSaveStatus(row.id) ? tableMeta.editing.getRowSaveStatus(row.id) : undefined,
18256
18301
  onFocus: handleFocus
18257
18302
  };
18258
18303
  return /*#__PURE__*/React__default.createElement(DisplayRow, Object.assign({}, props, attributes), tableMeta.editing.getRowSaveStatus(row.id) ? /*#__PURE__*/React__default.createElement(SaveStatus, {