@procore/saved-views 5.0.0-alpha.4 → 5.0.0-alpha.6

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.
@@ -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
  }
@@ -11421,12 +11421,13 @@ var normalizeForComparison = (config) => {
11421
11421
  if (!(config == null ? void 0 : config.columnState))
11422
11422
  return config;
11423
11423
  return {
11424
- ...config,
11424
+ ...import_lodash.default.omit(config, ["enableRowGrouping", "enableColumnGrouping"]),
11425
11425
  columnState: config.columnState.map((col) => {
11426
+ const res = import_lodash.default.omit(col, ["aggFunc"]);
11426
11427
  if (col.flex) {
11427
- return import_lodash.default.omit(col, ["width", "flex"]);
11428
+ return import_lodash.default.omit(res, ["width", "flex"]);
11428
11429
  }
11429
- return col;
11430
+ return res;
11430
11431
  })
11431
11432
  };
11432
11433
  };
@@ -11439,10 +11440,9 @@ var isEqual = (viewTableConfig, tableConfig, defaultViewConfig, provider) => {
11439
11440
  );
11440
11441
  const normalizedViewConfig = normalizeForComparison(syncedViewTableConfig);
11441
11442
  const normalizedCurrentConfig = normalizeForComparison(tableConfig);
11442
- return import_lodash.default.isEqual(
11443
- cleanObject(normalizedViewConfig, provider),
11444
- cleanObject(normalizedCurrentConfig, provider)
11445
- );
11443
+ const cleanedViewConfig = cleanObject(normalizedViewConfig, provider);
11444
+ const cleanedCurrentConfig = cleanObject(normalizedCurrentConfig, provider);
11445
+ return import_lodash.default.isEqual(cleanedViewConfig, cleanedCurrentConfig);
11446
11446
  };
