ai-design-system 0.1.13 → 0.1.14
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/components/composites/AdjustableLayout/AdjustableLayout.tsx +23 -20
- package/dist/index.cjs +19 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -53,28 +53,31 @@ export const AdjustableLayout = React.memo<AdjustableLayoutProps>(
|
|
|
53
53
|
muted: "group-hover:bg-muted/30"
|
|
54
54
|
}
|
|
55
55
|
const containerRef = React.useRef<HTMLDivElement>(null)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
|
|
57
|
+
// Compute default sizes (server-safe — no localStorage access)
|
|
58
|
+
const defaultSizes = React.useMemo(() => {
|
|
59
|
+
const raw = sections.map(section => section.defaultSize ?? (100 / sections.length))
|
|
60
|
+
const total = raw.reduce((sum, size) => sum + size, 0)
|
|
61
|
+
return raw.map(size => (size / total) * 100)
|
|
62
|
+
}, [sections])
|
|
63
|
+
|
|
64
|
+
const [sizes, setSizes] = React.useState<number[]>(defaultSizes)
|
|
65
|
+
|
|
66
|
+
// After hydration, overwrite with persisted sizes if available
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
if (!storageKey) return
|
|
69
|
+
const saved = localStorage.getItem(storageKey)
|
|
70
|
+
if (!saved) return
|
|
71
|
+
try {
|
|
72
|
+
const parsed: number[] = JSON.parse(saved)
|
|
73
|
+
if (Array.isArray(parsed) && parsed.length === sections.length) {
|
|
74
|
+
setSizes(parsed)
|
|
66
75
|
}
|
|
76
|
+
} catch {
|
|
77
|
+
// ignore malformed storage
|
|
67
78
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const defaultSizes = sections.map(section =>
|
|
71
|
-
section.defaultSize ?? (100 / sections.length)
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
// Normalize to 100%
|
|
75
|
-
const total = defaultSizes.reduce((sum, size) => sum + size, 0)
|
|
76
|
-
return defaultSizes.map(size => (size / total) * 100)
|
|
77
|
-
})
|
|
79
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
+
}, [storageKey])
|
|
78
81
|
|
|
79
82
|
const [draggingIndex, setDraggingIndex] = React.useState<number | null>(null)
|
|
80
83
|
const [startX, setStartX] = React.useState(0)
|
package/dist/index.cjs
CHANGED
|
@@ -6797,25 +6797,27 @@ var AdjustableLayout = React33__namespace.memo(
|
|
|
6797
6797
|
muted: "group-hover:bg-muted/30"
|
|
6798
6798
|
};
|
|
6799
6799
|
const containerRef = React33__namespace.useRef(null);
|
|
6800
|
-
const
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6800
|
+
const defaultSizes = React33__namespace.useMemo(() => {
|
|
6801
|
+
const raw = sections.map((section) => {
|
|
6802
|
+
var _a2;
|
|
6803
|
+
return (_a2 = section.defaultSize) != null ? _a2 : 100 / sections.length;
|
|
6804
|
+
});
|
|
6805
|
+
const total = raw.reduce((sum, size) => sum + size, 0);
|
|
6806
|
+
return raw.map((size) => size / total * 100);
|
|
6807
|
+
}, [sections]);
|
|
6808
|
+
const [sizes, setSizes] = React33__namespace.useState(defaultSizes);
|
|
6809
|
+
React33__namespace.useEffect(() => {
|
|
6810
|
+
if (!storageKey) return;
|
|
6811
|
+
const saved = localStorage.getItem(storageKey);
|
|
6812
|
+
if (!saved) return;
|
|
6813
|
+
try {
|
|
6814
|
+
const parsed = JSON.parse(saved);
|
|
6815
|
+
if (Array.isArray(parsed) && parsed.length === sections.length) {
|
|
6816
|
+
setSizes(parsed);
|
|
6808
6817
|
}
|
|
6818
|
+
} catch (e) {
|
|
6809
6819
|
}
|
|
6810
|
-
|
|
6811
|
-
(section) => {
|
|
6812
|
-
var _a2;
|
|
6813
|
-
return (_a2 = section.defaultSize) != null ? _a2 : 100 / sections.length;
|
|
6814
|
-
}
|
|
6815
|
-
);
|
|
6816
|
-
const total = defaultSizes.reduce((sum, size) => sum + size, 0);
|
|
6817
|
-
return defaultSizes.map((size) => size / total * 100);
|
|
6818
|
-
});
|
|
6820
|
+
}, [storageKey]);
|
|
6819
6821
|
const [draggingIndex, setDraggingIndex] = React33__namespace.useState(null);
|
|
6820
6822
|
const [startX, setStartX] = React33__namespace.useState(0);
|
|
6821
6823
|
const [startSizes, setStartSizes] = React33__namespace.useState([]);
|