fluentui-svelte 0.2.0 → 0.2.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.
Files changed (60) hide show
  1. package/dist/components/auto-suggest-box/auto-suggest-box.svelte +68 -56
  2. package/dist/components/auto-suggest-box/docs/llms.md +46 -14
  3. package/dist/components/auto-suggest-box/option.svelte +2 -1
  4. package/dist/components/avatar/docs/llms.md +20 -14
  5. package/dist/components/badge/docs/llms.md +29 -16
  6. package/dist/components/button/button.svelte +11 -5
  7. package/dist/components/button/docs/llms.md +33 -24
  8. package/dist/components/calendar-date-picker/docs/llms.md +17 -7
  9. package/dist/components/calendar-view/calendar-view-header.svelte +2 -2
  10. package/dist/components/calendar-view/calendar-view-header.svelte.d.ts +2 -17
  11. package/dist/components/calendar-view/calendar-view-months.svelte +1 -1
  12. package/dist/components/calendar-view/calendar-view-years.svelte +1 -1
  13. package/dist/components/calendar-view/calendar-view.svelte +66 -52
  14. package/dist/components/calendar-view/docs/llms.md +42 -30
  15. package/dist/components/card/docs/llms.md +54 -34
  16. package/dist/components/checkbox/docs/llms.md +18 -12
  17. package/dist/components/date-picker/docs/llms.md +25 -15
  18. package/dist/components/dialog/dialog-surface.svelte +8 -8
  19. package/dist/components/dialog/dialog.svelte +41 -39
  20. package/dist/components/dialog/docs/llms.md +59 -34
  21. package/dist/components/divider/docs/llms.md +14 -9
  22. package/dist/components/dropdown/docs/llms.md +34 -15
  23. package/dist/components/dropdown/dropdown.svelte +4 -2
  24. package/dist/components/dropdown-select/docs/llms.md +28 -14
  25. package/dist/components/expander/docs/llms.md +19 -12
  26. package/dist/components/flyout/docs/llms.md +17 -11
  27. package/dist/components/hyperlink/docs/llms.md +11 -7
  28. package/dist/components/info-bar/docs/llms.md +15 -9
  29. package/dist/components/label/docs/llms.md +15 -11
  30. package/dist/components/list-view/docs/llms.md +34 -24
  31. package/dist/components/list-view/list-view-item.svelte +10 -4
  32. package/dist/components/list-view/list-view.svelte +68 -63
  33. package/dist/components/menu/context-menu-trigger.svelte +45 -40
  34. package/dist/components/menu/docs/llms.md +63 -34
  35. package/dist/components/menu/menu-item-checkbox.svelte +3 -1
  36. package/dist/components/menu/menu-item-radio.svelte +3 -1
  37. package/dist/components/menu/menu-item-switch.svelte +3 -1
  38. package/dist/components/menu/menu-item.svelte +5 -1
  39. package/dist/components/menu/menu-popover.svelte +21 -10
  40. package/dist/components/menu/menu-trigger.svelte +22 -9
  41. package/dist/components/menu/menu.svelte +98 -87
  42. package/dist/components/number-box/docs/llms.md +10 -6
  43. package/dist/components/persona/docs/llms.md +19 -14
  44. package/dist/components/progress-bar/docs/llms.md +18 -10
  45. package/dist/components/progress-ring/docs/llms.md +19 -12
  46. package/dist/components/radio-button/docs/llms.md +13 -8
  47. package/dist/components/skeleton/docs/llms.md +13 -8
  48. package/dist/components/slider/docs/llms.md +33 -21
  49. package/dist/components/slider/slider.svelte +13 -11
  50. package/dist/components/text-box/docs/llms.md +23 -17
  51. package/dist/components/textarea/docs/llms.md +16 -7
  52. package/dist/components/time-picker/docs/llms.md +20 -10
  53. package/dist/components/toggle-switch/docs/llms.md +13 -9
  54. package/dist/components/tooltip/docs/llms.md +24 -10
  55. package/dist/components/tree-view/docs/llms.md +53 -35
  56. package/dist/components/tree-view/tree-view-item-content.svelte +1 -1
  57. package/dist/components/tree-view/tree-view-item.svelte +3 -3
  58. package/dist/components/tree-view/tree-view.svelte +89 -93
  59. package/dist/providers/fluentui-svelte/fluentui-svelte.svelte +15 -15
  60. package/package.json +1 -1
