@sveltia/ui 0.91.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 (226) 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/conversion/editor-components.js +4 -4
  102. package/dist/components/text-editor/conversion/html/export.js +1 -1
  103. package/dist/components/text-editor/conversion/import.js +32 -26
  104. package/dist/components/text-editor/conversion/markdown/block-conversion.d.ts +4 -0
  105. package/dist/components/text-editor/conversion/markdown/block-conversion.js +154 -0
  106. package/dist/components/text-editor/conversion/markdown/block-structure.d.ts +16 -0
  107. package/dist/components/text-editor/conversion/markdown/block-structure.js +254 -0
  108. package/dist/components/text-editor/conversion/markdown/code-blocks.d.ts +57 -0
  109. package/dist/components/text-editor/conversion/markdown/code-blocks.js +279 -0
  110. package/dist/components/text-editor/conversion/markdown/code-spans.d.ts +19 -0
  111. package/dist/components/text-editor/conversion/markdown/code-spans.js +71 -0
  112. package/dist/components/text-editor/conversion/markdown/formatting.d.ts +22 -0
  113. package/dist/components/text-editor/conversion/markdown/formatting.js +451 -0
  114. package/dist/components/text-editor/conversion/markdown/index.d.ts +10 -0
  115. package/dist/components/text-editor/conversion/markdown/index.js +55 -0
  116. package/dist/components/text-editor/conversion/markdown/placeholders.d.ts +2 -0
  117. package/dist/components/text-editor/conversion/markdown/placeholders.js +229 -0
  118. package/dist/components/text-editor/conversion/markdown/syntax.d.ts +99 -0
  119. package/dist/components/text-editor/conversion/markdown/syntax.js +206 -0
  120. package/dist/components/text-editor/conversion/placeholder-chars.d.ts +43 -0
  121. package/dist/components/text-editor/conversion/placeholder-chars.js +51 -0
  122. package/dist/components/text-editor/conversion/transformers/block-escape.d.ts +1 -0
  123. package/dist/components/text-editor/conversion/transformers/block-escape.js +53 -26
  124. package/dist/components/text-editor/conversion/transformers/code.d.ts +3 -14
  125. package/dist/components/text-editor/conversion/transformers/code.js +78 -16
  126. package/dist/components/text-editor/conversion/transformers/formatted-code.js +3 -18
  127. package/dist/components/text-editor/conversion/transformers/inline-code.js +3 -1
  128. package/dist/components/text-editor/conversion/transformers/link.js +3 -1
  129. package/dist/components/text-editor/conversion/transformers/raw-syntax.d.ts +0 -19
  130. package/dist/components/text-editor/conversion/transformers/raw-syntax.js +22 -93
  131. package/dist/components/text-editor/conversion/transformers/table.js +57 -16
  132. package/dist/components/text-editor/conversion/update.d.ts +19 -2
  133. package/dist/components/text-editor/conversion/update.js +63 -39
  134. package/dist/components/text-editor/core.d.ts +12 -51
  135. package/dist/components/text-editor/core.js +44 -66
  136. package/dist/components/text-editor/editing/raw-markdown.d.ts +3 -0
  137. package/dist/components/text-editor/editing/raw-markdown.js +46 -2
  138. package/dist/components/text-editor/lexical-root.svelte +49 -47
  139. package/dist/components/text-editor/lexical-root.svelte.d.ts +4 -67
  140. package/dist/components/text-editor/shiki/{facade.d.ts → engine.d.ts} +8 -8
  141. package/dist/components/text-editor/shiki/{facade.js → engine.js} +53 -156
  142. package/dist/components/text-editor/shiki/highlighter.js +5 -5
  143. package/dist/components/text-editor/shiki/lexical.d.ts +6 -0
  144. package/dist/components/text-editor/shiki/lexical.js +165 -0
  145. package/dist/components/text-editor/shiki/preload.js +1 -1
  146. package/dist/components/text-editor/shiki/source-highlight.svelte.d.ts +15 -0
  147. package/dist/components/text-editor/shiki/source-highlight.svelte.js +120 -0
  148. package/dist/components/text-editor/shiki/version.d.ts +1 -1
  149. package/dist/components/text-editor/shiki/version.js +1 -1
  150. package/dist/components/text-editor/store.svelte.js +65 -16
  151. package/dist/components/text-editor/text-editor.svelte +53 -145
  152. package/dist/components/text-editor/text-editor.svelte.d.ts +5 -103
  153. package/dist/components/text-editor/toolbar/actions.d.ts +25 -0
  154. package/dist/components/text-editor/toolbar/actions.js +107 -0
  155. package/dist/components/text-editor/toolbar/align-menu-button.svelte +16 -14
  156. package/dist/components/text-editor/toolbar/format-text-button.svelte +26 -24
  157. package/dist/components/text-editor/toolbar/insert-horizontal-rule-button.svelte +23 -23
  158. package/dist/components/text-editor/toolbar/insert-item-button.svelte +1 -1
  159. package/dist/components/text-editor/toolbar/insert-link-button.svelte +47 -51
  160. package/dist/components/text-editor/toolbar/insert-menu-button.svelte +1 -1
  161. package/dist/components/text-editor/toolbar/insert-table-button.svelte +35 -52
  162. package/dist/components/text-editor/toolbar/table-action-menu.svelte +19 -17
  163. package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte +16 -4
  164. package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte.d.ts +0 -8
  165. package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte +34 -33
  166. package/dist/components/text-editor/widgets/emoji-autocomplete.svelte +7 -6
  167. package/dist/components/text-editor/widgets/floating-link-editor.svelte +19 -32
  168. package/dist/components/text-editor/widgets/table-cell-menu-button.svelte +28 -32
  169. package/dist/components/text-field/date-time-input.svelte +7 -8
  170. package/dist/components/text-field/date-time-input.svelte.d.ts +3 -32
  171. package/dist/components/text-field/number-input.d.ts +0 -2
  172. package/dist/components/text-field/number-input.js +25 -25
  173. package/dist/components/text-field/number-input.svelte +18 -9
  174. package/dist/components/text-field/number-input.svelte.d.ts +1 -1
  175. package/dist/components/text-field/text-area.d.ts +2 -0
  176. package/dist/components/text-field/text-area.js +31 -0
  177. package/dist/components/text-field/text-area.svelte +12 -25
  178. package/dist/components/text-field/text-area.svelte.d.ts +5 -67
  179. package/dist/components/toast/toast.svelte +31 -8
  180. package/dist/components/toast/toast.svelte.d.ts +6 -6
  181. package/dist/components/toolbar/toolbar.svelte +2 -7
  182. package/dist/components/toolbar/toolbar.svelte.d.ts +4 -37
  183. package/dist/components/tree/tree-item.svelte +2 -6
  184. package/dist/components/tree/tree-item.svelte.d.ts +3 -22
  185. package/dist/components/tree/tree.svelte +3 -10
  186. package/dist/components/tree/tree.svelte.d.ts +4 -39
  187. package/dist/components/util/group.svelte +2 -7
  188. package/dist/components/util/group.svelte.d.ts +4 -37
  189. package/dist/components/util/modal.d.ts +9 -0
  190. package/dist/components/util/modal.js +30 -0
  191. package/dist/components/util/modal.svelte +16 -12
  192. package/dist/index.d.ts +1 -1
  193. package/dist/index.js +1 -1
  194. package/dist/locales/hu.yaml +176 -0
  195. package/dist/services/composite-widget.svelte.d.ts +76 -0
  196. package/dist/services/composite-widget.svelte.js +157 -0
  197. package/dist/services/focus.d.ts +2 -0
  198. package/dist/services/focus.js +68 -0
  199. package/dist/services/group.svelte.d.ts +17 -69
  200. package/dist/services/group.svelte.js +128 -391
  201. package/dist/services/label.d.ts +9 -0
  202. package/dist/services/label.js +22 -0
  203. package/dist/services/menu.d.ts +8 -0
  204. package/dist/services/menu.js +237 -0
  205. package/dist/services/navigation.d.ts +9 -0
  206. package/dist/services/navigation.js +13 -0
  207. package/dist/services/number.d.ts +2 -0
  208. package/dist/services/number.js +27 -0
  209. package/dist/services/pointer-drag.d.ts +14 -0
  210. package/dist/services/pointer-drag.js +89 -0
  211. package/dist/services/popup.svelte.js +123 -103
  212. package/dist/services/text.d.ts +3 -0
  213. package/dist/services/text.js +17 -0
  214. package/dist/services/tree.svelte.d.ts +29 -43
  215. package/dist/services/tree.svelte.js +58 -105
  216. package/dist/services/type-ahead.d.ts +10 -1
  217. package/dist/services/type-ahead.js +56 -34
  218. package/dist/typedefs.d.ts +103 -4
  219. package/dist/typedefs.js +60 -4
  220. package/package.json +1 -1
  221. package/dist/components/text-editor/conversion/markdown.d.ts +0 -56
  222. package/dist/components/text-editor/conversion/markdown.js +0 -949
  223. package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte +0 -28
  224. package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte.d.ts +0 -37
  225. package/dist/components/text-editor/toolbar/insert-component.d.ts +0 -3
  226. package/dist/components/text-editor/toolbar/insert-component.js +0 -37
