Skip to content

Commit

Permalink
feat: adapt to json-layout latest slot support
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed Dec 5, 2024
1 parent d220249 commit 4360d81
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 45 deletions.
3 changes: 2 additions & 1 deletion .zellij.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ layout {
}
}
pane size=2 borderless=true {
plugin location="zellij:status-bar"
command "bash"
args "-ic" "echo -n -e \"Doc dev server available at \\e[1;96mhttp://localhost:3133\\033[0m\""
}
}
2 changes: 1 addition & 1 deletion compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
},
"dependencies": {
"@json-layout/core": "~1.2.2",
"@json-layout/core": "~1.3.0",
"debug": "^4.3.4",
"ejs": "^3.1.9"
},
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'path'
import ejs from 'ejs'
import { compile as compileLayout } from '@json-layout/core'
import { serialize as serializeCompiledLayout } from '@json-layout/core/src/compile/serialize'
import { childIsCompObject, isCompObject, isSwitchStruct } from '@json-layout/vocabulary'
import { childIsCompositeCompObject, isCompObject, isSwitchStruct } from '@json-layout/vocabulary'
import { getFullOptions } from './options.js'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
Expand All @@ -21,7 +21,7 @@ function listComps (comps, layout) {
comps.add(layout.comp)
if (layout.children) {
for (const child of /** @type {import('@json-layout/vocabulary').Children} */(layout.children)) {
if (childIsCompObject(child)) {
if (childIsCompositeCompObject(child)) {
listComps(comps, child)
}
}
Expand Down
2 changes: 1 addition & 1 deletion doc/components/vjsf-example.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
/>
</template>
<template #custom-message="{node}">
This message is defined in a slot (key={{ node.key }})
This message is defined in a slot (key={{ node.key }}, data={{ node.data }})
</template>
</vjsf>
</slot>
Expand Down
23 changes: 0 additions & 23 deletions doc/examples/merged/code-slots.js

This file was deleted.

3 changes: 1 addition & 2 deletions doc/examples/merged/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// merge some info into the JSON layout standard examples

import codeSlots from './code-slots.js'
// import imgCropper from './img-cropper.js'

/** @type {Record<string, import("@json-layout/examples").JSONLayoutExample[]>} */
export const additionalExamples = {
slots: [codeSlots]
// slots: [codeSlots]
// files: [imgCropper]
}

Expand Down
2 changes: 1 addition & 1 deletion doc/examples/slot-codes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const codes = {
</template>`,
'custom-message': `
<template #custom-message="{node, statefulLayout}">
This message is defined in a slot (key={{ node.key }})
This message is defined in a slot (key={{ node.key }}, data={{ node.data }})
</template>`
}

Expand Down
8 changes: 7 additions & 1 deletion doc/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export default defineNuxtConfig({
ssr: false,
css: ['vuetify/styles'],

app: {
header: {
link: [{ rel: 'icon', type: 'image/x-icon', href: targetURL.pathname + 'favicon.ico' }]
}
},

vite: {
vue: {
template: {
Expand Down Expand Up @@ -92,4 +98,4 @@ export default defineNuxtConfig({
},

compatibilityDate: '2024-07-22'
})
})
2 changes: 1 addition & 1 deletion doc/pages/editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
/>
</template>
<template #custom-message="{node}">
This message is defined in a slot (key={{ node.key }})
This message is defined in a slot (key={{ node.key }}, data={{ node.data }})
</template>
</vjsf>
<v-row class="ma-0">
Expand Down
Binary file added doc/public/favicon.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@koumoul/vjsf",
"version": "3.5.1",
"version": "3.6.0",
"description": "Generate forms for the vuetify UI library (vuejs) based on annotated JSON schemas.",
"scripts": {
"test": "vitest",
Expand Down Expand Up @@ -70,7 +70,7 @@
"vuetify": "^3.6.13"
},
"dependencies": {
"@json-layout/core": "~1.2.2",
"@json-layout/core": "~1.3.0",
"@vueuse/core": "^10.5.0",
"debug": "^4.3.4"
},
Expand Down
14 changes: 7 additions & 7 deletions lib/src/components/node.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const nodeClasses = computed(() => {
return classes
})
if (props.modelValue.layout.comp !== 'none' && !props.statefulLayout.options.nodeComponents[props.modelValue.layout.comp]) {
if (props.modelValue.layout.comp !== 'none' && !props.modelValue.slots?.component && !props.statefulLayout.options.nodeComponents[props.modelValue.layout.comp]) {
console.error(`vjsf: missing component to render vjsf node "${props.modelValue.layout.comp}", maybe you forgot to register a component from a plugin ?`)
}
Expand All @@ -64,9 +64,9 @@ if (props.modelValue.layout.comp !== 'none' && !props.statefulLayout.options.nod
:class="nodeClasses"
>
<node-slot
v-if="modelValue.layout.slots?.before"
v-if="modelValue.slots?.before"
key="before"
:layout-slot="modelValue.layout.slots?.before"
:layout-slot="modelValue.slots?.before"
:node="modelValue"
:stateful-layout="statefulLayout"
:class="beforeAfterClasses[modelValue.options.density]"
Expand All @@ -77,9 +77,9 @@ if (props.modelValue.layout.comp !== 'none' && !props.statefulLayout.options.nod
:node="modelValue"
/>
<node-slot
v-if="modelValue.layout.slots?.component"
v-if="modelValue.slots?.component"
key="component"
:layout-slot="modelValue.layout.slots?.component"
:layout-slot="modelValue.slots?.component"
:node="modelValue"
:stateful-layout="statefulLayout"
/>
Expand All @@ -91,9 +91,9 @@ if (props.modelValue.layout.comp !== 'none' && !props.statefulLayout.options.nod
/>
<node-slot
v-if="modelValue.layout.slots?.after"
v-if="modelValue.slots?.after"
key="after"
:layout-slot="modelValue.layout.slots?.after"
:layout-slot="modelValue.slots?.after"
:node="modelValue"
:stateful-layout="statefulLayout"
:class="beforeAfterClasses[modelValue.options.density]"
Expand Down
66 changes: 63 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4360d81

Please sign in to comment.