@@ -46,10 +46,19 @@ The `onChange` event is triggered whenever the content of the textarea changes.
46
46
 
47
47
  ## Component Props
48
48
 
49
- | Name | Type | Description |
50
- | ------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------ |
51
- | `placeholder` | `string` | The placeholder text for the textarea. |
52
- | `resize` | `string` | Controls the resizing behavior of the textarea. Possible values: `'none'`, `'both'`, `'horizontal'`, `'vertical'`. |
53
- | `onChange` | `function` | Event handler for when the content of the textarea changes. |
54
- | `element` | | The DOM reference of the textarea element. |
55
- | Element Attributes | | All other attributes that can be applied to the textarea element. |
49
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
50
+ <!-- props:TextAreaProps -->
51
+
52
+ | Name | Type | Default | Description |
53
+ | -------------------------------- | ------------------------------------------------------------------ | ------------ | ------------------------------------------------ |
54
+ | `value` _bindable_ | `string` | `''` | The current value of the textarea. |
55
+ | `ref` _bindable_ | `HTMLElement` | | The DOM reference of the textarea element. |
56
+ | `placeholder` | `string` | | The placeholder text for the textarea. |
57
+ | `resize` | `'none'` &#124; `'both'` &#124; `'horizontal'` &#124; `'vertical'` | `'vertical'` | Configures the resize behavior of the textarea. |
58
+ | `onChange` | `(e: Event) => void` | | Callback function for the change event. |
59
+ | `disabled` | `boolean` | `false` | Disables the user interaction. |
60
+ | `wrapperAttributes` | `HTMLAttributes` | | The attributes to spread on the wrapper element. |
61
+ | `wrapperRef` _bindable_ | `HTMLDivElement` | | The DOM reference of the wrapper element. |
62
+ | `SvelteHTMLElements['textarea']` | | | |
63
+
64
+ <!-- /props:TextAreaProps -->
@@ -35,13 +35,23 @@ Use `hideHours`, `hideMinutes`, or `hideSeconds` to hide individual columns. By
35
35
 
36
36
  ## Component Props
37
37
 
38
- | Name | Type | Description |
39
- | -------------- | --------------------------- | ------------------------------------------------------------------------------- |
40
- | `value` | bindable `string` | Selected time as 24h `HH:mm` or `HH:mm:ss` (matches `<input type="time">`). |
41
- | `format` | `12 \| 24` | Clock format: `24` (00–23) or `12` (01–12 with an AM/PM column). Default: `24`. |
42
- | `open` | bindable `boolean` | Whether the picker flyout is open. |
43
- | `hideHours` | `boolean` | Hide the hours column. |
44
- | `hideMinutes` | `boolean` | Hide the minutes column. |
45
- | `hideSeconds` | `boolean` | Hide the seconds column. |
46
- | `element` | bindable `HTMLElement` | The DOM reference of the time picker root element. |
47
- | `inputElement` | bindable `HTMLInputElement` | The DOM reference of the underlying input element. |
38
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
39
+ <!-- props:TimePickerProps -->
40
+
41
+ | Name | Type | Default | Description |
42
+ | ----------------------------- | --------------------- | ----------------- | --------------------------------------------------------------------------------------------------- |
43
+ | `value` _bindable_ | `string` | `''` | Selected time as 24h `HH:mm` or `HH:mm:ss` (matches `<input type="time">`). |
44
+ | `format` | `12` &#124; `24` | `24` | Clock format: `24` (00-23) or `12` (01-12 with an AM/PM column). |
45
+ | `open` _bindable_ | `boolean` | `false` | Controls the open state of the picker. |
46
+ | `hideHours` | `boolean` | `false` | Removes the hour column. |
47
+ | `hideMinutes` | `boolean` | `false` | Removes the minute column. |
48
+ | `hideSeconds` | `boolean` | `false` | Removes the second column. |
49
+ | `element` _bindable_ | `HTMLButtonElement` | | The DOM reference of the trigger button. |
50
+ | `wrapperRef` _bindable_ | `HTMLDivElement` | | The DOM reference of the element wrapping the trigger and its input. |
51
+ | `wrapperAttributes` | `HTMLAttributes` | | The attributes to spread on the wrapper element. |
52
+ | `inputElement` _bindable_ | `HTMLInputElement` | | The DOM reference of the underlying input element. |
53
+ | `inputProps` | `HTMLInputAttributes` | | HTML attributes for the underlying input element. Give it a `name` to submit the value with a form. |
54
+ | `popupLabel` | `string` | `'Choose a time'` | The accessible name of the popup, which is announced as a dialog. |
55
+ | Element Attributes (`button`) | | | |
56
+
57
+ <!-- /props:TimePickerProps -->
@@ -28,12 +28,16 @@ A toggle switch can be labeled, checked, or disabled.
28
28
 
