@koumoul/vjsf 3.0.0-beta.44 → 3.0.0-beta.45

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.
Files changed (96) hide show
  1. package/package.json +12 -18
  2. package/src/components/fragments/selection-group.vue +11 -10
  3. package/src/components/fragments/text-field-menu.vue +10 -6
  4. package/src/components/nodes/autocomplete.vue +6 -6
  5. package/src/components/nodes/checkbox.vue +29 -27
  6. package/src/components/nodes/color-picker.vue +6 -4
  7. package/src/components/nodes/combobox.vue +14 -40
  8. package/src/components/nodes/date-picker.vue +14 -6
  9. package/src/components/nodes/date-time-picker.vue +14 -11
  10. package/src/components/nodes/expansion-panels.vue +6 -3
  11. package/src/components/nodes/file-input.vue +11 -10
  12. package/src/components/nodes/list.vue +21 -15
  13. package/src/components/nodes/number-combobox.vue +16 -40
  14. package/src/components/nodes/number-field.vue +13 -10
  15. package/src/components/nodes/one-of-select.vue +14 -10
  16. package/src/components/nodes/radio-group.vue +8 -5
  17. package/src/components/nodes/select.vue +8 -8
  18. package/src/components/nodes/slider.vue +30 -30
  19. package/src/components/nodes/switch.vue +29 -27
  20. package/src/components/nodes/text-field.vue +6 -6
  21. package/src/components/nodes/textarea.vue +16 -11
  22. package/src/components/nodes/time-picker.vue +9 -6
  23. package/src/composables/use-dnd.js +1 -1
  24. package/src/composables/use-get-items.js +12 -7
  25. package/src/composables/use-node.js +136 -0
  26. package/src/composables/use-select-node.js +67 -0
  27. package/src/composables/use-vjsf.js +3 -2
  28. package/types/components/fragments/child-subtitle.vue.d.ts +1 -1
  29. package/types/components/fragments/help-message.vue.d.ts +1 -1
  30. package/types/components/fragments/node-slot.vue.d.ts +4 -4
  31. package/types/components/fragments/section-header.vue.d.ts +1 -1
  32. package/types/components/fragments/select-item-icon.vue.d.ts +4 -4
  33. package/types/components/fragments/select-item.vue.d.ts +3 -3
  34. package/types/components/fragments/select-selection.vue.d.ts +1 -1
  35. package/types/components/fragments/selection-group.vue.d.ts +4 -4
  36. package/types/components/fragments/text-field-menu.vue.d.ts +1 -1
  37. package/types/components/fragments/text-field-menu.vue.d.ts.map +1 -1
  38. package/types/components/node.vue.d.ts +1 -1
  39. package/types/components/nodes/autocomplete.vue.d.ts +4 -4
  40. package/types/components/nodes/autocomplete.vue.d.ts.map +1 -1
  41. package/types/components/nodes/card.vue.d.ts +1 -1
  42. package/types/components/nodes/checkbox-group.vue.d.ts +4 -4
  43. package/types/components/nodes/checkbox.vue.d.ts +25 -8
  44. package/types/components/nodes/checkbox.vue.d.ts.map +1 -1
  45. package/types/components/nodes/color-picker.vue.d.ts +1 -1
  46. package/types/components/nodes/combobox.vue.d.ts +4 -4
  47. package/types/components/nodes/combobox.vue.d.ts.map +1 -1
  48. package/types/components/nodes/date-picker.vue.d.ts +1 -1
  49. package/types/components/nodes/date-time-picker.vue.d.ts +1 -1
  50. package/types/components/nodes/expansion-panels.vue.d.ts +1 -1
  51. package/types/components/nodes/file-input.vue.d.ts +4 -4
  52. package/types/components/nodes/list.vue.d.ts +1 -1
  53. package/types/components/nodes/number-combobox.vue.d.ts +4 -4
  54. package/types/components/nodes/number-combobox.vue.d.ts.map +1 -1
  55. package/types/components/nodes/number-field.vue.d.ts +4 -4
  56. package/types/components/nodes/one-of-select.vue.d.ts +1 -1
  57. package/types/components/nodes/radio-group.vue.d.ts +4 -4
  58. package/types/components/nodes/section.vue.d.ts +1 -1
  59. package/types/components/nodes/select.vue.d.ts +4 -4
  60. package/types/components/nodes/select.vue.d.ts.map +1 -1
  61. package/types/components/nodes/slider.vue.d.ts +25 -8
  62. package/types/components/nodes/slider.vue.d.ts.map +1 -1
  63. package/types/components/nodes/stepper.vue.d.ts +1 -1
  64. package/types/components/nodes/switch-group.vue.d.ts +4 -4
  65. package/types/components/nodes/switch.vue.d.ts +25 -8
  66. package/types/components/nodes/switch.vue.d.ts.map +1 -1
  67. package/types/components/nodes/tabs.vue.d.ts +1 -1
  68. package/types/components/nodes/text-field.vue.d.ts +4 -4
  69. package/types/components/nodes/textarea.vue.d.ts +4 -4
  70. package/types/components/nodes/time-picker.vue.d.ts +1 -1
  71. package/types/components/nodes/vertical-tabs.vue.d.ts +1 -1
  72. package/types/components/tree.vue.d.ts +1 -1
  73. package/types/components/vjsf.vue.d.ts +1 -1
  74. package/types/composables/use-dnd.d.ts +3 -3
  75. package/types/composables/use-field-props.d.ts +30 -0
  76. package/types/composables/use-field-props.d.ts.map +1 -0
  77. package/types/composables/use-field.d.ts +31 -0
  78. package/types/composables/use-field.d.ts.map +1 -0
  79. package/types/composables/use-get-items.d.ts +7 -8
  80. package/types/composables/use-get-items.d.ts.map +1 -1
  81. package/types/composables/use-node.d.ts +32 -0
  82. package/types/composables/use-node.d.ts.map +1 -0
  83. package/types/composables/use-select-field.d.ts +21 -0
  84. package/types/composables/use-select-field.d.ts.map +1 -0
  85. package/types/composables/use-select-node.d.ts +27 -0
  86. package/types/composables/use-select-node.d.ts.map +1 -0
  87. package/types/composables/use-select-props.d.ts +21 -0
  88. package/types/composables/use-select-props.d.ts.map +1 -0
  89. package/types/composables/use-select.d.ts +21 -0
  90. package/types/composables/use-select.d.ts.map +1 -0
  91. package/types/composables/use-vjsf.d.ts +2 -2
  92. package/types/composables/use-vjsf.d.ts.map +1 -1
  93. package/types/utils/index.d.ts +0 -2
  94. package/src/utils/index.js +0 -4
  95. package/src/utils/props.js +0 -136
  96. package/src/utils/slots.js +0 -46
