@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 +41 -20
- package/dist/index.js.map +1 -1
- package/dist/modules/dock/index.js +54 -24
- package/dist/modules/dock/index.js.map +1 -1
- package/dist/modules/dock/surface/context.d.ts.map +1 -1
- package/dist/modules/dock/surface/hooks.d.ts.map +1 -1
- package/dist/modules/dock/surface/stack.d.ts.map +1 -1
- package/dist/modules/index.js +41 -20
- package/dist/modules/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -635,12 +635,12 @@ var SurfaceHeaderActionStore = class {
|
|
|
635
635
|
}
|
|
636
636
|
subscribe = (listener) => this.store.subscribe(listener);
|
|
637
637
|
getAction = (surfaceId) => {
|
|
638
|
-
const sId = surfaceId != null ? String(surfaceId) : "
|
|
638
|
+
const sId = surfaceId != null ? String(surfaceId) : "active";
|
|
639
639
|
const { actionsBySurface } = this.store.getSnapshot();
|
|
640
|
-
return actionsBySurface[sId] ?? actionsBySurface.global ?? null;
|
|
640
|
+
return actionsBySurface[sId] ?? actionsBySurface.active ?? actionsBySurface.global ?? null;
|
|
641
641
|
};
|
|
642
642
|
setAction = (surfaceId, action) => {
|
|
643
|
-
const sId = surfaceId != null ? String(surfaceId) : "
|
|
643
|
+
const sId = surfaceId != null ? String(surfaceId) : "active";
|
|
644
644
|
const current = this.store.getSnapshot();
|
|
645
645
|
if (current.actionsBySurface[sId] === action) return;
|
|
646
646
|
this.store.setState({
|
|
@@ -652,7 +652,7 @@ var SurfaceHeaderActionStore = class {
|
|
|
652
652
|
});
|
|
653
653
|
};
|
|
654
654
|
removeAction = (surfaceId) => {
|
|
655
|
-
const sId = surfaceId != null ? String(surfaceId) : "
|
|
655
|
+
const sId = surfaceId != null ? String(surfaceId) : "active";
|
|
656
656
|
const current = this.store.getSnapshot();
|
|
657
657
|
if (!(sId in current.actionsBySurface)) return;
|
|
658
658
|
const { [sId]: _, ...nextActions } = current.actionsBySurface;
|
|
@@ -676,17 +676,32 @@ var SurfaceExtensionsStore = class {
|
|
|
676
676
|
this.store.setState((prev) => ({ version: prev.version + 1 }));
|
|
677
677
|
};
|
|
678
678
|
getExtensionsForSurface = (surfaceId) => {
|
|
679
|
-
const sId = surfaceId != null ? String(surfaceId) : "
|
|
679
|
+
const sId = surfaceId != null ? String(surfaceId) : "active";
|
|
680
680
|
if (this.cachedListBySurface.has(sId))
|
|
681
681
|
return this.cachedListBySurface.get(sId);
|
|
682
682
|
const globalExts = this.extensionsBySurface.get("global");
|
|
683
|
-
const
|
|
684
|
-
|
|
683
|
+
const activeExts = this.extensionsBySurface.get("active");
|
|
684
|
+
const surfaceExts = sId !== "global" && sId !== "active" ? this.extensionsBySurface.get(sId) : void 0;
|
|
685
|
+
let fallbackExts;
|
|
686
|
+
if (!globalExts && !activeExts && !surfaceExts && this.extensionsBySurface.size > 0) {
|
|
687
|
+
for (const map of this.extensionsBySurface.values()) {
|
|
688
|
+
if (map.size > 0) {
|
|
689
|
+
fallbackExts = map;
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
if (!globalExts && !activeExts && !surfaceExts && !fallbackExts) {
|
|
685
695
|
const empty = [];
|
|
686
696
|
this.cachedListBySurface.set(sId, empty);
|
|
687
697
|
return empty;
|
|
688
698
|
}
|
|
689
|
-
const merged = new Map([
|
|
699
|
+
const merged = new Map([
|
|
700
|
+
...globalExts || [],
|
|
701
|
+
...activeExts || [],
|
|
702
|
+
...surfaceExts || [],
|
|
703
|
+
...fallbackExts || []
|
|
704
|
+
]);
|
|
690
705
|
const result = Array.from(merged.values()).sort(
|
|
691
706
|
(a, b) => a.order - b.order
|
|
692
707
|
);
|
|
@@ -697,7 +712,7 @@ var SurfaceExtensionsStore = class {
|
|
|
697
712
|
if (!extension) return;
|
|
698
713
|
const normalized = normalizeSurfaceExtension(extension);
|
|
699
714
|
if (!normalized) return;
|
|
700
|
-
const sId = surfaceId != null ? String(surfaceId) : "
|
|
715
|
+
const sId = surfaceId != null ? String(surfaceId) : "active";
|
|
701
716
|
let surfaceMap = this.extensionsBySurface.get(sId);
|
|
702
717
|
if (!surfaceMap) {
|
|
703
718
|
surfaceMap = /* @__PURE__ */ new Map();
|
|
@@ -711,17 +726,23 @@ var SurfaceExtensionsStore = class {
|
|
|
711
726
|
};
|
|
712
727
|
removeExtension = (surfaceId, extensionId) => {
|
|
713
728
|
if (!extensionId) return;
|
|
714
|
-
const sId = surfaceId != null ? String(surfaceId) : "
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
729
|
+
const sId = surfaceId != null ? String(surfaceId) : "active";
|
|
730
|
+
let removed = false;
|
|
731
|
+
for (const [key, map] of this.extensionsBySurface.entries()) {
|
|
732
|
+
if (key === sId || key === "active" || key === "global") {
|
|
733
|
+
if (map.has(extensionId)) {
|
|
734
|
+
map.delete(extensionId);
|
|
735
|
+
if (map.size === 0) this.extensionsBySurface.delete(key);
|
|
736
|
+
removed = true;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
if (removed) this.notify();
|
|
720
741
|
};
|
|
721
742
|
clearSurface = (surfaceId) => {
|
|
722
|
-
const sId = surfaceId != null ? String(surfaceId) : "
|
|
723
|
-
if (!this.extensionsBySurface.has(sId)) return;
|
|
743
|
+
const sId = surfaceId != null ? String(surfaceId) : "active";
|
|
724
744
|
this.extensionsBySurface.delete(sId);
|
|
745
|
+
this.extensionsBySurface.delete("active");
|
|
725
746
|
this.notify();
|
|
726
747
|
};
|
|
727
748
|
};
|
|
@@ -4304,7 +4325,7 @@ function useDockSurfaceControlsModel({
|
|
|
4304
4325
|
const phase = propSurfacePhase ?? activeItem?.surfacePhase;
|
|
4305
4326
|
const isBodyVisible = phase ? phase === DOCK_SURFACE_PHASE.EXPANDING_BODY || phase === DOCK_SURFACE_PHASE.OPEN : true;
|
|
4306
4327
|
const actionStore = use(SurfaceExtensionsContext)?.headerActions ?? null;
|
|
4307
|
-
const surfaceId = activeItem?.surfaceId || "
|
|
4328
|
+
const surfaceId = activeItem?.surfaceId || "active";
|
|
4308
4329
|
const subscribeAction = useCallback(
|
|
4309
4330
|
(onStoreChange) => actionStore ? actionStore.subscribe(onStoreChange) : () => {
|
|
4310
4331
|
},
|
|
@@ -4342,26 +4363,35 @@ function useDockSurfaceExtension({
|
|
|
4342
4363
|
const surfaceId = useSurfaceId();
|
|
4343
4364
|
const generatedId = useId();
|
|
4344
4365
|
const effectiveId = id || `dock-surface-ext-${generatedId}`;
|
|
4345
|
-
|
|
4366
|
+
useIsomorphicLayoutEffect(() => {
|
|
4346
4367
|
if (!store) return;
|
|
4347
|
-
|
|
4368
|
+
const extension = {
|
|
4348
4369
|
align,
|
|
4349
4370
|
className,
|
|
4350
4371
|
content: children,
|
|
4351
4372
|
id: effectiveId,
|
|
4352
4373
|
order,
|
|
4353
4374
|
unstyled
|
|
4354
|
-
}
|
|
4375
|
+
};
|
|
4376
|
+
store.setExtension(surfaceId, extension);
|
|
4377
|
+
if (surfaceId && surfaceId !== "active") {
|
|
4378
|
+
store.setExtension("active", extension);
|
|
4379
|
+
}
|
|
4355
4380
|
});
|
|
4356
4381
|
useEffect(() => {
|
|
4357
4382
|
return () => {
|
|
4358
|
-
if (store)
|
|
4383
|
+
if (store) {
|
|
4384
|
+
store.removeExtension(surfaceId, effectiveId);
|
|
4385
|
+
if (surfaceId && surfaceId !== "active") {
|
|
4386
|
+
store.removeExtension("active", effectiveId);
|
|
4387
|
+
}
|
|
4388
|
+
}
|
|
4359
4389
|
};
|
|
4360
4390
|
}, [store, surfaceId, effectiveId]);
|
|
4361
4391
|
}
|
|
4362
4392
|
function useIsSurfaceExtensionsVisible(activeItem) {
|
|
4363
4393
|
const store = use(SurfaceExtensionsContext)?.extensions ?? null;
|
|
4364
|
-
const surfaceId = activeItem?.surfaceId || "
|
|
4394
|
+
const surfaceId = activeItem?.surfaceId || "active";
|
|
4365
4395
|
const isSurface = Boolean(activeItem?.isSurface);
|
|
4366
4396
|
const phase = activeItem?.surfacePhase;
|
|
4367
4397
|
const isBodyVisible = phase === DOCK_SURFACE_PHASE.EXPANDING_BODY || phase === DOCK_SURFACE_PHASE.OPEN;
|
|
@@ -4387,7 +4417,7 @@ function useDockSurfaceExtensionsBarModel({
|
|
|
4387
4417
|
activeItem
|
|
4388
4418
|
}) {
|
|
4389
4419
|
const store = use(SurfaceExtensionsContext)?.extensions ?? null;
|
|
4390
|
-
const surfaceId = activeItem?.surfaceId || "
|
|
4420
|
+
const surfaceId = activeItem?.surfaceId || "active";
|
|
4391
4421
|
const subscribe2 = useCallback(
|
|
4392
4422
|
(onStoreChange) => store ? store.subscribe(onStoreChange) : () => {
|
|
4393
4423
|
},
|