@proyecto-viviana/solidaria 0.2.4 → 0.2.8
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.
- package/LICENSE +21 -0
- package/dist/actiongroup/createActionGroup.d.ts +29 -0
- package/dist/actiongroup/createActionGroup.d.ts.map +1 -0
- package/dist/actiongroup/index.d.ts +2 -0
- package/dist/actiongroup/index.d.ts.map +1 -0
- package/dist/autocomplete/createAutocomplete.d.ts +6 -2
- package/dist/autocomplete/createAutocomplete.d.ts.map +1 -1
- package/dist/breadcrumbs/createBreadcrumbs.d.ts +2 -0
- package/dist/breadcrumbs/createBreadcrumbs.d.ts.map +1 -1
- package/dist/button/createToggleButtonGroup.d.ts +32 -0
- package/dist/button/createToggleButtonGroup.d.ts.map +1 -0
- package/dist/button/index.d.ts +2 -0
- package/dist/button/index.d.ts.map +1 -1
- package/dist/calendar/createCalendarCell.d.ts +2 -0
- package/dist/calendar/createCalendarCell.d.ts.map +1 -1
- package/dist/calendar/createCalendarGrid.d.ts.map +1 -1
- package/dist/calendar/createRangeCalendarCell.d.ts +3 -1
- package/dist/calendar/createRangeCalendarCell.d.ts.map +1 -1
- package/dist/checkbox/createCheckboxGroup.d.ts +5 -1
- package/dist/checkbox/createCheckboxGroup.d.ts.map +1 -1
- package/dist/collections/index.d.ts +56 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/color/createColorArea.d.ts.map +1 -1
- package/dist/color/createColorSlider.d.ts.map +1 -1
- package/dist/color/createColorWheel.d.ts.map +1 -1
- package/dist/combobox/createComboBox.d.ts +6 -0
- package/dist/combobox/createComboBox.d.ts.map +1 -1
- package/dist/datepicker/createDatePicker.d.ts +6 -0
- package/dist/datepicker/createDatePicker.d.ts.map +1 -1
- package/dist/datepicker/createDateRangePicker.d.ts +40 -0
- package/dist/datepicker/createDateRangePicker.d.ts.map +1 -0
- package/dist/datepicker/createDateSegment.d.ts +1 -1
- package/dist/datepicker/createDateSegment.d.ts.map +1 -1
- package/dist/datepicker/createTimeSegment.d.ts +29 -0
- package/dist/datepicker/createTimeSegment.d.ts.map +1 -0
- package/dist/datepicker/index.d.ts +2 -0
- package/dist/datepicker/index.d.ts.map +1 -1
- package/dist/disclosure/createDisclosureGroup.d.ts +2 -1
- package/dist/disclosure/createDisclosureGroup.d.ts.map +1 -1
- package/dist/dnd/createDrag.d.ts.map +1 -1
- package/dist/dnd/createDraggableCollection.d.ts +4 -0
- package/dist/dnd/createDraggableCollection.d.ts.map +1 -1
- package/dist/dnd/createDraggableItem.d.ts.map +1 -1
- package/dist/dnd/createDrop.d.ts.map +1 -1
- package/dist/dnd/createDroppableCollection.d.ts +32 -1
- package/dist/dnd/createDroppableCollection.d.ts.map +1 -1
- package/dist/dnd/createDroppableItem.d.ts.map +1 -1
- package/dist/dnd/index.d.ts +1 -1
- package/dist/dnd/index.d.ts.map +1 -1
- package/dist/grid/createGrid.d.ts.map +1 -1
- package/dist/gridlist/createGridList.d.ts.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4659 -3452
- package/dist/index.js.map +1 -7
- package/dist/index.ssr.js +4659 -3452
- package/dist/index.ssr.js.map +1 -7
- package/dist/interactions/createFocus.d.ts.map +1 -1
- package/dist/interactions/createFocusWithin.d.ts.map +1 -1
- package/dist/link/createLink.d.ts +10 -0
- package/dist/link/createLink.d.ts.map +1 -1
- package/dist/listbox/createListBox.d.ts +1 -0
- package/dist/listbox/createListBox.d.ts.map +1 -1
- package/dist/listbox/createOption.d.ts.map +1 -1
- package/dist/menu/createMenu.d.ts +1 -0
- package/dist/menu/createMenu.d.ts.map +1 -1
- package/dist/meter/createMeter.d.ts.map +1 -1
- package/dist/numberfield/createNumberField.d.ts +18 -0
- package/dist/numberfield/createNumberField.d.ts.map +1 -1
- package/dist/overlays/createModal.d.ts +16 -0
- package/dist/overlays/createModal.d.ts.map +1 -1
- package/dist/overlays/createOverlay.d.ts.map +1 -1
- package/dist/overlays/index.d.ts +1 -1
- package/dist/overlays/index.d.ts.map +1 -1
- package/dist/popover/createOverlayPosition.d.ts.map +1 -1
- package/dist/popover/createPopover.d.ts.map +1 -1
- package/dist/progress/createProgressBar.d.ts.map +1 -1
- package/dist/radio/createRadioGroup.d.ts +2 -2
- package/dist/radio/createRadioGroup.d.ts.map +1 -1
- package/dist/searchfield/createSearchField.d.ts.map +1 -1
- package/dist/select/createHiddenSelect.d.ts.map +1 -1
- package/dist/select/createSelect.d.ts.map +1 -1
- package/dist/slider/createSlider.d.ts.map +1 -1
- package/dist/table/createTable.d.ts.map +1 -1
- package/dist/tabs/createTabs.d.ts +1 -1
- package/dist/tabs/createTabs.d.ts.map +1 -1
- package/dist/tag/createTag.d.ts.map +1 -1
- package/dist/tag/createTagGroup.d.ts.map +1 -1
- package/dist/toast/createToast.d.ts +4 -0
- package/dist/toast/createToast.d.ts.map +1 -1
- package/dist/toast/createToastRegion.d.ts.map +1 -1
- package/dist/toolbar/createToolbar.d.ts.map +1 -1
- package/dist/tooltip/createTooltipTrigger.d.ts.map +1 -1
- package/dist/tree/createTree.d.ts.map +1 -1
- package/dist/tree/createTreeItem.d.ts.map +1 -1
- package/dist/tree/types.d.ts +4 -0
- package/dist/tree/types.d.ts.map +1 -1
- package/dist/utils/env.d.ts +1 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/visually-hidden/createVisuallyHidden.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/actiongroup/createActionGroup.ts +324 -0
- package/src/actiongroup/index.ts +8 -0
- package/src/autocomplete/createAutocomplete.ts +32 -9
- package/src/breadcrumbs/createBreadcrumbs.ts +10 -15
- package/src/button/createButton.ts +1 -1
- package/src/button/createToggleButtonGroup.ts +128 -0
- package/src/button/index.ts +9 -0
- package/src/calendar/createCalendarCell.ts +6 -4
- package/src/calendar/createCalendarGrid.ts +27 -18
- package/src/calendar/createRangeCalendarCell.ts +26 -9
- package/src/checkbox/createCheckboxGroup.ts +21 -4
- package/src/collections/index.ts +242 -0
- package/src/color/createColorArea.ts +380 -314
- package/src/color/createColorField.ts +137 -137
- package/src/color/createColorSlider.ts +286 -197
- package/src/color/createColorSwatch.ts +40 -40
- package/src/color/createColorWheel.ts +218 -208
- package/src/color/index.ts +24 -24
- package/src/color/types.ts +116 -116
- package/src/combobox/createComboBox.ts +670 -647
- package/src/combobox/index.ts +6 -6
- package/src/datepicker/createDatePicker.ts +54 -16
- package/src/datepicker/createDateRangePicker.ts +246 -0
- package/src/datepicker/createDateSegment.ts +185 -31
- package/src/datepicker/createTimeSegment.ts +370 -0
- package/src/datepicker/index.ts +14 -0
- package/src/dialog/createDialog.ts +120 -120
- package/src/dialog/index.ts +2 -2
- package/src/dialog/types.ts +19 -19
- package/src/disclosure/createDisclosureGroup.ts +5 -2
- package/src/dnd/createDrag.ts +224 -209
- package/src/dnd/createDraggableCollection.ts +96 -63
- package/src/dnd/createDraggableItem.ts +259 -243
- package/src/dnd/createDrop.ts +322 -321
- package/src/dnd/createDroppableCollection.ts +682 -293
- package/src/dnd/createDroppableItem.ts +215 -213
- package/src/dnd/index.ts +55 -47
- package/src/dnd/types.ts +89 -89
- package/src/dnd/utils.ts +294 -294
- package/src/focus/createAutoFocus.ts +321 -321
- package/src/focus/createFocusRestore.ts +313 -313
- package/src/focus/createVirtualFocus.ts +396 -396
- package/src/form/createFormValidation.ts +224 -224
- package/src/form/index.ts +11 -11
- package/src/grid/createGrid.ts +3 -1
- package/src/gridlist/createGridList.ts +16 -0
- package/src/gridlist/createGridListItem.ts +1 -1
- package/src/i18n/NumberFormatter.ts +266 -266
- package/src/i18n/createCollator.ts +79 -79
- package/src/i18n/createDateFormatter.ts +83 -83
- package/src/i18n/createFilter.ts +131 -131
- package/src/i18n/createNumberFormatter.ts +52 -52
- package/src/i18n/index.ts +40 -40
- package/src/i18n/locale.tsx +188 -188
- package/src/i18n/utils.ts +99 -99
- package/src/index.ts +51 -0
- package/src/interactions/createFocus.ts +6 -5
- package/src/interactions/createFocusWithin.ts +6 -5
- package/src/interactions/createLongPress.ts +174 -174
- package/src/interactions/createMove.ts +289 -289
- package/src/interactions/createPress.ts +5 -5
- package/src/landmark/createLandmark.ts +377 -377
- package/src/landmark/index.ts +8 -8
- package/src/link/createLink.ts +23 -8
- package/src/listbox/createListBox.ts +308 -269
- package/src/listbox/createOption.ts +162 -151
- package/src/listbox/index.ts +12 -12
- package/src/live-announcer/announce.ts +322 -322
- package/src/live-announcer/index.ts +9 -9
- package/src/menu/createMenu.ts +405 -396
- package/src/menu/createMenuItem.ts +149 -149
- package/src/menu/createMenuTrigger.ts +88 -88
- package/src/menu/index.ts +18 -18
- package/src/meter/createMeter.ts +1 -6
- package/src/numberfield/createNumberField.ts +311 -268
- package/src/numberfield/index.ts +5 -5
- package/src/overlays/ariaHideOutside.ts +219 -219
- package/src/overlays/createInteractOutside.ts +149 -149
- package/src/overlays/createModal.tsx +238 -202
- package/src/overlays/createOverlay.ts +165 -155
- package/src/overlays/createOverlayTrigger.ts +85 -85
- package/src/overlays/createPreventScroll.ts +266 -266
- package/src/overlays/index.ts +48 -44
- package/src/popover/calculatePosition.ts +6 -6
- package/src/popover/createOverlayPosition.ts +7 -4
- package/src/popover/createPopover.ts +21 -7
- package/src/progress/createProgressBar.ts +6 -1
- package/src/radio/createRadioGroup.ts +88 -14
- package/src/searchfield/createSearchField.ts +241 -186
- package/src/searchfield/index.ts +2 -2
- package/src/select/createHiddenSelect.tsx +263 -236
- package/src/select/createSelect.ts +373 -395
- package/src/select/index.ts +14 -14
- package/src/slider/createSlider.ts +364 -349
- package/src/slider/index.ts +2 -2
- package/src/ssr/index.tsx +370 -370
- package/src/table/createTable.ts +3 -1
- package/src/table/createTableColumnHeader.ts +1 -1
- package/src/table/createTableRow.ts +1 -1
- package/src/tabs/createTabs.ts +80 -51
- package/src/tag/createTag.ts +135 -6
- package/src/tag/createTagGroup.ts +7 -2
- package/src/toast/createToast.ts +8 -2
- package/src/toast/createToastRegion.ts +0 -1
- package/src/toolbar/createToolbar.ts +75 -1
- package/src/tooltip/createTooltip.ts +79 -79
- package/src/tooltip/createTooltipTrigger.ts +226 -222
- package/src/tooltip/index.ts +6 -6
- package/src/tree/createTree.ts +261 -246
- package/src/tree/createTreeItem.ts +282 -233
- package/src/tree/createTreeSelectionCheckbox.ts +68 -68
- package/src/tree/index.ts +16 -16
- package/src/tree/types.ts +91 -87
- package/src/utils/env.ts +55 -54
- package/src/utils/platform.ts +16 -6
- package/src/visually-hidden/createVisuallyHidden.ts +139 -124
- package/src/visually-hidden/index.ts +6 -6
|
@@ -1,349 +1,364 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provides the behavior and accessibility implementation for a slider component.
|
|
3
|
-
* A slider allows users to select a value from a range.
|
|
4
|
-
* Based on @react-aria/slider useSlider.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { type JSX, onCleanup, onMount } from 'solid-js';
|
|
8
|
-
import { createLabel } from '../label/createLabel';
|
|
9
|
-
import { createFocusRing } from '../interactions/createFocusRing';
|
|
10
|
-
import { filterDOMProps } from '../utils/filterDOMProps';
|
|
11
|
-
import { mergeProps } from '../utils/mergeProps';
|
|
12
|
-
import { createId } from '../ssr';
|
|
13
|
-
import { access, type MaybeAccessor } from '../utils/reactivity';
|
|
14
|
-
import type { SliderState, SliderOrientation } from '@proyecto-viviana/solid-stately';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
label
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
orientation
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
position = (
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
e.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
case '
|
|
174
|
-
e.preventDefault();
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
get
|
|
268
|
-
return
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
'
|
|
308
|
-
'
|
|
309
|
-
'
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Provides the behavior and accessibility implementation for a slider component.
|
|
3
|
+
* A slider allows users to select a value from a range.
|
|
4
|
+
* Based on @react-aria/slider useSlider.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { type JSX, onCleanup, onMount } from 'solid-js';
|
|
8
|
+
import { createLabel } from '../label/createLabel';
|
|
9
|
+
import { createFocusRing } from '../interactions/createFocusRing';
|
|
10
|
+
import { filterDOMProps } from '../utils/filterDOMProps';
|
|
11
|
+
import { mergeProps } from '../utils/mergeProps';
|
|
12
|
+
import { createId } from '../ssr';
|
|
13
|
+
import { access, type MaybeAccessor } from '../utils/reactivity';
|
|
14
|
+
import type { SliderState, SliderOrientation } from '@proyecto-viviana/solid-stately';
|
|
15
|
+
import { useLocale } from '../i18n';
|
|
16
|
+
|
|
17
|
+
export interface AriaSliderProps {
|
|
18
|
+
/** An ID for the slider. */
|
|
19
|
+
id?: string;
|
|
20
|
+
/** Whether the slider is disabled. */
|
|
21
|
+
isDisabled?: boolean;
|
|
22
|
+
/** The label for the slider. */
|
|
23
|
+
label?: JSX.Element;
|
|
24
|
+
/** An accessible label for the slider when no visible label is provided. */
|
|
25
|
+
'aria-label'?: string;
|
|
26
|
+
/** The ID of an element that labels the slider. */
|
|
27
|
+
'aria-labelledby'?: string;
|
|
28
|
+
/** The ID of an element that describes the slider. */
|
|
29
|
+
'aria-describedby'?: string;
|
|
30
|
+
/** The orientation of the slider. */
|
|
31
|
+
orientation?: SliderOrientation;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface SliderAria {
|
|
35
|
+
/** Props for the label element. */
|
|
36
|
+
labelProps: JSX.HTMLAttributes<HTMLElement>;
|
|
37
|
+
/** Props for the root group element. */
|
|
38
|
+
groupProps: JSX.HTMLAttributes<HTMLElement>;
|
|
39
|
+
/** Props for the track element. */
|
|
40
|
+
trackProps: JSX.HTMLAttributes<HTMLElement>;
|
|
41
|
+
/** Props for the thumb element. */
|
|
42
|
+
thumbProps: JSX.HTMLAttributes<HTMLElement>;
|
|
43
|
+
/** Props for the hidden input element. */
|
|
44
|
+
inputProps: JSX.InputHTMLAttributes<HTMLInputElement>;
|
|
45
|
+
/** Props for the output element (showing current value). */
|
|
46
|
+
outputProps: JSX.HTMLAttributes<HTMLElement>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Provides the behavior and accessibility implementation for a slider.
|
|
51
|
+
*/
|
|
52
|
+
export function createSlider(
|
|
53
|
+
props: MaybeAccessor<AriaSliderProps>,
|
|
54
|
+
state: SliderState,
|
|
55
|
+
trackRef?: () => HTMLElement | null
|
|
56
|
+
): SliderAria {
|
|
57
|
+
const getProps = () => access(props);
|
|
58
|
+
const id = createId(getProps().id);
|
|
59
|
+
const locale = useLocale();
|
|
60
|
+
|
|
61
|
+
// Generate IDs for associated elements
|
|
62
|
+
const inputId = `${id}-input`;
|
|
63
|
+
const outputId = `${id}-output`;
|
|
64
|
+
|
|
65
|
+
// Filter DOM props
|
|
66
|
+
const domProps = () =>
|
|
67
|
+
filterDOMProps(getProps() as unknown as Record<string, unknown>, { labelable: true });
|
|
68
|
+
|
|
69
|
+
// Label handling
|
|
70
|
+
const { labelProps, fieldProps } = createLabel({
|
|
71
|
+
get id() {
|
|
72
|
+
return inputId;
|
|
73
|
+
},
|
|
74
|
+
get label() {
|
|
75
|
+
return getProps().label;
|
|
76
|
+
},
|
|
77
|
+
get 'aria-label'() {
|
|
78
|
+
return getProps()['aria-label'];
|
|
79
|
+
},
|
|
80
|
+
get 'aria-labelledby'() {
|
|
81
|
+
return getProps()['aria-labelledby'];
|
|
82
|
+
},
|
|
83
|
+
labelElementType: 'span',
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Focus ring for keyboard focus styling
|
|
87
|
+
const { isFocusVisible, focusProps } = createFocusRing({
|
|
88
|
+
within: true,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Track pointer state for drag handling
|
|
92
|
+
let currentPointerId: number | null = null;
|
|
93
|
+
|
|
94
|
+
// Calculate position from pointer event
|
|
95
|
+
const getPositionFromPointer = (clientX: number, clientY: number): number => {
|
|
96
|
+
const track = trackRef?.();
|
|
97
|
+
if (!track) return 0;
|
|
98
|
+
|
|
99
|
+
const rect = track.getBoundingClientRect();
|
|
100
|
+
const isVertical = state.orientation === 'vertical';
|
|
101
|
+
|
|
102
|
+
let position: number;
|
|
103
|
+
if (isVertical) {
|
|
104
|
+
position = (rect.bottom - clientY) / rect.height;
|
|
105
|
+
} else {
|
|
106
|
+
position = (clientX - rect.left) / rect.width;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return Math.max(0, Math.min(1, position));
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Handle pointer down on track
|
|
113
|
+
const onTrackPointerDown = (e: PointerEvent) => {
|
|
114
|
+
if (state.isDisabled || e.button !== 0) return;
|
|
115
|
+
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
currentPointerId = e.pointerId;
|
|
118
|
+
|
|
119
|
+
const track = trackRef?.();
|
|
120
|
+
if (track) {
|
|
121
|
+
track.setPointerCapture(e.pointerId);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const percent = getPositionFromPointer(e.clientX, e.clientY);
|
|
125
|
+
state.setValuePercent(percent);
|
|
126
|
+
state.setDragging(true);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Handle pointer move for dragging
|
|
130
|
+
const onTrackPointerMove = (e: PointerEvent) => {
|
|
131
|
+
if (!state.isDragging() || e.pointerId !== currentPointerId) return;
|
|
132
|
+
|
|
133
|
+
const percent = getPositionFromPointer(e.clientX, e.clientY);
|
|
134
|
+
state.setValuePercent(percent);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Handle pointer up to end drag
|
|
138
|
+
const onTrackPointerUp = (e: PointerEvent) => {
|
|
139
|
+
if (e.pointerId !== currentPointerId) return;
|
|
140
|
+
|
|
141
|
+
const track = trackRef?.();
|
|
142
|
+
if (track) {
|
|
143
|
+
track.releasePointerCapture(e.pointerId);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
currentPointerId = null;
|
|
147
|
+
state.setDragging(false);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// Keyboard navigation for thumb
|
|
151
|
+
const onThumbKeyDown = (e: KeyboardEvent) => {
|
|
152
|
+
if (state.isDisabled) return;
|
|
153
|
+
|
|
154
|
+
const isVertical = state.orientation === 'vertical';
|
|
155
|
+
const isRTL = locale().direction === 'rtl';
|
|
156
|
+
const shouldIncrementOnArrowRight = !isVertical && !isRTL;
|
|
157
|
+
const shouldIncrementOnArrowLeft = !isVertical && isRTL;
|
|
158
|
+
|
|
159
|
+
switch (e.key) {
|
|
160
|
+
case 'ArrowRight':
|
|
161
|
+
case 'ArrowUp':
|
|
162
|
+
e.preventDefault();
|
|
163
|
+
if (
|
|
164
|
+
(e.key === 'ArrowRight' && shouldIncrementOnArrowRight) ||
|
|
165
|
+
(e.key === 'ArrowUp' && isVertical)
|
|
166
|
+
) {
|
|
167
|
+
state.increment();
|
|
168
|
+
} else {
|
|
169
|
+
state.decrement();
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
case 'ArrowLeft':
|
|
173
|
+
case 'ArrowDown':
|
|
174
|
+
e.preventDefault();
|
|
175
|
+
if (
|
|
176
|
+
(e.key === 'ArrowLeft' && shouldIncrementOnArrowLeft) ||
|
|
177
|
+
(e.key === 'ArrowDown' && isVertical)
|
|
178
|
+
) {
|
|
179
|
+
state.increment();
|
|
180
|
+
} else {
|
|
181
|
+
state.decrement();
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
case 'PageUp':
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
state.increment(state.pageStep / state.step);
|
|
187
|
+
break;
|
|
188
|
+
case 'PageDown':
|
|
189
|
+
e.preventDefault();
|
|
190
|
+
state.decrement(state.pageStep / state.step);
|
|
191
|
+
break;
|
|
192
|
+
case 'Home':
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
state.setValue(state.minValue);
|
|
195
|
+
break;
|
|
196
|
+
case 'End':
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
state.setValue(state.maxValue);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// Handle focus events
|
|
204
|
+
const onFocus = () => {
|
|
205
|
+
state.setFocused(true);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const onBlur = () => {
|
|
209
|
+
state.setFocused(false);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// Handle pointer down on thumb (for direct thumb dragging)
|
|
213
|
+
const onThumbPointerDown = (e: PointerEvent) => {
|
|
214
|
+
if (state.isDisabled || e.button !== 0) return;
|
|
215
|
+
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
e.stopPropagation(); // Prevent track from also handling
|
|
218
|
+
currentPointerId = e.pointerId;
|
|
219
|
+
|
|
220
|
+
// Capture pointer on document for smooth dragging
|
|
221
|
+
document.body.setPointerCapture(e.pointerId);
|
|
222
|
+
state.setDragging(true);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// Global pointer move handler for thumb dragging
|
|
226
|
+
const onDocumentPointerMove = (e: PointerEvent) => {
|
|
227
|
+
if (!state.isDragging() || e.pointerId !== currentPointerId) return;
|
|
228
|
+
|
|
229
|
+
const percent = getPositionFromPointer(e.clientX, e.clientY);
|
|
230
|
+
state.setValuePercent(percent);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// Global pointer up handler
|
|
234
|
+
const onDocumentPointerUp = (e: PointerEvent) => {
|
|
235
|
+
if (e.pointerId !== currentPointerId) return;
|
|
236
|
+
|
|
237
|
+
try {
|
|
238
|
+
document.body.releasePointerCapture(e.pointerId);
|
|
239
|
+
} catch {
|
|
240
|
+
// Ignore if capture was already released
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
currentPointerId = null;
|
|
244
|
+
state.setDragging(false);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// Set up global listeners on mount (client-side only)
|
|
248
|
+
onMount(() => {
|
|
249
|
+
if (typeof document === 'undefined') return;
|
|
250
|
+
|
|
251
|
+
document.addEventListener('pointermove', onDocumentPointerMove);
|
|
252
|
+
document.addEventListener('pointerup', onDocumentPointerUp);
|
|
253
|
+
document.addEventListener('pointercancel', onDocumentPointerUp);
|
|
254
|
+
|
|
255
|
+
// Cleanup when component unmounts
|
|
256
|
+
onCleanup(() => {
|
|
257
|
+
document.removeEventListener('pointermove', onDocumentPointerMove);
|
|
258
|
+
document.removeEventListener('pointerup', onDocumentPointerUp);
|
|
259
|
+
document.removeEventListener('pointercancel', onDocumentPointerUp);
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const labelledBy = () => (fieldProps as { 'aria-labelledby'?: string })['aria-labelledby'];
|
|
264
|
+
const ariaLabel = () => (fieldProps as { 'aria-label'?: string })['aria-label'];
|
|
265
|
+
|
|
266
|
+
return {
|
|
267
|
+
get labelProps() {
|
|
268
|
+
return labelProps as JSX.HTMLAttributes<HTMLElement>;
|
|
269
|
+
},
|
|
270
|
+
get groupProps() {
|
|
271
|
+
return mergeProps(
|
|
272
|
+
domProps(),
|
|
273
|
+
fieldProps as Record<string, unknown>,
|
|
274
|
+
{
|
|
275
|
+
role: 'group',
|
|
276
|
+
'data-disabled': state.isDisabled || undefined,
|
|
277
|
+
'data-orientation': state.orientation,
|
|
278
|
+
} as Record<string, unknown>
|
|
279
|
+
) as JSX.HTMLAttributes<HTMLElement>;
|
|
280
|
+
},
|
|
281
|
+
get trackProps() {
|
|
282
|
+
return {
|
|
283
|
+
onPointerDown: onTrackPointerDown,
|
|
284
|
+
onPointerMove: onTrackPointerMove,
|
|
285
|
+
onPointerUp: onTrackPointerUp,
|
|
286
|
+
onPointerCancel: onTrackPointerUp,
|
|
287
|
+
style: {
|
|
288
|
+
position: 'relative',
|
|
289
|
+
'touch-action': 'none',
|
|
290
|
+
},
|
|
291
|
+
'data-disabled': state.isDisabled || undefined,
|
|
292
|
+
'data-orientation': state.orientation,
|
|
293
|
+
'data-dragging': state.isDragging() || undefined,
|
|
294
|
+
} as JSX.HTMLAttributes<HTMLElement>;
|
|
295
|
+
},
|
|
296
|
+
get thumbProps() {
|
|
297
|
+
const percent = state.getValuePercent();
|
|
298
|
+
const isVertical = state.orientation === 'vertical';
|
|
299
|
+
|
|
300
|
+
return mergeProps(
|
|
301
|
+
focusProps as Record<string, unknown>,
|
|
302
|
+
{
|
|
303
|
+
role: 'slider',
|
|
304
|
+
tabIndex: state.isDisabled ? undefined : 0,
|
|
305
|
+
'aria-valuemin': state.minValue,
|
|
306
|
+
'aria-valuemax': state.maxValue,
|
|
307
|
+
'aria-valuenow': state.value(),
|
|
308
|
+
'aria-valuetext': state.getFormattedValue(),
|
|
309
|
+
'aria-orientation': state.orientation,
|
|
310
|
+
'aria-disabled': state.isDisabled || undefined,
|
|
311
|
+
'aria-labelledby': labelledBy(),
|
|
312
|
+
'aria-label': labelledBy() ? undefined : ariaLabel(),
|
|
313
|
+
onPointerDown: onThumbPointerDown,
|
|
314
|
+
onKeyDown: onThumbKeyDown,
|
|
315
|
+
onFocus,
|
|
316
|
+
onBlur,
|
|
317
|
+
style: {
|
|
318
|
+
position: 'absolute',
|
|
319
|
+
[isVertical ? 'bottom' : 'left']: `${percent * 100}%`,
|
|
320
|
+
transform: isVertical ? 'translateY(50%)' : 'translateX(-50%)',
|
|
321
|
+
},
|
|
322
|
+
'data-disabled': state.isDisabled || undefined,
|
|
323
|
+
'data-dragging': state.isDragging() || undefined,
|
|
324
|
+
'data-focus-visible': isFocusVisible() || undefined,
|
|
325
|
+
} as Record<string, unknown>
|
|
326
|
+
) as JSX.HTMLAttributes<HTMLElement>;
|
|
327
|
+
},
|
|
328
|
+
get inputProps() {
|
|
329
|
+
return {
|
|
330
|
+
type: 'range',
|
|
331
|
+
id: inputId,
|
|
332
|
+
min: state.minValue,
|
|
333
|
+
max: state.maxValue,
|
|
334
|
+
step: state.step,
|
|
335
|
+
value: state.value(),
|
|
336
|
+
disabled: state.isDisabled,
|
|
337
|
+
'aria-hidden': true,
|
|
338
|
+
tabIndex: -1,
|
|
339
|
+
style: {
|
|
340
|
+
position: 'absolute',
|
|
341
|
+
width: '1px',
|
|
342
|
+
height: '1px',
|
|
343
|
+
padding: '0',
|
|
344
|
+
margin: '-1px',
|
|
345
|
+
overflow: 'hidden',
|
|
346
|
+
clip: 'rect(0, 0, 0, 0)',
|
|
347
|
+
'white-space': 'nowrap',
|
|
348
|
+
border: '0',
|
|
349
|
+
},
|
|
350
|
+
onChange: (e: Event) => {
|
|
351
|
+
const target = e.target as HTMLInputElement;
|
|
352
|
+
state.setValue(parseFloat(target.value));
|
|
353
|
+
},
|
|
354
|
+
} as JSX.InputHTMLAttributes<HTMLInputElement>;
|
|
355
|
+
},
|
|
356
|
+
get outputProps() {
|
|
357
|
+
return {
|
|
358
|
+
id: outputId,
|
|
359
|
+
'for': inputId,
|
|
360
|
+
'aria-live': 'off',
|
|
361
|
+
} as JSX.HTMLAttributes<HTMLElement>;
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
}
|