@dative-gpi/foundation-shared-components 1.0.34 → 1.0.35
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/autocompletes/FSAutocompleteLanguage.vue +18 -39
- package/components/autocompletes/FSAutocompleteTimeZone.vue +19 -37
- package/components/fields/FSAutocompleteField.vue +419 -251
- package/components/fields/FSAutocompleteTag.vue +100 -0
- package/components/fields/FSTextField.vue +11 -7
- package/composables/useAddress.ts +2 -2
- package/package.json +4 -4
- package/components/autocompletes/FSAutocompleteTag.vue +0 -138
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FSAutocompleteField
|
|
3
|
+
:placeholder="innerPlaceholder"
|
|
4
|
+
:items="innerItems"
|
|
5
|
+
:showSearch="true"
|
|
6
|
+
:multiple="true"
|
|
7
|
+
:modelValue="modelValue?.map(m => m.id)"
|
|
8
|
+
@update:modelValue="onUpdateModelValue"
|
|
9
|
+
@add:item="onAddItem"
|
|
10
|
+
@keydown="onKeydown"
|
|
11
|
+
v-bind="$attrs"
|
|
12
|
+
>
|
|
13
|
+
<template
|
|
14
|
+
v-for="(_, name) in $slots"
|
|
15
|
+
v-slot:[name]="slotData"
|
|
16
|
+
>
|
|
17
|
+
<slot
|
|
18
|
+
:name="name"
|
|
19
|
+
v-bind="slotData"
|
|
20
|
+
/>
|
|
21
|
+
</template>
|
|
22
|
+
</FSAutocompleteField>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script lang="ts">
|
|
26
|
+
import { computed, defineComponent, type PropType, ref, watch } from "vue";
|
|
27
|
+
|
|
28
|
+
import { useTranslations as useTranslationsProvider, uuidv4 } from "@dative-gpi/bones-ui";
|
|
29
|
+
|
|
30
|
+
import FSAutocompleteField from "../fields/FSAutocompleteField.vue";
|
|
31
|
+
|
|
32
|
+
export default defineComponent({
|
|
33
|
+
components: {
|
|
34
|
+
FSAutocompleteField
|
|
35
|
+
},
|
|
36
|
+
props:{
|
|
37
|
+
placeholder: {
|
|
38
|
+
type: String as PropType<string | null>,
|
|
39
|
+
required: false,
|
|
40
|
+
default: null
|
|
41
|
+
},
|
|
42
|
+
items: {
|
|
43
|
+
type: Array as PropType<{id: string, label: string, isCustom: boolean}[]>,
|
|
44
|
+
required: false,
|
|
45
|
+
default: () => []
|
|
46
|
+
},
|
|
47
|
+
modelValue: {
|
|
48
|
+
type: Array as PropType<{id: string, label: string, isCustom: boolean}[] | null>,
|
|
49
|
+
required: false,
|
|
50
|
+
default: () => []
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
emits: ["update:modelValue"],
|
|
54
|
+
setup(props, {emit}) {
|
|
55
|
+
const { $tr } = useTranslationsProvider();
|
|
56
|
+
|
|
57
|
+
const tagValues = ref<{id : string, label : string, isCustom : boolean}[]>([]);
|
|
58
|
+
|
|
59
|
+
const innerItems = computed(() => props.items.concat(tagValues.value));
|
|
60
|
+
|
|
61
|
+
const innerPlaceholder = computed((): string | null => {
|
|
62
|
+
if (!props.modelValue || props.modelValue.length === 0) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return props.placeholder ?? $tr("ui.autocomplete-tag.items-selected", "{0} item(s) selected", props.modelValue?.length ?? 0);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const onUpdateModelValue = (value: string[] | null): void => {
|
|
69
|
+
emit("update:modelValue", value?.map((v) => innerItems.value.find((i) => i.id === v)));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const onAddItem = (value: string): void => {
|
|
73
|
+
emit("update:modelValue", [
|
|
74
|
+
...props.modelValue ?? [],
|
|
75
|
+
{ id: uuidv4(), label: value, isCustom: true }
|
|
76
|
+
]);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const onKeydown = (event: KeyboardEvent): void => {
|
|
80
|
+
if (event.key === "Backspace") {
|
|
81
|
+
emit("update:modelValue", [...props.modelValue ?? []]);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
watch(() => props.modelValue, (newValue) => {
|
|
86
|
+
if (newValue) {
|
|
87
|
+
tagValues.value = props.modelValue?.filter(m=>m.isCustom) ?? [];
|
|
88
|
+
}
|
|
89
|
+
}, {immediate: true});
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
innerPlaceholder,
|
|
93
|
+
innerItems,
|
|
94
|
+
onUpdateModelValue,
|
|
95
|
+
onAddItem,
|
|
96
|
+
onKeydown
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
</script>
|
|
@@ -52,13 +52,17 @@
|
|
|
52
52
|
<template
|
|
53
53
|
#clear
|
|
54
54
|
>
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
<slot
|
|
56
|
+
name="clear"
|
|
57
|
+
>
|
|
58
|
+
<FSButton
|
|
59
|
+
v-if="$props.clearable && $props.editable && !!$props.modelValue"
|
|
60
|
+
icon="mdi-close"
|
|
61
|
+
variant="icon"
|
|
62
|
+
:color="ColorEnum.Dark"
|
|
63
|
+
@click="$emit('update:modelValue', null)"
|
|
64
|
+
/>
|
|
65
|
+
</slot>
|
|
62
66
|
</template>
|
|
63
67
|
</v-text-field>
|
|
64
68
|
</FSBaseField>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Place } from "@dative-gpi/foundation-shared-domain/models";
|
|
2
|
-
import { Address } from "@dative-gpi/foundation-shared-domain/models";
|
|
3
1
|
import _ from "lodash";
|
|
4
2
|
|
|
3
|
+
import { Address, type Place } from "@dative-gpi/foundation-shared-domain/models";
|
|
4
|
+
|
|
5
5
|
export const useAddress = () => {
|
|
6
6
|
const enabled = true;
|
|
7
7
|
let initialized = false;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.35",
|
|
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": "1.0.
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "1.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "1.0.35",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "1.0.35"
|
|
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": "10111fadbf8f2207213a9d5f13ae4c3c4f71f0bc"
|
|
39
39
|
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<FSCol>
|
|
3
|
-
<FSAutocompleteField
|
|
4
|
-
v-if="variant=='standard'"
|
|
5
|
-
:label="label"
|
|
6
|
-
:items="innerItems"
|
|
7
|
-
:multiple="true"
|
|
8
|
-
:modelValue="modelValue?.map(m=>m.id)"
|
|
9
|
-
@update:modelValue="onUpdateModelValue"
|
|
10
|
-
@keydown="onKeydown"
|
|
11
|
-
v-binds="$attrs"
|
|
12
|
-
>
|
|
13
|
-
<template
|
|
14
|
-
#autocomplete-chip
|
|
15
|
-
>
|
|
16
|
-
</template>
|
|
17
|
-
</FSAutocompleteField>
|
|
18
|
-
<FSAutocompleteField
|
|
19
|
-
v-else
|
|
20
|
-
:label="label"
|
|
21
|
-
:items="innerItems"
|
|
22
|
-
:multiple="true"
|
|
23
|
-
:modelValue="modelValue?.map(m=>m.id)"
|
|
24
|
-
:showSearch="true"
|
|
25
|
-
@update:modelValue="onUpdateModelValue"
|
|
26
|
-
@add:item="onAddItem"
|
|
27
|
-
@keydown="onKeydown"
|
|
28
|
-
v-binds="$attrs"
|
|
29
|
-
>
|
|
30
|
-
<template
|
|
31
|
-
#autocomplete-chip
|
|
32
|
-
>
|
|
33
|
-
</template>
|
|
34
|
-
</FSAutocompleteField>
|
|
35
|
-
<FSTagGroup
|
|
36
|
-
v-if="modelValue != null"
|
|
37
|
-
:tags="modelValue?.map((v) => v.label) ?? []"
|
|
38
|
-
@remove="onRemoveValue($event)"
|
|
39
|
-
/>
|
|
40
|
-
</FSCol>
|
|
41
|
-
</template>
|
|
42
|
-
|
|
43
|
-
<script lang="ts">
|
|
44
|
-
import type { PropType } from "vue";
|
|
45
|
-
import { computed, defineComponent, ref, watch } from "vue";
|
|
46
|
-
|
|
47
|
-
import { uuidv4 } from '@dative-gpi/bones-ui';
|
|
48
|
-
|
|
49
|
-
import FSAutocompleteField from "../fields/FSAutocompleteField.vue";
|
|
50
|
-
import FSTagGroup from "../FSTagGroup.vue";
|
|
51
|
-
|
|
52
|
-
export default defineComponent({
|
|
53
|
-
components: {
|
|
54
|
-
FSAutocompleteField,
|
|
55
|
-
FSTagGroup,
|
|
56
|
-
},
|
|
57
|
-
props:{
|
|
58
|
-
modelValue: {
|
|
59
|
-
type: Array as PropType<{id : string, label : string, isCustom: boolean}[] | null>,
|
|
60
|
-
required: false,
|
|
61
|
-
default: () => []
|
|
62
|
-
},
|
|
63
|
-
items: {
|
|
64
|
-
type: Array as PropType<{id : string, label : string, isCustom: boolean}[]>,
|
|
65
|
-
required: false,
|
|
66
|
-
default: () => []
|
|
67
|
-
},
|
|
68
|
-
label : {
|
|
69
|
-
type: String,
|
|
70
|
-
required: false
|
|
71
|
-
},
|
|
72
|
-
variant: {
|
|
73
|
-
type: String as PropType<'standard' | 'tagged'>,
|
|
74
|
-
required: false,
|
|
75
|
-
default : 'standard'
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
emits: ["update:modelValue"],
|
|
79
|
-
setup(props, {emit}) {
|
|
80
|
-
|
|
81
|
-
const tagValues = ref<{id : string, label : string, isCustom : boolean}[]>([]);
|
|
82
|
-
|
|
83
|
-
const innerItems = computed(()=>{
|
|
84
|
-
|
|
85
|
-
if(props.variant === 'standard'){
|
|
86
|
-
return props.items
|
|
87
|
-
}
|
|
88
|
-
else{
|
|
89
|
-
return props.items.concat(tagValues.value);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const onUpdateModelValue = (value: string[] | null) => {
|
|
94
|
-
emit('update:modelValue', value?.map((v) => innerItems.value.find((i) => i.id === v)));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const onRemoveValue = (value: string) => {
|
|
98
|
-
const idValue = innerItems.value.find((v) => v.label === value)?.id;
|
|
99
|
-
if (idValue) {
|
|
100
|
-
if(tagValues.value.map((v) => v.label).includes(value)){
|
|
101
|
-
tagValues.value = tagValues.value.filter((v) => v.label !== value);
|
|
102
|
-
}
|
|
103
|
-
emit('update:modelValue', [...props.modelValue?.filter((v) => v.id !== idValue) ?? []]);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const onAddItem = (value: string) => {
|
|
108
|
-
if (innerItems.value.map((v) => v.label).includes(value)) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
let item = {id: uuidv4(), label: value, isCustom: true};
|
|
112
|
-
tagValues.value.push(item);
|
|
113
|
-
emit('update:modelValue', [...props.modelValue?? [],item]);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const onKeydown = (event: KeyboardEvent) => {
|
|
117
|
-
if (event.key === 'Backspace') {
|
|
118
|
-
emit('update:modelValue', [...props.modelValue ?? []]);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
watch(() => props.modelValue, (newValue) => {
|
|
123
|
-
if (newValue) {
|
|
124
|
-
tagValues.value = props.modelValue?.filter(m=>m.isCustom) ?? [];
|
|
125
|
-
}
|
|
126
|
-
}, {immediate: true});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
innerItems,
|
|
131
|
-
onUpdateModelValue,
|
|
132
|
-
onAddItem,
|
|
133
|
-
onRemoveValue,
|
|
134
|
-
onKeydown
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
</script>
|