@koumoul/vjsf 3.21.0 → 3.22.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 +2 -2
- package/src/components/fragments/list-select-key.vue +68 -0
- package/src/components/nodes/list.vue +17 -3
- package/src/components/nodes/select.vue +1 -3
- package/src/utils/arrays.js +0 -1
- package/types/components/fragments/list-select-key.vue.d.ts +47 -0
- package/types/components/fragments/list-select-key.vue.d.ts.map +1 -0
- package/types/utils/arrays.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koumoul/vjsf",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.22.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",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"vuetify": "^3.8.12"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@json-layout/core": "~2.1.
|
|
75
|
+
"@json-layout/core": "~2.1.1",
|
|
76
76
|
"@json-layout/vocabulary": "~2.9.0",
|
|
77
77
|
"@vueuse/core": "^12.5.0",
|
|
78
78
|
"debug": "^4.3.4"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { VAutocomplete } from 'vuetify/components/VAutocomplete'
|
|
3
|
+
import { VSelect } from 'vuetify/components/VSelect'
|
|
4
|
+
import { defineComponent, h, computed, toRef } from 'vue'
|
|
5
|
+
import { useDefaults } from 'vuetify'
|
|
6
|
+
import useSelectNode from '../../composables/use-select-node.js'
|
|
7
|
+
import useCompDefaults from '../../composables/use-comp-defaults.js'
|
|
8
|
+
import { mergePropsLevels } from '../../composables/use-node.js'
|
|
9
|
+
|
|
10
|
+
export default defineComponent({
|
|
11
|
+
props: {
|
|
12
|
+
modelValue: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
listNode: {
|
|
17
|
+
/** @type import('vue').PropType<import('../../types.js').VjsfListNode> */
|
|
18
|
+
type: Object,
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
statefulLayout: {
|
|
22
|
+
/** @type import('vue').PropType<import('../../types.js').VjsfStatefulLayout> */
|
|
23
|
+
type: Object,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
rules: {
|
|
27
|
+
/** @type import('vue').PropType<((v: string) => boolean)[]> */
|
|
28
|
+
type: Array,
|
|
29
|
+
required: true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
emits: ['update:modelValue'],
|
|
33
|
+
setup (props, { emit }) {
|
|
34
|
+
useDefaults({}, 'VjsfListSelectKey')
|
|
35
|
+
const vSelectProps = useCompDefaults('VjsfSelectItem-VSelect', { variant: 'outlined', class: 'mt-2' })
|
|
36
|
+
const avatarProps = useCompDefaults('VjsfSelectItem-VAvatar', { rounded: false, size: 'small' })
|
|
37
|
+
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
const { getItems, selectProps, selectSlots } = useSelectNode(toRef(props, 'listNode'), props.statefulLayout, avatarProps.value, 'v-select')
|
|
40
|
+
|
|
41
|
+
const fieldProps = computed(() => {
|
|
42
|
+
const fieldProps = mergePropsLevels([vSelectProps.value, selectProps.value])
|
|
43
|
+
fieldProps.label = props.listNode.messages.addItem
|
|
44
|
+
fieldProps.loading = getItems.loading.value
|
|
45
|
+
fieldProps.items = getItems.items.value
|
|
46
|
+
delete fieldProps.clearable
|
|
47
|
+
delete fieldProps['onBlur']
|
|
48
|
+
fieldProps.rules = props.rules
|
|
49
|
+
fieldProps.active = false
|
|
50
|
+
fieldProps.modelValue = props.modelValue
|
|
51
|
+
fieldProps['onUpdate:modelValue'] = (/** @type string */value) => {
|
|
52
|
+
emit('update:modelValue', value)
|
|
53
|
+
}
|
|
54
|
+
return fieldProps
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const fieldSlots = computed(() => {
|
|
58
|
+
const fieldSlots = { ...selectSlots.value }
|
|
59
|
+
delete fieldSlots.selection
|
|
60
|
+
return fieldSlots
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
return () => h(getItems.items.value.length > 20 ? VAutocomplete : VSelect, fieldProps.value, fieldSlots.value)
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
</script>
|
|
@@ -13,6 +13,7 @@ import { VDialog } from 'vuetify/components/VDialog'
|
|
|
13
13
|
import { VToolbar } from 'vuetify/components/VToolbar'
|
|
14
14
|
import { VForm } from 'vuetify/components/VForm'
|
|
15
15
|
import { VSheet } from 'vuetify/components/VSheet'
|
|
16
|
+
import ListSelectKey from '../fragments/list-select-key.vue'
|
|
16
17
|
import { isSection, getRegexp } from '@json-layout/core/state'
|
|
17
18
|
import { clone } from '@json-layout/core/utils/clone'
|
|
18
19
|
import Node from '../node.vue'
|
|
@@ -207,6 +208,10 @@ const itemBorderColor = computed(() => (/** @type {import('@json-layout/core').S
|
|
|
207
208
|
return 'transparent'
|
|
208
209
|
})
|
|
209
210
|
|
|
211
|
+
const indexedListRules = computed(() => {
|
|
212
|
+
return [(/** @type {string} */v) => !props.modelValue.children.some(c => c.key === v), (/** @type {string} */v) => !v || !!props.modelValue.layout.indexed?.some(pattern => v.match(getRegexp(pattern)))]
|
|
213
|
+
})
|
|
214
|
+
|
|
210
215
|
</script>
|
|
211
216
|
|
|
212
217
|
<template>
|
|
@@ -328,11 +333,11 @@ const itemBorderColor = computed(() => (/** @type {import('@json-layout/core').S
|
|
|
328
333
|
v-bind="vEditMenuProps"
|
|
329
334
|
@update:model-value="value => value || statefulLayout.deactivateItem(modelValue)"
|
|
330
335
|
>
|
|
331
|
-
<template #activator="{props}">
|
|
336
|
+
<template #activator="{props: listItemProps}">
|
|
332
337
|
<v-list-item
|
|
333
338
|
:density="modelValue.options.density"
|
|
334
339
|
base-color="primary"
|
|
335
|
-
v-bind="
|
|
340
|
+
v-bind="listItemProps"
|
|
336
341
|
@click="statefulLayout.activateItem(modelValue, childIndex);"
|
|
337
342
|
>
|
|
338
343
|
<template #prepend>
|
|
@@ -451,12 +456,21 @@ const itemBorderColor = computed(() => (/** @type {import('@json-layout/core').S
|
|
|
451
456
|
style="max-width: 250px;"
|
|
452
457
|
@submit.prevent
|
|
453
458
|
>
|
|
459
|
+
<list-select-key
|
|
460
|
+
v-if="modelValue.layout.getItems ?? modelValue.layout.items"
|
|
461
|
+
v-model="newKey"
|
|
462
|
+
:list-node="modelValue"
|
|
463
|
+
:stateful-layout="statefulLayout"
|
|
464
|
+
:rules="indexedListRules"
|
|
465
|
+
@update:model-value="pushEmptyIndexedItem"
|
|
466
|
+
/>
|
|
454
467
|
<v-text-field
|
|
468
|
+
v-else
|
|
455
469
|
v-model="newKey"
|
|
456
470
|
variant="outlined"
|
|
457
471
|
:placeholder="modelValue.messages.addItem"
|
|
458
472
|
hide-details
|
|
459
|
-
:rules="
|
|
473
|
+
:rules="indexedListRules"
|
|
460
474
|
@keypress.enter="pushEmptyIndexedItem"
|
|
461
475
|
>
|
|
462
476
|
<template #append>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { VSelect } from 'vuetify/components/VSelect'
|
|
3
|
-
import { defineComponent, h, computed, toRef
|
|
3
|
+
import { defineComponent, h, computed, toRef } from 'vue'
|
|
4
4
|
import { useDefaults } from 'vuetify'
|
|
5
5
|
import useSelectNode from '../../composables/use-select-node.js'
|
|
6
6
|
import useCompDefaults from '../../composables/use-comp-defaults.js'
|
|
@@ -32,8 +32,6 @@ export default defineComponent({
|
|
|
32
32
|
return fieldProps
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
watch(() => fieldProps.value.items, () => console.log(fieldProps.value.items))
|
|
36
|
-
|
|
37
35
|
// @ts-ignore
|
|
38
36
|
return () => h(VSelect, fieldProps.value, selectSlots.value)
|
|
39
37
|
}
|
package/src/utils/arrays.js
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
modelValue: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
required: true;
|
|
5
|
+
};
|
|
6
|
+
listNode: {
|
|
7
|
+
/** @type import('vue').PropType<import('../../types.js').VjsfListNode> */
|
|
8
|
+
type: import('vue').PropType<import('../../types.js').VjsfListNode>;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
statefulLayout: {
|
|
12
|
+
/** @type import('vue').PropType<import('../../types.js').VjsfStatefulLayout> */
|
|
13
|
+
type: import('vue').PropType<import('../../types.js').VjsfStatefulLayout>;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
rules: {
|
|
17
|
+
/** @type import('vue').PropType<((v: string) => boolean)[]> */
|
|
18
|
+
type: import("vue").PropType<((v: string) => boolean)[]>;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
24
|
+
modelValue: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
required: true;
|
|
27
|
+
};
|
|
28
|
+
listNode: {
|
|
29
|
+
/** @type import('vue').PropType<import('../../types.js').VjsfListNode> */
|
|
30
|
+
type: import('vue').PropType<import('../../types.js').VjsfListNode>;
|
|
31
|
+
required: true;
|
|
32
|
+
};
|
|
33
|
+
statefulLayout: {
|
|
34
|
+
/** @type import('vue').PropType<import('../../types.js').VjsfStatefulLayout> */
|
|
35
|
+
type: import('vue').PropType<import('../../types.js').VjsfStatefulLayout>;
|
|
36
|
+
required: true;
|
|
37
|
+
};
|
|
38
|
+
rules: {
|
|
39
|
+
/** @type import('vue').PropType<((v: string) => boolean)[]> */
|
|
40
|
+
type: import("vue").PropType<((v: string) => boolean)[]>;
|
|
41
|
+
required: true;
|
|
42
|
+
};
|
|
43
|
+
}>> & Readonly<{
|
|
44
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
45
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
46
|
+
export default _default;
|
|
47
|
+
//# sourceMappingURL=list-select-key.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../../src/utils/arrays.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,mCALW,GAAG,EAAE,GAAG,OAAO,MAAM,EAAE,GAAG,CAAC,aAC3B,MAAM,WACN,MAAM,GACL,GAAG,EAAE,GAAG,OAAO,MAAM,EAAE,GAAG,CAAC,CAMtC;AAED;;;;;GAKG;AACH,oCALW,GAAG,EAAE,aACL,MAAM,WACN,MAAM,GACL,GAAG,EAAE,CAWhB;AAED;;;;;GAKG;AACH,qCALW,OAAO,MAAM,EAAE,GAAG,CAAC,aACnB,MAAM,WACN,MAAM,GACL,OAAO,MAAM,EAAE,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../../src/utils/arrays.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,mCALW,GAAG,EAAE,GAAG,OAAO,MAAM,EAAE,GAAG,CAAC,aAC3B,MAAM,WACN,MAAM,GACL,GAAG,EAAE,GAAG,OAAO,MAAM,EAAE,GAAG,CAAC,CAMtC;AAED;;;;;GAKG;AACH,oCALW,GAAG,EAAE,aACL,MAAM,WACN,MAAM,GACL,GAAG,EAAE,CAWhB;AAED;;;;;GAKG;AACH,qCALW,OAAO,MAAM,EAAE,GAAG,CAAC,aACnB,MAAM,WACN,MAAM,GACL,OAAO,MAAM,EAAE,GAAG,CAAC,CAW9B"}
|