@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.
- package/dist/legacy/index.d.mts +2 -1
- package/dist/legacy/index.d.ts +2 -1
- package/dist/legacy/index.js +216 -76
- package/dist/legacy/index.mjs +200 -60
- package/dist/modern/index.d.mts +2 -1
- package/dist/modern/index.d.ts +2 -1
- package/dist/modern/index.js +206 -76
- package/dist/modern/index.mjs +190 -60
- package/package.json +2 -1
package/dist/modern/index.js
CHANGED
|
@@ -8774,9 +8774,36 @@ var bt = "__sc-".concat(a, "__");
|
|
|
8774
8774
|
// src/components/EnvironmentI18nProvider.tsx
|
|
8775
8775
|
var import_react2 = __toESM(require("react"));
|
|
8776
8776
|
var import_core_react = require("@procore/core-react");
|
|
8777
|
+
|
|
8778
|
+
// src/utils/translations/translationCache.ts
|
|
8779
|
+
var CACHE_KEY_PREFIX = "sg-saved-views-translations";
|
|
8780
|
+
function cacheKey(locale) {
|
|
8781
|
+
return `${CACHE_KEY_PREFIX}-${locale}`;
|
|
8782
|
+
}
|
|
8783
|
+
function readCache(locale) {
|
|
8784
|
+
try {
|
|
8785
|
+
const raw = localStorage.getItem(cacheKey(locale));
|
|
8786
|
+
if (!raw) return null;
|
|
8787
|
+
return JSON.parse(raw);
|
|
8788
|
+
} catch {
|
|
8789
|
+
return null;
|
|
8790
|
+
}
|
|
8791
|
+
}
|
|
8792
|
+
function writeCache(locale, translations) {
|
|
8793
|
+
try {
|
|
8794
|
+
localStorage.setItem(cacheKey(locale), JSON.stringify(translations));
|
|
8795
|
+
} catch {
|
|
8796
|
+
}
|
|
8797
|
+
}
|
|
8798
|
+
|
|
8799
|
+
// src/components/EnvironmentI18nProvider.tsx
|
|
8777
8800
|
var import_cdn_translations = require("@procore/cdn-translations");
|
|
8778
8801
|
var useCDNTranslations = () => {
|
|
8779
8802
|
const i18n = (0, import_core_react.useI18nContext)();
|
|
8803
|
+
const cachedTranslations = (0, import_react2.useMemo)(
|
|
8804
|
+
() => readCache(i18n.locale),
|
|
8805
|
+
[i18n.locale]
|
|
8806
|
+
);
|
|
8780
8807
|
const cdnTranslations = (0, import_cdn_translations.useRequestTranslations)(
|
|
8781
8808
|
{
|
|
8782
8809
|
type: "file",
|
|
@@ -8791,8 +8818,17 @@ var useCDNTranslations = () => {
|
|
|
8791
8818
|
enableCDN: i18n.enableCDN
|
|
8792
8819
|
}
|
|
8793
8820
|
);
|
|
8821
|
+
(0, import_react2.useEffect)(() => {
|
|
8822
|
+
if (cdnTranslations.status === "resolved" && cdnTranslations.translations) {
|
|
8823
|
+
writeCache(
|
|
8824
|
+
i18n.locale,
|
|
8825
|
+
cdnTranslations.translations
|
|
8826
|
+
);
|
|
8827
|
+
}
|
|
8828
|
+
}, [cdnTranslations.status, cdnTranslations.translations, i18n.locale]);
|
|
8829
|
+
const translationsToUse = cdnTranslations.status === "resolved" ? cdnTranslations.translations : cachedTranslations ?? getTranslations(i18n.locale);
|
|
8794
8830
|
return (0, import_core_react.useI18n)({
|
|
8795
|
-
translations:
|
|
8831
|
+
translations: translationsToUse,
|
|
8796
8832
|
locale: i18n.locale
|
|
8797
8833
|
});
|
|
8798
8834
|
};
|
|
@@ -9180,7 +9216,6 @@ function setSmartGridConfig(api, config) {
|
|
|
9180
9216
|
});
|
|
9181
9217
|
api.setColumnGroupState(config.columnGroupState);
|
|
9182
9218
|
api.setRowGroupColumns(config.rowGroupState);
|
|
9183
|
-
api.setFilterModel(config.filterState);
|
|
9184
9219
|
if (config.rowHeight) {
|
|
9185
9220
|
api.setGridOption("rowHeight", config.rowHeight);
|
|
9186
9221
|
}
|
|
@@ -9233,11 +9268,21 @@ var updateTableConfig = (view, tableApi, provider) => {
|
|
|
9233
9268
|
const dataTableApi = tableApi;
|
|
9234
9269
|
const tableConfig = view.table_config;
|
|
9235
9270
|
if (tableConfig) {
|
|
9236
|
-
const
|
|
9271
|
+
const currentTableConfig = dataTableApi?.getTableConfiguration?.();
|
|
9272
|
+
const rowHeight = tableConfig?.rowHeight ?? currentTableConfig?.rowHeight;
|
|
9273
|
+
const hasServerFilters = Boolean(currentTableConfig?.serverFilters?.length) || Boolean(tableConfig?.serverFilters?.length);
|
|
9274
|
+
const usesServerSideFiltering = hasServerFilters;
|
|
9237
9275
|
if (rowHeight !== void 0) {
|
|
9238
9276
|
dataTableApi?.setRowHeight(rowHeight);
|
|
9239
9277
|
}
|
|
9240
|
-
|
|
9278
|
+
if (usesServerSideFiltering) {
|
|
9279
|
+
dataTableApi?.setTableConfiguration({
|
|
9280
|
+
...tableConfig,
|
|
9281
|
+
filters: void 0
|
|
9282
|
+
});
|
|
9283
|
+
} else {
|
|
9284
|
+
dataTableApi?.setTableConfiguration(tableConfig);
|
|
9285
|
+
}
|
|
9241
9286
|
}
|
|
9242
9287
|
}
|
|
9243
9288
|
};
|
|
@@ -9602,7 +9647,7 @@ var PanelContent = (props) => {
|
|
|
9602
9647
|
|
|
9603
9648
|
// src/components/saved-views/SavedViews.tsx
|
|
9604
9649
|
var import_core_react15 = require("@procore/core-react");
|
|
9605
|
-
var
|
|
9650
|
+
var import_react15 = __toESM(require("react"));
|
|
9606
9651
|
var import_react_query3 = require("@tanstack/react-query");
|
|
9607
9652
|
var import_toast_alert3 = require("@procore/toast-alert");
|
|
9608
9653
|
|
|
@@ -10044,7 +10089,7 @@ var SharedViewFormModal = ({
|
|
|
10044
10089
|
};
|
|
10045
10090
|
|
|
10046
10091
|
// src/utils/hooks/useViewSelection.ts
|
|
10047
|
-
var
|
|
10092
|
+
var import_react13 = require("react");
|
|
10048
10093
|
var import_react_router_dom = require("react-router-dom");
|
|
10049
10094
|
var import_core_react14 = require("@procore/core-react");
|
|
10050
10095
|
|
|
@@ -10070,6 +10115,16 @@ var ViewStorage = {
|
|
|
10070
10115
|
}
|
|
10071
10116
|
};
|
|
10072
10117
|
|
|
10118
|
+
// src/utils/hooks/useLatest.ts
|
|
10119
|
+
var import_react12 = require("react");
|
|
10120
|
+
var useLatest = (callback) => {
|
|
10121
|
+
const ref = (0, import_react12.useRef)(callback);
|
|
10122
|
+
(0, import_react12.useLayoutEffect)(() => {
|
|
10123
|
+
ref.current = callback;
|
|
10124
|
+
});
|
|
10125
|
+
return (0, import_react12.useCallback)((...args) => ref.current(...args), []);
|
|
10126
|
+
};
|
|
10127
|
+
|
|
10073
10128
|
// src/utils/hooks/useViewSelection.ts
|
|
10074
10129
|
var isSmartGridConfig = (config) => {
|
|
10075
10130
|
return config != null && "rowGroupState" in config;
|
|
@@ -10121,31 +10176,31 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10121
10176
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
10122
10177
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
10123
10178
|
const [searchParams, setSearchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
10124
|
-
const previousSavedViewParamRef = (0,
|
|
10125
|
-
const [selectedSavedView, setSelectedSavedView] = (0,
|
|
10179
|
+
const previousSavedViewParamRef = (0, import_react13.useRef)(null);
|
|
10180
|
+
const [selectedSavedView, setSelectedSavedView] = (0, import_react13.useState)(() => {
|
|
10126
10181
|
const stored = ViewStorage.load(storageKey, config.defaultView);
|
|
10127
10182
|
return stored ?? config.defaultView;
|
|
10128
10183
|
});
|
|
10129
|
-
const [temporaryView, setTemporaryView] = (0,
|
|
10184
|
+
const [temporaryView, setTemporaryView] = (0, import_react13.useState)(() => {
|
|
10130
10185
|
const loaded = ViewStorage.load(temporaryStorageKey, config.defaultView);
|
|
10131
10186
|
return loaded && (loaded.id === "temporary" || loaded.view_level === "temporary") ? loaded : null;
|
|
10132
10187
|
});
|
|
10133
|
-
const persistViewToStorageAndUrl = (0,
|
|
10188
|
+
const persistViewToStorageAndUrl = (0, import_react13.useCallback)(
|
|
10134
10189
|
(view) => {
|
|
10135
10190
|
ViewStorage.save(storageKey, view);
|
|
10136
10191
|
setViewInUrl(view, setSearchParams);
|
|
10137
10192
|
},
|
|
10138
10193
|
[storageKey, setSearchParams]
|
|
10139
10194
|
);
|
|
10140
|
-
const baseViews = (0,
|
|
10195
|
+
const baseViews = (0, import_react13.useMemo)(
|
|
10141
10196
|
() => [...savedViews ?? [], ...presetViews ?? []],
|
|
10142
10197
|
[savedViews, presetViews]
|
|
10143
10198
|
);
|
|
10144
|
-
const allViews = (0,
|
|
10199
|
+
const allViews = (0, import_react13.useMemo)(
|
|
10145
10200
|
() => temporaryView ? [...baseViews, temporaryView] : baseViews,
|
|
10146
10201
|
[baseViews, temporaryView]
|
|
10147
10202
|
);
|
|
10148
|
-
const selectView = (0,
|
|
10203
|
+
const selectView = (0, import_react13.useCallback)(
|
|
10149
10204
|
(view) => {
|
|
10150
10205
|
const viewToSelect = config.onSelect({ item: view });
|
|
10151
10206
|
setSelectedSavedView(viewToSelect);
|
|
@@ -10154,7 +10209,7 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10154
10209
|
},
|
|
10155
10210
|
[config, persistViewToStorageAndUrl]
|
|
10156
10211
|
);
|
|
10157
|
-
const createTemporaryView = (0,
|
|
10212
|
+
const createTemporaryView = (0, import_react13.useCallback)(
|
|
10158
10213
|
(fetchedView) => {
|
|
10159
10214
|
const tempView = {
|
|
10160
10215
|
...fetchedView,
|
|
@@ -10169,30 +10224,27 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10169
10224
|
},
|
|
10170
10225
|
[temporaryStorageKey, selectView]
|
|
10171
10226
|
);
|
|
10172
|
-
const clearTemporaryView = (0,
|
|
10227
|
+
const clearTemporaryView = (0, import_react13.useCallback)(() => {
|
|
10173
10228
|
ViewStorage.remove(temporaryStorageKey);
|
|
10174
10229
|
setTemporaryView(null);
|
|
10175
10230
|
selectView(config.defaultView);
|
|
10176
10231
|
}, [temporaryStorageKey, config.defaultView, selectView]);
|
|
10177
|
-
const isViewAlreadySelected = (0,
|
|
10232
|
+
const isViewAlreadySelected = (0, import_react13.useCallback)(
|
|
10178
10233
|
(viewId) => checkIsViewSelected(selectedSavedView, viewId),
|
|
10179
10234
|
[selectedSavedView]
|
|
10180
10235
|
);
|
|
10181
|
-
const handleSavedViewFromUrl = (
|
|
10182
|
-
(viewId)
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
[isViewAlreadySelected, openSharedViewModal, allViews, selectView]
|
|
10194
|
-
);
|
|
10195
|
-
(0, import_react12.useEffect)(() => {
|
|
10236
|
+
const handleSavedViewFromUrl = useLatest((viewId) => {
|
|
10237
|
+
if (isViewAlreadySelected(viewId)) {
|
|
10238
|
+
return;
|
|
10239
|
+
}
|
|
10240
|
+
const viewInList = findViewByToken(allViews, viewId);
|
|
10241
|
+
if (viewInList) {
|
|
10242
|
+
selectView(viewInList);
|
|
10243
|
+
} else {
|
|
10244
|
+
openSharedViewModal(viewId);
|
|
10245
|
+
}
|
|
10246
|
+
});
|
|
10247
|
+
(0, import_react13.useEffect)(() => {
|
|
10196
10248
|
const savedViewId = searchParams.get("saved-view");
|
|
10197
10249
|
restoreUrlParameter(
|
|
10198
10250
|
savedViewId,
|
|
@@ -10206,14 +10258,14 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10206
10258
|
handleSavedViewFromUrl(savedViewId);
|
|
10207
10259
|
}
|
|
10208
10260
|
}, [searchParams, handleSavedViewFromUrl, allViews.length]);
|
|
10209
|
-
const previousRowGroupStateRef = (0,
|
|
10261
|
+
const previousRowGroupStateRef = (0, import_react13.useRef)(
|
|
10210
10262
|
isSmartGridConfig(tableConfig) ? tableConfig.rowGroupState : void 0
|
|
10211
10263
|
);
|
|
10212
|
-
const selectedViewRef = (0,
|
|
10264
|
+
const selectedViewRef = (0, import_react13.useRef)(selectedSavedView);
|
|
10213
10265
|
selectedViewRef.current = selectedSavedView;
|
|
10214
|
-
const defaultViewRef = (0,
|
|
10266
|
+
const defaultViewRef = (0, import_react13.useRef)(config.defaultView);
|
|
10215
10267
|
defaultViewRef.current = config.defaultView;
|
|
10216
|
-
(0,
|
|
10268
|
+
(0, import_react13.useEffect)(() => {
|
|
10217
10269
|
if (!isSmartGridConfig(tableConfig) || !presetViews?.length) return;
|
|
10218
10270
|
const currentView = selectedViewRef.current;
|
|
10219
10271
|
const isPresetSelected = !currentView || currentView.view_level === "default";
|
|
@@ -10252,7 +10304,54 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10252
10304
|
};
|
|
10253
10305
|
};
|
|
10254
10306
|
|
|
10307
|
+
// src/components/saved-views/FocusScopeToggle.tsx
|
|
10308
|
+
var import_focus = require("@react-aria/focus");
|
|
10309
|
+
var import_react14 = require("react");
|
|
10310
|
+
var useFocusScopeToggle = (isOpen) => {
|
|
10311
|
+
const focusManager = (0, import_focus.useFocusManager)();
|
|
10312
|
+
const triggerRef = (0, import_react14.useRef)(null);
|
|
10313
|
+
const firstFocusedElementRef = (0, import_react14.useRef)(null);
|
|
10314
|
+
(0, import_react14.useEffect)(() => {
|
|
10315
|
+
const handleKeyDown = (event) => {
|
|
10316
|
+
if (!event.shiftKey || event.key !== "Tab") {
|
|
10317
|
+
return;
|
|
10318
|
+
}
|
|
10319
|
+
if (document.activeElement !== firstFocusedElementRef.current) {
|
|
10320
|
+
return;
|
|
10321
|
+
}
|
|
10322
|
+
event.preventDefault();
|
|
10323
|
+
triggerRef.current?.focus();
|
|
10324
|
+
};
|
|
10325
|
+
if (isOpen) {
|
|
10326
|
+
triggerRef.current = document.activeElement;
|
|
10327
|
+
focusManager?.focusFirst({ tabbable: true });
|
|
10328
|
+
firstFocusedElementRef.current = document.activeElement;
|
|
10329
|
+
firstFocusedElementRef.current?.addEventListener(
|
|
10330
|
+
"keydown",
|
|
10331
|
+
handleKeyDown
|
|
10332
|
+
);
|
|
10333
|
+
} else {
|
|
10334
|
+
firstFocusedElementRef.current = null;
|
|
10335
|
+
const activeElement = document.activeElement;
|
|
10336
|
+
if (!activeElement || activeElement === document.body) {
|
|
10337
|
+
triggerRef.current?.focus();
|
|
10338
|
+
}
|
|
10339
|
+
}
|
|
10340
|
+
return () => {
|
|
10341
|
+
firstFocusedElementRef.current?.removeEventListener(
|
|
10342
|
+
"keydown",
|
|
10343
|
+
handleKeyDown
|
|
10344
|
+
);
|
|
10345
|
+
};
|
|
10346
|
+
}, [isOpen, focusManager]);
|
|
10347
|
+
};
|
|
10348
|
+
var FocusScopeToggle = ({ isOpen }) => {
|
|
10349
|
+
useFocusScopeToggle(isOpen);
|
|
10350
|
+
return null;
|
|
10351
|
+
};
|
|
10352
|
+
|
|
10255
10353
|
// src/components/saved-views/SavedViews.tsx
|
|
10354
|
+
var import_focus2 = require("@react-aria/focus");
|
|
10256
10355
|
var StyledPanel = pt.div`
|
|
10257
10356
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
10258
10357
|
`;
|
|
@@ -10269,13 +10368,13 @@ var SavedViewsContent = (props) => {
|
|
|
10269
10368
|
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
10270
10369
|
const { showToast } = (0, import_toast_alert3.useToastAlertContext)();
|
|
10271
10370
|
const i18n = (0, import_core_react15.useI18nContext)();
|
|
10272
|
-
const [activeModal, setActiveModal] = (0,
|
|
10273
|
-
const [modalData, setModalData] = (0,
|
|
10371
|
+
const [activeModal, setActiveModal] = (0, import_react15.useState)(null);
|
|
10372
|
+
const [modalData, setModalData] = (0, import_react15.useState)(null);
|
|
10274
10373
|
const openModal = (type, data) => {
|
|
10275
10374
|
setActiveModal(type);
|
|
10276
10375
|
setModalData(data ?? null);
|
|
10277
10376
|
};
|
|
10278
|
-
const closeModal = (0,
|
|
10377
|
+
const closeModal = (0, import_react15.useCallback)(() => {
|
|
10279
10378
|
setActiveModal(null);
|
|
10280
10379
|
setModalData(null);
|
|
10281
10380
|
}, []);
|
|
@@ -10315,7 +10414,7 @@ var SavedViewsContent = (props) => {
|
|
|
10315
10414
|
error: createError,
|
|
10316
10415
|
reset: resetCreateError
|
|
10317
10416
|
} = useCreateSavedView(queryInput);
|
|
10318
|
-
(0,
|
|
10417
|
+
(0, import_react15.useEffect)(() => {
|
|
10319
10418
|
if (fetchError) {
|
|
10320
10419
|
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
10321
10420
|
selectView(selectedView ?? props.defaultView);
|
|
@@ -10363,19 +10462,19 @@ var SavedViewsContent = (props) => {
|
|
|
10363
10462
|
deleteSelectedView();
|
|
10364
10463
|
closeModal();
|
|
10365
10464
|
};
|
|
10366
|
-
return /* @__PURE__ */
|
|
10465
|
+
return /* @__PURE__ */ import_react15.default.createElement(import_focus2.FocusScope, { contain: false }, /* @__PURE__ */ import_react15.default.createElement(StyledPanel, { id: "saved-views-panel", provider: props.provider }, /* @__PURE__ */ import_react15.default.createElement(FocusScopeToggle, { isOpen: props.isPanelOpen ?? true }), /* @__PURE__ */ import_react15.default.createElement(
|
|
10367
10466
|
ExpandedPanel,
|
|
10368
10467
|
{
|
|
10369
10468
|
"data-testid": "saved-view-expanded-panel",
|
|
10370
10469
|
provider: props.provider
|
|
10371
10470
|
},
|
|
10372
|
-
/* @__PURE__ */
|
|
10471
|
+
/* @__PURE__ */ import_react15.default.createElement(import_core_react15.Panel.Header, { id: "saved-views-collections-panel-header" }, /* @__PURE__ */ import_react15.default.createElement(import_core_react15.Panel.Title, null, /* @__PURE__ */ import_react15.default.createElement(import_core_react15.Flex, { alignItems: "center" }, /* @__PURE__ */ import_react15.default.createElement(import_core_react15.Box, { paddingRight: "sm" }, i18n.t("savedViews.title")), /* @__PURE__ */ import_react15.default.createElement(
|
|
10373
10472
|
import_core_react15.Tooltip,
|
|
10374
10473
|
{
|
|
10375
10474
|
showDelay: 200,
|
|
10376
|
-
overlay: /* @__PURE__ */
|
|
10475
|
+
overlay: /* @__PURE__ */ import_react15.default.createElement(import_core_react15.Tooltip.Content, null, i18n.t("savedViews.tooltip"))
|
|
10377
10476
|
},
|
|
10378
|
-
/* @__PURE__ */
|
|
10477
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
10379
10478
|
Help_default,
|
|
10380
10479
|
{
|
|
10381
10480
|
tabIndex: 0,
|
|
@@ -10383,16 +10482,16 @@ var SavedViewsContent = (props) => {
|
|
|
10383
10482
|
"aria-label": i18n.t("savedViews.tooltip")
|
|
10384
10483
|
}
|
|
10385
10484
|
)
|
|
10386
|
-
))), /* @__PURE__ */
|
|
10485
|
+
))), /* @__PURE__ */ import_react15.default.createElement(
|
|
10387
10486
|
import_core_react15.Tooltip,
|
|
10388
10487
|
{
|
|
10389
10488
|
overlay: i18n.t("savedViews.actions.create"),
|
|
10390
10489
|
showDelay: 1e3
|
|
10391
10490
|
},
|
|
10392
|
-
/* @__PURE__ */
|
|
10491
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
10393
10492
|
import_core_react15.Button,
|
|
10394
10493
|
{
|
|
10395
|
-
icon: /* @__PURE__ */
|
|
10494
|
+
icon: /* @__PURE__ */ import_react15.default.createElement(Plus_default, null),
|
|
10396
10495
|
variant: "secondary",
|
|
10397
10496
|
"data-testid": "expanded-panel-create-button",
|
|
10398
10497
|
onClick: () => openModal("create" /* CREATE */),
|
|
@@ -10401,7 +10500,7 @@ var SavedViewsContent = (props) => {
|
|
|
10401
10500
|
i18n.t("savedViews.actions.create")
|
|
10402
10501
|
)
|
|
10403
10502
|
)),
|
|
10404
|
-
/* @__PURE__ */
|
|
10503
|
+
/* @__PURE__ */ import_react15.default.createElement(import_core_react15.Panel.Body, { style: { display: "flex", flexFlow: "column" } }, /* @__PURE__ */ import_react15.default.createElement(
|
|
10405
10504
|
PanelContent,
|
|
10406
10505
|
{
|
|
10407
10506
|
onSelect: ({ item }) => selectView(item),
|
|
@@ -10418,7 +10517,7 @@ var SavedViewsContent = (props) => {
|
|
|
10418
10517
|
onClearTemporary: clearTemporaryView
|
|
10419
10518
|
}
|
|
10420
10519
|
))
|
|
10421
|
-
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */
|
|
10520
|
+
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ import_react15.default.createElement(
|
|
10422
10521
|
FormModal,
|
|
10423
10522
|
{
|
|
10424
10523
|
open: true,
|
|
@@ -10432,14 +10531,14 @@ var SavedViewsContent = (props) => {
|
|
|
10432
10531
|
setOpenEditCreateModal: closeModal,
|
|
10433
10532
|
defaultView: props.defaultView
|
|
10434
10533
|
}
|
|
10435
|
-
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */
|
|
10534
|
+
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ import_react15.default.createElement(
|
|
10436
10535
|
SavedViewsDeleteConfirmationModalShared,
|
|
10437
10536
|
{
|
|
10438
10537
|
open: true,
|
|
10439
10538
|
onDelete: confirmDeleteAndCloseModal,
|
|
10440
10539
|
onCancel: closeModal
|
|
10441
10540
|
}
|
|
10442
|
-
), fetchedView && isModalOpen("sharedView" /* SHARED_VIEW */) && /* @__PURE__ */
|
|
10541
|
+
), fetchedView && isModalOpen("sharedView" /* SHARED_VIEW */) && /* @__PURE__ */ import_react15.default.createElement(
|
|
10443
10542
|
SharedViewFormModal,
|
|
10444
10543
|
{
|
|
10445
10544
|
open: true,
|
|
@@ -10451,17 +10550,17 @@ var SavedViewsContent = (props) => {
|
|
|
10451
10550
|
isCreating,
|
|
10452
10551
|
resetCreateError
|
|
10453
10552
|
}
|
|
10454
|
-
));
|
|
10553
|
+
)));
|
|
10455
10554
|
};
|
|
10456
10555
|
var SavedViews = (props) => {
|
|
10457
|
-
return /* @__PURE__ */
|
|
10556
|
+
return /* @__PURE__ */ import_react15.default.createElement(EnvironmentI18nProvider, null, /* @__PURE__ */ import_react15.default.createElement(import_react_query3.QueryClientProvider, { client: queryClient }, /* @__PURE__ */ import_react15.default.createElement(import_toast_alert3.ToastAlertProvider, null, /* @__PURE__ */ import_react15.default.createElement(SavedViewsContent, { ...props }))));
|
|
10458
10557
|
};
|
|
10459
10558
|
|
|
10460
10559
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
10461
|
-
var
|
|
10560
|
+
var import_react19 = __toESM(require("react"));
|
|
10462
10561
|
|
|
10463
10562
|
// src/components/adapters/smart-grid/SmartGridDefaultSavedView.tsx
|
|
10464
|
-
var
|
|
10563
|
+
var import_react16 = require("react");
|
|
10465
10564
|
var DEFAULT_COLUMN_STATE = {
|
|
10466
10565
|
hide: false,
|
|
10467
10566
|
pinned: null,
|
|
@@ -10508,7 +10607,7 @@ var extractDefaultView = (gridApi, receivedConfig) => {
|
|
|
10508
10607
|
return result;
|
|
10509
10608
|
};
|
|
10510
10609
|
var useNormalizedDefaultViews = (defaultViews, gridApi) => {
|
|
10511
|
-
return (0,
|
|
10610
|
+
return (0, import_react16.useMemo)(() => {
|
|
10512
10611
|
if (!gridApi)
|
|
10513
10612
|
return defaultViews.map((view) => ({ ...view, share_token: view.id }));
|
|
10514
10613
|
return defaultViews.map((view) => ({
|
|
@@ -10520,7 +10619,7 @@ var useNormalizedDefaultViews = (defaultViews, gridApi) => {
|
|
|
10520
10619
|
};
|
|
10521
10620
|
|
|
10522
10621
|
// src/components/adapters/smart-grid/useSmartGridConfig.ts
|
|
10523
|
-
var
|
|
10622
|
+
var import_react17 = require("react");
|
|
10524
10623
|
var GRID_STATE_EVENTS = [
|
|
10525
10624
|
"sortChanged",
|
|
10526
10625
|
"filterOpened",
|
|
@@ -10536,10 +10635,10 @@ var GRID_STATE_EVENTS = [
|
|
|
10536
10635
|
"gridReady"
|
|
10537
10636
|
];
|
|
10538
10637
|
var useSmartGridConfig = (gridApi) => {
|
|
10539
|
-
const [config, setConfig] = (0,
|
|
10638
|
+
const [config, setConfig] = (0, import_react17.useState)(
|
|
10540
10639
|
() => getSmartGridConfig(gridApi)
|
|
10541
10640
|
);
|
|
10542
|
-
(0,
|
|
10641
|
+
(0, import_react17.useEffect)(() => {
|
|
10543
10642
|
if (!gridApi) return;
|
|
10544
10643
|
const updateConfig = () => {
|
|
10545
10644
|
setConfig(getSmartGridConfig(gridApi));
|
|
@@ -10556,19 +10655,43 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
10556
10655
|
return { config, setConfig };
|
|
10557
10656
|
};
|
|
10558
10657
|
|
|
10658
|
+
// src/components/adapters/smart-grid/useSavedViewsPanelOpen.ts
|
|
10659
|
+
var import_react18 = require("react");
|
|
10660
|
+
var SAVED_VIEWS_PANEL_ID = "savedViews";
|
|
10661
|
+
var useSavedViewsPanelOpen = (gridApi) => {
|
|
10662
|
+
const [isOpen, setIsOpen] = (0, import_react18.useState)(
|
|
10663
|
+
gridApi.getOpenedToolPanel?.() === SAVED_VIEWS_PANEL_ID
|
|
10664
|
+
);
|
|
10665
|
+
(0, import_react18.useEffect)(() => {
|
|
10666
|
+
const syncOpenState = () => {
|
|
10667
|
+
setIsOpen(gridApi.getOpenedToolPanel?.() === SAVED_VIEWS_PANEL_ID);
|
|
10668
|
+
};
|
|
10669
|
+
syncOpenState();
|
|
10670
|
+
gridApi.addEventListener?.("toolPanelVisibleChanged", syncOpenState);
|
|
10671
|
+
return () => {
|
|
10672
|
+
gridApi.removeEventListener?.("toolPanelVisibleChanged", syncOpenState);
|
|
10673
|
+
};
|
|
10674
|
+
}, [gridApi]);
|
|
10675
|
+
return isOpen;
|
|
10676
|
+
};
|
|
10677
|
+
|
|
10559
10678
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
10560
10679
|
var SmartGridSavedViews = (props) => {
|
|
10561
10680
|
const { gridApi, userId, projectId, companyId } = props;
|
|
10562
10681
|
const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
|
|
10682
|
+
const isPanelOpen = useSavedViewsPanelOpen(gridApi);
|
|
10563
10683
|
const presetViews = useNormalizedDefaultViews(props.defaultViews, gridApi);
|
|
10564
10684
|
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
10565
|
-
const onSelect = (0,
|
|
10685
|
+
const onSelect = (0, import_react19.useCallback)(
|
|
10566
10686
|
({ item }) => {
|
|
10567
10687
|
if (!gridApi) return item;
|
|
10568
10688
|
const isPresetView = item.view_level === "default";
|
|
10569
10689
|
if (isPresetView) {
|
|
10570
10690
|
updateTableConfig(item, gridApi, "smart-grid");
|
|
10571
|
-
setTableConfig(
|
|
10691
|
+
setTableConfig({
|
|
10692
|
+
...item.table_config,
|
|
10693
|
+
filterState: gridApi.getFilterModel?.() ?? {}
|
|
10694
|
+
});
|
|
10572
10695
|
return item;
|
|
10573
10696
|
}
|
|
10574
10697
|
const updatedView = {
|
|
@@ -10579,12 +10702,14 @@ var SmartGridSavedViews = (props) => {
|
|
|
10579
10702
|
)
|
|
10580
10703
|
};
|
|
10581
10704
|
updateTableConfig(updatedView, gridApi, "smart-grid");
|
|
10582
|
-
|
|
10705
|
+
const updatedConfig = updatedView.table_config;
|
|
10706
|
+
gridApi.setFilterModel(updatedConfig.filterState ?? {});
|
|
10707
|
+
setTableConfig(updatedConfig);
|
|
10583
10708
|
return updatedView;
|
|
10584
10709
|
},
|
|
10585
10710
|
[gridApi, tableConfig, setTableConfig]
|
|
10586
10711
|
);
|
|
10587
|
-
return /* @__PURE__ */
|
|
10712
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
10588
10713
|
SavedViews,
|
|
10589
10714
|
{
|
|
10590
10715
|
onSelect,
|
|
@@ -10596,16 +10721,17 @@ var SmartGridSavedViews = (props) => {
|
|
|
10596
10721
|
defaultView,
|
|
10597
10722
|
presetViews,
|
|
10598
10723
|
tableName: props.tableName,
|
|
10599
|
-
tableConfig
|
|
10724
|
+
tableConfig,
|
|
10725
|
+
isPanelOpen
|
|
10600
10726
|
}
|
|
10601
10727
|
);
|
|
10602
10728
|
};
|
|
10603
10729
|
|
|
10604
10730
|
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
10605
|
-
var
|
|
10731
|
+
var import_react21 = __toESM(require("react"));
|
|
10606
10732
|
|
|
10607
10733
|
// src/components/adapters/data-table/DataTableDefaultSavedView.tsx
|
|
10608
|
-
var
|
|
10734
|
+
var import_react20 = require("react");
|
|
10609
10735
|
var DEFAULT_COLUMN_STATE2 = {
|
|
10610
10736
|
hidden: false,
|
|
10611
10737
|
pinned: null,
|
|
@@ -10652,7 +10778,7 @@ var extractDefaultView2 = (columnDefinitions, receivedConfigFromTool) => {
|
|
|
10652
10778
|
return result;
|
|
10653
10779
|
};
|
|
10654
10780
|
var useNormalizedDefaultViews2 = (defaultViews, columnDefinitions) => {
|
|
10655
|
-
return (0,
|
|
10781
|
+
return (0, import_react20.useMemo)(
|
|
10656
10782
|
() => defaultViews.map((view) => ({
|
|
10657
10783
|
...view,
|
|
10658
10784
|
share_token: view.id,
|
|
@@ -10663,32 +10789,36 @@ var useNormalizedDefaultViews2 = (defaultViews, columnDefinitions) => {
|
|
|
10663
10789
|
};
|
|
10664
10790
|
|
|
10665
10791
|
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
10666
|
-
var DataTableSavedViews = (0,
|
|
10792
|
+
var DataTableSavedViews = (0, import_react21.forwardRef)((props, ref) => {
|
|
10667
10793
|
const { tableApi, userId, projectId, companyId } = props;
|
|
10668
10794
|
const presetViews = useNormalizedDefaultViews2(
|
|
10669
10795
|
props.defaultViews,
|
|
10670
10796
|
props.columnDefinitions
|
|
10671
10797
|
);
|
|
10672
10798
|
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
10673
|
-
const [internalTableConfig, setInternalTableConfig] = (0,
|
|
10799
|
+
const [internalTableConfig, setInternalTableConfig] = (0, import_react21.useState)(
|
|
10674
10800
|
ViewStorage.load(props.stickyViewsKey, defaultView).table_config
|
|
10675
10801
|
);
|
|
10676
|
-
(0,
|
|
10802
|
+
(0, import_react21.useImperativeHandle)(ref, () => ({
|
|
10677
10803
|
setTableConfig: (newConfig) => {
|
|
10678
10804
|
setInternalTableConfig(newConfig);
|
|
10679
10805
|
}
|
|
10680
10806
|
}));
|
|
10681
|
-
const onSelect = (0,
|
|
10807
|
+
const onSelect = (0, import_react21.useCallback)(
|
|
10682
10808
|
({ item }) => {
|
|
10683
10809
|
const isPresetView = item.view_level === "default";
|
|
10810
|
+
const syncReferenceConfig = tableApi?.getTableConfiguration?.() ?? defaultView.table_config;
|
|
10811
|
+
const syncedConfig = isPresetView ? item.table_config : customAndConfigSync(
|
|
10812
|
+
item.table_config,
|
|
10813
|
+
syncReferenceConfig
|
|
10814
|
+
);
|
|
10684
10815
|
const updatedView = isPresetView ? item : {
|
|
10685
10816
|
...item,
|
|
10686
|
-
table_config:
|
|
10687
|
-
item.table_config,
|
|
10688
|
-
defaultView.table_config
|
|
10689
|
-
)
|
|
10817
|
+
table_config: syncedConfig
|
|
10690
10818
|
};
|
|
10691
|
-
|
|
10819
|
+
if (tableApi) {
|
|
10820
|
+
updateTableConfig(updatedView, tableApi, "data-table");
|
|
10821
|
+
}
|
|
10692
10822
|
setInternalTableConfig(updatedView.table_config);
|
|
10693
10823
|
return updatedView;
|
|
10694
10824
|
},
|
|
@@ -10697,7 +10827,7 @@ var DataTableSavedViews = (0, import_react18.forwardRef)((props, ref) => {
|
|
|
10697
10827
|
if (!internalTableConfig) {
|
|
10698
10828
|
return null;
|
|
10699
10829
|
}
|
|
10700
|
-
return /* @__PURE__ */
|
|
10830
|
+
return /* @__PURE__ */ import_react21.default.createElement(
|
|
10701
10831
|
SavedViews,
|
|
10702
10832
|
{
|
|
10703
10833
|
onSelect,
|