@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
package/src/Modal.tsx
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
createInteractOutside,
|
|
22
22
|
ariaHideOutside,
|
|
23
23
|
FocusScope,
|
|
24
|
+
useUNSAFE_PortalContext,
|
|
24
25
|
} from '@proyecto-viviana/solidaria'
|
|
25
26
|
import {
|
|
26
27
|
type RenderChildren,
|
|
@@ -51,6 +52,9 @@ interface InternalModalContextValue {
|
|
|
51
52
|
|
|
52
53
|
const InternalModalContext = createContext<InternalModalContextValue | null>(null)
|
|
53
54
|
|
|
55
|
+
// Stack of visible modals, used to ensure only the top-most modal dismisses on Escape/outside interaction.
|
|
56
|
+
const visibleModals: Array<() => Element | null> = []
|
|
57
|
+
|
|
54
58
|
// ============================================
|
|
55
59
|
// TYPES
|
|
56
60
|
// ============================================
|
|
@@ -90,6 +94,7 @@ export interface ModalProps extends ModalOverlayProps {}
|
|
|
90
94
|
// Re-export from contexts for backwards compatibility
|
|
91
95
|
export { OverlayTriggerStateContext, type OverlayTriggerState } from './contexts'
|
|
92
96
|
export { useOverlayTriggerState } from './contexts'
|
|
97
|
+
export const ModalContext = OverlayTriggerStateContext;
|
|
93
98
|
|
|
94
99
|
// ============================================
|
|
95
100
|
// MODAL OVERLAY COMPONENT
|
|
@@ -197,6 +202,8 @@ export function ModalOverlay(props: ModalOverlayProps): JSX.Element {
|
|
|
197
202
|
isDismissable: local.isDismissable,
|
|
198
203
|
isKeyboardDismissDisabled: local.isKeyboardDismissDisabled,
|
|
199
204
|
}
|
|
205
|
+
const portalContext = useUNSAFE_PortalContext()
|
|
206
|
+
const portalContainer = () => portalContext.getContainer?.() ?? undefined
|
|
200
207
|
|
|
201
208
|
// Resolve children - handle both static JSX and render functions
|
|
202
209
|
// IMPORTANT: We access props.children directly (not local.children) to preserve
|
|
@@ -211,7 +218,7 @@ export function ModalOverlay(props: ModalOverlayProps): JSX.Element {
|
|
|
211
218
|
|
|
212
219
|
return (
|
|
213
220
|
<Show when={isOpen() || local.isExiting}>
|
|
214
|
-
<Portal>
|
|
221
|
+
<Portal mount={portalContainer()}>
|
|
215
222
|
<OverlayTriggerStateContext.Provider value={state}>
|
|
216
223
|
<InternalModalContext.Provider value={internalModalContext}>
|
|
217
224
|
<div
|
|
@@ -319,6 +326,7 @@ function ModalContent(props: ModalProps & { internalContext: InternalModalContex
|
|
|
319
326
|
])
|
|
320
327
|
|
|
321
328
|
let modalRef!: HTMLDivElement
|
|
329
|
+
const modalRefAccessor = () => modalRef ?? null
|
|
322
330
|
|
|
323
331
|
// Get state from parent OverlayTriggerStateContext (provided by ModalOverlay)
|
|
324
332
|
const parentState = useContext(OverlayTriggerStateContext)
|
|
@@ -333,6 +341,24 @@ function ModalContent(props: ModalProps & { internalContext: InternalModalContex
|
|
|
333
341
|
return parentState?.isOpen ?? false
|
|
334
342
|
}
|
|
335
343
|
|
|
344
|
+
// Keep this modal in a global stack so nested modals dismiss in top-down order.
|
|
345
|
+
createEffect(() => {
|
|
346
|
+
if (!isOpen()) return
|
|
347
|
+
|
|
348
|
+
if (!visibleModals.includes(modalRefAccessor)) {
|
|
349
|
+
visibleModals.push(modalRefAccessor)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
onCleanup(() => {
|
|
353
|
+
const index = visibleModals.indexOf(modalRefAccessor)
|
|
354
|
+
if (index >= 0) {
|
|
355
|
+
visibleModals.splice(index, 1)
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
const isTopMostModal = () => visibleModals[visibleModals.length - 1] === modalRefAccessor
|
|
361
|
+
|
|
336
362
|
const close = () => {
|
|
337
363
|
if (local.isOpen !== undefined) {
|
|
338
364
|
local.onOpenChange?.(false)
|
|
@@ -360,9 +386,11 @@ function ModalContent(props: ModalProps & { internalContext: InternalModalContex
|
|
|
360
386
|
if (!isOpen() || !isDismissable()) return
|
|
361
387
|
|
|
362
388
|
createInteractOutside({
|
|
363
|
-
ref:
|
|
389
|
+
ref: modalRefAccessor,
|
|
364
390
|
onInteractOutside: () => {
|
|
365
|
-
|
|
391
|
+
if (isTopMostModal()) {
|
|
392
|
+
close()
|
|
393
|
+
}
|
|
366
394
|
},
|
|
367
395
|
isDisabled: false,
|
|
368
396
|
})
|
|
@@ -373,7 +401,7 @@ function ModalContent(props: ModalProps & { internalContext: InternalModalContex
|
|
|
373
401
|
if (!isOpen() || isKeyboardDismissDisabled()) return
|
|
374
402
|
|
|
375
403
|
const handleKeyDown = (e: KeyboardEvent) => {
|
|
376
|
-
if (e.key === 'Escape') {
|
|
404
|
+
if (e.key === 'Escape' && !e.isComposing && isTopMostModal()) {
|
|
377
405
|
e.preventDefault()
|
|
378
406
|
e.stopPropagation()
|
|
379
407
|
close()
|
package/src/NumberField.tsx
CHANGED
|
@@ -140,9 +140,11 @@ interface NumberFieldContextValue {
|
|
|
140
140
|
isInvalid: boolean;
|
|
141
141
|
isRequired: boolean;
|
|
142
142
|
isReadOnly: boolean;
|
|
143
|
+
setInputRef: (el: HTMLInputElement) => void;
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
export const NumberFieldContext = createContext<NumberFieldContextValue | null>(null);
|
|
147
|
+
export const NumberFieldStateContext = createContext<NumberFieldState | null>(null);
|
|
146
148
|
|
|
147
149
|
// ============================================
|
|
148
150
|
// COMPONENTS
|
|
@@ -156,7 +158,30 @@ export function NumberField(props: NumberFieldProps): JSX.Element {
|
|
|
156
158
|
props,
|
|
157
159
|
['children', 'class', 'style', 'slot'],
|
|
158
160
|
['value', 'defaultValue', 'onChange', 'minValue', 'maxValue', 'step', 'locale', 'formatOptions'],
|
|
159
|
-
[
|
|
161
|
+
[
|
|
162
|
+
'label',
|
|
163
|
+
'aria-label',
|
|
164
|
+
'aria-labelledby',
|
|
165
|
+
'aria-describedby',
|
|
166
|
+
'isDisabled',
|
|
167
|
+
'isReadOnly',
|
|
168
|
+
'isRequired',
|
|
169
|
+
'isInvalid',
|
|
170
|
+
'description',
|
|
171
|
+
'errorMessage',
|
|
172
|
+
'id',
|
|
173
|
+
'autoFocus',
|
|
174
|
+
'name',
|
|
175
|
+
'form',
|
|
176
|
+
'onFocus',
|
|
177
|
+
'onBlur',
|
|
178
|
+
'onFocusChange',
|
|
179
|
+
'onKeyDown',
|
|
180
|
+
'onKeyUp',
|
|
181
|
+
'onPaste',
|
|
182
|
+
'onCopy',
|
|
183
|
+
'onCut',
|
|
184
|
+
]
|
|
160
185
|
);
|
|
161
186
|
|
|
162
187
|
// Create number field state
|
|
@@ -195,17 +220,83 @@ export function NumberField(props: NumberFieldProps): JSX.Element {
|
|
|
195
220
|
|
|
196
221
|
// Ref for the input
|
|
197
222
|
let inputRef: HTMLInputElement | undefined;
|
|
223
|
+
const setInputRef = (el: HTMLInputElement) => {
|
|
224
|
+
inputRef = el;
|
|
225
|
+
};
|
|
198
226
|
|
|
199
227
|
// Create number field aria props
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
228
|
+
const numberFieldAria = createNumberField(
|
|
229
|
+
{
|
|
230
|
+
get label() {
|
|
231
|
+
return ariaProps.label;
|
|
232
|
+
},
|
|
233
|
+
get 'aria-label'() {
|
|
234
|
+
return ariaProps['aria-label'];
|
|
235
|
+
},
|
|
236
|
+
get 'aria-labelledby'() {
|
|
237
|
+
return ariaProps['aria-labelledby'];
|
|
238
|
+
},
|
|
239
|
+
get 'aria-describedby'() {
|
|
240
|
+
return ariaProps['aria-describedby'];
|
|
241
|
+
},
|
|
242
|
+
get isDisabled() {
|
|
243
|
+
return ariaProps.isDisabled;
|
|
244
|
+
},
|
|
245
|
+
get isReadOnly() {
|
|
246
|
+
return ariaProps.isReadOnly;
|
|
247
|
+
},
|
|
248
|
+
get isRequired() {
|
|
249
|
+
return ariaProps.isRequired;
|
|
250
|
+
},
|
|
251
|
+
get isInvalid() {
|
|
252
|
+
return ariaProps.isInvalid;
|
|
253
|
+
},
|
|
254
|
+
get description() {
|
|
255
|
+
return ariaProps.description;
|
|
256
|
+
},
|
|
257
|
+
get errorMessage() {
|
|
258
|
+
return ariaProps.errorMessage;
|
|
259
|
+
},
|
|
260
|
+
get id() {
|
|
261
|
+
return ariaProps.id;
|
|
262
|
+
},
|
|
263
|
+
get autoFocus() {
|
|
264
|
+
return ariaProps.autoFocus;
|
|
265
|
+
},
|
|
266
|
+
get name() {
|
|
267
|
+
return ariaProps.name;
|
|
268
|
+
},
|
|
269
|
+
get form() {
|
|
270
|
+
return ariaProps.form;
|
|
271
|
+
},
|
|
272
|
+
get onFocus() {
|
|
273
|
+
return ariaProps.onFocus;
|
|
274
|
+
},
|
|
275
|
+
get onBlur() {
|
|
276
|
+
return ariaProps.onBlur;
|
|
277
|
+
},
|
|
278
|
+
get onFocusChange() {
|
|
279
|
+
return ariaProps.onFocusChange;
|
|
280
|
+
},
|
|
281
|
+
get onKeyDown() {
|
|
282
|
+
return ariaProps.onKeyDown;
|
|
283
|
+
},
|
|
284
|
+
get onKeyUp() {
|
|
285
|
+
return ariaProps.onKeyUp;
|
|
286
|
+
},
|
|
287
|
+
get onPaste() {
|
|
288
|
+
return ariaProps.onPaste;
|
|
289
|
+
},
|
|
290
|
+
get onCopy() {
|
|
291
|
+
return ariaProps.onCopy;
|
|
292
|
+
},
|
|
293
|
+
get onCut() {
|
|
294
|
+
return ariaProps.onCut;
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
state,
|
|
298
|
+
() => inputRef ?? null
|
|
299
|
+
);
|
|
209
300
|
|
|
210
301
|
// Render props values
|
|
211
302
|
const renderValues = createMemo<NumberFieldRenderProps>(() => ({
|
|
@@ -230,35 +321,60 @@ export function NumberField(props: NumberFieldProps): JSX.Element {
|
|
|
230
321
|
// Filter DOM props
|
|
231
322
|
const domProps = createMemo(() => filterDOMProps(rest as Record<string, unknown>, { global: true }));
|
|
232
323
|
|
|
324
|
+
const contextValue: NumberFieldContextValue = {
|
|
325
|
+
state,
|
|
326
|
+
get inputProps() {
|
|
327
|
+
return numberFieldAria.inputProps;
|
|
328
|
+
},
|
|
329
|
+
get incrementButtonProps() {
|
|
330
|
+
return numberFieldAria.incrementButtonProps;
|
|
331
|
+
},
|
|
332
|
+
get decrementButtonProps() {
|
|
333
|
+
return numberFieldAria.decrementButtonProps;
|
|
334
|
+
},
|
|
335
|
+
get labelProps() {
|
|
336
|
+
return numberFieldAria.labelProps;
|
|
337
|
+
},
|
|
338
|
+
get groupProps() {
|
|
339
|
+
return numberFieldAria.groupProps;
|
|
340
|
+
},
|
|
341
|
+
get descriptionProps() {
|
|
342
|
+
return numberFieldAria.descriptionProps;
|
|
343
|
+
},
|
|
344
|
+
get errorMessageProps() {
|
|
345
|
+
return numberFieldAria.errorMessageProps;
|
|
346
|
+
},
|
|
347
|
+
get isDisabled() {
|
|
348
|
+
return ariaProps.isDisabled ?? false;
|
|
349
|
+
},
|
|
350
|
+
get isInvalid() {
|
|
351
|
+
return ariaProps.isInvalid ?? false;
|
|
352
|
+
},
|
|
353
|
+
get isRequired() {
|
|
354
|
+
return ariaProps.isRequired ?? false;
|
|
355
|
+
},
|
|
356
|
+
get isReadOnly() {
|
|
357
|
+
return ariaProps.isReadOnly ?? false;
|
|
358
|
+
},
|
|
359
|
+
setInputRef,
|
|
360
|
+
};
|
|
361
|
+
|
|
233
362
|
return (
|
|
234
|
-
<
|
|
235
|
-
value={
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
>
|
|
250
|
-
<div
|
|
251
|
-
{...domProps()}
|
|
252
|
-
class={renderProps.class()}
|
|
253
|
-
style={renderProps.style()}
|
|
254
|
-
data-disabled={ariaProps.isDisabled || undefined}
|
|
255
|
-
data-invalid={ariaProps.isInvalid || undefined}
|
|
256
|
-
data-required={ariaProps.isRequired || undefined}
|
|
257
|
-
data-readonly={ariaProps.isReadOnly || undefined}
|
|
258
|
-
>
|
|
259
|
-
{renderProps.renderChildren()}
|
|
260
|
-
</div>
|
|
261
|
-
</NumberFieldContext.Provider>
|
|
363
|
+
<NumberFieldStateContext.Provider value={state}>
|
|
364
|
+
<NumberFieldContext.Provider value={contextValue}>
|
|
365
|
+
<div
|
|
366
|
+
{...domProps()}
|
|
367
|
+
class={renderProps.class()}
|
|
368
|
+
style={renderProps.style()}
|
|
369
|
+
data-disabled={ariaProps.isDisabled || undefined}
|
|
370
|
+
data-invalid={ariaProps.isInvalid || undefined}
|
|
371
|
+
data-required={ariaProps.isRequired || undefined}
|
|
372
|
+
data-readonly={ariaProps.isReadOnly || undefined}
|
|
373
|
+
>
|
|
374
|
+
{renderProps.renderChildren()}
|
|
375
|
+
</div>
|
|
376
|
+
</NumberFieldContext.Provider>
|
|
377
|
+
</NumberFieldStateContext.Provider>
|
|
262
378
|
);
|
|
263
379
|
}
|
|
264
380
|
|
|
@@ -312,7 +428,7 @@ export function NumberFieldGroup(props: { children?: JSX.Element; class?: string
|
|
|
312
428
|
* The input element for a number field.
|
|
313
429
|
*/
|
|
314
430
|
export function NumberFieldInput(props: NumberFieldInputProps): JSX.Element {
|
|
315
|
-
const [local] = splitProps(props, ['class', 'style', 'slot']);
|
|
431
|
+
const [local, domProps] = splitProps(props, ['class', 'style', 'slot']);
|
|
316
432
|
|
|
317
433
|
const context = useContext(NumberFieldContext);
|
|
318
434
|
if (!context) {
|
|
@@ -364,6 +480,8 @@ export function NumberFieldInput(props: NumberFieldInputProps): JSX.Element {
|
|
|
364
480
|
|
|
365
481
|
return (
|
|
366
482
|
<input
|
|
483
|
+
{...domProps}
|
|
484
|
+
ref={context.setInputRef}
|
|
367
485
|
{...cleanInputProps()}
|
|
368
486
|
{...cleanFocusProps()}
|
|
369
487
|
{...cleanHoverProps()}
|
|
@@ -382,7 +500,7 @@ export function NumberFieldInput(props: NumberFieldInputProps): JSX.Element {
|
|
|
382
500
|
* The increment button for a number field.
|
|
383
501
|
*/
|
|
384
502
|
export function NumberFieldIncrementButton(props: NumberFieldIncrementButtonProps): JSX.Element {
|
|
385
|
-
const [local] = splitProps(props, ['class', 'style', 'slot']);
|
|
503
|
+
const [local, domProps] = splitProps(props, ['class', 'style', 'slot', 'children']);
|
|
386
504
|
|
|
387
505
|
const context = useContext(NumberFieldContext);
|
|
388
506
|
if (!context) {
|
|
@@ -395,7 +513,7 @@ export function NumberFieldIncrementButton(props: NumberFieldIncrementButtonProp
|
|
|
395
513
|
return context.isDisabled || !context.state.canIncrement();
|
|
396
514
|
},
|
|
397
515
|
onPress: () => {
|
|
398
|
-
context.
|
|
516
|
+
(context.incrementButtonProps.onClick as ((e?: MouseEvent) => void) | undefined)?.();
|
|
399
517
|
},
|
|
400
518
|
});
|
|
401
519
|
|
|
@@ -442,6 +560,7 @@ export function NumberFieldIncrementButton(props: NumberFieldIncrementButtonProp
|
|
|
442
560
|
|
|
443
561
|
return (
|
|
444
562
|
<button
|
|
563
|
+
{...domProps}
|
|
445
564
|
{...cleanButtonProps()}
|
|
446
565
|
{...cleanPressProps()}
|
|
447
566
|
{...cleanHoverProps()}
|
|
@@ -460,7 +579,7 @@ export function NumberFieldIncrementButton(props: NumberFieldIncrementButtonProp
|
|
|
460
579
|
* The decrement button for a number field.
|
|
461
580
|
*/
|
|
462
581
|
export function NumberFieldDecrementButton(props: NumberFieldDecrementButtonProps): JSX.Element {
|
|
463
|
-
const [local] = splitProps(props, ['class', 'style', 'slot']);
|
|
582
|
+
const [local, domProps] = splitProps(props, ['class', 'style', 'slot', 'children']);
|
|
464
583
|
|
|
465
584
|
const context = useContext(NumberFieldContext);
|
|
466
585
|
if (!context) {
|
|
@@ -473,7 +592,7 @@ export function NumberFieldDecrementButton(props: NumberFieldDecrementButtonProp
|
|
|
473
592
|
return context.isDisabled || !context.state.canDecrement();
|
|
474
593
|
},
|
|
475
594
|
onPress: () => {
|
|
476
|
-
context.
|
|
595
|
+
(context.decrementButtonProps.onClick as ((e?: MouseEvent) => void) | undefined)?.();
|
|
477
596
|
},
|
|
478
597
|
});
|
|
479
598
|
|
|
@@ -520,6 +639,7 @@ export function NumberFieldDecrementButton(props: NumberFieldDecrementButtonProp
|
|
|
520
639
|
|
|
521
640
|
return (
|
|
522
641
|
<button
|
|
642
|
+
{...domProps}
|
|
523
643
|
{...cleanButtonProps()}
|
|
524
644
|
{...cleanPressProps()}
|
|
525
645
|
{...cleanHoverProps()}
|