@dative-gpi/foundation-shared-components 0.0.10 → 0.0.12

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 (61) hide show
  1. package/aliases/FSButton.ts +8 -6
  2. package/components/FSAutocompleteField.vue +7 -5
  3. package/components/FSBreadcrumbs.vue +3 -1
  4. package/components/FSButton.vue +30 -23
  5. package/components/FSCalendar.vue +4 -3
  6. package/components/FSCalendarTwin.vue +4 -3
  7. package/components/FSCarousel.vue +3 -1
  8. package/components/FSCheckbox.vue +5 -3
  9. package/components/FSChip.vue +5 -3
  10. package/components/FSClock.vue +5 -4
  11. package/components/FSColor.vue +3 -1
  12. package/components/FSColorIcon.vue +3 -1
  13. package/components/FSContainer.vue +4 -2
  14. package/components/FSDateField.vue +4 -3
  15. package/components/FSDateRangeField.vue +4 -3
  16. package/components/FSDateTimeField.vue +4 -3
  17. package/components/FSDateTimeRangeField.vue +4 -3
  18. package/components/FSDivider.vue +3 -1
  19. package/components/FSFadeOut.vue +3 -1
  20. package/components/FSFileButton.vue +4 -3
  21. package/components/FSIconField.vue +5 -3
  22. package/components/FSImage.vue +1 -1
  23. package/components/FSLink.vue +95 -0
  24. package/components/FSPagination.vue +80 -0
  25. package/components/FSPasswordField.vue +4 -2
  26. package/components/FSRadio.vue +5 -3
  27. package/components/FSRemoveDialog.vue +1 -1
  28. package/components/FSRichTextField.vue +7 -6
  29. package/components/FSSearchField.vue +46 -13
  30. package/components/FSSelectField.vue +5 -3
  31. package/components/FSSlideGroup.vue +2 -1
  32. package/components/FSSlider.vue +5 -3
  33. package/components/FSSubmitDialog.vue +1 -1
  34. package/components/FSSwitch.vue +6 -4
  35. package/components/FSTabs.vue +4 -3
  36. package/components/FSTag.vue +4 -2
  37. package/components/FSTagField.vue +4 -3
  38. package/components/FSText.vue +2 -1
  39. package/components/FSTextArea.vue +4 -3
  40. package/components/FSTextField.vue +5 -3
  41. package/components/FSWrapGroup.vue +2 -1
  42. package/components/deviceOrganisations/FSConnectivity.vue +2 -1
  43. package/components/deviceOrganisations/FSWorstAlert.vue +2 -1
  44. package/components/lists/FSDataTableUI.vue +5 -4
  45. package/components/lists/FSFilterButton.vue +24 -16
  46. package/components/lists/FSHiddenButton.vue +1 -0
  47. package/components/lists/FSLoadDataTable.vue +88 -0
  48. package/components/tiles/FSDeviceOrganisationTileUI.vue +1 -1
  49. package/components/tiles/FSGroupTileUI.vue +1 -1
  50. package/components/{FSLoadTile.vue → tiles/FSLoadTile.vue} +9 -7
  51. package/components/{FSTile.vue → tiles/FSTile.vue} +5 -4
  52. package/composables/index.ts +1 -0
  53. package/composables/useDebounce.ts +22 -0
  54. package/models/rules.ts +2 -1
  55. package/package.json +6 -4
  56. package/styles/components/fs_calendar.scss +2 -2
  57. package/styles/components/fs_link.scss +6 -0
  58. package/styles/components/fs_load_data_table.scss +77 -0
  59. package/styles/components/fs_pagination.scss +11 -0
  60. package/styles/components/index.scss +3 -0
  61. package/index.ts +0 -6
@@ -1,10 +1,12 @@
1
- import { useTranslationsProvider } from "@dative-gpi/foundation-shared-services";
1
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
2
2
  import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
3
3
 
4
4
  import FSButton from "@dative-gpi/foundation-shared-components/components/FSButton.vue";
