@procore/data-table 14.8.0 → 14.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ import { detectPrng, factory } from 'ulid';
11
11
  import { useToastAlertContext, ToastAlertProvider } from '@procore/toast-alert';
12
12
  import ReactDOM, { createPortal } from 'react-dom';
13
13
  import { renderToString, renderToStaticMarkup } from 'react-dom/server';
14
+ import { storage } from '@procore/web-sdk-storage';
14
15
  import _isEqual from 'lodash.isequal';
15
16
  import ReactResizeDetector from 'react-resize-detector';
16
17
  import { DateTimeSelectField } from '@procore/labs-datetime-select';
@@ -1403,7 +1404,7 @@ ag-grid, ag-grid-angular, ag-grid-ng2, ag-grid-polymer, ag-grid-aurelia {
1403
1404
  animation-iteration-count: infinite;
1404
1405
  animation-name: ag-shake-left-to-right;
1405
1406
  }
1406
- @keyframes _ag-shake-left-to-right_10eap_366 {
1407
+ @keyframes _ag-shake-left-to-right_7x7l9_366 {
1407
1408
  from {
1408
1409
  padding-left: 6px;
1409
1410
  padding-right: 2px;
@@ -5404,7 +5405,7 @@ input[class^=ag-][type=button]:focus, button[class^=ag-]:focus {
5404
5405
  animation-iteration-count: infinite;
5405
5406
  animation-timing-function: linear;
5406
5407
  }
5407
- @keyframes _spin_10eap_1 {
5408
+ @keyframes _spin_7x7l9_1 {
5408
5409
  from {
5409
5410
  transform: rotate(0deg);
5410
5411
  }
@@ -7525,6 +7526,18 @@ input[class^=ag-][type=range]:disabled {
7525
7526
  box-shadow: 0px -6px 12px -3px hsla(200, 8%, 10%, 0.25);
7526
7527
  z-index: 2;
7527
7528
  }
7529
+ .ag-theme-alpine.ag-theme-alpine .ag-floating-bottom .ag-pinned-left-floating-bottom .ag-row, .ag-theme-alpine.ag-theme-alpine .ag-floating-bottom .ag-pinned-right-floating-bottom .ag-row {
7530
+ background-color: #f4f5f6;
7531
+ }
7532
+ .ag-theme-alpine.ag-theme-alpine .ag-floating-bottom .ag-pinned-left-floating-bottom {
7533
+ z-index: 1;
7534
+ box-shadow: 3px 0px 12px 0.5px hsl(200, 8%, 90%);
7535
+ border-right: 1px solid #d6dadc;
7536
+ }
7537
+ .ag-theme-alpine.ag-theme-alpine .ag-floating-bottom .ag-pinned-right-floating-bottom {
7538
+ box-shadow: -3px 0px 12px 0.5px hsl(200, 8%, 90%);
7539
+ border-left: 1px solid #d6dadc;
7540
+ }
7528
7541
  .ag-theme-alpine.ag-theme-alpine .ag-group-value {
7529
7542
  line-height: 16px;
7530
7543
  }
@@ -7891,7 +7904,7 @@ input[class^=ag-][type=range]:disabled {
7891
7904
  padding-left: 16px;
7892
7905
  }
7893
7906
 
7894
- div._contextPanel_10eap_7131 {
7907
+ div._contextPanel_7x7l9_7144 {
7895
7908
  width: 400px;
7896
7909
  transition: all ease 500ms;
7897
7910
  flex: 0 0 auto;
@@ -7900,7 +7913,7 @@ div._contextPanel_10eap_7131 {
7900
7913
  border: 1px solid #d6dadc;
7901
7914
  display: flex;
7902
7915
  }
7903
- div._contextPanel--hidden_10eap_7140 {
7916
+ div._contextPanel--hidden_7x7l9_7153 {
7904
7917
  border: none;
7905
7918
  overflow: hidden;
7906
7919
  padding: 0px;
@@ -7908,50 +7921,50 @@ div._contextPanel--hidden_10eap_7140 {
7908
7921
  width: 0px;
7909
7922
  }
7910
7923
 
7911
- ._contextPanelWrapper_10eap_7148 {
7924
+ ._contextPanelWrapper_7x7l9_7161 {
7912
7925
  position: relative;
7913
7926
  flex-grow: 1;
7914
7927
  }
7915
7928
 
7916
- ._contextPanelBody_10eap_7153 {
7929
+ ._contextPanelBody_7x7l9_7166 {
7917
7930
  width: clamp(380px, 400px, 100%);
7918
7931
  }
7919
7932
 
7920
- ._contextPanel-stickyHeader_10eap_7157 {
7933
+ ._contextPanel-stickyHeader_7x7l9_7170 {
7921
7934
  background-color: #ffffff;
7922
7935
  position: sticky;
7923
7936
  top: 0;
7924
7937
  z-index: 5;
7925
7938
  }
7926
7939
 
7927
- ._filters-list_10eap_7164 {
7940
+ ._filters-list_7x7l9_7177 {
7928
7941
  padding: 0;
7929
7942
  margin: 0;
7930
7943
  }
7931
- ._filters-list_10eap_7164 ol {
7944
+ ._filters-list_7x7l9_7177 ol {
7932
7945
  padding: 0;
7933
7946
  margin: 0;
7934
7947
  }
7935
7948
 
7936
- ._col-drag-column-icon_10eap_7173 {
7949
+ ._col-drag-column-icon_7x7l9_7186 {
7937
7950
  color: #6a767c;
7938
7951
  }
7939
7952
 
7940
- ._tabular-nums_10eap_7177 {
7953
+ ._tabular-nums_7x7l9_7190 {
7941
7954
  font-variant-numeric: tabular-nums;
7942
7955
  }`;
7943
7956
  document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css));
7944
7957
  var styles_default = {
7945
- "contextPanel": "_contextPanel_10eap_7131",
7946
- "contextPanel--hidden": "_contextPanel--hidden_10eap_7140",
7947
- "contextPanelWrapper": "_contextPanelWrapper_10eap_7148",
7948
- "contextPanelBody": "_contextPanelBody_10eap_7153",
7949
- "contextPanel-stickyHeader": "_contextPanel-stickyHeader_10eap_7157",
7950
- "filters-list": "_filters-list_10eap_7164",
7951
- "col-drag-column-icon": "_col-drag-column-icon_10eap_7173",
7952
- "tabular-nums": "_tabular-nums_10eap_7177",
7953
- "ag-shake-left-to-right": "_ag-shake-left-to-right_10eap_366",
7954
- "spin": "_spin_10eap_1"
7958
+ "contextPanel": "_contextPanel_7x7l9_7144",
7959
+ "contextPanel--hidden": "_contextPanel--hidden_7x7l9_7153",
7960
+ "contextPanelWrapper": "_contextPanelWrapper_7x7l9_7161",
7961
+ "contextPanelBody": "_contextPanelBody_7x7l9_7166",
7962
+ "contextPanel-stickyHeader": "_contextPanel-stickyHeader_7x7l9_7170",
7963
+ "filters-list": "_filters-list_7x7l9_7177",
7964
+ "col-drag-column-icon": "_col-drag-column-icon_7x7l9_7186",
7965
+ "tabular-nums": "_tabular-nums_7x7l9_7190",
7966
+ "ag-shake-left-to-right": "_ag-shake-left-to-right_7x7l9_366",
7967
+ "spin": "_spin_7x7l9_1"
7955
7968
  };
7956
7969
 
7957
7970
  // src/utils/getCellValueTypographyProps.ts
@@ -55156,6 +55169,16 @@ function getParentSelectionState(parent, affectedRows, parentChildrenMap) {
55156
55169
  return rowSelectionState.indeterminate;
55157
55170
  }
55158
55171
  }
55172
+ function getNodeSelectedState(node) {
55173
+ const filteredChildren = node.childrenAfterFilter || [];
55174
+ const numSelectedChildren = filteredChildren.filter(
55175
+ (child) => child.isSelected()
55176
+ ).length;
55177
+ return {
55178
+ selected: filteredChildren.length > 0 ? numSelectedChildren > 0 : node.isSelected(),
55179
+ indeterminate: filteredChildren ? numSelectedChildren > 0 && filteredChildren.length !== numSelectedChildren : false
55180
+ };
55181
+ }
55159
55182
  function getAffectedRows(currentRows, selectionNode, affectedRows) {
55160
55183
  const isNodeRootLevel = isNodeRootLevelOfGrid(selectionNode.parent);
55161
55184
  const nodeId = selectionNode.id;
@@ -55235,12 +55258,8 @@ function getAffectedRows(currentRows, selectionNode, affectedRows) {
55235
55258
  function noop2() {
55236
55259
  }
55237
55260
  function ClientSideRowCheckbox(props) {
55238
- const [selected, setSelected] = useState(props.node.isSelected());
55239
- const numSelectedChildren = (props.node.childrenAfterGroup || []).filter(
55240
- (child) => child.isSelected()
55241
- ).length;
55242
- const selectedState = props.node.childrenAfterGroup ? numSelectedChildren > 0 : props.node.isSelected();
55243
- const indeterminateState = props.node.childrenAfterGroup ? numSelectedChildren > 0 && props.node.childrenAfterGroup?.length !== numSelectedChildren : false;
55261
+ const [_selected, setSelected] = useState(props.node.isSelected());
55262
+ const { selected, indeterminate } = getNodeSelectedState(props.node);
55244
55263
  function handleRowSelection(event) {
55245
55264
  if (props.node === event.node) {
55246
55265
  setSelected(event.node.isSelected());
@@ -55255,13 +55274,18 @@ function ClientSideRowCheckbox(props) {
55255
55274
  return /* @__PURE__ */ React83.createElement(Box, { paddingRight: "md" }, /* @__PURE__ */ React83.createElement(
55256
55275
  Checkbox,
55257
55276
  {
55258
- checked: selectedState,
55277
+ checked: selected,
55259
55278
  disabled: props.data?.checkboxDisabled,
55260
- indeterminate: indeterminateState,
55279
+ indeterminate,
55261
55280
  "data-qa": "rowCheckbox",
55262
55281
  onClick: noop2,
55263
- onChange: () => {
55264
- props.node.setSelected(!selected, void 0, "checkboxSelected");
55282
+ onChange: (event) => {
55283
+ return props.node.setSelectedParams({
55284
+ newValue: event.target.checked,
55285
+ groupSelectsFiltered: true,
55286
+ event,
55287
+ source: "checkboxSelected"
55288
+ });
55265
55289
  }
55266
55290
  }
55267
55291
  ));
@@ -55423,23 +55447,33 @@ var AutoGroupCellRenderer = (props) => {
55423
55447
  };
55424
55448
 
55425
55449
  // src/CellRenderers/rowActionsCellStyles.scss
55426
- var css6 = `div[col-id=rowActions] {
55427
- left: calc(var(--viewport-width) - var(--rowActions-width)) !important;
55428
- padding: 0px 8px !important;
55450
+ var css6 = `.ag-theme-alpine.ag-theme-alpine div.ag-cell[col-id=rowActions] {
55451
+ left: var(--viewport-width) !important;
55452
+ width: 0px !important;
55453
+ padding: 0px !important;
55429
55454
  position: sticky;
55430
55455
  visibility: hidden;
55431
55456
  flex: none;
55457
+ background: none;
55458
+ overflow: visible;
55459
+ }
55460
+ .ag-theme-alpine.ag-theme-alpine div.ag-cell[col-id=rowActions] .inline-nonedit-wrapper {
55461
+ width: auto;
55462
+ height: 100%;
55463
+ padding: 0px 8px;
55464
+ position: absolute;
55465
+ right: 0px;
55432
55466
  }
55433
- .ag-row-hover div[col-id=rowActions] {
55467
+ .ag-theme-alpine.ag-theme-alpine .ag-row-hover div.ag-cell[col-id=rowActions] .inline-nonedit-wrapper {
55434
55468
  background: #f4f5f6;
55435
55469
  }
55436
- .ag-row-focus div[col-id=rowActions] {
55470
+ .ag-theme-alpine.ag-theme-alpine .ag-row-focus div.ag-cell[col-id=rowActions] .inline-nonedit-wrapper {
55437
55471
  background: #f6f9fe;
55438
55472
  }
55439
- .ag-row-hover div[col-id=rowActions], .ag-row-focus div[col-id=rowActions] {
55473
+ .ag-theme-alpine.ag-theme-alpine .ag-row-hover .ag-cell[col-id=rowActions], .ag-theme-alpine.ag-theme-alpine .ag-row-focus .ag-cell[col-id=rowActions] {
55440
55474
  visibility: visible;
55441
55475
  }
55442
- div[col-id=rowActions-pinned] {
55476
+ .ag-theme-alpine.ag-theme-alpine .ag-cell[col-id=rowActions-pinned] {
55443
55477
  background: "transparent";
55444
55478
  left: calc(var(--viewport-width) - var(--rowActions-width)) !important;
55445
55479
  padding: 2px 8px !important;
@@ -55448,8 +55482,18 @@ div[col-id=rowActions-pinned] {
55448
55482
  document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css6));
55449
55483
 
55450
55484
  // src/CellRenderers/RowActionsCell.tsx
55485
+ function getRowActions(actions, rowProps) {
55486
+ if (typeof actions === "function") {
55487
+ return actions(rowProps);
55488
+ }
55489
+ return actions;
55490
+ }
55451
55491
  var InternalRowActionsCellRenderer = (props) => {
55452
- if (props.rowPinned || props.columnDefinition.cellRendererParams.hideActionsOnGroupedRow && props.isGroup) {
55492
+ const actions = getRowActions(
55493
+ props.columnDefinition.cellRendererParams.actions,
55494
+ props
55495
+ );
55496
+ if (props.rowPinned || props.columnDefinition.cellRendererParams.hideActionsOnGroupedRow && props.isGroup || actions.length === 0) {
55453
55497
  return null;
55454
55498
  }
55455
55499
  return /* @__PURE__ */ React83.createElement(
@@ -55460,7 +55504,7 @@ var InternalRowActionsCellRenderer = (props) => {
55460
55504
  size: "xs",
55461
55505
  margin: "0px 4px"
55462
55506
  },
55463
- props.columnDefinition.cellRendererParams.actions.map((Action, idx) => {
55507
+ actions.map((Action, idx) => {
55464
55508
  const key = `${Action.displayName}${idx}`;
55465
55509
  return /* @__PURE__ */ React83.createElement(Action, { ...props, key });
55466
55510
  })
@@ -56112,6 +56156,7 @@ var css7 = `.ag-header-cell .data-table-header-menu {
56112
56156
  document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css7));
56113
56157
 
56114
56158
  // src/GenericHeader/GenericHeader.tsx
56159
+ var filterChanged = "filterChanged";
56115
56160
  var selectionChanged = "selectionChanged";
56116
56161
  var paginationChanged = "paginationChanged";
56117
56162
  var tooltipDelay = {
@@ -56413,7 +56458,7 @@ var GenericHeaderRenderer = (props) => {
56413
56458
  if (node.selectable === false) {
56414
56459
  return;
56415
56460
  }
56416
- if (node.isSelected()) {
56461
+ if (getNodeSelectedState(node).selected) {
56417
56462
  hasSelectedNodes = true;
56418
56463
  } else {
56419
56464
  isAllSelected = false;
@@ -56427,9 +56472,11 @@ var GenericHeaderRenderer = (props) => {
56427
56472
  setSelectAll("none" /* None */);
56428
56473
  }
56429
56474
  }
56475
+ props.api.addEventListener(filterChanged, onSelectionChanged);
56430
56476
  props.api.addEventListener(selectionChanged, onSelectionChanged);
56431
56477
  onSelectionChanged();
56432
56478
  return () => {
56479
+ removeEventListenerFromGrid(filterChanged, onSelectionChanged, props.api);
56433
56480
  removeEventListenerFromGrid(
56434
56481
  selectionChanged,
56435
56482
  onSelectionChanged,
@@ -80964,9 +81011,20 @@ var useTableApi = ({
80964
81011
  message
80965
81012
  });
80966
81013
  }, []);
81014
+ function getUnviewableGroupedColumns(columnApi2) {
81015
+ return (columnApi2?.getRowGroupColumns() ?? []).filter((column2) => {
81016
+ const colDef = column2.getColDef();
81017
+ return colDef.lockVisible && colDef.hide;
81018
+ }).map((column2) => column2.getColId());
81019
+ }
80967
81020
  const setRowGrouping = React83.useCallback(
80968
81021
  (value) => {
81022
+ const unviewableGroupedColumns = getUnviewableGroupedColumns(columnApi);
80969
81023
  columnApi?.setRowGroupColumns(value);
81024
+ const recentlyUngroupedUnviewableColumns = unviewableGroupedColumns.filter((colId) => !value.includes(colId));
81025
+ if (recentlyUngroupedUnviewableColumns.length > 0) {
81026
+ columnApi?.setColumnsVisible(recentlyUngroupedUnviewableColumns, false);
81027
+ }
80970
81028
  resetPagination();
80971
81029
  },
80972
81030
  [columnApi]
@@ -81436,15 +81494,16 @@ var DataTable = ({
81436
81494
  onTableConfigChange,
81437
81495
  showExpandCollapseAllToggle,
81438
81496
  translations: translations2 = {},
81439
- enableCellTextSelection
81497
+ enableCellTextSelection,
81498
+ localStoragePersistenceKey
81440
81499
  }) => {
81441
- const [initialTableConfig] = React83.useState(_initialTableConfig);
81500
+ const initialTableConfig = localStoragePersistenceKey && storage.local.getItem(localStoragePersistenceKey) || _initialTableConfig;
81442
81501
  const onServerSideDataRequestRef = React83.useRef(onServerSideDataRequest);
81443
81502
  const tableRef = React83.useRef(null);
81444
81503
  const [totalRowCount, setTotalRowCount] = React83.useState(0);
81445
81504
  const [selectedGroupIndex, setSelectedGroupIndex] = React83.useState(null);
81446
81505
  const [initialConfigSet, setInitialConfigSet] = React83.useState(
81447
- !_initialTableConfig
81506
+ !initialTableConfig
81448
81507
  );
81449
81508
  const contextPanel = useContextPanel();
81450
81509
  const clientI18n = useI18nContext();
@@ -81532,18 +81591,31 @@ var DataTable = ({
81532
81591
  });
81533
81592
  checkboxColumn.current = newCheckboxColumn;
81534
81593
  }
81535
- if (!gridApi || !columnApi || !onTableConfigChange) {
81594
+ if (!gridApi || !columnApi) {
81536
81595
  return;
81537
81596
  }
81538
81597
  const config = tableRef?.current?.getTableConfiguration();
81539
81598
  if (config) {
81540
- onTableConfigChange({
81599
+ if (localStoragePersistenceKey) {
81600
+ storage.local.setItem(localStoragePersistenceKey, {
81601
+ ...config,
81602
+ rowHeight: rowHeightRef.current,
81603
+ serverFilters: filterStorage.filtersState
81604
+ });
81605
+ }
81606
+ onTableConfigChange?.({
81541
81607
  ...config,
81542
81608
  rowHeight: rowHeightRef.current,
81543
81609
  serverFilters: filterStorage.filtersState
81544
81610
  });
81545
81611
  }
81546
- }, [gridApi, columnApi, onTableConfigChange, filterStorage.filtersState]);
81612
+ }, [
81613
+ gridApi,
81614
+ columnApi,
81615
+ onTableConfigChange,
81616
+ filterStorage.filtersState,
81617
+ localStoragePersistenceKey
81618
+ ]);
81547
81619
  const filtersRef = useRef(filterStorage.selectedFilters);
81548
81620
  if (!_isEqual(filtersRef.current, filterStorage.selectedFilters)) {
81549
81621
  filtersRef.current = filterStorage.selectedFilters;
@@ -81886,10 +81958,14 @@ var Table = (props) => {
81886
81958
  suppressMovable: true,
81887
81959
  suppressSizeToFit: true,
81888
81960
  suppressMenu: true,
81889
- width: rowActionsWidth.current,
81890
- minWidth: rowActionsWidth.current,
81961
+ width: suppressColumnVirtualisation ? 0 : rowActionsWidth.current,
81962
+ minWidth: suppressColumnVirtualisation ? 0 : rowActionsWidth.current,
81891
81963
  cellStyle: (params) => {
81892
- if (params.node.rowPinned === "bottom") {
81964
+ const actions = getRowActions(
81965
+ params.colDef.cellRendererParams.actions,
81966
+ params
81967
+ );
81968
+ if (params.node.rowPinned === "bottom" || actions.length === 0) {
81893
81969
  return {
81894
81970
  display: "none"
81895
81971
  };
@@ -82623,7 +82699,8 @@ var ClientSideDataTable = ({
82623
82699
  onBulkEditUpdate,
82624
82700
  onTableConfigChange,
82625
82701
  translations: translations2 = {},
82626
- enableCellTextSelection
82702
+ enableCellTextSelection,
82703
+ localStoragePersistenceKey
82627
82704
  }) => {
82628
82705
  return /* @__PURE__ */ React83.createElement(
82629
82706
  DataTable,
@@ -82639,6 +82716,7 @@ var ClientSideDataTable = ({
82639
82716
  onBulkEditUpdate,
82640
82717
  showExpandCollapseAllToggle: true,
82641
82718
  translations: translations2,
82719
+ localStoragePersistenceKey,
82642
82720
  customBulkEditorFields,
82643
82721
  enableCellTextSelection
82644
82722
  },
@@ -87119,8 +87197,8 @@ var FilterListener = class FilterListener2 extends BeanStub {
87119
87197
  Object.keys(allColKeysMap).forEach((key) => {
87120
87198
  const oldJson = JSON.stringify(oldModel[key]);
87121
87199
  const newJson = JSON.stringify(newModel[key]);
87122
- const filterChanged = oldJson != newJson;
87123
- if (filterChanged) {
87200
+ const filterChanged2 = oldJson != newJson;
87201
+ if (filterChanged2) {
87124
87202
  res.push(key);
87125
87203
  }
87126
87204
  });
@@ -88031,7 +88109,8 @@ var ServerSideDataTable = ({
88031
88109
  onTableConfigChange,
88032
88110
  enableCellTextSelection,
88033
88111
  showExpandCollapseAllToggle,
88034
- translations: translations2 = {}
88112
+ translations: translations2 = {},
88113
+ localStoragePersistenceKey
88035
88114
  }) => {
88036
88115
  return /* @__PURE__ */ React83.createElement(
88037
88116
  DataTable,
@@ -88049,7 +88128,8 @@ var ServerSideDataTable = ({
88049
88128
  showExpandCollapseAllToggle,
88050
88129
  translations: translations2,
88051
88130
  customBulkEditorFields,
88052
- enableCellTextSelection
88131
+ enableCellTextSelection,
88132
+ localStoragePersistenceKey
88053
88133
  },
88054
88134
  children
88055
88135
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/data-table",
3
- "version": "14.8.0",
3
+ "version": "14.9.0",
4
4
  "description": "Complex data grid built on top of ag-grid, with DST components and styles.",
5
5
  "type": "module",
6
6
  "main": "dist/legacy/index.cjs",
@@ -81,6 +81,7 @@
81
81
  "@procore/labs-datetime-select": "0.1.0",
82
82
  "@procore/labs-group-by-select": "3.1.2",
83
83
  "@procore/toast-alert": "5.1.0",
84
+ "@procore/web-sdk-storage": "^0.1.0",
84
85
  "classnames": "2.5.1",
85
86
  "date-fns": "2.29.1",
86
87
  "decimal.js": "10.3.1",
@@ -107,9 +108,9 @@
107
108
  "@dotenvx/dotenvx": "1.6.4",
108
109
  "@ngneat/falso": "6.4.0",
109
110
  "@procore/core-css": "10.17.0",
110
- "@procore/core-icons": "12.0.0",
111
+ "@procore/core-icons": "12.1.0",
111
112
  "@procore/core-prettier": "10.2.0",
112
- "@procore/core-react": "12.6.0",
113
+ "@procore/core-react": "12.7.0",
113
114
  "@procore/eslint-config": "10.0.0",
114
115
  "@procore/globalization-toolkit": "3.1.0",
115
116
  "@procore/labs-financials-utils": "3.0.1",