@noxlovette/material 0.3.2 → 0.4.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/README.md +1 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/actions/rovingFocusGroup.d.ts +20 -0
- package/dist/actions/rovingFocusGroup.js +82 -0
- package/dist/components/badge/theme.d.ts +8 -8
- package/dist/components/buttons/button-group/ButtonGroup.stories.svelte +83 -0
- package/dist/components/buttons/button-group/ButtonGroup.stories.svelte.d.ts +19 -0
- package/dist/components/buttons/button-group/ButtonGroup.svelte +10 -29
- package/dist/components/buttons/button-group/ButtonGroup.svelte.d.ts +7 -3
- package/dist/components/buttons/button-group/index.d.ts +0 -1
- package/dist/components/buttons/button-group/index.js +3 -1
- package/dist/components/buttons/button-group/theme.d.ts +17 -103
- package/dist/components/buttons/button-group/theme.js +7 -35
- package/dist/components/buttons/button-group/types.d.ts +9 -20
- package/dist/components/buttons/connected/ConnectedButtonGroup.stories.svelte +118 -0
- package/dist/components/buttons/connected/ConnectedButtonGroup.stories.svelte.d.ts +19 -0
- package/dist/components/buttons/connected/ConnectedButtonGroup.svelte +52 -0
- package/dist/components/buttons/connected/ConnectedButtonGroup.svelte.d.ts +12 -0
- package/dist/components/buttons/connected/ConnectedButtonGroupItem.svelte +37 -0
- package/dist/components/buttons/connected/ConnectedButtonGroupItem.svelte.d.ts +9 -0
- package/dist/components/buttons/connected/index.d.ts +3 -1
- package/dist/components/buttons/connected/index.js +3 -1
- package/dist/components/buttons/connected/theme.d.ts +125 -0
- package/dist/components/buttons/connected/theme.js +38 -0
- package/dist/components/buttons/connected/types.d.ts +32 -13
- package/dist/components/buttons/index.d.ts +1 -0
- package/dist/components/buttons/index.js +1 -0
- package/dist/components/buttons/split-button/SplitButton.stories.svelte +103 -0
- package/dist/components/buttons/split-button/SplitButton.stories.svelte.d.ts +19 -0
- package/dist/components/buttons/split-button/SplitButton.svelte +104 -0
- package/dist/components/buttons/split-button/SplitButton.svelte.d.ts +19 -0
- package/dist/components/buttons/split-button/index.d.ts +3 -0
- package/dist/components/{containers/panes → buttons/split-button}/index.js +1 -3
- package/dist/components/buttons/split-button/theme.d.ts +35 -0
- package/dist/components/buttons/split-button/theme.js +26 -0
- package/dist/components/buttons/split-button/types.d.ts +33 -0
- package/dist/components/buttons/theme.d.ts +142 -142
- package/dist/components/buttons/theme.js +2 -2
- package/dist/components/cards/Card.stories.svelte +58 -0
- package/dist/components/cards/Card.stories.svelte.d.ts +2 -17
- package/dist/components/cards/Card.svelte +76 -8
- package/dist/components/cards/theme.d.ts +26 -14
- package/dist/components/cards/theme.js +5 -1
- package/dist/components/cards/types.d.ts +39 -1
- package/dist/components/chips/Chip.stories.svelte +64 -0
- package/dist/components/chips/Chip.stories.svelte.d.ts +19 -0
- package/dist/components/chips/Chip.svelte +115 -0
- package/dist/components/chips/Chip.svelte.d.ts +14 -0
- package/dist/components/chips/index.d.ts +3 -0
- package/dist/components/chips/index.js +6 -0
- package/dist/components/chips/theme.d.ts +78 -0
- package/dist/components/chips/theme.js +72 -0
- package/dist/components/chips/types.d.ts +43 -0
- package/dist/components/containers/action-rail/ActionRail.stories.svelte +36 -0
- package/dist/components/containers/{panes/SinglePane.stories.svelte.d.ts → action-rail/ActionRail.stories.svelte.d.ts} +4 -4
- package/dist/components/containers/action-rail/ActionRail.svelte +35 -0
- package/dist/components/containers/action-rail/ActionRail.svelte.d.ts +17 -0
- package/dist/components/containers/action-rail/index.d.ts +3 -0
- package/dist/components/containers/action-rail/index.js +6 -0
- package/dist/components/containers/action-rail/theme.d.ts +45 -0
- package/dist/components/containers/action-rail/theme.js +26 -0
- package/dist/components/containers/action-rail/types.d.ts +20 -0
- package/dist/components/containers/action-rail/types.js +1 -0
- package/dist/components/containers/app/App.svelte +6 -6
- package/dist/components/containers/app/App.svelte.d.ts +4 -2
- package/dist/components/containers/app/theme.d.ts +1 -1
- package/dist/components/containers/app/types.d.ts +9 -4
- package/dist/components/containers/bottom-sheet/BottomSheet.stories.svelte +1 -1
- package/dist/components/containers/bottom-sheet/BottomSheet.svelte +1 -1
- package/dist/components/containers/context-menu/ContextMenu.stories.svelte +44 -0
- package/dist/components/containers/context-menu/ContextMenu.svelte +21 -5
- package/dist/components/containers/context-menu/ContextMenu.svelte.d.ts +11 -0
- package/dist/components/containers/context-menu/theme.d.ts +20 -2
- package/dist/components/containers/context-menu/theme.js +31 -8
- package/dist/components/containers/context-menu/types.d.ts +14 -2
- package/dist/components/containers/dialogue/theme.d.ts +20 -20
- package/dist/components/containers/divider/theme.d.ts +17 -17
- package/dist/components/containers/index.d.ts +2 -3
- package/dist/components/containers/index.js +2 -3
- package/dist/components/containers/link-preview/theme.d.ts +11 -11
- package/dist/components/containers/list/ListItem.stories.svelte +100 -0
- package/dist/components/containers/list/ListItem.stories.svelte.d.ts +19 -0
- package/dist/components/containers/list/theme.d.ts +14 -14
- package/dist/components/containers/list/theme.js +3 -3
- package/dist/components/containers/menu/Menu.stories.svelte +105 -3
- package/dist/components/containers/menu/Menu.stories.svelte.d.ts +2 -17
- package/dist/components/containers/menu/Menu.svelte +9 -7
- package/dist/components/containers/menu/MenuCheckboxItem.svelte +55 -0
- package/dist/components/containers/menu/MenuCheckboxItem.svelte.d.ts +25 -0
- package/dist/components/containers/menu/MenuGroup.svelte +43 -0
- package/dist/components/containers/menu/MenuGroup.svelte.d.ts +28 -0
- package/dist/components/containers/menu/MenuRadioGroup.svelte +39 -0
- package/dist/components/containers/menu/MenuRadioGroup.svelte.d.ts +27 -0
- package/dist/components/containers/menu/MenuRadioItem.svelte +49 -0
- package/dist/components/containers/menu/MenuRadioItem.svelte.d.ts +17 -0
- package/dist/components/containers/menu/MenuSub.svelte +91 -0
- package/dist/components/containers/menu/MenuSub.svelte.d.ts +29 -0
- package/dist/components/containers/menu/index.d.ts +7 -0
- package/dist/components/containers/menu/index.js +8 -0
- package/dist/components/containers/menu/menu-item/MenuItem.svelte +71 -0
- package/dist/components/containers/{menu-item → menu/menu-item}/MenuItem.svelte.d.ts +2 -1
- package/dist/components/containers/{menu-item → menu/menu-item}/types.d.ts +5 -1
- package/dist/components/containers/menu/menu-item/types.js +1 -0
- package/dist/components/containers/menu/theme.d.ts +68 -0
- package/dist/components/containers/menu/theme.js +36 -0
- package/dist/components/containers/menu/types.d.ts +113 -2
- package/dist/components/containers/pane/DraggablePane.stories.svelte +199 -0
- package/dist/components/containers/pane/DraggablePane.stories.svelte.d.ts +4 -0
- package/dist/components/containers/pane/DraggablePane.svelte +533 -0
- package/dist/components/containers/pane/DraggablePane.svelte.d.ts +29 -0
- package/dist/components/containers/pane/Pane.stories.svelte +104 -0
- package/dist/components/containers/pane/Pane.stories.svelte.d.ts +19 -0
- package/dist/components/containers/pane/Pane.svelte +78 -0
- package/dist/components/containers/pane/Pane.svelte.d.ts +18 -0
- package/dist/components/containers/pane/PaneGrid.stories.svelte +134 -0
- package/dist/components/containers/pane/PaneGrid.stories.svelte.d.ts +19 -0
- package/dist/components/containers/pane/PaneGrid.svelte +43 -0
- package/dist/components/containers/pane/PaneGrid.svelte.d.ts +13 -0
- package/dist/components/containers/pane/PaneHandle.svelte +90 -0
- package/dist/components/containers/pane/PaneHandle.svelte.d.ts +12 -0
- package/dist/components/containers/pane/dragStore.svelte.d.ts +16 -0
- package/dist/components/containers/pane/dragStore.svelte.js +38 -0
- package/dist/components/containers/pane/index.d.ts +8 -0
- package/dist/components/containers/pane/index.js +11 -0
- package/dist/components/containers/pane/resizeStore.svelte.d.ts +10 -0
- package/dist/components/containers/pane/resizeStore.svelte.js +30 -0
- package/dist/components/containers/pane/theme.d.ts +571 -0
- package/dist/components/containers/pane/theme.js +211 -0
- package/dist/components/containers/pane/types.d.ts +249 -0
- package/dist/components/containers/pane/types.js +1 -0
- package/dist/components/containers/popover/Popover.stories.svelte +4 -4
- package/dist/components/containers/popover/Popover.svelte +3 -1
- package/dist/components/containers/popover/theme.d.ts +20 -20
- package/dist/components/containers/popover/types.d.ts +6 -2
- package/dist/components/containers/scroll-area/theme.d.ts +2 -2
- package/dist/components/containers/side-sheet/SideSheet.stories.svelte +16 -24
- package/dist/components/containers/side-sheet/SideSheet.svelte +73 -7
- package/dist/components/containers/side-sheet/SideSheet.svelte.d.ts +5 -0
- package/dist/components/containers/stack/theme.d.ts +44 -44
- package/dist/components/date/DateField.stories.svelte +57 -0
- package/dist/components/{containers/panes/SplitPane.stories.svelte.d.ts → date/DateField.stories.svelte.d.ts} +4 -4
- package/dist/components/date/DateField.svelte +11 -2
- package/dist/components/date/DateRangeField.stories.svelte +53 -0
- package/dist/components/{containers/panes/SupportingPane.stories.svelte.d.ts → date/DateRangeField.stories.svelte.d.ts} +4 -4
- package/dist/components/date/DateRangeField.svelte +2 -1
- package/dist/components/date/theme.d.ts +73 -4
- package/dist/components/date/theme.js +95 -26
- package/dist/components/date/types.d.ts +5 -0
- package/dist/components/forms/checkbox/Checkbox.svelte +7 -9
- package/dist/components/forms/checkbox/theme.d.ts +8 -8
- package/dist/components/forms/checkbox/theme.js +31 -9
- package/dist/components/forms/command/Command.stories.svelte +86 -0
- package/dist/components/forms/command/Command.stories.svelte.d.ts +19 -0
- package/dist/components/forms/command/theme.d.ts +35 -35
- package/dist/components/forms/command/theme.js +4 -4
- package/dist/components/forms/pin/theme.d.ts +2 -2
- package/dist/components/forms/radio-group/theme.d.ts +2 -2
- package/dist/components/forms/search/theme.d.ts +8 -8
- package/dist/components/forms/select/Select.svelte +3 -2
- package/dist/components/forms/select/theme.d.ts +26 -2
- package/dist/components/forms/select/theme.js +56 -22
- package/dist/components/forms/slider/theme.d.ts +20 -20
- package/dist/components/forms/switch/theme.d.ts +2 -2
- package/dist/components/forms/textfield/Textfield.stories.svelte +22 -0
- package/dist/components/forms/textfield/Textfield.svelte +10 -1
- package/dist/components/forms/textfield/theme.d.ts +44 -2
- package/dist/components/forms/textfield/theme.js +56 -16
- package/dist/components/forms/toggle-group/ToggleGroup.svelte +2 -2
- package/dist/components/forms/toggle-group/ToggleGroup.svelte.d.ts +2 -2
- package/dist/components/forms/toggle-group/ToggleGroupItem.svelte +1 -1
- package/dist/components/forms/toggle-group/ToggleGroupItem.svelte.d.ts +1 -1
- package/dist/components/forms/toggle-group/theme.d.ts +16 -16
- package/dist/components/forms/toggle-group/types.d.ts +2 -2
- package/dist/components/forms/tooltip/Tooltip.stories.svelte +90 -0
- package/dist/components/forms/tooltip/Tooltip.stories.svelte.d.ts +19 -0
- package/dist/components/forms/tooltip/Tooltip.svelte +5 -4
- package/dist/components/forms/tooltip/theme.d.ts +5 -2
- package/dist/components/forms/tooltip/theme.js +6 -5
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/misc/Avatar.stories.svelte +63 -0
- package/dist/components/misc/Avatar.stories.svelte.d.ts +19 -0
- package/dist/components/misc/Avatar.svelte +35 -10
- package/dist/components/misc/DicebearAvatarBuilder.d.ts +59 -0
- package/dist/components/misc/DicebearAvatarBuilder.js +115 -0
- package/dist/components/misc/ThemeSettings.svelte +1 -1
- package/dist/components/misc/ThemeSwitcher.svelte +2 -2
- package/dist/components/misc/dicebearStyles.d.ts +21 -0
- package/dist/components/misc/dicebearStyles.js +169 -0
- package/dist/components/misc/index.d.ts +3 -0
- package/dist/components/misc/index.js +3 -0
- package/dist/components/misc/materialAvatarPalette.d.ts +6 -0
- package/dist/components/misc/materialAvatarPalette.js +44 -0
- package/dist/components/misc/theme.d.ts +20 -2
- package/dist/components/misc/theme.js +9 -3
- package/dist/components/misc/types.d.ts +20 -2
- package/dist/components/nav/appbar/AppBar.stories.svelte +1 -1
- package/dist/components/nav/appbar/AppBar.svelte +46 -15
- package/dist/components/nav/appbar/AppBar.svelte.d.ts +5 -0
- package/dist/components/nav/appbar/theme.d.ts +20 -14
- package/dist/components/nav/appbar/theme.js +11 -7
- package/dist/components/nav/appbar/types.d.ts +3 -1
- package/dist/components/nav/breadcrumb/Breadcrumb.stories.svelte +50 -0
- package/dist/components/nav/breadcrumb/Breadcrumb.stories.svelte.d.ts +19 -0
- package/dist/components/nav/breadcrumb/Breadcrumb.svelte +46 -0
- package/dist/components/nav/breadcrumb/Breadcrumb.svelte.d.ts +13 -0
- package/dist/components/nav/breadcrumb/index.d.ts +3 -0
- package/dist/components/nav/breadcrumb/index.js +6 -0
- package/dist/components/nav/breadcrumb/theme.d.ts +84 -0
- package/dist/components/nav/breadcrumb/theme.js +35 -0
- package/dist/components/nav/breadcrumb/types.d.ts +14 -0
- package/dist/components/nav/breadcrumb/types.js +1 -0
- package/dist/components/nav/index.d.ts +1 -0
- package/dist/components/nav/index.js +1 -0
- package/dist/components/nav/navbar/theme.d.ts +19 -19
- package/dist/components/nav/rail/Rail.stories.svelte +1 -5
- package/dist/components/nav/rail/Rail.svelte +3 -25
- package/dist/components/nav/rail/theme.d.ts +4 -4
- package/dist/components/nav/rail/types.d.ts +0 -5
- package/dist/components/nav/tabs/TabHolder.svelte +2 -1
- package/dist/components/nav/tabs/theme.d.ts +21 -21
- package/dist/components/nav/tabs/theme.js +6 -0
- package/dist/components/nav/tabs/types.d.ts +2 -2
- package/dist/components/pill/theme.d.ts +35 -35
- package/dist/components/snackbar/theme.d.ts +8 -8
- package/dist/components/table/Table.stories.svelte +267 -0
- package/dist/components/table/Table.stories.svelte.d.ts +19 -0
- package/dist/components/table/Table.svelte +1 -1
- package/dist/components/table/TableBody.svelte +16 -3
- package/dist/components/table/TableBody.svelte.d.ts +5 -1
- package/dist/components/table/TableRow.svelte +1 -1
- package/dist/components/table/theme.d.ts +2 -2
- package/dist/components/table/theme.js +2 -2
- package/dist/components/table/types.d.ts +7 -0
- package/dist/components/time/theme.d.ts +29 -29
- package/dist/components/time/theme.js +2 -2
- package/dist/components/toolbar/Toolbar.stories.svelte +71 -0
- package/dist/components/toolbar/Toolbar.stories.svelte.d.ts +19 -0
- package/dist/components/toolbar/Toolbar.svelte +19 -3
- package/dist/components/toolbar/Toolbar.svelte.d.ts +8 -2
- package/dist/components/toolbar/ToolbarButton.svelte +28 -4
- package/dist/components/toolbar/ToolbarDivider.svelte +4 -3
- package/dist/components/toolbar/ToolbarGroup.svelte +7 -2
- package/dist/components/toolbar/ToolbarGroupItem.svelte +29 -4
- package/dist/components/toolbar/ToolbarSection.svelte +35 -0
- package/dist/components/toolbar/ToolbarSection.svelte.d.ts +9 -0
- package/dist/components/toolbar/ToolbarSpacer.svelte +18 -0
- package/dist/components/toolbar/ToolbarSpacer.svelte.d.ts +9 -0
- package/dist/components/toolbar/index.d.ts +2 -0
- package/dist/components/toolbar/index.js +2 -0
- package/dist/components/toolbar/theme.d.ts +36 -21
- package/dist/components/toolbar/theme.js +27 -11
- package/dist/components/toolbar/types.d.ts +37 -4
- package/dist/components/typography/body/theme.d.ts +14 -14
- package/dist/components/typography/display/theme.d.ts +14 -14
- package/dist/components/typography/headline/theme.d.ts +14 -14
- package/dist/components/typography/kbd/Kbd.stories.svelte +41 -0
- package/dist/components/typography/kbd/Kbd.stories.svelte.d.ts +19 -0
- package/dist/components/typography/kbd/theme.d.ts +9 -9
- package/dist/components/typography/kbd/theme.js +2 -2
- package/dist/components/typography/label/theme.d.ts +14 -14
- package/dist/components/typography/title/theme.d.ts +14 -14
- package/dist/styles/component.css +126 -4
- package/dist/styles/motion.css +6 -3
- package/dist/utils/Layer.svelte +7 -3
- package/dist/utils/Theme.svelte +20 -20
- package/dist/utils/ThemeScript.svelte +1 -1
- package/dist/utils/icon/theme.d.ts +14 -14
- package/package.json +38 -37
- package/bin/install-skill.js +0 -29
- package/dist/components/buttons/button-group/ButtonGroupItem.svelte +0 -41
- package/dist/components/buttons/button-group/ButtonGroupItem.svelte.d.ts +0 -8
- package/dist/components/buttons/connected/ConnectedButtons.svelte +0 -14
- package/dist/components/buttons/connected/ConnectedButtons.svelte.d.ts +0 -8
- package/dist/components/containers/menu-item/MenuItem.svelte +0 -74
- package/dist/components/containers/merger/InputMerger.svelte +0 -29
- package/dist/components/containers/merger/InputMerger.svelte.d.ts +0 -14
- package/dist/components/containers/merger/index.d.ts +0 -1
- package/dist/components/containers/merger/index.js +0 -3
- package/dist/components/containers/panes/SinglePane.stories.svelte +0 -67
- package/dist/components/containers/panes/SinglePane.svelte +0 -32
- package/dist/components/containers/panes/SinglePane.svelte.d.ts +0 -5
- package/dist/components/containers/panes/SplitPane.stories.svelte +0 -124
- package/dist/components/containers/panes/SplitPane.svelte +0 -144
- package/dist/components/containers/panes/SplitPane.svelte.d.ts +0 -8
- package/dist/components/containers/panes/SupportingPane.stories.svelte +0 -113
- package/dist/components/containers/panes/SupportingPane.svelte +0 -175
- package/dist/components/containers/panes/SupportingPane.svelte.d.ts +0 -9
- package/dist/components/containers/panes/index.d.ts +0 -5
- package/dist/components/containers/panes/theme.d.ts +0 -490
- package/dist/components/containers/panes/theme.js +0 -185
- package/dist/components/containers/panes/types.d.ts +0 -108
- package/dist/components/nav/rail/RailNavContext.svelte +0 -14
- package/dist/components/nav/rail/RailNavContext.svelte.d.ts +0 -8
- /package/dist/components/{containers/menu-item → buttons/split-button}/types.js +0 -0
- /package/dist/components/{containers/panes → chips}/types.js +0 -0
- /package/dist/components/containers/{menu-item → menu/menu-item}/index.d.ts +0 -0
- /package/dist/components/containers/{menu-item → menu/menu-item}/index.js +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
A single content region. Used standalone as a page-level wrapper (centered column,
|
|
4
|
+
padding/gap, optional background), or as a child of PaneGrid to become one region
|
|
5
|
+
of a multi-pane layout — a sidebar, a detail column, a supporting panel — via
|
|
6
|
+
`width`/`resizable`/`sticky`/`visibleFrom`/`hiddenFrom`. A `resizable` pane doesn't
|
|
7
|
+
own a drag handle itself — place a `PaneHandle` with a matching `persistKey`
|
|
8
|
+
alongside it in the PaneGrid; this pane just mirrors the width it drags to.
|
|
9
|
+
|
|
10
|
+
With `full` (the default), the pane's min-height is `100dvh` minus
|
|
11
|
+
`--appbar-height`, a CSS custom property `AppBar` publishes on the document root
|
|
12
|
+
while mounted (0px otherwise) — automatic, no props needed here. A hand-rolled
|
|
13
|
+
fixed top bar instead of `AppBar` won't set it, so set `--appbar-height: <px>` on
|
|
14
|
+
the document root yourself to get the same behavior.
|
|
15
|
+
-->
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
import clsx from 'clsx';
|
|
18
|
+
import { onMount } from 'svelte';
|
|
19
|
+
import { pane, responsiveTables } from './theme.js';
|
|
20
|
+
import { paneWidths } from './resizeStore.svelte.js';
|
|
21
|
+
import type { PaneProps } from './types.js';
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
children,
|
|
25
|
+
background = true,
|
|
26
|
+
full = true,
|
|
27
|
+
padding = 'md',
|
|
28
|
+
gap = 'md',
|
|
29
|
+
rounded = true,
|
|
30
|
+
width = $bindable(undefined),
|
|
31
|
+
resizable = false,
|
|
32
|
+
persistKey,
|
|
33
|
+
sticky = false,
|
|
34
|
+
stickyTop = 0,
|
|
35
|
+
visibleFrom,
|
|
36
|
+
hiddenFrom,
|
|
37
|
+
class: className,
|
|
38
|
+
contentClass,
|
|
39
|
+
...rest
|
|
40
|
+
}: PaneProps = $props();
|
|
41
|
+
|
|
42
|
+
const flexible = $derived(width === undefined);
|
|
43
|
+
|
|
44
|
+
const { base, content } = $derived(
|
|
45
|
+
pane({ padding, gap, full, background, rounded, flexible, sticky })
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const visibilityClass = $derived(
|
|
49
|
+
clsx(
|
|
50
|
+
visibleFrom && responsiveTables.visibleFrom[visibleFrom],
|
|
51
|
+
hiddenFrom && responsiveTables.hiddenFrom[hiddenFrom]
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const style = $derived(
|
|
56
|
+
clsx(
|
|
57
|
+
!flexible && `width: ${width}px; flex-basis: ${width}px;`,
|
|
58
|
+
sticky && `--pane-sticky-top: ${stickyTop}px;`
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
onMount(() => {
|
|
63
|
+
if (!resizable || !persistKey) return;
|
|
64
|
+
width = paneWidths.hydrate(persistKey, width ?? 200);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
$effect(() => {
|
|
68
|
+
if (!resizable || !persistKey) return;
|
|
69
|
+
const stored = paneWidths.get(persistKey);
|
|
70
|
+
if (stored !== undefined) width = stored;
|
|
71
|
+
});
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<div class={base({ class: clsx(className, visibilityClass) })} {style} {...rest}>
|
|
75
|
+
<div class={content({ class: clsx(contentClass) })}>
|
|
76
|
+
{@render children()}
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PaneProps } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A single content region. Used standalone as a page-level wrapper (centered column,
|
|
4
|
+
* padding/gap, optional background), or as a child of PaneGrid to become one region
|
|
5
|
+
* of a multi-pane layout — a sidebar, a detail column, a supporting panel — via
|
|
6
|
+
* `width`/`resizable`/`sticky`/`visibleFrom`/`hiddenFrom`. A `resizable` pane doesn't
|
|
7
|
+
* own a drag handle itself — place a `PaneHandle` with a matching `persistKey`
|
|
8
|
+
* alongside it in the PaneGrid; this pane just mirrors the width it drags to.
|
|
9
|
+
*
|
|
10
|
+
* With `full` (the default), the pane's min-height is `100dvh` minus
|
|
11
|
+
* `--appbar-height`, a CSS custom property `AppBar` publishes on the document root
|
|
12
|
+
* while mounted (0px otherwise) — automatic, no props needed here. A hand-rolled
|
|
13
|
+
* fixed top bar instead of `AppBar` won't set it, so set `--appbar-height: <px>` on
|
|
14
|
+
* the document root yourself to get the same behavior.
|
|
15
|
+
*/
|
|
16
|
+
declare const Pane: import("svelte").Component<PaneProps, {}, "width">;
|
|
17
|
+
type Pane = ReturnType<typeof Pane>;
|
|
18
|
+
export default Pane;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import PaneGrid from './PaneGrid.svelte';
|
|
4
|
+
import Pane from './Pane.svelte';
|
|
5
|
+
import PaneHandle from './PaneHandle.svelte';
|
|
6
|
+
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
title: 'Containers/Pane Grid',
|
|
9
|
+
component: PaneGrid
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<!--
|
|
14
|
+
Resizable two-column split — replaces the old SplitPane. A PaneHandle sits
|
|
15
|
+
between the two Panes as its own flex child (not clipped inside the left
|
|
16
|
+
Pane the way a self-owned handle was) and drags the left Pane's width via
|
|
17
|
+
a shared persistKey. Drag near 360/412px to feel it snap.
|
|
18
|
+
-->
|
|
19
|
+
<Story name="Resizable Split" asChild>
|
|
20
|
+
<div
|
|
21
|
+
class="border-md-sys-color-outline-variant relative h-[420px] overflow-hidden rounded-lg border"
|
|
22
|
+
>
|
|
23
|
+
<PaneGrid gap="none" class="h-full">
|
|
24
|
+
<Pane
|
|
25
|
+
width={320}
|
|
26
|
+
resizable
|
|
27
|
+
persistKey="storybook:pane-grid-split"
|
|
28
|
+
rounded={false}
|
|
29
|
+
background={false}
|
|
30
|
+
full={false}
|
|
31
|
+
>
|
|
32
|
+
<div class="p-4">
|
|
33
|
+
<p class="md-sys-typescale-title-small mb-2">Left pane</p>
|
|
34
|
+
<p class="text-md-sys-color-on-surface-variant text-sm">
|
|
35
|
+
Drag the handle to resize — persisted to localStorage, and snaps near 360/412px.
|
|
36
|
+
</p>
|
|
37
|
+
</div>
|
|
38
|
+
</Pane>
|
|
39
|
+
<PaneHandle persistKey="storybook:pane-grid-split" min={240} max={560} />
|
|
40
|
+
<Pane rounded={false} full={false}>
|
|
41
|
+
<div class="p-4">
|
|
42
|
+
<p class="md-sys-typescale-title-small mb-2">Right pane</p>
|
|
43
|
+
<p class="text-md-sys-color-on-surface-variant text-sm">Main content area.</p>
|
|
44
|
+
</div>
|
|
45
|
+
</Pane>
|
|
46
|
+
</PaneGrid>
|
|
47
|
+
</div>
|
|
48
|
+
</Story>
|
|
49
|
+
|
|
50
|
+
<!--
|
|
51
|
+
Sticky nav — a static (non-resizable) sidebar that sticks to the top of its
|
|
52
|
+
scroll container as the main content scrolls past it. Replaces
|
|
53
|
+
SplitPane anchor="sticky". Works inside any scrolling ancestor, not just the
|
|
54
|
+
true browser viewport, which is what lets this demo meaningfully inside
|
|
55
|
+
Storybook's bounded canvas.
|
|
56
|
+
-->
|
|
57
|
+
<Story name="Sticky Sidebar" asChild>
|
|
58
|
+
<div class="border-md-sys-color-outline-variant h-[420px] overflow-y-auto rounded-lg border">
|
|
59
|
+
<PaneGrid rounded>
|
|
60
|
+
<Pane width={240} sticky rounded={false}>
|
|
61
|
+
<div class="p-4">
|
|
62
|
+
<p class="md-sys-typescale-title-small mb-2">Sticky nav</p>
|
|
63
|
+
<p class="text-md-sys-color-on-surface-variant text-sm">
|
|
64
|
+
Stays pinned to the top of the scroll container while the right pane scrolls past it.
|
|
65
|
+
</p>
|
|
66
|
+
</div>
|
|
67
|
+
</Pane>
|
|
68
|
+
<Pane rounded={false}>
|
|
69
|
+
<div class="flex flex-col gap-4 p-4">
|
|
70
|
+
{#each Array(12) as _, i}
|
|
71
|
+
<div class="bg-md-sys-color-surface-container-high rounded-lg p-6">
|
|
72
|
+
Scrollable content block {i + 1}
|
|
73
|
+
</div>
|
|
74
|
+
{/each}
|
|
75
|
+
</div>
|
|
76
|
+
</Pane>
|
|
77
|
+
</PaneGrid>
|
|
78
|
+
</div>
|
|
79
|
+
</Story>
|
|
80
|
+
|
|
81
|
+
<!--
|
|
82
|
+
Main + supporting panel that stacks on small viewports and moves to a row
|
|
83
|
+
from `large` up — replaces SupportingPane. The panel is sticky once it's
|
|
84
|
+
in the row layout, so it stays visible while the main column scrolls.
|
|
85
|
+
-->
|
|
86
|
+
<Story name="Main + Supporting" asChild>
|
|
87
|
+
<div class="border-md-sys-color-outline-variant h-[420px] overflow-y-auto rounded-lg border">
|
|
88
|
+
<PaneGrid direction={{ small: 'column', large: 'row' }} gap="lg" padding="md">
|
|
89
|
+
<Pane background={false} padding="none">
|
|
90
|
+
<div class="flex flex-col gap-4">
|
|
91
|
+
{#each Array(6) as _, i}
|
|
92
|
+
<div class="bg-md-sys-color-surface-container-high rounded-lg p-6">
|
|
93
|
+
Main content block {i + 1}
|
|
94
|
+
</div>
|
|
95
|
+
{/each}
|
|
96
|
+
</div>
|
|
97
|
+
</Pane>
|
|
98
|
+
<Pane width={280} sticky background={false} padding="none">
|
|
99
|
+
<div class="bg-md-sys-color-surface-container rounded-lg p-4">
|
|
100
|
+
<p class="md-sys-typescale-title-small mb-2">Supporting content</p>
|
|
101
|
+
<p class="text-md-sys-color-on-surface-variant text-sm">
|
|
102
|
+
Fixed-width panel — e.g. a table of contents or contextual actions.
|
|
103
|
+
</p>
|
|
104
|
+
</div>
|
|
105
|
+
</Pane>
|
|
106
|
+
</PaneGrid>
|
|
107
|
+
</div>
|
|
108
|
+
</Story>
|
|
109
|
+
|
|
110
|
+
<!--
|
|
111
|
+
List-detail: the detail pane only appears from `medium` up via `visibleFrom`;
|
|
112
|
+
below that, the list pane fills the screen alone. Toggle Storybook's viewport
|
|
113
|
+
controls to see the detail pane drop out.
|
|
114
|
+
-->
|
|
115
|
+
<Story name="List-Detail (detail hidden on small)" asChild>
|
|
116
|
+
<div
|
|
117
|
+
class="border-md-sys-color-outline-variant relative h-[320px] overflow-hidden rounded-lg border"
|
|
118
|
+
>
|
|
119
|
+
<PaneGrid full>
|
|
120
|
+
<Pane width={320} rounded={false} background={false}>
|
|
121
|
+
<div class="p-4">
|
|
122
|
+
<p class="md-sys-typescale-title-small mb-2">List</p>
|
|
123
|
+
<p class="text-md-sys-color-on-surface-variant text-sm">Always visible.</p>
|
|
124
|
+
</div>
|
|
125
|
+
</Pane>
|
|
126
|
+
<Pane visibleFrom="medium" rounded={false}>
|
|
127
|
+
<div class="p-4">
|
|
128
|
+
<p class="md-sys-typescale-title-small mb-2">Detail</p>
|
|
129
|
+
<p class="text-md-sys-color-on-surface-variant text-sm">Visible from `medium` up only.</p>
|
|
130
|
+
</div>
|
|
131
|
+
</Pane>
|
|
132
|
+
</PaneGrid>
|
|
133
|
+
</div>
|
|
134
|
+
</Story>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import PaneGrid from './PaneGrid.svelte';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const PaneGrid: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type PaneGrid = InstanceType<typeof PaneGrid>;
|
|
19
|
+
export default PaneGrid;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Arranges Pane children relative to one another: direction, gap, and outer
|
|
4
|
+
margin/padding, each independently responsive across viewport tiers
|
|
5
|
+
(small/medium/large/extraLarge). PaneGrid owns layout only — sizing, stickiness,
|
|
6
|
+
resizing, and breakpoint visibility are declared per-Pane.
|
|
7
|
+
|
|
8
|
+
With `full`, min-height is `100dvh` minus `--appbar-height` — see Pane.svelte's
|
|
9
|
+
doc comment for how that CSS custom property gets set.
|
|
10
|
+
-->
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import clsx from 'clsx';
|
|
13
|
+
import { paneGrid, resolveResponsive, responsiveTables } from './theme.js';
|
|
14
|
+
import type { PaneGridProps } from './types.js';
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
children,
|
|
18
|
+
direction = 'row',
|
|
19
|
+
gap = 'md',
|
|
20
|
+
padding = 'none',
|
|
21
|
+
margin = 'none',
|
|
22
|
+
full = false,
|
|
23
|
+
rounded = false,
|
|
24
|
+
wrap = false,
|
|
25
|
+
class: className,
|
|
26
|
+
...rest
|
|
27
|
+
}: PaneGridProps = $props();
|
|
28
|
+
|
|
29
|
+
const { base } = $derived(paneGrid({ full, rounded, wrap }));
|
|
30
|
+
|
|
31
|
+
const responsiveClass = $derived(
|
|
32
|
+
clsx(
|
|
33
|
+
resolveResponsive(direction, responsiveTables.direction),
|
|
34
|
+
resolveResponsive(gap, responsiveTables.gap),
|
|
35
|
+
resolveResponsive(padding, responsiveTables.padding),
|
|
36
|
+
resolveResponsive(margin, responsiveTables.margin)
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<div class={base({ class: clsx(responsiveClass, className) })} {...rest}>
|
|
42
|
+
{@render children()}
|
|
43
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PaneGridProps } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Arranges Pane children relative to one another: direction, gap, and outer
|
|
4
|
+
* margin/padding, each independently responsive across viewport tiers
|
|
5
|
+
* (small/medium/large/extraLarge). PaneGrid owns layout only — sizing, stickiness,
|
|
6
|
+
* resizing, and breakpoint visibility are declared per-Pane.
|
|
7
|
+
*
|
|
8
|
+
* With `full`, min-height is `100dvh` minus `--appbar-height` — see Pane.svelte's
|
|
9
|
+
* doc comment for how that CSS custom property gets set.
|
|
10
|
+
*/
|
|
11
|
+
declare const PaneGrid: import("svelte").Component<PaneGridProps, {}, "">;
|
|
12
|
+
type PaneGrid = ReturnType<typeof PaneGrid>;
|
|
13
|
+
export default PaneGrid;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
A drag divider for a PaneGrid, placed as its own child between the `Pane` it
|
|
4
|
+
resizes and its neighbor. Unlike a handle absolutely-positioned inside a Pane
|
|
5
|
+
(clipped by that Pane's `overflow-clip`, cramped into its own border), this
|
|
6
|
+
sits in the grid's flex flow — a real sibling with room to breathe in the
|
|
7
|
+
gutter. Dragging it writes to the shared resize store; any `Pane` with a
|
|
8
|
+
matching `persistKey` picks the new width up reactively.
|
|
9
|
+
-->
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import clsx from 'clsx';
|
|
12
|
+
import { onMount } from 'svelte';
|
|
13
|
+
import { paneHandle } from './theme.js';
|
|
14
|
+
import { paneWidths } from './resizeStore.svelte.js';
|
|
15
|
+
import type { PaneHandleProps } from './types.js';
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
persistKey,
|
|
19
|
+
min = 200,
|
|
20
|
+
max = 640,
|
|
21
|
+
snapPoints = [360, 412],
|
|
22
|
+
snapThreshold = 16,
|
|
23
|
+
class: className,
|
|
24
|
+
...rest
|
|
25
|
+
}: PaneHandleProps = $props();
|
|
26
|
+
|
|
27
|
+
let dragging = $state(false);
|
|
28
|
+
let snapped = $state(false);
|
|
29
|
+
|
|
30
|
+
const { base, grip } = $derived(paneHandle({ dragging, snapped }));
|
|
31
|
+
|
|
32
|
+
const clampWidth = (next: number) => Math.min(max, Math.max(min, next));
|
|
33
|
+
|
|
34
|
+
/** Nearest snap point within `snapThreshold` of `value`, if any. */
|
|
35
|
+
const nearestSnap = (value: number): number | undefined => {
|
|
36
|
+
let closest: number | undefined;
|
|
37
|
+
let closestDist = snapThreshold;
|
|
38
|
+
for (const point of snapPoints) {
|
|
39
|
+
const dist = Math.abs(value - point);
|
|
40
|
+
if (dist <= closestDist) {
|
|
41
|
+
closest = point;
|
|
42
|
+
closestDist = dist;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return closest;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
let dragStartX = 0;
|
|
49
|
+
let dragStartWidth = 0;
|
|
50
|
+
|
|
51
|
+
onMount(() => {
|
|
52
|
+
paneWidths.hydrate(persistKey, min);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const startDrag = (event: PointerEvent) => {
|
|
56
|
+
dragging = true;
|
|
57
|
+
dragStartX = event.clientX;
|
|
58
|
+
dragStartWidth = paneWidths.get(persistKey) ?? min;
|
|
59
|
+
(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const moveDrag = (event: PointerEvent) => {
|
|
63
|
+
if (!dragging) return;
|
|
64
|
+
const raw = clampWidth(dragStartWidth + (event.clientX - dragStartX));
|
|
65
|
+
const snap = nearestSnap(raw);
|
|
66
|
+
snapped = snap !== undefined;
|
|
67
|
+
paneWidths.set(persistKey, snap ?? raw);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const endDrag = () => {
|
|
71
|
+
dragging = false;
|
|
72
|
+
snapped = false;
|
|
73
|
+
};
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<div
|
|
77
|
+
class={base({ class: clsx(className) })}
|
|
78
|
+
role="separator"
|
|
79
|
+
aria-orientation="vertical"
|
|
80
|
+
aria-valuenow={paneWidths.get(persistKey)}
|
|
81
|
+
aria-valuemin={min}
|
|
82
|
+
aria-valuemax={max}
|
|
83
|
+
onpointerdown={startDrag}
|
|
84
|
+
onpointermove={moveDrag}
|
|
85
|
+
onpointerup={endDrag}
|
|
86
|
+
onpointercancel={endDrag}
|
|
87
|
+
{...rest}
|
|
88
|
+
>
|
|
89
|
+
<div class={grip()}></div>
|
|
90
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PaneHandleProps } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A drag divider for a PaneGrid, placed as its own child between the `Pane` it
|
|
4
|
+
* resizes and its neighbor. Unlike a handle absolutely-positioned inside a Pane
|
|
5
|
+
* (clipped by that Pane's `overflow-clip`, cramped into its own border), this
|
|
6
|
+
* sits in the grid's flex flow — a real sibling with room to breathe in the
|
|
7
|
+
* gutter. Dragging it writes to the shared resize store; any `Pane` with a
|
|
8
|
+
* matching `persistKey` picks the new width up reactively.
|
|
9
|
+
*/
|
|
10
|
+
declare const PaneHandle: import("svelte").Component<PaneHandleProps, {}, "">;
|
|
11
|
+
type PaneHandle = ReturnType<typeof PaneHandle>;
|
|
12
|
+
export default PaneHandle;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type DragPosition = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
};
|
|
7
|
+
declare function get(key: string): DragPosition | undefined;
|
|
8
|
+
/** Seeds `key` from localStorage (or `fallback`) the first time it's read; a no-op after that. */
|
|
9
|
+
declare function hydrate(key: string, fallback: DragPosition): DragPosition;
|
|
10
|
+
declare function set(key: string, value: DragPosition): void;
|
|
11
|
+
export declare const dragPositions: {
|
|
12
|
+
get: typeof get;
|
|
13
|
+
hydrate: typeof hydrate;
|
|
14
|
+
set: typeof set;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
2
|
+
/**
|
|
3
|
+
* Shared, localStorage-backed position/size registry keyed by `persistKey`. A
|
|
4
|
+
* `DraggablePane` reads/writes its own entry here so its last dragged
|
|
5
|
+
* position and (once resized) size survive reloads without the consumer
|
|
6
|
+
* having to manage it.
|
|
7
|
+
*/
|
|
8
|
+
const positions = new SvelteMap();
|
|
9
|
+
function get(key) {
|
|
10
|
+
return positions.get(key);
|
|
11
|
+
}
|
|
12
|
+
/** Seeds `key` from localStorage (or `fallback`) the first time it's read; a no-op after that. */
|
|
13
|
+
function hydrate(key, fallback) {
|
|
14
|
+
if (positions.has(key))
|
|
15
|
+
return positions.get(key);
|
|
16
|
+
let initial = fallback;
|
|
17
|
+
if (typeof localStorage !== 'undefined') {
|
|
18
|
+
const stored = localStorage.getItem(key);
|
|
19
|
+
if (stored) {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(stored);
|
|
22
|
+
if (typeof parsed?.x === 'number' && typeof parsed?.y === 'number')
|
|
23
|
+
initial = parsed;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// malformed stored value — fall back to `fallback`
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
positions.set(key, initial);
|
|
31
|
+
return initial;
|
|
32
|
+
}
|
|
33
|
+
function set(key, value) {
|
|
34
|
+
positions.set(key, value);
|
|
35
|
+
if (typeof localStorage !== 'undefined')
|
|
36
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
37
|
+
}
|
|
38
|
+
export const dragPositions = { get, hydrate, set };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './dragStore.svelte.js';
|
|
2
|
+
export * from './resizeStore.svelte.js';
|
|
3
|
+
export * from './theme.js';
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
export { default as DraggablePane } from './DraggablePane.svelte';
|
|
6
|
+
export { default as Pane } from './Pane.svelte';
|
|
7
|
+
export { default as PaneGrid } from './PaneGrid.svelte';
|
|
8
|
+
export { default as PaneHandle } from './PaneHandle.svelte';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// THIS FILE IS AUTO-GENERATED BY scripts/generate-components-index.ts - DO NOT EDIT MANUALLY
|
|
2
|
+
// re-export TS/JS modules from this folder
|
|
3
|
+
export * from './dragStore.svelte.js';
|
|
4
|
+
export * from './resizeStore.svelte.js';
|
|
5
|
+
export * from './theme.js';
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
// default exports for components in this folder
|
|
8
|
+
export { default as DraggablePane } from './DraggablePane.svelte';
|
|
9
|
+
export { default as Pane } from './Pane.svelte';
|
|
10
|
+
export { default as PaneGrid } from './PaneGrid.svelte';
|
|
11
|
+
export { default as PaneHandle } from './PaneHandle.svelte';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare function get(key: string): number | undefined;
|
|
2
|
+
/** Seeds `key` from localStorage (or `fallback`) the first time it's read; a no-op after that. */
|
|
3
|
+
declare function hydrate(key: string, fallback: number): number;
|
|
4
|
+
declare function set(key: string, value: number): void;
|
|
5
|
+
export declare const paneWidths: {
|
|
6
|
+
get: typeof get;
|
|
7
|
+
hydrate: typeof hydrate;
|
|
8
|
+
set: typeof set;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
2
|
+
/**
|
|
3
|
+
* Shared, localStorage-backed width registry keyed by `persistKey`. A `Pane`
|
|
4
|
+
* and a `PaneHandle` that share the same `persistKey` stay in sync through
|
|
5
|
+
* this map without needing a direct parent/child relationship — the handle
|
|
6
|
+
* writes on drag, the pane reads reactively.
|
|
7
|
+
*/
|
|
8
|
+
const widths = new SvelteMap();
|
|
9
|
+
function get(key) {
|
|
10
|
+
return widths.get(key);
|
|
11
|
+
}
|
|
12
|
+
/** Seeds `key` from localStorage (or `fallback`) the first time it's read; a no-op after that. */
|
|
13
|
+
function hydrate(key, fallback) {
|
|
14
|
+
if (widths.has(key))
|
|
15
|
+
return widths.get(key);
|
|
16
|
+
let initial = fallback;
|
|
17
|
+
if (typeof localStorage !== 'undefined') {
|
|
18
|
+
const stored = Number(localStorage.getItem(key));
|
|
19
|
+
if (!Number.isNaN(stored) && stored > 0)
|
|
20
|
+
initial = stored;
|
|
21
|
+
}
|
|
22
|
+
widths.set(key, initial);
|
|
23
|
+
return initial;
|
|
24
|
+
}
|
|
25
|
+
function set(key, value) {
|
|
26
|
+
widths.set(key, value);
|
|
27
|
+
if (typeof localStorage !== 'undefined')
|
|
28
|
+
localStorage.setItem(key, String(value));
|
|
29
|
+
}
|
|
30
|
+
export const paneWidths = { get, hydrate, set };
|