fluentui-svelte 0.6.0 → 0.7.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 (243) hide show
  1. package/dist/components/app-surface/app-surface.svelte +96 -0
  2. package/dist/components/app-surface/app-surface.svelte.d.ts +22 -0
  3. package/dist/components/app-surface/docs/llms.md +73 -0
  4. package/dist/components/app-surface/types.d.ts +19 -0
  5. package/dist/components/app-surface/types.js +1 -0
  6. package/dist/components/app-window/app-window.d.ts +3 -0
  7. package/dist/components/app-window/app-window.js +3 -0
  8. package/dist/components/app-window/app-window.svelte +193 -0
  9. package/dist/components/app-window/app-window.svelte.d.ts +25 -0
  10. package/dist/components/app-window/docs/llms.md +119 -0
  11. package/dist/components/app-window/types.d.ts +66 -0
  12. package/dist/components/app-window/types.js +1 -0
  13. package/dist/components/auto-suggest-box/auto-suggest-box.svelte +47 -31
  14. package/dist/components/auto-suggest-box/auto-suggest-box.svelte.d.ts +2 -2
  15. package/dist/components/auto-suggest-box/docs/llms.md +34 -33
  16. package/dist/components/auto-suggest-box/option.svelte +6 -4
  17. package/dist/components/auto-suggest-box/types.d.ts +13 -16
  18. package/dist/components/avatar/avatar.svelte +4 -3
  19. package/dist/components/avatar/docs/llms.md +1 -1
  20. package/dist/components/avatar/type.d.ts +1 -1
  21. package/dist/components/badge/badge-icon.svelte +2 -2
  22. package/dist/components/badge/badge.svelte +2 -2
  23. package/dist/components/badge/docs/llms.md +2 -2
  24. package/dist/components/badge/types.d.ts +2 -2
  25. package/dist/components/breadcrumb/breadcrumb-button.svelte +2 -2
  26. package/dist/components/breadcrumb/breadcrumb-divider.svelte +2 -2
  27. package/dist/components/breadcrumb/breadcrumb-item.svelte +2 -2
  28. package/dist/components/breadcrumb/breadcrumb.svelte +10 -5
  29. package/dist/components/breadcrumb/docs/llms.md +11 -11
  30. package/dist/components/breadcrumb/types.d.ts +7 -7
  31. package/dist/components/button/button.svelte +2 -2
  32. package/dist/components/button/docs/llms.md +17 -17
  33. package/dist/components/button/split-button.svelte +7 -7
  34. package/dist/components/button/types.d.ts +5 -5
  35. package/dist/components/calendar-date-picker/calendar-date-picker.svelte +98 -10
  36. package/dist/components/calendar-date-picker/calendar-date-picker.svelte.d.ts +1 -1
  37. package/dist/components/calendar-date-picker/docs/llms.md +19 -14
  38. package/dist/components/calendar-date-picker/types.d.ts +22 -8
  39. package/dist/components/calendar-view/calendar-view-days.svelte +3 -2
  40. package/dist/components/calendar-view/calendar-view-grid.js +8 -3
  41. package/dist/components/calendar-view/calendar-view-item.svelte +10 -4
  42. package/dist/components/calendar-view/calendar-view-months.svelte +3 -2
  43. package/dist/components/calendar-view/calendar-view-years.svelte +3 -2
  44. package/dist/components/calendar-view/calendar-view.svelte +11 -4
  45. package/dist/components/calendar-view/calendar-view.svelte.js +5 -0
  46. package/dist/components/calendar-view/docs/llms.md +20 -19
  47. package/dist/components/calendar-view/types.d.ts +6 -1
  48. package/dist/components/card/card-footer.svelte +2 -2
  49. package/dist/components/card/card-header.svelte +5 -4
  50. package/dist/components/card/card-preview.svelte +13 -2
  51. package/dist/components/card/card.svelte +5 -5
  52. package/dist/components/card/docs/llms.md +22 -21
  53. package/dist/components/card/types.d.ts +8 -4
  54. package/dist/components/checkbox/checkbox.svelte +47 -26
  55. package/dist/components/checkbox/checkbox.svelte.d.ts +3 -24
  56. package/dist/components/checkbox/docs/llms.md +24 -23
  57. package/dist/components/checkbox/types.d.ts +10 -23
  58. package/dist/components/date-picker/date-picker.svelte +98 -27
  59. package/dist/components/date-picker/date-picker.svelte.d.ts +1 -1
  60. package/dist/components/date-picker/docs/llms.md +23 -20
  61. package/dist/components/date-picker/types.d.ts +24 -15
  62. package/dist/components/dialog/dialog-actions.svelte +2 -2
  63. package/dist/components/dialog/dialog-content.svelte +2 -2
  64. package/dist/components/dialog/dialog-surface.svelte +102 -9
  65. package/dist/components/dialog/dialog-title.svelte +2 -2
  66. package/dist/components/dialog/dialog-trigger.svelte +2 -2
  67. package/dist/components/dialog/dialog.svelte +22 -11
  68. package/dist/components/dialog/docs/llms.md +56 -19
  69. package/dist/components/dialog/types.d.ts +25 -7
  70. package/dist/components/divider/divider.svelte +6 -4
  71. package/dist/components/divider/types.d.ts +1 -1
  72. package/dist/components/dropdown/docs/llms.md +30 -28
  73. package/dist/components/dropdown/dropdown-option.svelte +17 -5
  74. package/dist/components/dropdown/dropdown.svelte +182 -84
  75. package/dist/components/dropdown/dropdown.svelte.d.ts +1 -1
  76. package/dist/components/dropdown/types.d.ts +26 -20
  77. package/dist/components/dropdown-select/docs/llms.md +24 -22
  78. package/dist/components/dropdown-select/dropdown-select-option.svelte +2 -2
  79. package/dist/components/dropdown-select/dropdown-select.svelte +42 -7
  80. package/dist/components/dropdown-select/types.d.ts +4 -4
  81. package/dist/components/expander/docs/llms.md +3 -3
  82. package/dist/components/expander/expander.svelte +13 -8
  83. package/dist/components/expander/types.d.ts +5 -5
  84. package/dist/components/flyout/docs/llms.md +1 -1
  85. package/dist/components/flyout/flyout.svelte +17 -6
  86. package/dist/components/flyout/types.d.ts +1 -1
  87. package/dist/components/hyperlink/docs/llms.md +6 -6
  88. package/dist/components/hyperlink/hyperlink.svelte +13 -4
  89. package/dist/components/hyperlink/types.d.ts +1 -1
  90. package/dist/components/info-bar/docs/llms.md +11 -10
  91. package/dist/components/info-bar/info-bar.svelte +3 -2
  92. package/dist/components/info-bar/types.d.ts +4 -0
  93. package/dist/components/label/docs/llms.md +75 -22
  94. package/dist/components/label/label-context.d.ts +14 -0
  95. package/dist/components/label/label-context.js +10 -0
  96. package/dist/components/label/label.svelte +153 -30
  97. package/dist/components/label/label.svelte.d.ts +1 -1
  98. package/dist/components/label/types.d.ts +48 -4
  99. package/dist/components/list-view/docs/llms.md +103 -33
  100. package/dist/components/list-view/list-view-item-branch.svelte +257 -0
  101. package/dist/components/list-view/list-view-item-branch.svelte.d.ts +4 -0
  102. package/dist/components/list-view/list-view-item.svelte +164 -46
  103. package/dist/components/list-view/list-view-item.svelte.d.ts +5 -5
  104. package/dist/components/list-view/list-view.svelte +73 -25
  105. package/dist/components/list-view/types.d.ts +71 -8
  106. package/dist/components/list-view/utils.d.ts +10 -0
  107. package/dist/components/list-view/utils.js +17 -1
  108. package/dist/components/menu/docs/llms.md +98 -15
  109. package/dist/components/menu/menu-command-bar-item.svelte +61 -0
  110. package/dist/components/menu/menu-command-bar-item.svelte.d.ts +14 -0
  111. package/dist/components/menu/menu-command-bar.svelte +218 -0
  112. package/dist/components/menu/menu-command-bar.svelte.d.ts +21 -0
  113. package/dist/components/menu/menu-group.svelte +6 -3
  114. package/dist/components/menu/menu-item-checkbox.svelte +5 -4
  115. package/dist/components/menu/menu-item-radio.svelte +5 -4
  116. package/dist/components/menu/menu-item-switch.svelte +5 -4
  117. package/dist/components/menu/menu-item.svelte +5 -5
  118. package/dist/components/menu/menu-item.svelte.d.ts +2 -3
  119. package/dist/components/menu/menu-list.svelte +10 -1
  120. package/dist/components/menu/menu-popover.svelte +9 -5
  121. package/dist/components/menu/menu-trigger.svelte +2 -1
  122. package/dist/components/menu/menu.svelte.js +1 -0
  123. package/dist/components/menu/types.d.ts +62 -7
  124. package/dist/components/number-box/docs/llms.md +6 -4
  125. package/dist/components/number-box/number-box.svelte +35 -29
  126. package/dist/components/number-box/number-box.svelte.d.ts +1 -1
  127. package/dist/components/number-box/types.d.ts +1 -1
  128. package/dist/components/persona/docs/llms.md +29 -25
  129. package/dist/components/persona/persona.svelte +8 -6
  130. package/dist/components/persona/types.d.ts +4 -3
  131. package/dist/components/progress-bar/docs/llms.md +13 -13
  132. package/dist/components/progress-bar/progress-bar.svelte +6 -6
  133. package/dist/components/progress-bar/types.d.ts +4 -4
  134. package/dist/components/progress-ring/docs/llms.md +14 -14
  135. package/dist/components/progress-ring/progress-ring.svelte +5 -5
  136. package/dist/components/progress-ring/types.d.ts +3 -3
  137. package/dist/components/radio-button/docs/llms.md +11 -8
  138. package/dist/components/radio-button/radio-button.svelte +38 -12
  139. package/dist/components/radio-button/radio-button.svelte.d.ts +1 -1
  140. package/dist/components/radio-button/types.d.ts +11 -8
  141. package/dist/components/rating/docs/llms.md +15 -14
  142. package/dist/components/rating/rating.svelte +66 -29
  143. package/dist/components/rating/rating.svelte.d.ts +1 -1
  144. package/dist/components/rating/types.d.ts +8 -8
  145. package/dist/components/side-nav/docs/llms.md +110 -0
  146. package/dist/components/side-nav/side-nav-branch.svelte +43 -0
  147. package/dist/components/side-nav/side-nav-branch.svelte.d.ts +4 -0
  148. package/dist/components/side-nav/side-nav-item.svelte +75 -0
  149. package/dist/components/side-nav/side-nav-item.svelte.d.ts +25 -0
  150. package/dist/components/side-nav/side-nav-list.svelte +32 -0
  151. package/dist/components/side-nav/side-nav-list.svelte.d.ts +7 -0
  152. package/dist/components/side-nav/side-nav.d.ts +2 -0
  153. package/dist/components/side-nav/side-nav.js +2 -0
  154. package/dist/components/side-nav/side-nav.svelte +355 -0
  155. package/dist/components/side-nav/side-nav.svelte.d.ts +24 -0
  156. package/dist/components/side-nav/types.d.ts +149 -0
  157. package/dist/components/side-nav/types.js +1 -0
  158. package/dist/components/skeleton/docs/llms.md +1 -1
  159. package/dist/components/skeleton/skeleton.svelte +2 -2
  160. package/dist/components/skeleton/types.d.ts +1 -1
  161. package/dist/components/slider/docs/llms.md +31 -28
  162. package/dist/components/slider/slider.svelte +126 -61
  163. package/dist/components/slider/slider.svelte.d.ts +1 -3
  164. package/dist/components/slider/types.d.ts +21 -14
  165. package/dist/components/tab-view/docs/llms.md +7 -7
  166. package/dist/components/tab-view/tab-view-tab.svelte +16 -14
  167. package/dist/components/tab-view/tab-view.svelte +16 -9
  168. package/dist/components/tab-view/types.d.ts +6 -6
  169. package/dist/components/table/docs/llms.md +38 -33
  170. package/dist/components/table/table-body.svelte +2 -2
  171. package/dist/components/table/table-cell-actions.svelte +8 -2
  172. package/dist/components/table/table-cell-layout.svelte +2 -2
  173. package/dist/components/table/table-cell.svelte +2 -2
  174. package/dist/components/table/table-header-cell.svelte +2 -2
  175. package/dist/components/table/table-header.svelte +2 -2
  176. package/dist/components/table/table-row.svelte +2 -2
  177. package/dist/components/table/table-selection-cell.svelte +6 -6
  178. package/dist/components/table/table.svelte +2 -2
  179. package/dist/components/table/types.d.ts +11 -11
  180. package/dist/components/tag/docs/llms.md +26 -26
  181. package/dist/components/tag/tag-group.svelte +2 -2
  182. package/dist/components/tag/tag.svelte +13 -12
  183. package/dist/components/tag/types.d.ts +6 -4
  184. package/dist/components/tag-picker/docs/llms.md +61 -55
  185. package/dist/components/tag-picker/option-group.svelte +17 -4
  186. package/dist/components/tag-picker/option-group.svelte.d.ts +1 -1
  187. package/dist/components/tag-picker/option.svelte +15 -4
  188. package/dist/components/tag-picker/tag-picker.svelte +137 -65
  189. package/dist/components/tag-picker/tag-picker.svelte.d.ts +2 -2
  190. package/dist/components/tag-picker/types.d.ts +36 -16
  191. package/dist/components/text-box/docs/llms.md +31 -4
  192. package/dist/components/text-box/text-box-button.svelte +3 -3
  193. package/dist/components/text-box/text-box-button.svelte.d.ts +1 -1
  194. package/dist/components/text-box/text-box.svelte +41 -14
  195. package/dist/components/text-box/types.d.ts +5 -5
  196. package/dist/components/textarea/docs/llms.md +4 -3
  197. package/dist/components/textarea/textarea.svelte +14 -6
  198. package/dist/components/textarea/types.d.ts +2 -4
  199. package/dist/components/time-picker/docs/llms.md +18 -15
  200. package/dist/components/time-picker/time-picker.svelte +133 -33
  201. package/dist/components/time-picker/time-picker.svelte.d.ts +1 -1
  202. package/dist/components/time-picker/types.d.ts +23 -13
  203. package/dist/components/title-bar/docs/llms.md +382 -0
  204. package/dist/components/title-bar/title-bar-left-controls.svelte +215 -0
  205. package/dist/components/title-bar/title-bar-left-controls.svelte.d.ts +22 -0
  206. package/dist/components/title-bar/title-bar-right-controls.svelte +190 -0
  207. package/dist/components/title-bar/title-bar-right-controls.svelte.d.ts +27 -0
  208. package/dist/components/title-bar/title-bar.d.ts +3 -0
  209. package/dist/components/title-bar/title-bar.js +4 -0
  210. package/dist/components/title-bar/title-bar.svelte +224 -0
  211. package/dist/components/title-bar/title-bar.svelte.d.ts +26 -0
  212. package/dist/components/title-bar/types.d.ts +165 -0
  213. package/dist/components/title-bar/types.js +1 -0
  214. package/dist/components/toggle-switch/docs/llms.md +11 -9
  215. package/dist/components/toggle-switch/toggle-switch.svelte +23 -14
  216. package/dist/components/toggle-switch/toggle-switch.svelte.d.ts +1 -1
  217. package/dist/components/toggle-switch/types.d.ts +12 -10
  218. package/dist/components/tooltip/docs/llms.md +1 -1
  219. package/dist/components/tooltip/tooltip.svelte +5 -4
  220. package/dist/components/tooltip/types.d.ts +1 -1
  221. package/dist/components/top-nav/docs/llms.md +1 -1
  222. package/dist/components/top-nav/top-nav-item.svelte +2 -2
  223. package/dist/components/top-nav/top-nav.svelte +2 -2
  224. package/dist/components/top-nav/types.d.ts +2 -2
  225. package/dist/components/tree-view/docs/llms.md +11 -11
  226. package/dist/components/tree-view/tree-view-item-content.svelte +3 -3
  227. package/dist/components/tree-view/tree-view-item.svelte +13 -5
  228. package/dist/components/tree-view/tree-view.svelte +20 -5
  229. package/dist/components/tree-view/tree-view.svelte.d.ts +1 -1
  230. package/dist/components/tree-view/tree-view.svelte.js +31 -3
  231. package/dist/components/tree-view/types.d.ts +7 -3
  232. package/dist/index.d.ts +18 -0
  233. package/dist/index.js +20 -0
  234. package/dist/internal/components/dynamic-carousel/dynamic-carousel.svelte +26 -5
  235. package/dist/internal/components/dynamic-carousel/dynamic-carousel.svelte.d.ts +2 -0
  236. package/dist/internal/index.d.ts +1 -0
  237. package/dist/internal/index.js +1 -0
  238. package/dist/internal/native-field.svelte.d.ts +44 -0
  239. package/dist/internal/native-field.svelte.js +85 -0
  240. package/dist/internal/utils.d.ts +16 -2
  241. package/dist/internal/utils.js +25 -3
  242. package/dist/types/index.d.ts +3 -3
  243. package/package.json +50 -36
