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.
Files changed (35) hide show
  1. package/README.md +8 -9
  2. package/dist/components/Accordion.svelte +1 -1
  3. package/dist/components/AccordionItem.svelte +7 -3
  4. package/dist/components/Anchor.svelte +12 -12
  5. package/dist/components/BreadcrumbItem.svelte +1 -1
  6. package/dist/components/Button.svelte +16 -16
  7. package/dist/components/Checkbox.svelte +10 -10
  8. package/dist/components/Combobox.svelte +13 -13
  9. package/dist/components/DataGrid.svelte +4 -4
  10. package/dist/components/DataGridCell.svelte +8 -8
  11. package/dist/components/DataGridRow.svelte +3 -3
  12. package/dist/components/Dialog.svelte +5 -5
  13. package/dist/components/Listbox.svelte +3 -3
  14. package/dist/components/MenuButton.svelte +3 -3
  15. package/dist/components/NumberField.svelte +15 -15
  16. package/dist/components/Option.svelte +6 -6
  17. package/dist/components/Paginator.svelte +4 -4
  18. package/dist/components/QuickGrid.svelte +1 -1
  19. package/dist/components/Select.svelte +13 -0
  20. package/dist/components/Slider.svelte +12 -12
  21. package/dist/components/Switch.svelte +8 -8
  22. package/dist/components/TabPanel.svelte +1 -1
  23. package/dist/components/TextField.svelte +14 -14
  24. package/dist/components/Textarea.svelte +16 -16
  25. package/dist/components/Toolbar.svelte +3 -3
  26. package/dist/components/layout/MultiSplitter.svelte +1152 -157
  27. package/dist/components/layout/MultiSplitter.svelte.d.ts +19 -9
  28. package/dist/components/layout/MultiSplitterPane.svelte +78 -99
  29. package/dist/components/layout/MultiSplitterPane.svelte.d.ts +7 -4
  30. package/dist/components/layout/index.d.ts +1 -0
  31. package/dist/types/multi-splitter.d.ts +35 -0
  32. package/dist/types/multi-splitter.js +9 -0
  33. package/dist/version.d.ts +1 -1
  34. package/dist/version.js +1 -1
  35. package/package.json +1 -1
@@ -1,25 +1,35 @@
1
- import type { SlotType } from "../../types/index.js";
2
- type Orientation = "horizontal" | "vertical";
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 MultiSplitterResizeEventArgs = {
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
- barSize?: string;
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 PaneStatus = "normal" | "collapsed" | "expanded"
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
- minSize?: string
11
- maxSize?: string
12
- resizable?: boolean
13
- collapsible?: boolean
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
- minSize = undefined,
22
- maxSize = undefined,
23
- resizable = true,
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
- let element: HTMLDivElement | undefined = $state()
30
- let index = $state(-1)
31
- let status = $state<PaneStatus>("normal")
32
- let isLast = $state(false)
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
- const splitter = getContext<{
35
- orientation: "horizontal" | "vertical"
36
- registerPane: (pane: any) => number
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 (splitter && element) {
45
- index = splitter.registerPane({
46
- element,
47
- size,
48
- minSize,
49
- maxSize,
50
- resizable,
51
- collapsible,
52
- status
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 (splitter && index >= 0) {
59
- splitter.unregisterPane(index)
60
- }
68
+ if (handle) ctx.unregisterPane(handle)
61
69
  })
62
70
 
63
- let computedStyle = $derived(
64
- [
65
- size && (splitter.orientation === "horizontal" ? `width: ${size};` : `height: ${size};`),
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
- let isExpandable = $derived(status === "collapsed")
82
- let isCollapsible = $derived(collapsible && status !== "collapsed")
83
- let isResizable = $derived(resizable && status !== "collapsed")
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={element}
88
- class="fluent-multi-splitter-pane {className}"
89
- style={computedStyle}
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
- data-status={status}
96
+ style={style}
97
+ onclick={handlePaneClick}
92
98
  >
93
99
  {@render children?.()}
94
100
  </div>
95
101
 
96
102
  {#if !isLast}
97
- <!-- svelte-ignore a11y_click_events_have_key_events -->
98
- <!-- svelte-ignore a11y_no_static_element_interactions -->
103
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
104
+ <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
99
105
  <div
100
- class="fluent-multi-splitter-bar"
101
- data-status={status}
102
- onmousedown={(e) => splitter.resizeExec(e, index)}
103
- onclick={(e) => {
104
- e.preventDefault()
105
- e.stopPropagation()
106
- }}
107
- >
108
- {#if isCollapsible}
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
- minSize?: string;
6
- maxSize?: string;
7
- resizable?: boolean;
8
- collapsible?: boolean;
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.3.2";
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.3.2";
4
+ export const VERSION = "1.4.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-fluentui",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "A Svelte wrapper library for Microsoft FluentUI web components",
5
5
  "license": "MIT",
6
6
  "author": "KeenMate",