@koumoul/vjsf 3.0.0-beta.26 → 3.0.0-beta.27

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": "3.0.0-beta.26",
3
+ "version": "3.0.0-beta.27",
4
4
  "description": "Generate forms for the vuetify UI library (vuejs) based on annotated JSON schemas.",
5
5
  "scripts": {
6
6
  "test": "vitest",
@@ -76,7 +76,7 @@
76
76
  "vuetify": "^3.6.8"
77
77
  },
78
78
  "dependencies": {
79
- "@json-layout/core": "0.22.0",
79
+ "@json-layout/core": "0.23.0",
80
80
  "@vueuse/core": "^10.5.0",
81
81
  "debug": "^4.3.4",
82
82
  "ejs": "^3.1.9"
@@ -15,7 +15,7 @@ export const defaultOptions = {
15
15
  * @returns
16
16
  */
17
17
  export const getFullOptions = (options, form, width, slots, defaultNodeComponents) => {
18
- const components = options?.components ?? {}
18
+ const components = { ...options?.components }
19
19
  const nodeComponents = { ...defaultNodeComponents, ...options?.nodeComponents }
20
20
  if (options?.plugins) {
21
21
  for (const plugin of options.plugins) {
@@ -90,35 +90,36 @@ export const useVjsf = (schema, modelValue, options, nodeComponents, emit, compi
90
90
  }
91
91
  }
92
92
 
93
+ const onAutofocus = () => {
94
+ if (!el.value) return
95
+ // @ts-ignore
96
+ const autofocusNodeElement = el.value.querySelector('.vjsf-input--autofocus')
97
+ if (autofocusNodeElement) {
98
+ const autofocusInputElement = autofocusNodeElement.querySelector('input') ?? autofocusNodeElement.querySelector('textarea:not([style*="display: none"]')
99
+ if (autofocusInputElement) autofocusInputElement.focus()
100
+ }
101
+ }
102
+
93
103
  const initStatefulLayout = () => {
94
104
  if (!width.value) return
105
+ if (statefulLayout.value) {
106
+ statefulLayout.value.events.off('update', onStatefulLayoutUpdate)
107
+ statefulLayout.value.events.off('data', onDataUpdate)
108
+ statefulLayout.value.events.off('autofocus', onAutofocus)
109
+ }
95
110
 
96
111
  // @ts-ignore
97
- const _statefulLayout = /** @type {import('../types.js').VjsfStatefulLayout} */(new StatefulLayout(
112
+ statefulLayout.value = /** @type {import('../types.js').VjsfStatefulLayout} */(new StatefulLayout(
98
113
  toRaw(compiledLayout.value),
99
114
  toRaw(compiledLayout.value.skeletonTrees[compiledLayout.value.mainTree]),
100
115
  toRaw(fullOptions.value),
101
116
  toRaw(modelValue.value)
102
117
  ))
103
- statefulLayout.value = _statefulLayout
104
118
  onStatefulLayoutUpdate()
105
119
  onDataUpdate()
106
- _statefulLayout.events.on('update', () => {
107
- onStatefulLayoutUpdate()
108
- })
109
- _statefulLayout.events.on('data', () => {
110
- onDataUpdate()
111
- })
112
- emit('update:state', _statefulLayout)
113
- _statefulLayout.events.on('autofocus', () => {
114
- if (!el.value) return
115
- // @ts-ignore
116
- const autofocusNodeElement = el.value.querySelector('.vjsf-input--autofocus')
117
- if (autofocusNodeElement) {
118
- const autofocusInputElement = autofocusNodeElement.querySelector('input') ?? autofocusNodeElement.querySelector('textarea:not([style*="display: none"]')
119
- if (autofocusInputElement) autofocusInputElement.focus()
120
- }
121
- })
120
+ statefulLayout.value.events.on('update', onStatefulLayoutUpdate)
121
+ statefulLayout.value.events.on('data', onDataUpdate)
122
+ statefulLayout.value.events.on('autofocus', onAutofocus)
122
123
  }
123
124
 
124
125
  // case where options are updated from outside
@@ -1,13 +1,13 @@
1
1
  declare const _default: import("vue").DefineComponent<{}, {
2
2
  $emit: ((event: "update:modelValue", data: any) => void) & ((event: "update:state", state: import("../types.js").VjsfStatefulLayout) => void);
3
- options: Partial<Omit<import("../types.js").VjsfOptions, "width" | "vjsfSlots">> | null;
4
- modelValue: any;
5
3
  schema: Record<string, any>;
4
+ modelValue: any;
5
+ options: Partial<Omit<import("../types.js").VjsfOptions, "width" | "vjsfSlots">> | null;
6
6
  precompiledLayout: import("../../../node_modules/@json-layout/core/types/compile/types.js").CompiledLayout;
7
7
  $props: {
8
- readonly options?: Partial<Omit<import("../types.js").VjsfOptions, "width" | "vjsfSlots">> | null | undefined;
9
- readonly modelValue?: any;
10
8
  readonly schema?: Record<string, any> | undefined;
9
+ readonly modelValue?: any;
10
+ readonly options?: Partial<Omit<import("../types.js").VjsfOptions, "width" | "vjsfSlots">> | null | undefined;
11
11
  readonly precompiledLayout?: import("../../../node_modules/@json-layout/core/types/compile/types.js").CompiledLayout | undefined;
12
12
  };
13
13
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
@@ -1 +1 @@
1
- {"version":3,"file":"use-vjsf.d.ts","sourceRoot":"","sources":["../../src/composables/use-vjsf.js"],"names":[],"mappings":"AASA;IACE;;MAEE;gCADO,GAAG;IAGZ;;MAEE;4BADO,OAAO,aAAa,EAAE,kBAAkB;EAGlD;AAWM,gCARI,OAAO,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,cACzB,OAAO,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,WACtB,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC,kBAClE,OAAO,MAAM,EAAE,OAAO,KAAK,EAAE,SAAS,CAAC,QACvC,GAAG;;;;EAsHb"}
1
+ {"version":3,"file":"use-vjsf.d.ts","sourceRoot":"","sources":["../../src/composables/use-vjsf.js"],"names":[],"mappings":"AASA;IACE;;MAEE;gCADO,GAAG;IAGZ;;MAEE;4BADO,OAAO,aAAa,EAAE,kBAAkB;EAGlD;AAWM,gCARI,OAAO,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,cACzB,OAAO,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,WACtB,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC,kBAClE,OAAO,MAAM,EAAE,OAAO,KAAK,EAAE,SAAS,CAAC,QACvC,GAAG;;;;EAuHb"}