@carbonbits/sixr 1.3.0 → 1.4.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.
Files changed (42) hide show
  1. package/README.md +77 -18
  2. package/dist/chunk-NZHHNVXZ.js +118 -0
  3. package/dist/chunk-NZHHNVXZ.js.map +1 -0
  4. package/dist/email-input.cjs +390 -0
  5. package/dist/email-input.cjs.map +1 -0
  6. package/dist/email-input.d.cts +14 -0
  7. package/dist/email-input.d.ts +14 -0
  8. package/dist/email-input.js +367 -0
  9. package/dist/email-input.js.map +1 -0
  10. package/dist/index-DwjxC4l4.d.cts +62 -0
  11. package/dist/index-DwjxC4l4.d.ts +62 -0
  12. package/dist/index.cjs +112 -0
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +48 -9
  15. package/dist/index.d.ts +48 -9
  16. package/dist/index.js +1 -0
  17. package/dist/password-input.cjs +406 -0
  18. package/dist/password-input.cjs.map +1 -0
  19. package/dist/password-input.d.cts +20 -0
  20. package/dist/password-input.d.ts +20 -0
  21. package/dist/password-input.js +385 -0
  22. package/dist/password-input.js.map +1 -0
  23. package/dist/phone-input.cjs +386 -0
  24. package/dist/phone-input.cjs.map +1 -0
  25. package/dist/phone-input.d.cts +12 -0
  26. package/dist/phone-input.d.ts +12 -0
  27. package/dist/phone-input.js +363 -0
  28. package/dist/phone-input.js.map +1 -0
  29. package/dist/styles.css +1 -1
  30. package/dist/text-input.cjs +228 -59
  31. package/dist/text-input.cjs.map +1 -1
  32. package/dist/text-input.d.cts +10 -58
  33. package/dist/text-input.d.ts +10 -58
  34. package/dist/text-input.js +226 -60
  35. package/dist/text-input.js.map +1 -1
  36. package/dist/typography.cjs +120 -0
  37. package/dist/typography.cjs.map +1 -0
  38. package/dist/typography.d.cts +46 -0
  39. package/dist/typography.d.ts +46 -0
  40. package/dist/typography.js +3 -0
  41. package/dist/typography.js.map +1 -0
  42. package/package.json +45 -1
@@ -25,11 +25,13 @@ __export(text_input_exports, {
25
25
  TextInput: () => TextInput
26
26
  });
27
27
  module.exports = __toCommonJS(text_input_exports);
28
+
29
+ // src/components/field/index.tsx
30
+ var import_react_label = require("@radix-ui/react-label");
31
+ var import_react2 = require("react");
32
+
33
+ // src/components/field/use-field-behaviour.ts
28
34
  var import_react = require("react");
29
- var import_jsx_runtime = require("react/jsx-runtime");
30
- var FIELD_CLASSES = "h-10 w-full rounded-field border bg-surface px-3 font-[inherit] text-field text-fg outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed disabled:opacity-45";
31
- var VALID_CLASSES = "border-line focus:border-accent focus:ring-3 focus:ring-accent-soft";
32
- var INVALID_CLASSES = "border-danger focus:border-danger focus:ring-3 focus:ring-danger-soft";
33
35
  var FALLBACK_MESSAGE = "Invalid value";