@@ -1,7 +1,8 @@
1
- import type { HTMLAttributes, HTMLButtonAttributes, HTMLInputAttributes } from 'svelte/elements';
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes, HTMLButtonAttributes, HTMLSelectAttributes } from 'svelte/elements';
2
3
  import type { ListViewProps, ListViewItemProps } from '../list-view/types.ts';
3
4
  import type { FlyoutProps } from '../flyout/types.ts';
4
- import type { FSContext } from '../../internal/index.js';
5
+ import type { FSContext, NativeFieldAttributes } from '../../internal/index.js';
5
6
  /** The value shape of a dropdown that allows more than one selection. */
6
7
  export type DropdownMultipleValue = {
7
8
  multiple: true;
@@ -28,34 +29,32 @@ export type DropdownProps = {
28
29
  placeholder?: string;
29
30
  /** Disables the user interaction. */
30
31
  disabled?: boolean;
31
- /** The name submitted with the form. Falls back to the id of the dropdown.
32
- * @default id
33
- */
32
+ /** The name the value is submitted under. Without one, the form leaves the value out, as with any field. */
34
33
  name?: string | null;
35
- /** The DOM reference of the dropdown element.
34
+ /** The DOM reference of the wrapper element.
36
35
  * @bindable
37
36
  */
38
- ref?: HTMLDivElement;
39
- /** Called when the dropdown is clicked. */
40
- onclick?: (e: MouseEvent) => void;
37
+ wrapperRef?: HTMLDivElement | null;
41
38
  /** The attributes to spread on the wrapper element.
42
39
  * @type HTMLAttributes
43
40
  */
44
- wrapperProps?: HTMLAttributes<HTMLDivElement>;
41
+ wrapperAttributes?: HTMLAttributes<HTMLDivElement>;
42
+ /** The DOM reference of the native select that holds the value. The other attributes of the dropdown are applied to it.
43
+ * @bindable
44
+ */
45
+ ref?: HTMLSelectElement | null;
45
46
  /** The DOM reference of the button that opens the dropdown.
46
47
  * @bindable
47
48
  */
48
- buttonRef?: HTMLButtonElement;
49
+ buttonRef?: HTMLButtonElement | null;
49
50
  /** The attributes to spread on the button that opens the dropdown.
50
51
  * @type HTMLButtonAttributes
51
52
  */
52
- buttonProps?: HTMLButtonAttributes;
53
- /** The DOM reference of the hidden input holding the value. */
54
- inputRef?: HTMLInputElement;
53
+ buttonAttributes?: Omit<HTMLButtonAttributes, 'type' | 'role' | 'value'>;
55
54
  /** The DOM reference of the flyout element.
56
55
  * @bindable
57
56
  */
58
- flyoutRef?: HTMLDivElement;
57
+ flyoutRef?: HTMLDivElement | null;
59
58
  /** The props to spread on the flyout.
60
59
  * @type FlyoutProps
61
60
  */
@@ -65,18 +64,25 @@ export type DropdownProps = {
65
64
  /** The DOM reference of the listbox element.
66
65
  * @bindable
67
66
  */
68
- listboxRef?: HTMLUListElement;
67
+ listboxRef?: HTMLUListElement | null;
69
68
  /** The props to spread on the listbox rendered inside the flyout.
70
69
  * @type ListViewProps
71
70
  */
72
71
  listboxProps?: Omit<ListViewProps<'ul'>, 'ref' | 'children' | 'selectedItems' | 'selectionMode'>;
73
- } & (DropdownMultipleValue | DropdownSingleValue) & Omit<HTMLInputAttributes, 'value' | 'onclick'>;
72
+ /** The `DropdownOption` elements of the list. */
73
+ children?: Snippet;
74
+ } & (DropdownMultipleValue | DropdownSingleValue) & NativeFieldAttributes<HTMLSelectAttributes>;
74
75
  /** @propsmith DropdownOptionProps */
75
76
  export type DropdownOptionProps = {
76
- /** The text shown by the dropdown once the option is selected. Falls back to the rendered children. */
77
+ /** The text shown by the dropdown once the option is selected. Falls back to the rendered children, which the server cannot read: pass it when rendering on the server. */
77
78
  text?: string;
78
79
  } & ListViewItemProps<'li'>;
80
+ /** What an option tells the trigger, read live. */
81
+ export type DropdownOptionLabel = {
82
+ readonly value?: string;
83
+ readonly text?: string;
84
+ };
79
85
  export type DropdownContext = FSContext<null, null, null, {
80
- /** Options report their display text so the trigger can show a label instead of the raw value. */
81
- registerOption: (value: string, text: string) => void;
86
+ /** Options report their display text so the trigger can show a label instead of the raw value. Returns the call that withdraws the option. */
87
+ registerOption: (option: DropdownOptionLabel) => () => void;
82
88
  }>;
@@ -11,7 +11,7 @@ The Dropdown Select is a dropdown built on the native `<select>` element. It let
11
11
  import { DropdownSelect, DropdownSelectOption } from 'fluentui-svelte';
12
12
  </script>
13
13
 
14
- <DropdownSelect>
14
+ <DropdownSelect aria-label="Choose an option">
15
15
  <DropdownSelectOption value="A">Option A</DropdownSelectOption>
16
16
  <DropdownSelectOption value="B">Option B</DropdownSelectOption>
17
17
  <DropdownSelectOption value="C">Option C</DropdownSelectOption>
@@ -25,13 +25,13 @@ The Dropdown Select is a dropdown built on the native `<select>` element. It let
25
25
  Options can render rich content such as a `Persona`. Provide a `text` prop for the plain-text selection label.
26
26
 
27
27
  ```svelte
28
- <DropdownSelect>
28
+ <DropdownSelect aria-label="Choose an option">
29
29
  <DropdownSelectOption value="John Doe" text="John Doe">
30
30
  <Persona
31
31
  name="John Doe"
32
32
  primaryText="Software Engineer"
33
33
  presence={{ status: 'available' }}
34
- avatar={{ color: 'colorful', idForColor: '' }}
34
+ avatarProps={{ color: 'colorful', idForColor: '' }}
35
35
  />
36
36
  </DropdownSelectOption>
37
37
  <DropdownSelectOption value="B">Option B</DropdownSelectOption>
@@ -44,28 +44,30 @@ Options can render rich content such as a `Persona`. Provide a `text` prop for t
44
44
  Set the `multiple` prop to allow selecting more than one option.
45
45
 
46
46
  ```svelte
47
- <DropdownSelect multiple>
47
+ <DropdownSelect multiple aria-label="Choose options">
48
48
  <DropdownSelectOption value="A">Option A</DropdownSelectOption>
49
49
  <DropdownSelectOption value="B">Option B</DropdownSelectOption>
50
50
  <DropdownSelectOption value="C">Option C</DropdownSelectOption>
51
51
  </DropdownSelect>
52
52
  ```
53
53
 
54
+ HTML attributes, including class, id and ARIA attributes, apply to the control element. Bind ref to access that control. Use wrapperAttributes and wrapperRef for the outer container.
55
+
54
56
  ## Component Props
55
57
 
56
58
  <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
57
59
  <!-- props:DropdownSelectProps -->
58
60
 
59
- | Name | Type | Default | Description |
60
- | ----------------------------- | -------------------------- | -------------------------- | ---------------------------------------------------------------------- |
61
- | `value` _bindable_ | `string` &#124; `string[]` | `multiple ? [] : ''` | The selected value. An array of values when `multiple` is set. |
62
- | `multiple` | `boolean` | | Allows more than one option to be selected at a time. |
63
- | `placeholder` | `string` | `'Native Select Dropdown'` | The text shown while no option is selected. |
64
- | `hidePlaceholder` | `boolean` | | Keeps the placeholder out of the option list once a value is selected. |
65
- | `ref` _bindable_ | `HTMLSelectElement` | | The DOM reference of the select element. |
66
- | `wrapperRef` _bindable_ | `HTMLDivElement` | | The DOM reference of the wrapper element. |
67
- | `wrapperProps` | `HTMLAttributes` | | The attributes to spread on the wrapper element. |
68
- | Element Attributes (`select`) | | | |
61
+ | Name | Type | Default | Description |
62
+ | ----------------------------- | --------------------------------- | -------------------------- | ---------------------------------------------------------------------- |
63
+ | `value` _bindable_ | `string` &#124; `string[]` | `multiple ? [] : ''` | The selected value. An array of values when `multiple` is set. |
64
+ | `multiple` | `boolean` | | Allows more than one option to be selected at a time. |
65
+ | `placeholder` | `string` | `'Native Select Dropdown'` | The text shown while no option is selected. |
66
+ | `hidePlaceholder` | `boolean` | | Keeps the placeholder out of the option list once a value is selected. |
67
+ | `ref` _bindable_ | `HTMLSelectElement` &#124; `null` | | The DOM reference of the select element. |
68
+ | `wrapperRef` _bindable_ | `HTMLDivElement` &#124; `null` | | The DOM reference of the wrapper element. |
69
+ | `wrapperAttributes` | `HTMLAttributes` | | The attributes to spread on the wrapper element. |
70
+ | Element Attributes (`select`) | | | |
69
71
 
70
72
  <!-- /props:DropdownSelectProps -->
71
73
 
@@ -74,13 +76,13 @@ Set the `multiple` prop to allow selecting more than one option.
74
76
  <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
75
77
  <!-- props:DropdownSelectOptionProps -->
76
78
 
77
- | Name | Type | Default | Description |
78
- | ----------------------------- | ------------- | ------- | ------------------------------------------------------------- |
79
- | `value` | `string` | | The value reported to the select when the option is picked. |
80
- | `text` | `string` | | The label of the option. Falls back to the rendered children. |
81
- | `disabled` | `boolean` | | Disables the user interaction. |
82
- | `ref` _bindable_ | `HTMLElement` | | The DOM reference of the option element. |
83
- | `children` | `Snippet` | | The content of the option, used when no `text` is given. |
84
- | Element Attributes (`option`) | | | |
79
+ | Name | Type | Default | Description |
80
+ | ----------------------------- | --------------------------- | ------- | ------------------------------------------------------------- |
81
+ | `value` | `string` | | The value reported to the select when the option is picked. |
82
+ | `text` | `string` | | The label of the option. Falls back to the rendered children. |
83
+ | `disabled` | `boolean` | | Disables the user interaction. |
84
+ | `ref` _bindable_ | `HTMLElement` &#124; `null` | | The DOM reference of the option element. |
85
+ | `children` | `Snippet` | | The content of the option, used when no `text` is given. |
86
+ | Element Attributes (`option`) | | | |
85
87
 
86
88
  <!-- /props:DropdownSelectOptionProps -->
@@ -6,14 +6,14 @@
6
6
  value,
7
7
  text,
8
8
  disabled,
9
- ref = $bindable(),
9
+ ref = $bindable(null),
10
10
  class: classes,
11
11
  children,
12
12
  ...attributes
13
13
  }: DropdownSelectOptionProps = $props();
14
14
  </script>
15
15
 
16
- <option class="fs-dropdown-select-option {classes}" {value} {disabled} bind:this={ref} {...attributes}>
16
+ <option {...attributes} class="fs-dropdown-select-option {classes}" {value} {disabled} bind:this={ref}>
17
17
  <span class="option-content">
18
18
  <CheckmarkFilled class="checkmark" width="16" height="16" />
19
19
  {#if text}
@@ -1,22 +1,29 @@
1
1
  <script lang="ts">
2
+ import { claimLabel } from '../label/label-context.js';
3
+ import { flushSync } from 'svelte';
2
4
  import ChevronDownFilled from 'fluentui-icons-svelte/ChevronDownFilled.svelte';
3
5
  import { selectDirection } from './dropdown-select.svelte.js';
4
6
  import type { DropdownSelectProps } from './types.js';
5
7
 
8
+ const labelContext = claimLabel(() => id);
9
+
6
10
  let {
7
11
  hidePlaceholder,
8
12
  placeholder = 'Native Select Dropdown',
9
- ref = $bindable(),
13
+ ref = $bindable(null),
10
14
  children,
11
- wrapperRef = $bindable(),
12
- wrapperProps,
15
+ wrapperRef = $bindable(null),
16
+ wrapperAttributes,
13
17
  multiple,
18
+ class: classes,
14
19
  value = $bindable(multiple ? [] : ''),
20
+ id = labelContext?.fieldId,
21
+ name = id,
15
22
  ...attributes
16
23
  }: DropdownSelectProps = $props();
17
24
  </script>
18
25
 
19
- <div class="fs-dropdown" bind:this={wrapperRef} {...wrapperProps}>
26
+ <div {...wrapperAttributes} class={['fs-dropdown', wrapperAttributes?.class]} bind:this={wrapperRef}>
20
27
  {#if !multiple}
21
28
  <ChevronDownFilled class="indicator" />
22
29
  {/if}
@@ -25,17 +32,40 @@
25
32
  We need to use a if block with the same structure
26
33
  -->
27
34
  {#if multiple}
28
- <select class="fs-dropdown-select" {@attach selectDirection()} multiple bind:value bind:this={ref} {...attributes}>
35
+ <select
36
+ {...attributes}
37
+ {id}
38
+ {name}
39
+ class={['fs-dropdown-select', classes]}
40
+ {@attach selectDirection()}
41
+ multiple
42
+ bind:value
43
+ bind:this={ref}
44
+ >
29
45
  <button>
30
46
  <selectedcontent></selectedcontent>
31
47
  </button>
32
48
  {#if !hidePlaceholder}
33
- <option class="fs-dropdown-placeholder" disabled selected hidden value="">{placeholder}</option>
49
+ <option class="fs-dropdown-placeholder" disabled selected={!value?.length} hidden value="">{placeholder}</option
50
+ >
34
51
  {/if}
35
52
  {@render children?.()}
36
53
  </select>
37
54
  {:else}
38
- <select class="fs-dropdown-select" {@attach selectDirection()} bind:value bind:this={ref} {...attributes}>
55
+ <select
56
+ {...attributes}
57
+ {id}
58
+ {name}
59
+ class={['fs-dropdown-select', classes]}
60
+ {@attach selectDirection()}
61
+ bind:value
62
+ bind:this={ref}
63
+ oninputcapture={(event) => {
64
+ // selectedcontent mutates before change; sync the binding before its observer restores the old value.
65
+ flushSync(() => (value = event.currentTarget.value));
66
+ attributes.oninputcapture?.(event);
67
+ }}
68
+ >
39
69
  <button>
40
70
  <selectedcontent></selectedcontent>
41
71
  </button>
@@ -94,6 +124,11 @@
94
124
  left: 0;
95
125
  background-color: var(--fs-accent-fill-default);
96
126
  }
127
+ &:has(select:is(:user-invalid, [aria-invalid='true'])):after {
128
+ width: calc(100%);
129
+ left: 0;
130
+ background-color: var(--fs-system-critical);
131
+ }
97
132
  & .fs-dropdown-select {
98
133
  border-radius: 0;
99
134
  background: unset;
@@ -19,15 +19,15 @@ export type DropdownSelectProps = {
19
19
  /** The DOM reference of the select element.
20
20
  * @bindable
21
21
  */
22
- ref?: HTMLSelectElement;
22
+ ref?: HTMLSelectElement | null;
23
23
  /** The DOM reference of the wrapper element.
24
24
  * @bindable
25
25
  */
26
- wrapperRef?: HTMLDivElement;
26
+ wrapperRef?: HTMLDivElement | null;
27
27
  /** The attributes to spread on the wrapper element.
28
28
  * @type HTMLAttributes
29
29
  */
30
- wrapperProps?: HTMLAttributes<HTMLDivElement>;
30
+ wrapperAttributes?: HTMLAttributes<HTMLDivElement>;
31
31
  } & HTMLSelectAttributes;
32
32
  /** @propsmith DropdownSelectOptionProps */
33
33
  export type DropdownSelectOptionProps = {
@@ -40,7 +40,7 @@ export type DropdownSelectOptionProps = {
40
40
  /** The DOM reference of the option element.
41
41
  * @bindable
42
42
  */
43
- ref?: HTMLElement;
43
+ ref?: HTMLElement | null;
44
44
  /** The content of the option, used when no `text` is given. */
45
45
  children?: Snippet;
46
46
  } & HTMLOptionAttributes;
@@ -86,10 +86,10 @@ You can easily add an icon to an expander's header using the `Icon` prop. You ca
86
86
  | `disabled` | `boolean` | `false` | Disables the user interaction. |
87
87
  | `animation` | `{ duration: number; easing: string; }` | | The animation configuration. Reduced motion is always honoured over this. |
88
88
  | `expanded` _bindable_ | `boolean` | `false` | Control the opening state of the expander. |
89
- | `ref` _bindable_ | `HTMLDetailsElement` | | The DOM reference of the expander element. |
89
+ | `ref` _bindable_ | `HTMLDetailsElement` &#124; `null` | | The DOM reference of the expander element. |
90
90
  | `Icon` | `Snippet` &#124; `Component` | | The icon to display before the label. |
91
- | `summaryRef` _bindable_ | `HTMLElement` | | The DOM reference of the summary element. |
92
- | `summaryProps` | `HTMLAttributes` | | The props to spread on the summary element. |
91
+ | `summaryRef` _bindable_ | `HTMLElement` &#124; `null` | | The DOM reference of the summary element. |
92
+ | `summaryAttributes` | `HTMLAttributes<HTMLElement>` | | The HTML attributes to spread on the summary element. |
93
93
  | Element Attributes (`details`) | | | |
94
94
 
95
95
  <!-- /props:ExpanderProps -->
@@ -13,12 +13,12 @@
13
13
  direction = 'down',
14
14
  animation,
15
15
  justify = false,
16
- ref = $bindable(),
16
+ ref = $bindable(null),
17
17
  expanded = $bindable(false),
18
18
  children,
19
19
  Icon,
20
- summaryRef = $bindable(),
21
- summaryProps,
20
+ summaryRef = $bindable(null),
21
+ summaryAttributes,
22
22
  ...attributes
23
23
  }: ExpanderProps = $props();
24
24
 
@@ -66,17 +66,22 @@ improve the user experience.
66
66
  ```
67
67
  -->
68
68
  <details
69
+ {...attributes}
69
70
  bind:this={ref}
70
71
  bind:open={expanded}
71
72
  use:expander
72
- class={['fs-expander', direction, { disabled, justify }]}
73
- {...attributes}
73
+ class={['fs-expander', direction, { disabled, justify }, attributes?.class]}
74
74
  >
75
75
  <summary
76
- class="fs-summary"
77
- onclick={(e) => invokeHandlers(e, [disabled], [supportInterpolation && (() => e.preventDefault()), handleClick])}
76
+ {...summaryAttributes}
77
+ class={['fs-summary', summaryAttributes?.class]}
78
+ onclick={(e) =>
79
+ invokeHandlers(
80
+ e,
81
+ [disabled],
82
+ [supportInterpolation && (() => e.preventDefault()), handleClick, summaryAttributes?.onclick]
83
+ )}
78
84
  bind:this={summaryRef}
79
- {...summaryProps}
80
85
  >
81
86
  <span class="row">
82
87
  {#if Icon}
@@ -31,7 +31,7 @@ export type ExpanderProps = {
31
31
  /** The DOM reference of the expander element.
32
32
  * @bindable
33
33
  */
34
- ref?: HTMLDetailsElement;
34
+ ref?: HTMLDetailsElement | null;
35
35
  /** The icon to display before the label.
36
36
  * @type Snippet | Component
37
37
  */
@@ -39,9 +39,9 @@ export type ExpanderProps = {
39
39
  /** The DOM reference of the summary element.
40
40
  * @bindable
41
41
  */
42
- summaryRef?: HTMLElement;
43
- /** The props to spread on the summary element.
44
- * @type HTMLAttributes
42
+ summaryRef?: HTMLElement | null;
43
+ /** The HTML attributes to spread on the summary element.
44
+ * @type HTMLAttributes<HTMLElement>
45
45
  */
46
- summaryProps?: HTMLAttributes<HTMLElement>;
46
+ summaryAttributes?: HTMLAttributes<HTMLElement>;
47
47
  } & HTMLDetailsAttributes;
@@ -23,7 +23,7 @@ The Flyout.
23
23
 
24
24
  | Name | Type | Default | Description |
25
25
  | -------------------------- | ------------------------------------------------------------------------- | ---------- | ------------------------------------------------------------------------------- |
26
- | `ref` _bindable_ | `HTMLElement` | | The DOM reference of the flyout element. |
26
+ | `ref` _bindable_ | `HTMLElement` &#124; `null` | | The DOM reference of the flyout element. |
27
27
  | `children` | `Snippet` | | The content of the flyout. |
28
28
  | `floating` | `boolean` | `false` | Positions the flyout with floating-ui instead of leaving it in the normal flow. |
29
29
  | `reference` | `HTMLElement` | | The element the flyout is positioned against when `floating` is set. |
@@ -1,11 +1,10 @@
1
1
  <script lang="ts">
2
- import { onMount } from 'svelte';
3
2
  import { computePosition, offset, autoPlacement, hide, autoUpdate, type Placement } from '@floating-ui/dom';
4
3
  import { roundByDPR } from '../../internal/index.js';
5
4
  import type { FlyoutProps } from './types.js';
6
5
 
7
6
  let {
8
- ref = $bindable(),
7
+ ref = $bindable(null),
9
8
  children,
10
9
  floating = false,
11
10
  reference,
@@ -14,6 +13,7 @@
14
13
  placementConfig,
15
14
  roundCorners = 'all',
16
15
  offset: offsetValue = 8,
16
+ hidden,
17
17
  class: classes,
18
18
  ...attributes
19
19
  }: FlyoutProps = $props();
@@ -37,9 +37,12 @@
37
37
  return 'round-all';
38
38
  }
39
39
 
40
- onMount(() => {
41
- if (floating && reference && ref) {
40
+ // A hidden flyout stays in the page unplaced, and is placed again once it shows.
41
+ $effect(() => {
42
+ if (floating && reference && ref && !hidden) {
42
43
  const middleware = [offset(offsetValue), autoPlacement(placementConfig), hide()];
44
+ // A position that arrives once the flyout is hidden or gone is dropped.
45
+ let placing = true;
43
46
  const update = async () => {
44
47
  if (!reference || !ref) return;
45
48
 
@@ -53,6 +56,8 @@
53
56
  middleware
54
57
  });
55
58
 
59
+ if (!placing || !ref) return;
60
+
56
61
  Object.assign(ref.style, {
57
62
  transform: `translate(${roundByDPR(x)}px, ${roundByDPR(y)}px)`,
58
63
  visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
@@ -64,7 +69,10 @@
64
69
  }
65
70
  };
66
71
  const cleanup = autoUpdate(reference, ref, update);
67
- return () => cleanup();
72
+ return () => {
73
+ placing = false;
74
+ cleanup();
75
+ };
68
76
  }
69
77
  });
70
78
  </script>
@@ -85,7 +93,7 @@ A contextual popup that displays a set of actions or options. It appears when us
85
93
  </Flyout>
86
94
  ```
87
95
  -->
88
- <div class={['fs-flyout', roundClass, classes, { floating }]} bind:this={ref} {...attributes}>
96
+ <div {...attributes} {hidden} class={['fs-flyout', roundClass, classes, { floating }]} bind:this={ref}>
89
97
  {@render children?.()}
90
98
  </div>
91
99
 
@@ -100,6 +108,9 @@ A contextual popup that displays a set of actions or options. It appears when us
100
108
  border: 1px solid var(--fs-control-surface-stroke-flyout);
101
109
  background-clip: padding-box;
102
110
  color: var(--fs-text-primary);
111
+ &[hidden] {
112
+ display: none;
113
+ }
103
114
  &.floating {
104
115
  position: absolute;
105
116
  top: 0;
@@ -6,7 +6,7 @@ export type FlyoutProps = {
6
6
  /** The DOM reference of the flyout element.
7
7
  * @bindable
8
8
  */
9
- ref?: HTMLElement;
9
+ ref?: HTMLElement | null;
10
10
  /** The content of the flyout. */
11
11
  children?: Snippet;
12
12
  /** Positions the flyout with floating-ui instead of leaving it in the normal flow.
@@ -27,11 +27,11 @@ Disables the hyperlink and prevents navigation.
27
27
  <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
28
28
  <!-- props:HyperlinkProps -->
29
29
 
30
- | Name | Type | Default | Description |
31
- | ------------------------ | ------------------- | ------- | ---------------------------------------- |
32
- | `href` | `string` | `'#'` | The URL the hyperlink points to. |
33
- | `disabled` | `boolean` | | Disables the user interaction. |
34
- | `ref` _bindable_ | `HTMLAnchorElement` | | The DOM reference of the anchor element. |
35
- | Element Attributes (`a`) | | | |
30
+ | Name | Type | Default | Description |
31
+ | ------------------------ | --------------------------------- | ------- | ---------------------------------------- |
32
+ | `href` | `string` | `'#'` | The URL the hyperlink points to. |
33
+ | `disabled` | `boolean` | | Disables the user interaction. |
34
+ | `ref` _bindable_ | `HTMLAnchorElement` &#124; `null` | | The DOM reference of the anchor element. |
35
+ | Element Attributes (`a`) | | | |
36
36
 
37
37
  <!-- /props:HyperlinkProps -->
@@ -1,7 +1,16 @@
1
1
  <script lang="ts">
2
+ import { invokeHandlers } from '../../internal/index.js';
2
3
  import type { HyperlinkProps } from './types.js';
3
4
 
4
- let { href = '#', disabled, class: classes, children, ref = $bindable(), ...attributes }: HyperlinkProps = $props();
5
+ let {
6
+ href = '#',
7
+ disabled,
8
+ onclick,
9
+ class: classes,
10
+ children,
11
+ ref = $bindable(null),
12
+ ...attributes
13
+ }: HyperlinkProps = $props();
5
14
  </script>
6
15
 
7
16
  <!--
@@ -19,14 +28,14 @@ F
19
28
  ```
20
29
  -->
21
30
  <a
31
+ {...attributes}
22
32
  // eslint-disable-next-line svelte/no-navigation-without-resolve
23
33
  {href}
24
34
  class={['fs-hyperlink', classes, { disabled }]}
25
- tabindex={disabled ? -1 : undefined}
35
+ tabindex={disabled ? -1 : attributes.tabindex}
26
36
  aria-disabled={disabled || undefined}
27
- onclick={disabled ? (e) => e?.preventDefault() : undefined}
37
+ onclick={(e) => invokeHandlers(e, disabled, [onclick])}
28
38
  bind:this={ref}
29
- {...attributes}
30
39
  >
31
40
  {#if children}
32
41
  {@render children()}
@@ -10,5 +10,5 @@ export type HyperlinkProps = {
10
10
  /** The DOM reference of the anchor element.
11
11
  * @bindable
12
12
  */
13
- ref?: HTMLAnchorElement;
13
+ ref?: HTMLAnchorElement | null;
14
14
  } & HTMLAnchorAttributes;
@@ -73,15 +73,16 @@ The hideCloseButton prop allows you to hide the close button in the InfoBar.
73
73
  <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
74
74
  <!-- props:InfoBarProps -->
75
75
 
76
- | Name | Type | Default | Description |
77
- | -------------------------- | ---------------------------------------------------------------------------------------------- | --------------- | ---------------------------------------------------------------------------- |
78
- | `status` | `'information'` &#124; `'attention'` &#124; `'warning'` &#124; `'critical'` &#124; `'success'` | `'information'` | The severity of the message, which picks the icon and the colors. |
79
- | `style` | `'inline'` &#124; `'multiline'` | `'inline'` | Lays the message out on a single line, or stacked below the title. |
80
- | `title` | `string` | | The title of the InfoBar. |
81
- | `icon` | `Snippet` &#124; `Component` | | Custom icon, rendered instead of the one the `status` would pick on its own. |
82
- | `iconSize` | `number` | `20` | The size of the icon in pixels. |
83
- | `hideCloseButton` | `boolean` | | Removes the button that dismisses the InfoBar. |
84
- | `children` | `Snippet` | | The message of the InfoBar. |
85
- | Element Attributes (`div`) | | | |
76
+ | Name | Type | Default | Description |
77
+ | -------------------------- | ---------------------------------------------------------------------------------------------- | --------------- | ----------------------------------------------------------------------------------------- |
78
+ | `status` | `'information'` &#124; `'attention'` &#124; `'warning'` &#124; `'critical'` &#124; `'success'` | `'information'` | The severity of the message, which picks the icon and the colors. |
79
+ | `style` | `'inline'` &#124; `'multiline'` | `'inline'` | Lays the message out on a single line, or stacked below the title. |
80
+ | `title` | `string` | | The title of the InfoBar. |
81
+ | `headingLevel` | `1` &#124; `2` &#124; `3` &#124; `4` &#124; `5` &#124; `6` | `3` | The level of the heading that holds the title, to fit the headings of the page around it. |
82
+ | `icon` | `Snippet` &#124; `Component` | | Custom icon, rendered instead of the one the `status` would pick on its own. |
83
+ | `iconSize` | `number` | `20` | The size of the icon in pixels. |
84
+ | `hideCloseButton` | `boolean` | | Removes the button that dismisses the InfoBar. |
85
+ | `children` | `Snippet` | | The message of the InfoBar. |
86
+ | Element Attributes (`div`) | | | |
86
87
 
87
88
  <!-- /props:InfoBarProps -->
@@ -12,6 +12,7 @@
12
12
  let {
13
13
  status = 'information',
14
14
  title,
15
+ headingLevel = 3,
15
16
  icon: Icon,
16
17
  style = 'inline',
17
18
  hideCloseButton,
@@ -55,7 +56,7 @@
55
56
  {/if}
56
57
  </div>
57
58
  <div class="content">
58
- {#if title}<h3>{title}</h3>{/if}
59
+ {#if title}<svelte:element this={`h${headingLevel}`} class="title">{title}</svelte:element>{/if}
59
60
  {@render children?.()}
60
61
  </div>
61
62
  {#if !hideCloseButton}
@@ -120,7 +121,7 @@
120
121
  align-items: center;
121
122
  gap: 0.5rem;
122
123
  width: 100%;
123
- & h3 {
124
+ & .title {
124
125
  font-weight: semibold;
125
126
  font-size: var(--fs-body-font-size);
126
127
  line-height: var(--fs-body-line-height);
@@ -12,6 +12,10 @@ export type InfoBarProps = {
12
12
  style?: 'inline' | 'multiline';
13
13
  /** The title of the InfoBar. */
14
14
  title?: string;
15
+ /** The level of the heading that holds the title, to fit the headings of the page around it.
16
+ * @default 3
17
+ */
18
+ headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
15
19
  /** Custom icon, rendered instead of the one the `status` would pick on its own.
16
20
  * @type Snippet | Component
17
21
  */