@koumoul/vjsf 4.1.4 → 4.2.0

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": "4.1.4",
3
+ "version": "4.2.0",
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",
@@ -25,6 +25,12 @@
25
25
  "default": "./src/index.js"
26
26
  }
27
27
  },
28
+ "./webmcp": {
29
+ "import": {
30
+ "types": "./types/webmcp.d.ts",
31
+ "default": "./src/webmcp.js"
32
+ }
33
+ },
28
34
  "./types.js": {
29
35
  "import": {
30
36
  "types": "./types/types.d.ts",
@@ -72,7 +78,7 @@
72
78
  "vuetify": "^4.0.0"
73
79
  },
74
80
  "dependencies": {
75
- "@json-layout/core": "~2.5.0",
81
+ "@json-layout/core": "~2.6.0",
76
82
  "@json-layout/vocabulary": "~2.12.0",
77
83
  "@vueuse/core": "^12.5.0",
78
84
  "debug": "^4.3.4"
@@ -33,7 +33,7 @@ export default defineComponent({
33
33
  setup (props, { emit }) {
34
34
  useDefaults({}, 'VjsfListSelectKey')
35
35
  const vSelectProps = useCompDefaults('VjsfIndexedList-VSelect', { variant: 'outlined', class: 'mt-2' })
36
- const avatarProps = useCompDefaults('VjsfSelectItem-VAvatar', { rounded: false, size: 'small' })
36
+ const avatarProps = useCompDefaults('VjsfSelectItem-VAvatar', { rounded: false, size: 'small', color: 'transparent' })
37
37
 
38
38
  // @ts-ignore
39
39
  const { getItems, selectProps, selectSlots } = useSelectNode(toRef(props, 'listNode'), props.statefulLayout, avatarProps.value, 'v-select')
@@ -17,7 +17,7 @@ export default defineComponent({
17
17
  }
18
18
  },
19
19
  setup (props) {
20
- const isUrl = computed(() => props.icon.startsWith('http://') || props.icon.startsWith('https://'))
20
+ const isUrl = computed(() => props.icon.startsWith('http://') || props.icon.startsWith('https://') || props.icon.startsWith('/'))
21
21
  const isSVG = computed(() => props.icon.startsWith('<?xml') || props.icon.startsWith('<svg'))
22
22
  return () => {
23
23
  if (isUrl.value) {
@@ -20,7 +20,7 @@ export default defineComponent({
20
20
  },
21
21
  setup (props) {
22
22
  useDefaults({}, 'VjsfAutocomplete')
23
- const avatarProps = useCompDefaults('VjsfSelectItem-VAvatar', { rounded: false, size: 'small' })
23
+ const avatarProps = useCompDefaults('VjsfSelectItem-VAvatar', { rounded: false, size: 'small', color: 'transparent' })
24
24
 
25
25
  const { getItems, selectProps, selectSlots, localData } = useSelectNode(toRef(props, 'modelValue'), props.statefulLayout, avatarProps.value, 'v-autocomplete')
26
26
 
@@ -20,7 +20,7 @@ export default defineComponent({
20
20
  },
21
21
  setup (props) {
22
22
  useDefaults({}, 'VjsfSelect')
23
- const avatarProps = useCompDefaults('VjsfSelectItem-VAvatar', { rounded: false, size: 'small' })
23
+ const avatarProps = useCompDefaults('VjsfSelectItem-VAvatar', { rounded: false, size: 'small', color: 'transparent' })
24
24
 
25
25
  const { getItems, selectProps, selectSlots, localData } = useSelectNode(toRef(props, 'modelValue'), props.statefulLayout, avatarProps.value, 'v-select')
26
26
 
@@ -40,3 +40,9 @@ export default defineComponent({
40
40
  }
41
41
  })
42
42
  </script>
43
+
44
+ <style>
45
+ .vjsf-node-slider .v-slider {
46
+ padding-right: 8px;
47
+ }
48
+ </style>
@@ -0,0 +1,87 @@
1
+ <script setup>
2
+ import { computed, shallowRef, watch } from 'vue'
3
+
4
+ import { compile, produceCompileOptions } from '@json-layout/core/compile'
5
+ import { WebMCP } from '@json-layout/core/webmcp'
6
+ import Tree from './tree.vue'
7
+ import { useVjsf, emits } from '../composables/use-vjsf.js'
8
+ import '../styles/vjsf.css'
9
+ import { nodeComponents } from './nodes/index.js'
10
+
11
+ const props = defineProps({
12
+ schema: {
13
+ type: Object,
14
+ required: true
15
+ },
16
+ precompiledLayout: {
17
+ /** @type import('vue').PropType<import('@json-layout/core').CompiledLayout> */
18
+ type: Object,
19
+ default: null
20
+ },
21
+ modelValue: {
22
+ type: null,
23
+ default: null
24
+ },
25
+ options: {
26
+ /** @type import('vue').PropType<import('../types.js').PartialVjsfOptions | null> */
27
+ type: Object,
28
+ default: null
29
+ },
30
+ prefixName: {
31
+ type: String,
32
+ default: null
33
+ },
34
+ dataTitle: {
35
+ type: String,
36
+ default: null
37
+ },
38
+ subAgent: {
39
+ type: Boolean,
40
+ default: false
41
+ }
42
+ })
43
+
44
+ const emit = defineEmits(emits)
45
+
46
+ const { el, statefulLayout, stateTree } = useVjsf(
47
+ computed(() => props.schema),
48
+ computed(() => props.modelValue),
49
+ computed(() => props.options),
50
+ nodeComponents,
51
+ emit,
52
+ compile,
53
+ produceCompileOptions,
54
+ computed(() => props.precompiledLayout)
55
+ )
56
+
57
+ /** @type import('vue').ShallowRef<WebMCP | null> */
58
+ const webMCP = shallowRef(null)
59
+ watch(statefulLayout, () => {
60
+ if (webMCP.value) webMCP.value.unregisterTools()
61
+ if (statefulLayout.value) {
62
+ webMCP.value = new WebMCP(
63
+ /** @type {import('@json-layout/core').StatefulLayout} */(/** @type {unknown} */(statefulLayout.value)),
64
+ { prefixName: props.prefixName, dataTitle: props.dataTitle, schema: props.schema, includeSubAgent: props.subAgent }
65
+ )
66
+ webMCP.value.registerTools()
67
+ }
68
+ }, { immediate: true })
69
+
70
+ </script>
71
+
72
+ <template>
73
+ <div
74
+ ref="el"
75
+ class="vjsf"
76
+ >
77
+ <tree
78
+ v-if="statefulLayout && stateTree"
79
+ :model-value="stateTree"
80
+ :stateful-layout="statefulLayout"
81
+ />
82
+ </div>
83
+ </template>
84
+
85
+ <style lang="css">
86
+ /* nothing here, use ../styles/vjsf.css */
87
+ </style>
package/src/webmcp.js ADDED
@@ -0,0 +1,2 @@
1
+ import Vjsf from './components/vjsf-webmcp.vue'
2
+ export default Vjsf
@@ -1 +1 @@
1
- {"version":3,"file":"slider.vue.d.ts","sourceRoot":"","sources":["../../../src/components/nodes/slider.vue"],"names":[],"mappings":"wBAkDqB,OAAO,YAAY;;AAQxC;;QAGM,4EAA4E;cAAlE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,cAAc,CAAC;;;;QAKzE,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;;;;;QAL7E,4EAA4E;cAAlE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,cAAc,CAAC;;;;QAKzE,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;6IA0BhF"}
1
+ {"version":3,"file":"slider.vue.d.ts","sourceRoot":"","sources":["../../../src/components/nodes/slider.vue"],"names":[],"mappings":"wBAwDqB,OAAO,YAAY;;AAQxC;;QAGM,4EAA4E;cAAlE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,cAAc,CAAC;;;;QAKzE,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;;;;;QAL7E,4EAA4E;cAAlE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,cAAc,CAAC;;;;QAKzE,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;6IA0BhF"}
@@ -0,0 +1,79 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: import("vue", { with: { "resolution-mode": "import" } }).DefineComponent<import("vue", { with: { "resolution-mode": "import" } }).ExtractPropTypes<{
4
+ schema: {
5
+ type: ObjectConstructor;
6
+ required: true;
7
+ };
8
+ precompiledLayout: {
9
+ /** @type import('vue').PropType<import('@json-layout/core').CompiledLayout> */
10
+ type: import("vue").PropType<import("@json-layout/core").CompiledLayout>;
11
+ default: null;
12
+ };
13
+ modelValue: {
14
+ type: null;
15
+ default: null;
16
+ };
17
+ options: {
18
+ /** @type import('vue').PropType<import('../types.js').PartialVjsfOptions | null> */
19
+ type: import("vue").PropType<import("../types.js").PartialVjsfOptions | null>;
20
+ default: null;
21
+ };
22
+ prefixName: {
23
+ type: StringConstructor;
24
+ default: null;
25
+ };
26
+ dataTitle: {
27
+ type: StringConstructor;
28
+ default: null;
29
+ };
30
+ subAgent: {
31
+ type: BooleanConstructor;
32
+ default: boolean;
33
+ };
34
+ }>, {}, {}, {}, {}, import("vue", { with: { "resolution-mode": "import" } }).ComponentOptionsMixin, import("vue", { with: { "resolution-mode": "import" } }).ComponentOptionsMixin, {
35
+ "update:state": (state: import("../types.js", { with: { "resolution-mode": "import" } }).VjsfStatefulLayout) => void;
36
+ "update:modelValue": (data: any) => void;
37
+ }, string, import("vue", { with: { "resolution-mode": "import" } }).PublicProps, Readonly<import("vue", { with: { "resolution-mode": "import" } }).ExtractPropTypes<{
38
+ schema: {
39
+ type: ObjectConstructor;
40
+ required: true;
41
+ };
42
+ precompiledLayout: {
43
+ /** @type import('vue').PropType<import('@json-layout/core').CompiledLayout> */
44
+ type: import("vue").PropType<import("@json-layout/core").CompiledLayout>;
45
+ default: null;
46
+ };
47
+ modelValue: {
48
+ type: null;
49
+ default: null;
50
+ };
51
+ options: {
52
+ /** @type import('vue').PropType<import('../types.js').PartialVjsfOptions | null> */
53
+ type: import("vue").PropType<import("../types.js").PartialVjsfOptions | null>;
54
+ default: null;
55
+ };
56
+ prefixName: {
57
+ type: StringConstructor;
58
+ default: null;
59
+ };
60
+ dataTitle: {
61
+ type: StringConstructor;
62
+ default: null;
63
+ };
64
+ subAgent: {
65
+ type: BooleanConstructor;
66
+ default: boolean;
67
+ };
68
+ }>> & Readonly<{
69
+ "onUpdate:state"?: ((state: import("../types.js", { with: { "resolution-mode": "import" } }).VjsfStatefulLayout) => any) | undefined;
70
+ "onUpdate:modelValue"?: ((data: any) => any) | undefined;
71
+ }>, {
72
+ options: import("../types.js", { with: { "resolution-mode": "import" } }).PartialVjsfOptions | null;
73
+ modelValue: any;
74
+ precompiledLayout: import("../../../node_modules/@json-layout/core/types/compile/types.js", { with: { "resolution-mode": "import" } }).CompiledLayout;
75
+ prefixName: string;
76
+ dataTitle: string;
77
+ subAgent: boolean;
78
+ }, {}, {}, {}, string, import("vue", { with: { "resolution-mode": "import" } }).ComponentProvideOptions, true, {}, any>;
79
+ //# sourceMappingURL=vjsf-webmcp.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vjsf-webmcp.vue.d.ts","sourceRoot":"","sources":["../../src/components/vjsf-webmcp.vue"],"names":[],"mappings":"wBA4OqB,OAAO,YAAY;;AAnCxC;;;;;;QAQI,+EAA+E;cAArE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,mBAAmB,EAAE,cAAc,CAAC;;;;;;;;QAS5E,oFAAoF;cAA1E,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;QATjF,+EAA+E;cAArE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,mBAAmB,EAAE,cAAc,CAAC;;;;;;;;QAS5E,oFAAoF;cAA1E,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;wHAiBlF"}
@@ -0,0 +1,3 @@
1
+ export default Vjsf;
2
+ import Vjsf from './components/vjsf-webmcp.vue';
3
+ //# sourceMappingURL=webmcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webmcp.d.ts","sourceRoot":"","sources":["../src/webmcp.js"],"names":[],"mappings":";iBAAiB,8BAA8B"}
@@ -1,28 +0,0 @@
1
- import { shallowRef, onScopeDispose, toValue } from 'vue'
2
- import { WebMCP } from '@json-layout/core/webmcp'
3
-
4
- /**
5
- * @param {{ prefixName?: import('vue').MaybeRefOrGetter<string | null | undefined>, dataTitle?: import('vue').MaybeRefOrGetter<string | null | undefined>, schema: import('vue').MaybeRefOrGetter<object> }} options
6
- */
7
- export function useWebMCP (options) {
8
- /** @type import('vue').ShallowRef<WebMCP | null> */
9
- const webMCP = shallowRef(null)
10
-
11
- /**
12
- * @param {import('@json-layout/core').StatefulLayout} statefulLayout
13
- */
14
- function onStateUpdate (statefulLayout) {
15
- if (webMCP.value) webMCP.value.unregisterTools()
16
- webMCP.value = new WebMCP(
17
- /** @type {import('@json-layout/core').StatefulLayout} */(/** @type {unknown} */(statefulLayout)),
18
- { prefixName: toValue(options.prefixName) ?? undefined, dataTitle: toValue(options.dataTitle) ?? undefined, schema: toValue(options.schema) }
19
- )
20
- webMCP.value.registerTools()
21
- }
22
-
23
- onScopeDispose(() => {
24
- if (webMCP.value) webMCP.value.unregisterTools()
25
- })
26
-
27
- return { onStateUpdate }
28
- }