@dative-gpi/foundation-shared-components 0.0.4 → 0.0.6

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 (52) hide show
  1. package/components/FSBreadcrumbs.vue +23 -18
  2. package/components/FSButton.vue +138 -30
  3. package/components/FSCheckbox.vue +41 -26
  4. package/components/FSCol.vue +56 -16
  5. package/components/FSColor.vue +80 -0
  6. package/components/FSFadeOut.vue +11 -6
  7. package/components/FSIcon.vue +5 -3
  8. package/components/FSNumberField.vue +65 -0
  9. package/components/FSPasswordField.vue +119 -0
  10. package/components/FSRadio.vue +40 -26
  11. package/components/FSRadioGroup.vue +6 -8
  12. package/components/FSRow.vue +57 -17
  13. package/components/FSSearchField.vue +122 -0
  14. package/components/FSSlideGroup.vue +17 -13
  15. package/components/FSSpan.vue +28 -4
  16. package/components/FSSwitch.vue +45 -28
  17. package/components/FSTab.vue +36 -22
  18. package/components/FSTabs.vue +21 -12
  19. package/components/FSTag.vue +48 -31
  20. package/components/FSTagField.vue +152 -0
  21. package/components/FSTagGroup.vue +60 -0
  22. package/components/FSText.vue +78 -0
  23. package/components/FSTextField.vue +122 -13
  24. package/components/FSWrapGroup.vue +16 -13
  25. package/composables/useColors.ts +31 -39
  26. package/models/FSButtons.ts +111 -0
  27. package/models/FSTags.ts +8 -0
  28. package/models/FSTextFields.ts +17 -0
  29. package/package.json +5 -4
  30. package/styles/components/fs_breadcrumbs.scss +29 -11
  31. package/styles/components/fs_button.scss +36 -9
  32. package/styles/components/fs_checkbox.scss +3 -4
  33. package/styles/components/fs_col.scss +87 -2
  34. package/styles/components/fs_color.scss +5 -0
  35. package/styles/components/fs_icon.scss +4 -4
  36. package/styles/components/fs_password_field.scss +10 -0
  37. package/styles/components/fs_radio.scss +3 -4
  38. package/styles/components/fs_row.scss +86 -1
  39. package/styles/components/fs_span.scss +8 -3
  40. package/styles/components/fs_switch.scss +4 -4
  41. package/styles/components/fs_tabs.scss +8 -9
  42. package/styles/components/fs_tag.scss +8 -8
  43. package/styles/components/fs_tag_field.scss +10 -0
  44. package/styles/components/fs_text.scss +5 -0
  45. package/styles/components/fs_text_field.scss +46 -17
  46. package/styles/components/index.scss +18 -14
  47. package/styles/globals/fixes.scss +5 -0
  48. package/styles/globals/index.scss +4 -1
  49. package/styles/globals/overrides.scss +26 -4
  50. package/styles/globals/text_fonts.scss +48 -24
  51. package/themes/default.ts +6 -6
  52. package/defaults/FSButtons.ts +0 -63
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <FSTextField
3
+ type="number"
4
+ :label="$props.label"
5
+ :description="$props.description"
6
+ :color="$props.color"
7
+ :required="$props.required"
8
+ :editable="$props.editable"
9
+ :value="$props.value?.toString()"
10
+ @update:value="(value) => $emit('update:value', isNaN(parseFloat(value)) ? 0 : parseFloat(value))"
11
+ v-bind="$attrs"
12
+ >
13
+ <template v-for="(_, name) in $slots" v-slot:[name]="slotData">
14
+ <slot :name="name" v-bind="slotData" />
15
+ </template>
16
+ </FSTextField>
17
+ </template>
18
+
19
+ <script lang="ts">
20
+ import { defineComponent, PropType } from "vue";
21
+
22
+ import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
23
+
24
+ import FSTextField from "./FSTextField.vue";
25
+
26
+ export default defineComponent({
27
+ name: "FSNumberField",
28
+ components: {
29
+ FSTextField
30
+ },
31
+ props: {
32
+ label: {
33
+ type: String,
34
+ required: false,
35
+ default: null
36
+ },
37
+ description: {
38
+ type: String,
39
+ required: false,
40
+ default: null
41
+ },
42
+ value: {
43
+ type: Number,
44
+ required: false,
45
+ default: null
46
+ },
47
+ color: {
48
+ type: String as PropType<ColorBase>,
49
+ required: false,
50
+ default: ColorBase.Dark
51
+ },
52
+ required: {
53
+ type: Boolean,
54
+ required: false,
55
+ default: false
56
+ },
57
+ editable: {
58
+ type: Boolean,
59
+ required: false,
60
+ default: true
61
+ }
62
+ },
63
+ emits: ["update:value"]
64
+ });
65
+ </script>
@@ -0,0 +1,119 @@
1
+ <template>
2
+ <FSTextField
3
+ :label="$props.label"
4
+ :description="$props.description"
5
+ :type="type"
6
+ :color="$props.color"
7
+ :required="$props.required"
8
+ :editable="$props.editable"
9
+ :value="$props.value"
10
+ @update:value="(value) => $emit('update:value', value)"
11
+ v-bind="$attrs"
12
+ >
13
+ <template #append-inner>
14
+ <FSIcon
15
+ class="fs-password-field-icon"
16
+ size="m"
17
+ :style="style"
18
+ @click="onToggle"
19
+ >
20
+ {{ icon }}
21
+ </FSIcon>
22
+ </template>
23
+ <template v-for="(_, name) in $slots" v-slot:[name]="slotData">
24
+ <slot :name="name" v-bind="slotData" />
25
+ </template>
26
+ </FSTextField>
27
+ </template>
28
+
29
+ <script lang="ts">
30
+ import { computed, defineComponent, PropType, ref, toRefs } from "vue";
31
+
32
+ import { useColors } from "@dative-gpi/foundation-shared-components/composables";
33
+ import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
34
+
35
+ import FSTextField from "./FSTextField.vue";
36
+ import FSIcon from "./FSIcon.vue";
37
+
38
+ export default defineComponent({
39
+ name: "FSPasswordField",
40
+ components: {
41
+ FSTextField,
42
+ FSIcon
43
+ },
44
+ props: {
45
+ label: {
46
+ type: String,
47
+ required: false,
48
+ default: null
49
+ },
50
+ description: {
51
+ type: String,
52
+ required: false,
53
+ default: null
54
+ },
55
+ value: {
56
+ type: String,
57
+ required: false,
58
+ default: null
59
+ },
60
+ color: {
61
+ type: String as PropType<ColorBase>,
62
+ required: false,
63
+ default: ColorBase.Dark
64
+ },
65
+ required: {
66
+ type: Boolean,
67
+ required: false,
68
+ default: false
69
+ },
70
+ editable: {
71
+ type: Boolean,
72
+ required: false,
73
+ default: true
74
+ }
75
+ },
76
+ emits: ["update:value"],
77
+ setup(props) {
78
+ const { editable } = toRefs(props);
79
+
80
+ const stars = ref(true);
81
+
82
+ const lights = useColors().getColors(ColorBase.Light);
83
+ const darks = useColors().getColors(ColorBase.Dark);
84
+
85
+ const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
86
+ if (!editable.value) {
87
+ return {
88
+ "--fs-password-field-cursor" : "default",
89
+ "--fs-password-field-base-text": lights.dark,
90
+ "--fs-password-field-dark-text": lights.dark
91
+ };
92
+ }
93
+ return {
94
+ "--fs-password-field-cursor" : "pointer",
95
+ "--fs-password-field-base-text": darks.base,
96
+ "--fs-password-field-dark-text": darks.dark
97
+ };
98
+ });
99
+
100
+ const type = computed((): string => stars.value ? "password" : "text");
101
+
102
+ const icon = computed((): string => stars.value ? "mdi-eye-off-outline" : "mdi-eye-outline");
103
+
104
+ const onToggle = (): void => {
105
+ if (!editable.value) {
106
+ return;
107
+ }
108
+ stars.value = !stars.value;
109
+ };
110
+
111
+ return {
112
+ type,
113
+ icon,
114
+ style,
115
+ onToggle
116
+ };
117
+ }
118
+ });
119
+ </script>
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <FSCol width="hug" height="hug">
3
- <FSRow width="hug" height="hug">
2
+ <FSCol width="hug">
3
+ <FSRow width="hug" align="center-left">
4
4
  <FSIcon
