fluentui-svelte 0.5.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 (259) 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 +17 -2
  63. package/dist/components/dialog/dialog-content.svelte +2 -2
  64. package/dist/components/dialog/dialog-content.svelte.d.ts +1 -1
  65. package/dist/components/dialog/dialog-surface.svelte +130 -8
  66. package/dist/components/dialog/dialog-title.svelte +23 -6
  67. package/dist/components/dialog/dialog-trigger.svelte +8 -2
  68. package/dist/components/dialog/dialog-trigger.svelte.d.ts +1 -1
  69. package/dist/components/dialog/dialog.svelte +22 -11
  70. package/dist/components/dialog/docs/llms.md +56 -19
  71. package/dist/components/dialog/types.d.ts +31 -9
  72. package/dist/components/dialog/utils.d.ts +2 -0
  73. package/dist/components/dialog/utils.js +1 -0
  74. package/dist/components/divider/divider.svelte +6 -4
  75. package/dist/components/divider/types.d.ts +1 -1
  76. package/dist/components/dropdown/docs/llms.md +30 -28
  77. package/dist/components/dropdown/dropdown-option.svelte +17 -5
  78. package/dist/components/dropdown/dropdown.svelte +182 -84
  79. package/dist/components/dropdown/dropdown.svelte.d.ts +1 -1
  80. package/dist/components/dropdown/types.d.ts +26 -20
  81. package/dist/components/dropdown-select/docs/llms.md +24 -22
  82. package/dist/components/dropdown-select/dropdown-select-option.svelte +2 -2
  83. package/dist/components/dropdown-select/dropdown-select.svelte +42 -7
  84. package/dist/components/dropdown-select/types.d.ts +4 -4
  85. package/dist/components/expander/docs/llms.md +3 -3
  86. package/dist/components/expander/expander.svelte +13 -8
  87. package/dist/components/expander/types.d.ts +5 -5
  88. package/dist/components/flyout/docs/llms.md +1 -1
  89. package/dist/components/flyout/flyout.svelte +17 -6
  90. package/dist/components/flyout/types.d.ts +1 -1
  91. package/dist/components/hyperlink/docs/llms.md +6 -6
  92. package/dist/components/hyperlink/hyperlink.svelte +13 -4
  93. package/dist/components/hyperlink/types.d.ts +1 -1
  94. package/dist/components/info-bar/docs/llms.md +11 -10
  95. package/dist/components/info-bar/info-bar.svelte +3 -2
  96. package/dist/components/info-bar/types.d.ts +4 -0
  97. package/dist/components/label/docs/llms.md +75 -22
  98. package/dist/components/label/label-context.d.ts +14 -0
  99. package/dist/components/label/label-context.js +10 -0
  100. package/dist/components/label/label.svelte +153 -30
  101. package/dist/components/label/label.svelte.d.ts +1 -1
  102. package/dist/components/label/types.d.ts +48 -4
  103. package/dist/components/list-view/docs/llms.md +103 -33
  104. package/dist/components/list-view/list-view-item-branch.svelte +257 -0
  105. package/dist/components/list-view/list-view-item-branch.svelte.d.ts +4 -0
  106. package/dist/components/list-view/list-view-item.svelte +164 -46
  107. package/dist/components/list-view/list-view-item.svelte.d.ts +5 -5
  108. package/dist/components/list-view/list-view.svelte +73 -25
  109. package/dist/components/list-view/types.d.ts +71 -8
  110. package/dist/components/list-view/utils.d.ts +10 -0
  111. package/dist/components/list-view/utils.js +17 -1
  112. package/dist/components/menu/docs/llms.md +98 -15
  113. package/dist/components/menu/menu-command-bar-item.svelte +61 -0
  114. package/dist/components/menu/menu-command-bar-item.svelte.d.ts +14 -0
  115. package/dist/components/menu/menu-command-bar.svelte +218 -0
  116. package/dist/components/menu/menu-command-bar.svelte.d.ts +21 -0
  117. package/dist/components/menu/menu-group.svelte +6 -3
  118. package/dist/components/menu/menu-item-checkbox.svelte +5 -4
  119. package/dist/components/menu/menu-item-radio.svelte +5 -4
  120. package/dist/components/menu/menu-item-switch.svelte +5 -4
  121. package/dist/components/menu/menu-item.svelte +5 -5
  122. package/dist/components/menu/menu-item.svelte.d.ts +2 -3
  123. package/dist/components/menu/menu-list.svelte +10 -1
  124. package/dist/components/menu/menu-popover.svelte +9 -5
  125. package/dist/components/menu/menu-trigger.svelte +2 -1
  126. package/dist/components/menu/menu.svelte.js +1 -0
  127. package/dist/components/menu/types.d.ts +62 -7
  128. package/dist/components/number-box/docs/llms.md +6 -4
  129. package/dist/components/number-box/number-box.svelte +35 -29
  130. package/dist/components/number-box/number-box.svelte.d.ts +1 -1
  131. package/dist/components/number-box/types.d.ts +1 -1
  132. package/dist/components/persona/docs/llms.md +29 -25
  133. package/dist/components/persona/persona.svelte +8 -6
  134. package/dist/components/persona/types.d.ts +4 -3
  135. package/dist/components/progress-bar/docs/llms.md +13 -13
  136. package/dist/components/progress-bar/progress-bar.svelte +6 -6
  137. package/dist/components/progress-bar/types.d.ts +4 -4
  138. package/dist/components/progress-ring/docs/llms.md +14 -14
  139. package/dist/components/progress-ring/progress-ring.svelte +5 -5
  140. package/dist/components/progress-ring/types.d.ts +3 -3
  141. package/dist/components/radio-button/docs/llms.md +11 -8
  142. package/dist/components/radio-button/radio-button.svelte +38 -12
  143. package/dist/components/radio-button/radio-button.svelte.d.ts +1 -1
  144. package/dist/components/radio-button/types.d.ts +11 -8
  145. package/dist/components/rating/docs/llms.md +111 -0
  146. package/dist/components/rating/rating.svelte +247 -0
  147. package/dist/components/rating/rating.svelte.d.ts +19 -0
  148. package/dist/components/rating/types.d.ts +44 -0
  149. package/dist/components/rating/types.js +1 -0
  150. package/dist/components/side-nav/docs/llms.md +110 -0
  151. package/dist/components/side-nav/side-nav-branch.svelte +43 -0
  152. package/dist/components/side-nav/side-nav-branch.svelte.d.ts +4 -0
  153. package/dist/components/side-nav/side-nav-item.svelte +75 -0
  154. package/dist/components/side-nav/side-nav-item.svelte.d.ts +25 -0
  155. package/dist/components/side-nav/side-nav-list.svelte +32 -0
  156. package/dist/components/side-nav/side-nav-list.svelte.d.ts +7 -0
  157. package/dist/components/side-nav/side-nav.d.ts +2 -0
  158. package/dist/components/side-nav/side-nav.js +2 -0
  159. package/dist/components/side-nav/side-nav.svelte +355 -0
  160. package/dist/components/side-nav/side-nav.svelte.d.ts +24 -0
  161. package/dist/components/side-nav/types.d.ts +149 -0
  162. package/dist/components/side-nav/types.js +1 -0
  163. package/dist/components/skeleton/docs/llms.md +1 -1
  164. package/dist/components/skeleton/skeleton.svelte +2 -2
  165. package/dist/components/skeleton/types.d.ts +1 -1
  166. package/dist/components/slider/docs/llms.md +31 -28
  167. package/dist/components/slider/slider.svelte +126 -61
  168. package/dist/components/slider/slider.svelte.d.ts +1 -3
  169. package/dist/components/slider/types.d.ts +21 -14
  170. package/dist/components/tab-view/docs/llms.md +7 -7
  171. package/dist/components/tab-view/tab-view-tab.svelte +16 -14
  172. package/dist/components/tab-view/tab-view.svelte +16 -9
  173. package/dist/components/tab-view/types.d.ts +6 -6
  174. package/dist/components/table/docs/llms.md +38 -33
  175. package/dist/components/table/table-body.svelte +2 -2
  176. package/dist/components/table/table-cell-actions.svelte +8 -2
  177. package/dist/components/table/table-cell-layout.svelte +2 -2
  178. package/dist/components/table/table-cell.svelte +2 -2
  179. package/dist/components/table/table-header-cell.svelte +2 -2
  180. package/dist/components/table/table-header.svelte +2 -2
  181. package/dist/components/table/table-row.svelte +2 -2
  182. package/dist/components/table/table-selection-cell.svelte +6 -6
  183. package/dist/components/table/table.svelte +2 -2
  184. package/dist/components/table/types.d.ts +11 -11
  185. package/dist/components/tag/docs/llms.md +383 -0
  186. package/dist/components/tag/tag-group.d.ts +2 -0
  187. package/dist/components/tag/tag-group.js +2 -0
  188. package/dist/components/tag/tag-group.svelte +117 -0
  189. package/dist/components/tag/tag-group.svelte.d.ts +20 -0
  190. package/dist/components/tag/tag.svelte +459 -0
  191. package/dist/components/tag/tag.svelte.d.ts +19 -0
  192. package/dist/components/tag/types.d.ts +137 -0
  193. package/dist/components/tag/types.js +1 -0
  194. package/dist/components/tag-picker/docs/llms.md +298 -0
  195. package/dist/components/tag-picker/option-group.svelte +51 -0
  196. package/dist/components/tag-picker/option-group.svelte.d.ts +4 -0
  197. package/dist/components/tag-picker/option.svelte +82 -0
  198. package/dist/components/tag-picker/option.svelte.d.ts +4 -0
  199. package/dist/components/tag-picker/tag-picker.d.ts +2 -0
  200. package/dist/components/tag-picker/tag-picker.js +2 -0
  201. package/dist/components/tag-picker/tag-picker.svelte +716 -0
  202. package/dist/components/tag-picker/tag-picker.svelte.d.ts +21 -0
  203. package/dist/components/tag-picker/types.d.ts +142 -0
  204. package/dist/components/tag-picker/types.js +1 -0
  205. package/dist/components/text-box/docs/llms.md +31 -4
  206. package/dist/components/text-box/text-box-button.svelte +3 -3
  207. package/dist/components/text-box/text-box-button.svelte.d.ts +1 -1
  208. package/dist/components/text-box/text-box.svelte +41 -14
  209. package/dist/components/text-box/types.d.ts +5 -5
  210. package/dist/components/textarea/docs/llms.md +4 -3
  211. package/dist/components/textarea/textarea.svelte +14 -6
  212. package/dist/components/textarea/types.d.ts +2 -4
  213. package/dist/components/time-picker/docs/llms.md +18 -15
  214. package/dist/components/time-picker/time-picker.svelte +133 -33
  215. package/dist/components/time-picker/time-picker.svelte.d.ts +1 -1
  216. package/dist/components/time-picker/types.d.ts +23 -13
  217. package/dist/components/title-bar/docs/llms.md +382 -0
  218. package/dist/components/title-bar/title-bar-left-controls.svelte +215 -0
  219. package/dist/components/title-bar/title-bar-left-controls.svelte.d.ts +22 -0
  220. package/dist/components/title-bar/title-bar-right-controls.svelte +190 -0
  221. package/dist/components/title-bar/title-bar-right-controls.svelte.d.ts +27 -0
  222. package/dist/components/title-bar/title-bar.d.ts +3 -0
  223. package/dist/components/title-bar/title-bar.js +4 -0
  224. package/dist/components/title-bar/title-bar.svelte +224 -0
  225. package/dist/components/title-bar/title-bar.svelte.d.ts +26 -0
  226. package/dist/components/title-bar/types.d.ts +165 -0
  227. package/dist/components/title-bar/types.js +1 -0
  228. package/dist/components/toggle-switch/docs/llms.md +11 -9
  229. package/dist/components/toggle-switch/toggle-switch.svelte +23 -14
  230. package/dist/components/toggle-switch/toggle-switch.svelte.d.ts +1 -1
  231. package/dist/components/toggle-switch/types.d.ts +12 -10
  232. package/dist/components/tooltip/docs/llms.md +1 -1
  233. package/dist/components/tooltip/tooltip.svelte +5 -4
  234. package/dist/components/tooltip/types.d.ts +1 -1
  235. package/dist/components/top-nav/docs/llms.md +1 -1
  236. package/dist/components/top-nav/top-nav-item.svelte +2 -2
  237. package/dist/components/top-nav/top-nav.svelte +2 -2
  238. package/dist/components/top-nav/types.d.ts +2 -2
  239. package/dist/components/tree-view/docs/llms.md +11 -11
  240. package/dist/components/tree-view/tree-view-item-content.svelte +3 -3
  241. package/dist/components/tree-view/tree-view-item.svelte +13 -5
  242. package/dist/components/tree-view/tree-view.svelte +20 -5
  243. package/dist/components/tree-view/tree-view.svelte.d.ts +1 -1
  244. package/dist/components/tree-view/tree-view.svelte.js +31 -3
  245. package/dist/components/tree-view/types.d.ts +7 -3
  246. package/dist/index.d.ts +25 -0
  247. package/dist/index.js +32 -0
  248. package/dist/internal/components/dynamic-carousel/dynamic-carousel.svelte +26 -5
  249. package/dist/internal/components/dynamic-carousel/dynamic-carousel.svelte.d.ts +2 -0
  250. package/dist/internal/constants.d.ts +0 -4
  251. package/dist/internal/constants.js +0 -4002
  252. package/dist/internal/index.d.ts +1 -0
  253. package/dist/internal/index.js +1 -0
  254. package/dist/internal/native-field.svelte.d.ts +44 -0
  255. package/dist/internal/native-field.svelte.js +85 -0
  256. package/dist/internal/utils.d.ts +16 -2
  257. package/dist/internal/utils.js +25 -3
  258. package/dist/types/index.d.ts +3 -3
  259. package/package.json +51 -37
