@proyecto-viviana/solidaria-components 0.2.9 → 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/README.md +39 -272
- package/dist/ActionBar.d.ts +21 -13
- package/dist/ActionBar.d.ts.map +1 -1
- package/dist/ActionGroup.d.ts +8 -8
- package/dist/ActionGroup.d.ts.map +1 -1
- package/dist/Alert.d.ts +5 -5
- package/dist/Alert.d.ts.map +1 -1
- package/dist/Autocomplete.d.ts +5 -5
- package/dist/Autocomplete.d.ts.map +1 -1
- package/dist/Breadcrumbs.d.ts +18 -7
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Button.d.ts +24 -5
- package/dist/Button.d.ts.map +1 -1
- package/dist/Calendar.d.ts +38 -7
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Checkbox.d.ts +32 -7
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Collection.d.ts +19 -14
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Color.d.ts +103 -14
- package/dist/Color.d.ts.map +1 -1
- package/dist/ColorEditor.d.ts +6 -6
- package/dist/ColorEditor.d.ts.map +1 -1
- package/dist/ComboBox.d.ts +85 -19
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ContextualHelpTrigger.d.ts +2 -2
- package/dist/ContextualHelpTrigger.d.ts.map +1 -1
- package/dist/DateField.d.ts +8 -6
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DatePicker.d.ts +53 -22
- 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 +23 -5
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/DragAndDrop.d.ts +6 -6
- package/dist/DragAndDrop.d.ts.map +1 -1
- package/dist/DragPreview.d.ts +2 -2
- package/dist/DragPreview.d.ts.map +1 -1
- package/dist/DropZone.d.ts +4 -4
- package/dist/DropZone.d.ts.map +1 -1
- package/dist/FieldError.d.ts +9 -5
- package/dist/FieldError.d.ts.map +1 -1
- package/dist/FileTrigger.d.ts +3 -3
- package/dist/FileTrigger.d.ts.map +1 -1
- package/dist/Focusable.d.ts +2 -2
- package/dist/Focusable.d.ts.map +1 -1
- package/dist/Form.d.ts +18 -4
- package/dist/Form.d.ts.map +1 -1
- package/dist/GridList.d.ts +32 -12
- 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 +5 -5
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Keyboard.d.ts +1 -1
- 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 +32 -12
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListDropTargetDelegate.d.ts +6 -6
- package/dist/ListDropTargetDelegate.d.ts.map +1 -1
- package/dist/Menu.d.ts +65 -14
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Meter.d.ts +3 -3
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Modal.d.ts +5 -5
- package/dist/Modal.d.ts.map +1 -1
- package/dist/NumberField.d.ts +8 -12
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/Popover.d.ts +28 -5
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Pressable.d.ts +2 -2
- package/dist/Pressable.d.ts.map +1 -1
- package/dist/ProgressBar.d.ts +5 -3
- 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 +34 -7
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RouterProvider.d.ts +2 -2
- package/dist/RouterProvider.d.ts.map +1 -1
- package/dist/SearchField.d.ts +23 -20
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/Select.d.ts +41 -11
- package/dist/Select.d.ts.map +1 -1
- package/dist/SelectionIndicator.d.ts +3 -3
- package/dist/SelectionIndicator.d.ts.map +1 -1
- package/dist/Separator.d.ts +9 -3
- package/dist/Separator.d.ts.map +1 -1
- package/dist/SharedElementTransition.d.ts +6 -4
- package/dist/SharedElementTransition.d.ts.map +1 -1
- package/dist/Slider.d.ts +12 -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 +187 -23
- package/dist/Table.d.ts.map +1 -1
- package/dist/Tabs.d.ts +45 -9
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/TagGroup.d.ts +12 -10
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/Text.d.ts +2 -2
- package/dist/TextField.d.ts +15 -11
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TimeField.d.ts +6 -6
- 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 +11 -5
- package/dist/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButtonGroup.d.ts +7 -7
- package/dist/ToggleButtonGroup.d.ts.map +1 -1
- package/dist/Toolbar.d.ts +7 -3
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Tooltip.d.ts +50 -8
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tree.d.ts +66 -17
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Virtualizer.d.ts +12 -12
- package/dist/Virtualizer.d.ts.map +1 -1
- package/dist/VirtualizerLayouts.d.ts +2 -2
- package/dist/VirtualizerLayouts.d.ts.map +1 -1
- package/dist/VisuallyHidden.d.ts +1 -1
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/contexts.d.ts +5 -1
- package/dist/contexts.d.ts.map +1 -1
- package/dist/index.d.ts +73 -71
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23247 -18564
- package/dist/index.js.map +1 -1
- package/dist/index.jsx +18110 -0
- package/dist/index.jsx.map +1 -0
- package/dist/useDragAndDrop.d.ts +13 -13
- package/dist/useDragAndDrop.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/virtualizer/Layout.d.ts +1 -1
- package/dist/virtualizer/Layout.d.ts.map +1 -1
- package/package.json +31 -32
- package/src/ActionBar.tsx +75 -72
- package/src/ActionGroup.tsx +53 -61
- package/src/Alert.tsx +17 -42
- package/src/Autocomplete.tsx +39 -44
- package/src/Breadcrumbs.tsx +149 -80
- package/src/Button.tsx +267 -70
- package/src/Calendar.tsx +218 -138
- package/src/Checkbox.tsx +413 -121
- package/src/Collection.tsx +67 -58
- package/src/Color.tsx +803 -380
- package/src/ColorEditor.tsx +131 -149
- package/src/ComboBox.tsx +414 -249
- package/src/ContextualHelpTrigger.tsx +86 -74
- package/src/DateField.tsx +185 -91
- package/src/DatePicker.tsx +524 -213
- package/src/DateRangePickerContext.tsx +44 -0
- package/src/Dialog.tsx +156 -118
- package/src/Disclosure.tsx +127 -80
- package/src/DragAndDrop.tsx +60 -54
- package/src/DragPreview.tsx +13 -11
- package/src/DropZone.tsx +42 -22
- package/src/FieldError.tsx +45 -23
- package/src/FileTrigger.tsx +19 -19
- package/src/Focusable.tsx +21 -24
- package/src/Form.tsx +71 -16
- package/src/GridList.tsx +273 -197
- package/src/HiddenDateInput.tsx +153 -0
- package/src/HiddenTimeInput.tsx +133 -0
- package/src/Icon.tsx +22 -43
- package/src/Keyboard.tsx +3 -3
- package/src/Landmark.tsx +37 -63
- package/src/Link.tsx +125 -75
- package/src/ListBox.tsx +332 -233
- package/src/ListDropTargetDelegate.ts +81 -80
- package/src/Menu.tsx +1023 -274
- package/src/Meter.tsx +38 -56
- package/src/Modal.tsx +243 -175
- package/src/NumberField.tsx +139 -143
- package/src/Popover.tsx +386 -233
- package/src/Pressable.tsx +21 -21
- package/src/ProgressBar.tsx +48 -57
- package/src/RadioGroup.tsx +524 -122
- package/src/RangeCalendar.tsx +157 -90
- package/src/RouterProvider.tsx +30 -47
- package/src/SearchField.tsx +362 -143
- package/src/Select.tsx +656 -233
- package/src/SelectionIndicator.tsx +18 -15
- package/src/Separator.tsx +47 -49
- package/src/SharedElementTransition.tsx +103 -97
- package/src/Slider.tsx +138 -98
- package/src/StepList.tsx +272 -0
- package/src/Switch.tsx +93 -46
- package/src/Table.tsx +1308 -342
- package/src/Tabs.tsx +324 -103
- package/src/TagGroup.tsx +139 -126
- package/src/Text.tsx +3 -3
- package/src/TextField.tsx +389 -79
- package/src/TimeField.tsx +136 -76
- package/src/Toast.tsx +209 -157
- package/src/ToggleButton.tsx +47 -37
- package/src/ToggleButtonGroup.tsx +39 -34
- package/src/Toolbar.tsx +54 -69
- package/src/Tooltip.tsx +387 -119
- package/src/Tree.tsx +651 -368
- package/src/Virtualizer.tsx +208 -180
- package/src/VirtualizerLayouts.ts +45 -30
- package/src/VisuallyHidden.tsx +19 -19
- package/src/contexts.ts +29 -37
- package/src/index.ts +110 -195
- package/src/useDragAndDrop.ts +87 -71
- package/src/utils.tsx +40 -55
- package/src/virtualizer/Layout.ts +14 -22
- package/dist/index.ssr.js +0 -16996
- package/dist/index.ssr.js.map +0 -1
package/src/TimeField.tsx
CHANGED
|
@@ -14,19 +14,20 @@ import {
|
|
|
14
14
|
useContext,
|
|
15
15
|
For,
|
|
16
16
|
Show,
|
|
17
|
-
} from
|
|
17
|
+
} from "solid-js";
|
|
18
18
|
import {
|
|
19
19
|
createTimeField,
|
|
20
20
|
createTimeSegment,
|
|
21
21
|
type AriaTimeFieldProps,
|
|
22
|
-
} from
|
|
22
|
+
} from "@proyecto-viviana/solidaria";
|
|
23
23
|
import {
|
|
24
24
|
createTimeFieldState,
|
|
25
|
+
access,
|
|
25
26
|
type TimeFieldState,
|
|
26
27
|
type TimeFieldStateProps,
|
|
27
28
|
type TimeSegment as TimeSegmentType,
|
|
28
29
|
type TimeValue,
|
|
29
|
-
} from
|
|
30
|
+
} from "@proyecto-viviana/solid-stately";
|
|
30
31
|
import {
|
|
31
32
|
type RenderChildren,
|
|
32
33
|
type ClassNameOrFunction,
|
|
@@ -35,11 +36,9 @@ import {
|
|
|
35
36
|
useRenderProps,
|
|
36
37
|
dataAttr,
|
|
37
38
|
useIsHydrated,
|
|
38
|
-
} from
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// TYPES
|
|
42
|
-
// ============================================
|
|
39
|
+
} from "./utils";
|
|
40
|
+
import { HiddenTimeInput } from "./HiddenTimeInput";
|
|
41
|
+
import { FormContext, type FormProps } from "./Form";
|
|
43
42
|
|
|
44
43
|
export interface TimeFieldRenderProps {
|
|
45
44
|
/** Whether the field is disabled. */
|
|
@@ -53,8 +52,9 @@ export interface TimeFieldRenderProps {
|
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
export interface TimeFieldProps<T extends TimeValue = TimeValue>
|
|
56
|
-
extends
|
|
57
|
-
Omit<
|
|
55
|
+
extends
|
|
56
|
+
Omit<AriaTimeFieldProps, "id" | "isDisabled" | "isReadOnly" | "isRequired">,
|
|
57
|
+
Omit<TimeFieldStateProps<T>, "locale">,
|
|
58
58
|
SlotProps {
|
|
59
59
|
/** The children of the component. */
|
|
60
60
|
children?: JSX.Element | ((segment: TimeSegmentType) => JSX.Element);
|
|
@@ -90,7 +90,7 @@ export interface TimeSegmentRenderProps {
|
|
|
90
90
|
/** Whether the segment is a placeholder. */
|
|
91
91
|
isPlaceholder: boolean;
|
|
92
92
|
/** The segment type. */
|
|
93
|
-
type: TimeSegmentType[
|
|
93
|
+
type: TimeSegmentType["type"];
|
|
94
94
|
/** The text to display. */
|
|
95
95
|
text: string;
|
|
96
96
|
}
|
|
@@ -106,10 +106,6 @@ export interface TimeSegmentProps extends SlotProps {
|
|
|
106
106
|
style?: StyleOrFunction<TimeSegmentRenderProps>;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
// ============================================
|
|
110
|
-
// CONTEXT
|
|
111
|
-
// ============================================
|
|
112
|
-
|
|
113
109
|
export interface TimeFieldContextValue {
|
|
114
110
|
state: TimeFieldState<TimeValue>;
|
|
115
111
|
aria: {
|
|
@@ -123,10 +119,57 @@ export interface TimeFieldContextValue {
|
|
|
123
119
|
export const TimeFieldContext = createContext<TimeFieldContextValue | null>(null);
|
|
124
120
|
export const TimeFieldStateContext = createContext<TimeFieldState<TimeValue> | null>(null);
|
|
125
121
|
|
|
122
|
+
function withFormValidationBehavior<P extends object>(props: P, formContext: FormProps | null): P {
|
|
123
|
+
if (!formContext?.validationBehavior) {
|
|
124
|
+
return props;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return new Proxy(props, {
|
|
128
|
+
get(target, property, receiver) {
|
|
129
|
+
const localValue = Reflect.get(target, property, receiver);
|
|
130
|
+
if (property === "validationBehavior" && localValue === undefined) {
|
|
131
|
+
return formContext.validationBehavior;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return localValue;
|
|
135
|
+
},
|
|
136
|
+
has(target, property) {
|
|
137
|
+
return (
|
|
138
|
+
Reflect.has(target, property) ||
|
|
139
|
+
(property === "validationBehavior" && formContext.validationBehavior !== undefined)
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
ownKeys(target) {
|
|
143
|
+
const keys = new Set(Reflect.ownKeys(target));
|
|
144
|
+
if (formContext.validationBehavior !== undefined) {
|
|
145
|
+
keys.add("validationBehavior");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return Array.from(keys);
|
|
149
|
+
},
|
|
150
|
+
getOwnPropertyDescriptor(target, property) {
|
|
151
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, property);
|
|
152
|
+
if (descriptor) {
|
|
153
|
+
return descriptor;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (property === "validationBehavior" && formContext.validationBehavior !== undefined) {
|
|
157
|
+
return {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
configurable: true,
|
|
160
|
+
get: () => formContext.validationBehavior,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return undefined;
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
126
169
|
function useTimeFieldContextValue(): TimeFieldContextValue {
|
|
127
170
|
const context = useContext(TimeFieldContext);
|
|
128
171
|
if (!context) {
|
|
129
|
-
throw new Error(
|
|
172
|
+
throw new Error("TimeField components must be used within a TimeField");
|
|
130
173
|
}
|
|
131
174
|
return context;
|
|
132
175
|
}
|
|
@@ -135,10 +178,6 @@ export function useTimeFieldContext(): TimeFieldState<TimeValue> {
|
|
|
135
178
|
return useTimeFieldContextValue().state;
|
|
136
179
|
}
|
|
137
180
|
|
|
138
|
-
// ============================================
|
|
139
|
-
// TIME FIELD COMPONENT
|
|
140
|
-
// ============================================
|
|
141
|
-
|
|
142
181
|
/**
|
|
143
182
|
* A time field allows users to enter and edit time values using a keyboard.
|
|
144
183
|
*
|
|
@@ -152,57 +191,75 @@ export function useTimeFieldContext(): TimeFieldState<TimeValue> {
|
|
|
152
191
|
* </TimeField>
|
|
153
192
|
* ```
|
|
154
193
|
*/
|
|
155
|
-
export function TimeField<T extends TimeValue = TimeValue>(
|
|
156
|
-
props: TimeFieldProps<T>
|
|
157
|
-
): JSX.Element {
|
|
194
|
+
export function TimeField<T extends TimeValue = TimeValue>(props: TimeFieldProps<T>): JSX.Element {
|
|
158
195
|
// Use hydration-safe pattern for client-only rendering
|
|
159
196
|
const isHydrated = useIsHydrated();
|
|
197
|
+
const formContext = useContext(FormContext);
|
|
160
198
|
|
|
161
199
|
return (
|
|
162
200
|
<Show
|
|
163
201
|
when={isHydrated()}
|
|
164
|
-
fallback={
|
|
202
|
+
fallback={
|
|
203
|
+
<div class="solidaria-TimeField solidaria-TimeField--placeholder" aria-hidden="true" />
|
|
204
|
+
}
|
|
165
205
|
>
|
|
166
|
-
<TimeFieldInner {...props} />
|
|
206
|
+
<TimeFieldInner {...props} __formContext={formContext} />
|
|
167
207
|
</Show>
|
|
168
208
|
);
|
|
169
209
|
}
|
|
170
210
|
|
|
211
|
+
type TimeFieldInnerProps<T extends TimeValue = TimeValue> = TimeFieldProps<T> & {
|
|
212
|
+
__formContext?: FormProps | null;
|
|
213
|
+
};
|
|
214
|
+
|
|
171
215
|
/**
|
|
172
216
|
* Internal TimeField component that renders after client mount.
|
|
173
217
|
*/
|
|
174
218
|
function TimeFieldInner<T extends TimeValue = TimeValue>(
|
|
175
|
-
props:
|
|
219
|
+
props: TimeFieldInnerProps<T>,
|
|
176
220
|
): JSX.Element {
|
|
221
|
+
const formContext = props.__formContext ?? useContext(FormContext);
|
|
222
|
+
const mergedProps = withFormValidationBehavior(props, formContext);
|
|
177
223
|
const [local, stateProps, rest] = splitProps(
|
|
178
|
-
|
|
179
|
-
[
|
|
224
|
+
mergedProps,
|
|
225
|
+
["children", "class", "style", "slot", "__formContext"],
|
|
180
226
|
[
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
227
|
+
"value",
|
|
228
|
+
"defaultValue",
|
|
229
|
+
"onChange",
|
|
230
|
+
"minValue",
|
|
231
|
+
"maxValue",
|
|
232
|
+
"isInvalid",
|
|
233
|
+
"isDisabled",
|
|
234
|
+
"isReadOnly",
|
|
235
|
+
"isRequired",
|
|
236
|
+
"locale",
|
|
237
|
+
"granularity",
|
|
238
|
+
"hourCycle",
|
|
239
|
+
"shouldForceLeadingZeros",
|
|
240
|
+
"validationState",
|
|
241
|
+
"validationBehavior",
|
|
242
|
+
"validate",
|
|
243
|
+
"description",
|
|
244
|
+
"errorMessage",
|
|
245
|
+
"placeholderValue",
|
|
246
|
+
],
|
|
195
247
|
);
|
|
196
248
|
|
|
197
249
|
const [fieldRef, setFieldRef] = createSignal<HTMLDivElement | null>(null);
|
|
198
250
|
|
|
199
|
-
// Create time field state
|
|
200
251
|
const state = createTimeFieldState(stateProps);
|
|
201
252
|
|
|
202
|
-
|
|
203
|
-
|
|
253
|
+
const fieldAria = createTimeField(
|
|
254
|
+
() => ({
|
|
255
|
+
...(rest as Record<string, unknown>),
|
|
256
|
+
description: stateProps.description,
|
|
257
|
+
errorMessage: stateProps.errorMessage,
|
|
258
|
+
}),
|
|
259
|
+
state as unknown as TimeFieldState<TimeValue>,
|
|
260
|
+
fieldRef,
|
|
261
|
+
);
|
|
204
262
|
|
|
205
|
-
// Render props values
|
|
206
263
|
const renderValues = createMemo<TimeFieldRenderProps>(() => ({
|
|
207
264
|
isDisabled: state.isDisabled(),
|
|
208
265
|
isReadOnly: state.isReadOnly(),
|
|
@@ -210,16 +267,20 @@ function TimeFieldInner<T extends TimeValue = TimeValue>(
|
|
|
210
267
|
isInvalid: state.isInvalid(),
|
|
211
268
|
}));
|
|
212
269
|
|
|
213
|
-
// Resolve render props
|
|
214
270
|
const renderProps = useRenderProps(
|
|
215
271
|
{
|
|
216
272
|
class: local.class,
|
|
217
273
|
style: local.style,
|
|
218
|
-
defaultClassName:
|
|
274
|
+
defaultClassName: "solidaria-TimeField",
|
|
219
275
|
},
|
|
220
|
-
renderValues
|
|
276
|
+
renderValues,
|
|
221
277
|
);
|
|
222
278
|
|
|
279
|
+
const validationBehavior = () =>
|
|
280
|
+
(stateProps as { validationBehavior?: "aria" | "native" }).validationBehavior ??
|
|
281
|
+
formContext?.validationBehavior ??
|
|
282
|
+
"native";
|
|
283
|
+
|
|
223
284
|
return (
|
|
224
285
|
<TimeFieldStateContext.Provider value={state as unknown as TimeFieldState<TimeValue>}>
|
|
225
286
|
<TimeFieldContext.Provider
|
|
@@ -243,17 +304,31 @@ function TimeFieldInner<T extends TimeValue = TimeValue>(
|
|
|
243
304
|
data-required={dataAttr(state.isRequired())}
|
|
244
305
|
data-invalid={dataAttr(state.isInvalid())}
|
|
245
306
|
>
|
|
246
|
-
{
|
|
307
|
+
{local.children as JSX.Element}
|
|
247
308
|
</div>
|
|
309
|
+
<Show when={(rest as Record<string, unknown>).name}>
|
|
310
|
+
<HiddenTimeInput
|
|
311
|
+
name={(rest as Record<string, unknown>).name as string | undefined}
|
|
312
|
+
form={(rest as Record<string, unknown>).form as string | undefined}
|
|
313
|
+
value={state.value()}
|
|
314
|
+
autoComplete={(rest as Record<string, unknown>).autoComplete as string | undefined}
|
|
315
|
+
isDisabled={state.isDisabled()}
|
|
316
|
+
isRequired={state.isRequired()}
|
|
317
|
+
validationBehavior={validationBehavior()}
|
|
318
|
+
validationState={state}
|
|
319
|
+
focus={() => {
|
|
320
|
+
fieldRef()?.querySelector<HTMLElement>('[role="spinbutton"]')?.focus();
|
|
321
|
+
}}
|
|
322
|
+
minValue={access(stateProps.minValue) as TimeValue | undefined}
|
|
323
|
+
maxValue={access(stateProps.maxValue) as TimeValue | undefined}
|
|
324
|
+
granularity={state.granularity}
|
|
325
|
+
/>
|
|
326
|
+
</Show>
|
|
248
327
|
</TimeFieldContext.Provider>
|
|
249
328
|
</TimeFieldStateContext.Provider>
|
|
250
329
|
);
|
|
251
330
|
}
|
|
252
331
|
|
|
253
|
-
// ============================================
|
|
254
|
-
// TIME INPUT COMPONENT
|
|
255
|
-
// ============================================
|
|
256
|
-
|
|
257
332
|
/**
|
|
258
333
|
* The input area containing time segments.
|
|
259
334
|
*/
|
|
@@ -261,20 +336,18 @@ export function TimeInput(props: TimeInputProps): JSX.Element {
|
|
|
261
336
|
const { state, aria } = useTimeFieldContextValue();
|
|
262
337
|
const [isFocused, setIsFocused] = createSignal(false);
|
|
263
338
|
|
|
264
|
-
// Render props values
|
|
265
339
|
const renderValues = createMemo<TimeInputRenderProps>(() => ({
|
|
266
340
|
isDisabled: state.isDisabled(),
|
|
267
341
|
isFocused: isFocused(),
|
|
268
342
|
}));
|
|
269
343
|
|
|
270
|
-
// Resolve render props
|
|
271
344
|
const renderProps = useRenderProps(
|
|
272
345
|
{
|
|
273
346
|
class: props.class,
|
|
274
347
|
style: props.style,
|
|
275
|
-
defaultClassName:
|
|
348
|
+
defaultClassName: "solidaria-TimeInput",
|
|
276
349
|
},
|
|
277
|
-
renderValues
|
|
350
|
+
renderValues,
|
|
278
351
|
);
|
|
279
352
|
|
|
280
353
|
return (
|
|
@@ -287,17 +360,11 @@ export function TimeInput(props: TimeInputProps): JSX.Element {
|
|
|
287
360
|
onFocusIn={() => setIsFocused(true)}
|
|
288
361
|
onFocusOut={() => setIsFocused(false)}
|
|
289
362
|
>
|
|
290
|
-
<For each={state.segments()}>
|
|
291
|
-
{(segment) => props.children?.(segment)}
|
|
292
|
-
</For>
|
|
363
|
+
<For each={state.segments()}>{(segment) => props.children?.(segment)}</For>
|
|
293
364
|
</div>
|
|
294
365
|
);
|
|
295
366
|
}
|
|
296
367
|
|
|
297
|
-
// ============================================
|
|
298
|
-
// TIME SEGMENT COMPONENT
|
|
299
|
-
// ============================================
|
|
300
|
-
|
|
301
368
|
/**
|
|
302
369
|
* A segment of a time field (hour, minute, second, AM/PM).
|
|
303
370
|
*/
|
|
@@ -308,10 +375,9 @@ export function TimeSegment(props: TimeSegmentProps): JSX.Element {
|
|
|
308
375
|
const segmentAria = createTimeSegment(
|
|
309
376
|
{ segment: props.segment },
|
|
310
377
|
state as unknown as TimeFieldState,
|
|
311
|
-
segmentRef
|
|
378
|
+
segmentRef,
|
|
312
379
|
);
|
|
313
380
|
|
|
314
|
-
// Render props values
|
|
315
381
|
const renderValues = createMemo<TimeSegmentRenderProps>(() => ({
|
|
316
382
|
isFocused: segmentAria.isFocused,
|
|
317
383
|
isEditable: segmentAria.isEditable,
|
|
@@ -320,20 +386,19 @@ export function TimeSegment(props: TimeSegmentProps): JSX.Element {
|
|
|
320
386
|
text: segmentAria.text,
|
|
321
387
|
}));
|
|
322
388
|
|
|
323
|
-
// Resolve render props
|
|
324
389
|
const renderProps = useRenderProps(
|
|
325
390
|
{
|
|
326
391
|
children: props.children,
|
|
327
392
|
class: props.class,
|
|
328
393
|
style: props.style,
|
|
329
|
-
defaultClassName:
|
|
394
|
+
defaultClassName: "solidaria-TimeSegment",
|
|
330
395
|
},
|
|
331
|
-
renderValues
|
|
396
|
+
renderValues,
|
|
332
397
|
);
|
|
333
398
|
|
|
334
399
|
// Determine children content - avoid Show for SSR hydration compatibility
|
|
335
400
|
const getChildren = () => {
|
|
336
|
-
if (typeof props.children ===
|
|
401
|
+
if (typeof props.children === "function") {
|
|
337
402
|
return renderProps.renderChildren();
|
|
338
403
|
}
|
|
339
404
|
return segmentAria.text;
|
|
@@ -355,10 +420,6 @@ export function TimeSegment(props: TimeSegmentProps): JSX.Element {
|
|
|
355
420
|
);
|
|
356
421
|
}
|
|
357
422
|
|
|
358
|
-
// ============================================
|
|
359
|
-
// LABEL / DESCRIPTION / ERROR
|
|
360
|
-
// ============================================
|
|
361
|
-
|
|
362
423
|
export interface TimeFieldLabelProps {
|
|
363
424
|
children?: JSX.Element;
|
|
364
425
|
class?: string;
|
|
@@ -401,5 +462,4 @@ export function TimeFieldErrorMessage(props: TimeFieldErrorMessageProps): JSX.El
|
|
|
401
462
|
);
|
|
402
463
|
}
|
|
403
464
|
|
|
404
|
-
// Re-export types
|
|
405
465
|
export type { TimeFieldState, TimeSegmentType, TimeValue };
|