@kong-ui-public/forms 4.11.17-pr.2064.29cb8e050.0 → 4.11.17-pr.2066.b56908197.0
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 +48 -0
- package/dist/forms.es.js +719 -717
- package/dist/forms.umd.js +2 -2
- package/dist/style.css +1 -1
- package/dist/types/components/FormGenerator.vue.d.ts +1 -1
- package/dist/types/components/FormGroup.vue.d.ts +1 -1
- package/dist/types/components/FormGroup.vue.d.ts.map +1 -1
- package/dist/types/components/fields/FieldArray.vue.d.ts +1 -1
- package/dist/types/components/forms/OIDCForm.vue.d.ts +1 -1
- package/dist/types/composables/useAbstractFields.d.ts +3 -2
- package/dist/types/composables/useAbstractFields.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/form-fields.d.ts +2 -0
- package/dist/types/types/form-fields.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -21,3 +21,51 @@ Here are the steps
|
|
|
21
21
|
|
|
22
22
|
That's it - next time the version of @kong-ui-public/forms is used - your `src/forms/PostFunction.vue` will be presented when user selects `Post Function` plugin to install or edit.
|
|
23
23
|
|
|
24
|
+
## how to add a custom field component
|
|
25
|
+
You can define custom field components to be used for specific fields.
|
|
26
|
+
|
|
27
|
+
For example, the field schema should like this:
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
type: 'array',
|
|
31
|
+
component: CatFoodField, // <== the custom Vue component
|
|
32
|
+
model: 'eats',
|
|
33
|
+
id: 'eats',
|
|
34
|
+
label: 'Eats',
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Please take a look at `sandbox/CatFoodField.vue` for an example of a custom field component.
|
|
39
|
+
|
|
40
|
+
You should have at least the following props, emits and function defined:
|
|
41
|
+
```ts
|
|
42
|
+
const props = defineProps<{
|
|
43
|
+
disabled?: boolean
|
|
44
|
+
formOptions?: Record<string, any>
|
|
45
|
+
model?: Record<string, any>
|
|
46
|
+
schema: Record<string, any>
|
|
47
|
+
vfg: Record<string, any>
|
|
48
|
+
errors?: Array<any>
|
|
49
|
+
hint?: string
|
|
50
|
+
}>()
|
|
51
|
+
|
|
52
|
+
const emit = defineEmits<{
|
|
53
|
+
(event: 'modelUpdated', value: any, model: Record<string, any>): void
|
|
54
|
+
}>()
|
|
55
|
+
|
|
56
|
+
const { clearValidationErrors } = composables.useAbstractFields({
|
|
57
|
+
model: propsRefs.model,
|
|
58
|
+
schema: props.schema,
|
|
59
|
+
formOptions: props.formOptions,
|
|
60
|
+
emitModelUpdated: (data: { value: any, model: Record<string, any> }): void => {
|
|
61
|
+
emit('modelUpdated', data.value, data.model)
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
defineExpose({
|
|
66
|
+
clearValidationErrors,
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`composables.useAbstractFields` is a useful helper that can be used to simplify the implementation of custom field components.
|
|
71
|
+
|