@koumoul/vjsf 4.1.2 → 4.1.3

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.2",
3
+ "version": "4.1.3",
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",
@@ -8,7 +8,7 @@ import { VIcon } from 'vuetify/components/VIcon'
8
8
  import { VSheet } from 'vuetify/components/VSheet'
9
9
  import { useDate, useDefaults } from 'vuetify'
10
10
  import { computed, ref, watch, toRef } from 'vue'
11
- import { getDateTimeParts, getDateTimeWithOffset, getShortTime } from '../../utils/dates.js'
11
+ import { getDateTime, getDateTimeParts, getDateTimeWithOffset, getShortTime } from '../../utils/dates.js'
12
12
  import useNode from '../../composables/use-node.js'
13
13
  import useCompDefaults from '../../composables/use-comp-defaults.js'
14
14
 
@@ -49,7 +49,8 @@ const datePickerProps = computed(() => {
49
49
  if (localData.value) {
50
50
  // replace date part of current value
51
51
  const datePart = value && getDateTimeParts(/** @type Date */(/** @type unknown */(value)))[0]
52
- props.statefulLayout.input(props.modelValue, datePart + localData.value.slice(10))
52
+ const timePart = getShortTime(localData.value.slice(11))
53
+ props.statefulLayout.input(props.modelValue, getDateTime([datePart, timePart]))
53
54
  } else {
54
55
  props.statefulLayout.input(props.modelValue, getDateTimeWithOffset(value))
55
56
  }
@@ -0,0 +1,28 @@
1
+ import { shallowRef, onScopeDispose, toValue } from 'vue'
2
+ import { WebMCP } from '@json-layout/core/webmcp'
3
+
4
+ /**
5
+ * @param {{ prefixName?: string | import('vue').Ref<string | null>, dataTitle?: string | import('vue').Ref<string | null>, schema: object | import('vue').Ref<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
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"date-time-picker.vue.d.ts","sourceRoot":"","sources":["../../../src/components/nodes/date-time-picker.vue"],"names":[],"mappings":"wBAmaqB,OAAO,YAAY;;AAdxC;;QAGI,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;;QAK7E,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;;;QAL7E,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;;QAK7E,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;6IAK9E"}
1
+ {"version":3,"file":"date-time-picker.vue.d.ts","sourceRoot":"","sources":["../../../src/components/nodes/date-time-picker.vue"],"names":[],"mappings":"wBAqaqB,OAAO,YAAY;;AAdxC;;QAGI,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;;QAK7E,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;;;QAL7E,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;;QAK7E,gFAAgF;cAAtE,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,gBAAgB,EAAE,kBAAkB,CAAC;;;6IAK9E"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @param {{ prefixName?: string | import('vue').Ref<string | null>, dataTitle?: string | import('vue').Ref<string | null>, schema: object | import('vue').Ref<object> }} options
3
+ */
4
+ export function useWebMCP(options: {
5
+ prefixName?: string | import("vue").Ref<string | null>;
6
+ dataTitle?: string | import("vue").Ref<string | null>;
7
+ schema: object | import("vue").Ref<object>;
8
+ }): {
9
+ onStateUpdate: (statefulLayout: import("@json-layout/core").StatefulLayout) => void;
10
+ };
11
+ //# sourceMappingURL=use-webmcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-webmcp.d.ts","sourceRoot":"","sources":["../../src/composables/use-webmcp.js"],"names":[],"mappings":"AAGA;;GAEG;AACH,mCAFW;IAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,KAAK,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,KAAK,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,OAAO,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE;oCAO3J,OAAO,mBAAmB,EAAE,cAAc;EAgBtD"}
@@ -1,83 +0,0 @@
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>
@@ -1,70 +0,0 @@
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
@@ -1 +0,0 @@
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"}