29
29
  ## Component Props
30
30
 
31
- | Name | Type | Description |
32
- | ------------------ | --------------------- | ------------------------------------------------------------ |
33
- | `ref` | `HTMLInputElement` | Get the DOM reference of the input element. |
34
- | `label` | `string` | The label for the toggle switch. |
35
- | `labelAttributes` | `HTMLLabelAttributes` | Attributes to be spread on the label wrapper element. |
36
- | `labelElement` | `HTMLLabelElement` | Get the DOM reference of the label element. |
37
- | `disabled` | `boolean` | Whether the toggle switch is disabled. |
38
- | `checked` | `boolean` | Whether the toggle switch is checked (on). |
39
- | Element Attributes | `object` | Additional attributes to apply to the toggle switch element. |
31
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
32
+ <!-- props:ToggleSwitchProps -->
33
+
34
+ | Name | Type | Default | Description |
35
+ | ----------------------------- | --------------------- | ------- | ---------------------------------------------------------- |
36
+ | `checked` _bindable_ | `boolean` | | Whether the switch is on. |
37
+ | `ref` _bindable_ | `HTMLInputElement` | | The DOM reference of the input element. |
38
+ | `label` | `string` | | The label displayed next to the input element. |
39
+ | `labelAttributes` | `HTMLLabelAttributes` | | The attributes to spread on the label wrapping the switch. |
40
+ | `labelElement` | `HTMLLabelElement` | | The DOM reference of the label element. |
41
+ | `SvelteHTMLElements['input']` | | | |
42
+
43
+ <!-- /props:ToggleSwitchProps -->
@@ -62,13 +62,27 @@ The relationship prop allows you to specify the relationship between the tooltip
62
62
 
63
63
  ## Component Props
64
64
 
