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.
- package/dist/components/auto-suggest-box/auto-suggest-box.svelte +68 -56
- package/dist/components/auto-suggest-box/docs/llms.md +46 -14
- package/dist/components/auto-suggest-box/option.svelte +2 -1
- package/dist/components/avatar/docs/llms.md +20 -14
- package/dist/components/badge/docs/llms.md +29 -16
- package/dist/components/button/button.svelte +11 -5
- package/dist/components/button/docs/llms.md +33 -24
- package/dist/components/calendar-date-picker/docs/llms.md +17 -7
- package/dist/components/calendar-view/calendar-view-header.svelte +2 -2
- package/dist/components/calendar-view/calendar-view-header.svelte.d.ts +2 -17
- package/dist/components/calendar-view/calendar-view-months.svelte +1 -1
- package/dist/components/calendar-view/calendar-view-years.svelte +1 -1
- package/dist/components/calendar-view/calendar-view.svelte +66 -52
- package/dist/components/calendar-view/docs/llms.md +42 -30
- package/dist/components/card/docs/llms.md +54 -34
- package/dist/components/checkbox/docs/llms.md +18 -12
- package/dist/components/date-picker/docs/llms.md +25 -15
- package/dist/components/dialog/dialog-surface.svelte +8 -8
- package/dist/components/dialog/dialog.svelte +41 -39
- package/dist/components/dialog/docs/llms.md +59 -34
- package/dist/components/divider/docs/llms.md +14 -9
- package/dist/components/dropdown/docs/llms.md +34 -15
- package/dist/components/dropdown/dropdown.svelte +4 -2
- package/dist/components/dropdown-select/docs/llms.md +28 -14
- package/dist/components/expander/docs/llms.md +19 -12
- package/dist/components/flyout/docs/llms.md +17 -11
- package/dist/components/hyperlink/docs/llms.md +11 -7
- package/dist/components/info-bar/docs/llms.md +15 -9
- package/dist/components/label/docs/llms.md +15 -11
- package/dist/components/list-view/docs/llms.md +34 -24
- package/dist/components/list-view/list-view-item.svelte +10 -4
- package/dist/components/list-view/list-view.svelte +68 -63
- package/dist/components/menu/context-menu-trigger.svelte +45 -40
- package/dist/components/menu/docs/llms.md +63 -34
- package/dist/components/menu/menu-item-checkbox.svelte +3 -1
- package/dist/components/menu/menu-item-radio.svelte +3 -1
- package/dist/components/menu/menu-item-switch.svelte +3 -1
- package/dist/components/menu/menu-item.svelte +5 -1
- package/dist/components/menu/menu-popover.svelte +21 -10
- package/dist/components/menu/menu-trigger.svelte +22 -9
- package/dist/components/menu/menu.svelte +98 -87
- package/dist/components/number-box/docs/llms.md +10 -6
- package/dist/components/persona/docs/llms.md +19 -14
- package/dist/components/progress-bar/docs/llms.md +18 -10
- package/dist/components/progress-ring/docs/llms.md +19 -12
- package/dist/components/radio-button/docs/llms.md +13 -8
- package/dist/components/skeleton/docs/llms.md +13 -8
- package/dist/components/slider/docs/llms.md +33 -21
- package/dist/components/slider/slider.svelte +13 -11
- package/dist/components/text-box/docs/llms.md +23 -17
- package/dist/components/textarea/docs/llms.md +16 -7
- package/dist/components/time-picker/docs/llms.md +20 -10
- package/dist/components/toggle-switch/docs/llms.md +13 -9
- package/dist/components/tooltip/docs/llms.md +24 -10
- package/dist/components/tree-view/docs/llms.md +53 -35
- package/dist/components/tree-view/tree-view-item-content.svelte +1 -1
- package/dist/components/tree-view/tree-view-item.svelte +3 -3
- package/dist/components/tree-view/tree-view.svelte +89 -93
- package/dist/providers/fluentui-svelte/fluentui-svelte.svelte +15 -15
- 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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
| `
|
|
55
|
-
|
|
|
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'` | `'both'` | `'horizontal'` | `'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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
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` | `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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
|
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
|
|
|
65
|
+
<!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
|
|
66
|
+
<!-- props:TooltipProps -->
|
|
67
|
+
|
|
68
|
+
| Name | Type | Default | Description |
|
|
69
|
+
| --------------------------------------------------- | -------------------------------------------------------- | ------------------ | -------------------------------------------------------------------------------------------------------- |
|
|
70
|
+
| `content` | `string` | `Snippet` | `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'` | `'description'` | `'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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `onOpenChange`
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
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'` | `'medium'` | `'large'` | `'medium'` | The size of every item in the tree. |
|
|
84
|
+
| `navigationMode` | `'tree'` | `'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'` | `'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[]` | `SvelteSet<string>` | | The ids of the open branches. A `SvelteSet` is required when a `virtualizer` is set. |
|
|
90
|
+
| `checkedItems` _bindable_ | `string[]` | `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` | `TreeViewStaticProps` | | | |
|
|
93
|
+
| Element Attributes (`ul`) | | | |
|
|
94
|
+
|
|
95
|
+
<!-- /props:TreeViewProps -->
|
|
89
96
|
|
|
90
97
|
## Component Props (TreeViewItem)
|
|
91
98
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
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'` | `'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` | `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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
| `
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
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` | `Component` | | Custom icon for the control that opens a branch. |
|
|
129
|
+
| `iconBefore` | `Snippet` | `Component` | | Content rendered before the label. |
|
|
130
|
+
| `iconAfter` | `Snippet` | `Component` | | Content rendered after the label. |
|
|
131
|
+
| `aside` | `Snippet` | `Component` | | Content pinned to the end of the row. |
|
|
132
|
+
| `actions` | `Snippet` | `Component` | | Content pinned to the end of the row, revealed on hover and on focus. |
|
|
133
|
+
| Element Attributes (`div`) | | | |
|
|
134
|
+
|
|
135
|
+
<!-- /props:TreeViewItemLayoutProps -->
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
|
|
41
41
|
const { config, methods } = context;
|
|
42
42
|
|
|
43
|
-
const
|
|
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
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
openItems
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
117
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
|
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
|
|
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:
|
|
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(
|
|
60
|
+
root.dataset.fsReducedMotion = String(context.state.reducedMotion);
|
|
61
61
|
|
|
62
62
|
return () => {
|
|
63
63
|
delete root.dataset.fsReducedMotion;
|