@koumoul/vjsf 3.1.0 → 3.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koumoul/vjsf",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Generate forms for the vuetify UI library (vuejs) based on annotated JSON schemas.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "vitest",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"vuetify": "^3.6.13"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@json-layout/core": "0.
|
|
73
|
+
"@json-layout/core": "0.35.0",
|
|
74
74
|
"@vueuse/core": "^10.5.0",
|
|
75
75
|
"debug": "^4.3.4"
|
|
76
76
|
},
|
package/src/compat/v2.js
CHANGED
|
@@ -140,6 +140,10 @@ const processFragment = (schema, getJSONRef, schemaId, processed) => {
|
|
|
140
140
|
layout.cols = schema['x-cols']
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
if (schema['x-options']?.hideInArrayItem && !layout.if) {
|
|
144
|
+
layout.if = '!summary'
|
|
145
|
+
}
|
|
146
|
+
|
|
143
147
|
// compact the layout keyword if possible
|
|
144
148
|
if (Object.keys(layout).length === 1 && 'comp' in layout) {
|
|
145
149
|
schema.layout = layout.comp
|
|
@@ -14,6 +14,6 @@ export default function useCompDefaultProps (name, localDefaults = null) {
|
|
|
14
14
|
return computed(() => {
|
|
15
15
|
const componentDefaults = defaults.value?.[name] ?? {}
|
|
16
16
|
if (!localDefaults) return componentDefaults
|
|
17
|
-
return { ...
|
|
17
|
+
return { ...localDefaults, ...componentDefaults }
|
|
18
18
|
})
|
|
19
19
|
}
|
|
@@ -50,9 +50,10 @@ export const useVjsf = (schema, modelValue, options, nodeComponents, emit, compi
|
|
|
50
50
|
// cf https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/composables/form.ts
|
|
51
51
|
/** @type {any | null} */
|
|
52
52
|
const form = inject(Symbol.for('vuetify:form'), null)
|
|
53
|
+
const formMemberId = `vjsf-${Math.random().toString(36).substring(2, 9)}`
|
|
53
54
|
if (form) {
|
|
54
55
|
form.register({
|
|
55
|
-
id:
|
|
56
|
+
id: formMemberId,
|
|
56
57
|
validate: () => {
|
|
57
58
|
statefulLayout.value?.validate()
|
|
58
59
|
return statefulLayout.value?.errors || []
|
|
@@ -61,6 +62,8 @@ export const useVjsf = (schema, modelValue, options, nodeComponents, emit, compi
|
|
|
61
62
|
resetValidation: () => statefulLayout.value?.resetValidation(),
|
|
62
63
|
vm: getCurrentInstance()
|
|
63
64
|
})
|
|
65
|
+
} else {
|
|
66
|
+
console.warn('Vjsf should be wrapped in VForm')
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
const slots = useSlots()
|
|
@@ -77,9 +80,9 @@ export const useVjsf = (schema, modelValue, options, nodeComponents, emit, compi
|
|
|
77
80
|
emit('update:state', statefulLayout)
|
|
78
81
|
if (form) {
|
|
79
82
|
// cf https://vuetifyjs.com/en/components/forms/#validation-state
|
|
80
|
-
if (statefulLayout.valid) form.update(
|
|
81
|
-
else if (statefulLayout.hasHiddenError) form.update(
|
|
82
|
-
else form.update(
|
|
83
|
+
if (statefulLayout.valid) form.update(formMemberId, true, [])
|
|
84
|
+
else if (statefulLayout.hasHiddenError) form.update(formMemberId, null, [])
|
|
85
|
+
else form.update(formMemberId, false, [])
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
/**
|
package/types/compat/v2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../src/compat/v2.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../src/compat/v2.js"],"names":[],"mappings":"AAyMA;;;;;;GAMG;AACH,kCALW,MAAM,+CAEN,MAAM,0BAoBhB;sBAjOqB,KAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-vjsf.d.ts","sourceRoot":"","sources":["../../src/composables/use-vjsf.js"],"names":[],"mappings":"AAaA;IACE;;MAEE;gCADO,GAAG;IAGZ;;MAEE;4BADO,OAAO,aAAa,EAAE,kBAAkB;EAGlD;AAWM,gCARI,OAAO,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,cACzB,OAAO,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,WACtB,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC,kBAClE,OAAO,MAAM,EAAE,OAAO,KAAK,EAAE,SAAS,CAAC,QACvC,GAAG;;;;
|
|
1
|
+
{"version":3,"file":"use-vjsf.d.ts","sourceRoot":"","sources":["../../src/composables/use-vjsf.js"],"names":[],"mappings":"AAaA;IACE;;MAEE;gCADO,GAAG;IAGZ;;MAEE;4BADO,OAAO,aAAa,EAAE,kBAAkB;EAGlD;AAWM,gCARI,OAAO,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,cACzB,OAAO,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,WACtB,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC,kBAClE,OAAO,MAAM,EAAE,OAAO,KAAK,EAAE,SAAS,CAAC,QACvC,GAAG;;;;EA2Ib"}
|