@dative-gpi/foundation-shared-components 0.0.8 → 0.0.9

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 (139) hide show
  1. package/{models/FSButtons.ts → aliases/FSButton.ts} +24 -21
  2. package/aliases/index.ts +1 -0
  3. package/components/FSAutocompleteField.vue +207 -0
  4. package/components/FSBadge.vue +38 -0
  5. package/components/FSBreadcrumbs.vue +49 -55
  6. package/components/FSButton.vue +116 -101
  7. package/components/FSCalendar.vue +52 -39
  8. package/components/FSCalendarTwin.vue +120 -102
  9. package/components/FSCard.vue +35 -21
  10. package/components/FSCarousel.vue +63 -0
  11. package/components/FSCheckbox.vue +111 -103
  12. package/components/FSChip.vue +140 -0
  13. package/components/FSClock.vue +149 -15
  14. package/components/FSCol.vue +104 -98
  15. package/components/FSColor.vue +61 -64
  16. package/components/FSColorIcon.vue +67 -0
  17. package/components/FSContainer.vue +64 -0
  18. package/components/FSDateField.vue +211 -0
  19. package/components/FSDateRangeField.vue +225 -0
  20. package/components/FSDateTimeField.vue +257 -0
  21. package/components/FSDateTimeRangeField.vue +286 -0
  22. package/components/FSDialog.vue +103 -0
  23. package/components/FSDivider.vue +39 -0
  24. package/components/FSFadeOut.vue +49 -59
  25. package/components/FSFileButton.vue +245 -0
  26. package/components/FSHeaderButton.vue +17 -0
  27. package/components/FSIcon.vue +23 -23
  28. package/components/FSIconField.vue +232 -0
  29. package/components/FSImage.vue +142 -0
  30. package/components/FSLoadTile.vue +93 -0
  31. package/components/FSNumberField.vue +51 -53
  32. package/components/FSPasswordField.vue +99 -101
  33. package/components/FSRadio.vue +107 -109
  34. package/components/FSRadioGroup.vue +55 -57
  35. package/components/FSRemoveDialog.vue +123 -0
  36. package/components/FSRichTextField.vue +26 -33
  37. package/components/FSRow.vue +110 -104
  38. package/components/FSSearchField.vue +35 -27
  39. package/components/FSSelectField.vue +188 -0
  40. package/components/FSSlideGroup.vue +45 -49
  41. package/components/FSSlider.vue +31 -33
  42. package/components/FSSpan.vue +53 -37
  43. package/components/FSSubmitDialog.vue +165 -0
  44. package/components/FSSwitch.vue +110 -109
  45. package/components/FSTab.vue +61 -61
  46. package/components/FSTabs.vue +53 -55
  47. package/components/FSTag.vue +88 -84
  48. package/components/FSTagField.vue +32 -36
  49. package/components/FSTagGroup.vue +38 -45
  50. package/components/FSText.vue +74 -64
  51. package/components/FSTextArea.vue +187 -185
  52. package/components/FSTextField.vue +18 -20
  53. package/components/FSTile.vue +90 -0
  54. package/components/FSToggleSet.vue +282 -0
  55. package/components/FSTooltip.vue +21 -0
  56. package/components/FSWindow.vue +26 -16
  57. package/components/FSWrapGroup.vue +44 -47
  58. package/components/deviceOrganisations/FSConnectivity.vue +114 -0
  59. package/components/deviceOrganisations/FSStatus.vue +117 -0
  60. package/components/deviceOrganisations/FSStatusesCarousel.vue +105 -0
  61. package/components/deviceOrganisations/FSStatusesRow.vue +66 -0
  62. package/components/deviceOrganisations/FSWorstAlert.vue +165 -0
  63. package/components/lists/FSDataIteratorGroup.vue +7 -0
  64. package/components/lists/FSDataIteratorItem.vue +103 -0
  65. package/components/lists/FSDataTable.vue +964 -0
  66. package/components/lists/FSFilterButton.vue +176 -0
  67. package/components/lists/FSHeaderButton.vue +99 -0
  68. package/components/lists/FSHiddenButton.vue +79 -0
  69. package/components/tiles/FSDeviceOrganisationTileUI.vue +232 -0
  70. package/components/tiles/FSGroupTileUI.vue +192 -0
  71. package/composables/index.ts +1 -1
  72. package/composables/useBreakpoints.ts +23 -4
  73. package/composables/useColors.ts +53 -23
  74. package/composables/useSlots.ts +43 -0
  75. package/index.ts +6 -0
  76. package/models/breadcrumbs.ts +8 -0
  77. package/models/colors.ts +17 -0
  78. package/models/deviceAlerts.ts +10 -0
  79. package/models/deviceConnectivities.ts +11 -0
  80. package/models/deviceStatuses.ts +16 -0
  81. package/models/dispositions.ts +33 -0
  82. package/models/index.ts +9 -0
  83. package/models/modelStatuses.ts +11 -0
  84. package/models/rules.ts +50 -0
  85. package/models/toggleSets.ts +7 -0
  86. package/package.json +5 -4
  87. package/plugins/colorPlugin.ts +2 -2
  88. package/shims-plugin.d.ts +1 -1
  89. package/styles/components/fs_autocomplete_field.scss +123 -0
  90. package/styles/components/fs_button.scss +4 -6
  91. package/styles/components/fs_calendar.scss +24 -1
  92. package/styles/components/fs_card.scss +2 -5
  93. package/styles/components/fs_carousel.scss +4 -0
  94. package/styles/components/fs_chip.scss +33 -0
  95. package/styles/components/fs_clock.scss +43 -0
  96. package/styles/components/fs_col.scss +2 -0
  97. package/styles/components/fs_color_icon.scss +37 -0
  98. package/styles/components/fs_container.scss +16 -0
  99. package/styles/components/fs_data_iterator_item.scss +19 -0
  100. package/styles/components/fs_data_table.scss +97 -0
  101. package/styles/components/fs_date_field.scss +8 -0
  102. package/styles/components/fs_dialog.scss +30 -0
  103. package/styles/components/fs_divider.scss +5 -0
  104. package/styles/components/fs_fade_out.scss +10 -2
  105. package/styles/components/fs_filter_button.scss +12 -0
  106. package/styles/components/fs_header_button.scss +4 -0
  107. package/styles/components/fs_icon.scss +19 -3
  108. package/styles/components/fs_icon_field.scss +12 -0
  109. package/styles/components/fs_image.scss +7 -0
  110. package/styles/components/fs_load_tile.scss +49 -0
  111. package/styles/components/fs_password_field.scss +2 -2
  112. package/styles/components/fs_row.scss +4 -1
  113. package/styles/components/fs_select_field.scss +71 -0
  114. package/styles/components/fs_slide_group.scss +6 -0
  115. package/styles/components/fs_slider.scss +29 -9
  116. package/styles/components/fs_span.scss +8 -0
  117. package/styles/components/fs_submit_dialog.scss +9 -0
  118. package/styles/components/fs_tabs.scss +4 -0
  119. package/styles/components/fs_tag_field.scss +0 -11
  120. package/styles/components/fs_text_field.scss +23 -15
  121. package/styles/components/fs_tile.scss +33 -0
  122. package/styles/components/fs_tooltip.scss +5 -0
  123. package/styles/components/fs_wrap_group.scss +7 -8
  124. package/styles/components/index.scss +21 -1
  125. package/styles/globals/breakpoints.scss +7 -0
  126. package/styles/globals/overrides.scss +20 -7
  127. package/styles/globals/text_fonts.scss +8 -8
  128. package/themes/default.ts +1 -11
  129. package/utils/css.ts +11 -0
  130. package/utils/icons.ts +75416 -0
  131. package/utils/index.ts +5 -1
  132. package/utils/levenshtein.ts +97 -0
  133. package/utils/sort.ts +9 -0
  134. package/components/FSDatePicker.vue +0 -226
  135. package/composables/useDates.ts +0 -39
  136. package/models/FSTags.ts +0 -8
  137. package/models/FSTextFields.ts +0 -23
  138. package/styles/components/fs_date_picker.scss +0 -0
  139. /package/utils/{FSRichTextField.ts → lexical.ts} +0 -0
