@koumoul/vjsf 3.10.4 → 3.12.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": "3.10.4",
3
+ "version": "3.12.0",
4
4
  "description": "Generate forms for the vuetify UI library (vuejs) based on annotated JSON schemas.",
5
5
  "scripts": {
6
6
  "test": "vitest run",
@@ -71,8 +71,8 @@
71
71
  "vuetify": "^3.6.13"
72
72
  },
73
73
  "dependencies": {
74
- "@json-layout/core": "~1.5.2",
75
- "@json-layout/vocabulary": "~1.5.1",
74
+ "@json-layout/core": "~1.7.0",
75
+ "@json-layout/vocabulary": "~2.1.0",
76
76
  "@vueuse/core": "^12.5.0",
77
77
  "debug": "^4.3.4"
78
78
  },
package/src/compat/v2.js CHANGED
@@ -17,11 +17,13 @@ const expressionKeyMappings = {
17
17
  * @param {string} expression
18
18
  * @returns {string}
19
19
  */
20
- const prefixExpression = (expression) => {
21
- // looks like a simple expression missing the data. prefix
20
+ const fixSimpleExpression = (expression) => {
21
+ // looks like a simple expression is missing the data. prefix
22
22
  if (expression.match(/^[a-z.]*$/i) && !['data', 'context', 'rootData', 'parent'].some(key => expression.startsWith(key + '.'))) {
23
- return 'rootData.' + expression
23
+ expression = 'rootData.' + expression
24
24
  }
25
+ // replace a array item referenced with dot notation to bracket notation
26
+ expression = expression.replace(/(.*)\.(\d+)(.*)/, '$1[$2]$3')
25
27
  return expression
26
28
  }
27
29
 
@@ -44,11 +46,11 @@ const fixExpression = (expression, type = 'js-eval') => {
44
46
  expr = expr.replace(new RegExp(`${key}\\.`, 'g'), value + '.')
45
47
  }
46
48
  if (type === 'js-eval') {
47
- expr = prefixExpression(expr)
49
+ expr = fixSimpleExpression(expr)
48
50
  }
49
51
  if (type === 'js-tpl') {
50
52
  for (const expressionMatch of expr.matchAll(/\{(.*?)\}/g)) {
51
- if (expressionMatch[1] !== 'q') expr = expr.replace(expressionMatch[0], '${' + prefixExpression(expressionMatch[1]) + '}')
53
+ if (expressionMatch[1] !== 'q') expr = expr.replace(expressionMatch[0], '${' + fixSimpleExpression(expressionMatch[1]) + '}')
52
54
  }
53
55
  }
54
56
 
@@ -9,21 +9,29 @@
9
9
  >
10
10
  <template #activator="{ props }">
11
11
  <v-btn
12
- color="info"
12
+ :color="node.layout.warning ? 'warning' : 'info'"
13
13
  :class="`vjsf-help-message-toggle`"
14
- :icon="node.options.icons.infoSymbol"
14
+ :icon="node.layout.warning ? node.options.icons.alert : node.options.icons.infoSymbol"
15
15
  density="compact"
16
- variant="flat"
16
+ :variant="node.layout.warning ? 'text' : 'flat'"
17
17
  :size="node.options.density === 'default' ? 28 : 24"
18
18
  :title="show ? '' : node.messages.showHelp"
19
19
  v-bind="props"
20
20
  />
21
21
  </template>
22
22
  <v-alert
23
- color="info"
23
+ :color="node.layout.warning ? 'warning' : 'info'"
24
24
  :density="node.options.density"
25
25
  >
26
- <div v-html="node.layout.help" />
26
+ <p
27
+ v-if="node.layout.warning"
28
+ class="mb-2"
29
+ v-html="node.layout.warning"
30
+ />
31
+ <div
32
+ v-if="node.layout.help"
33
+ v-html="node.layout.help"
34
+ />
27
35
  </v-alert>
28
36
  </v-menu>
29
37
  </div>
@@ -51,13 +51,17 @@ const indent = computed(() => {
51
51
  return 6
52
52
  })
53
53
 
54
+ const showHelp = computed(() => {
55
+ return (props.modelValue.layout.help || props.modelValue.layout.warning) && !props.modelValue.options.summary
56
+ })
57
+
54
58
  const nodeClasses = computed(() => {
55
59
  let classes = `vjsf-node vjsf-node-${props.modelValue.layout.comp} vjsf-density-${props.modelValue.options.density}`
56
60
  if (props.modelValue.options.readOnly) classes += ' vjsf-readonly'
57
61
  if (props.modelValue.options.summary) classes += ' vjsf-summary'
58
62
  if (theme.current.value.dark) classes += ' vjsf-dark'
59
63
  if (indent.value) classes += ' ml-' + indent.value
60
- if (props.modelValue.layout.help && !props.modelValue.options.summary) classes += ' vjsf-has-help'
64
+ if (showHelp.value) classes += ' vjsf-has-help'
61
65
  return classes
62
66
  })
63
67
 
@@ -84,7 +88,7 @@ if (props.modelValue.layout.comp !== 'none' && !props.modelValue.slots?.componen
84
88
  />
85
89
 
86
90
  <help-message
87
- v-if="modelValue.layout.help && !modelValue.options.summary"
91
+ v-if="showHelp"
88
92
  :node="modelValue"
89
93
  />
90
94
  <node-slot
@@ -13,7 +13,7 @@ import SelectSelection from '../components/fragments/select-selection.vue'
13
13
  export default function (nodeRef, statefulLayout, avatarProps) {
14
14
  const layout = computed(() => nodeRef.value.layout)
15
15
 
16
- const { inputProps, options, skeleton, localData, compSlots } = useField(nodeRef, statefulLayout, { layoutPropsMap: ['multiple'], bindData: false })
16
+ const { inputProps, options, skeleton, localData, compSlots } = useField(nodeRef, statefulLayout, { layoutPropsMap: ['multiple', 'placeholder'], bindData: false })
17
17
  const getItems = useGetItems(nodeRef, statefulLayout)
18
18
 
19
19
  const selectProps = computed(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../src/compat/v2.js"],"names":[],"mappings":"AAyMA;;;;;;GAMG;AACH,kCALW,MAAM,2CAEN,MAAM,0BAoBhB;sBAjOqB,KAAK"}
1
+ {"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../src/compat/v2.js"],"names":[],"mappings":"AA2MA;;;;;;GAMG;AACH,kCALW,MAAM,2CAEN,MAAM,0BAoBhB;sBAnOqB,KAAK"}
@@ -1,7 +1,7 @@
1
1
  declare const _default: import("vue").DefineComponent<{}, {
2
- modelValue: import("../../../node_modules/@json-layout/core/types/state/types.js").StateNode;
2
+ modelValue: import("../../../../node_modules/@json-layout/core/types/state/types.js").StateNode;
3
3
  $props: {
4
- modelValue?: import("../../../node_modules/@json-layout/core/types/state/types.js").StateNode | undefined;
4
+ modelValue?: import("../../../../node_modules/@json-layout/core/types/state/types.js").StateNode | undefined;
5
5
  };
6
6
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
7
7
  export default _default;
@@ -1,11 +1,11 @@
1
1
  declare const _default: import("vue").DefineComponent<{}, {
2
2
  multiple: boolean;
3
- item: import("../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItem;
3
+ item: import("../../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItem;
4
4
  avatarProps: Record<string, any>;
5
5
  itemProps: Record<string, any>;
6
6
  $props: {
7
7
  readonly multiple?: boolean | undefined;
8
- readonly item?: import("../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItem | undefined;
8
+ readonly item?: import("../../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItem | undefined;
9
9
  readonly avatarProps?: Record<string, any> | undefined;
10
10
  readonly itemProps?: Record<string, any> | undefined;
11
11
  };
@@ -1,11 +1,11 @@
1
1
  declare const _default: import("vue").DefineComponent<{}, {
2
2
  multiple: boolean;
3
- item: import("../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItem;
3
+ item: import("../../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItem;
4
4
  avatarProps: Record<string, any>;
5
5
  last: boolean;
6
6
  $props: {
7
7
  readonly multiple?: boolean | undefined;
8
- readonly item?: import("../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItem | undefined;
8
+ readonly item?: import("../../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItem | undefined;
9
9
  readonly avatarProps?: Record<string, any> | undefined;
10
10
  readonly last?: boolean | undefined;
11
11
  };
@@ -1,8 +1,8 @@
1
1
  declare const _default: import("vue").DefineComponent<{}, {
2
- modelValue: import("../../node_modules/@json-layout/core/types/state/types.js").StateTree;
2
+ modelValue: import("../../../node_modules/@json-layout/core/types/state/types.js").StateTree;
3
3
  statefulLayout: import("../types.js").VjsfStatefulLayout;
4
4
  $props: {
5
- readonly modelValue?: import("../../node_modules/@json-layout/core/types/state/types.js").StateTree | undefined;
5
+ readonly modelValue?: import("../../../node_modules/@json-layout/core/types/state/types.js").StateTree | undefined;
6
6
  readonly statefulLayout?: import("../types.js").VjsfStatefulLayout | undefined;
7
7
  };
8
8
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -3,12 +3,12 @@ declare const _default: import("vue").DefineComponent<{}, {
3
3
  options: import("../types.js").PartialVjsfOptions | null;
4
4
  modelValue: any;
5
5
  schema: Record<string, any>;
6
- precompiledLayout: import("../../node_modules/@json-layout/core/types/compile/types.js").CompiledLayout;
6
+ precompiledLayout: import("../../../node_modules/@json-layout/core/types/compile/types.js").CompiledLayout;
7
7
  $props: {
8
8
  readonly options?: import("../types.js").PartialVjsfOptions | null | undefined;
9
9
  readonly modelValue?: any;
10
10
  readonly schema?: Record<string, any> | undefined;
11
- readonly precompiledLayout?: import("../../node_modules/@json-layout/core/types/compile/types.js").CompiledLayout | undefined;
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<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
14
14
  export default _default;
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export default function _default(nodeRef: import('vue').Ref<import('../types.js').VjsfNode>, statefulLayout: import('../types.js').VjsfStatefulLayout): {
6
6
  hasItems: import("vue").ComputedRef<boolean>;
7
- items: import("vue").Ref<import("../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItems, import("../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItems>;
7
+ items: import("vue").Ref<import("../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItems, import("../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItems>;
8
8
  loading: import("vue").Ref<boolean, boolean>;
9
9
  search: import("vue").Ref<string, string>;
10
10
  prepareSelectedItem: (selectedItem: any, itemValue: any) => any;
@@ -24,9 +24,9 @@ export default function _default(nodeRef: import('vue').Ref<import('../types.js'
24
24
  }>;
25
25
  compSlots: import("vue").ComputedRef<Record<string, any>>;
26
26
  options: import("vue").ComputedRef<Required<import("../types.js").VjsfOptions>>;
27
- skeleton: import("vue").ComputedRef<import("../../node_modules/@json-layout/core/types/compile/types.js").SkeletonNode>;
28
- layout: import("vue").ComputedRef<import("../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").BaseCompObject>;
27
+ skeleton: import("vue").ComputedRef<import("../../../node_modules/@json-layout/core/types/compile/types.js").SkeletonNode>;
28
+ layout: import("vue").ComputedRef<import("../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").BaseCompObject>;
29
29
  data: import("vue").ComputedRef<unknown>;
30
- children: import("vue").ComputedRef<import("../../node_modules/@json-layout/core/types/state/types.js").StateNode[] | undefined>;
30
+ children: import("vue").ComputedRef<import("../../../node_modules/@json-layout/core/types/state/types.js").StateNode[] | undefined>;
31
31
  };
32
32
  //# sourceMappingURL=use-node.d.ts.map
@@ -19,7 +19,7 @@ export default function _default(nodeRef: import('vue').Ref<import('../types.js'
19
19
  }>;
20
20
  getItems: {
21
21
  hasItems: import("vue").ComputedRef<boolean>;
22
- items: import("vue").Ref<import("../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItems, import("../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItems>;
22
+ items: import("vue").Ref<import("../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItems, import("../../../node_modules/@json-layout/vocabulary/types/normalized-layout/types.js").SelectItems>;
23
23
  loading: import("vue").Ref<boolean, boolean>;
24
24
  search: import("vue").Ref<string, string>;
25
25
  prepareSelectedItem: (selectedItem: any, itemValue: any) => any;
@@ -8,9 +8,9 @@ export const emits: {
8
8
  */
9
9
  'update:state': (state: import('../types.js').VjsfStatefulLayout) => boolean;
10
10
  };
11
- export function useVjsf(schema: import('vue').Ref<Object>, modelValue: import('vue').Ref<any>, options: import('vue').Ref<import("../types.js").PartialVjsfOptions | null>, nodeComponents: Record<string, import('vue').Component>, emit: any, compile?: typeof import("@json-layout/core").compile | undefined, precompiledLayout?: import("vue").Ref<import("../../node_modules/@json-layout/core/types/compile/types.js").CompiledLayout, import("../../node_modules/@json-layout/core/types/compile/types.js").CompiledLayout> | undefined): {
11
+ export function useVjsf(schema: import('vue').Ref<Object>, modelValue: import('vue').Ref<any>, options: import('vue').Ref<import("../types.js").PartialVjsfOptions | null>, nodeComponents: Record<string, import('vue').Component>, emit: any, compile?: typeof import("@json-layout/core").compile | undefined, precompiledLayout?: import("vue").Ref<import("../../../node_modules/@json-layout/core/types/compile/types.js").CompiledLayout, import("../../../node_modules/@json-layout/core/types/compile/types.js").CompiledLayout> | undefined): {
12
12
  el: import("vue").Ref<null, null>;
13
13
  statefulLayout: import("vue").ShallowRef<import("../types.js").VjsfStatefulLayout | null, import("../types.js").VjsfStatefulLayout | null>;
14
- stateTree: import("vue").ShallowRef<import("../../node_modules/@json-layout/core/types/state/types.js").StateTree | null, import("../../node_modules/@json-layout/core/types/state/types.js").StateTree | null>;
14
+ stateTree: import("vue").ShallowRef<import("../../../node_modules/@json-layout/core/types/state/types.js").StateTree | null, import("../../../node_modules/@json-layout/core/types/state/types.js").StateTree | null>;
15
15
  };
16
16
  //# sourceMappingURL=use-vjsf.d.ts.map