@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,197 +1,286 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* createColorSlider hook.
|
|
3
|
-
*
|
|
4
|
-
* Provides ARIA attributes and keyboard handling for a color slider.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { createMemo, type Accessor } from 'solid-js';
|
|
8
|
-
import type { ColorSliderState } from '@proyecto-viviana/solid-stately';
|
|
9
|
-
import { createId } from '../ssr';
|
|
10
|
-
import type { AriaColorSliderOptions, ColorSliderAria } from './types';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Creates ARIA props for a color slider.
|
|
14
|
-
*/
|
|
15
|
-
export function createColorSlider(
|
|
16
|
-
props: Accessor<AriaColorSliderOptions>,
|
|
17
|
-
state: Accessor<ColorSliderState>,
|
|
18
|
-
trackRef: Accessor<HTMLDivElement | null>
|
|
19
|
-
): ColorSliderAria {
|
|
20
|
-
const getProps = () => props();
|
|
21
|
-
const getState = () => state();
|
|
22
|
-
|
|
23
|
-
// Generate IDs
|
|
24
|
-
const inputId = createId();
|
|
25
|
-
const labelId = createId();
|
|
26
|
-
|
|
27
|
-
// Get channel name for ARIA label
|
|
28
|
-
const channelName = createMemo(() => {
|
|
29
|
-
const p = getProps();
|
|
30
|
-
if (p.channelName) return p.channelName;
|
|
31
|
-
const s = getState();
|
|
32
|
-
return s.value.getChannelName(s.channel, 'en-US');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
const
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
1
|
+
/**
|
|
2
|
+
* createColorSlider hook.
|
|
3
|
+
*
|
|
4
|
+
* Provides ARIA attributes and keyboard handling for a color slider.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createMemo, type Accessor } from 'solid-js';
|
|
8
|
+
import type { ColorSliderState } from '@proyecto-viviana/solid-stately';
|
|
9
|
+
import { createId } from '../ssr';
|
|
10
|
+
import type { AriaColorSliderOptions, ColorSliderAria } from './types';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates ARIA props for a color slider.
|
|
14
|
+
*/
|
|
15
|
+
export function createColorSlider(
|
|
16
|
+
props: Accessor<AriaColorSliderOptions>,
|
|
17
|
+
state: Accessor<ColorSliderState>,
|
|
18
|
+
trackRef: Accessor<HTMLDivElement | null>
|
|
19
|
+
): ColorSliderAria {
|
|
20
|
+
const getProps = () => props();
|
|
21
|
+
const getState = () => state();
|
|
22
|
+
|
|
23
|
+
// Generate IDs
|
|
24
|
+
const inputId = createId();
|
|
25
|
+
const labelId = createId();
|
|
26
|
+
|
|
27
|
+
// Get channel name for ARIA label
|
|
28
|
+
const channelName = createMemo(() => {
|
|
29
|
+
const p = getProps();
|
|
30
|
+
if (p.channelName) return p.channelName;
|
|
31
|
+
const s = getState();
|
|
32
|
+
return s.value.getChannelName(s.channel, 'en-US');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const updateFromClientX = (clientX: number) => {
|
|
36
|
+
if (getProps().isDisabled || getState().isDisabled) return;
|
|
37
|
+
|
|
38
|
+
const track = trackRef();
|
|
39
|
+
if (!track) return;
|
|
40
|
+
|
|
41
|
+
const rect = track.getBoundingClientRect();
|
|
42
|
+
const percent = (clientX - rect.left) / rect.width;
|
|
43
|
+
getState().setThumbPercent(Math.max(0, Math.min(1, percent)));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const endDrag = (target: EventTarget | null, pointerId?: number) => {
|
|
47
|
+
const s = getState();
|
|
48
|
+
if (!s.isDragging) return;
|
|
49
|
+
s.setDragging(false);
|
|
50
|
+
if (pointerId == null) return;
|
|
51
|
+
(target as HTMLElement | null)?.releasePointerCapture?.(pointerId);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Handle pointer interaction on the track
|
|
55
|
+
const onTrackPointerDown = (e: PointerEvent) => {
|
|
56
|
+
if (getProps().isDisabled || getState().isDisabled) return;
|
|
57
|
+
updateFromClientX(e.clientX);
|
|
58
|
+
getState().setDragging(true);
|
|
59
|
+
(e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const onTrackPointerMove = (e: PointerEvent) => {
|
|
64
|
+
if (!getState().isDragging) return;
|
|
65
|
+
updateFromClientX(e.clientX);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const onTrackPointerUp = (e: PointerEvent) => {
|
|
69
|
+
endDrag(e.currentTarget, e.pointerId);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const onTrackPointerCancel = (e: PointerEvent) => {
|
|
73
|
+
endDrag(e.currentTarget, e.pointerId);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const onTrackMouseDown = (e: MouseEvent) => {
|
|
77
|
+
if (getProps().isDisabled || getState().isDisabled) return;
|
|
78
|
+
updateFromClientX(e.clientX);
|
|
79
|
+
getState().setDragging(true);
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const onTrackMouseMove = (e: MouseEvent) => {
|
|
84
|
+
if (!getState().isDragging) return;
|
|
85
|
+
updateFromClientX(e.clientX);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const onTrackMouseUp = (e: MouseEvent) => {
|
|
89
|
+
endDrag(e.currentTarget);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// Handle keyboard
|
|
93
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
94
|
+
if (getProps().isDisabled || getState().isDisabled) return;
|
|
95
|
+
|
|
96
|
+
const s = getState();
|
|
97
|
+
let handled = true;
|
|
98
|
+
|
|
99
|
+
switch (e.key) {
|
|
100
|
+
case 'ArrowRight':
|
|
101
|
+
case 'ArrowUp':
|
|
102
|
+
s.incrementThumb();
|
|
103
|
+
break;
|
|
104
|
+
case 'ArrowLeft':
|
|
105
|
+
case 'ArrowDown':
|
|
106
|
+
s.decrementThumb();
|
|
107
|
+
break;
|
|
108
|
+
case 'PageUp':
|
|
109
|
+
s.incrementThumb(s.pageSize);
|
|
110
|
+
break;
|
|
111
|
+
case 'PageDown':
|
|
112
|
+
s.decrementThumb(s.pageSize);
|
|
113
|
+
break;
|
|
114
|
+
case 'Home':
|
|
115
|
+
s.setThumbValue(s.minValue);
|
|
116
|
+
break;
|
|
117
|
+
case 'End':
|
|
118
|
+
s.setThumbValue(s.maxValue);
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
handled = false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (handled) {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
e.stopPropagation();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// Generate gradient background for the slider track
|
|
131
|
+
const generateBackground = () => {
|
|
132
|
+
const s = getState();
|
|
133
|
+
const value = s.value;
|
|
134
|
+
const channel = s.channel;
|
|
135
|
+
const to = 'right';
|
|
136
|
+
|
|
137
|
+
switch (channel) {
|
|
138
|
+
case 'hue': {
|
|
139
|
+
const stops = [0, 60, 120, 180, 240, 300, 360]
|
|
140
|
+
.map(hue => value.withChannelValue('hue', hue).toString('css'))
|
|
141
|
+
.join(', ');
|
|
142
|
+
return `linear-gradient(to ${to}, ${stops})`;
|
|
143
|
+
}
|
|
144
|
+
case 'lightness': {
|
|
145
|
+
const min = s.minValue;
|
|
146
|
+
const max = s.maxValue;
|
|
147
|
+
const start = value.withChannelValue(channel, min).toString('css');
|
|
148
|
+
const middle = value.withChannelValue(channel, (max - min) / 2).toString('css');
|
|
149
|
+
const end = value.withChannelValue(channel, max).toString('css');
|
|
150
|
+
return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;
|
|
151
|
+
}
|
|
152
|
+
case 'saturation':
|
|
153
|
+
case 'brightness':
|
|
154
|
+
case 'red':
|
|
155
|
+
case 'green':
|
|
156
|
+
case 'blue':
|
|
157
|
+
case 'alpha': {
|
|
158
|
+
const start = value.withChannelValue(channel, s.minValue).toString('css');
|
|
159
|
+
const end = value.withChannelValue(channel, s.maxValue).toString('css');
|
|
160
|
+
return `linear-gradient(to ${to}, ${start}, ${end})`;
|
|
161
|
+
}
|
|
162
|
+
default:
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Track props
|
|
168
|
+
const trackProps = createMemo(() => {
|
|
169
|
+
const s = getState();
|
|
170
|
+
const bg = generateBackground();
|
|
171
|
+
return {
|
|
172
|
+
role: 'presentation' as const,
|
|
173
|
+
onPointerDown: onTrackPointerDown,
|
|
174
|
+
onPointerMove: onTrackPointerMove,
|
|
175
|
+
onPointerUp: onTrackPointerUp,
|
|
176
|
+
onPointerCancel: onTrackPointerCancel,
|
|
177
|
+
onMouseDown: onTrackMouseDown,
|
|
178
|
+
onMouseMove: onTrackMouseMove,
|
|
179
|
+
onMouseUp: onTrackMouseUp,
|
|
180
|
+
style: {
|
|
181
|
+
position: 'relative' as const,
|
|
182
|
+
'touch-action': 'none',
|
|
183
|
+
...(bg ? { background: bg, 'forced-color-adjust': 'none' as const } : {}),
|
|
184
|
+
},
|
|
185
|
+
'data-disabled': s.isDisabled || undefined,
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// Thumb props
|
|
190
|
+
const thumbProps = createMemo(() => {
|
|
191
|
+
const s = getState();
|
|
192
|
+
const p = getProps();
|
|
193
|
+
const percent = s.getThumbPercent();
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
role: 'presentation' as const,
|
|
197
|
+
style: {
|
|
198
|
+
position: 'absolute' as const,
|
|
199
|
+
left: `${percent * 100}%`,
|
|
200
|
+
top: '50%',
|
|
201
|
+
transform: 'translate(-50%, -50%)',
|
|
202
|
+
'touch-action': 'none',
|
|
203
|
+
},
|
|
204
|
+
'data-dragging': s.isDragging || undefined,
|
|
205
|
+
'data-disabled': s.isDisabled || p.isDisabled || undefined,
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Input props (hidden, for accessibility)
|
|
210
|
+
const inputProps = createMemo(() => {
|
|
211
|
+
const s = getState();
|
|
212
|
+
const p = getProps();
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
type: 'range',
|
|
216
|
+
id: inputId,
|
|
217
|
+
min: s.minValue,
|
|
218
|
+
max: s.maxValue,
|
|
219
|
+
step: s.step,
|
|
220
|
+
value: s.getThumbValue(),
|
|
221
|
+
disabled: s.isDisabled || p.isDisabled,
|
|
222
|
+
'aria-label': p['aria-label'] ?? channelName(),
|
|
223
|
+
'aria-labelledby': p['aria-labelledby'],
|
|
224
|
+
'aria-describedby': p['aria-describedby'],
|
|
225
|
+
'aria-valuetext': s.getThumbValueLabel(),
|
|
226
|
+
onKeyDown,
|
|
227
|
+
onChange: (e: Event) => {
|
|
228
|
+
const target = e.target as HTMLInputElement;
|
|
229
|
+
s.setThumbValue(parseFloat(target.value));
|
|
230
|
+
},
|
|
231
|
+
onFocus: () => {
|
|
232
|
+
// Focus handling
|
|
233
|
+
},
|
|
234
|
+
onBlur: () => {
|
|
235
|
+
if (s.isDragging) {
|
|
236
|
+
s.setDragging(false);
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
style: {
|
|
240
|
+
position: 'absolute' as const,
|
|
241
|
+
width: '1px',
|
|
242
|
+
height: '1px',
|
|
243
|
+
padding: '0',
|
|
244
|
+
margin: '-1px',
|
|
245
|
+
overflow: 'hidden',
|
|
246
|
+
clip: 'rect(0, 0, 0, 0)',
|
|
247
|
+
'white-space': 'nowrap',
|
|
248
|
+
border: '0',
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// Output props
|
|
254
|
+
const outputProps = createMemo(() => {
|
|
255
|
+
return {
|
|
256
|
+
'aria-live': 'off' as const,
|
|
257
|
+
for: inputId,
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// Label props
|
|
262
|
+
const labelProps = createMemo(() => {
|
|
263
|
+
return {
|
|
264
|
+
id: labelId,
|
|
265
|
+
for: inputId,
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
get trackProps() {
|
|
271
|
+
return trackProps();
|
|
272
|
+
},
|
|
273
|
+
get thumbProps() {
|
|
274
|
+
return thumbProps();
|
|
275
|
+
},
|
|
276
|
+
get inputProps() {
|
|
277
|
+
return inputProps();
|
|
278
|
+
},
|
|
279
|
+
get outputProps() {
|
|
280
|
+
return outputProps();
|
|
281
|
+
},
|
|
282
|
+
get labelProps() {
|
|
283
|
+
return labelProps();
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* createColorSwatch hook.
|
|
3
|
-
*
|
|
4
|
-
* Provides ARIA attributes for a color swatch display.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { createMemo, type Accessor } from 'solid-js';
|
|
8
|
-
import { normalizeColor } from '@proyecto-viviana/solid-stately';
|
|
9
|
-
import type { AriaColorSwatchOptions, ColorSwatchAria } from './types';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Creates ARIA props for a color swatch.
|
|
13
|
-
*/
|
|
14
|
-
export function createColorSwatch(
|
|
15
|
-
props: Accessor<AriaColorSwatchOptions>
|
|
16
|
-
): ColorSwatchAria {
|
|
17
|
-
const getProps = () => props();
|
|
18
|
-
|
|
19
|
-
// Swatch props
|
|
20
|
-
const swatchProps = createMemo(() => {
|
|
21
|
-
const p = getProps();
|
|
22
|
-
const color = normalizeColor(p.color);
|
|
23
|
-
const colorName = color.getColorName('en-US');
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
role: 'img' as const,
|
|
27
|
-
'aria-label': p['aria-label'] ?? colorName,
|
|
28
|
-
'aria-roledescription': 'color swatch',
|
|
29
|
-
style: {
|
|
30
|
-
'background-color': color.toString('css'),
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
get swatchProps() {
|
|
37
|
-
return swatchProps();
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* createColorSwatch hook.
|
|
3
|
+
*
|
|
4
|
+
* Provides ARIA attributes for a color swatch display.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createMemo, type Accessor } from 'solid-js';
|
|
8
|
+
import { normalizeColor } from '@proyecto-viviana/solid-stately';
|
|
9
|
+
import type { AriaColorSwatchOptions, ColorSwatchAria } from './types';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates ARIA props for a color swatch.
|
|
13
|
+
*/
|
|
14
|
+
export function createColorSwatch(
|
|
15
|
+
props: Accessor<AriaColorSwatchOptions>
|
|
16
|
+
): ColorSwatchAria {
|
|
17
|
+
const getProps = () => props();
|
|
18
|
+
|
|
19
|
+
// Swatch props
|
|
20
|
+
const swatchProps = createMemo(() => {
|
|
21
|
+
const p = getProps();
|
|
22
|
+
const color = normalizeColor(p.color);
|
|
23
|
+
const colorName = color.getColorName('en-US');
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
role: 'img' as const,
|
|
27
|
+
'aria-label': p['aria-label'] ?? colorName,
|
|
28
|
+
'aria-roledescription': 'color swatch',
|
|
29
|
+
style: {
|
|
30
|
+
'background-color': color.toString('css'),
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
get swatchProps() {
|
|
37
|
+
return swatchProps();
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|