5
5
  class="fs-radio"
6
6
  size="checkbox"
@@ -9,24 +9,28 @@
9
9
  >
10
10
  {{ icon }}
11
11
  </FSIcon>
12
+ <slot name="default">
13
+ <FSSpan
14
+ v-if="$props.label"
15
+ class="fs-radio-label"
16
+ :style="style"
17
+ :font="font"
18
+ @click="onToggle"
19
+ >
20
+ {{ $props.label }}
21
+ </FSSpan>
22
+ </slot>
23
+ </FSRow>
24
+ <slot name="description">
12
25
  <FSSpan
13
- v-if="$props.label"
14
- class="fs-radio-label"
26
+ v-if="$props.description"
27
+ class="fs-radio-description"
28
+ font="text-underline"
15
29
  :style="style"
16
- :font="font"
17
- @click="onToggle"
18
30
  >
19
- {{ $props.label }}
31
+ {{ $props.description }}
20
32
  </FSSpan>
21
- </FSRow>
22
- <FSSpan
23
- v-if="$props.description"
24
- class="fs-radio-description"
25
- font="text-overline"
26
- :style="style"
27
- >
28
- {{ $props.description }}
29
- </FSSpan>
33
+ </slot>
30
34
  </FSCol>
31
35
  </template>
32
36
 
