@koumoul/vjsf 3.20.8 → 3.22.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.20.8",
3
+ "version": "3.22.0",
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,8 +72,8 @@
72
72
  "vuetify": "^3.8.12"
73
73
  },
74
74
  "dependencies": {
75
- "@json-layout/core": "~2.0.0",
76
- "@json-layout/vocabulary": "~2.8.0",
75
+ "@json-layout/core": "~2.1.1",
76
+ "@json-layout/vocabulary": "~2.9.0",
77
77
  "@vueuse/core": "^12.5.0",
78
78
  "debug": "^4.3.4"
79
79
  },
@@ -0,0 +1,67 @@
1
+ <script>
2
+ import { VSelect } from 'vuetify/components/VSelect'
3
+ import { defineComponent, h, computed, toRef } from 'vue'
4
+ import { useDefaults } from 'vuetify'
5
+ import useSelectNode from '../../composables/use-select-node.js'
6
+ import useCompDefaults from '../../composables/use-comp-defaults.js'
7
+ import { mergePropsLevels } from '../../composables/use-node.js'
8
+
9
+ export default defineComponent({
10
+ props: {
11
+ modelValue: {
12
+ type: String,
13
+ required: true
14
+ },
15
+ listNode: {
16
+ /** @type import('vue').PropType<import('../../types.js').VjsfListNode> */
17
+ type: Object,
18
+ required: true
19
+ },
20
+ statefulLayout: {
21
+ /** @type import('vue').PropType<import('../../types.js').VjsfStatefulLayout> */
22
+ type: Object,
23
+ required: true
24
+ },
25
+ rules: {
26
+ /** @type import('vue').PropType<((v: string) => boolean)[]> */
27
+ type: Array,
28
+ required: true
29
+ }
30
+ },
31
+ emits: ['update:modelValue'],
32
+ setup (props, { emit }) {
33
+ useDefaults({}, 'VjsfListSelectKey')
34
+ const vSelectProps = useCompDefaults('VjsfSelectItem-VSelect', { variant: 'outlined', class: 'mt-2' })
35
+ const avatarProps = useCompDefaults('VjsfSelectItem-VAvatar', { rounded: false, size: 'small' })
36
+
37
+ // @ts-ignore
38
+ const { getItems, selectProps, selectSlots } = useSelectNode(toRef(props, 'listNode'), props.statefulLayout, avatarProps.value, 'v-select')
39
+
40
+ const fieldProps = computed(() => {
41
+ const fieldProps = mergePropsLevels([vSelectProps.value, selectProps.value])
42
+ fieldProps.label = props.listNode.messages.addItem
43
+ fieldProps.loading = getItems.loading.value
44
+ fieldProps.items = getItems.items.value
45
+ delete fieldProps.clearable
46
+ delete fieldProps['onBlur']
47
+ fieldProps.rules = props.rules
48
+ fieldProps.active = false
49
+ fieldProps.modelValue = props.modelValue
50
+ fieldProps['onUpdate:modelValue'] = (/** @type string */value) => {
51
+ emit('update:modelValue', value)
52
+ }
53
+ return fieldProps
54
+ })
55
+
56
+ const fieldSlots = computed(() => {
57
+ const fieldSlots = { ...selectSlots.value }
58
+ delete fieldSlots.selection
59
+ return fieldSlots
60
+ })
61
+
62
+ // @ts-ignore
63
+ return () => h(VSelect, fieldProps.value, fieldSlots.value)
64
+ }
65
+ })
66
+
67
+ </script>
@@ -0,0 +1,28 @@
1
+ <script setup>
2
+
3
+ import { VListSubheader } from 'vuetify/components/VList'
4
+ import VSelectItemIcon from './select-item-icon.vue'
5
+
6
+ defineProps({
7
+ item: {
8
+ /** @type import('vue').PropType<import('@json-layout/vocabulary').SelectItemHeader> */
9
+ type: Object,
10
+ required: true
11
+ },
12
+ avatarProps: {
13
+ type: Object,
14
+ required: true
15
+ }
16
+ })
17
+ </script>
18
+
19
+ <template>
20
+ <v-list-subheader>
21
+ <v-select-item-icon
22
+ v-if="typeof item.icon === 'string'"
23
+ :icon="item.icon"
24
+ :avatar-props="avatarProps"
25
+ />
26
+ {{ item.title }}
27
+ </v-list-subheader>
28
+ </template>
@@ -56,7 +56,7 @@ export default defineComponent({
56
56
  } else {
57
57
  modelValue = localData.value === item.value
58
58
  }
59
- checkboxes.push(h(props.type === 'switch' ? VSwitch : VCheckbox, {
59
+ checkboxes.push(h(/** @type {import('vue').Component} */(props.type === 'switch' ? VSwitch : VCheckbox), {
60
60
  label: item.title,
61
61
  hideDetails: true,
62
62
  key: item.key,
@@ -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="props"
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="[(/** @type {string} */v) => !modelValue.children.some(c => c.key === v), v => !v || !!modelValue.layout.indexed?.some(pattern => v.match(getRegexp(pattern)))]"
473
+ :rules="indexedListRules"
460
474
  @keypress.enter="pushEmptyIndexedItem"
461
475
  >
462
476
  <template #append>
@@ -2,6 +2,7 @@ import { computed, h } from 'vue'
2
2
  import useField from './use-node.js'
3
3
  import useGetItems from './use-get-items.js'
4
4
  import SelectItem from '../components/fragments/select-item.vue'
5
+ import SelectItemHeader from '../components/fragments/select-item-header.vue'
5
6
  import SelectSelection from '../components/fragments/select-selection.vue'
6
7
  import useZIndexStack from './use-z-index-stack.js'
7
8
 
@@ -55,12 +56,21 @@ export default function (nodeRef, statefulLayout, avatarProps, cssPrefix) {
55
56
  const selectSlots = computed(() => {
56
57
  const slots = { ...compSlots.value }
57
58
  if (!slots.item) {
58
- slots.item = (/** @type {any} */ context) => h(SelectItem, {
59
- multiple: layout.value.multiple,
60
- itemProps: context.props,
61
- item: context.item.raw,
62
- avatarProps
63
- })
59
+ slots.item = (/** @type {any} */ context) => {
60
+ if (context.item.raw.header) {
61
+ return h(SelectItemHeader, {
62
+ item: context.item.raw,
63
+ avatarProps
64
+ })
65
+ } else {
66
+ return h(SelectItem, {
67
+ multiple: layout.value.multiple,
68
+ itemProps: context.props,
69
+ item: context.item.raw,
70
+ avatarProps
71
+ })
72
+ }
73
+ }
64
74
  }
65
75
  if (!slots.selection) {
66
76
  slots.selection = (/** @type {any} */ context) => h(SelectSelection, {
@@ -41,6 +41,5 @@ export function moveObjectItem (data, fromIndex, toIndex) {
41
41
  for (const key of newKeys) {
42
42
  newData[key] = data[key]
43
43
  }
44
- console.log(newData)
45
44
  return newData
46
45
  }
@@ -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":";;;;;;QAgBM,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"}
@@ -0,0 +1,14 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {
2
+ multiple: boolean;
3
+ itemProps: Record<string, any>;
4
+ item: import("../../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItem;
5
+ avatarProps: Record<string, any>;
6
+ $props: {
7
+ readonly multiple?: boolean | undefined;
8
+ readonly itemProps?: Record<string, any> | undefined;
9
+ readonly item?: import("../../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItem | undefined;
10
+ readonly avatarProps?: Record<string, any> | undefined;
11
+ };
12
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
13
+ export default _default;
14
+ //# sourceMappingURL=select-item%20copy.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-item copy.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fragments/select-item copy.vue.js"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {
2
+ item: import("../../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItemHeader;
3
+ avatarProps: Record<string, any>;
4
+ $props: {
5
+ readonly item?: import("../../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItemHeader | undefined;
6
+ readonly avatarProps?: Record<string, any> | undefined;
7
+ };
8
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
9
+ export default _default;
10
+ //# sourceMappingURL=select-item-header.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-item-header.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fragments/select-item-header.vue.js"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"use-select-node.d.ts","sourceRoot":"","sources":["../../src/composables/use-select-node.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,0CALW,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,aAAa,EAAE,cAAc,CAAC,kBACvD,OAAO,aAAa,EAAE,kBAAkB,eACxC,GAAG,aACH,gBAAgB,GAAG,UAAU;;;;;;;;;;;;;;;;;;;;EAiEvC"}
1
+ {"version":3,"file":"use-select-node.d.ts","sourceRoot":"","sources":["../../src/composables/use-select-node.js"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,0CALW,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,aAAa,EAAE,cAAc,CAAC,kBACvD,OAAO,aAAa,EAAE,kBAAkB,eACxC,GAAG,aACH,gBAAgB,GAAG,UAAU;;;;;;;;;;;;;;;;;;;;EA0EvC"}
@@ -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,CAY9B"}
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"}