ovr 6.2.4 → 7.0.0-next.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 (136) hide show
  1. package/README.md +3 -1
  2. package/dist/app/index.d.ts +51 -7
  3. package/dist/app/index.d.ts.map +1 -1
  4. package/dist/app/index.js +163 -28
  5. package/dist/auth/auth-data.d.ts +26 -0
  6. package/dist/auth/auth-data.d.ts.map +1 -0
  7. package/dist/auth/auth-data.js +42 -0
  8. package/dist/auth/cbor.d.ts +50 -0
  9. package/dist/auth/cbor.d.ts.map +1 -0
  10. package/dist/auth/cbor.js +200 -0
  11. package/dist/auth/client-source.d.ts +3 -0
  12. package/dist/auth/client-source.d.ts.map +1 -0
  13. package/dist/auth/client-source.js +3 -0
  14. package/dist/auth/client.d.ts +3 -0
  15. package/dist/auth/client.d.ts.map +1 -0
  16. package/dist/auth/client.js +186 -0
  17. package/dist/auth/configure.d.ts +28 -0
  18. package/dist/auth/configure.d.ts.map +1 -0
  19. package/dist/auth/configure.js +228 -0
  20. package/dist/auth/der.d.ts +6 -0
  21. package/dist/auth/der.d.ts.map +1 -0
  22. package/dist/auth/der.js +36 -0
  23. package/dist/auth/index.d.ts +242 -0
  24. package/dist/auth/index.d.ts.map +1 -0
  25. package/dist/auth/index.js +152 -0
  26. package/dist/auth/issue.d.ts +36 -0
  27. package/dist/auth/issue.d.ts.map +1 -0
  28. package/dist/auth/issue.js +47 -0
  29. package/dist/auth/metadata.d.ts +22 -0
  30. package/dist/auth/metadata.d.ts.map +1 -0
  31. package/dist/auth/metadata.js +134 -0
  32. package/dist/auth/oauth.d.ts +29 -0
  33. package/dist/auth/oauth.d.ts.map +1 -0
  34. package/dist/auth/oauth.js +724 -0
  35. package/dist/auth/passkey.d.ts +101 -0
  36. package/dist/auth/passkey.d.ts.map +1 -0
  37. package/dist/auth/passkey.js +393 -0
  38. package/dist/auth/state.d.ts +49 -0
  39. package/dist/auth/state.d.ts.map +1 -0
  40. package/dist/auth/state.js +184 -0
  41. package/dist/auth/storage.d.ts +193 -0
  42. package/dist/auth/storage.d.ts.map +1 -0
  43. package/dist/auth/storage.js +410 -0
  44. package/dist/auth/token.d.ts +12 -0
  45. package/dist/auth/token.d.ts.map +1 -0
  46. package/dist/auth/token.js +39 -0
  47. package/dist/context/index.d.ts +86 -16
  48. package/dist/context/index.d.ts.map +1 -1
  49. package/dist/context/index.js +166 -42
  50. package/dist/cookie/index.d.ts +3 -0
  51. package/dist/cookie/index.d.ts.map +1 -1
  52. package/dist/cookie/index.js +1 -0
  53. package/dist/database/index.d.ts +262 -0
  54. package/dist/database/index.d.ts.map +1 -0
  55. package/dist/database/index.js +807 -0
  56. package/dist/form/index.d.ts +699 -0
  57. package/dist/form/index.d.ts.map +1 -0
  58. package/dist/form/index.js +901 -0
  59. package/dist/index.d.ts +10 -3
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +9 -3
  62. package/dist/jsx/elements.d.ts +28 -2
  63. package/dist/jsx/elements.d.ts.map +1 -1
  64. package/dist/jsx/index.d.ts +20 -4
  65. package/dist/jsx/index.d.ts.map +1 -1
  66. package/dist/jsx/index.js +6 -65
  67. package/dist/limiter/index.d.ts +65 -0
  68. package/dist/limiter/index.d.ts.map +1 -0
  69. package/dist/limiter/index.js +157 -0
  70. package/dist/markdown/index.d.ts +61 -0
  71. package/dist/markdown/index.d.ts.map +1 -0
  72. package/dist/markdown/index.js +1160 -0
  73. package/dist/markup/index.d.ts +188 -0
  74. package/dist/markup/index.d.ts.map +1 -0
  75. package/dist/markup/index.js +718 -0
  76. package/dist/mcp/index.d.ts +73 -0
  77. package/dist/mcp/index.d.ts.map +1 -0
  78. package/dist/mcp/index.js +988 -0
  79. package/dist/middleware/index.d.ts +3 -4
  80. package/dist/middleware/index.d.ts.map +1 -1
  81. package/dist/multipart/index.d.ts +53 -7
  82. package/dist/multipart/index.d.ts.map +1 -1
  83. package/dist/multipart/index.js +332 -124
  84. package/dist/route/index.d.ts +226 -80
  85. package/dist/route/index.d.ts.map +1 -1
  86. package/dist/route/index.js +239 -99
  87. package/dist/schema/index.d.ts +307 -734
  88. package/dist/schema/index.d.ts.map +1 -1
  89. package/dist/schema/index.js +783 -1050
  90. package/dist/table/index.d.ts +132 -0
  91. package/dist/table/index.d.ts.map +1 -0
  92. package/dist/table/index.js +188 -0
  93. package/dist/trie/index.js +4 -4
  94. package/dist/util/index.d.ts +37 -5
  95. package/dist/util/index.d.ts.map +1 -1
  96. package/dist/util/index.js +156 -41
  97. package/package.json +11 -4
  98. package/src/app/index.ts +230 -42
  99. package/src/auth/auth-data.ts +56 -0
  100. package/src/auth/cbor.ts +231 -0
  101. package/src/auth/client-source.ts +3 -0
  102. package/src/auth/client.ts +205 -0
  103. package/src/auth/configure.ts +279 -0
  104. package/src/auth/der.ts +35 -0
  105. package/src/auth/index.ts +387 -0
  106. package/src/auth/issue.ts +52 -0
  107. package/src/auth/metadata.ts +149 -0
  108. package/src/auth/oauth.ts +882 -0
  109. package/src/auth/passkey.ts +556 -0
  110. package/src/auth/state.ts +213 -0
  111. package/src/auth/storage.ts +572 -0
  112. package/src/auth/token.ts +67 -0
  113. package/src/context/index.ts +240 -65
  114. package/src/cookie/index.ts +3 -0
  115. package/src/database/index.ts +1193 -0
  116. package/src/form/index.ts +1720 -0
  117. package/src/index.ts +10 -3
  118. package/src/jsx/elements.ts +45 -25
  119. package/src/jsx/index.ts +24 -69
  120. package/src/limiter/index.ts +221 -0
  121. package/src/markdown/index.ts +1322 -0
  122. package/src/markup/index.ts +853 -0
  123. package/src/mcp/conformance.2025-11-25.yml +39 -0
  124. package/src/mcp/conformance.2026-07-28.yml +56 -0
  125. package/src/mcp/index.ts +1262 -0
  126. package/src/middleware/index.ts +5 -6
  127. package/src/multipart/index.ts +410 -158
  128. package/src/route/index.ts +559 -278
  129. package/src/schema/index.ts +1542 -2256
  130. package/src/table/index.ts +387 -0
  131. package/src/trie/index.ts +4 -4
  132. package/src/util/index.ts +163 -49
  133. package/dist/render/index.d.ts +0 -79
  134. package/dist/render/index.d.ts.map +0 -1
  135. package/dist/render/index.js +0 -257
  136. package/src/render/index.ts +0 -314
