@wirekyt/react 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.cjs +209 -0
- package/dist/accordion.d.cts +69 -0
- package/dist/accordion.d.ts +69 -0
- package/dist/accordion.js +184 -0
- package/dist/angle-slider.cjs +193 -0
- package/dist/angle-slider.d.cts +73 -0
- package/dist/angle-slider.d.ts +73 -0
- package/dist/angle-slider.js +168 -0
- package/dist/avatar.cjs +120 -0
- package/dist/avatar.d.cts +48 -0
- package/dist/avatar.d.ts +48 -0
- package/dist/avatar.js +100 -0
- package/dist/carousel.cjs +246 -0
- package/dist/carousel.d.cts +94 -0
- package/dist/carousel.d.ts +94 -0
- package/dist/carousel.js +223 -0
- package/dist/checkbox.cjs +284 -0
- package/dist/checkbox.d.cts +115 -0
- package/dist/checkbox.d.ts +115 -0
- package/dist/checkbox.js +263 -0
- package/dist/client-only.cjs +12 -0
- package/dist/client-only.d.cts +8 -0
- package/dist/client-only.d.ts +8 -0
- package/dist/client-only.js +11 -0
- package/dist/clipboard.cjs +174 -0
- package/dist/clipboard.d.cts +70 -0
- package/dist/clipboard.d.ts +70 -0
- package/dist/clipboard.js +150 -0
- package/dist/collapsible-B62i_oPJ.cjs +185 -0
- package/dist/collapsible-CiTNjCNf.js +131 -0
- package/dist/collapsible.cjs +23 -0
- package/dist/collapsible.d.cts +56 -0
- package/dist/collapsible.d.ts +56 -0
- package/dist/collapsible.js +2 -0
- package/dist/collection-BFjWNdUS.cjs +223 -0
- package/dist/collection-BJOl6a4H.js +180 -0
- package/dist/collection.cjs +9 -0
- package/dist/collection.d.cts +2 -0
- package/dist/collection.d.ts +2 -0
- package/dist/collection.js +2 -0
- package/dist/color-picker.cjs +575 -0
- package/dist/color-picker.d.cts +179 -0
- package/dist/color-picker.d.ts +179 -0
- package/dist/color-picker.js +530 -0
- package/dist/combobox.cjs +390 -0
- package/dist/combobox.d.cts +128 -0
- package/dist/combobox.d.ts +128 -0
- package/dist/combobox.js +359 -0
- package/dist/core-CBFAnVIP.cjs +375 -0
- package/dist/core-CEYOEcVI.js +357 -0
- package/dist/date-input.cjs +217 -0
- package/dist/date-input.d.cts +69 -0
- package/dist/date-input.d.ts +69 -0
- package/dist/date-input.js +193 -0
- package/dist/date-picker.cjs +588 -0
- package/dist/date-picker.d.cts +190 -0
- package/dist/date-picker.d.ts +190 -0
- package/dist/date-picker.js +543 -0
- package/dist/dialog.cjs +199 -0
- package/dist/dialog.d.cts +78 -0
- package/dist/dialog.d.ts +78 -0
- package/dist/dialog.js +174 -0
- package/dist/download-trigger.cjs +53 -0
- package/dist/download-trigger.d.cts +22 -0
- package/dist/download-trigger.d.ts +22 -0
- package/dist/download-trigger.js +51 -0
- package/dist/drawer.cjs +296 -0
- package/dist/drawer.d.cts +115 -0
- package/dist/drawer.d.ts +115 -0
- package/dist/drawer.js +264 -0
- package/dist/editable.cjs +228 -0
- package/dist/editable.d.cts +79 -0
- package/dist/editable.d.ts +79 -0
- package/dist/editable.js +202 -0
- package/dist/environment-B6IaCAuQ.cjs +59 -0
- package/dist/environment-BTgKwk5E.js +42 -0
- package/dist/factory--dkoVnFK.d.cts +14 -0
- package/dist/factory--dkoVnFK.d.ts +14 -0
- package/dist/factory-CFFufs5e.cjs +59 -0
- package/dist/factory-Nm__-4xn.js +48 -0
- package/dist/field-Cy1E02DH.js +349 -0
- package/dist/field-x8H5uXB9.cjs +438 -0
- package/dist/field.cjs +22 -0
- package/dist/field.d.cts +129 -0
- package/dist/field.d.ts +129 -0
- package/dist/field.js +2 -0
- package/dist/fieldset-DWZXj1t5.cjs +232 -0
- package/dist/fieldset-fx44GCtM.js +178 -0
- package/dist/fieldset.cjs +18 -0
- package/dist/fieldset.d.cts +71 -0
- package/dist/fieldset.d.ts +71 -0
- package/dist/fieldset.js +3 -0
- package/dist/file-upload.cjs +328 -0
- package/dist/file-upload.d.cts +101 -0
- package/dist/file-upload.d.ts +101 -0
- package/dist/file-upload.js +298 -0
- package/dist/floating-panel.cjs +271 -0
- package/dist/floating-panel.d.cts +98 -0
- package/dist/floating-panel.d.ts +98 -0
- package/dist/floating-panel.js +242 -0
- package/dist/format.cjs +64 -0
- package/dist/format.d.cts +44 -0
- package/dist/format.d.ts +44 -0
- package/dist/format.js +54 -0
- package/dist/frame.cjs +85 -0
- package/dist/frame.d.cts +12 -0
- package/dist/frame.d.ts +12 -0
- package/dist/frame.js +84 -0
- package/dist/highlight.cjs +29 -0
- package/dist/highlight.d.cts +13 -0
- package/dist/highlight.d.ts +13 -0
- package/dist/highlight.js +27 -0
- package/dist/hover-card.cjs +154 -0
- package/dist/hover-card.d.cts +68 -0
- package/dist/hover-card.d.ts +68 -0
- package/dist/hover-card.js +131 -0
- package/dist/image-cropper.cjs +0 -0
- package/dist/image-cropper.d.cts +1 -0
- package/dist/image-cropper.d.ts +1 -0
- package/dist/image-cropper.js +0 -0
- package/dist/index-3Al0R5bH.d.cts +73 -0
- package/dist/index-B7wAg5Wf.d.ts +146 -0
- package/dist/index-BAn8qiCM.d.ts +73 -0
- package/dist/index-BSX88T_g.d.cts +146 -0
- package/dist/index-CQAbOgb7.d.cts +23 -0
- package/dist/index-CW-Aj6aT.d.ts +95 -0
- package/dist/index-CxWYgVJk.d.ts +23 -0
- package/dist/index-DRnET7mJ.d.ts +33 -0
- package/dist/index-DTLK6Fuh.d.cts +95 -0
- package/dist/index-DyTY8HEb.d.cts +33 -0
- package/dist/index-srZfUQNt.d.cts +20 -0
- package/dist/index-srZfUQNt.d.ts +20 -0
- package/dist/index.cjs +45 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/json-tree-view.cjs +244 -0
- package/dist/json-tree-view.d.cts +45 -0
- package/dist/json-tree-view.d.ts +45 -0
- package/dist/json-tree-view.js +234 -0
- package/dist/listbox.cjs +290 -0
- package/dist/listbox.d.cts +109 -0
- package/dist/listbox.d.ts +109 -0
- package/dist/listbox.js +264 -0
- package/dist/marquee.cjs +164 -0
- package/dist/marquee.d.cts +60 -0
- package/dist/marquee.d.ts +60 -0
- package/dist/marquee.js +142 -0
- package/dist/menu.cjs +506 -0
- package/dist/menu.d.cts +162 -0
- package/dist/menu.d.ts +162 -0
- package/dist/menu.js +469 -0
- package/dist/navigation-menu.cjs +331 -0
- package/dist/navigation-menu.d.cts +89 -0
- package/dist/navigation-menu.d.ts +89 -0
- package/dist/navigation-menu.js +303 -0
- package/dist/number-input.cjs +222 -0
- package/dist/number-input.d.cts +73 -0
- package/dist/number-input.d.ts +73 -0
- package/dist/number-input.js +197 -0
- package/dist/pagination.cjs +183 -0
- package/dist/pagination.d.cts +68 -0
- package/dist/pagination.d.ts +68 -0
- package/dist/pagination.js +159 -0
- package/dist/password-input.cjs +179 -0
- package/dist/password-input.d.cts +65 -0
- package/dist/password-input.d.ts +65 -0
- package/dist/password-input.js +156 -0
- package/dist/pin-input.cjs +180 -0
- package/dist/pin-input.d.cts +58 -0
- package/dist/pin-input.d.ts +58 -0
- package/dist/pin-input.js +158 -0
- package/dist/popover.cjs +222 -0
- package/dist/popover.d.cts +93 -0
- package/dist/popover.d.ts +93 -0
- package/dist/popover.js +194 -0
- package/dist/portal-6_XzBXiA.cjs +33 -0
- package/dist/portal-QYL_2wB0.js +28 -0
- package/dist/portal.cjs +3 -0
- package/dist/portal.d.cts +9 -0
- package/dist/portal.d.ts +9 -0
- package/dist/portal.js +2 -0
- package/dist/presence-BOs-D6Cv.cjs +96 -0
- package/dist/presence-I8Rceflw.js +65 -0
- package/dist/presence.cjs +7 -0
- package/dist/presence.d.cts +2 -0
- package/dist/presence.d.ts +2 -0
- package/dist/presence.js +2 -0
- package/dist/progress.cjs +206 -0
- package/dist/progress.d.cts +78 -0
- package/dist/progress.d.ts +78 -0
- package/dist/progress.js +180 -0
- package/dist/providers-DrJEJcrE.cjs +128 -0
- package/dist/providers-FEHnDTvb.js +87 -0
- package/dist/qr-code.cjs +154 -0
- package/dist/qr-code.d.cts +58 -0
- package/dist/qr-code.d.ts +58 -0
- package/dist/qr-code.js +132 -0
- package/dist/radio-group.cjs +222 -0
- package/dist/radio-group.d.cts +78 -0
- package/dist/radio-group.d.ts +78 -0
- package/dist/radio-group.js +196 -0
- package/dist/rating-group.cjs +186 -0
- package/dist/rating-group.d.cts +68 -0
- package/dist/rating-group.d.ts +68 -0
- package/dist/rating-group.js +162 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/rolldown-runtime-DakpK96I.cjs +43 -0
- package/dist/scroll-area.cjs +166 -0
- package/dist/scroll-area.d.cts +67 -0
- package/dist/scroll-area.d.ts +67 -0
- package/dist/scroll-area.js +143 -0
- package/dist/segment-group.cjs +215 -0
- package/dist/segment-group.d.cts +81 -0
- package/dist/segment-group.d.ts +81 -0
- package/dist/segment-group.js +194 -0
- package/dist/select.cjs +395 -0
- package/dist/select.d.cts +132 -0
- package/dist/select.d.ts +132 -0
- package/dist/select.js +358 -0
- package/dist/signature-pad.cjs +197 -0
- package/dist/signature-pad.d.cts +68 -0
- package/dist/signature-pad.d.ts +68 -0
- package/dist/signature-pad.js +173 -0
- package/dist/slider.cjs +260 -0
- package/dist/slider.d.cts +88 -0
- package/dist/slider.d.ts +88 -0
- package/dist/slider.js +232 -0
- package/dist/steps.cjs +271 -0
- package/dist/steps.d.cts +104 -0
- package/dist/steps.d.ts +104 -0
- package/dist/steps.js +241 -0
- package/dist/swap.cjs +134 -0
- package/dist/swap.d.cts +49 -0
- package/dist/swap.d.ts +49 -0
- package/dist/swap.js +121 -0
- package/dist/switch.cjs +166 -0
- package/dist/switch.d.cts +58 -0
- package/dist/switch.d.ts +58 -0
- package/dist/switch.js +144 -0
- package/dist/tabs.cjs +177 -0
- package/dist/tabs.d.cts +59 -0
- package/dist/tabs.d.ts +59 -0
- package/dist/tabs.js +155 -0
- package/dist/tags-input.cjs +298 -0
- package/dist/tags-input.d.cts +98 -0
- package/dist/tags-input.d.ts +98 -0
- package/dist/tags-input.js +268 -0
- package/dist/timer.cjs +167 -0
- package/dist/timer.d.cts +63 -0
- package/dist/timer.d.ts +63 -0
- package/dist/timer.js +144 -0
- package/dist/toast.cjs +154 -0
- package/dist/toast.d.cts +59 -0
- package/dist/toast.d.ts +59 -0
- package/dist/toast.js +132 -0
- package/dist/toggle-group.cjs +118 -0
- package/dist/toggle-group.d.cts +43 -0
- package/dist/toggle-group.d.ts +43 -0
- package/dist/toggle-group.js +99 -0
- package/dist/toggle.cjs +85 -0
- package/dist/toggle.d.cts +38 -0
- package/dist/toggle.d.ts +38 -0
- package/dist/toggle.js +71 -0
- package/dist/tooltip.cjs +154 -0
- package/dist/tooltip.d.cts +68 -0
- package/dist/tooltip.d.ts +68 -0
- package/dist/tooltip.js +131 -0
- package/dist/tour.cjs +290 -0
- package/dist/tour.d.cts +112 -0
- package/dist/tour.d.ts +112 -0
- package/dist/tour.js +246 -0
- package/dist/tree-view-CNTEWXlu.js +339 -0
- package/dist/tree-view-CU4Hl5X1.cjs +484 -0
- package/dist/tree-view.cjs +41 -0
- package/dist/tree-view.d.cts +3 -0
- package/dist/tree-view.d.ts +3 -0
- package/dist/tree-view.js +3 -0
- package/dist/types-BQQfrr86.d.cts +6 -0
- package/dist/types-BQQfrr86.d.ts +6 -0
- package/dist/use-context-38DKWHsx.cjs +20 -0
- package/dist/use-context-CITa6pn9.js +10 -0
- package/dist/utils-Cfwm9WW1.cjs +166 -0
- package/dist/utils-CqLmqrgj.js +107 -0
- package/package.json +274 -6
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { c as createSplitProps, l as useComposedRefs, n as useSafeLayoutEffect, u as createContext$1 } from "./utils-CqLmqrgj.js";
|
|
3
|
+
import { n as useEnvironmentContext } from "./environment-BTgKwk5E.js";
|
|
4
|
+
import { t as mergeProps$1 } from "./core-CEYOEcVI.js";
|
|
5
|
+
import { n as wire } from "./factory-Nm__-4xn.js";
|
|
6
|
+
import "./providers-FEHnDTvb.js";
|
|
7
|
+
import { n as useFieldsetContext } from "./use-context-CITa6pn9.js";
|
|
8
|
+
import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { mergeProps } from "@wirekyt/dom";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
import { ariaAttr, dataAttr } from "@wirekyt/dom/dom-query";
|
|
12
|
+
import { createAnatomy } from "@wirekyt/dom/anatomy";
|
|
13
|
+
import { autoresizeTextarea } from "@wirekyt/dom/auto-resize";
|
|
14
|
+
//#region src/components/field/use-context.ts
|
|
15
|
+
const [FieldProvider, useFieldContext] = createContext$1({
|
|
16
|
+
name: "FieldContext",
|
|
17
|
+
hookName: "useFieldContext",
|
|
18
|
+
providerName: "<FieldProvider />",
|
|
19
|
+
strict: false
|
|
20
|
+
});
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/components/field/context.tsx
|
|
23
|
+
const FieldContext = (props) => props.children(useFieldContext());
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/components/field/error-text.tsx
|
|
26
|
+
const FieldErrorText = forwardRef((props, ref) => {
|
|
27
|
+
const field = useFieldContext();
|
|
28
|
+
const mergedProps = mergeProps$1(field.getErrorTextProps(), props);
|
|
29
|
+
if (field?.invalid) return /* @__PURE__ */ jsx(wire.span, {
|
|
30
|
+
...mergedProps,
|
|
31
|
+
ref
|
|
32
|
+
});
|
|
33
|
+
return null;
|
|
34
|
+
});
|
|
35
|
+
FieldErrorText.displayName = "FieldErrorText";
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/components/field/helper-text.tsx
|
|
38
|
+
const FieldHelperText = forwardRef((props, ref) => {
|
|
39
|
+
const mergedProps = mergeProps$1(useFieldContext()?.getHelperTextProps(), props);
|
|
40
|
+
return /* @__PURE__ */ jsx(wire.span, {
|
|
41
|
+
...mergedProps,
|
|
42
|
+
ref
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
FieldHelperText.displayName = "FieldHelperText";
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/components/field/input.tsx
|
|
48
|
+
const FieldInput = forwardRef((props, ref) => {
|
|
49
|
+
const mergedProps = mergeProps$1(useFieldContext()?.getInputProps(), props);
|
|
50
|
+
return /* @__PURE__ */ jsx(wire.input, {
|
|
51
|
+
...mergedProps,
|
|
52
|
+
ref
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
FieldInput.displayName = "FieldInput";
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/components/field/anatomy.ts
|
|
58
|
+
const fieldAnatomy = createAnatomy("field").parts("root", "errorText", "helperText", "input", "label", "select", "textarea", "requiredIndicator");
|
|
59
|
+
const parts = fieldAnatomy.build();
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/components/field/item.tsx
|
|
62
|
+
const FieldItem = (props) => {
|
|
63
|
+
const { value, children } = props;
|
|
64
|
+
const parentField = useFieldContext();
|
|
65
|
+
return /* @__PURE__ */ jsx(FieldProvider, {
|
|
66
|
+
value: useMemo(() => {
|
|
67
|
+
if (!parentField) throw new Error("Field.Item must be used within Field.Root");
|
|
68
|
+
const controlId = `field::${parentField.ids.control}::item::${value}`;
|
|
69
|
+
const labelId = `${controlId}::label`;
|
|
70
|
+
const getControlProps = () => ({
|
|
71
|
+
...parentField.getInputProps(),
|
|
72
|
+
id: controlId
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
...parentField,
|
|
76
|
+
ids: {
|
|
77
|
+
...parentField.ids,
|
|
78
|
+
control: controlId,
|
|
79
|
+
label: labelId
|
|
80
|
+
},
|
|
81
|
+
getLabelProps: () => ({
|
|
82
|
+
...parentField.getLabelProps(),
|
|
83
|
+
id: labelId,
|
|
84
|
+
htmlFor: controlId
|
|
85
|
+
}),
|
|
86
|
+
getInputProps: () => ({
|
|
87
|
+
...getControlProps(),
|
|
88
|
+
...parts.input.attrs
|
|
89
|
+
}),
|
|
90
|
+
getSelectProps: () => ({
|
|
91
|
+
...getControlProps(),
|
|
92
|
+
...parts.select.attrs
|
|
93
|
+
}),
|
|
94
|
+
getTextareaProps: () => ({
|
|
95
|
+
...getControlProps(),
|
|
96
|
+
...parts.textarea.attrs
|
|
97
|
+
})
|
|
98
|
+
};
|
|
99
|
+
}, [parentField, value]),
|
|
100
|
+
children
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
FieldItem.displayName = "FieldItem";
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/components/field/label.tsx
|
|
106
|
+
const FieldLabel = forwardRef((props, ref) => {
|
|
107
|
+
const mergedProps = mergeProps$1(useFieldContext()?.getLabelProps(), props);
|
|
108
|
+
return /* @__PURE__ */ jsx(wire.label, {
|
|
109
|
+
...mergedProps,
|
|
110
|
+
ref
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
FieldLabel.displayName = "FieldLabel";
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/components/field/required-indicator.tsx
|
|
116
|
+
const FieldRequiredIndicator = forwardRef(({ fallback, ...props }, ref) => {
|
|
117
|
+
const field = useFieldContext();
|
|
118
|
+
if (!field.required) return fallback;
|
|
119
|
+
const mergedProps = mergeProps(field.getRequiredIndicatorProps(), props);
|
|
120
|
+
return /* @__PURE__ */ jsx(wire.span, {
|
|
121
|
+
...mergedProps,
|
|
122
|
+
ref,
|
|
123
|
+
children: props.children ?? "*"
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
FieldRequiredIndicator.displayName = "FieldRequiredIndicator";
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/components/field/use.ts
|
|
129
|
+
const useField = (props = {}) => {
|
|
130
|
+
const fieldset = useFieldsetContext();
|
|
131
|
+
const env = useEnvironmentContext();
|
|
132
|
+
const { ids, target, disabled = Boolean(fieldset?.disabled), invalid = false, readOnly = false, required = false } = props;
|
|
133
|
+
const [hasErrorText, setHasErrorText] = useState(false);
|
|
134
|
+
const [hasHelperText, setHasHelperText] = useState(false);
|
|
135
|
+
const uid = useId();
|
|
136
|
+
const id = props.id ?? uid;
|
|
137
|
+
const rootRef = useRef(null);
|
|
138
|
+
const rootId = ids?.control ?? `field::${id}`;
|
|
139
|
+
const errorTextId = ids?.errorText ?? `field::${id}::error-text`;
|
|
140
|
+
const helperTextId = ids?.helperText ?? `field::${id}::helper-text`;
|
|
141
|
+
const labelId = ids?.label ?? `field::${id}::label`;
|
|
142
|
+
useSafeLayoutEffect(() => {
|
|
143
|
+
const rootNode = rootRef.current;
|
|
144
|
+
if (!rootNode) return;
|
|
145
|
+
const checkTextElements = () => {
|
|
146
|
+
const docOrShadowRoot = env.getRootNode();
|
|
147
|
+
setHasErrorText(!!docOrShadowRoot.getElementById(errorTextId));
|
|
148
|
+
setHasHelperText(!!docOrShadowRoot.getElementById(helperTextId));
|
|
149
|
+
};
|
|
150
|
+
checkTextElements();
|
|
151
|
+
const observer = new (env.getWindow()).MutationObserver(checkTextElements);
|
|
152
|
+
observer.observe(rootNode, {
|
|
153
|
+
childList: true,
|
|
154
|
+
subtree: true
|
|
155
|
+
});
|
|
156
|
+
return () => observer.disconnect();
|
|
157
|
+
}, [
|
|
158
|
+
env,
|
|
159
|
+
errorTextId,
|
|
160
|
+
helperTextId
|
|
161
|
+
]);
|
|
162
|
+
const getRootProps = useMemo(() => () => ({
|
|
163
|
+
...parts.root.attrs,
|
|
164
|
+
id: rootId,
|
|
165
|
+
ref: rootRef,
|
|
166
|
+
role: "group",
|
|
167
|
+
"data-disabled": dataAttr(disabled),
|
|
168
|
+
"data-invalid": dataAttr(invalid),
|
|
169
|
+
"data-readonly": dataAttr(readOnly)
|
|
170
|
+
}), [
|
|
171
|
+
disabled,
|
|
172
|
+
invalid,
|
|
173
|
+
readOnly,
|
|
174
|
+
rootId
|
|
175
|
+
]);
|
|
176
|
+
const targetControlId = target ? `field::${id}::item::${target}` : void 0;
|
|
177
|
+
const getLabelProps = useMemo(() => () => ({
|
|
178
|
+
...parts.label.attrs,
|
|
179
|
+
id: labelId,
|
|
180
|
+
"data-disabled": dataAttr(disabled),
|
|
181
|
+
"data-invalid": dataAttr(invalid),
|
|
182
|
+
"data-readonly": dataAttr(readOnly),
|
|
183
|
+
"data-required": dataAttr(required),
|
|
184
|
+
htmlFor: targetControlId ?? id
|
|
185
|
+
}), [
|
|
186
|
+
disabled,
|
|
187
|
+
invalid,
|
|
188
|
+
readOnly,
|
|
189
|
+
required,
|
|
190
|
+
id,
|
|
191
|
+
labelId,
|
|
192
|
+
targetControlId
|
|
193
|
+
]);
|
|
194
|
+
const errorMessageId = hasErrorText && invalid ? errorTextId : void 0;
|
|
195
|
+
const getControlProps = useMemo(() => () => ({
|
|
196
|
+
"aria-describedby": hasHelperText ? helperTextId : void 0,
|
|
197
|
+
"aria-errormessage": errorMessageId,
|
|
198
|
+
"aria-invalid": ariaAttr(invalid),
|
|
199
|
+
"data-invalid": dataAttr(invalid),
|
|
200
|
+
"data-required": dataAttr(required),
|
|
201
|
+
"data-readonly": dataAttr(readOnly),
|
|
202
|
+
id,
|
|
203
|
+
required,
|
|
204
|
+
disabled,
|
|
205
|
+
readOnly
|
|
206
|
+
}), [
|
|
207
|
+
hasHelperText,
|
|
208
|
+
helperTextId,
|
|
209
|
+
invalid,
|
|
210
|
+
required,
|
|
211
|
+
readOnly,
|
|
212
|
+
id,
|
|
213
|
+
errorMessageId,
|
|
214
|
+
disabled
|
|
215
|
+
]);
|
|
216
|
+
const getInputProps = useMemo(() => () => ({
|
|
217
|
+
...getControlProps(),
|
|
218
|
+
...parts.input.attrs
|
|
219
|
+
}), [getControlProps]);
|
|
220
|
+
const getTextareaProps = useMemo(() => () => ({
|
|
221
|
+
...getControlProps(),
|
|
222
|
+
...parts.textarea.attrs
|
|
223
|
+
}), [getControlProps]);
|
|
224
|
+
const getSelectProps = useMemo(() => () => ({
|
|
225
|
+
...getControlProps(),
|
|
226
|
+
...parts.select.attrs
|
|
227
|
+
}), [getControlProps]);
|
|
228
|
+
const getHelperTextProps = useMemo(() => () => ({
|
|
229
|
+
id: helperTextId,
|
|
230
|
+
...parts.helperText.attrs,
|
|
231
|
+
"data-disabled": dataAttr(disabled)
|
|
232
|
+
}), [disabled, helperTextId]);
|
|
233
|
+
const getErrorTextProps = useMemo(() => () => ({
|
|
234
|
+
id: errorTextId,
|
|
235
|
+
...parts.errorText.attrs,
|
|
236
|
+
"aria-live": "polite"
|
|
237
|
+
}), [errorTextId]);
|
|
238
|
+
const getRequiredIndicatorProps = useMemo(() => () => ({
|
|
239
|
+
"aria-hidden": true,
|
|
240
|
+
...parts.requiredIndicator.attrs
|
|
241
|
+
}), []);
|
|
242
|
+
return {
|
|
243
|
+
ariaDescribedby: hasHelperText ? helperTextId : void 0,
|
|
244
|
+
ids: {
|
|
245
|
+
root: rootId,
|
|
246
|
+
control: id,
|
|
247
|
+
label: labelId,
|
|
248
|
+
errorText: errorTextId,
|
|
249
|
+
helperText: helperTextId
|
|
250
|
+
},
|
|
251
|
+
refs: { rootRef },
|
|
252
|
+
disabled,
|
|
253
|
+
invalid,
|
|
254
|
+
readOnly,
|
|
255
|
+
required,
|
|
256
|
+
getLabelProps,
|
|
257
|
+
getRootProps,
|
|
258
|
+
getInputProps,
|
|
259
|
+
getTextareaProps,
|
|
260
|
+
getSelectProps,
|
|
261
|
+
getHelperTextProps,
|
|
262
|
+
getErrorTextProps,
|
|
263
|
+
getRequiredIndicatorProps
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/components/field/root.tsx
|
|
268
|
+
const splitRootProps = createSplitProps();
|
|
269
|
+
const FieldRoot = forwardRef((props, ref) => {
|
|
270
|
+
const [useFieldProps, localProps] = splitRootProps(props, [
|
|
271
|
+
"id",
|
|
272
|
+
"ids",
|
|
273
|
+
"disabled",
|
|
274
|
+
"invalid",
|
|
275
|
+
"readOnly",
|
|
276
|
+
"required",
|
|
277
|
+
"target"
|
|
278
|
+
]);
|
|
279
|
+
const field = useField(useFieldProps);
|
|
280
|
+
const mergedProps = mergeProps$1(field.getRootProps(), localProps);
|
|
281
|
+
const composedRefs = useComposedRefs(ref, field.refs.rootRef);
|
|
282
|
+
return /* @__PURE__ */ jsx(FieldProvider, {
|
|
283
|
+
value: field,
|
|
284
|
+
children: /* @__PURE__ */ jsx(wire.div, {
|
|
285
|
+
...mergedProps,
|
|
286
|
+
ref: composedRefs
|
|
287
|
+
})
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
FieldRoot.displayName = "FieldRoot";
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/components/field/root-provider.tsx
|
|
293
|
+
const splitRootProviderProps = createSplitProps();
|
|
294
|
+
const FieldRootProvider = forwardRef((props, ref) => {
|
|
295
|
+
const [{ value: field }, localProps] = splitRootProviderProps(props, ["value"]);
|
|
296
|
+
const mergedProps = mergeProps$1(field.getRootProps(), localProps);
|
|
297
|
+
return /* @__PURE__ */ jsx(FieldProvider, {
|
|
298
|
+
value: field,
|
|
299
|
+
children: /* @__PURE__ */ jsx(wire.div, {
|
|
300
|
+
...mergedProps,
|
|
301
|
+
ref
|
|
302
|
+
})
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
FieldRootProvider.displayName = "FieldRootProvider";
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/components/field/select.tsx
|
|
308
|
+
const FieldSelect = forwardRef((props, ref) => {
|
|
309
|
+
const mergedProps = mergeProps$1(useFieldContext()?.getSelectProps(), props);
|
|
310
|
+
return /* @__PURE__ */ jsx(wire.select, {
|
|
311
|
+
...mergedProps,
|
|
312
|
+
ref
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
FieldSelect.displayName = "FieldSelect";
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/components/field/textarea.tsx
|
|
318
|
+
const FieldTextarea = forwardRef((props, ref) => {
|
|
319
|
+
const { autoresize, ...textareaProps } = props;
|
|
320
|
+
const textareaRef = useRef(null);
|
|
321
|
+
const mergedProps = mergeProps$1(useFieldContext()?.getTextareaProps(), { style: { resize: autoresize ? "none" : void 0 } }, textareaProps);
|
|
322
|
+
const composedRefs = useComposedRefs(ref, textareaRef);
|
|
323
|
+
useEffect(() => {
|
|
324
|
+
if (!autoresize) return;
|
|
325
|
+
return autoresizeTextarea(textareaRef.current);
|
|
326
|
+
}, [autoresize]);
|
|
327
|
+
return /* @__PURE__ */ jsx(wire.textarea, {
|
|
328
|
+
...mergedProps,
|
|
329
|
+
ref: composedRefs
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
FieldTextarea.displayName = "FieldTextarea";
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/components/field/field.ts
|
|
335
|
+
var field_exports = /* @__PURE__ */ __exportAll({
|
|
336
|
+
Context: () => FieldContext,
|
|
337
|
+
ErrorText: () => FieldErrorText,
|
|
338
|
+
HelperText: () => FieldHelperText,
|
|
339
|
+
Input: () => FieldInput,
|
|
340
|
+
Item: () => FieldItem,
|
|
341
|
+
Label: () => FieldLabel,
|
|
342
|
+
RequiredIndicator: () => FieldRequiredIndicator,
|
|
343
|
+
Root: () => FieldRoot,
|
|
344
|
+
RootProvider: () => FieldRootProvider,
|
|
345
|
+
Select: () => FieldSelect,
|
|
346
|
+
Textarea: () => FieldTextarea
|
|
347
|
+
});
|
|
348
|
+
//#endregion
|
|
349
|
+
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 };
|