@ederzeel/nuxt-schema-form-nightly 0.1.0-29057656.cb4db15 → 0.1.0-29072955.186dab3
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.
|
@@ -4,6 +4,7 @@ import convertToYup from 'json-schema-yup-transformer'
|
|
|
4
4
|
import type { JsonSchema } from 'json-schema-library'
|
|
5
5
|
import { computed, ref } from 'vue'
|
|
6
6
|
import type { Config } from 'json-schema-yup-transformer'
|
|
7
|
+
import type { CustomValidation } from '#schema-form-types'
|
|
7
8
|
|
|
8
9
|
const props = defineProps<{
|
|
9
10
|
schema: JsonSchema
|
|
@@ -24,12 +25,6 @@ const formValidationSchema = computed(() => {
|
|
|
24
25
|
return convertToYup(props.schema, props?.options?.jsonSchemaYupTransfromer ?? {})
|
|
25
26
|
})
|
|
26
27
|
|
|
27
|
-
export type CustomValidation = {
|
|
28
|
-
field: string
|
|
29
|
-
message: string
|
|
30
|
-
validate(state: any): boolean
|
|
31
|
-
}
|
|
32
|
-
|
|
33
28
|
const validateFields = async (fields: string[]) => {
|
|
34
29
|
let allValid = true
|
|
35
30
|
for (const field of fields) {
|
|
@@ -66,13 +61,8 @@ const submit = () => {
|
|
|
66
61
|
<div>
|
|
67
62
|
<!-- {{ formRef ? formRef.errors : undefined }} -->
|
|
68
63
|
<UForm ref="formRef" :state="value" :schema="formValidationSchema" autocomplete="on" @submit="onSubmit">
|
|
69
|
-
<SComponent
|
|
70
|
-
|
|
71
|
-
v-bind="schema"
|
|
72
|
-
:validate-fields="validateFields"
|
|
73
|
-
@submit="submit"
|
|
74
|
-
:isRequired="true"
|
|
75
|
-
/>
|
|
64
|
+
<SComponent v-model="value" v-bind="schema" :validate-fields="validateFields" @submit="submit"
|
|
65
|
+
:isRequired="true" />
|
|
76
66
|
<slot />
|
|
77
67
|
|
|
78
68
|
<slot name="submit">
|
|
@@ -41,13 +41,9 @@ const onSubmit = () => {
|
|
|
41
41
|
|
|
42
42
|
<template>
|
|
43
43
|
<div class="s-form-group">
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
v-model="value"
|
|
48
|
-
:is="typeof renderer === 'string' ? renderer : undefined"
|
|
49
|
-
@submit="onSubmit"
|
|
50
|
-
/>
|
|
44
|
+
<template v-if="renderer != null && renderer === 'none'">test</template>
|
|
45
|
+
<component v-else-if="renderer" v-bind="options" v-model="value"
|
|
46
|
+
:is="typeof renderer === 'string' ? renderer : undefined" @submit="onSubmit" />
|
|
51
47
|
|
|
52
48
|
<SDate v-else-if="type === 'string' && format === 'full-date'" v-bind="options" v-model="value" />
|
|
53
49
|
<SInputNumber v-else-if="type === 'number' || type === 'integer'" v-bind="options" v-model="value" />
|
|
@@ -12,13 +12,12 @@ const value = defineModel<number>({ required: true, default: 0 })
|
|
|
12
12
|
|
|
13
13
|
<template>
|
|
14
14
|
<div>
|
|
15
|
-
<UFormField
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<UInputNumber v-model="value" class="w-full" />
|
|
15
|
+
<UFormField :label="props.title || id" :hint="!props.isRequired ? 'optional' : undefined"
|
|
16
|
+
:description="props.description" :name="props.id">
|
|
17
|
+
<UInputNumber v-model="value" class="w-full" orientation="vertical" :stepSnapping="props.type === 'number'"
|
|
18
|
+
:format-options="{
|
|
19
|
+
minimumFractionDigits: props.type === 'number' ? 1 : undefined
|
|
20
|
+
}" />
|
|
22
21
|
</UFormField>
|
|
23
22
|
</div>
|
|
24
23
|
</template>
|
|
File without changes
|