@koumoul/vjsf 4.1.4 → 4.1.5

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.1.5",
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",
@@ -0,0 +1,83 @@
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
+ })
39
+
40
+ const emit = defineEmits(emits)
41
+
42
+ const { el, statefulLayout, stateTree } = useVjsf(
43
+ computed(() => props.schema),
44
+ computed(() => props.modelValue),
45
+ computed(() => props.options),
46
+ nodeComponents,
47
+ emit,
48
+ compile,
49
+ produceCompileOptions,
50
+ computed(() => props.precompiledLayout)
51
+ )
52
+
53
+ /** @type import('vue').ShallowRef<WebMCP | null> */
54
+ const webMCP = shallowRef(null)
55
+ watch(statefulLayout, () => {
56
+ if (webMCP.value) webMCP.value.unregisterTools()
57
+ if (statefulLayout.value) {
58
+ webMCP.value = new WebMCP(
59
+ /** @type {import('@json-layout/core').StatefulLayout} */(/** @type {unknown} */(statefulLayout.value)),
60
+ { prefixName: props.prefixName, dataTitle: props.dataTitle, schema: props.schema }
61
+ )
62
+ webMCP.value.registerTools()
63
+ }
64
+ }, { immediate: true })
65
+
66
+ </script>
67
+
68
+ <template>
69
+ <div
70
+ ref="el"
71
+ class="vjsf"
72
+ >
73
+ <tree
74
+ v-if="statefulLayout && stateTree"
75
+ :model-value="stateTree"
76
+ :stateful-layout="statefulLayout"
77
+ />
78
+ </div>
79
+ </template>
80
+
81
+ <style lang="css">
82
+ /* nothing here, use ../styles/vjsf.css */
83
+ </style>
package/src/webmcp.js ADDED
@@ -0,0 +1,2 @@
1
+ import Vjsf from './components/vjsf-webmcp.vue'
2
+ export default Vjsf
@@ -0,0 +1,70 @@
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
+ }>, {}, {}, {}, {}, import("vue", { with: { "resolution-mode": "import" } }).ComponentOptionsMixin, import("vue", { with: { "resolution-mode": "import" } }).ComponentOptionsMixin, {
31
+ "update:state": (state: import("../types.js", { with: { "resolution-mode": "import" } }).VjsfStatefulLayout) => void;
32
+ "update:modelValue": (data: any) => void;
33
+ }, string, import("vue", { with: { "resolution-mode": "import" } }).PublicProps, Readonly<import("vue", { with: { "resolution-mode": "import" } }).ExtractPropTypes<{
34
+ schema: {
35
+ type: ObjectConstructor;
36
+ required: true;
37
+ };
38
+ precompiledLayout: {
39
+ /** @type import('vue').PropType<import('@json-layout/core').CompiledLayout> */
40
+ type: import("vue").PropType<import("@json-layout/core").CompiledLayout>;
41
+ default: null;
42
+ };
43
+ modelValue: {
44
+ type: null;
45
+ default: null;
46
+ };
47
+ options: {
48
+ /** @type import('vue').PropType<import('../types.js').PartialVjsfOptions | null> */
49
+ type: import("vue").PropType<import("../types.js").PartialVjsfOptions | null>;
50
+ default: null;
51
+ };
52
+ prefixName: {
53
+ type: StringConstructor;
54
+ default: null;
55
+ };
56
+ dataTitle: {
57
+ type: StringConstructor;
58
+ default: null;
59
+ };
60
+ }>> & Readonly<{
61
+ "onUpdate:state"?: ((state: import("../types.js", { with: { "resolution-mode": "import" } }).VjsfStatefulLayout) => any) | undefined;
62
+ "onUpdate:modelValue"?: ((data: any) => any) | undefined;
63
+ }>, {
64
+ options: import("../types.js", { with: { "resolution-mode": "import" } }).PartialVjsfOptions | null;
65
+ modelValue: any;
66
+ precompiledLayout: import("../../../node_modules/@json-layout/core/types/compile/types.js", { with: { "resolution-mode": "import" } }).CompiledLayout;
67
+ prefixName: string;
68
+ dataTitle: string;
69
+ }, {}, {}, {}, string, import("vue", { with: { "resolution-mode": "import" } }).ComponentProvideOptions, true, {}, any>;
70
+ //# 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":"wBAgOqB,OAAO,YAAY;;AA/BxC;;;;;;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;;;;;;;;;;;;;;;;;;;;wHAalF"}
@@ -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
- }