@procore/saved-views 6.0.0 → 6.0.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.
- 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/legacy/index.d.mts
CHANGED
|
@@ -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
|
|
80
|
+
tableApi?: TableApi;
|
|
80
81
|
defaultViews: IDataTableDefaultViewConfig[];
|
|
81
82
|
columnDefinitions: ColumnDefinition[];
|
|
82
83
|
}
|
package/dist/legacy/index.d.ts
CHANGED
|
@@ -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
|
|
80
|
+
tableApi?: TableApi;
|
|
80
81
|
defaultViews: IDataTableDefaultViewConfig[];
|
|
81
82
|
columnDefinitions: ColumnDefinition[];
|
|
82
83
|
}
|
package/dist/legacy/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
|
};
|
|
@@ -9183,7 +9219,6 @@ function setSmartGridConfig(api, config) {
|
|
|
9183
9219
|
});
|
|
9184
9220
|
api.setColumnGroupState(config.columnGroupState);
|
|
9185
9221
|
api.setRowGroupColumns(config.rowGroupState);
|
|
9186
|
-
api.setFilterModel(config.filterState);
|
|
9187
9222
|
if (config.rowHeight) {
|
|
9188
9223
|
api.setGridOption("rowHeight", config.rowHeight);
|
|
9189
9224
|
}
|
|
@@ -9227,6 +9262,7 @@ var getColumnIdentifier = (col) => {
|
|
|
9227
9262
|
return "";
|
|
9228
9263
|
};
|
|
9229
9264
|
var updateTableConfig = (view, tableApi, provider) => {
|
|
9265
|
+
var _a, _b, _c;
|
|
9230
9266
|
if (provider === "smart-grid") {
|
|
9231
9267
|
setSmartGridConfig(
|
|
9232
9268
|
tableApi,
|
|
@@ -9236,11 +9272,21 @@ var updateTableConfig = (view, tableApi, provider) => {
|
|
|
9236
9272
|
const dataTableApi = tableApi;
|
|
9237
9273
|
const tableConfig = view.table_config;
|
|
9238
9274
|
if (tableConfig) {
|
|
9239
|
-
const
|
|
9275
|
+
const currentTableConfig = (_a = dataTableApi == null ? void 0 : dataTableApi.getTableConfiguration) == null ? void 0 : _a.call(dataTableApi);
|
|
9276
|
+
const rowHeight = (tableConfig == null ? void 0 : tableConfig.rowHeight) ?? (currentTableConfig == null ? void 0 : currentTableConfig.rowHeight);
|
|
9277
|
+
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);
|
|
9278
|
+
const usesServerSideFiltering = hasServerFilters;
|
|
9240
9279
|
if (rowHeight !== void 0) {
|
|
9241
9280
|
dataTableApi == null ? void 0 : dataTableApi.setRowHeight(rowHeight);
|
|
9242
9281
|
}
|
|
9243
|
-
|
|
9282
|
+
if (usesServerSideFiltering) {
|
|
9283
|
+
dataTableApi == null ? void 0 : dataTableApi.setTableConfiguration({
|
|
9284
|
+
...tableConfig,
|
|
9285
|
+
filters: void 0
|
|
9286
|
+
});
|
|
9287
|
+
} else {
|
|
9288
|
+
dataTableApi == null ? void 0 : dataTableApi.setTableConfiguration(tableConfig);
|
|
9289
|
+
}
|
|
9244
9290
|
}
|
|
9245
9291
|
}
|
|
9246
9292
|
};
|
|
@@ -9605,7 +9651,7 @@ var PanelContent = (props) => {
|
|
|
9605
9651
|
|
|
9606
9652
|
// src/components/saved-views/SavedViews.tsx
|
|
9607
9653
|
var import_core_react15 = require("@procore/core-react");
|
|
9608
|
-
var
|
|
9654
|
+
var import_react15 = __toESM(require("react"));
|
|
9609
9655
|
var import_react_query3 = require("@tanstack/react-query");
|
|
9610
9656
|
var import_toast_alert3 = require("@procore/toast-alert");
|
|
9611
9657
|
|
|
@@ -10048,7 +10094,7 @@ var SharedViewFormModal = ({
|
|
|
10048
10094
|
};
|
|
10049
10095
|
|
|
10050
10096
|
// src/utils/hooks/useViewSelection.ts
|
|
10051
|
-
var
|
|
10097
|
+
var import_react13 = require("react");
|
|
10052
10098
|
var import_react_router_dom = require("react-router-dom");
|
|
10053
10099
|
var import_core_react14 = require("@procore/core-react");
|
|
10054
10100
|
|
|
@@ -10074,6 +10120,16 @@ var ViewStorage = {
|
|
|
10074
10120
|
}
|
|
10075
10121
|
};
|
|
10076
10122
|
|
|
10123
|
+
// src/utils/hooks/useLatest.ts
|
|
10124
|
+
var import_react12 = require("react");
|
|
10125
|
+
var useLatest = (callback) => {
|
|
10126
|
+
const ref = (0, import_react12.useRef)(callback);
|
|
10127
|
+
(0, import_react12.useLayoutEffect)(() => {
|
|
10128
|
+
ref.current = callback;
|
|
10129
|
+
});
|
|
10130
|
+
return (0, import_react12.useCallback)((...args) => ref.current(...args), []);
|
|
10131
|
+
};
|
|
10132
|
+
|
|
10077
10133
|
// src/utils/hooks/useViewSelection.ts
|
|
10078
10134
|
var isSmartGridConfig = (config) => {
|
|
10079
10135
|
return config != null && "rowGroupState" in config;
|
|
@@ -10125,31 +10181,31 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10125
10181
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
10126
10182
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
10127
10183
|
const [searchParams, setSearchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
10128
|
-
const previousSavedViewParamRef = (0,
|
|
10129
|
-
const [selectedSavedView, setSelectedSavedView] = (0,
|
|
10184
|
+
const previousSavedViewParamRef = (0, import_react13.useRef)(null);
|
|
10185
|
+
const [selectedSavedView, setSelectedSavedView] = (0, import_react13.useState)(() => {
|
|
10130
10186
|
const stored = ViewStorage.load(storageKey, config.defaultView);
|
|
10131
10187
|
return stored ?? config.defaultView;
|
|
10132
10188
|
});
|
|
10133
|
-
const [temporaryView, setTemporaryView] = (0,
|
|
10189
|
+
const [temporaryView, setTemporaryView] = (0, import_react13.useState)(() => {
|
|
10134
10190
|
const loaded = ViewStorage.load(temporaryStorageKey, config.defaultView);
|
|
10135
10191
|
return loaded && (loaded.id === "temporary" || loaded.view_level === "temporary") ? loaded : null;
|
|
10136
10192
|
});
|
|
10137
|
-
const persistViewToStorageAndUrl = (0,
|
|
10193
|
+
const persistViewToStorageAndUrl = (0, import_react13.useCallback)(
|
|
10138
10194
|
(view) => {
|
|
10139
10195
|
ViewStorage.save(storageKey, view);
|
|
10140
10196
|
setViewInUrl(view, setSearchParams);
|
|
10141
10197
|
},
|
|
10142
10198
|
[storageKey, setSearchParams]
|
|
10143
10199
|
);
|
|
10144
|
-
const baseViews = (0,
|
|
10200
|
+
const baseViews = (0, import_react13.useMemo)(
|
|
10145
10201
|
() => [...savedViews ?? [], ...presetViews ?? []],
|
|
10146
10202
|
[savedViews, presetViews]
|
|
10147
10203
|
);
|
|
10148
|
-
const allViews = (0,
|
|
10204
|
+
const allViews = (0, import_react13.useMemo)(
|
|
10149
10205
|
() => temporaryView ? [...baseViews, temporaryView] : baseViews,
|
|
10150
10206
|
[baseViews, temporaryView]
|
|
10151
10207
|
);
|
|
10152
|
-
const selectView = (0,
|
|
10208
|
+
const selectView = (0, import_react13.useCallback)(
|
|
10153
10209
|
(view) => {
|
|
10154
10210
|
const viewToSelect = config.onSelect({ item: view });
|
|
10155
10211
|
setSelectedSavedView(viewToSelect);
|
|
@@ -10158,7 +10214,7 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10158
10214
|
},
|
|
10159
10215
|
[config, persistViewToStorageAndUrl]
|
|
10160
10216
|
);
|
|
10161
|
-
const createTemporaryView = (0,
|
|
10217
|
+
const createTemporaryView = (0, import_react13.useCallback)(
|
|
10162
10218
|
(fetchedView) => {
|
|
10163
10219
|
const tempView = {
|
|
10164
10220
|
...fetchedView,
|
|
@@ -10173,30 +10229,27 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10173
10229
|
},
|
|
10174
10230
|
[temporaryStorageKey, selectView]
|
|
10175
10231
|
);
|
|
10176
|
-
const clearTemporaryView = (0,
|
|
10232
|
+
const clearTemporaryView = (0, import_react13.useCallback)(() => {
|
|
10177
10233
|
ViewStorage.remove(temporaryStorageKey);
|
|
10178
10234
|
setTemporaryView(null);
|
|
10179
10235
|
selectView(config.defaultView);
|
|
10180
10236
|
}, [temporaryStorageKey, config.defaultView, selectView]);
|
|
10181
|
-
const isViewAlreadySelected = (0,
|
|
10237
|
+
const isViewAlreadySelected = (0, import_react13.useCallback)(
|
|
10182
10238
|
(viewId) => checkIsViewSelected(selectedSavedView, viewId),
|
|
10183
10239
|
[selectedSavedView]
|
|
10184
10240
|
);
|
|
10185
|
-
const handleSavedViewFromUrl = (
|
|
10186
|
-
(viewId)
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
[isViewAlreadySelected, openSharedViewModal, allViews, selectView]
|
|
10198
|
-
);
|
|
10199
|
-
(0, import_react12.useEffect)(() => {
|
|
10241
|
+
const handleSavedViewFromUrl = useLatest((viewId) => {
|
|
10242
|
+
if (isViewAlreadySelected(viewId)) {
|
|
10243
|
+
return;
|
|
10244
|
+
}
|
|
10245
|
+
const viewInList = findViewByToken(allViews, viewId);
|
|
10246
|
+
if (viewInList) {
|
|
10247
|
+
selectView(viewInList);
|
|
10248
|
+
} else {
|
|
10249
|
+
openSharedViewModal(viewId);
|
|
10250
|
+
}
|
|
10251
|
+
});
|
|
10252
|
+
(0, import_react13.useEffect)(() => {
|
|
10200
10253
|
const savedViewId = searchParams.get("saved-view");
|
|
10201
10254
|
restoreUrlParameter(
|
|
10202
10255
|
savedViewId,
|
|
@@ -10210,14 +10263,14 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10210
10263
|
handleSavedViewFromUrl(savedViewId);
|
|
10211
10264
|
}
|
|
10212
10265
|
}, [searchParams, handleSavedViewFromUrl, allViews.length]);
|
|
10213
|
-
const previousRowGroupStateRef = (0,
|
|
10266
|
+
const previousRowGroupStateRef = (0, import_react13.useRef)(
|
|
10214
10267
|
isSmartGridConfig(tableConfig) ? tableConfig.rowGroupState : void 0
|
|
10215
10268
|
);
|
|
10216
|
-
const selectedViewRef = (0,
|
|
10269
|
+
const selectedViewRef = (0, import_react13.useRef)(selectedSavedView);
|
|
10217
10270
|
selectedViewRef.current = selectedSavedView;
|
|
10218
|
-
const defaultViewRef = (0,
|
|
10271
|
+
const defaultViewRef = (0, import_react13.useRef)(config.defaultView);
|
|
10219
10272
|
defaultViewRef.current = config.defaultView;
|
|
10220
|
-
(0,
|
|
10273
|
+
(0, import_react13.useEffect)(() => {
|
|
10221
10274
|
var _a;
|
|
10222
10275
|
if (!isSmartGridConfig(tableConfig) || !(presetViews == null ? void 0 : presetViews.length)) return;
|
|
10223
10276
|
const currentView = selectedViewRef.current;
|
|
@@ -10257,7 +10310,57 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10257
10310
|
};
|
|
10258
10311
|
};
|
|
10259
10312
|
|
|
10313
|
+
// src/components/saved-views/FocusScopeToggle.tsx
|
|
10314
|
+
var import_focus = require("@react-aria/focus");
|
|
10315
|
+
var import_react14 = require("react");
|
|
10316
|
+
var useFocusScopeToggle = (isOpen) => {
|
|
10317
|
+
const focusManager = (0, import_focus.useFocusManager)();
|
|
10318
|
+
const triggerRef = (0, import_react14.useRef)(null);
|
|
10319
|
+
const firstFocusedElementRef = (0, import_react14.useRef)(null);
|
|
10320
|
+
(0, import_react14.useEffect)(() => {
|
|
10321
|
+
var _a, _b;
|
|
10322
|
+
const handleKeyDown = (event) => {
|
|
10323
|
+
var _a2;
|
|
10324
|
+
if (!event.shiftKey || event.key !== "Tab") {
|
|
10325
|
+
return;
|
|
10326
|
+
}
|
|
10327
|
+
if (document.activeElement !== firstFocusedElementRef.current) {
|
|
10328
|
+
return;
|
|
10329
|
+
}
|
|
10330
|
+
event.preventDefault();
|
|
10331
|
+
(_a2 = triggerRef.current) == null ? void 0 : _a2.focus();
|
|
10332
|
+
};
|
|
10333
|
+
if (isOpen) {
|
|
10334
|
+
triggerRef.current = document.activeElement;
|
|
10335
|
+
focusManager == null ? void 0 : focusManager.focusFirst({ tabbable: true });
|
|
10336
|
+
firstFocusedElementRef.current = document.activeElement;
|
|
10337
|
+
(_a = firstFocusedElementRef.current) == null ? void 0 : _a.addEventListener(
|
|
10338
|
+
"keydown",
|
|
10339
|
+
handleKeyDown
|
|
10340
|
+
);
|
|
10341
|
+
} else {
|
|
10342
|
+
firstFocusedElementRef.current = null;
|
|
10343
|
+
const activeElement = document.activeElement;
|
|
10344
|
+
if (!activeElement || activeElement === document.body) {
|
|
10345
|
+
(_b = triggerRef.current) == null ? void 0 : _b.focus();
|
|
10346
|
+
}
|
|
10347
|
+
}
|
|
10348
|
+
return () => {
|
|
10349
|
+
var _a2;
|
|
10350
|
+
(_a2 = firstFocusedElementRef.current) == null ? void 0 : _a2.removeEventListener(
|
|
10351
|
+
"keydown",
|
|
10352
|
+
handleKeyDown
|
|
10353
|
+
);
|
|
10354
|
+
};
|
|
10355
|
+
}, [isOpen, focusManager]);
|
|
10356
|
+
};
|
|
10357
|
+
var FocusScopeToggle = ({ isOpen }) => {
|
|
10358
|
+
useFocusScopeToggle(isOpen);
|
|
10359
|
+
return null;
|
|
10360
|
+
};
|
|
10361
|
+
|
|
10260
10362
|
// src/components/saved-views/SavedViews.tsx
|
|
10363
|
+
var import_focus2 = require("@react-aria/focus");
|
|
10261
10364
|
var StyledPanel = pt.div`
|
|
10262
10365
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
10263
10366
|
`;
|
|
@@ -10274,13 +10377,13 @@ var SavedViewsContent = (props) => {
|
|
|
10274
10377
|
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
10275
10378
|
const { showToast } = (0, import_toast_alert3.useToastAlertContext)();
|
|
10276
10379
|
const i18n = (0, import_core_react15.useI18nContext)();
|
|
10277
|
-
const [activeModal, setActiveModal] = (0,
|
|
10278
|
-
const [modalData, setModalData] = (0,
|
|
10380
|
+
const [activeModal, setActiveModal] = (0, import_react15.useState)(null);
|
|
10381
|
+
const [modalData, setModalData] = (0, import_react15.useState)(null);
|
|
10279
10382
|
const openModal = (type, data) => {
|
|
10280
10383
|
setActiveModal(type);
|
|
10281
10384
|
setModalData(data ?? null);
|
|
10282
10385
|
};
|
|
10283
|
-
const closeModal = (0,
|
|
10386
|
+
const closeModal = (0, import_react15.useCallback)(() => {
|
|
10284
10387
|
setActiveModal(null);
|
|
10285
10388
|
setModalData(null);
|
|
10286
10389
|
}, []);
|
|
@@ -10320,7 +10423,7 @@ var SavedViewsContent = (props) => {
|
|
|
10320
10423
|
error: createError,
|
|
10321
10424
|
reset: resetCreateError
|
|
10322
10425
|
} = useCreateSavedView(queryInput);
|
|
10323
|
-
(0,
|
|
10426
|
+
(0, import_react15.useEffect)(() => {
|
|
10324
10427
|
if (fetchError) {
|
|
10325
10428
|
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
10326
10429
|
selectView(selectedView ?? props.defaultView);
|
|
@@ -10368,19 +10471,19 @@ var SavedViewsContent = (props) => {
|
|
|
10368
10471
|
deleteSelectedView();
|
|
10369
10472
|
closeModal();
|
|
10370
10473
|
};
|
|
10371
|
-
return /* @__PURE__ */
|
|
10474
|
+
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(
|
|
10372
10475
|
ExpandedPanel,
|
|
10373
10476
|
{
|
|
10374
10477
|
"data-testid": "saved-view-expanded-panel",
|
|
10375
10478
|
provider: props.provider
|
|
10376
10479
|
},
|
|
10377
|
-
/* @__PURE__ */
|
|
10480
|
+
/* @__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(
|
|
10378
10481
|
import_core_react15.Tooltip,
|
|
10379
10482
|
{
|
|
10380
10483
|
showDelay: 200,
|
|
10381
|
-
overlay: /* @__PURE__ */
|
|
10484
|
+
overlay: /* @__PURE__ */ import_react15.default.createElement(import_core_react15.Tooltip.Content, null, i18n.t("savedViews.tooltip"))
|
|
10382
10485
|
},
|
|
10383
|
-
/* @__PURE__ */
|
|
10486
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
10384
10487
|
Help_default,
|
|
10385
10488
|
{
|
|
10386
10489
|
tabIndex: 0,
|
|
@@ -10388,16 +10491,16 @@ var SavedViewsContent = (props) => {
|
|
|
10388
10491
|
"aria-label": i18n.t("savedViews.tooltip")
|
|
10389
10492
|
}
|
|
10390
10493
|
)
|
|
10391
|
-
))), /* @__PURE__ */
|
|
10494
|
+
))), /* @__PURE__ */ import_react15.default.createElement(
|
|
10392
10495
|
import_core_react15.Tooltip,
|
|
10393
10496
|
{
|
|
10394
10497
|
overlay: i18n.t("savedViews.actions.create"),
|
|
10395
10498
|
showDelay: 1e3
|
|
10396
10499
|
},
|
|
10397
|
-
/* @__PURE__ */
|
|
10500
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
10398
10501
|
import_core_react15.Button,
|
|
10399
10502
|
{
|
|
10400
|
-
icon: /* @__PURE__ */
|
|
10503
|
+
icon: /* @__PURE__ */ import_react15.default.createElement(Plus_default, null),
|
|
10401
10504
|
variant: "secondary",
|
|
10402
10505
|
"data-testid": "expanded-panel-create-button",
|
|
10403
10506
|
onClick: () => openModal("create" /* CREATE */),
|
|
@@ -10406,7 +10509,7 @@ var SavedViewsContent = (props) => {
|
|
|
10406
10509
|
i18n.t("savedViews.actions.create")
|
|
10407
10510
|
)
|
|
10408
10511
|
)),
|
|
10409
|
-
/* @__PURE__ */
|
|
10512
|
+
/* @__PURE__ */ import_react15.default.createElement(import_core_react15.Panel.Body, { style: { display: "flex", flexFlow: "column" } }, /* @__PURE__ */ import_react15.default.createElement(
|
|
10410
10513
|
PanelContent,
|
|
10411
10514
|
{
|
|
10412
10515
|
onSelect: ({ item }) => selectView(item),
|
|
@@ -10423,7 +10526,7 @@ var SavedViewsContent = (props) => {
|
|
|
10423
10526
|
onClearTemporary: clearTemporaryView
|
|
10424
10527
|
}
|
|
10425
10528
|
))
|
|
10426
|
-
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */
|
|
10529
|
+
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ import_react15.default.createElement(
|
|
10427
10530
|
FormModal,
|
|
10428
10531
|
{
|
|
10429
10532
|
open: true,
|
|
@@ -10437,14 +10540,14 @@ var SavedViewsContent = (props) => {
|
|
|
10437
10540
|
setOpenEditCreateModal: closeModal,
|
|
10438
10541
|
defaultView: props.defaultView
|
|
10439
10542
|
}
|
|
10440
|
-
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */
|
|
10543
|
+
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ import_react15.default.createElement(
|
|
10441
10544
|
SavedViewsDeleteConfirmationModalShared,
|
|
10442
10545
|
{
|
|
10443
10546
|
open: true,
|
|
10444
10547
|
onDelete: confirmDeleteAndCloseModal,
|
|
10445
10548
|
onCancel: closeModal
|
|
10446
10549
|
}
|
|
10447
|
-
), fetchedView && isModalOpen("sharedView" /* SHARED_VIEW */) && /* @__PURE__ */
|
|
10550
|
+
), fetchedView && isModalOpen("sharedView" /* SHARED_VIEW */) && /* @__PURE__ */ import_react15.default.createElement(
|
|
10448
10551
|
SharedViewFormModal,
|
|
10449
10552
|
{
|
|
10450
10553
|
open: true,
|
|
@@ -10456,17 +10559,17 @@ var SavedViewsContent = (props) => {
|
|
|
10456
10559
|
isCreating,
|
|
10457
10560
|
resetCreateError
|
|
10458
10561
|
}
|
|
10459
|
-
));
|
|
10562
|
+
)));
|
|
10460
10563
|
};
|
|
10461
10564
|
var SavedViews = (props) => {
|
|
10462
|
-
return /* @__PURE__ */
|
|
10565
|
+
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 }))));
|
|
10463
10566
|
};
|
|
10464
10567
|
|
|
10465
10568
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
10466
|
-
var
|
|
10569
|
+
var import_react19 = __toESM(require("react"));
|
|
10467
10570
|
|
|
10468
10571
|
// src/components/adapters/smart-grid/SmartGridDefaultSavedView.tsx
|
|
10469
|
-
var
|
|
10572
|
+
var import_react16 = require("react");
|
|
10470
10573
|
var DEFAULT_COLUMN_STATE = {
|
|
10471
10574
|
hide: false,
|
|
10472
10575
|
pinned: null,
|
|
@@ -10514,7 +10617,7 @@ var extractDefaultView = (gridApi, receivedConfig) => {
|
|
|
10514
10617
|
return result;
|
|
10515
10618
|
};
|
|
10516
10619
|
var useNormalizedDefaultViews = (defaultViews, gridApi) => {
|
|
10517
|
-
return (0,
|
|
10620
|
+
return (0, import_react16.useMemo)(() => {
|
|
10518
10621
|
if (!gridApi)
|
|
10519
10622
|
return defaultViews.map((view) => ({ ...view, share_token: view.id }));
|
|
10520
10623
|
return defaultViews.map((view) => ({
|
|
@@ -10526,7 +10629,7 @@ var useNormalizedDefaultViews = (defaultViews, gridApi) => {
|
|
|
10526
10629
|
};
|
|
10527
10630
|
|
|
10528
10631
|
// src/components/adapters/smart-grid/useSmartGridConfig.ts
|
|
10529
|
-
var
|
|
10632
|
+
var import_react17 = require("react");
|
|
10530
10633
|
var GRID_STATE_EVENTS = [
|
|
10531
10634
|
"sortChanged",
|
|
10532
10635
|
"filterOpened",
|
|
@@ -10542,10 +10645,10 @@ var GRID_STATE_EVENTS = [
|
|
|
10542
10645
|
"gridReady"
|
|
10543
10646
|
];
|
|
10544
10647
|
var useSmartGridConfig = (gridApi) => {
|
|
10545
|
-
const [config, setConfig] = (0,
|
|
10648
|
+
const [config, setConfig] = (0, import_react17.useState)(
|
|
10546
10649
|
() => getSmartGridConfig(gridApi)
|
|
10547
10650
|
);
|
|
10548
|
-
(0,
|
|
10651
|
+
(0, import_react17.useEffect)(() => {
|
|
10549
10652
|
if (!gridApi) return;
|
|
10550
10653
|
const updateConfig = () => {
|
|
10551
10654
|
setConfig(getSmartGridConfig(gridApi));
|
|
@@ -10562,19 +10665,48 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
10562
10665
|
return { config, setConfig };
|
|
10563
10666
|
};
|
|
10564
10667
|
|
|
10668
|
+
// src/components/adapters/smart-grid/useSavedViewsPanelOpen.ts
|
|
10669
|
+
var import_react18 = require("react");
|
|
10670
|
+
var SAVED_VIEWS_PANEL_ID = "savedViews";
|
|
10671
|
+
var useSavedViewsPanelOpen = (gridApi) => {
|
|
10672
|
+
var _a;
|
|
10673
|
+
const [isOpen, setIsOpen] = (0, import_react18.useState)(
|
|
10674
|
+
((_a = gridApi.getOpenedToolPanel) == null ? void 0 : _a.call(gridApi)) === SAVED_VIEWS_PANEL_ID
|
|
10675
|
+
);
|
|
10676
|
+
(0, import_react18.useEffect)(() => {
|
|
10677
|
+
var _a2;
|
|
10678
|
+
const syncOpenState = () => {
|
|
10679
|
+
var _a3;
|
|
10680
|
+
setIsOpen(((_a3 = gridApi.getOpenedToolPanel) == null ? void 0 : _a3.call(gridApi)) === SAVED_VIEWS_PANEL_ID);
|
|
10681
|
+
};
|
|
10682
|
+
syncOpenState();
|
|
10683
|
+
(_a2 = gridApi.addEventListener) == null ? void 0 : _a2.call(gridApi, "toolPanelVisibleChanged", syncOpenState);
|
|
10684
|
+
return () => {
|
|
10685
|
+
var _a3;
|
|
10686
|
+
(_a3 = gridApi.removeEventListener) == null ? void 0 : _a3.call(gridApi, "toolPanelVisibleChanged", syncOpenState);
|
|
10687
|
+
};
|
|
10688
|
+
}, [gridApi]);
|
|
10689
|
+
return isOpen;
|
|
10690
|
+
};
|
|
10691
|
+
|
|
10565
10692
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
10566
10693
|
var SmartGridSavedViews = (props) => {
|
|
10567
10694
|
const { gridApi, userId, projectId, companyId } = props;
|
|
10568
10695
|
const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
|
|
10696
|
+
const isPanelOpen = useSavedViewsPanelOpen(gridApi);
|
|
10569
10697
|
const presetViews = useNormalizedDefaultViews(props.defaultViews, gridApi);
|
|
10570
10698
|
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
10571
|
-
const onSelect = (0,
|
|
10699
|
+
const onSelect = (0, import_react19.useCallback)(
|
|
10572
10700
|
({ item }) => {
|
|
10701
|
+
var _a;
|
|
10573
10702
|
if (!gridApi) return item;
|
|
10574
10703
|
const isPresetView = item.view_level === "default";
|
|
10575
10704
|
if (isPresetView) {
|
|
10576
10705
|
updateTableConfig(item, gridApi, "smart-grid");
|
|
10577
|
-
setTableConfig(
|
|
10706
|
+
setTableConfig({
|
|
10707
|
+
...item.table_config,
|
|
10708
|
+
filterState: ((_a = gridApi.getFilterModel) == null ? void 0 : _a.call(gridApi)) ?? {}
|
|
10709
|
+
});
|
|
10578
10710
|
return item;
|
|
10579
10711
|
}
|
|
10580
10712
|
const updatedView = {
|
|
@@ -10585,12 +10717,14 @@ var SmartGridSavedViews = (props) => {
|
|
|
10585
10717
|
)
|
|
10586
10718
|
};
|
|
10587
10719
|
updateTableConfig(updatedView, gridApi, "smart-grid");
|
|
10588
|
-
|
|
10720
|
+
const updatedConfig = updatedView.table_config;
|
|
10721
|
+
gridApi.setFilterModel(updatedConfig.filterState ?? {});
|
|
10722
|
+
setTableConfig(updatedConfig);
|
|
10589
10723
|
return updatedView;
|
|
10590
10724
|
},
|
|
10591
10725
|
[gridApi, tableConfig, setTableConfig]
|
|
10592
10726
|
);
|
|
10593
|
-
return /* @__PURE__ */
|
|
10727
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
10594
10728
|
SavedViews,
|
|
10595
10729
|
{
|
|
10596
10730
|
onSelect,
|
|
@@ -10602,16 +10736,17 @@ var SmartGridSavedViews = (props) => {
|
|
|
10602
10736
|
defaultView,
|
|
10603
10737
|
presetViews,
|
|
10604
10738
|
tableName: props.tableName,
|
|
10605
|
-
tableConfig
|
|
10739
|
+
tableConfig,
|
|
10740
|
+
isPanelOpen
|
|
10606
10741
|
}
|
|
10607
10742
|
);
|
|
10608
10743
|
};
|
|
10609
10744
|
|
|
10610
10745
|
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
10611
|
-
var
|
|
10746
|
+
var import_react21 = __toESM(require("react"));
|
|
10612
10747
|
|
|
10613
10748
|
// src/components/adapters/data-table/DataTableDefaultSavedView.tsx
|
|
10614
|
-
var
|
|
10749
|
+
var import_react20 = require("react");
|
|
10615
10750
|
var DEFAULT_COLUMN_STATE2 = {
|
|
10616
10751
|
hidden: false,
|
|
10617
10752
|
pinned: null,
|
|
@@ -10659,7 +10794,7 @@ var extractDefaultView2 = (columnDefinitions, receivedConfigFromTool) => {
|
|
|
10659
10794
|
return result;
|
|
10660
10795
|
};
|
|
10661
10796
|
var useNormalizedDefaultViews2 = (defaultViews, columnDefinitions) => {
|
|
10662
|
-
return (0,
|
|
10797
|
+
return (0, import_react20.useMemo)(
|
|
10663
10798
|
() => defaultViews.map((view) => ({
|
|
10664
10799
|
...view,
|
|
10665
10800
|
share_token: view.id,
|
|
@@ -10670,32 +10805,37 @@ var useNormalizedDefaultViews2 = (defaultViews, columnDefinitions) => {
|
|
|
10670
10805
|
};
|
|
10671
10806
|
|
|
10672
10807
|
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
10673
|
-
var DataTableSavedViews = (0,
|
|
10808
|
+
var DataTableSavedViews = (0, import_react21.forwardRef)((props, ref) => {
|
|
10674
10809
|
const { tableApi, userId, projectId, companyId } = props;
|
|
10675
10810
|
const presetViews = useNormalizedDefaultViews2(
|
|
10676
10811
|
props.defaultViews,
|
|
10677
10812
|
props.columnDefinitions
|
|
10678
10813
|
);
|
|
10679
10814
|
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
10680
|
-
const [internalTableConfig, setInternalTableConfig] = (0,
|
|
10815
|
+
const [internalTableConfig, setInternalTableConfig] = (0, import_react21.useState)(
|
|
10681
10816
|
ViewStorage.load(props.stickyViewsKey, defaultView).table_config
|
|
10682
10817
|
);
|
|
10683
|
-
(0,
|
|
10818
|
+
(0, import_react21.useImperativeHandle)(ref, () => ({
|
|
10684
10819
|
setTableConfig: (newConfig) => {
|
|
10685
10820
|
setInternalTableConfig(newConfig);
|
|
10686
10821
|
}
|
|
10687
10822
|
}));
|
|
10688
|
-
const onSelect = (0,
|
|
10823
|
+
const onSelect = (0, import_react21.useCallback)(
|
|
10689
10824
|
({ item }) => {
|
|
10825
|
+
var _a;
|
|
10690
10826
|
const isPresetView = item.view_level === "default";
|
|
10827
|
+
const syncReferenceConfig = ((_a = tableApi == null ? void 0 : tableApi.getTableConfiguration) == null ? void 0 : _a.call(tableApi)) ?? defaultView.table_config;
|
|
10828
|
+
const syncedConfig = isPresetView ? item.table_config : customAndConfigSync(
|
|
10829
|
+
item.table_config,
|
|
10830
|
+
syncReferenceConfig
|
|
10831
|
+
);
|
|
10691
10832
|
const updatedView = isPresetView ? item : {
|
|
10692
10833
|
...item,
|
|
10693
|
-
table_config:
|
|
10694
|
-
item.table_config,
|
|
10695
|
-
defaultView.table_config
|
|
10696
|
-
)
|
|
10834
|
+
table_config: syncedConfig
|
|
10697
10835
|
};
|
|
10698
|
-
|
|
10836
|
+
if (tableApi) {
|
|
10837
|
+
updateTableConfig(updatedView, tableApi, "data-table");
|
|
10838
|
+
}
|
|
10699
10839
|
setInternalTableConfig(updatedView.table_config);
|
|
10700
10840
|
return updatedView;
|
|
10701
10841
|
},
|
|
@@ -10704,7 +10844,7 @@ var DataTableSavedViews = (0, import_react18.forwardRef)((props, ref) => {
|
|
|
10704
10844
|
if (!internalTableConfig) {
|
|
10705
10845
|
return null;
|
|
10706
10846
|
}
|
|
10707
|
-
return /* @__PURE__ */
|
|
10847
|
+
return /* @__PURE__ */ import_react21.default.createElement(
|
|
10708
10848
|
SavedViews,
|
|
10709
10849
|
{
|
|
10710
10850
|
onSelect,
|