@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
@@ -10,7 +10,10 @@
10
10
  <script>
11
11
  import { isRTL } from '@sveltia/i18n';
12
12
  import { onMount, untrack } from 'svelte';
13
+ import { hasModifier } from '../../services/navigation.js';
14
+ import { startPointerDrag } from '../../services/pointer-drag.js';
13
15
  import {
16
+ clampThumbIndex,
14
17
  findNearestStepIndex,
15
18
  getNearestThumbIndex,
16
19
  getSliderCurrentIndex,
@@ -18,11 +21,10 @@
18
21
  getSliderKeyTargetIndex,
19
22
  getSliderSteps,
20
23
  toLogicalX,
21
- wouldCrossThumbs,
22
24
  } from './slider.js';
23
25
 
24
26
  /**
25
- * @import { Snippet } from 'svelte';
27
+ * @import { ContainerProps, WidgetStateProps } from '../../typedefs.js';
26
28
  */
27
29
 
28
30
  /**
@@ -39,21 +41,16 @@
39
41
  * @property {(string[] | number[])} [optionLabels] Visible labels on the slider. When there is
40
42
  * one per step, the current one is also read out as the value (`aria-valuetext`).
41
43
  * @property {boolean} [flex] Make the text input container flexible.
42
- * @property {string} [class] The `class` attribute on the wrapper element.
43
- * @property {boolean} [hidden] Whether to hide the widget.
44
- * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
45
- * attribute.
46
44
  * @property {boolean} [readonly] Whether to make the widget read-only. An alias of the
47
45
  * `aria-readonly` attribute.
48
46
  * @property {boolean} [invalid] Whether to mark the widget invalid. An alias of the
49
47
  * `aria-invalid` attribute.
50
- * @property {Snippet} [children] Primary slot content.
51
48
  * @property {(detail: { values?: number[], value?: number }) => void} [onChange] `change` event
52
49
  * handler.
53
50
  */
54
51
 
55
52
  /**
56
- * @type {Props & Record<string, any>}
53
+ * @type {ContainerProps & WidgetStateProps & Props & Record<string, any>}
57
54
  */
