@dative-gpi/foundation-shared-components 1.0.34 → 1.0.36

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.
@@ -2,6 +2,7 @@
2
2
  <FSAutocompleteField
3
3
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
4
4
  :multiple="$props.multiple"
5
+ :placeholder="placeholder"
5
6
  :loading="loading"
6
7
  :items="languages"
7
8
  :modelValue="$props.modelValue"
@@ -9,64 +10,33 @@
9
10
  v-bind="$attrs"
10
11
  >
11
12
  <template
12
- #autocomplete-selection="{ item }"
13
+ #item-prepend="{ item }"
13
14
  >
14
- <FSRow
15
- v-if="$props.modelValue"
16
- align="center-center"
17
- :wrap="false"
15
+ <FSIcon
16
+ v-if="item.icon"
18
17
  >
19
- <FSIcon
20
- v-if="item.raw.icon"
21
- >
22
- {{ item.raw.icon }}
23
- </FSIcon>
24
- <FSSpan>
25
- {{ item.raw.label }}
26
- </FSSpan>
27
- </FSRow>
28
- </template>
29
- <template
30
- #item-label="{ item, font }"
31
- >
32
- <FSRow
33
- align="center-left"
34
- :wrap="false"
35
- >
36
- <FSIcon
37
- v-if="item.raw.icon"
38
- >
39
- {{ item.raw.icon }}
40
- </FSIcon>
41
- <FSSpan
42
- :font="font"
43
- >
44
- {{ item.raw.label }}
45
- </FSSpan>
46
- </FSRow>
18
+ {{ item.icon }}
19
+ </FSIcon>
47
20
  </template>
48
21
  </FSAutocompleteField>
49
22
  </template>
50
23
 
51
24
  <script lang="ts">
52
- import { computed, defineComponent, type PropType } from "vue"
25
+ import { computed, defineComponent, type PropType } from "vue";
53
26
 
54
27
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
55
28
  import { type LanguageFilters } from "@dative-gpi/foundation-shared-domain/models";
29
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
56
30
  import { useLanguages } from "@dative-gpi/foundation-shared-services/composables";
57
31
 
58
32
  import FSAutocompleteField from "../fields/FSAutocompleteField.vue";
59
33
  import FSIcon from "../FSIcon.vue";
60
- import FSSpan from "../FSSpan.vue";
61
- import FSRow from "../FSRow.vue";
62
34
 
