@procore/saved-views 1.0.1-alpha.0 → 1.0.1-alpha.2

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.
@@ -146,6 +146,7 @@ type SavedViewCollectionMenuItemProps = {
146
146
  isUpdateProcessing?: boolean;
147
147
  permissions?: IPermissions;
148
148
  onClearTemporary?: () => void;
149
+ enableSharingViews?: boolean;
149
150
  };
150
151
  declare const SavedViewCollectionMenuItem: (props: SavedViewCollectionMenuItemProps) => React.JSX.Element;
151
152
 
@@ -146,6 +146,7 @@ type SavedViewCollectionMenuItemProps = {
146
146
  isUpdateProcessing?: boolean;
147
147
  permissions?: IPermissions;
148
148
  onClearTemporary?: () => void;
149
+ enableSharingViews?: boolean;
149
150
  };
150
151
  declare const SavedViewCollectionMenuItem: (props: SavedViewCollectionMenuItemProps) => React.JSX.Element;
151
152
 
@@ -3976,7 +3976,7 @@ var require_lodash = __commonJS({
3976
3976
  if (typeof func != "function") {
3977
3977
  throw new TypeError2(FUNC_ERROR_TEXT);
3978
3978
  }
3979
- return setTimeout(function() {
3979
+ return setTimeout2(function() {
3980
3980
  func.apply(undefined2, args);
3981
3981
  }, wait);
3982
3982
  }
@@ -5807,7 +5807,7 @@ var require_lodash = __commonJS({
5807
5807
  return object2[key];
5808
5808
  }
5809
5809
  var setData = shortOut(baseSetData);
5810
- var setTimeout = ctxSetTimeout || function(func, wait) {
5810
+ var setTimeout2 = ctxSetTimeout || function(func, wait) {
5811
5811
  return root.setTimeout(func, wait);
5812
5812
  };
5813
5813
  var setToString = shortOut(baseSetToString);
@@ -6599,7 +6599,7 @@ var require_lodash = __commonJS({
6599
6599
  }
6600
6600
  function leadingEdge(time) {
6601
6601
  lastInvokeTime = time;
6602
- timerId = setTimeout(timerExpired, wait);
6602
+ timerId = setTimeout2(timerExpired, wait);
6603
6603
  return leading ? invokeFunc(time) : result2;
6604
6604
  }
6605
6605
  function remainingWait(time) {
@@ -6615,7 +6615,7 @@ var require_lodash = __commonJS({
6615
6615
  if (shouldInvoke(time)) {
6616
6616
  return trailingEdge(time);
6617
6617
  }
6618
- timerId = setTimeout(timerExpired, remainingWait(time));
6618
+ timerId = setTimeout2(timerExpired, remainingWait(time));
6619
6619
  }
6620
6620
  function trailingEdge(time) {
6621
6621
  timerId = undefined2;
@@ -6646,12 +6646,12 @@ var require_lodash = __commonJS({
6646
6646
  }
6647
6647
  if (maxing) {
6648
6648
  clearTimeout(timerId);
6649
- timerId = setTimeout(timerExpired, wait);
6649
+ timerId = setTimeout2(timerExpired, wait);
6650
6650
  return invokeFunc(lastCallTime);
6651
6651
  }
6652
6652
  }
6653
6653
  if (timerId === undefined2) {
6654
- timerId = setTimeout(timerExpired, wait);
6654
+ timerId = setTimeout2(timerExpired, wait);
6655
6655
  }
6656
6656
  return result2;
6657
6657
  }
@@ -11391,7 +11391,7 @@ var SavedViewCollectionMenuItem = (props) => {
11391
11391
  loading: props.isUpdateProcessing
11392
11392
  },
11393
11393
  i18n.t("savedViews.actions.update")
11394
- )), props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
11394
+ )), (props.enableSharingViews ?? true) && props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
11395
11395
  import_core_react3.Button,
11396
11396
  {
11397
11397
  onClick: copyShareLink,
@@ -11520,10 +11520,12 @@ var getColumnIdentifier = (col) => {
11520
11520
  };
11521
11521
  var updateTableConfig = (view, tableApi, provider) => {
11522
11522
  if (provider === "smart-grid") {
11523
- setSmartGridConfig(
11524
- tableApi,
11525
- view.table_config
11526
- );
11523
+ setTimeout(() => {
11524
+ setSmartGridConfig(
11525
+ tableApi,
11526
+ view.table_config
11527
+ );
11528
+ }, 0);
11527
11529
  } else {
11528
11530
  const dataTableApi = tableApi;
11529
11531
  const tableConfig = view.table_config;
@@ -11595,9 +11597,15 @@ var cleanObject = (table_config, provider) => {
11595
11597
  var normalizeForComparison = (config) => {
11596
11598
  if (!(config == null ? void 0 : config.columnState))
11597
11599
  return config;
11600
+ const filteredColumnState = config.columnState.filter(
11601
+ (col) => {
11602
+ const colId = getColumnIdentifier(col);
11603
+ return colId !== "drag_handle" && colId !== "ag-Grid-AutoColumn";
11604
+ }
11605
+ );
11598
11606
  return {
11599
11607
  ...import_lodash.default.omit(config, ["enableRowGrouping", "enableColumnGrouping"]),
11600
- columnState: config.columnState.map((col) => {
11608
+ columnState: filteredColumnState.map((col) => {
11601
11609
  const res = import_lodash.default.omit(col, ["aggFunc"]);
11602
11610
  if (col.flex) {
11603
11611
  return import_lodash.default.omit(res, ["width", "flex"]);
@@ -11765,7 +11773,8 @@ var PanelContent = (props) => {
11765
11773
  {
11766
11774
  item: temporaryView,
11767
11775
  selected: isTemporarySelected,
11768
- onClearTemporary: props.onClearTemporary
11776
+ onClearTemporary: props.onClearTemporary,
11777
+ enableSharingViews: false
11769
11778
  }
11770
11779
  )
11771
11780
  ), presetViews.map((presetView) => {
@@ -11782,7 +11791,8 @@ var PanelContent = (props) => {
11782
11791
  SavedViewCollectionMenuItem,
11783
11792
  {
11784
11793
  item: presetView,
11785
- selected: isSelected
11794
+ selected: isSelected,
11795
+ enableSharingViews: false
11786
11796
  }
11787
11797
  )
11788
11798
  );
@@ -11830,7 +11840,8 @@ var PanelContent = (props) => {
11830
11840
  isUpdateProcessing: isUpdateLoading,
11831
11841
  onEdit: () => props.openModal("update" /* UPDATE */),
11832
11842
  onDelete: props.onDelete,
11833
- permissions
11843
+ permissions,
11844
+ enableSharingViews: false
11834
11845
  }
11835
11846
  )
11836
11847
  );
@@ -15118,26 +15129,37 @@ var DEFAULT_COLUMN_STATE = {
15118
15129
  rowGroupIndex: null,
15119
15130
  flex: null
15120
15131
  };
15132
+ var isColGroupDef = (colDef) => {
15133
+ return "children" in colDef && Array.isArray(colDef.children);
15134
+ };
15121
15135
  var getColumnStateFromDefs = (columnDefs) => {
15122
- return columnDefs.map((colDef) => {
15123
- const field = colDef.field ?? colDef.colId;
15124
- if (!field)
15125
- return null;
15126
- return {
15127
- colId: field,
15128
- hide: colDef.hide ?? false,
15129
- pinned: colDef.pinned ?? null,
15130
- width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
15131
- sort: null,
15132
- sortIndex: null,
15133
- pivot: false,
15134
- pivotIndex: null,
15135
- aggFunc: null,
15136
- rowGroup: false,
15137
- rowGroupIndex: null,
15138
- flex: colDef.flex ?? null
15139
- };
15140
- }).filter((col) => col !== null);
15136
+ return columnDefs.flatMap((colDef) => {
15137
+ if (isColGroupDef(colDef)) {
15138
+ return getColumnStateFromDefs(colDef.children);
15139
+ }
15140
+ return getColumnStateFromSingleDef(colDef);
15141
+ }).filter(
15142
+ (col) => col !== null
15143
+ );
15144
+ };
15145
+ var getColumnStateFromSingleDef = (colDef) => {
15146
+ const field = colDef.field ?? colDef.colId;
15147
+ if (!field)
15148
+ return null;
15149
+ return {
15150
+ colId: field,
15151
+ hide: colDef.hide ?? false,
15152
+ pinned: colDef.pinned ?? null,
15153
+ width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
15154
+ sort: null,
15155
+ sortIndex: null,
15156
+ pivot: false,
15157
+ pivotIndex: null,
15158
+ aggFunc: null,
15159
+ rowGroup: false,
15160
+ rowGroupIndex: null,
15161
+ flex: colDef.flex ?? null
15162
+ };
15141
15163
  };
15142
15164
  var extractDefaultView = (gridApi, receivedConfig) => {
15143
15165
  var _a, _b;
@@ -15220,18 +15242,21 @@ var SmartGridSavedViews = (props) => {
15220
15242
  const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
15221
15243
  const onSelect = (0, import_react16.useCallback)(
15222
15244
  ({ item }) => {
15245
+ var _a;
15223
15246
  if (!gridApi)
15224
15247
  return item;
15225
15248
  const isPresetView = item.view_level === "default";
15249
+ const newConfig = item.table_config;
15250
+ const transformedConfig = ((_a = props.transformSettings) == null ? void 0 : _a.call(props, newConfig)) ?? newConfig;
15226
15251
  if (isPresetView) {
15227
15252
  updateTableConfig(item, gridApi, "smart-grid");
15228
- setTableConfig(item.table_config);
15253
+ setTableConfig(transformedConfig);
15229
15254
  return item;
15230
15255
  }
15231
15256
  const updatedView = {
15232
15257
  ...item,
15233
15258
  table_config: customAndConfigSync(
15234
- item.table_config,
15259
+ transformedConfig,
15235
15260
  tableConfig
15236
15261
  )
15237
15262
  };
@@ -3982,7 +3982,7 @@ var require_lodash = __commonJS({
3982
3982
  if (typeof func != "function") {
3983
3983
  throw new TypeError2(FUNC_ERROR_TEXT);
3984
3984
  }
3985
- return setTimeout(function() {
3985
+ return setTimeout2(function() {
3986
3986
  func.apply(undefined2, args);
3987
3987
  }, wait);
3988
3988
  }
@@ -5813,7 +5813,7 @@ var require_lodash = __commonJS({
5813
5813
  return object2[key];
5814
5814
  }
5815
5815
  var setData = shortOut(baseSetData);
5816
- var setTimeout = ctxSetTimeout || function(func, wait) {
5816
+ var setTimeout2 = ctxSetTimeout || function(func, wait) {
5817
5817
  return root.setTimeout(func, wait);
5818
5818
  };
5819
5819
  var setToString = shortOut(baseSetToString);
@@ -6605,7 +6605,7 @@ var require_lodash = __commonJS({
6605
6605
  }
6606
6606
  function leadingEdge(time) {
6607
6607
  lastInvokeTime = time;
6608
- timerId = setTimeout(timerExpired, wait);
6608
+ timerId = setTimeout2(timerExpired, wait);
6609
6609
  return leading ? invokeFunc(time) : result2;
6610
6610
  }
6611
6611
  function remainingWait(time) {
@@ -6621,7 +6621,7 @@ var require_lodash = __commonJS({
6621
6621
  if (shouldInvoke(time)) {
6622
6622
  return trailingEdge(time);
6623
6623
  }
6624
- timerId = setTimeout(timerExpired, remainingWait(time));
6624
+ timerId = setTimeout2(timerExpired, remainingWait(time));
6625
6625
  }
6626
6626
  function trailingEdge(time) {
6627
6627
  timerId = undefined2;
@@ -6652,12 +6652,12 @@ var require_lodash = __commonJS({
6652
6652
  }
6653
6653
  if (maxing) {
6654
6654
  clearTimeout(timerId);
6655
- timerId = setTimeout(timerExpired, wait);
6655
+ timerId = setTimeout2(timerExpired, wait);
6656
6656
  return invokeFunc(lastCallTime);
6657
6657
  }
6658
6658
  }
6659
6659
  if (timerId === undefined2) {
6660
- timerId = setTimeout(timerExpired, wait);
6660
+ timerId = setTimeout2(timerExpired, wait);
6661
6661
  }
6662
6662
  return result2;
6663
6663
  }
@@ -11387,7 +11387,7 @@ var SavedViewCollectionMenuItem = (props) => {
11387
11387
  loading: props.isUpdateProcessing
11388
11388
  },
11389
11389
  i18n.t("savedViews.actions.update")
11390
- )), props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
11390
+ )), (props.enableSharingViews ?? true) && props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
11391
11391
  Button2,
11392
11392
  {
11393
11393
  onClick: copyShareLink,
@@ -11516,10 +11516,12 @@ var getColumnIdentifier = (col) => {
11516
11516
  };
11517
11517
  var updateTableConfig = (view, tableApi, provider) => {
11518
11518
  if (provider === "smart-grid") {
11519
- setSmartGridConfig(
11520
- tableApi,
11521
- view.table_config
11522
- );
11519
+ setTimeout(() => {
11520
+ setSmartGridConfig(
11521
+ tableApi,
11522
+ view.table_config
11523
+ );
11524
+ }, 0);
11523
11525
  } else {
11524
11526
  const dataTableApi = tableApi;
11525
11527
  const tableConfig = view.table_config;
@@ -11591,9 +11593,15 @@ var cleanObject = (table_config, provider) => {
11591
11593
  var normalizeForComparison = (config) => {
11592
11594
  if (!(config == null ? void 0 : config.columnState))
11593
11595
  return config;
11596
+ const filteredColumnState = config.columnState.filter(
11597
+ (col) => {
11598
+ const colId = getColumnIdentifier(col);
11599
+ return colId !== "drag_handle" && colId !== "ag-Grid-AutoColumn";
11600
+ }
11601
+ );
11594
11602
  return {
11595
11603
  ...import_lodash.default.omit(config, ["enableRowGrouping", "enableColumnGrouping"]),
11596
- columnState: config.columnState.map((col) => {
11604
+ columnState: filteredColumnState.map((col) => {
11597
11605
  const res = import_lodash.default.omit(col, ["aggFunc"]);
11598
11606
  if (col.flex) {
11599
11607
  return import_lodash.default.omit(res, ["width", "flex"]);
@@ -11772,7 +11780,8 @@ var PanelContent = (props) => {
11772
11780
  {
11773
11781
  item: temporaryView,
11774
11782
  selected: isTemporarySelected,
11775
- onClearTemporary: props.onClearTemporary
11783
+ onClearTemporary: props.onClearTemporary,
11784
+ enableSharingViews: false
11776
11785
  }
11777
11786
  )
11778
11787
  ), presetViews.map((presetView) => {
@@ -11789,7 +11798,8 @@ var PanelContent = (props) => {
11789
11798
  SavedViewCollectionMenuItem,
11790
11799
  {
11791
11800
  item: presetView,
11792
- selected: isSelected
11801
+ selected: isSelected,
11802
+ enableSharingViews: false
11793
11803
  }
11794
11804
  )
11795
11805
  );
@@ -11837,7 +11847,8 @@ var PanelContent = (props) => {
11837
11847
  isUpdateProcessing: isUpdateLoading,
11838
11848
  onEdit: () => props.openModal("update" /* UPDATE */),
11839
11849
  onDelete: props.onDelete,
11840
- permissions
11850
+ permissions,
11851
+ enableSharingViews: false
11841
11852
  }
11842
11853
  )
11843
11854
  );
@@ -15162,26 +15173,37 @@ var DEFAULT_COLUMN_STATE = {
15162
15173
  rowGroupIndex: null,
15163
15174
  flex: null
15164
15175
  };
15176
+ var isColGroupDef = (colDef) => {
15177
+ return "children" in colDef && Array.isArray(colDef.children);
15178
+ };
15165
15179
  var getColumnStateFromDefs = (columnDefs) => {
15166
- return columnDefs.map((colDef) => {
15167
- const field = colDef.field ?? colDef.colId;
15168
- if (!field)
15169
- return null;
15170
- return {
15171
- colId: field,
15172
- hide: colDef.hide ?? false,
15173
- pinned: colDef.pinned ?? null,
15174
- width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
15175
- sort: null,
15176
- sortIndex: null,
15177
- pivot: false,
15178
- pivotIndex: null,
15179
- aggFunc: null,
15180
- rowGroup: false,
15181
- rowGroupIndex: null,
15182
- flex: colDef.flex ?? null
15183
- };
15184
- }).filter((col) => col !== null);
15180
+ return columnDefs.flatMap((colDef) => {
15181
+ if (isColGroupDef(colDef)) {
15182
+ return getColumnStateFromDefs(colDef.children);
15183
+ }
15184
+ return getColumnStateFromSingleDef(colDef);
15185
+ }).filter(
15186
+ (col) => col !== null
15187
+ );
15188
+ };
15189
+ var getColumnStateFromSingleDef = (colDef) => {
15190
+ const field = colDef.field ?? colDef.colId;
15191
+ if (!field)
15192
+ return null;
15193
+ return {
15194
+ colId: field,
15195
+ hide: colDef.hide ?? false,
15196
+ pinned: colDef.pinned ?? null,
15197
+ width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
15198
+ sort: null,
15199
+ sortIndex: null,
15200
+ pivot: false,
15201
+ pivotIndex: null,
15202
+ aggFunc: null,
15203
+ rowGroup: false,
15204
+ rowGroupIndex: null,
15205
+ flex: colDef.flex ?? null
15206
+ };
15185
15207
  };
15186
15208
  var extractDefaultView = (gridApi, receivedConfig) => {
15187
15209
  var _a, _b;
@@ -15264,18 +15286,21 @@ var SmartGridSavedViews = (props) => {
15264
15286
  const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
15265
15287
  const onSelect = useCallback4(
15266
15288
  ({ item }) => {
15289
+ var _a;
15267
15290
  if (!gridApi)
15268
15291
  return item;
15269
15292
  const isPresetView = item.view_level === "default";
15293
+ const newConfig = item.table_config;
15294
+ const transformedConfig = ((_a = props.transformSettings) == null ? void 0 : _a.call(props, newConfig)) ?? newConfig;
15270
15295
  if (isPresetView) {
15271
15296
  updateTableConfig(item, gridApi, "smart-grid");
15272
- setTableConfig(item.table_config);
15297
+ setTableConfig(transformedConfig);
15273
15298
  return item;
15274
15299
  }
15275
15300
  const updatedView = {
15276
15301
  ...item,
15277
15302
  table_config: customAndConfigSync(
15278
- item.table_config,
15303
+ transformedConfig,
15279
15304
  tableConfig
15280
15305
  )
15281
15306
  };
@@ -146,6 +146,7 @@ type SavedViewCollectionMenuItemProps = {
146
146
  isUpdateProcessing?: boolean;
147
147
  permissions?: IPermissions;
148
148
  onClearTemporary?: () => void;
149
+ enableSharingViews?: boolean;
149
150
  };
150
151
  declare const SavedViewCollectionMenuItem: (props: SavedViewCollectionMenuItemProps) => React.JSX.Element;
151
152
 
@@ -146,6 +146,7 @@ type SavedViewCollectionMenuItemProps = {
146
146
  isUpdateProcessing?: boolean;
147
147
  permissions?: IPermissions;
148
148
  onClearTemporary?: () => void;
149
+ enableSharingViews?: boolean;
149
150
  };
150
151
  declare const SavedViewCollectionMenuItem: (props: SavedViewCollectionMenuItemProps) => React.JSX.Element;
151
152
 
@@ -3976,7 +3976,7 @@ var require_lodash = __commonJS({
3976
3976
  if (typeof func != "function") {
3977
3977
  throw new TypeError2(FUNC_ERROR_TEXT);
3978
3978
  }
3979
- return setTimeout(function() {
3979
+ return setTimeout2(function() {
3980
3980
  func.apply(undefined2, args);
3981
3981
  }, wait);
3982
3982
  }
@@ -5807,7 +5807,7 @@ var require_lodash = __commonJS({
5807
5807
  return object2[key];
5808
5808
  }
5809
5809
  var setData = shortOut(baseSetData);
5810
- var setTimeout = ctxSetTimeout || function(func, wait) {
5810
+ var setTimeout2 = ctxSetTimeout || function(func, wait) {
5811
5811
  return root.setTimeout(func, wait);
5812
5812
  };
5813
5813
  var setToString = shortOut(baseSetToString);
@@ -6599,7 +6599,7 @@ var require_lodash = __commonJS({
6599
6599
  }
6600
6600
  function leadingEdge(time) {
6601
6601
  lastInvokeTime = time;
6602
- timerId = setTimeout(timerExpired, wait);
6602
+ timerId = setTimeout2(timerExpired, wait);
6603
6603
  return leading ? invokeFunc(time) : result2;
6604
6604
  }
6605
6605
  function remainingWait(time) {
@@ -6615,7 +6615,7 @@ var require_lodash = __commonJS({
6615
6615
  if (shouldInvoke(time)) {
6616
6616
  return trailingEdge(time);
6617
6617
  }
6618
- timerId = setTimeout(timerExpired, remainingWait(time));
6618
+ timerId = setTimeout2(timerExpired, remainingWait(time));
6619
6619
  }
6620
6620
  function trailingEdge(time) {
6621
6621
  timerId = undefined2;
@@ -6646,12 +6646,12 @@ var require_lodash = __commonJS({
6646
6646
  }
6647
6647
  if (maxing) {
6648
6648
  clearTimeout(timerId);
6649
- timerId = setTimeout(timerExpired, wait);
6649
+ timerId = setTimeout2(timerExpired, wait);
6650
6650
  return invokeFunc(lastCallTime);
6651
6651
  }
6652
6652
  }
6653
6653
  if (timerId === undefined2) {
6654
- timerId = setTimeout(timerExpired, wait);
6654
+ timerId = setTimeout2(timerExpired, wait);
6655
6655
  }
6656
6656
  return result2;
6657
6657
  }
@@ -11389,7 +11389,7 @@ var SavedViewCollectionMenuItem = (props) => {
11389
11389
  loading: props.isUpdateProcessing
11390
11390
  },
11391
11391
  i18n.t("savedViews.actions.update")
11392
- )), props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
11392
+ )), (props.enableSharingViews ?? true) && props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
11393
11393
  import_core_react3.Button,
11394
11394
  {
11395
11395
  onClick: copyShareLink,
@@ -11517,10 +11517,12 @@ var getColumnIdentifier = (col) => {
11517
11517
  };
11518
11518
  var updateTableConfig = (view, tableApi, provider) => {
11519
11519
  if (provider === "smart-grid") {
11520
- setSmartGridConfig(
11521
- tableApi,
11522
- view.table_config
11523
- );
11520
+ setTimeout(() => {
11521
+ setSmartGridConfig(
11522
+ tableApi,
11523
+ view.table_config
11524
+ );
11525
+ }, 0);
11524
11526
  } else {
11525
11527
  const dataTableApi = tableApi;
11526
11528
  const tableConfig = view.table_config;
@@ -11592,9 +11594,15 @@ var cleanObject = (table_config, provider) => {
11592
11594
  var normalizeForComparison = (config) => {
11593
11595
  if (!config?.columnState)
11594
11596
  return config;
11597
+ const filteredColumnState = config.columnState.filter(
11598
+ (col) => {
11599
+ const colId = getColumnIdentifier(col);
11600
+ return colId !== "drag_handle" && colId !== "ag-Grid-AutoColumn";
11601
+ }
11602
+ );
11595
11603
  return {
11596
11604
  ...import_lodash.default.omit(config, ["enableRowGrouping", "enableColumnGrouping"]),
11597
- columnState: config.columnState.map((col) => {
11605
+ columnState: filteredColumnState.map((col) => {
11598
11606
  const res = import_lodash.default.omit(col, ["aggFunc"]);
11599
11607
  if (col.flex) {
11600
11608
  return import_lodash.default.omit(res, ["width", "flex"]);
@@ -11762,7 +11770,8 @@ var PanelContent = (props) => {
11762
11770
  {
11763
11771
  item: temporaryView,
11764
11772
  selected: isTemporarySelected,
11765
- onClearTemporary: props.onClearTemporary
11773
+ onClearTemporary: props.onClearTemporary,
11774
+ enableSharingViews: false
11766
11775
  }
11767
11776
  )
11768
11777
  ), presetViews.map((presetView) => {
@@ -11779,7 +11788,8 @@ var PanelContent = (props) => {
11779
11788
  SavedViewCollectionMenuItem,
11780
11789
  {
11781
11790
  item: presetView,
11782
- selected: isSelected
11791
+ selected: isSelected,
11792
+ enableSharingViews: false
11783
11793
  }
11784
11794
  )
11785
11795
  );
@@ -11827,7 +11837,8 @@ var PanelContent = (props) => {
11827
11837
  isUpdateProcessing: isUpdateLoading,
11828
11838
  onEdit: () => props.openModal("update" /* UPDATE */),
11829
11839
  onDelete: props.onDelete,
11830
- permissions
11840
+ permissions,
11841
+ enableSharingViews: false
11831
11842
  }
11832
11843
  )
11833
11844
  );
@@ -15115,26 +15126,37 @@ var DEFAULT_COLUMN_STATE = {
15115
15126
  rowGroupIndex: null,
15116
15127
  flex: null
15117
15128
  };
15129
+ var isColGroupDef = (colDef) => {
15130
+ return "children" in colDef && Array.isArray(colDef.children);
15131
+ };
15118
15132
  var getColumnStateFromDefs = (columnDefs) => {
15119
- return columnDefs.map((colDef) => {
15120
- const field = colDef.field ?? colDef.colId;
15121
- if (!field)
15122
- return null;
15123
- return {
15124
- colId: field,
15125
- hide: colDef.hide ?? false,
15126
- pinned: colDef.pinned ?? null,
15127
- width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
15128
- sort: null,
15129
- sortIndex: null,
15130
- pivot: false,
15131
- pivotIndex: null,
15132
- aggFunc: null,
15133
- rowGroup: false,
15134
- rowGroupIndex: null,
15135
- flex: colDef.flex ?? null
15136
- };
15137
- }).filter((col) => col !== null);
15133
+ return columnDefs.flatMap((colDef) => {
15134
+ if (isColGroupDef(colDef)) {
15135
+ return getColumnStateFromDefs(colDef.children);
15136
+ }
15137
+ return getColumnStateFromSingleDef(colDef);
15138
+ }).filter(
15139
+ (col) => col !== null
15140
+ );
15141
+ };
15142
+ var getColumnStateFromSingleDef = (colDef) => {
15143
+ const field = colDef.field ?? colDef.colId;
15144
+ if (!field)
15145
+ return null;
15146
+ return {
15147
+ colId: field,
15148
+ hide: colDef.hide ?? false,
15149
+ pinned: colDef.pinned ?? null,
15150
+ width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
15151
+ sort: null,
15152
+ sortIndex: null,
15153
+ pivot: false,
15154
+ pivotIndex: null,
15155
+ aggFunc: null,
15156
+ rowGroup: false,
15157
+ rowGroupIndex: null,
15158
+ flex: colDef.flex ?? null
15159
+ };
15138
15160
  };
15139
15161
  var extractDefaultView = (gridApi, receivedConfig) => {
15140
15162
  const columnDefs = gridApi.getColumnDefs() ?? [];
@@ -15219,15 +15241,17 @@ var SmartGridSavedViews = (props) => {
15219
15241
  if (!gridApi)
15220
15242
  return item;
15221
15243
  const isPresetView = item.view_level === "default";
15244
+ const newConfig = item.table_config;
15245
+ const transformedConfig = props.transformSettings?.(newConfig) ?? newConfig;
15222
15246
  if (isPresetView) {
15223
15247
  updateTableConfig(item, gridApi, "smart-grid");
15224
- setTableConfig(item.table_config);
15248
+ setTableConfig(transformedConfig);
15225
15249
  return item;
15226
15250
  }
15227
15251
  const updatedView = {
15228
15252
  ...item,
15229
15253
  table_config: customAndConfigSync(
15230
- item.table_config,
15254
+ transformedConfig,
15231
15255
  tableConfig
15232
15256
  )
15233
15257
  };
@@ -3982,7 +3982,7 @@ var require_lodash = __commonJS({
3982
3982
  if (typeof func != "function") {
3983
3983
  throw new TypeError2(FUNC_ERROR_TEXT);
3984
3984
  }
3985
- return setTimeout(function() {
3985
+ return setTimeout2(function() {
3986
3986
  func.apply(undefined2, args);
3987
3987
  }, wait);
3988
3988
  }
@@ -5813,7 +5813,7 @@ var require_lodash = __commonJS({
5813
5813
  return object2[key];
5814
5814
  }
5815
5815
  var setData = shortOut(baseSetData);
5816
- var setTimeout = ctxSetTimeout || function(func, wait) {
5816
+ var setTimeout2 = ctxSetTimeout || function(func, wait) {
5817
5817
  return root.setTimeout(func, wait);
5818
5818
  };
5819
5819
  var setToString = shortOut(baseSetToString);
@@ -6605,7 +6605,7 @@ var require_lodash = __commonJS({
6605
6605
  }
6606
6606
  function leadingEdge(time) {
6607
6607
  lastInvokeTime = time;
6608
- timerId = setTimeout(timerExpired, wait);
6608
+ timerId = setTimeout2(timerExpired, wait);
6609
6609
  return leading ? invokeFunc(time) : result2;
6610
6610
  }
6611
6611
  function remainingWait(time) {
@@ -6621,7 +6621,7 @@ var require_lodash = __commonJS({
6621
6621
  if (shouldInvoke(time)) {
6622
6622
  return trailingEdge(time);
6623
6623
  }
6624
- timerId = setTimeout(timerExpired, remainingWait(time));
6624
+ timerId = setTimeout2(timerExpired, remainingWait(time));
6625
6625
  }
6626
6626
  function trailingEdge(time) {
6627
6627
  timerId = undefined2;
@@ -6652,12 +6652,12 @@ var require_lodash = __commonJS({
6652
6652
  }
6653
6653
  if (maxing) {
6654
6654
  clearTimeout(timerId);
6655
- timerId = setTimeout(timerExpired, wait);
6655
+ timerId = setTimeout2(timerExpired, wait);
6656
6656
  return invokeFunc(lastCallTime);
6657
6657
  }
6658
6658
  }
6659
6659
  if (timerId === undefined2) {
6660
- timerId = setTimeout(timerExpired, wait);
6660
+ timerId = setTimeout2(timerExpired, wait);
6661
6661
  }
6662
6662
  return result2;
6663
6663
  }
@@ -11385,7 +11385,7 @@ var SavedViewCollectionMenuItem = (props) => {
11385
11385
  loading: props.isUpdateProcessing
11386
11386
  },
11387
11387
  i18n.t("savedViews.actions.update")
11388
- )), props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
11388
+ )), (props.enableSharingViews ?? true) && props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
11389
11389
  Button2,
11390
11390
  {
11391
11391
  onClick: copyShareLink,
@@ -11513,10 +11513,12 @@ var getColumnIdentifier = (col) => {
11513
11513
  };
11514
11514
  var updateTableConfig = (view, tableApi, provider) => {
11515
11515
  if (provider === "smart-grid") {
11516
- setSmartGridConfig(
11517
- tableApi,
11518
- view.table_config
11519
- );
11516
+ setTimeout(() => {
11517
+ setSmartGridConfig(
11518
+ tableApi,
11519
+ view.table_config
11520
+ );
11521
+ }, 0);
11520
11522
  } else {
11521
11523
  const dataTableApi = tableApi;
11522
11524
  const tableConfig = view.table_config;
@@ -11588,9 +11590,15 @@ var cleanObject = (table_config, provider) => {
11588
11590
  var normalizeForComparison = (config) => {
11589
11591
  if (!config?.columnState)
11590
11592
  return config;
11593
+ const filteredColumnState = config.columnState.filter(
11594
+ (col) => {
11595
+ const colId = getColumnIdentifier(col);
11596
+ return colId !== "drag_handle" && colId !== "ag-Grid-AutoColumn";
11597
+ }
11598
+ );
11591
11599
  return {
11592
11600
  ...import_lodash.default.omit(config, ["enableRowGrouping", "enableColumnGrouping"]),
11593
- columnState: config.columnState.map((col) => {
11601
+ columnState: filteredColumnState.map((col) => {
11594
11602
  const res = import_lodash.default.omit(col, ["aggFunc"]);
11595
11603
  if (col.flex) {
11596
11604
  return import_lodash.default.omit(res, ["width", "flex"]);
@@ -11769,7 +11777,8 @@ var PanelContent = (props) => {
11769
11777
  {
11770
11778
  item: temporaryView,
11771
11779
  selected: isTemporarySelected,
11772
- onClearTemporary: props.onClearTemporary
11780
+ onClearTemporary: props.onClearTemporary,
11781
+ enableSharingViews: false
11773
11782
  }
11774
11783
  )
11775
11784
  ), presetViews.map((presetView) => {
@@ -11786,7 +11795,8 @@ var PanelContent = (props) => {
11786
11795
  SavedViewCollectionMenuItem,
11787
11796
  {
11788
11797
  item: presetView,
11789
- selected: isSelected
11798
+ selected: isSelected,
11799
+ enableSharingViews: false
11790
11800
  }
11791
11801
  )
11792
11802
  );
@@ -11834,7 +11844,8 @@ var PanelContent = (props) => {
11834
11844
  isUpdateProcessing: isUpdateLoading,
11835
11845
  onEdit: () => props.openModal("update" /* UPDATE */),
11836
11846
  onDelete: props.onDelete,
11837
- permissions
11847
+ permissions,
11848
+ enableSharingViews: false
11838
11849
  }
11839
11850
  )
11840
11851
  );
@@ -15159,26 +15170,37 @@ var DEFAULT_COLUMN_STATE = {
15159
15170
  rowGroupIndex: null,
15160
15171
  flex: null
15161
15172
  };
15173
+ var isColGroupDef = (colDef) => {
15174
+ return "children" in colDef && Array.isArray(colDef.children);
15175
+ };
15162
15176
  var getColumnStateFromDefs = (columnDefs) => {
15163
- return columnDefs.map((colDef) => {
15164
- const field = colDef.field ?? colDef.colId;
15165
- if (!field)
15166
- return null;
15167
- return {
15168
- colId: field,
15169
- hide: colDef.hide ?? false,
15170
- pinned: colDef.pinned ?? null,
15171
- width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
15172
- sort: null,
15173
- sortIndex: null,
15174
- pivot: false,
15175
- pivotIndex: null,
15176
- aggFunc: null,
15177
- rowGroup: false,
15178
- rowGroupIndex: null,
15179
- flex: colDef.flex ?? null
15180
- };
15181
- }).filter((col) => col !== null);
15177
+ return columnDefs.flatMap((colDef) => {
15178
+ if (isColGroupDef(colDef)) {
15179
+ return getColumnStateFromDefs(colDef.children);
15180
+ }
15181
+ return getColumnStateFromSingleDef(colDef);
15182
+ }).filter(
15183
+ (col) => col !== null
15184
+ );
15185
+ };
15186
+ var getColumnStateFromSingleDef = (colDef) => {
15187
+ const field = colDef.field ?? colDef.colId;
15188
+ if (!field)
15189
+ return null;
15190
+ return {
15191
+ colId: field,
15192
+ hide: colDef.hide ?? false,
15193
+ pinned: colDef.pinned ?? null,
15194
+ width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
15195
+ sort: null,
15196
+ sortIndex: null,
15197
+ pivot: false,
15198
+ pivotIndex: null,
15199
+ aggFunc: null,
15200
+ rowGroup: false,
15201
+ rowGroupIndex: null,
15202
+ flex: colDef.flex ?? null
15203
+ };
15182
15204
  };
15183
15205
  var extractDefaultView = (gridApi, receivedConfig) => {
15184
15206
  const columnDefs = gridApi.getColumnDefs() ?? [];
@@ -15263,15 +15285,17 @@ var SmartGridSavedViews = (props) => {
15263
15285
  if (!gridApi)
15264
15286
  return item;
15265
15287
  const isPresetView = item.view_level === "default";
15288
+ const newConfig = item.table_config;
15289
+ const transformedConfig = props.transformSettings?.(newConfig) ?? newConfig;
15266
15290
  if (isPresetView) {
15267
15291
  updateTableConfig(item, gridApi, "smart-grid");
15268
- setTableConfig(item.table_config);
15292
+ setTableConfig(transformedConfig);
15269
15293
  return item;
15270
15294
  }
15271
15295
  const updatedView = {
15272
15296
  ...item,
15273
15297
  table_config: customAndConfigSync(
15274
- item.table_config,
15298
+ transformedConfig,
15275
15299
  tableConfig
15276
15300
  )
15277
15301
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/saved-views",
3
- "version": "1.0.1-alpha.0",
3
+ "version": "1.0.1-alpha.2",
4
4
  "description": "Saved Views Component for Data Table",
5
5
  "author": "Procore Technologies, Inc",
6
6
  "repository": {