svelte-fluentui 1.3.2 → 1.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 +8 -9
- package/dist/components/Accordion.svelte +1 -1
- package/dist/components/AccordionItem.svelte +7 -3
- package/dist/components/Anchor.svelte +12 -12
- package/dist/components/BreadcrumbItem.svelte +1 -1
- package/dist/components/Button.svelte +16 -16
- package/dist/components/Checkbox.svelte +10 -10
- package/dist/components/Combobox.svelte +13 -13
- package/dist/components/DataGrid.svelte +4 -4
- package/dist/components/DataGridCell.svelte +8 -8
- package/dist/components/DataGridRow.svelte +3 -3
- package/dist/components/Dialog.svelte +5 -5
- package/dist/components/Listbox.svelte +3 -3
- package/dist/components/MenuButton.svelte +3 -3
- package/dist/components/NumberField.svelte +15 -15
- package/dist/components/Option.svelte +6 -6
- package/dist/components/Paginator.svelte +4 -4
- package/dist/components/QuickGrid.svelte +1 -1
- package/dist/components/Select.svelte +13 -0
- package/dist/components/Slider.svelte +12 -12
- package/dist/components/Switch.svelte +8 -8
- package/dist/components/TabPanel.svelte +1 -1
- package/dist/components/TextField.svelte +14 -14
- package/dist/components/Textarea.svelte +16 -16
- package/dist/components/Toolbar.svelte +3 -3
- package/dist/components/layout/MultiSplitter.svelte +1152 -157
- package/dist/components/layout/MultiSplitter.svelte.d.ts +19 -9
- package/dist/components/layout/MultiSplitterPane.svelte +78 -99
- package/dist/components/layout/MultiSplitterPane.svelte.d.ts +7 -4
- package/dist/components/layout/index.d.ts +1 -0
- package/dist/types/multi-splitter.d.ts +35 -0
- package/dist/types/multi-splitter.js +9 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
export type MultiSplitterEventArgs = {
|
|
1
|
+
export type { MultiSplitterContext, PaneHandle, PaneRegistration } from "../../types/multi-splitter.js";
|
|
2
|
+
export type MultiSplitterResizeDetail = {
|
|
4
3
|
index: number;
|
|
5
4
|
pane: HTMLElement;
|
|
5
|
+
size: number;
|
|
6
6
|
};
|
|
7
|
-
export type
|
|
7
|
+
export type MultiSplitterToggleDetail = {
|
|
8
8
|
index: number;
|
|
9
9
|
pane: HTMLElement;
|
|
10
|
-
size: number;
|
|
11
10
|
};
|
|
11
|
+
import type { SlotType } from "../../types/index.js";
|
|
12
|
+
type Orientation = "horizontal" | "vertical";
|
|
12
13
|
type Props = {
|
|
13
14
|
children?: SlotType;
|
|
14
15
|
orientation?: Orientation;
|
|
15
|
-
|
|
16
|
+
/** localStorage persistence key — saves under "fluent-multi-splitter:<id>". */
|
|
17
|
+
id?: string;
|
|
18
|
+
/** Keyboard step in px when a gutter is focused. */
|
|
19
|
+
step?: number;
|
|
20
|
+
/** Rail width in px when a pane is minimized. */
|
|
21
|
+
railSize?: number;
|
|
22
|
+
/** Drag-to-rail snap threshold as ratio of the drag-start size (0–1). */
|
|
23
|
+
minimizeThreshold?: number;
|
|
16
24
|
width?: string;
|
|
17
25
|
height?: string;
|
|
18
|
-
onCollapse?: (args: MultiSplitterEventArgs) => void;
|
|
19
|
-
onExpand?: (args: MultiSplitterEventArgs) => void;
|
|
20
|
-
onResize?: (args: MultiSplitterResizeEventArgs) => void;
|
|
21
26
|
class?: string;
|
|
22
27
|
style?: string;
|
|
28
|
+
/** Logs drag / minimize transitions to console (development aid). */
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
onresize?: (detail: MultiSplitterResizeDetail) => void;
|
|
31
|
+
oncollapse?: (detail: MultiSplitterToggleDetail) => void;
|
|
32
|
+
onexpand?: (detail: MultiSplitterToggleDetail) => void;
|
|
23
33
|
};
|
|
24
34
|
declare const MultiSplitter: import("svelte").Component<Props, {}, "">;
|
|
25
35
|
type MultiSplitter = ReturnType<typeof MultiSplitter>;
|
|
@@ -1,16 +1,34 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* MultiSplitterPane
|
|
3
|
+
*
|
|
4
|
+
* Child component of MultiSplitter. Registers itself with the parent via
|
|
5
|
+
* "multi-splitter" context on mount, receives a stable handle, and reads
|
|
6
|
+
* back a reactive `index` + `isLast` so it knows whether to render the
|
|
7
|
+
* trailing gutter (every pane except the last renders one — gutters
|
|
8
|
+
* alternate with panes in the parent flex row/column).
|
|
9
|
+
*
|
|
10
|
+
* Sizing/min/max/minimize are passed by prop instead of data-attrs.
|
|
11
|
+
*
|
|
12
|
+
* Drag/keyboard/click logic lives entirely in MultiSplitter; this component
|
|
13
|
+
* just forwards events to the context with its own handle so the parent
|
|
14
|
+
* knows which gutter was hit.
|
|
15
|
+
-->
|
|
16
|
+
|
|
1
17
|
<script lang="ts">
|
|
2
|
-
import type {SlotType} from "../../types/index.js"
|
|
3
18
|
import {getContext, onMount, onDestroy} from "svelte"
|
|
4
|
-
|
|
5
|
-
type
|
|
19
|
+
import type {SlotType} from "../../types/index.js"
|
|
20
|
+
import type {MultiSplitterContext, PaneHandle} from "../../types/multi-splitter.js"
|
|
6
21
|
|
|
7
22
|
type Props = {
|
|
8
23
|
children?: SlotType
|
|
24
|
+
/** Initial size: "200px" or "30%". If omitted, shares leftover with other unsized panes. */
|
|
9
25
|
size?: string
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
26
|
+
/** Min size: "150px" or "10%". Default 0. */
|
|
27
|
+
min?: string
|
|
28
|
+
/** Max size: "400px" or "50%". Default unbounded. */
|
|
29
|
+
max?: string
|
|
30
|
+
/** If true, pane can collapse to a rail. */
|
|
31
|
+
minimize?: boolean
|
|
14
32
|
class?: string
|
|
15
33
|
style?: string
|
|
16
34
|
}
|
|
@@ -18,119 +36,80 @@
|
|
|
18
36
|
let {
|
|
19
37
|
children = undefined,
|
|
20
38
|
size = undefined,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
collapsible = false,
|
|
39
|
+
min = undefined,
|
|
40
|
+
max = undefined,
|
|
41
|
+
minimize = false,
|
|
25
42
|
class: className = "",
|
|
26
43
|
style = ""
|
|
27
44
|
}: Props = $props()
|
|
28
45
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
const ctx = getContext<MultiSplitterContext>("multi-splitter")
|
|
47
|
+
if (!ctx) {
|
|
48
|
+
throw new Error("MultiSplitterPane must be a direct child of MultiSplitter")
|
|
49
|
+
}
|
|
33
50
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
unregisterPane: (index: number) => void
|
|
38
|
-
resizeExec: (e: MouseEvent, index: number) => void
|
|
39
|
-
collapseExec: (e: MouseEvent, index: number) => void
|
|
40
|
-
expandExec: (e: MouseEvent, index: number) => void
|
|
41
|
-
}>("multisplitter")
|
|
51
|
+
let paneEl: HTMLDivElement | undefined = $state()
|
|
52
|
+
let gutterEl: HTMLDivElement | undefined = $state()
|
|
53
|
+
let handle: PaneHandle | undefined = $state()
|
|
42
54
|
|
|
43
55
|
onMount(() => {
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
}
|
|
56
|
+
if (!paneEl) return
|
|
57
|
+
handle = ctx.registerPane({
|
|
58
|
+
el: paneEl,
|
|
59
|
+
getGutterEl: () => gutterEl,
|
|
60
|
+
size,
|
|
61
|
+
min,
|
|
62
|
+
max,
|
|
63
|
+
canMin: minimize
|
|
64
|
+
})
|
|
55
65
|
})
|
|
56
66
|
|
|
57
67
|
onDestroy(() => {
|
|
58
|
-
if (
|
|
59
|
-
splitter.unregisterPane(index)
|
|
60
|
-
}
|
|
68
|
+
if (handle) ctx.unregisterPane(handle)
|
|
61
69
|
})
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
minSize &&
|
|
67
|
-
(splitter.orientation === "horizontal"
|
|
68
|
-
? `min-width: ${minSize};`
|
|
69
|
-
: `min-height: ${minSize};`),
|
|
70
|
-
maxSize &&
|
|
71
|
-
(splitter.orientation === "horizontal"
|
|
72
|
-
? `max-width: ${maxSize};`
|
|
73
|
-
: `max-height: ${maxSize};`),
|
|
74
|
-
!size && "flex: 1;",
|
|
75
|
-
style
|
|
76
|
-
]
|
|
77
|
-
.filter(Boolean)
|
|
78
|
-
.join(" ")
|
|
79
|
-
)
|
|
71
|
+
const index = $derived(handle ? ctx.indexOf(handle) : -1)
|
|
72
|
+
const isLast = $derived(handle ? ctx.isLast(handle) : false)
|
|
73
|
+
const isMinimized = $derived(handle ? ctx.isMinimized(handle) : false)
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
function handleGutterPointerDown(e: PointerEvent) {
|
|
76
|
+
if (handle) ctx.onGutterPointerDown(e, handle)
|
|
77
|
+
}
|
|
78
|
+
function handleGutterKeydown(e: KeyboardEvent) {
|
|
79
|
+
if (handle) ctx.onGutterKeydown(e, handle)
|
|
80
|
+
}
|
|
81
|
+
function handleGutterDblClick(e: MouseEvent) {
|
|
82
|
+
if (handle) ctx.onGutterDblClick(e, handle)
|
|
83
|
+
}
|
|
84
|
+
function handlePaneClick(e: MouseEvent) {
|
|
85
|
+
if (handle) ctx.onPaneClick(e, handle)
|
|
86
|
+
}
|
|
84
87
|
</script>
|
|
85
88
|
|
|
89
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
90
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
86
91
|
<div
|
|
87
|
-
bind:this={
|
|
88
|
-
class="fluent-multi-splitter-pane {className}"
|
|
89
|
-
|
|
92
|
+
bind:this={paneEl}
|
|
93
|
+
class="fluent-multi-splitter-pane fluent-multi-splitter-pane--{ctx.orientation} {className}"
|
|
94
|
+
class:fluent-multi-splitter-pane--minimized={isMinimized}
|
|
90
95
|
data-index={index}
|
|
91
|
-
|
|
96
|
+
style={style}
|
|
97
|
+
onclick={handlePaneClick}
|
|
92
98
|
>
|
|
93
99
|
{@render children?.()}
|
|
94
100
|
</div>
|
|
95
101
|
|
|
96
102
|
{#if !isLast}
|
|
97
|
-
<!-- svelte-ignore
|
|
98
|
-
<!-- svelte-ignore
|
|
103
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
104
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
99
105
|
<div
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
110
|
-
<span
|
|
111
|
-
data-part="collapse"
|
|
112
|
-
onmousedown={(e) => {
|
|
113
|
-
e.preventDefault()
|
|
114
|
-
e.stopPropagation()
|
|
115
|
-
splitter.collapseExec(e, index)
|
|
116
|
-
}}
|
|
117
|
-
></span>
|
|
118
|
-
{/if}
|
|
119
|
-
|
|
120
|
-
{#if isResizable}
|
|
121
|
-
<span data-part="resize"></span>
|
|
122
|
-
{/if}
|
|
123
|
-
|
|
124
|
-
{#if isExpandable}
|
|
125
|
-
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
126
|
-
<span
|
|
127
|
-
data-part="expand"
|
|
128
|
-
onmousedown={(e) => {
|
|
129
|
-
e.preventDefault()
|
|
130
|
-
e.stopPropagation()
|
|
131
|
-
splitter.expandExec(e, index)
|
|
132
|
-
}}
|
|
133
|
-
></span>
|
|
134
|
-
{/if}
|
|
135
|
-
</div>
|
|
106
|
+
bind:this={gutterEl}
|
|
107
|
+
class="fluent-multi-splitter-gutter"
|
|
108
|
+
role="separator"
|
|
109
|
+
aria-orientation={ctx.orientation === "vertical" ? "horizontal" : "vertical"}
|
|
110
|
+
tabindex="0"
|
|
111
|
+
onpointerdown={handleGutterPointerDown}
|
|
112
|
+
onkeydown={handleGutterKeydown}
|
|
113
|
+
ondblclick={handleGutterDblClick}
|
|
114
|
+
></div>
|
|
136
115
|
{/if}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { SlotType } from "../../types/index.js";
|
|
2
2
|
type Props = {
|
|
3
3
|
children?: SlotType;
|
|
4
|
+
/** Initial size: "200px" or "30%". If omitted, shares leftover with other unsized panes. */
|
|
4
5
|
size?: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/** Min size: "150px" or "10%". Default 0. */
|
|
7
|
+
min?: string;
|
|
8
|
+
/** Max size: "400px" or "50%". Default unbounded. */
|
|
9
|
+
max?: string;
|
|
10
|
+
/** If true, pane can collapse to a rail. */
|
|
11
|
+
minimize?: boolean;
|
|
9
12
|
class?: string;
|
|
10
13
|
style?: string;
|
|
11
14
|
};
|
|
@@ -8,5 +8,6 @@ export { default as BodyContent } from "./BodyContent.svelte";
|
|
|
8
8
|
export { default as Grid } from "./Grid.svelte";
|
|
9
9
|
export { default as GridItem } from "./GridItem.svelte";
|
|
10
10
|
export { default as MultiSplitter } from "./MultiSplitter.svelte";
|
|
11
|
+
export type { MultiSplitterResizeDetail, MultiSplitterToggleDetail } from "./MultiSplitter.svelte";
|
|
11
12
|
export { default as MultiSplitterPane } from "./MultiSplitterPane.svelte";
|
|
12
13
|
export { default as Panel } from "./Panel.svelte";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for MultiSplitter / MultiSplitterPane communication via the
|
|
3
|
+
* "multi-splitter" Svelte context.
|
|
4
|
+
*
|
|
5
|
+
* PaneHandle is intentionally opaque from the pane's POV — it just holds it
|
|
6
|
+
* and passes it back to context methods for identity. The parent owns all
|
|
7
|
+
* working state attached to the handle.
|
|
8
|
+
*/
|
|
9
|
+
export type PaneRegistration = {
|
|
10
|
+
el: HTMLElement;
|
|
11
|
+
getGutterEl: () => HTMLElement | undefined;
|
|
12
|
+
size?: string;
|
|
13
|
+
min?: string;
|
|
14
|
+
max?: string;
|
|
15
|
+
canMin: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type PaneHandle = {
|
|
18
|
+
/** Opaque identity. Carries reactive `isMin` for the pane to read. */
|
|
19
|
+
readonly id: number;
|
|
20
|
+
readonly state: {
|
|
21
|
+
isMin: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type MultiSplitterContext = {
|
|
25
|
+
readonly orientation: "horizontal" | "vertical";
|
|
26
|
+
registerPane(opts: PaneRegistration): PaneHandle;
|
|
27
|
+
unregisterPane(handle: PaneHandle): void;
|
|
28
|
+
indexOf(handle: PaneHandle): number;
|
|
29
|
+
isLast(handle: PaneHandle): boolean;
|
|
30
|
+
isMinimized(handle: PaneHandle): boolean;
|
|
31
|
+
onGutterPointerDown(e: PointerEvent, handle: PaneHandle): void;
|
|
32
|
+
onGutterKeydown(e: KeyboardEvent, handle: PaneHandle): void;
|
|
33
|
+
onGutterDblClick(e: MouseEvent, handle: PaneHandle): void;
|
|
34
|
+
onPaneClick(e: MouseEvent, handle: PaneHandle): void;
|
|
35
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for MultiSplitter / MultiSplitterPane communication via the
|
|
3
|
+
* "multi-splitter" Svelte context.
|
|
4
|
+
*
|
|
5
|
+
* PaneHandle is intentionally opaque from the pane's POV — it just holds it
|
|
6
|
+
* and passes it back to context methods for identity. The parent owns all
|
|
7
|
+
* working state attached to the handle.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.4.0";
|
package/dist/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Auto-generated by scripts/pre-package.js — do NOT edit by hand.
|
|
2
2
|
// In dev this file holds whatever value was committed last; on each `npm run package`
|
|
3
3
|
// the pre-package script overwrites it with the current package.json version.
|
|
4
|
-
export const VERSION = "1.
|
|
4
|
+
export const VERSION = "1.4.0";
|