@dative-gpi/foundation-shared-components 0.0.35 → 0.0.37

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.
@@ -8,9 +8,10 @@
8
8
  :color="$props.color"
9
9
  :load="$props.load"
10
10
  :padding="padding"
11
+ :to="$props.to"
11
12
  :style="style"
12
13
  :width="width"
13
- @click="$emit('click')"
14
+ @click.stop="onClick"
14
15
  v-bind="$attrs"
15
16
  >
16
17
  <FSRow
@@ -61,6 +62,24 @@
61
62
  :color="loadColor"
62
63
  />
63
64
  </template>
65
+ <template v-else-if="$props.to">
66
+ <router-link
67
+ :to="$props.to"
68
+ >
69
+ <FSIcon
70
+ v-if="$props.icon"
71
+ size="l"
72
+ >
73
+ {{ $props.icon }}
74
+ </FSIcon>
75
+ <FSSpan
76
+ v-if="$props.label"
77
+ font="text-overline"
78
+ >
79
+ {{ $props.label }}
80
+ </FSSpan>
81
+ </router-link>
82
+ </template>
64
83
  <template v-else>
65
84
  <FSIcon
66
85
  v-if="$props.icon"
@@ -80,6 +99,7 @@
80
99
 
81
100
  <script lang="ts">
82
101
  import { computed, defineComponent, PropType } from "vue";
102
+ import { RouteLocation, useRouter } from "vue-router";
83
103
 
84
104
  import { useColors, useSlots } from "@dative-gpi/foundation-shared-components/composables";
85
105
  import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
