@ederzeel/nuxt-schema-form-nightly 0.1.0-29121840.7b5ed76 → 0.1.0-29140419.4bc9165

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/README.md CHANGED
@@ -14,10 +14,10 @@ Runtime form generation for Nuxt apps.
14
14
 
15
15
  ```ts
16
16
  <script lang="ts" setup>
17
- import { Draft2019 } from 'json-schema-library'
17
+ import { compileSchema } from 'json-schema-library'
18
18
 
19
19
  const schemaObject = ref(
20
- new Draft2019({
20
+ compileSchema({
21
21
  title: 'From',
22
22
  description: 'A minimal form example',
23
23
  type: 'object',
@@ -33,8 +33,8 @@ const schemaObject = ref(
33
33
  })
34
34
  )
35
35
 
36
- const schema = ref(schemaObject.value.rootSchema)
37
- const state = ref(schemaObject.value.getTemplate())
36
+ const schema = ref(schemaObject.value.getNode().node.schema)
37
+ const state = ref(schemaObject.value.getData())
38
38
  </script>
39
39
 
40
40
  <template>
@@ -7,7 +7,7 @@ const props = defineProps<{
7
7
  isRequired: boolean
8
8
  }>()
9
9
 
10
- const value = defineModel<string>({ required: true, default: '' })
10
+ const value = defineModel<string>()
11
11
  </script>
12
12
 
13
13
  <template>
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { Draft2019 } from 'json-schema-library'
2
+ import { compileSchema } from 'json-schema-library'
3
3
  import SComponent from '../Component.vue'
4
4
  import { ref, computed, h, resolveComponent } from 'vue'
5
5
  import type { TableColumn } from '@nuxt/ui'
@@ -38,7 +38,7 @@ const massActions = [
38
38
  ]
39
39
 
40
40
  const selectedRows = ref<{ __id: any }[]>([])
41
- const schemaObject = ref(new Draft2019(props.items))
41
+ const schemaObject = ref(compileSchema(props.items))
42
42
  const model = ref<{ open: boolean; index: number; value: Record<string, unknown> }>({
43
43
  open: false,
44
44
  index: 0,
@@ -53,7 +53,7 @@ const values = computed(() => {
53
53
  if (props.modelValue.length > 0) {
54
54
  return props.modelValue.map((x, i) => ({ ...x, __id: i }))
55
55
  } else if (props.minItems && props.minItems > 0) {
56
- const template = schemaObject.value.getTemplate()
56
+ const template = schemaObject.value.getData()
57
57
  return [...Array(props.minItems)].map((_, i) => ({ ...template, __id: i }))
58
58
  }
59
59
 
@@ -62,6 +62,17 @@ const values = computed(() => {
62
62
 
63
63
  const columns = computed<TableColumn<{}>[]>(() => {
64
64
  const columns = props.columns ?? []
65
+
66
+ if (!props.columns && props.items.type === 'object') {
67
+ for (const column of Object.keys(props?.items?.properties).map<TableColumn<{}>>(x => ({
68
+ header: x,
69
+ accessorKey: x,
70
+ cell: ({ row }) => row.getValue(x)
71
+ }))) {
72
+ columns.push(column)
73
+ }
74
+ }
75
+
65
76
  if (props.editInline) {
66
77
  columns.push({
67
78
  id: 'expand',
@@ -80,16 +91,6 @@ const columns = computed<TableColumn<{}>[]>(() => {
80
91
  })
81
92
  }
82
93
 
83
- if (props.items.type === 'object') {
84
- for (const column of Object.keys(props?.items?.properties).map<TableColumn<{}>>(x => ({
85
- header: x,
86
- accessorKey: x,
87
- cell: ({ row }) => row.getValue(x)
88
- }))) {
89
- columns.push(column)
90
- }
91
- }
92
-
93
94
  if (props.edit) {
94
95
  columns.push({
95
96
  id: 'actions',
@@ -172,7 +173,7 @@ const onInput = (value: Record<string, unknown>, index: number) => {
172
173
  }
173
174
 
174
175
  const add = () => {
175
- emit('update:modelValue', [...props.modelValue, schemaObject.value.getTemplate()])
176
+ emit('update:modelValue', [...props.modelValue, schemaObject.value.getData()])
176
177
  }
177
178
 
178
179
  const remove = (index: number) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ederzeel/nuxt-schema-form-nightly",
3
- "version": "0.1.0-29121840.7b5ed76",
3
+ "version": "0.1.0-29140419.4bc9165",
4
4
  "description": "A runtime form generator for nuxt",
5
5
  "type": "module",
6
6
  "exports": {
@@ -58,7 +58,7 @@
58
58
  "eslint-config-prettier": "^10.0.1",
59
59
  "globals": "^15.14.0",
60
60
  "jiti": "^2.4.2",
61
- "json-schema-library": "10.0.0-rc7",
61
+ "json-schema-library": "10.0.0",
62
62
  "magic-string": "^0.30.17",
63
63
  "mlly": "^1.7.4",
64
64
  "nuxt": "^3.16.0",