@economic/taco 2.8.1 → 2.9.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.
Files changed (75) hide show
  1. package/dist/components/Icon/components/Lock.d.ts +3 -0
  2. package/dist/components/Icon/components/index.d.ts +1 -1
  3. package/dist/components/Input/Input.d.ts +1 -1
  4. package/dist/components/Menu/components/Item.d.ts +1 -1
  5. package/dist/components/Menu/components/Link.d.ts +1 -1
  6. package/dist/components/Navigation2/components/Link.d.ts +1 -1
  7. package/dist/components/Select2/components/Option.d.ts +1 -1
  8. package/dist/components/Select2/components/Search.d.ts +1 -1
  9. package/dist/components/Table3/components/columns/styles.d.ts +1 -0
  10. package/dist/components/Table3/components/toolbar/ColumnSettings.d.ts +3 -2
  11. package/dist/components/Table3/components/toolbar/Filter/filters/Filters.d.ts +1 -1
  12. package/dist/components/Table3/components/toolbar/PrintButton/WarningDialog.d.ts +2 -1
  13. package/dist/components/Table3/components/toolbar/Settings.d.ts +6 -0
  14. package/dist/components/Table3/hooks/features/useCurrentRow.d.ts +3 -3
  15. package/dist/components/Table3/hooks/useCssGrid.d.ts +1 -1
  16. package/dist/components/Tag/Tag.d.ts +1 -1
  17. package/dist/esm/packages/taco/src/components/Header/components/Agreement/Display.js +1 -1
  18. package/dist/esm/packages/taco/src/components/Icon/components/Lock.js +19 -0
  19. package/dist/esm/packages/taco/src/components/Icon/components/Lock.js.map +1 -0
  20. package/dist/esm/packages/taco/src/components/Icon/components/index.js +2 -0
  21. package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
  22. package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js +1 -1
  23. package/dist/esm/packages/taco/src/components/Provider/Localization.js +3 -3
  24. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +1 -1
  26. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
  27. package/dist/esm/packages/taco/src/components/Table3/Table3.js +3 -1
  28. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  29. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +3 -2
  30. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +3 -2
  32. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js +2 -1
  34. package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js.map +1 -1
  35. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +34 -35
  36. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js.map +1 -1
  37. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +19 -7
  38. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
  39. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js +66 -18
  40. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js.map +1 -1
  41. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +12 -8
  42. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
  43. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/WarningDialog.js +5 -1
  44. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/WarningDialog.js.map +1 -1
  45. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js +2 -2
  46. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js.map +1 -1
  47. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js +61 -0
  48. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js.map +1 -0
  49. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Toolbar.js +8 -35
  50. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Toolbar.js.map +1 -1
  51. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js +3 -2
  52. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js.map +1 -1
  53. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js +1 -1
  54. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js.map +1 -1
  55. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js +1 -1
  56. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js.map +1 -1
  57. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js +5 -2
  58. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js.map +1 -1
  59. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js +2 -1
  60. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js.map +1 -1
  61. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js +8 -4
  62. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js.map +1 -1
  63. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js +1 -1
  64. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js.map +1 -1
  65. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js +7 -3
  66. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js.map +1 -1
  67. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +9 -4
  68. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
  69. package/dist/esm/packages/taco/src/index.js +2 -2
  70. package/dist/taco.cjs.development.js +352 -217
  71. package/dist/taco.cjs.development.js.map +1 -1
  72. package/dist/taco.cjs.production.min.js +1 -1
  73. package/dist/taco.cjs.production.min.js.map +1 -1
  74. package/package.json +2 -2
  75. package/types.json +14055 -11802
@@ -2107,6 +2107,21 @@ function IconLockOpen(props, svgRef) {
2107
2107
  }
2108
2108
  var LockOpen = /*#__PURE__*/React.forwardRef(IconLockOpen);
2109
2109
 
