@vc-shell/framework 1.0.198 → 1.0.200
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/CHANGELOG.md +26 -0
- package/dist/framework.js +9962 -9878
- package/dist/index.css +1 -1
- package/dist/locales/en.json +2 -1
- package/dist/shared/modules/dynamic/components/SchemaRender.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/Button.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/Card.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/Checkbox.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/ContentField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/CustomComponent.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/DynamicProperty.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/DynamicProperty.d.ts.map +1 -1
- package/dist/shared/modules/dynamic/components/fields/EditorField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/Fieldset.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/GalleryField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/ImageField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/InputCurrency.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/InputField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/MultivalueField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/RatingField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/SelectField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/StatusField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/SwitchField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/Table.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/TextareaField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/VideoField.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/props.d.ts +1 -1
- package/dist/shared/modules/dynamic/components/fields/storybook/Button.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/Card.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/ContentField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/EditorField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/ImageField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/InputField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/RatingField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/SelectField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/StatusField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/VideoField.stories.d.ts +3 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts +3 -3
- package/dist/shared/modules/dynamic/factories/types/index.d.ts +1 -1
- package/dist/shared/modules/dynamic/factories/types/index.d.ts.map +1 -1
- package/dist/shared/modules/dynamic/pages/dynamic-blade-form.vue.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/components/atoms/vc-card/vc-card.stories.d.ts +26 -7
- package/dist/ui/components/atoms/vc-card/vc-card.stories.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-input/vc-input.stories.d.ts +26 -7
- package/dist/ui/components/molecules/vc-input/vc-input.stories.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-input/vc-input.vue.d.ts +9 -2
- package/dist/ui/components/molecules/vc-input/vc-input.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.stories.d.ts +84 -63
- package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.stories.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.vue.d.ts +14 -10
- package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-select/vc-select.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-dynamic-property/vc-dynamic-property.vue.d.ts +3 -9
- package/dist/ui/components/organisms/vc-dynamic-property/vc-dynamic-property.vue.d.ts.map +1 -1
- package/package.json +4 -4
- package/shared/modules/dynamic/components/fields/DynamicProperty.ts +7 -3
- package/shared/modules/dynamic/factories/types/index.ts +1 -1
- package/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.vue +3 -2
- package/ui/components/molecules/vc-input/vc-input.vue +58 -18
- package/ui/components/molecules/vc-multivalue/vc-multivalue.vue +135 -84
- package/ui/components/molecules/vc-select/vc-select.vue +42 -17
- package/ui/components/organisms/vc-dynamic-property/vc-dynamic-property.vue +44 -15
|
@@ -31,94 +31,100 @@
|
|
|
31
31
|
ref="dropdownToggleRef"
|
|
32
32
|
class="vc-multivalue__field-wrapper"
|
|
33
33
|
>
|
|
34
|
-
<div
|
|
35
|
-
v-for="(item, i) in modelValue"
|
|
36
|
-
:key="`${item?.id}_${generateId()}`"
|
|
37
|
-
class="vc-multivalue__field-value-wrapper"
|
|
38
|
-
>
|
|
34
|
+
<div class="tw-items-center tw-flex tw-flex-wrap tw-flex-grow">
|
|
39
35
|
<div
|
|
40
|
-
v-
|
|
41
|
-
|
|
36
|
+
v-for="(item, i) in modelValue"
|
|
37
|
+
:key="`${item?.id}_${generateId()}`"
|
|
38
|
+
class="vc-multivalue__field-value-wrapper"
|
|
42
39
|
>
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
type === 'number'
|
|
47
|
-
? Number(item[props.optionLabel as keyof T]).toFixed(3)
|
|
48
|
-
: item[props.optionLabel as keyof T]
|
|
49
|
-
"
|
|
50
|
-
:item="item"
|
|
51
|
-
:remove="() => onDelete(i)"
|
|
40
|
+
<div
|
|
41
|
+
v-if="item"
|
|
42
|
+
class="vc-multivalue__field-value"
|
|
52
43
|
>
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
<slot
|
|
45
|
+
name="selected-item"
|
|
46
|
+
:value="formatValue(item)"
|
|
47
|
+
:item="item"
|
|
48
|
+
:remove="() => onDelete(i)"
|
|
49
|
+
>
|
|
50
|
+
<span class="tw-truncate">{{ formatValue(item) }}</span>
|
|
51
|
+
</slot>
|
|
52
|
+
<VcIcon
|
|
53
|
+
v-if="!disabled"
|
|
54
|
+
class="vc-multivalue__field-value-clear"
|
|
55
|
+
icon="fas fa-times"
|
|
56
|
+
size="s"
|
|
57
|
+
@click="onDelete(i)"
|
|
58
|
+
></VcIcon>
|
|
59
|
+
</div>
|
|
66
60
|
</div>
|
|
67
|
-
</div>
|
|
68
61
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
>
|
|
77
|
-
<teleport to="body">
|
|
78
|
-
<div
|
|
79
|
-
v-if="isOpened"
|
|
80
|
-
ref="dropdownRef"
|
|
81
|
-
v-on-click-outside="[toggleDropdown, { ignore: [dropdownToggleRef] }]"
|
|
82
|
-
class="vc-multivalue__dropdown"
|
|
83
|
-
:style="dropdownStyle"
|
|
62
|
+
<template v-if="multivalue">
|
|
63
|
+
<div class="vc-multivalue__field vc-multivalue__field_dictionary tw-grow tw-basis-0 tw-p-2">
|
|
64
|
+
<VcButton
|
|
65
|
+
small
|
|
66
|
+
:disabled="disabled"
|
|
67
|
+
@click.stop="toggleDropdown"
|
|
68
|
+
>Add +</VcButton
|
|
84
69
|
>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
ref="root"
|
|
93
|
-
:no-padding="true"
|
|
70
|
+
<teleport to="body">
|
|
71
|
+
<div
|
|
72
|
+
v-if="isOpened"
|
|
73
|
+
ref="dropdownRef"
|
|
74
|
+
v-on-click-outside="[toggleDropdown, { ignore: [dropdownToggleRef] }]"
|
|
75
|
+
class="vc-multivalue__dropdown"
|
|
76
|
+
:style="dropdownStyle"
|
|
94
77
|
>
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
78
|
+
<input
|
|
79
|
+
ref="searchRef"
|
|
80
|
+
class="vc-multivalue__search"
|
|
81
|
+
@input="onSearch"
|
|
82
|
+
/>
|
|
83
|
+
|
|
84
|
+
<VcContainer
|
|
85
|
+
ref="root"
|
|
86
|
+
:no-padding="true"
|
|
100
87
|
>
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
:
|
|
104
|
-
|
|
88
|
+
<div
|
|
89
|
+
v-for="(item, i) in slicedDictionary"
|
|
90
|
+
:key="i"
|
|
91
|
+
class="vc-multivalue__item"
|
|
92
|
+
@click="onItemSelect(item)"
|
|
105
93
|
>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
94
|
+
<slot
|
|
95
|
+
name="option"
|
|
96
|
+
:item="item"
|
|
97
|
+
>{{ item[optionLabel as keyof T] }}</slot
|
|
98
|
+
>
|
|
99
|
+
</div>
|
|
100
|
+
</VcContainer>
|
|
101
|
+
</div>
|
|
102
|
+
</teleport>
|
|
103
|
+
</div>
|
|
104
|
+
</template>
|
|
105
|
+
<template v-else>
|
|
106
|
+
<input
|
|
107
|
+
v-model="value"
|
|
108
|
+
class="vc-multivalue__field tw-grow tw-basis-0 tw-px-3"
|
|
109
|
+
:placeholder="placeholder"
|
|
110
|
+
:type="internalTypeComputed"
|
|
111
|
+
:disabled="disabled"
|
|
112
|
+
@keypress.enter.stop.prevent="onInput"
|
|
113
|
+
@blur="onInput"
|
|
114
|
+
@keydown="onKeyDown"
|
|
115
|
+
/>
|
|
116
|
+
</template>
|
|
117
|
+
</div>
|
|
118
|
+
<!-- Loading-->
|
|
119
|
+
<div
|
|
120
|
+
v-if="loading"
|
|
121
|
+
class="tw-flex tw-items-center tw-flex-nowrap tw-px-3 tw-text-[color:var(--select-clear-color)]"
|
|
122
|
+
>
|
|
123
|
+
<VcIcon
|
|
124
|
+
icon="fas fa-circle-notch tw-animate-spin"
|
|
125
|
+
size="m"
|
|
126
|
+
></VcIcon>
|
|
127
|
+
</div>
|
|
122
128
|
</div>
|
|
123
129
|
|
|
124
130
|
<Transition
|
|
@@ -160,7 +166,7 @@ export interface Props<T> {
|
|
|
160
166
|
modelValue?: T[];
|
|
161
167
|
required?: boolean;
|
|
162
168
|
disabled?: boolean;
|
|
163
|
-
type?: "text" | "number";
|
|
169
|
+
type?: "text" | "number" | "integer";
|
|
164
170
|
label?: string;
|
|
165
171
|
tooltip?: string;
|
|
166
172
|
name?: string;
|
|
@@ -173,6 +179,7 @@ export interface Props<T> {
|
|
|
173
179
|
errorMessage?: string;
|
|
174
180
|
multilanguage?: boolean;
|
|
175
181
|
currentLanguage?: string;
|
|
182
|
+
loading?: boolean;
|
|
176
183
|
}
|
|
177
184
|
|
|
178
185
|
export interface Emits<T> {
|
|
@@ -204,7 +211,7 @@ const props = withDefaults(defineProps<Props<T>>(), {
|
|
|
204
211
|
const emit = defineEmits<Emits<T>>();
|
|
205
212
|
defineSlots<{
|
|
206
213
|
option: (args: { item: T }) => any;
|
|
207
|
-
"selected-item": (args: { value: string | T[keyof T]; item: T; remove: () => void }) => any;
|
|
214
|
+
"selected-item": (args: { value: string | number | T[keyof T]; item: T; remove: () => void }) => any;
|
|
208
215
|
hint: void;
|
|
209
216
|
error: void;
|
|
210
217
|
}>();
|
|
@@ -215,6 +222,7 @@ const root = ref();
|
|
|
215
222
|
const searchRef = ref();
|
|
216
223
|
const isOpened = ref(false);
|
|
217
224
|
const value = ref();
|
|
225
|
+
const internalType = ref(unref(props.type));
|
|
218
226
|
|
|
219
227
|
const popper = useFloating(dropdownToggleRef, dropdownRef, {
|
|
220
228
|
placement: "bottom",
|
|
@@ -243,8 +251,46 @@ const slicedDictionary = computed(() => {
|
|
|
243
251
|
});
|
|
244
252
|
});
|
|
245
253
|
|
|
246
|
-
|
|
254
|
+
const formatValue = computed(() => {
|
|
255
|
+
return (item: T) => {
|
|
256
|
+
if (props.type === "number") {
|
|
257
|
+
return Number(item[props.optionLabel as keyof T]).toFixed(3);
|
|
258
|
+
} else if (props.type === "integer") {
|
|
259
|
+
return Math.trunc(+item[props.optionLabel as keyof T]);
|
|
260
|
+
} else {
|
|
261
|
+
return item[props.optionLabel as keyof T];
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
const internalTypeComputed = computed({
|
|
267
|
+
get() {
|
|
268
|
+
if (internalType.value === "integer") {
|
|
269
|
+
return "number";
|
|
270
|
+
}
|
|
271
|
+
return internalType.value;
|
|
272
|
+
},
|
|
273
|
+
set(value) {
|
|
274
|
+
internalType.value = value;
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
function onKeyDown(e: KeyboardEvent) {
|
|
279
|
+
const allowedKeys = ["Backspace", "Delete", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Enter"];
|
|
280
|
+
const keypressed = e.key;
|
|
281
|
+
if (props.type === "integer") {
|
|
282
|
+
if (!/^\d$/.test(keypressed) && !allowedKeys.includes(keypressed)) {
|
|
283
|
+
e.preventDefault();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function onInput(e: KeyboardEvent | FocusEvent) {
|
|
247
290
|
const newValue = (e.target as HTMLInputElement).value;
|
|
291
|
+
if (newValue === "" || newValue === undefined || newValue === null) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
248
294
|
emit("update:model-value", [...props.modelValue, { [props.optionLabel]: newValue } as T]);
|
|
249
295
|
value.value = undefined;
|
|
250
296
|
}
|
|
@@ -356,8 +402,7 @@ function onSearch(event: Event) {
|
|
|
356
402
|
tw-rounded-[var(--multivalue-border-radius)]
|
|
357
403
|
tw-bg-[color:var(--multivalue-background-color)]
|
|
358
404
|
tw-items-center
|
|
359
|
-
tw-flex
|
|
360
|
-
tw-flex-wrap;
|
|
405
|
+
tw-flex tw-justify-between;
|
|
361
406
|
}
|
|
362
407
|
|
|
363
408
|
&__dropdown {
|
|
@@ -408,6 +453,12 @@ function onSearch(event: Event) {
|
|
|
408
453
|
@apply tw-text-[color:var(--multivalue-placeholder-color)];
|
|
409
454
|
}
|
|
410
455
|
|
|
456
|
+
&[type="number"]::-webkit-inner-spin-button,
|
|
457
|
+
&[type="number"]::-webkit-outer-spin-button {
|
|
458
|
+
-webkit-appearance: none;
|
|
459
|
+
margin: 0;
|
|
460
|
+
}
|
|
461
|
+
|
|
411
462
|
&-value-wrapper {
|
|
412
463
|
@apply tw-min-h-[var(--multivalue-height)] tw-ml-2 tw-flex tw-items-center;
|
|
413
464
|
}
|
|
@@ -76,7 +76,6 @@
|
|
|
76
76
|
<div class="tw-flex tw-flex-wrap tw-gap-1 tw-py-1">
|
|
77
77
|
<div
|
|
78
78
|
v-for="(item, i) in selectedScope"
|
|
79
|
-
v-bind="item"
|
|
80
79
|
:key="i"
|
|
81
80
|
class="tw-flex tw-items-center"
|
|
82
81
|
>
|
|
@@ -84,12 +83,19 @@
|
|
|
84
83
|
<div
|
|
85
84
|
class="tw-bg-[#fbfdfe] tw-border tw-border-solid tw-border-[color:#bdd1df] tw-rounded-[2px] tw-flex tw-items-center tw-h-[28px] tw-box-border tw-px-2"
|
|
86
85
|
>
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
<template v-if="loading">
|
|
87
|
+
<span class="tw-text-[#a5a5a5]">{{
|
|
88
|
+
t("COMPONENTS.MOLECULES.VC_SELECT.LOADING")
|
|
89
|
+
}}</span>
|
|
90
|
+
</template>
|
|
91
|
+
<template v-else>
|
|
92
|
+
<slot
|
|
93
|
+
name="selected-item"
|
|
94
|
+
v-bind="item"
|
|
95
|
+
>
|
|
96
|
+
<span>{{ getOptionLabel(item.opt) }}</span>
|
|
97
|
+
</slot>
|
|
98
|
+
</template>
|
|
93
99
|
<VcIcon
|
|
94
100
|
v-if="!disabled"
|
|
95
101
|
class="tw-text-[#a9bfd2] tw-ml-2 tw-cursor-pointer hover:tw-text-[color:var(--select-clear-color-hover)]"
|
|
@@ -100,12 +106,23 @@
|
|
|
100
106
|
</div>
|
|
101
107
|
</template>
|
|
102
108
|
<template v-else-if="!multiple">
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
<template v-if="loading">
|
|
110
|
+
<span class="tw-text-[#a5a5a5]">{{
|
|
111
|
+
t("COMPONENTS.MOLECULES.VC_SELECT.LOADING")
|
|
112
|
+
}}</span>
|
|
113
|
+
</template>
|
|
114
|
+
<template v-else>
|
|
115
|
+
<slot
|
|
116
|
+
name="selected-item"
|
|
117
|
+
v-bind="item"
|
|
118
|
+
>
|
|
119
|
+
{{
|
|
120
|
+
loading
|
|
121
|
+
? t("COMPONENTS.MOLECULES.VC_SELECT.LOADING")
|
|
122
|
+
: getEmittingOptionValue(item.opt)
|
|
123
|
+
}}
|
|
124
|
+
</slot>
|
|
125
|
+
</template>
|
|
109
126
|
</template>
|
|
110
127
|
</div>
|
|
111
128
|
</div>
|
|
@@ -140,7 +157,7 @@
|
|
|
140
157
|
class="tw-flex tw-items-center tw-flex-nowrap tw-pl-3 tw-text-[color:var(--select-clear-color)]"
|
|
141
158
|
>
|
|
142
159
|
<VcIcon
|
|
143
|
-
icon="fas fa-
|
|
160
|
+
icon="fas fa-circle-notch tw-animate-spin"
|
|
144
161
|
size="m"
|
|
145
162
|
></VcIcon>
|
|
146
163
|
</div>
|
|
@@ -715,9 +732,17 @@ const dropdownStyle = computed(() => {
|
|
|
715
732
|
function getPropValueFn(propValue: OptionProp<Option>, defaultVal: OptionProp<Option>) {
|
|
716
733
|
const val = propValue !== undefined ? propValue : defaultVal;
|
|
717
734
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
735
|
+
if (typeof val === "function") {
|
|
736
|
+
return val;
|
|
737
|
+
} else {
|
|
738
|
+
return (opt: Option) => {
|
|
739
|
+
if (opt !== null && typeof opt === "object" && val && val in opt) {
|
|
740
|
+
return opt[val as keyof Option];
|
|
741
|
+
} else {
|
|
742
|
+
return opt;
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
}
|
|
721
746
|
}
|
|
722
747
|
|
|
723
748
|
function getOption(value: Option, valueCache: Option[]) {
|
|
@@ -65,8 +65,9 @@
|
|
|
65
65
|
:current-language="currentLanguage"
|
|
66
66
|
:options="items"
|
|
67
67
|
:option-label="multilanguage ? 'value' : 'alias'"
|
|
68
|
-
option-value="
|
|
68
|
+
:option-value="multilanguage ? 'value' : 'alias'"
|
|
69
69
|
:multivalue="computedProperty.multivalue"
|
|
70
|
+
:loading="loading"
|
|
70
71
|
@search="onSearch"
|
|
71
72
|
@close="onClose"
|
|
72
73
|
></VcMultivalue>
|
|
@@ -82,7 +83,6 @@
|
|
|
82
83
|
:required="computedProperty.required"
|
|
83
84
|
:placeholder="computedProperty.displayName || 'Add value'"
|
|
84
85
|
:disabled="disabled"
|
|
85
|
-
:multilanguage="multilanguage"
|
|
86
86
|
:current-language="currentLanguage"
|
|
87
87
|
:loading="loading"
|
|
88
88
|
></VcInput>
|
|
@@ -98,6 +98,8 @@
|
|
|
98
98
|
type="number"
|
|
99
99
|
:error="!!errors.length"
|
|
100
100
|
:error-message="errorMessage"
|
|
101
|
+
option-label="value"
|
|
102
|
+
option-value="value"
|
|
101
103
|
:options="items"
|
|
102
104
|
></VcMultivalue>
|
|
103
105
|
</template>
|
|
@@ -109,9 +111,11 @@
|
|
|
109
111
|
:required="computedProperty.required"
|
|
110
112
|
placeholder="Add value"
|
|
111
113
|
:disabled="disabled"
|
|
112
|
-
type="
|
|
114
|
+
type="integer"
|
|
113
115
|
:error="!!errors.length"
|
|
114
116
|
:error-message="errorMessage"
|
|
117
|
+
option-label="value"
|
|
118
|
+
option-value="value"
|
|
115
119
|
:options="items"
|
|
116
120
|
></VcMultivalue>
|
|
117
121
|
</template>
|
|
@@ -138,7 +142,7 @@
|
|
|
138
142
|
:error-message="errorMessage"
|
|
139
143
|
:label="computedProperty.displayName"
|
|
140
144
|
clearable
|
|
141
|
-
type="
|
|
145
|
+
type="integer"
|
|
142
146
|
step="1"
|
|
143
147
|
:required="computedProperty.required"
|
|
144
148
|
:placeholder="computedProperty.placeholder"
|
|
@@ -169,7 +173,6 @@
|
|
|
169
173
|
:required="computedProperty.required"
|
|
170
174
|
:placeholder="computedProperty.placeholder"
|
|
171
175
|
:disabled="disabled"
|
|
172
|
-
:multilanguage="multilanguage"
|
|
173
176
|
:current-language="currentLanguage"
|
|
174
177
|
></VcTextarea
|
|
175
178
|
></template>
|
|
@@ -190,10 +193,11 @@
|
|
|
190
193
|
|
|
191
194
|
<!-- eslint-disable @typescript-eslint/no-explicit-any -->
|
|
192
195
|
<script lang="ts" setup generic="T extends { [x: string]: any; id?: string }">
|
|
193
|
-
import { ref, onMounted, computed, Ref } from "vue";
|
|
196
|
+
import { ref, onMounted, computed, Ref, watch } from "vue";
|
|
194
197
|
import { Field } from "vee-validate";
|
|
195
198
|
import { useI18n } from "vue-i18n";
|
|
196
199
|
import { VcSelect, VcInput, VcTextarea, VcCheckbox } from "./../../";
|
|
200
|
+
import * as _ from "lodash-es";
|
|
197
201
|
|
|
198
202
|
type IValidationRules = {
|
|
199
203
|
required?: boolean;
|
|
@@ -206,7 +210,11 @@ const props = withDefaults(
|
|
|
206
210
|
defineProps<{
|
|
207
211
|
property: T;
|
|
208
212
|
modelValue: any;
|
|
209
|
-
optionsGetter: (
|
|
213
|
+
optionsGetter: (
|
|
214
|
+
propertyId: string,
|
|
215
|
+
keyword?: string,
|
|
216
|
+
locale?: string,
|
|
217
|
+
) => Promise<any[] | undefined> | any[] | undefined;
|
|
210
218
|
required: boolean;
|
|
211
219
|
multivalue?: boolean;
|
|
212
220
|
multilanguage?: boolean;
|
|
@@ -236,9 +244,7 @@ const props = withDefaults(
|
|
|
236
244
|
);
|
|
237
245
|
|
|
238
246
|
const emit = defineEmits<{
|
|
239
|
-
"update:model-value": [
|
|
240
|
-
data: { readonly property: T; readonly value: any; readonly dictionary?: any[]; readonly locale?: string },
|
|
241
|
-
];
|
|
247
|
+
"update:model-value": [data: { readonly value: any; readonly dictionary?: any[]; readonly locale?: string }];
|
|
242
248
|
}>();
|
|
243
249
|
|
|
244
250
|
const { locale, te, t } = useI18n({ useScope: "global" });
|
|
@@ -246,6 +252,30 @@ const { locale, te, t } = useI18n({ useScope: "global" });
|
|
|
246
252
|
const items: Ref<any[]> = ref([]);
|
|
247
253
|
const loading = ref(false);
|
|
248
254
|
const initialOptions = ref<any[]>([]);
|
|
255
|
+
const internalProperty = ref(props.property) as Ref<typeof props.property>;
|
|
256
|
+
const internalModel = ref(props.modelValue) as Ref<typeof props.modelValue>;
|
|
257
|
+
|
|
258
|
+
watch(
|
|
259
|
+
() => props.property,
|
|
260
|
+
(newVal) => {
|
|
261
|
+
internalProperty.value = _.cloneDeep(newVal);
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
deep: true,
|
|
265
|
+
immediate: true,
|
|
266
|
+
},
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
watch(
|
|
270
|
+
() => props.modelValue,
|
|
271
|
+
(newVal) => {
|
|
272
|
+
internalModel.value = _.cloneDeep(newVal);
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
deep: true,
|
|
276
|
+
immediate: true,
|
|
277
|
+
},
|
|
278
|
+
);
|
|
249
279
|
|
|
250
280
|
const computedProperty = computed(() => {
|
|
251
281
|
const rules: IValidationRules = {};
|
|
@@ -278,7 +308,7 @@ const computedProperty = computed(() => {
|
|
|
278
308
|
dictionary: props.dictionary || false,
|
|
279
309
|
multivalue: props.multivalue || false,
|
|
280
310
|
name: props.multilanguage ? props.name + "_" + props.currentLanguage : props.name,
|
|
281
|
-
key: props.multilanguage ?
|
|
311
|
+
key: props.multilanguage ? internalProperty.value.id + "_" + props.currentLanguage : internalProperty.value.id,
|
|
282
312
|
displayName: propertyDisplayNameLocalized,
|
|
283
313
|
optionValue: props.optionsValue,
|
|
284
314
|
optionLabel: optionLabelField,
|
|
@@ -289,11 +319,10 @@ const computedProperty = computed(() => {
|
|
|
289
319
|
|
|
290
320
|
const value = computed({
|
|
291
321
|
get() {
|
|
292
|
-
return
|
|
322
|
+
return internalModel.value;
|
|
293
323
|
},
|
|
294
324
|
set(newValue) {
|
|
295
325
|
emit("update:model-value", {
|
|
296
|
-
property: props.property,
|
|
297
326
|
value: newValue,
|
|
298
327
|
dictionary: items.value,
|
|
299
328
|
locale: props.currentLanguage,
|
|
@@ -307,10 +336,10 @@ onMounted(async () => {
|
|
|
307
336
|
});
|
|
308
337
|
|
|
309
338
|
async function getOptions(keyword: string | undefined = undefined) {
|
|
310
|
-
if (props.optionsGetter) {
|
|
339
|
+
if (props.optionsGetter && internalProperty.value.dictionary && internalProperty.value.id) {
|
|
311
340
|
try {
|
|
312
341
|
loading.value = true;
|
|
313
|
-
const res = await props.optionsGetter(
|
|
342
|
+
const res = await props.optionsGetter(internalProperty.value.id, keyword, props.currentLanguage);
|
|
314
343
|
|
|
315
344
|
if (res) {
|
|
316
345
|
items.value = res;
|