65
- | Name | Type | Description |
66
- | ------------------ | -------------------------------- | --------------------------------------------------------------------------------------------------------------- |
67
- | `content` | `string \| Snippet \| Component` | The content to be displayed in the tooltip. This can be a string, a Svelte component, or a Snippet. |
68
- | `positionConfig` | `Partial<ComputePositionConfig>` | The position configuration of the tooltip. This allows you to define custom offsets, middleware, and more. |
69
- | `withArrow` | `boolean` | Whether the tooltip should display an arrow pointing towards the target element. |
70
- | `openDelay` | `number` | The delay, in milliseconds, before the tooltip is shown after the user hovers over the target element. |
71
- | `hideDelay` | `number` | The delay, in milliseconds, before the tooltip is hidden after the user stops hovering over the target element. |
72
- | `onVisibleChange` | `(visible: boolean) => void` | A callback function that is called whenever the visibility of the tooltip changes. |
73
- | `element` | `HTMLElement` | The DOM reference of the tooltip element. |
74
- | Element Attributes | | All other attributes that can be applied to the tooltip element. |
65
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
66
+ <!-- props:TooltipProps -->
67
+
68
+ | Name | Type | Default | Description |
69
+ | --------------------------------------------------- | -------------------------------------------------------- | ------------------ | -------------------------------------------------------------------------------------------------------- |
70
+ | `content` | `string` &#124; `Snippet` &#124; `Component` | `'I am a tooltip'` | The content to display in the tooltip. |
71
+ | `class` | `string` | | The class to apply to the tooltip. |
72
+ | `ref` _bindable_ | `HTMLElement` | | The DOM reference of the tooltip element. |
73
+ | `target` | `HTMLElement` | | The element the tooltip is anchored to. Falls back to the rendered children. |
74
+ | `open` _bindable_ | `boolean` | `false` | Controls the open state of the tooltip. |
75
+ | `withArrow` | `boolean` | `false` | Whether the tooltip has an arrow pointing at its target. |
76
+ | `positionConfig` | `ComputePositionConfig` | | The position configuration handed over to floating-ui. |
77
+ | `openDelay` | `number` | `100` | The delay in milliseconds before the tooltip is shown. |
78
+ | `hideDelay` | `number` | `300` | The delay in milliseconds before the tooltip is hidden. |
79
+ | `onVisibleChange` | `(visible: boolean) => void` | | Callback function that is called when the visibility of the tooltip changes. |
80
+ | `relationship` | `'label'` &#124; `'description'` &#124; `'inaccessible'` | `'label'` | The relationship of the tooltip to its target, which decides how it is announced. |
81
+ | `placement` | `Placement` | | Where the tooltip is placed relative to its target. |
82
+ | `id` | `string` | | The id of the tooltip element, referenced by the target. Falls back to a generated id. |
83
+ | `preventClose` _bindable_ | `boolean` | `false` | Keeps the tooltip open until it is closed by hand. |
84
+ | `animationFrame` | `boolean` | `false` | Repositions the tooltip on every animation frame, for a target that keeps moving. |
85
+ | `children` | `Snippet` | | The target of the tooltip. It receives the ARIA attributes and the attachment to spread on your element. |
86
+ | `HTMLAttributes<HTMLDivElement>` without `children` | | | |
87
+
88
+ <!-- /props:TooltipProps -->
@@ -74,44 +74,62 @@ Use the bindable `openItems` and `checkedItems` props on the root `TreeView` to
74
74
 
75
75
  ## Component Props (TreeView)
76
76
 
77
- | Name | Type | Description |
78
- | ----------------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
79
- | `ref` | `HTMLUListElement` | Bindable DOM reference of the root ul element. |
80
- | `size` | `'small' \| 'medium' \| 'large'` | Visual size of the tree. Default is 'medium'. |
81
- | `navigationMode` | `'tree' \| 'treegrid'` | Keyboard navigation mode. Default is 'tree'. |
82
- | `selectionMode` | `'single' \| 'multiple'` | Selection mode for checkable items. Default is 'multiple'. |
83
- | `openItems` | `string[] \| SvelteSet<string>` | Bindable list or set of open item ids. Uses SvelteSet when a virtualizer is provided. |
84
- | `checkedItems` | `string[] \| SvelteSet<string>` | Bindable list or set of checked item ids. Uses SvelteSet when a virtualizer is provided. |
85
- | `onOpenChange` | `(e: Event, openItems: string[]) => void` | Callback fired when an item is expanded or collapsed. |
86
- | `onCheckedChange` | `(e: Event, checkedItems: string[]) => void` | Callback fired when an item is checked or unchecked. |
87
- | `virtualizer` | `TreeViewVirtualizer` | Optional adapter for windowing or virtual list libraries. When provided, only the rendered slice is in the DOM. |
88
- | `children` | `Snippet` | The TreeViewItem children of the tree. |
77
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
78
+ <!-- props:TreeViewProps -->
79
+
80
+ | Name | Type | Default | Description |
81
+ | --------------------------------------------------- | -------------------------------------------- | ------------ | ------------------------------------------------------------------------------------ |
82
+ | `ref` _bindable_ | `HTMLUListElement` | | The DOM reference of the tree element. |
83
+ | `size` | `'small'` &#124; `'medium'` &#124; `'large'` | `'medium'` | The size of every item in the tree. |
84
+ | `navigationMode` | `'tree'` &#124; `'treegrid'` | `'tree'` | Whether the tree takes a single tab stop, or every row is reachable on its own. |
85
+ | `onOpenChange` | `(e: Event, openItems: string[]) => void` | | Called whenever a branch opens or closes. |
86
+ | `selectionMode` | `'single'` &#124; `'multiple'` | `'multiple'` | How many items can be checked at a time. |
87
+ | `onCheckedChange` | `(e: Event, checkedItems: string[]) => void` | | Called whenever an item is checked or unchecked. |
88
+ | `virtualizer` | `TreeViewVirtualizer` | | Bridge to a windowing library. Only the rendered slice of items lives in the DOM. |
89
+ | `openItems` _bindable_ | `string[]` &#124; `SvelteSet<string>` | | The ids of the open branches. A `SvelteSet` is required when a `virtualizer` is set. |
90
+ | `checkedItems` _bindable_ | `string[]` &#124; `SvelteSet<string>` | | The ids of the checked items. A `SvelteSet` is required when a `virtualizer` is set. |
91
+ | `children` | `Snippet` | | The items of the tree. |
92
+ | `TreeViewVirtualProps` &#124; `TreeViewStaticProps` | | | |
93
+ | Element Attributes (`ul`) | | | |
94
+
95
+ <!-- /props:TreeViewProps -->
89
96
 
