@fungi.computer/caps 0.0.0-stage → 0.0.1
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/LICENSE +21 -0
- package/README.md +1125 -2
- package/dist/blocks/app-bar.d.ts +43 -0
- package/dist/blocks/app-bar.js +244 -0
- package/dist/blocks/app-status-bar.d.ts +93 -0
- package/dist/blocks/app-status-bar.js +42 -0
- package/dist/blocks/async-state.d.ts +21 -0
- package/dist/blocks/async-state.js +8 -0
- package/dist/blocks/card-grid.d.ts +11 -0
- package/dist/blocks/card-grid.js +21 -0
- package/dist/blocks/command-menu.d.ts +26 -0
- package/dist/blocks/command-menu.js +70 -0
- package/dist/blocks/composer.d.ts +23 -0
- package/dist/blocks/composer.js +13 -0
- package/dist/blocks/empty-state.d.ts +59 -0
- package/dist/blocks/empty-state.js +35 -0
- package/dist/blocks/faq-chat.d.ts +62 -0
- package/dist/blocks/faq-chat.js +77 -0
- package/dist/blocks/game-share-card.d.ts +17 -0
- package/dist/blocks/game-share-card.js +9 -0
- package/dist/blocks/launcher-grid.d.ts +50 -0
- package/dist/blocks/launcher-grid.js +11 -0
- package/dist/blocks/listing-detail.d.ts +23 -0
- package/dist/blocks/listing-detail.js +12 -0
- package/dist/blocks/loading-state.d.ts +5 -0
- package/dist/blocks/loading-state.js +8 -0
- package/dist/blocks/mosaic.d.ts +29 -0
- package/dist/blocks/mosaic.js +19 -0
- package/dist/blocks/permission-grid.d.ts +45 -0
- package/dist/blocks/permission-grid.js +14 -0
- package/dist/blocks/pricing-card.d.ts +53 -0
- package/dist/blocks/pricing-card.js +12 -0
- package/dist/blocks/release-tag.d.ts +20 -0
- package/dist/blocks/release-tag.js +10 -0
- package/dist/blocks/resource-select.d.ts +22 -0
- package/dist/blocks/resource-select.js +16 -0
- package/dist/blocks/result-state.d.ts +15 -0
- package/dist/blocks/result-state.js +8 -0
- package/dist/blocks/section-card.d.ts +31 -0
- package/dist/blocks/section-card.js +7 -0
- package/dist/blocks/section-heading.d.ts +13 -0
- package/dist/blocks/section-heading.js +11 -0
- package/dist/blocks/spec-sheet.d.ts +125 -0
- package/dist/blocks/spec-sheet.js +47 -0
- package/dist/blocks/status-tray.d.ts +83 -0
- package/dist/blocks/status-tray.js +79 -0
- package/dist/blocks/upload-queue.d.ts +48 -0
- package/dist/blocks/upload-queue.js +24 -0
- package/dist/components/action-row.d.ts +16 -0
- package/dist/components/action-row.js +11 -0
- package/dist/components/activity-line.d.ts +33 -0
- package/dist/components/activity-line.js +69 -0
- package/dist/components/alert.d.ts +17 -0
- package/dist/components/alert.js +17 -0
- package/dist/components/badge.d.ts +19 -0
- package/dist/components/badge.js +24 -0
- package/dist/components/button.d.ts +55 -0
- package/dist/components/button.js +230 -0
- package/dist/components/card.d.ts +61 -0
- package/dist/components/card.js +48 -0
- package/dist/components/chat-bubble.d.ts +34 -0
- package/dist/components/chat-bubble.js +10 -0
- package/dist/components/checkbox-bead.d.ts +6 -0
- package/dist/components/checkbox-bead.js +67 -0
- package/dist/components/checkbox.d.ts +21 -0
- package/dist/components/checkbox.js +46 -0
- package/dist/components/code-input.d.ts +35 -0
- package/dist/components/code-input.js +126 -0
- package/dist/components/combobox.d.ts +86 -0
- package/dist/components/combobox.js +218 -0
- package/dist/components/confirm-action.d.ts +23 -0
- package/dist/components/confirm-action.js +64 -0
- package/dist/components/copy-field.d.ts +53 -0
- package/dist/components/copy-field.js +49 -0
- package/dist/components/count-badge.d.ts +15 -0
- package/dist/components/count-badge.js +9 -0
- package/dist/components/cover-pattern.d.ts +19 -0
- package/dist/components/cover-pattern.js +74 -0
- package/dist/components/data-list.d.ts +25 -0
- package/dist/components/data-list.js +16 -0
- package/dist/components/dialog.d.ts +39 -0
- package/dist/components/dialog.js +73 -0
- package/dist/components/diff-view.d.ts +14 -0
- package/dist/components/diff-view.js +13 -0
- package/dist/components/disclosure.d.ts +29 -0
- package/dist/components/disclosure.js +19 -0
- package/dist/components/dropdown-menu.d.ts +49 -0
- package/dist/components/dropdown-menu.js +98 -0
- package/dist/components/field-guide.d.ts +41 -0
- package/dist/components/field-guide.js +18 -0
- package/dist/components/field.d.ts +164 -0
- package/dist/components/field.js +228 -0
- package/dist/components/game-feedback.d.ts +84 -0
- package/dist/components/game-feedback.js +48 -0
- package/dist/components/game-hud.d.ts +126 -0
- package/dist/components/game-hud.js +136 -0
- package/dist/components/generation-frame.d.ts +36 -0
- package/dist/components/generation-frame.js +97 -0
- package/dist/components/gooey.d.ts +32 -0
- package/dist/components/gooey.js +25 -0
- package/dist/components/hold-button.d.ts +26 -0
- package/dist/components/hold-button.js +115 -0
- package/dist/components/icon-button.d.ts +24 -0
- package/dist/components/icon-button.js +18 -0
- package/dist/components/icon-checkbox.d.ts +20 -0
- package/dist/components/icon-checkbox.js +9 -0
- package/dist/components/icon-choice-mark.d.ts +6 -0
- package/dist/components/icon-choice-mark.js +5 -0
- package/dist/components/icon-lamp.d.ts +42 -0
- package/dist/components/icon-lamp.js +15 -0
- package/dist/components/icon-radio.d.ts +16 -0
- package/dist/components/icon-radio.js +9 -0
- package/dist/components/inline-code.d.ts +3 -0
- package/dist/components/inline-code.js +7 -0
- package/dist/components/input-group.d.ts +9 -0
- package/dist/components/input-group.js +15 -0
- package/dist/components/input.d.ts +15 -0
- package/dist/components/input.js +15 -0
- package/dist/components/item-grid.d.ts +110 -0
- package/dist/components/item-grid.js +136 -0
- package/dist/components/keycap.d.ts +80 -0
- package/dist/components/keycap.js +18 -0
- package/dist/components/label.d.ts +13 -0
- package/dist/components/label.js +7 -0
- package/dist/components/listbox.d.ts +50 -0
- package/dist/components/listbox.js +134 -0
- package/dist/components/loader-blobs.d.ts +5 -0
- package/dist/components/loader-blobs.js +128 -0
- package/dist/components/loader.d.ts +21 -0
- package/dist/components/loader.js +25 -0
- package/dist/components/markdown.d.ts +23 -0
- package/dist/components/markdown.js +70 -0
- package/dist/components/minimap-labels.d.ts +39 -0
- package/dist/components/minimap-labels.js +113 -0
- package/dist/components/monogram.d.ts +32 -0
- package/dist/components/monogram.js +24 -0
- package/dist/components/motion-visibility.d.ts +2 -0
- package/dist/components/motion-visibility.js +25 -0
- package/dist/components/navigation-rail.d.ts +11 -0
- package/dist/components/navigation-rail.js +55 -0
- package/dist/components/overlay-root.d.ts +16 -0
- package/dist/components/overlay-root.js +24 -0
- package/dist/components/pixel-number.d.ts +50 -0
- package/dist/components/pixel-number.js +113 -0
- package/dist/components/popover.d.ts +31 -0
- package/dist/components/popover.js +24 -0
- package/dist/components/presence.d.ts +59 -0
- package/dist/components/presence.js +232 -0
- package/dist/components/price-tag.d.ts +11 -0
- package/dist/components/price-tag.js +6 -0
- package/dist/components/progress.d.ts +25 -0
- package/dist/components/progress.js +24 -0
- package/dist/components/prose.d.ts +14 -0
- package/dist/components/prose.js +10 -0
- package/dist/components/quota-meter.d.ts +24 -0
- package/dist/components/quota-meter.js +11 -0
- package/dist/components/radio-bead.d.ts +4 -0
- package/dist/components/radio-bead.js +53 -0
- package/dist/components/radio-group.d.ts +54 -0
- package/dist/components/radio-group.js +64 -0
- package/dist/components/resize-handle.d.ts +23 -0
- package/dist/components/resize-handle.js +31 -0
- package/dist/components/rough-drawing.d.ts +42 -0
- package/dist/components/rough-drawing.js +231 -0
- package/dist/components/rough.d.ts +68 -0
- package/dist/components/rough.js +33 -0
- package/dist/components/scroll-area.d.ts +12 -0
- package/dist/components/scroll-area.js +96 -0
- package/dist/components/scroll-motion.d.ts +12 -0
- package/dist/components/scroll-motion.js +31 -0
- package/dist/components/scroll-to-bottom-blob-state.d.ts +40 -0
- package/dist/components/scroll-to-bottom-blob-state.js +109 -0
- package/dist/components/scroll-to-bottom-blob.d.ts +16 -0
- package/dist/components/scroll-to-bottom-blob.js +174 -0
- package/dist/components/select.d.ts +9 -0
- package/dist/components/select.js +12 -0
- package/dist/components/selectable.d.ts +13 -0
- package/dist/components/selectable.js +45 -0
- package/dist/components/send-action.d.ts +33 -0
- package/dist/components/send-action.js +96 -0
- package/dist/components/separator.d.ts +11 -0
- package/dist/components/separator.js +7 -0
- package/dist/components/skeleton.d.ts +5 -0
- package/dist/components/skeleton.js +7 -0
- package/dist/components/slider.d.ts +18 -0
- package/dist/components/slider.js +31 -0
- package/dist/components/stat.d.ts +17 -0
- package/dist/components/stat.js +7 -0
- package/dist/components/status-bead.d.ts +9 -0
- package/dist/components/status-bead.js +107 -0
- package/dist/components/status-mark.d.ts +12 -0
- package/dist/components/status-mark.js +177 -0
- package/dist/components/status.d.ts +38 -0
- package/dist/components/status.js +28 -0
- package/dist/components/store-card.d.ts +21 -0
- package/dist/components/store-card.js +10 -0
- package/dist/components/surface.d.ts +89 -0
- package/dist/components/surface.js +31 -0
- package/dist/components/switch-bead.d.ts +4 -0
- package/dist/components/switch-bead.js +62 -0
- package/dist/components/switch.d.ts +11 -0
- package/dist/components/switch.js +36 -0
- package/dist/components/tabs.d.ts +55 -0
- package/dist/components/tabs.js +81 -0
- package/dist/components/technonomicon.d.ts +192 -0
- package/dist/components/technonomicon.js +121 -0
- package/dist/components/textarea.d.ts +9 -0
- package/dist/components/textarea.js +11 -0
- package/dist/components/toaster.d.ts +4 -0
- package/dist/components/toaster.js +13 -0
- package/dist/components/tool-call-chip.d.ts +22 -0
- package/dist/components/tool-call-chip.js +100 -0
- package/dist/components/tooltip.d.ts +41 -0
- package/dist/components/tooltip.js +169 -0
- package/dist/components/trading-card.d.ts +60 -0
- package/dist/components/trading-card.js +13 -0
- package/dist/components/undo-action.d.ts +52 -0
- package/dist/components/undo-action.js +100 -0
- package/dist/components/undo-toast.d.ts +21 -0
- package/dist/components/undo-toast.js +58 -0
- package/dist/components/visually-hidden.d.ts +9 -0
- package/dist/components/visually-hidden.js +11 -0
- package/dist/components/window.d.ts +65 -0
- package/dist/components/window.js +31 -0
- package/dist/components/wizard.d.ts +17 -0
- package/dist/components/wizard.js +19 -0
- package/dist/enhance/cigarette-card.d.ts +8 -0
- package/dist/enhance/cigarette-card.js +33 -0
- package/dist/enhance/sketch.d.ts +16 -0
- package/dist/enhance/sketch.js +130 -0
- package/dist/form-error.d.ts +7 -0
- package/dist/form-error.js +14 -0
- package/dist/form-fields.d.ts +15 -0
- package/dist/form-fields.js +250 -0
- package/dist/form-schema.d.ts +166 -0
- package/dist/form-schema.js +398 -0
- package/dist/form.d.ts +30 -0
- package/dist/form.js +20 -0
- package/dist/lib/cn.d.ts +8 -0
- package/dist/lib/cn.js +12 -0
- package/dist/lib/format-money.d.ts +2 -0
- package/dist/lib/format-money.js +22 -0
- package/dist/lib/glide.d.ts +12 -0
- package/dist/lib/glide.js +143 -0
- package/dist/lib/ime.d.ts +3 -0
- package/dist/lib/ime.js +8 -0
- package/dist/lib/motion-spring.d.ts +27 -0
- package/dist/lib/motion-spring.js +36 -0
- package/dist/lib/motion.d.ts +51 -0
- package/dist/lib/motion.js +161 -0
- package/dist/lib/reorder-motion.d.ts +13 -0
- package/dist/lib/reorder-motion.js +201 -0
- package/dist/lib/seed-hash.d.ts +6 -0
- package/dist/lib/seed-hash.js +13 -0
- package/dist/lib/tanstack-highlight.d.ts +4 -0
- package/dist/lib/tanstack-highlight.js +41 -0
- package/dist/schema-form.d.ts +120 -0
- package/dist/schema-form.js +129 -0
- package/dist/styles.css +18814 -0
- package/docs/api/README.md +134 -0
- package/docs/api/blocks/app-bar.md +227 -0
- package/docs/api/blocks/app-status-bar.md +257 -0
- package/docs/api/blocks/async-state.md +53 -0
- package/docs/api/blocks/card-grid.md +31 -0
- package/docs/api/blocks/command-menu.md +89 -0
- package/docs/api/blocks/composer.md +40 -0
- package/docs/api/blocks/empty-state.md +97 -0
- package/docs/api/blocks/faq-chat.md +147 -0
- package/docs/api/blocks/game-share-card.md +40 -0
- package/docs/api/blocks/launcher-grid.md +86 -0
- package/docs/api/blocks/listing-detail.md +51 -0
- package/docs/api/blocks/loading-state.md +21 -0
- package/docs/api/blocks/mosaic.md +94 -0
- package/docs/api/blocks/permission-grid.md +79 -0
- package/docs/api/blocks/pricing-card.md +90 -0
- package/docs/api/blocks/release-tag.md +62 -0
- package/docs/api/blocks/resource-select.md +126 -0
- package/docs/api/blocks/result-state.md +42 -0
- package/docs/api/blocks/section-card.md +42 -0
- package/docs/api/blocks/section-heading.md +61 -0
- package/docs/api/blocks/spec-sheet.md +400 -0
- package/docs/api/blocks/status-tray.md +141 -0
- package/docs/api/blocks/upload-queue.md +110 -0
- package/docs/api/components/action-row.md +51 -0
- package/docs/api/components/activity-line.md +103 -0
- package/docs/api/components/alert.md +60 -0
- package/docs/api/components/badge.md +77 -0
- package/docs/api/components/button.md +94 -0
- package/docs/api/components/card.md +165 -0
- package/docs/api/components/chat-bubble.md +66 -0
- package/docs/api/components/checkbox-bead.md +20 -0
- package/docs/api/components/checkbox.md +42 -0
- package/docs/api/components/code-input.md +61 -0
- package/docs/api/components/combobox.md +303 -0
- package/docs/api/components/confirm-action.md +58 -0
- package/docs/api/components/copy-field.md +106 -0
- package/docs/api/components/count-badge.md +39 -0
- package/docs/api/components/cover-pattern.md +43 -0
- package/docs/api/components/data-list.md +80 -0
- package/docs/api/components/dialog.md +235 -0
- package/docs/api/components/diff-view.md +59 -0
- package/docs/api/components/disclosure.md +71 -0
- package/docs/api/components/dropdown-menu.md +269 -0
- package/docs/api/components/field-guide.md +174 -0
- package/docs/api/components/field.md +252 -0
- package/docs/api/components/game-feedback.md +157 -0
- package/docs/api/components/game-hud.md +359 -0
- package/docs/api/components/generation-frame.md +59 -0
- package/docs/api/components/hold-button.md +44 -0
- package/docs/api/components/icon-button.md +56 -0
- package/docs/api/components/icon-checkbox.md +42 -0
- package/docs/api/components/icon-choice-mark.md +31 -0
- package/docs/api/components/icon-lamp.md +92 -0
- package/docs/api/components/icon-radio.md +42 -0
- package/docs/api/components/inline-code.md +21 -0
- package/docs/api/components/input-group.md +53 -0
- package/docs/api/components/input.md +54 -0
- package/docs/api/components/item-grid.md +262 -0
- package/docs/api/components/keycap.md +102 -0
- package/docs/api/components/label.md +40 -0
- package/docs/api/components/listbox.md +131 -0
- package/docs/api/components/loader-blobs.md +9 -0
- package/docs/api/components/loader.md +51 -0
- package/docs/api/components/markdown.md +91 -0
- package/docs/api/components/minimap-labels.md +84 -0
- package/docs/api/components/monogram.md +96 -0
- package/docs/api/components/motion-visibility.md +9 -0
- package/docs/api/components/navigation-rail.md +37 -0
- package/docs/api/components/overlay-root.md +92 -0
- package/docs/api/components/pixel-number.md +120 -0
- package/docs/api/components/popover.md +80 -0
- package/docs/api/components/presence.md +106 -0
- package/docs/api/components/price-tag.md +48 -0
- package/docs/api/components/progress.md +90 -0
- package/docs/api/components/prose.md +48 -0
- package/docs/api/components/quota-meter.md +47 -0
- package/docs/api/components/radio-bead.md +9 -0
- package/docs/api/components/radio-group.md +126 -0
- package/docs/api/components/resize-handle.md +46 -0
- package/docs/api/components/rough-drawing.md +122 -0
- package/docs/api/components/rough.md +66 -0
- package/docs/api/components/scroll-area.md +22 -0
- package/docs/api/components/scroll-motion.md +9 -0
- package/docs/api/components/scroll-to-bottom-blob-state.md +162 -0
- package/docs/api/components/scroll-to-bottom-blob.md +73 -0
- package/docs/api/components/select.md +39 -0
- package/docs/api/components/send-action.md +58 -0
- package/docs/api/components/separator.md +38 -0
- package/docs/api/components/skeleton.md +31 -0
- package/docs/api/components/slider.md +70 -0
- package/docs/api/components/stat.md +42 -0
- package/docs/api/components/status-bead.md +19 -0
- package/docs/api/components/status-mark.md +19 -0
- package/docs/api/components/status.md +105 -0
- package/docs/api/components/store-card.md +53 -0
- package/docs/api/components/surface.md +161 -0
- package/docs/api/components/switch-bead.md +9 -0
- package/docs/api/components/switch.md +40 -0
- package/docs/api/components/tabs.md +138 -0
- package/docs/api/components/technonomicon.md +773 -0
- package/docs/api/components/textarea.md +40 -0
- package/docs/api/components/toaster.md +29 -0
- package/docs/api/components/tool-call-chip.md +68 -0
- package/docs/api/components/tooltip.md +113 -0
- package/docs/api/components/trading-card.md +95 -0
- package/docs/api/components/undo-action.md +117 -0
- package/docs/api/components/undo-toast.md +49 -0
- package/docs/api/components/visually-hidden.md +37 -0
- package/docs/api/components/window.md +291 -0
- package/docs/api/components/wizard.md +65 -0
- package/docs/api/enhance/cigarette-card.md +52 -0
- package/docs/api/enhance/sketch.md +42 -0
- package/docs/api/form.md +1623 -0
- package/docs/api/lib/cn.md +46 -0
- package/docs/api/lib/format-money.md +30 -0
- package/docs/api/lib/glide.md +36 -0
- package/docs/api/lib/ime.md +29 -0
- package/docs/api/lib/motion-spring.md +91 -0
- package/docs/api/lib/motion.md +212 -0
- package/docs/api/lib/reorder-motion.md +46 -0
- package/docs/api/lib/seed-hash.md +31 -0
- package/docs/api/lib/tanstack-highlight.md +40 -0
- package/package.json +597 -3
- package/src/app-status-bar.css +158 -0
- package/src/fonts.css +1 -0
- package/src/status-tray.css +282 -0
- package/src/styles.css +10177 -0
package/docs/api/form.md
ADDED
|
@@ -0,0 +1,1623 @@
|
|
|
1
|
+
<!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
|
|
2
|
+
|
|
3
|
+
[**@fungi.computer/caps**](README.md)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
[@fungi.computer/caps](README.md) / form
|
|
8
|
+
|
|
9
|
+
# form
|
|
10
|
+
|
|
11
|
+
## converting
|
|
12
|
+
|
|
13
|
+
### effectValidator
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
const effectValidator: <S>(
|
|
17
|
+
self,
|
|
18
|
+
options?,
|
|
19
|
+
) => StandardSchemaV1<S["Encoded"], S["Type"]> & S = Schema.toStandardSchemaV1;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Effect's maintained Standard Schema adapter, including nested issue paths.
|
|
23
|
+
|
|
24
|
+
Returns a "Standard Schema" object conforming to the
|
|
25
|
+
[Standard Schema v1](https://standardschema.dev/) specification.
|
|
26
|
+
|
|
27
|
+
**Details**
|
|
28
|
+
|
|
29
|
+
This function creates a schema whose `validate` method attempts to decode and
|
|
30
|
+
validate the provided input synchronously. If the underlying `Schema` includes
|
|
31
|
+
any asynchronous components (e.g., asynchronous message resolutions or checks),
|
|
32
|
+
then validation will necessarily return a `Promise` instead.
|
|
33
|
+
|
|
34
|
+
**Example** (Creating a standard schema from a regular schema)
|
|
35
|
+
|
|
36
|
+
```ts import.meta.vitest
|
|
37
|
+
import { Schema } from "effect";
|
|
38
|
+
|
|
39
|
+
// Define custom hook functions for error formatting
|
|
40
|
+
const leafHook = (issue: any) => {
|
|
41
|
+
switch (issue._tag) {
|
|
42
|
+
case "InvalidType":
|
|
43
|
+
return "Expected different type";
|
|
44
|
+
case "InvalidValue":
|
|
45
|
+
return "Invalid value provided";
|
|
46
|
+
case "MissingKey":
|
|
47
|
+
return "Required property missing";
|
|
48
|
+
case "UnexpectedKey":
|
|
49
|
+
return "Unexpected property found";
|
|
50
|
+
case "Forbidden":
|
|
51
|
+
return "Operation not allowed";
|
|
52
|
+
case "OneOf":
|
|
53
|
+
return "Multiple valid options available";
|
|
54
|
+
default:
|
|
55
|
+
return "Validation error";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Create a standard schema from a regular schema
|
|
60
|
+
const PersonSchema = Schema.Struct({
|
|
61
|
+
name: Schema.NonEmptyString,
|
|
62
|
+
age: Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 150 })),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const standardSchema = Schema.toStandardSchemaV1(PersonSchema, {
|
|
66
|
+
leafHook,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// The standard schema can be used with any Standard Schema v1 compatible library
|
|
70
|
+
const validResult = standardSchema["~standard"].validate({
|
|
71
|
+
name: "Alice",
|
|
72
|
+
age: 30,
|
|
73
|
+
});
|
|
74
|
+
const invalidResult = standardSchema["~standard"].validate({
|
|
75
|
+
name: "",
|
|
76
|
+
age: 200,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (validResult instanceof Promise || invalidResult instanceof Promise) {
|
|
80
|
+
throw new Error("Expected synchronous validation");
|
|
81
|
+
}
|
|
82
|
+
if ("value" in validResult) {
|
|
83
|
+
validResult.value; // => { name: "Alice", age: 30 }
|
|
84
|
+
}
|
|
85
|
+
invalidResult.issues?.map((issue) => issue.path); // => [["name"], ["age"]]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Type Parameters
|
|
89
|
+
|
|
90
|
+
| Type Parameter |
|
|
91
|
+
| ------------------------------------------------------- |
|
|
92
|
+
| `S` _extends_ `ConstraintDecoder`\<`unknown`, `never`\> |
|
|
93
|
+
|
|
94
|
+
#### Parameters
|
|
95
|
+
|
|
96
|
+
| Parameter | Type |
|
|
97
|
+
| ---------- | ----- |
|
|
98
|
+
| `self` | `S` |
|
|
99
|
+
| `options?` | \{ \} |
|
|
100
|
+
|
|
101
|
+
#### Returns
|
|
102
|
+
|
|
103
|
+
`StandardSchemaV1`\<`S`\[`"Encoded"`\], `S`\[`"Type"`\]\> & `S`
|
|
104
|
+
|
|
105
|
+
#### Stability
|
|
106
|
+
|
|
107
|
+
stable
|
|
108
|
+
|
|
109
|
+
#### Since
|
|
110
|
+
|
|
111
|
+
4.0.0
|
|
112
|
+
|
|
113
|
+
## Other
|
|
114
|
+
|
|
115
|
+
### fieldError()
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
function fieldError(meta): string | undefined;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
First readable TanStack string error or Standard Schema issue.
|
|
122
|
+
|
|
123
|
+
#### Parameters
|
|
124
|
+
|
|
125
|
+
| Parameter | Type |
|
|
126
|
+
| ------------- | ------------------------------------- |
|
|
127
|
+
| `meta` | \{ `errors`: readonly `unknown`[]; \} |
|
|
128
|
+
| `meta.errors` | readonly `unknown`[] |
|
|
129
|
+
|
|
130
|
+
#### Returns
|
|
131
|
+
|
|
132
|
+
`string` \| `undefined`
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
### FormFieldsProps
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
type FormFieldsProps<V> = object;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Props accepted by FormFields.
|
|
143
|
+
|
|
144
|
+
#### Type Parameters
|
|
145
|
+
|
|
146
|
+
| Type Parameter |
|
|
147
|
+
| ----------------------------------------- |
|
|
148
|
+
| `V` _extends_ [`FormValues`](#formvalues) |
|
|
149
|
+
|
|
150
|
+
#### Properties
|
|
151
|
+
|
|
152
|
+
##### model
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
model: SchemaFormModel<V>;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
##### names?
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
optional names?: readonly keyof V & string[];
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Render only these fields, in this order, without section headings.
|
|
165
|
+
|
|
166
|
+
##### disabled?
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
optional disabled?: boolean;
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Disable every field, such as while an uncertain request is retried.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
### FormFields()
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
function FormFields<V>(__namedParameters): (Element | null)[];
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Render a schema form's fields from its schema: every section in order, or only
|
|
183
|
+
`names` (for placing fields in Screen cells or custom layouts).
|
|
184
|
+
|
|
185
|
+
#### Type Parameters
|
|
186
|
+
|
|
187
|
+
| Type Parameter |
|
|
188
|
+
| ----------------------------------------------------------------------------- |
|
|
189
|
+
| `V` _extends_ `Readonly`\<`Record`\<`string`, [`FieldInput`](#fieldinput)\>\> |
|
|
190
|
+
|
|
191
|
+
#### Parameters
|
|
192
|
+
|
|
193
|
+
| Parameter | Type |
|
|
194
|
+
| ------------------- | -------------------------------------------- |
|
|
195
|
+
| `__namedParameters` | [`FormFieldsProps`](#formfieldsprops)\<`V`\> |
|
|
196
|
+
|
|
197
|
+
#### Returns
|
|
198
|
+
|
|
199
|
+
(`Element` \| `null`)[]
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### FieldInput
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
type FieldInput =
|
|
207
|
+
| string
|
|
208
|
+
| number
|
|
209
|
+
| boolean
|
|
210
|
+
| null
|
|
211
|
+
| undefined
|
|
212
|
+
| readonly string[]
|
|
213
|
+
| readonly File[];
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
The raw input one field holds: text, a number (or empty), a flag, or a set of
|
|
217
|
+
chosen values or files. The schema turns it into the domain value at submit.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
### FormValues
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
type FormValues = Readonly<Record<string, FieldInput>>;
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
The raw values a schema form holds: one entry per field name.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### FieldKind
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
type FieldKind =
|
|
235
|
+
| "text"
|
|
236
|
+
| "email"
|
|
237
|
+
| "url"
|
|
238
|
+
| "tel"
|
|
239
|
+
| "textarea"
|
|
240
|
+
| "secret"
|
|
241
|
+
| "money"
|
|
242
|
+
| "date"
|
|
243
|
+
| "number"
|
|
244
|
+
| "select"
|
|
245
|
+
| "combobox"
|
|
246
|
+
| "file"
|
|
247
|
+
| "radio"
|
|
248
|
+
| "icon-radio"
|
|
249
|
+
| "checkbox"
|
|
250
|
+
| "switch"
|
|
251
|
+
| "checkboxes"
|
|
252
|
+
| "icon-checkboxes";
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Every control a schema field can render as.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### OptionAnnotation
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
type OptionAnnotation = object;
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
One choice's presentation, keyed by its value in `options`.
|
|
266
|
+
|
|
267
|
+
#### Properties
|
|
268
|
+
|
|
269
|
+
##### label?
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
readonly optional label?: string;
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
##### description?
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
readonly optional description?: string;
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
A sentence under the label; radio options with one render as cards.
|
|
282
|
+
|
|
283
|
+
##### meta?
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
readonly optional meta?: string;
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
A short readout on a radio card's trailing edge, such as a price.
|
|
290
|
+
|
|
291
|
+
##### icon?
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
readonly optional icon?: ReactNode;
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
A Sigil or App icon: choices with icons render as icon keys.
|
|
298
|
+
|
|
299
|
+
##### caption?
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
readonly optional caption?: string;
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
The short legend on an icon key; `label` stays the accessible name.
|
|
306
|
+
|
|
307
|
+
##### disabled?
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
readonly optional disabled?: boolean;
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
### FieldRenderProps
|
|
316
|
+
|
|
317
|
+
```ts
|
|
318
|
+
type FieldRenderProps<T> = object;
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
What a `render` annotation receives: the same wiring every built-in kind gets.
|
|
322
|
+
|
|
323
|
+
#### Type Parameters
|
|
324
|
+
|
|
325
|
+
| Type Parameter | Default type |
|
|
326
|
+
| ----------------------------------------- | --------------------------- |
|
|
327
|
+
| `T` _extends_ [`FieldInput`](#fieldinput) | [`FieldInput`](#fieldinput) |
|
|
328
|
+
|
|
329
|
+
#### Properties
|
|
330
|
+
|
|
331
|
+
##### name
|
|
332
|
+
|
|
333
|
+
```ts
|
|
334
|
+
readonly name: string;
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
##### label
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
readonly label: string;
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
##### help
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
readonly help: ReactNode;
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
##### value
|
|
350
|
+
|
|
351
|
+
```ts
|
|
352
|
+
readonly value: T;
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
##### onBlur
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
readonly onBlur: () => void;
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Mark the field visited, so its error shows.
|
|
362
|
+
|
|
363
|
+
###### Returns
|
|
364
|
+
|
|
365
|
+
`void`
|
|
366
|
+
|
|
367
|
+
##### error
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
readonly error: string | undefined;
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
The visible error, after the person leaves the field or submits.
|
|
374
|
+
|
|
375
|
+
##### disabled
|
|
376
|
+
|
|
377
|
+
```ts
|
|
378
|
+
readonly disabled: boolean;
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
##### id
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
readonly id: string;
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
Put these on the control so the Field's label, help and error name it.
|
|
388
|
+
|
|
389
|
+
##### aria-describedby
|
|
390
|
+
|
|
391
|
+
```ts
|
|
392
|
+
readonly aria-describedby: string | undefined;
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
##### aria-invalid
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
readonly aria-invalid: boolean;
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
#### Methods
|
|
402
|
+
|
|
403
|
+
##### onChange()
|
|
404
|
+
|
|
405
|
+
```ts
|
|
406
|
+
onChange(value): void;
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
Set the field's raw value; validation runs as it would for a built-in kind.
|
|
410
|
+
|
|
411
|
+
###### Parameters
|
|
412
|
+
|
|
413
|
+
| Parameter | Type |
|
|
414
|
+
| --------- | ---- |
|
|
415
|
+
| `value` | `T` |
|
|
416
|
+
|
|
417
|
+
###### Returns
|
|
418
|
+
|
|
419
|
+
`void`
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
### FieldAnnotation
|
|
424
|
+
|
|
425
|
+
```ts
|
|
426
|
+
type FieldAnnotation<T> = object;
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
Presentation for one schema field. The schema stays the single source.
|
|
430
|
+
|
|
431
|
+
#### Type Parameters
|
|
432
|
+
|
|
433
|
+
| Type Parameter | Default type |
|
|
434
|
+
| ----------------------------------------- | --------------------------- |
|
|
435
|
+
| `T` _extends_ [`FieldInput`](#fieldinput) | [`FieldInput`](#fieldinput) |
|
|
436
|
+
|
|
437
|
+
#### Properties
|
|
438
|
+
|
|
439
|
+
##### label?
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
readonly optional label?: string;
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
The visible label and accessible name; defaults to the humanized key.
|
|
446
|
+
|
|
447
|
+
##### help?
|
|
448
|
+
|
|
449
|
+
```ts
|
|
450
|
+
readonly optional help?: string;
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
##### kind?
|
|
454
|
+
|
|
455
|
+
```ts
|
|
456
|
+
readonly optional kind?: FieldKind;
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
Overrides the kind inferred from the schema type.
|
|
460
|
+
|
|
461
|
+
##### placeholder?
|
|
462
|
+
|
|
463
|
+
```ts
|
|
464
|
+
readonly optional placeholder?: string;
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
##### section?
|
|
468
|
+
|
|
469
|
+
```ts
|
|
470
|
+
readonly optional section?: string;
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
The `sections` key this field sits in; unsectioned fields come first.
|
|
474
|
+
|
|
475
|
+
##### order?
|
|
476
|
+
|
|
477
|
+
```ts
|
|
478
|
+
readonly optional order?: number;
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
Sort position within its section; fields keep schema order otherwise.
|
|
482
|
+
|
|
483
|
+
##### layout?
|
|
484
|
+
|
|
485
|
+
```ts
|
|
486
|
+
readonly optional layout?: "stacked" | "row";
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
`row` puts the control opposite its label (a settings row).
|
|
490
|
+
|
|
491
|
+
##### required?
|
|
492
|
+
|
|
493
|
+
```ts
|
|
494
|
+
readonly optional required?: boolean;
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
##### optional?
|
|
498
|
+
|
|
499
|
+
```ts
|
|
500
|
+
readonly optional optional?: boolean;
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
Marks an optional field in a mostly required form.
|
|
504
|
+
|
|
505
|
+
##### icon?
|
|
506
|
+
|
|
507
|
+
```ts
|
|
508
|
+
readonly optional icon?: ReactNode;
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
A decorative Sigil or App icon before the label.
|
|
512
|
+
|
|
513
|
+
##### options?
|
|
514
|
+
|
|
515
|
+
```ts
|
|
516
|
+
readonly optional options?: Readonly<Record<string, string | OptionAnnotation>>;
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
Labels, help and icons for literal choices, keyed by value.
|
|
520
|
+
|
|
521
|
+
##### currency?
|
|
522
|
+
|
|
523
|
+
```ts
|
|
524
|
+
readonly optional currency?: string;
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
##### unit?
|
|
528
|
+
|
|
529
|
+
```ts
|
|
530
|
+
readonly optional unit?: string;
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
##### min?
|
|
534
|
+
|
|
535
|
+
```ts
|
|
536
|
+
readonly optional min?: number;
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
##### max?
|
|
540
|
+
|
|
541
|
+
```ts
|
|
542
|
+
readonly optional max?: number;
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
##### step?
|
|
546
|
+
|
|
547
|
+
```ts
|
|
548
|
+
readonly optional step?: number;
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
##### wrap?
|
|
552
|
+
|
|
553
|
+
```ts
|
|
554
|
+
readonly optional wrap?: boolean;
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
##### rows?
|
|
558
|
+
|
|
559
|
+
```ts
|
|
560
|
+
readonly optional rows?: number;
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
##### maxLength?
|
|
564
|
+
|
|
565
|
+
```ts
|
|
566
|
+
readonly optional maxLength?: number;
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
##### autoComplete?
|
|
570
|
+
|
|
571
|
+
```ts
|
|
572
|
+
readonly optional autoComplete?: string;
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
##### accept?
|
|
576
|
+
|
|
577
|
+
```ts
|
|
578
|
+
readonly optional accept?: string;
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
Native file-picker filter; the schema owns file-type validation.
|
|
582
|
+
|
|
583
|
+
##### multiple?
|
|
584
|
+
|
|
585
|
+
```ts
|
|
586
|
+
readonly optional multiple?: boolean;
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
##### maxBytes?
|
|
590
|
+
|
|
591
|
+
```ts
|
|
592
|
+
readonly optional maxBytes?: number;
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
Per-file byte limit, enforced by the field's schema check.
|
|
596
|
+
|
|
597
|
+
##### readOnly?
|
|
598
|
+
|
|
599
|
+
```ts
|
|
600
|
+
readonly optional readOnly?: boolean;
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
#### Methods
|
|
604
|
+
|
|
605
|
+
##### when()?
|
|
606
|
+
|
|
607
|
+
```ts
|
|
608
|
+
optional when(values): boolean;
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
Show the field only while this holds for the current raw values.
|
|
612
|
+
|
|
613
|
+
###### Parameters
|
|
614
|
+
|
|
615
|
+
| Parameter | Type |
|
|
616
|
+
| --------- | --------------------------- |
|
|
617
|
+
| `values` | [`FormValues`](#formvalues) |
|
|
618
|
+
|
|
619
|
+
###### Returns
|
|
620
|
+
|
|
621
|
+
`boolean`
|
|
622
|
+
|
|
623
|
+
##### render()?
|
|
624
|
+
|
|
625
|
+
```ts
|
|
626
|
+
optional render(field): ReactNode;
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
The bailout: draw this field's control yourself. Caps still owns the label,
|
|
630
|
+
help, error, layout, validation and save bar.
|
|
631
|
+
|
|
632
|
+
###### Parameters
|
|
633
|
+
|
|
634
|
+
| Parameter | Type |
|
|
635
|
+
| --------- | ---------------------------------------------- |
|
|
636
|
+
| `field` | [`FieldRenderProps`](#fieldrenderprops)\<`T`\> |
|
|
637
|
+
|
|
638
|
+
###### Returns
|
|
639
|
+
|
|
640
|
+
`ReactNode`
|
|
641
|
+
|
|
642
|
+
---
|
|
643
|
+
|
|
644
|
+
### SectionAnnotation
|
|
645
|
+
|
|
646
|
+
```ts
|
|
647
|
+
type SectionAnnotation = object;
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
A titled group of fields, declared on the struct.
|
|
651
|
+
|
|
652
|
+
#### Properties
|
|
653
|
+
|
|
654
|
+
##### title
|
|
655
|
+
|
|
656
|
+
```ts
|
|
657
|
+
readonly title: string;
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
##### description?
|
|
661
|
+
|
|
662
|
+
```ts
|
|
663
|
+
readonly optional description?: string;
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
---
|
|
667
|
+
|
|
668
|
+
### FieldMeta
|
|
669
|
+
|
|
670
|
+
Holds a field annotation inside schema annotations (Effect or Zod).
|
|
671
|
+
|
|
672
|
+
#### Constructors
|
|
673
|
+
|
|
674
|
+
##### Constructor
|
|
675
|
+
|
|
676
|
+
```ts
|
|
677
|
+
new FieldMeta(annotation): FieldMeta;
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
###### Parameters
|
|
681
|
+
|
|
682
|
+
| Parameter | Type |
|
|
683
|
+
| ------------ | ------------------------------------- |
|
|
684
|
+
| `annotation` | [`FieldAnnotation`](#fieldannotation) |
|
|
685
|
+
|
|
686
|
+
###### Returns
|
|
687
|
+
|
|
688
|
+
[`FieldMeta`](#fieldmeta)
|
|
689
|
+
|
|
690
|
+
#### Properties
|
|
691
|
+
|
|
692
|
+
##### annotation
|
|
693
|
+
|
|
694
|
+
```ts
|
|
695
|
+
readonly annotation: FieldAnnotation;
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
---
|
|
699
|
+
|
|
700
|
+
### SectionsMeta
|
|
701
|
+
|
|
702
|
+
Holds the section list inside a struct's annotations.
|
|
703
|
+
|
|
704
|
+
#### Constructors
|
|
705
|
+
|
|
706
|
+
##### Constructor
|
|
707
|
+
|
|
708
|
+
```ts
|
|
709
|
+
new SectionsMeta(sections): SectionsMeta;
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
###### Parameters
|
|
713
|
+
|
|
714
|
+
| Parameter | Type |
|
|
715
|
+
| ---------- | ----------------------------------------------------------------------------- |
|
|
716
|
+
| `sections` | `Readonly`\<`Record`\<`string`, [`SectionAnnotation`](#sectionannotation)\>\> |
|
|
717
|
+
|
|
718
|
+
###### Returns
|
|
719
|
+
|
|
720
|
+
[`SectionsMeta`](#sectionsmeta)
|
|
721
|
+
|
|
722
|
+
#### Properties
|
|
723
|
+
|
|
724
|
+
##### sections
|
|
725
|
+
|
|
726
|
+
```ts
|
|
727
|
+
readonly sections: Readonly<Record<string, SectionAnnotation>>;
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
---
|
|
731
|
+
|
|
732
|
+
### FieldAnnotations
|
|
733
|
+
|
|
734
|
+
```ts
|
|
735
|
+
type FieldAnnotations = Record<`caps/form:${number}`, FieldMeta> & object;
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
Schema annotations for one field: Effect `.annotate()` or Zod `.meta()`.
|
|
739
|
+
|
|
740
|
+
#### Type Declaration
|
|
741
|
+
|
|
742
|
+
| Name | Type |
|
|
743
|
+
| -------------- | -------- |
|
|
744
|
+
| `title?` | `string` |
|
|
745
|
+
| `description?` | `string` |
|
|
746
|
+
|
|
747
|
+
---
|
|
748
|
+
|
|
749
|
+
### SectionAnnotations
|
|
750
|
+
|
|
751
|
+
```ts
|
|
752
|
+
type SectionAnnotations = object;
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
Schema annotations for a struct's sections.
|
|
756
|
+
|
|
757
|
+
#### Properties
|
|
758
|
+
|
|
759
|
+
##### caps/form
|
|
760
|
+
|
|
761
|
+
```ts
|
|
762
|
+
readonly caps/form: SectionsMeta;
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
---
|
|
766
|
+
|
|
767
|
+
### field()
|
|
768
|
+
|
|
769
|
+
```ts
|
|
770
|
+
function field<T>(annotation): FieldAnnotations;
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
Annotate a schema field for forms. Works with Effect
|
|
774
|
+
(`Schema.String.annotate(field({ … }))`) and Zod
|
|
775
|
+
(`z.string().meta(field({ … }))`). `label` and `help` also become the schema's
|
|
776
|
+
`title` and `description`.
|
|
777
|
+
|
|
778
|
+
#### Type Parameters
|
|
779
|
+
|
|
780
|
+
| Type Parameter | Default type |
|
|
781
|
+
| ----------------------------------------- | --------------------------- |
|
|
782
|
+
| `T` _extends_ [`FieldInput`](#fieldinput) | [`FieldInput`](#fieldinput) |
|
|
783
|
+
|
|
784
|
+
#### Parameters
|
|
785
|
+
|
|
786
|
+
| Parameter | Type |
|
|
787
|
+
| ------------ | -------------------------------------------- |
|
|
788
|
+
| `annotation` | [`FieldAnnotation`](#fieldannotation)\<`T`\> |
|
|
789
|
+
|
|
790
|
+
#### Returns
|
|
791
|
+
|
|
792
|
+
[`FieldAnnotations`](#fieldannotations)
|
|
793
|
+
|
|
794
|
+
---
|
|
795
|
+
|
|
796
|
+
### sections()
|
|
797
|
+
|
|
798
|
+
```ts
|
|
799
|
+
function sections(list): SectionAnnotations;
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
Annotate a struct with its sections, in display order.
|
|
803
|
+
|
|
804
|
+
#### Parameters
|
|
805
|
+
|
|
806
|
+
| Parameter | Type |
|
|
807
|
+
| --------- | ----------------------------------------------------------------------------- |
|
|
808
|
+
| `list` | `Readonly`\<`Record`\<`string`, [`SectionAnnotation`](#sectionannotation)\>\> |
|
|
809
|
+
|
|
810
|
+
#### Returns
|
|
811
|
+
|
|
812
|
+
[`SectionAnnotations`](#sectionannotations)
|
|
813
|
+
|
|
814
|
+
---
|
|
815
|
+
|
|
816
|
+
### Secret
|
|
817
|
+
|
|
818
|
+
```ts
|
|
819
|
+
const Secret: brand<String, "Secret">;
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
A key or token: masked, never autofilled, with a reveal key.
|
|
823
|
+
|
|
824
|
+
---
|
|
825
|
+
|
|
826
|
+
### ResolvedOption
|
|
827
|
+
|
|
828
|
+
```ts
|
|
829
|
+
type ResolvedOption = object;
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
One choice, resolved for rendering.
|
|
833
|
+
|
|
834
|
+
#### Properties
|
|
835
|
+
|
|
836
|
+
##### value
|
|
837
|
+
|
|
838
|
+
```ts
|
|
839
|
+
readonly value: string;
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
##### label
|
|
843
|
+
|
|
844
|
+
```ts
|
|
845
|
+
readonly label: string;
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
##### description
|
|
849
|
+
|
|
850
|
+
```ts
|
|
851
|
+
readonly description: string | undefined;
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
##### meta
|
|
855
|
+
|
|
856
|
+
```ts
|
|
857
|
+
readonly meta: string | undefined;
|
|
858
|
+
```
|
|
859
|
+
|
|
860
|
+
##### icon
|
|
861
|
+
|
|
862
|
+
```ts
|
|
863
|
+
readonly icon: ReactNode;
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
##### caption
|
|
867
|
+
|
|
868
|
+
```ts
|
|
869
|
+
readonly caption: string | undefined;
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
##### disabled
|
|
873
|
+
|
|
874
|
+
```ts
|
|
875
|
+
readonly disabled: boolean;
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
---
|
|
879
|
+
|
|
880
|
+
### ResolvedField
|
|
881
|
+
|
|
882
|
+
```ts
|
|
883
|
+
type ResolvedField = Omit<FieldAnnotation, "options" | "kind" | "help"> &
|
|
884
|
+
object;
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
One field, resolved from the schema for rendering.
|
|
888
|
+
|
|
889
|
+
#### Type Declaration
|
|
890
|
+
|
|
891
|
+
| Name | Type |
|
|
892
|
+
| ------------------ | ---------------------------------------------- |
|
|
893
|
+
| `help` | `string` \| `undefined` |
|
|
894
|
+
| `name` | `string` |
|
|
895
|
+
| `label` | `string` |
|
|
896
|
+
| `kind` | [`FieldKind`](#fieldkind) |
|
|
897
|
+
| `options` | readonly [`ResolvedOption`](#resolvedoption)[] |
|
|
898
|
+
| `optionalInSchema` | `boolean` |
|
|
899
|
+
| `index` | `number` |
|
|
900
|
+
|
|
901
|
+
---
|
|
902
|
+
|
|
903
|
+
### ResolvedSection
|
|
904
|
+
|
|
905
|
+
```ts
|
|
906
|
+
type ResolvedSection = object;
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
A section and its fields, in display order.
|
|
910
|
+
|
|
911
|
+
#### Properties
|
|
912
|
+
|
|
913
|
+
##### id
|
|
914
|
+
|
|
915
|
+
```ts
|
|
916
|
+
readonly id: string | null;
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
##### title
|
|
920
|
+
|
|
921
|
+
```ts
|
|
922
|
+
readonly title: string | undefined;
|
|
923
|
+
```
|
|
924
|
+
|
|
925
|
+
##### description
|
|
926
|
+
|
|
927
|
+
```ts
|
|
928
|
+
readonly description: string | undefined;
|
|
929
|
+
```
|
|
930
|
+
|
|
931
|
+
##### fields
|
|
932
|
+
|
|
933
|
+
```ts
|
|
934
|
+
readonly fields: readonly ResolvedField[];
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
---
|
|
938
|
+
|
|
939
|
+
### FormDescription
|
|
940
|
+
|
|
941
|
+
```ts
|
|
942
|
+
type FormDescription = object;
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
Everything a form needs from its schema.
|
|
946
|
+
|
|
947
|
+
#### Properties
|
|
948
|
+
|
|
949
|
+
##### sections
|
|
950
|
+
|
|
951
|
+
```ts
|
|
952
|
+
readonly sections: readonly ResolvedSection[];
|
|
953
|
+
```
|
|
954
|
+
|
|
955
|
+
##### fields
|
|
956
|
+
|
|
957
|
+
```ts
|
|
958
|
+
readonly fields: readonly ResolvedField[];
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
##### defaults
|
|
962
|
+
|
|
963
|
+
```ts
|
|
964
|
+
readonly defaults: FormValues;
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
---
|
|
968
|
+
|
|
969
|
+
### describeSchema()
|
|
970
|
+
|
|
971
|
+
```ts
|
|
972
|
+
function describeSchema(schema): FormDescription;
|
|
973
|
+
```
|
|
974
|
+
|
|
975
|
+
Read a form's fields, sections and empty defaults from its schema.
|
|
976
|
+
|
|
977
|
+
#### Parameters
|
|
978
|
+
|
|
979
|
+
| Parameter | Type |
|
|
980
|
+
| --------- | ------------------------------------------------------------------------------------------ |
|
|
981
|
+
| `schema` | \| `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> \| `Top` |
|
|
982
|
+
|
|
983
|
+
#### Returns
|
|
984
|
+
|
|
985
|
+
[`FormDescription`](#formdescription)
|
|
986
|
+
|
|
987
|
+
---
|
|
988
|
+
|
|
989
|
+
### FormSchema
|
|
990
|
+
|
|
991
|
+
```ts
|
|
992
|
+
type FormSchema<V, Out> = Schema.Codec<Out, V> | z.ZodType<Out, V>;
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
A form schema: an Effect `Schema.Struct` (the house path) or a Zod object. `V`
|
|
996
|
+
is the raw input the controls hold; `Out` is what the submit receives.
|
|
997
|
+
|
|
998
|
+
#### Type Parameters
|
|
999
|
+
|
|
1000
|
+
| Type Parameter | Default type |
|
|
1001
|
+
| ----------------------------------------- | --------------------------- |
|
|
1002
|
+
| `V` _extends_ [`FormValues`](#formvalues) | [`FormValues`](#formvalues) |
|
|
1003
|
+
| `Out` | `unknown` |
|
|
1004
|
+
|
|
1005
|
+
---
|
|
1006
|
+
|
|
1007
|
+
### standardSchema()
|
|
1008
|
+
|
|
1009
|
+
```ts
|
|
1010
|
+
function standardSchema<V, Out>(schema): StandardSchemaV1<V, Out>;
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
The schema as a Standard Schema validator for TanStack Form.
|
|
1014
|
+
|
|
1015
|
+
#### Type Parameters
|
|
1016
|
+
|
|
1017
|
+
| Type Parameter |
|
|
1018
|
+
| ----------------------------------------------------------------------------- |
|
|
1019
|
+
| `V` _extends_ `Readonly`\<`Record`\<`string`, [`FieldInput`](#fieldinput)\>\> |
|
|
1020
|
+
| `Out` |
|
|
1021
|
+
|
|
1022
|
+
#### Parameters
|
|
1023
|
+
|
|
1024
|
+
| Parameter | Type |
|
|
1025
|
+
| --------- | ----------------------------------------- |
|
|
1026
|
+
| `schema` | [`FormSchema`](#formschema)\<`V`, `Out`\> |
|
|
1027
|
+
|
|
1028
|
+
#### Returns
|
|
1029
|
+
|
|
1030
|
+
`StandardSchemaV1`\<`V`, `Out`\>
|
|
1031
|
+
|
|
1032
|
+
---
|
|
1033
|
+
|
|
1034
|
+
### FormField()
|
|
1035
|
+
|
|
1036
|
+
```ts
|
|
1037
|
+
function FormField<
|
|
1038
|
+
TParentData,
|
|
1039
|
+
TName,
|
|
1040
|
+
TData,
|
|
1041
|
+
TOnMount,
|
|
1042
|
+
TOnChange,
|
|
1043
|
+
TOnChangeAsync,
|
|
1044
|
+
TOnBlur,
|
|
1045
|
+
TOnBlurAsync,
|
|
1046
|
+
TOnSubmit,
|
|
1047
|
+
TOnSubmitAsync,
|
|
1048
|
+
TOnDynamic,
|
|
1049
|
+
TOnDynamicAsync,
|
|
1050
|
+
TFormOnMount,
|
|
1051
|
+
TFormOnChange,
|
|
1052
|
+
TFormOnChangeAsync,
|
|
1053
|
+
TFormOnBlur,
|
|
1054
|
+
TFormOnBlurAsync,
|
|
1055
|
+
TFormOnSubmit,
|
|
1056
|
+
TFormOnSubmitAsync,
|
|
1057
|
+
TFormOnDynamic,
|
|
1058
|
+
TFormOnDynamicAsync,
|
|
1059
|
+
TFormOnServer,
|
|
1060
|
+
TSubmitMeta,
|
|
1061
|
+
>(__namedParameters): Element;
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
TanStack field binding with Caps labels, descriptions, errors, and control ARIA.
|
|
1065
|
+
|
|
1066
|
+
#### Type Parameters
|
|
1067
|
+
|
|
1068
|
+
| Type Parameter |
|
|
1069
|
+
| ------------------------------------------------------------------------------------------------------ |
|
|
1070
|
+
| `TParentData` |
|
|
1071
|
+
| `TName` _extends_ `string` |
|
|
1072
|
+
| `TData` |
|
|
1073
|
+
| `TOnMount` _extends_ `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\> \| `undefined` |
|
|
1074
|
+
| `TOnChange` _extends_ `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\> \| `undefined` |
|
|
1075
|
+
| `TOnChangeAsync` _extends_ `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\> \| `undefined` |
|
|
1076
|
+
| `TOnBlur` _extends_ `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\> \| `undefined` |
|
|
1077
|
+
| `TOnBlurAsync` _extends_ `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\> \| `undefined` |
|
|
1078
|
+
| `TOnSubmit` _extends_ `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\> \| `undefined` |
|
|
1079
|
+
| `TOnSubmitAsync` _extends_ `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\> \| `undefined` |
|
|
1080
|
+
| `TOnDynamic` _extends_ `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\> \| `undefined` |
|
|
1081
|
+
| `TOnDynamicAsync` _extends_ `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\> \| `undefined` |
|
|
1082
|
+
| `TFormOnMount` _extends_ `FormValidateOrFn`\<`TParentData`\> \| `undefined` |
|
|
1083
|
+
| `TFormOnChange` _extends_ `FormValidateOrFn`\<`TParentData`\> \| `undefined` |
|
|
1084
|
+
| `TFormOnChangeAsync` _extends_ `FormAsyncValidateOrFn`\<`TParentData`\> \| `undefined` |
|
|
1085
|
+
| `TFormOnBlur` _extends_ `FormValidateOrFn`\<`TParentData`\> \| `undefined` |
|
|
1086
|
+
| `TFormOnBlurAsync` _extends_ `FormAsyncValidateOrFn`\<`TParentData`\> \| `undefined` |
|
|
1087
|
+
| `TFormOnSubmit` _extends_ `FormValidateOrFn`\<`TParentData`\> \| `undefined` |
|
|
1088
|
+
| `TFormOnSubmitAsync` _extends_ `FormAsyncValidateOrFn`\<`TParentData`\> \| `undefined` |
|
|
1089
|
+
| `TFormOnDynamic` _extends_ `FormValidateOrFn`\<`TParentData`\> \| `undefined` |
|
|
1090
|
+
| `TFormOnDynamicAsync` _extends_ `FormAsyncValidateOrFn`\<`TParentData`\> \| `undefined` |
|
|
1091
|
+
| `TFormOnServer` _extends_ `FormAsyncValidateOrFn`\<`TParentData`\> \| `undefined` |
|
|
1092
|
+
| `TSubmitMeta` |
|
|
1093
|
+
|
|
1094
|
+
#### Parameters
|
|
1095
|
+
|
|
1096
|
+
| Parameter | Type |
|
|
1097
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1098
|
+
| `__namedParameters` | `FieldComponentProps`\<`TParentData`, `TName`, `TData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnDynamic`, `TOnDynamicAsync`, `TFormOnMount`, `TFormOnChange`, `TFormOnChangeAsync`, `TFormOnBlur`, `TFormOnBlurAsync`, `TFormOnSubmit`, `TFormOnSubmitAsync`, `TFormOnDynamic`, `TFormOnDynamicAsync`, `TFormOnServer`, `TSubmitMeta`, \{ \}\> & `Pick`\<[`FieldProps`](components/field.md#fieldprops), \| `"required"` \| `"optional"` \| `"orientation"` \| `"className"` \| `"label"` \| `"description"`\> |
|
|
1099
|
+
|
|
1100
|
+
#### Returns
|
|
1101
|
+
|
|
1102
|
+
`Element`
|
|
1103
|
+
|
|
1104
|
+
---
|
|
1105
|
+
|
|
1106
|
+
### SubmissionState
|
|
1107
|
+
|
|
1108
|
+
```ts
|
|
1109
|
+
type SubmissionState = object;
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
Values read by the submit action from TanStack’s form store.
|
|
1113
|
+
|
|
1114
|
+
#### Properties
|
|
1115
|
+
|
|
1116
|
+
##### canSubmit
|
|
1117
|
+
|
|
1118
|
+
```ts
|
|
1119
|
+
canSubmit: boolean;
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
##### isSubmitting
|
|
1123
|
+
|
|
1124
|
+
```ts
|
|
1125
|
+
isSubmitting: boolean;
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
---
|
|
1129
|
+
|
|
1130
|
+
### SubmitFooterProps
|
|
1131
|
+
|
|
1132
|
+
```ts
|
|
1133
|
+
type SubmitFooterProps = Omit<FormFooterProps, "children"> & object;
|
|
1134
|
+
```
|
|
1135
|
+
|
|
1136
|
+
Footer presentation plus the submit action; TanStack owns availability and busy
|
|
1137
|
+
state.
|
|
1138
|
+
|
|
1139
|
+
#### Type Declaration
|
|
1140
|
+
|
|
1141
|
+
| Name | Type | Description |
|
|
1142
|
+
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
|
|
1143
|
+
| `form` | `object` | - |
|
|
1144
|
+
| `form.Subscribe()` | (`props`) => `ReactNode` | TanStack’s reactive selector component. |
|
|
1145
|
+
| `label` | `ReactNode` | - |
|
|
1146
|
+
| `disabled?` | `boolean` | - |
|
|
1147
|
+
| `buttonProps?` | `Omit`\<[`ButtonProps`](components/button.md#buttonprops), `"type"` \| `"disabled"` \| `"loading"` \| `"children"` \| `"onClick"` \| `"asChild"`\> | - |
|
|
1148
|
+
|
|
1149
|
+
---
|
|
1150
|
+
|
|
1151
|
+
### SubmitFooter()
|
|
1152
|
+
|
|
1153
|
+
```ts
|
|
1154
|
+
function SubmitFooter(__namedParameters): Element;
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
Submit button subscribed to TanStack's canSubmit/isSubmitting store state.
|
|
1158
|
+
|
|
1159
|
+
#### Parameters
|
|
1160
|
+
|
|
1161
|
+
| Parameter | Type |
|
|
1162
|
+
| ------------------- | ----------------------------------------- |
|
|
1163
|
+
| `__namedParameters` | [`SubmitFooterProps`](#submitfooterprops) |
|
|
1164
|
+
|
|
1165
|
+
#### Returns
|
|
1166
|
+
|
|
1167
|
+
`Element`
|
|
1168
|
+
|
|
1169
|
+
---
|
|
1170
|
+
|
|
1171
|
+
### SubmitResult
|
|
1172
|
+
|
|
1173
|
+
```ts
|
|
1174
|
+
type SubmitResult<V> =
|
|
1175
|
+
| {
|
|
1176
|
+
kind: "saved";
|
|
1177
|
+
values?: V;
|
|
1178
|
+
message?: string;
|
|
1179
|
+
}
|
|
1180
|
+
| {
|
|
1181
|
+
kind: "refused";
|
|
1182
|
+
error?: string;
|
|
1183
|
+
fields?: Partial<Readonly<Record<keyof V & string, string>>>;
|
|
1184
|
+
};
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
What a submit handler reports. Return nothing (or `saved`) when the change
|
|
1188
|
+
landed; return `refused` with a form-level `error` and/or per-field `fields`
|
|
1189
|
+
messages when the server said no. Field messages clear when that field changes;
|
|
1190
|
+
the form message clears on the next change anywhere.
|
|
1191
|
+
|
|
1192
|
+
#### Type Parameters
|
|
1193
|
+
|
|
1194
|
+
| Type Parameter |
|
|
1195
|
+
| ----------------------------------------- |
|
|
1196
|
+
| `V` _extends_ [`FormValues`](#formvalues) |
|
|
1197
|
+
|
|
1198
|
+
#### Union Members
|
|
1199
|
+
|
|
1200
|
+
##### Type Literal
|
|
1201
|
+
|
|
1202
|
+
```ts
|
|
1203
|
+
{
|
|
1204
|
+
kind: "saved";
|
|
1205
|
+
values?: V;
|
|
1206
|
+
message?: string;
|
|
1207
|
+
}
|
|
1208
|
+
```
|
|
1209
|
+
|
|
1210
|
+
| Name | Type | Description |
|
|
1211
|
+
| ---------- | --------- | ----------------------------------------------------------------------- |
|
|
1212
|
+
| `kind` | `"saved"` | - |
|
|
1213
|
+
| `values?` | `V` | The new baseline; defaults to the submitted values. Clear secrets here. |
|
|
1214
|
+
| `message?` | `string` | Replaces the default "Saved" readout. |
|
|
1215
|
+
|
|
1216
|
+
---
|
|
1217
|
+
|
|
1218
|
+
##### Type Literal
|
|
1219
|
+
|
|
1220
|
+
```ts
|
|
1221
|
+
{
|
|
1222
|
+
kind: "refused";
|
|
1223
|
+
error?: string;
|
|
1224
|
+
fields?: Partial<Readonly<Record<keyof V & string, string>>>;
|
|
1225
|
+
}
|
|
1226
|
+
```
|
|
1227
|
+
|
|
1228
|
+
---
|
|
1229
|
+
|
|
1230
|
+
### SchemaFormOptions
|
|
1231
|
+
|
|
1232
|
+
```ts
|
|
1233
|
+
type SchemaFormOptions<V, Out> = object;
|
|
1234
|
+
```
|
|
1235
|
+
|
|
1236
|
+
Options accepted by useSchemaForm and an unbound SchemaForm.
|
|
1237
|
+
|
|
1238
|
+
#### Type Parameters
|
|
1239
|
+
|
|
1240
|
+
| Type Parameter |
|
|
1241
|
+
| ----------------------------------------- |
|
|
1242
|
+
| `V` _extends_ [`FormValues`](#formvalues) |
|
|
1243
|
+
| `Out` |
|
|
1244
|
+
|
|
1245
|
+
#### Properties
|
|
1246
|
+
|
|
1247
|
+
##### schema
|
|
1248
|
+
|
|
1249
|
+
```ts
|
|
1250
|
+
schema: FormSchema<V, Out>;
|
|
1251
|
+
```
|
|
1252
|
+
|
|
1253
|
+
The single source: an Effect `Schema.Struct` (house path) or a Zod object. It
|
|
1254
|
+
validates raw input, parses the submitted value, and its annotations (`field`,
|
|
1255
|
+
`sections`) give labels, kinds, help, options, order and grouping.
|
|
1256
|
+
|
|
1257
|
+
##### defaultValues
|
|
1258
|
+
|
|
1259
|
+
```ts
|
|
1260
|
+
defaultValues: V;
|
|
1261
|
+
```
|
|
1262
|
+
|
|
1263
|
+
The raw values to start from, such as the saved settings.
|
|
1264
|
+
|
|
1265
|
+
##### onSubmit
|
|
1266
|
+
|
|
1267
|
+
```ts
|
|
1268
|
+
onSubmit: (value, raw) =>
|
|
1269
|
+
| Promise<SubmitResult<V> | undefined>
|
|
1270
|
+
| Promise<void>
|
|
1271
|
+
| SubmitResult<V>
|
|
1272
|
+
| undefined;
|
|
1273
|
+
```
|
|
1274
|
+
|
|
1275
|
+
Receives the parsed value, never the raw input.
|
|
1276
|
+
|
|
1277
|
+
###### Parameters
|
|
1278
|
+
|
|
1279
|
+
| Parameter | Type |
|
|
1280
|
+
| --------- | ----- |
|
|
1281
|
+
| `value` | `Out` |
|
|
1282
|
+
| `raw` | `V` |
|
|
1283
|
+
|
|
1284
|
+
###### Returns
|
|
1285
|
+
|
|
1286
|
+
\| `Promise`\<[`SubmitResult`](#submitresult)\<`V`\> \| `undefined`\> \|
|
|
1287
|
+
`Promise`\<`void`\> \| [`SubmitResult`](#submitresult)\<`V`\> \| `undefined`
|
|
1288
|
+
|
|
1289
|
+
---
|
|
1290
|
+
|
|
1291
|
+
### Validator
|
|
1292
|
+
|
|
1293
|
+
```ts
|
|
1294
|
+
type Validator<V> = StandardSchemaV1<V, unknown>;
|
|
1295
|
+
```
|
|
1296
|
+
|
|
1297
|
+
The schema as TanStack validates it: raw values in, any output.
|
|
1298
|
+
|
|
1299
|
+
#### Type Parameters
|
|
1300
|
+
|
|
1301
|
+
| Type Parameter |
|
|
1302
|
+
| -------------- |
|
|
1303
|
+
| `V` |
|
|
1304
|
+
|
|
1305
|
+
---
|
|
1306
|
+
|
|
1307
|
+
### SchemaFormApi
|
|
1308
|
+
|
|
1309
|
+
```ts
|
|
1310
|
+
type SchemaFormApi<V> = ReactFormExtendedApi<
|
|
1311
|
+
V,
|
|
1312
|
+
undefined,
|
|
1313
|
+
Validator<V>,
|
|
1314
|
+
undefined,
|
|
1315
|
+
undefined,
|
|
1316
|
+
undefined,
|
|
1317
|
+
Validator<V>,
|
|
1318
|
+
undefined,
|
|
1319
|
+
undefined,
|
|
1320
|
+
undefined,
|
|
1321
|
+
undefined,
|
|
1322
|
+
unknown
|
|
1323
|
+
>;
|
|
1324
|
+
```
|
|
1325
|
+
|
|
1326
|
+
The TanStack form a schema form owns: typed values, schema validators.
|
|
1327
|
+
|
|
1328
|
+
#### Type Parameters
|
|
1329
|
+
|
|
1330
|
+
| Type Parameter |
|
|
1331
|
+
| ----------------------------------------- |
|
|
1332
|
+
| `V` _extends_ [`FormValues`](#formvalues) |
|
|
1333
|
+
|
|
1334
|
+
---
|
|
1335
|
+
|
|
1336
|
+
### SchemaFormModel
|
|
1337
|
+
|
|
1338
|
+
```ts
|
|
1339
|
+
type SchemaFormModel<V> = object;
|
|
1340
|
+
```
|
|
1341
|
+
|
|
1342
|
+
The model returned by useSchemaForm and read by SchemaForm, FormFields and
|
|
1343
|
+
SaveBar.
|
|
1344
|
+
|
|
1345
|
+
#### Type Parameters
|
|
1346
|
+
|
|
1347
|
+
| Type Parameter |
|
|
1348
|
+
| ----------------------------------------- |
|
|
1349
|
+
| `V` _extends_ [`FormValues`](#formvalues) |
|
|
1350
|
+
|
|
1351
|
+
#### Properties
|
|
1352
|
+
|
|
1353
|
+
##### description
|
|
1354
|
+
|
|
1355
|
+
```ts
|
|
1356
|
+
readonly description: FormDescription;
|
|
1357
|
+
```
|
|
1358
|
+
|
|
1359
|
+
The fields, kinds and sections read from the schema.
|
|
1360
|
+
|
|
1361
|
+
##### form
|
|
1362
|
+
|
|
1363
|
+
```ts
|
|
1364
|
+
readonly form: SchemaFormApi<V>;
|
|
1365
|
+
```
|
|
1366
|
+
|
|
1367
|
+
TanStack's typed form: read values with `useSelector(model.form.store, …)`.
|
|
1368
|
+
|
|
1369
|
+
##### error
|
|
1370
|
+
|
|
1371
|
+
```ts
|
|
1372
|
+
readonly error: string | null;
|
|
1373
|
+
```
|
|
1374
|
+
|
|
1375
|
+
The last refused submit's form-level message.
|
|
1376
|
+
|
|
1377
|
+
##### saved
|
|
1378
|
+
|
|
1379
|
+
```ts
|
|
1380
|
+
readonly saved: string | null;
|
|
1381
|
+
```
|
|
1382
|
+
|
|
1383
|
+
The last landed submit's readout, until the next change.
|
|
1384
|
+
|
|
1385
|
+
##### discard
|
|
1386
|
+
|
|
1387
|
+
```ts
|
|
1388
|
+
readonly discard: () => void;
|
|
1389
|
+
```
|
|
1390
|
+
|
|
1391
|
+
Restore the baseline values and clear every message.
|
|
1392
|
+
|
|
1393
|
+
###### Returns
|
|
1394
|
+
|
|
1395
|
+
`void`
|
|
1396
|
+
|
|
1397
|
+
##### submit
|
|
1398
|
+
|
|
1399
|
+
```ts
|
|
1400
|
+
readonly submit: () => Promise<void>;
|
|
1401
|
+
```
|
|
1402
|
+
|
|
1403
|
+
Submit through the schema; the same path as the native submit event.
|
|
1404
|
+
|
|
1405
|
+
###### Returns
|
|
1406
|
+
|
|
1407
|
+
`Promise`\<`void`\>
|
|
1408
|
+
|
|
1409
|
+
---
|
|
1410
|
+
|
|
1411
|
+
### useSchemaForm()
|
|
1412
|
+
|
|
1413
|
+
```ts
|
|
1414
|
+
function useSchemaForm<V, Out>(options): SchemaFormModel<V>;
|
|
1415
|
+
```
|
|
1416
|
+
|
|
1417
|
+
One form, declared by its schema. TanStack owns field state and timing; the
|
|
1418
|
+
schema owns validation and parses the submitted value; the handler only sees
|
|
1419
|
+
parsed data and reports `saved` or `refused`.
|
|
1420
|
+
|
|
1421
|
+
#### Type Parameters
|
|
1422
|
+
|
|
1423
|
+
| Type Parameter |
|
|
1424
|
+
| ----------------------------------------------------------------------------- |
|
|
1425
|
+
| `V` _extends_ `Readonly`\<`Record`\<`string`, [`FieldInput`](#fieldinput)\>\> |
|
|
1426
|
+
| `Out` |
|
|
1427
|
+
|
|
1428
|
+
#### Parameters
|
|
1429
|
+
|
|
1430
|
+
| Parameter | Type |
|
|
1431
|
+
| --------- | ------------------------------------------------------- |
|
|
1432
|
+
| `options` | [`SchemaFormOptions`](#schemaformoptions)\<`V`, `Out`\> |
|
|
1433
|
+
|
|
1434
|
+
#### Returns
|
|
1435
|
+
|
|
1436
|
+
[`SchemaFormModel`](#schemaformmodel)\<`V`\>
|
|
1437
|
+
|
|
1438
|
+
---
|
|
1439
|
+
|
|
1440
|
+
### SchemaFormStatus
|
|
1441
|
+
|
|
1442
|
+
```ts
|
|
1443
|
+
type SchemaFormStatus = object;
|
|
1444
|
+
```
|
|
1445
|
+
|
|
1446
|
+
Live status for leave guards and save bars.
|
|
1447
|
+
|
|
1448
|
+
#### Properties
|
|
1449
|
+
|
|
1450
|
+
##### dirty
|
|
1451
|
+
|
|
1452
|
+
```ts
|
|
1453
|
+
dirty: boolean;
|
|
1454
|
+
```
|
|
1455
|
+
|
|
1456
|
+
Values differ from the baseline.
|
|
1457
|
+
|
|
1458
|
+
##### submitting
|
|
1459
|
+
|
|
1460
|
+
```ts
|
|
1461
|
+
submitting: boolean;
|
|
1462
|
+
```
|
|
1463
|
+
|
|
1464
|
+
##### canSubmit
|
|
1465
|
+
|
|
1466
|
+
```ts
|
|
1467
|
+
canSubmit: boolean;
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
Validation allows a submit right now.
|
|
1471
|
+
|
|
1472
|
+
---
|
|
1473
|
+
|
|
1474
|
+
### useSchemaFormStatus()
|
|
1475
|
+
|
|
1476
|
+
```ts
|
|
1477
|
+
function useSchemaFormStatus<V>(model): SchemaFormStatus;
|
|
1478
|
+
```
|
|
1479
|
+
|
|
1480
|
+
Subscribe to a schema form's dirty and submitting state.
|
|
1481
|
+
|
|
1482
|
+
#### Type Parameters
|
|
1483
|
+
|
|
1484
|
+
| Type Parameter |
|
|
1485
|
+
| ----------------------------------------------------------------------------- |
|
|
1486
|
+
| `V` _extends_ `Readonly`\<`Record`\<`string`, [`FieldInput`](#fieldinput)\>\> |
|
|
1487
|
+
|
|
1488
|
+
#### Parameters
|
|
1489
|
+
|
|
1490
|
+
| Parameter | Type |
|
|
1491
|
+
| --------- | -------------------------------------------- |
|
|
1492
|
+
| `model` | [`SchemaFormModel`](#schemaformmodel)\<`V`\> |
|
|
1493
|
+
|
|
1494
|
+
#### Returns
|
|
1495
|
+
|
|
1496
|
+
[`SchemaFormStatus`](#schemaformstatus)
|
|
1497
|
+
|
|
1498
|
+
---
|
|
1499
|
+
|
|
1500
|
+
### SchemaFormPresentation
|
|
1501
|
+
|
|
1502
|
+
```ts
|
|
1503
|
+
type SchemaFormPresentation = object &
|
|
1504
|
+
Omit<FormProps, "busy" | "onSubmit" | "noValidate" | "children">;
|
|
1505
|
+
```
|
|
1506
|
+
|
|
1507
|
+
How a SchemaForm presents its actions and state.
|
|
1508
|
+
|
|
1509
|
+
#### Type Declaration
|
|
1510
|
+
|
|
1511
|
+
| Name | Type | Description |
|
|
1512
|
+
| --------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
1513
|
+
| `submitLabel?` | `ReactNode` | The primary action's label; defaults to "Save changes". |
|
|
1514
|
+
| `discardLabel?` | `ReactNode` | Show a Discard action while there are unsaved changes. |
|
|
1515
|
+
| `allowClean?` | `boolean` | Keep the primary action available on a clean form (create forms). |
|
|
1516
|
+
| `footer?` | `ReactNode` | Replaces the SaveBar, such as a footer with a retry key; `null` drops it. |
|
|
1517
|
+
| `children?` | `ReactNode` | Replaces the generated field list, for custom layouts such as Screen cells: place fields with `<FormFields model names={[…]} />`. |
|
|
1518
|
+
| `disabled?` | `boolean` | Disable every field, such as while an uncertain request is retried. |
|
|
1519
|
+
|
|
1520
|
+
---
|
|
1521
|
+
|
|
1522
|
+
### SchemaFormProps
|
|
1523
|
+
|
|
1524
|
+
```ts
|
|
1525
|
+
type SchemaFormProps<V, Out> = SchemaFormPresentation &
|
|
1526
|
+
| {
|
|
1527
|
+
model: SchemaFormModel<V>;
|
|
1528
|
+
}
|
|
1529
|
+
| SchemaFormOptions<V, Out>;
|
|
1530
|
+
```
|
|
1531
|
+
|
|
1532
|
+
Props accepted by SchemaForm: a model from useSchemaForm, or its options.
|
|
1533
|
+
|
|
1534
|
+
#### Type Parameters
|
|
1535
|
+
|
|
1536
|
+
| Type Parameter |
|
|
1537
|
+
| ----------------------------------------- |
|
|
1538
|
+
| `V` _extends_ [`FormValues`](#formvalues) |
|
|
1539
|
+
| `Out` |
|
|
1540
|
+
|
|
1541
|
+
---
|
|
1542
|
+
|
|
1543
|
+
### SchemaForm()
|
|
1544
|
+
|
|
1545
|
+
```ts
|
|
1546
|
+
function SchemaForm<V, Out>(props): Element;
|
|
1547
|
+
```
|
|
1548
|
+
|
|
1549
|
+
A whole form from its schema: fields, sections, validation, busy state and the
|
|
1550
|
+
SaveBar. Pass `schema`, `defaultValues` and `onSubmit`, or a `model` from
|
|
1551
|
+
useSchemaForm when the page needs its status or a custom layout.
|
|
1552
|
+
|
|
1553
|
+
#### Type Parameters
|
|
1554
|
+
|
|
1555
|
+
| Type Parameter |
|
|
1556
|
+
| ----------------------------------------------------------------------------- |
|
|
1557
|
+
| `V` _extends_ `Readonly`\<`Record`\<`string`, [`FieldInput`](#fieldinput)\>\> |
|
|
1558
|
+
| `Out` |
|
|
1559
|
+
|
|
1560
|
+
#### Parameters
|
|
1561
|
+
|
|
1562
|
+
| Parameter | Type |
|
|
1563
|
+
| --------- | --------------------------------------------------- |
|
|
1564
|
+
| `props` | [`SchemaFormProps`](#schemaformprops)\<`V`, `Out`\> |
|
|
1565
|
+
|
|
1566
|
+
#### Returns
|
|
1567
|
+
|
|
1568
|
+
`Element`
|
|
1569
|
+
|
|
1570
|
+
---
|
|
1571
|
+
|
|
1572
|
+
### SaveBarProps
|
|
1573
|
+
|
|
1574
|
+
```ts
|
|
1575
|
+
type SaveBarProps<V> = object &
|
|
1576
|
+
Omit<FormFooterProps, "children" | "error" | "status">;
|
|
1577
|
+
```
|
|
1578
|
+
|
|
1579
|
+
Props accepted by SaveBar.
|
|
1580
|
+
|
|
1581
|
+
#### Type Declaration
|
|
1582
|
+
|
|
1583
|
+
| Name | Type | Description |
|
|
1584
|
+
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1585
|
+
| `model` | [`SchemaFormModel`](#schemaformmodel)\<`V`\> | - |
|
|
1586
|
+
| `label` | `ReactNode` | The primary action, such as "Save changes" or "Create Team". |
|
|
1587
|
+
| `discardLabel?` | `ReactNode` | Show a Discard action while there are unsaved changes. |
|
|
1588
|
+
| `allowClean?` | `boolean` | Keep the primary action available on a clean form (create forms that may submit their defaults). By default a clean form has nothing to save. |
|
|
1589
|
+
| `dirtyLabel?` | `ReactNode` | The quiet readout while there are unsaved changes. |
|
|
1590
|
+
| `buttonProps?` | `Omit`\<[`ButtonProps`](components/button.md#buttonprops), `"type"` \| `"disabled"` \| `"loading"` \| `"children"` \| `"onClick"` \| `"asChild"`\> | - |
|
|
1591
|
+
|
|
1592
|
+
#### Type Parameters
|
|
1593
|
+
|
|
1594
|
+
| Type Parameter |
|
|
1595
|
+
| ----------------------------------------- |
|
|
1596
|
+
| `V` _extends_ [`FormValues`](#formvalues) |
|
|
1597
|
+
|
|
1598
|
+
---
|
|
1599
|
+
|
|
1600
|
+
### SaveBar()
|
|
1601
|
+
|
|
1602
|
+
```ts
|
|
1603
|
+
function SaveBar<V>(__namedParameters): Element;
|
|
1604
|
+
```
|
|
1605
|
+
|
|
1606
|
+
The form's action row: the refused-submit error, a quiet "Unsaved changes" or
|
|
1607
|
+
"Saved" readout, an optional Discard, and the one primary submit.
|
|
1608
|
+
|
|
1609
|
+
#### Type Parameters
|
|
1610
|
+
|
|
1611
|
+
| Type Parameter |
|
|
1612
|
+
| ----------------------------------------------------------------------------- |
|
|
1613
|
+
| `V` _extends_ `Readonly`\<`Record`\<`string`, [`FieldInput`](#fieldinput)\>\> |
|
|
1614
|
+
|
|
1615
|
+
#### Parameters
|
|
1616
|
+
|
|
1617
|
+
| Parameter | Type |
|
|
1618
|
+
| ------------------- | -------------------------------------- |
|
|
1619
|
+
| `__namedParameters` | [`SaveBarProps`](#savebarprops)\<`V`\> |
|
|
1620
|
+
|
|
1621
|
+
#### Returns
|
|
1622
|
+
|
|
1623
|
+
`Element`
|