@page-speed/forms 0.5.7 → 0.5.9
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/FormContext-089h0j0Q.d.ts +153 -0
- package/dist/FormContext-iHzBALZa.d.cts +153 -0
- package/dist/{chunk-A7R6GEMA.js → chunk-455PI4LV.js} +84 -3
- package/dist/chunk-455PI4LV.js.map +1 -0
- package/dist/{chunk-5WWMVS2I.js → chunk-4ROWNTY6.js} +334 -415
- package/dist/chunk-4ROWNTY6.js.map +1 -0
- package/dist/{chunk-FIDKDYT7.cjs → chunk-ED4UK63G.cjs} +439 -521
- package/dist/chunk-ED4UK63G.cjs.map +1 -0
- package/dist/{chunk-Q7VR374Y.js → chunk-MJYEXJ3U.js} +3 -3
- package/dist/{chunk-Q7VR374Y.js.map → chunk-MJYEXJ3U.js.map} +1 -1
- package/dist/{chunk-KPHMVGTU.cjs → chunk-MUBEMXI7.cjs} +6 -6
- package/dist/{chunk-KPHMVGTU.cjs.map → chunk-MUBEMXI7.cjs.map} +1 -1
- package/dist/chunk-OF6ZYT7A.cjs +287 -0
- package/dist/chunk-OF6ZYT7A.cjs.map +1 -0
- package/dist/{chunk-QQSBW6N3.cjs → chunk-QRI5TMES.cjs} +85 -2
- package/dist/chunk-QRI5TMES.cjs.map +1 -0
- package/dist/chunk-TOPOO33Z.js +263 -0
- package/dist/chunk-TOPOO33Z.js.map +1 -0
- package/dist/core.cjs +13 -9
- package/dist/core.d.cts +66 -141
- package/dist/core.d.ts +66 -141
- package/dist/core.js +3 -3
- package/dist/index.cjs +14 -14
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/inputs.cjs +16 -16
- package/dist/inputs.d.cts +1 -1
- package/dist/inputs.d.ts +1 -1
- package/dist/inputs.js +2 -2
- package/dist/integration.cjs +17 -17
- package/dist/integration.d.cts +1 -1
- package/dist/integration.d.ts +1 -1
- package/dist/integration.js +3 -3
- package/dist/{types-CnOCn7b3.d.ts → types-BemGfSPA.d.cts} +27 -1
- package/dist/{types-CnOCn7b3.d.cts → types-BemGfSPA.d.ts} +27 -1
- package/dist/validation-rules.d.cts +1 -1
- package/dist/validation-rules.d.ts +1 -1
- package/dist/validation-utils.d.cts +1 -1
- package/dist/validation-utils.d.ts +1 -1
- package/dist/validation-valibot.d.cts +1 -1
- package/dist/validation-valibot.d.ts +1 -1
- package/dist/validation.d.cts +1 -1
- package/dist/validation.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-5WWMVS2I.js.map +0 -1
- package/dist/chunk-A7R6GEMA.js.map +0 -1
- package/dist/chunk-FIDKDYT7.cjs.map +0 -1
- package/dist/chunk-N2HOVRRN.js +0 -150
- package/dist/chunk-N2HOVRRN.js.map +0 -1
- package/dist/chunk-O4ZLR7AN.cjs +0 -173
- package/dist/chunk-O4ZLR7AN.cjs.map +0 -1
- package/dist/chunk-QQSBW6N3.cjs.map +0 -1
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkMUBEMXI7_cjs = require('./chunk-MUBEMXI7.cjs');
|
|
4
|
+
var chunkQRI5TMES_cjs = require('./chunk-QRI5TMES.cjs');
|
|
5
|
+
var React4 = require('react');
|
|
6
|
+
var classVarianceAuthority = require('class-variance-authority');
|
|
7
|
+
require('radix-ui');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
|
|
28
|
+
|
|
29
|
+
function renderMessage(message, fallbackClassName, className) {
|
|
30
|
+
if (typeof message === "string") {
|
|
31
|
+
return /* @__PURE__ */ React4__namespace.createElement(
|
|
32
|
+
"p",
|
|
33
|
+
{
|
|
34
|
+
className: chunkQRI5TMES_cjs.cn(
|
|
35
|
+
"text-sm font-medium text-center text-balance",
|
|
36
|
+
className
|
|
37
|
+
)
|
|
38
|
+
},
|
|
39
|
+
message
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ React4__namespace.createElement("div", { className: chunkQRI5TMES_cjs.cn(fallbackClassName, className) }, message);
|
|
43
|
+
}
|
|
44
|
+
function FormFeedback({
|
|
45
|
+
successMessage,
|
|
46
|
+
submissionError,
|
|
47
|
+
successMessageClassName,
|
|
48
|
+
errorMessageClassName
|
|
49
|
+
}) {
|
|
50
|
+
if (!successMessage && !submissionError) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */ React4__namespace.createElement(React4__namespace.Fragment, null, successMessage ? /* @__PURE__ */ React4__namespace.createElement(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
className: chunkQRI5TMES_cjs.cn(
|
|
57
|
+
"rounded-md border border-primary bg-primary px-4 py-3 shadow-sm",
|
|
58
|
+
successMessageClassName
|
|
59
|
+
),
|
|
60
|
+
role: "status",
|
|
61
|
+
"aria-live": "polite"
|
|
62
|
+
},
|
|
63
|
+
renderMessage(
|
|
64
|
+
successMessage,
|
|
65
|
+
"text-primary-foreground",
|
|
66
|
+
"text-primary-foreground"
|
|
67
|
+
)
|
|
68
|
+
) : null, submissionError ? /* @__PURE__ */ React4__namespace.createElement(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
className: chunkQRI5TMES_cjs.cn(
|
|
72
|
+
"rounded-md border border-destructive bg-destructive px-4 py-3 shadow-sm",
|
|
73
|
+
errorMessageClassName
|
|
74
|
+
),
|
|
75
|
+
role: "alert",
|
|
76
|
+
"aria-live": "assertive"
|
|
77
|
+
},
|
|
78
|
+
renderMessage(
|
|
79
|
+
submissionError,
|
|
80
|
+
"text-destructive-foreground",
|
|
81
|
+
"text-destructive-foreground"
|
|
82
|
+
)
|
|
83
|
+
) : null);
|
|
84
|
+
}
|
|
85
|
+
FormFeedback.displayName = "FormFeedback";
|
|
86
|
+
var buttonGroupVariants = classVarianceAuthority.cva(
|
|
87
|
+
"flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",
|
|
88
|
+
{
|
|
89
|
+
variants: {
|
|
90
|
+
orientation: {
|
|
91
|
+
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
92
|
+
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
defaultVariants: {
|
|
96
|
+
orientation: "horizontal"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
function ButtonGroup({
|
|
101
|
+
className,
|
|
102
|
+
orientation,
|
|
103
|
+
...props
|
|
104
|
+
}) {
|
|
105
|
+
return /* @__PURE__ */ React4__namespace.createElement(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
role: "group",
|
|
109
|
+
"data-slot": "button-group",
|
|
110
|
+
"data-orientation": orientation,
|
|
111
|
+
className: chunkQRI5TMES_cjs.cn(buttonGroupVariants({ orientation }), className),
|
|
112
|
+
...props
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/core/button-group-form.tsx
|
|
118
|
+
function ButtonGroupForm({
|
|
119
|
+
name,
|
|
120
|
+
label,
|
|
121
|
+
inputProps,
|
|
122
|
+
submitLabel = "Submit",
|
|
123
|
+
submitVariant = "default",
|
|
124
|
+
size = "default",
|
|
125
|
+
isSubmitting = false,
|
|
126
|
+
className,
|
|
127
|
+
labelClassName
|
|
128
|
+
}) {
|
|
129
|
+
const inputId = `button-group-input-${name}`;
|
|
130
|
+
const inputSizeClasses = {
|
|
131
|
+
xs: "h-8 text-xs px-3",
|
|
132
|
+
sm: "h-9 text-sm px-3",
|
|
133
|
+
default: "h-10 text-sm px-4",
|
|
134
|
+
lg: "h-12 text-base px-6"
|
|
135
|
+
};
|
|
136
|
+
const buttonSizes = {
|
|
137
|
+
xs: "xs",
|
|
138
|
+
sm: "sm",
|
|
139
|
+
default: "default",
|
|
140
|
+
lg: "lg"
|
|
141
|
+
};
|
|
142
|
+
return /* @__PURE__ */ React4__namespace.createElement("div", { className: chunkQRI5TMES_cjs.cn("space-y-2", className) }, label && /* @__PURE__ */ React4__namespace.createElement(chunkQRI5TMES_cjs.FieldLabel, { htmlFor: inputId, className: labelClassName }, label), /* @__PURE__ */ React4__namespace.createElement(ButtonGroup, null, /* @__PURE__ */ React4__namespace.createElement(
|
|
143
|
+
chunkQRI5TMES_cjs.TextInput,
|
|
144
|
+
{
|
|
145
|
+
...inputProps,
|
|
146
|
+
id: inputId,
|
|
147
|
+
className: chunkQRI5TMES_cjs.cn(
|
|
148
|
+
inputSizeClasses[size],
|
|
149
|
+
"border-r-0 rounded-r-none focus-visible:z-10",
|
|
150
|
+
inputProps.className
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
), /* @__PURE__ */ React4__namespace.createElement(
|
|
154
|
+
chunkQRI5TMES_cjs.Button,
|
|
155
|
+
{
|
|
156
|
+
size: buttonSizes[size],
|
|
157
|
+
type: "submit",
|
|
158
|
+
variant: submitVariant,
|
|
159
|
+
disabled: isSubmitting,
|
|
160
|
+
className: "rounded-l-none"
|
|
161
|
+
},
|
|
162
|
+
submitLabel
|
|
163
|
+
)));
|
|
164
|
+
}
|
|
165
|
+
ButtonGroupForm.displayName = "ButtonGroupForm";
|
|
166
|
+
|
|
167
|
+
// src/core/Form.tsx
|
|
168
|
+
function Form({
|
|
169
|
+
form,
|
|
170
|
+
children,
|
|
171
|
+
fields,
|
|
172
|
+
className,
|
|
173
|
+
action,
|
|
174
|
+
method,
|
|
175
|
+
noValidate = true,
|
|
176
|
+
submissionConfig,
|
|
177
|
+
successMessage,
|
|
178
|
+
submissionError,
|
|
179
|
+
successMessageClassName,
|
|
180
|
+
errorMessageClassName,
|
|
181
|
+
onNewSubmission,
|
|
182
|
+
notificationConfig,
|
|
183
|
+
styleConfig,
|
|
184
|
+
formConfig,
|
|
185
|
+
...props
|
|
186
|
+
}) {
|
|
187
|
+
const handleFormSubmit = React4__namespace.useCallback(
|
|
188
|
+
async (e) => {
|
|
189
|
+
try {
|
|
190
|
+
await form.handleSubmit(e);
|
|
191
|
+
} catch {
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
[form]
|
|
195
|
+
);
|
|
196
|
+
const resolvedClassName = className ?? styleConfig?.formClassName;
|
|
197
|
+
const resolvedAction = action ?? formConfig?.endpoint;
|
|
198
|
+
const resolvedMethod = method ?? formConfig?.method ?? "post";
|
|
199
|
+
const resolvedSubmissionConfig = submissionConfig ?? formConfig?.submissionConfig;
|
|
200
|
+
const resolvedSuccessMessage = successMessage ?? notificationConfig?.successMessage;
|
|
201
|
+
const resolvedSubmissionError = submissionError ?? notificationConfig?.submissionError;
|
|
202
|
+
const resolvedSuccessMessageClassName = successMessageClassName ?? styleConfig?.successMessageClassName;
|
|
203
|
+
const resolvedErrorMessageClassName = errorMessageClassName ?? styleConfig?.errorMessageClassName;
|
|
204
|
+
const behavior = resolvedSubmissionConfig?.behavior || "showConfirmation";
|
|
205
|
+
const shouldManageSubmissionUi = resolvedSubmissionConfig !== void 0 || resolvedSuccessMessage !== void 0 || resolvedSuccessMessageClassName !== void 0 || resolvedErrorMessageClassName !== void 0 || resolvedSubmissionError != null || onNewSubmission !== void 0;
|
|
206
|
+
const hasSubmissionError = Boolean(resolvedSubmissionError);
|
|
207
|
+
const isSubmissionSuccessful = shouldManageSubmissionUi && form.status === "success" && !hasSubmissionError;
|
|
208
|
+
const defaultSuccessMessage = behavior === "redirect" ? "Form submitted successfully. Redirecting..." : "Thank you. Your form has been submitted successfully.";
|
|
209
|
+
const finalSuccessMessage = resolvedSuccessMessage ?? defaultSuccessMessage;
|
|
210
|
+
const shouldRenderCustomComponent = isSubmissionSuccessful && behavior === "renderCustomComponent" && Boolean(resolvedSubmissionConfig?.customComponent);
|
|
211
|
+
const newSubmissionAction = resolvedSubmissionConfig?.newFormSubmissionAction;
|
|
212
|
+
const showNewSubmissionAction = isSubmissionSuccessful && (typeof newSubmissionAction?.enable === "boolean" ? newSubmissionAction.enable : Boolean(newSubmissionAction?.label));
|
|
213
|
+
const newSubmissionLabel = newSubmissionAction?.label ?? "Submit another response";
|
|
214
|
+
const handleNewSubmission = React4__namespace.useCallback(() => {
|
|
215
|
+
form.resetForm();
|
|
216
|
+
onNewSubmission?.();
|
|
217
|
+
}, [form, onNewSubmission]);
|
|
218
|
+
const formLayout = formConfig?.formLayout ?? "standard";
|
|
219
|
+
const isButtonGroupLayout = formLayout === "button-group";
|
|
220
|
+
const hasTextField = fields && fields.length === 1 && fields[0] && ["text", "email", "password", "url", "tel", "search"].includes(fields[0].type);
|
|
221
|
+
const shouldUseButtonGroup = isButtonGroupLayout && hasTextField;
|
|
222
|
+
const buttonGroupContent = React4__namespace.useMemo(() => {
|
|
223
|
+
if (!shouldUseButtonGroup || !fields || fields.length === 0) return null;
|
|
224
|
+
const field = fields[0];
|
|
225
|
+
const fieldProps = form.getFieldProps(field.name);
|
|
226
|
+
return /* @__PURE__ */ React4__namespace.createElement(
|
|
227
|
+
ButtonGroupForm,
|
|
228
|
+
{
|
|
229
|
+
name: field.name,
|
|
230
|
+
label: field.label,
|
|
231
|
+
inputProps: {
|
|
232
|
+
name: fieldProps.name,
|
|
233
|
+
value: fieldProps.value,
|
|
234
|
+
onChange: fieldProps.onChange,
|
|
235
|
+
onBlur: fieldProps.onBlur,
|
|
236
|
+
type: field.type,
|
|
237
|
+
placeholder: field.placeholder,
|
|
238
|
+
required: field.required,
|
|
239
|
+
disabled: field.disabled
|
|
240
|
+
},
|
|
241
|
+
submitLabel: formConfig?.submitLabel,
|
|
242
|
+
submitVariant: formConfig?.submitVariant,
|
|
243
|
+
size: formConfig?.buttonGroupSize,
|
|
244
|
+
isSubmitting: form.isSubmitting
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
}, [shouldUseButtonGroup, fields, form, formConfig]);
|
|
248
|
+
return /* @__PURE__ */ React4__namespace.createElement(chunkMUBEMXI7_cjs.FormContext.Provider, { value: form }, /* @__PURE__ */ React4__namespace.createElement(
|
|
249
|
+
"form",
|
|
250
|
+
{
|
|
251
|
+
onSubmit: handleFormSubmit,
|
|
252
|
+
action: resolvedAction,
|
|
253
|
+
method: resolvedMethod,
|
|
254
|
+
noValidate,
|
|
255
|
+
className: resolvedClassName,
|
|
256
|
+
...props
|
|
257
|
+
},
|
|
258
|
+
isSubmissionSuccessful ? /* @__PURE__ */ React4__namespace.createElement("div", { className: "space-y-4" }, shouldRenderCustomComponent ? resolvedSubmissionConfig?.customComponent : /* @__PURE__ */ React4__namespace.createElement(
|
|
259
|
+
FormFeedback,
|
|
260
|
+
{
|
|
261
|
+
successMessage: finalSuccessMessage,
|
|
262
|
+
successMessageClassName: resolvedSuccessMessageClassName
|
|
263
|
+
}
|
|
264
|
+
), showNewSubmissionAction ? /* @__PURE__ */ React4__namespace.createElement(
|
|
265
|
+
chunkQRI5TMES_cjs.Button,
|
|
266
|
+
{
|
|
267
|
+
type: "button",
|
|
268
|
+
variant: "outline",
|
|
269
|
+
onClick: handleNewSubmission
|
|
270
|
+
},
|
|
271
|
+
newSubmissionLabel
|
|
272
|
+
) : null) : /* @__PURE__ */ React4__namespace.createElement(React4__namespace.Fragment, null, shouldUseButtonGroup ? buttonGroupContent : children, resolvedSubmissionError ? /* @__PURE__ */ React4__namespace.createElement("div", { className: "mt-4" }, /* @__PURE__ */ React4__namespace.createElement(
|
|
273
|
+
FormFeedback,
|
|
274
|
+
{
|
|
275
|
+
submissionError: resolvedSubmissionError,
|
|
276
|
+
errorMessageClassName: resolvedErrorMessageClassName
|
|
277
|
+
}
|
|
278
|
+
)) : null)
|
|
279
|
+
));
|
|
280
|
+
}
|
|
281
|
+
Form.displayName = "Form";
|
|
282
|
+
|
|
283
|
+
exports.ButtonGroupForm = ButtonGroupForm;
|
|
284
|
+
exports.Form = Form;
|
|
285
|
+
exports.FormFeedback = FormFeedback;
|
|
286
|
+
//# sourceMappingURL=chunk-OF6ZYT7A.cjs.map
|
|
287
|
+
//# sourceMappingURL=chunk-OF6ZYT7A.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/form-feedback.tsx","../src/components/ui/button-group.tsx","../src/core/button-group-form.tsx","../src/core/Form.tsx"],"names":["React","cn","cva","React2","React3","FieldLabel","TextInput","Button","React4","FormContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,SAAS,aAAA,CACP,OAAA,EACA,iBAAA,EACA,SAAA,EACA;AACA,EAAA,IAAI,OAAO,YAAY,QAAA,EAAU;AAC/B,IAAA,uBACEA,iBAAA,CAAA,aAAA;AAAA,MAAC,GAAA;AAAA,MAAA;AAAA,QACC,SAAA,EAAWC,oBAAA;AAAA,UACT,8CAAA;AAAA,UACA;AAAA;AACF,OAAA;AAAA,MAEC;AAAA,KACH;AAAA,EAEJ;AAEA,EAAA,uDAAQ,KAAA,EAAA,EAAI,SAAA,EAAWA,qBAAG,iBAAA,EAA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AAA,QACjB,qBAAA,EAAuB;AAAA;AAAA,KAE3B,IACE,IACN;AAAA,GAGN,CAAA;AAEJ;AAEA,IAAA,CAAK,WAAA,GAAc,MAAA","file":"chunk-OF6ZYT7A.cjs","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\nexport interface FormFeedbackProps {\n successMessage?: React.ReactNode;\n submissionError?: React.ReactNode;\n successMessageClassName?: string;\n errorMessageClassName?: string;\n}\n\nfunction renderMessage(\n message: React.ReactNode,\n fallbackClassName: string,\n className?: string,\n) {\n if (typeof message === \"string\") {\n return (\n <p\n className={cn(\n \"text-sm font-medium text-center text-balance\",\n className,\n )}\n >\n {message}\n </p>\n );\n }\n\n return <div className={cn(fallbackClassName, className)}>{message}</div>;\n}\n\nexport function FormFeedback({\n successMessage,\n submissionError,\n successMessageClassName,\n errorMessageClassName,\n}: FormFeedbackProps) {\n if (!successMessage && !submissionError) {\n return null;\n }\n\n return (\n <>\n {successMessage ? (\n <div\n className={cn(\n \"rounded-md border border-primary bg-primary px-4 py-3 shadow-sm\",\n successMessageClassName,\n )}\n role=\"status\"\n aria-live=\"polite\"\n >\n {renderMessage(\n successMessage,\n \"text-primary-foreground\",\n \"text-primary-foreground\",\n )}\n </div>\n ) : null}\n\n {submissionError ? (\n <div\n className={cn(\n \"rounded-md border border-destructive bg-destructive px-4 py-3 shadow-sm\",\n errorMessageClassName,\n )}\n role=\"alert\"\n aria-live=\"assertive\"\n >\n {renderMessage(\n submissionError,\n \"text-destructive-foreground\",\n \"text-destructive-foreground\",\n )}\n </div>\n ) : null}\n </>\n );\n}\n\nFormFeedback.displayName = \"FormFeedback\";\n","import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { Slot } from \"radix-ui\"\n\nimport { cn } from \"../../lib/utils\"\nimport { Separator } from \"./separator\"\n\nconst buttonGroupVariants = cva(\n \"flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2\",\n {\n variants: {\n orientation: {\n horizontal:\n \"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none\",\n vertical:\n \"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none\",\n },\n },\n defaultVariants: {\n orientation: \"horizontal\",\n },\n }\n)\n\nfunction ButtonGroup({\n className,\n orientation,\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof buttonGroupVariants>) {\n return (\n <div\n role=\"group\"\n data-slot=\"button-group\"\n data-orientation={orientation}\n className={cn(buttonGroupVariants({ orientation }), className)}\n {...props}\n />\n )\n}\n\nfunction ButtonGroupText({\n className,\n asChild = false,\n ...props\n}: React.ComponentProps<\"div\"> & {\n asChild?: boolean\n}) {\n const Comp = asChild ? Slot.Root : \"div\"\n\n return (\n <Comp\n className={cn(\n \"bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ButtonGroupSeparator({\n className,\n orientation = \"vertical\",\n ...props\n}: React.ComponentProps<typeof Separator>) {\n return (\n <Separator\n data-slot=\"button-group-separator\"\n orientation={orientation}\n className={cn(\n \"bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n ButtonGroup,\n ButtonGroupSeparator,\n ButtonGroupText,\n buttonGroupVariants,\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { Button } from \"../components/ui/button\";\nimport { ButtonGroup } from \"../components/ui/button-group\";\nimport { FieldLabel } from \"../components/ui/field\";\nimport { TextInput } from \"../inputs/TextInput\";\nimport type { InputProps } from \"./types\";\n\nexport type ButtonGroupFormSize = \"xs\" | \"sm\" | \"default\" | \"lg\";\n\nexport type ButtonGroupFormProps = {\n /**\n * Field name\n */\n name: string;\n /**\n * Optional label above the input\n */\n label?: React.ReactNode;\n /**\n * Placeholder text for the input\n */\n placeholder?: string;\n /**\n * Input props from form field\n */\n inputProps: InputProps<string> & {\n type?: \"text\" | \"email\" | \"password\" | \"url\" | \"tel\" | \"search\";\n };\n /**\n * Submit button label\n */\n submitLabel?: React.ReactNode;\n /**\n * Submit button size\n */\n size?: ButtonGroupFormSize;\n /**\n * Submit button variant\n */\n submitVariant?:\n | \"link\"\n | \"default\"\n | \"destructive\"\n | \"outline\"\n | \"secondary\"\n | \"ghost\"\n | null\n | undefined;\n /**\n * Whether form is submitting\n */\n isSubmitting?: boolean;\n /**\n * Additional className for the container\n */\n className?: string;\n /**\n * Additional className for the label\n */\n labelClassName?: string;\n};\n\n/**\n * ButtonGroupForm - Inline form layout with input and submit button grouped together\n *\n * Commonly used for newsletter signups and other simple single-field forms.\n * The input and button automatically adjust sizing together.\n *\n * Size mappings:\n * - xs: h-8 text-xs\n * - sm: h-9 text-sm\n * - default: h-10 text-sm\n * - lg: h-12 text-base\n *\n * @example\n * ```tsx\n * <ButtonGroupForm\n * name=\"email\"\n * placeholder=\"Enter your email\"\n * inputProps={form.getFieldProps('email')}\n * submitLabel=\"Subscribe\"\n * size=\"default\"\n * />\n * ```\n */\nexport function ButtonGroupForm({\n name,\n label,\n inputProps,\n submitLabel = \"Submit\",\n submitVariant = \"default\",\n size = \"default\",\n isSubmitting = false,\n className,\n labelClassName,\n}: ButtonGroupFormProps) {\n const inputId = `button-group-input-${name}`;\n\n // Size-specific classes for input to match button heights\n const inputSizeClasses = {\n xs: \"h-8 text-xs px-3\",\n sm: \"h-9 text-sm px-3\",\n default: \"h-10 text-sm px-4\",\n lg: \"h-12 text-base px-6\",\n };\n\n // Map button group sizes to button sizes\n const buttonSizes: Record<ButtonGroupFormSize, \"xs\" | \"sm\" | \"default\" | \"lg\"> = {\n xs: \"xs\",\n sm: \"sm\",\n default: \"default\",\n lg: \"lg\",\n };\n\n return (\n <div className={cn(\"space-y-2\", className)}>\n {label && (\n <FieldLabel htmlFor={inputId} className={labelClassName}>\n {label}\n </FieldLabel>\n )}\n <ButtonGroup>\n <TextInput\n {...inputProps}\n id={inputId}\n className={cn(\n inputSizeClasses[size],\n \"border-r-0 rounded-r-none focus-visible:z-10\",\n inputProps.className,\n )}\n />\n <Button\n size={buttonSizes[size]}\n type=\"submit\"\n variant={submitVariant}\n disabled={isSubmitting}\n className=\"rounded-l-none\"\n >\n {submitLabel}\n </Button>\n </ButtonGroup>\n </div>\n );\n}\n\nButtonGroupForm.displayName = \"ButtonGroupForm\";\n","\"use client\";\n\nimport * as React from \"react\";\nimport { FormContext } from \"./FormContext\";\nimport type { FormProps, FormValues } from \"./types\";\nimport { FormFeedback } from \"./form-feedback\";\nimport { Button } from \"../components/ui/button\";\nimport { ButtonGroupForm } from \"./button-group-form\";\nimport type { FormFieldConfig } from \"../integration/form-field-types\";\n\n/**\n * Form - Progressive enhancement form component\n *\n * Provides form context to child components and handles form submission.\n * Supports progressive enhancement with server-side fallback.\n *\n * Features:\n * - Provides FormContext for useField hook\n * - Handles form submission with validation\n * - Progressive enhancement support (works without JavaScript)\n * - Accessible form semantics\n *\n * @example\n * ```tsx\n * const form = useForm({\n * initialValues: { email: '' },\n * onSubmit: async (values) => {\n * await submitForm(values);\n * },\n * });\n *\n * return (\n * <Form form={form} action=\"/api/submit\" method=\"post\">\n * <input {...form.getFieldProps('email')} />\n * <button type=\"submit\">Submit</button>\n * </Form>\n * );\n * ```\n *\n * @see https://opensite.ai/developers/page-speed/forms/form\n */\nexport function Form<T extends FormValues = FormValues>({\n form,\n children,\n fields,\n className,\n action,\n method,\n noValidate = true,\n submissionConfig,\n successMessage,\n submissionError,\n successMessageClassName,\n errorMessageClassName,\n onNewSubmission,\n notificationConfig,\n styleConfig,\n formConfig,\n ...props\n}: FormProps<T> & React.FormHTMLAttributes<HTMLFormElement>) {\n // Wrap handleSubmit to catch any unhandled rejections\n const handleFormSubmit = React.useCallback(\n async (e: React.FormEvent) => {\n try {\n await form.handleSubmit(e);\n } catch {\n // Error is already handled by useForm, just prevent unhandled rejection\n // The form status and errors are already set by useForm's error handling\n }\n },\n [form],\n );\n\n const resolvedClassName = className ?? styleConfig?.formClassName;\n const resolvedAction = action ?? formConfig?.endpoint;\n const resolvedMethod = method ?? formConfig?.method ?? \"post\";\n const resolvedSubmissionConfig = submissionConfig ?? formConfig?.submissionConfig;\n const resolvedSuccessMessage =\n successMessage ?? notificationConfig?.successMessage;\n const resolvedSubmissionError =\n submissionError ?? notificationConfig?.submissionError;\n const resolvedSuccessMessageClassName =\n successMessageClassName ?? styleConfig?.successMessageClassName;\n const resolvedErrorMessageClassName =\n errorMessageClassName ?? styleConfig?.errorMessageClassName;\n\n const behavior = resolvedSubmissionConfig?.behavior || \"showConfirmation\";\n\n const shouldManageSubmissionUi =\n resolvedSubmissionConfig !== undefined ||\n resolvedSuccessMessage !== undefined ||\n resolvedSuccessMessageClassName !== undefined ||\n resolvedErrorMessageClassName !== undefined ||\n resolvedSubmissionError != null ||\n onNewSubmission !== undefined;\n\n const hasSubmissionError = Boolean(resolvedSubmissionError);\n\n const isSubmissionSuccessful =\n shouldManageSubmissionUi &&\n form.status === \"success\" &&\n !hasSubmissionError;\n\n const defaultSuccessMessage =\n behavior === \"redirect\"\n ? \"Form submitted successfully. Redirecting...\"\n : \"Thank you. Your form has been submitted successfully.\";\n\n const finalSuccessMessage = resolvedSuccessMessage ?? defaultSuccessMessage;\n\n const shouldRenderCustomComponent =\n isSubmissionSuccessful &&\n behavior === \"renderCustomComponent\" &&\n Boolean(resolvedSubmissionConfig?.customComponent);\n\n const newSubmissionAction = resolvedSubmissionConfig?.newFormSubmissionAction;\n\n const showNewSubmissionAction =\n isSubmissionSuccessful &&\n (typeof newSubmissionAction?.enable === \"boolean\"\n ? newSubmissionAction.enable\n : Boolean(newSubmissionAction?.label));\n\n const newSubmissionLabel =\n newSubmissionAction?.label ?? \"Submit another response\";\n\n const handleNewSubmission = React.useCallback(() => {\n form.resetForm();\n onNewSubmission?.();\n }, [form, onNewSubmission]);\n\n // Check if we should use button-group layout\n const formLayout = formConfig?.formLayout ?? \"standard\";\n const isButtonGroupLayout = formLayout === \"button-group\";\n const hasTextField = fields && fields.length === 1 && fields[0] &&\n [\"text\", \"email\", \"password\", \"url\", \"tel\", \"search\"].includes(fields[0].type);\n const shouldUseButtonGroup = isButtonGroupLayout && hasTextField;\n\n // Render button-group layout if conditions are met\n const buttonGroupContent = React.useMemo(() => {\n if (!shouldUseButtonGroup || !fields || fields.length === 0) return null;\n\n const field = fields[0] as FormFieldConfig;\n const fieldProps = form.getFieldProps(field.name);\n\n return (\n <ButtonGroupForm\n name={field.name}\n label={field.label}\n inputProps={{\n name: fieldProps.name,\n value: fieldProps.value as string,\n onChange: fieldProps.onChange as (value: string) => void,\n onBlur: fieldProps.onBlur,\n type: field.type as \"text\" | \"email\" | \"password\" | \"url\" | \"tel\" | \"search\",\n placeholder: field.placeholder,\n required: field.required,\n disabled: field.disabled,\n }}\n submitLabel={formConfig?.submitLabel}\n submitVariant={formConfig?.submitVariant}\n size={formConfig?.buttonGroupSize}\n isSubmitting={form.isSubmitting}\n />\n );\n }, [shouldUseButtonGroup, fields, form, formConfig]);\n\n return (\n <FormContext.Provider value={form}>\n <form\n onSubmit={handleFormSubmit}\n action={resolvedAction}\n method={resolvedMethod}\n noValidate={noValidate}\n className={resolvedClassName}\n {...props}\n >\n {isSubmissionSuccessful ? (\n <div className=\"space-y-4\">\n {shouldRenderCustomComponent ? (\n resolvedSubmissionConfig?.customComponent\n ) : (\n <FormFeedback\n successMessage={finalSuccessMessage}\n successMessageClassName={resolvedSuccessMessageClassName}\n />\n )}\n\n {showNewSubmissionAction ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={handleNewSubmission}\n >\n {newSubmissionLabel}\n </Button>\n ) : null}\n </div>\n ) : (\n <>\n {shouldUseButtonGroup ? buttonGroupContent : children}\n {resolvedSubmissionError ? (\n <div className=\"mt-4\">\n <FormFeedback\n submissionError={resolvedSubmissionError}\n errorMessageClassName={resolvedErrorMessageClassName}\n />\n </div>\n ) : null}\n </>\n )}\n </form>\n </FormContext.Provider>\n );\n}\n\nForm.displayName = \"Form\";\n"]}
|
|
@@ -127,6 +127,87 @@ var FieldError = React2__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
127
127
|
);
|
|
128
128
|
});
|
|
129
129
|
FieldError.displayName = "FieldError";
|
|
130
|
+
var Input = React2__namespace.forwardRef(
|
|
131
|
+
({ className, type, ...props }, ref) => {
|
|
132
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
133
|
+
"input",
|
|
134
|
+
{
|
|
135
|
+
ref,
|
|
136
|
+
type,
|
|
137
|
+
"data-slot": "input",
|
|
138
|
+
className: cn(
|
|
139
|
+
// Core structure - no hardcoded colors, uses CSS variables
|
|
140
|
+
"flex h-9 w-full min-w-0 rounded-md border border-input",
|
|
141
|
+
"bg-transparent px-3 py-1 text-base shadow-sm",
|
|
142
|
+
"transition-colors outline-none md:text-sm",
|
|
143
|
+
// Focus state - uses ring-ring CSS variable (adapts to theme)
|
|
144
|
+
"focus-visible:ring-1 focus-visible:ring-ring",
|
|
145
|
+
// Error state - uses destructive CSS variables (adapts to theme)
|
|
146
|
+
"aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive",
|
|
147
|
+
// Disabled state - no color hardcoding
|
|
148
|
+
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
149
|
+
// File input specific - inherits text color from parent
|
|
150
|
+
"file:inline-flex file:h-7 file:border-0 file:bg-transparent",
|
|
151
|
+
"file:text-sm file:font-medium",
|
|
152
|
+
// Autofill reset - prevents browser from overriding our dynamic colors
|
|
153
|
+
INPUT_AUTOFILL_RESET_CLASSES,
|
|
154
|
+
className
|
|
155
|
+
),
|
|
156
|
+
...props
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
Input.displayName = "Input";
|
|
162
|
+
|
|
163
|
+
// src/inputs/TextInput.tsx
|
|
164
|
+
function TextInput({
|
|
165
|
+
name,
|
|
166
|
+
value,
|
|
167
|
+
onChange,
|
|
168
|
+
onBlur,
|
|
169
|
+
placeholder,
|
|
170
|
+
disabled = false,
|
|
171
|
+
required = false,
|
|
172
|
+
error = false,
|
|
173
|
+
className = "",
|
|
174
|
+
type = "text",
|
|
175
|
+
id = "text",
|
|
176
|
+
...props
|
|
177
|
+
}) {
|
|
178
|
+
const handleChange = (e) => {
|
|
179
|
+
onChange(e.target.value);
|
|
180
|
+
};
|
|
181
|
+
const handleBlur = () => {
|
|
182
|
+
onBlur?.();
|
|
183
|
+
};
|
|
184
|
+
const hasValue = String(value ?? "").trim().length > 0;
|
|
185
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
186
|
+
Input,
|
|
187
|
+
{
|
|
188
|
+
type,
|
|
189
|
+
id,
|
|
190
|
+
name,
|
|
191
|
+
value: value ?? "",
|
|
192
|
+
onChange: handleChange,
|
|
193
|
+
onBlur: handleBlur,
|
|
194
|
+
placeholder,
|
|
195
|
+
disabled,
|
|
196
|
+
required,
|
|
197
|
+
className: cn(
|
|
198
|
+
// Valid value indicator - ring-2 when has value and no error
|
|
199
|
+
!error && hasValue && "ring-2 ring-ring",
|
|
200
|
+
// Error state - handled by Input component via aria-invalid
|
|
201
|
+
className
|
|
202
|
+
),
|
|
203
|
+
"aria-invalid": error || props["aria-invalid"],
|
|
204
|
+
"aria-describedby": props["aria-describedby"],
|
|
205
|
+
"aria-required": required || props["aria-required"],
|
|
206
|
+
...props
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
TextInput.displayName = "TextInput";
|
|
130
211
|
var buttonVariants = classVarianceAuthority.cva(
|
|
131
212
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 aria-invalid:border-destructive",
|
|
132
213
|
{
|
|
@@ -231,8 +312,10 @@ exports.FieldError = FieldError;
|
|
|
231
312
|
exports.FieldGroup = FieldGroup;
|
|
232
313
|
exports.FieldLabel = FieldLabel;
|
|
233
314
|
exports.INPUT_AUTOFILL_RESET_CLASSES = INPUT_AUTOFILL_RESET_CLASSES;
|
|
315
|
+
exports.Input = Input;
|
|
234
316
|
exports.LabelGroup = LabelGroup;
|
|
317
|
+
exports.TextInput = TextInput;
|
|
235
318
|
exports.buttonVariants = buttonVariants;
|
|
236
319
|
exports.cn = cn;
|
|
237
|
-
//# sourceMappingURL=chunk-
|
|
238
|
-
//# sourceMappingURL=chunk-
|
|
320
|
+
//# sourceMappingURL=chunk-QRI5TMES.cjs.map
|
|
321
|
+
//# sourceMappingURL=chunk-QRI5TMES.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/utils.ts","../src/components/ui/label.tsx","../src/components/ui/field.tsx","../src/components/ui/input.tsx","../src/inputs/TextInput.tsx","../src/components/ui/button.tsx","../src/core/label-group.tsx"],"names":["twMerge","clsx","React","LabelPrimitive","React2","React3","React4","cva","Slot","React5","React6"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAOA,qBAAA,CAAQC,SAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;AAKO,IAAM,4BAAA,GACX;;;ACNF,SAAS,KAAA,CAAM;AAAA,EACb,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAqD;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AW;AAAA,SAAA;AAAA,QAEV;AAAA,OACH;AAAA,IAEJ,CAAA,MAAA,IAAW,YAAY,QAAA,EAAU;AAC/B,MAAA,cAAA,mDACG,QAAA,EAAA,EAAO,WAAA,EAAU,gBAAe,SAAA,EAAW,cAAA,EAAA,EACzC,SACA,iBACH,CAAA;AAAA,IAEJ,CAAA,MAAO;AACL,MAAA,cAAA,mDACG,KAAA,EAAA,EAAI,WAAA,EAAU,eAAc,SAAA,EAAW,cAAA,EAAA,EACrC,SACA,iBACH,CAAA;AAAA,IAEJ;AAAA,EACF;AAEA,EAAA,MAAM,mBAAmB,SAAA,mBACvBA,iBAAA,CAAA,aAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAI,WAAA;AAAA,MACJ,SAAA,EAAW,EAAA,CAAG,4BAAA,EAA8B,kBAAkB;AAAA,KAAA;AAAA,IAE7D;AAAA,GACH,GACE,IAAA;AAEJ,EAAA,IAAI,CAAC,cAAA,IAAkB,CAAC,gBAAA,EAAkB,OAAO,IAAA;AAGjD,EAAA,IAAI,YAAY,QAAA,EAAU;AACxB,IAAA,uBACEA,iBAAA,CAAA,aAAA,CAAAA,iBAAA,CAAA,QAAA,EAAA,IAAA,EACG,gBACA,gBACH,CAAA;AAAA,EAEJ;AAEA,EAAA,uBACEA,iBAAA,CAAA,aAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,8BAAA,EAAA,EACZ,gBACA,gBACH,CAAA;AAEJ","file":"chunk-QRI5TMES.cjs","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n/**\n * Normalizes browser autofill colors so inputs keep theme colors.\n */\nexport const INPUT_AUTOFILL_RESET_CLASSES =\n \"autofill:bg-transparent autofill:text-foreground \" +\n \"[&:-webkit-autofill]:[-webkit-text-fill-color:hsl(var(--foreground))] \" +\n \"[&:-webkit-autofill]:[caret-color:hsl(var(--foreground))] \" +\n \"[&:-webkit-autofill]:[box-shadow:0_0_0px_1000px_hsl(var(--background))_inset] \" +\n \"[&:-webkit-autofill:hover]:[box-shadow:0_0_0px_1000px_hsl(var(--background))_inset] \" +\n \"[&:-webkit-autofill:focus]:[box-shadow:0_0_0px_1000px_hsl(var(--background))_inset] \" +\n \"[&:-webkit-autofill]:[transition:background-color_9999s_ease-out,color_9999s_ease-out]\";\n","import * as React from \"react\"\nimport { Label as LabelPrimitive } from \"radix-ui\"\n\nimport { cn } from \"../../lib/utils\"\n\nfunction Label({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n return (\n <LabelPrimitive.Root\n data-slot=\"label\"\n className={cn(\n \"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport { Label }\n","import * as React from \"react\";\nimport { Label } from \"./label\";\nimport { cn } from \"../../lib/utils\";\n\ntype FieldOrientation = \"vertical\" | \"horizontal\";\n\ninterface FieldProps extends React.HTMLAttributes<HTMLDivElement> {\n orientation?: FieldOrientation;\n invalid?: boolean;\n}\n\n/**\n * Field - Container component for form inputs with validation display\n *\n * Provides consistent layout and spacing for form fields with labels,\n * inputs, descriptions, and error messages.\n */\nconst Field = React.forwardRef<HTMLDivElement, FieldProps>(\n({ className, orientation = \"vertical\", invalid = false, ...props }, ref) => {\n return (\n <div\n ref={ref}\n data-slot=\"field\"\n data-orientation={orientation}\n data-invalid={invalid || undefined}\n className={cn(\n // Use space-y instead of flex to avoid interfering with parent grid layouts\n orientation === \"horizontal\"\n ? \"flex items-center gap-2\"\n : \"space-y-1.5\",\n className,\n )}\n {...props}\n />\n );\n});\nField.displayName = \"Field\";\n\n/**\n * FieldGroup - Container for multiple related fields\n *\n * Used to group fields together (e.g., first name + last name in a row)\n */\nconst FieldGroup = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n data-slot=\"field-group\"\n className={cn(\"flex flex-col gap-4\", className)}\n {...props}\n />\n );\n});\nFieldGroup.displayName = \"FieldGroup\";\n\n/**\n * FieldLabel - Label component for form fields\n *\n * Wrapper around ShadCN Label with consistent styling\n */\nconst FieldLabel = React.forwardRef<\n HTMLLabelElement,\n React.LabelHTMLAttributes<HTMLLabelElement> & {\n required?: boolean;\n }\n>(({ className, required, children, ...props }, ref) => {\n return (\n <Label\n ref={ref}\n data-slot=\"field-label\"\n className={cn(\n \"text-sm font-medium leading-none select-none\",\n \"peer-disabled:cursor-not-allowed peer-disabled:opacity-50\",\n className,\n )}\n {...props}\n >\n {children}\n {required && <span className=\"text-destructive ml-1\">*</span>}\n </Label>\n );\n});\nFieldLabel.displayName = \"FieldLabel\";\n\n/**\n * FieldDescription - Helper text for form fields\n *\n * Displays additional information or instructions for the field\n */\nconst FieldDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n return (\n <p\n ref={ref}\n data-slot=\"field-description\"\n className={cn(\"text-sm opacity-70\", className)}\n {...props}\n />\n );\n});\nFieldDescription.displayName = \"FieldDescription\";\n\n/**\n * FieldError - Error message display for form fields\n *\n * Shows validation errors with proper styling and accessibility\n */\nconst FieldError = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n return (\n <p\n ref={ref}\n data-slot=\"field-error\"\n role=\"alert\"\n aria-live=\"polite\"\n className={cn(\"text-sm text-destructive\", className)}\n {...props}\n />\n );\n});\nFieldError.displayName = \"FieldError\";\n\nexport { Field, FieldGroup, FieldLabel, FieldDescription, FieldError };\n","import * as React from \"react\";\nimport { cn } from \"../../lib/utils\";\nimport { INPUT_AUTOFILL_RESET_CLASSES } from \"../../lib/utils\";\n\n/**\n * Input component - Optimized for dynamic theming across thousands of client brands\n *\n * CRITICAL: This component must work with dynamic Section backgrounds (light/dark/primary/etc)\n * Only uses CSS variables that adapt automatically - NO hardcoded semantic colors\n *\n * See: SHADCN_INTEGRATION_GUIDE.md for full documentation\n */\nconst Input = React.forwardRef<HTMLInputElement, React.ComponentProps<\"input\">>(\n ({ className, type, ...props }, ref) => {\n return (\n <input\n ref={ref}\n type={type}\n data-slot=\"input\"\n className={cn(\n // Core structure - no hardcoded colors, uses CSS variables\n \"flex h-9 w-full min-w-0 rounded-md border border-input\",\n \"bg-transparent px-3 py-1 text-base shadow-sm\",\n \"transition-colors outline-none md:text-sm\",\n\n // Focus state - uses ring-ring CSS variable (adapts to theme)\n \"focus-visible:ring-1 focus-visible:ring-ring\",\n\n // Error state - uses destructive CSS variables (adapts to theme)\n \"aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive\",\n\n // Disabled state - no color hardcoding\n \"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50\",\n\n // File input specific - inherits text color from parent\n \"file:inline-flex file:h-7 file:border-0 file:bg-transparent\",\n \"file:text-sm file:font-medium\",\n\n // Autofill reset - prevents browser from overriding our dynamic colors\n INPUT_AUTOFILL_RESET_CLASSES,\n\n className,\n )}\n {...props}\n />\n );\n },\n);\nInput.displayName = \"Input\";\n\nexport { Input };\n","\"use client\";\n\nimport * as React from \"react\";\nimport type { InputProps } from \"../core/types\";\nimport { Input } from \"../components/ui/input\";\nimport { cn } from \"../lib/utils\";\n\n/**\n * TextInput - High-performance text input component (ShadCN-based)\n *\n * Built on ShadCN Input component with form-specific behavior:\n * - Error state handling\n * - Valid value indicator (ring-2)\n * - Form integration (onChange, onBlur)\n * - Full accessibility support\n *\n * @example\n * ```tsx\n * const form = useForm({ initialValues: { email: '' } });\n *\n * <TextInput\n * {...form.getFieldProps('email')}\n * type=\"email\"\n * placeholder=\"Enter your email\"\n * error={!!form.errors.email}\n * aria-invalid={!!form.errors.email}\n * aria-describedby={form.errors.email ? 'email-error' : undefined}\n * />\n * ```\n *\n * @see https://opensite.ai/developers/page-speed/forms/text-input\n */\nexport function TextInput({\n name,\n value,\n onChange,\n onBlur,\n placeholder,\n disabled = false,\n required = false,\n error = false,\n className = \"\",\n type = \"text\",\n id = \"text\",\n ...props\n}: InputProps<string> & {\n type?: \"text\" | \"email\" | \"password\" | \"url\" | \"tel\" | \"search\";\n}) {\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(e.target.value);\n };\n\n const handleBlur = () => {\n onBlur?.();\n };\n\n const hasValue = String(value ?? \"\").trim().length > 0;\n\n return (\n <Input\n type={type}\n id={id}\n name={name}\n value={value ?? \"\"}\n onChange={handleChange}\n onBlur={handleBlur}\n placeholder={placeholder}\n disabled={disabled}\n required={required}\n className={cn(\n // Valid value indicator - ring-2 when has value and no error\n !error && hasValue && \"ring-2 ring-ring\",\n // Error state - handled by Input component via aria-invalid\n className,\n )}\n aria-invalid={error || props[\"aria-invalid\"]}\n aria-describedby={props[\"aria-describedby\"]}\n aria-required={required || props[\"aria-required\"]}\n {...props}\n />\n );\n}\n\nTextInput.displayName = \"TextInput\";\n","import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { Slot } from \"radix-ui\"\n\nimport { cn } from \"../../lib/utils\"\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 aria-invalid:border-destructive\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n destructive:\n \"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20\",\n outline:\n \"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground\",\n secondary:\n \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost:\n \"hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-9 px-4 py-2 has-[>svg]:px-3\",\n xs: \"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3\",\n sm: \"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5\",\n lg: \"h-10 rounded-md px-6 has-[>svg]:px-4\",\n icon: \"size-9\",\n \"icon-xs\": \"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3\",\n \"icon-sm\": \"size-8\",\n \"icon-lg\": \"size-10\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nfunction Button({\n className,\n variant = \"default\",\n size = \"default\",\n asChild = false,\n ...props\n}: React.ComponentProps<\"button\"> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean\n }) {\n const Comp = asChild ? Slot.Root : \"button\"\n\n return (\n <Comp\n data-slot=\"button\"\n data-variant={variant}\n data-size={size}\n className={cn(buttonVariants({ variant, size, className }))}\n {...props}\n />\n )\n}\n\nexport { Button, buttonVariants }\n","\"use client\";\n\nimport * as React from \"react\";\nimport type { ReactNode } from \"react\";\nimport { FieldDescription, FieldLabel } from \"../components/ui/field\";\nimport { cn } from \"../lib/utils\";\n\nexport type LabelGroupProps = {\n variant?: \"legend\" | \"label\" | \"text\";\n secondary?: ReactNode;\n secondaryId?: string;\n primary?: ReactNode;\n labelHtmlFor?: string;\n required?: boolean;\n primaryClassName?: string;\n secondaryClassName?: string;\n};\n\nconst LabelGroup = ({\n labelHtmlFor,\n required = false,\n variant = \"label\",\n secondaryId,\n secondary,\n primary,\n primaryClassName,\n secondaryClassName,\n}: LabelGroupProps) => {\n const primaryClasses = cn(\n \"text-sm font-medium leading-snug\",\n variant === \"legend\" ? \"mb-1.5\" : \"mb-1 block\",\n primaryClassName,\n );\n\n const requiredIndicator =\n required && variant !== \"label\" ? (\n <span className=\"text-destructive pl-0.5\" aria-label=\"required\">\n *\n </span>\n ) : null;\n\n let primaryElement: ReactNode = null;\n if (primary) {\n if (variant === \"label\") {\n primaryElement = (\n <FieldLabel\n htmlFor={labelHtmlFor}\n required={required}\n className={primaryClasses}\n >\n {primary}\n </FieldLabel>\n );\n } else if (variant === \"legend\") {\n primaryElement = (\n <legend data-slot=\"field-legend\" className={primaryClasses}>\n {primary}\n {requiredIndicator}\n </legend>\n );\n } else {\n primaryElement = (\n <div data-slot=\"field-label\" className={primaryClasses}>\n {primary}\n {requiredIndicator}\n </div>\n );\n }\n }\n\n const secondaryElement = secondary ? (\n <FieldDescription\n id={secondaryId}\n className={cn(\"leading-normal font-normal\", secondaryClassName)}\n >\n {secondary}\n </FieldDescription>\n ) : null;\n\n if (!primaryElement && !secondaryElement) return null;\n\n // Legend should remain a direct child of fieldset for proper semantics.\n if (variant === \"legend\") {\n return (\n <>\n {primaryElement}\n {secondaryElement}\n </>\n );\n }\n\n return (\n <div className=\"flex flex-1 flex-col gap-0.5\">\n {primaryElement}\n {secondaryElement}\n </div>\n );\n};\n\nexport { LabelGroup };\n"]}
|