@@ -98,6 +118,11 @@ export default defineComponent({
98
118
  FSRow
99
119
  },
100
120
  props: {
121
+ to: {
122
+ type: [String, Object] as PropType<string | RouteLocation>,
123
+ required: false,
124
+ default: null
125
+ },
101
126
  prependIcon: {
102
127
  type: String,
103
128
  required: false,
@@ -148,6 +173,7 @@ export default defineComponent({
148
173
  setup(props, { emit }) {
149
174
  const { getColors } = useColors();
150
175
  const { slots } = useSlots();
176
+ const router = useRouter();
151
177
 
152
178
  const colors = computed(() => getColors(props.color));
153
179
  const lights = getColors(ColorEnum.Light);
@@ -209,9 +235,21 @@ export default defineComponent({
209
235
  return "fit-content";
210
236
  });
211
237
 
212
- const onClick = () => {
213
- if (props.editable && !props.load) {
214
- emit("click");
238
+ const href = computed((): string | null => {
239
+ if (!props.to || !props.editable || props.load) {
240
+ return null;
241
+ }
242
+ if (typeof props.to === "string") {
243
+ return props.to;
244
+ }
245
+ else {
246
+ return router.resolve(props.to).href;
247
+ }
248
+ });
249
+
250
+ const onClick = (event: MouseEvent) => {
251
+ if (!props.to && props.editable && !props.load) {
252
+ emit("click", event);
215
253
  }
216
254
  };
217
255
 
@@ -202,9 +202,9 @@ export default defineComponent({
202
202
  }
203
203
  });
204
204
 
205
- const onClick = () => {
205
+ const onClick = (event: MouseEvent) => {
206
206
  if (!props.to && props.editable && !props.load) {
207
- emit("click");
207
+ emit("click", event);
208
208
  }
209
209
  };
210
210
 
@@ -24,7 +24,7 @@ export default defineComponent({
24
24
  default: "m"
25
25
  },
26
26
  variant: {
27
- type: String as PropType<"standard" | "fill">,
27
+ type: String as PropType<"standard" | "full">,
28
28
  required: false,
29
29
  default: "standard"
30
30
  },
@@ -41,7 +41,7 @@ export default defineComponent({
41
41
 
42
42
  const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
43
43
  switch (props.variant) {
44
- case "fill": return {
44
+ case "full": return {
45
45
  "--fs-icon-background-color": colors.value.light
46
46
  };
47
47
  default: return {
@@ -53,7 +53,7 @@ export default defineComponent({
53
53
  const classes = computed((): string[] => {
54
54
  const classNames = [`fs-icon-${props.size}`];
55
55
  switch (props.variant) {
56
- case "fill":
56
+ case "full":
57
57
  classNames.push("fs-color-icon");
58
58
  break;
59
59
  }
@@ -93,8 +93,8 @@ export default defineComponent({
93
93
  });
94
94
 
95
95
  return {
96
- ColorEnum,
97
96
  isExtraSmall,
97
+ ColorEnum,
98
98
  classes,
99
99
  width
100
100
  };
@@ -47,7 +47,7 @@ export default defineComponent({
47
47
  variant: {
48
48
  type: String as PropType<"base" | "light" | "dark">,
49
49
  required: false,
50
- default: "dark"
50
+ default: "base"
51
51
  }
52
52
  },
53
53
  setup(props) {
@@ -6,7 +6,7 @@
6
6
  <template #activator="{ props }">
7
7
  <FSColorIcon
8
8
  size="m"
9
- variant="fill"
9
+ variant="full"
10
10
  :color="$props.deviceConnectivity.color"
11
11
  v-bind="props"
12
12
  >
@@ -6,7 +6,7 @@
6
6
  <template #activator="{ props }">
7
7
  <FSColorIcon
8
8
  size="m"
9
- variant="fill"
9
+ variant="full"
10
10
  :color="$props.statusGroup.color"
11
11
  v-bind="props"
12
12
  >
@@ -10,7 +10,7 @@
10
10
  >
11
11
  <FSColorIcon
12
12
  size="m"
13
- variant="fill"
13
+ variant="full"
14
14
  :color="criticityColor"
15
15
  v-bind="props"
16
16
  >
@@ -662,20 +662,23 @@ export default defineComponent({
662
662
  const activeFilters: { key: string, filter: FSDataTableFilter }[] = Object.keys(filters.value).reduce((acc, key) => {
663
663
  return acc.concat(filters.value[key].filter((filter) => filter.hidden).map((filter) => ({ key, filter })));
664
664
  }, []);
665
- return props.items.filter((item) => {
666
- if (props.selectedOnly && !innerValue.value.includes(item[props.itemValue])) {
667
- return false;
668
- }
669
- if (innerSearch.value) {
670
- if (!JSON.stringify(item).toLowerCase().includes(innerSearch.value.toString().toLowerCase())) {
665
+ if (props.items && props.items.length) {
666
+ return props.items.filter((item) => {
667
+ if (props.selectedOnly && !innerValue.value.includes(item[props.itemValue])) {
671
668
  return false;
672
669
  }
673
- }
674
- if (activeFilters.some(af => af.filter.filter(af.filter.value, item[af.key], item))) {
675
- return false;
676
- }
677
- return true;
678
- });
670
+ if (innerSearch.value) {
671
+ if (!JSON.stringify(item).toLowerCase().includes(innerSearch.value.toString().toLowerCase())) {
672
+ return false;
673
+ }
674
+ }
675
+ if (activeFilters.some(af => af.filter.filter(af.filter.value, item[af.key], item))) {
676
+ return false;
677
+ }
678
+ return true;
679
+ });
680
+ }
681
+ return [];
679
682
  });
680
683
 
681
684
  const headersSlots = computed((): FSDataTableColumn[] => {
@@ -811,19 +814,21 @@ export default defineComponent({
811
814
  }));
812
815
  }
813
816
  else {
814
- const mapToInnerValue = header.innerValue ? header.innerValue : (i: any) => i;
815
- const itemValues = props.items.flatMap((item) => Array.isArray(item[key]) && item[key].length == 0 ? undefined : item[key]).map(mapToInnerValue);
816
- const distinctValues = [...new Set(itemValues)];
817
-
818
- value = distinctValues.map((dv): FSDataTableFilter => ({
819
- hidden: currentFilters?.find((cf) => cf.value == (dv || null))?.hidden ?? false,
820
- text: dv?.toString() ?? "—",
821
- value: dv || null,
822
- filter: header.methodFilter ?? ((_, property) => {
823
- property = [property].flat().map(mapToInnerValue);
824
- return Array.isArray(property) ? property.includes(dv) || (!dv && property.length == 0) : (!dv && !property) || dv == property;
825
- })
826
- }));
817
+ if (props.items && props.items.length) {
818
+ const mapToInnerValue = header.innerValue ? header.innerValue : (i: any) => i;
819
+ const itemValues = props.items.flatMap((item) => Array.isArray(item[key]) && item[key].length == 0 ? undefined : item[key]).map(mapToInnerValue);
820
+ const distinctValues = [...new Set(itemValues)];
821
+
822
+ value = distinctValues.map((dv): FSDataTableFilter => ({
823
+ hidden: currentFilters?.find((cf) => cf.value == (dv || null))?.hidden ?? false,
824
+ text: dv?.toString() ?? "—",
825
+ value: dv || null,
826
+ filter: header.methodFilter ?? ((_, property) => {
827
+ property = [property].flat().map(mapToInnerValue);
828
+ return Array.isArray(property) ? property.includes(dv) || (!dv && property.length == 0) : (!dv && !property) || dv == property;
829
+ })
830
+ }));
831
+ }
827
832
  }
828
833
  filterDictionary[key] = value.sort((v1, v2) => {
829
834
  return v1.text.localeCompare(v2.text, undefined, { numeric: true });
@@ -2,10 +2,10 @@ import { computed, ref } from "vue";
2
2
 
3
3
  let initialized = false;
4
4
 
5
- export const useBreakpoints = () => {
6
- const windowHeight = ref(window.innerHeight);
7
- const windowWidth = ref(window.innerWidth);
5
+ const windowHeight = ref(window.innerHeight);
6
+ const windowWidth = ref(window.innerWidth);
8
7
 
8
+ export const useBreakpoints = () => {
9
9
  const onSizeChange = (): void => {
10
10
  windowHeight.value = window.innerHeight;
11
11
  windowWidth.value = window.innerWidth;
@@ -50,7 +50,7 @@ export const useColors = () => {
50
50
  const getContrasts = (color: ColorBase): ColorVariations => {
51
51
  const themed = (Object as any).values(ColorEnum).includes(color);
52
52
 
53
- const base = themed ? new Color(theme.colors[color as ColorEnum]) : new Color(color);
53
+ let base = themed ? new Color(theme.colors[color as ColorEnum]) : new Color(color);
54
54
 
55
55
  if (isGrayScale(base)) {
56
56
  switch (color) {
@@ -60,15 +60,15 @@ export const useColors = () => {
60
60
  return getColors(ColorEnum.Light);
61
61
  default:
62
62
  if (base.value() > 50) {
63
- base.value(Math.max(base.value() - 65, 0));
63
+ base = base.value(Math.max(base.value() - 65, 0));
64
64
  }
65
65
  else {
66
- base.value(Math.min(base.value() + 65, 100));
66
+ base = base.value(Math.min(base.value() + 65, 100));
67
67
  }
68
68
  break;
69
69
  }
70
70
  }
71
- return getColors(color);
71
+ return getColors(base.hex());
72
72
  };
73
73
 
74
74
  const getGradients = (colors: ColorBase | ColorBase[]): ColorVariations => {
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.35",
4
+ "version": "0.0.37",
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.35",
14
- "@dative-gpi/foundation-shared-services": "0.0.35",
13
+ "@dative-gpi/foundation-shared-domain": "0.0.37",
14
+ "@dative-gpi/foundation-shared-services": "0.0.37",
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": "91779c855747711392153c2adc6e6b2bbc982e48"
35
+ "gitHead": "60d7b514ce598dccaef07b4696e957ea2165a7a3"
36
36
  }
@@ -6,4 +6,9 @@
6
6
  color: var(--fs-button-hover-color) !important;
7
7
  cursor: pointer !important;
8
8
  }
9
+
10
+ &.fs-button-disabled,
11
+ &:has(.fs-button-load) {
12
+ cursor: default !important;
13
+ }
9
14
  }