@@ -0,0 +1,699 @@
1
+ import { type JSX } from "../jsx/index.js";
2
+ import type { Multipart } from "../multipart/index.js";
3
+ import { Schema, ShapeUtil, annotate } from "../schema/index.js";
4
+ /** Internal protocol for a GET route, to make the form its fields render. */
5
+ export declare const query: unique symbol;
6
+ /** A field's components and render, which a route's form reads */
7
+ declare const component: unique symbol;
8
+ declare const render: unique symbol;
9
+ /**
10
+ * Each route's form, kept apart from the route so its parsing is not part of
11
+ * the route's API.
12
+ */
13
+ export declare const forms: WeakMap<object, Form<any>>;
14
+ /**
15
+ * Form schema with JSX rendering capabilities.
16
+ *
17
+ * Parses `FormData` or `URLSearchParams` and generates form field
18
+ * components.
19
+ *
20
+ * @template Shape Form field shape type
21
+ */
22
+ export declare class Form<Shape extends Field.Shape = Field.Shape> {
23
+ #private;
24
+ /** Query param keys ordered as `[return, form]`. */
25
+ static readonly params: readonly ["_return", "_form"];
26
+ /** Field definitions. */
27
+ readonly shape: Shape;
28
+ /** Field names in definition order. */
29
+ readonly names: ShapeUtil.Name<Shape>[];
30
+ /** Maximum expected multipart parts derived from field cardinality. */
31
+ readonly parts: number;
32
+ /**
33
+ * Create a new form schema validator.
34
+ *
35
+ * @param shape Form fields
36
+ */
37
+ constructor(shape: Shape);
38
+ /** @returns The form for a GET route, whose submission is the page's URL */
39
+ [query](): Form<Shape>;
40
+ /**
41
+ * Parse and validate form data.
42
+ *
43
+ * @param source FormData, URLSearchParams, or Multipart to parse
44
+ * @param path Internal path reference
45
+ * @returns Parsed result
46
+ */
47
+ parse: (source: FormData | URLSearchParams | Multipart, path?: Schema.Issue.Path) => Promise<Field.Parse.Result<Shape>>;
48
+ /**
49
+ * Render a single form field.
50
+ *
51
+ * @param props Component props
52
+ * @example
53
+ *
54
+ * ```tsx
55
+ * <User.Field name="username" />
56
+ * ```
57
+ */
58
+ Field: ({ values, ...props }: Field.Component.Props<Shape> & {
59
+ values?: Field.Value.Initial<Shape> | undefined;
60
+ }) => JSX.Element;
61
+ /**
62
+ * Render all form fields.
63
+ *
64
+ * @param props Component props
65
+ * @example
66
+ *
67
+ * ```tsx
68
+ * <User.Fields />
69
+ * ```
70
+ */
71
+ Fields: ({ values, ...props }?: // partial because name is not required
72
+ Partial<Field.Component.Props<Shape>> & {
73
+ values?: Field.Value.Initial<Shape> | undefined;
74
+ }) => JSX.Element[];
75
+ /**
76
+ * Access bound sub-components for a field.
77
+ *
78
+ * @template N Type of the form field name
79
+ * @param props Field component props
80
+ * @example
81
+ *
82
+ * ```tsx
83
+ * const Radio = User.component({ name: "radio" });
84
+ *
85
+ * <Radio.Label />
86
+ * <Radio.Control />
87
+ * ```
88
+ */
89
+ component: <N extends ShapeUtil.Name<Shape>>({ values, ...props }: {
90
+ name: N;
91
+ } & Field.Component.Props<Shape> & {
92
+ values?: Field.Value.Initial<Shape> | undefined;
93
+ }) => Field.Component<Shape[N]>;
94
+ }
95
+ /**
96
+ * Represents a form field with parsing logic and rendering metadata.
97
+ *
98
+ * @template Output Output type of the field
99
+ * @template Tag Tag name
100
+ * @template Type Input type
101
+ * @template Values Persisted field value type
102
+ * @template Stream If the field should be streamed as a part
103
+ */
104
+ declare class FieldSchema<Output = unknown, Tag extends Field.Tag = "input", Type extends Field.Type = Field.Type, Values extends Field.Options | undefined = undefined, Stream extends boolean | undefined = undefined> extends Schema<Output> {
105
+ #private;
106
+ /** Field type */
107
+ readonly type: Type;
108
+ /** Field tag */
109
+ readonly tag: Tag;
110
+ /** Choices of a select, radio, or checkbox group */
111
+ readonly options: Values;
112
+ /** Maximum expected multipart part count for this field name. */
113
+ readonly parts: number;
114
+ /** If the field should be streamed as a part */
115
+ readonly streaming: Stream | undefined;
116
+ /**
117
+ * Create a new field.
118
+ *
119
+ * @param options Field options
120
+ * @param schema How to validate the input
121
+ * @param read How to read the form data
122
+ * @param parts Maximum expected multipart parts for this field
123
+ * @param stream If this field should be streamed as a multipart part
124
+ * @param persist If this field should persist invalid state values
125
+ */
126
+ constructor(config: Field.Config<Values, Tag>, schema: Schema<Output> | Schema.Def, read?: Field.Read, parts?: number, stream?: Stream, persist?: boolean);
127
+ /**
128
+ * @internal The label people read, which names a terse field such as
129
+ * `dob`, and an unchecked box's default
130
+ * @param io Side of the description
131
+ * @returns Keywords added to the property's JSON Schema
132
+ */
133
+ [annotate](io: "input" | "output"): {
134
+ title?: string;
135
+ description?: string;
136
+ format?: string;
137
+ default?: boolean;
138
+ };
139
+ /**
140
+ * @param field Field instance
141
+ * @param data Form data source
142
+ * @param name HTML name attribute
143
+ * @returns Raw field input
144
+ */
145
+ static read(field: Field.Any, data: FormData | URLSearchParams, name: string): Field.Input;
146
+ /**
147
+ * Stream this field as a multipart request `Part`.
148
+ *
149
+ * @returns Part field
150
+ */
151
+ stream(): Field.Instance<Output, Tag, Type, Values, true>;
152
+ /**
153
+ * Name the field. People read it as the control's label, or a group's
154
+ * legend, and agents as the field's `title`. Without one it is the field's
155
+ * name.
156
+ *
157
+ * ```ts
158
+ * Field.email().label("Email address");
159
+ * ```
160
+ *
161
+ * @param text Label
162
+ * @returns Field with the label
163
+ */
164
+ label(text: string): Field.Instance<Output, Tag, Type, Values, Stream>;
165
+ /**
166
+ * Attributes for the field's control wherever it renders, such as a
167
+ * placeholder. Those for one form are passed when it renders.
168
+ *
169
+ * ```ts
170
+ * Field.email().control({ placeholder: "name@example.com" });
171
+ * ```
172
+ *
173
+ * @param attributes Attributes of the control's element
174
+ * @returns Field with the attributes
175
+ */
176
+ control(attributes: Tag extends "select" ? Field.Props.Select : Tag extends "textarea" ? Field.Props.Textarea : // the field is its type
177
+ Field.Props.Input & {
178
+ readonly type?: never;
179
+ }): Field.Instance<Output, Tag, Type, Values, Stream>;
180
+ /**
181
+ * Take more than one value: files, or options of a select. The value is
182
+ * an array, required to have one unless the field is made optional after.
183
+ *
184
+ * ```ts
185
+ * Field.file().multiple();
186
+ * Field.select(["red", "green", "blue"]).multiple();
187
+ * ```
188
+ *
189
+ * @returns Field whose value is an array
190
+ */
191
+ multiple(this: Field.Instance<File, "input", "file", Values, Stream>): Field.Instance<File[], "input", "file", Values, Stream>;
192
+ multiple<V extends string>(this: Field.Instance<V, "select", Type, readonly [V, ...V[]], Stream>): Field.Instance<V[], "select", Type, readonly [V, ...V[]], Stream>;
193
+ /**
194
+ * Persist this field in the encoded invalid form state.
195
+ *
196
+ * Use this for non-sensitive values that should refill after an invalid
197
+ * redirect.
198
+ *
199
+ * @template U Input type, one that can persist: not a password or file
200
+ * @returns Field that persists submitted values across invalid redirects
201
+ */
202
+ persist<U extends (Tag extends "input" ? Exclude<Type, "password" | "file"> : Type)>(this: Field.Instance<Output, Tag, U, Values, Stream>): Field.Instance<Output, Tag, U, Values, Stream>;
203
+ /**
204
+ * Derive a new Field from the current instance type.
205
+ *
206
+ * @template O Output type of the new Field
207
+ * @param def Definition of the new Field
208
+ * @returns New `Field` instance
209
+ */
210
+ protected derive<O>(def: Schema.Def): Field.Instance<O, Tag, Type, Values, Stream>;
211
+ /**
212
+ * @template S Form shape type
213
+ * @param props Field control props
214
+ * @returns Field component with sub-components
215
+ */
216
+ [component]<S extends Field.Shape>(props: Field.Component.Props<S, false>): Field.Component<this>;
217
+ /**
218
+ * @template S Form shape type
219
+ * @param props Field control props including `name` of the field to render
220
+ * @returns Component that renders the HTML field with default structure
221
+ */
222
+ [render]<S extends Field.Shape>(props: Field.Component.Props<S, false>): JSX.Element;
223
+ /**
224
+ * @param field Field definition
225
+ * @returns `true` when the field persists invalid-state values
226
+ */
227
+ static persisted(field: Field.Any): boolean;
228
+ }
229
+ /**
230
+ * @param value Schema
231
+ * @returns `true` for a form field, such as a table column made with `Field`
232
+ */
233
+ export declare const field: (value: unknown) => value is Field.Any;
234
+ export declare namespace Field {
235
+ /** Fields by name, as a route's `fields` takes them. */
236
+ type Shape = Record<string, Field.Any>;
237
+ /** Persisted form value */
238
+ type Value = string | number | boolean | string[];
239
+ namespace Value {
240
+ /**
241
+ * Value map by field name.
242
+ *
243
+ * @template S Shape type
244
+ */
245
+ type Map<S extends Shape = Shape> = Partial<Record<ShapeUtil.Name<S>, Value>>;
246
+ /**
247
+ * Initial values by field name, for example a record being edited.
248
+ * Values a field cannot render, such as dates and `null`, are skipped.
249
+ *
250
+ * @template S Shape type
251
+ */
252
+ type Initial<S extends Shape = Shape> = {
253
+ readonly [K in ShapeUtil.Name<S>]?: unknown;
254
+ };
255
+ }
256
+ /**
257
+ * Encoded form state.
258
+ *
259
+ * @template S Shape type to infer value keys from
260
+ */
261
+ interface State<S extends Shape = Shape> {
262
+ /** Form id generated using the field names */
263
+ readonly id: string;
264
+ /** Non-empty list of validation issues */
265
+ readonly issues?: Schema.Issue.List;
266
+ /** Map of field names to possible values */
267
+ readonly values?: Value.Map<S>;
268
+ }
269
+ namespace Parse {
270
+ /**
271
+ * Field names that are not marked to stream as multipart parts.
272
+ *
273
+ * @template S Form shape
274
+ */
275
+ type NonStreamNames<S extends Shape> = {
276
+ [K in keyof S]-?: S[K] extends Field.Instance<any, any, any, any, infer P> ? P extends true ? never : K : never;
277
+ }[keyof S];
278
+ /**
279
+ * Parsed data shape with streamed `stream()` fields removed.
280
+ *
281
+ * @template S Form shape
282
+ */
283
+ type NonStreamShape<S extends Shape> = Pick<S, NonStreamNames<S>>;
284
+ /**
285
+ * Parsed form data output.
286
+ *
287
+ * @template S Form shape
288
+ */
289
+ export type Data<S extends Shape> = Schema.Infer<NonStreamShape<S>>;
290
+ /**
291
+ * Form parse result.
292
+ *
293
+ * @template S Form shape
294
+ * @template M Extra invalid result metadata
295
+ */
296
+ export type Result<S extends Shape, M extends object = {}> = Schema.Parse.Result<Data<S>, Result.Invalid<M>, {
297
+ /** Rest of the multipart parts to stream */
298
+ readonly stream?: AsyncGenerator<Multipart.Part> | undefined;
299
+ /**
300
+ * Create an invalid result for issues found after parsing, for
301
+ * example a database constraint, keeping persisted values.
302
+ *
303
+ * @param messages Issue message by field name
304
+ */
305
+ readonly invalid: (messages: Messages<S>) => Schema.Parse.Invalid & Result.Invalid<M>;
306
+ }>;
307
+ /**
308
+ * Issue messages by field name.
309
+ *
310
+ * @template S Form shape
311
+ */
312
+ export type Messages<S extends Shape> = {
313
+ readonly [K in ShapeUtil.Name<S>]?: string;
314
+ };
315
+ export namespace Result {
316
+ /** Form search params iterable */
317
+ type Search = [["_form", string]] | undefined;
318
+ /**
319
+ * Invalid result metadata.
320
+ *
321
+ * @template M Extra invalid result metadata
322
+ */
323
+ type Invalid<M extends object = {}> = {
324
+ /** Encoded URL search param field state */
325
+ readonly search: Search;
326
+ /** Invalid parses do not expose remaining multipart parts */
327
+ readonly stream?: never;
328
+ } & M;
329
+ }
330
+ export {};
331
+ }
332
+ /**
333
+ * Base options to create a Field.
334
+ *
335
+ * @template V Choices of a select, radio, or checkbox group
336
+ * @template T Tag name
337
+ */
338
+ interface Config<V extends Options | undefined = undefined, T extends Tag = Tag> {
339
+ /**
340
+ * Tag name.
341
+ *
342
+ * @default "input"
343
+ */
344
+ readonly tag?: T;
345
+ /** Choices of a select, radio, or checkbox group */
346
+ readonly options?: V;
347
+ /** What people call the field, set with `label()` */
348
+ readonly label?: string;
349
+ /** Field props */
350
+ readonly props?: Props | undefined;
351
+ }
352
+ /**
353
+ * Raw field value before schema parsing.
354
+ *
355
+ * Single-value fields read one entry, multi-value fields read all entries,
356
+ * and checkboxes read presence.
357
+ */
358
+ type Input = FormDataEntryValue | FormDataEntryValue[] | boolean | undefined;
359
+ /**
360
+ * @param data FormData or URLSearchParams
361
+ * @param name HTML name attribute
362
+ * @returns Resolved value read from the form data
363
+ */
364
+ type Read = (data: FormData | URLSearchParams, name: string) => Input;
365
+ /** Form field tag name */
366
+ type Tag = "input" | "textarea" | "select";
367
+ /** `<input type=...>` */
368
+ type Type = JSX.IntrinsicElements["input"]["type"];
369
+ /** Value type for select and radio options */
370
+ type Options = readonly [string, ...string[]];
371
+ /**
372
+ * Field instance type
373
+ *
374
+ * @template Output Parsed value
375
+ * @template Tag Element tag
376
+ * @template Type Input type
377
+ * @template Values Options of a select, radio, or checkbox group
378
+ * @template Stream Whether the field streams as a multipart part
379
+ */
380
+ type Instance<Output = unknown, Tag extends Field.Tag = "input", Type extends Field.Type = Field.Type, Values extends Field.Options | undefined = undefined, Stream extends boolean | undefined = undefined> = FieldSchema<Output, Tag, Type, Values, Stream>;
381
+ /** Any field - `<input type=...>` / `<select>` / `<textarea>` */
382
+ type Any = Instance<any, Tag, Type, Options | undefined, boolean | undefined>;
383
+ /**
384
+ * Obtain the tag name of a field.
385
+ *
386
+ * @template F Field
387
+ */
388
+ type TagOf<F extends Any> = F extends Instance<any, infer T, Field.Type, Field.Options | undefined> ? T : Tag;
389
+ namespace Component {
390
+ /**
391
+ * Component props available to users to pass into the
392
+ * constructed `<Field />` component.
393
+ *
394
+ * @template S Form shape type
395
+ * @template I `true` the state is a `URL`, `false` is just `State`
396
+ */
397
+ type Props<S extends Field.Shape, I extends boolean = true> = {
398
+ /** Field name attribute */
399
+ readonly name: ShapeUtil.Name<S>;
400
+ /** Form state */
401
+ readonly state?: (I extends true ? URL : Field.State<S>) | undefined;
402
+ } & Field.Props;
403
+ /** Root element for the Field component */
404
+ type Root = JSX.IntrinsicElements["div"];
405
+ namespace Root {
406
+ /** Root for input groups */
407
+ type Group = JSX.IntrinsicElements["fieldset"];
408
+ }
409
+ /** `<Field.Legend />` component props */
410
+ type Legend = JSX.IntrinsicElements["legend"];
411
+ /** `<Field.Description />` component props */
412
+ type Description = JSX.IntrinsicElements["p"];
413
+ /** `<Field.Issue />` component props */
414
+ type Issue = JSX.IntrinsicElements["p"];
415
+ /**
416
+ * `<Field.Control />` component props
417
+ *
418
+ * @template T Tag name
419
+ */
420
+ type Control<T extends Tag> = T extends "textarea" ? JSX.IntrinsicElements["textarea"] : T extends "select" ? JSX.IntrinsicElements["select"] : JSX.IntrinsicElements["input"];
421
+ namespace Control {
422
+ /**
423
+ * `<Field.Control />` component props for group input element.
424
+ *
425
+ * @template T Tag name
426
+ * @template V Option values
427
+ */
428
+ type Group<T extends Tag, V extends Options> = Control<T> & {
429
+ readonly value: V[number];
430
+ };
431
+ }
432
+ /** `<Field.Label />` component props */
433
+ type Label = JSX.IntrinsicElements["label"];
434
+ namespace Label {
435
+ /**
436
+ * `<Field.Label />` component props for group input element.
437
+ *
438
+ * @template V Option values
439
+ */
440
+ type Group<V extends Options> = Label & {
441
+ readonly value: V[number];
442
+ };
443
+ }
444
+ /**
445
+ * `<Field.Option />` select component props
446
+ *
447
+ * @template V Options
448
+ */
449
+ type Option<V extends Options> = JSX.IntrinsicElements["option"] & {
450
+ /** Option value */
451
+ readonly value: V[number];
452
+ };
453
+ namespace Option {
454
+ /**
455
+ * `<Field.Option />` input group component props
456
+ *
457
+ * Wrapper for both the `<Label />` and `<Input />` components.
458
+ *
459
+ * @template V Options
460
+ */
461
+ type Input<V extends Options> = JSX.IntrinsicElements["div"] & {
462
+ /** Option value */
463
+ readonly value: V[number];
464
+ };
465
+ }
466
+ }
467
+ /**
468
+ * Base Field component object that contains sub-components,
469
+ * use for fine grained rendering control.
470
+ *
471
+ * @template F Field
472
+ */
473
+ type Component<F extends Any> = Readonly<{
474
+ /**
475
+ * @param props Description props
476
+ * @returns Description paragraph, nothing when the field has no description
477
+ */
478
+ Description: (props?: Component.Description) => JSX.Element;
479
+ /**
480
+ * @param props Issue props
481
+ * @returns Issue container paragraph
482
+ */
483
+ Issue: (props?: Component.Issue) => JSX.Element;
484
+ } & (F extends Instance<any, "select", Field.Type, infer V> ? V extends Options ? {
485
+ /** The select's options */
486
+ options: V;
487
+ /**
488
+ * @param props Root props
489
+ * @returns Root container div
490
+ */
491
+ Root: (props?: Component.Root) => JSX.Element;
492
+ /**
493
+ * @param props Label props
494
+ * @returns Label element
495
+ */
496
+ Label: (props?: Component.Label) => JSX.Element;
497
+ /**
498
+ * @param props Control props
499
+ * @returns Control select element
500
+ */
501
+ Control: (props?: Component.Control<"select">) => JSX.Element;
502
+ /**
503
+ * @param props Option props
504
+ * @returns Select option element
505
+ */
506
+ Option: (props: Component.Option<V>) => JSX.Element;
507
+ } : never : F extends Instance<any, "input", Field.Type, infer V> ? V extends Options ? {
508
+ /** The group's options */
509
+ options: V;
510
+ /**
511
+ * @param props Root props
512
+ * @returns Root container fieldset
513
+ */
514
+ Root: (props?: Component.Root.Group) => JSX.Element;
515
+ /**
516
+ * @param props Legend element props
517
+ * @returns Legend element
518
+ */
519
+ Legend: (props?: Component.Legend) => JSX.Element;
520
+ /**
521
+ * @param props Label props including `value`
522
+ * @returns Label element
523
+ */
524
+ Label: (props: Component.Label.Group<V>) => JSX.Element;
525
+ /**
526
+ * @param props Control props
527
+ * @returns Control input element
528
+ */
529
+ Control: (props?: Component.Control.Group<"input", V>) => JSX.Element;
530
+ /**
531
+ * @param props Option props
532
+ * @returns Both label and input elements together
533
+ */
534
+ Option: (props: Component.Option.Input<V>) => JSX.Element;
535
+ } : {
536
+ /**
537
+ * @param props Root props
538
+ * @returns Root container div
539
+ */
540
+ Root: (props?: Component.Root) => JSX.Element;
541
+ /**
542
+ * @param props Label props
543
+ * @returns Label element
544
+ */
545
+ Label: (props?: Component.Label) => JSX.Element;
546
+ /**
547
+ * @param props Control props
548
+ * @returns Control input element
549
+ */
550
+ Control: (props?: Component.Control<"input">) => JSX.Element;
551
+ } : {
552
+ /**
553
+ * @param props Root props
554
+ * @returns Root container div
555
+ */
556
+ Root: (props?: Component.Root) => JSX.Element;
557
+ /**
558
+ * @param props Label props
559
+ * @returns Label element
560
+ */
561
+ Label: (props?: Component.Label) => JSX.Element;
562
+ /**
563
+ * @param props Control props
564
+ * @returns Control textarea element
565
+ */
566
+ Control: (props?: Component.Control<"textarea">) => JSX.Element;
567
+ })>;
568
+ /** Any field props */
569
+ type Props = Props.Input | Props.Select | Props.Textarea;
570
+ namespace Props {
571
+ /**
572
+ * A field's label and description are what it means, for people and
573
+ * agents, and not attributes of its control: set them with `label()` and
574
+ * `describe()`, and the control's attributes with `control()`.
575
+ */
576
+ interface Chained {
577
+ /** Use `field.label(text)` */
578
+ readonly label?: never;
579
+ /** Use `field.describe(text)` */
580
+ readonly description?: never;
581
+ }
582
+ /** Attributes of an `<input>` field's control */
583
+ export type Input = JSX.IntrinsicElements["input"] & Chained;
584
+ /** Attributes of a `<select>` field's control */
585
+ export type Select = JSX.IntrinsicElements["select"] & Chained;
586
+ /** Attributes of a `<textarea>` field's control */
587
+ export type Textarea = JSX.IntrinsicElements["textarea"] & Chained;
588
+ export {};
589
+ }
590
+ }
591
+ /** Field factory functions */
592
+ export declare class Field {
593
+ #private;
594
+ /**
595
+ * @returns Text input field
596
+ */
597
+ static text(): Field.Instance<string, "input", "text">;
598
+ /**
599
+ * @returns Password input field
600
+ */
601
+ static password(): Field.Instance<string, "input", "password">;
602
+ /**
603
+ * @returns Search input field
604
+ */
605
+ static search(): Field.Instance<string, "input", "search">;
606
+ /**
607
+ * @returns Telephone input field
608
+ */
609
+ static tel(): Field.Instance<string, "input", "tel">;
610
+ /**
611
+ * @returns Color input field
612
+ */
613
+ static color(): Field.Instance<string, "input", "color">;
614
+ /**
615
+ * @returns Hidden input field
616
+ */
617
+ static hidden(): Field.Instance<string, "input", "hidden">;
618
+ /**
619
+ * @returns Date input field
620
+ */
621
+ static date(): Field.Instance<string, "input", "date">;
622
+ /**
623
+ * @returns Datetime input field
624
+ */
625
+ static datetime(): Field.Instance<string, "input", "datetime-local">;
626
+ /**
627
+ * @returns Month input field
628
+ */
629
+ static month(): Field.Instance<string, "input", "month">;
630
+ /**
631
+ * @returns Week input field
632
+ */
633
+ static week(): Field.Instance<string, "input", "week">;
634
+ /**
635
+ * @returns Time input field
636
+ */
637
+ static time(): Field.Instance<string, "input", "time">;
638
+ /**
639
+ * Validates email string.
640
+ *
641
+ * @param message Issue message when invalid
642
+ * @returns Email input field
643
+ */
644
+ static email(message?: string): Field.Instance<string, "input", "email">;
645
+ /**
646
+ * Validates parsable URL.
647
+ *
648
+ * @param message Issue message when invalid
649
+ * @returns URL input field
650
+ */
651
+ static url(message?: string): Field.Instance<string, "input", "url">;
652
+ /**
653
+ * Coerces to number.
654
+ *
655
+ * @returns Number input field
656
+ */
657
+ static number(): Field.Instance<number, "input", "number">;
658
+ /**
659
+ * Coerces to number.
660
+ *
661
+ * @returns Range input field
662
+ */
663
+ static range(): Field.Instance<number, "input", "range">;
664
+ /**
665
+ * - unchecked => key missing => `false`
666
+ * - checked => key present => `true`
667
+ *
668
+ * @returns Checkbox input field
669
+ */
670
+ static checkbox(): Field.Instance<boolean, "input", "checkbox">;
671
+ /**
672
+ * @returns File input field
673
+ */
674
+ static file(): Field.Instance<File, "input", "file">;
675
+ /**
676
+ * @template V Value type
677
+ * @param options Checkbox options
678
+ * @returns Checkbox group input field
679
+ */
680
+ static checkboxes<const V extends string>(options: readonly [V, ...V[]]): Field.Instance<V[], "input", "checkbox", readonly [V, ...V[]]>;
681
+ /**
682
+ * @template V Value type
683
+ * @param options Radio button options
684
+ * @returns Radio group input field
685
+ */
686
+ static radio<const V extends string>(options: readonly [V, ...V[]]): Field.Instance<V, "input", "radio", readonly [V, ...V[]]>;
687
+ /**
688
+ * @returns Textarea field
689
+ */
690
+ static textarea(): Field.Instance<string, "textarea">;
691
+ /**
692
+ * @template V Value type
693
+ * @param options Select options
694
+ * @returns Select field
695
+ */
696
+ static select<const V extends string>(options: readonly [V, ...V[]]): Field.Instance<V, "select", Field.Type, readonly [V, ...V[]]>;
697
+ }
698
+ export {};
699
+ //# sourceMappingURL=index.d.ts.map