34
36
  function runSchema(schema, value) {
35
37
  if (!schema) {
@@ -44,50 +46,6 @@ function runSchema(schema, value) {
44
46
  error: result.error.issues[0]?.message ?? FALLBACK_MESSAGE
45
47
  };
46
48
  }
47
- function fieldClassName(invalid, mono, hasTrailing, className) {
48
- return [
49
- FIELD_CLASSES,
50
- invalid ? INVALID_CLASSES : VALID_CLASSES,
51
- mono ? "font-code" : "",
52
- hasTrailing ? "pr-16" : "",
53
- className ?? ""
54
- ].filter(Boolean).join(" ");
55
- }
56
- function FieldLabel({
57
- htmlFor,
58
- label,
59
- optional,
60
- action
61
- }) {
62
- if (!label) {
63
- return null;
64
- }
65
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
66
- "label",
67
- {
68
- htmlFor,
69
- className: "mb-1.5 flex items-center text-label font-semibold text-fg-muted",
70
- children: [
71
- label,
72
- optional ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ml-auto text-hint font-semibold text-fg-subtle", children: "Optional" }) : null,
73
- action ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ml-auto", children: action }) : null
74
- ]
75
- }
76
- );
77
- }
78
- function FieldMessage({
79
- id,
80
- error,
81
- hint
82
- }) {
83
- if (error) {
84
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { id, role: "alert", className: "mt-1.5 text-hint text-danger", children: error });
85
- }
86
- if (hint) {
87
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { id, className: "mt-1.5 text-hint text-fg-subtle", children: hint });
88
- }
89
- return null;
90
- }
91
49
  function useFieldBehaviour({
92
50
  value,
93
51
  defaultValue,
@@ -141,15 +99,210 @@ function useFieldBehaviour({
141
99
  handleBlur
142
100
  };
143
101
  }
144
- function TextInput({
102
+
103
+ // src/components/typography/index.tsx
104
+ var import_react_slot = require("@radix-ui/react-slot");
105
+ var import_jsx_runtime = require("react/jsx-runtime");
106
+ var DEFAULT_ELEMENT = {
107
+ display: "h1",
108
+ heading: "h2",
109
+ subheading: "h3",
110
+ body: "p",
111
+ label: "span",
112
+ hint: "p",
113
+ code: "code"
114
+ };
115
+ var DEFAULT_WEIGHT = {
116
+ display: "semibold",
117
+ heading: "semibold",
118
+ subheading: "medium",
119
+ body: "regular",
120
+ label: "semibold",
121
+ hint: "regular",
122
+ code: "regular"
123
+ };
124
+ var VARIANT_CLASSES = {
125
+ display: "text-display leading-tight tracking-tight",
126
+ heading: "text-heading leading-tight tracking-tight",
127
+ subheading: "text-subheading leading-snug",
128
+ body: "text-field leading-normal",
129
+ label: "text-label leading-normal",
130
+ hint: "text-hint leading-normal",
131
+ code: "font-code text-field leading-normal"
132
+ };
133
+ var TONE_CLASSES = {
134
+ default: "text-fg",
135
+ muted: "text-fg-muted",
136
+ subtle: "text-fg-subtle",
137
+ accent: "text-accent",
138
+ "on-accent": "text-on-accent",
139
+ success: "text-success",
140
+ warning: "text-warning",
141
+ info: "text-info",
142
+ danger: "text-danger"
143
+ };
144
+ var WEIGHT_CLASSES = {
145
+ regular: "font-normal",
146
+ medium: "font-medium",
147
+ semibold: "font-semibold",
148
+ bold: "font-bold"
149
+ };
150
+ var ALIGN_CLASSES = {
151
+ start: "text-start",
152
+ center: "text-center",
153
+ end: "text-end"
154
+ };
155
+ var ICON_CLASSES = "inline-flex shrink-0 items-center [&>svg]:h-[1em] [&>svg]:w-[1em]";
156
+ function typographyClassName({
157
+ variant,
158
+ tone,
159
+ weight,
160
+ align,
161
+ truncate,
162
+ hasIcon,
163
+ className
164
+ }) {
165
+ return [
166
+ VARIANT_CLASSES[variant],
167
+ TONE_CLASSES[tone],
168
+ WEIGHT_CLASSES[weight],
169
+ align ? ALIGN_CLASSES[align] : "",
170
+ hasIcon ? "inline-flex items-center gap-1.5" : "",
171
+ // With an icon the root is a flex container, and text-overflow only
172
+ // clips block text, so the text span carries the truncation instead.
173
+ truncate && !hasIcon ? "truncate" : "",
174
+ className ?? ""
175
+ ].filter(Boolean).join(" ");
176
+ }
177
+ function Typography({
178
+ variant = "body",
179
+ tone = "default",
180
+ weight,
181
+ align,
182
+ truncate = false,
183
+ icon,
184
+ iconPosition = "leading",
185
+ as,
186
+ asChild = false,
187
+ className,
188
+ children,
189
+ ...rest
190
+ }) {
191
+ const hasIcon = icon !== void 0 && icon !== null;
192
+ const Component = asChild ? import_react_slot.Slot : as ?? DEFAULT_ELEMENT[variant];
193
+ const iconNode = hasIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", className: ICON_CLASSES, children: icon }) : null;
194
+ const content = hasIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
195
+ iconPosition === "leading" ? iconNode : null,
196
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: truncate ? "min-w-0 truncate" : void 0, children }),
197
+ iconPosition === "trailing" ? iconNode : null
198
+ ] }) : children;
199
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
200
+ Component,
201
+ {
202
+ ...rest,
203
+ className: typographyClassName({
204
+ variant,
205
+ tone,
206
+ weight: weight ?? DEFAULT_WEIGHT[variant],
207
+ align,
208
+ truncate,
209
+ hasIcon,
210
+ className
211
+ }),
212
+ children: content
213
+ }
214
+ );
215
+ }
216
+
217
+ // src/components/field/index.tsx
218
+ var import_jsx_runtime2 = require("react/jsx-runtime");
219
+ var FIELD_CLASSES = "h-10 w-full rounded-field border bg-surface px-3 font-[inherit] text-field text-fg outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed disabled:opacity-45";
220
+ var VALID_CLASSES = "border-line focus:border-accent focus:ring-3 focus:ring-accent-soft";
221
+ var INVALID_CLASSES = "border-danger focus:border-danger focus:ring-3 focus:ring-danger-soft";
222
+ function fieldClassName(invalid, hasTrailing, className) {
223
+ return [
224
+ FIELD_CLASSES,
225
+ invalid ? INVALID_CLASSES : VALID_CLASSES,
226
+ hasTrailing ? "pr-16" : "",
227
+ className ?? ""
228
+ ].filter(Boolean).join(" ");
229
+ }
230
+ function FieldLabel({
231
+ htmlFor,
232
+ label,
233
+ optional,
234
+ action
235
+ }) {
236
+ if (!label) {
237
+ return null;
238
+ }
239
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
240
+ Typography,
241
+ {
242
+ variant: "label",
243
+ tone: "muted",
244
+ className: "mb-1.5 flex items-center",
245
+ asChild: true,
246
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_label.Label, { htmlFor, children: [
247
+ label,
248
+ optional ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
249
+ Typography,
250
+ {
251
+ as: "span",
252
+ variant: "hint",
253
+ tone: "subtle",
254
+ weight: "semibold",
255
+ className: "ml-auto",
256
+ children: "Optional"
257
+ }
258
+ ) : null,
259
+ action ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ml-auto", children: action }) : null
260
+ ] })
261
+ }
262
+ );
263
+ }
264
+ function FieldMessage({
265
+ id,
266
+ error,
267
+ hint
268
+ }) {
269
+ if (error) {
270
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
271
+ Typography,
272
+ {
273
+ as: "p",
274
+ variant: "hint",
275
+ tone: "danger",
276
+ id,
277
+ role: "alert",
278
+ className: "mt-1.5",
279
+ children: error
280
+ }
281
+ );
282
+ }
283
+ if (hint) {
284
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
285
+ Typography,
286
+ {
287
+ as: "p",
288
+ variant: "hint",
289
+ tone: "subtle",
290
+ id,
291
+ className: "mt-1.5",
292
+ children: hint
293
+ }
294
+ );
295
+ }
296
+ return null;
297
+ }
298
+ function Field({
145
299
  label,
146
300
  hint,
147
301
  error,
148
302
  optional = false,
149
303
  action,
150
304
  trailing,
151
- mono = false,
152
- type = "text",
305
+ type,
153
306
  value,
154
307
  defaultValue,
155
308
  onChange,
@@ -161,7 +314,7 @@ function TextInput({
161
314
  onBlur,
162
315
  ...rest
163
316
  }) {
164
- const generatedId = (0, import_react.useId)();
317
+ const generatedId = (0, import_react2.useId)();
165
318
  const inputId = id ?? generatedId;
166
319
  const describedById = `${inputId}-description`;
167
320
  const { currentValue, shownError, handleChange, handleBlur } = useFieldBehaviour({
@@ -174,8 +327,8 @@ function TextInput({
174
327
  validateOn,
175
328
  onValidationChange
176
329
  });
177
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col", children: [
178
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
330
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-col", children: [
331
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
179
332
  FieldLabel,
180
333
  {
181
334
  htmlFor: inputId,
@@ -184,8 +337,8 @@ function TextInput({
184
337
  action
185
338
  }
186
339
  ),
187
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: trailing ? "relative" : void 0, children: [
188
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
340
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: trailing ? "relative" : void 0, children: [
341
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
189
342
  "input",
190
343
  {
191
344
  ...rest,
@@ -198,17 +351,33 @@ function TextInput({
198
351
  onBlur: handleBlur,
199
352
  className: fieldClassName(
200
353
  Boolean(shownError),
201
- mono,
202
354
  Boolean(trailing),
203
355
  className
204
356
  )
205
357
  }
206
358
  ),
207
- trailing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "absolute top-1/2 right-[9px] -translate-y-1/2 text-hint font-semibold text-fg-subtle", children: trailing }) : null
359
+ trailing ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "absolute top-1/2 right-[9px] flex -translate-y-1/2 items-center text-hint font-semibold text-fg-subtle", children: trailing }) : null
208
360
  ] }),
209
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldMessage, { id: describedById, error: shownError, hint })
361
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FieldMessage, { id: describedById, error: shownError, hint })
210
362
  ] });
