@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,406 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-BYnRvbsk.cjs');
|
|
2
|
+
const require_create_context = require('./create-context-CQ4U0lLj.cjs');
|
|
3
|
+
const require_environment = require('./environment-CvilmfQt.cjs');
|
|
4
|
+
const require_compose_refs = require('./compose-refs-C5QNDywq.cjs');
|
|
5
|
+
const require_factory = require('./factory-C166evrS.cjs');
|
|
6
|
+
const require_create_split_props = require('./create-split-props-Dp4TWOyM.cjs');
|
|
7
|
+
const require_use_fieldset_context = require('./use-fieldset-context-CCQLmNLL.cjs');
|
|
8
|
+
const require_use_safe_layout_effect = require('./use-safe-layout-effect-C2GgvNT3.cjs');
|
|
9
|
+
let __sprawlify_primitives_core = require("@sprawlify/primitives/core");
|
|
10
|
+
let react = require("react");
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
let __sprawlify_primitives_dom_query = require("@sprawlify/primitives/dom-query");
|
|
13
|
+
let __sprawlify_primitives_anatomy = require("@sprawlify/primitives/anatomy");
|
|
14
|
+
let __sprawlify_primitives_auto_resize = require("@sprawlify/primitives/auto-resize");
|
|
15
|
+
|
|
16
|
+
//#region src/components/field/use-field-context.ts
|
|
17
|
+
const [FieldProvider, useFieldContext] = require_create_context.createContext({
|
|
18
|
+
name: "FieldContext",
|
|
19
|
+
hookName: "useFieldContext",
|
|
20
|
+
providerName: "<FieldProvider />",
|
|
21
|
+
strict: false
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/components/field/field-context.tsx
|
|
26
|
+
const FieldContext = (props) => props.children(useFieldContext());
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/components/field/field-error-text.tsx
|
|
30
|
+
const FieldErrorText = (0, react.forwardRef)((props, ref) => {
|
|
31
|
+
const field = useFieldContext();
|
|
32
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(field.getErrorTextProps(), props);
|
|
33
|
+
if (field?.invalid) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.span, {
|
|
34
|
+
...mergedProps,
|
|
35
|
+
ref
|
|
36
|
+
});
|
|
37
|
+
return null;
|
|
38
|
+
});
|
|
39
|
+
FieldErrorText.displayName = "FieldErrorText";
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/components/field/field-helper-text.tsx
|
|
43
|
+
const FieldHelperText = (0, react.forwardRef)((props, ref) => {
|
|
44
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(useFieldContext()?.getHelperTextProps(), props);
|
|
45
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.span, {
|
|
46
|
+
...mergedProps,
|
|
47
|
+
ref
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
FieldHelperText.displayName = "FieldHelperText";
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/field/field-input.tsx
|
|
54
|
+
const FieldInput = (0, react.forwardRef)((props, ref) => {
|
|
55
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(useFieldContext()?.getInputProps(), props);
|
|
56
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.input, {
|
|
57
|
+
...mergedProps,
|
|
58
|
+
ref
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
FieldInput.displayName = "FieldInput";
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/components/field/field-label.tsx
|
|
65
|
+
const FieldLabel = (0, react.forwardRef)((props, ref) => {
|
|
66
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(useFieldContext()?.getLabelProps(), props);
|
|
67
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.label, {
|
|
68
|
+
...mergedProps,
|
|
69
|
+
ref
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
FieldLabel.displayName = "FieldLabel";
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/components/field/field-required-indicator.tsx
|
|
76
|
+
const FieldRequiredIndicator = (0, react.forwardRef)(({ fallback, ...props }, ref) => {
|
|
77
|
+
const field = useFieldContext();
|
|
78
|
+
if (!field.required) return fallback;
|
|
79
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(field.getRequiredIndicatorProps(), props);
|
|
80
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.span, {
|
|
81
|
+
...mergedProps,
|
|
82
|
+
ref,
|
|
83
|
+
children: props.children ?? "*"
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
FieldRequiredIndicator.displayName = "FieldRequiredIndicator";
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/components/field/field-anatomy.ts
|
|
90
|
+
const fieldAnatomy = (0, __sprawlify_primitives_anatomy.createAnatomy)("field").parts("root", "errorText", "helperText", "input", "label", "select", "textarea", "requiredIndicator");
|
|
91
|
+
const parts = fieldAnatomy.build();
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/components/field/use-field.ts
|
|
95
|
+
const useField = (props = {}) => {
|
|
96
|
+
const fieldset = require_use_fieldset_context.useFieldsetContext();
|
|
97
|
+
const env = require_environment.useEnvironmentContext();
|
|
98
|
+
const { ids, disabled = Boolean(fieldset?.disabled), invalid = false, readOnly = false, required = false } = props;
|
|
99
|
+
const [hasErrorText, setHasErrorText] = (0, react.useState)(false);
|
|
100
|
+
const [hasHelperText, setHasHelperText] = (0, react.useState)(false);
|
|
101
|
+
const uid = (0, react.useId)();
|
|
102
|
+
const id = props.id ?? uid;
|
|
103
|
+
const rootRef = (0, react.useRef)(null);
|
|
104
|
+
const rootId = ids?.control ?? `field::${id}`;
|
|
105
|
+
const errorTextId = ids?.errorText ?? `field::${id}::error-text`;
|
|
106
|
+
const helperTextId = ids?.helperText ?? `field::${id}::helper-text`;
|
|
107
|
+
const labelId = ids?.label ?? `field::${id}::label`;
|
|
108
|
+
require_use_safe_layout_effect.useSafeLayoutEffect(() => {
|
|
109
|
+
const rootNode = rootRef.current;
|
|
110
|
+
if (!rootNode) return;
|
|
111
|
+
const checkTextElements = () => {
|
|
112
|
+
const docOrShadowRoot = env.getRootNode();
|
|
113
|
+
setHasErrorText(!!docOrShadowRoot.getElementById(errorTextId));
|
|
114
|
+
setHasHelperText(!!docOrShadowRoot.getElementById(helperTextId));
|
|
115
|
+
};
|
|
116
|
+
checkTextElements();
|
|
117
|
+
const observer = new (env.getWindow()).MutationObserver(checkTextElements);
|
|
118
|
+
observer.observe(rootNode, {
|
|
119
|
+
childList: true,
|
|
120
|
+
subtree: true
|
|
121
|
+
});
|
|
122
|
+
return () => observer.disconnect();
|
|
123
|
+
}, [
|
|
124
|
+
env,
|
|
125
|
+
errorTextId,
|
|
126
|
+
helperTextId
|
|
127
|
+
]);
|
|
128
|
+
const labelIds = (0, react.useMemo)(() => {
|
|
129
|
+
const ids$1 = [];
|
|
130
|
+
if (hasErrorText && invalid) ids$1.push(errorTextId);
|
|
131
|
+
if (hasHelperText) ids$1.push(helperTextId);
|
|
132
|
+
return ids$1.join(" ") || void 0;
|
|
133
|
+
}, [
|
|
134
|
+
invalid,
|
|
135
|
+
errorTextId,
|
|
136
|
+
helperTextId,
|
|
137
|
+
hasErrorText,
|
|
138
|
+
hasHelperText
|
|
139
|
+
]);
|
|
140
|
+
const getRootProps = (0, react.useMemo)(() => () => ({
|
|
141
|
+
...parts.root.attrs,
|
|
142
|
+
id: rootId,
|
|
143
|
+
ref: rootRef,
|
|
144
|
+
role: "group",
|
|
145
|
+
"data-disabled": (0, __sprawlify_primitives_dom_query.dataAttr)(disabled),
|
|
146
|
+
"data-invalid": (0, __sprawlify_primitives_dom_query.dataAttr)(invalid),
|
|
147
|
+
"data-readonly": (0, __sprawlify_primitives_dom_query.dataAttr)(readOnly)
|
|
148
|
+
}), [
|
|
149
|
+
disabled,
|
|
150
|
+
invalid,
|
|
151
|
+
readOnly,
|
|
152
|
+
rootId
|
|
153
|
+
]);
|
|
154
|
+
const getLabelProps = (0, react.useMemo)(() => () => ({
|
|
155
|
+
...parts.label.attrs,
|
|
156
|
+
id: labelId,
|
|
157
|
+
"data-disabled": (0, __sprawlify_primitives_dom_query.dataAttr)(disabled),
|
|
158
|
+
"data-invalid": (0, __sprawlify_primitives_dom_query.dataAttr)(invalid),
|
|
159
|
+
"data-readonly": (0, __sprawlify_primitives_dom_query.dataAttr)(readOnly),
|
|
160
|
+
"data-required": (0, __sprawlify_primitives_dom_query.dataAttr)(required),
|
|
161
|
+
htmlFor: id
|
|
162
|
+
}), [
|
|
163
|
+
disabled,
|
|
164
|
+
invalid,
|
|
165
|
+
readOnly,
|
|
166
|
+
required,
|
|
167
|
+
id,
|
|
168
|
+
labelId
|
|
169
|
+
]);
|
|
170
|
+
const getControlProps = (0, react.useMemo)(() => () => ({
|
|
171
|
+
"aria-describedby": labelIds,
|
|
172
|
+
"aria-invalid": (0, __sprawlify_primitives_dom_query.ariaAttr)(invalid),
|
|
173
|
+
"data-invalid": (0, __sprawlify_primitives_dom_query.dataAttr)(invalid),
|
|
174
|
+
"data-required": (0, __sprawlify_primitives_dom_query.dataAttr)(required),
|
|
175
|
+
"data-readonly": (0, __sprawlify_primitives_dom_query.dataAttr)(readOnly),
|
|
176
|
+
id,
|
|
177
|
+
required,
|
|
178
|
+
disabled,
|
|
179
|
+
readOnly
|
|
180
|
+
}), [
|
|
181
|
+
labelIds,
|
|
182
|
+
invalid,
|
|
183
|
+
required,
|
|
184
|
+
readOnly,
|
|
185
|
+
id,
|
|
186
|
+
disabled
|
|
187
|
+
]);
|
|
188
|
+
const getInputProps = (0, react.useMemo)(() => () => ({
|
|
189
|
+
...getControlProps(),
|
|
190
|
+
...parts.input.attrs
|
|
191
|
+
}), [getControlProps]);
|
|
192
|
+
const getTextareaProps = (0, react.useMemo)(() => () => ({
|
|
193
|
+
...getControlProps(),
|
|
194
|
+
...parts.textarea.attrs
|
|
195
|
+
}), [getControlProps]);
|
|
196
|
+
const getSelectProps = (0, react.useMemo)(() => () => ({
|
|
197
|
+
...getControlProps(),
|
|
198
|
+
...parts.select.attrs
|
|
199
|
+
}), [getControlProps]);
|
|
200
|
+
const getHelperTextProps = (0, react.useMemo)(() => () => ({
|
|
201
|
+
id: helperTextId,
|
|
202
|
+
...parts.helperText.attrs,
|
|
203
|
+
"data-disabled": (0, __sprawlify_primitives_dom_query.dataAttr)(disabled)
|
|
204
|
+
}), [disabled, helperTextId]);
|
|
205
|
+
const getErrorTextProps = (0, react.useMemo)(() => () => ({
|
|
206
|
+
id: errorTextId,
|
|
207
|
+
...parts.errorText.attrs,
|
|
208
|
+
"aria-live": "polite"
|
|
209
|
+
}), [errorTextId]);
|
|
210
|
+
const getRequiredIndicatorProps = (0, react.useMemo)(() => () => ({
|
|
211
|
+
"aria-hidden": true,
|
|
212
|
+
...parts.requiredIndicator.attrs
|
|
213
|
+
}), []);
|
|
214
|
+
return {
|
|
215
|
+
ariaDescribedby: labelIds,
|
|
216
|
+
ids: {
|
|
217
|
+
root: rootId,
|
|
218
|
+
control: id,
|
|
219
|
+
label: labelId,
|
|
220
|
+
errorText: errorTextId,
|
|
221
|
+
helperText: helperTextId
|
|
222
|
+
},
|
|
223
|
+
refs: { rootRef },
|
|
224
|
+
disabled,
|
|
225
|
+
invalid,
|
|
226
|
+
readOnly,
|
|
227
|
+
required,
|
|
228
|
+
getLabelProps,
|
|
229
|
+
getRootProps,
|
|
230
|
+
getInputProps,
|
|
231
|
+
getTextareaProps,
|
|
232
|
+
getSelectProps,
|
|
233
|
+
getHelperTextProps,
|
|
234
|
+
getErrorTextProps,
|
|
235
|
+
getRequiredIndicatorProps
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/components/field/field-root.tsx
|
|
241
|
+
const splitRootProps = require_create_split_props.createSplitProps();
|
|
242
|
+
const FieldRoot = (0, react.forwardRef)((props, ref) => {
|
|
243
|
+
const [useFieldProps, localProps] = splitRootProps(props, [
|
|
244
|
+
"id",
|
|
245
|
+
"ids",
|
|
246
|
+
"disabled",
|
|
247
|
+
"invalid",
|
|
248
|
+
"readOnly",
|
|
249
|
+
"required"
|
|
250
|
+
]);
|
|
251
|
+
const field = useField(useFieldProps);
|
|
252
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(field.getRootProps(), localProps);
|
|
253
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldProvider, {
|
|
254
|
+
value: field,
|
|
255
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.div, {
|
|
256
|
+
...mergedProps,
|
|
257
|
+
ref: require_compose_refs.composeRefs(ref, field.refs.rootRef)
|
|
258
|
+
})
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
FieldRoot.displayName = "FieldRoot";
|
|
262
|
+
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/components/field/field-root-provider.tsx
|
|
265
|
+
const splitRootProviderProps = require_create_split_props.createSplitProps();
|
|
266
|
+
const FieldRootProvider = (0, react.forwardRef)((props, ref) => {
|
|
267
|
+
const [{ value: field }, localProps] = splitRootProviderProps(props, ["value"]);
|
|
268
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(field.getRootProps(), localProps);
|
|
269
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldProvider, {
|
|
270
|
+
value: field,
|
|
271
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.div, {
|
|
272
|
+
...mergedProps,
|
|
273
|
+
ref
|
|
274
|
+
})
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
FieldRootProvider.displayName = "FieldRootProvider";
|
|
278
|
+
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/components/field/field-select.tsx
|
|
281
|
+
const FieldSelect = (0, react.forwardRef)((props, ref) => {
|
|
282
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(useFieldContext()?.getSelectProps(), props);
|
|
283
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.select, {
|
|
284
|
+
...mergedProps,
|
|
285
|
+
ref
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
FieldSelect.displayName = "FieldSelect";
|
|
289
|
+
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/components/field/field-textarea.tsx
|
|
292
|
+
const FieldTextarea = (0, react.forwardRef)((props, ref) => {
|
|
293
|
+
const { autoresize, ...textareaProps } = props;
|
|
294
|
+
const textareaRef = (0, react.useRef)(null);
|
|
295
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(useFieldContext()?.getTextareaProps(), { style: { resize: autoresize ? "none" : void 0 } }, textareaProps);
|
|
296
|
+
(0, react.useEffect)(() => {
|
|
297
|
+
if (!autoresize) return;
|
|
298
|
+
return (0, __sprawlify_primitives_auto_resize.autoresizeTextarea)(textareaRef.current);
|
|
299
|
+
}, [autoresize]);
|
|
300
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.textarea, {
|
|
301
|
+
...mergedProps,
|
|
302
|
+
ref: require_compose_refs.composeRefs(ref, textareaRef)
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
FieldTextarea.displayName = "FieldTextarea";
|
|
306
|
+
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/components/field/field.ts
|
|
309
|
+
var field_exports = /* @__PURE__ */ require_chunk.__export({
|
|
310
|
+
Context: () => FieldContext,
|
|
311
|
+
ErrorText: () => FieldErrorText,
|
|
312
|
+
HelperText: () => FieldHelperText,
|
|
313
|
+
Input: () => FieldInput,
|
|
314
|
+
Label: () => FieldLabel,
|
|
315
|
+
RequiredIndicator: () => FieldRequiredIndicator,
|
|
316
|
+
Root: () => FieldRoot,
|
|
317
|
+
RootProvider: () => FieldRootProvider,
|
|
318
|
+
Select: () => FieldSelect,
|
|
319
|
+
Textarea: () => FieldTextarea
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
//#endregion
|
|
323
|
+
Object.defineProperty(exports, 'FieldContext', {
|
|
324
|
+
enumerable: true,
|
|
325
|
+
get: function () {
|
|
326
|
+
return FieldContext;
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
Object.defineProperty(exports, 'FieldErrorText', {
|
|
330
|
+
enumerable: true,
|
|
331
|
+
get: function () {
|
|
332
|
+
return FieldErrorText;
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
Object.defineProperty(exports, 'FieldHelperText', {
|
|
336
|
+
enumerable: true,
|
|
337
|
+
get: function () {
|
|
338
|
+
return FieldHelperText;
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
Object.defineProperty(exports, 'FieldInput', {
|
|
342
|
+
enumerable: true,
|
|
343
|
+
get: function () {
|
|
344
|
+
return FieldInput;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
Object.defineProperty(exports, 'FieldLabel', {
|
|
348
|
+
enumerable: true,
|
|
349
|
+
get: function () {
|
|
350
|
+
return FieldLabel;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
Object.defineProperty(exports, 'FieldRequiredIndicator', {
|
|
354
|
+
enumerable: true,
|
|
355
|
+
get: function () {
|
|
356
|
+
return FieldRequiredIndicator;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
Object.defineProperty(exports, 'FieldRoot', {
|
|
360
|
+
enumerable: true,
|
|
361
|
+
get: function () {
|
|
362
|
+
return FieldRoot;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
Object.defineProperty(exports, 'FieldRootProvider', {
|
|
366
|
+
enumerable: true,
|
|
367
|
+
get: function () {
|
|
368
|
+
return FieldRootProvider;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
Object.defineProperty(exports, 'FieldSelect', {
|
|
372
|
+
enumerable: true,
|
|
373
|
+
get: function () {
|
|
374
|
+
return FieldSelect;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
Object.defineProperty(exports, 'FieldTextarea', {
|
|
378
|
+
enumerable: true,
|
|
379
|
+
get: function () {
|
|
380
|
+
return FieldTextarea;
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
Object.defineProperty(exports, 'fieldAnatomy', {
|
|
384
|
+
enumerable: true,
|
|
385
|
+
get: function () {
|
|
386
|
+
return fieldAnatomy;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
Object.defineProperty(exports, 'field_exports', {
|
|
390
|
+
enumerable: true,
|
|
391
|
+
get: function () {
|
|
392
|
+
return field_exports;
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
Object.defineProperty(exports, 'useField', {
|
|
396
|
+
enumerable: true,
|
|
397
|
+
get: function () {
|
|
398
|
+
return useField;
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
Object.defineProperty(exports, 'useFieldContext', {
|
|
402
|
+
enumerable: true,
|
|
403
|
+
get: function () {
|
|
404
|
+
return useFieldContext;
|
|
405
|
+
}
|
|
406
|
+
});
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-BYnRvbsk.cjs');
|
|
2
|
+
const require_environment = require('./environment-CvilmfQt.cjs');
|
|
3
|
+
const require_compose_refs = require('./compose-refs-C5QNDywq.cjs');
|
|
4
|
+
const require_factory = require('./factory-C166evrS.cjs');
|
|
5
|
+
const require_create_split_props = require('./create-split-props-Dp4TWOyM.cjs');
|
|
6
|
+
const require_use_fieldset_context = require('./use-fieldset-context-CCQLmNLL.cjs');
|
|
7
|
+
const require_use_safe_layout_effect = require('./use-safe-layout-effect-C2GgvNT3.cjs');
|
|
8
|
+
let react = require("react");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
let __sprawlify_primitives_dom_query = require("@sprawlify/primitives/dom-query");
|
|
11
|
+
let __sprawlify_primitives_anatomy = require("@sprawlify/primitives/anatomy");
|
|
12
|
+
let __sprawlify_primitives_core = require("@sprawlify/primitives/core");
|
|
13
|
+
|
|
14
|
+
//#region src/components/fieldset/fieldset-context.tsx
|
|
15
|
+
const FieldsetContext = (props) => props.children(require_use_fieldset_context.useFieldsetContext());
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/components/fieldset/fieldset-error-text.tsx
|
|
19
|
+
const FieldsetErrorText = (0, react.forwardRef)((props, ref) => {
|
|
20
|
+
const fieldset = require_use_fieldset_context.useFieldsetContext();
|
|
21
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(fieldset.getErrorTextProps(), props);
|
|
22
|
+
return fieldset.invalid ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.span, {
|
|
23
|
+
...mergedProps,
|
|
24
|
+
ref
|
|
25
|
+
}) : null;
|
|
26
|
+
});
|
|
27
|
+
FieldsetErrorText.displayName = "FieldsetErrorText";
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/components/fieldset/fieldset-helper-text.tsx
|
|
31
|
+
const FieldsetHelperText = (0, react.forwardRef)((props, ref) => {
|
|
32
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(require_use_fieldset_context.useFieldsetContext().getHelperTextProps(), props);
|
|
33
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.span, {
|
|
34
|
+
...mergedProps,
|
|
35
|
+
ref
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
FieldsetHelperText.displayName = "FieldsetHelperText";
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/components/fieldset/fieldset-legend.tsx
|
|
42
|
+
const FieldsetLegend = (0, react.forwardRef)((props, ref) => {
|
|
43
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(require_use_fieldset_context.useFieldsetContext().getLegendProps(), props);
|
|
44
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.legend, {
|
|
45
|
+
...mergedProps,
|
|
46
|
+
ref
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
FieldsetLegend.displayName = "FieldsetLegend";
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/components/fieldset/fieldset-anatomy.ts
|
|
53
|
+
const fieldsetAnatomy = (0, __sprawlify_primitives_anatomy.createAnatomy)("fieldset").parts("root", "errorText", "helperText", "legend");
|
|
54
|
+
const parts = fieldsetAnatomy.build();
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/components/fieldset/use-fieldset.ts
|
|
58
|
+
const useFieldset = (props = {}) => {
|
|
59
|
+
const { disabled = false, invalid = false } = props;
|
|
60
|
+
const env = require_environment.useEnvironmentContext();
|
|
61
|
+
const [textElements, setTextElements] = (0, react.useState)({
|
|
62
|
+
hasErrorText: false,
|
|
63
|
+
hasHelperText: false
|
|
64
|
+
});
|
|
65
|
+
const uid = (0, react.useId)();
|
|
66
|
+
const id = props.id ?? uid;
|
|
67
|
+
const rootRef = (0, react.useRef)(null);
|
|
68
|
+
const legendId = `fieldset::${id}::legend`;
|
|
69
|
+
const errorTextId = `fieldset::${id}::error-text`;
|
|
70
|
+
const helperTextId = `fieldset::${id}::helper-text`;
|
|
71
|
+
require_use_safe_layout_effect.useSafeLayoutEffect(() => {
|
|
72
|
+
const rootNode = rootRef.current;
|
|
73
|
+
if (!rootNode) return;
|
|
74
|
+
const checkTextElements = () => {
|
|
75
|
+
const docOrShadowRoot = env.getRootNode();
|
|
76
|
+
setTextElements({
|
|
77
|
+
hasErrorText: !!docOrShadowRoot.getElementById(errorTextId),
|
|
78
|
+
hasHelperText: !!docOrShadowRoot.getElementById(helperTextId)
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
checkTextElements();
|
|
82
|
+
const observer = new (env.getWindow()).MutationObserver(checkTextElements);
|
|
83
|
+
observer.observe(rootNode, {
|
|
84
|
+
childList: true,
|
|
85
|
+
subtree: true
|
|
86
|
+
});
|
|
87
|
+
return () => observer.disconnect();
|
|
88
|
+
}, [
|
|
89
|
+
env,
|
|
90
|
+
errorTextId,
|
|
91
|
+
helperTextId
|
|
92
|
+
]);
|
|
93
|
+
const ids = [];
|
|
94
|
+
if (textElements.hasErrorText && invalid) ids.push(errorTextId);
|
|
95
|
+
if (textElements.hasHelperText) ids.push(helperTextId);
|
|
96
|
+
const labelIds = ids.length > 0 ? ids.join(" ") : void 0;
|
|
97
|
+
const getRootProps = () => ({
|
|
98
|
+
...parts.root.attrs,
|
|
99
|
+
ref: rootRef,
|
|
100
|
+
disabled,
|
|
101
|
+
"data-disabled": (0, __sprawlify_primitives_dom_query.dataAttr)(disabled),
|
|
102
|
+
"data-invalid": (0, __sprawlify_primitives_dom_query.dataAttr)(invalid),
|
|
103
|
+
"aria-labelledby": legendId,
|
|
104
|
+
"aria-describedby": labelIds
|
|
105
|
+
});
|
|
106
|
+
const getLegendProps = () => ({
|
|
107
|
+
id: legendId,
|
|
108
|
+
...parts.legend.attrs,
|
|
109
|
+
"data-disabled": (0, __sprawlify_primitives_dom_query.dataAttr)(disabled),
|
|
110
|
+
"data-invalid": (0, __sprawlify_primitives_dom_query.dataAttr)(invalid)
|
|
111
|
+
});
|
|
112
|
+
const getHelperTextProps = () => ({
|
|
113
|
+
id: helperTextId,
|
|
114
|
+
...parts.helperText.attrs
|
|
115
|
+
});
|
|
116
|
+
const getErrorTextProps = () => ({
|
|
117
|
+
id: errorTextId,
|
|
118
|
+
...parts.errorText.attrs,
|
|
119
|
+
"aria-live": "polite"
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
refs: { rootRef },
|
|
123
|
+
ids: {
|
|
124
|
+
legend: legendId,
|
|
125
|
+
errorText: errorTextId,
|
|
126
|
+
helperText: helperTextId
|
|
127
|
+
},
|
|
128
|
+
disabled,
|
|
129
|
+
invalid,
|
|
130
|
+
getRootProps,
|
|
131
|
+
getLegendProps,
|
|
132
|
+
getHelperTextProps,
|
|
133
|
+
getErrorTextProps
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/components/fieldset/fieldset-root.tsx
|
|
139
|
+
const splitRootProps = require_create_split_props.createSplitProps();
|
|
140
|
+
const FieldsetRoot = (0, react.forwardRef)((props, ref) => {
|
|
141
|
+
const [useFieldsetProps, localProps] = splitRootProps(props, [
|
|
142
|
+
"id",
|
|
143
|
+
"disabled",
|
|
144
|
+
"invalid"
|
|
145
|
+
]);
|
|
146
|
+
const fieldset = useFieldset(useFieldsetProps);
|
|
147
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(fieldset.getRootProps(), localProps);
|
|
148
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_use_fieldset_context.FieldsetProvider, {
|
|
149
|
+
value: fieldset,
|
|
150
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.fieldset, {
|
|
151
|
+
...mergedProps,
|
|
152
|
+
ref: require_compose_refs.composeRefs(ref, fieldset.refs.rootRef)
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
FieldsetRoot.displayName = "FieldsetRoot";
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/components/fieldset/fieldset-root-provider.tsx
|
|
160
|
+
const splitRootProviderProps = require_create_split_props.createSplitProps();
|
|
161
|
+
const FieldsetRootProvider = (0, react.forwardRef)((props, ref) => {
|
|
162
|
+
const [{ value: fieldset }, localProps] = splitRootProviderProps(props, ["value"]);
|
|
163
|
+
const mergedProps = (0, __sprawlify_primitives_core.mergeProps)(fieldset.getRootProps(), localProps);
|
|
164
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_use_fieldset_context.FieldsetProvider, {
|
|
165
|
+
value: fieldset,
|
|
166
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.sprawlify.fieldset, {
|
|
167
|
+
...mergedProps,
|
|
168
|
+
ref
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
FieldsetRootProvider.displayName = "FieldsetRootProvider";
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/components/fieldset/fieldset.ts
|
|
176
|
+
var fieldset_exports = /* @__PURE__ */ require_chunk.__export({
|
|
177
|
+
Context: () => FieldsetContext,
|
|
178
|
+
ErrorText: () => FieldsetErrorText,
|
|
179
|
+
HelperText: () => FieldsetHelperText,
|
|
180
|
+
Legend: () => FieldsetLegend,
|
|
181
|
+
Root: () => FieldsetRoot,
|
|
182
|
+
RootProvider: () => FieldsetRootProvider
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
//#endregion
|
|
186
|
+
Object.defineProperty(exports, 'FieldsetContext', {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function () {
|
|
189
|
+
return FieldsetContext;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
Object.defineProperty(exports, 'FieldsetErrorText', {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
get: function () {
|
|
195
|
+
return FieldsetErrorText;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
Object.defineProperty(exports, 'FieldsetHelperText', {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
get: function () {
|
|
201
|
+
return FieldsetHelperText;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
Object.defineProperty(exports, 'FieldsetLegend', {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
get: function () {
|
|
207
|
+
return FieldsetLegend;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
Object.defineProperty(exports, 'FieldsetRoot', {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
get: function () {
|
|
213
|
+
return FieldsetRoot;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
Object.defineProperty(exports, 'FieldsetRootProvider', {
|
|
217
|
+
enumerable: true,
|
|
218
|
+
get: function () {
|
|
219
|
+
return FieldsetRootProvider;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
Object.defineProperty(exports, 'fieldsetAnatomy', {
|
|
223
|
+
enumerable: true,
|
|
224
|
+
get: function () {
|
|
225
|
+
return fieldsetAnatomy;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
Object.defineProperty(exports, 'fieldset_exports', {
|
|
229
|
+
enumerable: true,
|
|
230
|
+
get: function () {
|
|
231
|
+
return fieldset_exports;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
Object.defineProperty(exports, 'useFieldset', {
|
|
235
|
+
enumerable: true,
|
|
236
|
+
get: function () {
|
|
237
|
+
return useFieldset;
|
|
238
|
+
}
|
|
239
|
+
});
|