@forgeax/app-shell 0.40.0 → 0.41.0
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/react.d.ts +22 -1
- package/dist/react.js +72 -4
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -10,6 +10,27 @@ declare function isSlotDebugEnabled(search?: string): boolean;
|
|
|
10
10
|
/** Dev-time visualization derived only from live `data-fx-slot` markers. */
|
|
11
11
|
declare function SlotDebugOverlay(): ReactElement;
|
|
12
12
|
|
|
13
|
+
interface PersistentSizeStorage {
|
|
14
|
+
getItem(key: string): string | null;
|
|
15
|
+
setItem(key: string, value: string): void;
|
|
16
|
+
}
|
|
17
|
+
interface PersistentSizeStoreOptions {
|
|
18
|
+
storageKey: string;
|
|
19
|
+
defaultSize: number;
|
|
20
|
+
minSize: number;
|
|
21
|
+
maxSize: number;
|
|
22
|
+
storage?: PersistentSizeStorage | null;
|
|
23
|
+
}
|
|
24
|
+
type PersistentSizeUpdate = number | ((previous: number) => number);
|
|
25
|
+
interface PersistentSizeStore {
|
|
26
|
+
getSnapshot(): number;
|
|
27
|
+
subscribe(listener: () => void): () => void;
|
|
28
|
+
setSize(next: PersistentSizeUpdate): void;
|
|
29
|
+
reload(): void;
|
|
30
|
+
}
|
|
31
|
+
/** Product-neutral persistent numeric state for resizable shell regions. */
|
|
32
|
+
declare function createPersistentSizeStore(options: PersistentSizeStoreOptions): PersistentSizeStore;
|
|
33
|
+
declare function usePersistentSizeStore(store: PersistentSizeStore): number;
|
|
13
34
|
declare function useLocalSize(key: string, initial: number, min: number, max: number): readonly [number, (next: number | ((previous: number) => number)) => void];
|
|
14
35
|
interface ResizeHandleProps {
|
|
15
36
|
orientation: 'col' | 'row';
|
|
@@ -181,4 +202,4 @@ interface ShellSlotProps extends HTMLAttributes<HTMLElement> {
|
|
|
181
202
|
/** Structural shell marker that preserves the caller's semantic element. */
|
|
182
203
|
declare function ShellSlot({ as, name, ...props }: ShellSlotProps): ReactElement;
|
|
183
204
|
|
|
184
|
-
export { type AnchoredResizeDirection, AnchoredResizeHandle, type AnchoredResizeHandleProps, type AnchoredResizeSession, DetachedPanelBoundary, type DetachedPanelBoundaryProps, DetachedSurfaceFrame, type DetachedSurfaceFrameProps, DetachedSurfaceStatus, type DetachedSurfaceStatusProps, type DetachedSurfaceStatusTone, type DockLayoutControlBinding, type DockLayoutControlBindingOptions, DockLayoutMenu, type DockLayoutMenuPanel, type DockLayoutMenuProps, FloatingMenu, type FloatingMenuAnchor, type FloatingMenuPoint, type FloatingMenuProps, type PanelContentPadding, type PanelContentPolicy, type PanelContentScroll, type PanelContentTone, PanelEmptyState, type PanelEmptyStateProps, PanelSurface, type PanelSurfaceProps, ResizeHandle, type ResizeHandleProps, ShellSlot, type ShellSlotElement, type ShellSlotProps, SlotDebugOverlay, SurfacePlaceholder, type SurfacePlaceholderProps, SurfaceRegion, type SurfaceRegionProps, applyAnchoredResizeDelta, beginAnchoredResize, hashSlotHue, isSlotDebugEnabled, useDockLayoutControlBinding, useLocalSize };
|
|
205
|
+
export { type AnchoredResizeDirection, AnchoredResizeHandle, type AnchoredResizeHandleProps, type AnchoredResizeSession, DetachedPanelBoundary, type DetachedPanelBoundaryProps, DetachedSurfaceFrame, type DetachedSurfaceFrameProps, DetachedSurfaceStatus, type DetachedSurfaceStatusProps, type DetachedSurfaceStatusTone, type DockLayoutControlBinding, type DockLayoutControlBindingOptions, DockLayoutMenu, type DockLayoutMenuPanel, type DockLayoutMenuProps, FloatingMenu, type FloatingMenuAnchor, type FloatingMenuPoint, type FloatingMenuProps, type PanelContentPadding, type PanelContentPolicy, type PanelContentScroll, type PanelContentTone, PanelEmptyState, type PanelEmptyStateProps, PanelSurface, type PanelSurfaceProps, type PersistentSizeStorage, type PersistentSizeStore, type PersistentSizeStoreOptions, type PersistentSizeUpdate, ResizeHandle, type ResizeHandleProps, ShellSlot, type ShellSlotElement, type ShellSlotProps, SlotDebugOverlay, SurfacePlaceholder, type SurfacePlaceholderProps, SurfaceRegion, type SurfaceRegionProps, applyAnchoredResizeDelta, beginAnchoredResize, createPersistentSizeStore, hashSlotHue, isSlotDebugEnabled, useDockLayoutControlBinding, useLocalSize, usePersistentSizeStore };
|
package/dist/react.js
CHANGED
|
@@ -595,8 +595,74 @@ function SlotDebugOverlay() {
|
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
// src/resize.tsx
|
|
598
|
-
import { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
598
|
+
import { useEffect as useEffect2, useRef, useState as useState2, useSyncExternalStore } from "react";
|
|
599
599
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
600
|
+
function browserPersistentSizeStorage() {
|
|
601
|
+
if (typeof window === "undefined") return null;
|
|
602
|
+
try {
|
|
603
|
+
return window.localStorage;
|
|
604
|
+
} catch {
|
|
605
|
+
return null;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
function createPersistentSizeStore(options) {
|
|
609
|
+
const minSize = Math.min(options.minSize, options.maxSize);
|
|
610
|
+
const maxSize = Math.max(options.minSize, options.maxSize);
|
|
611
|
+
const normalize = (value2, fallback) => {
|
|
612
|
+
if (!Number.isFinite(value2)) return fallback;
|
|
613
|
+
return Math.min(maxSize, Math.max(minSize, Math.round(value2)));
|
|
614
|
+
};
|
|
615
|
+
const defaultSize = normalize(options.defaultSize, minSize);
|
|
616
|
+
const storage = options.storage === void 0 ? browserPersistentSizeStorage() : options.storage;
|
|
617
|
+
const read = () => {
|
|
618
|
+
try {
|
|
619
|
+
const raw = storage?.getItem(options.storageKey);
|
|
620
|
+
if (!raw) return defaultSize;
|
|
621
|
+
const parsed = Number.parseInt(raw, 10);
|
|
622
|
+
return normalize(parsed, defaultSize);
|
|
623
|
+
} catch {
|
|
624
|
+
return defaultSize;
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
let value = read();
|
|
628
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
629
|
+
const commit = (next) => {
|
|
630
|
+
if (Object.is(value, next)) return;
|
|
631
|
+
value = next;
|
|
632
|
+
for (const listener of [...listeners]) {
|
|
633
|
+
try {
|
|
634
|
+
listener();
|
|
635
|
+
} catch {
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
return {
|
|
640
|
+
getSnapshot: () => value,
|
|
641
|
+
subscribe: (listener) => {
|
|
642
|
+
listeners.add(listener);
|
|
643
|
+
let active = true;
|
|
644
|
+
return () => {
|
|
645
|
+
if (!active) return;
|
|
646
|
+
active = false;
|
|
647
|
+
listeners.delete(listener);
|
|
648
|
+
};
|
|
649
|
+
},
|
|
650
|
+
setSize: (next) => {
|
|
651
|
+
const candidate = typeof next === "function" ? next(value) : next;
|
|
652
|
+
const normalized = normalize(candidate, value);
|
|
653
|
+
if (Object.is(value, normalized)) return;
|
|
654
|
+
try {
|
|
655
|
+
storage?.setItem(options.storageKey, String(normalized));
|
|
656
|
+
} catch {
|
|
657
|
+
}
|
|
658
|
+
commit(normalized);
|
|
659
|
+
},
|
|
660
|
+
reload: () => commit(read())
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
function usePersistentSizeStore(store) {
|
|
664
|
+
return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
665
|
+
}
|
|
600
666
|
function useLocalSize(key, initial, min, max) {
|
|
601
667
|
const clamp = (value2) => Math.min(max, Math.max(min, value2));
|
|
602
668
|
const [value, setValueRaw] = useState2(() => {
|
|
@@ -944,7 +1010,7 @@ var SurfaceRegion = forwardRef(
|
|
|
944
1010
|
);
|
|
945
1011
|
|
|
946
1012
|
// src/dock-layout-control.ts
|
|
947
|
-
import { useEffect as useEffect3, useMemo, useSyncExternalStore } from "react";
|
|
1013
|
+
import { useEffect as useEffect3, useMemo, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
948
1014
|
function useDockLayoutControlBinding({
|
|
949
1015
|
state,
|
|
950
1016
|
onToggle,
|
|
@@ -952,7 +1018,7 @@ function useDockLayoutControlBinding({
|
|
|
952
1018
|
closePanel,
|
|
953
1019
|
reopenPanel
|
|
954
1020
|
}) {
|
|
955
|
-
const snapshot =
|
|
1021
|
+
const snapshot = useSyncExternalStore2(
|
|
956
1022
|
state.subscribe,
|
|
957
1023
|
state.getSnapshot,
|
|
958
1024
|
state.getSnapshot
|
|
@@ -1167,10 +1233,12 @@ export {
|
|
|
1167
1233
|
SurfaceRegion,
|
|
1168
1234
|
applyAnchoredResizeDelta,
|
|
1169
1235
|
beginAnchoredResize,
|
|
1236
|
+
createPersistentSizeStore,
|
|
1170
1237
|
hashSlotHue,
|
|
1171
1238
|
isSlotDebugEnabled,
|
|
1172
1239
|
useDockLayoutControlBinding,
|
|
1173
|
-
useLocalSize
|
|
1240
|
+
useLocalSize,
|
|
1241
|
+
usePersistentSizeStore
|
|
1174
1242
|
};
|
|
1175
1243
|
/*! Bundled license information:
|
|
1176
1244
|
|