@ederzeel/nuxt-schema-form-nightly 0.1.0-29104758.61b406e → 0.1.0-29118956.9ee4a3d

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.
@@ -22,14 +22,7 @@ const props = defineProps<{
22
22
  columns?: TableColumn<{}>[]
23
23
  editInline?: boolean
24
24
  }>()
25
-
26
- type ColumnItem = {
27
- key: string
28
- label?: string
29
- header?: string
30
- accessorKey?: string
31
- class?: string
32
- }
25
+ const emit = defineEmits(['update:modelValue', 'submit'])
33
26
 
34
27
  type PropertiesType = {
35
28
  properties: {
@@ -37,13 +30,30 @@ type PropertiesType = {
37
30
  }
38
31
  [key: string]: unknown
39
32
  }
40
- const emit = defineEmits(['update:modelValue', 'submit'])
41
- const onInput = (value: Record<string, unknown>, index: number) => {
42
- props.modelValue[index] = value
43
- emit('update:modelValue', props.modelValue)
44
- }
45
33
 
34
+ const massActions = [
35
+ [
36
+ {
37
+ label: 'delete',
38
+ click: () => {
39
+ massRemove()
40
+ selectedRows.value = []
41
+ }
42
+ }
43
+ ]
44
+ ]
45
+
46
+ const selectedRows = ref<{ __id: any }[]>([])
46
47
  const schemaObject = ref(new Draft2019(props.items))
48
+ const model = ref<{ open: boolean; index: number; value: Record<string, unknown> }>({
49
+ open: false,
50
+ index: 0,
51
+ value: {}
52
+ })
53
+ const expand = ref({
54
+ openedRows: [],
55
+ row: null
56
+ })
47
57
 
48
58
  const values = computed(() => {
49
59
  if (props.modelValue.length > 0) {
@@ -56,46 +66,6 @@ const values = computed(() => {
56
66
  return []
57
67
  })
58
68
 
59
- const add = () => {
60
- emit('update:modelValue', [...props.modelValue, schemaObject.value.getTemplate()])
61
- }
62
-
63
- const remove = (index: number) => {
64
- const res = props.modelValue.splice(index, 1)
65
- emit('update:modelValue', props.modelValue)
66
- }
67
-
68
- const massRemove = () => {
69
- let res = props.modelValue
70
- for (const index of selectedRows.value.map(x => x.__id)) {
71
- res.splice(index, 1)
72
- }
73
-
74
- emit('update:modelValue', res)
75
- }
76
-
77
- const model = ref<{ open: boolean; index: number; value: Record<string, unknown> }>({
78
- open: false,
79
- index: 0,
80
- value: {}
81
- })
82
-
83
- const open = (index: number) => {
84
- model.value = { open: true, index: index, value: structuredClone(values.value[index]) }
85
- }
86
-
87
- const massActions = [
88
- [
89
- {
90
- label: 'delete',
91
- click: () => {
92
- massRemove()
93
- selectedRows.value = []
94
- }
95
- }
96
- ]
97
- ]
98
-
99
69
  const columns = computed<TableColumn<{}>[]>(() => {
100
70
  const columns = props.columns ?? []
101
71
  if (props.editInline) {
@@ -175,13 +145,6 @@ function getRowItems(row: Row<{}>) {
175
145
  ]
176
146
  }
177
147
 
178
- const selectedRows = ref<{ __id: any }[]>([])
179
-
180
- const expand = ref({
181
- openedRows: [],
182
- row: null
183
- })
184
-
185
148
  const options = computed(() => {
186
149
  let res: {
187
150
  modelValue?: any
@@ -204,6 +167,33 @@ const options = computed(() => {
204
167
 
205
168
  return res
206
169
  })
170
+
171
+ const open = (index: number) => {
172
+ model.value = { open: true, index: index, value: structuredClone(values.value[index]) }
173
+ }
174
+
175
+ const onInput = (value: Record<string, unknown>, index: number) => {
176
+ props.modelValue[index] = value
177
+ emit('update:modelValue', props.modelValue)
178
+ }
179
+
180
+ const add = () => {
181
+ emit('update:modelValue', [...props.modelValue, schemaObject.value.getTemplate()])
182
+ }
183
+
184
+ const remove = (index: number) => {
185
+ props.modelValue.splice(index, 1)
186
+ emit('update:modelValue', props.modelValue)
187
+ }
188
+
189
+ const massRemove = () => {
190
+ let res = props.modelValue
191
+ for (const index of selectedRows.value.map(x => x.__id)) {
192
+ res.splice(index, 1)
193
+ }
194
+
195
+ emit('update:modelValue', res)
196
+ }
207
197
  </script>
208
198
 
209
199
  <template>
@@ -41,7 +41,7 @@ const validateFields = async (fields: string[]) => {
41
41
  for (const { field, message, validate } of props.options.customValidation) {
42
42
  if (!fields.includes(field)) continue
43
43
  if (!validate(value.value)) {
44
- const errors = [{ field, message }]
44
+ const errors = [{ name: field, message }]
45
45
  formRef.value.setErrors(errors, field)
46
46
  allValid = false
47
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ederzeel/nuxt-schema-form-nightly",
3
- "version": "0.1.0-29104758.61b406e",
3
+ "version": "0.1.0-29118956.9ee4a3d",
4
4
  "description": "A runtime form generator for nuxt",
5
5
  "type": "module",
6
6
  "exports": {