11447
11447
  var hasPermissionForViewLevel = (viewLevel, permissions) => {
11448
11448
  switch (viewLevel) {
@@ -11679,10 +11679,14 @@ var useSmartGridConfig = (gridApi) => {
11679
11679
  const [config, setConfig] = (0, import_react10.useState)(
11680
11680
  () => getSmartGridConfig(gridApi)
11681
11681
  );
11682
+ const eventListenersDisabledRef = (0, import_react10.useRef)(false);
11682
11683
  (0, import_react10.useEffect)(() => {
11683
11684
  if (!gridApi)
11684
11685
  return;
11685
- const updateConfig = () => {
11686
+ const updateConfig = (par) => {
11687
+ if (eventListenersDisabledRef.current) {
11688
+ return;
11689
+ }
11686
11690
  setConfig(getSmartGridConfig(gridApi));
11687
11691
  };
11688
11692
  GRID_STATE_EVENTS.forEach((event) => {
@@ -11694,7 +11698,13 @@ var useSmartGridConfig = (gridApi) => {
11694
11698
  });
11695
11699
  };
11696
11700
  }, [gridApi]);
11697
- return { config, setConfig };
11701
+ const disableEventListeners = () => {
11702
+ eventListenersDisabledRef.current = true;
11703
+ };
11704
+ const enableEventListeners = () => {
11705
+ eventListenersDisabledRef.current = false;
11706
+ };
11707
+ return { config, setConfig, disableEventListeners, enableEventListeners };
11698
11708
  };
11699
11709
 
11700
11710
  // src/SavedViews/components/SavedViews/SavedViews.tsx
@@ -14059,7 +14069,7 @@ function extractMessage(error, I18n) {
14059
14069
  }
14060
14070
 
14061
14071
  // src/SavedViews/components/SavedViewsModals/SavedViewsCreateUpdateModalBase.tsx
14062
- var { useEffect: useEffect3, useRef: useRef2 } = React17;
14072
+ var { useEffect: useEffect3, useRef: useRef3 } = React17;
14063
14073
  var ScrollContainer = styled_components_esm_default("div")`
14064
14074
  overflow: auto;
14065
14075
  `;
@@ -14082,7 +14092,7 @@ var SavedViewsCreateUpdateModalBase = ({
14082
14092
  }) => {
14083
14093
  const I18n = (0, import_core_react9.useI18nContext)();
14084
14094
  const NAME_MAX_LENGTH = 150;
14085
- const originalBodyWidth = useRef2("");
14095
+ const originalBodyWidth = useRef3("");
14086
14096
  useEffect3(() => {
14087
14097
  if (open) {
14088
14098
  originalBodyWidth.current = document.body.style.width || "";
@@ -14593,7 +14603,12 @@ var SavedViews = (props) => {
14593
14603
  var import_toast_alert2 = require("@procore/toast-alert");
14594
14604
  var SmartGridSavedViews = (props) => {
14595
14605
  const { gridApi, projectId, companyId } = props;
14596
- const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
14606
+ const {
14607
+ config: tableConfig,
14608
+ setConfig: setTableConfig,
14609
+ disableEventListeners,
14610
+ enableEventListeners
14611
+ } = useSmartGridConfig(gridApi);
14597
14612
  const defaultView = useDefaultView({
14598
14613
  defaultViewName: props.defaultViewName,
14599
14614
  domain: props.domain
@@ -14619,8 +14634,15 @@ var SmartGridSavedViews = (props) => {
14619
14634
  tableConfig2
14620
14635
  )
14621
14636
  };
14622
- updateTableConfig(updatedView, gridApi, "smart-grid");
14623
- setTableConfig(updatedView.table_config);
14637
+ disableEventListeners();
14638
+ try {
14639
+ updateTableConfig(updatedView, gridApi, "smart-grid");
14640
+ setTableConfig(updatedView.table_config);
14641
+ } finally {
14642
+ setTimeout(() => {
14643
+ enableEventListeners();
14644
+ }, 0);
14645
+ }
14624
14646
  return updatedView;
14625
14647
  };
14626
14648
  return /* @__PURE__ */ import_react14.default.createElement(import_toast_alert2.ToastAlertProvider, null, /* @__PURE__ */ import_react14.default.createElement(
@@ -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
  }
@@ -11425,12 +11425,13 @@ var normalizeForComparison = (config) => {
11425
11425
  if (!(config == null ? void 0 : config.columnState))
11426
11426
  return config;
11427
11427
  return {
11428
- ...config,
11428
+ ...import_lodash.default.omit(config, ["enableRowGrouping", "enableColumnGrouping"]),
11429
11429
  columnState: config.columnState.map((col) => {
11430
+ const res = import_lodash.default.omit(col, ["aggFunc"]);
11430
11431
  if (col.flex) {
11431
- return import_lodash.default.omit(col, ["width", "flex"]);
11432
+ return import_lodash.default.omit(res, ["width", "flex"]);
11432
11433
  }
11433
- return col;
11434
+ return res;
11434
11435
  })
11435
11436
  };
11436
11437
  };
@@ -11443,10 +11444,9 @@ var isEqual = (viewTableConfig, tableConfig, defaultViewConfig, provider) => {
11443
11444
  );
11444
11445
  const normalizedViewConfig = normalizeForComparison(syncedViewTableConfig);
11445
11446
  const normalizedCurrentConfig = normalizeForComparison(tableConfig);
11446
- return import_lodash.default.isEqual(
11447
- cleanObject(normalizedViewConfig, provider),
11448
- cleanObject(normalizedCurrentConfig, provider)
11449
- );
11447
+ const cleanedViewConfig = cleanObject(normalizedViewConfig, provider);
11448
+ const cleanedCurrentConfig = cleanObject(normalizedCurrentConfig, provider);
11449
+ return import_lodash.default.isEqual(cleanedViewConfig, cleanedCurrentConfig);
11450
11450
  };
11451
11451
  var hasPermissionForViewLevel = (viewLevel, permissions) => {
11452
11452
  switch (viewLevel) {
@@ -11670,7 +11670,7 @@ var useDefaultView = (props) => {
11670
11670
  };
11671
11671
 
11672
11672
  // src/SavedViews/components/SavedViews/SmartGrid/useSmartGridConfig.ts
11673
- import { useState as useState3, useEffect as useEffect2 } from "react";
11673
+ import { useState as useState3, useEffect as useEffect2, useRef as useRef2 } from "react";
11674
11674
  var GRID_STATE_EVENTS = [
11675
11675
  "sortChanged",
11676
11676
  "filterOpened",
@@ -11689,10 +11689,14 @@ var useSmartGridConfig = (gridApi) => {
11689
11689
  const [config, setConfig] = useState3(
11690
11690
  () => getSmartGridConfig(gridApi)
11691
11691
  );
11692
+ const eventListenersDisabledRef = useRef2(false);
11692
11693
  useEffect2(() => {
11693
11694
  if (!gridApi)
11694
11695
  return;
11695
- const updateConfig = () => {
11696
+ const updateConfig = (par) => {
11697
+ if (eventListenersDisabledRef.current) {
11698
+ return;
11699
+ }
11696
11700
  setConfig(getSmartGridConfig(gridApi));
11697
11701
  };
11698
11702
  GRID_STATE_EVENTS.forEach((event) => {
@@ -11704,7 +11708,13 @@ var useSmartGridConfig = (gridApi) => {
11704
11708
  });
11705
11709
  };
11706
11710
  }, [gridApi]);
11707
- return { config, setConfig };
11711
+ const disableEventListeners = () => {
11712
+ eventListenersDisabledRef.current = true;
11713
+ };
11714
+ const enableEventListeners = () => {
11715
+ eventListenersDisabledRef.current = false;
11716
+ };
11717
+ return { config, setConfig, disableEventListeners, enableEventListeners };
11708
11718
  };
11709
11719
 
11710
11720
  // src/SavedViews/components/SavedViews/SavedViews.tsx
@@ -14094,7 +14104,7 @@ function extractMessage(error, I18n) {
14094
14104
  }
14095
14105
 
14096
14106
  // src/SavedViews/components/SavedViewsModals/SavedViewsCreateUpdateModalBase.tsx
14097
- var { useEffect: useEffect3, useRef: useRef2 } = React17;
14107
+ var { useEffect: useEffect3, useRef: useRef3 } = React17;
14098
14108
  var ScrollContainer = styled_components_esm_default("div")`
14099
14109
  overflow: auto;
14100
14110
  `;
@@ -14117,7 +14127,7 @@ var SavedViewsCreateUpdateModalBase = ({
14117
14127
  }) => {
14118
14128
  const I18n = useI18nContext7();
14119
14129
  const NAME_MAX_LENGTH = 150;
14120
- const originalBodyWidth = useRef2("");
14130
+ const originalBodyWidth = useRef3("");
14121
14131
  useEffect3(() => {
14122
14132
  if (open) {
14123
14133
  originalBodyWidth.current = document.body.style.width || "";
@@ -14628,7 +14638,12 @@ var SavedViews = (props) => {
14628
14638
  import { ToastAlertProvider } from "@procore/toast-alert";
14629
14639
  var SmartGridSavedViews = (props) => {
14630
14640
  const { gridApi, projectId, companyId } = props;
14631
- const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
14641
+ const {
14642
+ config: tableConfig,
14643
+ setConfig: setTableConfig,
14644
+ disableEventListeners,
14645
+ enableEventListeners
14646
+ } = useSmartGridConfig(gridApi);
14632
14647
  const defaultView = useDefaultView({
14633
14648
  defaultViewName: props.defaultViewName,
14634
14649
  domain: props.domain
@@ -14654,8 +14669,15 @@ var SmartGridSavedViews = (props) => {
14654
14669
  tableConfig2
14655
14670
  )
14656
14671
  };
14657
- updateTableConfig(updatedView, gridApi, "smart-grid");
14658
- setTableConfig(updatedView.table_config);
14672
+ disableEventListeners();
14673
+ try {
14674
+ updateTableConfig(updatedView, gridApi, "smart-grid");
14675
+ setTableConfig(updatedView.table_config);
14676
+ } finally {
14677
+ setTimeout(() => {
14678
+ enableEventListeners();
14679
+ }, 0);
14680
+ }
14659
14681
  return updatedView;
14660
14682
  };
14661
14683
  return /* @__PURE__ */ React20.createElement(ToastAlertProvider, null, /* @__PURE__ */ React20.createElement(
@@ -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
  }
@@ -11419,12 +11419,13 @@ var normalizeForComparison = (config) => {
11419
11419
  if (!config?.columnState)
11420
11420
  return config;
11421
11421
  return {
11422
- ...config,
11422
+ ...import_lodash.default.omit(config, ["enableRowGrouping", "enableColumnGrouping"]),
11423
11423
  columnState: config.columnState.map((col) => {
11424
+ const res = import_lodash.default.omit(col, ["aggFunc"]);
11424
11425
  if (col.flex) {
11425
- return import_lodash.default.omit(col, ["width", "flex"]);
11426
+ return import_lodash.default.omit(res, ["width", "flex"]);
11426
11427
  }
11427
- return col;
11428
+ return res;
11428
11429
  })
11429
11430
  };
11430
11431
  };
@@ -11437,10 +11438,9 @@ var isEqual = (viewTableConfig, tableConfig, defaultViewConfig, provider) => {
11437
11438
  );
11438
11439
  const normalizedViewConfig = normalizeForComparison(syncedViewTableConfig);
11439
11440
  const normalizedCurrentConfig = normalizeForComparison(tableConfig);
11440
- return import_lodash.default.isEqual(
11441
- cleanObject(normalizedViewConfig, provider),
11442
- cleanObject(normalizedCurrentConfig, provider)
11443
- );
11441
+ const cleanedViewConfig = cleanObject(normalizedViewConfig, provider);
11442
+ const cleanedCurrentConfig = cleanObject(normalizedCurrentConfig, provider);
11443
+ return import_lodash.default.isEqual(cleanedViewConfig, cleanedCurrentConfig);
11444
11444
  };
11445
11445
  var hasPermissionForViewLevel = (viewLevel, permissions) => {
11446
11446
  switch (viewLevel) {
@@ -11675,10 +11675,14 @@ var useSmartGridConfig = (gridApi) => {
11675
11675
  const [config, setConfig] = (0, import_react10.useState)(
11676
11676
  () => getSmartGridConfig(gridApi)
11677
11677
  );
11678
+ const eventListenersDisabledRef = (0, import_react10.useRef)(false);
11678
11679
  (0, import_react10.useEffect)(() => {
11679
11680
  if (!gridApi)
11680
11681
  return;
11681
- const updateConfig = () => {
11682
+ const updateConfig = (par) => {
11683
+ if (eventListenersDisabledRef.current) {
11684
+ return;
11685
+ }
11682
11686
  setConfig(getSmartGridConfig(gridApi));
11683
11687
  };
11684
11688
  GRID_STATE_EVENTS.forEach((event) => {
@@ -11690,7 +11694,13 @@ var useSmartGridConfig = (gridApi) => {
11690
11694
  });
11691
11695
  };
11692
11696
  }, [gridApi]);
11693
- return { config, setConfig };
11697
+ const disableEventListeners = () => {
11698
+ eventListenersDisabledRef.current = true;
11699
+ };
11700
+ const enableEventListeners = () => {
11701
+ eventListenersDisabledRef.current = false;
11702
+ };
11703
+ return { config, setConfig, disableEventListeners, enableEventListeners };
11694
11704
  };
11695
11705
 
11696
11706
  // src/SavedViews/components/SavedViews/SavedViews.tsx
@@ -14055,7 +14065,7 @@ function extractMessage(error, I18n) {
14055
14065
  }
14056
14066
 
14057
14067
  // src/SavedViews/components/SavedViewsModals/SavedViewsCreateUpdateModalBase.tsx
14058
- var { useEffect: useEffect3, useRef: useRef2 } = React17;
14068
+ var { useEffect: useEffect3, useRef: useRef3 } = React17;
14059
14069
  var ScrollContainer = styled_components_esm_default("div")`
14060
14070
  overflow: auto;
14061
14071
  `;
@@ -14078,7 +14088,7 @@ var SavedViewsCreateUpdateModalBase = ({
14078
14088
  }) => {
14079
14089
  const I18n = (0, import_core_react9.useI18nContext)();
14080
14090
  const NAME_MAX_LENGTH = 150;
14081
- const originalBodyWidth = useRef2("");
14091
+ const originalBodyWidth = useRef3("");
14082
14092
  useEffect3(() => {
14083
14093
  if (open) {
14084
14094
  originalBodyWidth.current = document.body.style.width || "";
@@ -14589,7 +14599,12 @@ var SavedViews = (props) => {
14589
14599
  var import_toast_alert2 = require("@procore/toast-alert");
14590
14600
  var SmartGridSavedViews = (props) => {
14591
14601
  const { gridApi, projectId, companyId } = props;
14592
- const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
14602
+ const {
14603
+ config: tableConfig,
14604
+ setConfig: setTableConfig,
14605
+ disableEventListeners,
14606
+ enableEventListeners
14607
+ } = useSmartGridConfig(gridApi);
14593
14608
  const defaultView = useDefaultView({
14594
14609
  defaultViewName: props.defaultViewName,
14595
14610
  domain: props.domain
@@ -14614,8 +14629,15 @@ var SmartGridSavedViews = (props) => {
14614
14629
  tableConfig2
14615
14630
  )
14616
14631
  };
14617
- updateTableConfig(updatedView, gridApi, "smart-grid");
14618
- setTableConfig(updatedView.table_config);
14632
+ disableEventListeners();
14633
+ try {
14634
+ updateTableConfig(updatedView, gridApi, "smart-grid");
14635
+ setTableConfig(updatedView.table_config);
14636
+ } finally {
14637
+ setTimeout(() => {
14638
+ enableEventListeners();
14639
+ }, 0);
14640
+ }
14619
14641
  return updatedView;
14620
14642
  };
14621
14643
  return /* @__PURE__ */ import_react14.default.createElement(import_toast_alert2.ToastAlertProvider, null, /* @__PURE__ */ import_react14.default.createElement(
@@ -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
  }
@@ -11423,12 +11423,13 @@ var normalizeForComparison = (config) => {
11423
11423
  if (!config?.columnState)
11424
11424
  return config;
11425
11425
  return {
11426
- ...config,
11426
+ ...import_lodash.default.omit(config, ["enableRowGrouping", "enableColumnGrouping"]),
11427
11427
  columnState: config.columnState.map((col) => {
11428
+ const res = import_lodash.default.omit(col, ["aggFunc"]);
11428
11429
  if (col.flex) {
11429
- return import_lodash.default.omit(col, ["width", "flex"]);
11430
+ return import_lodash.default.omit(res, ["width", "flex"]);
11430
11431
  }
11431
- return col;
11432
+ return res;
11432
11433
  })
11433
11434
  };
11434
11435
  };
@@ -11441,10 +11442,9 @@ var isEqual = (viewTableConfig, tableConfig, defaultViewConfig, provider) => {
11441
11442
  );
11442
11443
  const normalizedViewConfig = normalizeForComparison(syncedViewTableConfig);
11443
11444
  const normalizedCurrentConfig = normalizeForComparison(tableConfig);
11444
- return import_lodash.default.isEqual(
11445
- cleanObject(normalizedViewConfig, provider),
11446
- cleanObject(normalizedCurrentConfig, provider)
11447
- );
11445
+ const cleanedViewConfig = cleanObject(normalizedViewConfig, provider);
11446
+ const cleanedCurrentConfig = cleanObject(normalizedCurrentConfig, provider);
11447
+ return import_lodash.default.isEqual(cleanedViewConfig, cleanedCurrentConfig);
11448
11448
  };
11449
11449
  var hasPermissionForViewLevel = (viewLevel, permissions) => {
11450
11450
  switch (viewLevel) {
@@ -11666,7 +11666,7 @@ var useDefaultView = (props) => {
11666
11666
  };
11667
11667
 
11668
11668
  // src/SavedViews/components/SavedViews/SmartGrid/useSmartGridConfig.ts
11669
- import { useState as useState3, useEffect as useEffect2 } from "react";
11669
+ import { useState as useState3, useEffect as useEffect2, useRef as useRef2 } from "react";
11670
11670
  var GRID_STATE_EVENTS = [
11671
11671
  "sortChanged",
11672
11672
  "filterOpened",
@@ -11685,10 +11685,14 @@ var useSmartGridConfig = (gridApi) => {
11685
11685
  const [config, setConfig] = useState3(
11686
11686
  () => getSmartGridConfig(gridApi)
11687
11687
  );
11688
+ const eventListenersDisabledRef = useRef2(false);
11688
11689
  useEffect2(() => {
11689
11690
  if (!gridApi)
11690
11691
  return;
11691
- const updateConfig = () => {
11692
+ const updateConfig = (par) => {
11693
+ if (eventListenersDisabledRef.current) {
11694
+ return;
11695
+ }
11692
11696
  setConfig(getSmartGridConfig(gridApi));
11693
11697
  };
11694
11698
  GRID_STATE_EVENTS.forEach((event) => {
@@ -11700,7 +11704,13 @@ var useSmartGridConfig = (gridApi) => {
11700
11704
  });
11701
11705
  };
11702
11706
  }, [gridApi]);
11703
- return { config, setConfig };
11707
+ const disableEventListeners = () => {
11708
+ eventListenersDisabledRef.current = true;
11709
+ };
11710
+ const enableEventListeners = () => {
11711
+ eventListenersDisabledRef.current = false;
11712
+ };
11713
+ return { config, setConfig, disableEventListeners, enableEventListeners };
11704
11714
  };
11705
11715
 
11706
11716
  // src/SavedViews/components/SavedViews/SavedViews.tsx
@@ -14090,7 +14100,7 @@ function extractMessage(error, I18n) {
14090
14100
  }
14091
14101
 
14092
14102
  // src/SavedViews/components/SavedViewsModals/SavedViewsCreateUpdateModalBase.tsx
14093
- var { useEffect: useEffect3, useRef: useRef2 } = React17;
14103
+ var { useEffect: useEffect3, useRef: useRef3 } = React17;
14094
14104
  var ScrollContainer = styled_components_esm_default("div")`
14095
14105
  overflow: auto;
14096
14106
  `;
@@ -14113,7 +14123,7 @@ var SavedViewsCreateUpdateModalBase = ({
14113
14123
  }) => {
14114
14124
  const I18n = useI18nContext7();
14115
14125
  const NAME_MAX_LENGTH = 150;
14116
- const originalBodyWidth = useRef2("");
14126
+ const originalBodyWidth = useRef3("");
14117
14127
  useEffect3(() => {
14118
14128
  if (open) {
14119
14129
  originalBodyWidth.current = document.body.style.width || "";
@@ -14624,7 +14634,12 @@ var SavedViews = (props) => {
14624
14634
  import { ToastAlertProvider } from "@procore/toast-alert";
14625
14635
  var SmartGridSavedViews = (props) => {
14626
14636
  const { gridApi, projectId, companyId } = props;
14627
- const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
14637
+ const {
14638
+ config: tableConfig,
14639
+ setConfig: setTableConfig,
14640
+ disableEventListeners,
14641
+ enableEventListeners
14642
+ } = useSmartGridConfig(gridApi);
14628
14643
  const defaultView = useDefaultView({
14629
14644
  defaultViewName: props.defaultViewName,
14630
14645
  domain: props.domain
@@ -14649,8 +14664,15 @@ var SmartGridSavedViews = (props) => {
14649
14664
  tableConfig2
14650
14665
  )
14651
14666
  };
14652
- updateTableConfig(updatedView, gridApi, "smart-grid");
14653
- setTableConfig(updatedView.table_config);
14667
+ disableEventListeners();
14668
+ try {
14669
+ updateTableConfig(updatedView, gridApi, "smart-grid");
14670
+ setTableConfig(updatedView.table_config);
14671
+ } finally {
14672
+ setTimeout(() => {
14673
+ enableEventListeners();
14674
+ }, 0);
14675
+ }
14654
14676
  return updatedView;
14655
14677
  };
14656
14678
  return /* @__PURE__ */ React20.createElement(ToastAlertProvider, null, /* @__PURE__ */ React20.createElement(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/saved-views",
3
- "version": "5.0.0-alpha.4",
3
+ "version": "5.0.0-alpha.6",
4
4
  "description": "Saved Views Component for Data Table",
5
5
  "author": "Procore Technologies, Inc",
6
6
  "repository": {