90
97
  ## Component Props (TreeViewItem)
91
98
 
92
- | Name | Type | Description |
93
- | ----------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------- |
94
- | `id` | `string` | Unique identifier of the item. Required for open and checked state tracking. |
95
- | `type` | `'item' \| 'branch'` | Whether the item is a leaf ('item') or a branch that can contain a nested TreeView. |
96
- | `ref` | `HTMLLIElement` | Bindable DOM reference of the li element. |
97
- | `value` | `string \| number` | Optional value associated with the item. |
98
- | `text` | `string` | Optional accessible text label used by the tree. |
99
- | `open` | `boolean` | Bindable open state for type='branch' items. |
100
- | `checked` | `boolean` | Bindable checked state for selectable items. |
101
- | `indeterminate` | `boolean` | Whether the item is in an indeterminate check state. |
102
- | `disabled` | `boolean` | Disables the item. |
103
- | `index` | `number` | Explicit index — used with a virtualizer to keep keyboard navigation in sync. |
104
- | `onOpenChange` | `(e: Event, data: { id: string; open: boolean }) => void` | Callback fired when this item is expanded or collapsed. |
105
- | `onCheckedChange` | `(e: Event, data: { id: string; checked: boolean }) => void` | Callback fired when this item is checked or unchecked. |
99
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
100
+ <!-- props:TreeViewItemProps -->
101
+
102
+ | Name | Type | Default | Description |
103
+ | ------------------------- | ------------------------------------------------------------ | -------- | -------------------------------------------------------------------------------------- |
104
+ | `id` | `string` | | The id of the item, used by the tree to track its state. Falls back to a generated id. |
105
+ | `type` | `'item'` &#124; `'branch'` | `'item'` | Whether the item holds children, and can therefore be opened. |
106
+ | `ref` | `HTMLLIElement` | | The DOM reference of the item element. |
107
+ | `value` | `string` &#124; `number` | `id` | The value reported by the tree events. Falls back to the id of the item. |
108
+ | `text` | `string` | | The label of the item, used by the type-ahead navigation. |
109
+ | `open` | `boolean` | | Whether the branch is open. |
110
+ | `checked` | `boolean` | | Whether the item is checked. |
111
+ | `indeterminate` | `boolean` | | Renders the checkbox in its mixed state, when only some children are checked. |
112
+ | `disabled` | `boolean` | | Disables the user interaction. |
113
+ | `index` | `number` | | The real index of the item in the data set. Required when the tree is virtualized. |
114
+ | `onOpenChange` | `(e: Event, data: { id: string; open: boolean }) => void` | | Called when this branch opens or closes. |
115
+ | `onCheckedChange` | `(e: Event, data: { id: string; checked: boolean }) => void` | | Called when this item is checked or unchecked. |
116
+ | Element Attributes (`li`) | | | |
117
+
118
+ <!-- /props:TreeViewItemProps -->
106
119
 
