@dorsk/tsumikit 0.13.0 → 0.13.1
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.
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import { browser } from '../../env';
|
|
4
4
|
import Icon from '../atoms/Icon.svelte';
|
|
5
|
+
import { parseStoredCollapsed, parseStoredWidth } from './resizable-panel-persistence';
|
|
5
6
|
|
|
6
7
|
let {
|
|
7
8
|
panel,
|
|
@@ -64,12 +65,18 @@
|
|
|
64
65
|
restored = true;
|
|
65
66
|
if (!widthKey) return;
|
|
66
67
|
|
|
67
|
-
const savedWidth =
|
|
68
|
-
|
|
68
|
+
const savedWidth = parseStoredWidth(
|
|
69
|
+
localStorage.getItem(widthKey),
|
|
70
|
+
boundedMin,
|
|
71
|
+
boundedMax
|
|
72
|
+
);
|
|
73
|
+
if (savedWidth !== undefined) panelWidth = savedWidth;
|
|
69
74
|
|
|
70
75
|
if (persistCollapsed) {
|
|
71
|
-
const savedCollapsed =
|
|
72
|
-
|
|
76
|
+
const savedCollapsed = parseStoredCollapsed(
|
|
77
|
+
localStorage.getItem(`${widthKey}:collapsed`)
|
|
78
|
+
);
|
|
79
|
+
if (savedCollapsed !== undefined) collapsed = savedCollapsed;
|
|
73
80
|
}
|
|
74
81
|
});
|
|
75
82
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a persisted panel width without treating a missing or blank value as zero.
|
|
3
|
+
* @param {string | null} value
|
|
4
|
+
* @param {number} minWidth
|
|
5
|
+
* @param {number} maxWidth
|
|
6
|
+
* @returns {number | undefined}
|
|
7
|
+
*/
|
|
8
|
+
export function parseStoredWidth(value: string | null, minWidth: number, maxWidth: number): number | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Only values written by the panel itself may restore its collapsed state.
|
|
11
|
+
* @param {string | null} value
|
|
12
|
+
* @returns {boolean | undefined}
|
|
13
|
+
*/
|
|
14
|
+
export function parseStoredCollapsed(value: string | null): boolean | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a persisted panel width without treating a missing or blank value as zero.
|
|
3
|
+
* @param {string | null} value
|
|
4
|
+
* @param {number} minWidth
|
|
5
|
+
* @param {number} maxWidth
|
|
6
|
+
* @returns {number | undefined}
|
|
7
|
+
*/
|
|
8
|
+
export function parseStoredWidth(value, minWidth, maxWidth) {
|
|
9
|
+
if (value === null || value.trim() === '') return undefined;
|
|
10
|
+
|
|
11
|
+
const width = Number(value);
|
|
12
|
+
return Number.isFinite(width) ? Math.max(minWidth, Math.min(width, maxWidth)) : undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Only values written by the panel itself may restore its collapsed state.
|
|
17
|
+
* @param {string | null} value
|
|
18
|
+
* @returns {boolean | undefined}
|
|
19
|
+
*/
|
|
20
|
+
export function parseStoredCollapsed(value) {
|
|
21
|
+
if (value === 'true') return true;
|
|
22
|
+
if (value === 'false') return false;
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dorsk/tsumikit",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "Minimal, dependency-free Svelte 5 + pure-CSS UI kit. Token-driven atoms, molecules & layouts with theming out of the box.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"dev": "vite dev",
|
|
46
46
|
"build": "vite build",
|
|
47
47
|
"preview": "vite preview",
|
|
48
|
+
"test": "node --test tests/resizable-panel-persistence.test.js",
|
|
48
49
|
"prepare": "svelte-kit sync && (lefthook install || true)",
|
|
49
50
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
50
51
|
"lint": "biome check .",
|