2110
+ function IconLock(props, svgRef) {
2111
+ return /*#__PURE__*/React.createElement("svg", Object.assign({
2112
+ fill: "none",
2113
+ xmlns: "http://www.w3.org/2000/svg",
2114
+ viewBox: "0 0 24 24",
2115
+ ref: svgRef
2116
+ }, props), /*#__PURE__*/React.createElement("path", {
2117
+ fillRule: "evenodd",
2118
+ clipRule: "evenodd",
2119
+ d: "M12 1a5 5 0 015 5v2h1.25c.966 0 1.75.784 1.75 1.75v10.5A1.75 1.75 0 0118.25 22H5.75A1.75 1.75 0 014 20.25V9.75C4 8.784 4.784 8 5.75 8H7V6a5 5 0 015-5zm6.25 8.5H5.75a.25.25 0 00-.243.193L5.5 9.75v10.5a.25.25 0 00.193.243l.057.007h12.5a.25.25 0 00.243-.193l.007-.057V9.75a.25.25 0 00-.193-.243L18.25 9.5zM12 13a1.5 1.5 0 01.751 2.799l-.001.951a.75.75 0 01-1.5 0v-.95A1.5 1.5 0 0112 13zm0-10.5a3.5 3.5 0 00-3.495 3.308L8.5 6v2h7V6a3.5 3.5 0 00-3.308-3.495L12 2.5z",
2120
+ fill: "currentColor"
2121
+ }));
2122
+ }
2123
+ var Lock = /*#__PURE__*/React.forwardRef(IconLock);
2124
+
2110
2125
  function IconLogOut(props, svgRef) {
2111
2126
  return /*#__PURE__*/React.createElement("svg", Object.assign({
2112
2127
  fill: "none",
@@ -3395,6 +3410,7 @@ const icons = {
3395
3410
  'list-search': ListSearch,
3396
3411
  list: List,
3397
3412
  'lock-open': LockOpen,
3413
+ lock: Lock,
3398
3414
  'log-out': LogOut,
3399
3415
  log: Log,
3400
3416
  market: Market,
@@ -4319,8 +4335,8 @@ const defaultLocalisationTexts = {
4319
4335
  },
4320
4336
  columnSettings: {
4321
4337
  search: 'Search column...',
4322
- tooltip: 'Columns',
4323
- button: 'Columns',
4338
+ tooltip: 'Column settings',
4339
+ button: 'Column settings',
4324
4340
  noResults: 'No results'
4325
4341
  },
4326
4342
  editing: {
@@ -4444,7 +4460,7 @@ const defaultLocalisationTexts = {
4444
4460
  collapseRow: 'Collapse current row'
4445
4461
  },
4446
4462
  otherOptions: {
4447
- tooltip: 'Other options'
4463
+ tooltip: 'Table settings'
4448
4464
  }
4449
4465
  },
4450
4466
  searchInput: {
@@ -9072,7 +9088,7 @@ const SearchInput2 = /*#__PURE__*/React__default.forwardRef(function SearchInput
9072
9088
  const handleClear = () => {
9073
9089
  requestAnimationFrame(() => {
9074
9090
  var _internalRef$current2;
9075
- return (_internalRef$current2 = internalRef.current) === null || _internalRef$current2 === void 0 ? void 0 : _internalRef$current2.focus();
9091
+ return (_internalRef$current2 = internalRef.current) === null || _internalRef$current2 === void 0 ? void 0 : _internalRef$current2.blur();
9076
9092
  });
9077
9093
  handleChange('');
9078
9094
  };
@@ -16566,6 +16582,7 @@ function getCellValueAsString(value, dataType) {
16566
16582
  }
16567
16583
 
16568
16584
  const MIN_COLUMN_SIZE$1 = 80; // accounts for padding and sort controls
16585
+ const PRINT_MIN_COLUMN_SIZE = 20; // while printing, it accounts for minimum width each column can take
16569
16586
  const getCellAlignmentClasses$1 = (alignment = 'left') => {
16570
16587
  return cn({
16571
16588
  'justify-start text-left': alignment === 'left',
@@ -16578,7 +16595,7 @@ const getInputAppearanceClassnames = () => {
16578
16595
  return cn('[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none');
16579
16596
  };
16580
16597
 
16581
- const useCssGrid = table => {
16598
+ const useCssGrid = (table, isPrintTable = false) => {
16582
16599
  const allVisibleColumns = table.getVisibleLeafColumns();
16583
16600
  const columnSizing = table.getState().columnSizing;
16584
16601
  const rowsLength = table.getRowModel().rows.length;
@@ -16591,7 +16608,11 @@ const useCssGrid = table => {
16591
16608
  // column has a getSize function, but it always returns a default value (150), and we want the
16592
16609
  // first render to use auto layout - so we get the size directly from table state where it is undefined
16593
16610
  const width = columnSizing[column.id];
16594
- if (isInternalColumn$1(column.id)) {
16611
+ const isColumnInternal = isInternalColumn$1(column.id);
16612
+ if (isPrintTable) {
16613
+ const maxWidth = isColumnInternal ? `${column.getSize()}px` : '1fr';
16614
+ size = `minmax(${PRINT_MIN_COLUMN_SIZE}px, ${maxWidth})`;
16615
+ } else if (isColumnInternal) {
16595
16616
  if (column.id === COLUMN_ID) {
16596
16617
  size = 'minmax(max-content, auto)';
16597
16618
  } else {
@@ -16631,7 +16652,7 @@ const useCssGrid = table => {
16631
16652
  };
16632
16653
  };
16633
16654
 
16634
- function useCurrentRow(defaultCurrentRowIndex = 0) {
16655
+ function useCurrentRow(defaultCurrentRowIndex) {
16635
16656
  const [currentRowIndex, setCurrentRowIndex] = React__default.useState(defaultCurrentRowIndex);
16636
16657
  const move = (direction, length, scrollToIndex) => setCurrentRowIndex(currentIndex => {
16637
16658
  const nextIndex = currentIndex !== undefined ? getNextIndex$2(direction, currentIndex, length) : 0;
@@ -17051,7 +17072,8 @@ function useCurrentRowListener(table) {
17051
17072
  const meta = table.options.meta;
17052
17073
  const rows = table.getRowModel().rows;
17053
17074
  React__default.useEffect(() => {
17054
- if (meta.currentRow.currentRowIndex > rows.length) {
17075
+ const currentRowIndex = meta.currentRow.currentRowIndex;
17076
+ if (currentRowIndex !== undefined && currentRowIndex > rows.length) {
17055
17077
  meta.currentRow.setCurrentRowIndex(0);
17056
17078
  }
17057
17079
  }, [rows.length]);
@@ -17114,8 +17136,9 @@ function useColumnFreezingStyle(tableId, table) {
17114
17136
  if (tableMeta.columnFreezing.frozenInternalColumnCount > 0 || tableMeta.columnFreezing.isEnabled && frozenColumnIndex !== undefined) {
17115
17137
  var _visibleFrozenColumns;
17116
17138
  const visibleFrozenColumns = table.getVisibleLeafColumns().slice(0, frozenColumnIndex + 1);
17117
- // if all frozen columns haven't had their size set yet, then abort
17118
- if (visibleFrozenColumns.every(column => columnSizing[column.id] === undefined)) {
17139
+ const visibleExternalFrozenColumns = visibleFrozenColumns.filter(column => !isInternalColumn$1(column.id));
17140
+ // if all external frozen columns haven't had their size set yet, then abort
17141
+ if (visibleExternalFrozenColumns.length && visibleExternalFrozenColumns.every(column => columnSizing[column.id] === undefined)) {
17119
17142
  return undefined;
17120
17143
  }
17121
17144
  const offsets = {};
@@ -17161,9 +17184,12 @@ function useRowSelection() {
17161
17184
  const rows = table.getRowModel().rows;
17162
17185
  const tableMeta = table.options.meta;
17163
17186
  if (event.key === ' ') {
17164
- var _rows$tableMeta$curre;
17165
17187
  event.preventDefault();
17166
- (_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.toggleSelected();
17188
+ const currentRowIndex = tableMeta.currentRow.currentRowIndex;
17189
+ if (currentRowIndex !== undefined) {
17190
+ var _rows$currentRowIndex;
17191
+ (_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.toggleSelected();
17192
+ }
17167
17193
  return;
17168
17194
  } else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
17169
17195
  event.preventDefault();
@@ -17186,7 +17212,7 @@ function useRowClick(onRowClick) {
17186
17212
  const tableMeta = table.options.meta;
17187
17213
  if (event.key === 'Enter') {
17188
17214
  event.preventDefault();
17189
- if (onRowClick) {
17215
+ if (onRowClick && tableMeta.currentRow.currentRowIndex !== undefined) {
17190
17216
  onRowClick(rows[tableMeta.currentRow.currentRowIndex].original);
17191
17217
  }
17192
17218
  return;
@@ -17965,7 +17991,7 @@ function EditingCell$1(props) {
17965
17991
  }));
17966
17992
  }
17967
17993
  const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
17968
- var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$curre, _column$columnDef$met;
17994
+ var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$currentRowIndex, _column$columnDef$met;
17969
17995
  const {
17970
17996
  cell,
17971
17997
  column,
@@ -18017,7 +18043,8 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
18017
18043
  // row move indicator
18018
18044
  const moveReason = (_tableMeta$editing$ro = tableMeta.editing.rowMoveReason[cell.column.id]) !== null && _tableMeta$editing$ro !== void 0 ? _tableMeta$editing$ro : null;
18019
18045
  const rows = table.getRowModel().rows;
18020
- const isCurrentRow = ((_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.id) === row.id;
18046
+ const currentRowIndex = tableMeta.currentRow.currentRowIndex;
18047
+ const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
18021
18048
  const mountNode = React__default.useMemo(() => {
18022
18049
  if (moveReason) {
18023
18050
  var _cellRef$current2, _cellRef$current2$par;
@@ -18107,7 +18134,7 @@ function getRowMoveReason(table, rowIndex, rowValues, cell, newValue) {
18107
18134
  }
18108
18135
 
18109
18136
  function Cell$3(props) {
18110
- var _rows$tableMeta$curre;
18137
+ var _rows$currentRowIndex;
18111
18138
  const {
18112
18139
  column,
18113
18140
  row,
@@ -18119,7 +18146,8 @@ function Cell$3(props) {
18119
18146
  const rows = table.getRowModel().rows;
18120
18147
  const tableMeta = table.options.meta;
18121
18148
  const columnMeta = column.columnDef.meta;
18122
- const isCurrentRow = ((_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.id) === row.id;
18149
+ const currentRowIndex = tableMeta.currentRow.currentRowIndex;
18150
+ const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
18123
18151
  if (tableMeta.editing.isEditing && columnMeta.control && (isCurrentRow || isHoveredRow && !tableMeta.hoverState.isPaused)) {
18124
18152
  return /*#__PURE__*/React__default.createElement(EditingCell$1, Object.assign({}, props));
18125
18153
  }
@@ -18538,7 +18566,7 @@ function useShortcutsListener(table, shortcuts) {
18538
18566
  const shortcutKeys = Object.keys(shortcuts !== null && shortcuts !== void 0 ? shortcuts : {});
18539
18567
  const globalHandlers = [];
18540
18568
  // convert the shortcut into the correct format to register it
18541
- if (shortcuts && shortcutKeys.length) {
18569
+ if (shortcuts && shortcutKeys.length && meta.currentRow.currentRowIndex !== undefined) {
18542
18570
  const currentRow = rows[meta.currentRow.currentRowIndex];
18543
18571
  shortcutKeys.forEach(key => {
18544
18572
  const handler = shortcuts[key];
@@ -18606,10 +18634,14 @@ function useEditingStateListener(table) {
18606
18634
  }, [meta.currentRow.currentRowIndex]);
18607
18635
  // save if editing gets toggled off
18608
18636
  React__default.useEffect(() => {
18609
- if (meta.editing.isEnabled && !meta.editing.isEditing) {
18610
- requestAnimationFrame(() => {
18611
- meta.editing.saveChangesIfNeeded();
18612
- });
18637
+ if (meta.editing.isEnabled) {
18638
+ if (!meta.editing.isEditing) {
18639
+ requestAnimationFrame(() => {
18640
+ meta.editing.saveChangesIfNeeded();
18641
+ });
18642
+ } else if (meta.currentRow.currentRowIndex === undefined) {
18643
+ meta.currentRow.setCurrentRowIndex(0);
18644
+ }
18613
18645
  }
18614
18646
  }, [meta.editing.isEditing]);
18615
18647
  }
@@ -18741,10 +18773,15 @@ function useTable$2(props) {
18741
18773
  tableOptions.globalFilterFn = (row, columnId, searchQuery) => {
18742
18774
  try {
18743
18775
  if (row.original) {
18744
- var _row$_getAllCellsByCo, _row$_getAllCellsByCo2;
18745
- const dataType = (_row$_getAllCellsByCo = row._getAllCellsByColumnId()[columnId]) === null || _row$_getAllCellsByCo === void 0 ? void 0 : (_row$_getAllCellsByCo2 = _row$_getAllCellsByCo.column.columnDef.meta) === null || _row$_getAllCellsByCo2 === void 0 ? void 0 : _row$_getAllCellsByCo2.dataType;
18746
- const cellValue = getCellValueAsString(row.original[columnId], dataType);
18747
- return globalFilterFn$1(cellValue, searchQuery);
18776
+ const cell = row.getAllCells().find(cell => cell.column.id === columnId);
18777
+ const columnMeta = cell === null || cell === void 0 ? void 0 : cell.column.columnDef.meta;
18778
+ if (cell && cell.column.getIsVisible() && columnMeta !== null && columnMeta !== void 0 && columnMeta.enableSearch) {
18779
+ const cellValue = getCellValueAsString(row.original[columnId], columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.dataType);
18780
+ if (cellValue !== undefined) {
18781
+ return globalFilterFn$1(cellValue, searchQuery);
18782
+ }
18783
+ }
18784
+ return false;
18748
18785
  }
18749
18786
  } catch {
18750
18787
  //
@@ -19291,32 +19328,6 @@ function useTableRenderStrategy$1(props, table, ref) {
19291
19328
  return useTableRenderStrategy(props, table, ref);
19292
19329
  }
19293
19330
 
19294
- function RowHeight(props) {
19295
- const {
19296
- texts
19297
- } = useLocalization();
19298
- const meta = props.table.options.meta;
19299
- const handleChange = value => {
19300
- const height = value;
19301
- meta.rowHeight.setHeight(height);
19302
- if (height === 'short' && meta.fontSize.size === 'large') {
19303
- meta.fontSize.setSize('medium');
19304
- }
19305
- };
19306
- return /*#__PURE__*/React__default.createElement(Menu$1.SubMenu, null, /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup, {
19307
- onChange: handleChange,
19308
- value: meta.rowHeight.height
19309
- }, /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
19310
- value: "short"
19311
- }, texts.table3.rowHeight.sizes.short), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
19312
- value: "medium"
19313
- }, texts.table3.rowHeight.sizes.medium), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
19314
- value: "tall"
19315
- }, texts.table3.rowHeight.sizes.tall), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
19316
- value: "extra-tall"
19317
- }, texts.table3.rowHeight.sizes.extraTall)));
19318
- }
19319
-
19320
19331
  // augments useEffect to not run debounced
19321
19332
  function useDebouncedEffect(effect, deps, ms = 200) {
19322
19333
  const timeoutRef = React__default.useRef();
@@ -19458,10 +19469,10 @@ function resetHighlightedColumnIndexes(enabled, value, table) {
19458
19469
  columns.forEach((column, columnIndex) => {
19459
19470
  try {
19460
19471
  var _column$columnDef$met;
19461
- if ((_column$columnDef$met = column.columnDef.meta) !== null && _column$columnDef$met !== void 0 && _column$columnDef$met.enableSearch) {
19472
+ if (column.getIsVisible() && (_column$columnDef$met = column.columnDef.meta) !== null && _column$columnDef$met !== void 0 && _column$columnDef$met.enableSearch) {
19462
19473
  var _row$original, _column$columnDef$met2;
19463
19474
  const cellValue = getCellValueAsString((_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original[column.id], (_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.dataType);
19464
- if (cellValue && globalFilterFn$1(cellValue, value)) {
19475
+ if (cellValue !== undefined && globalFilterFn$1(cellValue, value)) {
19465
19476
  indexes.push([rowIndex, columnIndex]);
19466
19477
  }
19467
19478
  }
@@ -19828,11 +19839,27 @@ function Filter$1(props) {
19828
19839
  }));
19829
19840
  }
19830
19841
 
19842
+ const useMatchMedia = (query, defaultMatches = false) => {
19843
+ const [matches, setMatches] = React__default.useState(defaultMatches);
19844
+ const handleChange = React__default.useCallback(event => setMatches(event.matches), []);
19845
+ React__default.useEffect(() => {
19846
+ const mediaQuery = window.matchMedia(query);
19847
+ setMatches(mediaQuery.matches);
19848
+ mediaQuery.addEventListener('change', handleChange);
19849
+ return () => {
19850
+ mediaQuery.removeEventListener('change', handleChange);
19851
+ };
19852
+ }, []);
19853
+ return matches;
19854
+ };
19855
+
19856
+ const useIsLargeScreen = () => useMatchMedia('(min-width: 1024px)', window.innerWidth > 1024);
19857
+
19831
19858
  function sortByHeader(a, b) {
19832
19859
  var _a$columnDef$meta, _a$columnDef$meta$hea, _a$columnDef$meta$hea2, _b$columnDef$meta;
19833
19860
  return (_a$columnDef$meta = a.columnDef.meta) === null || _a$columnDef$meta === void 0 ? void 0 : (_a$columnDef$meta$hea = _a$columnDef$meta.header) === null || _a$columnDef$meta$hea === void 0 ? void 0 : (_a$columnDef$meta$hea2 = _a$columnDef$meta$hea.localeCompare) === null || _a$columnDef$meta$hea2 === void 0 ? void 0 : _a$columnDef$meta$hea2.call(_a$columnDef$meta$hea, (_b$columnDef$meta = b.columnDef.meta) === null || _b$columnDef$meta === void 0 ? void 0 : _b$columnDef$meta.header);
19834
19861
  }
19835
- function Filters(props) {
19862
+ function FiltersButton$1(props) {
19836
19863
  const {
19837
19864
  total,
19838
19865
  table
@@ -19842,6 +19869,7 @@ function Filters(props) {
19842
19869
  texts
19843
19870
  } = useLocalization();
19844
19871
  const ref = React__default.useRef(null);
19872
+ const isLargeScreen = useIsLargeScreen();
19845
19873
  const allColumns = table.getAllLeafColumns().filter(column => !isInternalColumn$1(column.id)).sort(sortByHeader);
19846
19874
  const appliedFilters = table.getState().columnFilters;
19847
19875
  useGlobalKeyDown({
@@ -19904,8 +19932,8 @@ function Filters(props) {
19904
19932
  setFilters([]);
19905
19933
  setPlaceholderCount(1);
19906
19934
  };
19907
- return /*#__PURE__*/React__default.createElement(Button$1, {
19908
- "aria-label": texts.table3.filters.tooltip,
19935
+ const buttonProps = {
19936
+ 'aria-label': texts.table3.filters.tooltip,
19909
19937
  className: cn({
19910
19938
  '!wcag-blue-100': appliedFilters.length
19911
19939
  }),
@@ -19949,7 +19977,7 @@ function Filters(props) {
19949
19977
  appearance: "primary",
19950
19978
  onClick: handleApply
19951
19979
  }, "Apply"))))),
19952
- ref: ref,
19980
+ ref,
19953
19981
  tooltip: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, texts.table3.filters.tooltip, /*#__PURE__*/React__default.createElement(Shortcut, {
19954
19982
  className: "ml-2",
19955
19983
  keys: {
@@ -19958,97 +19986,18 @@ function Filters(props) {
19958
19986
  shift: true
19959
19987
  }
19960
19988
  }))
19961
- }, /*#__PURE__*/React__default.createElement(Icon, {
19962
- name: appliedFilters.length ? 'filter-solid' : 'filter'
19963
- }), texts.table3.filters.button, " ", appliedFilters.length ? `(${appliedFilters.length})` : '');
19964
- }
19965
-
19966
- const Column$4 = /*#__PURE__*/React__default.forwardRef(function Column(props, ref) {
19967
- var _column$columnDef$met;
19968
- const {
19969
- column,
19970
- draggable = false,
19971
- ...dragAttributes
19972
- } = props;
19973
- const canHide = column.getCanHide();
19974
- const className = cn('group/column flex items-center gap-x-2 rounded py-1 px-2', {
19975
- 'hover:bg-grey-200': canHide || draggable,
19976
- 'hover:cursor-pointer': canHide,
19977
- 'active:cursor-move active:bg-grey-300': draggable
19978
- });
19979
- const attributes = draggable ? dragAttributes : undefined;
19980
- const isVisible = column.getIsVisible();
19981
- return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
19982
- key: column.id,
19983
- className: className,
19984
- onClick: () => column.toggleVisibility(!isVisible),
19985
- ref: ref
19986
- }), draggable ? /*#__PURE__*/React__default.createElement(Icon, {
19987
- name: "drag",
19988
- className: "text-grey-500 group-hover/column:text-grey-700 -mx-2 !h-5"
19989
- }) : null, /*#__PURE__*/React__default.createElement("span", {
19990
- className: "flex-grow truncate"
19991
- }, (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.header), canHide ? /*#__PURE__*/React__default.createElement(Checkbox, {
19992
- checked: isVisible,
19993
- onChange: () => column.toggleVisibility(!isVisible)
19994
- }) : null);
19995
- });
19996
- function ColumnSettings(props) {
19997
- const {
19998
- table
19999
- } = props;
20000
- const {
20001
- texts
20002
- } = useLocalization();
20003
- const [query, setQuery] = React__default.useState('');
20004
- const allColumns = table.getAllLeafColumns();
20005
- const tableMeta = table.options.meta;
20006
- const columns = React__default.useMemo(() => allColumns.filter(column => !isInternalColumn$1(column.id)).filter(column => {
20007
- var _column$columnDef$met2;
20008
- return query !== null && query !== void 0 && query.length ? (_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.header.toLowerCase().includes(query.toLowerCase()) : true;
20009
- }), [allColumns, query]);
20010
- const listClassName = 'flex max-h-64 flex-col gap-y-px overflow-auto';
20011
- const handleReorder = (activeId, overId) => {
20012
- if (columns.find(column => {
20013
- var _column$columnDef$met3;
20014
- return column.id === overId && ((_column$columnDef$met3 = column.columnDef.meta) === null || _column$columnDef$met3 === void 0 ? void 0 : _column$columnDef$met3.enableOrdering) === false;
20015
- })) {
20016
- return;
20017
- }
20018
- table.setColumnOrder(currentOrder => ensureOrdering$1(allColumns, SortablePrimitive.arrayMove(currentOrder, currentOrder.findIndex(c => c === activeId), currentOrder.findIndex(c => c === overId))));
20019
19989
  };
20020
- return /*#__PURE__*/React__default.createElement(Button$1, {
20021
- popover: popoverProps => /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps), /*#__PURE__*/React__default.createElement(Popover.Content, null, /*#__PURE__*/React__default.createElement("div", {
20022
- className: "flex w-60 flex-col gap-2"
20023
- }, table.options.enableHiding ? /*#__PURE__*/React__default.createElement(Input, {
20024
- onChange: event => setQuery(event.target.value),
20025
- placeholder: texts.table3.columnSettings.search,
20026
- value: query
20027
- }) : null, tableMeta.columnOrdering.isEnabled && columns.length && !(query !== null && query !== void 0 && query.length) ? /*#__PURE__*/React__default.createElement(Container, {
20028
- reorder: handleReorder
20029
- }, /*#__PURE__*/React__default.createElement(List$1, {
20030
- id: "columns",
20031
- className: listClassName
20032
- }, columns.map(column => {
20033
- var _column$columnDef$met4, _column$columnDef$met5;
20034
- return /*#__PURE__*/React__default.createElement(Item$3, {
20035
- key: column.id,
20036
- id: column.id,
20037
- disabled: !((_column$columnDef$met4 = column.columnDef.meta) !== null && _column$columnDef$met4 !== void 0 && _column$columnDef$met4.enableOrdering),
20038
- asChild: true
20039
- }, /*#__PURE__*/React__default.createElement(Column$4, {
20040
- column: column,
20041
- draggable: (_column$columnDef$met5 = column.columnDef.meta) === null || _column$columnDef$met5 === void 0 ? void 0 : _column$columnDef$met5.enableOrdering
20042
- }));
20043
- }))) : /*#__PURE__*/React__default.createElement("div", {
20044
- className: listClassName
20045
- }, columns.length ? columns.map(column => /*#__PURE__*/React__default.createElement(Column$4, {
20046
- column: column,
20047
- key: column.id
20048
- })) : texts.table3.columnSettings.noResults))))
20049
- }, /*#__PURE__*/React__default.createElement(Icon, {
20050
- name: "columns"
20051
- }), texts.table3.columnSettings.button);
19990
+ if (!isLargeScreen && !appliedFilters.length) {
19991
+ return /*#__PURE__*/React__default.createElement(IconButton, Object.assign({}, buttonProps, {
19992
+ icon: "filter"
19993
+ }));
19994
+ }
19995
+ return /*#__PURE__*/React__default.createElement(Button$1, Object.assign({}, buttonProps), /*#__PURE__*/React__default.createElement(Icon, {
19996
+ className: cn({
19997
+ '-mr-1.5': !isLargeScreen
19998
+ }),
19999
+ name: appliedFilters.length ? 'filter-solid' : 'filter'
20000
+ }), isLargeScreen ? texts.table3.filters.button : '', appliedFilters.length ? `(${appliedFilters.length})` : '');
20052
20001
  }
20053
20002
 
20054
20003
  function EditButton(props) {
@@ -20178,6 +20127,7 @@ function PrintIFrame({
20178
20127
  const [contentRef, setContentRef] = React__default.useState(null);
20179
20128
  const [mountNode, setMountNode] = React__default.useState(null);
20180
20129
  const isFirefoxBrowser = React__default.useMemo(() => navigator.userAgent.toLowerCase().includes('firefox'), []);
20130
+ const isSafariBrowser = React__default.useMemo(() => navigator.userAgent.toLowerCase().includes('safari') && !navigator.userAgent.toLowerCase().includes('chrome'), []);
20181
20131
  const iframeWindow = contentRef === null || contentRef === void 0 ? void 0 : contentRef.contentWindow;
20182
20132
  const stylesReady = useParentStylesheets(iframeWindow);
20183
20133
  // Calls print method when table has loaded in the iframe.
@@ -20246,13 +20196,16 @@ function PrintIFrame({
20246
20196
  tableWrapper.classList.add('h-fit');
20247
20197
  tableWrapper.classList.add('[&>[role="table"]]:!h-fit');
20248
20198
  if (isFirefoxBrowser) {
20249
- // Fix for firefox bug which adds page-long whitespace between page's top content and table
20199
+ // Fix for firefox bug which adds page-long whitespace between page's top content and table.
20250
20200
  tableWrapper.classList.add('[&>[role="table"]]:!absolute');
20251
20201
  }
20252
- // Safari print preview assigns no width to the table when w-screen class is used.
20253
- // By assigning table a big static width and hiding the horizontal scrollbar, the table on chrome
20254
- // and safari will always take full page width.
20255
- tableWrapper.classList.add('w-[10000px]');
20202
+ // Makes sure table takes the full screen width.
20203
+ if (isSafariBrowser) {
20204
+ // Safari browser doesn't apply correct width to the columns when w-screen is used.
20205
+ tableWrapper.classList.add('w-full');
20206
+ } else {
20207
+ tableWrapper.classList.add('w-screen');
20208
+ }
20256
20209
  if (tableElement) {
20257
20210
  var _tableElement$parentN;
20258
20211
  (_tableElement$parentN = tableElement.parentNode) === null || _tableElement$parentN === void 0 ? void 0 : _tableElement$parentN.insertBefore(tableWrapper, tableElement);
@@ -20297,7 +20250,7 @@ function PrintIFrame({
20297
20250
  };
20298
20251
  // -top-60 -left-60 styles make sure that iframe is added outside of the viewport
20299
20252
  return /*#__PURE__*/React__default.createElement("iframe", {
20300
- className: "fixed -left-60 -top-60 !h-0 !w-0",
20253
+ className: "fixed -left-[6000px] -top-[6000px] -z-50 !h-0 !w-0",
20301
20254
  ref: setContentRef,
20302
20255
  // Temporary fix to support printing in firefox: Find another solution while upgrading React
20303
20256
  src: "javascript:void(0);"
@@ -20306,6 +20259,7 @@ function PrintIFrame({
20306
20259
 
20307
20260
  const WarningDialog = ({
20308
20261
  onAccept,
20262
+ onCancel,
20309
20263
  onClose,
20310
20264
  onVisibilityChange,
20311
20265
  ...props
@@ -20339,7 +20293,10 @@ const WarningDialog = ({
20339
20293
  checked: hideWarningDialog,
20340
20294
  onChange: setHideWarningDialog
20341
20295
  }), /*#__PURE__*/React__default.createElement(Group, null, /*#__PURE__*/React__default.createElement(Button$1, {
20342
- onClick: handleClose
20296
+ onClick: () => {
20297
+ handleClose();
20298
+ onCancel();
20299
+ }
20343
20300
  }, texts.table3.print.warningDialog.cancelButtonText), /*#__PURE__*/React__default.createElement(Button$1, {
20344
20301
  appearance: "primary",
20345
20302
  autoFocus: true,
@@ -20369,20 +20326,23 @@ function PrintButton(props) {
20369
20326
  const {
20370
20327
  printWarningDialogVisibility
20371
20328
  } = tableMeta.printing;
20329
+ // When changing printTableId, update packages/taco/src/components/Table3/Table3.tsx file and other usages where
20330
+ // printTableId is used to figure out whether the table is a print table or not.
20372
20331
  const printTableId = `${tableProps.id}_print`;
20332
+ const excludeUnmatchedResults = tableMeta.search.excludeUnmatchedResults;
20373
20333
  const defaultSettings = React__default.useMemo(() => ({
20374
20334
  columnFreezingIndex: tableMeta.columnFreezing.frozenColumnIndex,
20375
20335
  columnOrder: state.columnOrder,
20376
20336
  columnSizing: state.columnSizing,
20377
20337
  columnVisibility: state.columnVisibility,
20378
- excludeUnmatchedRecordsInSearch: tableMeta.search.excludeUnmatchedResults,
20338
+ excludeUnmatchedRecordsInSearch: excludeUnmatchedResults,
20379
20339
  fontSize: tableMeta.fontSize.size,
20380
20340
  rowHeight: tableMeta.rowHeight.height,
20381
20341
  sorting: state.sorting,
20382
20342
  // we don't save these, but we must pass them to print
20383
20343
  columnFilters: state.columnFilters,
20384
20344
  globalFilter: state.globalFilter
20385
- }), [tableMeta.columnFreezing.frozenColumnIndex, state.columnOrder, state.columnSizing, state.columnVisibility, tableMeta.search.excludeUnmatchedResults, tableMeta.fontSize.size, tableMeta.rowHeight.height, state.sorting, state.columnFilters, state.globalFilter]);
20345
+ }), [tableMeta.columnFreezing.frozenColumnIndex, state.columnOrder, state.columnSizing, state.columnVisibility, excludeUnmatchedResults, tableMeta.fontSize.size, tableMeta.rowHeight.height, state.sorting, state.columnFilters, state.globalFilter]);
20386
20346
  const iframeTableProps = {
20387
20347
  ...tableProps,
20388
20348
  defaultSettings,
@@ -20398,20 +20358,51 @@ function PrintButton(props) {
20398
20358
  // Starts custom printing
20399
20359
  (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.click();
20400
20360
  });
20401
- const handleAfterPrint = () => {
20361
+ const handleLoadingError = error => {
20402
20362
  var _loadingToastRef$curr;
20403
- setIsPrinting(false);
20404
- (_loadingToastRef$curr = loadingToastRef.current) === null || _loadingToastRef$curr === void 0 ? void 0 : _loadingToastRef$curr.close();
20363
+ const errorMessage = `${texts.table3.print.error}: ${error}`;
20364
+ console.error(errorMessage);
20365
+ (_loadingToastRef$curr = loadingToastRef.current) === null || _loadingToastRef$curr === void 0 ? void 0 : _loadingToastRef$curr.error(errorMessage);
20366
+ };
20367
+ const restoreTableDataWithoutSearch = function () {
20368
+ try {
20369
+ const _temp = _catch(function () {
20370
+ var _tableMeta$printing$l, _tableMeta$printing;
20371
+ return Promise.resolve((_tableMeta$printing$l = (_tableMeta$printing = tableMeta.printing).loadAll) === null || _tableMeta$printing$l === void 0 ? void 0 : _tableMeta$printing$l.call(_tableMeta$printing, table.getState().sorting, table.getState().columnFilters, undefined)).then(function () {});
20372
+ }, function (error) {
20373
+ handleLoadingError(error);
20374
+ });
20375
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
20376
+ } catch (e) {
20377
+ return Promise.reject(e);
20378
+ }
20379
+ };
20380
+ const handleAfterPrint = function () {
20381
+ try {
20382
+ function _temp3() {
20383
+ var _loadingToastRef$curr2;
20384
+ setIsPrinting(false);
20385
+ (_loadingToastRef$curr2 = loadingToastRef.current) === null || _loadingToastRef$curr2 === void 0 ? void 0 : _loadingToastRef$curr2.close();
20386
+ }
20387
+ const _temp2 = function () {
20388
+ if (tableMeta.printing.loadAll && excludeUnmatchedResults) {
20389
+ return Promise.resolve(restoreTableDataWithoutSearch()).then(function () {});
20390
+ }
20391
+ }();
20392
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2));
20393
+ } catch (e) {
20394
+ return Promise.reject(e);
20395
+ }
20405
20396
  };
20406
20397
  const handleBeforePrint = () => {
20407
- var _loadingToastRef$curr2;
20408
- (_loadingToastRef$curr2 = loadingToastRef.current) === null || _loadingToastRef$curr2 === void 0 ? void 0 : _loadingToastRef$curr2.close();
20398
+ var _loadingToastRef$curr3;
20399
+ (_loadingToastRef$curr3 = loadingToastRef.current) === null || _loadingToastRef$curr3 === void 0 ? void 0 : _loadingToastRef$curr3.close();
20409
20400
  };
20410
20401
  const handlePrint = function () {
20411
20402
  try {
20412
20403
  let _exit = false;
20413
- function _temp3(_result2) {
20414
- if (_exit) return _result2;
20404
+ function _temp6(_result3) {
20405
+ if (_exit) return _result3;
20415
20406
  if (hasNonSafeCellCount && printWarningDialogVisibility) {
20416
20407
  setShowWarningDialog(true);
20417
20408
  } else {
@@ -20424,7 +20415,7 @@ function PrintButton(props) {
20424
20415
  let hasNonSafeCellCount = false;
20425
20416
  // if loadAll is not defined, just print with what we've got
20426
20417
  // don't compare length to data.length because the api might be choosing not to return all for performance
20427
- const _temp2 = function () {
20418
+ const _temp5 = function () {
20428
20419
  if (!tableMeta.printing.loadAll) {
20429
20420
  const {
20430
20421
  data
@@ -20432,8 +20423,12 @@ function PrintButton(props) {
20432
20423
  const cellCount = getCellCount(data);
20433
20424
  hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;
20434
20425
  } else {
20435
- const _temp = _catch(function () {
20436
- return Promise.resolve(tableMeta.printing.loadAll(table.getState().sorting, table.getState().columnFilters, tableMeta.search.query)).then(function () {
20426
+ const _temp4 = _catch(function () {
20427
+ return Promise.resolve(tableMeta.printing.loadAll(table.getState().sorting, table.getState().columnFilters,
20428
+ // We need to pass search query to the server when printing, to be able to render correct data set in iFrame,
20429
+ // But in "display" table, search is performed only on client side, so we'll need to request data again without search query,
20430
+ // when printing will be finished.
20431
+ excludeUnmatchedResults ? tableMeta.search.query : undefined)).then(function () {
20437
20432
  // After the loadAll call above, the data changes. Hence, it becomes essential to acquire the data after
20438
20433
  // this call rather than before it.
20439
20434
  const {
@@ -20443,17 +20438,14 @@ function PrintButton(props) {
20443
20438
  hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;
20444
20439
  });
20445
20440
  }, function (error) {
20446
- var _loadingToastRef$curr3;
20447
- const errorMessage = `${texts.table3.print.error}: ${error}`;
20448
- console.error(errorMessage);
20449
- (_loadingToastRef$curr3 = loadingToastRef.current) === null || _loadingToastRef$curr3 === void 0 ? void 0 : _loadingToastRef$curr3.error(errorMessage);
20441
+ handleLoadingError(error);
20450
20442
  // in case of error, we return early
20451
20443
  _exit = true;
20452
20444
  });
20453
- if (_temp && _temp.then) return _temp.then(function () {});
20445
+ if (_temp4 && _temp4.then) return _temp4.then(function () {});
20454
20446
  }
20455
20447
  }();
20456
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2));
20448
+ return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5));
20457
20449
  } catch (e) {
20458
20450
  return Promise.reject(e);
20459
20451
  }
@@ -20461,6 +20453,18 @@ function PrintButton(props) {
20461
20453
  const handleWarningDialogAccept = () => {
20462
20454
  setIsPrinting(true);
20463
20455
  };
20456
+ const handleWarningDialogCancel = function () {
20457
+ try {
20458
+ const _temp7 = function () {
20459
+ if (tableMeta.printing.loadAll && excludeUnmatchedResults) {
20460
+ return Promise.resolve(restoreTableDataWithoutSearch()).then(function () {});
20461
+ }
20462
+ }();
20463
+ return Promise.resolve(_temp7 && _temp7.then ? _temp7.then(function () {}) : void 0);
20464
+ } catch (e) {
20465
+ return Promise.reject(e);
20466
+ }
20467
+ };
20464
20468
  const handleWarningDialogClose = () => {
20465
20469
  var _loadingToastRef$curr4;
20466
20470
  (_loadingToastRef$curr4 = loadingToastRef.current) === null || _loadingToastRef$curr4 === void 0 ? void 0 : _loadingToastRef$curr4.close();
@@ -20481,10 +20485,125 @@ function PrintButton(props) {
20481
20485
  open: showWarningDialog,
20482
20486
  onAccept: handleWarningDialogAccept,
20483
20487
  onClose: handleWarningDialogClose,
20488
+ onCancel: handleWarningDialogCancel,
20484
20489
  onVisibilityChange: tableMeta.printing.setPrintWarningDialogVisibility
20485
20490
  }));
20486
20491
  }
20487
20492
 
20493
+ function RowHeight(props) {
20494
+ const {
20495
+ texts
20496
+ } = useLocalization();
20497
+ const meta = props.table.options.meta;
20498
+ const handleChange = value => {
20499
+ const height = value;
20500
+ meta.rowHeight.setHeight(height);
20501
+ if (height === 'short' && meta.fontSize.size === 'large') {
20502
+ meta.fontSize.setSize('medium');
20503
+ }
20504
+ };
20505
+ return /*#__PURE__*/React__default.createElement(Menu$1.SubMenu, null, /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup, {
20506
+ onChange: handleChange,
20507
+ value: meta.rowHeight.height
20508
+ }, /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
20509
+ value: "short"
20510
+ }, texts.table3.rowHeight.sizes.short), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
20511
+ value: "medium"
20512
+ }, texts.table3.rowHeight.sizes.medium), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
20513
+ value: "tall"
20514
+ }, texts.table3.rowHeight.sizes.tall), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
20515
+ value: "extra-tall"
20516
+ }, texts.table3.rowHeight.sizes.extraTall)));
20517
+ }
20518
+
20519
+ const Column$4 = /*#__PURE__*/React__default.forwardRef(function Column(props, ref) {
20520
+ var _column$columnDef$met;
20521
+ const {
20522
+ column,
20523
+ draggable = false,
20524
+ ...dragAttributes
20525
+ } = props;
20526
+ const canHide = column.getCanHide();
20527
+ const className = cn('group/column flex items-center gap-x-2 rounded py-1 px-2', {
20528
+ 'hover:bg-grey-200': canHide || draggable,
20529
+ 'hover:cursor-pointer': canHide,
20530
+ 'active:cursor-move active:bg-grey-300': draggable
20531
+ });
20532
+ const attributes = draggable ? dragAttributes : undefined;
20533
+ const isVisible = column.getIsVisible();
20534
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
20535
+ key: column.id,
20536
+ className: className,
20537
+ onClick: () => column.toggleVisibility(!isVisible),
20538
+ ref: ref
20539
+ }), draggable ? /*#__PURE__*/React__default.createElement(Icon, {
20540
+ name: "drag",
20541
+ className: "text-grey-500 group-hover/column:text-grey-700 -mx-2 !h-5"
20542
+ }) : null, /*#__PURE__*/React__default.createElement("span", {
20543
+ className: "flex-grow truncate"
20544
+ }, (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.header), canHide ? /*#__PURE__*/React__default.createElement(Checkbox, {
20545
+ checked: isVisible,
20546
+ onChange: () => column.toggleVisibility(!isVisible)
20547
+ }) : null);
20548
+ });
20549
+ function ColumnSettingsPopover(props) {
20550
+ const {
20551
+ table,
20552
+ trigger,
20553
+ ...popoverProps
20554
+ } = props;
20555
+ const {
20556
+ texts
20557
+ } = useLocalization();
20558
+ const [query, setQuery] = React__default.useState('');
20559
+ const allColumns = table.getAllLeafColumns();
20560
+ const tableMeta = table.options.meta;
20561
+ const columns = React__default.useMemo(() => allColumns.filter(column => !isInternalColumn$1(column.id)).filter(column => {
20562
+ var _column$columnDef$met2;
20563
+ return query !== null && query !== void 0 && query.length ? (_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.header.toLowerCase().includes(query.toLowerCase()) : true;
20564
+ }), [allColumns, query]);
20565
+ const listClassName = 'flex max-h-64 flex-col gap-y-px overflow-auto';
20566
+ const handleReorder = (activeId, overId) => {
20567
+ if (columns.find(column => {
20568
+ var _column$columnDef$met3;
20569
+ return column.id === overId && ((_column$columnDef$met3 = column.columnDef.meta) === null || _column$columnDef$met3 === void 0 ? void 0 : _column$columnDef$met3.enableOrdering) === false;
20570
+ })) {
20571
+ return;
20572
+ }
20573
+ table.setColumnOrder(currentOrder => ensureOrdering$1(allColumns, SortablePrimitive.arrayMove(currentOrder, currentOrder.findIndex(c => c === activeId), currentOrder.findIndex(c => c === overId))));
20574
+ };
20575
+ return /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps, {
20576
+ anchor: trigger
20577
+ }), /*#__PURE__*/React__default.createElement(Popover.Content, null, /*#__PURE__*/React__default.createElement("div", {
20578
+ className: "flex w-60 flex-col gap-2"
20579
+ }, table.options.enableHiding ? /*#__PURE__*/React__default.createElement(Input, {
20580
+ onChange: event => setQuery(event.target.value),
20581
+ placeholder: texts.table3.columnSettings.search,
20582
+ value: query
20583
+ }) : null, tableMeta.columnOrdering.isEnabled && columns.length && !(query !== null && query !== void 0 && query.length) ? /*#__PURE__*/React__default.createElement(Container, {
20584
+ reorder: handleReorder
20585
+ }, /*#__PURE__*/React__default.createElement(List$1, {
20586
+ id: "columns",
20587
+ className: listClassName
20588
+ }, columns.map(column => {
20589
+ var _column$columnDef$met4, _column$columnDef$met5;
20590
+ return /*#__PURE__*/React__default.createElement(Item$3, {
20591
+ key: column.id,
20592
+ id: column.id,
20593
+ disabled: !((_column$columnDef$met4 = column.columnDef.meta) !== null && _column$columnDef$met4 !== void 0 && _column$columnDef$met4.enableOrdering),
20594
+ asChild: true
20595
+ }, /*#__PURE__*/React__default.createElement(Column$4, {
20596
+ column: column,
20597
+ draggable: (_column$columnDef$met5 = column.columnDef.meta) === null || _column$columnDef$met5 === void 0 ? void 0 : _column$columnDef$met5.enableOrdering
20598
+ }));
20599
+ }))) : /*#__PURE__*/React__default.createElement("div", {
20600
+ className: listClassName
20601
+ }, columns.length ? columns.map(column => /*#__PURE__*/React__default.createElement(Column$4, {
20602
+ column: column,
20603
+ key: column.id
20604
+ })) : texts.table3.columnSettings.noResults))));
20605
+ }
20606
+
20488
20607
  function FontSize$1(props) {
20489
20608
  const {
20490
20609
  texts
@@ -20504,6 +20623,57 @@ function FontSize$1(props) {
20504
20623
  }, texts.table3.fontSize.sizes.large)));
20505
20624
  }
20506
20625
 
20626
+ function SettingsButton(props) {
20627
+ const {
20628
+ table
20629
+ } = props;
20630
+ const {
20631
+ texts
20632
+ } = useLocalization();
20633
+ const [popover, setPopover] = React__default.useState(undefined);
20634
+ const tableMeta = table.options.meta;
20635
+ const hasColumnSettings = table.options.enableHiding || tableMeta.columnOrdering.isEnabled;
20636
+ let popoverElement;
20637
+ if (popover) {
20638
+ const handleClosePopover = () => setPopover(undefined);
20639
+ switch (popover) {
20640
+ case 'columnSettings':
20641
+ {
20642
+ if (hasColumnSettings) {
20643
+ popoverElement = props => /*#__PURE__*/React__default.createElement(ColumnSettingsPopover, Object.assign({}, props, {
20644
+ open: true,
20645
+ onChange: handleClosePopover,
20646
+ table: table
20647
+ }));
20648
+ }
20649
+ }
20650
+ }
20651
+ }
20652
+ return /*#__PURE__*/React__default.createElement(IconButton, {
20653
+ "aria-label": texts.table3.otherOptions.tooltip,
20654
+ icon: "sliders",
20655
+ menu: popoverElement ? undefined : menuProps => /*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, {
20656
+ align: "end"
20657
+ }, table.options.enableHiding || tableMeta.columnOrdering.isEnabled ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Menu$1.Item, {
20658
+ icon: "columns",
20659
+ onClick: () => setPopover('columnSettings')
20660
+ }, texts.table3.columnSettings.button), /*#__PURE__*/React__default.createElement(Menu$1.Separator, null)) : null, tableMeta.rowHeight.isEnabled ? /*#__PURE__*/React__default.createElement(Menu$1.Item, {
20661
+ icon: `height-${tableMeta.rowHeight.height}`,
20662
+ subMenu: () => /*#__PURE__*/React__default.createElement(RowHeight, {
20663
+ table: table
20664
+ })
20665
+ }, texts.table3.rowHeight.tooltip) : null, tableMeta.fontSize.isEnabled ? /*#__PURE__*/React__default.createElement(Menu$1.Item, {
20666
+ icon: "font-size",
20667
+ subMenu: () => /*#__PURE__*/React__default.createElement(FontSize$1, {
20668
+ table: table
20669
+ })
20670
+ }, texts.table3.fontSize.tooltip) : null)),
20671
+ popover: popoverElement,
20672
+ onClickCapture: event => event.preventDefault(),
20673
+ tooltip: texts.table3.otherOptions.tooltip
20674
+ });
20675
+ }
20676
+
20507
20677
  function Toolbar(props) {
20508
20678
  const {
20509
20679
  left,
@@ -20513,9 +20683,6 @@ function Toolbar(props) {
20513
20683
  tableProps,
20514
20684
  total
20515
20685
  } = props;
20516
- const {
20517
- texts
20518
- } = useLocalization();
20519
20686
  if (!isToolbarVisible(props)) {
20520
20687
  return null;
20521
20688
  }
@@ -20527,38 +20694,20 @@ function Toolbar(props) {
20527
20694
  className: "ml-auto flex-shrink-0 print:hidden"
20528
20695
  }, tableMeta.editing.isEnabled ? /*#__PURE__*/React__default.createElement(EditButton, {
20529
20696
  table: table
20530
- }) : null, table.options.enableColumnFilters ? /*#__PURE__*/React__default.createElement(Filters, {
20697
+ }) : null, table.options.enableColumnFilters ? /*#__PURE__*/React__default.createElement(FiltersButton$1, {
20531
20698
  table: table,
20532
20699
  total: total
20533
- }) : null, table.options.enableHiding || tableMeta.columnOrdering.isEnabled ? /*#__PURE__*/React__default.createElement(ColumnSettings, {
20534
- table: table
20535
- }) : null, tableMeta.printing.isEnabled ? /*#__PURE__*/React__default.createElement(PrintButton, {
20700
+ }) : null, right, tableMeta.printing.isEnabled ? /*#__PURE__*/React__default.createElement(PrintButton, {
20536
20701
  table: table,
20537
20702
  tableProps: tableProps
20538
- }) : null, right, isMoreVisible(props) ? /*#__PURE__*/React__default.createElement(Tooltip, {
20539
- title: texts.table3.otherOptions.tooltip
20540
- }, /*#__PURE__*/React__default.createElement(IconButton, {
20541
- "aria-label": texts.table3.otherOptions.tooltip,
20542
- icon: "more",
20543
- menu: menuProps => /*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, {
20544
- align: "end"
20545
- }, tableMeta.rowHeight.isEnabled ? /*#__PURE__*/React__default.createElement(Menu$1.Item, {
20546
- icon: `height-${tableMeta.rowHeight.height}`,
20547
- subMenu: () => /*#__PURE__*/React__default.createElement(RowHeight, {
20548
- table: table
20549
- })
20550
- }, texts.table3.rowHeight.tooltip) : null, tableMeta.fontSize.isEnabled ? /*#__PURE__*/React__default.createElement(Menu$1.Item, {
20551
- icon: "font-size",
20552
- subMenu: () => /*#__PURE__*/React__default.createElement(FontSize$1, {
20553
- table: table
20554
- })
20555
- }, texts.table3.fontSize.tooltip) : null))
20556
- })) : null, tableMeta.search.isEnabled ? /*#__PURE__*/React__default.createElement(Search$3, {
20703
+ }) : null, isSettingsVisible(props) ? /*#__PURE__*/React__default.createElement(SettingsButton, {
20704
+ table: table
20705
+ }) : null, tableMeta.search.isEnabled ? /*#__PURE__*/React__default.createElement(Search$3, {
20557
20706
  scrollToIndex: scrollToIndex,
20558
20707
  table: table
20559
20708
  }) : null));
20560
20709
  }
20561
- function isMoreVisible(props) {
20710
+ function isSettingsVisible(props) {
20562
20711
  const {
20563
20712
  table
20564
20713
  } = props;
@@ -20882,9 +21031,11 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
20882
21031
  'text-sm': tableMeta.fontSize.size === 'medium',
20883
21032
  'text-base': tableMeta.fontSize.size === 'large'
20884
21033
  });
21034
+ // Print tables have "_print" as the postfix for the table id, so we can use the it to determine
21035
+ // if the table is a print table or not.
20885
21036
  const {
20886
21037
  style: cssGridStyle
20887
- } = useCssGrid(table);
21038
+ } = useCssGrid(table, props.id.endsWith('_print'));
20888
21039
  const {
20889
21040
  style: cssVars
20890
21041
  } = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);
@@ -21424,20 +21575,6 @@ const AgreementItem = props => {
21424
21575
  }))), children);
21425
21576
  };
21426
21577
 
21427
- const useMatchMedia = (query, defaultMatches = false) => {
21428
- const [matches, setMatches] = React__default.useState(defaultMatches);
21429
- const handleChange = React__default.useCallback(event => setMatches(event.matches), []);
21430
- React__default.useEffect(() => {
21431
- const mediaQuery = window.matchMedia(query);
21432
- setMatches(mediaQuery.matches);
21433
- mediaQuery.addEventListener('change', handleChange);
21434
- return () => {
21435
- mediaQuery.removeEventListener('change', handleChange);
21436
- };
21437
- }, []);
21438
- return matches;
21439
- };
21440
-
21441
21578
  const AgreementDisplay = props => {
21442
21579
  const {
21443
21580
  children,
@@ -21626,8 +21763,6 @@ const Content$9 = /*#__PURE__*/React__default.forwardRef(function LayoutContent(
21626
21763
  }));
21627
21764
  });
21628
21765
 
21629
- const useIsLargeScreen = () => useMatchMedia('(min-width: 1024px)', window.innerWidth > 1024);
21630
-
21631
21766
  const SidebarBackdrop = /*#__PURE__*/framerMotion.motion(Backdrop);
21632
21767
  const Sidebar = /*#__PURE__*/React__default.forwardRef(function LayoutSidebar(props, ref) {
21633
21768
  const {