107
120
  ## Component Props (TreeViewItemContent)
108
121
 
109
- | Name | Type | Description |
110
- | ------------ | ---------------------- | ----------------------------------------------------------- |
111
- | `ref` | `HTMLDivElement` | Bindable DOM reference of the layout element. |
112
- | `expandIcon` | `Snippet \| Component` | Custom icon rendered for the expand or collapse affordance. |
113
- | `iconBefore` | `Snippet \| Component` | Icon rendered before the item text. |
114
- | `iconAfter` | `Snippet \| Component` | Icon rendered after the item text. |
115
- | `aside` | `Snippet \| Component` | Content rendered on the trailing side of the row. |
116
- | `actions` | `Snippet \| Component` | Interactive actions rendered on hover or focus. |
117
- | `children` | `Snippet` | The item label content. |
122
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
123
+ <!-- props:TreeViewItemLayoutProps -->
124
+
125
+ | Name | Type | Default | Description |
126
+ | -------------------------- | ---------------------------- | ------- | --------------------------------------------------------------------- |
127
+ | `ref` | `HTMLDivElement` | | The DOM reference of the layout element. |
128
+ | `expandIcon` | `Snippet` &#124; `Component` | | Custom icon for the control that opens a branch. |
129
+ | `iconBefore` | `Snippet` &#124; `Component` | | Content rendered before the label. |
130
+ | `iconAfter` | `Snippet` &#124; `Component` | | Content rendered after the label. |
131
+ | `aside` | `Snippet` &#124; `Component` | | Content pinned to the end of the row. |
132
+ | `actions` | `Snippet` &#124; `Component` | | Content pinned to the end of the row, revealed on hover and on focus. |
133
+ | Element Attributes (`div`) | | | |
134
+
135
+ <!-- /props:TreeViewItemLayoutProps -->
@@ -16,7 +16,7 @@
16
16
 
17
17
  const { config, methods } = TREE_VIEW_CONTEXT;
18
18
 
19
- const { size } = config;
19
+ const size = $derived(config.size);
20
20
 
21
21
  const { handleCheck } = methods;
22
22
  </script>
@@ -40,9 +40,9 @@
40
40
 
41
41
  const { config, methods } = context;
42
42
 
43
- const { size } = config;
43
+ const size = $derived(config.size);
44
44
 
45
- const itemState: TreeViewItemContext = {
45
+ const itemState: TreeViewItemContext = $state({
46
46
  get disabled() {
47
47
  return itemContext?.disabled ?? disabled;
48
48
  },
@@ -79,7 +79,7 @@
79
79
  set indeterminate(v) {
80
80
  indeterminate = v;
81
81
  }
82
- };
82
+ });
83
83
 
84
84
  setTreeViewItemContext(itemState);
85
85
 
@@ -35,106 +35,102 @@
35
35
  ...attributes
36
36
  }: TreeViewProps = $props();
37
37
 
38
- const config: TreeViewContext['config'] = $derived({
39
- navigationMode: CONTEXT?.config.navigationMode || navigationMode,
40
- size: CONTEXT?.config.size || size,
41
- virtualized: CONTEXT?.config.virtualized ?? !!virtualizer,
42
- virtualCount: CONTEXT?.config.virtualCount ?? virtualizer?.size
43
- });
44
-
45
38
  let forceVirtualRender = $state(false);
46
39
 
