@procore/saved-views 6.0.0 → 6.0.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.
@@ -8758,11 +8758,38 @@ var bt = "__sc-".concat(a, "__");
8758
8758
  "production" !== process.env.NODE_ENV && "test" !== process.env.NODE_ENV && "undefined" != typeof window && (window[bt] || (window[bt] = 0), 1 === window[bt] && console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-several-instances-of-module-on-the-page for more info."), window[bt] += 1);
8759
8759
 
8760
8760
  // src/components/EnvironmentI18nProvider.tsx
8761
- import React12 from "react";
8761
+ import React12, { useEffect, useMemo } from "react";
8762
8762
  import { I18nContext, useI18n, useI18nContext } from "@procore/core-react";
8763
+
8764
+ // src/utils/translations/translationCache.ts
8765
+ var CACHE_KEY_PREFIX = "sg-saved-views-translations";
8766
+ function cacheKey(locale) {
8767
+ return `${CACHE_KEY_PREFIX}-${locale}`;
8768
+ }
8769
+ function readCache(locale) {
8770
+ try {
8771
+ const raw = localStorage.getItem(cacheKey(locale));
8772
+ if (!raw) return null;
8773
+ return JSON.parse(raw);
8774
+ } catch {
8775
+ return null;
8776
+ }
8777
+ }
8778
+ function writeCache(locale, translations) {
8779
+ try {
8780
+ localStorage.setItem(cacheKey(locale), JSON.stringify(translations));
8781
+ } catch {
8782
+ }
8783
+ }
8784
+
8785
+ // src/components/EnvironmentI18nProvider.tsx
8763
8786
  import { useRequestTranslations } from "@procore/cdn-translations";
8764
8787
  var useCDNTranslations = () => {
8765
8788
  const i18n = useI18nContext();
8789
+ const cachedTranslations = useMemo(
8790
+ () => readCache(i18n.locale),
8791
+ [i18n.locale]
8792
+ );
8766
8793
  const cdnTranslations = useRequestTranslations(
8767
8794
  {
8768
8795
  type: "file",
@@ -8777,8 +8804,17 @@ var useCDNTranslations = () => {
8777
8804
  enableCDN: i18n.enableCDN
8778
8805
  }
8779
8806
  );
8807
+ useEffect(() => {
8808
+ if (cdnTranslations.status === "resolved" && cdnTranslations.translations) {
8809
+ writeCache(
8810
+ i18n.locale,
8811
+ cdnTranslations.translations
8812
+ );
8813
+ }
8814
+ }, [cdnTranslations.status, cdnTranslations.translations, i18n.locale]);
8815
+ const translationsToUse = cdnTranslations.status === "resolved" ? cdnTranslations.translations : cachedTranslations ?? getTranslations(i18n.locale);
8780
8816
  return useI18n({
8781
- translations: cdnTranslations.translations,
8817
+ translations: translationsToUse,
8782
8818
  locale: i18n.locale
8783
8819
  });
8784
8820
  };
@@ -9175,7 +9211,6 @@ function setSmartGridConfig(api, config) {
9175
9211
  });
9176
9212
  api.setColumnGroupState(config.columnGroupState);
9177
9213
  api.setRowGroupColumns(config.rowGroupState);
9178
- api.setFilterModel(config.filterState);
9179
9214
  if (config.rowHeight) {
9180
9215
  api.setGridOption("rowHeight", config.rowHeight);
9181
9216
  }
@@ -9219,6 +9254,7 @@ var getColumnIdentifier = (col) => {
9219
9254
  return "";
9220
9255
  };
9221
9256
  var updateTableConfig = (view, tableApi, provider) => {
9257
+ var _a, _b, _c;
9222
9258
  if (provider === "smart-grid") {
9223
9259
  setSmartGridConfig(
9224
9260
  tableApi,
@@ -9228,11 +9264,21 @@ var updateTableConfig = (view, tableApi, provider) => {
9228
9264
  const dataTableApi = tableApi;
9229
9265
  const tableConfig = view.table_config;
9230
9266
  if (tableConfig) {
9231
- const rowHeight = (tableConfig == null ? void 0 : tableConfig.rowHeight) ?? (dataTableApi == null ? void 0 : dataTableApi.getTableConfiguration().rowHeight);
9267
+ const currentTableConfig = (_a = dataTableApi == null ? void 0 : dataTableApi.getTableConfiguration) == null ? void 0 : _a.call(dataTableApi);
9268
+ const rowHeight = (tableConfig == null ? void 0 : tableConfig.rowHeight) ?? (currentTableConfig == null ? void 0 : currentTableConfig.rowHeight);
9269
+ const hasServerFilters = Boolean((_b = currentTableConfig == null ? void 0 : currentTableConfig.serverFilters) == null ? void 0 : _b.length) || Boolean((_c = tableConfig == null ? void 0 : tableConfig.serverFilters) == null ? void 0 : _c.length);
9270
+ const usesServerSideFiltering = hasServerFilters;
9232
9271
  if (rowHeight !== void 0) {
9233
9272
  dataTableApi == null ? void 0 : dataTableApi.setRowHeight(rowHeight);
9234
9273
  }
9235
- dataTableApi == null ? void 0 : dataTableApi.setTableConfiguration(tableConfig);
9274
+ if (usesServerSideFiltering) {
9275
+ dataTableApi == null ? void 0 : dataTableApi.setTableConfiguration({
9276
+ ...tableConfig,
9277
+ filters: void 0
9278
+ });
9279
+ } else {
9280
+ dataTableApi == null ? void 0 : dataTableApi.setTableConfiguration(tableConfig);
9281
+ }
9236
9282
  }
9237
9283
  }
9238
9284
  };
@@ -9413,10 +9459,10 @@ var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
9413
9459
  var ViewLevelHeader_default = ViewLevelHeader;
9414
9460
 
9415
9461
  // src/utils/hooks/useScrollToRef.ts
9416
- import { useEffect, useRef } from "react";
9462
+ import { useEffect as useEffect2, useRef } from "react";
9417
9463
  var useScrollToRef = (dependency) => {
9418
9464
  const ref = useRef(null);
9419
- useEffect(() => {
9465
+ useEffect2(() => {
9420
9466
  if (ref.current) {
9421
9467
  ref.current.scrollIntoView({ behavior: "smooth", block: "nearest" });
9422
9468
  }
@@ -9615,7 +9661,7 @@ import {
9615
9661
  Tooltip,
9616
9662
  useI18nContext as useI18nContext12
9617
9663
  } from "@procore/core-react";
9618
- import React23, { useState as useState4, useEffect as useEffect4, useCallback as useCallback3 } from "react";
9664
+ import React23, { useState as useState4, useEffect as useEffect6, useCallback as useCallback4 } from "react";
9619
9665
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
9620
9666
  import { useToastAlertContext as useToastAlertContext3, ToastAlertProvider } from "@procore/toast-alert";
9621
9667
 
@@ -10087,7 +10133,7 @@ var SharedViewFormModal = ({
10087
10133
  };
10088
10134
 
10089
10135
  // src/utils/hooks/useViewSelection.ts
10090
- import { useState as useState3, useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2, useMemo } from "react";
10136
+ import { useState as useState3, useCallback as useCallback3, useEffect as useEffect4, useRef as useRef3, useMemo as useMemo2 } from "react";
10091
10137
  import { useSearchParams } from "react-router-dom";
10092
10138
  import { useI18nContext as useI18nContext11 } from "@procore/core-react";
10093
10139
 
@@ -10113,6 +10159,16 @@ var ViewStorage = {
10113
10159
  }
10114
10160
  };
10115
10161
 
10162
+ // src/utils/hooks/useLatest.ts
10163
+ import { useCallback as useCallback2, useLayoutEffect, useRef as useRef2 } from "react";
10164
+ var useLatest = (callback) => {
10165
+ const ref = useRef2(callback);
10166
+ useLayoutEffect(() => {
10167
+ ref.current = callback;
10168
+ });
10169
+ return useCallback2((...args) => ref.current(...args), []);
10170
+ };
10171
+
10116
10172
  // src/utils/hooks/useViewSelection.ts
10117
10173
  var isSmartGridConfig = (config) => {
10118
10174
  return config != null && "rowGroupState" in config;
@@ -10164,7 +10220,7 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
10164
10220
  const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
10165
10221
  const temporaryStorageKey = `${storageKey}-temporary`;
10166
10222
  const [searchParams, setSearchParams] = useSearchParams();
10167
- const previousSavedViewParamRef = useRef2(null);
10223
+ const previousSavedViewParamRef = useRef3(null);
10168
10224
  const [selectedSavedView, setSelectedSavedView] = useState3(() => {
10169
10225
  const stored = ViewStorage.load(storageKey, config.defaultView);
10170
10226
  return stored ?? config.defaultView;
@@ -10173,22 +10229,22 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
10173
10229
  const loaded = ViewStorage.load(temporaryStorageKey, config.defaultView);
10174
10230
  return loaded && (loaded.id === "temporary" || loaded.view_level === "temporary") ? loaded : null;
10175
10231
  });
10176
- const persistViewToStorageAndUrl = useCallback2(
10232
+ const persistViewToStorageAndUrl = useCallback3(
10177
10233
  (view) => {
10178
10234
  ViewStorage.save(storageKey, view);
10179
10235
  setViewInUrl(view, setSearchParams);
10180
10236
  },
10181
10237
  [storageKey, setSearchParams]
10182
10238
  );
10183
- const baseViews = useMemo(
10239
+ const baseViews = useMemo2(
10184
10240
  () => [...savedViews ?? [], ...presetViews ?? []],
10185
10241
  [savedViews, presetViews]
10186
10242
  );
10187
- const allViews = useMemo(
10243
+ const allViews = useMemo2(
10188
10244
  () => temporaryView ? [...baseViews, temporaryView] : baseViews,
10189
10245
  [baseViews, temporaryView]
10190
10246
  );
10191
- const selectView = useCallback2(
10247
+ const selectView = useCallback3(
10192
10248
  (view) => {
10193
10249
  const viewToSelect = config.onSelect({ item: view });
10194
10250
  setSelectedSavedView(viewToSelect);
@@ -10197,7 +10253,7 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
10197
10253
  },
10198
10254
  [config, persistViewToStorageAndUrl]
10199
10255
  );
10200
- const createTemporaryView = useCallback2(
10256
+ const createTemporaryView = useCallback3(
10201
10257
  (fetchedView) => {
10202
10258
  const tempView = {
10203
10259
  ...fetchedView,
@@ -10212,30 +10268,27 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
10212
10268
  },
10213
10269
  [temporaryStorageKey, selectView]
10214
10270
  );
10215
- const clearTemporaryView = useCallback2(() => {
10271
+ const clearTemporaryView = useCallback3(() => {
10216
10272
  ViewStorage.remove(temporaryStorageKey);
10217
10273
  setTemporaryView(null);
10218
10274
  selectView(config.defaultView);
10219
10275
  }, [temporaryStorageKey, config.defaultView, selectView]);
10220
- const isViewAlreadySelected = useCallback2(
10276
+ const isViewAlreadySelected = useCallback3(
10221
10277
  (viewId) => checkIsViewSelected(selectedSavedView, viewId),
10222
10278
  [selectedSavedView]
10223
10279
  );
10224
- const handleSavedViewFromUrl = useCallback2(
10225
- (viewId) => {
10226
- if (isViewAlreadySelected(viewId)) {
10227
- return;
10228
- }
10229
- const viewInList = findViewByToken(allViews, viewId);
10230
- if (viewInList) {
10231
- selectView(viewInList);
10232
- } else {
10233
- openSharedViewModal(viewId);
10234
- }
10235
- },
10236
- [isViewAlreadySelected, openSharedViewModal, allViews, selectView]
10237
- );
10238
- useEffect3(() => {
10280
+ const handleSavedViewFromUrl = useLatest((viewId) => {
10281
+ if (isViewAlreadySelected(viewId)) {
10282
+ return;
10283
+ }
10284
+ const viewInList = findViewByToken(allViews, viewId);
10285
+ if (viewInList) {
10286
+ selectView(viewInList);
10287
+ } else {
10288
+ openSharedViewModal(viewId);
10289
+ }
10290
+ });
10291
+ useEffect4(() => {
10239
10292
  const savedViewId = searchParams.get("saved-view");
10240
10293
  restoreUrlParameter(
10241
10294
  savedViewId,
@@ -10249,14 +10302,14 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
10249
10302
  handleSavedViewFromUrl(savedViewId);
10250
10303
  }
10251
10304
  }, [searchParams, handleSavedViewFromUrl, allViews.length]);
10252
- const previousRowGroupStateRef = useRef2(
10305
+ const previousRowGroupStateRef = useRef3(
10253
10306
  isSmartGridConfig(tableConfig) ? tableConfig.rowGroupState : void 0
10254
10307
  );
10255
- const selectedViewRef = useRef2(selectedSavedView);
10308
+ const selectedViewRef = useRef3(selectedSavedView);
10256
10309
  selectedViewRef.current = selectedSavedView;
10257
- const defaultViewRef = useRef2(config.defaultView);
10310
+ const defaultViewRef = useRef3(config.defaultView);
10258
10311
  defaultViewRef.current = config.defaultView;
10259
- useEffect3(() => {
10312
+ useEffect4(() => {
10260
10313
  var _a;
10261
10314
  if (!isSmartGridConfig(tableConfig) || !(presetViews == null ? void 0 : presetViews.length)) return;
10262
10315
  const currentView = selectedViewRef.current;
@@ -10296,7 +10349,57 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
10296
10349
  };
10297
10350
  };
10298
10351
 
10352
+ // src/components/saved-views/FocusScopeToggle.tsx
10353
+ import { useFocusManager } from "@react-aria/focus";
10354
+ import { useEffect as useEffect5, useRef as useRef4 } from "react";
10355
+ var useFocusScopeToggle = (isOpen) => {
10356
+ const focusManager = useFocusManager();
10357
+ const triggerRef = useRef4(null);
10358
+ const firstFocusedElementRef = useRef4(null);
10359
+ useEffect5(() => {
10360
+ var _a, _b;
10361
+ const handleKeyDown = (event) => {
10362
+ var _a2;
10363
+ if (!event.shiftKey || event.key !== "Tab") {
10364
+ return;
10365
+ }
10366
+ if (document.activeElement !== firstFocusedElementRef.current) {
10367
+ return;
10368
+ }
10369
+ event.preventDefault();
10370
+ (_a2 = triggerRef.current) == null ? void 0 : _a2.focus();
10371
+ };
10372
+ if (isOpen) {
10373
+ triggerRef.current = document.activeElement;
10374
+ focusManager == null ? void 0 : focusManager.focusFirst({ tabbable: true });
10375
+ firstFocusedElementRef.current = document.activeElement;
10376
+ (_a = firstFocusedElementRef.current) == null ? void 0 : _a.addEventListener(
10377
+ "keydown",
10378
+ handleKeyDown
10379
+ );
10380
+ } else {
10381
+ firstFocusedElementRef.current = null;
10382
+ const activeElement = document.activeElement;
10383
+ if (!activeElement || activeElement === document.body) {
10384
+ (_b = triggerRef.current) == null ? void 0 : _b.focus();
10385
+ }
10386
+ }
10387
+ return () => {
10388
+ var _a2;
10389
+ (_a2 = firstFocusedElementRef.current) == null ? void 0 : _a2.removeEventListener(
10390
+ "keydown",
10391
+ handleKeyDown
10392
+ );
10393
+ };
10394
+ }, [isOpen, focusManager]);
10395
+ };
10396
+ var FocusScopeToggle = ({ isOpen }) => {
10397
+ useFocusScopeToggle(isOpen);
10398
+ return null;
10399
+ };
10400
+
10299
10401
  // src/components/saved-views/SavedViews.tsx
10402
+ import { FocusScope } from "@react-aria/focus";
10300
10403
  var StyledPanel = pt.div`
10301
10404
  border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
10302
10405
  `;
@@ -10319,7 +10422,7 @@ var SavedViewsContent = (props) => {
10319
10422
  setActiveModal(type);
10320
10423
  setModalData(data ?? null);
10321
10424
  };
10322
- const closeModal = useCallback3(() => {
10425
+ const closeModal = useCallback4(() => {
10323
10426
  setActiveModal(null);
10324
10427
  setModalData(null);
10325
10428
  }, []);
@@ -10359,7 +10462,7 @@ var SavedViewsContent = (props) => {
10359
10462
  error: createError,
10360
10463
  reset: resetCreateError
10361
10464
  } = useCreateSavedView(queryInput);
10362
- useEffect4(() => {
10465
+ useEffect6(() => {
10363
10466
  if (fetchError) {
10364
10467
  showToast.error(i18n.t("savedViews.errors.notFound"));
10365
10468
  selectView(selectedView ?? props.defaultView);
@@ -10407,7 +10510,7 @@ var SavedViewsContent = (props) => {
10407
10510
  deleteSelectedView();
10408
10511
  closeModal();
10409
10512
  };
10410
- return /* @__PURE__ */ React23.createElement(StyledPanel, { id: "saved-views-panel", provider: props.provider }, /* @__PURE__ */ React23.createElement(
10513
+ return /* @__PURE__ */ React23.createElement(FocusScope, { contain: false }, /* @__PURE__ */ React23.createElement(StyledPanel, { id: "saved-views-panel", provider: props.provider }, /* @__PURE__ */ React23.createElement(FocusScopeToggle, { isOpen: props.isPanelOpen ?? true }), /* @__PURE__ */ React23.createElement(
10411
10514
  ExpandedPanel,
10412
10515
  {
10413
10516
  "data-testid": "saved-view-expanded-panel",
@@ -10495,17 +10598,17 @@ var SavedViewsContent = (props) => {
10495
10598
  isCreating,
10496
10599
  resetCreateError
10497
10600
  }
10498
- ));
10601
+ )));
10499
10602
  };
10500
10603
  var SavedViews = (props) => {
10501
10604
  return /* @__PURE__ */ React23.createElement(EnvironmentI18nProvider, null, /* @__PURE__ */ React23.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React23.createElement(ToastAlertProvider, null, /* @__PURE__ */ React23.createElement(SavedViewsContent, { ...props }))));
10502
10605
  };
10503
10606
 
10504
10607
  // src/components/adapters/smart-grid/SmartGridSavedViews.tsx
10505
- import React24, { useCallback as useCallback4 } from "react";
10608
+ import React24, { useCallback as useCallback5 } from "react";
10506
10609
 
10507
10610
  // src/components/adapters/smart-grid/SmartGridDefaultSavedView.tsx
10508
- import { useMemo as useMemo2 } from "react";
10611
+ import { useMemo as useMemo3 } from "react";
10509
10612
  var DEFAULT_COLUMN_STATE = {
10510
10613
  hide: false,
10511
10614
  pinned: null,
@@ -10553,7 +10656,7 @@ var extractDefaultView = (gridApi, receivedConfig) => {
10553
10656
  return result;
10554
10657
  };
10555
10658
  var useNormalizedDefaultViews = (defaultViews, gridApi) => {
10556
- return useMemo2(() => {
10659
+ return useMemo3(() => {
10557
10660
  if (!gridApi)
10558
10661
  return defaultViews.map((view) => ({ ...view, share_token: view.id }));
10559
10662
  return defaultViews.map((view) => ({
@@ -10565,7 +10668,7 @@ var useNormalizedDefaultViews = (defaultViews, gridApi) => {
10565
10668
  };
10566
10669
 
10567
10670
  // src/components/adapters/smart-grid/useSmartGridConfig.ts
10568
- import { useState as useState5, useEffect as useEffect5 } from "react";
10671
+ import { useState as useState5, useEffect as useEffect7 } from "react";
10569
10672
  var GRID_STATE_EVENTS = [
10570
10673
  "sortChanged",
10571
10674
  "filterOpened",
@@ -10584,7 +10687,7 @@ var useSmartGridConfig = (gridApi) => {
10584
10687
  const [config, setConfig] = useState5(
10585
10688
  () => getSmartGridConfig(gridApi)
10586
10689
  );
10587
- useEffect5(() => {
10690
+ useEffect7(() => {
10588
10691
  if (!gridApi) return;
10589
10692
  const updateConfig = () => {
10590
10693
  setConfig(getSmartGridConfig(gridApi));
@@ -10601,19 +10704,48 @@ var useSmartGridConfig = (gridApi) => {
10601
10704
  return { config, setConfig };
10602
10705
  };
10603
10706
 
10707
+ // src/components/adapters/smart-grid/useSavedViewsPanelOpen.ts
10708
+ import { useEffect as useEffect8, useState as useState6 } from "react";
10709
+ var SAVED_VIEWS_PANEL_ID = "savedViews";
10710
+ var useSavedViewsPanelOpen = (gridApi) => {
10711
+ var _a;
10712
+ const [isOpen, setIsOpen] = useState6(
10713
+ ((_a = gridApi.getOpenedToolPanel) == null ? void 0 : _a.call(gridApi)) === SAVED_VIEWS_PANEL_ID
10714
+ );
10715
+ useEffect8(() => {
10716
+ var _a2;
10717
+ const syncOpenState = () => {
10718
+ var _a3;
10719
+ setIsOpen(((_a3 = gridApi.getOpenedToolPanel) == null ? void 0 : _a3.call(gridApi)) === SAVED_VIEWS_PANEL_ID);
10720
+ };
10721
+ syncOpenState();
10722
+ (_a2 = gridApi.addEventListener) == null ? void 0 : _a2.call(gridApi, "toolPanelVisibleChanged", syncOpenState);
10723
+ return () => {
10724
+ var _a3;
10725
+ (_a3 = gridApi.removeEventListener) == null ? void 0 : _a3.call(gridApi, "toolPanelVisibleChanged", syncOpenState);
10726
+ };
10727
+ }, [gridApi]);
10728
+ return isOpen;
10729
+ };
10730
+
10604
10731
  // src/components/adapters/smart-grid/SmartGridSavedViews.tsx
10605
10732
  var SmartGridSavedViews = (props) => {
10606
10733
  const { gridApi, userId, projectId, companyId } = props;
10607
10734
  const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
10735
+ const isPanelOpen = useSavedViewsPanelOpen(gridApi);
10608
10736
  const presetViews = useNormalizedDefaultViews(props.defaultViews, gridApi);
10609
10737
  const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
10610
- const onSelect = useCallback4(
10738
+ const onSelect = useCallback5(
10611
10739
  ({ item }) => {
10740
+ var _a;
10612
10741
  if (!gridApi) return item;
10613
10742
  const isPresetView = item.view_level === "default";
10614
10743
  if (isPresetView) {
10615
10744
  updateTableConfig(item, gridApi, "smart-grid");
10616
- setTableConfig(item.table_config);
10745
+ setTableConfig({
10746
+ ...item.table_config,
10747
+ filterState: ((_a = gridApi.getFilterModel) == null ? void 0 : _a.call(gridApi)) ?? {}
10748
+ });
10617
10749
  return item;
10618
10750
  }
10619
10751
  const updatedView = {
@@ -10624,7 +10756,9 @@ var SmartGridSavedViews = (props) => {
10624
10756
  )
10625
10757
  };
10626
10758
  updateTableConfig(updatedView, gridApi, "smart-grid");
10627
- setTableConfig(updatedView.table_config);
10759
+ const updatedConfig = updatedView.table_config;
10760
+ gridApi.setFilterModel(updatedConfig.filterState ?? {});
10761
+ setTableConfig(updatedConfig);
10628
10762
  return updatedView;
10629
10763
  },
10630
10764
  [gridApi, tableConfig, setTableConfig]
@@ -10641,7 +10775,8 @@ var SmartGridSavedViews = (props) => {
10641
10775
  defaultView,
10642
10776
  presetViews,
10643
10777
  tableName: props.tableName,
10644
- tableConfig
10778
+ tableConfig,
10779
+ isPanelOpen
10645
10780
  }
10646
10781
  );
10647
10782
  };
@@ -10650,12 +10785,12 @@ var SmartGridSavedViews = (props) => {
10650
10785
  import React25, {
10651
10786
  forwardRef as forwardRef11,
10652
10787
  useImperativeHandle,
10653
- useState as useState6,
10654
- useCallback as useCallback5
10788
+ useState as useState7,
10789
+ useCallback as useCallback6
10655
10790
  } from "react";
10656
10791
 
10657
10792
  // src/components/adapters/data-table/DataTableDefaultSavedView.tsx
10658
- import { useMemo as useMemo3 } from "react";
10793
+ import { useMemo as useMemo4 } from "react";
10659
10794
  var DEFAULT_COLUMN_STATE2 = {
10660
10795
  hidden: false,
10661
10796
  pinned: null,
@@ -10703,7 +10838,7 @@ var extractDefaultView2 = (columnDefinitions, receivedConfigFromTool) => {
10703
10838
  return result;
10704
10839
  };
10705
10840
  var useNormalizedDefaultViews2 = (defaultViews, columnDefinitions) => {
10706
- return useMemo3(
10841
+ return useMemo4(
10707
10842
  () => defaultViews.map((view) => ({
10708
10843
  ...view,
10709
10844
  share_token: view.id,
@@ -10721,7 +10856,7 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
10721
10856
  props.columnDefinitions
10722
10857
  );
10723
10858
  const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
10724
- const [internalTableConfig, setInternalTableConfig] = useState6(
10859
+ const [internalTableConfig, setInternalTableConfig] = useState7(
10725
10860
  ViewStorage.load(props.stickyViewsKey, defaultView).table_config
10726
10861
  );
10727
10862
  useImperativeHandle(ref, () => ({
@@ -10729,17 +10864,22 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
10729
10864
  setInternalTableConfig(newConfig);
10730
10865
  }
10731
10866
  }));
10732
- const onSelect = useCallback5(
10867
+ const onSelect = useCallback6(
10733
10868
  ({ item }) => {
10869
+ var _a;
10734
10870
  const isPresetView = item.view_level === "default";
10871
+ const syncReferenceConfig = ((_a = tableApi == null ? void 0 : tableApi.getTableConfiguration) == null ? void 0 : _a.call(tableApi)) ?? defaultView.table_config;
10872
+ const syncedConfig = isPresetView ? item.table_config : customAndConfigSync(
10873
+ item.table_config,
10874
+ syncReferenceConfig
10875
+ );
10735
10876
  const updatedView = isPresetView ? item : {
10736
10877
  ...item,
10737
- table_config: customAndConfigSync(
10738
- item.table_config,
10739
- defaultView.table_config
10740
- )
10878
+ table_config: syncedConfig
10741
10879
  };
10742
- updateTableConfig(updatedView, tableApi, "data-table");
10880
+ if (tableApi) {
10881
+ updateTableConfig(updatedView, tableApi, "data-table");
10882
+ }
10743
10883
  setInternalTableConfig(updatedView.table_config);
10744
10884
  return updatedView;
10745
10885
  },
@@ -73,10 +73,11 @@ interface ISavedViewsProps extends Omit<IBaseSavedViewsProps, 'stickyViewsKey'>
73
73
  }) => ISavedView;
74
74
  tableConfig: ISmartGridConfig | DataTableConfig;
75
75
  provider: TableProvider;
76
+ isPanelOpen?: boolean;
76
77
  }
77
78
 
78
79
  interface IDataTableSavedViewsExternalConsumerProps extends IBaseSavedViewsProps {
79
- tableApi: TableApi;
80
+ tableApi?: TableApi;
80
81
  defaultViews: IDataTableDefaultViewConfig[];
81
82
  columnDefinitions: ColumnDefinition[];
82
83
  }
@@ -73,10 +73,11 @@ interface ISavedViewsProps extends Omit<IBaseSavedViewsProps, 'stickyViewsKey'>
73
73
  }) => ISavedView;
74
74
  tableConfig: ISmartGridConfig | DataTableConfig;
75
75
  provider: TableProvider;
76
+ isPanelOpen?: boolean;
76
77
  }
77
78
 
78
79
  interface IDataTableSavedViewsExternalConsumerProps extends IBaseSavedViewsProps {
79
- tableApi: TableApi;
80
+ tableApi?: TableApi;
80
81
  defaultViews: IDataTableDefaultViewConfig[];
81
82
  columnDefinitions: ColumnDefinition[];
82
83
  }