@@ -1,102 +1,106 @@
1
1
  <template>
2
- <FSRow
3
- class="fs-tag"
4
- width="hug"
5
- align="center-left"
6
- :style="style"
7
- v-bind="$attrs"
8
- >
9
- <slot name="default" v-bind="{ color, colors }">
10
- <FSSpan class="fs-tag-label">
11
- {{ $props.label }}
12
- </FSSpan>
13
- </slot>
14
- <slot name="button" v-bind="{ color, colors }">
15
- <v-btn
16
- v-if="$props.editable"
17
- class="fs-tag-button"
18
- :ripple="false"
19
- @click="$emit('remove')"
20
- >
21
- <FSIcon size="s">
22
- mdi-close
23
- </FSIcon>
24
- </v-btn>
25
- </slot>
26
- </FSRow>
2
+ <FSRow
3
+ class="fs-tag"
4
+ width="hug"
5
+ align="center-left"
6
+ :style="style"
7
+ :wrap="false"
8
+ v-bind="$attrs"
9
+ >
10
+ <slot v-bind="{ color: $props.color, colors }">
11
+ <FSSpan
12
+ v-if="$props.label"
13
+ class="fs-tag-label"
14
+ >
15
+ {{ $props.label }}
16
+ </FSSpan>
17
+ </slot>
18
+ <slot name="button" v-bind="{ color: $props.color, colors }">
19
+ <v-btn
20
+ v-if="$props.editable"
21
+ class="fs-tag-button"
22
+ :ripple="false"
23
+ @click="$emit('remove')"
24
+ >
25
+ <FSIcon
26
+ size="s"
27
+ >
28
+ mdi-close
29
+ </FSIcon>
30
+ </v-btn>
31
+ </slot>
32
+ </FSRow>
27
33
  </template>