@@ -8,19 +8,14 @@
8
8
  import { _ } from '@sveltia/i18n';
9
9
  import { setContext } from 'svelte';
10
10
  import TablePart from '../table/table-part.svelte';
11
+ import { UNSELECTABLE_ROWS_KEY } from './grid.js';
11
12
 
12
13
  /**
13
- * @import { Snippet } from 'svelte';
14
+ * @import { ContainerProps } from '../../typedefs.js';
14
15
  */
15
16
 
16
17
  /**
17
- * @typedef {object} Props
18
- * @property {string} [class] The `class` attribute on the wrapper element.
19
- * @property {Snippet} [children] Primary slot content.
20
- */
21
-
22
- /**
23
- * @type {Props & Record<string, any>}
18
+ * @type {ContainerProps & Record<string, any>}
24
19
  */
25
20
  let {
26
21
  /* eslint-disable prefer-const */
@@ -29,7 +24,7 @@
29
24
  } = $props();
30
25
 
31
26
  // Tell the `<GridRow>`s inside that they are header rows, which can be focused but not selected
32
- setContext('sui:grid-unselectable-rows', true);
27
+ setContext(UNSELECTABLE_ROWS_KEY, true);
33
28
  </script>
34
29
 
35
30
  <TablePart
@@ -1,31 +1,12 @@
1
1
  export default GridHead;
