@sveltia/ui 0.90.0 → 0.92.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 (284) hide show
  1. package/dist/components/bottom-navigation/bottom-navigation.svelte +3 -9
  2. package/dist/components/bottom-navigation/bottom-navigation.svelte.d.ts +4 -39
  3. package/dist/components/button/button-group.svelte +2 -4
  4. package/dist/components/button/button-group.svelte.d.ts +3 -19
  5. package/dist/components/button/select-button-group.svelte +2 -13
  6. package/dist/components/button/select-button-group.svelte.d.ts +5 -67
  7. package/dist/components/calendar/calendar.d.ts +9 -0
  8. package/dist/components/calendar/calendar.js +43 -0
  9. package/dist/components/calendar/calendar.svelte +26 -27
  10. package/dist/components/checkbox/checkbox-group.svelte +2 -8
  11. package/dist/components/checkbox/checkbox-group.svelte.d.ts +4 -39
  12. package/dist/components/dialog/alert-dialog.svelte.d.ts +2 -3
  13. package/dist/components/dialog/confirmation-dialog.svelte.d.ts +2 -3
  14. package/dist/components/dialog/dialog.svelte +6 -7
  15. package/dist/components/dialog/dialog.svelte.d.ts +2 -3
  16. package/dist/components/dialog/prompt-dialog.svelte +2 -2
  17. package/dist/components/dialog/prompt-dialog.svelte.d.ts +2 -3
  18. package/dist/components/disclosure/disclosure.svelte +14 -16
  19. package/dist/components/disclosure/disclosure.svelte.d.ts +4 -38
  20. package/dist/components/drawer/drawer.svelte +22 -39
  21. package/dist/components/drawer/drawer.svelte.d.ts +3 -24
  22. package/dist/components/grid/grid-body.svelte +2 -3
  23. package/dist/components/grid/grid-body.svelte.d.ts +3 -18
  24. package/dist/components/grid/grid-cell.svelte +2 -8
  25. package/dist/components/grid/grid-cell.svelte.d.ts +3 -22
  26. package/dist/components/grid/grid-col-header.svelte +2 -4
  27. package/dist/components/grid/grid-col-header.svelte.d.ts +3 -19
  28. package/dist/components/grid/grid-foot.svelte +4 -9
  29. package/dist/components/grid/grid-foot.svelte.d.ts +3 -22
  30. package/dist/components/grid/grid-head.svelte +4 -9
  31. package/dist/components/grid/grid-head.svelte.d.ts +3 -22
  32. package/dist/components/grid/grid-row-header.svelte +2 -8
  33. package/dist/components/grid/grid-row-header.svelte.d.ts +3 -22
  34. package/dist/components/grid/grid-row.svelte +4 -5
  35. package/dist/components/grid/grid-row.svelte.d.ts +3 -19
  36. package/dist/components/grid/grid.d.ts +10 -0
  37. package/dist/components/grid/grid.js +11 -0
  38. package/dist/components/grid/grid.svelte +6 -7
  39. package/dist/components/grid/grid.svelte.d.ts +5 -21
  40. package/dist/components/listbox/listbox.svelte +34 -15
  41. package/dist/components/listbox/listbox.svelte.d.ts +5 -69
  42. package/dist/components/listbox/option-group.svelte +2 -8
  43. package/dist/components/listbox/option-group.svelte.d.ts +4 -39
  44. package/dist/components/listbox/option.svelte +2 -1
  45. package/dist/components/menu/menu-item-group.svelte +2 -6
  46. package/dist/components/menu/menu-item-group.svelte.d.ts +3 -22
  47. package/dist/components/menu/menu-item.svelte +5 -1
  48. package/dist/components/menu/menu.svelte +2 -8
  49. package/dist/components/menu/menu.svelte.d.ts +4 -39
  50. package/dist/components/radio/radio-group.svelte +2 -17
  51. package/dist/components/radio/radio-group.svelte.d.ts +5 -67
  52. package/dist/components/radio/radio.svelte +19 -22
  53. package/dist/components/radio/radio.svelte.d.ts +10 -40
  54. package/dist/components/resizable-pane/resizable-handle.svelte +42 -49
  55. package/dist/components/resizable-pane/resizable-pane-group.svelte +44 -58
  56. package/dist/components/resizable-pane/resizable-pane-group.svelte.d.ts +3 -19
  57. package/dist/components/resizable-pane/resizable-pane.svelte +2 -5
  58. package/dist/components/resizable-pane/resizable-pane.svelte.d.ts +3 -19
  59. package/dist/components/resizable-pane/sizing.d.ts +24 -0
  60. package/dist/components/resizable-pane/sizing.js +83 -0
  61. package/dist/components/select/combobox.svelte +35 -39
  62. package/dist/components/select/select-tags.svelte +3 -13
  63. package/dist/components/select/select-tags.svelte.d.ts +5 -67
  64. package/dist/components/slider/slider.d.ts +5 -4
  65. package/dist/components/slider/slider.js +28 -23
  66. package/dist/components/slider/slider.svelte +64 -62
  67. package/dist/components/slider/slider.svelte.d.ts +4 -37
  68. package/dist/components/switch/switch.svelte +2 -13
  69. package/dist/components/switch/switch.svelte.d.ts +5 -67
  70. package/dist/components/table/table-body.svelte +2 -4
  71. package/dist/components/table/table-body.svelte.d.ts +3 -19
  72. package/dist/components/table/table-cell.svelte +2 -8
  73. package/dist/components/table/table-cell.svelte.d.ts +3 -22
  74. package/dist/components/table/table-col-header.svelte +2 -8
  75. package/dist/components/table/table-col-header.svelte.d.ts +3 -22
  76. package/dist/components/table/table-foot.svelte +2 -8
  77. package/dist/components/table/table-foot.svelte.d.ts +3 -22
  78. package/dist/components/table/table-head.svelte +2 -8
  79. package/dist/components/table/table-head.svelte.d.ts +3 -22
  80. package/dist/components/table/table-part.svelte +2 -4
  81. package/dist/components/table/table-part.svelte.d.ts +3 -19
  82. package/dist/components/table/table-row-header.svelte +2 -8
  83. package/dist/components/table/table-row-header.svelte.d.ts +3 -22
  84. package/dist/components/table/table-row.svelte +2 -8
  85. package/dist/components/table/table-row.svelte.d.ts +3 -22
  86. package/dist/components/table/table.svelte +2 -4
  87. package/dist/components/table/table.svelte.d.ts +3 -19
  88. package/dist/components/tabs/tab-box.svelte +2 -4
  89. package/dist/components/tabs/tab-box.svelte.d.ts +3 -19
  90. package/dist/components/tabs/tab-list.svelte +2 -7
  91. package/dist/components/tabs/tab-list.svelte.d.ts +4 -37
  92. package/dist/components/tabs/tab-panel.svelte +2 -8
  93. package/dist/components/tabs/tab-panel.svelte.d.ts +3 -22
  94. package/dist/components/tabs/tab-panels.svelte +2 -8
  95. package/dist/components/tabs/tab-panels.svelte.d.ts +3 -22
  96. package/dist/components/text-editor/code-editor.js +14 -7
  97. package/dist/components/text-editor/code-editor.svelte +14 -22
  98. package/dist/components/text-editor/code-editor.svelte.d.ts +5 -103
  99. package/dist/components/text-editor/config.d.ts +73 -0
  100. package/dist/components/text-editor/config.js +110 -0
  101. package/dist/components/text-editor/constants.d.ts +40 -6
  102. package/dist/components/text-editor/constants.js +81 -7
  103. package/dist/components/text-editor/conversion/editor-components.js +4 -4
  104. package/dist/components/text-editor/conversion/html/components.d.ts +16 -0
  105. package/dist/components/text-editor/conversion/html/components.js +87 -0
  106. package/dist/components/text-editor/conversion/html/export.d.ts +10 -0
  107. package/dist/components/text-editor/conversion/html/export.js +360 -0
  108. package/dist/components/text-editor/conversion/html/import-rules.d.ts +12 -0
  109. package/dist/components/text-editor/conversion/html/import-rules.js +234 -0
  110. package/dist/components/text-editor/conversion/html/index.d.ts +10 -0
  111. package/dist/components/text-editor/conversion/html/index.js +33 -0
  112. package/dist/components/text-editor/conversion/html/paragraph.d.ts +1 -0
  113. package/dist/components/text-editor/conversion/html/paragraph.js +123 -0
  114. package/dist/components/text-editor/conversion/html/task-list.d.ts +13 -0
  115. package/dist/components/text-editor/conversion/html/task-list.js +82 -0
  116. package/dist/components/text-editor/conversion/html/unsupported.d.ts +2 -0
  117. package/dist/components/text-editor/conversion/html/unsupported.js +122 -0
  118. package/dist/components/text-editor/conversion/html/utils.d.ts +6 -0
  119. package/dist/components/text-editor/conversion/html/utils.js +34 -0
  120. package/dist/components/text-editor/conversion/import.js +33 -27
  121. package/dist/components/text-editor/conversion/markdown/block-conversion.d.ts +4 -0
  122. package/dist/components/text-editor/conversion/markdown/block-conversion.js +154 -0
  123. package/dist/components/text-editor/conversion/markdown/block-structure.d.ts +16 -0
  124. package/dist/components/text-editor/conversion/markdown/block-structure.js +254 -0
  125. package/dist/components/text-editor/conversion/markdown/code-blocks.d.ts +57 -0
  126. package/dist/components/text-editor/conversion/markdown/code-blocks.js +279 -0
  127. package/dist/components/text-editor/conversion/markdown/code-spans.d.ts +19 -0
  128. package/dist/components/text-editor/conversion/markdown/code-spans.js +71 -0
  129. package/dist/components/text-editor/conversion/markdown/formatting.d.ts +22 -0
  130. package/dist/components/text-editor/conversion/markdown/formatting.js +451 -0
  131. package/dist/components/text-editor/conversion/markdown/index.d.ts +10 -0
  132. package/dist/components/text-editor/conversion/markdown/index.js +55 -0
  133. package/dist/components/text-editor/conversion/markdown/placeholders.d.ts +2 -0
  134. package/dist/components/text-editor/conversion/markdown/placeholders.js +229 -0
  135. package/dist/components/text-editor/conversion/markdown/syntax.d.ts +99 -0
  136. package/dist/components/text-editor/conversion/markdown/syntax.js +206 -0
  137. package/dist/components/text-editor/conversion/placeholder-chars.d.ts +43 -0
  138. package/dist/components/text-editor/conversion/placeholder-chars.js +51 -0
  139. package/dist/components/text-editor/conversion/transformers/block-escape.d.ts +1 -0
  140. package/dist/components/text-editor/conversion/transformers/block-escape.js +53 -26
  141. package/dist/components/text-editor/conversion/transformers/code.d.ts +3 -14
  142. package/dist/components/text-editor/conversion/transformers/code.js +78 -16
  143. package/dist/components/text-editor/conversion/transformers/formatted-code.js +3 -18
  144. package/dist/components/text-editor/conversion/transformers/inline-code.js +3 -1
  145. package/dist/components/text-editor/conversion/transformers/link.js +3 -1
  146. package/dist/components/text-editor/conversion/transformers/raw-syntax.d.ts +0 -19
  147. package/dist/components/text-editor/conversion/transformers/raw-syntax.js +22 -93
  148. package/dist/components/text-editor/conversion/transformers/table.js +57 -16
  149. package/dist/components/text-editor/conversion/transformers/task-list.d.ts +24 -0
  150. package/dist/components/text-editor/conversion/transformers/task-list.js +53 -0
  151. package/dist/components/text-editor/conversion/update.d.ts +19 -2
  152. package/dist/components/text-editor/conversion/update.js +64 -40
  153. package/dist/components/text-editor/core.d.ts +12 -51
  154. package/dist/components/text-editor/core.js +47 -77
  155. package/dist/components/text-editor/editing/commands.js +9 -18
  156. package/dist/components/text-editor/editing/guards.d.ts +7 -0
  157. package/dist/components/text-editor/editing/guards.js +123 -0
  158. package/dist/components/text-editor/editing/raw-markdown.d.ts +7 -2
  159. package/dist/components/text-editor/editing/raw-markdown.js +68 -8
  160. package/dist/components/text-editor/editing/selection.js +6 -2
  161. package/dist/components/text-editor/lexical-root.svelte +89 -47
  162. package/dist/components/text-editor/lexical-root.svelte.d.ts +4 -67
  163. package/dist/components/text-editor/shiki/{facade.d.ts → engine.d.ts} +8 -8
  164. package/dist/components/text-editor/shiki/{facade.js → engine.js} +53 -156
  165. package/dist/components/text-editor/shiki/highlighter.js +5 -5
  166. package/dist/components/text-editor/shiki/lexical.d.ts +6 -0
  167. package/dist/components/text-editor/shiki/lexical.js +165 -0
  168. package/dist/components/text-editor/shiki/preload.js +1 -1
  169. package/dist/components/text-editor/shiki/source-highlight.svelte.d.ts +15 -0
  170. package/dist/components/text-editor/shiki/source-highlight.svelte.js +120 -0
  171. package/dist/components/text-editor/shiki/version.d.ts +1 -1
  172. package/dist/components/text-editor/shiki/version.js +1 -1
  173. package/dist/components/text-editor/store.svelte.js +65 -16
  174. package/dist/components/text-editor/text-editor.svelte +57 -146
  175. package/dist/components/text-editor/text-editor.svelte.d.ts +9 -105
  176. package/dist/components/text-editor/toolbar/actions.d.ts +25 -0
  177. package/dist/components/text-editor/toolbar/actions.js +107 -0
  178. package/dist/components/text-editor/toolbar/align-menu-button.svelte +16 -14
  179. package/dist/components/text-editor/toolbar/format-text-button.svelte +27 -19
  180. package/dist/components/text-editor/toolbar/insert-horizontal-rule-button.svelte +23 -23
  181. package/dist/components/text-editor/toolbar/insert-item-button.svelte +1 -1
  182. package/dist/components/text-editor/toolbar/insert-link-button.svelte +47 -51
  183. package/dist/components/text-editor/toolbar/insert-menu-button.svelte +1 -1
  184. package/dist/components/text-editor/toolbar/insert-table-button.svelte +35 -52
  185. package/dist/components/text-editor/toolbar/table-action-menu.svelte +19 -17
  186. package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte +34 -11
  187. package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte.d.ts +0 -8
  188. package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte +35 -41
  189. package/dist/components/text-editor/widgets/emoji-autocomplete.svelte +7 -6
  190. package/dist/components/text-editor/widgets/floating-link-editor.svelte +19 -32
  191. package/dist/components/text-editor/widgets/table-cell-menu-button.svelte +28 -32
  192. package/dist/components/text-field/date-time-input.svelte +7 -8
  193. package/dist/components/text-field/date-time-input.svelte.d.ts +3 -32
  194. package/dist/components/text-field/number-input.d.ts +0 -2
  195. package/dist/components/text-field/number-input.js +25 -25
  196. package/dist/components/text-field/number-input.svelte +18 -9
  197. package/dist/components/text-field/number-input.svelte.d.ts +1 -1
  198. package/dist/components/text-field/text-area.d.ts +2 -0
  199. package/dist/components/text-field/text-area.js +31 -0
  200. package/dist/components/text-field/text-area.svelte +12 -25
  201. package/dist/components/text-field/text-area.svelte.d.ts +5 -67
  202. package/dist/components/toast/toast.svelte +31 -8
  203. package/dist/components/toast/toast.svelte.d.ts +6 -6
  204. package/dist/components/toolbar/toolbar.svelte +2 -7
  205. package/dist/components/toolbar/toolbar.svelte.d.ts +4 -37
  206. package/dist/components/tree/tree-item.svelte +2 -6
  207. package/dist/components/tree/tree-item.svelte.d.ts +3 -22
  208. package/dist/components/tree/tree.svelte +3 -10
  209. package/dist/components/tree/tree.svelte.d.ts +4 -39
  210. package/dist/components/util/group.svelte +2 -7
  211. package/dist/components/util/group.svelte.d.ts +4 -37
  212. package/dist/components/util/modal.d.ts +9 -0
  213. package/dist/components/util/modal.js +30 -0
  214. package/dist/components/util/modal.svelte +16 -12
  215. package/dist/index.d.ts +1 -1
  216. package/dist/index.js +1 -1
  217. package/dist/locales/ar.yaml +2 -0
  218. package/dist/locales/bg.yaml +2 -0
  219. package/dist/locales/ca.yaml +2 -0
  220. package/dist/locales/cs.yaml +2 -0
  221. package/dist/locales/da.yaml +2 -0
  222. package/dist/locales/de.yaml +2 -0
  223. package/dist/locales/el.yaml +2 -0
  224. package/dist/locales/en-CA.yaml +2 -0
  225. package/dist/locales/en-GB.yaml +2 -0
  226. package/dist/locales/en-US.yaml +2 -0
  227. package/dist/locales/en-ZA.yaml +2 -0
  228. package/dist/locales/es-CO.yaml +2 -0
  229. package/dist/locales/es-ES.yaml +2 -0
  230. package/dist/locales/fa.yaml +2 -0
  231. package/dist/locales/fi.yaml +2 -0
  232. package/dist/locales/fr.yaml +2 -0
  233. package/dist/locales/he.yaml +2 -0
  234. package/dist/locales/hr.yaml +2 -0
  235. package/dist/locales/hu.yaml +176 -0
  236. package/dist/locales/it.yaml +2 -0
  237. package/dist/locales/ja.yaml +2 -0
  238. package/dist/locales/ko.yaml +2 -0
  239. package/dist/locales/nl.yaml +2 -0
  240. package/dist/locales/pl.yaml +2 -0
  241. package/dist/locales/pt-BR.yaml +2 -0
  242. package/dist/locales/pt-PT.yaml +2 -0
  243. package/dist/locales/ru.yaml +2 -0
  244. package/dist/locales/sk.yaml +2 -0
  245. package/dist/locales/sv.yaml +2 -0
  246. package/dist/locales/tr.yaml +2 -0
  247. package/dist/locales/uk.yaml +2 -0
  248. package/dist/locales/vi.yaml +2 -0
  249. package/dist/locales/zh-CN.yaml +2 -0
  250. package/dist/locales/zh-TW.yaml +2 -0
  251. package/dist/services/composite-widget.svelte.d.ts +76 -0
  252. package/dist/services/composite-widget.svelte.js +157 -0
  253. package/dist/services/focus.d.ts +2 -0
  254. package/dist/services/focus.js +68 -0
  255. package/dist/services/group.svelte.d.ts +17 -69
  256. package/dist/services/group.svelte.js +128 -391
  257. package/dist/services/label.d.ts +9 -0
  258. package/dist/services/label.js +22 -0
  259. package/dist/services/menu.d.ts +8 -0
  260. package/dist/services/menu.js +237 -0
  261. package/dist/services/navigation.d.ts +9 -0
  262. package/dist/services/navigation.js +13 -0
  263. package/dist/services/number.d.ts +2 -0
  264. package/dist/services/number.js +27 -0
  265. package/dist/services/pointer-drag.d.ts +14 -0
  266. package/dist/services/pointer-drag.js +89 -0
  267. package/dist/services/popup.svelte.js +123 -103
  268. package/dist/services/text.d.ts +3 -0
  269. package/dist/services/text.js +17 -0
  270. package/dist/services/tree.svelte.d.ts +29 -43
  271. package/dist/services/tree.svelte.js +58 -105
  272. package/dist/services/type-ahead.d.ts +10 -1
  273. package/dist/services/type-ahead.js +56 -34
  274. package/dist/typedefs.d.ts +108 -6
  275. package/dist/typedefs.js +63 -6
  276. package/package.json +5 -5
  277. package/dist/components/text-editor/conversion/html.d.ts +0 -30
  278. package/dist/components/text-editor/conversion/html.js +0 -857
  279. package/dist/components/text-editor/conversion/markdown.d.ts +0 -56
  280. package/dist/components/text-editor/conversion/markdown.js +0 -949
  281. package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte +0 -28
  282. package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte.d.ts +0 -37
  283. package/dist/components/text-editor/toolbar/insert-component.d.ts +0 -3
  284. package/dist/components/text-editor/toolbar/insert-component.js +0 -37