58
55
  let {
59
56
  /* eslint-disable prefer-const */
@@ -105,9 +102,12 @@
105
102
  let startScreenX = $state(0);
106
103
  // eslint-disable-next-line prefer-const
107
104
  let sliderPositions = $state([0, 0]);
108
- let dragging = $state(false);
109
- let targetPointerId = $state(0);
110
105
  let targetValueIndex = $state(0);
106
+ /**
107
+ * Function to stop following the pointer in the middle of a drag.
108
+ * @type {(() => void) | undefined}
109
+ */
110
+ let stopDrag;
111
111
 
112
112
  /**
113
113
  * Set the value of a thumb, and fire the `change` event if it’s actually changed. This is only
@@ -137,16 +137,20 @@
137
137
  * @param {number} physicalX Physical X position in pixels from the left edge.
138
138
  */
139
139
  const moveThumb = (physicalX) => {
140
- const index = findNearestStepIndex(positionList, toLogicalX(physicalX, barWidth, isRTL()));
140
+ let index = findNearestStepIndex(positionList, toLogicalX(physicalX, barWidth, isRTL()));
141
141
 
142
- if (
143
- multiThumb &&
144
- wouldCrossThumbs({
142
+ // Stop at the other thumb rather than ignoring the move, so a fast drag past it still brings
143
+ // the thumb as close as it can get
144
+ if (multiThumb) {
145
+ index = clampThumbIndex({
145
146
  valueIndex: targetValueIndex,
146
- targetPosition: positionList[index],
147
+ index,
148
+ positionList,
147
149
  sliderPositions,
148
- })
149
- ) {
150
+ });
151
+ }
152
+
153
+ if (index === -1) {
150
154
  return;
151
155
  }
152
156
 
@@ -159,17 +163,16 @@
159
163
  * @param {number} [valueIndex] Index in the {@link values} array to be used to get/set the value.
160
164
  */
161
165
  const onKeyDown = (event, valueIndex = 0) => {
162
- const { key, ctrlKey, metaKey, shiftKey, altKey } = event;
163
- const hasModifier = shiftKey || altKey || ctrlKey || metaKey;
166
+ const { key } = event;
164
167
 
165
- if (disabled || readonly || hasModifier) {
168
+ if (disabled || readonly || hasModifier(event)) {
166
169
  return;
167
170
  }
168
171
 
169
172
  const _value = multiThumb ? /** @type {[number, number]} */ (values)[valueIndex] : value;
170
173
  const rtl = isRTL();
171
174
 
172
- const index = getSliderKeyTargetIndex({
175
+ let index = getSliderKeyTargetIndex({
173
176
  key,
174
177
  rtl,
175
178
  currentIndex: getSliderCurrentIndex({
@@ -192,31 +195,39 @@
192
195
  event.preventDefault();
193
196
  event.stopPropagation();
194
197
 
195
- if (
196
- multiThumb &&
197
- wouldCrossThumbs({ valueIndex, targetPosition: positionList[index], sliderPositions })
198
- ) {
199
- return;
198
+ if (multiThumb) {
199
+ const targetValue = valueList[index];
200
+
201
+ // Stop at the other thumb rather than ignoring the key, so Home, End and the Page keys still
202
+ // bring the thumb as close as it can get
203
+ index = clampThumbIndex({ valueIndex, index, positionList, sliderPositions });
204
+
205
+ // Don’t move the thumb at all if the clamped step lies the other way, which can happen when
206
+ // the value sits between two steps
207
+ if (
208
+ index === -1 ||
209
+ Math.sign(valueList[index] - _value) !== Math.sign(targetValue - _value)
210
+ ) {
211
+ return;
212
+ }
200
213
  }
201
214
 
202
215
  setValue(valueIndex, valueList[index]);
203
216
  };
204
217
 
205
218
  /**
206
- * Handle the `pointermove` event fired anywhere on the page.
219
+ * Handle the `pointermove` event fired anywhere on the page while dragging.
207
220
  * @param {PointerEvent} event `pointermove` event.
208
221
  */
209
222
  const onPointerMove = (event) => {
210
- const { screenX, pointerId } = event;
211
-
212
- if (disabled || readonly || !dragging || pointerId !== targetPointerId) {
223
+ if (disabled || readonly) {
213
224
  return;
214
225
  }
215
226
 
216
227
  event.preventDefault();
217
228
  event.stopPropagation();
218
229
 
219
- const screenDiff = screenX - startScreenX;
230
+ const screenDiff = event.screenX - startScreenX;
220
231
  // Calculate new physical position from left edge
221
232
  const physicalX = startX + screenDiff;
222
233
 
@@ -224,40 +235,35 @@
224
235
  };
225
236
 
226
237
  /**
227
- * Handle the `pointerup` and `pointercancel` events fired anywhere on the page.
228
- * @param {PointerEvent} event `pointerup` or `pointercancel` event.
238
+ * Handle the end of a drag.
239
+ * @param {PointerEvent} event `pointerup` or `pointercancel` event, or `pointermove` event of a
240
+ * mouse that no longer has the primary button held down.
229
241
  */
230
- const onPointerUp = (event) => {
231
- const { pointerId, target } = event;
242
+ const onDragEnd = (event) => {
243
+ stopDrag = undefined;
232
244
 
233
- if (disabled || readonly || !dragging || pointerId !== targetPointerId) {
245
+ if (disabled || readonly) {
234
246
  return;
235
247
  }
236
248
 
237
249
  event.stopPropagation();
238
250
 
239
- const slider = /** @type {HTMLElement} */ (target);
240
-
241
- // Handle a click on the bars
242
- if (slider.matches('.base-bar, .slider-bar')) {
251
+ // Handle a click on the bars, but not a drag ended by a mouse moved without the button held
252
+ if (
253
+ event.type !== 'pointermove' &&
254
+ /** @type {HTMLElement} */ (event.target).matches('.base-bar, .slider-bar')
255
+ ) {
243
256
  const rect = /** @type {HTMLElement} */ (base).getBoundingClientRect();
244
257
  // Get physical X position from left edge
245
- const physicalX = /** @type {any} */ (event).clientX - rect.left;
258
+ const physicalX = event.clientX - rect.left;
246
259
 
247
260
  moveThumb(physicalX);
248
261
  }
249
262
 
250
263
  // Reset everything
251
- slider.releasePointerCapture(pointerId);
252
- dragging = false;
253
264
  startX = 0;
254
265
  startScreenX = 0;
255
- targetPointerId = 0;
256
266
  targetValueIndex = 0;
257
-
258
- document.removeEventListener('pointermove', onPointerMove);
259
- document.removeEventListener('pointerup', onPointerUp);
260
- document.removeEventListener('pointercancel', onPointerUp);
261
267
  };
262
268
 
263
269
  /**
@@ -274,26 +280,23 @@
274
280
  event.preventDefault();
275
281
  event.stopPropagation();
276
282
 
277
- dragging = true;
278
-
279
- const { clientX, screenX, pointerId, target } = event;
280
- const slider = /** @type {HTMLElement} */ (target);
283
+ const { clientX, screenX, target } = event;
281
284
  const rect = /** @type {HTMLElement} */ (base).getBoundingClientRect();
282
285
 
286
+ // A pointer pressed while another one is dragging takes over
287
+ stopDrag?.();
283
288
  // Store physical X position from left edge (same in LTR and RTL)
284
289
  startX = clientX - rect.left;
285
290
  startScreenX = screenX;
286
- targetPointerId = pointerId;
287
291
  targetValueIndex =
288
292
  valueIndex ??
289
293
  (multiThumb
290
294
  ? getNearestThumbIndex(sliderPositions, toLogicalX(startX, barWidth, isRTL()))
291
295
  : 0);
292
- slider.setPointerCapture(pointerId);
293
-
294
- document.addEventListener('pointermove', onPointerMove);
295
- document.addEventListener('pointerup', onPointerUp);
296
- document.addEventListener('pointercancel', onPointerUp);
296
+ stopDrag = startPointerDrag(/** @type {HTMLElement} */ (target), event, {
297
+ onMove: onPointerMove,
298
+ onEnd: onDragEnd,
299
+ });
297
300
  };
298
301
 
299
302
  /**
@@ -345,9 +348,7 @@
345
348
  observer.disconnect();
346
349
  query.removeEventListener('change', init);
347
350
  // Stop listening if the slider is removed in the middle of a drag
348
- document.removeEventListener('pointermove', onPointerMove);
349
- document.removeEventListener('pointerup', onPointerUp);
350
- document.removeEventListener('pointercancel', onPointerUp);
351
+ stopDrag?.();
351
352
  };
352
353
  });
353
354
 
@@ -369,7 +370,8 @@
369
370
 
370
371
  <svelte:body
371
372
  onclick={() => {
372
- dragging = false;
373
+ stopDrag?.();
374
+ stopDrag = undefined;
373
375
  }}
374
376
  />
375
377
 
@@ -1,7 +1,7 @@
1
1
  export default Slider;
2
2
  type Slider = {
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="range">` element, but it comes with the multi-thumb
@@ -11,7 +11,7 @@ type Slider = {
11
11
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/slider/
12
12
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/slider-multithumb/
13
13
  */
14
- declare const Slider: import("svelte").Component<{
14
+ declare const Slider: import("svelte").Component<ContainerProps & WidgetStateProps & {
15
15
  /**
16
16
  * Current value.
17
17
  */
@@ -54,19 +54,6 @@ declare const Slider: import("svelte").Component<{
54
54
  * Make the text input container flexible.
55
55
  */
56
56
  flex?: boolean | undefined;
57
- /**
58
- * The `class` attribute on the wrapper element.
59
- */
60
- class?: string | undefined;
61
- /**
62
- * Whether to hide the widget.
63
- */
64
- hidden?: boolean | undefined;
65
- /**
66
- * Whether to disable the widget. An alias of the `aria-disabled`
67
- * attribute.
68
- */
69
- disabled?: boolean | undefined;
70
57
  /**
71
58
  * Whether to make the widget read-only. An alias of the
72
59
  * `aria-readonly` attribute.
@@ -77,10 +64,6 @@ declare const Slider: import("svelte").Component<{
77
64
  * `aria-invalid` attribute.
78
65
  */
79
66
  invalid?: boolean | undefined;
80
- /**
81
- * Primary slot content.
82
- */
83
- children?: Snippet<[]> | undefined;
84
67
  /**
85
68
  * `change` event
86
69
  * handler.
@@ -133,19 +116,6 @@ type Props = {
133
116
  * Make the text input container flexible.
134
117
  */
135
118
  flex?: boolean | undefined;
136
- /**
137
- * The `class` attribute on the wrapper element.
138
- */
139
- class?: string | undefined;
140
- /**
141
- * Whether to hide the widget.
142
- */
143
- hidden?: boolean | undefined;
144
- /**
145
- * Whether to disable the widget. An alias of the `aria-disabled`
146
- * attribute.
147
- */
148
- disabled?: boolean | undefined;
149
119
  /**
150
120
  * Whether to make the widget read-only. An alias of the
151
121
  * `aria-readonly` attribute.
@@ -156,10 +126,6 @@ type Props = {
156
126
  * `aria-invalid` attribute.
157
127
  */
158
128
  invalid?: boolean | undefined;
159
- /**
160
- * Primary slot content.
161
- */
162
- children?: Snippet<[]> | undefined;
163
129
  /**
164
130
  * `change` event
165
131
  * handler.
@@ -169,4 +135,5 @@ type Props = {
169
135
  value?: number;
170
136
  }) => void) | undefined;
171
137
  };
172
- import type { Snippet } from 'svelte';
138
+ import type { ContainerProps } from '../../typedefs.js';
139
+ import type { WidgetStateProps } from '../../typedefs.js';
@@ -6,29 +6,18 @@
6
6
  -->
7
7
  <script>
8
8
  /**
9
- * @import { Snippet } from 'svelte';
9
+ * @import { ContainerProps, FormFieldStateProps, WidgetStateProps } from '../../typedefs.js';
10
10
  */
11
11
 
12
12
  /**
13
13
  * @typedef {object} Props
14
14
  * @property {string} [label] Text label displayed next to the switch.
15
- * @property {string} [class] The `class` attribute on the wrapper element.
16
- * @property {boolean} [hidden] Whether to hide the widget.
17
- * @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
18
- * attribute.
19
- * @property {boolean} [readonly] Whether to make the widget read-only. An alias of the
20
- * `aria-readonly` attribute.
21
- * @property {boolean} [required] Whether to mark the widget required. An alias of the
22
- * `aria-required` attribute.
23
- * @property {boolean} [invalid] Whether to mark the widget invalid. An alias of the
24
- * `aria-invalid` attribute.
25
15
  * @property {string} [ariaLabel] The `aria-label` attribute on the wrapper element.
26
- * @property {Snippet} [children] Primary slot content.
27
16
  * @property {(event: CustomEvent) => void} [onChange] Custom `Change` event handler.
28
17
  */
29
18
 
30
19
  /**
31
- * @type {Props & Record<string, any>}
20
+ * @type {ContainerProps & WidgetStateProps & FormFieldStateProps & Props & Record<string, any>}
32
21
  */
33
22
  let {
34
23
  /* eslint-disable prefer-const */
@@ -1,54 +1,22 @@
1
1
  export default Switch;
2
2
  type Switch = {
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
  * A variant of `<Checkbox>`, looking like a switch that can be often seen on mobile apps.
8
8
  * @see https://w3c.github.io/aria/#switch
9
9
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/switch/
10
10
  */
11
- declare const Switch: import("svelte").Component<{
11
+ declare const Switch: import("svelte").Component<ContainerProps & WidgetStateProps & FormFieldStateProps & {
12
12
  /**
13
13
  * Text label displayed next to the switch.
14
14
  */
15
15
  label?: string | undefined;
16
- /**
17
- * The `class` attribute on the wrapper element.
18
- */
19
- class?: string | undefined;
20
- /**
21
- * Whether to hide the widget.
22
- */
23
- hidden?: boolean | undefined;
24
- /**
25
- * Whether to disable the widget. An alias of the `aria-disabled`
26
- * attribute.
27
- */
28
- disabled?: boolean | undefined;
29
- /**
30
- * Whether to make the widget read-only. An alias of the
31
- * `aria-readonly` attribute.
32
- */
33
- readonly?: boolean | undefined;
34
- /**
35
- * Whether to mark the widget required. An alias of the
36
- * `aria-required` attribute.
37
- */
38
- required?: boolean | undefined;
39
- /**
40
- * Whether to mark the widget invalid. An alias of the
41
- * `aria-invalid` attribute.
42
- */
43
- invalid?: boolean | undefined;
44
16
  /**
45
17
  * The `aria-label` attribute on the wrapper element.
46
18
  */
47
19
  ariaLabel?: string | undefined;
48
- /**
49
- * Primary slot content.
50
- */
51
- children?: Snippet<[]> | undefined;
52
20
  /**
53
21
  * Custom `Change` event handler.
54
22
  */
@@ -59,45 +27,15 @@ type Props = {
59
27
  * Text label displayed next to the switch.
60
28
  */
61
29
  label?: string | undefined;
62
- /**
63
- * The `class` attribute on the wrapper element.
64
- */
65
- class?: string | undefined;
66
- /**
67
- * Whether to hide the widget.
68
- */
69
- hidden?: boolean | undefined;
70
- /**
71
- * Whether to disable the widget. An alias of the `aria-disabled`
72
- * attribute.
73
- */
74
- disabled?: boolean | undefined;
75
- /**
76
- * Whether to make the widget read-only. An alias of the
77
- * `aria-readonly` attribute.
78
- */
79
- readonly?: boolean | undefined;
80
- /**
81
- * Whether to mark the widget required. An alias of the
82
- * `aria-required` attribute.
83
- */
84
- required?: boolean | undefined;
85
- /**
86
- * Whether to mark the widget invalid. An alias of the
87
- * `aria-invalid` attribute.
88
- */
89
- invalid?: boolean | undefined;
90
30
  /**
91
31
  * The `aria-label` attribute on the wrapper element.
92
32
  */
93
33
  ariaLabel?: string | undefined;
94
- /**
95
- * Primary slot content.
96
- */
97
- children?: Snippet<[]> | undefined;
98
34
  /**
99
35
  * Custom `Change` event handler.
100
36
  */
101
37
  onChange?: ((event: CustomEvent) => void) | undefined;
102
38
  };
103
- import type { Snippet } from 'svelte';
39
+ import type { ContainerProps } from '../../typedefs.js';
40
+ import type { WidgetStateProps } from '../../typedefs.js';
41
+ import type { FormFieldStateProps } from '../../typedefs.js';
@@ -8,18 +8,16 @@
8
8
  import { _ } from '@sveltia/i18n';
9
9
 
10
10
  /**
11
- * @import { Snippet } from 'svelte';
11
+ * @import { ContainerProps } 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
16
  * @property {string} [label] Display label for the row group.
18
- * @property {Snippet} [children] Primary slot content.
19
17
  */
20
18
 
21
19
  /**
22
- * @type {Props & Record<string, any>}
20
+ * @type {ContainerProps & Props & Record<string, any>}
23
21
  */
24
22
  let {
25
23
  /* eslint-disable prefer-const */
@@ -1,39 +1,23 @@
1
1
  export default TableBody;
2
2
  type TableBody = {
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 equivalent of the HTML `<tbody>` element.
8
8
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody
9
9
  * @see https://w3c.github.io/aria/#rowgroup
10
10
  */
11
- declare const TableBody: import("svelte").Component<{
12
- /**
13
- * The `class` attribute on the wrapper element.
14
- */
15
- class?: string | undefined;
11
+ declare const TableBody: import("svelte").Component<ContainerProps & {
16
12
  /**
17
13
  * Display label for the row group.
18
14
  */
19
15
  label?: string | undefined;
20
- /**
21
- * Primary slot content.
22
- */
23
- children?: Snippet<[]> | undefined;
24
16
  } & Record<string, any>, {}, "">;
25
17
  type Props = {
26
- /**
27
- * The `class` attribute on the wrapper element.
28
- */
29
- class?: string | undefined;
30
18
  /**
31
19
  * Display label for the row group.
32
20
  */
33
21
  label?: string | undefined;
34
- /**
35
- * Primary slot content.
36
- */
37
- children?: Snippet<[]> | undefined;
38
22
  };
39
- import type { Snippet } from 'svelte';
23
+ import type { ContainerProps } from '../../typedefs.js';
@@ -8,17 +8,11 @@
8
8
  import TablePart from './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 TableCell;
2
2
  type TableCell = {
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 equivalent of the HTML `<td>` element.
8
8
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td
9
9
  * @see https://w3c.github.io/aria/#cell
10
10
  */
11
- declare const TableCell: 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 TableCell: import("svelte").Component<ContainerProps & Record<string, any>, {}, "">;
12
+ import type { ContainerProps } from '../../typedefs.js';
@@ -8,17 +8,11 @@
8
8
  import TablePart from './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 TableColHeader;
2
2
  type TableColHeader = {
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 equivalent of the HTML `<th scope="col">` element.
8
8
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th
9
9
  * @see https://w3c.github.io/aria/#columnheader
10
10
  */
11
- declare const TableColHeader: 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 TableColHeader: import("svelte").Component<ContainerProps & Record<string, any>, {}, "">;
12
+ import type { ContainerProps } from '../../typedefs.js';