@proyecto-viviana/solidaria-components 0.2.5 → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +39 -272
- package/dist/ActionBar.d.ts +79 -0
- package/dist/ActionBar.d.ts.map +1 -0
- package/dist/ActionGroup.d.ts +74 -0
- package/dist/ActionGroup.d.ts.map +1 -0
- package/dist/Alert.d.ts +70 -0
- package/dist/Alert.d.ts.map +1 -0
- package/dist/Autocomplete.d.ts +5 -5
- package/dist/Autocomplete.d.ts.map +1 -1
- package/dist/Breadcrumbs.d.ts +27 -8
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Button.d.ts +28 -5
- package/dist/Button.d.ts.map +1 -1
- package/dist/Calendar.d.ts +51 -7
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Checkbox.d.ts +33 -8
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Collection.d.ts +130 -0
- package/dist/Collection.d.ts.map +1 -0
- package/dist/Color.d.ts +210 -9
- package/dist/Color.d.ts.map +1 -1
- package/dist/ColorEditor.d.ts +42 -0
- package/dist/ColorEditor.d.ts.map +1 -0
- package/dist/ComboBox.d.ts +146 -16
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ContextualHelpTrigger.d.ts +40 -0
- package/dist/ContextualHelpTrigger.d.ts.map +1 -0
- package/dist/DateField.d.ts +35 -8
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DatePicker.d.ts +101 -5
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/DateRangePickerContext.d.ts +30 -0
- package/dist/DateRangePickerContext.d.ts.map +1 -0
- package/dist/Dialog.d.ts +5 -5
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Disclosure.d.ts +25 -5
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/DragAndDrop.d.ts +80 -0
- package/dist/DragAndDrop.d.ts.map +1 -0
- package/dist/DragPreview.d.ts +14 -0
- package/dist/DragPreview.d.ts.map +1 -0
- package/dist/DropZone.d.ts +27 -0
- package/dist/DropZone.d.ts.map +1 -0
- package/dist/FieldError.d.ts +27 -0
- package/dist/FieldError.d.ts.map +1 -0
- package/dist/FileTrigger.d.ts +26 -0
- package/dist/FileTrigger.d.ts.map +1 -0
- package/dist/Focusable.d.ts +27 -0
- package/dist/Focusable.d.ts.map +1 -0
- package/dist/Form.d.ts +41 -0
- package/dist/Form.d.ts.map +1 -0
- package/dist/GridList.d.ts +69 -10
- package/dist/GridList.d.ts.map +1 -1
- package/dist/HiddenDateInput.d.ts +26 -0
- package/dist/HiddenDateInput.d.ts.map +1 -0
- package/dist/HiddenTimeInput.d.ts +25 -0
- package/dist/HiddenTimeInput.d.ts.map +1 -0
- package/dist/Icon.d.ts +57 -0
- package/dist/Icon.d.ts.map +1 -0
- package/dist/Keyboard.d.ts +13 -0
- package/dist/Keyboard.d.ts.map +1 -0
- package/dist/Landmark.d.ts +3 -3
- package/dist/Landmark.d.ts.map +1 -1
- package/dist/Link.d.ts +10 -4
- package/dist/Link.d.ts.map +1 -1
- package/dist/ListBox.d.ts +73 -11
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListDropTargetDelegate.d.ts +38 -0
- package/dist/ListDropTargetDelegate.d.ts.map +1 -0
- package/dist/Menu.d.ts +79 -10
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Meter.d.ts +4 -4
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Modal.d.ts +6 -4
- package/dist/Modal.d.ts.map +1 -1
- package/dist/NumberField.d.ts +10 -12
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/Popover.d.ts +32 -7
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Pressable.d.ts +27 -0
- package/dist/Pressable.d.ts.map +1 -0
- package/dist/ProgressBar.d.ts +6 -4
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/RadioGroup.d.ts +43 -9
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RangeCalendar.d.ts +39 -7
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RouterProvider.d.ts +75 -0
- package/dist/RouterProvider.d.ts.map +1 -0
- package/dist/SearchField.d.ts +23 -21
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/Select.d.ts +48 -7
- package/dist/Select.d.ts.map +1 -1
- package/dist/SelectionIndicator.d.ts +30 -0
- package/dist/SelectionIndicator.d.ts.map +1 -0
- package/dist/Separator.d.ts +9 -3
- package/dist/Separator.d.ts.map +1 -1
- package/dist/SharedElementTransition.d.ts +41 -0
- package/dist/SharedElementTransition.d.ts.map +1 -0
- package/dist/Slider.d.ts +15 -8
- package/dist/Slider.d.ts.map +1 -1
- package/dist/StepList.d.ts +90 -0
- package/dist/StepList.d.ts.map +1 -0
- package/dist/Switch.d.ts +11 -5
- package/dist/Switch.d.ts.map +1 -1
- package/dist/Table.d.ts +222 -19
- package/dist/Table.d.ts.map +1 -1
- package/dist/Tabs.d.ts +47 -10
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/TagGroup.d.ts +22 -10
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/Text.d.ts +10 -0
- package/dist/Text.d.ts.map +1 -0
- package/dist/TextField.d.ts +19 -11
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TimeField.d.ts +32 -7
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/Toast.d.ts +29 -14
- package/dist/Toast.d.ts.map +1 -1
- package/dist/ToggleButton.d.ts +36 -0
- package/dist/ToggleButton.d.ts.map +1 -0
- package/dist/ToggleButtonGroup.d.ts +33 -0
- package/dist/ToggleButtonGroup.d.ts.map +1 -0
- package/dist/Toolbar.d.ts +7 -3
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Tooltip.d.ts +58 -7
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tree.d.ts +102 -11
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Virtualizer.d.ts +61 -0
- package/dist/Virtualizer.d.ts.map +1 -0
- package/dist/VirtualizerLayouts.d.ts +82 -0
- package/dist/VirtualizerLayouts.d.ts.map +1 -0
- package/dist/VisuallyHidden.d.ts +4 -2
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/contexts.d.ts +6 -1
- package/dist/contexts.d.ts.map +1 -1
- package/dist/index.d.ts +73 -39
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23342 -10644
- package/dist/index.js.map +1 -7
- package/dist/index.jsx +18110 -0
- package/dist/index.jsx.map +1 -0
- package/dist/useDragAndDrop.d.ts +93 -0
- package/dist/useDragAndDrop.d.ts.map +1 -0
- package/dist/utils.d.ts +8 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/virtualizer/Layout.d.ts +79 -0
- package/dist/virtualizer/Layout.d.ts.map +1 -0
- package/package.json +33 -32
- package/src/ActionBar.tsx +251 -0
- package/src/ActionGroup.tsx +277 -0
- package/src/Alert.tsx +152 -0
- package/src/Autocomplete.tsx +39 -44
- package/src/Breadcrumbs.tsx +227 -72
- package/src/Button.tsx +315 -74
- package/src/Calendar.tsx +347 -141
- package/src/Checkbox.tsx +414 -123
- package/src/Collection.tsx +350 -0
- package/src/Color.tsx +1325 -284
- package/src/ColorEditor.tsx +213 -0
- package/src/ComboBox.tsx +644 -245
- package/src/ContextualHelpTrigger.tsx +195 -0
- package/src/DateField.tsx +274 -106
- package/src/DatePicker.tsx +892 -111
- package/src/DateRangePickerContext.tsx +44 -0
- package/src/Dialog.tsx +173 -104
- package/src/Disclosure.tsx +158 -105
- package/src/DragAndDrop.tsx +340 -0
- package/src/DragPreview.tsx +47 -0
- package/src/DropZone.tsx +233 -0
- package/src/FieldError.tsx +89 -0
- package/src/FileTrigger.tsx +83 -0
- package/src/Focusable.tsx +103 -0
- package/src/Form.tsx +140 -0
- package/src/GridList.tsx +542 -128
- package/src/HiddenDateInput.tsx +153 -0
- package/src/HiddenTimeInput.tsx +133 -0
- package/src/Icon.tsx +133 -0
- package/src/Keyboard.tsx +26 -0
- package/src/Landmark.tsx +37 -63
- package/src/Link.tsx +132 -69
- package/src/ListBox.tsx +656 -106
- package/src/ListDropTargetDelegate.ts +283 -0
- package/src/Menu.tsx +1234 -132
- package/src/Meter.tsx +44 -58
- package/src/Modal.tsx +262 -166
- package/src/NumberField.tsx +267 -151
- package/src/Popover.tsx +452 -343
- package/src/Pressable.tsx +108 -0
- package/src/ProgressBar.tsx +54 -59
- package/src/RadioGroup.tsx +533 -121
- package/src/RangeCalendar.tsx +249 -150
- package/src/RouterProvider.tsx +223 -0
- package/src/SearchField.tsx +460 -133
- package/src/Select.tsx +804 -233
- package/src/SelectionIndicator.tsx +108 -0
- package/src/Separator.tsx +47 -49
- package/src/SharedElementTransition.tsx +264 -0
- package/src/Slider.tsx +148 -98
- package/src/StepList.tsx +272 -0
- package/src/Switch.tsx +93 -46
- package/src/Table.tsx +1551 -225
- package/src/Tabs.tsx +377 -123
- package/src/TagGroup.tsx +233 -135
- package/src/Text.tsx +18 -0
- package/src/TextField.tsx +413 -86
- package/src/TimeField.tsx +232 -222
- package/src/Toast.tsx +306 -160
- package/src/ToggleButton.tsx +169 -0
- package/src/ToggleButtonGroup.tsx +141 -0
- package/src/Toolbar.tsx +61 -70
- package/src/Tooltip.tsx +473 -116
- package/src/Tree.tsx +1514 -175
- package/src/Virtualizer.tsx +730 -0
- package/src/VirtualizerLayouts.ts +280 -0
- package/src/VisuallyHidden.tsx +32 -38
- package/src/contexts.ts +29 -36
- package/src/index.ts +972 -620
- package/src/useDragAndDrop.ts +367 -0
- package/src/utils.tsx +69 -50
- package/src/virtualizer/Layout.ts +192 -0
- package/dist/index.ssr.js +0 -9785
- package/dist/index.ssr.js.map +0 -7
package/src/Slider.tsx
CHANGED
|
@@ -5,25 +5,19 @@
|
|
|
5
5
|
* Port of react-aria-components/src/Slider.tsx
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
type JSX,
|
|
10
|
-
createContext,
|
|
11
|
-
createMemo,
|
|
12
|
-
splitProps,
|
|
13
|
-
useContext,
|
|
14
|
-
Show,
|
|
15
|
-
} from 'solid-js';
|
|
8
|
+
import { type JSX, createContext, createMemo, splitProps, useContext, Show } from "solid-js";
|
|
16
9
|
import {
|
|
17
10
|
createSlider,
|
|
18
11
|
createFocusRing,
|
|
19
12
|
createHover,
|
|
13
|
+
mergeProps,
|
|
20
14
|
type AriaSliderProps,
|
|
21
|
-
} from
|
|
15
|
+
} from "@proyecto-viviana/solidaria";
|
|
22
16
|
import {
|
|
23
17
|
createSliderState,
|
|
24
18
|
type SliderState,
|
|
25
19
|
type SliderOrientation,
|
|
26
|
-
} from
|
|
20
|
+
} from "@proyecto-viviana/solid-stately";
|
|
27
21
|
import {
|
|
28
22
|
type RenderChildren,
|
|
29
23
|
type ClassNameOrFunction,
|
|
@@ -31,11 +25,8 @@ import {
|
|
|
31
25
|
type SlotProps,
|
|
32
26
|
useRenderProps,
|
|
33
27
|
filterDOMProps,
|
|
34
|
-
} from
|
|
35
|
-
|
|
36
|
-
// ============================================
|
|
37
|
-
// TYPES
|
|
38
|
-
// ============================================
|
|
28
|
+
} from "./utils";
|
|
29
|
+
import { VisuallyHidden } from "./VisuallyHidden";
|
|
39
30
|
|
|
40
31
|
export interface SliderRenderProps {
|
|
41
32
|
/** Whether the slider is disabled. */
|
|
@@ -52,7 +43,7 @@ export interface SliderRenderProps {
|
|
|
52
43
|
orientation: SliderOrientation;
|
|
53
44
|
}
|
|
54
45
|
|
|
55
|
-
export interface SliderProps extends Omit<AriaSliderProps,
|
|
46
|
+
export interface SliderProps extends Omit<AriaSliderProps, "label">, SlotProps {
|
|
56
47
|
/** The current value (controlled). */
|
|
57
48
|
value?: number;
|
|
58
49
|
/** The default value (uncontrolled). */
|
|
@@ -81,6 +72,8 @@ export interface SliderProps extends Omit<AriaSliderProps, 'label'>, SlotProps {
|
|
|
81
72
|
class?: ClassNameOrFunction<SliderRenderProps>;
|
|
82
73
|
/** The inline style for the element. */
|
|
83
74
|
style?: StyleOrFunction<SliderRenderProps>;
|
|
75
|
+
/** Ref for the slider root element. */
|
|
76
|
+
ref?: (el: HTMLDivElement) => void;
|
|
84
77
|
}
|
|
85
78
|
|
|
86
79
|
export interface SliderTrackRenderProps {
|
|
@@ -94,7 +87,8 @@ export interface SliderTrackRenderProps {
|
|
|
94
87
|
orientation: SliderOrientation;
|
|
95
88
|
}
|
|
96
89
|
|
|
97
|
-
export interface SliderTrackProps
|
|
90
|
+
export interface SliderTrackProps
|
|
91
|
+
extends SlotProps, Omit<JSX.HTMLAttributes<HTMLDivElement>, "class" | "style" | "children"> {
|
|
98
92
|
/** The children of the track. */
|
|
99
93
|
children?: RenderChildren<SliderTrackRenderProps>;
|
|
100
94
|
/** The CSS className for the element. */
|
|
@@ -120,7 +114,8 @@ export interface SliderThumbRenderProps {
|
|
|
120
114
|
valuePercent: number;
|
|
121
115
|
}
|
|
122
116
|
|
|
123
|
-
export interface SliderThumbProps
|
|
117
|
+
export interface SliderThumbProps
|
|
118
|
+
extends SlotProps, Omit<JSX.HTMLAttributes<HTMLDivElement>, "class" | "style" | "children"> {
|
|
124
119
|
/** The children of the thumb. */
|
|
125
120
|
children?: RenderChildren<SliderThumbRenderProps>;
|
|
126
121
|
/** The CSS className for the element. */
|
|
@@ -136,7 +131,8 @@ export interface SliderOutputRenderProps {
|
|
|
136
131
|
formattedValue: string;
|
|
137
132
|
}
|
|
138
133
|
|
|
139
|
-
export interface SliderOutputProps
|
|
134
|
+
export interface SliderOutputProps
|
|
135
|
+
extends SlotProps, Omit<JSX.HTMLAttributes<HTMLElement>, "class" | "style" | "children"> {
|
|
140
136
|
/** The children of the output. */
|
|
141
137
|
children?: RenderChildren<SliderOutputRenderProps>;
|
|
142
138
|
/** The CSS className for the element. */
|
|
@@ -145,10 +141,6 @@ export interface SliderOutputProps extends SlotProps {
|
|
|
145
141
|
style?: StyleOrFunction<SliderOutputRenderProps>;
|
|
146
142
|
}
|
|
147
143
|
|
|
148
|
-
// ============================================
|
|
149
|
-
// CONTEXT
|
|
150
|
-
// ============================================
|
|
151
|
-
|
|
152
144
|
interface SliderContextValue {
|
|
153
145
|
state: SliderState;
|
|
154
146
|
trackProps: JSX.HTMLAttributes<HTMLElement>;
|
|
@@ -157,13 +149,14 @@ interface SliderContextValue {
|
|
|
157
149
|
inputProps: JSX.InputHTMLAttributes<HTMLInputElement>;
|
|
158
150
|
trackRef: HTMLElement | undefined;
|
|
159
151
|
setTrackRef: (el: HTMLElement) => void;
|
|
152
|
+
inputRef: HTMLInputElement | undefined;
|
|
153
|
+
setInputRef: (el: HTMLInputElement) => void;
|
|
160
154
|
}
|
|
161
155
|
|
|
162
156
|
export const SliderContext = createContext<SliderContextValue | null>(null);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// ============================================
|
|
157
|
+
export const SliderStateContext = SliderContext;
|
|
158
|
+
export const SliderTrackContext = SliderContext;
|
|
159
|
+
export const SliderOutputContext = SliderContext;
|
|
167
160
|
|
|
168
161
|
/**
|
|
169
162
|
* A slider allows users to select a value from a range.
|
|
@@ -171,12 +164,31 @@ export const SliderContext = createContext<SliderContextValue | null>(null);
|
|
|
171
164
|
export function Slider(props: SliderProps): JSX.Element {
|
|
172
165
|
const [local, stateProps, ariaProps, rest] = splitProps(
|
|
173
166
|
props,
|
|
174
|
-
[
|
|
175
|
-
[
|
|
176
|
-
|
|
167
|
+
["class", "style", "slot", "ref"],
|
|
168
|
+
[
|
|
169
|
+
"value",
|
|
170
|
+
"defaultValue",
|
|
171
|
+
"onChange",
|
|
172
|
+
"onChangeEnd",
|
|
173
|
+
"minValue",
|
|
174
|
+
"maxValue",
|
|
175
|
+
"step",
|
|
176
|
+
"orientation",
|
|
177
|
+
"locale",
|
|
178
|
+
"formatOptions",
|
|
179
|
+
],
|
|
180
|
+
[
|
|
181
|
+
"label",
|
|
182
|
+
"aria-label",
|
|
183
|
+
"aria-labelledby",
|
|
184
|
+
"aria-describedby",
|
|
185
|
+
"isDisabled",
|
|
186
|
+
"id",
|
|
187
|
+
"name",
|
|
188
|
+
"form",
|
|
189
|
+
],
|
|
177
190
|
);
|
|
178
191
|
|
|
179
|
-
// Create slider state
|
|
180
192
|
const state = createSliderState({
|
|
181
193
|
get value() {
|
|
182
194
|
return stateProps.value;
|
|
@@ -213,23 +225,22 @@ export function Slider(props: SliderProps): JSX.Element {
|
|
|
213
225
|
},
|
|
214
226
|
});
|
|
215
227
|
|
|
216
|
-
// Track ref for pointer handling
|
|
217
228
|
let trackRef: HTMLElement | undefined;
|
|
218
229
|
const setTrackRef = (el: HTMLElement) => {
|
|
219
230
|
trackRef = el;
|
|
220
231
|
};
|
|
232
|
+
let inputRef: HTMLInputElement | undefined;
|
|
233
|
+
const setInputRef = (el: HTMLInputElement) => {
|
|
234
|
+
inputRef = el;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const sliderAria = createSlider(
|
|
238
|
+
ariaProps,
|
|
239
|
+
state,
|
|
240
|
+
() => trackRef ?? null,
|
|
241
|
+
() => inputRef ?? null,
|
|
242
|
+
);
|
|
221
243
|
|
|
222
|
-
// Create slider aria props
|
|
223
|
-
const {
|
|
224
|
-
labelProps,
|
|
225
|
-
groupProps,
|
|
226
|
-
trackProps,
|
|
227
|
-
thumbProps,
|
|
228
|
-
inputProps,
|
|
229
|
-
outputProps,
|
|
230
|
-
} = createSlider(ariaProps, state, () => trackRef ?? null);
|
|
231
|
-
|
|
232
|
-
// Render props values
|
|
233
244
|
const renderValues = createMemo<SliderRenderProps>(() => ({
|
|
234
245
|
isDisabled: state.isDisabled,
|
|
235
246
|
isDragging: state.isDragging(),
|
|
@@ -239,23 +250,48 @@ export function Slider(props: SliderProps): JSX.Element {
|
|
|
239
250
|
orientation: state.orientation,
|
|
240
251
|
}));
|
|
241
252
|
|
|
242
|
-
// Resolve render props
|
|
243
253
|
const renderProps = useRenderProps(
|
|
244
254
|
{
|
|
245
255
|
children: props.children,
|
|
246
256
|
class: local.class,
|
|
247
257
|
style: local.style,
|
|
248
|
-
defaultClassName:
|
|
258
|
+
defaultClassName: "solidaria-Slider",
|
|
249
259
|
},
|
|
250
|
-
renderValues
|
|
260
|
+
renderValues,
|
|
251
261
|
);
|
|
252
262
|
|
|
253
|
-
|
|
254
|
-
|
|
263
|
+
const childRenderValues: SliderRenderProps = {
|
|
264
|
+
get isDisabled() {
|
|
265
|
+
return state.isDisabled;
|
|
266
|
+
},
|
|
267
|
+
get isDragging() {
|
|
268
|
+
return state.isDragging();
|
|
269
|
+
},
|
|
270
|
+
get isFocused() {
|
|
271
|
+
return state.isFocused();
|
|
272
|
+
},
|
|
273
|
+
get value() {
|
|
274
|
+
return state.value();
|
|
275
|
+
},
|
|
276
|
+
get valuePercent() {
|
|
277
|
+
return state.getValuePercent();
|
|
278
|
+
},
|
|
279
|
+
get orientation() {
|
|
280
|
+
return state.orientation;
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const sliderChildren = () => {
|
|
285
|
+
const children = props.children;
|
|
286
|
+
return typeof children === "function" ? children(childRenderValues) : children;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const domProps = createMemo(() =>
|
|
290
|
+
filterDOMProps(rest as Record<string, unknown>, { global: true }),
|
|
291
|
+
);
|
|
255
292
|
|
|
256
|
-
// Clean props helpers
|
|
257
293
|
const cleanGroupProps = () => {
|
|
258
|
-
const { ref: _ref, ...rest } = groupProps as Record<string, unknown>;
|
|
294
|
+
const { ref: _ref, ...rest } = sliderAria.groupProps as Record<string, unknown>;
|
|
259
295
|
return rest;
|
|
260
296
|
};
|
|
261
297
|
|
|
@@ -263,32 +299,43 @@ export function Slider(props: SliderProps): JSX.Element {
|
|
|
263
299
|
<SliderContext.Provider
|
|
264
300
|
value={{
|
|
265
301
|
state,
|
|
266
|
-
trackProps
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
302
|
+
get trackProps() {
|
|
303
|
+
return sliderAria.trackProps;
|
|
304
|
+
},
|
|
305
|
+
get thumbProps() {
|
|
306
|
+
return sliderAria.thumbProps;
|
|
307
|
+
},
|
|
308
|
+
get outputProps() {
|
|
309
|
+
return sliderAria.outputProps;
|
|
310
|
+
},
|
|
311
|
+
get inputProps() {
|
|
312
|
+
return sliderAria.inputProps;
|
|
313
|
+
},
|
|
314
|
+
get trackRef() {
|
|
315
|
+
return trackRef;
|
|
316
|
+
},
|
|
271
317
|
setTrackRef,
|
|
318
|
+
get inputRef() {
|
|
319
|
+
return inputRef;
|
|
320
|
+
},
|
|
321
|
+
setInputRef,
|
|
272
322
|
}}
|
|
273
323
|
>
|
|
274
324
|
<div
|
|
275
325
|
{...domProps()}
|
|
276
326
|
{...cleanGroupProps()}
|
|
327
|
+
ref={local.ref}
|
|
277
328
|
class={renderProps.class()}
|
|
278
329
|
style={renderProps.style()}
|
|
279
330
|
data-disabled={state.isDisabled || undefined}
|
|
280
331
|
data-orientation={state.orientation}
|
|
281
332
|
data-dragging={state.isDragging() || undefined}
|
|
282
333
|
>
|
|
283
|
-
{/* Label */}
|
|
284
334
|
<Show when={ariaProps.label}>
|
|
285
|
-
<span {...labelProps}>{ariaProps.label}</span>
|
|
335
|
+
<span {...sliderAria.labelProps}>{ariaProps.label}</span>
|
|
286
336
|
</Show>
|
|
287
337
|
|
|
288
|
-
{
|
|
289
|
-
|
|
290
|
-
{/* Hidden input for form submission */}
|
|
291
|
-
<input {...inputProps} />
|
|
338
|
+
{sliderChildren()}
|
|
292
339
|
</div>
|
|
293
340
|
</SliderContext.Provider>
|
|
294
341
|
);
|
|
@@ -298,16 +345,15 @@ export function Slider(props: SliderProps): JSX.Element {
|
|
|
298
345
|
* The track element of a slider.
|
|
299
346
|
*/
|
|
300
347
|
export function SliderTrack(props: SliderTrackProps): JSX.Element {
|
|
301
|
-
const [local] = splitProps(props, [
|
|
348
|
+
const [local, domProps] = splitProps(props, ["class", "style", "slot", "children"]);
|
|
302
349
|
|
|
303
350
|
const context = useContext(SliderContext);
|
|
304
351
|
if (!context) {
|
|
305
|
-
throw new Error(
|
|
352
|
+
throw new Error("SliderTrack must be used within a Slider");
|
|
306
353
|
}
|
|
307
354
|
|
|
308
|
-
const { state,
|
|
355
|
+
const { state, setTrackRef } = context;
|
|
309
356
|
|
|
310
|
-
// Render props values
|
|
311
357
|
const renderValues = createMemo<SliderTrackRenderProps>(() => ({
|
|
312
358
|
isDisabled: state.isDisabled,
|
|
313
359
|
isDragging: state.isDragging(),
|
|
@@ -315,32 +361,30 @@ export function SliderTrack(props: SliderTrackProps): JSX.Element {
|
|
|
315
361
|
orientation: state.orientation,
|
|
316
362
|
}));
|
|
317
363
|
|
|
318
|
-
// Resolve render props
|
|
319
364
|
const renderProps = useRenderProps(
|
|
320
365
|
{
|
|
321
366
|
children: props.children,
|
|
322
367
|
class: local.class,
|
|
323
368
|
style: local.style,
|
|
324
|
-
defaultClassName:
|
|
369
|
+
defaultClassName: "solidaria-Slider-track",
|
|
325
370
|
},
|
|
326
|
-
renderValues
|
|
371
|
+
renderValues,
|
|
327
372
|
);
|
|
328
373
|
|
|
329
|
-
// Clean props
|
|
330
374
|
const cleanTrackProps = () => {
|
|
331
|
-
const { ref: _ref, style: trackStyle, ...rest } = trackProps as Record<string, unknown>;
|
|
375
|
+
const { ref: _ref, style: trackStyle, ...rest } = context.trackProps as Record<string, unknown>;
|
|
332
376
|
return rest;
|
|
333
377
|
};
|
|
334
378
|
|
|
335
|
-
// Merge styles
|
|
336
379
|
const mergedStyle = () => {
|
|
337
|
-
const trackStyle = (trackProps as { style?: Record<string, string> }).style || {};
|
|
380
|
+
const trackStyle = (context.trackProps as { style?: Record<string, string> }).style || {};
|
|
338
381
|
const renderStyle = renderProps.style() || {};
|
|
339
382
|
return { ...trackStyle, ...renderStyle };
|
|
340
383
|
};
|
|
341
384
|
|
|
342
385
|
return (
|
|
343
386
|
<div
|
|
387
|
+
{...domProps}
|
|
344
388
|
ref={setTrackRef}
|
|
345
389
|
{...cleanTrackProps()}
|
|
346
390
|
class={renderProps.class()}
|
|
@@ -358,26 +402,23 @@ export function SliderTrack(props: SliderTrackProps): JSX.Element {
|
|
|
358
402
|
* The thumb element of a slider.
|
|
359
403
|
*/
|
|
360
404
|
export function SliderThumb(props: SliderThumbProps): JSX.Element {
|
|
361
|
-
const [local] = splitProps(props, [
|
|
405
|
+
const [local, domProps] = splitProps(props, ["class", "style", "slot", "children"]);
|
|
362
406
|
|
|
363
407
|
const context = useContext(SliderContext);
|
|
364
408
|
if (!context) {
|
|
365
|
-
throw new Error(
|
|
409
|
+
throw new Error("SliderThumb must be used within a Slider");
|
|
366
410
|
}
|
|
367
411
|
|
|
368
|
-
const { state,
|
|
412
|
+
const { state, setInputRef } = context;
|
|
369
413
|
|
|
370
|
-
// Create focus ring
|
|
371
414
|
const { isFocused, isFocusVisible, focusProps } = createFocusRing();
|
|
372
415
|
|
|
373
|
-
// Create hover
|
|
374
416
|
const { isHovered, hoverProps } = createHover({
|
|
375
417
|
get isDisabled() {
|
|
376
418
|
return state.isDisabled;
|
|
377
419
|
},
|
|
378
420
|
});
|
|
379
421
|
|
|
380
|
-
// Render props values
|
|
381
422
|
const renderValues = createMemo<SliderThumbRenderProps>(() => ({
|
|
382
423
|
isDisabled: state.isDisabled,
|
|
383
424
|
isDragging: state.isDragging(),
|
|
@@ -388,20 +429,18 @@ export function SliderThumb(props: SliderThumbProps): JSX.Element {
|
|
|
388
429
|
valuePercent: state.getValuePercent(),
|
|
389
430
|
}));
|
|
390
431
|
|
|
391
|
-
// Resolve render props
|
|
392
432
|
const renderProps = useRenderProps(
|
|
393
433
|
{
|
|
394
434
|
children: props.children,
|
|
395
435
|
class: local.class,
|
|
396
436
|
style: local.style,
|
|
397
|
-
defaultClassName:
|
|
437
|
+
defaultClassName: "solidaria-Slider-thumb",
|
|
398
438
|
},
|
|
399
|
-
renderValues
|
|
439
|
+
renderValues,
|
|
400
440
|
);
|
|
401
441
|
|
|
402
|
-
// Clean props
|
|
403
442
|
const cleanThumbProps = () => {
|
|
404
|
-
const { ref: _ref, style: thumbStyle, ...rest } = thumbProps as Record<string, unknown>;
|
|
443
|
+
const { ref: _ref, style: thumbStyle, ...rest } = context.thumbProps as Record<string, unknown>;
|
|
405
444
|
return rest;
|
|
406
445
|
};
|
|
407
446
|
const cleanFocusProps = () => {
|
|
@@ -413,26 +452,37 @@ export function SliderThumb(props: SliderThumbProps): JSX.Element {
|
|
|
413
452
|
return rest;
|
|
414
453
|
};
|
|
415
454
|
|
|
416
|
-
// Merge styles
|
|
417
455
|
const mergedStyle = () => {
|
|
418
|
-
const thumbStyle = (thumbProps as { style?: Record<string, string> }).style || {};
|
|
456
|
+
const thumbStyle = (context.thumbProps as { style?: Record<string, string> }).style || {};
|
|
419
457
|
const renderStyle = renderProps.style() || {};
|
|
420
458
|
return { ...thumbStyle, ...renderStyle };
|
|
421
459
|
};
|
|
460
|
+
const cleanInputProps = () => {
|
|
461
|
+
const { ref: _ref, ...rest } = context.inputProps as Record<string, unknown>;
|
|
462
|
+
return rest;
|
|
463
|
+
};
|
|
464
|
+
const mergedInputProps = () =>
|
|
465
|
+
mergeProps(
|
|
466
|
+
cleanInputProps() as Record<string, unknown>,
|
|
467
|
+
cleanFocusProps() as Record<string, unknown>,
|
|
468
|
+
) as JSX.InputHTMLAttributes<HTMLInputElement>;
|
|
422
469
|
|
|
423
470
|
return (
|
|
424
471
|
<div
|
|
472
|
+
{...domProps}
|
|
425
473
|
{...cleanThumbProps()}
|
|
426
|
-
{...cleanFocusProps()}
|
|
427
474
|
{...cleanHoverProps()}
|
|
428
475
|
class={renderProps.class()}
|
|
429
476
|
style={mergedStyle()}
|
|
430
477
|
data-disabled={state.isDisabled || undefined}
|
|
431
478
|
data-dragging={state.isDragging() || undefined}
|
|
432
|
-
data-focused={isFocused() || undefined}
|
|
479
|
+
data-focused={isFocused() || state.isFocused() || undefined}
|
|
433
480
|
data-focus-visible={isFocusVisible() || undefined}
|
|
434
481
|
data-hovered={isHovered() || undefined}
|
|
435
482
|
>
|
|
483
|
+
<VisuallyHidden>
|
|
484
|
+
<input ref={setInputRef} {...mergedInputProps()} />
|
|
485
|
+
</VisuallyHidden>
|
|
436
486
|
{renderProps.renderChildren()}
|
|
437
487
|
</div>
|
|
438
488
|
);
|
|
@@ -442,39 +492,39 @@ export function SliderThumb(props: SliderThumbProps): JSX.Element {
|
|
|
442
492
|
* The output element of a slider, displaying the current value.
|
|
443
493
|
*/
|
|
444
494
|
export function SliderOutput(props: SliderOutputProps): JSX.Element {
|
|
445
|
-
const [local] = splitProps(props, [
|
|
495
|
+
const [local, domProps] = splitProps(props, ["class", "style", "slot", "children"]);
|
|
446
496
|
|
|
447
497
|
const context = useContext(SliderContext);
|
|
448
498
|
if (!context) {
|
|
449
|
-
throw new Error(
|
|
499
|
+
throw new Error("SliderOutput must be used within a Slider");
|
|
450
500
|
}
|
|
451
501
|
|
|
452
|
-
const { state
|
|
502
|
+
const { state } = context;
|
|
453
503
|
|
|
454
|
-
// Render props values
|
|
455
504
|
const renderValues = createMemo<SliderOutputRenderProps>(() => ({
|
|
456
505
|
value: state.value(),
|
|
457
506
|
formattedValue: state.getFormattedValue(),
|
|
458
507
|
}));
|
|
459
508
|
|
|
460
|
-
// Resolve render props
|
|
461
509
|
const renderProps = useRenderProps(
|
|
462
510
|
{
|
|
463
511
|
children: props.children,
|
|
464
512
|
class: local.class,
|
|
465
513
|
style: local.style,
|
|
466
|
-
defaultClassName:
|
|
514
|
+
defaultClassName: "solidaria-Slider-output",
|
|
467
515
|
},
|
|
468
|
-
renderValues
|
|
516
|
+
renderValues,
|
|
469
517
|
);
|
|
470
518
|
|
|
471
|
-
|
|
519
|
+
const cleanDomProps = () => {
|
|
520
|
+
const { ref: _ref, ...rest } = domProps as Record<string, unknown>;
|
|
521
|
+
return rest;
|
|
522
|
+
};
|
|
472
523
|
const cleanOutputProps = () => {
|
|
473
|
-
const { ref: _ref, ...rest } = outputProps as Record<string, unknown>;
|
|
524
|
+
const { ref: _ref, ...rest } = context.outputProps as Record<string, unknown>;
|
|
474
525
|
return rest;
|
|
475
526
|
};
|
|
476
527
|
|
|
477
|
-
// Default children shows formatted value
|
|
478
528
|
const renderedChildren = () => {
|
|
479
529
|
// Check if raw children prop exists before calling renderChildren
|
|
480
530
|
if (renderProps.children === undefined || renderProps.children === null) {
|
|
@@ -485,6 +535,7 @@ export function SliderOutput(props: SliderOutputProps): JSX.Element {
|
|
|
485
535
|
|
|
486
536
|
return (
|
|
487
537
|
<output
|
|
538
|
+
{...cleanDomProps()}
|
|
488
539
|
{...cleanOutputProps()}
|
|
489
540
|
class={renderProps.class()}
|
|
490
541
|
style={renderProps.style()}
|
|
@@ -494,7 +545,6 @@ export function SliderOutput(props: SliderOutputProps): JSX.Element {
|
|
|
494
545
|
);
|
|
495
546
|
}
|
|
496
547
|
|
|
497
|
-
// Attach sub-components
|
|
498
548
|
Slider.Track = SliderTrack;
|
|
499
549
|
Slider.Thumb = SliderThumb;
|
|
500
550
|
Slider.Output = SliderOutput;
|