@koumoul/vjsf 3.22.1 → 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.1",
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.1.1",
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"
@@ -32,24 +32,31 @@ export default defineComponent({
32
32
  emits: ['update:modelValue'],
33
33
  setup (props, { emit }) {
34
34
  useDefaults({}, 'VjsfListSelectKey')
35
- const vSelectProps = useCompDefaults('VjsfSelectItem-VSelect', { variant: 'outlined', class: 'mt-2' })
35
+ const vSelectProps = useCompDefaults('VjsfIndexedList-VSelect', { variant: 'outlined', class: 'mt-2' })
36
36
  const avatarProps = useCompDefaults('VjsfSelectItem-VAvatar', { rounded: false, size: 'small' })
37
37
 
38
38
  // @ts-ignore
39
39
  const { getItems, selectProps, selectSlots } = useSelectNode(toRef(props, 'listNode'), props.statefulLayout, avatarProps.value, 'v-select')
40
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
+
41
48
  const fieldProps = computed(() => {
42
- const fieldProps = mergePropsLevels([vSelectProps.value, selectProps.value])
43
- fieldProps.label = props.listNode.messages.addItem
49
+ const fieldProps = mergePropsLevels([vSelectProps.value, fixedSelectProps.value])
44
50
  fieldProps.loading = getItems.loading.value
45
51
  fieldProps.items = getItems.items.value
46
52
  delete fieldProps.clearable
47
53
  delete fieldProps['onBlur']
48
54
  fieldProps.rules = props.rules
49
55
  fieldProps.active = false
50
- fieldProps.modelValue = props.modelValue
56
+ if (props.modelValue) fieldProps.modelValue = props.modelValue
57
+ else delete fieldProps.modelValue
51
58
  fieldProps['onUpdate:modelValue'] = (/** @type string */value) => {
52
- emit('update:modelValue', value)
59
+ if (value) emit('update:modelValue', value)
53
60
  }
54
61
  return fieldProps
55
62
  })
@@ -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
- if (layout.value.listEditMode === 'inline-single' || layout.value.listEditMode === 'dialog') {
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
- if (layout.value.listEditMode === 'inline-single') {
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
- if (layout.value.listEditMode === 'inline-single') {
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
- if (layout.value.listEditMode === 'inline-single') {
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) => {
@@ -54,4 +54,8 @@ export default defineComponent({
54
54
  overflow: hidden;
55
55
  mask-image: linear-gradient(180deg, #000 66%, transparent 90%);
56
56
  }
57
+
58
+ .vjsf-readonly textarea {
59
+ pointer-events: auto;
60
+ }
57
61
  </style>