@omerdlw/base-framework 1.0.4 → 1.0.5

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/index.js CHANGED
@@ -8809,12 +8809,12 @@ var SurfaceHeaderActionStore = class {
8809
8809
  }
8810
8810
  subscribe = (listener) => this.store.subscribe(listener);
8811
8811
  getAction = (surfaceId) => {
8812
- const sId = surfaceId != null ? String(surfaceId) : "global";
8812
+ const sId = surfaceId != null ? String(surfaceId) : "active";
8813
8813
  const { actionsBySurface } = this.store.getSnapshot();
8814
- return actionsBySurface[sId] ?? actionsBySurface.global ?? null;
8814
+ return actionsBySurface[sId] ?? actionsBySurface.active ?? actionsBySurface.global ?? null;
8815
8815
  };
8816
8816
  setAction = (surfaceId, action) => {
8817
- const sId = surfaceId != null ? String(surfaceId) : "global";
8817
+ const sId = surfaceId != null ? String(surfaceId) : "active";
8818
8818
  const current = this.store.getSnapshot();
8819
8819
  if (current.actionsBySurface[sId] === action) return;
8820
8820
  this.store.setState({
@@ -8826,7 +8826,7 @@ var SurfaceHeaderActionStore = class {
8826
8826
  });
8827
8827
  };
8828
8828
  removeAction = (surfaceId) => {
8829
- const sId = surfaceId != null ? String(surfaceId) : "global";
8829
+ const sId = surfaceId != null ? String(surfaceId) : "active";
8830
8830
  const current = this.store.getSnapshot();
8831
8831
  if (!(sId in current.actionsBySurface)) return;
8832
8832
  const { [sId]: _, ...nextActions } = current.actionsBySurface;
@@ -8850,17 +8850,32 @@ var SurfaceExtensionsStore = class {
8850
8850
  this.store.setState((prev) => ({ version: prev.version + 1 }));
8851
8851
  };
8852
8852
  getExtensionsForSurface = (surfaceId) => {
8853
- const sId = surfaceId != null ? String(surfaceId) : "global";
8853
+ const sId = surfaceId != null ? String(surfaceId) : "active";
8854
8854
  if (this.cachedListBySurface.has(sId))
8855
8855
  return this.cachedListBySurface.get(sId);
8856
8856
  const globalExts = this.extensionsBySurface.get("global");
8857
- const surfaceExts = this.extensionsBySurface.get(sId);
8858
- if (!globalExts && !surfaceExts) {
8857
+ const activeExts = this.extensionsBySurface.get("active");
8858
+ const surfaceExts = sId !== "global" && sId !== "active" ? this.extensionsBySurface.get(sId) : void 0;
8859
+ let fallbackExts;
8860
+ if (!globalExts && !activeExts && !surfaceExts && this.extensionsBySurface.size > 0) {
8861
+ for (const map2 of this.extensionsBySurface.values()) {
8862
+ if (map2.size > 0) {
8863
+ fallbackExts = map2;
8864
+ break;
8865
+ }
8866
+ }
8867
+ }
8868
+ if (!globalExts && !activeExts && !surfaceExts && !fallbackExts) {
8859
8869
  const empty = [];
8860
8870
  this.cachedListBySurface.set(sId, empty);
8861
8871
  return empty;
8862
8872
  }
8863
- const merged = new Map([...globalExts || [], ...surfaceExts || []]);
8873
+ const merged = new Map([
8874
+ ...globalExts || [],
8875
+ ...activeExts || [],
8876
+ ...surfaceExts || [],
8877
+ ...fallbackExts || []
8878
+ ]);
8864
8879
  const result = Array.from(merged.values()).sort(
8865
8880
  (a, b) => a.order - b.order
8866
8881
  );
@@ -8871,7 +8886,7 @@ var SurfaceExtensionsStore = class {
8871
8886
  if (!extension) return;
8872
8887
  const normalized = normalizeSurfaceExtension(extension);
8873
8888
  if (!normalized) return;
8874
- const sId = surfaceId != null ? String(surfaceId) : "global";
8889
+ const sId = surfaceId != null ? String(surfaceId) : "active";
8875
8890
  let surfaceMap = this.extensionsBySurface.get(sId);
8876
8891
  if (!surfaceMap) {
8877
8892
  surfaceMap = /* @__PURE__ */ new Map();
@@ -8885,17 +8900,23 @@ var SurfaceExtensionsStore = class {
8885
8900
  };
8886
8901
  removeExtension = (surfaceId, extensionId) => {
8887
8902
  if (!extensionId) return;
8888
- const sId = surfaceId != null ? String(surfaceId) : "global";
8889
- const surfaceMap = this.extensionsBySurface.get(sId);
8890
- if (!surfaceMap || !surfaceMap.has(extensionId)) return;
8891
- surfaceMap.delete(extensionId);
8892
- if (surfaceMap.size === 0) this.extensionsBySurface.delete(sId);
8893
- this.notify();
8903
+ const sId = surfaceId != null ? String(surfaceId) : "active";
8904
+ let removed = false;
8905
+ for (const [key, map2] of this.extensionsBySurface.entries()) {
8906
+ if (key === sId || key === "active" || key === "global") {
8907
+ if (map2.has(extensionId)) {
8908
+ map2.delete(extensionId);
8909
+ if (map2.size === 0) this.extensionsBySurface.delete(key);
8910
+ removed = true;
8911
+ }
8912
+ }
8913
+ }
8914
+ if (removed) this.notify();
8894
8915
  };
8895
8916
  clearSurface = (surfaceId) => {
8896
- const sId = surfaceId != null ? String(surfaceId) : "global";
8897
- if (!this.extensionsBySurface.has(sId)) return;
8917
+ const sId = surfaceId != null ? String(surfaceId) : "active";
8898
8918
  this.extensionsBySurface.delete(sId);
8919
+ this.extensionsBySurface.delete("active");
8899
8920
  this.notify();
8900
8921
  };
8901
8922
  };
@@ -11626,7 +11647,7 @@ function useDockSurfaceControlsModel({
11626
11647
  const phase = propSurfacePhase ?? activeItem?.surfacePhase;
11627
11648
  const isBodyVisible = phase ? phase === DOCK_SURFACE_PHASE.EXPANDING_BODY || phase === DOCK_SURFACE_PHASE.OPEN : true;
11628
11649
  const actionStore = use(SurfaceExtensionsContext)?.headerActions ?? null;
11629
- const surfaceId = activeItem?.surfaceId || "global";
11650
+ const surfaceId = activeItem?.surfaceId || "active";
11630
11651
  const subscribeAction = useCallback(
11631
11652
  (onStoreChange) => actionStore ? actionStore.subscribe(onStoreChange) : () => {
11632
11653
  },
@@ -11654,7 +11675,7 @@ function SurfaceExtensionsProvider({
11654
11675
  }
11655
11676
  function useIsSurfaceExtensionsVisible(activeItem) {
11656
11677
  const store = use(SurfaceExtensionsContext)?.extensions ?? null;
11657
- const surfaceId = activeItem?.surfaceId || "global";
11678
+ const surfaceId = activeItem?.surfaceId || "active";
11658
11679
  const isSurface = Boolean(activeItem?.isSurface);
11659
11680
  const phase = activeItem?.surfacePhase;
11660
11681
  const isBodyVisible = phase === DOCK_SURFACE_PHASE.EXPANDING_BODY || phase === DOCK_SURFACE_PHASE.OPEN;
@@ -11680,7 +11701,7 @@ function useDockSurfaceExtensionsBarModel({
11680
11701
  activeItem
11681
11702
  }) {
11682
11703
  const store = use(SurfaceExtensionsContext)?.extensions ?? null;
11683
- const surfaceId = activeItem?.surfaceId || "global";
11704
+ const surfaceId = activeItem?.surfaceId || "active";
11684
11705
  const subscribe2 = useCallback(
11685
11706
  (onStoreChange) => store ? store.subscribe(onStoreChange) : () => {
11686
11707
  },