47
- const _state: TreeViewContext['state'] = {
48
- get openItems() {
49
- return openItems;
50
- },
51
- get checkedItems() {
52
- return checkedItems;
53
- },
54
- get selectionMode() {
55
- return selectionMode;
56
- },
57
- get TREE_NODES() {
58
- return CONTEXT?.state.TREE_NODES ?? TREE_NODES;
59
- },
60
- get forceVirtualRender() {
61
- return CONTEXT?.state.forceVirtualRender ?? forceVirtualRender;
62
- },
63
- set forceVirtualRender(v) {
64
- if (CONTEXT?.state.forceVirtualRender) {
65
- CONTEXT.state.forceVirtualRender = v;
66
- } else {
67
- forceVirtualRender = v;
68
- }
69
- }
70
- };
71
-
72
- const events: TreeViewContext['events'] = $derived({
73
- onCheckedChange: CONTEXT?.events.onCheckedChange ?? ((e, data) => onCheckedChange?.(e, data)),
74
- onOpenChange: CONTEXT?.events.onOpenChange ?? ((e, data) => onOpenChange?.(e, data))
75
- });
76
-
77
- const methods: TreeViewContext['methods'] = {
78
- handleCheck: async (e, id, checked) => {
79
- if (virtualizer) {
80
- _state.forceVirtualRender = true;
81
- await tick();
82
- }
83
-
84
- if (_state.selectionMode === 'single') {
85
- traversalSyncSingleSelection(id, _state.TREE_NODES, checkedItems);
86
- return;
40
+ const treeViewContext: TreeViewContext = $state({
41
+ config: {
42
+ get navigationMode() {
43
+ return CONTEXT?.config.navigationMode || navigationMode;
44
+ },
45
+ get size() {
46
+ return CONTEXT?.config.size || size;
47
+ },
48
+ get virtualized() {
49
+ return CONTEXT?.config.virtualized ?? !!virtualizer;
50
+ },
51
+ get virtualCount() {
52
+ return CONTEXT?.config.virtualCount ?? virtualizer?.size;
87
53
  }
88
-
89
- traversalSync(id, _state.TREE_NODES, checkedItems, checked);
90
54
  },
91
- openItem: (e, id) => {
92
- if (openItems instanceof SvelteSet) {
93
- openItems.add(id);
94
- } else {
95
- openItems = [...openItems, id];
96
- }
97
- const node = _state.TREE_NODES.get(id)!;
98
-
99
- node.open = true;
100
- },
101
- closeItem: (e, id) => {
102
- if (openItems instanceof SvelteSet) {
103
- openItems.delete(id);
104
- } else {
105
- openItems = openItems.filter((itemId) => itemId !== id);
106
- }
107
- const node = _state.TREE_NODES.get(id)!;
108
-
109
- node.open = false;
110
-
111
- // If
112
- if (virtualizer && _state.forceVirtualRender) {
113
- _state.forceVirtualRender = false;
55
+ state: {
56
+ get openItems() {
57
+ return openItems;
58
+ },
59
+ get checkedItems() {
60
+ return checkedItems;
61
+ },
62
+ get selectionMode() {
63
+ return selectionMode;
64
+ },
65
+ get TREE_NODES() {
66
+ return CONTEXT?.state.TREE_NODES ?? TREE_NODES;
67
+ },
68
+ get forceVirtualRender() {
69
+ return CONTEXT?.state.forceVirtualRender ?? forceVirtualRender;
70
+ },
71
+ set forceVirtualRender(v) {
72
+ if (CONTEXT) {
73
+ CONTEXT.state.forceVirtualRender = v;
74
+ } else {
75
+ forceVirtualRender = v;
76
+ }
114
77
  }
115
78
  },
116
- registerItem: (node) => {
117
- _state.TREE_NODES.set(node.id, node);
79
+ events: {
80
+ onCheckedChange: CONTEXT?.events.onCheckedChange ?? ((e, data) => onCheckedChange?.(e, data)),
81
+ onOpenChange: CONTEXT?.events.onOpenChange ?? ((e, data) => onOpenChange?.(e, data))
118
82
  },
119
- unregisterItem: (id) => {
120
- _state.TREE_NODES.delete(id);
121
- }
122
- };
123
-
124
- const treeViewContext: TreeViewContext = {
125
- get config() {
126
- return config;
127
- },
128
- get state() {
129
- return _state;
130
- },
131
- get events() {
132
- return events;
133
- },
134
- get methods() {
135
- return methods;
83
+ methods: {
84
+ handleCheck: async (e, id, checked) => {
85
+ const { state } = treeViewContext;
86
+
87
+ if (virtualizer) {
88
+ state.forceVirtualRender = true;
89
+ await tick();
90
+ }
91
+
92
+ if (selectionMode === 'single') {
93
+ traversalSyncSingleSelection(id, state.TREE_NODES, checkedItems);
94
+ return;
95
+ }
96
+
97
+ traversalSync(id, state.TREE_NODES, checkedItems, checked);
98
+ },
99
+ openItem: (e, id) => {
100
+ if (openItems instanceof SvelteSet) {
101
+ openItems.add(id);
102
+ } else {
103
+ openItems = [...openItems, id];
104
+ }
105
+ const node = treeViewContext.state.TREE_NODES.get(id)!;
106
+
107
+ node.open = true;
108
+ },
109
+ closeItem: (e, id) => {
110
+ const { state } = treeViewContext;
111
+
112
+ if (openItems instanceof SvelteSet) {
113
+ openItems.delete(id);
114
+ } else {
115
+ openItems = openItems.filter((itemId) => itemId !== id);
116
+ }
117
+ const node = state.TREE_NODES.get(id)!;
118
+
119
+ node.open = false;
120
+
121
+ // If
122
+ if (virtualizer && state.forceVirtualRender) {
123
+ state.forceVirtualRender = false;
124
+ }
125
+ },
126
+ registerItem: (node) => {
127
+ treeViewContext.state.TREE_NODES.set(node.id, node);
128
+ },
129
+ unregisterItem: (id) => {
130
+ treeViewContext.state.TREE_NODES.delete(id);
131
+ }
136
132
  }
137
- };
133
+ });
138
134
 
139
135
  setTreeViewContext(treeViewContext);
140
136
 
@@ -194,7 +190,7 @@
194
190
  </script>
195
191
 
196
192
  <!-- Render only when necessary (virtualizer perf) -->
197
- {#if _state.forceVirtualRender || (config.virtualized && (!IS_SUB_TREE || ITEM_CONTEXT?.open)) || !config.virtualized}
193
+ {#if treeViewContext.state.forceVirtualRender || (treeViewContext.config.virtualized && (!IS_SUB_TREE || ITEM_CONTEXT?.open)) || !treeViewContext.config.virtualized}
198
194
  <ul
199
195
  class="fs-tree-view"
200
196
  role={IS_SUB_TREE ? 'group' : 'tree'}
@@ -20,21 +20,19 @@
20
20
  // Syncing
21
21
  let reducedMotion = $derived(userReducedMotion.current ?? prefersReducedMotion.current);
22
22
 
23
- const _state: FSProviderContext['state'] = {
24
- get tabspotInstance() {
25
- return tabspotInstance;
26
- },
27
- get reducedMotion() {
28
- return reducedMotion;
29
- },
30
- get theme() {
31
- return mode.current;
32
- }
33
- };
34
-
35
- setGlobalFSContext({
23
+ const context: FSProviderContext = $state({
36
24
  config: null,
37
- state: _state,
25
+ state: {
26
+ get tabspotInstance() {
27
+ return tabspotInstance;
28
+ },
29
+ get reducedMotion() {
30
+ return reducedMotion;
31
+ },
32
+ get theme() {
33
+ return mode.current;
34
+ }
35
+ },
38
36
  events: null,
39
37
  methods: {
40
38
  setReducedMotion: (value) => {
@@ -46,6 +44,8 @@
46
44
  }
47
45
  });
48
46
 
47
+ setGlobalFSContext(context);
48
+
49
49
  onMount(() => {
50
50
  tabspotInstance ??= tabspot();
51
51
 
@@ -57,7 +57,7 @@
57
57
  $effect(() => {
58
58
  const root = document.documentElement;
59
59
 
60
- root.dataset.fsReducedMotion = String(_state.reducedMotion);
60
+ root.dataset.fsReducedMotion = String(context.state.reducedMotion);
61
61
 
62
62
  return () => {
63
63
  delete root.dataset.fsReducedMotion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluentui-svelte",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Modern Fluent UI 2 Components for Svelte 5",
5
5
  "author": {
6
6
  "name": "Jorge Acosta",