@koumoul/vjsf 3.22.0 → 3.22.2
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.22.
|
|
3
|
+
"version": "3.22.2",
|
|
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",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"vuetify": "^3.8.12"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@json-layout/core": "~2.
|
|
75
|
+
"@json-layout/core": "~2.2.1",
|
|
76
76
|
"@json-layout/vocabulary": "~2.9.0",
|
|
77
77
|
"@vueuse/core": "^12.5.0",
|
|
78
78
|
"debug": "^4.3.4"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { VAutocomplete } from 'vuetify/components/VAutocomplete'
|
|
2
3
|
import { VSelect } from 'vuetify/components/VSelect'
|
|
3
4
|
import { defineComponent, h, computed, toRef } from 'vue'
|
|
4
5
|
import { useDefaults } from 'vuetify'
|
|
@@ -31,24 +32,31 @@ export default defineComponent({
|
|
|
31
32
|
emits: ['update:modelValue'],
|
|
32
33
|
setup (props, { emit }) {
|
|
33
34
|
useDefaults({}, 'VjsfListSelectKey')
|
|
34
|
-
const vSelectProps = useCompDefaults('
|
|
35
|
+
const vSelectProps = useCompDefaults('VjsfIndexedList-VSelect', { variant: 'outlined', class: 'mt-2' })
|
|
35
36
|
const avatarProps = useCompDefaults('VjsfSelectItem-VAvatar', { rounded: false, size: 'small' })
|
|
36
37
|
|
|
37
38
|
// @ts-ignore
|
|
38
39
|
const { getItems, selectProps, selectSlots } = useSelectNode(toRef(props, 'listNode'), props.statefulLayout, avatarProps.value, 'v-select')
|
|
39
40
|
|
|
41
|
+
const fixedSelectProps = computed(() => {
|
|
42
|
+
const fixedSelectProps = { ...selectProps.value }
|
|
43
|
+
delete fixedSelectProps.hint
|
|
44
|
+
fixedSelectProps.label = props.listNode.messages.addItem
|
|
45
|
+
return fixedSelectProps
|
|
46
|
+
})
|
|
47
|
+
|
|
40
48
|
const fieldProps = computed(() => {
|
|
41
|
-
const fieldProps = mergePropsLevels([vSelectProps.value,
|
|
42
|
-
fieldProps.label = props.listNode.messages.addItem
|
|
49
|
+
const fieldProps = mergePropsLevels([vSelectProps.value, fixedSelectProps.value])
|
|
43
50
|
fieldProps.loading = getItems.loading.value
|
|
44
51
|
fieldProps.items = getItems.items.value
|
|
45
52
|
delete fieldProps.clearable
|
|
46
53
|
delete fieldProps['onBlur']
|
|
47
54
|
fieldProps.rules = props.rules
|
|
48
55
|
fieldProps.active = false
|
|
49
|
-
fieldProps.modelValue = props.modelValue
|
|
56
|
+
if (props.modelValue) fieldProps.modelValue = props.modelValue
|
|
57
|
+
else delete fieldProps.modelValue
|
|
50
58
|
fieldProps['onUpdate:modelValue'] = (/** @type string */value) => {
|
|
51
|
-
emit('update:modelValue', value)
|
|
59
|
+
if (value) emit('update:modelValue', value)
|
|
52
60
|
}
|
|
53
61
|
return fieldProps
|
|
54
62
|
})
|
|
@@ -60,7 +68,7 @@ export default defineComponent({
|
|
|
60
68
|
})
|
|
61
69
|
|
|
62
70
|
// @ts-ignore
|
|
63
|
-
return () => h(VSelect, fieldProps.value, fieldSlots.value)
|
|
71
|
+
return () => h(getItems.items.value.length > 20 ? VAutocomplete : VSelect, fieldProps.value, fieldSlots.value)
|
|
64
72
|
}
|
|
65
73
|
})
|
|
66
74
|
|
|
@@ -115,12 +115,18 @@ const itemSubtitles = computed(() => {
|
|
|
115
115
|
return sortableArray.value.map((child) => props.statefulLayout.evalNodeExpression(props.modelValue, expr, child.data))
|
|
116
116
|
})
|
|
117
117
|
|
|
118
|
+
const activateOrFocus = (/** @type number | string */childKey) => {
|
|
119
|
+
if (layout.value.listEditMode === 'inline-single' || layout.value.listEditMode === 'dialog') {
|
|
120
|
+
props.statefulLayout.activateItem(props.modelValue, childKey)
|
|
121
|
+
} else {
|
|
122
|
+
props.statefulLayout.focusNode(props.modelValue.fullKey + '/' + childKey)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
118
126
|
const pushEmptyItem = () => {
|
|
119
127
|
const newData = (props.modelValue.data ?? []).concat([undefined])
|
|
120
128
|
props.statefulLayout.input(props.modelValue, newData)
|
|
121
|
-
|
|
122
|
-
props.statefulLayout.activateItem(props.modelValue, newData.length - 1)
|
|
123
|
-
}
|
|
129
|
+
activateOrFocus(newData.length - 1)
|
|
124
130
|
}
|
|
125
131
|
|
|
126
132
|
const newKey = ref('')
|
|
@@ -132,9 +138,7 @@ const pushEmptyIndexedItem = () => {
|
|
|
132
138
|
if (!newKeyForm.value.isValid) return
|
|
133
139
|
const newData = { ...(props.modelValue.data ?? {}), [newKey.value]: undefined }
|
|
134
140
|
props.statefulLayout.input(props.modelValue, newData)
|
|
135
|
-
|
|
136
|
-
props.statefulLayout.activateItem(props.modelValue, Object.keys(newData).length - 1)
|
|
137
|
-
}
|
|
141
|
+
activateOrFocus(newKey.value)
|
|
138
142
|
newKey.value = ''
|
|
139
143
|
newKeyForm.value?.reset()
|
|
140
144
|
}
|
|
@@ -169,9 +173,7 @@ const duplicateItem = (child, childIndex) => {
|
|
|
169
173
|
const newItem = props.modelValue.layout.itemCopy ? props.statefulLayout.evalNodeExpression(props.modelValue, props.modelValue.layout.itemCopy, clone(child.data)) : clone(child.data)
|
|
170
174
|
const newData = [...props.modelValue.data.slice(0, childIndex + 1), newItem, ...props.modelValue.data.slice(childIndex + 1)]
|
|
171
175
|
props.statefulLayout.input(props.modelValue, newData)
|
|
172
|
-
|
|
173
|
-
props.statefulLayout.activateItem(props.modelValue, childIndex + 1)
|
|
174
|
-
}
|
|
176
|
+
activateOrFocus(childIndex + 1)
|
|
175
177
|
menuOpened.value = -1
|
|
176
178
|
}
|
|
177
179
|
|
|
@@ -194,9 +196,7 @@ const pasteItem = (child) => {
|
|
|
194
196
|
const newItem = props.modelValue.layout.itemCopy ? props.statefulLayout.evalNodeExpression(props.modelValue, props.modelValue.layout.itemCopy, clone(copiedItem)) : clone(copiedItem)
|
|
195
197
|
const newData = [...(props.modelValue.data ?? []), newItem]
|
|
196
198
|
props.statefulLayout.input(props.modelValue, newData)
|
|
197
|
-
|
|
198
|
-
props.statefulLayout.activateItem(props.modelValue, newData.length - 1)
|
|
199
|
-
}
|
|
199
|
+
activateOrFocus(newData.length - 1)
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
const itemBorderColor = computed(() => (/** @type {import('@json-layout/core').StateNode} */child, /** @type {number} */childIndex) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-select-key.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fragments/list-select-key.vue.js"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"list-select-key.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fragments/list-select-key.vue.js"],"names":[],"mappings":";;;;;;QAiBM,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;;;;QAK7E,+DAA+D;0CAAzB,MAAM,KAAK,OAAO;;;;;;;;;;;QAVxD,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;;;;QAK7E,+DAA+D;0CAAzB,MAAM,KAAK,OAAO"}
|