@ederzeel/nuxt-schema-form-nightly 0.1.0-29104650.63764c1 → 0.1.0-29104758.61b406e
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { Draft2019 } from 'json-schema-library'
|
|
3
3
|
import SComponent from './Component.vue'
|
|
4
|
-
import { ref, computed, h, resolveComponent
|
|
4
|
+
import { ref, computed, h, resolveComponent } from 'vue'
|
|
5
5
|
import type { TableColumn } from '@nuxt/ui'
|
|
6
6
|
import type { Row } from '@tanstack/vue-table'
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ const props = defineProps<{
|
|
|
14
14
|
description?: string
|
|
15
15
|
jsonSchemaPath: string
|
|
16
16
|
items: PropertiesType
|
|
17
|
-
modelValue: unknown[]
|
|
17
|
+
modelValue: Record<string, unknown>[]
|
|
18
18
|
isRequired: boolean
|
|
19
19
|
minItems?: number
|
|
20
20
|
maxItems?: number
|
|
@@ -38,7 +38,7 @@ type PropertiesType = {
|
|
|
38
38
|
[key: string]: unknown
|
|
39
39
|
}
|
|
40
40
|
const emit = defineEmits(['update:modelValue', 'submit'])
|
|
41
|
-
const onInput = (value:
|
|
41
|
+
const onInput = (value: Record<string, unknown>, index: number) => {
|
|
42
42
|
props.modelValue[index] = value
|
|
43
43
|
emit('update:modelValue', props.modelValue)
|
|
44
44
|
}
|
|
@@ -57,7 +57,6 @@ const values = computed(() => {
|
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
const add = () => {
|
|
60
|
-
console.log('add')
|
|
61
60
|
emit('update:modelValue', [...props.modelValue, schemaObject.value.getTemplate()])
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -75,13 +74,14 @@ const massRemove = () => {
|
|
|
75
74
|
emit('update:modelValue', res)
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
const model = ref({
|
|
77
|
+
const model = ref<{ open: boolean; index: number; value: Record<string, unknown> }>({
|
|
79
78
|
open: false,
|
|
80
|
-
index: 0
|
|
79
|
+
index: 0,
|
|
80
|
+
value: {}
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
const open = (index: number) => {
|
|
84
|
-
model.value = { open: true, index: index }
|
|
84
|
+
model.value = { open: true, index: index, value: structuredClone(values.value[index]) }
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
const massActions = [
|
|
@@ -185,7 +185,7 @@ const expand = ref({
|
|
|
185
185
|
const options = computed(() => {
|
|
186
186
|
let res: {
|
|
187
187
|
modelValue?: any
|
|
188
|
-
|
|
188
|
+
'onUpdate:modelValue'?: (v: any) => void
|
|
189
189
|
expand?: {
|
|
190
190
|
openedRows: any[]
|
|
191
191
|
row: null
|
|
@@ -195,7 +195,7 @@ const options = computed(() => {
|
|
|
195
195
|
|
|
196
196
|
if (props.edit) {
|
|
197
197
|
res.modelValue = selectedRows.value
|
|
198
|
-
|
|
198
|
+
res['onUpdate:modelValue'] = value => (selectedRows.value = value)
|
|
199
199
|
}
|
|
200
200
|
if (props.editInline) {
|
|
201
201
|
res.expand = expand.value
|
|
@@ -214,15 +214,8 @@ const options = computed(() => {
|
|
|
214
214
|
<div>
|
|
215
215
|
<div class="flex justify-between items-center w-full px-4 py-3">
|
|
216
216
|
<div class="flex gap-1.5 items-center">
|
|
217
|
-
<UButton
|
|
218
|
-
|
|
219
|
-
:disabled="maxItems && values.length >= maxItems"
|
|
220
|
-
@click="add"
|
|
221
|
-
icon="i-heroicons-plus"
|
|
222
|
-
trailing
|
|
223
|
-
color="neutral"
|
|
224
|
-
size="xs"
|
|
225
|
-
/>
|
|
217
|
+
<UButton v-if="edit" :disabled="maxItems && values.length >= maxItems" @click="add" icon="i-heroicons-plus"
|
|
218
|
+
trailing color="neutral" size="xs" />
|
|
226
219
|
</div>
|
|
227
220
|
<div class="flex gap-1.5 items-center">
|
|
228
221
|
<UDropdownMenu v-if="selectedRows.length > 0" :items="massActions">
|
|
@@ -231,21 +224,14 @@ const options = computed(() => {
|
|
|
231
224
|
</div>
|
|
232
225
|
</div>
|
|
233
226
|
<UTable v-bind="options" by="__id" :data="values" :columns="columns" class="flex-1">
|
|
234
|
-
<template #expanded="{ row
|
|
227
|
+
<template #expanded="{ row }">
|
|
228
|
+
{{ row }}
|
|
235
229
|
<div class="p-4">
|
|
236
|
-
{
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
:model-value="row.
|
|
240
|
-
|
|
241
|
-
jsonSchemaPath?.length <= 0 ? `properties.${index}` : `${jsonSchemaPath}[${row.index}]`
|
|
242
|
-
"
|
|
243
|
-
v-bind="items"
|
|
244
|
-
:isRequired="false"
|
|
245
|
-
class="mt-4"
|
|
246
|
-
@update:model-value="(event: unknown) => onInput(event, row.index)"
|
|
247
|
-
@submit="() => emit('submit')"
|
|
248
|
-
/>
|
|
230
|
+
<SComponent :id="id.length <= 0 ? `${row.index}` : `${id}[${row.index}].${items.id}`"
|
|
231
|
+
:model-value="row.original" :json-schema-path="jsonSchemaPath?.length <= 0 ? `properties.${row.index}` : `${jsonSchemaPath}[${row.index}]`
|
|
232
|
+
" v-bind="items" :isRequired="false" class="mt-4"
|
|
233
|
+
@update:model-value="(event: Record<string, unknown>) => onInput(event, row.index)"
|
|
234
|
+
@submit="() => emit('submit')" />
|
|
249
235
|
</div>
|
|
250
236
|
</template>
|
|
251
237
|
</UTable>
|
|
@@ -253,20 +239,18 @@ const options = computed(() => {
|
|
|
253
239
|
<UModal v-model:open="model.open">
|
|
254
240
|
<template #content>
|
|
255
241
|
<UCard>
|
|
256
|
-
<SComponent
|
|
257
|
-
:
|
|
258
|
-
|
|
259
|
-
:
|
|
260
|
-
|
|
261
|
-
"
|
|
262
|
-
v-bind="items"
|
|
263
|
-
:isRequired="false"
|
|
264
|
-
class="mt-4"
|
|
265
|
-
@update:model-value="event => onInput(event, model.index)"
|
|
266
|
-
@submit="() => emit('submit')"
|
|
267
|
-
/>
|
|
242
|
+
<SComponent :id="id.length <= 0 ? `${model.index}` : `${id}[0].${items.id}`" :model-value="model.value"
|
|
243
|
+
:json-schema-path="jsonSchemaPath?.length <= 0 ? `properties.${model.index}` : `${jsonSchemaPath}[${model.index}]`
|
|
244
|
+
" v-bind="items" :isRequired="false" class="mt-4"
|
|
245
|
+
@update:model-value="(event: Record<string, unknown>) => (model.value = event)"
|
|
246
|
+
@submit="() => emit('submit')" />
|
|
268
247
|
<template #footer>
|
|
269
|
-
<UButton
|
|
248
|
+
<UButton @click="
|
|
249
|
+
() => {
|
|
250
|
+
onInput(model.value, model.index)
|
|
251
|
+
model.open = false
|
|
252
|
+
}
|
|
253
|
+
">Save</UButton>
|
|
270
254
|
</template>
|
|
271
255
|
</UCard>
|
|
272
256
|
</template>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ederzeel/nuxt-schema-form-nightly",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-29104758.61b406e",
|
|
4
4
|
"description": "A runtime form generator for nuxt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"@nuxt/kit": "^3.15.4",
|
|
53
53
|
"@nuxt/module-builder": "^0.8.4",
|
|
54
54
|
"@nuxt/ui": "^3.0.0",
|
|
55
|
+
"@tanstack/vue-table": "^8.21.3",
|
|
55
56
|
"@types/eslint": "^9.6.1",
|
|
56
57
|
"eslint": "^9.19.0",
|
|
57
58
|
"eslint-config-prettier": "^10.0.1",
|