211
363
  }
364
+
365
+ // src/components/text-input/index.tsx
366
+ var import_jsx_runtime3 = require("react/jsx-runtime");
367
+ function TextInput({
368
+ mono = false,
369
+ className,
370
+ ...rest
371
+ }) {
372
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
373
+ Field,
374
+ {
375
+ ...rest,
376
+ type: "text",
377
+ className: [mono ? "font-code" : "", className ?? ""].filter(Boolean).join(" ")
378
+ }
379
+ );
380
+ }
212
381
  // Annotate the CommonJS export names for ESM import in node:
213
382
  0 && (module.exports = {
214
383
  TextInput
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/text-input/index.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ChangeEvent,\n type FocusEvent,\n type InputHTMLAttributes,\n type ReactNode,\n useCallback,\n useId,\n useState,\n} from \"react\";\n\n/**\n * Structural shape of a zod schema — every zod schema satisfies it, and any\n * version of zod does. Declaring it this way rather than importing `ZodType`\n * keeps zod out of this module's public types, so consumers who only want an\n * input do not have to install zod to typecheck it.\n */\nexport type TextInputSchema = {\n safeParse: (\n value: unknown,\n ) =>\n | { success: true }\n | { success: false; error: { issues: readonly { message: string }[] } };\n};\n\n/** Outcome of a single validation pass, handed to `onValidationChange`. */\nexport type TextInputValidation = {\n valid: boolean;\n /** First issue reported by the schema, or `undefined` when valid. */\n error?: string;\n};\n\nexport type TextInputProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"onChange\" | \"value\" | \"defaultValue\" | \"type\"\n> & {\n label?: string;\n /** Guidance under the field. Replaced by the error message while invalid. */\n hint?: ReactNode;\n /**\n * Error supplied by the caller — a server-side or cross-field failure. Takes\n * precedence over the schema, so a form can hold a field invalid regardless\n * of what `schema` makes of the value on its own.\n */\n error?: string;\n /** Renders the design's muted \"Optional\" marker at the end of the label. */\n optional?: boolean;\n /** Trailing label slot, for affordances like the design's \"Forgot?\" link. */\n action?: ReactNode;\n /** Trailing in-field slot, for affordances like the design's password peek. */\n trailing?: ReactNode;\n /** Renders the value in the design's monospace face. */\n mono?: boolean;\n type?: \"text\" | \"email\" | \"password\" | \"tel\" | \"url\" | \"search\";\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /**\n * Any zod schema that accepts a string. Only `safeParse` is used, so a\n * refined, transformed or preprocessed schema works as well as a plain one.\n */\n schema?: TextInputSchema;\n /**\n * When the schema runs. `blur` — the default — avoids scolding someone\n * mid-keystroke; once a field has gone invalid it revalidates on every\n * keystroke so the message clears as soon as it is fixed.\n */\n validateOn?: \"blur\" | \"change\" | \"never\";\n onValidationChange?: (state: TextInputValidation) => void;\n};\n\nconst FIELD_CLASSES =\n \"h-10 w-full rounded-field border bg-surface px-3 font-[inherit] text-field text-fg outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed disabled:opacity-45\";\nconst VALID_CLASSES =\n \"border-line focus:border-accent focus:ring-3 focus:ring-accent-soft\";\nconst INVALID_CLASSES =\n \"border-danger focus:border-danger focus:ring-3 focus:ring-danger-soft\";\nconst FALLBACK_MESSAGE = \"Invalid value\";\n\nfunction runSchema(\n schema: TextInputSchema | undefined,\n value: string,\n): TextInputValidation {\n if (!schema) {\n return { valid: true };\n }\n\n const result = schema.safeParse(value);\n if (result.success) {\n return { valid: true };\n }\n\n return {\n valid: false,\n error: result.error.issues[0]?.message ?? FALLBACK_MESSAGE,\n };\n}\n\nfunction fieldClassName(\n invalid: boolean,\n mono: boolean,\n hasTrailing: boolean,\n className: string | undefined,\n): string {\n return [\n FIELD_CLASSES,\n invalid ? INVALID_CLASSES : VALID_CLASSES,\n mono ? \"font-code\" : \"\",\n hasTrailing ? \"pr-16\" : \"\",\n className ?? \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n}\n\nfunction FieldLabel({\n htmlFor,\n label,\n optional,\n action,\n}: {\n htmlFor: string;\n label: string | undefined;\n optional: boolean;\n action: ReactNode;\n}) {\n if (!label) {\n return null;\n }\n\n return (\n <label\n htmlFor={htmlFor}\n className=\"mb-1.5 flex items-center text-label font-semibold text-fg-muted\"\n >\n {label}\n {optional ? (\n <span className=\"ml-auto text-hint font-semibold text-fg-subtle\">\n Optional\n </span>\n ) : null}\n {action ? <span className=\"ml-auto\">{action}</span> : null}\n </label>\n );\n}\n\nfunction FieldMessage({\n id,\n error,\n hint,\n}: {\n id: string;\n error: string | undefined;\n hint: ReactNode;\n}) {\n if (error) {\n return (\n <p id={id} role=\"alert\" className=\"mt-1.5 text-hint text-danger\">\n {error}\n </p>\n );\n }\n\n if (hint) {\n return (\n <p id={id} className=\"mt-1.5 text-hint text-fg-subtle\">\n {hint}\n </p>\n );\n }\n\n return null;\n}\n\ntype FieldBehaviour = Pick<\n TextInputProps,\n | \"value\"\n | \"defaultValue\"\n | \"error\"\n | \"onChange\"\n | \"onBlur\"\n | \"schema\"\n | \"validateOn\"\n | \"onValidationChange\"\n>;\n\n/**\n * Owns the value (controlled or not), the schema verdict, and when to re-run\n * it. Split out so the component itself stays markup.\n */\nfunction useFieldBehaviour({\n value,\n defaultValue,\n error,\n onChange,\n onBlur,\n schema,\n validateOn = \"blur\",\n onValidationChange,\n}: FieldBehaviour) {\n const [uncontrolledValue, setUncontrolledValue] = useState(\n defaultValue ?? \"\",\n );\n const [schemaError, setSchemaError] = useState<string | undefined>(undefined);\n\n const isControlled = value !== undefined;\n\n const validate = useCallback(\n (next: string) => {\n const state = runSchema(schema, next);\n setSchemaError(state.error);\n onValidationChange?.(state);\n },\n [schema, onValidationChange],\n );\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const next = event.target.value;\n if (!isControlled) {\n setUncontrolledValue(next);\n }\n onChange?.(next);\n\n // Revalidate on every keystroke once the field is already invalid, so a\n // corrected value clears the message without waiting for another blur.\n if (validateOn === \"change\" || (validateOn === \"blur\" && schemaError)) {\n validate(next);\n }\n },\n [isControlled, onChange, validateOn, schemaError, validate],\n );\n\n const handleBlur = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (validateOn === \"blur\") {\n validate(event.target.value);\n }\n onBlur?.(event);\n },\n [validateOn, validate, onBlur],\n );\n\n return {\n currentValue: isControlled ? value : uncontrolledValue,\n // A caller-supplied error outranks the schema's verdict.\n shownError: error ?? schemaError,\n handleChange,\n handleBlur,\n };\n}\n\nexport function TextInput({\n label,\n hint,\n error,\n optional = false,\n action,\n trailing,\n mono = false,\n type = \"text\",\n value,\n defaultValue,\n onChange,\n schema,\n validateOn = \"blur\",\n onValidationChange,\n id,\n className,\n onBlur,\n ...rest\n}: TextInputProps) {\n const generatedId = useId();\n const inputId = id ?? generatedId;\n const describedById = `${inputId}-description`;\n\n const { currentValue, shownError, handleChange, handleBlur } =\n useFieldBehaviour({\n value,\n defaultValue,\n error,\n onChange,\n onBlur,\n schema,\n validateOn,\n onValidationChange,\n });\n\n return (\n <div className=\"flex flex-col\">\n <FieldLabel\n htmlFor={inputId}\n label={label}\n optional={optional}\n action={action}\n />\n\n <div className={trailing ? \"relative\" : undefined}>\n <input\n {...rest}\n id={inputId}\n type={type}\n value={currentValue}\n aria-invalid={shownError ? true : undefined}\n aria-describedby={shownError || hint ? describedById : undefined}\n onChange={handleChange}\n onBlur={handleBlur}\n className={fieldClassName(\n Boolean(shownError),\n mono,\n Boolean(trailing),\n className,\n )}\n />\n {trailing ? (\n <span className=\"absolute top-1/2 right-[9px] -translate-y-1/2 text-hint font-semibold text-fg-subtle\">\n {trailing}\n </span>\n ) : null}\n </div>\n\n <FieldMessage id={describedById} error={shownError} hint={hint} />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAQO;AA0HH;AA5DJ,IAAM,gBACJ;AACF,IAAM,gBACJ;AACF,IAAM,kBACJ;AACF,IAAM,mBAAmB;AAEzB,SAAS,UACP,QACA,OACqB;AACrB,MAAI,CAAC,QAAQ;AACX,WAAO,EAAE,OAAO,KAAK;AAAA,EACvB;AAEA,QAAM,SAAS,OAAO,UAAU,KAAK;AACrC,MAAI,OAAO,SAAS;AAClB,WAAO,EAAE,OAAO,KAAK;AAAA,EACvB;AAEA,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,OAAO,MAAM,OAAO,CAAC,GAAG,WAAW;AAAA,EAC5C;AACF;AAEA,SAAS,eACP,SACA,MACA,aACA,WACQ;AACR,SAAO;AAAA,IACL;AAAA,IACA,UAAU,kBAAkB;AAAA,IAC5B,OAAO,cAAc;AAAA,IACrB,cAAc,UAAU;AAAA,IACxB,aAAa;AAAA,EACf,EACG,OAAO,OAAO,EACd,KAAK,GAAG;AACb;AAEA,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAU;AAAA,MAET;AAAA;AAAA,QACA,WACC,4CAAC,UAAK,WAAU,kDAAiD,sBAEjE,IACE;AAAA,QACH,SAAS,4CAAC,UAAK,WAAU,WAAW,kBAAO,IAAU;AAAA;AAAA;AAAA,EACxD;AAEJ;AAEA,SA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src/components/text-input/index.tsx","../src/components/field/index.tsx","../src/components/field/use-field-behaviour.ts","../src/components/typography/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field, type FieldProps } from \"@/components/field\";\n\nexport type {\n FieldSchema,\n FieldValidation,\n} from \"@/components/field\";\n\n/**\n * Plain free text: names, job titles, one-time codes. Anything with a format\n * of its own — an email address, a phone number, a password — has its own\n * component (`EmailInput`, `PhoneInput`, `PasswordInput`), which fixes the\n * keyboard, autocomplete and input type that format needs.\n */\nexport type TextInputProps = FieldProps & {\n /** Renders the value in the design's monospace face, as the code entry does. */\n mono?: boolean;\n};\n\nexport function TextInput({\n mono = false,\n className,\n ...rest\n}: TextInputProps) {\n return (\n <Field\n {...rest}\n type=\"text\"\n className={[mono ? \"font-code\" : \"\", className ?? \"\"]\n .filter(Boolean)\n .join(\" \")}\n />\n );\n}\n","\"use client\";\n\nimport { Label } from \"@radix-ui/react-label\";\nimport { type InputHTMLAttributes, type ReactNode, useId } from \"react\";\nimport {\n type FieldSchema,\n type FieldValidation,\n useFieldBehaviour,\n} from \"@/components/field/use-field-behaviour\";\nimport { Typography } from \"@/components/typography\";\n\nexport type {\n FieldSchema,\n FieldValidation,\n} from \"@/components/field/use-field-behaviour\";\n\n/**\n * The single-line input behind `TextInput`, `EmailInput`, `PasswordInput` and\n * `PhoneInput`. Each of those fixes the `type` (and the keyboard, autocomplete\n * and validation defaults that go with it) and hands everything else here.\n *\n * Internal: this module has no subpath of its own. Consumers reach it through\n * the specialised inputs, and its shared types through the barrel.\n */\n\nexport type FieldType = \"text\" | \"email\" | \"password\" | \"tel\";\n\n/** Props every specialised input shares. `type` is fixed by the wrapper. */\nexport type FieldProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"onChange\" | \"value\" | \"defaultValue\" | \"type\"\n> & {\n label?: string;\n /** Guidance under the field. Replaced by the error message while invalid. */\n hint?: ReactNode;\n /**\n * Error supplied by the caller — a server-side or cross-field failure. Takes\n * precedence over the schema, so a form can hold a field invalid regardless\n * of what `schema` makes of the value on its own.\n */\n error?: string;\n /** Renders the design's muted \"Optional\" marker at the end of the label. */\n optional?: boolean;\n /** Trailing label slot, for affordances like the design's \"Forgot?\" link. */\n action?: ReactNode;\n /** Trailing in-field slot, for affordances like the design's password peek. */\n trailing?: ReactNode;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /**\n * Any zod schema that accepts a string. Only `safeParse` is used, so a\n * refined, transformed or preprocessed schema works as well as a plain one.\n */\n schema?: FieldSchema;\n /**\n * When the schema runs. `blur` — the default — avoids scolding someone\n * mid-keystroke; once a field has gone invalid it revalidates on every\n * keystroke so the message clears as soon as it is fixed.\n */\n validateOn?: \"blur\" | \"change\" | \"never\";\n onValidationChange?: (state: FieldValidation) => void;\n};\n\nconst FIELD_CLASSES =\n \"h-10 w-full rounded-field border bg-surface px-3 font-[inherit] text-field text-fg outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed disabled:opacity-45\";\nconst VALID_CLASSES =\n \"border-line focus:border-accent focus:ring-3 focus:ring-accent-soft\";\nconst INVALID_CLASSES =\n \"border-danger focus:border-danger focus:ring-3 focus:ring-danger-soft\";\nfunction fieldClassName(\n invalid: boolean,\n hasTrailing: boolean,\n className: string | undefined,\n): string {\n return [\n FIELD_CLASSES,\n invalid ? INVALID_CLASSES : VALID_CLASSES,\n hasTrailing ? \"pr-16\" : \"\",\n className ?? \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n}\n\nfunction FieldLabel({\n htmlFor,\n label,\n optional,\n action,\n}: {\n htmlFor: string;\n label: string | undefined;\n optional: boolean;\n action: ReactNode;\n}) {\n if (!label) {\n return null;\n }\n\n return (\n <Typography\n variant=\"label\"\n tone=\"muted\"\n className=\"mb-1.5 flex items-center\"\n asChild\n >\n <Label htmlFor={htmlFor}>\n {label}\n {optional ? (\n <Typography\n as=\"span\"\n variant=\"hint\"\n tone=\"subtle\"\n weight=\"semibold\"\n className=\"ml-auto\"\n >\n Optional\n </Typography>\n ) : null}\n {action ? <span className=\"ml-auto\">{action}</span> : null}\n </Label>\n </Typography>\n );\n}\n\nfunction FieldMessage({\n id,\n error,\n hint,\n}: {\n id: string;\n error: string | undefined;\n hint: ReactNode;\n}) {\n if (error) {\n return (\n <Typography\n as=\"p\"\n variant=\"hint\"\n tone=\"danger\"\n id={id}\n role=\"alert\"\n className=\"mt-1.5\"\n >\n {error}\n </Typography>\n );\n }\n\n if (hint) {\n return (\n <Typography\n as=\"p\"\n variant=\"hint\"\n tone=\"subtle\"\n id={id}\n className=\"mt-1.5\"\n >\n {hint}\n </Typography>\n );\n }\n\n return null;\n}\n\nexport type FieldComponentProps = FieldProps & { type: FieldType };\n\nexport function Field({\n label,\n hint,\n error,\n optional = false,\n action,\n trailing,\n type,\n value,\n defaultValue,\n onChange,\n schema,\n validateOn = \"blur\",\n onValidationChange,\n id,\n className,\n onBlur,\n ...rest\n}: FieldComponentProps) {\n const generatedId = useId();\n const inputId = id ?? generatedId;\n const describedById = `${inputId}-description`;\n\n const { currentValue, shownError, handleChange, handleBlur } =\n useFieldBehaviour({\n value,\n defaultValue,\n error,\n onChange,\n onBlur,\n schema,\n validateOn,\n onValidationChange,\n });\n\n return (\n <div className=\"flex flex-col\">\n <FieldLabel\n htmlFor={inputId}\n label={label}\n optional={optional}\n action={action}\n />\n\n <div className={trailing ? \"relative\" : undefined}>\n <input\n {...rest}\n id={inputId}\n type={type}\n value={currentValue}\n aria-invalid={shownError ? true : undefined}\n aria-describedby={shownError || hint ? describedById : undefined}\n onChange={handleChange}\n onBlur={handleBlur}\n className={fieldClassName(\n Boolean(shownError),\n Boolean(trailing),\n className,\n )}\n />\n {trailing ? (\n <span className=\"absolute top-1/2 right-[9px] flex -translate-y-1/2 items-center text-hint font-semibold text-fg-subtle\">\n {trailing}\n </span>\n ) : null}\n </div>\n\n <FieldMessage id={describedById} error={shownError} hint={hint} />\n </div>\n );\n}\n","import {\n type ChangeEvent,\n type FocusEvent,\n useCallback,\n useState,\n} from \"react\";\n\n/**\n * Structural shape of a zod schema — every zod schema satisfies it, and any\n * version of zod does. Declaring it this way rather than importing `ZodType`\n * keeps zod out of this module's public types, so consumers who only want an\n * input do not have to install zod to typecheck it.\n */\nexport type FieldSchema = {\n safeParse: (\n value: unknown,\n ) =>\n | { success: true }\n | { success: false; error: { issues: readonly { message: string }[] } };\n};\n\n/** Outcome of a single validation pass, handed to `onValidationChange`. */\nexport type FieldValidation = {\n valid: boolean;\n /** First issue reported by the schema, or `undefined` when valid. */\n error?: string;\n};\n\nexport type FieldBehaviour = {\n value?: string;\n defaultValue?: string;\n /** A caller-supplied error. Outranks the schema's verdict. */\n error?: string;\n onChange?: (value: string) => void;\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void;\n schema?: FieldSchema;\n validateOn?: \"blur\" | \"change\" | \"never\";\n onValidationChange?: (state: FieldValidation) => void;\n};\n\nconst FALLBACK_MESSAGE = \"Invalid value\";\n\nfunction runSchema(\n schema: FieldSchema | undefined,\n value: string,\n): FieldValidation {\n if (!schema) {\n return { valid: true };\n }\n\n const result = schema.safeParse(value);\n if (result.success) {\n return { valid: true };\n }\n\n return {\n valid: false,\n error: result.error.issues[0]?.message ?? FALLBACK_MESSAGE,\n };\n}\n\n/**\n * Owns the value (controlled or not), the schema verdict, and when to re-run\n * it. Split out so the `Field` component itself stays markup.\n */\nexport function useFieldBehaviour({\n value,\n defaultValue,\n error,\n onChange,\n onBlur,\n schema,\n validateOn = \"blur\",\n onValidationChange,\n}: FieldBehaviour) {\n const [uncontrolledValue, setUncontrolledValue] = useState(\n defaultValue ?? \"\",\n );\n const [schemaError, setSchemaError] = useState<string | undefined>(undefined);\n\n const isControlled = value !== undefined;\n\n const validate = useCallback(\n (next: string) => {\n const state = runSchema(schema, next);\n setSchemaError(state.error);\n onValidationChange?.(state);\n },\n [schema, onValidationChange],\n );\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const next = event.target.value;\n if (!isControlled) {\n setUncontrolledValue(next);\n }\n onChange?.(next);\n\n // Revalidate on every keystroke once the field is already invalid, so a\n // corrected value clears the message without waiting for another blur.\n if (validateOn === \"change\" || (validateOn === \"blur\" && schemaError)) {\n validate(next);\n }\n },\n [isControlled, onChange, validateOn, schemaError, validate],\n );\n\n const handleBlur = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (validateOn === \"blur\") {\n validate(event.target.value);\n }\n onBlur?.(event);\n },\n [validateOn, validate, onBlur],\n );\n\n return {\n currentValue: isControlled ? value : uncontrolledValue,\n // A caller-supplied error outranks the schema's verdict.\n shownError: error ?? schemaError,\n handleChange,\n handleBlur,\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":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA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AE,cAAc,YAAY,cAAc,WAAW,IACzD,kBAAkB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAEH,SACE,8CAAC,SAAI,WAAU,iBACb;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,SAAS;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,IAEA,8CAAC,SAAI,WAAW,WAAW,aAAa,QACtC;AAAA;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACJ,IAAI;AAAA,UACJ;AAAA,UACA,OAAO;AAAA,UACP,gBAAc,aAAa,OAAO;AAAA,UAClC,oBAAkB,cAAc,OAAO,gBAAgB;AAAA,UACvD,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,WAAW;AAAA,YACT,QAAQ,UAAU;AAAA,YAClB,QAAQ,QAAQ;AAAA,YAChB;AAAA,UACF;AAAA;AAAA,MACF;AAAA,MACC,WACC,6CAAC,UAAK,WAAU,0GACb,oBACH,IACE;AAAA,OACN;AAAA,IAEA,6CAAC,gBAAa,IAAI,eAAe,OAAO,YAAY,MAAY;AAAA,KAClE;AAEJ;;;ADrNI,IAAAC,sBAAA;AANG,SAAS,UAAU;AAAA,EACxB,OAAO;AAAA,EACP;AAAA,EACA,GAAG;AACL,GAAmB;AACjB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,MAAK;AAAA,MACL,WAAW,CAAC,OAAO,cAAc,IAAI,aAAa,EAAE,EACjD,OAAO,OAAO,EACd,KAAK,GAAG;AAAA;AAAA,EACb;AAEJ;","names":["import_react","import_jsx_runtime","import_jsx_runtime"]}
@@ -1,65 +1,17 @@
1
1
  import * as react from 'react';
2
- import { InputHTMLAttributes, ReactNode } from 'react';
2
+ import { F as FieldProps } from './index-DwjxC4l4.cjs';
3
+ export { a as FieldSchema, b as FieldValidation } from './index-DwjxC4l4.cjs';
3
4
 
4
5
  /**
5
- * Structural shape of a zod schema — every zod schema satisfies it, and any
6
- * version of zod does. Declaring it this way rather than importing `ZodType`
7
- * keeps zod out of this module's public types, so consumers who only want an
8
- * input do not have to install zod to typecheck it.
6
+ * Plain free text: names, job titles, one-time codes. Anything with a format
7
+ * of its own — an email address, a phone number, a password — has its own
8
+ * component (`EmailInput`, `PhoneInput`, `PasswordInput`), which fixes the
9
+ * keyboard, autocomplete and input type that format needs.
9
10
  */
10
- type TextInputSchema = {
11
- safeParse: (value: unknown) => {
12
- success: true;
13
- } | {
14
- success: false;
15
- error: {
16
- issues: readonly {
17
- message: string;
18
- }[];
19
- };
20
- };
21
- };
22
- /** Outcome of a single validation pass, handed to `onValidationChange`. */
23
- type TextInputValidation = {
24
- valid: boolean;
25
- /** First issue reported by the schema, or `undefined` when valid. */
26
- error?: string;
27
- };
28
- type TextInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "defaultValue" | "type"> & {
29
- label?: string;
30
- /** Guidance under the field. Replaced by the error message while invalid. */
31
- hint?: ReactNode;
32
- /**
33
- * Error supplied by the caller — a server-side or cross-field failure. Takes
34
- * precedence over the schema, so a form can hold a field invalid regardless
35
- * of what `schema` makes of the value on its own.
36
- */
37
- error?: string;
38
- /** Renders the design's muted "Optional" marker at the end of the label. */
39
- optional?: boolean;
40
- /** Trailing label slot, for affordances like the design's "Forgot?" link. */
41
- action?: ReactNode;
42
- /** Trailing in-field slot, for affordances like the design's password peek. */
43
- trailing?: ReactNode;
44
- /** Renders the value in the design's monospace face. */
11
+ type TextInputProps = FieldProps & {
12
+ /** Renders the value in the design's monospace face, as the code entry does. */
45
13
  mono?: boolean;
46
- type?: "text" | "email" | "password" | "tel" | "url" | "search";
47
- value?: string;
48
- defaultValue?: string;
49
- onChange?: (value: string) => void;
50
- /**
51
- * Any zod schema that accepts a string. Only `safeParse` is used, so a
52
- * refined, transformed or preprocessed schema works as well as a plain one.
53
- */
54
- schema?: TextInputSchema;
55
- /**
56
- * When the schema runs. `blur` — the default — avoids scolding someone
57
- * mid-keystroke; once a field has gone invalid it revalidates on every
58
- * keystroke so the message clears as soon as it is fixed.
59
- */
60
- validateOn?: "blur" | "change" | "never";
61
- onValidationChange?: (state: TextInputValidation) => void;
62
14
  };
63
- declare function TextInput({ label, hint, error, optional, action, trailing, mono, type, value, defaultValue, onChange, schema, validateOn, onValidationChange, id, className, onBlur, ...rest }: TextInputProps): react.JSX.Element;
15
+ declare function TextInput({ mono, className, ...rest }: TextInputProps): react.JSX.Element;
64
16
 
65
- export { TextInput, type TextInputProps, type TextInputSchema, type TextInputValidation };
17
+ export { TextInput, type TextInputProps };
@@ -1,65 +1,17 @@
1
1
  import * as react from 'react';
2
- import { InputHTMLAttributes, ReactNode } from 'react';
2
+ import { F as FieldProps } from './index-DwjxC4l4.js';
3
+ export { a as FieldSchema, b as FieldValidation } from './index-DwjxC4l4.js';
3
4
 
4
5
  /**
5
- * Structural shape of a zod schema — every zod schema satisfies it, and any
6
- * version of zod does. Declaring it this way rather than importing `ZodType`
7
- * keeps zod out of this module's public types, so consumers who only want an
8
- * input do not have to install zod to typecheck it.
6
+ * Plain free text: names, job titles, one-time codes. Anything with a format
7
+ * of its own — an email address, a phone number, a password — has its own
8
+ * component (`EmailInput`, `PhoneInput`, `PasswordInput`), which fixes the
9
+ * keyboard, autocomplete and input type that format needs.
9
10
  */
10
- type TextInputSchema = {
11
- safeParse: (value: unknown) => {
12
- success: true;
13
- } | {
14
- success: false;
15
- error: {
16
- issues: readonly {
17
- message: string;
18
- }[];
19
- };
20
- };
21
- };
22
- /** Outcome of a single validation pass, handed to `onValidationChange`. */
23
- type TextInputValidation = {
24
- valid: boolean;
25
- /** First issue reported by the schema, or `undefined` when valid. */
26
- error?: string;
27
- };
28
- type TextInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "defaultValue" | "type"> & {
29
- label?: string;
30
- /** Guidance under the field. Replaced by the error message while invalid. */
31
- hint?: ReactNode;
32
- /**
33
- * Error supplied by the caller — a server-side or cross-field failure. Takes
34
- * precedence over the schema, so a form can hold a field invalid regardless
35
- * of what `schema` makes of the value on its own.
36
- */
37
- error?: string;
38
- /** Renders the design's muted "Optional" marker at the end of the label. */
39
- optional?: boolean;
40
- /** Trailing label slot, for affordances like the design's "Forgot?" link. */
41
- action?: ReactNode;
42
- /** Trailing in-field slot, for affordances like the design's password peek. */
43
- trailing?: ReactNode;
44
- /** Renders the value in the design's monospace face. */
11
+ type TextInputProps = FieldProps & {
12
+ /** Renders the value in the design's monospace face, as the code entry does. */
45
13
  mono?: boolean;
46
- type?: "text" | "email" | "password" | "tel" | "url" | "search";
47
- value?: string;
48
- defaultValue?: string;
49
- onChange?: (value: string) => void;
50
- /**
51
- * Any zod schema that accepts a string. Only `safeParse` is used, so a
52
- * refined, transformed or preprocessed schema works as well as a plain one.
53
- */
54
- schema?: TextInputSchema;
55
- /**
56
- * When the schema runs. `blur` — the default — avoids scolding someone
57
- * mid-keystroke; once a field has gone invalid it revalidates on every
58
- * keystroke so the message clears as soon as it is fixed.
59
- */
60
- validateOn?: "blur" | "change" | "never";
61
- onValidationChange?: (state: TextInputValidation) => void;
62
14
  };
63
- declare function TextInput({ label, hint, error, optional, action, trailing, mono, type, value, defaultValue, onChange, schema, validateOn, onValidationChange, id, className, onBlur, ...rest }: TextInputProps): react.JSX.Element;
15
+ declare function TextInput({ mono, className, ...rest }: TextInputProps): react.JSX.Element;
64
16
 
65
- export { TextInput, type TextInputProps, type TextInputSchema, type TextInputValidation };
17
+ export { TextInput, type TextInputProps };