@koumoul/vjsf 4.2.0 → 4.3.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 +3 -3
- package/src/components/nodes/list.vue +10 -2
- package/src/components/nodes/one-of-select.vue +8 -4
- package/src/composables/use-dnd.js +9 -2
- package/src/composables/use-vjsf.js +3 -1
- package/types/components/nodes/list.vue.d.ts.map +1 -1
- package/types/components/nodes/one-of-select.vue.d.ts.map +1 -1
- package/types/composables/use-dnd.d.ts +1 -1
- package/types/composables/use-dnd.d.ts.map +1 -1
- package/types/composables/use-vjsf.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koumoul/vjsf",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "Generate forms for the vuetify UI library (vuejs) based on annotated JSON schemas.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test-tz1": "TZ=Europe/Paris vitest run",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"vuetify": "^4.0.0"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@json-layout/core": "~2.
|
|
82
|
-
"@json-layout/vocabulary": "~2.
|
|
81
|
+
"@json-layout/core": "~2.7.0",
|
|
82
|
+
"@json-layout/vocabulary": "~2.13.0",
|
|
83
83
|
"@vueuse/core": "^12.5.0",
|
|
84
84
|
"debug": "^4.3.4"
|
|
85
85
|
},
|
|
@@ -106,6 +106,14 @@ const buttonDensity = computed(() => {
|
|
|
106
106
|
return options.value.density
|
|
107
107
|
})
|
|
108
108
|
|
|
109
|
+
const menuActions = computed(() => {
|
|
110
|
+
return layout.value.listActions.filter(a => {
|
|
111
|
+
if (a === 'add' || a === 'paste') return false
|
|
112
|
+
if (a === 'edit' && layout.value.listEditMode === 'inline') return false
|
|
113
|
+
return true
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
|
|
109
117
|
const itemTitles = computed(() => {
|
|
110
118
|
const expr = props.modelValue.layout.itemTitle
|
|
111
119
|
if (!expr) return null
|
|
@@ -276,7 +284,7 @@ const toggleDialog = (/** @type {boolean} */value) => {
|
|
|
276
284
|
/>
|
|
277
285
|
</v-row>
|
|
278
286
|
<template
|
|
279
|
-
v-if="!modelValue.options.readOnly &&
|
|
287
|
+
v-if="!modelValue.options.readOnly && menuActions.length"
|
|
280
288
|
#append
|
|
281
289
|
>
|
|
282
290
|
<div class="vjsf-list-item-actions-wrapper">
|
|
@@ -316,7 +324,7 @@ const toggleDialog = (/** @type {boolean} */value) => {
|
|
|
316
324
|
/>
|
|
317
325
|
</v-list-item-action>
|
|
318
326
|
<v-list-item-action
|
|
319
|
-
v-else-if="(editedItem === undefined || modelValue.layout.listEditMode === 'menu') &&
|
|
327
|
+
v-else-if="(editedItem === undefined || modelValue.layout.listEditMode === 'menu') && menuActions.length"
|
|
320
328
|
>
|
|
321
329
|
<v-menu
|
|
322
330
|
location="bottom end"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { VRow, VCol } from 'vuetify/components/VGrid'
|
|
3
3
|
import { VSelect } from 'vuetify/components/VSelect'
|
|
4
|
+
import { VAutocomplete } from 'vuetify/components/VAutocomplete'
|
|
4
5
|
import { ref, watch, computed, toRef } from 'vue'
|
|
5
6
|
import { isSection } from '@json-layout/core/state'
|
|
6
7
|
import { isCompObject, isOneOfItemHeader, isOneOfItemChild } from '@json-layout/vocabulary'
|
|
@@ -32,6 +33,7 @@ const { inputProps, localData, skeleton, children } = useNode(
|
|
|
32
33
|
toRef(props, 'modelValue'), props.statefulLayout, { bindData: false }
|
|
33
34
|
)
|
|
34
35
|
const zIndex = useZIndexStack(props.modelValue.fullKey)
|
|
36
|
+
const isAutocomplete = computed(() => !!props.modelValue.layout.autocomplete)
|
|
35
37
|
|
|
36
38
|
/** @type import('vue').Ref<string | undefined> */
|
|
37
39
|
const activeChildTree = ref(undefined)
|
|
@@ -45,9 +47,10 @@ watch(() => children.value?.[0]?.key, () => {
|
|
|
45
47
|
}
|
|
46
48
|
}, { immediate: true })
|
|
47
49
|
|
|
48
|
-
const onChange = (/** @type {string} */childTree) => {
|
|
50
|
+
const onChange = (/** @type {string | null} */childTree) => {
|
|
49
51
|
if (!skeleton.value.childrenTrees) return
|
|
50
|
-
|
|
52
|
+
const index = childTree == null ? -1 : skeleton.value.childrenTrees.indexOf(childTree)
|
|
53
|
+
props.statefulLayout.activateItem(props.modelValue, index)
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
const fieldProps = computed(() => {
|
|
@@ -83,7 +86,8 @@ const fieldProps = computed(() => {
|
|
|
83
86
|
v-if="modelValue.skeleton.childrenTrees"
|
|
84
87
|
cols="12"
|
|
85
88
|
>
|
|
86
|
-
<
|
|
89
|
+
<component
|
|
90
|
+
:is="isAutocomplete ? VAutocomplete : VSelect"
|
|
87
91
|
v-bind="fieldProps"
|
|
88
92
|
:model-value="activeChildTree"
|
|
89
93
|
>
|
|
@@ -112,7 +116,7 @@ const fieldProps = computed(() => {
|
|
|
112
116
|
</template>
|
|
113
117
|
</v-list-item>
|
|
114
118
|
</template>
|
|
115
|
-
</
|
|
119
|
+
</component>
|
|
116
120
|
</v-col>
|
|
117
121
|
<template v-if="modelValue.children?.[0]">
|
|
118
122
|
<node
|
|
@@ -34,15 +34,22 @@ export default function useDnd (array, callback) {
|
|
|
34
34
|
hovered.value = -1
|
|
35
35
|
},
|
|
36
36
|
|
|
37
|
-
// drag the item
|
|
38
|
-
onDragstart: () => {
|
|
37
|
+
// drag the item — only when the user activated drag through the handle (handleBind sets draggable)
|
|
38
|
+
onDragstart: (/** @type {DragEvent} */e) => {
|
|
39
|
+
if (draggable.value !== itemIndex) {
|
|
40
|
+
// a child element (text, link, image, etc.) started a native drag; cancel it
|
|
41
|
+
e.preventDefault()
|
|
42
|
+
return
|
|
43
|
+
}
|
|
39
44
|
dragging.value = itemIndex
|
|
40
45
|
},
|
|
41
46
|
onDragover: () => {
|
|
47
|
+
if (dragging.value === -1) return
|
|
42
48
|
sortableArray.value = moveArrayItem(sortableArray.value, dragging.value, itemIndex)
|
|
43
49
|
dragging.value = itemIndex
|
|
44
50
|
},
|
|
45
51
|
onDragend: () => {
|
|
52
|
+
if (dragging.value === -1) return
|
|
46
53
|
hovered.value = itemIndex
|
|
47
54
|
dragging.value = -1
|
|
48
55
|
callback()
|
|
@@ -67,6 +67,7 @@ export const useVjsf = (schema, modelValue, options, nodeComponents, emit, compi
|
|
|
67
67
|
// cf https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/composables/form.ts
|
|
68
68
|
/** @type {any | null} */
|
|
69
69
|
const form = inject(Symbol.for('vuetify:form'), null)
|
|
70
|
+
const parentVjsf = inject(Symbol.for('vjsf:form'), false)
|
|
70
71
|
const formMemberId = `vjsf-${Math.random().toString(36).substring(2, 9)}`
|
|
71
72
|
if (form) {
|
|
72
73
|
form.register({
|
|
@@ -79,7 +80,7 @@ export const useVjsf = (schema, modelValue, options, nodeComponents, emit, compi
|
|
|
79
80
|
resetValidation: () => statefulLayout.value?.resetValidation(),
|
|
80
81
|
vm: getCurrentInstance()
|
|
81
82
|
})
|
|
82
|
-
} else {
|
|
83
|
+
} else if (!parentVjsf) {
|
|
83
84
|
console.warn('Vjsf should be wrapped in VForm')
|
|
84
85
|
}
|
|
85
86
|
|
|
@@ -88,6 +89,7 @@ export const useVjsf = (schema, modelValue, options, nodeComponents, emit, compi
|
|
|
88
89
|
// registers as a single form member above. Without this, each VInput registers
|
|
89
90
|
// separately, causing VForm to cascade updates to all N fields on every keystroke.
|
|
90
91
|
provide(Symbol.for('vuetify:form'), null)
|
|
92
|
+
provide(Symbol.for('vjsf:form'), true)
|
|
91
93
|
|
|
92
94
|
const slots = useSlots()
|
|
93
95
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.vue.d.ts","sourceRoot":"","sources":["../../../src/components/nodes/list.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.vue.d.ts","sourceRoot":"","sources":["../../../src/components/nodes/list.vue"],"names":[],"mappings":"wBAqnEqB,OAAO,YAAY;;AAdxC;;QAGI,0EAA0E;cAAhE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,YAAY,CAAC;;;;QAKvE,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;;;QAL7E,0EAA0E;cAAhE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,YAAY,CAAC;;;;QAKvE,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;6IAK9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-of-select.vue.d.ts","sourceRoot":"","sources":["../../../src/components/nodes/one-of-select.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"one-of-select.vue.d.ts","sourceRoot":"","sources":["../../../src/components/nodes/one-of-select.vue"],"names":[],"mappings":"wBAkYqB,OAAO,YAAY;;AAdxC;;QAGI,iFAAiF;cAAvE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,mBAAmB,CAAC;;;;QAK9E,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;;;QAL7E,iFAAiF;cAAvE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,mBAAmB,CAAC;;;;QAK9E,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;6IAK9E"}
|
|
@@ -13,7 +13,7 @@ export default function useDnd<T>(array: T[], callback: () => void): {
|
|
|
13
13
|
itemBind: (itemIndex: number, defaultItemProps: Record<string, any>) => {
|
|
14
14
|
onMouseenter: () => void;
|
|
15
15
|
onMouseleave: () => void;
|
|
16
|
-
onDragstart: () => void;
|
|
16
|
+
onDragstart: (e: DragEvent) => void;
|
|
17
17
|
onDragover: () => void;
|
|
18
18
|
onDragend: () => void;
|
|
19
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dnd.d.ts","sourceRoot":"","sources":["../../src/composables/use-dnd.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,+BALa,CAAC,SACH,CAAC,EAAE,YACH,MAAM,IAAI;;;;;;0BAoBU,MAAM,oBAA0B,MAAM,SAAS,GAAG,CAAC
|
|
1
|
+
{"version":3,"file":"use-dnd.d.ts","sourceRoot":"","sources":["../../src/composables/use-dnd.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,+BALa,CAAC,SACH,CAAC,EAAE,YACH,MAAM,IAAI;;;;;;0BAoBU,MAAM,oBAA0B,MAAM,SAAS,GAAG,CAAC;;;yBAWrD,SAAS;;;;4BAqBL,MAAM;;;;EAmBtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-vjsf.d.ts","sourceRoot":"","sources":["../../src/composables/use-vjsf.js"],"names":[],"mappings":"AAcA;IACE;;MAEE;gCADO,GAAG;IAGZ;;MAEE;4BADO,OAAO,aAAa,EAAE,kBAAkB;EAGlD;AAiBM,gCAdI,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,MAAM,CAAC,MAAM,EAAE,OAAO,KAAK,EAAE,SAAS,CAAC,QACvC,GAAG,YACH,cAAc,2BAA2B,EAAE,OAAO,0BAClD,cAAc,2BAA2B,EAAE,qBAAqB,sBAChE,OAAO,KAAK,EAAE,GAA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