28
34
 
29
35
  <script lang="ts">
30
- import { computed, defineComponent, PropType, toRefs } from "vue";
36
+ import { computed, defineComponent, PropType } from "vue";
31
37
 
38
+ import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
32
39
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
33
- import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
34
40
 
35
41
  import FSIcon from "./FSIcon.vue";
36
42
  import FSSpan from "./FSSpan.vue";
37
43
  import FSRow from "./FSRow.vue";
38
44
 
39
45
  export default defineComponent({
40
- name: "FSTag",
41
- components: {
42
- FSIcon,
43
- FSSpan,
44
- FSRow
46
+ name: "FSTag",
47
+ components: {
48
+ FSIcon,
49
+ FSSpan,
50
+ FSRow
51
+ },
52
+ props: {
53
+ label: {
54
+ type: String,
55
+ required: false,
56
+ default: null
45
57
  },
46
- props: {
47
- label: {
48
- type: String,
49
- required: true
50
- },
51
- variant: {
52
- type: String as PropType<"standard" | "full">,
53
- required: false,
54
- default: "full"
55
- },
56
- color: {
57
- type: String as PropType<ColorBase>,
58
- required: false,
59
- default: ColorBase.Primary
60
- },
61
- editable: {
62
- type: Boolean,
63
- required: false,
64
- default: true
65
- }
58
+ variant: {
59
+ type: String as PropType<"standard" | "full">,
60
+ required: false,
61
+ default: "full"
66
62
  },
67
- emits: ["remove"],
68
- setup(props) {
69
- const { variant, color } = toRefs(props);
70
-
71
- const textColors = useColors().getContrasts(color.value);
72
- const colors = useColors().getColors(color.value);
73
-
74
- const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
75
- switch (variant.value) {
76
- case "standard": return {
77
- "--fs-tag-background-color": colors.light,
78
- "--fs-tag-color": textColors.base,
79
- "--fs-tag-hover-background-color": colors.base,
80
- "--fs-tag-hover-color": textColors.light,
81
- "--fs-tag-active-background-color": colors.dark,
82
- "--fs-tag-active-color": textColors.light
83
- };
84
- case "full": return {
85
- "--fs-tag-background-color": colors.base,
86
- "--fs-tag-color": textColors.light,
87
- "--fs-tag-hover-background-color": colors.base,
88
- "--fs-tag-hover-color": textColors.light,
89
- "--fs-tag-active-background-color": colors.dark,
90
- "--fs-tag-active-color": textColors.light
91
- };
92
- }
93
- });
63
+ color: {
64
+ type: String as PropType<ColorBase>,
65
+ required: false,
66
+ default: ColorEnum.Primary
67
+ },
68
+ editable: {
69
+ type: Boolean,
70
+ required: false,
71
+ default: true
72
+ }
73
+ },
74
+ emits: ["remove"],
75
+ setup(props) {
76
+ const textColors = computed(() => useColors().getContrasts(props.color));
77
+ const colors = computed(() => useColors().getColors(props.color));
94
78
 
95
- return {
96
- colors,
97
- color,
98
- style
79
+ const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
80
+ switch (props.variant) {
81
+ case "standard": return {
82
+ "--fs-tag-background-color" : colors.value.light,
83
+ "--fs-tag-color" : textColors.value.base,
84
+ "--fs-tag-hover-background-color" : colors.value.base,
85
+ "--fs-tag-hover-color" : textColors.value.light,
86
+ "--fs-tag-active-background-color": colors.value.dark,
87
+ "--fs-tag-active-color" : textColors.value.light
99
88
  };
100
- }
89
+ case "full": return {
90
+ "--fs-tag-background-color" : colors.value.base,
91
+ "--fs-tag-color" : textColors.value.light,
92
+ "--fs-tag-hover-background-color" : colors.value.base,
93
+ "--fs-tag-hover-color" : textColors.value.light,
94
+ "--fs-tag-active-background-color": colors.value.dark,
95
+ "--fs-tag-active-color" : textColors.value.light
96
+ };
97
+ }
98
+ });
99
+
100
+ return {
101
+ colors,
102
+ style
103
+ };
104
+ }
101
105
  });
