@proyecto-viviana/solidaria-components 0.2.5 → 0.2.9
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/ActionBar.d.ts +71 -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/Breadcrumbs.d.ts +10 -2
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Button.d.ts +4 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Calendar.d.ts +13 -0
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Checkbox.d.ts +2 -2
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Collection.d.ts +125 -0
- package/dist/Collection.d.ts.map +1 -0
- package/dist/Color.d.ts +114 -2
- 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 +64 -0
- 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 +27 -2
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DatePicker.d.ts +67 -2
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Disclosure.d.ts +2 -0
- 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 +23 -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 +27 -0
- package/dist/Form.d.ts.map +1 -0
- package/dist/GridList.d.ts +40 -1
- package/dist/GridList.d.ts.map +1 -1
- 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/Link.d.ts.map +1 -1
- package/dist/ListBox.d.ts +43 -1
- 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 +20 -2
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Meter.d.ts +2 -2
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Modal.d.ts +2 -0
- package/dist/Modal.d.ts.map +1 -1
- package/dist/NumberField.d.ts +2 -0
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/Popover.d.ts +4 -2
- 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 +2 -2
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RangeCalendar.d.ts +5 -0
- 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 +2 -3
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/Select.d.ts +11 -0
- 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/SharedElementTransition.d.ts +39 -0
- package/dist/SharedElementTransition.d.ts.map +1 -0
- package/dist/Slider.d.ts +6 -3
- package/dist/Slider.d.ts.map +1 -1
- package/dist/Table.d.ts +39 -0
- package/dist/Table.d.ts.map +1 -1
- package/dist/Tabs.d.ts +4 -3
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/TagGroup.d.ts +12 -2
- 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 +4 -0
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TimeField.d.ts +26 -1
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/Toast.d.ts.map +1 -1
- package/dist/ToggleButton.d.ts +30 -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.map +1 -1
- package/dist/Tooltip.d.ts +9 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tree.d.ts +44 -2
- 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 +3 -1
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/contexts.d.ts +1 -0
- package/dist/contexts.d.ts.map +1 -1
- package/dist/index.d.ts +57 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13961 -5946
- package/dist/index.js.map +1 -7
- package/dist/index.ssr.js +9612 -2401
- package/dist/index.ssr.js.map +1 -7
- package/dist/useDragAndDrop.d.ts +93 -0
- package/dist/useDragAndDrop.d.ts.map +1 -0
- package/dist/utils.d.ts +7 -1
- 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 +8 -6
- package/src/ActionBar.tsx +248 -0
- package/src/ActionGroup.tsx +285 -0
- package/src/Alert.tsx +177 -0
- package/src/Autocomplete.tsx +1 -1
- package/src/Breadcrumbs.tsx +103 -17
- package/src/Button.tsx +65 -21
- package/src/Calendar.tsx +179 -53
- package/src/Checkbox.tsx +1 -2
- package/src/Collection.tsx +341 -0
- package/src/Color.tsx +652 -34
- package/src/ColorEditor.tsx +231 -0
- package/src/ComboBox.tsx +315 -81
- package/src/ContextualHelpTrigger.tsx +183 -0
- package/src/DateField.tsx +93 -19
- package/src/DatePicker.tsx +495 -25
- package/src/Dialog.tsx +40 -9
- package/src/Disclosure.tsx +33 -27
- package/src/DragAndDrop.tsx +334 -0
- package/src/DragPreview.tsx +45 -0
- package/src/DropZone.tsx +213 -0
- package/src/FieldError.tsx +67 -0
- package/src/FileTrigger.tsx +83 -0
- package/src/Focusable.tsx +106 -0
- package/src/Form.tsx +85 -0
- package/src/GridList.tsx +379 -41
- package/src/Icon.tsx +154 -0
- package/src/Keyboard.tsx +26 -0
- package/src/Link.tsx +14 -1
- package/src/ListBox.tsx +484 -33
- package/src/ListDropTargetDelegate.ts +282 -0
- package/src/Menu.tsx +388 -35
- package/src/Meter.tsx +7 -3
- package/src/Modal.tsx +32 -4
- package/src/NumberField.tsx +163 -43
- package/src/Popover.tsx +136 -180
- package/src/Pressable.tsx +108 -0
- package/src/ProgressBar.tsx +7 -3
- package/src/RadioGroup.tsx +35 -25
- package/src/RangeCalendar.tsx +100 -68
- package/src/RouterProvider.tsx +240 -0
- package/src/SearchField.tsx +142 -34
- package/src/Select.tsx +221 -73
- package/src/SelectionIndicator.tsx +105 -0
- package/src/SharedElementTransition.tsx +258 -0
- package/src/Slider.tsx +16 -6
- package/src/Table.tsx +417 -57
- package/src/Tabs.tsx +68 -35
- package/src/TagGroup.tsx +121 -36
- package/src/Text.tsx +18 -0
- package/src/TextField.tsx +25 -8
- package/src/TimeField.tsx +101 -151
- package/src/Toast.tsx +108 -14
- package/src/ToggleButton.tsx +159 -0
- package/src/ToggleButtonGroup.tsx +136 -0
- package/src/Toolbar.tsx +14 -8
- package/src/Tooltip.tsx +108 -19
- package/src/Tree.tsx +1143 -87
- package/src/Virtualizer.tsx +702 -0
- package/src/VirtualizerLayouts.ts +265 -0
- package/src/VisuallyHidden.tsx +15 -21
- package/src/contexts.ts +1 -0
- package/src/index.ts +1057 -620
- package/src/useDragAndDrop.ts +351 -0
- package/src/utils.tsx +37 -3
- package/src/virtualizer/Layout.ts +200 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SharedElementTransition primitives for solidaria-components.
|
|
3
|
+
*
|
|
4
|
+
* Provides FLIP-based shared element animations when elements move between
|
|
5
|
+
* parents within a scope. Captures geometry snapshots on unmount and applies
|
|
6
|
+
* transition animations on mount.
|
|
7
|
+
*
|
|
8
|
+
* Parity target: react-aria-components/src/SharedElementTransition.tsx
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
type JSX,
|
|
13
|
+
createContext,
|
|
14
|
+
createEffect,
|
|
15
|
+
createMemo,
|
|
16
|
+
createSignal,
|
|
17
|
+
onCleanup,
|
|
18
|
+
splitProps,
|
|
19
|
+
useContext,
|
|
20
|
+
Show,
|
|
21
|
+
on,
|
|
22
|
+
} from 'solid-js';
|
|
23
|
+
import {
|
|
24
|
+
type ClassNameOrFunction,
|
|
25
|
+
type StyleOrFunction,
|
|
26
|
+
type RenderChildren,
|
|
27
|
+
useRenderProps,
|
|
28
|
+
filterDOMProps,
|
|
29
|
+
} from './utils';
|
|
30
|
+
|
|
31
|
+
type SharedElementLifecycle = 'hidden' | 'entering' | 'visible' | 'exiting';
|
|
32
|
+
|
|
33
|
+
/** Safe wrapper — jsdom doesn't implement the Web Animations API. */
|
|
34
|
+
function getAnimations(el: HTMLElement): Animation[] {
|
|
35
|
+
return typeof el.getAnimations === 'function' ? el.getAnimations() : [];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface Snapshot {
|
|
39
|
+
rect: DOMRect;
|
|
40
|
+
style: [string, string][];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface SharedElementScope {
|
|
44
|
+
snapshots: { [name: string]: Snapshot };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const SharedElementContext = createContext<SharedElementScope | null>(null);
|
|
48
|
+
|
|
49
|
+
export function useHasSharedElementTransitionScope(): boolean {
|
|
50
|
+
return useContext(SharedElementContext) != null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface SharedElementTransitionProps {
|
|
54
|
+
children?: JSX.Element;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A scope for SharedElements, which animate between parents.
|
|
59
|
+
*/
|
|
60
|
+
export function SharedElementTransition(props: SharedElementTransitionProps): JSX.Element {
|
|
61
|
+
const scope: SharedElementScope = {
|
|
62
|
+
snapshots: {},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<SharedElementContext.Provider value={scope}>
|
|
67
|
+
{props.children}
|
|
68
|
+
</SharedElementContext.Provider>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface SharedElementRenderProps {
|
|
73
|
+
isEntering: boolean;
|
|
74
|
+
isExiting: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface SharedElementPropsBase
|
|
78
|
+
extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'style'> {
|
|
79
|
+
children?: RenderChildren<SharedElementRenderProps>;
|
|
80
|
+
class?: ClassNameOrFunction<SharedElementRenderProps>;
|
|
81
|
+
style?: StyleOrFunction<SharedElementRenderProps>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface SharedElementProps extends SharedElementPropsBase {
|
|
85
|
+
name: string;
|
|
86
|
+
isVisible?: boolean;
|
|
87
|
+
ref?: HTMLDivElement | ((el: HTMLDivElement) => void);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* An element that animates between its old and new position when moving
|
|
92
|
+
* between parents within a SharedElementTransition scope.
|
|
93
|
+
*/
|
|
94
|
+
export function SharedElement(props: SharedElementProps): JSX.Element | null {
|
|
95
|
+
const scope = useContext(SharedElementContext);
|
|
96
|
+
if (!scope) {
|
|
97
|
+
throw new Error('<SharedElement> must be rendered inside a <SharedElementTransition>');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const [local, domProps] = splitProps(props, [
|
|
101
|
+
'name', 'isVisible', 'children', 'class', 'style', 'ref',
|
|
102
|
+
]);
|
|
103
|
+
|
|
104
|
+
const [lifecycle, setLifecycle] = createSignal<SharedElementLifecycle>(
|
|
105
|
+
local.isVisible === false ? 'hidden' : 'visible'
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
let elementRef: HTMLDivElement | undefined;
|
|
109
|
+
let frame: number | undefined;
|
|
110
|
+
|
|
111
|
+
const setRef = (el: HTMLDivElement) => {
|
|
112
|
+
elementRef = el;
|
|
113
|
+
// Forward ref to consumer
|
|
114
|
+
const userRef = local.ref;
|
|
115
|
+
if (typeof userRef === 'function') {
|
|
116
|
+
userRef(el);
|
|
117
|
+
} else if (userRef !== undefined) {
|
|
118
|
+
// Direct assignment for ref={myVar} pattern
|
|
119
|
+
(local as any).ref = el;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// Handle visibility transitions with FLIP animation
|
|
124
|
+
createEffect(on(
|
|
125
|
+
() => local.isVisible !== false,
|
|
126
|
+
(isVisible) => {
|
|
127
|
+
const name = local.name;
|
|
128
|
+
const element = elementRef;
|
|
129
|
+
|
|
130
|
+
if (frame != null) {
|
|
131
|
+
cancelAnimationFrame(frame);
|
|
132
|
+
frame = undefined;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (isVisible && element) {
|
|
136
|
+
const prevSnapshot = scope.snapshots[name];
|
|
137
|
+
|
|
138
|
+
if (prevSnapshot) {
|
|
139
|
+
// FLIP: Element is transitioning from a previous instance.
|
|
140
|
+
setLifecycle('visible');
|
|
141
|
+
const animations = getAnimations(element);
|
|
142
|
+
|
|
143
|
+
// Set properties to animate from.
|
|
144
|
+
const values = prevSnapshot.style.map(([property, prevValue]) => {
|
|
145
|
+
const value = (element.style as any)[property];
|
|
146
|
+
if (property === 'translate') {
|
|
147
|
+
const prevRect = prevSnapshot.rect;
|
|
148
|
+
const currentRect = element.getBoundingClientRect();
|
|
149
|
+
const deltaX = prevRect.left - currentRect.left;
|
|
150
|
+
const deltaY = prevRect.top - currentRect.top;
|
|
151
|
+
element.style.translate = `${deltaX}px ${deltaY}px`;
|
|
152
|
+
} else {
|
|
153
|
+
(element.style as any)[property] = prevValue;
|
|
154
|
+
}
|
|
155
|
+
return [property, value] as [string, string];
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Cancel any new animations triggered by these properties.
|
|
159
|
+
for (const a of getAnimations(element)) {
|
|
160
|
+
if (!animations.includes(a)) {
|
|
161
|
+
a.cancel();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Remove overrides after one frame to animate to the current values.
|
|
166
|
+
frame = requestAnimationFrame(() => {
|
|
167
|
+
frame = undefined;
|
|
168
|
+
for (const [property, value] of values) {
|
|
169
|
+
(element.style as any)[property] = value;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
delete scope.snapshots[name];
|
|
174
|
+
} else {
|
|
175
|
+
// No previous instance exists, apply the entering state.
|
|
176
|
+
queueMicrotask(() => setLifecycle('entering'));
|
|
177
|
+
frame = requestAnimationFrame(() => {
|
|
178
|
+
frame = undefined;
|
|
179
|
+
setLifecycle('visible');
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
} else if (!isVisible && element) {
|
|
183
|
+
// Wait a microtask to check if a snapshot still exists (meaning no new
|
|
184
|
+
// SharedElement consumed it), then enter exiting state.
|
|
185
|
+
queueMicrotask(() => {
|
|
186
|
+
if (scope.snapshots[name]) {
|
|
187
|
+
delete scope.snapshots[name];
|
|
188
|
+
setLifecycle('exiting');
|
|
189
|
+
// Wait for animations to finish before hiding.
|
|
190
|
+
Promise.all(getAnimations(element).map(a => a.finished))
|
|
191
|
+
.then(() => setLifecycle('hidden'))
|
|
192
|
+
.catch(() => {});
|
|
193
|
+
} else {
|
|
194
|
+
// Snapshot was consumed by another instance, unmount immediately.
|
|
195
|
+
setLifecycle('hidden');
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
} else if (isVisible) {
|
|
199
|
+
// Element not yet in DOM, entering fresh
|
|
200
|
+
setLifecycle('entering');
|
|
201
|
+
frame = requestAnimationFrame(() => {
|
|
202
|
+
frame = undefined;
|
|
203
|
+
setLifecycle('visible');
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
));
|
|
208
|
+
|
|
209
|
+
// Capture snapshot on cleanup (unmount)
|
|
210
|
+
onCleanup(() => {
|
|
211
|
+
if (frame != null) {
|
|
212
|
+
cancelAnimationFrame(frame);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const element = elementRef;
|
|
216
|
+
if (element && element.isConnected && !element.hasAttribute('data-exiting')) {
|
|
217
|
+
// Store a snapshot of the rectangle and computed style for transitioning properties.
|
|
218
|
+
const style = window.getComputedStyle(element);
|
|
219
|
+
if (style.transitionProperty !== 'none') {
|
|
220
|
+
const transitionProperty = style.transitionProperty.split(/\s*,\s*/);
|
|
221
|
+
scope.snapshots[local.name] = {
|
|
222
|
+
rect: element.getBoundingClientRect(),
|
|
223
|
+
style: transitionProperty.map(p => [p, (style as any)[p]]),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
const renderProps = useRenderProps(
|
|
230
|
+
{
|
|
231
|
+
children: local.children,
|
|
232
|
+
class: local.class,
|
|
233
|
+
style: local.style,
|
|
234
|
+
defaultClassName: 'solidaria-SharedElement',
|
|
235
|
+
},
|
|
236
|
+
() => ({
|
|
237
|
+
isEntering: lifecycle() === 'entering',
|
|
238
|
+
isExiting: lifecycle() === 'exiting',
|
|
239
|
+
})
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
const filteredDomProps = createMemo(() => filterDOMProps(domProps, { global: true }));
|
|
243
|
+
|
|
244
|
+
return (
|
|
245
|
+
<Show when={lifecycle() !== 'hidden'}>
|
|
246
|
+
<div
|
|
247
|
+
ref={setRef}
|
|
248
|
+
{...filteredDomProps()}
|
|
249
|
+
class={renderProps.class()}
|
|
250
|
+
style={renderProps.style()}
|
|
251
|
+
data-entering={lifecycle() === 'entering' || undefined}
|
|
252
|
+
data-exiting={lifecycle() === 'exiting' || undefined}
|
|
253
|
+
>
|
|
254
|
+
{renderProps.renderChildren()}
|
|
255
|
+
</div>
|
|
256
|
+
</Show>
|
|
257
|
+
);
|
|
258
|
+
}
|
package/src/Slider.tsx
CHANGED
|
@@ -94,7 +94,7 @@ export interface SliderTrackRenderProps {
|
|
|
94
94
|
orientation: SliderOrientation;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export interface SliderTrackProps extends SlotProps {
|
|
97
|
+
export interface SliderTrackProps extends SlotProps, Omit<JSX.HTMLAttributes<HTMLDivElement>, 'class' | 'style' | 'children'> {
|
|
98
98
|
/** The children of the track. */
|
|
99
99
|
children?: RenderChildren<SliderTrackRenderProps>;
|
|
100
100
|
/** The CSS className for the element. */
|
|
@@ -120,7 +120,7 @@ export interface SliderThumbRenderProps {
|
|
|
120
120
|
valuePercent: number;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
export interface SliderThumbProps extends SlotProps {
|
|
123
|
+
export interface SliderThumbProps extends SlotProps, Omit<JSX.HTMLAttributes<HTMLDivElement>, 'class' | 'style' | 'children'> {
|
|
124
124
|
/** The children of the thumb. */
|
|
125
125
|
children?: RenderChildren<SliderThumbRenderProps>;
|
|
126
126
|
/** The CSS className for the element. */
|
|
@@ -136,7 +136,7 @@ export interface SliderOutputRenderProps {
|
|
|
136
136
|
formattedValue: string;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
export interface SliderOutputProps extends SlotProps {
|
|
139
|
+
export interface SliderOutputProps extends SlotProps, Omit<JSX.HTMLAttributes<HTMLElement>, 'class' | 'style' | 'children'> {
|
|
140
140
|
/** The children of the output. */
|
|
141
141
|
children?: RenderChildren<SliderOutputRenderProps>;
|
|
142
142
|
/** The CSS className for the element. */
|
|
@@ -160,6 +160,9 @@ interface SliderContextValue {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
export const SliderContext = createContext<SliderContextValue | null>(null);
|
|
163
|
+
export const SliderStateContext = SliderContext;
|
|
164
|
+
export const SliderTrackContext = SliderContext;
|
|
165
|
+
export const SliderOutputContext = SliderContext;
|
|
163
166
|
|
|
164
167
|
// ============================================
|
|
165
168
|
// COMPONENTS
|
|
@@ -298,7 +301,7 @@ export function Slider(props: SliderProps): JSX.Element {
|
|
|
298
301
|
* The track element of a slider.
|
|
299
302
|
*/
|
|
300
303
|
export function SliderTrack(props: SliderTrackProps): JSX.Element {
|
|
301
|
-
const [local] = splitProps(props, ['class', 'style', 'slot']);
|
|
304
|
+
const [local, domProps] = splitProps(props, ['class', 'style', 'slot', 'children']);
|
|
302
305
|
|
|
303
306
|
const context = useContext(SliderContext);
|
|
304
307
|
if (!context) {
|
|
@@ -341,6 +344,7 @@ export function SliderTrack(props: SliderTrackProps): JSX.Element {
|
|
|
341
344
|
|
|
342
345
|
return (
|
|
343
346
|
<div
|
|
347
|
+
{...domProps}
|
|
344
348
|
ref={setTrackRef}
|
|
345
349
|
{...cleanTrackProps()}
|
|
346
350
|
class={renderProps.class()}
|
|
@@ -358,7 +362,7 @@ export function SliderTrack(props: SliderTrackProps): JSX.Element {
|
|
|
358
362
|
* The thumb element of a slider.
|
|
359
363
|
*/
|
|
360
364
|
export function SliderThumb(props: SliderThumbProps): JSX.Element {
|
|
361
|
-
const [local] = splitProps(props, ['class', 'style', 'slot']);
|
|
365
|
+
const [local, domProps] = splitProps(props, ['class', 'style', 'slot', 'children']);
|
|
362
366
|
|
|
363
367
|
const context = useContext(SliderContext);
|
|
364
368
|
if (!context) {
|
|
@@ -422,6 +426,7 @@ export function SliderThumb(props: SliderThumbProps): JSX.Element {
|
|
|
422
426
|
|
|
423
427
|
return (
|
|
424
428
|
<div
|
|
429
|
+
{...domProps}
|
|
425
430
|
{...cleanThumbProps()}
|
|
426
431
|
{...cleanFocusProps()}
|
|
427
432
|
{...cleanHoverProps()}
|
|
@@ -442,7 +447,7 @@ export function SliderThumb(props: SliderThumbProps): JSX.Element {
|
|
|
442
447
|
* The output element of a slider, displaying the current value.
|
|
443
448
|
*/
|
|
444
449
|
export function SliderOutput(props: SliderOutputProps): JSX.Element {
|
|
445
|
-
const [local] = splitProps(props, ['class', 'style', 'slot']);
|
|
450
|
+
const [local, domProps] = splitProps(props, ['class', 'style', 'slot', 'children']);
|
|
446
451
|
|
|
447
452
|
const context = useContext(SliderContext);
|
|
448
453
|
if (!context) {
|
|
@@ -469,6 +474,10 @@ export function SliderOutput(props: SliderOutputProps): JSX.Element {
|
|
|
469
474
|
);
|
|
470
475
|
|
|
471
476
|
// Clean props
|
|
477
|
+
const cleanDomProps = () => {
|
|
478
|
+
const { ref: _ref, ...rest } = domProps as Record<string, unknown>;
|
|
479
|
+
return rest;
|
|
480
|
+
};
|
|
472
481
|
const cleanOutputProps = () => {
|
|
473
482
|
const { ref: _ref, ...rest } = outputProps as Record<string, unknown>;
|
|
474
483
|
return rest;
|
|
@@ -485,6 +494,7 @@ export function SliderOutput(props: SliderOutputProps): JSX.Element {
|
|
|
485
494
|
|
|
486
495
|
return (
|
|
487
496
|
<output
|
|
497
|
+
{...cleanDomProps()}
|
|
488
498
|
{...cleanOutputProps()}
|
|
489
499
|
class={renderProps.class()}
|
|
490
500
|
style={renderProps.style()}
|