63
35
  export default defineComponent({
64
36
  name: "FSAutocompleteLanguage",
65
37
  components: {
66
38
  FSAutocompleteField,
67
- FSIcon,
68
- FSSpan,
69
- FSRow
39
+ FSIcon
70
40
  },
71
41
  props: {
72
42
  languageFilters: {
@@ -93,11 +63,19 @@ export default defineComponent({
93
63
  emits: ["update:modelValue"],
94
64
  setup(props, { emit }) {
95
65
  const { getMany: getManyLanguages, fetching: fetchingLanguages, entities: languages } = useLanguages();
66
+ const { $tr } = useTranslationsProvider();
96
67
 
97
68
  const loading = computed((): boolean => {
98
69
  return init.value && fetchingLanguages.value;
99
70
  });
100
71
 
72
+ const placeholder = computed((): string | null => {
73
+ if (props.multiple && props.modelValue) {
74
+ return $tr("ui.autocomplete-language.placeholder", "{0} language(s) selected", props.modelValue.length);
75
+ }
76
+ return null;
77
+ });
78
+
101
79
  const fetch = (search: string | null) => {
102
80
  return getManyLanguages({ ...props.languageFilters, search: search ?? undefined });
103
81
  };
@@ -110,6 +88,7 @@ export default defineComponent({
110
88
  );
111
89
 
112
90
  return {
91
+ placeholder,
113
92
  languages,
114
93
  toggleSet,
115
94
  loading,
@@ -3,6 +3,7 @@
3
3
  itemTitle="id"
4
4
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
5
5
  :multiple="$props.multiple"
6
+ :placeholder="placeholder"
6
7
  :loading="loading"
7
8
  :items="timeZones"
8
9
  :modelValue="$props.modelValue"
@@ -10,37 +11,12 @@
10
11
  v-bind="$attrs"
11
12
  >
12
13
  <template
13
- #autocomplete-selection="{ item }"
14
+ #item-append="{ item }"
14
15
  >
15
- <FSRow
16
- v-if="$props.modelValue"
17
- align="center-center"
18
- :wrap="false"
19
- >
20
- <FSChip
21
- :label="item.raw.offset"
22
- />
23
- <FSSpan>
24
- {{ item.raw.id }}
25
- </FSSpan>
26
- </FSRow>
27
- </template>
28
- <template
29
- #item-label="{ item, font }"
30
- >
31
- <FSRow
32
- align="center-left"
33
- :wrap="false"
34
- >
35
- <FSChip
36
- :label="item.raw.offset"
37
- />
38
- <FSSpan
39
- :font="font"
40
- >
41
- {{ item.raw.id }}
42
- </FSSpan>
43
- </FSRow>
16
+ <FSChip
17
+ v-if="item.offset"
18
+ :label="item.offset.split(':')[0]"
19
+ />
44
20
  </template>
45
21
  <template
46
22
  #toggle-set-item="props"
@@ -53,10 +29,10 @@
53
29
  @click="props.toggle(props.item)"
54
30
  >
55
31
  <template
56
- v-if="props.item.offset"
57
- #prepend
32
+ #append
58
33
  >
59
34
  <FSChip
35
+ v-if="props.item.offset"
60
36
  :label="props.item.offset.split(':')[0]"
61
37
  />
62
38
  </template>
@@ -70,23 +46,20 @@ import { computed, defineComponent, type PropType } from "vue";
70
46
 
71
47
  import { type TimeZoneFilters, type TimeZoneInfos } from "@dative-gpi/foundation-shared-domain/models";
72
48
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
49
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
73
50
  import { useTimeZones } from "@dative-gpi/foundation-shared-services/composables";
74
51
  import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
75
52
 
76
53
  import FSAutocompleteField from "../fields/FSAutocompleteField.vue";
77
54
  import FSButton from "../FSButton.vue";
78
55
  import FSChip from "../FSChip.vue";
79
- import FSSpan from "../FSSpan.vue";
80
- import FSRow from "../FSRow.vue";
81
56
 
82
57
  export default defineComponent({
83
58
  name: "FSAutocompleteTimeZone",
84
59
  components: {
85
60
  FSAutocompleteField,
86
61
  FSButton,
87
- FSChip,
88
- FSSpan,
89
- FSRow
62
+ FSChip
90
63
  },
91
64
  props: {
92
65
  timeZoneFilters: {
@@ -113,11 +86,19 @@ export default defineComponent({
113
86
  emits: ["update:modelValue"],
114
87
  setup(props, { emit }) {
115
88
  const { getMany: getManyTimeZones, fetching: fetchingTimeZones, entities: timeZones } = useTimeZones();
89
+ const { $tr } = useTranslationsProvider();
116
90
 
117
91
  const loading = computed((): boolean => {
118
92
  return init.value && fetchingTimeZones.value;
119
93
  });
120
94
 
95
+ const placeholder = computed((): string | null => {
96
+ if (props.multiple && props.modelValue) {
97
+ return $tr("ui.autocomplete-time-zone.placeholder", "{0} time zone(s) selected", props.modelValue.length);
98
+ }
99
+ return null;
100
+ });
101
+
121
102
  const fetch = (search: string | null) => {
122
103
  return getManyTimeZones({ ...props.timeZoneFilters, search: search ?? undefined });
123
104
  };
@@ -133,6 +114,7 @@ export default defineComponent({
133
114
  );
134
115
 
135
116
  return {
117
+ placeholder,
136
118
  ColorEnum,
137
119
  timeZones,
138
120
  toggleSet,