Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit f4bb421

Browse files
committed
feat: finishing docs
1 parent c591bca commit f4bb421

File tree

9 files changed

+279
-8
lines changed

9 files changed

+279
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
node_modules
33
**/node_modules
44
/dist
5-
/docs/.vuepress/dist
5+
/docs/.vitepress/dist
66
/coverage
77
/tests/e2e/videos/
88
/tests/e2e/screenshots/
99
/temp
10+
1011
# local env files
1112
.env.local
1213
.env.*.local

docs/.vitepress/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ const config = {
3939
text: 'Validation',
4040
link: '/guide/validation',
4141
},
42+
{
43+
text: 'Models',
44+
link: '/guide/models',
45+
},
4246
],
4347
},
4448
{

docs/guide/api/props/dynamic-form-props.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ export interface DynamicForm {
2323
It contains the following properties:
2424

2525
- `id` : this field of type `string` contains the form [id](https://developer.mozilla.org/en-US/search?q=form), is especially useful to access your form via javascript when accessing the DOM, also helps to assign external inputs or submit buttons via form attribute.
26-
- `fields`: this property holds an `Object` of type [`FormFields`](../types.md#form-fields) which is going to be the base of creating the input controls.
26+
- `fields`: this property holds an `Object` of type [`FormFields`](../../models.md#form-fields) which is going to be the base of creating the input controls.
2727
- `field-order`: contains the desired order of the fields as an `Array` of strings.
28-
- `options`: Contains all the form options using [`FormOptions`](../types.md#form-options)
28+
- `options`: Contains all the form options using [`FormOptions`](../../models.md#form-options)

docs/guide/api/props/dynamic-input-props.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export type FormControl<T extends InputType> = T & {
3636
3737
## `forceValidation`
3838
39-
By default, input validation can be triggered by a `blur` or a `change` event on the input (Check [validation](../../guide/validation.md)). However you can force the validation state of the input by changing this prop to `true`.
39+
By default, input validation can be triggered by a `blur` or a `change` event on the input (Check [validation](../../validation.md)). However you can force the validation state of the input by changing this prop to `true`.
4040
4141
```typescript
4242
forceValidation: {

docs/guide/fields.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ By default, `Vue Dynamic Forms` cover the following input types:
1313
- Textarea
1414

1515
::: tip
16-
You can also include your very own custom input using `slots` (Check [Slots](../advanced/slots.md))
16+
You can also include your very own custom input using `slots` (Check [Slots](./advanced/slots.md))
1717
:::
1818

1919
## Text

docs/guide/models.md

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
## Form Fields & Inputs
2+
3+
### `FieldType`
4+
5+
```ts
6+
export enum FieldTypes {
7+
TEXT = 'text',
8+
TEXTAREA = 'textarea',
9+
SELECT = 'select',
10+
NUMBER = 'number',
11+
EMAIL = 'email',
12+
URL = 'url',
13+
PASSWORD = 'password',
14+
CHECKBOX = 'checkbox',
15+
RADIO = 'radio',
16+
CUSTOM = 'custom-field',
17+
COLOR = 'color',
18+
}
19+
```
20+
21+
### `InputType`
22+
23+
```ts
24+
export type InputType =
25+
| TextInput
26+
| NumberInput
27+
| SelectInput
28+
| TextAreaInput
29+
| CheckboxInput
30+
| RadioInput
31+
| EmailInput
32+
| PasswordInput
33+
| RadioInput
34+
| ColorInput
35+
| UrlInput
36+
| CustomInput
37+
```
38+
39+
### `FormFields`
40+
41+
```ts
42+
export type FormFields = {
43+
[key: string]: InputType
44+
}
45+
```
46+
47+
### `InputBase`
48+
49+
```ts
50+
export interface InputBase {
51+
name?: string
52+
label?: string
53+
ariaLabel?: string
54+
ariaLabelledBy?: string
55+
disabled?: boolean
56+
customClass?: string | string[] | BindingObject | BindingObject[] | unknown
57+
customStyles?: string | string[] | BindingObject | BindingObject[] | unknown
58+
placeholder?: string
59+
autocomplete?: string
60+
readonly?: boolean
61+
validations?: FormValidator[]
62+
validationTrigger?: ValidationTrigger
63+
}
64+
```
65+
66+
### `TextInput`
67+
68+
```ts
69+
export type TextInput = InputBase & {
70+
type: FieldTypes.TEXT
71+
value?: string
72+
}
73+
```
74+
75+
### `TextInput`
76+
77+
```ts
78+
export type NumberInput = InputBase & {
79+
type: FieldTypes.NUMBER
80+
value: number
81+
min: number
82+
max: number
83+
step: number
84+
}
85+
```
86+
87+
### `SelectInput`
88+
89+
```ts
90+
export type SelectInput<T = boolean | string> = InputBase & {
91+
type: FieldTypes.SELECT
92+
value: T
93+
optionValue: string
94+
optionLabel: string
95+
options?: { label: string; value: string; disabled?: boolean }[]
96+
}
97+
```
98+
99+
### `TextAreaInput`
100+
101+
```ts
102+
export type TextAreaInput = InputBase & {
103+
type: FieldTypes.TEXTAREA
104+
value: string
105+
cols?: number
106+
rows?: number
107+
}
108+
```
109+
110+
### `CheckboxInput`
111+
112+
```ts
113+
export type CheckboxInput = InputBase & {
114+
type: FieldTypes.CHECKBOX
115+
value: boolean
116+
}
117+
```
118+
119+
### `RadioInput`
120+
121+
```ts
122+
export type RadioInput = InputBase & {
123+
type: FieldTypes.RADIO
124+
value: string
125+
options?: { key: string; value: string; disabled?: boolean }[]
126+
}
127+
```
128+
129+
### `CustomInput`
130+
131+
```ts
132+
export type CustomInput = InputBase & {
133+
type: FieldTypes.CUSTOM
134+
value: boolean | string | number
135+
}
136+
```
137+
138+
### `EmailInput`
139+
140+
```ts
141+
export type EmailInput = InputBase & {
142+
type: FieldTypes.EMAIL
143+
value: string
144+
}
145+
```
146+
147+
### `PasswordInput`
148+
149+
```ts
150+
export type PasswordInput = InputBase & {
151+
type: FieldTypes.PASSWORD
152+
value: string
153+
}
154+
```
155+
156+
### `ColorInput`
157+
158+
```ts
159+
export type ColorInput = InputBase & {
160+
type: FieldTypes.COLOR
161+
value: string
162+
}
163+
```
164+
165+
### `UrlInput`
166+
167+
```ts
168+
export type UrlInput = InputBase & {
169+
type: FieldTypes.URL
170+
value: string
171+
}
172+
```
173+
174+
## Form
175+
176+
### `FormOptions`
177+
178+
```ts
179+
export interface FormOptions {
180+
customClass?: string | string[] | BindingObject | BindingObject[] | unknown
181+
customStyles?: string | string[] | BindingObject | BindingObject[] | unknown
182+
method?: string
183+
netlify?: boolean
184+
netlifyHoneypot?: string
185+
autocomplete?: boolean | string
186+
resetAfterSubmit?: boolean
187+
}
188+
```
189+
190+
### `DynamicForm`
191+
192+
```ts
193+
export interface DynamicForm {
194+
id: string
195+
fields: FormFields
196+
fieldOrder?: string[]
197+
options?: FormOptions
198+
}
199+
```
200+
201+
## Controls & Validation
202+
203+
### `ValidationTrigger`
204+
205+
```ts
206+
export enum ValidationTriggerTypes {
207+
BLUR = 'blur',
208+
CHANGE = 'change',
209+
}
210+
export interface ValidationTrigger {
211+
type: ValidationTriggerTypes
212+
threshold: number
213+
}
214+
```
215+
216+
### `ValidatorFn`
217+
218+
```ts
219+
export interface ValidatorFn {
220+
(value: ControlValue | undefined): ValidationErrors | null
221+
}
222+
```
223+
224+
### `ValidationErrors`
225+
226+
```ts
227+
export type ValidationErrors = {
228+
// eslint-disable-next-line
229+
[key: string]: any
230+
}
231+
```
232+
233+
### `FormValidator`
234+
235+
```ts
236+
export interface FormValidator {
237+
validator: ValidatorFn
238+
text: string
239+
type?: string
240+
}
241+
```
242+
243+
### `ControlValue`
244+
245+
```ts
246+
export type ControlValue = string | number | boolean
247+
```
248+
249+
### `FormControl`
250+
251+
```ts
252+
export type FormControl<T extends InputType> = T & {
253+
valid: boolean
254+
dirty: boolean
255+
touched: boolean
256+
errors: ValidationErrors | null
257+
}
258+
```

docs/guide/theming/basic.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ If you want a more "ready to go" solution you can import one of the themes we ha
88

99
More themes are in progress.
1010

11-
## Defaul Theme
11+
## Default Theme
1212

1313
Similar to default bootstrap theme for forms.
1414

@@ -31,7 +31,7 @@ $input-border-color: #aec64c;
3131

3232
You have all this variables to customize your form inputs.
3333

34-
Consider that this variables will affect **All** your inputs, for more selective styling please use `customClass` available on the [models](./models.md).
34+
Consider that this variables will affect **All** your inputs, for more selective styling please use `customClass` available on the [models](../models.md).
3535

3636
```scss
3737
$font-family-sans-serif: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
@@ -93,7 +93,7 @@ module.exports = {
9393

9494
You have all this variables to customize your form inputs.
9595

96-
Consider that this variables will affect **All** your inputs, for more selective styling please use `customClass` available on the [models](./models.md).
96+
Consider that this variables will affect **All** your inputs, for more selective styling please use `customClass` available on the [models](../models.md)..
9797

9898
```scss
9999
$theme-color: #6200ee;

docs/netlify.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build]
2+
publish = ".vitepress/dist"
3+
command = "npm run docs:build"
4+
[[redirects]]
5+
from = "/*"
6+
to = "/index.html"
7+
status = 200

tailwind.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// tailwind.config.js
22
module.exports = {
3+
purge: ['./src/**/*.html', './src/**/*.vue', './src/**/*.ts'],
34
theme: {
45
fontFamily: {
56
display: ['Montserrat'],

0 commit comments

Comments
 (0)