@uniquedj95/vform 2.0.3 → 3.0.3
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/README.md +256 -167
- package/dist/components/inputs/BaseInput.vue.d.ts +5 -6
- package/dist/components/inputs/BaseInput.vue.d.ts.map +1 -1
- package/dist/components/inputs/CheckboxInput.vue.d.ts +2 -3
- package/dist/components/inputs/CheckboxInput.vue.d.ts.map +1 -1
- package/dist/components/inputs/DateInput.vue.d.ts +2 -3
- package/dist/components/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/inputs/EmailInput.vue.d.ts +6 -4
- package/dist/components/inputs/EmailInput.vue.d.ts.map +1 -1
- package/dist/components/inputs/NumberInput.vue.d.ts +6 -4
- package/dist/components/inputs/NumberInput.vue.d.ts.map +1 -1
- package/dist/components/inputs/PasswordInput.vue.d.ts +6 -4
- package/dist/components/inputs/PasswordInput.vue.d.ts.map +1 -1
- package/dist/components/inputs/RepeatInput.vue.d.ts.map +1 -1
- package/dist/components/inputs/SelectInput.vue.d.ts +2 -1
- package/dist/components/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/inputs/TextAreaInput.vue.d.ts +3 -5
- package/dist/components/inputs/TextAreaInput.vue.d.ts.map +1 -1
- package/dist/components/inputs/TextInput.vue.d.ts +6 -4
- package/dist/components/inputs/TextInput.vue.d.ts.map +1 -1
- package/dist/components/shared/InputLabel.vue.d.ts +7 -0
- package/dist/components/shared/InputLabel.vue.d.ts.map +1 -0
- package/dist/components/vForm.vue.d.ts +2 -2
- package/dist/components/vForm.vue.d.ts.map +1 -1
- package/dist/composables/useCheckboxLabelText.d.ts +10 -0
- package/dist/composables/useCheckboxLabelText.d.ts.map +1 -0
- package/dist/composables/useDataTransformation.d.ts +11 -0
- package/dist/composables/useDataTransformation.d.ts.map +1 -0
- package/dist/composables/useFormValidation.d.ts +11 -0
- package/dist/composables/useFormValidation.d.ts.map +1 -0
- package/dist/composables/useInputProps.d.ts +25 -0
- package/dist/composables/useInputProps.d.ts.map +1 -0
- package/dist/composables/useInputValidation.d.ts +16 -0
- package/dist/composables/useInputValidation.d.ts.map +1 -0
- package/dist/composables/useLabelTemplate.d.ts +12 -0
- package/dist/composables/useLabelTemplate.d.ts.map +1 -0
- package/dist/composables/useValidationStyles.d.ts +10 -0
- package/dist/composables/useValidationStyles.d.ts.map +1 -0
- package/dist/constants/index.d.ts +41 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +793 -701
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +10 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/maskito.d.ts +7 -0
- package/dist/utils/maskito.d.ts.map +1 -0
- package/dist/vform.css +1 -1
- package/package.json +48 -3
package/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
A dynamic form builder for Vue.js with Ionic components
|
8
8
|
|
9
|
-
[](https://github.com/uniquedj95/vform/releases)
|
10
10
|
[](https://opensource.org/licenses/MIT)
|
11
11
|
[](https://vuejs.org/)
|
12
12
|
[](https://www.typescriptlang.org/)
|
@@ -14,9 +14,11 @@ A dynamic form builder for Vue.js with Ionic components
|
|
14
14
|
[](https://ionicframework.com/)
|
15
15
|
[](https://bundlephobia.com/package/@uniquedj95/vform)
|
16
16
|
[](https://github.com/uniquedj95/vform/pulls)
|
17
|
+
|
17
18
|
</div>
|
18
19
|
|
19
20
|
## Table of Contents
|
21
|
+
|
20
22
|
- [Overview](#overview)
|
21
23
|
- [Features](#features)
|
22
24
|
- [Installation](#installation)
|
@@ -37,9 +39,11 @@ A dynamic form builder for Vue.js with Ionic components
|
|
37
39
|
- [Contributors](#contributors)
|
38
40
|
|
39
41
|
## Overview
|
42
|
+
|
40
43
|
vForm is a Vue.js component that dynamically generates forms based on a provided schema. It leverages Ionic components for a responsive and mobile-friendly design, supporting complex forms with conditional rendering and validation logic. It provides a robust and flexible form-building solution for Vue.js applications, allowing for a high degree of customization and control over the form behavior and appearance.
|
41
44
|
|
42
45
|
## Features
|
46
|
+
|
43
47
|
- **Dynamic Form Generation**: Create forms dynamically based on a schema definition.
|
44
48
|
- **Conditional Field Rendering**: Fields can be shown or hidden based on other form values.
|
45
49
|
- **Responsive Grid Layout**: Utilizes Ionic Grid for a responsive design that works across different screen sizes.
|
@@ -59,16 +63,19 @@ vForm is a Vue.js component that dynamically generates forms based on a provided
|
|
59
63
|
1. Install the package using your preferred package manager:
|
60
64
|
|
61
65
|
Using NPM:
|
66
|
+
|
62
67
|
```sh
|
63
68
|
npm install @uniquedj95/vform
|
64
69
|
```
|
65
|
-
|
70
|
+
|
66
71
|
Using Yarn:
|
72
|
+
|
67
73
|
```sh
|
68
74
|
yarn add @uniquedj95/vform
|
69
75
|
```
|
70
76
|
|
71
77
|
2. Make sure you have the required peer dependencies:
|
78
|
+
|
72
79
|
- Vue 3.5+
|
73
80
|
- Ionic Vue (for UI components)
|
74
81
|
|
@@ -83,227 +90,239 @@ vForm is a Vue.js component that dynamically generates forms based on a provided
|
|
83
90
|
```
|
84
91
|
|
85
92
|
## Usage
|
93
|
+
|
86
94
|
1. Register `VForm` component in your Vue.js application:
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
95
|
+
|
96
|
+
```typescript
|
97
|
+
// src/main.ts
|
98
|
+
import { createApp, Plugin } from 'vue';
|
99
|
+
import App from './App.vue';
|
100
|
+
import router from './router';
|
101
|
+
import { IonicVue } from '@ionic/vue';
|
102
|
+
import { VForm } from '@uniquedj95/vform';
|
103
|
+
|
104
|
+
/* Import CSS styles and other components here */
|
105
|
+
import '@uniquedj95/vform/vform.css';
|
106
|
+
|
107
|
+
const app = createApp(App)
|
108
|
+
.use(IonicVue)
|
109
|
+
.use(VForm as Plugin)
|
110
|
+
.use(router);
|
111
|
+
|
112
|
+
router.isReady().then(() => {
|
113
|
+
app.mount('#app');
|
114
|
+
});
|
115
|
+
```
|
107
116
|
|
108
117
|
2. Use the component in your template:
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
118
|
+
|
119
|
+
```vue
|
120
|
+
<template>
|
121
|
+
<v-form :schema="formSchema" button-placement="end" @submit="onSubmit" />
|
122
|
+
</template>
|
123
|
+
|
124
|
+
<script setup lang="ts">
|
125
|
+
import { reactive } from 'vue';
|
126
|
+
import { FormSchema, FormData, ComputedData } from '@uniquedj95/vform';
|
127
|
+
|
128
|
+
const formSchema = reactive<FormSchema>({
|
129
|
+
// Define your form schema here
|
130
|
+
fieldId: {
|
131
|
+
type: 'TextInput', // or other InputType
|
132
|
+
label: 'Field Label',
|
133
|
+
placeholder: 'Enter a value',
|
134
|
+
required: true,
|
135
|
+
// additional field configuration options
|
136
|
+
},
|
137
|
+
// Additional fields
|
138
|
+
});
|
139
|
+
|
140
|
+
function onSubmit(data: FormData, computedData: ComputedData) {
|
141
|
+
console.log(data, computedData);
|
142
|
+
}
|
143
|
+
</script>
|
144
|
+
```
|
135
145
|
|
136
146
|
## Schema Structure
|
147
|
+
|
137
148
|
The schema object should define the structure of the form. Each key in the schema represents a form field with its configuration.
|
138
149
|
|
139
150
|
### Example Schema
|
151
|
+
|
140
152
|
```typescript
|
141
153
|
const formSchema: FormSchema = {
|
142
154
|
firstName: {
|
143
155
|
type: 'TextInput',
|
144
156
|
label: 'First Name',
|
145
157
|
required: true,
|
146
|
-
grid: { xs: '12', md: '6' }
|
158
|
+
grid: { xs: '12', md: '6' },
|
147
159
|
},
|
148
160
|
lastName: {
|
149
161
|
type: 'TextInput',
|
150
162
|
label: 'Last Name',
|
151
163
|
required: true,
|
152
|
-
grid: { xs: '12', md: '6' }
|
164
|
+
grid: { xs: '12', md: '6' },
|
153
165
|
},
|
154
166
|
birthDate: {
|
155
167
|
type: 'DateInput',
|
156
168
|
label: 'Date of Birth',
|
157
169
|
required: true,
|
158
|
-
pattern: 'DD/MMM/YYYY'
|
170
|
+
pattern: 'DD/MMM/YYYY',
|
159
171
|
},
|
160
172
|
email: {
|
161
173
|
type: 'EmailInput',
|
162
174
|
label: 'Email Address',
|
163
175
|
required: true,
|
164
|
-
validation:
|
176
|
+
validation: value => {
|
165
177
|
if (!value.includes('@')) {
|
166
178
|
return ['Invalid email format'];
|
167
179
|
}
|
168
180
|
return null;
|
169
|
-
}
|
181
|
+
},
|
170
182
|
},
|
171
183
|
category: {
|
172
184
|
type: 'SelectInput',
|
173
185
|
label: 'Category',
|
174
186
|
options: [
|
175
187
|
{ label: 'Option 1', value: '1' },
|
176
|
-
{
|
177
|
-
|
188
|
+
{
|
189
|
+
label: 'Option 2',
|
190
|
+
value: '2',
|
191
|
+
description: { text: 'With an explanation', color: 'secondary', show: 'always' },
|
192
|
+
},
|
193
|
+
],
|
178
194
|
},
|
179
195
|
notes: {
|
180
196
|
type: 'TextAreaInput',
|
181
197
|
label: 'Notes',
|
182
198
|
rows: 4,
|
183
|
-
autoGrow: true
|
184
|
-
}
|
199
|
+
autoGrow: true,
|
200
|
+
},
|
185
201
|
};
|
186
202
|
```
|
187
203
|
|
188
204
|
### Field Configuration Options
|
189
205
|
|
190
206
|
#### Input Types
|
207
|
+
|
191
208
|
The following input types are supported:
|
192
209
|
|
193
|
-
| Type
|
194
|
-
|
195
|
-
| `TextInput`
|
196
|
-
| `DateInput`
|
197
|
-
| `NumberInput`
|
198
|
-
| `EmailInput`
|
210
|
+
| Type | Description |
|
211
|
+
| --------------- | -------------------------------------------- |
|
212
|
+
| `TextInput` | Standard text input field |
|
213
|
+
| `DateInput` | Date picker with customizable format |
|
214
|
+
| `NumberInput` | Numeric input field |
|
215
|
+
| `EmailInput` | Input field with email validation |
|
199
216
|
| `PasswordInput` | Secure password input with toggle visibility |
|
200
|
-
| `TextAreaInput` | Multi-line text input
|
201
|
-
| `SelectInput`
|
202
|
-
| `CheckboxInput` | Toggle on/off input
|
203
|
-
| `RepeatInput`
|
217
|
+
| `TextAreaInput` | Multi-line text input |
|
218
|
+
| `SelectInput` | Dropdown selection |
|
219
|
+
| `CheckboxInput` | Toggle on/off input |
|
220
|
+
| `RepeatInput` | Repeatable group of fields |
|
204
221
|
|
205
222
|
#### Common Properties
|
206
223
|
|
207
|
-
| Property
|
208
|
-
|
209
|
-
| `label`
|
210
|
-
| `placeholder`
|
211
|
-
| `required`
|
212
|
-
| `disabled`
|
213
|
-
| `hidden`
|
214
|
-
| `autoFocus`
|
215
|
-
| `error`
|
216
|
-
| `fill`
|
217
|
-
| `labelPlacement` | `"stacked" \| "start" \| "end" \| "fixed" \| "floating"` | Determines the position of the label
|
224
|
+
| Property | Type | Description | Applies To |
|
225
|
+
| ---------------- | -------------------------------------------------------- | ------------------------------------------------------- | ----------------- |
|
226
|
+
| `label` | `string` | The label displayed for the form field | All |
|
227
|
+
| `placeholder` | `string` | Placeholder text for the input field | Text-based inputs |
|
228
|
+
| `required` | `boolean` | Determines if the field is required for form submission | All |
|
229
|
+
| `disabled` | `boolean` | Disables the input field if set to `true` | All |
|
230
|
+
| `hidden` | `boolean` | Hides the field completely if set to `true` | All |
|
231
|
+
| `autoFocus` | `boolean` | Automatically focuses the input field on form load | All |
|
232
|
+
| `error` | `string` | Custom error message for the field | All |
|
233
|
+
| `fill` | `"solid" \| "outline"` | Defines the fill style of the input field | All |
|
234
|
+
| `labelPlacement` | `"stacked" \| "start" \| "end" \| "fixed" \| "floating"` | Determines the position of the label | All |
|
218
235
|
|
219
236
|
#### Layout Properties
|
220
237
|
|
221
|
-
| Property | Type
|
222
|
-
|
223
|
-
| `grid`
|
224
|
-
| `icon`
|
225
|
-
| `prefix` | `string`
|
226
|
-
| `suffix` | `string`
|
238
|
+
| Property | Type | Description |
|
239
|
+
| -------- | ---------- | ------------------------------------------------------------- |
|
240
|
+
| `grid` | `GridSize` | Specifies responsive grid sizes: `xs`, `sm`, `md`, `lg`, `xl` |
|
241
|
+
| `icon` | `string` | Icon to display within the input field |
|
242
|
+
| `prefix` | `string` | Text to display before the input value |
|
243
|
+
| `suffix` | `string` | Text to display after the input value |
|
227
244
|
|
228
245
|
#### Validation and Dynamic Behavior
|
229
246
|
|
230
|
-
| Property
|
231
|
-
|
232
|
-
| `validation`
|
233
|
-
| `condition`
|
234
|
-
| `computedValue` | `ComputedValueHandler` | Function to compute derived values: `(value: FormValue, schema: FormSchema) => Promise<any> \| any`
|
235
|
-
| `onChange`
|
247
|
+
| Property | Type | Description |
|
248
|
+
| --------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
249
|
+
| `validation` | `FormValidator` | Custom validation function: `(value: FormValue, schema?: FormSchema) => Promise<Array<string> \| null> \| Array<string> \| null>` |
|
250
|
+
| `condition` | `Function` | Function to determine if field should be rendered: `(data: FormData, computedData: ComputedData) => boolean` |
|
251
|
+
| `computedValue` | `ComputedValueHandler` | Function to compute derived values: `(value: FormValue, schema: FormSchema) => Promise<any> \| any` |
|
252
|
+
| `onChange` | `Function` | Function triggered on field value changes: `(value: FormValue) => FormValue` |
|
236
253
|
|
237
254
|
#### Text Input Properties
|
238
255
|
|
239
|
-
| Property
|
240
|
-
|
241
|
-
| `minLength` | `number` | Minimum text length
|
242
|
-
| `maxLength` | `number` | Maximum text length
|
243
|
-
| `pattern`
|
256
|
+
| Property | Type | Description | Applies To |
|
257
|
+
| ----------- | -------- | ----------------------------------------- | ----------------- |
|
258
|
+
| `minLength` | `number` | Minimum text length | Text-based inputs |
|
259
|
+
| `maxLength` | `number` | Maximum text length | Text-based inputs |
|
260
|
+
| `pattern` | `string` | Regular expression pattern for validation | Text-based inputs |
|
244
261
|
|
245
262
|
#### Number Input Properties
|
246
263
|
|
247
|
-
| Property | Type
|
248
|
-
|
249
|
-
| `min`
|
250
|
-
| `max`
|
264
|
+
| Property | Type | Description |
|
265
|
+
| -------- | ------------------ | ------------- |
|
266
|
+
| `min` | `number \| string` | Minimum value |
|
267
|
+
| `max` | `number \| string` | Maximum value |
|
251
268
|
|
252
269
|
#### TextArea Properties
|
253
270
|
|
254
|
-
| Property
|
255
|
-
|
256
|
-
| `rows`
|
257
|
-
| `cols`
|
271
|
+
| Property | Type | Description |
|
272
|
+
| ---------- | --------- | -------------------------------------------- |
|
273
|
+
| `rows` | `number` | Number of visible text lines |
|
274
|
+
| `cols` | `number` | Visible width in characters |
|
258
275
|
| `autoGrow` | `boolean` | Automatic height adjustment based on content |
|
259
|
-
| `counter`
|
276
|
+
| `counter` | `boolean` | Show character counter |
|
260
277
|
|
261
278
|
#### Date Input Properties
|
262
279
|
|
263
|
-
| Property
|
264
|
-
|
265
|
-
| `pattern`
|
280
|
+
| Property | Type | Description |
|
281
|
+
| ------------ | --------- | ------------------------------------------- |
|
282
|
+
| `pattern` | `string` | Date format pattern (e.g., "DD/MMM/YYYY") |
|
266
283
|
| `enableTime` | `boolean` | Enable time picker alongside date selection |
|
267
284
|
|
268
285
|
#### Select Input Properties
|
269
286
|
|
270
|
-
| Property
|
271
|
-
|
272
|
-
| `options`
|
273
|
-
| `multiple`
|
274
|
-
| `interface`
|
275
|
-
| `optionsPlacement` | `"top" \| "bottom"`
|
287
|
+
| Property | Type | Description |
|
288
|
+
| ------------------ | ---------------------------------------- | ---------------------------------------------- |
|
289
|
+
| `options` | `FormOptions` | Array of options or function returning options |
|
290
|
+
| `multiple` | `boolean` | Allow multiple selections |
|
291
|
+
| `interface` | `"popover" \| "action-sheet" \| "alert"` | How select options are displayed |
|
292
|
+
| `optionsPlacement` | `"top" \| "bottom"` | Position of popover options list |
|
276
293
|
|
277
294
|
#### RepeatInput Properties
|
278
295
|
|
279
|
-
| Property
|
280
|
-
|
296
|
+
| Property | Type | Description |
|
297
|
+
| ---------- | ------------ | ------------------------------------- |
|
281
298
|
| `children` | `FormSchema` | Schema for the repeatable field group |
|
282
299
|
|
283
300
|
### Form Events
|
284
301
|
|
285
|
-
| Event
|
286
|
-
|
302
|
+
| Event | Description | Signature |
|
303
|
+
| -------- | ---------------------------------------------------------------- | -------------------------------------------------------------- |
|
287
304
|
| `submit` | Emitted when the form is submitted successfully after validation | `(formData: FormData, computedFormData: ComputedData) => void` |
|
288
|
-
| `clear`
|
289
|
-
| `cancel` | Emitted when the form submission is canceled, resetting fields
|
305
|
+
| `clear` | Emitted when the form fields are cleared to their initial state | `() => void` |
|
306
|
+
| `cancel` | Emitted when the form submission is canceled, resetting fields | `() => void` |
|
290
307
|
|
291
308
|
### Form Methods
|
292
309
|
|
293
310
|
When accessing the VForm via a template ref, you can utilize these methods:
|
294
311
|
|
295
|
-
| Method
|
296
|
-
|
297
|
-
| `resetForm()`
|
298
|
-
| `isFormValid()` | Validates all form fields and returns validation state | `Promise<boolean>`
|
299
|
-
| `resolveData()` | Returns the current form data and computed data
|
312
|
+
| Method | Description | Return Type |
|
313
|
+
| --------------- | ------------------------------------------------------ | ---------------------------------------------------- |
|
314
|
+
| `resetForm()` | Resets all form fields to their initial state | `void` |
|
315
|
+
| `isFormValid()` | Validates all form fields and returns validation state | `Promise<boolean>` |
|
316
|
+
| `resolveData()` | Returns the current form data and computed data | `{ formData: FormData, computedData: ComputedData }` |
|
300
317
|
|
301
318
|
### Advanced Components
|
302
319
|
|
303
320
|
#### SelectInput
|
321
|
+
|
304
322
|
The SelectInput component provides various display modes for selection options:
|
305
323
|
|
306
324
|
- **Popover Interface**: Default presentation that displays options in a dropdown.
|
325
|
+
|
307
326
|
```js
|
308
327
|
{
|
309
328
|
type: 'SelectInput',
|
@@ -323,7 +342,6 @@ The SelectInput component provides various display modes for selection options:
|
|
323
342
|
options: [...]
|
324
343
|
}
|
325
344
|
```
|
326
|
-
|
327
345
|
- **Alert Interface**: Displays options in a modal dialog.
|
328
346
|
```js
|
329
347
|
{
|
@@ -335,6 +353,7 @@ The SelectInput component provides various display modes for selection options:
|
|
335
353
|
```
|
336
354
|
|
337
355
|
#### Custom Buttons
|
356
|
+
|
338
357
|
You can add custom action buttons to the form with the `customButtons` prop:
|
339
358
|
|
340
359
|
```js
|
@@ -344,12 +363,13 @@ const customButtons = [
|
|
344
363
|
icon: 'save',
|
345
364
|
fill: 'outline',
|
346
365
|
color: 'secondary',
|
347
|
-
action: () => saveDraft()
|
348
|
-
}
|
366
|
+
action: () => saveDraft(),
|
367
|
+
},
|
349
368
|
];
|
350
369
|
```
|
351
370
|
|
352
371
|
#### RepeatInput
|
372
|
+
|
353
373
|
The RepeatInput component allows for creating repeatable groups of fields:
|
354
374
|
|
355
375
|
```js
|
@@ -374,6 +394,7 @@ The RepeatInput component allows for creating repeatable groups of fields:
|
|
374
394
|
Each repeated set includes add and remove buttons, allowing the user to dynamically create or delete instances of the field group.
|
375
395
|
|
376
396
|
#### Option Descriptions
|
397
|
+
|
377
398
|
When using SelectInput or CheckboxInput, you can add descriptions to options:
|
378
399
|
|
379
400
|
```js
|
@@ -381,8 +402,8 @@ When using SelectInput or CheckboxInput, you can add descriptions to options:
|
|
381
402
|
type: 'SelectInput',
|
382
403
|
label: 'Subscription Plan',
|
383
404
|
options: [
|
384
|
-
{
|
385
|
-
label: 'Basic',
|
405
|
+
{
|
406
|
+
label: 'Basic',
|
386
407
|
value: 'basic',
|
387
408
|
description: {
|
388
409
|
text: 'Free plan with limited features',
|
@@ -390,8 +411,8 @@ When using SelectInput or CheckboxInput, you can add descriptions to options:
|
|
390
411
|
show: 'always' // or 'onChecked' to show only when selected
|
391
412
|
}
|
392
413
|
},
|
393
|
-
{
|
394
|
-
label: 'Premium',
|
414
|
+
{
|
415
|
+
label: 'Premium',
|
395
416
|
value: 'premium',
|
396
417
|
description: {
|
397
418
|
text: 'Full access to all features',
|
@@ -404,44 +425,48 @@ When using SelectInput or CheckboxInput, you can add descriptions to options:
|
|
404
425
|
```
|
405
426
|
|
406
427
|
#### Date Pattern Formatting
|
428
|
+
|
407
429
|
The DateInput component supports various date pattern formats:
|
408
430
|
|
409
|
-
| Pattern | Description
|
410
|
-
|
411
|
-
| DD
|
412
|
-
| D
|
413
|
-
| MMM
|
414
|
-
| MMMM
|
415
|
-
| MM
|
416
|
-
| M
|
417
|
-
| YYYY
|
418
|
-
| YY
|
419
|
-
| HH
|
420
|
-
| mm
|
421
|
-
| ss
|
431
|
+
| Pattern | Description | Example |
|
432
|
+
| ------- | ----------------------------------------------- | ----------------------- |
|
433
|
+
| DD | Day of the month, two digits with leading zeros | 01 to 31 |
|
434
|
+
| D | Day of the month without leading zeros | 1 to 31 |
|
435
|
+
| MMM | Month name, abbreviated | Jan, Feb, Mar, etc. |
|
436
|
+
| MMMM | Month name, full | January, February, etc. |
|
437
|
+
| MM | Month as a number, with leading zeros | 01 to 12 |
|
438
|
+
| M | Month as a number, without leading zeros | 1 to 12 |
|
439
|
+
| YYYY | Year, four digits | 2025 |
|
440
|
+
| YY | Year, two digits | 25 |
|
441
|
+
| HH | Hour, two digits with leading zeros (24-hour) | 00 to 23 |
|
442
|
+
| mm | Minutes, two digits with leading zeros | 00 to 59 |
|
443
|
+
| ss | Seconds, two digits with leading zeros | 00 to 59 |
|
422
444
|
|
423
445
|
Example: `DD/MMM/YYYY HH:mm:ss` would format as `07/Jun/2025 14:30:00`
|
424
446
|
|
425
447
|
### Form Props
|
426
448
|
|
427
|
-
| Property
|
428
|
-
|
429
|
-
| `schema`
|
430
|
-
| `showLabels`
|
431
|
-
| `showClearButton`
|
432
|
-
| `showCancelButton` | `boolean`
|
433
|
-
| `buttonPlacement`
|
434
|
-
| `submitButtonText` | `string`
|
435
|
-
| `clearButtonText`
|
436
|
-
| `cancelButtonText` | `string`
|
437
|
-
| `hideButtons`
|
438
|
-
| `customButtons`
|
449
|
+
| Property | Type | Description | Default |
|
450
|
+
| ------------------ | ------------------------------ | ---------------------------------------------------------------------- | ---------- |
|
451
|
+
| `schema` | `FormSchema` | The schema object defining the form structure and field configurations | _Required_ |
|
452
|
+
| `showLabels` | `boolean` | Determines if labels are displayed for each field | `true` |
|
453
|
+
| `showClearButton` | `boolean` | Controls the visibility of the clear/reset button | `true` |
|
454
|
+
| `showCancelButton` | `boolean` | Controls the visibility of the cancel button | `true` |
|
455
|
+
| `buttonPlacement` | `'start' \| 'middle' \| 'end'` | Specifies the alignment of action buttons within the form | `'start'` |
|
456
|
+
| `submitButtonText` | `string` | Custom text for the submit button | `"Submit"` |
|
457
|
+
| `clearButtonText` | `string` | Custom text for the clear/reset button | `"Reset"` |
|
458
|
+
| `cancelButtonText` | `string` | Custom text for the cancel button | `"Cancel"` |
|
459
|
+
| `hideButtons` | `boolean` | When true, hides all action buttons | `false` |
|
460
|
+
| `customButtons` | `Array<CustomButton>` | Array of custom buttons to add to the form | `[]` |
|
439
461
|
|
440
462
|
## Issue Reporting and Feedback
|
463
|
+
|
441
464
|
If you encounter any issues or have suggestions for improvements, please feel free to report them on the [GitHub Issues page](https://github.com/uniquedj95/vform/issues). Your feedback is invaluable in helping us enhance this project.
|
442
465
|
|
443
466
|
## Contributors
|
467
|
+
|
444
468
|
I welcome contributions from the community! If you'd like to contribute, please follow these steps:
|
469
|
+
|
445
470
|
1. Fork the repository.
|
446
471
|
2. Create a new branch for your feature or bug fix.
|
447
472
|
3. Implement your changes and commit them to your branch.
|
@@ -454,33 +479,97 @@ Thank you to all the [contributors](https://github.com/uniquedj95/vform/graphs/c
|
|
454
479
|
vForm is built with TypeScript and provides complete type definitions for all components and interfaces. Import the types to get full IntelliSense support in your IDE:
|
455
480
|
|
456
481
|
```typescript
|
457
|
-
import {
|
458
|
-
FormSchema,
|
459
|
-
FormData,
|
460
|
-
ComputedData,
|
461
|
-
FormField,
|
482
|
+
import {
|
483
|
+
FormSchema,
|
484
|
+
FormData,
|
485
|
+
ComputedData,
|
486
|
+
FormField,
|
462
487
|
Option,
|
463
|
-
InputType,
|
488
|
+
InputType,
|
464
489
|
FormValidator,
|
465
490
|
ComputedValueHandler,
|
466
491
|
FormOptions,
|
467
492
|
GridSize,
|
468
|
-
CustomButton
|
469
|
-
} from
|
493
|
+
CustomButton,
|
494
|
+
} from '@uniquedj95/vform';
|
470
495
|
```
|
471
496
|
|
472
497
|
When defining your form schema, you can use these types for proper type checking:
|
473
498
|
|
474
499
|
```typescript
|
475
|
-
import { reactive } from
|
476
|
-
import { FormSchema } from
|
500
|
+
import { reactive } from 'vue';
|
501
|
+
import { FormSchema } from '@uniquedj95/vform';
|
477
502
|
|
478
503
|
const myFormSchema = reactive<FormSchema>({
|
479
504
|
// Your form fields here with proper type checking
|
480
505
|
});
|
481
506
|
```
|
482
507
|
|
508
|
+
## Development
|
509
|
+
|
510
|
+
### Setup
|
511
|
+
|
512
|
+
```bash
|
513
|
+
# Install dependencies
|
514
|
+
npm install
|
515
|
+
|
516
|
+
# Run tests
|
517
|
+
npm run test
|
518
|
+
|
519
|
+
# Build for production
|
520
|
+
npm run build
|
521
|
+
```
|
522
|
+
|
523
|
+
### Quality Tools
|
524
|
+
|
525
|
+
vForm uses several tools to ensure code quality:
|
526
|
+
|
527
|
+
- **ESLint**: Enforces code style and detects potential issues
|
528
|
+
|
529
|
+
```bash
|
530
|
+
# Run linting
|
531
|
+
npm run lint
|
532
|
+
```
|
533
|
+
|
534
|
+
- **Prettier**: Formats code consistently
|
535
|
+
|
536
|
+
```bash
|
537
|
+
# Format code
|
538
|
+
npm run format
|
539
|
+
```
|
540
|
+
|
541
|
+
- **Vitest**: Runs unit tests
|
542
|
+
```bash
|
543
|
+
# Run tests
|
544
|
+
npm run test
|
545
|
+
# Run tests with coverage report
|
546
|
+
npm run test:coverage
|
547
|
+
# Run tests in watch mode
|
548
|
+
npm run test:watch
|
549
|
+
```
|
550
|
+
|
551
|
+
### Versioning
|
552
|
+
|
553
|
+
vForm includes scripts to help with versioning:
|
554
|
+
|
555
|
+
```bash
|
556
|
+
# Patch update (0.0.x)
|
557
|
+
npm run version:patch
|
558
|
+
|
559
|
+
# Minor update (0.x.0)
|
560
|
+
npm run version:minor
|
561
|
+
|
562
|
+
# Major update (x.0.0)
|
563
|
+
npm run version:major
|
564
|
+
```
|
565
|
+
|
566
|
+
### Continuous Integration
|
567
|
+
|
568
|
+
This project uses GitHub Actions for CI/CD:
|
569
|
+
|
570
|
+
- Pull requests trigger linting, building, and testing
|
571
|
+
- Releases are automatically published to npm
|
572
|
+
|
483
573
|
## License
|
484
574
|
|
485
575
|
vForm is licensed under the MIT License. See the LICENSE file for more information.
|
486
|
-
|