@open-mercato/ui 0.6.7-develop.6758.1.697eade236 → 0.6.7-develop.6768.1.9d2c4efc43

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.
@@ -46,6 +46,7 @@ import { useT } from "@open-mercato/shared/lib/i18n/context";
46
46
  import { flash } from "./FlashMessages.js";
47
47
  import { useConfirmDialog } from "./confirm-dialog/index.js";
48
48
  import { ComponentReplacementHandles } from "@open-mercato/shared/modules/widgets/component-registry";
49
+ import { dataTableExtensionSpotId, extensionSpotChildId } from "@open-mercato/shared/modules/widgets/extension-points";
49
50
  import { insertByInjectionPlacement } from "@open-mercato/shared/modules/widgets/injection-position";
50
51
  import { useVirtualizer } from "@tanstack/react-virtual";
51
52
  import { getDefaultOperator, isAdvancedFilterState, flatToTree } from "@open-mercato/shared/lib/query/advanced-filter";
@@ -255,6 +256,32 @@ function writePerspectiveSnapshot(tableId, snapshot) {
255
256
  }
256
257
  writeVersionedPreference(key, PERSPECTIVE_SNAPSHOT_VERSION, snapshot);
257
258
  }
259
+ function clearAllPerspectiveState() {
260
+ if (typeof window !== "undefined") {
261
+ try {
262
+ const storage = window.localStorage;
263
+ const staleKeys = [];
264
+ for (let index = 0; index < storage.length; index += 1) {
265
+ const key = storage.key(index);
266
+ if (key && key.startsWith(`${PERSPECTIVE_STORAGE_PREFIX}:`)) staleKeys.push(key);
267
+ }
268
+ for (const key of staleKeys) storage.removeItem(key);
269
+ } catch {
270
+ }
271
+ }
272
+ if (typeof document !== "undefined") {
273
+ try {
274
+ const cookies = document.cookie ? document.cookie.split(";") : [];
275
+ for (const cookie of cookies) {
276
+ const name = cookie.split("=")[0]?.trim();
277
+ if (name && name.startsWith(`${PERSPECTIVE_COOKIE_PREFIX}:`)) {
278
+ document.cookie = `${name}=; Path=/; Max-Age=0; SameSite=Lax`;
279
+ }
280
+ }
281
+ } catch {
282
+ }
283
+ }
284
+ }
258
285
  function sanitizePerspectiveSettings(source) {
259
286
  if (!source || typeof source !== "object") return null;
260
287
  const forbidden = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
@@ -932,7 +959,7 @@ function DataTable({
932
959
  if (injectionSpotId?.startsWith("data-table:")) return injectionSpotId.slice("data-table:".length);
933
960
  return null;
934
961
  }, [injectionSpotId, perspective?.tableId, extensionTableIdProp]);
935
- const resolvedInjectionSpotId = injectionSpotId ?? (perspective?.tableId ? `data-table:${perspective.tableId}` : null) ?? (extensionTableIdProp ? `data-table:${extensionTableIdProp}` : null);
962
+ const resolvedInjectionSpotId = injectionSpotId ?? (perspective?.tableId ? dataTableExtensionSpotId(perspective.tableId) : null) ?? (extensionTableIdProp ? dataTableExtensionSpotId(extensionTableIdProp) : null);
936
963
  const resolvedReplacementHandle = replacementHandle ?? ComponentReplacementHandles.dataTable(extensionTableId ?? "unknown");
937
964
  const baseInjectionContext = React.useMemo(
938
965
  () => {
@@ -944,32 +971,32 @@ function DataTable({
944
971
  [injectionContext, perspective?.tableId, extensionTableId, title]
945
972
  );
946
973
  const headerInjectionSpotId = React.useMemo(
947
- () => resolvedInjectionSpotId ? `${resolvedInjectionSpotId}:header` : null,
974
+ () => resolvedInjectionSpotId ? extensionSpotChildId(resolvedInjectionSpotId, "header") : null,
948
975
  [resolvedInjectionSpotId]
949
976
  );
950
977
  const toolbarInjectionSpotId = React.useMemo(
951
- () => resolvedInjectionSpotId ? `${resolvedInjectionSpotId}:toolbar` : null,
978
+ () => resolvedInjectionSpotId ? extensionSpotChildId(resolvedInjectionSpotId, "toolbar") : null,
952
979
  [resolvedInjectionSpotId]
953
980
  );
954
981
  const searchTrailingInjectionSpotId = React.useMemo(
955
- () => resolvedInjectionSpotId ? `${resolvedInjectionSpotId}:search-trailing` : null,
982
+ () => resolvedInjectionSpotId ? extensionSpotChildId(resolvedInjectionSpotId, "search-trailing") : null,
956
983
  [resolvedInjectionSpotId]
957
984
  );
958
985
  const footerInjectionSpotId = React.useMemo(
959
- () => resolvedInjectionSpotId ? `${resolvedInjectionSpotId}:footer` : null,
986
+ () => resolvedInjectionSpotId ? extensionSpotChildId(resolvedInjectionSpotId, "footer") : null,
960
987
  [resolvedInjectionSpotId]
961
988
  );
962
989
  const { widgets: columnWidgets } = useInjectionDataWidgets(
963
- extensionTableId ? `data-table:${extensionTableId}:columns` : "__disabled__:columns"
990
+ extensionTableId ? dataTableExtensionSpotId(extensionTableId, "columns") : "__disabled__:columns"
964
991
  );
965
992
  const { widgets: rowActionWidgets } = useInjectionDataWidgets(
966
- extensionTableId ? `data-table:${extensionTableId}:row-actions` : "__disabled__:row-actions"
993
+ extensionTableId ? dataTableExtensionSpotId(extensionTableId, "row-actions") : "__disabled__:row-actions"
967
994
  );
968
995
  const { widgets: bulkActionWidgets } = useInjectionDataWidgets(
969
- extensionTableId ? `data-table:${extensionTableId}:bulk-actions` : "__disabled__:bulk-actions"
996
+ extensionTableId ? dataTableExtensionSpotId(extensionTableId, "bulk-actions") : "__disabled__:bulk-actions"
970
997
  );
971
998
  const { widgets: filterWidgets } = useInjectionDataWidgets(
972
- extensionTableId ? `data-table:${extensionTableId}:filters` : "__disabled__:filters"
999
+ extensionTableId ? dataTableExtensionSpotId(extensionTableId, "filters") : "__disabled__:filters"
973
1000
  );
974
1001
  const injectedColumnDefs = React.useMemo(() => {
975
1002
  const entries = [];
@@ -2555,6 +2582,7 @@ function DataTable({
2555
2582
  }
2556
2583
  export {
2557
2584
  DataTable,
2585
+ clearAllPerspectiveState,
2558
2586
  readPerspectiveSnapshot,
2559
2587
  sanitizePerspectiveSettings,
2560
2588
  withDataTableNamespaces,