@economic/taco 2.26.4 → 2.26.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,
@@ -10903,57 +10923,55 @@ function useTableStyleGrid(tableId, table, fontSize) {
10903
10923
  const globalMinSize = getCellMinWidth(fontSize);
10904
10924
  // header body ?footer
10905
10925
  const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';
10906
- return React__default.useMemo(() => {
10907
- let printGridTemplateColumns = '';
10908
- const printHiddenColumns = [];
10909
- const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {
10910
- var _column$columnDef$min, _column$columnDef$met;
10911
- if (table.options.enableGrouping && column.getIsGrouped()) {
10912
- return accum;
10913
- }
10914
- const minSize = (_column$columnDef$min = column.columnDef.minSize) !== null && _column$columnDef$min !== void 0 ? _column$columnDef$min : globalMinSize;
10915
- const width = columnSizing[column.id];
10916
- let size;
10917
- let printSize;
10918
- if (column.id === '__actions') {
10919
- const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */
10920
- size = `minmax(${minWidth}px, auto)`;
10921
- } else if (width !== undefined) {
10922
- const isLastColumn = index === allVisibleColumns.length - 1;
10923
- if (width === 'grow' || Number.isNaN(width) && !isLastColumn) {
10924
- size = `minmax(max-content, 1fr)`;
10926
+ let printGridTemplateColumns = '';
10927
+ const printHiddenColumns = [];
10928
+ const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {
10929
+ var _column$columnDef$min, _column$columnDef$met;
10930
+ if (table.options.enableGrouping && column.getIsGrouped()) {
10931
+ return accum;
10932
+ }
10933
+ const minSize = (_column$columnDef$min = column.columnDef.minSize) !== null && _column$columnDef$min !== void 0 ? _column$columnDef$min : globalMinSize;
10934
+ const width = columnSizing[column.id];
10935
+ let size;
10936
+ let printSize;
10937
+ if (column.id === '__actions') {
10938
+ const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */
10939
+ size = `minmax(${minWidth}px, auto)`;
10940
+ } else if (width !== undefined) {
10941
+ const isLastColumn = index === allVisibleColumns.length - 1;
10942
+ if (width === 'grow' || Number.isNaN(width) && !isLastColumn) {
10943
+ size = `minmax(max-content, 1fr)`;
10944
+ } else {
10945
+ const minWidth = width < minSize ? minSize : width;
10946
+ if (isLastColumn) {
10947
+ size = `minmax(${minWidth}px, auto)`;
10925
10948
  } else {
10926
- const minWidth = width < minSize ? minSize : width;
10927
- if (isLastColumn) {
10928
- size = `minmax(${minWidth}px, auto)`;
10929
- } else {
10930
- size = `${minWidth}px`;
10931
- }
10949
+ size = `${minWidth}px`;
10932
10950
  }
10933
- } else {
10934
- size = `minmax(max-content, auto)`;
10935
- }
10936
- if (((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.enablePrinting) === false) {
10937
- printSize = '';
10938
- printHiddenColumns.push(column.id);
10939
- } else {
10940
- printSize = 'auto';
10941
10951
  }
10942
- printGridTemplateColumns = `${printGridTemplateColumns} ${printSize}`.trim();
10943
- return `${accum} ${size}`.trim();
10944
- }, '');
10945
- // we have to be specific so that nested tables don't inherit the same css
10946
- 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
- const style = {
10948
- gridTemplateColumns,
10949
- gridTemplateRows
10950
- };
10951
- const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''}}`;
10952
- return {
10953
- style,
10954
- stylesheet
10955
- };
10956
- }, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);
10952
+ } else {
10953
+ size = `minmax(max-content, auto)`;
10954
+ }
10955
+ if (((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.enablePrinting) === false) {
10956
+ printSize = '';
10957
+ printHiddenColumns.push(column.id);
10958
+ } else {
10959
+ printSize = 'auto';
10960
+ }
10961
+ printGridTemplateColumns = `${printGridTemplateColumns} ${printSize}`.trim();
10962
+ return `${accum} ${size}`.trim();
10963
+ }, '');
10964
+ // we have to be specific so that nested tables don't inherit the same css
10965
+ 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(',');
10966
+ const style = {
10967
+ gridTemplateColumns,
10968
+ gridTemplateRows
10969
+ };
10970
+ const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''}}`;
10971
+ return {
10972
+ style,
10973
+ stylesheet
10974
+ };
10957
10975
  }
10958
10976
 
10959
10977
  function useTableStyleColumnFreezing(tableId, table) {
@@ -15735,11 +15753,12 @@ function TableGrid(props) {
15735
15753
  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, {
15736
15754
  id: table.id,
15737
15755
  "data-table-font-size": table.meta.fontSize.size,
15756
+ "data-table-grouped": !!((_table$state$grouping = table.state.grouping) !== null && _table$state$grouping !== void 0 && _table$state$grouping.length),
15738
15757
  "data-table-horizontally-scrolled": table.meta.columnFreezing.isHorizontallyScrolled ? true : undefined,
15758
+ "data-table-status": table.meta.server.isEnabled ? table.meta.server.isReady ? 'ready' : undefined : 'ready',
15739
15759
  "data-table-pause-hover": table.meta.rowActive.isHoverStatePaused ? true : undefined,
15740
15760
  "data-table-resizing": table.state.columnSizingInfo.isResizingColumn ? true : undefined,
15741
15761
  "data-table-row-height": table.meta.rowHeight.height,
15742
- "data-table-grouped": !!((_table$state$grouping = table.state.grouping) !== null && _table$state$grouping !== void 0 && _table$state$grouping.length),
15743
15762
  onFocus: handleFocus,
15744
15763
  onScroll: table.meta.columnFreezing.handleScroll,
15745
15764
  ref: table.ref,
@@ -18275,8 +18294,8 @@ function Row$2(props) {
18275
18294
  }
18276
18295
  }, [tableMeta.editing.isEditing, isActiveRow]);
18277
18296
  const attributes = {
18278
- 'data-row-editing-invalid': tableMeta.editing.hasRowErrors(row.id) ? !tableMeta.editing.hasRowErrorsSeen(row.id) ? 'unseen' : true : undefined,
18279
- 'data-row-editing-status': tableMeta.editing.getRowSaveStatus(row.id),
18297
+ 'data-row-editing-invalid': tableMeta.editing.isEnabled && tableMeta.editing.hasRowErrors(row.id) ? !tableMeta.editing.hasRowErrorsSeen(row.id) ? 'unseen' : true : undefined,
18298
+ 'data-row-editing-status': tableMeta.editing.isEnabled && tableMeta.editing.getRowSaveStatus(row.id) ? tableMeta.editing.getRowSaveStatus(row.id) : undefined,
18280
18299
  onFocus: handleFocus
18281
18300
  };
18282
18301
  return /*#__PURE__*/React__default.createElement(DisplayRow, Object.assign({}, props, attributes), tableMeta.editing.getRowSaveStatus(row.id) ? /*#__PURE__*/React__default.createElement(SaveStatus, {