@dative-gpi/foundation-shared-components 0.0.20 → 0.0.22

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.
@@ -1,16 +1,19 @@
1
1
  <template>
2
2
  <FSClickable
3
3
  v-if="!['icon'].includes($props.variant)"
4
- :height="['40px', '36px']"
5
4
  :editable="$props.editable"
5
+ :height="['40px', '36px']"
6
+ :variant="$props.variant"
6
7
  :color="$props.color"
8
+ :padding="padding"
7
9
  :class="classes"
8
10
  :style="style"
11
+ :width="width"
9
12
  v-bind="$attrs"
10
13
  >
11
14
  <FSRow
12
15
  align="center-center"
13
- width="hug"
16
+ width="fill"
14
17
  :wrap="false"
15
18
  >
16
19
  <slot name="prepend" v-bind="{ color: $props.color, colors }">
@@ -129,29 +132,15 @@ export default defineComponent({
129
132
  const lights = getColors(ColorEnum.Light);
130
133
  const darks = getColors(ColorEnum.Dark);
131
134
 
132
- const hasNoText = computed(() => {
133
- return !slots.default && !props.label;
134
- });
135
-
136
135
  const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
137
136
  if (!props.editable) {
138
137
  switch (props.variant) {
139
- case "standard":
140
- case "full": return {
141
- "--fs-button-padding": !hasNoText.value ? "0 16px" : "0 7px"
142
- };
143
138
  case "icon": return {
144
139
  "--fs-button-color": lights.dark,
145
140
  };
146
141
  }
147
142
  }
148
143
  switch (props.variant) {
149
- case "standard": return {
150
- "--fs-button-padding": !hasNoText.value ? "0 16px" : "0 7px"
151
- };
152
- case "full": return {
153
- "--fs-button-padding": !hasNoText.value ? "0 16px" : "0 7px"
154
- };
155
144
  case "icon": switch (props.color) {
156
145
  case ColorEnum.Dark:
157
146
  case ColorEnum.Light: return {
@@ -182,10 +171,27 @@ export default defineComponent({
182
171
  return classNames;
183
172
  });
184
173
 
174
+ const padding = computed((): string | number => {
175
+ switch (props.variant) {
176
+ case "standard":
177
+ case "full": return (!slots.default && !props.label) ? "0 7px" : "0 16px";
178
+ default: return "0px";
179
+ }
180
+ });
181
+
182
+ const width = computed((): string | number => {
183
+ if (props.fullWidth) {
184
+ return "100%";
185
+ }
186
+ return "fit-content";
187
+ });
188
+
185
189
  return {
186
190
  classes,
191
+ padding,
187
192
  colors,
188
- style
193
+ style,
194
+ width
189
195
  };
190
196
  }
191
197
  });
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <FSCard
3
+ v-if="!href"
3
4
  :border="$props.border"
4
5
  :class="classes"
5
6
  :style="style"
@@ -10,10 +11,26 @@
10
11
  <slot :name="name" v-bind="slotData" />
11
12
  </template>
12
13
  </FSCard>
14
+ <a
15
+ v-else
16
+ :href="href"
17
+ >
18
+ <FSCard
19
+ :border="$props.border"
20
+ :class="classes"
21
+ :style="style"
22
+ v-bind="$attrs"
23
+ >
24
+ <template v-for="(_, name) in $slots" v-slot:[name]="slotData">
25
+ <slot :name="name" v-bind="slotData" />
26
+ </template>
27
+ </FSCard>
28
+ </a>
13
29
  </template>
14
30
 
15
31
  <script lang="ts">
16
32
  import { computed, defineComponent, PropType } from "vue";
33
+ import { RouteLocation, useRouter } from "vue-router";
17
34
 
18
35
  import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
19
36
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
@@ -27,6 +44,11 @@ export default defineComponent({
27
44
  FSCard
28
45
  },
29
46
  props: {
47
+ to: {
48
+ type: [String, Object] as PropType<string | RouteLocation>,
49
+ required: false,
50
+ default: null
51
+ },
30
52
  border: {
31
53
  type: Boolean,
32
54
  required: false,
@@ -56,6 +78,7 @@ export default defineComponent({
56
78
  emits: ["click"],
57
79
  setup(props, { emit }) {
58
80
  const { getColors, getContrasts } = useColors();
81
+ const router = useRouter();
59
82
 
60
83
  const textColors = computed(() => getContrasts(props.color));
61
84
  const colors = computed(() => getColors(props.color));
@@ -68,7 +91,7 @@ export default defineComponent({
68
91
  "--fs-clickable-border-radius" : sizeToVar(props.borderRadius),
69
92
  "--fs-clickable-background-color": lights.base,
70
93
  "--fs-clickable-border-color" : lights.dark,
71
- "--fs-clickable-color" : lights.dark,
94
+ "--fs-clickable-color" : lights.dark
72
95
  };
73
96
  }
74
97
  switch (props.variant) {
@@ -83,7 +106,7 @@ export default defineComponent({
83
106
  "--fs-clickable-hover-color" : textColors.value.light,
84
107
  "--fs-clickable-active-background-color": colors.value.dark,
85
108
  "--fs-clickable-active-border-color" : colors.value.dark,
86
- "--fs-clickable-active-color" : textColors.value.light,
109
+ "--fs-clickable-active-color" : textColors.value.light
87
110
  };
88
111
  case "full": return {
89
112
  "--fs-clickable-border-size" : props.border ? "1px" : "0",
@@ -96,7 +119,7 @@ export default defineComponent({
96
119
  "--fs-clickable-hover-color" : textColors.value.light,
97
120
  "--fs-clickable-active-background-color": colors.value.dark,
98
121
  "--fs-clickable-active-border-color" : colors.value.dark,
99
- "--fs-clickable-active-color" : textColors.value.light,
122
+ "--fs-clickable-active-color" : textColors.value.light
100
123
  };
101
124
  }
102
125
  });
@@ -109,6 +132,18 @@ export default defineComponent({
109
132
  return classNames;
110
133
  });
111
134
 
135
+ const href = computed((): string | null => {
136
+ if (!props.to) {
137
+ return null;
138
+ }
139
+ if (typeof props.to === "string") {
140
+ return props.to;
141
+ }
142
+ else {
143
+ return router.resolve(props.to).href;
144
+ }
145
+ });
146
+
112
147
  const onClick = () => {
113
148
  if (props.editable) {
114
149
  emit("click");
@@ -118,6 +153,7 @@ export default defineComponent({
118
153
  return {
119
154
  classes,
120
155
  style,
156
+ href,
121
157
  onClick
122
158
  };
123
159
  }
@@ -1,15 +1,12 @@
1
1
  <template>
2
- <FSRow
3
- class="fs-color"
4
- :width="$props.width"
5
- :height="$props.height"
6
- :align="$props.align"
7
- :wrap="$props.wrap"
8
- :gap="$props.gap"
2
+ <FSCard
3
+ :border="$props.border"
4
+ :class="classes"
9
5
  :style="style"
6
+ v-bind="$attrs"
10
7
  >
11
8
  <slot v-bind="{ color: $props.color, colors }" />
12
- </FSRow>
9
+ </FSCard>
13
10
  </template>
14
11
 
15
12
  <script lang="ts">
@@ -18,39 +15,19 @@ import { computed, defineComponent, PropType, ref, Ref } from "vue";
18
15
  import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
19
16
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
20
17
 
21
- import FSRow from "./FSRow.vue";
18
+ import FSCard from "./FSCard.vue";
22
19
 
23
20
  export default defineComponent({
24
21
  name: "FSColor",
25
22
  components: {
26
- FSRow
23
+ FSCard
27
24
  },
28
25
  props: {
29
- width: {
30
- type: String as PropType<"hug" | "fill" | string>,
31
- required: false,
32
- default: "hug"
33
- },
34
- height: {
35
- type: String as PropType<"hug" | "fill" | string>,
36
- required: false,
37
- default: "hug"
38
- },
39
- align: {
40
- type: String as PropType<"top-left" | "top-center" | "top-right" | "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right">,
41
- required: false,
42
- default: "center-left"
43
- },
44
- wrap: {
26
+ border: {
45
27
  type: Boolean,
46
28
  required: false,
47
29
  default: true
48
30
  },
49
- gap: {
50
- type: [String, Number],
51
- required: false,
52
- default: "8px"
53
- },
54
31
  color: {
55
32
  type: String as PropType<ColorBase>,
56
33
  required: false,
@@ -64,13 +41,23 @@ export default defineComponent({
64
41
 
65
42
  const style: Ref<{ [code: string]: string } & Partial<CSSStyleDeclaration>> = ref({
66
43
  "--fs-color-background-color": colors.value.light,
44
+ "--fs-color-border-color" : colors.value.base,
67
45
  "--fs-color-color" : colors.value.base,
68
46
  "--fs-color-light" : colors.value.light,
69
47
  "--fs-color-base" : colors.value.base,
70
48
  "--fs-color-dark" : colors.value.dark
71
49
  });
72
50
 
51
+ const classes = computed((): string[] => {
52
+ const classNames = ["fs-color"];
53
+ if (props.border) {
54
+ classNames.push("fs-color-border");
55
+ }
56
+ return classNames;
57
+ });
58
+
73
59
  return {
60
+ classes,
74
61
  colors,
75
62
  style
76
63
  };
@@ -12,6 +12,7 @@ import { computed, defineComponent } from "vue";
12
12
 
13
13
  import { useColors } from "@dative-gpi/foundation-shared-components/composables";
14
14
  import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
15
+ import { sizeToVar } from "@dative-gpi/foundation-shared-components/utils";
15
16
 
16
17
  export default defineComponent({
17
18
  name: "FSContainer",
@@ -19,7 +20,7 @@ export default defineComponent({
19
20
  padding: {
20
21
  type: [String, Number],
21
22
  required: false,
22
- default: 8
23
+ default: "8px"
23
24
  },
24
25
  border: {
25
26
  type: Boolean,
@@ -40,7 +41,7 @@ export default defineComponent({
40
41
 
41
42
  const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
42
43
  return {
43
- "--fs-container-padding" : typeof(props.padding) === "string" ? props.padding : `${props.padding}px`,
44
+ "--fs-container-padding" : sizeToVar(props.padding),
44
45
  "--fs-container-background-color": backgrounds.base,
45
46
  "--fs-container-border-color" : lights.dark
46
47
  };
@@ -5,7 +5,9 @@
5
5
  :style="style"
6
6
  v-bind="$attrs"
7
7
  >
8
- {{ $props.label }}
8
+ <slot>
9
+ {{ $props.label }}
10
+ </slot>
9
11
  </span>
10
12
  <FSLoader
11
13
  v-else
@@ -1,16 +1,19 @@
1
1
  <template>
2
2
  <a
3
- :href="$props.to"
4
3
  :class="classes"
5
4
  :style="style"
5
+ :href="href"
6
6
  v-bind="$attrs"
7
7
  >
8
- <slot />
8
+ <slot>
9
+ {{ $props.label }}
10
+ </slot>
9
11
  </a>
10
12
  </template>
11
13
 
12
14
  <script lang="ts">
13
15
  import { computed, defineComponent, PropType } from "vue";
16
+ import { RouteLocation, useRouter } from "vue-router";
14
17
 
15
18
  import { useColors, useSlots } from "@dative-gpi/foundation-shared-components/composables";
16
19
  import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
@@ -18,10 +21,15 @@ import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/m
18
21
  export default defineComponent({
19
22
  name: "FSLink",
20
23
  props: {
24
+ label: {
25
+ type: [String, null, undefined],
26
+ required: false,
27
+ default: null
28
+ },
21
29
  to: {
22
- type: String,
23
- required: false,
24
- default: "_blank"
30
+ type: [String, Object] as PropType<string | RouteLocation>,
31
+ required: false,
32
+ default: "_blank"
25
33
  },
26
34
  font: {
27
35
  type: String as PropType<"text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline" | "text-underline">,
@@ -52,6 +60,7 @@ export default defineComponent({
52
60
  setup(props) {
53
61
  const { getColors } = useColors();
54
62
  const { slots } = useSlots();
63
+ const router = useRouter();
55
64
 
56
65
  const colors = computed(() => getColors(props.color));
57
66
 
@@ -86,9 +95,19 @@ export default defineComponent({
86
95
  }
87
96
  });
88
97
 
98
+ const href = computed((): string => {
99
+ if (typeof props.to === "string") {
100
+ return props.to;
101
+ }
102
+ else {
103
+ return router.resolve(props.to).href;
104
+ }
105
+ });
106
+
89
107
  return {
90
108
  classes,
91
- style
109
+ style,
110
+ href
92
111
  };
93
112
  }
94
113
  });
@@ -49,7 +49,7 @@
49
49
  />
50
50
  </template>
51
51
  <FSHiddenButton
52
- v-if="hiddenHeaders.length > 0"
52
+ v-if="innerMode === 'table' && hiddenHeaders.length > 0"
53
53
  :headers="hiddenHeaders"
54
54
  :color="$props.color"
55
55
  @update:show="(value) => updateHeader(value, 'hidden', false)"
@@ -359,7 +359,7 @@
359
359
  </template>
360
360
  </v-data-iterator>
361
361
  </template>
362
- <template v-else-if="innerMode === 'iterator'">
362
+ <template v-else>
363
363
  <v-data-iterator
364
364
  class="fs-data-table-iterator"
365
365
  :items="innerItems"
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <FSSelectField
3
+ :items="entities"
4
+ :modelValue="$props.modelValue"
5
+ @update:modelValue="$emit('update:modelValue', $event)"
6
+ v-bind="$attrs"
7
+ />
8
+ </template>
9
+
10
+ <script lang="ts">
11
+ import { defineComponent, onMounted } from "vue";
12
+
13
+ import { useTimeZones } from "@dative-gpi/foundation-shared-services/composables";
14
+
15
+ import FSSelectField from "../fields/FSSelectField.vue";
16
+
17
+ export default defineComponent({
18
+ name: "FSSelectTimeZone",
19
+ components: {
20
+ FSSelectField
21
+ },
22
+ props: {
23
+ modelValue: {
24
+ type: String,
25
+ required: false,
26
+ default: null
27
+ },
28
+ },
29
+ emits: ["update:modelValue"],
30
+ setup() {
31
+ const { getMany, entities } = useTimeZones();
32
+
33
+ onMounted(() => {
34
+ getMany();
35
+ });
36
+
37
+ return {
38
+ entities
39
+ };
40
+ }
41
+ });
42
+ </script>
@@ -38,6 +38,7 @@
38
38
  gap="4px"
39
39
  >
40
40
  <FSConnectivity
41
+ v-if="$props.deviceConnectivity"
41
42
  :deviceConnectivity="$props.deviceConnectivity"
42
43
  />
43
44
  <FSWorstAlert
@@ -129,7 +130,7 @@ export default defineComponent({
129
130
  deviceAlerts: {
130
131
  type: Array as PropType<FSDeviceAlert[]>,
131
132
  required: false,
132
- default: null
133
+ default: () => []
133
134
  },
134
135
  modelStatuses: {
135
136
  type: Array as PropType<FSModelStatus[]>,
@@ -40,16 +40,20 @@
40
40
  align="center-left"
41
41
  >
42
42
  <FSColor
43
- align="center-center"
44
43
  padding="0 8px"
45
44
  height="24px"
46
45
  :color="ColorEnum.Primary"
46
+ :border="false"
47
47
  >
48
- <FSText
49
- font="text-overline"
48
+ <FSRow
49
+ align="center-center"
50
50
  >
51
- {{ groupsLabel }}
52
- </FSText>
51
+ <FSText
52
+ font="text-overline"
53
+ >
54
+ {{ groupsLabel }}
55
+ </FSText>
56
+ </FSRow>
53
57
  </FSColor>
54
58
  <FSSpan
55
59
  font="text-overline"
@@ -61,16 +65,20 @@
61
65
  align="center-left"
62
66
  >
63
67
  <FSColor
64
- align="center-center"
65
68
  padding="0 8px"
66
69
  height="24px"
67
70
  :color="ColorEnum.Success"
71
+ :border="false"
68
72
  >
69
- <FSText
70
- font="text-overline"
73
+ <FSRow
74
+ align="center-center"
71
75
  >
72
- {{ deviceOrganisationsLabel }}
73
- </FSText>
76
+ <FSText
77
+ font="text-overline"
78
+ >
79
+ {{ deviceOrganisationsLabel }}
80
+ </FSText>
81
+ </FSRow>
74
82
  </FSColor>
75
83
  <FSSpan
76
84
  font="text-overline"
@@ -1,5 +1,7 @@
1
1
  import { computed, onMounted, onUnmounted, ref } from "vue";
2
2
 
3
+ let initialized = false;
4
+
3
5
  export const useBreakpoints = () => {
4
6
  const windowWidth = ref(window.innerWidth);
5
7
 
@@ -7,14 +9,6 @@ export const useBreakpoints = () => {
7
9
  windowWidth.value = window.innerWidth;
8
10
  };
9
11
 
10
- onMounted(() => {
11
- window.addEventListener("resize", onSizeChange);
12
- });
13
-
14
- onUnmounted(() => {
15
- window.removeEventListener("resize", onSizeChange);
16
- });
17
-
18
12
  const isTouchScreenEnabled = computed((): boolean => {
19
13
  return navigator.maxTouchPoints > 0;
20
14
  });
@@ -27,6 +21,11 @@ export const useBreakpoints = () => {
27
21
  return windowWidth.value < 600;
28
22
  });
29
23
 
24
+ if (!initialized) {
25
+ window.addEventListener("resize", onSizeChange);
26
+ initialized = true;
27
+ }
28
+
30
29
  return {
31
30
  isTouchScreenEnabled,
32
31
  isMobileSized,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-shared-components",
3
3
  "sideEffects": false,
4
- "version": "0.0.20",
4
+ "version": "0.0.22",
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": "0.0.20",
14
- "@dative-gpi/foundation-shared-services": "0.0.20",
13
+ "@dative-gpi/foundation-shared-domain": "0.0.22",
14
+ "@dative-gpi/foundation-shared-services": "0.0.22",
15
15
  "@fontsource/montserrat": "^5.0.16",
16
16
  "@lexical/clipboard": "^0.12.5",
17
17
  "@lexical/history": "^0.12.5",
@@ -32,5 +32,5 @@
32
32
  "sass": "^1.69.5",
33
33
  "sass-loader": "^13.3.2"
34
34
  },
35
- "gitHead": "9e8af5e1e592b3ae7725816cad435a497d2ffe91"
35
+ "gitHead": "2186455ca7eff6f916918d62b02874df3dd58150"
36
36
  }
@@ -1,11 +1,3 @@
1
- .fs-button {
2
- padding: var(--fs-button-padding) !important;
3
-
4
- &.fs-button-full-width {
5
- width: 100%;
6
- }
7
- }
8
-
9
1
  .fs-button-icon {
10
2
  transition: color 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
11
3
  color: var(--fs-button-color) !important;
@@ -23,4 +23,9 @@
23
23
  border-color: var(--fs-clickable-active-border-color) !important;
24
24
  color: var(--fs-clickable-active-color) !important;
25
25
  }
26
+ }
27
+
28
+ a:has(.fs-clickable) {
29
+ text-decoration: none;
30
+ padding: 0 !important;
26
31
  }
@@ -1,5 +1,6 @@
1
1
  .fs-color {
2
- background-color: var(--fs-color-background-color);
2
+ display: flex;
3
+ background-color: var(--fs-color-background-color) !important;
4
+ border-color: var(--fs-color-border-color) !important;
3
5
  color: var(--fs-color-color);
4
- border-radius: 4px;
5
6
  }