@@ -6,22 +6,18 @@
6
6
  import { _ } from '@sveltia/i18n';
7
7
 
8
8
  /**
9
- * @import { CommonEventHandlers } from '../../typedefs.js';
9
+ * @import { CommonEventHandlers, WidgetStateProps } from '../../typedefs.js';
10
10
  */
11
11
 
12
12
  /**
13
13
  * @typedef {object} Props
14
14
  * @property {string} [class] The `class` attribute on the wrapper element.
15
- * @property {boolean} [hidden] Whether to hide the widget. An alias of the `aria-hidden`
16
- * attribute.
17
- * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
18
- * attribute.
19
15
  * @property {string} [label] Text label displayed above the group items.
20
16
  * @property {string} [title] Deprecated: use `label` instead.
21
17
  */
22
18
 
23
19
  /**
24
- * @type {CommonEventHandlers & Props & Record<string, any>}
20
+ * @type {CommonEventHandlers & WidgetStateProps & Props & Record<string, any>}
25
21
  */
26
22
  let {
27
23
  /* eslint-disable prefer-const */
@@ -1,24 +1,14 @@
1
1
  export default MenuItemGroup;
2
2
  type MenuItemGroup = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<KeyboardEventHandlers & MouseEventHandlers & PointerEventHandlers & FocusEventHandlers & DragEventHandlers & Props & Record<string, any>>): void;