102
106
  </script>
@@ -3,17 +3,15 @@
3
3
  <FSTextField
4
4
  :label="$props.label"
5
5
  :description="$props.description"
6
- :type="type"
7
- :color="$props.color"
6
+ :hideHeader="$props.hideHeader"
8
7
  :required="$props.required"
9
8
  :editable="$props.editable"
10
9
  :error="messages.length > 0"
11
- :modelValue="innerValue"
12
- @update:modelValue="(value) => innerValue = value"
13
10
  @keydown.enter="onAdd"
11
+ v-model="innerValue"
14
12
  v-bind="$attrs"
15
13
  >
16
- <template #label>
14
+ <template v-if="!$props.hideHeader" #label>
17
15
  <slot name="label">
18
16
  <FSRow :wrap="false">
19
17
  <FSSpan
@@ -48,14 +46,13 @@
48
46
  </template>
49
47
  <template #append-inner>
50
48
  <slot name="append-inner">
51
- <FSIcon
52
- class="fs-tag-field-icon"
53
- size="m"
54
- :style="style"
49
+ <FSButton
50
+ variant="icon"
51
+ icon="mdi-tag-outline"
52
+ :editable="$props.editable"
53
+ :color="ColorEnum.Dark"
55
54
  @click="onAdd"
56
- >
57
- mdi-tag-outline
58
- </FSIcon>
55
+ />
59
56
  </slot>
60
57
  </template>
61
58
  <template v-for="(_, name) in $slots" v-slot:[name]="slotData">
@@ -73,13 +70,14 @@
73
70
  </template>