5
5
 
6
6
  const { $tr } = useTranslationsProvider();
7
7
 
8
+ import { computed } from "vue";
9
+
8
10
  export const FSButtonsAliases = {
9
11
  FSButtonSearch: FSButton,
10
12
  FSButtonSearchMini: FSButton,
@@ -23,7 +25,7 @@ export const FSButtonsAliases = {
23
25
  export const FSButtonsProps = {
24
26
  FSButtonSearch: {
25
27
  prependIcon: "mdi-magnify",
26
- label: $tr("ui.button.search", "Search"),
28
+ get label() { return $tr("ui.button.search", "Search") },
27
29
  variant: "standard",
28
30
  color: ColorEnum.Primary
29
31
  },
@@ -41,7 +43,7 @@ export const FSButtonsProps = {
41
43
  },
42
44
  FSButtonRemove: {
43
45
  prependIcon: "mdi-delete-outline",
44
- label: $tr("ui.button.remove", "Remove"),
46
+ get label() { return $tr("ui.button.remove", "Remove") },
45
47
  variant: "standard",
46
48
  color: ColorEnum.Error
47
49
  },
@@ -59,7 +61,7 @@ export const FSButtonsProps = {
59
61
  },
60
62
  FSButtonSave: {
61
63
  prependIcon: "mdi-content-save-outline",
62
- label: $tr("ui.button.save", "Save"),
64
+ get label() { return $tr("ui.button.save", "Save") },
63
65
  variant: "standard",
64
66
  color: ColorEnum.Primary
65
67
  },
@@ -77,7 +79,7 @@ export const FSButtonsProps = {
77
79
  },
78
80
  FSButtonCancel: {
79
81
  prependIcon: "mdi-cancel",
80
- label: $tr("ui.button.cancel", "Cancel"),
82
+ get label() { return $tr("ui.button.cancel", "Cancel") },
81
83
  variant: "standard",
82
84
  color: ColorEnum.Light
83
85
  },
@@ -95,7 +97,7 @@ export const FSButtonsProps = {
95
97
  },
96
98
  FSButtonDocumentation: {
97
99
  prependIcon: "mdi-file-document-outline",
98
- label: $tr("ui.button.documentation", "Documentation"),
100
+ get label() { return $tr("ui.button.documentation", "Documentation") },
99
101
  variant: "standard",
100
102
  color: ColorEnum.Light
101
103
  },
@@ -142,16 +142,18 @@ export default defineComponent({
142
142
  }
143
143
  },
144
144
  emits: ["update:modelValue", "update:search"],
145
- setup: (props, { emit }) => {
145
+ setup: (props, { emit }) => {
146
+ const { getColors } = useColors();
146
147
  const { slots } = useSlots();
148
+
147
149
  delete slots.label;
148
150
  delete slots.description;
149
151
 
150
- const innerSearch = ref("");
152
+ const errors = getColors(ColorEnum.Error);
153
+ const lights = getColors(ColorEnum.Light);
154
+ const darks = getColors(ColorEnum.Dark);
151
155
 
152
- const errors = useColors().getColors(ColorEnum.Error);
153
- const lights = useColors().getColors(ColorEnum.Light);
154
- const darks = useColors().getColors(ColorEnum.Dark);
156
+ const innerSearch = ref("");
155
157
 
156
158
  const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
157
159
  if (!props.editable) {
@@ -38,7 +38,9 @@ export default defineComponent({
38
38
  }
39
39
  },
40
40
  setup() {
41
- const darks = useColors().getColors(ColorEnum.Dark);
41
+ const { getColors } = useColors();
42
+
43
+ const darks = getColors(ColorEnum.Dark);
42
44
 
43
45
  const style: Ref<{ [code: string]: string } & Partial<CSSStyleDeclaration>> = ref({
44
46
  "--fs-breadcrumbs-color": darks.dark,
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <v-btn
3
- v-if="!['icon'].includes($props.variant)"
3
+ v-if="!['icon'].includes(props.variant)"
4
4
  :ripple="false"
5
5
  :style="style"
6
6
  :class="classes"
7
- :disabled="!$props.editable"
7
+ :disabled="!props.editable"
8
8
  v-bind="$attrs"
9
9
  >
10
10
  <FSRow
@@ -12,33 +12,33 @@
12
12
  width="hug"
13
13
  :wrap="false"
14
14
  >
15
- <slot name="prepend" v-bind="{ color: $props.color, colors }">
15
+ <slot name="prepend" v-bind="{ color: props.color, colors }">
16
16
  <FSIcon
17
- v-if="$props.prependIcon"
17
+ v-if="props.prependIcon"
18
18
  size="l"
19
19
  >
20
- {{ $props.prependIcon }}
20
+ {{ props.prependIcon }}
21
21
  </FSIcon>
22
22
  </slot>
23
- <slot v-bind="{ color: $props.color, colors }">
23
+ <slot v-bind="{ color: props.color, colors }">
24
24
  <FSSpan
25
- v-if="$props.label"
25
+ v-if="props.label"
26
26
  >
27
- {{ $props.label }}
27
+ {{ props.label }}
28
28
  </FSSpan>
29
29
  </slot>
30
- <slot name="append" v-bind="{ color: $props.color, colors }">
30
+ <slot name="append" v-bind="{ color: props.color, colors }">
31
31
  <FSIcon
32
- v-if="$props.appendIcon"
32
+ v-if="props.appendIcon"
33
33
  size="l"
34
34
  >
35
- {{ $props.appendIcon }}
35
+ {{ props.appendIcon }}
36
36
  </FSIcon>
37
37
  </slot>
38
38
  </FSRow>
39
39
  </v-btn>
40
40
  <FSRow
41
- v-else-if="$props.icon"
41
+ v-else-if="props.icon"
42
42
  align="center-center"
43
43
  width="hug"
44
44
  :style="style"
@@ -48,19 +48,20 @@
48
48
  <FSIcon
49
49
  size="l"
50
50
  >
51
- {{ $props.icon }}
51
+ {{ props.icon }}
52
52
  </FSIcon>
53
53
  <FSSpan
54
- v-if="$props.label"
54
+ v-if="props.label"
55
55
  font="text-overline"
56
56
  >
57
- {{ $props.label }}
57
+ {{ props.label }}
58
58
  </FSSpan>
59
59
  </FSRow>
60
60
  </template>
61
61
 
62
62
  <script lang="ts">
63
- import { computed, defineComponent, PropType } from "vue";
63
+ import { computed, defineComponent, getCurrentInstance, PropType } from "vue";
64
+ import { useDefaults } from "vuetify";
64
65
 
65
66
  import { useColors, useSlots } from "@dative-gpi/foundation-shared-components/composables";
66
67
  import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
@@ -83,7 +84,7 @@ export default defineComponent({
83
84
  default: null
84
85
  },
85
86
  label: {
86
- type: String,
87
+ type: [String, Function],
87
88
  required: false,
88
89
  default: null
89
90
  },
@@ -119,12 +120,16 @@ export default defineComponent({
119
120
  }
120
121
  },
121
122
  setup(props) {
122
- const textColors = computed(() => useColors().getContrasts(props.color));
123
- const colors = computed(() => useColors().getColors(props.color));
124
- const lights = useColors().getColors(ColorEnum.Light);
123
+ props = useDefaults(props, getCurrentInstance()?.type?.name ?? "FSButton");
125
124
 
125
+ const { getColors, getContrasts } = useColors();
126
126
  const { slots } = useSlots();
127
127
 
128
+ const textColors = computed(() => getContrasts(props.color));
129
+ const colors = computed(() => getColors(props.color));
130
+ const lights = getColors(ColorEnum.Light);
131
+ const darks = getColors(ColorEnum.Dark);
132
+
128
133
  const isEmpty = computed(() => {
129
134
  return !slots.default && !props.label;
130
135
  });
@@ -170,9 +175,10 @@ export default defineComponent({
170
175
  "--fs-button-active-color" : textColors.value.light,
171
176
  };
172
177
  case "icon": switch (props.color) {
173
- case ColorEnum.Dark: return {
174
- "--fs-button-color" : colors.value.light,
175
- "--fs-button-hover-color": colors.value.dark,
178
+ case ColorEnum.Dark:
179
+ case ColorEnum.Light: return {
180
+ "--fs-button-color" : darks.base,
181
+ "--fs-button-hover-color": darks.dark,
176
182
  };
177
183
  default: return {
178
184
  "--fs-button-color" : colors.value.base,
@@ -202,6 +208,7 @@ export default defineComponent({
202
208
  });
203
209
 
204
210
  return {
211
+ props,
205
212
  colors,
206
213
  style,
207
214
  classes
@@ -105,10 +105,11 @@ export default defineComponent({
105
105
  setup(props) {
106
106
  const { epochToPicker, pickerToEpoch, todayToEpoch } = useTimeZone();
107
107
  const { languageCode } = useLanguageCode();
108
+ const { getColors } = useColors();
108
109
 
109
- const colors = computed(() => useColors().getColors(props.color));
110
- const backgrounds = useColors().getColors(ColorEnum.Background);
111
- const darks = useColors().getColors(ColorEnum.Dark);
110
+ const colors = computed(() => getColors(props.color));
111
+ const backgrounds = getColors(ColorEnum.Background);
112
+ const darks = getColors(ColorEnum.Dark);
112
113
 
113
114
  const innerMonth = ref(props.modelValue ? epochToPicker(props.modelValue).getMonth() : new Date().getMonth());
114
115
  const innerYear = ref(props.modelValue ? epochToPicker(props.modelValue).getFullYear() : new Date().getFullYear());
@@ -143,10 +143,11 @@ export default defineComponent({
143
143
  setup(props, { emit }) {
144
144
  const { epochToPicker, epochToPickerHeader, pickerToEpoch, todayToEpoch } = useTimeZone();
145
145
  const { languageCode } = useLanguageCode();
146
+ const { getColors } = useColors();
146
147
 
147
- const colors = computed(() => useColors().getColors(props.color));
148
- const backgrounds = useColors().getColors(ColorEnum.Background);
149
- const darks = useColors().getColors(ColorEnum.Dark);
148
+ const colors = computed(() => getColors(props.color));
149
+ const backgrounds = getColors(ColorEnum.Background);
150
+ const darks = getColors(ColorEnum.Dark);
150
151
 
151
152
  const innerLeftMonth = ref(new Date().getMonth());
152
153
  const innerLeftYear = ref(new Date().getFullYear());
@@ -37,9 +37,11 @@ export default defineComponent({
37
37
  },
38
38
  setup(props) {
39
39
  const { slots, getChildren } = useSlots();
40
+ const { getColors } = useColors();
41
+
40
42
  delete slots.default;
41
43
 
42
- const backgrounds = useColors().getColors(ColorEnum.Background);
44
+ const backgrounds = getColors(ColorEnum.Background);
43
45
 
44
46
  const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
45
47
  return {
@@ -92,9 +92,11 @@ export default defineComponent({
92
92
  },
93
93
  emits: ["update:modelValue"],
94
94
  setup(props, { emit }) {
95
- const colors = computed(() => useColors().getColors(props.color));
96
- const lights = useColors().getColors(ColorEnum.Light);
97
- const darks = useColors().getColors(ColorEnum.Dark);
95
+ const { getColors } = useColors();
96
+
97
+ const colors = computed(() => getColors(props.color));
98
+ const lights = getColors(ColorEnum.Light);
99
+ const darks = getColors(ColorEnum.Dark);
98
100
 
99
101
  const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
100
102
  if (!props.editable) {
@@ -85,13 +85,15 @@ export default defineComponent({
85
85
  }
86
86
  },
87
87
  setup(props) {
88
- const colors = computed(() => useColors().getColors(props.color));
89
- const backgrounds = useColors().getColors(ColorEnum.Background);
88
+ const { getColors, getContrasts } = useColors();
89
+
90
+ const colors = computed(() => getColors(props.color));
91
+ const backgrounds = getColors(ColorEnum.Background);
90
92
 
91
93
  const textColors = computed(() => {
92
94
  switch (props.variant) {
93
95
  case "standard": return colors.value;
94
- case "full": return useColors().getContrasts(props.color);
96
+ case "full": return getContrasts(props.color);
95
97
  }
96
98
  });
97
99
 
@@ -117,11 +117,12 @@ export default defineComponent({
117
117
  emits: ["update:modelValue"],
118
118
  setup(props, { emit }) {
119
119
  const { epochToLongDateFormat } = useTimeZone();
120
+ const { getColors } = useColors();
120
121
 
121
- const colors = computed(() => useColors().getColors(props.color));
122
- const backgrounds = useColors().getColors(ColorEnum.Background);
123
- const lights = useColors().getColors(ColorEnum.Light);
124
- const darks = useColors().getColors(ColorEnum.Dark);
122
+ const colors = computed(() => getColors(props.color));
123
+ const backgrounds = getColors(ColorEnum.Background);
124
+ const lights = getColors(ColorEnum.Light);
125
+ const darks = getColors(ColorEnum.Dark);
125
126
 
126
127
  const innerHours = ref(props.modelValue ? Math.floor(props.modelValue / (60 * 60 * 1000)) : 0);
127
128
  const innerMinutes = ref(props.modelValue ? Math.floor((props.modelValue % (60 * 60 * 1000)) / (60 * 1000)) : 0);
@@ -58,7 +58,9 @@ export default defineComponent({
58
58
  }
59
59
  },
60
60
  setup(props) {
61
- const colors = computed(() => useColors().getColors(props.color));
61
+ const { getColors } = useColors();
62
+
63
+ const colors = computed(() => getColors(props.color));
62
64
 
63
65
  const style: Ref<{ [code: string]: string } & Partial<CSSStyleDeclaration>> = ref({
64
66
  "--fs-color-background-color": colors.value.light,
@@ -35,7 +35,9 @@ export default defineComponent({
35
35
  }
36
36
  },
37
37
  setup(props) {
38
- const colors = computed(() => useColors().getColors(props.color));
38
+ const { getColors } = useColors();
39
+
40
+ const colors = computed(() => getColors(props.color));
39
41
 
40
42
  const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
41
43
  switch (props.variant) {
@@ -33,8 +33,10 @@ export default defineComponent({
33
33
  }
34
34
  },
35
35
  setup(props) {
36
- const backgrounds = useColors().getColors(ColorEnum.Background);
37
- const lights = useColors().getColors(ColorEnum.Light);
36
+ const { getColors } = useColors();
37
+
38
+ const backgrounds = getColors(ColorEnum.Background);
39
+ const lights = getColors(ColorEnum.Light);
38
40
 
39
41
  const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
40
42
  return {
@@ -155,10 +155,11 @@ export default defineComponent({
155
155
  emits: ["update:modelValue"],
156
156
  setup(props, { emit }) {
157
157
  const { epochToLongDateFormat } = useTimeZone();
158
+ const { getColors } = useColors();
158
159
 
159
- const errors = useColors().getColors(ColorEnum.Error);
160
- const lights = useColors().getColors(ColorEnum.Light);
161
- const darks = useColors().getColors(ColorEnum.Dark);
160
+ const errors = getColors(ColorEnum.Error);
161
+ const lights = getColors(ColorEnum.Light);
162
+ const darks = getColors(ColorEnum.Dark);
162
163
 
163
164
  const menu = ref(false);
164
165
  const innerDate = ref(props.modelValue);
@@ -144,10 +144,11 @@ export default defineComponent({
144
144
  emits: ["update:modelValue"],
145
145
  setup(props, { emit }) {
146
146
  const { epochToShortDateFormat } = useTimeZone();
147
+ const { getColors } = useColors();
147
148
 
148
- const errors = useColors().getColors(ColorEnum.Error);
149
- const lights = useColors().getColors(ColorEnum.Light);
150
- const darks = useColors().getColors(ColorEnum.Dark);
149
+ const errors = getColors(ColorEnum.Error);
150
+ const lights = getColors(ColorEnum.Light);
151
+ const darks = getColors(ColorEnum.Dark);
151
152
 
152
153
  const dialog = ref(false);
153
154
  const innerDateRange = ref(props.modelValue);
@@ -183,10 +183,11 @@ export default defineComponent({
183
183
  emits: ["update:modelValue"],
184
184
  setup(props, { emit }) {
185
185
  const { getUserOffsetMillis, epochToLongTimeFormat } = useTimeZone();
186
+ const { getColors } = useColors();
186
187
 
187
- const errors = useColors().getColors(ColorEnum.Error);
188
- const lights = useColors().getColors(ColorEnum.Light);
189
- const darks = useColors().getColors(ColorEnum.Dark);
188
+ const errors = getColors(ColorEnum.Error);
189
+ const lights = getColors(ColorEnum.Light);
190
+ const darks = getColors(ColorEnum.Dark);
190
191
 
191
192
  const menu = ref(false);
192
193
  const tabs = ref(0);
@@ -162,10 +162,11 @@ export default defineComponent({
162
162
  emits: ["update:modelValue"],
163
163
  setup(props, { emit }) {
164
164
  const { getUserOffsetMillis, epochToShortTimeFormat } = useTimeZone();
165
+ const { getColors } = useColors();
165
166
 
166
- const errors = useColors().getColors(ColorEnum.Error);
167
- const lights = useColors().getColors(ColorEnum.Light);
168
- const darks = useColors().getColors(ColorEnum.Dark);
167
+ const errors = getColors(ColorEnum.Error);
168
+ const lights = getColors(ColorEnum.Light);
169
+ const darks = getColors(ColorEnum.Dark);
169
170
 
170
171
  const dialog = ref(false);
171
172
 
@@ -22,7 +22,9 @@ export default defineComponent({
22
22
  }
23
23
  },
24
24
  setup(props) {
25
- const lights = useColors().getColors(ColorEnum.Light);
25
+ const { getColors } = useColors();
26
+
27
+ const lights = getColors(ColorEnum.Light);
26
28
 
27
29
  const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
28
30
  return {
@@ -31,7 +31,9 @@ export default defineComponent({
31
31
  }
32
32
  },
33
33
  setup(props) {
34
- const backgrounds = useColors().getColors(ColorEnum.Background);
34
+ const { getColors } = useColors();
35
+
36
+ const backgrounds = getColors(ColorEnum.Background);
35
37
 
36
38
  const style: Ref<{ [code: string]: string } & Partial<CSSStyleDeclaration>> = ref({
37
39
  "--fs-fade-out-mask-color" : backgrounds.base,
@@ -130,11 +130,12 @@ export default defineComponent({
130
130
  },
131
131
  emits: ["update:modelValue"],
132
132
  setup(props, { emit }) {
133
+ const { getColors, getContrasts } = useColors();
133
134
  const { slots } = useSlots();
134
135
 
135
- const textColors = computed(() => useColors().getContrasts(props.color));
136
- const colors = computed(() => useColors().getColors(props.color));
137
- const lights = useColors().getColors(ColorEnum.Light);
136
+ const textColors = computed(() => getContrasts(props.color));
137
+ const colors = computed(() => getColors(props.color));
138
+ const lights = getColors(ColorEnum.Light);
138
139
 
139
140
  const input = ref(null);
140
141
 
@@ -151,9 +151,11 @@ export default defineComponent({
151
151
  },
152
152
  emits: ["update:modelValue"],
153
153
  setup(props) {
154
- const errors = useColors().getColors(ColorEnum.Error);
155
- const lights = useColors().getColors(ColorEnum.Light);
156
- const darks = useColors().getColors(ColorEnum.Dark);
154
+ const { getColors } = useColors();
155
+
156
+ const errors = getColors(ColorEnum.Error);
157
+ const lights = getColors(ColorEnum.Light);
158
+ const darks = getColors(ColorEnum.Dark);
157
159
 
158
160
  const innerValue = ref(null);
159
161
 
@@ -18,7 +18,7 @@
18
18
  <script lang="ts">
19
19
  import { computed, defineComponent, onMounted } from "vue";
20
20
 
21
- import { useImageRaw, useImageBlurHash } from "@dative-gpi/foundation-shared-services";
21
+ import { useImageRaw, useImageBlurHash } from "@dative-gpi/foundation-shared-services/composables";
22
22
 
23
23
  export default defineComponent({
24
24
  name: "FSImage",
@@ -0,0 +1,95 @@
1
+ <template>
2
+ <a
3
+ :href="$props.to"
4
+ :class="classes"
5
+ :style="style"
6
+ v-bind="$attrs"
7
+ >
8
+ <slot />
9
+ </a>
10
+ </template>
11
+
12
+ <script lang="ts">
13
+ import { computed, defineComponent, PropType } from "vue";
14
+
15
+ import { useColors, useSlots } from "@dative-gpi/foundation-shared-components/composables";
16
+ import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
17
+
18
+ export default defineComponent({
19
+ name: "FSLink",
20
+ props: {
21
+ to: {
22
+ type: String,
23
+ required: false,
24
+ default: "_blank"
25
+ },
26
+ font: {
27
+ type: String as PropType<"text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline" | "text-underline">,
28
+ required: false,
29
+ default: "text-body"
30
+ },
31
+ lineClamp: {
32
+ type: Number,
33
+ required: false,
34
+ default: 1
35
+ },
36
+ ellipsis: {
37
+ type: Boolean,
38
+ required: false,
39
+ default: true
40
+ },
41
+ color: {
42
+ type: String as PropType<ColorBase>,
43
+ required: false,
44
+ default: ColorEnum.Primary
45
+ },
46
+ variant: {
47
+ type: String as PropType<"base" | "light" | "dark">,
48
+ required: false,
49
+ default: "dark"
50
+ }
51
+ },
52
+ setup(props) {
53
+ const { getColors } = useColors();
54
+ const { slots } = useSlots();
55
+
56
+ const colors = computed(() => getColors(props.color));
57
+
58
+ const classes = computed((): string[] => {
59
+ const classNames = ["fs-link", props.font];
60
+ if (!slots.default) {
61
+ classNames.push("fs-span-pre-wrap");
62
+ }
63
+ if (props.lineClamp > 1) {
64
+ classNames.push("fs-span-line-clamp");
65
+ }
66
+ else if (props.ellipsis) {
67
+ classNames.push("fs-span-ellipsis");
68
+ }
69
+ return classNames;
70
+ });
71
+
72
+ const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
73
+ switch (props.variant) {
74
+ case "base": return {
75
+ "--fs-span-line-clamp": props.lineClamp.toString(),
76
+ "--fs-link-color" : colors.value.base
77
+ };
78
+ case "light": return {
79
+ "--fs-span-line-clamp": props.lineClamp.toString(),
80
+ "--fs-link-color" : colors.value.light
81
+ };
82
+ case "dark": return {
83
+ "--fs-span-line-clamp": props.lineClamp.toString(),
84
+ "--fs-link-color" : colors.value.dark
85
+ };
86
+ }
87
+ });
88
+
89
+ return {
90
+ classes,
91
+ style
92
+ };
93
+ }
94
+ });
95
+ </script>