4
+ $set?(props: Partial<KeyboardEventHandlers & MouseEventHandlers & PointerEventHandlers & FocusEventHandlers & DragEventHandlers & WidgetStateProps & Props & Record<string, any>>): void;
5
5
  };
6
6
  /** A menu item group. */
7
- declare const MenuItemGroup: import("svelte").Component<import("../../typedefs.js").KeyboardEventHandlers & import("../../typedefs.js").MouseEventHandlers & import("../../typedefs.js").PointerEventHandlers & import("../../typedefs.js").FocusEventHandlers & import("../../typedefs.js").DragEventHandlers & {
7
+ declare const MenuItemGroup: import("svelte").Component<import("../../typedefs.js").KeyboardEventHandlers & import("../../typedefs.js").MouseEventHandlers & import("../../typedefs.js").PointerEventHandlers & import("../../typedefs.js").FocusEventHandlers & import("../../typedefs.js").DragEventHandlers & WidgetStateProps & {
8
8
  /**
9
9
  * The `class` attribute on the wrapper element.
10
10
  */
11
11
  class?: string | undefined;
12
- /**
13
- * Whether to hide the widget. An alias of the `aria-hidden`
14
- * attribute.
15
- */
16
- hidden?: boolean | undefined;
17
- /**
18
- * Whether to disable the widget. An alias of the `aria-disabled`
19
- * attribute.
20
- */
21
- disabled?: boolean | undefined;
22
12
  /**
23
13
  * Text label displayed above the group items.
24
14
  */
@@ -33,16 +23,6 @@ type Props = {
33
23
  * The `class` attribute on the wrapper element.
34
24
  */
35
25
  class?: string | undefined;
36
- /**
37
- * Whether to hide the widget. An alias of the `aria-hidden`
38
- * attribute.
39
- */
40
- hidden?: boolean | undefined;
41
- /**
42
- * Whether to disable the widget. An alias of the `aria-disabled`
43
- * attribute.
44
- */
45
- disabled?: boolean | undefined;
46
26
  /**
47
27
  * Text label displayed above the group items.
48
28
  */
@@ -52,3 +32,4 @@ type Props = {
52
32
  */
53
33
  title?: string | undefined;
54
34
  };
35
+ import type { WidgetStateProps } from '../../typedefs.js';
@@ -161,7 +161,11 @@
161
161
  {@render _endIcon?.()}
162
162
  {/snippet}
163
163
  </Button>
164
- {#if hasItems && buttonElement && dialogElement}
164
+ <!--
165
+ A menu in a popup shares its `<dialog>` with the submenu, while a menu placed directly on the
166
+ page leaves the submenu to open its own
167
+ -->
168
+ {#if hasItems && buttonElement}
165
169
  <Popup
166
170
  anchor={buttonElement}
167
171
  parentDialogElement={dialogElement}
@@ -8,23 +8,17 @@
8
8
  import { activateGroup } from '../../services/group.svelte.js';
9
9
 
10
10
  /**
11
- * @import { Snippet } from 'svelte';
11
+ * @import { ContainerProps, WidgetStateProps } from '../../typedefs.js';
12
12
  */
13
13
 
14
14
  /**
15
15
  * @typedef {object} Props
16
- * @property {string} [class] The `class` attribute on the wrapper element.
17
- * @property {boolean} [hidden] Whether to hide the widget. An alias of the `aria-hidden`
18
- * attribute.
19
- * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
20
- * attribute.
21
16
  * @property {string} [ariaLabel] The `aria-label` attribute on the wrapper element.
22
- * @property {Snippet} [children] Primary slot content.
23
17
  * @property {(event: CustomEvent) => void} [onChange] Custom `Change` event handler.
24
18
  */
25
19
 
26
20
  /**
27
- * @type {Props & Record<string, any>}
21
+ * @type {ContainerProps & WidgetStateProps & Props & Record<string, any>}
28
22
  */
29
23
  let {
30
24
  /* eslint-disable prefer-const */
@@ -1,67 +1,32 @@
1
1
  export default Menu;
2
2
  type Menu = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<Props & Record<string, any>>): void;
4
+ $set?(props: Partial<ContainerProps & WidgetStateProps & Props & Record<string, any>>): void;
5
5
  };
6
6
  /**
7
7
  * A menu widget.
8
8
  * @see https://w3c.github.io/aria/#menu
9
9
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/menubar/
10
10
  */
11
- declare const Menu: import("svelte").Component<{
12
- /**
13
- * The `class` attribute on the wrapper element.
14
- */
15
- class?: string | undefined;
16
- /**
17
- * Whether to hide the widget. An alias of the `aria-hidden`
18
- * attribute.
19
- */
20
- hidden?: boolean | undefined;
21
- /**
22
- * Whether to disable the widget. An alias of the `aria-disabled`
23
- * attribute.
24
- */
25
- disabled?: boolean | undefined;
11
+ declare const Menu: import("svelte").Component<ContainerProps & WidgetStateProps & {
26
12
  /**
27
13
  * The `aria-label` attribute on the wrapper element.
28
14
  */
29
15
  ariaLabel?: string | undefined;
30
- /**
31
- * Primary slot content.
32
- */
33
- children?: Snippet<[]> | undefined;
34
16
  /**
35
17
  * Custom `Change` event handler.
36
18
  */
37
19
  onChange?: ((event: CustomEvent) => void) | undefined;
38
20
  } & Record<string, any>, {}, "">;
39
21
  type Props = {
40
- /**
41
- * The `class` attribute on the wrapper element.
42
- */
43
- class?: string | undefined;
44
- /**
45
- * Whether to hide the widget. An alias of the `aria-hidden`
46
- * attribute.
47
- */
48
- hidden?: boolean | undefined;
49
- /**
50
- * Whether to disable the widget. An alias of the `aria-disabled`
51
- * attribute.
52
- */
53
- disabled?: boolean | undefined;
54
22
  /**
55
23
  * The `aria-label` attribute on the wrapper element.
56
24
  */
57
25
  ariaLabel?: string | undefined;
58
- /**
59
- * Primary slot content.
60
- */
61
- children?: Snippet<[]> | undefined;
62
26
  /**
63
27
  * Custom `Change` event handler.
64
28
  */
65
29
  onChange?: ((event: CustomEvent) => void) | undefined;
66
30
  };
67
- import type { Snippet } from 'svelte';
31
+ import type { ContainerProps } from '../../typedefs.js';
32
+ import type { WidgetStateProps } from '../../typedefs.js';
@@ -8,30 +8,19 @@
8
8
  import { activateGroup } from '../../services/group.svelte.js';
9
9
 
10
10
  /**
11
- * @import { Snippet } from 'svelte';
11
+ * @import { ContainerProps, FormFieldStateProps, WidgetStateProps } from '../../typedefs.js';
12
12
  */
13
13
 
14
14
  /**
15
15
  * @typedef {object} Props
16
- * @property {string} [class] The `class` attribute on the wrapper element.
17
- * @property {boolean} [hidden] Whether to hide the widget.
18
- * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
19
- * attribute.
20
- * @property {boolean} [readonly] Whether to make the widget read-only. An alias of the
21
- * `aria-readonly` attribute.
22
- * @property {boolean} [required] Whether to mark the widget required. An alias of the
23
- * `aria-required` attribute.
24
- * @property {boolean} [invalid] Whether to mark the widget invalid. An alias of the
25
- * `aria-invalid` attribute.
26
16
  * @property {'horizontal'|'vertical'} [orientation] Orientation of the widget. An alias of the
27
17
  * `aria-orientation` attribute.
28
18
  * @property {string} [ariaLabel] The `aria-label` attribute on the wrapper element.
29
- * @property {Snippet} [children] Primary slot content.
30
19
  * @property {(event: CustomEvent) => void} [onChange] Custom `Change` event handler.
31
20
  */
32
21
 
33
22
  /**
34
- * @type {Props & Record<string, any>}
23
+ * @type {ContainerProps & WidgetStateProps & FormFieldStateProps & Props & Record<string, any>}
35
24
  */
36
25
  let {
37
26
  /* eslint-disable prefer-const */
@@ -44,7 +33,6 @@
44
33
  orientation = 'horizontal',
45
34
  ariaLabel = undefined,
46
35
  children,
47
- onChange,
48
36
  ...restProps
49
37
  /* eslint-enable prefer-const */
50
38
  } = $props();
@@ -63,9 +51,6 @@
63
51
  aria-invalid={invalid}
64
52
  aria-orientation={orientation}
65
53
  aria-label={ariaLabel}
66
- onChange={(/** @type {CustomEvent} */ event) => {
67
- onChange?.(event);
68
- }}
69
54
  {@attach activateGroup()}
70
55
  >
71
56
  <div role="none" class="inner" inert={disabled}>
@@ -1,42 +1,14 @@
1
1
  export default RadioGroup;
2
2
  type RadioGroup = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<Props & Record<string, any>>): void;
4
+ $set?(props: Partial<ContainerProps & WidgetStateProps & FormFieldStateProps & Props & Record<string, any>>): void;
5
5
  };
6
6
  /**
7
7
  * The container of `<Radio>`s.
8
8
  * @see https://w3c.github.io/aria/#radiogroup
9
9
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/radio/
10
10
  */
11
- declare const RadioGroup: import("svelte").Component<{
12
- /**
13
- * The `class` attribute on the wrapper element.
14
- */
15
- class?: string | undefined;
16
- /**
17
- * Whether to hide the widget.
18
- */
19
- hidden?: boolean | undefined;
20
- /**
21
- * Whether to disable the widget. An alias of the `aria-disabled`
22
- * attribute.
23
- */
24
- disabled?: boolean | undefined;
25
- /**
26
- * Whether to make the widget read-only. An alias of the
27
- * `aria-readonly` attribute.
28
- */
29
- readonly?: boolean | undefined;
30
- /**
31
- * Whether to mark the widget required. An alias of the
32
- * `aria-required` attribute.
33
- */
34
- required?: boolean | undefined;
35
- /**
36
- * Whether to mark the widget invalid. An alias of the
37
- * `aria-invalid` attribute.
38
- */
39
- invalid?: boolean | undefined;
11
+ declare const RadioGroup: import("svelte").Component<ContainerProps & WidgetStateProps & FormFieldStateProps & {
40
12
  /**
41
13
  * Orientation of the widget. An alias of the
42
14
  * `aria-orientation` attribute.
@@ -46,44 +18,12 @@ declare const RadioGroup: import("svelte").Component<{
46
18
  * The `aria-label` attribute on the wrapper element.
47
19
  */
48
20
  ariaLabel?: string | undefined;
49
- /**
50
- * Primary slot content.
51
- */
52
- children?: Snippet<[]> | undefined;
53
21
  /**
54
22
  * Custom `Change` event handler.
55
23
  */
56
24
  onChange?: ((event: CustomEvent) => void) | undefined;
57
25
  } & Record<string, any>, {}, "">;
58
26
  type Props = {
59
- /**
60
- * The `class` attribute on the wrapper element.
61
- */
62
- class?: string | undefined;
63
- /**
64
- * Whether to hide the widget.
65
- */
66
- hidden?: boolean | undefined;
67
- /**
68
- * Whether to disable the widget. An alias of the `aria-disabled`
69
- * attribute.
70
- */
71
- disabled?: boolean | undefined;
72
- /**
73
- * Whether to make the widget read-only. An alias of the
74
- * `aria-readonly` attribute.
75
- */
76
- readonly?: boolean | undefined;
77
- /**
78
- * Whether to mark the widget required. An alias of the
79
- * `aria-required` attribute.
80
- */
81
- required?: boolean | undefined;
82
- /**
83
- * Whether to mark the widget invalid. An alias of the
84
- * `aria-invalid` attribute.
85
- */
86
- invalid?: boolean | undefined;
87
27
  /**
88
28
  * Orientation of the widget. An alias of the
89
29
  * `aria-orientation` attribute.
@@ -93,13 +33,11 @@ type Props = {
93
33
  * The `aria-label` attribute on the wrapper element.
94
34
  */
95
35
  ariaLabel?: string | undefined;
96
- /**
97
- * Primary slot content.
98
- */
99
- children?: Snippet<[]> | undefined;
100
36
  /**
101
37
  * Custom `Change` event handler.
102
38
  */
103
39
  onChange?: ((event: CustomEvent) => void) | undefined;
104
40
  };
105
- import type { Snippet } from 'svelte';
41
+ import type { ContainerProps } from '../../typedefs.js';
42
+ import type { WidgetStateProps } from '../../typedefs.js';
43
+ import type { FormFieldStateProps } from '../../typedefs.js';
@@ -6,19 +6,17 @@
6
6
  @see https://www.w3.org/WAI/ARIA/apg/patterns/radio/
7
7
  -->
8
8
  <script>
9
+ import { untrack } from 'svelte';
9
10
  import { getToggleLabelAttrs } from '../../services/label.js';
10
11
  import Button from '../button/button.svelte';
11
12
 
12
13
  /**
13
14
  * @import { Snippet } from 'svelte';
15
+ * @import { ContainerProps, WidgetStateProps } from '../../typedefs.js';
14
16
  */
15
17
 
16
18
  /**
17
19
  * @typedef {object} Props
18
- * @property {string} [class] The `class` attribute on the wrapper element.
19
- * @property {boolean} [hidden] Whether to hide the widget.
20
- * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
21
- * attribute.
22
20
  * @property {boolean} [checked] Whether to check the widget. An alias of the `aria-checked`
23
21
  * attribute.
24
22
  * @property {string} [name] The `data-name` attribute on the `<button>` element.
@@ -28,17 +26,17 @@
28
26
  * @property {string} [label] Text label displayed next to the radio button.
29
27
  * @property {string} [ariaLabel] `aria-label` attribute on the `<button>` element, for a radio
30
28
  * button without a visible label.
31
- * @property {string} [group] The two-way bound variable to manage the state of a group of radio
29
+ * @property {any} [group] The two-way bound variable to manage the state of a group of radio
32
30
  * buttons. It works in the same way as the [`<input
33
- * bind:group>`](https://svelte.dev/docs/svelte/bind#input-bind:group) of Svelte.
34
- * @property {Snippet} [children] Primary slot content.
31
+ * bind:group>`](https://svelte.dev/docs/svelte/bind#input-bind:group) of Svelte: it can hold any
32
+ * type of value, including `undefined` before a choice is made.
35
33
  * @property {Snippet} [default] Default slot content.
36
34
  * @property {(event: CustomEvent) => void} [onChange] Custom `Change` event handler.
37
35
  * @property {(event: CustomEvent) => void} [onSelect] Custom `Select` event handler.
38
36
  */
39
37
 
40
38
  /**
41
- * @type {Props & Record<string, any>}
39
+ * @type {ContainerProps & WidgetStateProps & Props & Record<string, any>}
42
40
  */
43
41
  let {
44
42
  /* eslint-disable prefer-const */
@@ -82,17 +80,19 @@
82
80
  const isGroupReadOnly = () =>
83
81
  !!buttonElement?.closest('[role="radiogroup"]')?.matches('[aria-readonly="true"]');
84
82
 
85
- // Sync `checked` with `group` and `value`
83
+ // Sync `checked` with `group` and `value`. An unbound `group` and a bound one that’s still
84
+ // `undefined` read the same, so leave `checked` alone until there’s a choice. Only a change to
85
+ // `group` or `value` triggers the sync, not one to `checked`: without a bound `group`, the one
86
+ // set on a click stays local to this radio button, and must not check it again when the group
87
+ // unchecks it as the arrow keys move.
86
88
  $effect(() => {
87
- if (typeof group === 'string') {
88
- if (group === value) {
89
- if (!checked) {
90
- checked = true;
91
- }
92
- } else if (checked) {
93
- checked = false;
89
+ const isChecked = group !== undefined && group === value;
90
+
91
+ untrack(() => {
92
+ if (group !== undefined && checked !== isChecked) {
93
+ checked = isChecked;
94
94
  }
95
- }
95
+ });
96
96
  });
97
97
  </script>
98
98
 
@@ -133,10 +133,7 @@
133
133
  }
134
134
 
135
135
  checked = true;
136
-
137
- if (typeof group === 'string') {
138
- group = value;
139
- }
136
+ group = value;
140
137
  }}
141
138
  onChange={(/** @type {CustomEvent} */ event) => {
142
139
  // The group checks and unchecks the radio buttons by itself, as the arrow keys move, so keep
@@ -144,7 +141,7 @@
144
141
  // checked and ignore the next click
145
142
  checked = event.detail.checked;
146
143
 
147
- if (checked && typeof group === 'string') {
144
+ if (checked) {
148
145
  group = value;
149
146
  }
150
147
 
@@ -1,7 +1,7 @@
1
1
  export default Radio;
2
2
  type Radio = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<Props & Record<string, any>>): void;
4
+ $set?(props: Partial<ContainerProps & WidgetStateProps & Props & Record<string, any>>): void;
5
5
  };
6
6
  /**
7
7
  * The equivalent of the HTML `<input type="radio">` element.
@@ -9,20 +9,7 @@ type Radio = {
9
9
  * @see https://w3c.github.io/aria/#radio
10
10
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/radio/
11
11
  */
12
- declare const Radio: import("svelte").Component<{
13
- /**
14
- * The `class` attribute on the wrapper element.
15
- */
16
- class?: string | undefined;
17
- /**
18
- * Whether to hide the widget.
19
- */
20
- hidden?: boolean | undefined;
21
- /**
22
- * Whether to disable the widget. An alias of the `aria-disabled`
23
- * attribute.
24
- */
25
- disabled?: boolean | undefined;
12
+ declare const Radio: import("svelte").Component<ContainerProps & WidgetStateProps & {
26
13
  /**
27
14
  * Whether to check the widget. An alias of the `aria-checked`
28
15
  * attribute.
@@ -53,13 +40,10 @@ declare const Radio: import("svelte").Component<{
53
40
  /**
54
41
  * The two-way bound variable to manage the state of a group of radio
55
42
  * buttons. It works in the same way as the [`<input
56
- * bind:group>`](https://svelte.dev/docs/svelte/bind#input-bind:group) of Svelte.
57
- */
58
- group?: string | undefined;
59
- /**
60
- * Primary slot content.
43
+ * bind:group>`](https://svelte.dev/docs/svelte/bind#input-bind:group) of Svelte: it can hold any
44
+ * type of value, including `undefined` before a choice is made.
61
45
  */
62
- children?: Snippet<[]> | undefined;
46
+ group?: any;
63
47
  /**
64
48
  * Default slot content.
65
49
  */
@@ -74,19 +58,6 @@ declare const Radio: import("svelte").Component<{
74
58
  onSelect?: ((event: CustomEvent) => void) | undefined;
75
59
  } & Record<string, any>, {}, "group">;
76
60
  type Props = {
77
- /**
78
- * The `class` attribute on the wrapper element.
79
- */
80
- class?: string | undefined;
81
- /**
82
- * Whether to hide the widget.
83
- */
84
- hidden?: boolean | undefined;
85
- /**
86
- * Whether to disable the widget. An alias of the `aria-disabled`
87
- * attribute.
88
- */
89
- disabled?: boolean | undefined;
90
61
  /**
91
62
  * Whether to check the widget. An alias of the `aria-checked`
92
63
  * attribute.
@@ -117,13 +88,10 @@ type Props = {
117
88
  /**
118
89
  * The two-way bound variable to manage the state of a group of radio
119
90
  * buttons. It works in the same way as the [`<input
120
- * bind:group>`](https://svelte.dev/docs/svelte/bind#input-bind:group) of Svelte.
121
- */
122
- group?: string | undefined;
123
- /**
124
- * Primary slot content.
91
+ * bind:group>`](https://svelte.dev/docs/svelte/bind#input-bind:group) of Svelte: it can hold any
92
+ * type of value, including `undefined` before a choice is made.
125
93
  */
126
- children?: Snippet<[]> | undefined;
94
+ group?: any;
127
95
  /**
128
96
  * Default slot content.
129
97
  */
@@ -137,4 +105,6 @@ type Props = {
137
105
  */
138
106
  onSelect?: ((event: CustomEvent) => void) | undefined;
139
107
  };
108
+ import type { ContainerProps } from '../../typedefs.js';
109
+ import type { WidgetStateProps } from '../../typedefs.js';
140
110
  import type { Snippet } from 'svelte';