@wirekyt/solid 0.0.1 → 0.0.3
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/dist/accordion.d.ts +68 -0
- package/dist/accordion.js +168 -0
- package/dist/accordion.jsx +143 -0
- package/dist/angle-slider.d.ts +72 -0
- package/dist/angle-slider.js +141 -0
- package/dist/angle-slider.jsx +130 -0
- package/dist/avatar.d.ts +47 -0
- package/dist/avatar.js +86 -0
- package/dist/avatar.jsx +79 -0
- package/dist/carousel.d.ts +92 -0
- package/dist/carousel.js +189 -0
- package/dist/carousel.jsx +174 -0
- package/dist/checkbox.d.ts +140 -0
- package/dist/checkbox.js +252 -0
- package/dist/checkbox.jsx +234 -0
- package/dist/client-only.d.ts +9 -0
- package/dist/client-only.js +22 -0
- package/dist/client-only.jsx +13 -0
- package/dist/clipboard.d.ts +70 -0
- package/dist/clipboard.js +137 -0
- package/dist/clipboard.jsx +120 -0
- package/dist/collapsible-BwNoH1At.jsx +106 -0
- package/dist/collapsible-Dp8aqjtN.js +118 -0
- package/dist/collapsible.d.ts +58 -0
- package/dist/collapsible.js +2 -0
- package/dist/collapsible.jsx +2 -0
- package/dist/collection-By8qgqkx.js +213 -0
- package/dist/collection-Mkvw6TyT.jsx +213 -0
- package/dist/collection.d.ts +2 -0
- package/dist/collection.js +2 -0
- package/dist/collection.jsx +2 -0
- package/dist/color-picker.d.ts +179 -0
- package/dist/color-picker.js +457 -0
- package/dist/color-picker.jsx +395 -0
- package/dist/combobox.d.ts +128 -0
- package/dist/combobox.js +326 -0
- package/dist/combobox.jsx +284 -0
- package/dist/core-7QKBNp9p.js +485 -0
- package/dist/core-7QKBNp9p.jsx +485 -0
- package/dist/date-input.d.ts +68 -0
- package/dist/date-input.js +178 -0
- package/dist/date-input.jsx +163 -0
- package/dist/date-picker.d.ts +191 -0
- package/dist/date-picker.js +506 -0
- package/dist/date-picker.jsx +430 -0
- package/dist/dialog.d.ts +77 -0
- package/dist/dialog.js +205 -0
- package/dist/dialog.jsx +159 -0
- package/dist/download-trigger.d.ts +22 -0
- package/dist/download-trigger.js +55 -0
- package/dist/download-trigger.jsx +51 -0
- package/dist/drawer.d.ts +114 -0
- package/dist/drawer.js +291 -0
- package/dist/drawer.jsx +237 -0
- package/dist/editable.d.ts +77 -0
- package/dist/editable.js +171 -0
- package/dist/editable.jsx +162 -0
- package/dist/factory-D2A7xdtl.js +34 -0
- package/dist/factory-DRw_slzE.jsx +34 -0
- package/dist/factory-wuwfJqbU.d.ts +15 -0
- package/dist/field-CQr_Dibp.js +317 -0
- package/dist/field-R5jVNdtK.jsx +282 -0
- package/dist/field.d.ts +194 -0
- package/dist/field.js +2 -0
- package/dist/field.jsx +2 -0
- package/dist/fieldset-5shfE0Z5.jsx +155 -0
- package/dist/fieldset-D5teGLZ9.js +170 -0
- package/dist/fieldset.d.ts +98 -0
- package/dist/fieldset.js +2 -0
- package/dist/fieldset.jsx +2 -0
- package/dist/file-upload.d.ts +100 -0
- package/dist/file-upload.js +254 -0
- package/dist/file-upload.jsx +232 -0
- package/dist/floating-panel.d.ts +97 -0
- package/dist/floating-panel.js +231 -0
- package/dist/floating-panel.jsx +199 -0
- package/dist/focus-trap.d.ts +12 -0
- package/dist/focus-trap.js +30 -0
- package/dist/focus-trap.jsx +26 -0
- package/dist/format.d.ts +32 -0
- package/dist/format.js +50 -0
- package/dist/format.jsx +53 -0
- package/dist/frame.d.ts +12 -0
- package/dist/frame.js +119 -0
- package/dist/frame.jsx +83 -0
- package/dist/image-cropper.d.ts +62 -0
- package/dist/image-cropper.js +137 -0
- package/dist/image-cropper.jsx +130 -0
- package/dist/index-B17eqq14.d.ts +32 -0
- package/dist/index-BZHmHI7d.d.ts +142 -0
- package/dist/index-CANuc1X0.d.ts +81 -0
- package/dist/index-CJwZCGOS.d.ts +75 -0
- package/dist/index-ClU-Lb8Z.d.ts +23 -0
- package/dist/index-J9N2CBHP.d.ts +21 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.jsx +5 -0
- package/dist/json-tree-view.d.ts +50 -0
- package/dist/json-tree-view.js +330 -0
- package/dist/json-tree-view.jsx +201 -0
- package/dist/listbox.d.ts +109 -0
- package/dist/listbox.js +237 -0
- package/dist/listbox.jsx +212 -0
- package/dist/marquee.d.ts +57 -0
- package/dist/marquee.js +125 -0
- package/dist/marquee.jsx +113 -0
- package/dist/menu.d.ts +158 -0
- package/dist/menu.js +441 -0
- package/dist/menu.jsx +362 -0
- package/dist/navigation-menu.d.ts +88 -0
- package/dist/navigation-menu.js +289 -0
- package/dist/navigation-menu.jsx +228 -0
- package/dist/number-input.d.ts +72 -0
- package/dist/number-input.js +166 -0
- package/dist/number-input.jsx +157 -0
- package/dist/pagination.d.ts +67 -0
- package/dist/pagination.js +131 -0
- package/dist/pagination.jsx +124 -0
- package/dist/password-input.d.ts +64 -0
- package/dist/password-input.js +144 -0
- package/dist/password-input.jsx +125 -0
- package/dist/pin-input.d.ts +57 -0
- package/dist/pin-input.js +138 -0
- package/dist/pin-input.jsx +129 -0
- package/dist/popover.d.ts +92 -0
- package/dist/popover.js +206 -0
- package/dist/popover.jsx +174 -0
- package/dist/presence-9UGkuyfn.jsx +59 -0
- package/dist/presence-CE6lXCu5.js +72 -0
- package/dist/presence.d.ts +2 -0
- package/dist/presence.js +2 -0
- package/dist/presence.jsx +2 -0
- package/dist/progress.d.ts +77 -0
- package/dist/progress.js +146 -0
- package/dist/progress.jsx +137 -0
- package/dist/providers-B-Vi5wQ7.js +124 -0
- package/dist/providers-CqNHqLpB.jsx +110 -0
- package/dist/qr-code.d.ts +57 -0
- package/dist/qr-code.js +111 -0
- package/dist/qr-code.jsx +104 -0
- package/dist/radio-group.d.ts +77 -0
- package/dist/radio-group.js +170 -0
- package/dist/radio-group.jsx +157 -0
- package/dist/rating-group.d.ts +67 -0
- package/dist/rating-group.js +142 -0
- package/dist/rating-group.jsx +131 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/rolldown-runtime-D7D4PA-g.jsx +13 -0
- package/dist/run-if-fn-CjvD7VzQ.js +5 -0
- package/dist/run-if-fn-CjvD7VzQ.jsx +5 -0
- package/dist/scroll-area.d.ts +61 -0
- package/dist/scroll-area.js +119 -0
- package/dist/scroll-area.jsx +109 -0
- package/dist/segment-group.d.ts +80 -0
- package/dist/segment-group.js +166 -0
- package/dist/segment-group.jsx +153 -0
- package/dist/select.d.ts +132 -0
- package/dist/select.js +337 -0
- package/dist/select.jsx +283 -0
- package/dist/signature-pad.d.ts +67 -0
- package/dist/signature-pad.js +159 -0
- package/dist/signature-pad.jsx +141 -0
- package/dist/slider.d.ts +87 -0
- package/dist/slider.js +191 -0
- package/dist/slider.jsx +179 -0
- package/dist/splitter.d.ts +57 -0
- package/dist/splitter.js +126 -0
- package/dist/splitter.jsx +116 -0
- package/dist/steps.d.ts +100 -0
- package/dist/steps.js +199 -0
- package/dist/steps.jsx +184 -0
- package/dist/swap.d.ts +51 -0
- package/dist/swap.js +123 -0
- package/dist/swap.jsx +106 -0
- package/dist/switch.d.ts +57 -0
- package/dist/switch.js +125 -0
- package/dist/switch.jsx +116 -0
- package/dist/tabs.d.ts +58 -0
- package/dist/tabs.js +146 -0
- package/dist/tabs.jsx +122 -0
- package/dist/tags-input.d.ts +97 -0
- package/dist/tags-input.js +228 -0
- package/dist/tags-input.jsx +213 -0
- package/dist/timer.d.ts +62 -0
- package/dist/timer.js +119 -0
- package/dist/timer.jsx +110 -0
- package/dist/toast.d.ts +60 -0
- package/dist/toast.js +120 -0
- package/dist/toast.jsx +106 -0
- package/dist/toggle-group.d.ts +42 -0
- package/dist/toggle-group.js +87 -0
- package/dist/toggle-group.jsx +80 -0
- package/dist/toggle.d.ts +38 -0
- package/dist/toggle.js +73 -0
- package/dist/toggle.jsx +61 -0
- package/dist/tooltip.d.ts +67 -0
- package/dist/tooltip.js +159 -0
- package/dist/tooltip.jsx +127 -0
- package/dist/tour.d.ts +112 -0
- package/dist/tour.js +256 -0
- package/dist/tour.jsx +192 -0
- package/dist/tree-view-ATyeBPXq.js +290 -0
- package/dist/tree-view-CoWx7osT.jsx +265 -0
- package/dist/tree-view.d.ts +3 -0
- package/dist/tree-view.js +3 -0
- package/dist/tree-view.jsx +3 -0
- package/package.json +324 -6
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { a as mergeProps$2, d as createContext$1, l as createSplitProps, u as composeRefs } from "./core-7QKBNp9p.js";
|
|
3
|
+
import { t as wire } from "./factory-D2A7xdtl.js";
|
|
4
|
+
import { l as useEnvironmentContext } from "./providers-B-Vi5wQ7.js";
|
|
5
|
+
import { u as useFieldsetContext } from "./fieldset-D5teGLZ9.js";
|
|
6
|
+
import { Show, createMemo, createSignal, createUniqueId, mergeProps, onCleanup, onMount, splitProps } from "solid-js";
|
|
7
|
+
import { createComponent, mergeProps as mergeProps$1 } from "solid-js/web";
|
|
8
|
+
import { ariaAttr, dataAttr } from "@wirekyt/dom/dom-query";
|
|
9
|
+
import { createAnatomy } from "@wirekyt/dom/anatomy";
|
|
10
|
+
import { autoresizeTextarea } from "@wirekyt/dom/auto-resize";
|
|
11
|
+
//#region src/components/field/use-context.ts
|
|
12
|
+
const [FieldProvider, useFieldContext] = createContext$1({
|
|
13
|
+
hookName: "useFieldContext",
|
|
14
|
+
providerName: "<FieldProvider />",
|
|
15
|
+
strict: false
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/components/field/context.tsx
|
|
19
|
+
const FieldContext = (props) => props.children(useFieldContext());
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/components/field/error-text.tsx
|
|
22
|
+
const FieldErrorText = (props) => {
|
|
23
|
+
const field = useFieldContext();
|
|
24
|
+
const mergedProps = mergeProps$2(() => field().getErrorTextProps(), props);
|
|
25
|
+
return createComponent(Show, {
|
|
26
|
+
get when() {
|
|
27
|
+
return field?.().invalid;
|
|
28
|
+
},
|
|
29
|
+
get children() {
|
|
30
|
+
return createComponent(wire.span, mergedProps);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/components/field/helper-text.tsx
|
|
36
|
+
const FieldHelperText = (props) => {
|
|
37
|
+
const field = useFieldContext();
|
|
38
|
+
const mergedProps = mergeProps$2(() => field().getHelperTextProps(), props);
|
|
39
|
+
return createComponent(wire.span, mergedProps);
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/components/field/input.tsx
|
|
43
|
+
const FieldInput = (props) => {
|
|
44
|
+
const field = useFieldContext();
|
|
45
|
+
const mergedProps = mergeProps$2(() => field?.().getInputProps(), props);
|
|
46
|
+
return createComponent(wire.input, mergedProps);
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/components/field/anatomy.ts
|
|
50
|
+
const fieldAnatomy = createAnatomy("field").parts("root", "errorText", "helperText", "input", "label", "select", "textarea", "requiredIndicator");
|
|
51
|
+
const parts = fieldAnatomy.build();
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/field/item.tsx
|
|
54
|
+
const FieldItem = (props) => {
|
|
55
|
+
const parentField = useFieldContext();
|
|
56
|
+
const itemField = createMemo(() => {
|
|
57
|
+
const parent = parentField?.();
|
|
58
|
+
if (!parent) throw new Error("Field.Item must be used within Field.Root");
|
|
59
|
+
const controlId = `field::${parent.ids.control}::item::${props.value}`;
|
|
60
|
+
const labelId = `${controlId}::label`;
|
|
61
|
+
const getControlProps = () => ({
|
|
62
|
+
...parent.getInputProps(),
|
|
63
|
+
id: controlId
|
|
64
|
+
});
|
|
65
|
+
return () => ({
|
|
66
|
+
...parent,
|
|
67
|
+
ids: {
|
|
68
|
+
...parent.ids,
|
|
69
|
+
control: controlId,
|
|
70
|
+
label: labelId
|
|
71
|
+
},
|
|
72
|
+
getLabelProps: () => ({
|
|
73
|
+
...parent.getLabelProps(),
|
|
74
|
+
id: labelId,
|
|
75
|
+
htmlFor: controlId
|
|
76
|
+
}),
|
|
77
|
+
getInputProps: () => ({
|
|
78
|
+
...getControlProps(),
|
|
79
|
+
...parts.input.attrs
|
|
80
|
+
}),
|
|
81
|
+
getSelectProps: () => ({
|
|
82
|
+
...getControlProps(),
|
|
83
|
+
...parts.select.attrs
|
|
84
|
+
}),
|
|
85
|
+
getTextareaProps: () => ({
|
|
86
|
+
...getControlProps(),
|
|
87
|
+
...parts.textarea.attrs
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
return createComponent(FieldProvider, {
|
|
92
|
+
get value() {
|
|
93
|
+
return itemField();
|
|
94
|
+
},
|
|
95
|
+
get children() {
|
|
96
|
+
return props.children;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/components/field/label.tsx
|
|
102
|
+
const FieldLabel = (props) => {
|
|
103
|
+
const field = useFieldContext();
|
|
104
|
+
const mergedProps = mergeProps$2(() => field?.().getLabelProps(), props);
|
|
105
|
+
return createComponent(wire.label, mergedProps);
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/components/field/required-indicator.tsx
|
|
109
|
+
const FieldRequiredIndicator = (props) => {
|
|
110
|
+
const field = useFieldContext();
|
|
111
|
+
const mergedProps = mergeProps$2(() => field().getRequiredIndicatorProps(), props);
|
|
112
|
+
return createComponent(Show, {
|
|
113
|
+
get when() {
|
|
114
|
+
return field().required;
|
|
115
|
+
},
|
|
116
|
+
get fallback() {
|
|
117
|
+
return props.fallback;
|
|
118
|
+
},
|
|
119
|
+
get children() {
|
|
120
|
+
return createComponent(wire.span, mergeProps$1(mergedProps, { get children() {
|
|
121
|
+
return props.children ?? "*";
|
|
122
|
+
} }));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/components/field/use.ts
|
|
128
|
+
const useField = (props) => {
|
|
129
|
+
const fieldset = useFieldsetContext();
|
|
130
|
+
const env = useEnvironmentContext();
|
|
131
|
+
const fieldProps = mergeProps({
|
|
132
|
+
disabled: Boolean(fieldset?.().disabled),
|
|
133
|
+
required: false,
|
|
134
|
+
invalid: false,
|
|
135
|
+
readOnly: false
|
|
136
|
+
}, props);
|
|
137
|
+
const [hasErrorText, setHasErrorText] = createSignal(false);
|
|
138
|
+
const [hasHelperText, setHasHelperText] = createSignal(false);
|
|
139
|
+
const id = fieldProps.id ?? createUniqueId();
|
|
140
|
+
const [rootRef, setRootRef] = createSignal(void 0);
|
|
141
|
+
const rootId = fieldProps.ids?.control ?? `field::${id}`;
|
|
142
|
+
const errorTextId = fieldProps.ids?.errorText ?? `field::${id}::error-text`;
|
|
143
|
+
const helperTextId = fieldProps.ids?.helperText ?? `field::${id}::helper-text`;
|
|
144
|
+
const labelId = fieldProps.ids?.label ?? `field::${id}::label`;
|
|
145
|
+
onMount(() => {
|
|
146
|
+
const rootNode = rootRef();
|
|
147
|
+
if (!rootNode) return;
|
|
148
|
+
const checkTextElements = () => {
|
|
149
|
+
const docOrShadowRoot = env().getRootNode();
|
|
150
|
+
setHasErrorText(!!docOrShadowRoot.getElementById(errorTextId));
|
|
151
|
+
setHasHelperText(!!docOrShadowRoot.getElementById(helperTextId));
|
|
152
|
+
};
|
|
153
|
+
checkTextElements();
|
|
154
|
+
const observer = new (env().getWindow()).MutationObserver(checkTextElements);
|
|
155
|
+
observer.observe(rootNode, {
|
|
156
|
+
childList: true,
|
|
157
|
+
subtree: true
|
|
158
|
+
});
|
|
159
|
+
onCleanup(() => observer.disconnect());
|
|
160
|
+
});
|
|
161
|
+
const getRootProps = () => ({
|
|
162
|
+
...parts.root.attrs,
|
|
163
|
+
id: rootId,
|
|
164
|
+
role: "group",
|
|
165
|
+
"data-disabled": dataAttr(fieldProps.disabled),
|
|
166
|
+
"data-invalid": dataAttr(fieldProps.invalid),
|
|
167
|
+
"data-readonly": dataAttr(fieldProps.readOnly)
|
|
168
|
+
});
|
|
169
|
+
const targetControlId = fieldProps.target ? `field::${id}::item::${fieldProps.target}` : void 0;
|
|
170
|
+
const getLabelProps = () => ({
|
|
171
|
+
...parts.label.attrs,
|
|
172
|
+
id: labelId,
|
|
173
|
+
"data-disabled": dataAttr(fieldProps.disabled),
|
|
174
|
+
"data-invalid": dataAttr(fieldProps.invalid),
|
|
175
|
+
"data-readonly": dataAttr(fieldProps.readOnly),
|
|
176
|
+
"data-required": dataAttr(fieldProps.required),
|
|
177
|
+
htmlFor: targetControlId ?? id
|
|
178
|
+
});
|
|
179
|
+
const errorMessageId = createMemo(() => hasErrorText() && fieldProps.invalid ? errorTextId : void 0);
|
|
180
|
+
const getControlProps = () => ({
|
|
181
|
+
"aria-describedby": hasHelperText() ? helperTextId : void 0,
|
|
182
|
+
"aria-errormessage": errorMessageId(),
|
|
183
|
+
"aria-invalid": ariaAttr(fieldProps.invalid),
|
|
184
|
+
"data-invalid": dataAttr(fieldProps.invalid),
|
|
185
|
+
"data-required": dataAttr(fieldProps.required),
|
|
186
|
+
"data-readonly": dataAttr(fieldProps.readOnly),
|
|
187
|
+
id,
|
|
188
|
+
required: fieldProps.required,
|
|
189
|
+
disabled: fieldProps.disabled,
|
|
190
|
+
readOnly: fieldProps.readOnly || void 0
|
|
191
|
+
});
|
|
192
|
+
const getInputProps = () => ({
|
|
193
|
+
...getControlProps(),
|
|
194
|
+
...parts.input.attrs
|
|
195
|
+
});
|
|
196
|
+
const getTextareaProps = () => ({
|
|
197
|
+
...getControlProps(),
|
|
198
|
+
...parts.textarea.attrs
|
|
199
|
+
});
|
|
200
|
+
const getSelectProps = () => ({
|
|
201
|
+
...getControlProps(),
|
|
202
|
+
...parts.select.attrs
|
|
203
|
+
});
|
|
204
|
+
const getHelperTextProps = () => ({
|
|
205
|
+
id: helperTextId,
|
|
206
|
+
...parts.helperText.attrs,
|
|
207
|
+
"data-disabled": dataAttr(fieldProps.disabled)
|
|
208
|
+
});
|
|
209
|
+
const getErrorTextProps = () => ({
|
|
210
|
+
id: errorTextId,
|
|
211
|
+
...parts.errorText.attrs,
|
|
212
|
+
"aria-live": "polite"
|
|
213
|
+
});
|
|
214
|
+
const getRequiredIndicatorProps = () => ({
|
|
215
|
+
"aria-hidden": true,
|
|
216
|
+
...parts.requiredIndicator.attrs
|
|
217
|
+
});
|
|
218
|
+
return createMemo(() => ({
|
|
219
|
+
ariaDescribedby: hasHelperText() ? helperTextId : void 0,
|
|
220
|
+
ids: {
|
|
221
|
+
control: id,
|
|
222
|
+
label: labelId,
|
|
223
|
+
errorText: errorTextId,
|
|
224
|
+
helperText: helperTextId
|
|
225
|
+
},
|
|
226
|
+
refs: { rootRef: setRootRef },
|
|
227
|
+
disabled: fieldProps.disabled,
|
|
228
|
+
invalid: fieldProps.invalid,
|
|
229
|
+
readOnly: fieldProps.readOnly,
|
|
230
|
+
required: fieldProps.required,
|
|
231
|
+
getLabelProps,
|
|
232
|
+
getRootProps,
|
|
233
|
+
getInputProps,
|
|
234
|
+
getTextareaProps,
|
|
235
|
+
getSelectProps,
|
|
236
|
+
getHelperTextProps,
|
|
237
|
+
getErrorTextProps,
|
|
238
|
+
getRequiredIndicatorProps
|
|
239
|
+
}));
|
|
240
|
+
};
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/components/field/root.tsx
|
|
243
|
+
const FieldRoot = (props) => {
|
|
244
|
+
const [useFieldProps, localProps] = createSplitProps()(props, [
|
|
245
|
+
"id",
|
|
246
|
+
"ids",
|
|
247
|
+
"disabled",
|
|
248
|
+
"invalid",
|
|
249
|
+
"readOnly",
|
|
250
|
+
"required",
|
|
251
|
+
"target"
|
|
252
|
+
]);
|
|
253
|
+
const field = useField(useFieldProps);
|
|
254
|
+
const mergedProps = mergeProps$2(() => field().getRootProps(), localProps);
|
|
255
|
+
return createComponent(FieldProvider, {
|
|
256
|
+
value: field,
|
|
257
|
+
get children() {
|
|
258
|
+
return createComponent(wire.div, mergeProps$1(mergedProps, { ref(r$) {
|
|
259
|
+
var _ref$ = composeRefs(field().refs.rootRef, props.ref);
|
|
260
|
+
typeof _ref$ === "function" && _ref$(r$);
|
|
261
|
+
} }));
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/components/field/root-provider.tsx
|
|
267
|
+
const FieldRootProvider = (props) => {
|
|
268
|
+
const [{ value: field }, localProps] = createSplitProps()(props, ["value"]);
|
|
269
|
+
const mergedProps = mergeProps$2(() => field().getRootProps(), localProps);
|
|
270
|
+
return createComponent(FieldProvider, {
|
|
271
|
+
value: field,
|
|
272
|
+
get children() {
|
|
273
|
+
return createComponent(wire.div, mergedProps);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/components/field/select.tsx
|
|
279
|
+
const FieldSelect = (props) => {
|
|
280
|
+
const field = useFieldContext();
|
|
281
|
+
const mergedProps = mergeProps$2(() => field?.().getSelectProps(), props);
|
|
282
|
+
return createComponent(wire.select, mergedProps);
|
|
283
|
+
};
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/components/field/textarea.tsx
|
|
286
|
+
const FieldTextarea = (props) => {
|
|
287
|
+
const field = useFieldContext();
|
|
288
|
+
let textareaRef;
|
|
289
|
+
const [autoresizeProps, textareaProps] = splitProps(props, ["autoresize"]);
|
|
290
|
+
const mergedProps = mergeProps$2(() => field?.().getTextareaProps(), () => ({ style: { resize: autoresizeProps.autoresize ? "none" : void 0 } }), textareaProps);
|
|
291
|
+
onMount(() => {
|
|
292
|
+
if (!autoresizeProps.autoresize) return;
|
|
293
|
+
const cleanup = autoresizeTextarea(textareaRef);
|
|
294
|
+
onCleanup(() => cleanup?.());
|
|
295
|
+
});
|
|
296
|
+
return createComponent(wire.textarea, mergeProps$1(mergedProps, { ref(r$) {
|
|
297
|
+
var _ref$ = composeRefs((el) => textareaRef = el, props.ref);
|
|
298
|
+
typeof _ref$ === "function" && _ref$(r$);
|
|
299
|
+
} }));
|
|
300
|
+
};
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/components/field/field.ts
|
|
303
|
+
var field_exports = /* @__PURE__ */ __exportAll({
|
|
304
|
+
Context: () => FieldContext,
|
|
305
|
+
ErrorText: () => FieldErrorText,
|
|
306
|
+
HelperText: () => FieldHelperText,
|
|
307
|
+
Input: () => FieldInput,
|
|
308
|
+
Item: () => FieldItem,
|
|
309
|
+
Label: () => FieldLabel,
|
|
310
|
+
RequiredIndicator: () => FieldRequiredIndicator,
|
|
311
|
+
Root: () => FieldRoot,
|
|
312
|
+
RootProvider: () => FieldRootProvider,
|
|
313
|
+
Select: () => FieldSelect,
|
|
314
|
+
Textarea: () => FieldTextarea
|
|
315
|
+
});
|
|
316
|
+
//#endregion
|
|
317
|
+
export { FieldRoot as a, FieldLabel as c, FieldInput as d, FieldHelperText as f, useFieldContext as h, FieldRootProvider as i, FieldItem as l, FieldContext as m, FieldTextarea as n, useField as o, FieldErrorText as p, FieldSelect as r, FieldRequiredIndicator as s, field_exports as t, fieldAnatomy as u };
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.jsx";
|
|
2
|
+
import { a as mergeProps$1, d as createContext$1, l as createSplitProps, u as composeRefs } from "./core-7QKBNp9p.jsx";
|
|
3
|
+
import { t as wire } from "./factory-DRw_slzE.jsx";
|
|
4
|
+
import { l as useEnvironmentContext } from "./providers-CqNHqLpB.jsx";
|
|
5
|
+
import { u as useFieldsetContext } from "./fieldset-5shfE0Z5.jsx";
|
|
6
|
+
import { Show, createMemo, createSignal, createUniqueId, mergeProps, onCleanup, onMount, splitProps } from "solid-js";
|
|
7
|
+
import { ariaAttr, dataAttr } from "@wirekyt/dom/dom-query";
|
|
8
|
+
import { createAnatomy } from "@wirekyt/dom/anatomy";
|
|
9
|
+
import { autoresizeTextarea } from "@wirekyt/dom/auto-resize";
|
|
10
|
+
//#region src/components/field/use-context.ts
|
|
11
|
+
const [FieldProvider, useFieldContext] = createContext$1({
|
|
12
|
+
hookName: "useFieldContext",
|
|
13
|
+
providerName: "<FieldProvider />",
|
|
14
|
+
strict: false
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/components/field/context.tsx
|
|
18
|
+
const FieldContext = (props) => props.children(useFieldContext());
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/components/field/error-text.tsx
|
|
21
|
+
const FieldErrorText = (props) => {
|
|
22
|
+
const field = useFieldContext();
|
|
23
|
+
const mergedProps = mergeProps$1(() => field().getErrorTextProps(), props);
|
|
24
|
+
return <Show when={field?.().invalid}>
|
|
25
|
+
<wire.span {...mergedProps} />
|
|
26
|
+
</Show>;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/components/field/helper-text.tsx
|
|
30
|
+
const FieldHelperText = (props) => {
|
|
31
|
+
const field = useFieldContext();
|
|
32
|
+
const mergedProps = mergeProps$1(() => field().getHelperTextProps(), props);
|
|
33
|
+
return <wire.span {...mergedProps} />;
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/components/field/input.tsx
|
|
37
|
+
const FieldInput = (props) => {
|
|
38
|
+
const field = useFieldContext();
|
|
39
|
+
const mergedProps = mergeProps$1(() => field?.().getInputProps(), props);
|
|
40
|
+
return <wire.input {...mergedProps} />;
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/components/field/anatomy.ts
|
|
44
|
+
const fieldAnatomy = createAnatomy("field").parts("root", "errorText", "helperText", "input", "label", "select", "textarea", "requiredIndicator");
|
|
45
|
+
const parts = fieldAnatomy.build();
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/components/field/item.tsx
|
|
48
|
+
const FieldItem = (props) => {
|
|
49
|
+
const parentField = useFieldContext();
|
|
50
|
+
const itemField = createMemo(() => {
|
|
51
|
+
const parent = parentField?.();
|
|
52
|
+
if (!parent) throw new Error("Field.Item must be used within Field.Root");
|
|
53
|
+
const controlId = `field::${parent.ids.control}::item::${props.value}`;
|
|
54
|
+
const labelId = `${controlId}::label`;
|
|
55
|
+
const getControlProps = () => ({
|
|
56
|
+
...parent.getInputProps(),
|
|
57
|
+
id: controlId
|
|
58
|
+
});
|
|
59
|
+
return (() => ({
|
|
60
|
+
...parent,
|
|
61
|
+
ids: {
|
|
62
|
+
...parent.ids,
|
|
63
|
+
control: controlId,
|
|
64
|
+
label: labelId
|
|
65
|
+
},
|
|
66
|
+
getLabelProps: () => ({
|
|
67
|
+
...parent.getLabelProps(),
|
|
68
|
+
id: labelId,
|
|
69
|
+
htmlFor: controlId
|
|
70
|
+
}),
|
|
71
|
+
getInputProps: () => ({
|
|
72
|
+
...getControlProps(),
|
|
73
|
+
...parts.input.attrs
|
|
74
|
+
}),
|
|
75
|
+
getSelectProps: () => ({
|
|
76
|
+
...getControlProps(),
|
|
77
|
+
...parts.select.attrs
|
|
78
|
+
}),
|
|
79
|
+
getTextareaProps: () => ({
|
|
80
|
+
...getControlProps(),
|
|
81
|
+
...parts.textarea.attrs
|
|
82
|
+
})
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
return <FieldProvider value={itemField()}>{props.children}</FieldProvider>;
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/components/field/label.tsx
|
|
89
|
+
const FieldLabel = (props) => {
|
|
90
|
+
const field = useFieldContext();
|
|
91
|
+
const mergedProps = mergeProps$1(() => field?.().getLabelProps(), props);
|
|
92
|
+
return <wire.label {...mergedProps} />;
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/components/field/required-indicator.tsx
|
|
96
|
+
const FieldRequiredIndicator = (props) => {
|
|
97
|
+
const field = useFieldContext();
|
|
98
|
+
const mergedProps = mergeProps$1(() => field().getRequiredIndicatorProps(), props);
|
|
99
|
+
return <Show when={field().required} fallback={props.fallback}>
|
|
100
|
+
<wire.span {...mergedProps}>{props.children ?? "*"}</wire.span>
|
|
101
|
+
</Show>;
|
|
102
|
+
};
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/components/field/use.ts
|
|
105
|
+
const useField = (props) => {
|
|
106
|
+
const fieldset = useFieldsetContext();
|
|
107
|
+
const env = useEnvironmentContext();
|
|
108
|
+
const fieldProps = mergeProps({
|
|
109
|
+
disabled: Boolean(fieldset?.().disabled),
|
|
110
|
+
required: false,
|
|
111
|
+
invalid: false,
|
|
112
|
+
readOnly: false
|
|
113
|
+
}, props);
|
|
114
|
+
const [hasErrorText, setHasErrorText] = createSignal(false);
|
|
115
|
+
const [hasHelperText, setHasHelperText] = createSignal(false);
|
|
116
|
+
const id = fieldProps.id ?? createUniqueId();
|
|
117
|
+
const [rootRef, setRootRef] = createSignal(void 0);
|
|
118
|
+
const rootId = fieldProps.ids?.control ?? `field::${id}`;
|
|
119
|
+
const errorTextId = fieldProps.ids?.errorText ?? `field::${id}::error-text`;
|
|
120
|
+
const helperTextId = fieldProps.ids?.helperText ?? `field::${id}::helper-text`;
|
|
121
|
+
const labelId = fieldProps.ids?.label ?? `field::${id}::label`;
|
|
122
|
+
onMount(() => {
|
|
123
|
+
const rootNode = rootRef();
|
|
124
|
+
if (!rootNode) return;
|
|
125
|
+
const checkTextElements = () => {
|
|
126
|
+
const docOrShadowRoot = env().getRootNode();
|
|
127
|
+
setHasErrorText(!!docOrShadowRoot.getElementById(errorTextId));
|
|
128
|
+
setHasHelperText(!!docOrShadowRoot.getElementById(helperTextId));
|
|
129
|
+
};
|
|
130
|
+
checkTextElements();
|
|
131
|
+
const observer = new (env().getWindow()).MutationObserver(checkTextElements);
|
|
132
|
+
observer.observe(rootNode, {
|
|
133
|
+
childList: true,
|
|
134
|
+
subtree: true
|
|
135
|
+
});
|
|
136
|
+
onCleanup(() => observer.disconnect());
|
|
137
|
+
});
|
|
138
|
+
const getRootProps = () => ({
|
|
139
|
+
...parts.root.attrs,
|
|
140
|
+
id: rootId,
|
|
141
|
+
role: "group",
|
|
142
|
+
"data-disabled": dataAttr(fieldProps.disabled),
|
|
143
|
+
"data-invalid": dataAttr(fieldProps.invalid),
|
|
144
|
+
"data-readonly": dataAttr(fieldProps.readOnly)
|
|
145
|
+
});
|
|
146
|
+
const targetControlId = fieldProps.target ? `field::${id}::item::${fieldProps.target}` : void 0;
|
|
147
|
+
const getLabelProps = () => ({
|
|
148
|
+
...parts.label.attrs,
|
|
149
|
+
id: labelId,
|
|
150
|
+
"data-disabled": dataAttr(fieldProps.disabled),
|
|
151
|
+
"data-invalid": dataAttr(fieldProps.invalid),
|
|
152
|
+
"data-readonly": dataAttr(fieldProps.readOnly),
|
|
153
|
+
"data-required": dataAttr(fieldProps.required),
|
|
154
|
+
htmlFor: targetControlId ?? id
|
|
155
|
+
});
|
|
156
|
+
const errorMessageId = createMemo(() => hasErrorText() && fieldProps.invalid ? errorTextId : void 0);
|
|
157
|
+
const getControlProps = () => ({
|
|
158
|
+
"aria-describedby": hasHelperText() ? helperTextId : void 0,
|
|
159
|
+
"aria-errormessage": errorMessageId(),
|
|
160
|
+
"aria-invalid": ariaAttr(fieldProps.invalid),
|
|
161
|
+
"data-invalid": dataAttr(fieldProps.invalid),
|
|
162
|
+
"data-required": dataAttr(fieldProps.required),
|
|
163
|
+
"data-readonly": dataAttr(fieldProps.readOnly),
|
|
164
|
+
id,
|
|
165
|
+
required: fieldProps.required,
|
|
166
|
+
disabled: fieldProps.disabled,
|
|
167
|
+
readOnly: fieldProps.readOnly || void 0
|
|
168
|
+
});
|
|
169
|
+
const getInputProps = () => ({
|
|
170
|
+
...getControlProps(),
|
|
171
|
+
...parts.input.attrs
|
|
172
|
+
});
|
|
173
|
+
const getTextareaProps = () => ({
|
|
174
|
+
...getControlProps(),
|
|
175
|
+
...parts.textarea.attrs
|
|
176
|
+
});
|
|
177
|
+
const getSelectProps = () => ({
|
|
178
|
+
...getControlProps(),
|
|
179
|
+
...parts.select.attrs
|
|
180
|
+
});
|
|
181
|
+
const getHelperTextProps = () => ({
|
|
182
|
+
id: helperTextId,
|
|
183
|
+
...parts.helperText.attrs,
|
|
184
|
+
"data-disabled": dataAttr(fieldProps.disabled)
|
|
185
|
+
});
|
|
186
|
+
const getErrorTextProps = () => ({
|
|
187
|
+
id: errorTextId,
|
|
188
|
+
...parts.errorText.attrs,
|
|
189
|
+
"aria-live": "polite"
|
|
190
|
+
});
|
|
191
|
+
const getRequiredIndicatorProps = () => ({
|
|
192
|
+
"aria-hidden": true,
|
|
193
|
+
...parts.requiredIndicator.attrs
|
|
194
|
+
});
|
|
195
|
+
return createMemo(() => ({
|
|
196
|
+
ariaDescribedby: hasHelperText() ? helperTextId : void 0,
|
|
197
|
+
ids: {
|
|
198
|
+
control: id,
|
|
199
|
+
label: labelId,
|
|
200
|
+
errorText: errorTextId,
|
|
201
|
+
helperText: helperTextId
|
|
202
|
+
},
|
|
203
|
+
refs: { rootRef: setRootRef },
|
|
204
|
+
disabled: fieldProps.disabled,
|
|
205
|
+
invalid: fieldProps.invalid,
|
|
206
|
+
readOnly: fieldProps.readOnly,
|
|
207
|
+
required: fieldProps.required,
|
|
208
|
+
getLabelProps,
|
|
209
|
+
getRootProps,
|
|
210
|
+
getInputProps,
|
|
211
|
+
getTextareaProps,
|
|
212
|
+
getSelectProps,
|
|
213
|
+
getHelperTextProps,
|
|
214
|
+
getErrorTextProps,
|
|
215
|
+
getRequiredIndicatorProps
|
|
216
|
+
}));
|
|
217
|
+
};
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/components/field/root.tsx
|
|
220
|
+
const FieldRoot = (props) => {
|
|
221
|
+
const [useFieldProps, localProps] = createSplitProps()(props, [
|
|
222
|
+
"id",
|
|
223
|
+
"ids",
|
|
224
|
+
"disabled",
|
|
225
|
+
"invalid",
|
|
226
|
+
"readOnly",
|
|
227
|
+
"required",
|
|
228
|
+
"target"
|
|
229
|
+
]);
|
|
230
|
+
const field = useField(useFieldProps);
|
|
231
|
+
const mergedProps = mergeProps$1(() => field().getRootProps(), localProps);
|
|
232
|
+
return <FieldProvider value={field}>
|
|
233
|
+
<wire.div {...mergedProps} ref={composeRefs(field().refs.rootRef, props.ref)} />
|
|
234
|
+
</FieldProvider>;
|
|
235
|
+
};
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/components/field/root-provider.tsx
|
|
238
|
+
const FieldRootProvider = (props) => {
|
|
239
|
+
const [{ value: field }, localProps] = createSplitProps()(props, ["value"]);
|
|
240
|
+
const mergedProps = mergeProps$1(() => field().getRootProps(), localProps);
|
|
241
|
+
return <FieldProvider value={field}>
|
|
242
|
+
<wire.div {...mergedProps} />
|
|
243
|
+
</FieldProvider>;
|
|
244
|
+
};
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/components/field/select.tsx
|
|
247
|
+
const FieldSelect = (props) => {
|
|
248
|
+
const field = useFieldContext();
|
|
249
|
+
const mergedProps = mergeProps$1(() => field?.().getSelectProps(), props);
|
|
250
|
+
return <wire.select {...mergedProps} />;
|
|
251
|
+
};
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/components/field/textarea.tsx
|
|
254
|
+
const FieldTextarea = (props) => {
|
|
255
|
+
const field = useFieldContext();
|
|
256
|
+
let textareaRef;
|
|
257
|
+
const [autoresizeProps, textareaProps] = splitProps(props, ["autoresize"]);
|
|
258
|
+
const mergedProps = mergeProps$1(() => field?.().getTextareaProps(), () => ({ style: { resize: autoresizeProps.autoresize ? "none" : void 0 } }), textareaProps);
|
|
259
|
+
onMount(() => {
|
|
260
|
+
if (!autoresizeProps.autoresize) return;
|
|
261
|
+
const cleanup = autoresizeTextarea(textareaRef);
|
|
262
|
+
onCleanup(() => cleanup?.());
|
|
263
|
+
});
|
|
264
|
+
return <wire.textarea {...mergedProps} ref={composeRefs((el) => textareaRef = el, props.ref)} />;
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/components/field/field.ts
|
|
268
|
+
var field_exports = /* @__PURE__ */ __exportAll({
|
|
269
|
+
Context: () => FieldContext,
|
|
270
|
+
ErrorText: () => FieldErrorText,
|
|
271
|
+
HelperText: () => FieldHelperText,
|
|
272
|
+
Input: () => FieldInput,
|
|
273
|
+
Item: () => FieldItem,
|
|
274
|
+
Label: () => FieldLabel,
|
|
275
|
+
RequiredIndicator: () => FieldRequiredIndicator,
|
|
276
|
+
Root: () => FieldRoot,
|
|
277
|
+
RootProvider: () => FieldRootProvider,
|
|
278
|
+
Select: () => FieldSelect,
|
|
279
|
+
Textarea: () => FieldTextarea
|
|
280
|
+
});
|
|
281
|
+
//#endregion
|
|
282
|
+
export { FieldRoot as a, FieldLabel as c, FieldInput as d, FieldHelperText as f, useFieldContext as h, FieldRootProvider as i, FieldItem as l, FieldContext as m, FieldTextarea as n, useField as o, FieldErrorText as p, FieldSelect as r, FieldRequiredIndicator as s, field_exports as t, fieldAnatomy as u };
|