@koumoul/vjsf 3.0.1 → 3.1.1

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.0.1",
3
+ "version": "3.1.1",
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.33.4",
73
+ "@json-layout/core": "0.34.1",
74
74
  "@vueuse/core": "^10.5.0",
75
75
  "debug": "^4.3.4"
76
76
  },
@@ -27,7 +27,7 @@ export default defineComponent({
27
27
  const fullProps = computed(() => {
28
28
  const fullProps = { ...inputProps.value }
29
29
  fullProps.type = 'number'
30
- fullProps['onUpdate:modelValue'] = (/** @type string */value) => props.statefulLayout.input(props.modelValue, value && Number(value))
30
+ fullProps['onUpdate:modelValue'] = (/** @type string */value) => props.statefulLayout.input(props.modelValue, value ? Number(value) : undefined)
31
31
  fullProps.modelValue = localData.value
32
32
  return fullProps
33
33
  })
@@ -64,7 +64,10 @@ const fieldProps = computed(() => {
64
64
 
65
65
  <template>
66
66
  <v-row>
67
- <v-col v-if="modelValue.skeleton.childrenTrees">
67
+ <v-col
68
+ v-if="modelValue.skeleton.childrenTrees"
69
+ cols="12"
70
+ >
68
71
  <v-select
69
72
  v-bind="fieldProps"
70
73
  :model-value="activeChildTree"
@@ -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 { ...componentDefaults, ...localDefaults }
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: `vjsf-${Math.random().toString(36).substring(2, 9)}`,
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('vjsf', true, [])
81
- else if (statefulLayout.hasHiddenError) form.update('vjsf', null, [])
82
- else form.update('vjsf', false, [])
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
  /**
@@ -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;;;;EAwIb"}
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"}