@dative-gpi/foundation-shared-components 0.0.223 → 0.0.225
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/components/FSDialog.vue
CHANGED
|
@@ -34,7 +34,7 @@ import { computed, defineComponent } from "vue";
|
|
|
34
34
|
|
|
35
35
|
import { useBreakpoints } from "@dative-gpi/foundation-shared-components/composables";
|
|
36
36
|
|
|
37
|
-
import FSDialogContent from "./FSDialogContent";
|
|
37
|
+
import FSDialogContent from "./FSDialogContent.vue";
|
|
38
38
|
|
|
39
39
|
export default defineComponent({
|
|
40
40
|
name: "FSDialog",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
:label="label"
|
|
6
6
|
:items="innerItems"
|
|
7
7
|
:multiple="true"
|
|
8
|
-
:modelValue="modelValue"
|
|
9
|
-
@update:modelValue="
|
|
8
|
+
:modelValue="modelValue?.map(m=>m.id)"
|
|
9
|
+
@update:modelValue="onUpdateModelValue"
|
|
10
10
|
@keydown="onKeydown"
|
|
11
11
|
v-binds="$attrs"
|
|
12
12
|
>
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
:label="label"
|
|
21
21
|
:items="innerItems"
|
|
22
22
|
:multiple="true"
|
|
23
|
-
:modelValue="modelValue"
|
|
23
|
+
:modelValue="modelValue?.map(m=>m.id)"
|
|
24
24
|
:showSearch="true"
|
|
25
|
-
@update:modelValue="
|
|
25
|
+
@update:modelValue="onUpdateModelValue"
|
|
26
26
|
@add:item="onAddItem"
|
|
27
27
|
@keydown="onKeydown"
|
|
28
28
|
v-binds="$attrs"
|
|
@@ -34,14 +34,15 @@
|
|
|
34
34
|
</FSAutocompleteField>
|
|
35
35
|
<FSTagGroup
|
|
36
36
|
v-if="modelValue != null"
|
|
37
|
-
:tags="
|
|
37
|
+
:tags="modelValue?.map((v) => v.label) ?? []"
|
|
38
38
|
@remove="onRemoveValue($event)"
|
|
39
39
|
/>
|
|
40
40
|
</FSCol>
|
|
41
41
|
</template>
|
|
42
42
|
|
|
43
43
|
<script lang="ts">
|
|
44
|
-
import {
|
|
44
|
+
import type { PropType } from "vue";
|
|
45
|
+
import { computed, defineComponent, ref, watch } from "vue";
|
|
45
46
|
|
|
46
47
|
import { uuidv4 } from '@dative-gpi/bones-ui';
|
|
47
48
|
|
|
@@ -55,12 +56,12 @@ export default defineComponent({
|
|
|
55
56
|
},
|
|
56
57
|
props:{
|
|
57
58
|
modelValue: {
|
|
58
|
-
type: Array as PropType<string[] | null>,
|
|
59
|
+
type: Array as PropType<{id : string, label : string, isCustom: boolean}[] | null>,
|
|
59
60
|
required: false,
|
|
60
61
|
default: () => []
|
|
61
62
|
},
|
|
62
63
|
items: {
|
|
63
|
-
type: Array as PropType<{id : string, label : string}[]>,
|
|
64
|
+
type: Array as PropType<{id : string, label : string, isCustom: boolean}[]>,
|
|
64
65
|
required: false,
|
|
65
66
|
default: () => []
|
|
66
67
|
},
|
|
@@ -72,39 +73,45 @@ export default defineComponent({
|
|
|
72
73
|
type: String as PropType<'standard' | 'tagged'>,
|
|
73
74
|
required: false,
|
|
74
75
|
default : 'standard'
|
|
75
|
-
}
|
|
76
|
+
},
|
|
76
77
|
},
|
|
77
78
|
emits: ["update:modelValue"],
|
|
78
79
|
setup(props, {emit}) {
|
|
79
|
-
const tagValues = ref<{id : string, label : string}[]>([]);
|
|
80
80
|
|
|
81
|
-
const
|
|
82
|
-
|
|
81
|
+
const tagValues = ref<{id : string, label : string, isCustom : boolean}[]>([]);
|
|
82
|
+
|
|
83
|
+
const innerItems = computed(()=>{
|
|
84
|
+
|
|
85
|
+
if(props.variant === 'standard'){
|
|
83
86
|
return props.items
|
|
84
87
|
}
|
|
85
|
-
else
|
|
86
|
-
return props.items.concat(tagValues.value
|
|
88
|
+
else{
|
|
89
|
+
return props.items.concat(tagValues.value);
|
|
87
90
|
}
|
|
88
91
|
});
|
|
89
92
|
|
|
93
|
+
const onUpdateModelValue = (value: string[] | null) => {
|
|
94
|
+
emit('update:modelValue', value?.map((v) => innerItems.value.find((i) => i.id === v)));
|
|
95
|
+
}
|
|
96
|
+
|
|
90
97
|
const onRemoveValue = (value: string) => {
|
|
91
98
|
const idValue = innerItems.value.find((v) => v.label === value)?.id;
|
|
92
99
|
if (idValue) {
|
|
93
|
-
if
|
|
100
|
+
if(tagValues.value.map((v) => v.label).includes(value)){
|
|
94
101
|
tagValues.value = tagValues.value.filter((v) => v.label !== value);
|
|
95
102
|
}
|
|
96
|
-
emit('update:modelValue', [...props.modelValue?.filter((v) => v !== idValue) ?? []]);
|
|
103
|
+
emit('update:modelValue', [...props.modelValue?.filter((v) => v.id !== idValue) ?? []]);
|
|
97
104
|
}
|
|
98
|
-
}
|
|
105
|
+
}
|
|
99
106
|
|
|
100
107
|
const onAddItem = (value: string) => {
|
|
101
108
|
if (innerItems.value.map((v) => v.label).includes(value)) {
|
|
102
109
|
return;
|
|
103
110
|
}
|
|
104
|
-
let item = {id: uuidv4(), label: value};
|
|
111
|
+
let item = {id: uuidv4(), label: value, isCustom: true};
|
|
105
112
|
tagValues.value.push(item);
|
|
106
|
-
emit('update:modelValue', [...props.modelValue
|
|
107
|
-
}
|
|
113
|
+
emit('update:modelValue', [...props.modelValue?? [],item]);
|
|
114
|
+
}
|
|
108
115
|
|
|
109
116
|
const onKeydown = (event: KeyboardEvent) => {
|
|
110
117
|
if (event.key === 'Backspace') {
|
|
@@ -112,18 +119,20 @@ export default defineComponent({
|
|
|
112
119
|
}
|
|
113
120
|
};
|
|
114
121
|
|
|
115
|
-
watch(() => props.modelValue, () => {
|
|
116
|
-
if (
|
|
117
|
-
tagValues.value =
|
|
122
|
+
watch(() => props.modelValue, (newValue) => {
|
|
123
|
+
if (newValue) {
|
|
124
|
+
tagValues.value = props.modelValue?.filter(m=>m.isCustom) ?? [];
|
|
118
125
|
}
|
|
119
126
|
}, {immediate: true});
|
|
120
127
|
|
|
128
|
+
|
|
121
129
|
return {
|
|
122
130
|
innerItems,
|
|
123
|
-
|
|
131
|
+
onUpdateModelValue,
|
|
124
132
|
onAddItem,
|
|
133
|
+
onRemoveValue,
|
|
125
134
|
onKeydown
|
|
126
|
-
}
|
|
135
|
+
}
|
|
127
136
|
}
|
|
128
|
-
})
|
|
129
|
-
</script>
|
|
137
|
+
})
|
|
138
|
+
</script>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.225",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "0.0.
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "0.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "0.0.225",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "0.0.225"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@dative-gpi/bones-ui": "^0.0.75",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"sass": "1.71.1",
|
|
36
36
|
"sass-loader": "13.3.2"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "cbc2dac809c719bd2daf3b5fe166f51ae9b97fec"
|
|
39
39
|
}
|