Skip to content

Commit ccd29b0

Browse files
committed
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.
1 parent edbec87 commit ccd29b0

13 files changed

+858
-1149
lines changed

6.api-reference/1.context.md

Lines changed: 165 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -13,73 +13,115 @@ The context object, in general, can be thought of as a general purpose data stor
1313

1414
The context object always (unless noted) has the following properties:
1515

16-
<div data-tight class="docs-content-child">
17-
18-
## `_value`
16+
## Properties
1917

18+
::api-entry{name="_value" type="property"}
2019
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.
2120

22-
## `attrs`
21+
#### Signature
22+
23+
```typescript
24+
_value: any
25+
```
26+
::
2327

28+
::api-entry{name="attrs" type="property"}
2429
An object containing any attributes that will be passed to the internal input element.
2530

26-
## `fns`
31+
#### Signature
2732

33+
```typescript
34+
attrs: Record<string, any>
35+
```
36+
::
37+
38+
::api-entry{name="fns" type="property"}
2839
A small object of utility functions that are useful when writing schemas.
2940

30-
```js
31-
{
41+
#### Signature
42+
43+
```typescript
44+
fns: {
3245
// Returns the length of a given object
33-
length: (obj: Record<PropertyKey, any>) => Number,
46+
length: (obj: Record<PropertyKey, any>) => number
3447
// Casts a value to a number
35-
number: (value: any) => Number,
48+
number: (value: any) => number
3649
// Casts a value to a string
37-
string: (value: any) => String,
50+
string: (value: any) => string
3851
// Returns the JSON representation of a value
39-
json: (value: any) => String | false,
52+
json: (value: any) => string | false
4053
}
4154
```
55+
::
4256

43-
## `handlers`
44-
57+
::api-entry{name="handlers" type="property"}
4558
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.
4659

47-
```js
48-
{
60+
#### Signature
61+
62+
```typescript
63+
handlers: {
4964
// sets the state.blurred value to true
50-
blur: () => void,
65+
blur: () => void
5166
// sets the state.touched value to true
52-
touch: () => void,
67+
touch: () => void
5368
// Sets the value of the input
5469
DOMInput: (e: Event) => void
5570
}
5671
```
72+
::
5773

58-
## `help`
59-
74+
::api-entry{name="help" type="property"}
6075
The help text of the input provided by the `help` prop.
6176

62-
## `id`
77+
#### Signature
6378

79+
```typescript
80+
help: string | undefined
81+
```
82+
::
83+
84+
::api-entry{name="id" type="property"}
6485
The unique identifier of the input. This value is auto-generated unless the `id` prop is set.
6586

66-
## `label`
87+
#### Signature
6788

89+
```typescript
90+
id: string
91+
```
92+
::
93+
94+
::api-entry{name="label" type="property"}
6895
The label of the input provided by the `label` prop.
6996

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+
```
71112

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
73114

74-
```js
115+
For an input displaying a single failing validation message, this object would look like:
116+
117+
```typescript
75118
{
76119
rule_required: {
77120
// Determines if the message prevents form submission
78121
blocking: true,
79122
// The unique key of this message
80123
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
83125
meta: {
84126
// The name of the validation message (used in message lookups)
85127
messageKey: 'required',
@@ -94,28 +136,49 @@ An object of _visible_ messages (where the type is not `ui` — `ui`). The key
94136
type: 'validation',
95137
// The value of the message
96138
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
101140
visible: true
102141
}
103142
}
104143
```
144+
::
105145

106-
## `node`
107-
146+
::api-entry{name="node" type="property"}
108147
The underlying [core node](/essentials/architecture) of the current input. This object is not reactive (within the context of Vue).
109148

110-
## `options`
149+
#### Signature
150+
151+
```typescript
152+
node: FormKitNode
153+
```
154+
::
111155

156+
::api-entry{name="options" type="property"}
112157
For inputs that accept an options prop, this is a normalized array of option objects.
113158

114-
## `option`
159+
#### Signature
160+
161+
```typescript
162+
options: Array<{ label: string; value: any; attrs?: Record<string, any> }> | undefined
163+
```
164+
::
165+
166+
::api-entry{name="option" type="property"}
167+
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
115170

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+
```
117178

118-
```js
179+
#### Example
180+
181+
```typescript
119182
{
120183
value: 'foo',
121184
label: 'Foo',
@@ -124,109 +187,95 @@ For inputs that accept an options prop, this object is available to [section key
124187
}
125188
}
126189
```
190+
::
127191

128-
## `state`
192+
::api-entry{name="state" type="property"}
193+
Current state of the input.
129194

130-
Current state of the input:
195+
#### Signature
131196

132-
```js
133-
{
134-
/**
135-
* If the input has been blurred.
136-
*/
197+
```typescript
198+
state: {
199+
// If the input has been blurred
137200
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
154205
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
160208
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.
170212
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
175215
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
180218
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
184221
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)
189224
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
194227
settled: boolean
195-
/**
196-
* If the form has been submitted.
197-
*/
228+
229+
// If the form has been submitted
198230
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)
204233
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
211236
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
216239
validationVisible: boolean
217240
}
218241
```
242+
::
219243

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+
```
221252

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
223254

224-
## `ui`
255+
`text`, `select`, `autocomplete`
256+
::
225257

258+
::api-entry{name="ui" type="property"}
226259
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.
227260

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+
```
229276

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`.
277+
#### Examples
231278

232-
</div>
279+
- `$classes.input` returns `formkit-input` (by default)
280+
- `$classes.foobar` returns `formkit-foobar`
281+
::

0 commit comments

Comments
 (0)