@@ -0,0 +1,27 @@
1
+ /**
2
+ * specialized use of useFieldProps shared between select and autocomplete components
3
+ * @param {import('vue').Ref<import('../types.js').VjsfSelectNode>} nodeRef
4
+ * @param {import('../types.js').VjsfStatefulLayout} statefulLayout
5
+ */
6
+ export default function _default(nodeRef: import('vue').Ref<import('../types.js').VjsfSelectNode>, statefulLayout: import('../types.js').VjsfStatefulLayout): {
7
+ localData: import("vue").Ref<any, any>;
8
+ inputProps: import("vue").ComputedRef<Record<string, any> & {
9
+ class: string[];
10
+ }>;
11
+ selectProps: import("vue").ComputedRef<{
12
+ [x: string]: any;
13
+ class: string[];
14
+ }>;
15
+ compSlots: import("vue").ComputedRef<Record<string, any>>;
16
+ selectSlots: import("vue").ComputedRef<{
17
+ [x: string]: any;
18
+ }>;
19
+ getItems: {
20
+ hasItems: import("vue").ComputedRef<boolean>;
21
+ 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
+ loading: import("vue").Ref<boolean, boolean>;
23
+ search: import("vue").Ref<string, string>;
24
+ prepareSelectedItem: (selectedItem: any, itemValue: any) => any;
25
+ };
26
+ };
27
+ //# sourceMappingURL=use-select-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-select-node.d.ts","sourceRoot":"","sources":["../../src/composables/use-select-node.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,0CAHW,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,aAAa,EAAE,cAAc,CAAC,kBACvD,OAAO,aAAa,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;EAyDlD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * specialized use of useFieldProps shared between select and autocomplete components
3
+ * @param {import('vue').Ref<import('../types.js').VjsfSelectNode>} nodeRef
4
+ * @param {import('../types.js').VjsfStatefulLayout} statefulLayout
5
+ */
6
+ export default function _default(nodeRef: import('vue').Ref<import('../types.js').VjsfSelectNode>, statefulLayout: import('../types.js').VjsfStatefulLayout): {
7
+ modelValue: import("vue").Ref<unknown, unknown>;
8
+ inputProps: import("vue").ComputedRef<Record<string, any> & {
9
+ class: string[];
10
+ }>;
11
+ selectProps: import("vue").ComputedRef<Record<string, any>>;
12
+ compSlots: import("vue").ComputedRef<Record<string, any>>;
13
+ selectSlots: import("vue").ComputedRef<Record<string, any>>;
14
+ getItems: {
15
+ 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>;
16
+ loading: import("vue").Ref<boolean, boolean>;
17
+ search: import("vue").Ref<string, string>;
18
+ prepareSelectedItem: (selectedItem: any, itemValue: any) => any;
19
+ };
20
+ };
21
+ //# sourceMappingURL=use-select-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-select-props.d.ts","sourceRoot":"","sources":["../../src/composables/use-select-props.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,0CAHW,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,aAAa,EAAE,cAAc,CAAC,kBACvD,OAAO,aAAa,EAAE,kBAAkB;;;;;;;;;;;;;;EA2DlD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * specialized use of useFieldProps shared between select and autocomplete components
3
+ * @param {import('vue').Ref<import('../types.js').VjsfSelectNode>} nodeRef
4
+ * @param {import('../types.js').VjsfStatefulLayout} statefulLayout
5
+ */
6
+ export default function _default(nodeRef: import('vue').Ref<import('../types.js').VjsfSelectNode>, statefulLayout: import('../types.js').VjsfStatefulLayout): {
7
+ localData: import("vue").Ref<any, any>;
8
+ inputProps: import("vue").ComputedRef<Record<string, any> & {
9
+ class: string[];
10
+ }>;
11
+ selectProps: import("vue").ComputedRef<Record<string, any>>;
12
+ compSlots: import("vue").ComputedRef<Record<string, any>>;
13
+ selectSlots: import("vue").ComputedRef<Record<string, any>>;
14
+ getItems: {
15
+ 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>;
16
+ loading: import("vue").Ref<boolean, boolean>;
17
+ search: import("vue").Ref<string, string>;
18
+ prepareSelectedItem: (selectedItem: any, itemValue: any) => any;
19
+ };
20
+ };
21
+ //# sourceMappingURL=use-select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-select.d.ts","sourceRoot":"","sources":["../../src/composables/use-select.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,0CAHW,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,aAAa,EAAE,cAAc,CAAC,kBACvD,OAAO,aAAa,EAAE,kBAAkB;;;;;;;;;;;;;;EA2DlD"}
@@ -8,8 +8,8 @@ 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> | undefined): {
12
- el: import("vue").Ref<null>;
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
+ el: import("vue").Ref<null, null>;
13
13
  statefulLayout: import("vue").ShallowRef<import("../types.js").VjsfStatefulLayout | null>;
14
14
  stateTree: import("vue").ShallowRef<import("../../../node_modules/@json-layout/core/types/state/types.js").StateTree | null>;
15
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-vjsf.d.ts","sourceRoot":"","sources":["../../src/composables/use-vjsf.js"],"names":[],"mappings":"AAYA;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;;;;EAkIb"}
1
+ {"version":3,"file":"use-vjsf.d.ts","sourceRoot":"","sources":["../../src/composables/use-vjsf.js"],"names":[],"mappings":"AAYA;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;;;;EAmIb"}
@@ -1,5 +1,3 @@
1
1
  export * from "./arrays.js";
2
2
  export * from "./dates.js";
3
- export * from "./props.js";
4
- export * from "./slots.js";
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +0,0 @@
1
- export * from './arrays.js'
2
- export * from './dates.js'
3
- export * from './props.js'
4
- export * from './slots.js'
@@ -1,136 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { camelize } from 'vue'
3
-
4
- // NOTE: in a previous draft we used to have this in options,
5
- // but it was not very flexible and not very easy to use, user defined props should be managed
6
- // by a combination of layout.props, layout.getProps and vuetify defaults provider (https://vuetifyjs.com/en/components/defaults-providers/#usage)
7
- const defaultProps = {
8
- fieldPropsCompact: {
9
- hideDetails: 'auto'
10
- },
11
- fieldPropsReadOnly: { hideDetails: 'auto', variant: 'plain' },
12
- fieldPropsSummary: { hideDetails: true }
13
- }
14
-
15
- /**
16
- * @param {(Record<string, any> | undefined)[]} propsLevels
17
- * @returns {Record<string, any> & {class: string[]}}
18
- */
19
- export function mergePropsLevels (propsLevels) {
20
- /** @type {Record<string, any> & {class: string[]}} */
21
- const fullProps = { class: [] }
22
- for (const propsLevel of propsLevels) {
23
- if (propsLevel) {
24
- for (const key of Object.keys(propsLevel)) {
25
- if (key === 'class') {
26
- // a small convention for merging/overwriting classes:
27
- // a class defined as a simple string overwrites the previous ones
28
- // a class defined as an array is merged with the previous ones
29
- if (Array.isArray(propsLevel.class)) fullProps.class = fullProps.class.concat(propsLevel.class)
30
- else fullProps.class = [propsLevel.class]
31
- } else {
32
- fullProps[camelize(key)] = propsLevel[key]
33
- }
34
- }
35
- }
36
- }
37
- return fullProps
38
- }
39
-
40
- // calculate the props of a field/input type component (text fields, etc)
41
- // isMainComp is used to determine if this input component is also the main rendered component or if is mostly a wrapper (date picker, etc.)
42
- /**
43
- * @param {import('../types.js').VjsfNode} node
44
- * @param {import('../types.js').VjsfStatefulLayout} statefulLayout
45
- * @param {(string | [string, string])[]} [layoutPropsMap]
46
- * @param {boolean} [isMainComp]
47
- * @returns {Record<string, any>}
48
- */
49
- export function getInputProps (node, statefulLayout, layoutPropsMap, isMainComp = true) {
50
- const options = node.options
51
- /** @type {(Record<string, any> | undefined)[]} */
52
- const propsLevels = []
53
- if (options.density === 'compact') propsLevels.push(defaultProps.fieldPropsCompact)
54
- if (node.options.readOnly) propsLevels.push(defaultProps.fieldPropsReadOnly)
55
- if (isMainComp && node.props) propsLevels.push(node.props)
56
-
57
- const fullProps = mergePropsLevels(propsLevels)
58
-
59
- fullProps.label = node.layout.label
60
- if (node.error && node.validated) {
61
- fullProps.errorMessages = node.error
62
- }
63
- fullProps.modelValue = (typeof node.data === 'string' && node.layout.separator) ? node.data.split(/** @type {string} */(node.layout.separator)) : node.data
64
- if (node.options.readOnly) {
65
- fullProps.disabled = true
66
- fullProps.class.push('vjsf-input--readonly')
67
- }
68
- if (node.autofocus) {
69
- fullProps.class.push('vjsf-input--autofocus')
70
- }
71
-
72
- if (layoutPropsMap) {
73
- for (const propMap of layoutPropsMap) {
74
- if (typeof propMap === 'string') {
75
- if (propMap in node.layout) fullProps[propMap] = node.layout[propMap]
76
- } else {
77
- if (propMap[1] in node.layout) fullProps[propMap[0]] = node.layout[propMap[1]]
78
- }
79
- }
80
- }
81
-
82
- if (isMainComp) {
83
- fullProps['onUpdate:modelValue'] = (/** @type string */value) => {
84
- return statefulLayout.input(node, (Array.isArray(value) && node.layout.separator) ? value.join(/** @type {string} */(node.layout.separator)) : value)
85
- }
86
- fullProps.onBlur = () => statefulLayout.blur(node)
87
- }
88
-
89
- return fullProps
90
- }
91
-
92
- // calculate the props of components that are not of the field category
93
- /**
94
- * @param {import('@json-layout/core').StateNode} node
95
- * @param {boolean} isMainComp
96
- * @returns {Record<string, any>}
97
- */
98
- export function getCompProps (node, isMainComp = true) {
99
- const options = /** @type import('../types.js').VjsfOptions */(node.options)
100
- /** @type {(Record<string, any> | undefined)[]} */
101
- const propsLevels = [{ density: options.density }]
102
- if (isMainComp) propsLevels.push(node.layout.props)
103
- const fullProps = mergePropsLevels(propsLevels)
104
- return fullProps
105
- }
106
-
107
- /**
108
- * shared between select and autocomplete components
109
- * @param {import('../types.js').VjsfNode} node
110
- * @param {import('../types.js').VjsfStatefulLayout} statefulLayout
111
- * @returns {Record<string, any>}
112
- */
113
- export function getSelectProps (node, statefulLayout) {
114
- const fullProps = getInputProps(node, statefulLayout, ['multiple'], false)
115
- if (node.options.readOnly) fullProps.menuProps = { modelValue: false }
116
- fullProps.clearable = fullProps.clearable ?? !node.skeleton.required
117
- fullProps.valueComparator = (/** @type {any} */a, /** @type {any} */b) => {
118
- const aKey = typeof a === 'object' ? statefulLayout.prepareSelectItem(node, a).key : a
119
- const bKey = typeof b === 'object' ? statefulLayout.prepareSelectItem(node, b).key : b
120
- return aKey === bKey
121
- }
122
- fullProps['onUpdate:modelValue'] = (/** @type string */value) => {
123
- // fix some weird case where vuetify only keep the title property of an unknown item
124
- if (Array.isArray(value) && Array.isArray(node.data)) {
125
- for (let i = 0; i < node.data.length; i++) {
126
- if (typeof node.data[i] === 'object' && typeof value[i] === 'string') {
127
- value[i] = node.data[i]
128
- }
129
- }
130
- }
131
-
132
- return statefulLayout.input(node, (Array.isArray(value) && node.layout.separator) ? value.join(/** @type {string} */(node.layout.separator)) : value)
133
- }
134
- fullProps.onBlur = () => statefulLayout.blur(node)
135
- return fullProps
136
- }
@@ -1,46 +0,0 @@
1
- import { h } from 'vue'
2
- import NodeSlot from '../components/fragments/node-slot.vue'
3
- import SelectItem from '../components/fragments/select-item.vue'
4
- import SelectSelection from '../components/fragments/select-selection.vue'
5
-
6
- // calculate the slots of components
7
- /**
8
- * @param {import('../types.js').VjsfNode} node
9
- * @param {import('../types.js').VjsfStatefulLayout} statefulLayout
10
- * @returns {Record<string, any>}
11
- */
12
- export function getCompSlots (node, statefulLayout) {
13
- if (!node.layout.slots) return {}
14
- /** @type {Record<string, any>} */
15
- const slots = {}
16
- for (const [key, layoutSlot] of Object.entries(node.layout.slots)) {
17
- slots[key] = () => h(NodeSlot, { layoutSlot, node, statefulLayout })
18
- }
19
- return slots
20
- }
21
-
22
- /**
23
- * shared between select and autocomplete components
24
- * @param {import('../types.js').VjsfSelectNode} node
25
- * @param {import('../types.js').VjsfStatefulLayout} statefulLayout
26
- * @param {any} getItems
27
- * @returns {Record<string, any>}
28
- */
29
- export function getSelectSlots (node, statefulLayout, getItems) {
30
- const slots = getCompSlots(node, statefulLayout)
31
- if (!slots.item) {
32
- slots.item = (/** @type {any} */ context) => h(SelectItem, {
33
- multiple: node.layout.multiple,
34
- itemProps: context.props,
35
- item: context.item.raw
36
- })
37
- }
38
- if (!slots.selection) {
39
- slots.selection = (/** @type {any} */ context) => h(SelectSelection, {
40
- multiple: node.layout.multiple,
41
- last: node.layout.multiple && context.index === node.data.length - 1,
42
- item: getItems.prepareSelectedItem(context.item.raw, context.item.value)
43
- })
44
- }
45
- return slots
46
- }