@sprawlify/react 0.0.6 → 0.0.8
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/chunk-BYnRvbsk.cjs +53 -0
- package/dist/{collapsible-DYgHs1_i.mjs → collapsible-Nbt3Sequ.mjs} +7 -4
- package/dist/{collapsible-D_cXuaRy.cjs → collapsible-aFKYmVbP.cjs} +13 -9
- package/dist/collection-DGEUORi5.cjs +230 -0
- package/dist/collection-DQWWySNV.mjs +187 -0
- package/dist/components/accordion/index.cjs +21 -24
- package/dist/components/accordion/index.d.cts +11 -9
- package/dist/components/accordion/index.d.mts +11 -9
- package/dist/components/accordion/index.mjs +10 -14
- package/dist/components/angle-slider/index.cjs +14 -9
- package/dist/components/angle-slider/index.d.cts +13 -11
- package/dist/components/angle-slider/index.d.mts +13 -11
- package/dist/components/angle-slider/index.mjs +8 -4
- package/dist/components/avatar/index.cjs +14 -9
- package/dist/components/avatar/index.d.cts +8 -6
- package/dist/components/avatar/index.d.mts +8 -6
- package/dist/components/avatar/index.mjs +8 -4
- package/dist/components/bottom-sheet/index.cjs +216 -0
- package/dist/components/bottom-sheet/index.d.cts +80 -0
- package/dist/components/bottom-sheet/index.d.mts +81 -0
- package/dist/components/bottom-sheet/index.mjs +192 -0
- package/dist/components/carousel/index.cjs +265 -0
- package/dist/components/carousel/index.d.cts +95 -0
- package/dist/components/carousel/index.d.mts +95 -0
- package/dist/components/carousel/index.mjs +243 -0
- package/dist/components/checkbox/index.cjs +311 -0
- package/dist/components/checkbox/index.d.cts +115 -0
- package/dist/components/checkbox/index.d.mts +115 -0
- package/dist/components/checkbox/index.mjs +291 -0
- package/dist/components/client-only/index.cjs +14 -0
- package/dist/components/client-only/index.d.cts +8 -0
- package/dist/components/client-only/index.d.mts +8 -0
- package/dist/components/client-only/index.mjs +13 -0
- package/dist/components/clipboard/index.cjs +186 -0
- package/dist/components/clipboard/index.d.cts +71 -0
- package/dist/components/clipboard/index.d.mts +71 -0
- package/dist/components/clipboard/index.mjs +163 -0
- package/dist/components/collapsible/index.cjs +8 -3
- package/dist/components/collapsible/index.d.cts +10 -8
- package/dist/components/collapsible/index.d.mts +10 -8
- package/dist/components/collapsible/index.mjs +7 -3
- package/dist/components/collection/index.cjs +11 -0
- package/dist/components/collection/index.d.cts +2 -0
- package/dist/components/collection/index.d.mts +2 -0
- package/dist/components/collection/index.mjs +5 -0
- package/dist/components/color-picker/index.cjs +617 -0
- package/dist/components/color-picker/index.d.cts +181 -0
- package/dist/components/color-picker/index.d.mts +182 -0
- package/dist/components/color-picker/index.mjs +573 -0
- package/dist/components/combobox/index.cjs +420 -0
- package/dist/components/combobox/index.d.cts +132 -0
- package/dist/components/combobox/index.d.mts +133 -0
- package/dist/components/combobox/index.mjs +390 -0
- package/dist/components/date-picker/index.cjs +567 -0
- package/dist/components/date-picker/index.d.cts +164 -0
- package/dist/components/date-picker/index.d.mts +165 -0
- package/dist/components/date-picker/index.mjs +526 -0
- package/dist/components/dialog/index.cjs +211 -0
- package/dist/components/dialog/index.d.cts +80 -0
- package/dist/components/dialog/index.d.mts +81 -0
- package/dist/components/dialog/index.mjs +187 -0
- package/dist/components/download-trigger/index.cjs +43 -0
- package/dist/components/download-trigger/index.d.cts +16 -0
- package/dist/components/download-trigger/index.d.mts +16 -0
- package/dist/components/download-trigger/index.mjs +42 -0
- package/dist/components/editable/index.cjs +246 -0
- package/dist/components/editable/index.d.cts +79 -0
- package/dist/components/editable/index.d.mts +79 -0
- package/dist/components/editable/index.mjs +221 -0
- package/dist/components/field/index.cjs +29 -0
- package/dist/components/field/index.d.cts +116 -0
- package/dist/components/field/index.d.mts +116 -0
- package/dist/components/field/index.mjs +11 -0
- package/dist/components/fieldset/index.cjs +25 -0
- package/dist/components/fieldset/index.d.cts +73 -0
- package/dist/components/fieldset/index.d.mts +73 -0
- package/dist/components/fieldset/index.mjs +11 -0
- package/dist/components/file-upload/index.cjs +351 -0
- package/dist/components/file-upload/index.d.cts +102 -0
- package/dist/components/file-upload/index.d.mts +102 -0
- package/dist/components/file-upload/index.mjs +322 -0
- package/dist/components/floating-panel/index.cjs +287 -0
- package/dist/components/floating-panel/index.d.cts +100 -0
- package/dist/components/floating-panel/index.d.mts +101 -0
- package/dist/components/floating-panel/index.mjs +259 -0
- package/dist/components/focus-trap/index.cjs +36 -0
- package/dist/components/focus-trap/index.d.cts +14 -0
- package/dist/components/focus-trap/index.d.mts +14 -0
- package/dist/components/focus-trap/index.mjs +35 -0
- package/dist/components/format/index.cjs +57 -0
- package/dist/components/format/index.d.cts +36 -0
- package/dist/components/format/index.d.mts +36 -0
- package/dist/components/format/index.mjs +49 -0
- package/dist/components/frame/index.cjs +90 -0
- package/dist/components/frame/index.d.cts +13 -0
- package/dist/components/frame/index.d.mts +13 -0
- package/dist/components/frame/index.mjs +89 -0
- package/dist/components/highlight/index.cjs +32 -0
- package/dist/components/highlight/index.d.cts +14 -0
- package/dist/components/highlight/index.d.mts +14 -0
- package/dist/components/highlight/index.mjs +30 -0
- package/dist/components/portal/index.cjs +33 -0
- package/dist/components/portal/index.d.cts +11 -0
- package/dist/components/portal/index.d.mts +11 -0
- package/dist/components/portal/index.mjs +32 -0
- package/dist/components/presence/index.cjs +11 -0
- package/dist/components/presence/index.d.cts +2 -0
- package/dist/components/presence/index.d.mts +4 -0
- package/dist/components/presence/index.mjs +7 -0
- package/dist/components/select/index.cjs +423 -0
- package/dist/components/select/index.d.cts +132 -0
- package/dist/components/select/index.d.mts +133 -0
- package/dist/components/select/index.mjs +387 -0
- package/dist/compose-refs-BEptPEkE.mjs +16 -0
- package/dist/compose-refs-C5QNDywq.cjs +22 -0
- package/dist/{factory-DN0EdT7u.mjs → core-Ba4IEjhK.mjs} +4 -154
- package/dist/{factory-CfqPG186.cjs → core-DCWyxy9D.cjs} +2 -251
- package/dist/{create-context-DCEySQ7J.cjs → create-context-CQ4U0lLj.cjs} +1 -1
- package/dist/environment-CvilmfQt.cjs +58 -0
- package/dist/environment-Ded7DkGr.mjs +46 -0
- package/dist/factory-Bi8oEg8i.mjs +49 -0
- package/dist/factory-C-EBNsCW.d.mts +15 -0
- package/dist/factory-C166evrS.cjs +61 -0
- package/dist/factory-C4cfTHs7.d.cts +15 -0
- package/dist/field-B-6qoKdn.mjs +324 -0
- package/dist/field-C-57Gj2E.cjs +406 -0
- package/dist/fieldset-B-MkM2Ms.cjs +239 -0
- package/dist/fieldset-gaVneDYh.mjs +186 -0
- package/dist/index-BJvW7OpY.d.mts +25 -0
- package/dist/index-BhGgEHWc.d.cts +34 -0
- package/dist/index-ByIsf4E7.d.mts +74 -0
- package/dist/index-Cp1i1zbg.d.mts +34 -0
- package/dist/index-CumJbg8V.d.cts +74 -0
- package/dist/index.cjs +17 -12
- package/dist/index.d.cts +7 -5
- package/dist/index.d.mts +7 -5
- package/dist/index.mjs +7 -3
- package/dist/locale-BcnWD1Hf.cjs +78 -0
- package/dist/locale-Coin-d7R.mjs +54 -0
- package/dist/normalize-props-skGwa8Dk.d.cts +13 -0
- package/dist/presence-Bc6Bxe5i.mjs +72 -0
- package/dist/presence-CPov8wyU.cjs +103 -0
- package/dist/providers-BNAArubQ.cjs +0 -0
- package/dist/providers-Dm2P3F2_.mjs +1 -0
- package/dist/render-strategy-BywM_IvB.cjs +30 -0
- package/dist/render-strategy-FiPgAp1U.mjs +13 -0
- package/dist/types-B4tvWlDb.d.cts +6 -0
- package/dist/types-BmBABPZb.d.mts +6 -0
- package/dist/use-event-4J5QFFqK.mjs +19 -0
- package/dist/use-event-CLH8zHoJ.cjs +25 -0
- package/dist/use-fieldset-context-CCQLmNLL.cjs +23 -0
- package/dist/use-fieldset-context-LwveT1OS.mjs +12 -0
- package/dist/use-safe-layout-effect-C2GgvNT3.cjs +13 -0
- package/dist/use-safe-layout-effect-CLjnuJFb.mjs +7 -0
- package/dist/utils/index.cjs +3 -3
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.mjs +2 -2
- package/package.json +232 -2
- package/dist/factory-BZBSaT-0.d.cts +0 -29
- package/dist/factory-DaVMAttY.d.mts +0 -41
- /package/dist/{chunk-CYMnug_4.mjs → chunk-BXPHTOwk.mjs} +0 -0
- /package/dist/{create-context-DGYD_HQt.mjs → create-context-CCXzjEv8.mjs} +0 -0
- /package/dist/{create-split-props-BFscidWy.mjs → create-split-props-CBL0m-GX.mjs} +0 -0
- /package/dist/{create-split-props-CSaOnJRj.cjs → create-split-props-Dp4TWOyM.cjs} +0 -0
- /package/dist/{index-OOf7QNG5.d.mts → index-CureNJdc.d.mts} +0 -0
- /package/dist/{index-DiYk6N_L.d.cts → index-dbTyAXLy.d.cts} +0 -0
- /package/dist/{render-strategy--1FNKx5x.d.mts → render-strategy-C8IyLw0O.d.mts} +0 -0
- /package/dist/{render-strategy-RT-KvAqO.d.cts → render-strategy-rA4C5NUX.d.cts} +0 -0
- /package/dist/{utils-Cb5K29pi.cjs → utils-B_Ojepvp.cjs} +0 -0
- /package/dist/{utils-nfWHwVIS.mjs → utils-C-m3mZWI.mjs} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { ComponentPropsWithoutRef, JSX } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/factory.d.ts
|
|
4
|
+
interface PolymorphicProps {
|
|
5
|
+
asChild?: boolean | undefined;
|
|
6
|
+
}
|
|
7
|
+
type JsxElements = { [E in keyof JSX.IntrinsicElements]: SprawlifyForwardRefComponent<E> };
|
|
8
|
+
type SprawlifyForwardRefComponent<E$1 extends React.ElementType> = React.ForwardRefExoticComponent<SprawlifyPropsWithRef<E$1>>;
|
|
9
|
+
type SprawlifyPropsWithRef<E$1 extends React.ElementType> = React.ComponentPropsWithRef<E$1> & PolymorphicProps;
|
|
10
|
+
type HTMLProps<T extends keyof JSX.IntrinsicElements> = ComponentPropsWithoutRef<T>;
|
|
11
|
+
type HTMLSprawlifyProps<T extends keyof JSX.IntrinsicElements> = HTMLProps<T> & PolymorphicProps;
|
|
12
|
+
declare const jsxFactory: () => JsxElements;
|
|
13
|
+
declare const sprawlify: JsxElements;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { sprawlify as a, jsxFactory as i, HTMLSprawlifyProps as n, PolymorphicProps as r, HTMLProps as t };
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { t as __export } from "./chunk-BXPHTOwk.mjs";
|
|
2
|
+
import { t as mergeProps$1 } from "./core-Ba4IEjhK.mjs";
|
|
3
|
+
import { t as createContext$1 } from "./create-context-CCXzjEv8.mjs";
|
|
4
|
+
import { n as useEnvironmentContext } from "./environment-Ded7DkGr.mjs";
|
|
5
|
+
import { t as composeRefs } from "./compose-refs-BEptPEkE.mjs";
|
|
6
|
+
import { n as sprawlify } from "./factory-Bi8oEg8i.mjs";
|
|
7
|
+
import { t as createSplitProps } from "./create-split-props-CBL0m-GX.mjs";
|
|
8
|
+
import { n as useFieldsetContext } from "./use-fieldset-context-LwveT1OS.mjs";
|
|
9
|
+
import { t as useSafeLayoutEffect } from "./use-safe-layout-effect-CLjnuJFb.mjs";
|
|
10
|
+
import { mergeProps } from "@sprawlify/primitives/core";
|
|
11
|
+
import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
import { ariaAttr, dataAttr } from "@sprawlify/primitives/dom-query";
|
|
14
|
+
import { createAnatomy } from "@sprawlify/primitives/anatomy";
|
|
15
|
+
import { autoresizeTextarea } from "@sprawlify/primitives/auto-resize";
|
|
16
|
+
|
|
17
|
+
//#region src/components/field/use-field-context.ts
|
|
18
|
+
const [FieldProvider, useFieldContext] = createContext$1({
|
|
19
|
+
name: "FieldContext",
|
|
20
|
+
hookName: "useFieldContext",
|
|
21
|
+
providerName: "<FieldProvider />",
|
|
22
|
+
strict: false
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/components/field/field-context.tsx
|
|
27
|
+
const FieldContext = (props) => props.children(useFieldContext());
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/components/field/field-error-text.tsx
|
|
31
|
+
const FieldErrorText = forwardRef((props, ref) => {
|
|
32
|
+
const field = useFieldContext();
|
|
33
|
+
const mergedProps = mergeProps$1(field.getErrorTextProps(), props);
|
|
34
|
+
if (field?.invalid) return /* @__PURE__ */ jsx(sprawlify.span, {
|
|
35
|
+
...mergedProps,
|
|
36
|
+
ref
|
|
37
|
+
});
|
|
38
|
+
return null;
|
|
39
|
+
});
|
|
40
|
+
FieldErrorText.displayName = "FieldErrorText";
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/components/field/field-helper-text.tsx
|
|
44
|
+
const FieldHelperText = forwardRef((props, ref) => {
|
|
45
|
+
const mergedProps = mergeProps$1(useFieldContext()?.getHelperTextProps(), props);
|
|
46
|
+
return /* @__PURE__ */ jsx(sprawlify.span, {
|
|
47
|
+
...mergedProps,
|
|
48
|
+
ref
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
FieldHelperText.displayName = "FieldHelperText";
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/components/field/field-input.tsx
|
|
55
|
+
const FieldInput = forwardRef((props, ref) => {
|
|
56
|
+
const mergedProps = mergeProps$1(useFieldContext()?.getInputProps(), props);
|
|
57
|
+
return /* @__PURE__ */ jsx(sprawlify.input, {
|
|
58
|
+
...mergedProps,
|
|
59
|
+
ref
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
FieldInput.displayName = "FieldInput";
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/components/field/field-label.tsx
|
|
66
|
+
const FieldLabel = forwardRef((props, ref) => {
|
|
67
|
+
const mergedProps = mergeProps$1(useFieldContext()?.getLabelProps(), props);
|
|
68
|
+
return /* @__PURE__ */ jsx(sprawlify.label, {
|
|
69
|
+
...mergedProps,
|
|
70
|
+
ref
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
FieldLabel.displayName = "FieldLabel";
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/components/field/field-required-indicator.tsx
|
|
77
|
+
const FieldRequiredIndicator = forwardRef(({ fallback, ...props }, ref) => {
|
|
78
|
+
const field = useFieldContext();
|
|
79
|
+
if (!field.required) return fallback;
|
|
80
|
+
const mergedProps = mergeProps(field.getRequiredIndicatorProps(), props);
|
|
81
|
+
return /* @__PURE__ */ jsx(sprawlify.span, {
|
|
82
|
+
...mergedProps,
|
|
83
|
+
ref,
|
|
84
|
+
children: props.children ?? "*"
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
FieldRequiredIndicator.displayName = "FieldRequiredIndicator";
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/components/field/field-anatomy.ts
|
|
91
|
+
const fieldAnatomy = createAnatomy("field").parts("root", "errorText", "helperText", "input", "label", "select", "textarea", "requiredIndicator");
|
|
92
|
+
const parts = fieldAnatomy.build();
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/components/field/use-field.ts
|
|
96
|
+
const useField = (props = {}) => {
|
|
97
|
+
const fieldset = useFieldsetContext();
|
|
98
|
+
const env = useEnvironmentContext();
|
|
99
|
+
const { ids, disabled = Boolean(fieldset?.disabled), invalid = false, readOnly = false, required = false } = props;
|
|
100
|
+
const [hasErrorText, setHasErrorText] = useState(false);
|
|
101
|
+
const [hasHelperText, setHasHelperText] = useState(false);
|
|
102
|
+
const uid = useId();
|
|
103
|
+
const id = props.id ?? uid;
|
|
104
|
+
const rootRef = useRef(null);
|
|
105
|
+
const rootId = ids?.control ?? `field::${id}`;
|
|
106
|
+
const errorTextId = ids?.errorText ?? `field::${id}::error-text`;
|
|
107
|
+
const helperTextId = ids?.helperText ?? `field::${id}::helper-text`;
|
|
108
|
+
const labelId = ids?.label ?? `field::${id}::label`;
|
|
109
|
+
useSafeLayoutEffect(() => {
|
|
110
|
+
const rootNode = rootRef.current;
|
|
111
|
+
if (!rootNode) return;
|
|
112
|
+
const checkTextElements = () => {
|
|
113
|
+
const docOrShadowRoot = env.getRootNode();
|
|
114
|
+
setHasErrorText(!!docOrShadowRoot.getElementById(errorTextId));
|
|
115
|
+
setHasHelperText(!!docOrShadowRoot.getElementById(helperTextId));
|
|
116
|
+
};
|
|
117
|
+
checkTextElements();
|
|
118
|
+
const observer = new (env.getWindow()).MutationObserver(checkTextElements);
|
|
119
|
+
observer.observe(rootNode, {
|
|
120
|
+
childList: true,
|
|
121
|
+
subtree: true
|
|
122
|
+
});
|
|
123
|
+
return () => observer.disconnect();
|
|
124
|
+
}, [
|
|
125
|
+
env,
|
|
126
|
+
errorTextId,
|
|
127
|
+
helperTextId
|
|
128
|
+
]);
|
|
129
|
+
const labelIds = useMemo(() => {
|
|
130
|
+
const ids$1 = [];
|
|
131
|
+
if (hasErrorText && invalid) ids$1.push(errorTextId);
|
|
132
|
+
if (hasHelperText) ids$1.push(helperTextId);
|
|
133
|
+
return ids$1.join(" ") || void 0;
|
|
134
|
+
}, [
|
|
135
|
+
invalid,
|
|
136
|
+
errorTextId,
|
|
137
|
+
helperTextId,
|
|
138
|
+
hasErrorText,
|
|
139
|
+
hasHelperText
|
|
140
|
+
]);
|
|
141
|
+
const getRootProps = useMemo(() => () => ({
|
|
142
|
+
...parts.root.attrs,
|
|
143
|
+
id: rootId,
|
|
144
|
+
ref: rootRef,
|
|
145
|
+
role: "group",
|
|
146
|
+
"data-disabled": dataAttr(disabled),
|
|
147
|
+
"data-invalid": dataAttr(invalid),
|
|
148
|
+
"data-readonly": dataAttr(readOnly)
|
|
149
|
+
}), [
|
|
150
|
+
disabled,
|
|
151
|
+
invalid,
|
|
152
|
+
readOnly,
|
|
153
|
+
rootId
|
|
154
|
+
]);
|
|
155
|
+
const getLabelProps = useMemo(() => () => ({
|
|
156
|
+
...parts.label.attrs,
|
|
157
|
+
id: labelId,
|
|
158
|
+
"data-disabled": dataAttr(disabled),
|
|
159
|
+
"data-invalid": dataAttr(invalid),
|
|
160
|
+
"data-readonly": dataAttr(readOnly),
|
|
161
|
+
"data-required": dataAttr(required),
|
|
162
|
+
htmlFor: id
|
|
163
|
+
}), [
|
|
164
|
+
disabled,
|
|
165
|
+
invalid,
|
|
166
|
+
readOnly,
|
|
167
|
+
required,
|
|
168
|
+
id,
|
|
169
|
+
labelId
|
|
170
|
+
]);
|
|
171
|
+
const getControlProps = useMemo(() => () => ({
|
|
172
|
+
"aria-describedby": labelIds,
|
|
173
|
+
"aria-invalid": ariaAttr(invalid),
|
|
174
|
+
"data-invalid": dataAttr(invalid),
|
|
175
|
+
"data-required": dataAttr(required),
|
|
176
|
+
"data-readonly": dataAttr(readOnly),
|
|
177
|
+
id,
|
|
178
|
+
required,
|
|
179
|
+
disabled,
|
|
180
|
+
readOnly
|
|
181
|
+
}), [
|
|
182
|
+
labelIds,
|
|
183
|
+
invalid,
|
|
184
|
+
required,
|
|
185
|
+
readOnly,
|
|
186
|
+
id,
|
|
187
|
+
disabled
|
|
188
|
+
]);
|
|
189
|
+
const getInputProps = useMemo(() => () => ({
|
|
190
|
+
...getControlProps(),
|
|
191
|
+
...parts.input.attrs
|
|
192
|
+
}), [getControlProps]);
|
|
193
|
+
const getTextareaProps = useMemo(() => () => ({
|
|
194
|
+
...getControlProps(),
|
|
195
|
+
...parts.textarea.attrs
|
|
196
|
+
}), [getControlProps]);
|
|
197
|
+
const getSelectProps = useMemo(() => () => ({
|
|
198
|
+
...getControlProps(),
|
|
199
|
+
...parts.select.attrs
|
|
200
|
+
}), [getControlProps]);
|
|
201
|
+
const getHelperTextProps = useMemo(() => () => ({
|
|
202
|
+
id: helperTextId,
|
|
203
|
+
...parts.helperText.attrs,
|
|
204
|
+
"data-disabled": dataAttr(disabled)
|
|
205
|
+
}), [disabled, helperTextId]);
|
|
206
|
+
const getErrorTextProps = useMemo(() => () => ({
|
|
207
|
+
id: errorTextId,
|
|
208
|
+
...parts.errorText.attrs,
|
|
209
|
+
"aria-live": "polite"
|
|
210
|
+
}), [errorTextId]);
|
|
211
|
+
const getRequiredIndicatorProps = useMemo(() => () => ({
|
|
212
|
+
"aria-hidden": true,
|
|
213
|
+
...parts.requiredIndicator.attrs
|
|
214
|
+
}), []);
|
|
215
|
+
return {
|
|
216
|
+
ariaDescribedby: labelIds,
|
|
217
|
+
ids: {
|
|
218
|
+
root: rootId,
|
|
219
|
+
control: id,
|
|
220
|
+
label: labelId,
|
|
221
|
+
errorText: errorTextId,
|
|
222
|
+
helperText: helperTextId
|
|
223
|
+
},
|
|
224
|
+
refs: { rootRef },
|
|
225
|
+
disabled,
|
|
226
|
+
invalid,
|
|
227
|
+
readOnly,
|
|
228
|
+
required,
|
|
229
|
+
getLabelProps,
|
|
230
|
+
getRootProps,
|
|
231
|
+
getInputProps,
|
|
232
|
+
getTextareaProps,
|
|
233
|
+
getSelectProps,
|
|
234
|
+
getHelperTextProps,
|
|
235
|
+
getErrorTextProps,
|
|
236
|
+
getRequiredIndicatorProps
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/components/field/field-root.tsx
|
|
242
|
+
const splitRootProps = createSplitProps();
|
|
243
|
+
const FieldRoot = forwardRef((props, ref) => {
|
|
244
|
+
const [useFieldProps, localProps] = splitRootProps(props, [
|
|
245
|
+
"id",
|
|
246
|
+
"ids",
|
|
247
|
+
"disabled",
|
|
248
|
+
"invalid",
|
|
249
|
+
"readOnly",
|
|
250
|
+
"required"
|
|
251
|
+
]);
|
|
252
|
+
const field = useField(useFieldProps);
|
|
253
|
+
const mergedProps = mergeProps$1(field.getRootProps(), localProps);
|
|
254
|
+
return /* @__PURE__ */ jsx(FieldProvider, {
|
|
255
|
+
value: field,
|
|
256
|
+
children: /* @__PURE__ */ jsx(sprawlify.div, {
|
|
257
|
+
...mergedProps,
|
|
258
|
+
ref: composeRefs(ref, field.refs.rootRef)
|
|
259
|
+
})
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
FieldRoot.displayName = "FieldRoot";
|
|
263
|
+
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/components/field/field-root-provider.tsx
|
|
266
|
+
const splitRootProviderProps = createSplitProps();
|
|
267
|
+
const FieldRootProvider = forwardRef((props, ref) => {
|
|
268
|
+
const [{ value: field }, localProps] = splitRootProviderProps(props, ["value"]);
|
|
269
|
+
const mergedProps = mergeProps$1(field.getRootProps(), localProps);
|
|
270
|
+
return /* @__PURE__ */ jsx(FieldProvider, {
|
|
271
|
+
value: field,
|
|
272
|
+
children: /* @__PURE__ */ jsx(sprawlify.div, {
|
|
273
|
+
...mergedProps,
|
|
274
|
+
ref
|
|
275
|
+
})
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
FieldRootProvider.displayName = "FieldRootProvider";
|
|
279
|
+
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/components/field/field-select.tsx
|
|
282
|
+
const FieldSelect = forwardRef((props, ref) => {
|
|
283
|
+
const mergedProps = mergeProps$1(useFieldContext()?.getSelectProps(), props);
|
|
284
|
+
return /* @__PURE__ */ jsx(sprawlify.select, {
|
|
285
|
+
...mergedProps,
|
|
286
|
+
ref
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
FieldSelect.displayName = "FieldSelect";
|
|
290
|
+
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/components/field/field-textarea.tsx
|
|
293
|
+
const FieldTextarea = forwardRef((props, ref) => {
|
|
294
|
+
const { autoresize, ...textareaProps } = props;
|
|
295
|
+
const textareaRef = useRef(null);
|
|
296
|
+
const mergedProps = mergeProps$1(useFieldContext()?.getTextareaProps(), { style: { resize: autoresize ? "none" : void 0 } }, textareaProps);
|
|
297
|
+
useEffect(() => {
|
|
298
|
+
if (!autoresize) return;
|
|
299
|
+
return autoresizeTextarea(textareaRef.current);
|
|
300
|
+
}, [autoresize]);
|
|
301
|
+
return /* @__PURE__ */ jsx(sprawlify.textarea, {
|
|
302
|
+
...mergedProps,
|
|
303
|
+
ref: composeRefs(ref, textareaRef)
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
FieldTextarea.displayName = "FieldTextarea";
|
|
307
|
+
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region src/components/field/field.ts
|
|
310
|
+
var field_exports = /* @__PURE__ */ __export({
|
|
311
|
+
Context: () => FieldContext,
|
|
312
|
+
ErrorText: () => FieldErrorText,
|
|
313
|
+
HelperText: () => FieldHelperText,
|
|
314
|
+
Input: () => FieldInput,
|
|
315
|
+
Label: () => FieldLabel,
|
|
316
|
+
RequiredIndicator: () => FieldRequiredIndicator,
|
|
317
|
+
Root: () => FieldRoot,
|
|
318
|
+
RootProvider: () => FieldRootProvider,
|
|
319
|
+
Select: () => FieldSelect,
|
|
320
|
+
Textarea: () => FieldTextarea
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
//#endregion
|
|
324
|
+
export { FieldRoot as a, FieldRequiredIndicator as c, FieldHelperText as d, FieldErrorText as f, FieldRootProvider as i, FieldLabel as l, useFieldContext as m, FieldTextarea as n, useField as o, FieldContext as p, FieldSelect as r, fieldAnatomy as s, field_exports as t, FieldInput as u };
|