2
2
  type GridHead = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<Props & Record<string, any>>): void;
4
+ $set?(props: Partial<ContainerProps & Record<string, any>>): void;
5
5
  };
6
6
  /**
7
7
  * The interactive version of `<TableHead>`.
8
8
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/thead
9
9
  * @see https://w3c.github.io/aria/#rowgroup
10
10
  */
11
- declare const GridHead: import("svelte").Component<{
12
- /**
13
- * The `class` attribute on the wrapper element.
14
- */
15
- class?: string | undefined;
16
- /**
17
- * Primary slot content.
18
- */
19
- children?: Snippet<[]> | undefined;
20
- } & Record<string, any>, {}, "">;
21
- type Props = {
22
- /**
23
- * The `class` attribute on the wrapper element.
24
- */
25
- class?: string | undefined;
26
- /**
27
- * Primary slot content.
28
- */
29
- children?: Snippet<[]> | undefined;
30
- };
31
- import type { Snippet } from 'svelte';
11
+ declare const GridHead: import("svelte").Component<ContainerProps & Record<string, any>, {}, "">;
12
+ import type { ContainerProps } from '../../typedefs.js';
@@ -8,17 +8,11 @@
8
8
  import TablePart from '../table/table-part.svelte';
9
9
 
10
10
  /**
11
- * @import { Snippet } from 'svelte';
11
+ * @import { ContainerProps } from '../../typedefs.js';
12
12
  */
13
13
 
14
14
  /**
15
- * @typedef {object} Props
16
- * @property {string} [class] The `class` attribute on the wrapper element.
17
- * @property {Snippet} [children] Primary slot content.
18
- */
19
-
20
- /**
21
- * @type {Props & Record<string, any>}
15
+ * @type {ContainerProps & Record<string, any>}
22
16
  */
23
17
  let {
24
18
  /* eslint-disable prefer-const */
@@ -1,31 +1,12 @@
1
1
  export default GridRowHeader;
2
2
  type GridRowHeader = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<Props & Record<string, any>>): void;
4
+ $set?(props: Partial<ContainerProps & Record<string, any>>): void;
5
5
  };
6
6
  /**
7
7
  * The interactive version of `<TableRowHeader>`.
8
8
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th
9
9
  * @see https://w3c.github.io/aria/#rowheader
10
10
  */
11
- declare const GridRowHeader: import("svelte").Component<{
12
- /**
13
- * The `class` attribute on the wrapper element.
14
- */
15
- class?: string | undefined;
16
- /**
17
- * Primary slot content.
18
- */
19
- children?: Snippet<[]> | undefined;
20
- } & Record<string, any>, {}, "">;
21
- type Props = {
22
- /**
23
- * The `class` attribute on the wrapper element.
24
- */
25
- class?: string | undefined;
26
- /**
27
- * Primary slot content.
28
- */
29
- children?: Snippet<[]> | undefined;
30
- };
31
- import type { Snippet } from 'svelte';
11
+ declare const GridRowHeader: import("svelte").Component<ContainerProps & Record<string, any>, {}, "">;
12
+ import type { ContainerProps } from '../../typedefs.js';
@@ -7,25 +7,24 @@
7
7
  <script>
