@koumoul/vjsf 3.23.4 → 3.24.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.23.4",
3
+ "version": "3.24.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",
@@ -73,7 +73,7 @@
73
73
  },
74
74
  "dependencies": {
75
75
  "@json-layout/core": "~2.2.1",
76
- "@json-layout/vocabulary": "~2.9.3",
76
+ "@json-layout/vocabulary": "~2.10.1",
77
77
  "@vueuse/core": "^12.5.0",
78
78
  "debug": "^4.3.4"
79
79
  },
@@ -223,6 +223,9 @@ const indexedListRules = computed(() => {
223
223
  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)))]
224
224
  })
225
225
 
226
+ const toggleDialog = (/** @type {boolean} */value) => {
227
+ if (!value) props.statefulLayout.deactivateItem(props.modelValue)
228
+ }
226
229
  </script>
227
230
 
228
231
  <template>
@@ -522,31 +525,35 @@ const indexedListRules = computed(() => {
522
525
  v-bind="vEditDialogProps"
523
526
  :z-index="zIndex"
524
527
  class="vjsf-list-dialog"
528
+ @update:model-value="toggleDialog"
525
529
  >
526
- <v-sheet v-bind="vEditDialogVSheetProps">
527
- <v-toolbar
528
- density="compact"
529
- color="surface"
530
- >
531
- <v-spacer />
532
- <v-btn
533
- :title="modelValue.messages.close"
534
- :icon="options.icons.close"
535
- variant="flat"
536
- density="comfortable"
537
- :disabled="modelValue.loading"
538
- @click="statefulLayout.deactivateItem(modelValue)"
539
- />
540
- </v-toolbar>
541
- <v-row class="ma-0">
542
- <node
543
- v-for="grandChild of isSection(children[children.length - 1]) ? children[children.length - 1].children : [children[children.length - 1]]"
544
- :key="grandChild.fullKey"
545
- :model-value="/** @type import('../../types.js').VjsfNode */(grandChild)"
546
- :stateful-layout="statefulLayout"
547
- />
548
- </v-row>
549
- </v-sheet>
530
+ <template #default="{ isActive }">
531
+ <v-sheet v-bind="vEditDialogVSheetProps">
532
+ <v-toolbar
533
+ density="compact"
534
+ color="surface"
535
+ class="vjsf-list-dialog-toolbar"
536
+ >
537
+ <v-spacer />
538
+ <v-btn
539
+ :title="modelValue.messages.close"
540
+ :icon="options.icons.close"
541
+ variant="flat"
542
+ density="comfortable"
543
+ :disabled="modelValue.loading"
544
+ @click="isActive.value = false"
545
+ />
546
+ </v-toolbar>
547
+ <v-row class="ma-0">
548
+ <node
549
+ v-for="grandChild of isSection(children[children.length - 1]) ? children[children.length - 1].children : [children[children.length - 1]]"
550
+ :key="grandChild.fullKey"
551
+ :model-value="/** @type import('../../types.js').VjsfNode */(grandChild)"
552
+ :stateful-layout="statefulLayout"
553
+ />
554
+ </v-row>
555
+ </v-sheet>
556
+ </template>
550
557
  </v-dialog>
551
558
  </v-list>
552
559
  </v-card>
@@ -3,13 +3,17 @@ import { VRow, VCol } from 'vuetify/components/VGrid'
3
3
  import { VSelect } from 'vuetify/components/VSelect'
4
4
  import { ref, watch, computed, toRef } from 'vue'
5
5
  import { isSection } from '@json-layout/core/state'
6
- import { isCompObject } from '@json-layout/vocabulary'
6
+ import { isCompObject, isOneOfItemHeader, isOneOfItemChild } from '@json-layout/vocabulary'
7
7
  import useNode from '../../composables/use-node.js'
8
8
  import useZIndexStack from '../../composables/use-z-index-stack.js'
9
9
  import Node from '../node.vue'
10
10
  import { useDefaults } from 'vuetify'
11
+ import { VListSubheader, VListItem } from 'vuetify/components/VList'
12
+ import VSelectItemIcon from '../fragments/select-item-icon.vue'
13
+ import useCompDefaults from '../../composables/use-comp-defaults.js'
11
14
 
12
15
  useDefaults({}, 'VjsfOneOfSelect')
16
+ const avatarProps = useCompDefaults('VjsfOneOfSelect-VAvatar', { rounded: false, size: 'small' })
13
17
 
14
18
  const props = defineProps({
15
19
  modelValue: {
@@ -53,16 +57,22 @@ const fieldProps = computed(() => {
53
57
  fieldProps.menuProps = { zIndex }
54
58
  }
55
59
  const items = []
56
- for (const childTreePointer of skeleton.value.childrenTrees || []) {
57
- const childTree = props.statefulLayout.compiledLayout.skeletonTrees[childTreePointer]
58
- const childLayout = props.statefulLayout.compiledLayout.normalizedLayouts[childTree.root]
59
- if (!isCompObject(childLayout) || !childLayout.if || !!props.statefulLayout.evalNodeExpression(props.modelValue, childLayout.if, localData.value)) {
60
- items.push(childTree)
60
+ for (const oneOfItem of props.modelValue.layout.oneOfItems) {
61
+ if (isOneOfItemHeader(oneOfItem)) {
62
+ items.push(oneOfItem)
63
+ } else if (isOneOfItemChild(oneOfItem)) {
64
+ const childTreePointer = (skeleton.value.childrenTrees || [])[oneOfItem.key]
65
+ const childTree = props.statefulLayout.compiledLayout.skeletonTrees[childTreePointer]
66
+ const childLayout = props.statefulLayout.compiledLayout.normalizedLayouts[childTree.root]
67
+ if (!isCompObject(childLayout) || !childLayout.if || !!props.statefulLayout.evalNodeExpression(props.modelValue, childLayout.if, localData.value)) {
68
+ items.push({ ...oneOfItem, value: childTree })
69
+ }
61
70
  }
62
71
  }
63
72
  fieldProps.items = items
64
- fieldProps.itemTitle = 'title'
65
- fieldProps.itemValue = (/** @type {import('@json-layout/core').SkeletonTree} */childTree) => childTree.root
73
+ fieldProps.itemValue = (/** @type {{value: import('@json-layout/core').SkeletonTree}} */item) => {
74
+ return item.value?.root
75
+ }
66
76
  return fieldProps
67
77
  })
68
78
  </script>
@@ -76,7 +86,33 @@ const fieldProps = computed(() => {
76
86
  <v-select
77
87
  v-bind="fieldProps"
78
88
  :model-value="activeChildTree"
79
- />
89
+ >
90
+ <template #item="context">
91
+ <v-list-subheader v-if="context.item.raw.header">
92
+ <v-select-item-icon
93
+ v-if="typeof context.item.raw.icon === 'string'"
94
+ :icon="context.item.raw.icon"
95
+ :avatar-props="avatarProps"
96
+ />
97
+ {{ context.item.raw.title }}
98
+ </v-list-subheader>
99
+ <v-list-item
100
+ v-else
101
+ v-bind="context.props"
102
+ >
103
+ <template
104
+ v-if="context.item.raw.icon"
105
+ #prepend
106
+ >
107
+ <v-select-item-icon
108
+ v-if="typeof context.item.raw.icon === 'string'"
109
+ :icon="context.item.raw.icon"
110
+ :avatar-props="avatarProps"
111
+ />
112
+ </template>
113
+ </v-list-item>
114
+ </template>
115
+ </v-select>
80
116
  </v-col>
81
117
  <template v-if="modelValue.children?.[0]">
82
118
  <node