You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: migrate API reference pages to use ApiEntry MDC component
Convert all API reference documentation to use the new ::api-entry
component for consistent styling and better .md export support:
- formkit-vue, formkit-core, formkit-addons, formkit-inputs
- formkit-utils, formkit-validation, formkit-observer
- formkit-themes, formkit-i18n, formkit-schema, formkit-zod
- formkit-common, context object page
Each entry now has proper type indicators (function, interface, type, property)
and structured sections for signature, parameters, and returns.
@@ -13,73 +13,115 @@ The context object, in general, can be thought of as a general purpose data stor
13
13
14
14
The context object always (unless noted) has the following properties:
15
15
16
-
<divdata-tightclass="docs-content-child">
17
-
18
-
## `_value`
16
+
## Properties
19
17
18
+
::api-entry{name="_value"type="property"}
20
19
FormKit inputs have two values — the committed value (`node.value`) and the uncommitted value (`node._value`). At rest, these two values are equivalent, but the uncommitted value is the undebounced raw value of the input.
21
20
22
-
## `attrs`
21
+
#### Signature
22
+
23
+
```typescript
24
+
_value: any
25
+
```
26
+
::
23
27
28
+
::api-entry{name="attrs"type="property"}
24
29
An object containing any attributes that will be passed to the internal input element.
25
30
26
-
##`fns`
31
+
#### Signature
27
32
33
+
```typescript
34
+
attrs: Record<string, any>
35
+
```
36
+
::
37
+
38
+
::api-entry{name="fns"type="property"}
28
39
A small object of utility functions that are useful when writing schemas.
29
40
30
-
```js
31
-
{
41
+
#### Signature
42
+
43
+
```typescript
44
+
fns: {
32
45
// Returns the length of a given object
33
-
length: (obj:Record<PropertyKey, any>) =>Number,
46
+
length: (obj:Record<PropertyKey, any>) =>number
34
47
// Casts a value to a number
35
-
number: (value:any) =>Number,
48
+
number: (value:any) =>number
36
49
// Casts a value to a string
37
-
string: (value:any) =>String,
50
+
string: (value:any) =>string
38
51
// Returns the JSON representation of a value
39
-
json: (value:any) =>String|false,
52
+
json: (value:any) =>string|false
40
53
}
41
54
```
55
+
::
42
56
43
-
## `handlers`
44
-
57
+
::api-entry{name="handlers"type="property"}
45
58
A small object of common input handlers for use in the schema. Keep in mind that input "features" can replace or add to handlers on an input by input basis.
46
59
47
-
```js
48
-
{
60
+
#### Signature
61
+
62
+
```typescript
63
+
handlers: {
49
64
// sets the state.blurred value to true
50
-
blur: () =>void,
65
+
blur: () =>void
51
66
// sets the state.touched value to true
52
-
touch: () =>void,
67
+
touch: () =>void
53
68
// Sets the value of the input
54
69
DOMInput: (e:Event) =>void
55
70
}
56
71
```
72
+
::
57
73
58
-
## `help`
59
-
74
+
::api-entry{name="help"type="property"}
60
75
The help text of the input provided by the `help` prop.
61
76
62
-
##`id`
77
+
#### Signature
63
78
79
+
```typescript
80
+
help: string|undefined
81
+
```
82
+
::
83
+
84
+
::api-entry{name="id"type="property"}
64
85
The unique identifier of the input. This value is auto-generated unless the `id` prop is set.
65
86
66
-
##`label`
87
+
#### Signature
67
88
89
+
```typescript
90
+
id: string
91
+
```
92
+
::
93
+
94
+
::api-entry{name="label"type="property"}
68
95
The label of the input provided by the `label` prop.
69
96
70
-
## `messages`
97
+
#### Signature
98
+
99
+
```typescript
100
+
label: string|undefined
101
+
```
102
+
::
103
+
104
+
::api-entry{name="messages"type="property"}
105
+
An object of _visible_ messages (where the type is not `ui`). The key of this object is the message name, and the value is a core message object.
106
+
107
+
#### Signature
108
+
109
+
```typescript
110
+
messages: Record<string, FormKitMessage>
111
+
```
71
112
72
-
An object of _visible_ messages (where the type is not `ui` — `ui`). The key of this object is the message name, and the value is a core message object. For example, for an input displaying a single failing validation message, this object would look like:
113
+
#### Example
73
114
74
-
```js
115
+
For an input displaying a single failing validation message, this object would look like:
116
+
117
+
```typescript
75
118
{
76
119
rule_required: {
77
120
// Determines if the message prevents form submission
78
121
blocking: true,
79
122
// The unique key of this message
80
123
key: 'rule_required',
81
-
// Additional details about the message, you can put anything in here.
82
-
// Below are the meta details for validation messages:
124
+
// Additional details about the message
83
125
meta: {
84
126
// The name of the validation message (used in message lookups)
85
127
messageKey: 'required',
@@ -94,28 +136,49 @@ An object of _visible_ messages (where the type is not `ui` — `ui`). The key
94
136
type: 'validation',
95
137
// The value of the message
96
138
value: 'Email is required',
97
-
// If this message is intended to be displayed to end users — this does not
98
-
// mean the message is actively visible — that is determined by the
99
-
// {type}-visibility rules, but if this is false, it is never displayed to
100
-
// users.
139
+
// If this message is intended to be displayed to end users
101
140
visible: true
102
141
}
103
142
}
104
143
```
144
+
::
105
145
106
-
## `node`
107
-
146
+
::api-entry{name="node"type="property"}
108
147
The underlying [core node](/essentials/architecture) of the current input. This object is not reactive (within the context of Vue).
109
148
110
-
## `options`
149
+
#### Signature
150
+
151
+
```typescript
152
+
node: FormKitNode
153
+
```
154
+
::
111
155
156
+
::api-entry{name="options"type="property"}
112
157
For inputs that accept an options prop, this is a normalized array of option objects.
For inputs that accept an options prop, this object is available to [section keys](/essentials/inputs#sections) that are inside the iteration (i.e., the `label` section key on a `checkbox` input with multiple checkboxes).
168
+
169
+
#### Signature
115
170
116
-
For inputs that accept an options prop, this object is available to [section keys](/essentials/inputs#sections) that are inside the iteration (i.e., the `label` section key on a `checkbox` input with multiple checkboxes). The object contains a `label`, `value`, and sometimes `attrs`:
171
+
```typescript
172
+
option: {
173
+
value: any
174
+
label: string
175
+
attrs?:Record<string, any>
176
+
}
177
+
```
117
178
118
-
```js
179
+
#### Example
180
+
181
+
```typescript
119
182
{
120
183
value: 'foo',
121
184
label: 'Foo',
@@ -124,109 +187,95 @@ For inputs that accept an options prop, this object is available to [section key
124
187
}
125
188
}
126
189
```
190
+
::
127
191
128
-
## `state`
192
+
::api-entry{name="state"type="property"}
193
+
Current state of the input.
129
194
130
-
Current state of the input:
195
+
#### Signature
131
196
132
-
```js
133
-
{
134
-
/**
135
-
* If the input has been blurred.
136
-
*/
197
+
```typescript
198
+
state: {
199
+
// If the input has been blurred
137
200
blurred: boolean
138
-
/**
139
-
* True when these conditions are met:
140
-
*
141
-
* Either:
142
-
* - The input has validation rules
143
-
* - The validation rules are all passing
144
-
* - There are no errors on the input
145
-
* Or:
146
-
* - The input has no validation rules
147
-
* - The input has no errors
148
-
* - The input is dirty and has a value
149
-
*
150
-
* This is not intended to be used on forms/groups/lists, but instead on
151
-
* individual inputs. Imagine placing a green checkbox next to each input
152
-
* when the user filled it out correctly — that's what these are for.
153
-
*/
201
+
202
+
// True when the input is "complete" - either:
203
+
// - Has validation rules, all passing, no errors
204
+
// - Or: no validation rules, no errors, is dirty and has a value
154
205
complete: boolean
155
-
/**
156
-
* A flag that indicates if the "owning" component of this node has mounted
157
-
* to the dom or not. Listen to the `mounted` event to be notified when this
158
-
* flag is changed.
159
-
*/
206
+
207
+
// If the owning component has mounted to the DOM
160
208
didMount: boolean
161
-
/**
162
-
* The dirty-behavior prop controls how this state is set. By default it is
163
-
* considered dirty if any mutation was made to the input, but once a mutation
164
-
* has been made and dirty is `true` it stops checking.
165
-
*
166
-
* Alternatively the dirty-behavior prop can be set to `compare` which will
167
-
* diff the changes between the current value and the initial value after
168
-
* every mutation — this means if the input returns back to its initial value * dirty will become `false` again.
169
-
*/
209
+
210
+
// Controlled by dirty-behavior prop. By default true after any mutation.
211
+
// With dirty-behavior="compare", compares current vs initial value.
170
212
dirty: boolean
171
-
/**
172
-
* If the input has explicit errors placed on it, or in the case of a group,
173
-
* list, or form, this is true if any children have errors on them.
174
-
*/
213
+
214
+
// If the input has explicit errors, or any children have errors
175
215
errors: boolean
176
-
/**
177
-
* The loading state of the input or form. This property is only added while
178
-
* the input is loading and is removed when loading is complete.
179
-
*/
216
+
217
+
// Loading state - only present while loading, removed when complete
180
218
loading: true|undefined
181
-
/**
182
-
* Indicates if the input is has the "required" validation rule.
183
-
*/
219
+
220
+
// If the input has the "required" validation rule
184
221
required: boolean
185
-
/**
186
-
* True when the input has validation rules. Has nothing to do with the
187
-
* state of those validation rules.
188
-
*/
222
+
223
+
// True when the input has validation rules (regardless of state)
189
224
rules: boolean
190
-
/**
191
-
* True when the input has completed its internal debounce cycle and the
192
-
* value was committed to the form.
193
-
*/
225
+
226
+
// True when debounce cycle is complete and value was committed
194
227
settled: boolean
195
-
/**
196
-
* If the form has been submitted.
197
-
*/
228
+
229
+
// If the form has been submitted
198
230
submitted: boolean
199
-
/**
200
-
* If the input (or group/form/list) is passing all validation rules. In
201
-
* the case of groups, forms, and lists this includes the validation state
202
-
* of all its children.
203
-
*/
231
+
232
+
// If passing all validation rules (includes children for groups/forms/lists)
204
233
valid: boolean
205
-
/**
206
-
* == Added by @formkit/validation plugin — included in defaultConfig ==
207
-
* If the input (or group/form/list) is currently validating rules — including
208
-
* async validation rules. In the case of groups, forms, and lists this includes
209
-
* the validation state of all its children.
210
-
*/
234
+
235
+
// If currently validating (including async rules) - from @formkit/validation
211
236
validating?:boolean
212
-
/**
213
-
* If validation-visibility has been satisfied and any validation
214
-
* messages should be displayed.
215
-
*/
237
+
238
+
// If validation-visibility is satisfied and messages should display
216
239
validationVisible: boolean
217
240
}
218
241
```
242
+
::
219
243
220
-
## `type`
244
+
::api-entry{name="type"type="property"}
245
+
The type of the input provided by the `type` prop. This is the value that should be referenced when looking up definitions in a library of inputs.
246
+
247
+
#### Signature
248
+
249
+
```typescript
250
+
type: string
251
+
```
221
252
222
-
The type of the input provided by the `type` prop. This is the value that should be referenced when looking up definitions in a library of inputs. Examples of this value: `text`, `select`, or `autocomplete`.
253
+
#### Examples
223
254
224
-
## `ui`
255
+
`text`, `select`, `autocomplete`
256
+
::
225
257
258
+
::api-entry{name="ui"type="property"}
226
259
An object of visible messages (keyed by the `key`) of type `ui` that can be used in the interface. This allows for localized text for use on interface elements.
227
260
228
-
## `classes`
261
+
#### Signature
262
+
263
+
```typescript
264
+
ui: Record<string, FormKitMessage>
265
+
```
266
+
::
267
+
268
+
::api-entry{name="classes"type="property"}
269
+
A Proxy object for requesting classes. This object allows schema authors to request any [section](/essentials/inputs#sections) and get a generative class name.
270
+
271
+
#### Signature
272
+
273
+
```typescript
274
+
classes: Proxy<Record<string, string>>
275
+
```
229
276
230
-
A Proxy object for requesting classes. This object allows schema authors to request any [section](/essentials/inputs#sections) and get a generative class name. For example `$classes.input` would (by default without additional configuration) return `formkit-input` while `$classes.foobar` would return `formkit-foobar`.
0 commit comments