@@ -33,30 +33,33 @@ Use `hideDays`, `hideMonths`, or `hideYears` to hide individual selector columns
33
33
  <DatePicker hideDays />
34
34
  ```
35
35
 
36
+ 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.
37
+
36
38
  ## Component Props
37
39
 
38
40
  <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
39
41
  <!-- props:DatePickerProps -->
40
42
 
41
- | Name | Type | Default | Description |
42
- | ----------------------------- | ------------------------------------ | ----------------- | --------------------------------------------------------------------------------------------------- |
43
- | `value` _bindable_ | `string` | `''` | Selected date as `YYYY-MM-DD` (matches the underlying `<input type="date">`). |
44
- | `format` | `'MM/dd/yyyy'` &#124; `'dd/MM/yyyy'` | `'dd/MM/yyyy'` | The order the three columns are laid out in. |
45
- | `open` _bindable_ | `boolean` | `false` | Controls the open state of the picker. |
46
- | `hideYears` | `boolean` | `false` | Removes the year column. |
47
- | `hideMonths` | `boolean` | `false` | Removes the month column. |
48
- | `hideDays` | `boolean` | `false` | Removes the day column. |
49
- | `minYear` | `number` | `Current - 100` | The first year offered by the year column. |
50
- | `maxYear` | `number` | `Current + 100` | The last year offered by the year column. |
51
- | `disabledDates` | `Date[]` | `[]` | Specific days (year-month-day) that cannot be selected. |
52
- | `disabledMonths` | `Date[]` | `[]` | Specific months (by month + year) that cannot be selected. |
53
- | `disabledYears` | `Date[]` | `[]` | Specific years (by year) that cannot be selected. |
54
- | `ref` _bindable_ | `HTMLButtonElement` | | The DOM reference of the trigger button. |
55
- | `wrapperRef` _bindable_ | `HTMLDivElement` | | The DOM reference of the element wrapping the trigger and its input. |
56
- | `wrapperAttributes` | `HTMLAttributes` | | The attributes to spread on the wrapper element. |
57
- | `inputElement` _bindable_ | `HTMLInputElement` | | The DOM reference of the underlying input element. |
58
- | `inputProps` | `HTMLInputAttributes` | | HTML attributes for the underlying input element. Give it a `name` to submit the value with a form. |
59
- | `popupLabel` | `string` | `'Choose a date'` | The accessible name of the popup, which is announced as a dialog. |
60
- | Element Attributes (`button`) | | | |
43
+ | Name | Type | Default | Description |
44
+ | -------------------------------------------- | ------------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
45
+ | `value` _bindable_ | `string` | `''` | Selected date as `YYYY-MM-DD` (matches the underlying `<input type="date">`). |
46
+ | `format` | `'MM/dd/yyyy'` &#124; `'dd/MM/yyyy'` | `'dd/MM/yyyy'` | The order the three columns are laid out in. |
47
+ | `open` _bindable_ | `boolean` | `false` | Controls the open state of the picker. |
48
+ | `hideYears` | `boolean` | `false` | Removes the year column. |
49
+ | `hideMonths` | `boolean` | `false` | Removes the month column. |
50
+ | `hideDays` | `boolean` | `false` | Removes the day column. |
51
+ | `minYear` | `number` | `Current - 100` | The first year offered by the year column. Unless `min` is given, the native input accepts no earlier date. |
52
+ | `maxYear` | `number` | `Current + 100` | The last year offered by the year column. Unless `max` is given, the native input accepts no later date. |
53
+ | `disabledDates` | `Date[]` | `[]` | Specific days (year-month-day) that cannot be selected. |
54
+ | `disabledMonths` | `Date[]` | `[]` | Specific months (by month + year) that cannot be selected. |
55
+ | `disabledYears` | `Date[]` | `[]` | Specific years (by year) that cannot be selected. |
56
+ | `ref` _bindable_ | `HTMLInputElement` &#124; `null` | | The DOM reference of the native date input that holds the value. The other attributes of the picker are applied to it. |
57
+ | `buttonRef` _bindable_ | `HTMLButtonElement` &#124; `null` | | The DOM reference of the button that opens the picker. |
58
+ | `buttonAttributes` | `HTMLButtonAttributes` | | The attributes to spread on the button that opens the picker. |
59
+ | `wrapperRef` _bindable_ | `HTMLDivElement` &#124; `null` | | The DOM reference of the element wrapping the button and the native input. |
60
+ | `wrapperAttributes` | `HTMLAttributes` | | The attributes to spread on the wrapper element. |
61
+ | `popupLabel` | `string` | `'Choose a date'` | The accessible name of the popup, which is announced as a dialog. |
62
+ | `columnLabels` | `{ month?: string; day?: string; year?: string }` | `{ month: 'Month', day: 'Day', year: 'Year' }` | The names of the month, day and year columns: shown on the trigger while there is no date, and given to the lists of the popup. |
63
+ | `NativeFieldAttributes<HTMLInputAttributes>` | | | |
61
64
 
62
65
  <!-- /props:DatePickerProps -->
@@ -1,4 +1,5 @@
1
1
  import type { HTMLAttributes, HTMLButtonAttributes, HTMLInputAttributes } from 'svelte/elements';
2
+ import type { NativeFieldAttributes } from '../../internal/index.js';
2
3
  /** @propsmith DatePickerProps */
3
4
  export type DatePickerProps = {
4
5
  /** Selected date as `YYYY-MM-DD` (matches the underlying `<input type="date">`).
@@ -27,11 +28,11 @@ export type DatePickerProps = {
27
28
  * @default false
28
29
  */
29
30
  hideDays?: boolean;
30
- /** The first year offered by the year column.
31
+ /** The first year offered by the year column. Unless `min` is given, the native input accepts no earlier date.
31
32
  * @default Current - 100
32
33
  */
33
34
  minYear?: number;
34
- /** The last year offered by the year column.
35
+ /** The last year offered by the year column. Unless `max` is given, the native input accepts no later date.
35
36
  * @default Current + 100
36
37
  */
37
38
  maxYear?: number;
@@ -47,28 +48,36 @@ export type DatePickerProps = {
47
48
  * @default []
48
49
  */
49
50
  disabledYears?: Date[];
50
- /** The DOM reference of the trigger button.
51
+ /** The DOM reference of the native date input that holds the value. The other attributes of the picker are applied to it.
51
52
  * @bindable
52
53
  */
53
- ref?: HTMLButtonElement;
54
- /** The DOM reference of the element wrapping the trigger and its input.
54
+ ref?: HTMLInputElement | null;
55
+ /** The DOM reference of the button that opens the picker.
55
56
  * @bindable
56
57
  */
57
- wrapperRef?: HTMLDivElement;
58
- /** The attributes to spread on the wrapper element.
59
- * @type HTMLAttributes
58
+ buttonRef?: HTMLButtonElement | null;
59
+ /** The attributes to spread on the button that opens the picker.
60
+ * @type HTMLButtonAttributes
60
61
  */
61
- wrapperAttributes?: HTMLAttributes<HTMLDivElement>;
62
- /** The DOM reference of the underlying input element.
62
+ buttonAttributes?: HTMLButtonAttributes;
63
+ /** The DOM reference of the element wrapping the button and the native input.
63
64
  * @bindable
64
65
  */
65
- inputElement?: HTMLInputElement;
66
- /** HTML attributes for the underlying input element. Give it a `name` to submit the
67
- * value with a form.
66
+ wrapperRef?: HTMLDivElement | null;
67
+ /** The attributes to spread on the wrapper element.
68
+ * @type HTMLAttributes
68
69
  */
69
- inputProps?: HTMLInputAttributes;
70
+ wrapperAttributes?: HTMLAttributes<HTMLDivElement>;
70
71
  /** The accessible name of the popup, which is announced as a dialog.
71
72
  * @default 'Choose a date'
72
73
  */
73
74
  popupLabel?: string;
74
- } & HTMLButtonAttributes;
75
+ /** The names of the month, day and year columns: shown on the trigger while there is no date, and given to the lists of the popup.
76
+ * @default { month: 'Month', day: 'Day', year: 'Year' }
77
+ */
78
+ columnLabels?: {
79
+ month?: string;
80
+ day?: string;
81
+ year?: string;
82
+ };
83
+ } & NativeFieldAttributes<HTMLInputAttributes>;
@@ -2,7 +2,14 @@
2
2
  import { getTabspotAttributes } from 'tabspot';
3
3
  import type { DialogActionsProps } from './types.js';
4
4
 
5
- let { ref = $bindable(), position = 'end', fluid, children }: DialogActionsProps = $props();
5
+ let {
6
+ ref = $bindable(null),
7
+ position = 'end',
8
+ fluid,
9
+ class: classes,
10
+ children,
11
+ ...attributes
12
+ }: DialogActionsProps = $props();
6
13
 
7
14
  // The bar is one tab stop holding a row of buttons: without the mover the root would
8
15
  // take the tab stop and then offer no way to reach the rest of the buttons.
@@ -12,7 +19,12 @@
12
19
  });
13
20
  </script>
14
21
 
15
- <div class={['dialog-actions', `justify-${position}`, { fluid }]} bind:this={ref} {...tabspotAttributes}>
22
+ <div
23
+ {...attributes}
24
+ class={['dialog-actions', `justify-${position}`, { fluid }, classes]}
25
+ bind:this={ref}
26
+ {...tabspotAttributes}
27
+ >
16
28
  {@render children?.()}
17
29
  </div>
18
30
 
@@ -33,5 +45,8 @@
33
45
  &.justify-end {
34
46
  justify-content: flex-end;
35
47
  }
48
+ &.fluid > :global(*) {
49
+ flex: 1 1 0;
50
+ }
36
51
  }
37
52
  </style>
@@ -1,10 +1,10 @@
1
1
  <script lang="ts">
2
2
  import type { DialogContentProps } from './types.js';
3
3
 
4
- let { children }: DialogContentProps = $props();
4
+ let { ref = $bindable(null), class: classes, children, ...attributes }: DialogContentProps = $props();
5
5
  </script>
6
6
 
7
- <div class="dialog-content">
7
+ <div {...attributes} class={['dialog-content', classes]} bind:this={ref}>
8
8
  {@render children?.()}
9
9
  </div>
10
10
 
@@ -1,4 +1,4 @@
1
1
  import type { DialogContentProps } from './types.ts';
2
- declare const DialogContent: import("svelte").Component<DialogContentProps, {}, "">;
2
+ declare const DialogContent: import("svelte").Component<DialogContentProps, {}, "ref">;
3
3
  type DialogContent = ReturnType<typeof DialogContent>;
4
4
  export default DialogContent;
@@ -1,11 +1,12 @@
1
1
  <script lang="ts">
2
2
  import { onClickOutside } from 'runed';
3
+ import { on } from 'svelte/events';
3
4
  import type { DialogSurfaceProps } from './types.js';
4
5
  import { getDialogContext } from './dialog.svelte.js';
5
6
  import { Button } from '../../index.js';
6
7
  import DismissFilled from 'fluentui-icons-svelte/DismissFilled.svelte';
7
8
 
8
- let { ref = $bindable(), children, ...attributes }: DialogSurfaceProps = $props();
9
+ let { ref = $bindable(null), class: classes, oncancel, children, ...attributes }: DialogSurfaceProps = $props();
9
10
 
10
11
  const CONTEXT = getDialogContext();
11
12
 
@@ -17,22 +18,57 @@
17
18
 
18
19
  const { closeDialog } = methods;
19
20
 
21
+ const duration = $derived(
22
+ typeof config.duration === 'number'
23
+ ? `${Number.isFinite(config.duration) ? Math.max(0, config.duration) : 0}ms`
24
+ : `var(${config.duration.startsWith('--') ? config.duration : `--fs-${config.duration}-duration`}, 333ms)`
25
+ );
26
+
27
+ // runed reports an outside press 10ms after the pointer goes down. By then the press that opens the
28
+ // dialog has already opened it, and a press while it is closed has nothing to dismiss, so remember
29
+ // whether the dialog was open at the moment the pointer went down.
30
+ let openOnPointerDown = false;
31
+
32
+ $effect(() => {
33
+ const doc = ref?.ownerDocument;
34
+ if (!doc) return;
35
+ return on(doc, 'pointerdown', () => (openOnPointerDown = !!ref?.open), { capture: true });
36
+ });
37
+
20
38
  // Registered unconditionally and guarded from inside, so switching `type` after mount is honored.
21
39
  onClickOutside(
22
40
  () => ref,
23
41
  () => {
24
- if (config.type === 'alert') return;
42
+ if (config.type === 'alert' || !openOnPointerDown) return;
25
43
  closeDialog();
26
44
  }
27
45
  );
28
46
 
47
+ // Escape cancels a modal dialog natively. An alert has to be answered with one of its actions, and any
48
+ // other modal closes through `closeDialog` so `onOpenChange` hears about it. A consumer's `oncancel`
49
+ // can still veto it with `preventDefault`.
50
+ function handleCancel(e: Event & { currentTarget: EventTarget & HTMLDialogElement }) {
51
+ oncancel?.(e);
52
+ if (e.defaultPrevented) return;
53
+ e.preventDefault();
54
+ if (config.type !== 'alert') closeDialog();
55
+ }
56
+
29
57
  $effect(() => {
30
58
  if (!ref) return;
31
59
  _state.dialogRef = ref;
32
60
  });
33
61
  </script>
34
62
 
35
- <dialog open={_state.open} class="fs-dialog" aria-labelledby={_state.titleId} bind:this={ref} {...attributes}>
63
+ <dialog
64
+ {...attributes}
65
+ open={_state.open}
66
+ class={['fs-dialog', `position-${config.position}`, `animation-${config.animation}`, classes]}
67
+ style:--fs-dialog-duration={duration}
68
+ aria-labelledby={_state.titleId ?? attributes['aria-labelledby']}
69
+ bind:this={ref}
70
+ oncancel={handleCancel}
71
+ >
36
72
  <div class="dialog-wrapper">
37
73
  {#if config.type === 'non-modal'}
38
74
  <Button class="close-icon" appearance="subtle" onclick={() => methods.closeDialog()} aria-label="Close dialog">
@@ -45,21 +81,93 @@
45
81
 
46
82
  <style>
47
83
  .fs-dialog {
84
+ --fs-dialog-effective-duration: var(--fs-dialog-duration);
85
+ --fs-dialog-enter-easing: var(--fs-fast-dismiss, cubic-bezier(0, 0, 0, 1));
86
+ --fs-dialog-exit-easing: var(--fs-soft-dismiss, cubic-bezier(1, 0, 1, 1));
87
+ --fs-dialog-hidden-transform: none;
88
+ opacity: 0;
89
+ transform: var(--fs-dialog-hidden-transform);
90
+ transition:
91
+ opacity var(--fs-dialog-effective-duration) var(--fs-dialog-exit-easing),
92
+ transform var(--fs-dialog-effective-duration) var(--fs-dialog-exit-easing),
93
+ display var(--fs-dialog-effective-duration) allow-discrete,
94
+ overlay var(--fs-dialog-effective-duration) allow-discrete;
95
+ &[open] {
96
+ opacity: 1;
97
+ transform: none;
98
+ transition-timing-function: var(--fs-dialog-enter-easing);
99
+ }
100
+ &.animation-zoom {
101
+ --fs-dialog-hidden-transform: scale(0.9);
102
+ --fs-dialog-enter-transform: scale(0.88);
103
+ }
104
+ &.animation-slide {
105
+ --fs-dialog-hidden-transform: translateY(16px);
106
+ &.position-top-start,
107
+ &.position-top-center,
108
+ &.position-top-end {
109
+ --fs-dialog-hidden-transform: translateY(-16px);
110
+ }
111
+ }
112
+ &.animation-bounce {
113
+ --fs-dialog-hidden-transform: scale(0.96);
114
+ --fs-dialog-enter-easing: var(--fs-strong-invoke, cubic-bezier(0.13, 1.62, 0, 0.92));
115
+ /* Reverse of Fluent's strong-invoke curve: a small anticipation before dismissal. */
116
+ --fs-dialog-exit-easing: cubic-bezier(1, 0.08, 0.87, -0.62);
117
+ }
118
+ @starting-style {
119
+ &[open] {
120
+ opacity: 0;
121
+ transform: var(--fs-dialog-enter-transform, var(--fs-dialog-hidden-transform));
122
+ }
123
+ }
48
124
  position: fixed;
49
- top: 50%;
50
- left: 50%;
125
+ inset: 1rem;
126
+ margin: auto;
51
127
  padding: 0;
52
- transform: translate(-50%, -50%);
128
+ box-sizing: border-box;
53
129
  border: unset;
54
130
  z-index: 1100;
55
131
  width: 35vw;
56
- min-width: 20rem;
132
+ min-width: min(20rem, calc(100vw - 2rem));
133
+ max-width: calc(100vw - 2rem);
134
+ height: fit-content;
135
+ max-height: calc(100dvh - 2rem);
57
136
  overflow: visible;
58
137
  background: var(--fs-solid-background-base);
59
138
  border-radius: var(--fs-control-overlay-border-radius);
139
+ &.position-top-start,
140
+ &.position-top-center,
141
+ &.position-top-end {
142
+ margin-block-start: 0;
143
+ }
144
+ &.position-bottom-start,
145
+ &.position-bottom-center,
146
+ &.position-bottom-end {
147
+ margin-block-end: 0;
148
+ }
149
+ &.position-top-start,
150
+ &.position-middle-start,
151
+ &.position-bottom-start {
152
+ margin-inline-start: 0;
153
+ }
154
+ &.position-top-end,
155
+ &.position-middle-end,
156
+ &.position-bottom-end {
157
+ margin-inline-end: 0;
158
+ }
60
159
  &::backdrop {
160
+ opacity: 0;
61
161
  background-color: var(--fs-smoke-background-default);
62
162
  backdrop-filter: blur(0.25rem);
163
+ transition:
164
+ opacity var(--fs-dialog-effective-duration) var(--fs-soft-dismiss, cubic-bezier(1, 0, 1, 1)),
165
+ display var(--fs-dialog-effective-duration) allow-discrete,
166
+ overlay var(--fs-dialog-effective-duration) allow-discrete;
167
+ }
168
+ &[open]::backdrop {
169
+ opacity: 1;
170
+ transition-timing-function: var(--fs-fast-dismiss, cubic-bezier(0, 0, 0, 1));
63
171
  }
64
172
  & .dialog-wrapper {
65
173
  position: relative;
@@ -69,7 +177,7 @@
69
177
  display: grid;
70
178
  grid-template-rows: auto 1fr;
71
179
  width: 100%;
72
- max-height: 95vh;
180
+ max-height: calc(100dvh - 2rem);
73
181
  overflow: hidden;
74
182
  background: var(--fs-layer-alt);
75
183
  &::before {
@@ -92,4 +200,18 @@
92
200
  }
93
201
  }
94
202
  }
203
+ /* Pseudo-elements need a separate starting-style rule rather than nested &. */
204
+ @starting-style {
205
+ .fs-dialog[open]::backdrop {
206
+ opacity: 0;
207
+ }
208
+ }
209
+ :global(:root[data-fs-reduced-motion='true']) .fs-dialog {
210
+ --fs-dialog-effective-duration: 0ms;
211
+ }
212
+ @media (prefers-reduced-motion: reduce) {
213
+ :global(:root:not([data-fs-reduced-motion='false'])) .fs-dialog {
214
+ --fs-dialog-effective-duration: 0ms;
215
+ }
216
+ }
95
217
  </style>
@@ -1,19 +1,36 @@
1
1
  <script lang="ts" generics="T extends DialogTitleTag">
2
2
  import { PREFIX } from '../../internal/constants.js';
3
3
  import { getDialogContext } from './dialog.svelte.js';
4
+ import { TITLE_TAG } from './utils.js';
4
5
  import type { DialogTitleProps, DialogTitleTag } from './types.js';
5
6
 
6
- let { as = 'h3' as T, ref = $bindable(), children }: DialogTitleProps<T> = $props();
7
-
8
- const FALLBACK_ID = $props.id();
9
- const ID = `${PREFIX}dialog-title-${FALLBACK_ID}`;
7
+ const _ID = $props.id();
8
+ const FALLBACK_ID = `${PREFIX}dialog-title-${_ID}`;
9
+
10
+ let {
11
+ as = 'h3' as T,
12
+ ref = $bindable(null),
13
+ id = FALLBACK_ID,
14
+ class: classes,
15
+ children,
16
+ ...attributes
17
+ }: DialogTitleProps<T> = $props();
18
+
19
+ /**
20
+ * The tag the invariant rules over. The markup renders it through here, so it is checked
21
+ * during SSR and on every prop update rather than only once on mount.
22
+ */
23
+ const _as = $derived.by(() => {
24
+ if (!TITLE_TAG.includes(as)) throw new Error(`Invalid tag: ${as}. Must be one of ${TITLE_TAG.join(', ')}`);
25
+ return as;
26
+ });
10
27
 
11
28
  const context = getDialogContext();
12
29
 
13
30
  $effect.pre(() => {
14
31
  if (!context) return;
15
32
 
16
- context.state.titleId = ID;
33
+ context.state.titleId = id ?? undefined;
17
34
 
18
35
  return () => {
19
36
  context.state.titleId = undefined;
@@ -21,7 +38,7 @@
21
38
  });
22
39
  </script>
23
40
 
24
- <svelte:element this={as} id={ID} class="dialog-title" bind:this={ref}>
41
+ <svelte:element this={_as} {...attributes} {id} class={['dialog-title', classes]} bind:this={ref}>
25
42
  {@render children?.()}
26
43
  </svelte:element>
27
44
 
@@ -1,9 +1,10 @@
1
1
  <script lang="ts">
2
2
  import { Button } from '../../index.js';
3
+ import { invokeHandlers } from '../../internal/index.js';
3
4
  import { getDialogContext } from './dialog.svelte.js';
4
5
  import type { DialogTriggerProps } from './types.js';
5
6
 
6
- let { children }: DialogTriggerProps = $props();
7
+ let { ref = $bindable(null), class: classes, onclick, children, ...attributes }: DialogTriggerProps = $props();
7
8
 
8
9
  const CONTEXT = getDialogContext();
9
10
 
@@ -14,7 +15,12 @@
14
15
  const { methods } = CONTEXT;
15
16
  </script>
16
17
 
17
- <Button class="dialog-trigger" onclick={methods.openDialog}>
18
+ <Button
19
+ {...attributes}
20
+ bind:ref
21
+ class={['dialog-trigger', classes]}
22
+ onclick={(e: MouseEvent) => invokeHandlers(e, [], [onclick, methods.openDialog])}
23
+ >
18
24
  {#if children}
19
25
  {@render children()}
20
26
  {:else}
@@ -1,4 +1,4 @@
1
1
  import type { DialogTriggerProps } from './types.ts';
2
- declare const DialogTrigger: import("svelte").Component<DialogTriggerProps, {}, "">;
2
+ declare const DialogTrigger: import("svelte").Component<DialogTriggerProps, {}, "ref">;
3
3
  type DialogTrigger = ReturnType<typeof DialogTrigger>;
4
4
  export default DialogTrigger;
@@ -2,7 +2,15 @@
2
2
  import { setDialogContext } from './dialog.svelte.js';
3
3
  import type { DialogContext, DialogProps } from './types.js';
4
4
 
5
- let { type = 'modal', open = $bindable(), onOpenChange, children }: DialogProps = $props();
5
+ let {
6
+ type = 'modal',
7
+ position = 'middle-center',
8
+ animation = 'zoom',
9
+ duration = 'normal',
10
+ open = $bindable(null),
11
+ onOpenChange,
12
+ children
13
+ }: DialogProps = $props();
6
14
 
7
15
  let dialogRef: HTMLDialogElement | undefined = $state();
8
16
 
@@ -12,6 +20,15 @@
12
20
  config: {
13
21
  get type() {
14
22
  return type;
23
+ },
24
+ get position() {
25
+ return position;
26
+ },
27
+ get animation() {
28
+ return animation;
29
+ },
30
+ get duration() {
31
+ return duration;
15
32
  }
16
33
  },
17
34
  state: {
@@ -34,19 +51,13 @@
34
51
  events: null,
35
52
  methods: {
36
53
  openDialog: () => {
37
- if (type !== 'non-modal') {
38
- dialogRef?.showModal();
39
- } else {
40
- open = true;
41
- }
54
+ if (type !== 'non-modal') dialogRef?.showModal();
55
+ open = true;
42
56
  onOpenChange?.(true);
43
57
  },
44
58
  closeDialog: () => {
45
- if (type !== 'non-modal') {
46
- dialogRef?.close();
47
- } else {
48
- open = false;
49
- }
59
+ if (type !== 'non-modal') dialogRef?.close();
60
+ open = false;
50
61
  onOpenChange?.(false);
51
62
  }
52
63
  }