@@ -84,21 +88,31 @@ export default defineComponent({
84
88
  setup(props, { emit }) {
85
89
  const { value, selected, color, editable } = toRefs(props);
86
90
 
87
- const colors = useColors().getVariants(color.value);
88
- const dark = useColors().getDark();
91
+ const colors = useColors().getColors(color.value);
89
92
 
90
- const style = computed(() => ({
91
- "--fs-radio-cursor": (editable.value && !selected.value) ? "pointer" : "default",
92
- "--fs-radio-base-color": editable.value ? selected.value ? colors.base : dark.base : dark.light,
93
- "--fs-radio-base-text" : editable.value ? dark.base : dark.light
93
+ const lights = useColors().getColors(ColorBase.Light);
94
+ const darks = useColors().getColors(ColorBase.Dark);
94
95
 
95
- }));
96
+ const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
97
+ if (!editable.value) {
98
+ return {
99
+ "--fs-radio-cursor": "default",
100
+ "--fs-radio-radio-color": lights.dark,
101
+ "--fs-radio-color": lights.dark
102
+ };
103
+ }
104
+ return {
105
+ "--fs-radio-cursor": selected.value ? "default" : "pointer",
106
+ "--fs-radio-radio-color": selected.value ? colors.base : darks.base,
107
+ "--fs-radio-color" : darks.base
108
+ };
109
+ });
96
110
 
97
- const icon = computed(() => selected.value ? "mdi-radiobox-marked" : "mdi-radiobox-blank");
111
+ const icon = computed((): string => selected.value ? "mdi-radiobox-marked" : "mdi-radiobox-blank");
98
112
 
99
- const font = computed(() => selected.value ? "text-button" : "text-body");
113
+ const font = computed((): string => selected.value ? "text-button" : "text-body");
100
114
 
101
- const onToggle = () => {
115
+ const onToggle = (): void => {
102
116
  if (!editable.value) {
103
117
  return;
104
118
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <FSCol width="hug" height="hug">
2
+ <FSCol width="hug">
3
3
  <FSRadio
4
4
  v-for="item in $props.values"
5
5
  :key="item.value"
@@ -7,8 +7,8 @@
7
7
  :description="item.description"
8
8
  :value="item.value"
9
9
  :selected="isSelected(item.value)"
10
- :color="color"
11
- :editable="editable"
10
+ :color="$props.color"
11
+ :editable="$props.editable"
12
12
  @update:value="onToggle"
13
13
  />
14
14
  </FSCol>
@@ -52,21 +52,19 @@ export default defineComponent({
52
52
  },
53
53
  emits: ["update:value"],
54
54
  setup(props, { emit }) {
55
- const { value, color, editable } = toRefs(props);
55
+ const { value } = toRefs(props);
56
56
 
57
- const isSelected = (item: String | Boolean | Number) => {
57
+ const isSelected = (item: String | Boolean | Number): boolean => {
58
58
  return item == value.value;
59
59
  };
60
60
 
61
- const onToggle = (item: String | Boolean | Number) => {
61
+ const onToggle = (item: String | Boolean | Number): void => {
62
62
  if (item != value.value) {
63
63
  emit("update:value", item);
64
64
  }
65
65
  };
66
66
 
67
67
  return {
68
- color,
69
- editable,
70
68
  isSelected,
71
69
  onToggle
72
70
  };
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div
3
- class="fs-row"
4
3
  :style="style"
4
+ :class="classes"
5
5
  v-bind="$attrs"
6
6
  >
7
7
  <slot />
@@ -22,7 +22,12 @@ export default defineComponent({
22
22
  height: {
23
23
  type: String as PropType<"hug" | "fill" | string>,
24
24
  required: false,
25
- default: "fill"
25
+ default: "hug"
26
+ },
27
+ align: {
28
+ type: String as PropType<"top-left" | "top-center" | "top-right" | "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right">,
29
+ required: false,
30
+ default: "top-left"
26
31
  },
27
32
  wrap: {
28
33
  type: Boolean,
@@ -36,39 +41,74 @@ export default defineComponent({
36
41
  }
37
42
  },
38
43
  setup(props) {
39
- const { width, height, wrap, gap } = toRefs(props);
44
+ const { width, height, align, wrap, gap } = toRefs(props);
40
45
 
41
- const style = computed(() => {
42
- const style : {[code: string]: string} & Partial<CSSStyleDeclaration> = {
43
- "--fs-row-flex-wrap": wrap.value ? "wrap" : "nowrap",
44
- "--fs-row-gap": `${gap.value}px`
45
- };
46
+ const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => ({
47
+ "--fs-row-flex-wrap": wrap.value ? "wrap" : "nowrap",
48
+ "--fs-row-gap": `${gap.value}px`,
49
+ "--fs-row-width": width.value,
50
+ "--fs-row-height": height.value
51
+ }));
52
+
53
+ const classes = computed((): string[] => {
54
+ const classes = ["fs-row"];
46
55
  switch (width.value) {
47
56
  case "hug":
57
+ classes.push("fs-row-width-hug");
48
58
  break;
49
59
  case "fill":
50
- style.flex = "1 0 0";
60
+ classes.push("fs-row-width-fill");
51
61
  break;
52
- default:
53
- style.width = width.value;
62
+ default:
63
+ classes.push("fs-row-width-fixed");
54
64
  break;
55
65
  }
56
66
  switch (height.value) {
57
67
  case "hug":
68
+ classes.push("fs-row-height-hug");
58
69
  break;
59
70
  case "fill":
60
- style.alignSelf = "stretch";
71
+ classes.push("fs-row-height-fill");
72
+ break;
73
+ default:
74
+ classes.push("fs-row-height-fixed");
75
+ break;
76
+ }
77
+ switch (align.value) {
78
+ case "top-left":
79
+ classes.push("fs-row-top-left");
80
+ break;
81
+ case "top-center":
82
+ classes.push("fs-row-top-center");
83
+ break;
84
+ case "top-right":
85
+ classes.push("fs-row-top-right");
86
+ break;
87
+ case "center-left":
88
+ classes.push("fs-row-center-left");
89
+ break;
90
+ case "center-center":
91
+ classes.push("fs-row-center-center");
92
+ break;
93
+ case "center-right":
94
+ classes.push("fs-row-center-right");
95
+ break;
96
+ case "bottom-left":
97
+ classes.push("fs-row-bottom-left");
98
+ break;
99
+ case "bottom-center":
100
+ classes.push("fs-row-bottom-center");
61
101
  break;
62
- default:
63
- style.height = height.value;
64
- style.flexShrink = "0";
102
+ case "bottom-right":
103
+ classes.push("fs-row-bottom-right");
65
104
  break;
66
105
  }
67
- return style;
106
+ return classes;
68
107
  });
69
108
 
70
109
  return {
71
- style
110
+ style,
111
+ classes
72
112
  };
73
113
  }
74
114
  });
@@ -0,0 +1,122 @@
1
+ <template>
2
+ <FSTextField
3
+ :label="$props.label"
4
+ :description="$props.description"
5
+ :type="type"
6
+ :color="$props.color"
7
+ :required="$props.required"
8
+ :editable="$props.editable"
9
+ :value="innerValue"
10
+ @update:value="(value) => innerValue = value"
11
+ v-bind="$attrs"
12
+ >
13
+ <template #append>
14
+ <FSButton
15
+ :prependIcon="$props.buttonPrependIcon"
16
+ :label="$props.buttonLabel"
17
+ :appendIcon="$props.buttonAppendIcon"
18
+ :variant="$props.buttonVariant"
19
+ :color="$props.buttonColor"
20
+ :editable="$props.editable"
21
+ @click="onUpdate"
22
+ />
23
+ </template>
24
+ <template v-for="(_, name) in $slots" v-slot:[name]="slotData">
25
+ <slot :name="name" v-bind="slotData" />
26
+ </template>
27
+ </FSTextField>
28
+ </template>
29
+
30
+ <script lang="ts">
31
+ import { defineComponent, PropType, Ref, ref, toRefs } from "vue";
32
+
33
+ import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
34
+
35
+ import FSTextField from "./FSTextField.vue";
36
+ import FSButton from "./FSButton.vue";
37
+ import FSIcon from "./FSIcon.vue";
38
+
39
+ export default defineComponent({
40
+ name: "FSSearchField",
41
+ components: {
42
+ FSTextField,
43
+ FSButton,
44
+ FSIcon
45
+ },
46
+ props: {
47
+ label: {
48
+ type: String,
49
+ required: false,
50
+ default: null
51
+ },
52
+ description: {
53
+ type: String,
54
+ required: false,
55
+ default: null
56
+ },
57
+ buttonPrependIcon: {
58
+ type: String,
59
+ required: false,
60
+ default: "mdi-magnify"
61
+ },
62
+ buttonLabel: {
63
+ type: String,
64
+ required: false,
65
+ default: null
66
+ },
67
+ buttonAppendIcon: {
68
+ type: String,
69
+ required: false,
70
+ default: null
71
+ },
72
+ buttonVariant: {
73
+ type: String as PropType<"standard" | "full" | "icon">,
74
+ required: false,
75
+ default: "standard"
76
+ },
77
+ value: {
78
+ type: String,
79
+ required: false,
80
+ default: null
81
+ },
82
+ color: {
83
+ type: String as PropType<ColorBase>,
84
+ required: false,
85
+ default: ColorBase.Dark
86
+ },
87
+ buttonColor: {
88
+ type: String as PropType<ColorBase>,
89
+ required: false,
90
+ default: ColorBase.Primary
91
+ },
92
+ required: {
93
+ type: Boolean,
94
+ required: false,
95
+ default: false
96
+ },
97
+ editable: {
98
+ type: Boolean,
99
+ required: false,
100
+ default: true
101
+ }
102
+ },
103
+ emits: ["update:value"],
104
+ setup(props, { emit }) {
105
+ const { editable } = toRefs(props);
106
+
107
+ const innerValue: Ref<String> = ref(props.value);
108
+
109
+ const onUpdate = (): void => {
110
+ if (!editable.value) {
111
+ return;
112
+ }
113
+ emit("update:value", innerValue.value);
114
+ };
115
+
116
+ return {
117
+ innerValue,
118
+ onUpdate
119
+ };
120
+ }
121
+ });
122
+ </script>
@@ -5,16 +5,16 @@
5
5
  :style="style"
6
6
  v-bind="$attrs"
7
7
  >
8
- <FSRow height="hug">
8
+ <FSRow>
9
9
  <v-slide-group-item v-for="(component, index) in $slots.default()" :key="index">
10
- <component :is="component" v-bind="{ color }" />
10
+ <component :is="component" v-bind="{ color, colors, style }" />
11
11
  </v-slide-group-item>
12
12
  </FSRow>
13
13
  </v-slide-group>
14
14
  </template>
15
15
 
16
16
  <script lang="ts">
17
- import { defineComponent, PropType, toRefs } from "vue";
17
+ import { defineComponent, PropType, Ref, ref, toRefs } from "vue";
18
18
 
19
19
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
20
20
  import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
@@ -36,20 +36,24 @@ export default defineComponent({
36
36
  setup(props) {
37
37
  const { color } = toRefs(props);
38
38
 
39
- const colors = useColors().getVariants(color.value);
40
- const dark = useColors().getDark();
39
+ const textColors = useColors().getContrasts(color.value);
40
+ const colors = useColors().getColors(color.value);
41
41
 
42
- const style = {
43
- "--fs-group-light-color" : colors.light,
44
- "--fs-group-base-color" : colors.base,
45
- "--fs-group-dark-color" : colors.dark,
46
- "--fs-group-light-text" : dark.base,
47
- "--fs-group-base-text" : dark.base,
48
- "--fs-group-dark-text" : dark.dark
49
- };
42
+ const darks = useColors().getColors(ColorBase.Dark);
43
+
44
+ const style: Ref<{ [code: string]: string } & Partial<CSSStyleDeclaration>> = ref({
45
+ "--fs-group-color": darks.base,
46
+ "--fs-group-hover-background-color": colors.light,
47
+ "--fs-group-hover-color": darks.dark,
48
+ "--fs-group-disabled-color": darks.light,
49
+ "--fs-group-light": colors.light,
50
+ "--fs-group-base": colors.base,
51
+ "--fs-group-dark": colors.dark
52
+ });
50
53
 
51
54
  return {
52
55
  color,
56
+ colors,
53
57
  style
54
58
  };
55
59
  }
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <span
3
- class="fs-span"
4
- :class="$props.font"
3
+ :class="classes"
5
4
  v-bind="$attrs"
6
5
  >
7
6
  <slot />
@@ -9,16 +8,41 @@
9
8
  </template>
10
9
 
11
10
  <script lang="ts">
12
- import { defineComponent, PropType } from "vue";
11
+ import { computed, defineComponent, PropType, toRefs, useSlots } from "vue";
13
12
 
14
13
  export default defineComponent({
15
14
  name: "FSSpan",
16
15
  props: {
17
16
  font: {
18
- type: String as PropType<"text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline">,
17
+ type: String as PropType<"text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline" | "text-underline">,
19
18
  required: false,
20
19
  default: "text-body"
20
+ },
21
+ ellipsis: {
22
+ type: Boolean,
23
+ required: false,
24
+ default: true
21
25
  }
26
+ },
27
+ setup(props) {
28
+ const { font } = toRefs(props);
29
+
30
+ const slots = useSlots();
31
+
32
+ const classes = computed((): string[] => {
33
+ const classes = ["fs-span", font.value];
34
+ if (props.ellipsis) {
35
+ classes.push("fs-span-ellipsis");
36
+ }
37
+ if (!slots.default) {
38
+ classes.push("fs-span-pre-wrap");
39
+ }
40
+ return classes;
41
+ });
42
+
43
+ return {
44
+ classes
45
+ };
22
46
  }
23
47
  });
24
48
  </script>