8
8
  import { getContext } from 'svelte';
9
9
  import TablePart from '../table/table-part.svelte';
10
+ import { UNSELECTABLE_ROWS_KEY } from './grid.js';
10
11
 
11
12
  /**
12
- * @import { Snippet } from 'svelte';
13
13
  * @import { Attachment } from 'svelte/attachments';
14
+ * @import { ContainerProps } from '../../typedefs.js';
14
15
  */
15
16
 
16
17
  /**
17
18
  * @typedef {object} Props
18
- * @property {string} [class] The `class` attribute on the wrapper element.
19
19
  * @property {boolean} [selected] Whether to select the widget. An alias of the `aria-selected`
20
20
  * attribute. Ignored on a header or footer row inside `<GridHead>` or `<GridFoot>`, which can
21
21
  * never be selected.
22
- * @property {Snippet} [children] Primary slot content.
23
22
  * @property {(event: CustomEvent) => void} [onChange] Custom `Change` event handler.
24
23
  * @property {(event: CustomEvent) => void} [onSelect] Custom `Select` event handler.
25
24
  */
26
25
 
27
26
  /**
28
- * @type {Props & Record<string, any>}
27
+ * @type {ContainerProps & Props & Record<string, any>}
29
28
  */
30
29
  let {
31
30
  /* eslint-disable prefer-const */
@@ -39,7 +38,7 @@
39
38
  * keys still land on it, but it can’t be selected, so it has no `aria-selected` state, even one
40
39
  * passed as an attribute, and is marked for the group service to leave out of the selection.
41
40
  */
42
- const isUnselectableRow = getContext('sui:grid-unselectable-rows') === true;
41
+ const isUnselectableRow = getContext(UNSELECTABLE_ROWS_KEY) === true;
43
42
 
44
43
  const attributes = $derived.by(() => {
45
44
  if (!isUnselectableRow) {
@@ -1,28 +1,20 @@
1
1
  export default GridRow;
2
2
  type GridRow = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<Props & Record<string, any>>): void;
4
+ $set?(props: Partial<ContainerProps & Props & Record<string, any>>): void;
5
5
  };
6
6
  /**
7
7
  * The interactive version of `<TableRow>`.
8
8
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr
9
9
  * @see https://w3c.github.io/aria/#row
10
10
  */
11
- declare const GridRow: import("svelte").Component<{
12
- /**
13
- * The `class` attribute on the wrapper element.
14
- */
15
- class?: string | undefined;
11
+ declare const GridRow: import("svelte").Component<ContainerProps & {
16
12
  /**
17
13
  * Whether to select the widget. An alias of the `aria-selected`
18
14
  * attribute. Ignored on a header or footer row inside `<GridHead>` or `<GridFoot>`, which can
19
15
  * never be selected.
20
16
  */
21
17
  selected?: boolean | undefined;
22
- /**
23
- * Primary slot content.
24
- */
25
- children?: Snippet<[]> | undefined;
26
18
  /**
27
19
  * Custom `Change` event handler.
28
20
  */
@@ -33,20 +25,12 @@ declare const GridRow: import("svelte").Component<{
33
25
  onSelect?: ((event: CustomEvent) => void) | undefined;
34
26
  } & Record<string, any>, {}, "">;
35
27
  type Props = {
36
- /**
37
- * The `class` attribute on the wrapper element.
38
- */
39
- class?: string | undefined;
40
28
  /**
41
29
  * Whether to select the widget. An alias of the `aria-selected`
42
30
  * attribute. Ignored on a header or footer row inside `<GridHead>` or `<GridFoot>`, which can
43
31
  * never be selected.
44
32
  */
45
33
  selected?: boolean | undefined;
46
- /**
47
- * Primary slot content.
48
- */
49
- children?: Snippet<[]> | undefined;
50
34
  /**
51
35
  * Custom `Change` event handler.
52
36
  */
@@ -56,4 +40,4 @@ type Props = {
56
40
  */
57
41
  onSelect?: ((event: CustomEvent) => void) | undefined;
58
42
  };
59
- import type { Snippet } from 'svelte';
43
+ import type { ContainerProps } from '../../typedefs.js';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Values shared by the grid components.
3
+ */
4
+ /**
5
+ * Context key telling a `<GridRow>` whether it’s in a `<GridHead>` or `<GridFoot>`, where rows can
6
+ * be focused but not selected. A nested `<Grid>` resets it, as its rows are data rows of its own.
7
+ * `createContext()` isn’t used, as it requires a newer Svelte version than the library supports.
8
+ * @type {string}
9
+ */
10
+ export const UNSELECTABLE_ROWS_KEY: string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Values shared by the grid components.
3
+ */
4
+
5
+ /**
6
+ * Context key telling a `<GridRow>` whether it’s in a `<GridHead>` or `<GridFoot>`, where rows can
7
+ * be focused but not selected. A nested `<Grid>` resets it, as its rows are data rows of its own.
8
+ * `createContext()` isn’t used, as it requires a newer Svelte version than the library supports.
9
+ * @type {string}
10
+ */
11
+ export const UNSELECTABLE_ROWS_KEY = 'sui:grid-unselectable-rows';
@@ -7,25 +7,24 @@
7
7
  <script>
8
8
  import { setContext } from 'svelte';
9
9
  import { activateGroup } from '../../services/group.svelte.js';
10
+ import { UNSELECTABLE_ROWS_KEY } from './grid.js';
10
11
 
11
12
  /**
12
- * @import { Snippet } from 'svelte';
13
+ * @import { ContainerProps } from '../../typedefs.js';
13
14
  */
14
15
 
15
16
  /**
16
17
  * @typedef {object} Props
17
- * @property {string} [class] The `class` attribute on the wrapper element.
18
- * @property {boolean} [selected] Whether to allow selecting more than one `<GridRow>` and/or
18
+ * @property {boolean} [multiple] Whether to allow selecting more than one `<GridRow>` and/or
19
19
  * `<GridCell>`. An alias of the `aria-multiselectable` attribute.
20
20
  * @property {boolean} [clickToSelect] Whether to select a row by clicking on it.
21
21
  * @property {HTMLElement} [element] A reference to the wrapper element.
22
22
  * @property {string} [ariaLabel] The `aria-label` attribute on the wrapper element.
23
- * @property {Snippet} [children] Primary slot content.
24
23
  * @property {(event: CustomEvent) => void} [onChange] Custom `Change` event handler.
25
24
  */
26
25
 
27
26
  /**
28
- * @type {Props & Record<string, any>}
27
+ * @type {ContainerProps & Props & Record<string, any>}
29
28
  */
30
29
  let {
31
30
  /* eslint-disable prefer-const */
@@ -42,7 +41,7 @@
42
41
 
43
42
  // A grid nested in a header or footer cell of another grid has data rows of its own, so the
44
43
  // outer grid’s `<GridHead>` or `<GridFoot>` doesn’t make them unselectable
45
- setContext('sui:grid-unselectable-rows', false);
44
+ setContext(UNSELECTABLE_ROWS_KEY, false);
46
45
  </script>
47
46
 
48
47
  <div
@@ -55,7 +54,7 @@
55
54
  onChange={(/** @type {CustomEvent} */ event) => {
56
55
  onChange?.(event);
57
56
  }}
58
- {@attach activateGroup({ clickToSelect })}
57
+ {@attach activateGroup(() => ({ clickToSelect }))}
59
58
  >
60
59
  {@render children?.()}
61
60
  </div>
@@ -1,23 +1,19 @@
1
1
  export default Grid;
2
2
  type Grid = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<Props & Record<string, any>>): void;
4
+ $set?(props: Partial<ContainerProps & Props & Record<string, any>>): void;
5
5
  };
6
6
  /**
7
7
  * The interactive version of `<Table>`.
8
8
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table
9
9
  * @see https://w3c.github.io/aria/#grid
10
10
  */
11
- declare const Grid: import("svelte").Component<{
12
- /**
13
- * The `class` attribute on the wrapper element.
14
- */
15
- class?: string | undefined;
11
+ declare const Grid: import("svelte").Component<ContainerProps & {
16
12
  /**
17
13
  * Whether to allow selecting more than one `<GridRow>` and/or
18
14
  * `<GridCell>`. An alias of the `aria-multiselectable` attribute.
19
15
  */
20
- selected?: boolean | undefined;
16
+ multiple?: boolean | undefined;
21
17
  /**
22
18
  * Whether to select a row by clicking on it.
23
19
  */
@@ -30,25 +26,17 @@ declare const Grid: import("svelte").Component<{
30
26
  * The `aria-label` attribute on the wrapper element.
31
27
  */
32
28
  ariaLabel?: string | undefined;
33
- /**
34
- * Primary slot content.
35
- */
36
- children?: Snippet<[]> | undefined;
37
29
  /**
38
30
  * Custom `Change` event handler.
39
31
  */
40
32
  onChange?: ((event: CustomEvent) => void) | undefined;
41
33
  } & Record<string, any>, {}, "element">;
42
34
  type Props = {
43
- /**
44
- * The `class` attribute on the wrapper element.
45
- */
46
- class?: string | undefined;
47
35
  /**
48
36
  * Whether to allow selecting more than one `<GridRow>` and/or
49
37
  * `<GridCell>`. An alias of the `aria-multiselectable` attribute.
50
38
  */
51
- selected?: boolean | undefined;
39
+ multiple?: boolean | undefined;
52
40
  /**
53
41
  * Whether to select a row by clicking on it.
54
42
  */
@@ -61,13 +49,9 @@ type Props = {
61
49
  * The `aria-label` attribute on the wrapper element.
62
50
  */
63
51
  ariaLabel?: string | undefined;
64
- /**
65
- * Primary slot content.
66
- */
67
- children?: Snippet<[]> | undefined;
68
52
  /**
69
53
  * Custom `Change` event handler.
70
54
  */
71
55
  onChange?: ((event: CustomEvent) => void) | undefined;
72
56
  };
73
- import type { Snippet } from 'svelte';
57
+ import type { ContainerProps } from '../../typedefs.js';
@@ -9,34 +9,28 @@
9
9
  import { activateGroup } from '../../services/group.svelte.js';
10
10
 
11
11
  /**
12
- * @import { Snippet } from 'svelte';
13
- * @import { ButtonProps, CommonEventHandlers } from '../../typedefs.js';
12
+ * @import {
13
+ * ButtonProps,
14
+ * CommonEventHandlers,
15
+ * ContainerProps,
16
+ * FormFieldStateProps,
17
+ * WidgetStateProps,
18
+ * } from '../../typedefs.js';
14
19
  */
15
20
 
16
21
  /**
17
22
  * @typedef {object} Props
18
- * @property {string} [class] The `class` attribute on the wrapper element.
19
- * @property {boolean} [hidden] Whether to hide the widget. An alias of the `aria-hidden`
20
- * attribute.
21
- * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
22
- * attribute.
23
- * @property {boolean} [readonly] Whether to make the widget read-only. An alias of the
24
- * `aria-readonly` attribute.
25
- * @property {boolean} [required] Whether to mark the widget required. An alias of the
26
- * `aria-required` attribute.
27
- * @property {boolean} [invalid] Whether to mark the widget invalid. An alias of the
28
- * `aria-invalid` attribute.
29
23
  * @property {boolean} [multiple] Whether to allow selecting more than one `<Option>`. An alias of
30
24
  * the `aria-multiselectable` attribute.
31
25
  * @property {string} [searchTerms] Search terms to be used to filter the items.
32
26
  * @property {string} [ariaLabel] The `aria-label` attribute on the wrapper element.
33
- * @property {Snippet} [children] Primary slot content.
34
27
  * @property {(event: CustomEvent) => void} [onChange] Custom `Change` event handler.
35
28
  * @property {(event: CustomEvent) => void} [onFilter] Custom `Filter` event handler.
36
29
  */
37
30
 
38
31
  /**
39
- * @type {CommonEventHandlers & Props & Record<string, any>}
32
+ * @type {CommonEventHandlers & ContainerProps & WidgetStateProps & FormFieldStateProps & Props &
33
+ * Record<string, any>}
40
34
  */
41
35
  let {
42
36
  /* eslint-disable prefer-const */
@@ -50,6 +44,7 @@
50
44
  searchTerms = '',
51
45
  ariaLabel = undefined,
52
46
  children,
47
+ onChange,
53
48
  onFilter,
54
49
  ...restProps
55
50
  /* eslint-enable prefer-const */
@@ -59,6 +54,29 @@
59
54
  * @type {boolean}
60
55
  */
61
56
  let filtered = $state(false);
57
+
58
+ /**
59
+ * Handle the `Change` event from the group. The group only selects among the options that are
60
+ * shown, so an option hidden by the search terms keeps its selection. In a single-select listbox,
61
+ * that has to be cleared once another option is selected, or two would be selected once the
62
+ * filter is lifted.
63
+ * @param {CustomEvent} event The `Change` event.
64
+ */
65
+ const _onChange = (event) => {
66
+ const { currentTarget, target } = event;
67
+
68
+ // Only the listbox’s own event, not one dispatched on an option and bubbling up
69
+ if (!multiple && target === currentTarget) {
70
+ /** @type {HTMLElement} */ (currentTarget)
71
+ .querySelectorAll('[role="option"][aria-hidden="true"][aria-selected="true"]')
72
+ .forEach((option) => {
73
+ option.setAttribute('aria-selected', 'false');
74
+ option.dispatchEvent(new CustomEvent('Change', { detail: { selected: false } }));
75
+ });
76
+ }
77
+
78
+ onChange?.(event);
79
+ };
62
80
  </script>
63
81
 
64
82
  <div
@@ -75,6 +93,7 @@
75
93
  aria-invalid={invalid}
76
94
  aria-multiselectable={multiple}
77
95
  aria-label={ariaLabel}
96
+ onChange={_onChange}
78
97
  onFilter={(/** @type {CustomEvent} */ event) => {
79
98
  const {
80
99
  detail: { matched, total },
@@ -1,7 +1,7 @@
1
1
  export default Listbox;
2
2
  type Listbox = {
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 & ContainerProps & WidgetStateProps & FormFieldStateProps & Props & Record<string, any>>): void;
5
5
  };
6
6
  /**
7
7
  * A list widget with selectable options. The equivalent of the HTML `<select multiple>` element.
@@ -9,36 +9,7 @@ type Listbox = {
9
9
  * @see https://w3c.github.io/aria/#listbox
10
10
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/listbox/
11
11
  */
12
- declare const Listbox: import("svelte").Component<import("../../typedefs.js").KeyboardEventHandlers & import("../../typedefs.js").MouseEventHandlers & import("../../typedefs.js").PointerEventHandlers & import("../../typedefs.js").FocusEventHandlers & import("../../typedefs.js").DragEventHandlers & {
13
- /**
14
- * The `class` attribute on the wrapper element.
15
- */
16
- class?: string | undefined;
17
- /**
18
- * Whether to hide the widget. An alias of the `aria-hidden`
19
- * attribute.
20
- */
21
- hidden?: boolean | undefined;
22
- /**
23
- * Whether to disable the widget. An alias of the `aria-disabled`
24
- * attribute.
25
- */
26
- disabled?: boolean | undefined;
27
- /**
28
- * Whether to make the widget read-only. An alias of the
29
- * `aria-readonly` attribute.
30
- */
31
- readonly?: boolean | undefined;
32
- /**
33
- * Whether to mark the widget required. An alias of the
34
- * `aria-required` attribute.
35
- */
36
- required?: boolean | undefined;
37
- /**
38
- * Whether to mark the widget invalid. An alias of the
39
- * `aria-invalid` attribute.
40
- */
41
- invalid?: boolean | undefined;
12
+ declare const Listbox: import("svelte").Component<import("../../typedefs.js").KeyboardEventHandlers & import("../../typedefs.js").MouseEventHandlers & import("../../typedefs.js").PointerEventHandlers & import("../../typedefs.js").FocusEventHandlers & import("../../typedefs.js").DragEventHandlers & ContainerProps & WidgetStateProps & FormFieldStateProps & {
42
13
  /**
43
14
  * Whether to allow selecting more than one `<Option>`. An alias of
44
15
  * the `aria-multiselectable` attribute.
@@ -52,10 +23,6 @@ declare const Listbox: import("svelte").Component<import("../../typedefs.js").Ke
52
23
  * The `aria-label` attribute on the wrapper element.
53
24
  */
54
25
  ariaLabel?: string | undefined;
55
- /**
56
- * Primary slot content.
57
- */
58
- children?: Snippet<[]> | undefined;
59
26
  /**
60
27
  * Custom `Change` event handler.
61
28
  */
@@ -66,35 +33,6 @@ declare const Listbox: import("svelte").Component<import("../../typedefs.js").Ke
66
33
  onFilter?: ((event: CustomEvent) => void) | undefined;
67
34
  } & Record<string, any>, {}, "">;
68
35
  type Props = {
69
- /**
70
- * The `class` attribute on the wrapper element.
71
- */
72
- class?: string | undefined;
73
- /**
74
- * Whether to hide the widget. An alias of the `aria-hidden`
75
- * attribute.
76
- */
77
- hidden?: boolean | undefined;
78
- /**
79
- * Whether to disable the widget. An alias of the `aria-disabled`
80
- * attribute.
81
- */
82
- disabled?: boolean | undefined;
83
- /**
84
- * Whether to make the widget read-only. An alias of the
85
- * `aria-readonly` attribute.
86
- */
87
- readonly?: boolean | undefined;
88
- /**
89
- * Whether to mark the widget required. An alias of the
90
- * `aria-required` attribute.
91
- */
92
- required?: boolean | undefined;
93
- /**
94
- * Whether to mark the widget invalid. An alias of the
95
- * `aria-invalid` attribute.
96
- */
97
- invalid?: boolean | undefined;
98
36
  /**
99
37
  * Whether to allow selecting more than one `<Option>`. An alias of
100
38
  * the `aria-multiselectable` attribute.
@@ -108,10 +46,6 @@ type Props = {
108
46
  * The `aria-label` attribute on the wrapper element.
109
47
  */
110
48
  ariaLabel?: string | undefined;
111
- /**
112
- * Primary slot content.
113
- */
114
- children?: Snippet<[]> | undefined;
115
49
  /**
116
50
  * Custom `Change` event handler.
117
51
  */
@@ -121,4 +55,6 @@ type Props = {
121
55
  */
122
56
  onFilter?: ((event: CustomEvent) => void) | undefined;
123
57
  };
124
- import type { Snippet } from 'svelte';
58
+ import type { ContainerProps } from '../../typedefs.js';
59
+ import type { WidgetStateProps } from '../../typedefs.js';
60
+ import type { FormFieldStateProps } from '../../typedefs.js';
@@ -11,22 +11,16 @@
11
11
  import TruncatedText from '../typography/truncated-text.svelte';
12
12
 
13
13
  /**
14
- * @import { Snippet } from 'svelte';
14
+ * @import { ContainerProps, WidgetStateProps } from '../../typedefs.js';
15
15
  */
16
16
 
17
17
  /**
18
18
  * @typedef {object} Props
19
- * @property {string} [class] The `class` attribute on the wrapper element.
20
- * @property {boolean} [hidden] Whether to hide the widget. An alias of the `aria-hidden`
21
- * attribute.
22
- * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
23
- * attribute.
24
19
  * @property {string} [label] The group’s label to be displayed above the child `<Option>`s.
25
- * @property {Snippet} [children] Primary slot content.
26
20
  */
27
21
 
28
22
  /**
29
- * @type {Props & Record<string, any>}
23
+ * @type {ContainerProps & WidgetStateProps & Props & Record<string, any>}
30
24
  */
31
25
  let {
32
26
  /* eslint-disable prefer-const */
@@ -1,7 +1,7 @@
1
1
  export default OptionGroup;
2
2
  type OptionGroup = {
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 group within a `<Listbox>`. The equivalent of the HTML `<optgroup>` element. It can contain one
@@ -10,52 +10,17 @@ type OptionGroup = {
10
10
  * @see https://w3c.github.io/aria/#listbox
11
11
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/listbox/examples/listbox-grouped/
12
12
  */
13
- declare const OptionGroup: import("svelte").Component<{
14
- /**
15
- * The `class` attribute on the wrapper element.
16
- */
17
- class?: string | undefined;
18
- /**
19
- * Whether to hide the widget. An alias of the `aria-hidden`
20
- * attribute.
21
- */
22
- hidden?: boolean | undefined;
23
- /**
24
- * Whether to disable the widget. An alias of the `aria-disabled`
25
- * attribute.
26
- */
27
- disabled?: boolean | undefined;
13
+ declare const OptionGroup: import("svelte").Component<ContainerProps & WidgetStateProps & {
28
14
  /**
29
15
  * The group’s label to be displayed above the child `<Option>`s.
30
16
  */
31
17
  label?: string | undefined;
32
- /**
33
- * Primary slot content.
34
- */
35
- children?: Snippet<[]> | undefined;
36
18
  } & Record<string, any>, {}, "">;
37
19
  type Props = {
38
- /**
39
- * The `class` attribute on the wrapper element.
40
- */
41
- class?: string | undefined;
42
- /**
43
- * Whether to hide the widget. An alias of the `aria-hidden`
44
- * attribute.
45
- */
46
- hidden?: boolean | undefined;
47
- /**
48
- * Whether to disable the widget. An alias of the `aria-disabled`
49
- * attribute.
50
- */
51
- disabled?: boolean | undefined;
52
20
  /**
53
21
  * The group’s label to be displayed above the child `<Option>`s.
54
22
  */
55
23
  label?: string | undefined;
56
- /**
57
- * Primary slot content.
58
- */
59
- children?: Snippet<[]> | undefined;
60
24
  };
61
- import type { Snippet } from 'svelte';
25
+ import type { ContainerProps } from '../../typedefs.js';
26
+ import type { WidgetStateProps } from '../../typedefs.js';
@@ -150,8 +150,9 @@
150
150
  onChange?.(event);
151
151
  }}
152
152
  onToggle={(event) => {
153
+ // Being filtered out doesn’t change the selection, which comes back with the option. A
154
+ // single-select `<Listbox>` deselects it once another option is selected instead.
153
155
  hidden = event.detail.hidden;
154
- if (hidden) selected = false;
155
156
  onToggle?.(event);
156
157
  }}
157
158
  >