@carbonbits/sixr 1.3.0 → 1.5.0
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/README.md +204 -66
- package/dist/button.cjs +223 -0
- package/dist/button.cjs.map +1 -0
- package/dist/button.d.cts +34 -0
- package/dist/button.d.ts +34 -0
- package/dist/button.js +4 -0
- package/dist/button.js.map +1 -0
- package/dist/chunk-HDTW4FRT.js +111 -0
- package/dist/chunk-HDTW4FRT.js.map +1 -0
- package/dist/chunk-NZHHNVXZ.js +118 -0
- package/dist/chunk-NZHHNVXZ.js.map +1 -0
- package/dist/email-input.cjs +433 -0
- package/dist/email-input.cjs.map +1 -0
- package/dist/email-input.d.cts +12 -0
- package/dist/email-input.d.ts +12 -0
- package/dist/email-input.js +416 -0
- package/dist/email-input.js.map +1 -0
- package/dist/field.cjs +206 -0
- package/dist/field.cjs.map +1 -0
- package/dist/field.d.cts +80 -0
- package/dist/field.d.ts +80 -0
- package/dist/field.js +186 -0
- package/dist/field.js.map +1 -0
- package/dist/form.cjs +283 -42
- package/dist/form.cjs.map +1 -1
- package/dist/form.d.cts +79 -10
- package/dist/form.d.ts +79 -10
- package/dist/form.js +285 -45
- package/dist/form.js.map +1 -1
- package/dist/index-CdYkd6zz.d.cts +22 -0
- package/dist/index-CdYkd6zz.d.ts +22 -0
- package/dist/index.cjs +217 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +146 -46
- package/dist/index.d.ts +146 -46
- package/dist/index.js +2 -0
- package/dist/password-input.cjs +449 -0
- package/dist/password-input.cjs.map +1 -0
- package/dist/password-input.d.cts +19 -0
- package/dist/password-input.d.ts +19 -0
- package/dist/password-input.js +434 -0
- package/dist/password-input.js.map +1 -0
- package/dist/phone-input.cjs +429 -0
- package/dist/phone-input.cjs.map +1 -0
- package/dist/phone-input.d.cts +12 -0
- package/dist/phone-input.d.ts +12 -0
- package/dist/phone-input.js +412 -0
- package/dist/phone-input.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/text-input.cjs +359 -147
- package/dist/text-input.cjs.map +1 -1
- package/dist/text-input.d.cts +9 -58
- package/dist/text-input.d.ts +9 -58
- package/dist/text-input.js +365 -150
- package/dist/text-input.js.map +1 -1
- package/dist/typography.cjs +120 -0
- package/dist/typography.cjs.map +1 -0
- package/dist/typography.d.cts +46 -0
- package/dist/typography.d.ts +46 -0
- package/dist/typography.js +3 -0
- package/dist/typography.js.map +1 -0
- package/package.json +69 -1
package/dist/form.js
CHANGED
|
@@ -2,56 +2,173 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
|
|
4
4
|
// src/components/form/index.tsx
|
|
5
|
+
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
|
|
5
6
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "react";
|
|
7
|
+
FormProvider,
|
|
8
|
+
useForm,
|
|
9
|
+
useFormContext,
|
|
10
|
+
useFormState
|
|
11
|
+
} from "react-hook-form";
|
|
12
|
+
|
|
13
|
+
// src/components/button/index.tsx
|
|
14
|
+
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
15
|
+
|
|
16
|
+
// src/components/typography/index.tsx
|
|
17
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
11
18
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
var DEFAULT_ELEMENT = {
|
|
20
|
+
display: "h1",
|
|
21
|
+
heading: "h2",
|
|
22
|
+
subheading: "h3",
|
|
23
|
+
body: "p",
|
|
24
|
+
label: "span",
|
|
25
|
+
hint: "p",
|
|
26
|
+
code: "code"
|
|
27
|
+
};
|
|
28
|
+
var DEFAULT_WEIGHT = {
|
|
29
|
+
display: "semibold",
|
|
30
|
+
heading: "semibold",
|
|
31
|
+
subheading: "medium",
|
|
32
|
+
body: "regular",
|
|
33
|
+
label: "semibold",
|
|
34
|
+
hint: "regular",
|
|
35
|
+
code: "regular"
|
|
36
|
+
};
|
|
37
|
+
var VARIANT_CLASSES = {
|
|
38
|
+
display: "text-display leading-tight tracking-tight",
|
|
39
|
+
heading: "text-heading leading-tight tracking-tight",
|
|
40
|
+
subheading: "text-subheading leading-snug",
|
|
41
|
+
body: "text-field leading-normal",
|
|
42
|
+
label: "text-label leading-normal",
|
|
43
|
+
hint: "text-hint leading-normal",
|
|
44
|
+
code: "font-code text-field leading-normal"
|
|
45
|
+
};
|
|
46
|
+
var TONE_CLASSES = {
|
|
47
|
+
default: "text-fg",
|
|
48
|
+
muted: "text-fg-muted",
|
|
49
|
+
subtle: "text-fg-subtle",
|
|
50
|
+
accent: "text-accent",
|
|
51
|
+
"on-accent": "text-on-accent",
|
|
52
|
+
success: "text-success",
|
|
53
|
+
warning: "text-warning",
|
|
54
|
+
info: "text-info",
|
|
55
|
+
danger: "text-danger"
|
|
56
|
+
};
|
|
57
|
+
var WEIGHT_CLASSES = {
|
|
58
|
+
regular: "font-normal",
|
|
59
|
+
medium: "font-medium",
|
|
60
|
+
semibold: "font-semibold",
|
|
61
|
+
bold: "font-bold"
|
|
62
|
+
};
|
|
63
|
+
var ALIGN_CLASSES = {
|
|
64
|
+
start: "text-start",
|
|
65
|
+
center: "text-center",
|
|
66
|
+
end: "text-end"
|
|
67
|
+
};
|
|
68
|
+
var ICON_CLASSES = "inline-flex shrink-0 items-center [&>svg]:h-[1em] [&>svg]:w-[1em]";
|
|
69
|
+
function typographyClassName({
|
|
70
|
+
variant,
|
|
71
|
+
tone,
|
|
72
|
+
weight,
|
|
73
|
+
align,
|
|
74
|
+
truncate,
|
|
75
|
+
hasIcon,
|
|
76
|
+
className
|
|
77
|
+
}) {
|
|
78
|
+
return [
|
|
79
|
+
VARIANT_CLASSES[variant],
|
|
80
|
+
TONE_CLASSES[tone],
|
|
81
|
+
WEIGHT_CLASSES[weight],
|
|
82
|
+
align ? ALIGN_CLASSES[align] : "",
|
|
83
|
+
hasIcon ? "inline-flex items-center gap-1.5" : "",
|
|
84
|
+
// With an icon the root is a flex container, and text-overflow only
|
|
85
|
+
// clips block text, so the text span carries the truncation instead.
|
|
86
|
+
truncate && !hasIcon ? "truncate" : "",
|
|
87
|
+
className ?? ""
|
|
88
|
+
].filter(Boolean).join(" ");
|
|
89
|
+
}
|
|
90
|
+
function Typography({
|
|
91
|
+
variant = "body",
|
|
92
|
+
tone = "default",
|
|
93
|
+
weight,
|
|
94
|
+
align,
|
|
95
|
+
truncate = false,
|
|
96
|
+
icon,
|
|
97
|
+
iconPosition = "leading",
|
|
98
|
+
as,
|
|
99
|
+
asChild = false,
|
|
100
|
+
className,
|
|
101
|
+
children,
|
|
102
|
+
...rest
|
|
103
|
+
}) {
|
|
104
|
+
const hasIcon = icon !== void 0 && icon !== null;
|
|
105
|
+
const Component = asChild ? Slot : as ?? DEFAULT_ELEMENT[variant];
|
|
106
|
+
const iconNode = hasIcon ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: ICON_CLASSES, children: icon }) : null;
|
|
107
|
+
const content = hasIcon ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
108
|
+
iconPosition === "leading" ? iconNode : null,
|
|
109
|
+
/* @__PURE__ */ jsx("span", { className: truncate ? "min-w-0 truncate" : void 0, children }),
|
|
110
|
+
iconPosition === "trailing" ? iconNode : null
|
|
111
|
+
] }) : children;
|
|
28
112
|
return /* @__PURE__ */ jsx(
|
|
29
|
-
|
|
113
|
+
Component,
|
|
30
114
|
{
|
|
31
|
-
noValidate: true,
|
|
32
115
|
...rest,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
116
|
+
className: typographyClassName({
|
|
117
|
+
variant,
|
|
118
|
+
tone,
|
|
119
|
+
weight: weight ?? DEFAULT_WEIGHT[variant],
|
|
120
|
+
align,
|
|
121
|
+
truncate,
|
|
122
|
+
hasIcon,
|
|
123
|
+
className
|
|
124
|
+
}),
|
|
125
|
+
children: content
|
|
36
126
|
}
|
|
37
127
|
);
|
|
38
128
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
129
|
+
|
|
130
|
+
// src/components/button/index.tsx
|
|
131
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
132
|
+
var BASE_CLASSES = "inline-flex shrink-0 items-center justify-center gap-2 rounded-field border font-[inherit] text-field font-semibold outline-none transition-colors focus-visible:ring-3 focus-visible:ring-accent-soft disabled:cursor-not-allowed disabled:opacity-45";
|
|
133
|
+
var VARIANT_CLASSES2 = {
|
|
134
|
+
primary: "border-transparent bg-accent text-on-accent enabled:hover:bg-accent-2",
|
|
135
|
+
secondary: "border-line bg-surface text-fg enabled:hover:bg-surface-2",
|
|
136
|
+
ghost: "border-transparent bg-transparent text-fg enabled:hover:bg-surface-2"
|
|
137
|
+
};
|
|
138
|
+
var SIZE_CLASSES = {
|
|
139
|
+
md: "h-10 px-4",
|
|
140
|
+
lg: "h-11 px-5"
|
|
141
|
+
};
|
|
142
|
+
var LABEL_TONE = {
|
|
143
|
+
primary: "on-accent",
|
|
144
|
+
secondary: "default",
|
|
145
|
+
ghost: "default"
|
|
146
|
+
};
|
|
147
|
+
function buttonClassName({
|
|
148
|
+
variant,
|
|
149
|
+
size,
|
|
150
|
+
fullWidth,
|
|
151
|
+
className
|
|
152
|
+
}) {
|
|
153
|
+
return [
|
|
154
|
+
BASE_CLASSES,
|
|
155
|
+
VARIANT_CLASSES2[variant],
|
|
156
|
+
SIZE_CLASSES[size],
|
|
157
|
+
fullWidth ? "w-full" : "",
|
|
158
|
+
className ?? ""
|
|
159
|
+
].filter(Boolean).join(" ");
|
|
44
160
|
}
|
|
45
161
|
function Spinner() {
|
|
46
|
-
return /* @__PURE__ */
|
|
162
|
+
return /* @__PURE__ */ jsxs2(
|
|
47
163
|
"svg",
|
|
48
164
|
{
|
|
49
165
|
className: "h-4 w-4 animate-spin",
|
|
50
166
|
viewBox: "0 0 24 24",
|
|
51
167
|
fill: "none",
|
|
52
168
|
"aria-hidden": "true",
|
|
169
|
+
"data-testid": "button-spinner",
|
|
53
170
|
children: [
|
|
54
|
-
/* @__PURE__ */
|
|
171
|
+
/* @__PURE__ */ jsx2(
|
|
55
172
|
"circle",
|
|
56
173
|
{
|
|
57
174
|
className: "opacity-25",
|
|
@@ -62,7 +179,7 @@ function Spinner() {
|
|
|
62
179
|
strokeWidth: "4"
|
|
63
180
|
}
|
|
64
181
|
),
|
|
65
|
-
/* @__PURE__ */
|
|
182
|
+
/* @__PURE__ */ jsx2(
|
|
66
183
|
"path",
|
|
67
184
|
{
|
|
68
185
|
className: "opacity-75",
|
|
@@ -74,30 +191,153 @@ function Spinner() {
|
|
|
74
191
|
}
|
|
75
192
|
);
|
|
76
193
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
194
|
+
function Button({
|
|
195
|
+
variant = "primary",
|
|
196
|
+
size = "md",
|
|
197
|
+
fullWidth = false,
|
|
198
|
+
loading = false,
|
|
80
199
|
loadingLabel,
|
|
200
|
+
asChild = false,
|
|
201
|
+
type = "button",
|
|
202
|
+
disabled,
|
|
81
203
|
className,
|
|
204
|
+
children,
|
|
82
205
|
...rest
|
|
83
206
|
}) {
|
|
84
|
-
const
|
|
85
|
-
|
|
207
|
+
const classes = buttonClassName({ variant, size, fullWidth, className });
|
|
208
|
+
if (asChild) {
|
|
209
|
+
return /* @__PURE__ */ jsx2(Slot2, { ...rest, className: classes, children });
|
|
210
|
+
}
|
|
211
|
+
return /* @__PURE__ */ jsx2(
|
|
86
212
|
"button",
|
|
87
213
|
{
|
|
88
214
|
...rest,
|
|
89
|
-
type
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
215
|
+
type,
|
|
216
|
+
disabled: disabled || loading,
|
|
217
|
+
"aria-busy": loading || void 0,
|
|
218
|
+
className: classes,
|
|
219
|
+
children: loading ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
220
|
+
/* @__PURE__ */ jsx2(Spinner, {}),
|
|
93
221
|
loadingLabel
|
|
94
|
-
] }) :
|
|
222
|
+
] }) : /* @__PURE__ */ jsx2(
|
|
223
|
+
Typography,
|
|
224
|
+
{
|
|
225
|
+
as: "span",
|
|
226
|
+
variant: "body",
|
|
227
|
+
weight: "semibold",
|
|
228
|
+
tone: LABEL_TONE[variant],
|
|
229
|
+
children
|
|
230
|
+
}
|
|
231
|
+
)
|
|
95
232
|
}
|
|
96
233
|
);
|
|
97
234
|
}
|
|
235
|
+
|
|
236
|
+
// src/components/form/index.tsx
|
|
237
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
238
|
+
function useFormInstance({
|
|
239
|
+
schema,
|
|
240
|
+
defaultValues,
|
|
241
|
+
mode = "onTouched"
|
|
242
|
+
}) {
|
|
243
|
+
return useForm({
|
|
244
|
+
resolver: schema ? standardSchemaResolver(schema) : void 0,
|
|
245
|
+
defaultValues,
|
|
246
|
+
mode,
|
|
247
|
+
reValidateMode: "onChange"
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
var FORM_CLASSES = "flex flex-col gap-4";
|
|
251
|
+
var FIELDSET_CLASSES = "contents border-0 p-0 m-0 min-w-0";
|
|
252
|
+
function errorMessage(error) {
|
|
253
|
+
return error instanceof Error ? error.message : String(error);
|
|
254
|
+
}
|
|
255
|
+
function Form({
|
|
256
|
+
schema,
|
|
257
|
+
defaultValues,
|
|
258
|
+
mode,
|
|
259
|
+
onSubmit,
|
|
260
|
+
form: external,
|
|
261
|
+
children,
|
|
262
|
+
className,
|
|
263
|
+
...rest
|
|
264
|
+
}) {
|
|
265
|
+
const internal = useFormInstance({ schema, defaultValues, mode });
|
|
266
|
+
const form = external ?? internal;
|
|
267
|
+
const { isSubmitting } = form.formState;
|
|
268
|
+
const submit = form.handleSubmit(async (values) => {
|
|
269
|
+
try {
|
|
270
|
+
await onSubmit(values, form);
|
|
271
|
+
} catch (error) {
|
|
272
|
+
form.setError("root", { type: "submit", message: errorMessage(error) });
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
return /* @__PURE__ */ jsx3(FormProvider, { ...form, children: /* @__PURE__ */ jsx3(
|
|
276
|
+
"form",
|
|
277
|
+
{
|
|
278
|
+
noValidate: true,
|
|
279
|
+
...rest,
|
|
280
|
+
onSubmit: submit,
|
|
281
|
+
className: [FORM_CLASSES, className ?? ""].filter(Boolean).join(" "),
|
|
282
|
+
children: /* @__PURE__ */ jsx3("fieldset", { disabled: isSubmitting, className: FIELDSET_CLASSES, children })
|
|
283
|
+
}
|
|
284
|
+
) });
|
|
285
|
+
}
|
|
286
|
+
function FormErrorMessage({ children, className }) {
|
|
287
|
+
if (!children) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
return /* @__PURE__ */ jsx3(
|
|
291
|
+
Typography,
|
|
292
|
+
{
|
|
293
|
+
as: "p",
|
|
294
|
+
variant: "hint",
|
|
295
|
+
tone: "danger",
|
|
296
|
+
role: "alert",
|
|
297
|
+
className,
|
|
298
|
+
children
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
function ConnectedFormError({ children, className }) {
|
|
303
|
+
const { errors } = useFormState();
|
|
304
|
+
return /* @__PURE__ */ jsx3(FormErrorMessage, { className, children: children ?? errors.root?.message });
|
|
305
|
+
}
|
|
306
|
+
function FormError(props) {
|
|
307
|
+
const form = useFormContext();
|
|
308
|
+
return form ? /* @__PURE__ */ jsx3(ConnectedFormError, { ...props }) : /* @__PURE__ */ jsx3(FormErrorMessage, { ...props });
|
|
309
|
+
}
|
|
310
|
+
function ConnectedSubmitButton({
|
|
311
|
+
children,
|
|
312
|
+
loadingLabel,
|
|
313
|
+
fullWidth = true,
|
|
314
|
+
...rest
|
|
315
|
+
}) {
|
|
316
|
+
const { isSubmitting } = useFormState();
|
|
317
|
+
return /* @__PURE__ */ jsx3(
|
|
318
|
+
Button,
|
|
319
|
+
{
|
|
320
|
+
...rest,
|
|
321
|
+
type: "submit",
|
|
322
|
+
fullWidth,
|
|
323
|
+
loading: isSubmitting,
|
|
324
|
+
loadingLabel,
|
|
325
|
+
children
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
function SubmitButton(props) {
|
|
330
|
+
const form = useFormContext();
|
|
331
|
+
if (form) {
|
|
332
|
+
return /* @__PURE__ */ jsx3(ConnectedSubmitButton, { ...props });
|
|
333
|
+
}
|
|
334
|
+
const { fullWidth = true, ...rest } = props;
|
|
335
|
+
return /* @__PURE__ */ jsx3(Button, { ...rest, type: "submit", fullWidth });
|
|
336
|
+
}
|
|
98
337
|
export {
|
|
99
338
|
Form,
|
|
100
339
|
FormError,
|
|
101
|
-
SubmitButton
|
|
340
|
+
SubmitButton,
|
|
341
|
+
useFormInstance
|
|
102
342
|
};
|
|
103
343
|
//# sourceMappingURL=form.js.map
|
package/dist/form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/form/index.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ButtonHTMLAttributes,\n createContext,\n type FormHTMLAttributes,\n type ReactNode,\n type SubmitEvent,\n useCallback,\n useContext,\n useState,\n} from \"react\";\n\nconst SubmittingContext = createContext(false);\n\nexport type FormProps = Omit<\n FormHTMLAttributes<HTMLFormElement>,\n \"onSubmit\"\n> & {\n onSubmit: () => void | Promise<void>;\n children: ReactNode;\n};\n\nconst FORM_CLASSES = \"flex flex-col gap-4\";\nconst FIELDSET_CLASSES = \"contents border-0 p-0 m-0 min-w-0\";\n\nexport function Form({ onSubmit, children, className, ...rest }: FormProps) {\n const [submitting, setSubmitting] = useState(false);\n\n const handleSubmit = useCallback(\n (event: SubmitEvent<HTMLFormElement>) => {\n event.preventDefault();\n const result = onSubmit();\n if (result && typeof result.then === \"function\") {\n setSubmitting(true);\n result.finally(() => setSubmitting(false)).catch(() => undefined);\n }\n },\n [onSubmit],\n );\n\n return (\n <form\n noValidate\n {...rest}\n onSubmit={handleSubmit}\n className={[FORM_CLASSES, className ?? \"\"].filter(Boolean).join(\" \")}\n >\n <SubmittingContext.Provider value={submitting}>\n <fieldset disabled={submitting} className={FIELDSET_CLASSES}>\n {children}\n </fieldset>\n </SubmittingContext.Provider>\n </form>\n );\n}\n\nexport function FormError({ children }: { children?: ReactNode }) {\n if (!children) {\n return null;\n }\n\n return (\n <p role=\"alert\" className=\"text-hint text-danger\">\n {children}\n </p>\n );\n}\n\nfunction Spinner() {\n return (\n <svg\n className=\"h-4 w-4 animate-spin\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n aria-hidden=\"true\"\n >\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 0 1 8-8V0C5.373 0 0 5.373 0 12H4Z\"\n />\n </svg>\n );\n}\n\nexport type SubmitButtonProps = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"type\"\n> & {\n loadingLabel?: ReactNode;\n};\n\nconst BUTTON_CLASSES =\n \"flex h-10 w-full items-center justify-center gap-2 rounded-field bg-accent font-[inherit] text-field font-semibold text-on-accent outline-none focus:ring-3 focus:ring-accent-soft disabled:cursor-not-allowed disabled:opacity-45\";\n\nexport function SubmitButton({\n children,\n loadingLabel,\n className,\n ...rest\n}: SubmitButtonProps) {\n const submitting = useContext(SubmittingContext);\n\n return (\n <button\n {...rest}\n type=\"submit\"\n className={[BUTTON_CLASSES, className ?? \"\"].filter(Boolean).join(\" \")}\n >\n {submitting ? (\n <>\n <Spinner />\n {loadingLabel}\n </>\n ) : (\n children\n )}\n </button>\n );\n}\n"],"mapp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AA,YACP,aAAY;AAAA;AAAA,QACd;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,MAAK;AAAA,YACL,GAAE;AAAA;AAAA,QACJ;AAAA;AAAA;AAAA,EACF;AAEJ;AASA,IAAM,iBACJ;AAEK,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,QAAM,aAAa,WAAW,iBAAiB;AAE/C,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,MAAK;AAAA,MACL,WAAW,CAAC,gBAAgB,aAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MAEpE,uBACC,iCACE;AAAA,4BAAC,WAAQ;AAAA,QACR;AAAA,SACH,IAEA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/components/form/index.tsx","../src/components/button/index.tsx","../src/components/typography/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { standardSchemaResolver } from \"@hookform/resolvers/standard-schema\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { FormHTMLAttributes, ReactNode } from \"react\";\nimport {\n type DefaultValues,\n type FieldValues,\n FormProvider,\n type Mode,\n type UseFormReturn,\n useForm,\n useFormContext,\n useFormState,\n} from \"react-hook-form\";\nimport { Button, type ButtonProps } from \"@/components/button\";\nimport { Typography } from \"@/components/typography\";\n\n/**\n * A `<form>` on react-hook-form. The schema — any Standard Schema, which\n * every zod 4 schema is — validates the whole form: on first blur per field,\n * then on every change once a field has gone invalid, and again on submit.\n * Fields register themselves through `FieldRoot` (and so through every\n * input in this library), so a form is the schema, the inputs and a submit.\n *\n * `onSubmit` only runs with values the schema accepted, typed as its output.\n * Throwing from it — or calling `form.setError(\"root\", …)` — surfaces the\n * message through `FormError`. While it is pending the fields are disabled\n * and `SubmitButton` shows its spinner.\n *\n * Pass your own `form` (from `useFormInstance`) when a screen needs to reach\n * the instance itself, for `setError`, `reset` or `watch`.\n */\n\nexport type FormSchema = StandardSchemaV1<FieldValues, FieldValues>;\n\nexport type FormInput<Schema extends FormSchema> =\n StandardSchemaV1.InferInput<Schema>;\nexport type FormOutput<Schema extends FormSchema> =\n StandardSchemaV1.InferOutput<Schema>;\n\nexport type FormInstance<Schema extends FormSchema> = UseFormReturn<\n FormInput<Schema>,\n unknown,\n FormOutput<Schema>\n>;\n\nexport type UseFormInstanceOptions<Schema extends FormSchema> = {\n schema?: Schema;\n defaultValues?: DefaultValues<FormInput<Schema>>;\n /** When a field first validates. `onTouched`: first blur, then every change. */\n mode?: Mode;\n};\n\n// biome-ignore lint/style/useComponentExportOnlyModules: the hook is how a screen holds the instance Form would otherwise create, and belongs on the same subpath.\nexport function useFormInstance<Schema extends FormSchema>({\n schema,\n defaultValues,\n mode = \"onTouched\",\n}: UseFormInstanceOptions<Schema>): FormInstance<Schema> {\n return useForm<FormInput<Schema>, unknown, FormOutput<Schema>>({\n resolver: schema ? standardSchemaResolver(schema) : undefined,\n defaultValues,\n mode,\n reValidateMode: \"onChange\",\n });\n}\n\nexport type FormProps<Schema extends FormSchema = FormSchema> = Omit<\n FormHTMLAttributes<HTMLFormElement>,\n \"onSubmit\"\n> &\n UseFormInstanceOptions<Schema> & {\n onSubmit: (\n values: FormOutput<Schema>,\n form: FormInstance<Schema>,\n ) => void | Promise<void>;\n /** An instance from `useFormInstance`, when the screen needs it too. */\n form?: FormInstance<Schema>;\n children: ReactNode;\n };\n\nconst FORM_CLASSES = \"flex flex-col gap-4\";\nconst FIELDSET_CLASSES = \"contents border-0 p-0 m-0 min-w-0\";\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport function Form<Schema extends FormSchema = FormSchema>({\n schema,\n defaultValues,\n mode,\n onSubmit,\n form: external,\n children,\n className,\n ...rest\n}: FormProps<Schema>) {\n const internal = useFormInstance<Schema>({ schema, defaultValues, mode });\n const form = external ?? internal;\n const { isSubmitting } = form.formState;\n\n const submit = form.handleSubmit(async (values) => {\n try {\n await onSubmit(values, form);\n } catch (error) {\n form.setError(\"root\", { type: \"submit\", message: errorMessage(error) });\n }\n });\n\n return (\n <FormProvider {...form}>\n <form\n noValidate\n {...rest}\n onSubmit={submit}\n className={[FORM_CLASSES, className ?? \"\"].filter(Boolean).join(\" \")}\n >\n <fieldset disabled={isSubmitting} className={FIELDSET_CLASSES}>\n {children}\n </fieldset>\n </form>\n </FormProvider>\n );\n}\n\nexport type FormErrorProps = {\n /** A message to show in place of the form's own root error. */\n children?: ReactNode;\n className?: string;\n};\n\nfunction FormErrorMessage({ children, className }: FormErrorProps) {\n if (!children) {\n return null;\n }\n\n return (\n <Typography\n as=\"p\"\n variant=\"hint\"\n tone=\"danger\"\n role=\"alert\"\n className={className}\n >\n {children}\n </Typography>\n );\n}\n\nfunction ConnectedFormError({ children, className }: FormErrorProps) {\n const { errors } = useFormState();\n\n return (\n <FormErrorMessage className={className}>\n {children ?? errors.root?.message}\n </FormErrorMessage>\n );\n}\n\n/**\n * The form-level error: a rejected credential, a failed request. Shows\n * `children` when given, otherwise whatever `onSubmit` threw or\n * `form.setError(\"root\", …)` recorded. Renders nothing while there is none.\n */\nexport function FormError(props: FormErrorProps) {\n const form = useFormContext() as UseFormReturn<FieldValues> | null;\n\n return form ? (\n <ConnectedFormError {...props} />\n ) : (\n <FormErrorMessage {...props} />\n );\n}\n\nexport type SubmitButtonProps = Omit<\n ButtonProps,\n \"type\" | \"loading\" | \"asChild\"\n>;\n\nfunction ConnectedSubmitButton({\n children,\n loadingLabel,\n fullWidth = true,\n ...rest\n}: SubmitButtonProps) {\n const { isSubmitting } = useFormState();\n\n return (\n <Button\n {...rest}\n type=\"submit\"\n fullWidth={fullWidth}\n loading={isSubmitting}\n loadingLabel={loadingLabel}\n >\n {children}\n </Button>\n );\n}\n\n/**\n * `Button` bound to the enclosing `Form`: always `type=\"submit\"`, full width\n * as the design's forms are, and loading for as long as `onSubmit` runs.\n */\nexport function SubmitButton(props: SubmitButtonProps) {\n const form = useFormContext() as UseFormReturn<FieldValues> | null;\n\n if (form) {\n return <ConnectedSubmitButton {...props} />;\n }\n\n const { fullWidth = true, ...rest } = props;\n\n return <Button {...rest} type=\"submit\" fullWidth={fullWidth} />;\n}\n","import { Slot } from \"@radix-ui/react-slot\";\nimport type { ButtonHTMLAttributes, ReactNode, Ref } from \"react\";\nimport { Typography, type TypographyTone } from \"@/components/typography\";\n\n/**\n * The design's primary action, as the auth screens use it: a 40px (or 44px)\n * accent-filled control with the field type scale, a 4px radius and the\n * shared 45% disabled opacity. `secondary` and `ghost` cover the quieter\n * actions that sit beside it.\n *\n * Server-safe: no state, no handlers of its own. `asChild` composes onto a\n * consumer's element — a `next/link` for a navigation styled as a button —\n * through Radix `Slot`, so the link keeps its own semantics. `loading` swaps\n * the label for a spinner and disables the control; it applies to the\n * rendered `<button>` only, since a child element owns its own content.\n */\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\";\nexport type ButtonSize = \"md\" | \"lg\";\n\nexport type ButtonProps = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"children\"\n> & {\n variant?: ButtonVariant;\n size?: ButtonSize;\n /** Stretch to the container, as the auth forms' submit does. */\n fullWidth?: boolean;\n /** Shows a spinner in place of the label and disables the control. */\n loading?: boolean;\n /** Shown next to the spinner while `loading`; nothing but the spinner otherwise. */\n loadingLabel?: ReactNode;\n /** Merge the styles onto the child element instead of rendering a button. */\n asChild?: boolean;\n ref?: Ref<HTMLButtonElement>;\n children: ReactNode;\n};\n\nconst BASE_CLASSES =\n \"inline-flex shrink-0 items-center justify-center gap-2 rounded-field border font-[inherit] text-field font-semibold outline-none transition-colors focus-visible:ring-3 focus-visible:ring-accent-soft disabled:cursor-not-allowed disabled:opacity-45\";\n\nconst VARIANT_CLASSES: Record<ButtonVariant, string> = {\n primary:\n \"border-transparent bg-accent text-on-accent enabled:hover:bg-accent-2\",\n secondary: \"border-line bg-surface text-fg enabled:hover:bg-surface-2\",\n ghost: \"border-transparent bg-transparent text-fg enabled:hover:bg-surface-2\",\n};\n\nconst SIZE_CLASSES: Record<ButtonSize, string> = {\n md: \"h-10 px-4\",\n lg: \"h-11 px-5\",\n};\n\nconst LABEL_TONE: Record<ButtonVariant, TypographyTone> = {\n primary: \"on-accent\",\n secondary: \"default\",\n ghost: \"default\",\n};\n\nfunction buttonClassName({\n variant,\n size,\n fullWidth,\n className,\n}: {\n variant: ButtonVariant;\n size: ButtonSize;\n fullWidth: boolean;\n className: string | undefined;\n}): string {\n return [\n BASE_CLASSES,\n VARIANT_CLASSES[variant],\n SIZE_CLASSES[size],\n fullWidth ? \"w-full\" : \"\",\n className ?? \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n}\n\nfunction Spinner() {\n return (\n <svg\n className=\"h-4 w-4 animate-spin\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n aria-hidden=\"true\"\n data-testid=\"button-spinner\"\n >\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 0 1 8-8V0C5.373 0 0 5.373 0 12H4Z\"\n />\n </svg>\n );\n}\n\nexport function Button({\n variant = \"primary\",\n size = \"md\",\n fullWidth = false,\n loading = false,\n loadingLabel,\n asChild = false,\n type = \"button\",\n disabled,\n className,\n children,\n ...rest\n}: ButtonProps) {\n const classes = buttonClassName({ variant, size, fullWidth, className });\n\n if (asChild) {\n return (\n <Slot {...rest} className={classes}>\n {children}\n </Slot>\n );\n }\n\n return (\n <button\n {...rest}\n type={type}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n className={classes}\n >\n {loading ? (\n <>\n <Spinner />\n {loadingLabel}\n </>\n ) : (\n <Typography\n as=\"span\"\n variant=\"body\"\n weight=\"semibold\"\n tone={LABEL_TONE[variant]}\n >\n {children}\n </Typography>\n )}\n </button>\n );\n}\n","import { Slot } from \"@radix-ui/react-slot\";\nimport type { ElementType, HTMLAttributes, ReactNode, Ref } from \"react\";\n\n/**\n * The library's type scale. Everything that renders text — field labels, hints,\n * form errors, headings — goes through here, so a size or colour lives in one\n * place and the tokens in `src/styles/index.css` stay the single source of\n * truth for what \"hint\" or \"muted\" means.\n *\n * Server-safe: no state, no handlers, no directive. It composes Radix `Slot`\n * for `asChild`, which is how a consumer puts these styles on their own\n * element (a `next/link`, a Radix `Label`) without an extra wrapper.\n */\n\nexport type TypographyVariant =\n | \"display\"\n | \"heading\"\n | \"subheading\"\n | \"body\"\n | \"label\"\n | \"hint\"\n | \"code\";\n\nexport type TypographyTone =\n | \"default\"\n | \"muted\"\n | \"subtle\"\n | \"accent\"\n | \"on-accent\"\n | \"success\"\n | \"warning\"\n | \"info\"\n | \"danger\";\n\nexport type TypographyWeight = \"regular\" | \"medium\" | \"semibold\" | \"bold\";\n\nexport type TypographyElement =\n | \"p\"\n | \"span\"\n | \"div\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"label\"\n | \"code\"\n | \"strong\"\n | \"em\"\n | \"small\";\n\nexport type TypographyProps = Omit<HTMLAttributes<HTMLElement>, \"color\"> & {\n /** Size and default element. `body` unless told otherwise. */\n variant?: TypographyVariant;\n /** Colour role, from the design tokens. */\n tone?: TypographyTone;\n /** Overrides the variant's default weight. */\n weight?: TypographyWeight;\n align?: \"start\" | \"center\" | \"end\";\n /** Clip to one line with an ellipsis. */\n truncate?: boolean;\n /**\n * An icon rendered beside the text, hidden from assistive tech. Sized to the\n * text with `1em`, so the same SVG fits every variant.\n */\n icon?: ReactNode;\n iconPosition?: \"leading\" | \"trailing\";\n /** The element to render. Defaults per variant (`h2` for a heading, and so on). */\n as?: TypographyElement;\n /**\n * Radix-style composition: render the child element itself, with these\n * styles merged onto it, instead of a wrapper. Takes precedence over `as`.\n */\n asChild?: boolean;\n ref?: Ref<HTMLElement>;\n children?: ReactNode;\n};\n\nconst DEFAULT_ELEMENT: Record<TypographyVariant, TypographyElement> = {\n display: \"h1\",\n heading: \"h2\",\n subheading: \"h3\",\n body: \"p\",\n label: \"span\",\n hint: \"p\",\n code: \"code\",\n};\n\nconst DEFAULT_WEIGHT: Record<TypographyVariant, TypographyWeight> = {\n display: \"semibold\",\n heading: \"semibold\",\n subheading: \"medium\",\n body: \"regular\",\n label: \"semibold\",\n hint: \"regular\",\n code: \"regular\",\n};\n\nconst VARIANT_CLASSES: Record<TypographyVariant, string> = {\n display: \"text-display leading-tight tracking-tight\",\n heading: \"text-heading leading-tight tracking-tight\",\n subheading: \"text-subheading leading-snug\",\n body: \"text-field leading-normal\",\n label: \"text-label leading-normal\",\n hint: \"text-hint leading-normal\",\n code: \"font-code text-field leading-normal\",\n};\n\nconst TONE_CLASSES: Record<TypographyTone, string> = {\n default: \"text-fg\",\n muted: \"text-fg-muted\",\n subtle: \"text-fg-subtle\",\n accent: \"text-accent\",\n \"on-accent\": \"text-on-accent\",\n success: \"text-success\",\n warning: \"text-warning\",\n info: \"text-info\",\n danger: \"text-danger\",\n};\n\nconst WEIGHT_CLASSES: Record<TypographyWeight, string> = {\n regular: \"font-normal\",\n medium: \"font-medium\",\n semibold: \"font-semibold\",\n bold: \"font-bold\",\n};\n\nconst ALIGN_CLASSES = {\n start: \"text-start\",\n center: \"text-center\",\n end: \"text-end\",\n} as const;\n\nconst ICON_CLASSES =\n \"inline-flex shrink-0 items-center [&>svg]:h-[1em] [&>svg]:w-[1em]\";\n\nfunction typographyClassName({\n variant,\n tone,\n weight,\n align,\n truncate,\n hasIcon,\n className,\n}: {\n variant: TypographyVariant;\n tone: TypographyTone;\n weight: TypographyWeight;\n align: \"start\" | \"center\" | \"end\" | undefined;\n truncate: boolean;\n hasIcon: boolean;\n className: string | undefined;\n}): string {\n return [\n VARIANT_CLASSES[variant],\n TONE_CLASSES[tone],\n WEIGHT_CLASSES[weight],\n align ? ALIGN_CLASSES[align] : \"\",\n hasIcon ? \"inline-flex items-center gap-1.5\" : \"\",\n // With an icon the root is a flex container, and text-overflow only\n // clips block text, so the text span carries the truncation instead.\n truncate && !hasIcon ? \"truncate\" : \"\",\n className ?? \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n}\n\nexport function Typography({\n variant = \"body\",\n tone = \"default\",\n weight,\n align,\n truncate = false,\n icon,\n iconPosition = \"leading\",\n as,\n asChild = false,\n className,\n children,\n ...rest\n}: TypographyProps) {\n const hasIcon = icon !== undefined && icon !== null;\n // Widened to `ElementType`: the union of intrinsic tags would otherwise\n // demand a `ref` typed to one specific element.\n const Component: ElementType = asChild\n ? Slot\n : (as ?? DEFAULT_ELEMENT[variant]);\n\n const iconNode = hasIcon ? (\n <span aria-hidden=\"true\" className={ICON_CLASSES}>\n {icon}\n </span>\n ) : null;\n\n const content = hasIcon ? (\n <>\n {iconPosition === \"leading\" ? iconNode : null}\n <span className={truncate ? \"min-w-0 truncate\" : undefined}>\n {children}\n </span>\n {iconPosition === \"trailing\" ? iconNode : null}\n </>\n ) : (\n children\n );\n\n return (\n <Component\n {...rest}\n className={typographyClassName({\n variant,\n tone,\n weight: weight ?? DEFAULT_WEIGHT[variant],\n align,\n truncate,\n hasIcon,\n className,\n })}\n >\n {content}\n </Component>\n );\n}\n"],"mappings":";;;;AAEA,SAAS,8BAA8B;AAGvC;AAAA,EAGE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACdP,SAAS,QAAAA,aAAY;;;ACArB,SAAS,YAAY;AA+LjB,SAMA,UANA,KAMA,YANA;AAhHJ,IAAM,kBAAgE;AAAA,EACpE,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AACR;AAEA,IAAM,iBAA8D;AAAA,EAClE,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,M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J;AAOO,SAAS,UAAU,OAAuB;AAC/C,QAAM,OAAO,eAAe;AAE5B,SAAO,OACL,gBAAAA,KAAC,sBAAoB,GAAG,OAAO,IAE/B,gBAAAA,KAAC,oBAAkB,GAAG,OAAO;AAEjC;AAOA,SAAS,sBAAsB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,GAAsB;AACpB,QAAM,EAAE,aAAa,IAAI,aAAa;AAEtC,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,MAAK;AAAA,MACL;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAMO,SAAS,aAAa,OAA0B;AACrD,QAAM,OAAO,eAAe;AAE5B,MAAI,MAAM;AACR,WAAO,gBAAAA,KAAC,yBAAuB,GAAG,OAAO;AAAA,EAC3C;AAEA,QAAM,EAAE,YAAY,MAAM,GAAG,KAAK,IAAI;AAEtC,SAAO,gBAAAA,KAAC,UAAQ,GAAG,MAAM,MAAK,UAAS,WAAsB;AAC/D;","names":["Slot","Fragment","jsx","jsxs","VARIANT_CLASSES","Slot","jsx"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type InputFieldProps = Omit<ComponentPropsWithoutRef<"input">, "name" | "type"> & {
|
|
4
|
+
/** The form field this input edits — the key in the `Form`'s values. */
|
|
5
|
+
name: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Guidance under the field. Replaced by the error message while invalid. */
|
|
8
|
+
hint?: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Error supplied by the caller — a server-side or cross-field failure. Takes
|
|
11
|
+
* precedence over what the form's schema reports for this field.
|
|
12
|
+
*/
|
|
13
|
+
error?: string;
|
|
14
|
+
/** Renders the design's muted "Optional" marker at the end of the label. */
|
|
15
|
+
optional?: boolean;
|
|
16
|
+
/** Trailing label slot, for affordances like the design's "Forgot?" link. */
|
|
17
|
+
action?: ReactNode;
|
|
18
|
+
/** Trailing in-field slot, for affordances like the design's password peek. */
|
|
19
|
+
trailing?: ReactNode;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { InputFieldProps as I };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type InputFieldProps = Omit<ComponentPropsWithoutRef<"input">, "name" | "type"> & {
|
|
4
|
+
/** The form field this input edits — the key in the `Form`'s values. */
|
|
5
|
+
name: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Guidance under the field. Replaced by the error message while invalid. */
|
|
8
|
+
hint?: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Error supplied by the caller — a server-side or cross-field failure. Takes
|
|
11
|
+
* precedence over what the form's schema reports for this field.
|
|
12
|
+
*/
|
|
13
|
+
error?: string;
|
|
14
|
+
/** Renders the design's muted "Optional" marker at the end of the label. */
|
|
15
|
+
optional?: boolean;
|
|
16
|
+
/** Trailing label slot, for affordances like the design's "Forgot?" link. */
|
|
17
|
+
action?: ReactNode;
|
|
18
|
+
/** Trailing in-field slot, for affordances like the design's password peek. */
|
|
19
|
+
trailing?: ReactNode;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { InputFieldProps as I };
|