74
71
 
75
72
  <script lang="ts">
76
- import { computed, defineComponent, PropType, ref, toRefs } from "vue";
73
+ import { computed, defineComponent, PropType, ref } from "vue";
77
74
 
75
+ import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
78
76
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
79
- import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
80
77
 
81
78
  import FSTextField from "./FSTextField.vue";
82
79
  import FSTagGroup from "./FSTagGroup.vue";
80
+ import FSButton from "./FSButton.vue";
83
81
  import FSSpan from "./FSSpan.vue";
84
82
  import FSCol from "./FSCol.vue";
85
83
  import FSRow from "./FSRow.vue";
@@ -89,6 +87,7 @@ export default defineComponent({
89
87
  components: {
90
88
  FSTextField,
91
89
  FSTagGroup,
90
+ FSButton,
92
91
  FSSpan,
93
92
  FSCol,
94
93
  FSRow
@@ -109,11 +108,6 @@ export default defineComponent({
109
108
  required: false,
110
109
  default: () => []
111
110
  },
112
- color: {
113
- type: String as PropType<ColorBase>,
114
- required: false,
115
- default: ColorBase.Dark
116
- },
117
111
  tagVariant: {
118
112
  type: String as PropType<"standard" | "full">,
119
113
  required: false,
@@ -122,7 +116,12 @@ export default defineComponent({
122
116
  tagColor: {
123
117
  type: String as PropType<ColorBase>,
124
118
  required: false,
125
- default: ColorBase.Primary
119
+ default: ColorEnum.Primary
120
+ },
121
+ hideHeader: {
122
+ type: Boolean,
123
+ required: false,
124
+ default: false
126
125
  },
127
126
  required: {
128
127
  type: Boolean,
@@ -142,32 +141,28 @@ export default defineComponent({
142
141
  },
143
142
  emits: ["update:modelValue"],
144
143
  setup(props, { emit }) {
145
- const { modelValue, rules, editable } = toRefs(props);
146
144
 
147
- const innerValue = ref("");
145
+ const errors = useColors().getColors(ColorEnum.Error);
146
+ const lights = useColors().getColors(ColorEnum.Light);
147
+ const darks = useColors().getColors(ColorEnum.Dark);
148
148
 
149
- const errors = useColors().getColors(ColorBase.Error);
150
- const darks = useColors().getColors(ColorBase.Dark);
149
+ const innerValue = ref("");
151
150
 
152
151
  const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
153
- if (!editable.value) {
152
+ if (!props.editable) {
154
153
  return {
155
- "--fs-tag-field-cursor" : "default",
156
- "--fs-tag-field-base-text": darks.light,
157
- "--fs-tag-field-dark-text": darks.light
154
+ "--fs-tag-field-color": lights.dark
158
155
  };
159
156
  }
160
157
  return {
161
- "--fs-tag-field-cursor" : "pointer",
162
- "--fs-tag-field-base-text" : darks.base,
163
- "--fs-tag-field-dark-text" : darks.dark,
158
+ "--fs-tag-field-color" : darks.base,
164
159
  "--fs-tag-field-error-color": errors.base
165
160
  };
166
161
  });
167
162
 
168
163
  const messages = computed((): string[] => {
169
164
  const messages = [];
170
- for (const rule of rules.value) {
165
+ for (const rule of props.rules) {
171
166
  const message = rule(props.modelValue);
172
167
  if (typeof(message) === "string") {
173
168
  messages.push(message);
@@ -177,10 +172,10 @@ export default defineComponent({
177
172
  });
178
173
 
179
174
  const onAdd = (): void => {
180
- if (!editable.value) {
175
+ if (!props.editable) {
181
176
  return;
182
177
  }
183
- const tags = modelValue.value ?? [];
178
+ const tags = props.modelValue ?? [];
184
179
  if (!innerValue.value.length || tags.includes(innerValue.value)) {
185
180
  return;
186
181
  }
@@ -189,10 +184,10 @@ export default defineComponent({
189
184
  }
190
185
 
191
186
  const onRemove = (label: string): void => {
192
- if (!editable.value) {
187
+ if (!props.editable) {
193
188
  return;
194
189
  }
195
- const tags = modelValue.value ?? [];
190
+ const tags = props.modelValue ?? [];
196
191
  if (!tags.length || !tags.includes(label)) {
197
192
  return;
198
193
  }
@@ -200,6 +195,7 @@ export default defineComponent({
200
195
  }
201
196
 
202
197
  return {
198
+ ColorEnum,
203
199
  innerValue,
204
200
  messages,
205
201
  style,
@@ -1,60 +1,53 @@
1
1
  <template>
2
- <FSWrapGroup v-bind="$attrs">
3
- <FSTag
4
- v-for="(tag, index) in $props.tags"
5
- :key="index"
6
- :label="tag"
7
- :variant="$props.variant"
8
- :color="$props.color"
9
- :editable="$props.editable"
10
- @remove="() => $emit('remove', tag)"
11
- />
12
- <slot name="default" />
13
- </FSWrapGroup>
2
+ <FSWrapGroup v-bind="$attrs">
3
+ <FSTag
4
+ v-for="(tag, index) in $props.tags"
5
+ :key="index"
6
+ :label="tag"
7
+ :variant="$props.variant"
8
+ :color="$props.color"
9
+ :editable="$props.editable"
10
+ @remove="() => $emit('remove', tag)"
11
+ />
12
+ <slot />
13
+ </FSWrapGroup>
14
14
  </template>
15
15
 
16
16
  <script lang="ts">
17
17
  import { defineComponent, PropType } from "vue";
18
18
 
19
- import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
19
+ import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
20
20
 
21
21
  import FSWrapGroup from "./FSWrapGroup.vue";
22
22
  import FSTag from "./FSTag.vue";
23
23
 
24
- export interface FSTagItem {
25
- label: string,
26
- variant: "standard" | "full",
27
- color: ColorBase,
28
- editable: boolean
29
- }
30
-
31
24
  export default defineComponent({
32
- name: "FSTagGroup",
33
- components: {
34
- FSWrapGroup,
35
- FSTag
25
+ name: "FSTagGroup",
26
+ components: {
27
+ FSWrapGroup,
28
+ FSTag
29
+ },
30
+ props: {
31
+ tags: {
32
+ type: Array as PropType<string[]>,
33
+ required: false,
34
+ default: () => []
35
+ },
36
+ variant: {
37
+ type: String as PropType<"standard" | "full">,
38
+ required: false,
39
+ default: "full"
40
+ },
41
+ color: {
42
+ type: String as PropType<ColorBase>,
43
+ required: false,
44
+ default: ColorEnum.Primary
36
45
  },
37
- props: {
38
- tags: {
39
- type: Array as PropType<Array<String>>,
40
- required: false,
41
- default: () => []
42
- },
43
- variant: {
44
- type: String as PropType<"standard" | "full">,
45
- required: false,
46
- default: "full"
47
- },
48
- color: {
49
- type: String as PropType<ColorBase>,
50
- required: false,
51
- default: ColorBase.Primary
52
- },
53
- editable: {
54
- type: Boolean,
55
- required: false,
56
- default: true
57
- }
46
+ editable: {
47
+ type: Boolean,
48
+ required: false,
49
+ default: true
58
50
  }
51
+ }
59
52
  });
60
53
  </script>
@@ -1,78 +1,88 @@
1
1
  <template>
2
- <span
3
- :class="classes"
4
- :style="style"
5
- v-bind="$attrs"
6
- >
7
- <slot />
8
- </span>
2
+ <span
3
+ :class="classes"
4
+ :style="style"
5
+ v-bind="$attrs"
6
+ >
7
+ <slot />
8
+ </span>
9
9
  </template>
10
10
 
11
11
  <script lang="ts">
12
- import { computed, defineComponent, PropType, toRefs, useSlots } from "vue";
12
+ import { computed, defineComponent, PropType } from "vue";
13
13
 
14
- import { useColors } from "@dative-gpi/foundation-shared-components/composables";
15
- import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
14
+ import { useColors, useSlots } from "@dative-gpi/foundation-shared-components/composables";
15
+ import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
16
16
 
17
17
  export default defineComponent({
18
- name: "FSText",
19
- props: {
20
- font: {
21
- type: String as PropType<"text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline" | "text-underline">,
22
- required: false,
23
- default: "text-body"
24
- },
25
- color: {
26
- type: String as PropType<ColorBase>,
27
- required: false,
28
- default: ColorBase.Dark
29
- },
30
- variant: {
31
- type: String as PropType<"base" | "light" | "dark">,
32
- required: false,
33
- default: "dark"
34
- },
35
- ellipsis: {
36
- type: Boolean,
37
- required: false,
38
- default: true
39
- }
18
+ name: "FSText",
19
+ props: {
20
+ font: {
21
+ type: String as PropType<"text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline" | "text-underline">,
22
+ required: false,
23
+ default: "text-body"
40
24
  },
41
- setup(props) {
42
- const { color, font, variant } = toRefs(props);
43
-
44
- const colors = useColors().getColors(color.value);
45
- const slots = useSlots();
25
+ lineClamp: {
26
+ type: Number,
27
+ required: false,
28
+ default: 1
29
+ },
30
+ ellipsis: {
31
+ type: Boolean,
32
+ required: false,
33
+ default: true
34
+ },
35
+ color: {
36
+ type: String as PropType<ColorBase>,
37
+ required: false,
38
+ default: ColorEnum.Dark
39
+ },
40
+ variant: {
41
+ type: String as PropType<"base" | "light" | "dark">,
42
+ required: false,
43
+ default: "dark"
44
+ }
45
+ },
46
+ setup(props) {
47
+ const { slots } = useSlots();
46
48
 
47
- const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
48
- switch (variant.value) {
49
- case "base": return {
50
- "--fs-text-color": colors.base
51
- };
52
- case "light": return {
53
- "--fs-text-color": colors.light
54
- };
55
- case "dark": return {
56
- "--fs-text-color": colors.dark
57
- };
58
- }
59
- });
49
+ const colors = computed(() => useColors().getColors(props.color));
60
50
 
61
- const classes = computed((): string[] => {
62
- const classes = ["fs-text", font.value];
63
- if (props.ellipsis) {
64
- classes.push("fs-span-ellipsis");
65
- }
66
- if (!slots.default) {
67
- classes.push("fs-span-pre-wrap");
68
- }
69
- return classes;
70
- });
51
+ const classes = computed((): string[] => {
52
+ const classNames = ["fs-text", props.font];
53
+ if (!slots.default) {
54
+ classNames.push("fs-span-pre-wrap");
55
+ }
56
+ if (props.lineClamp > 1) {
57
+ classNames.push("fs-span-line-clamp");
58
+ }
59
+ else if (props.ellipsis) {
60
+ classNames.push("fs-span-ellipsis");
61
+ }
62
+ return classNames;
63
+ });
71
64
 
72
- return {
73
- classes,
74
- style
65
+ const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
66
+ switch (props.variant) {
67
+ case "base": return {
68
+ "--fs-span-line-clamp": props.lineClamp.toString(),
69
+ "--fs-text-color" : colors.value.base
75
70
  };
76
- }
71
+ case "light": return {
72
+ "--fs-span-line-clamp": props.lineClamp.toString(),
73
+ "--fs-text-color" : colors.value.light
74
+ };
75
+ case "dark": return {
76
+ "--fs-span-line-clamp": props.lineClamp.toString(),
77
+ "--fs-text-color" : colors.value.dark
78
+ };
79
+ }
80
+ });
81
+
82
+ return {
83
+ classes,
84
+ style
85
+ };
86
+ }
77
87
  });
78
88
  </script>