@dative-gpi/foundation-shared-components 0.0.38 → 0.0.40

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.
@@ -0,0 +1,132 @@
1
+ <template>
2
+ <FSClickable
3
+ padding="12px 0"
4
+ :editable="$props.editable"
5
+ :height="['32px', '28px']"
6
+ :variant="$props.variant"
7
+ :color="$props.color"
8
+ :load="$props.load"
9
+ :width="width"
10
+ @click.stop="onClick"
11
+ v-bind="$attrs"
12
+ >
13
+ <FSRow
14
+ align="center-center"
15
+ width="fill"
16
+ :wrap="false"
17
+ >
18
+ <slot name="prepend" v-bind="{ color: $props.color, colors }">
19
+ <FSIcon
20
+ v-if="$props.prependIcon || $props.icon"
21
+ size="l"
22
+ >
23
+ {{ $props.prependIcon ?? $props.icon }}
24
+ </FSIcon>
25
+ </slot>
26
+ <slot v-bind="{ color: $props.color, colors }">
27
+ <FSSpan
28
+ v-if="$props.label"
29
+ >
30
+ {{ $props.label }}
31
+ </FSSpan>
32
+ </slot>
33
+ <slot name="append" v-bind="{ color: $props.color, colors }">
34
+ <FSIcon
35
+ v-if="$props.appendIcon"
36
+ size="l"
37
+ >
38
+ {{ $props.appendIcon }}
39
+ </FSIcon>
40
+ </slot>
41
+ </FSRow>
42
+ </FSClickable>
43
+ </template>
44
+
45
+ <script lang="ts">
46
+ import { computed, defineComponent, PropType } from "vue";
47
+
48
+ import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
49
+ import { useColors } from "@dative-gpi/foundation-shared-components/composables";
50
+
51
+ import FSClickable from "./FSClickable.vue";
52
+ import FSSpan from "./FSSpan.vue";
53
+ import FSIcon from "./FSIcon.vue";
54
+ import FSRow from "./FSRow.vue";
55
+
56
+ export default defineComponent({
57
+ name: "FSOptionItem",
58
+ components: {
59
+ FSClickable,
60
+ FSSpan,
61
+ FSIcon,
62
+ FSRow
63
+ },
64
+ props: {
65
+ prependIcon: {
66
+ type: String,
67
+ required: false,
68
+ default: null
69
+ },
70
+ label: {
71
+ type: [String, Function],
72
+ required: false,
73
+ default: null
74
+ },
75
+ appendIcon: {
76
+ type: String,
77
+ required: false,
78
+ default: null
79
+ },
80
+ icon: {
81
+ type: String,
82
+ required: false,
83
+ default: null
84
+ },
85
+ variant: {
86
+ type: String as PropType<"standard" | "full">,
87
+ required: false,
88
+ default: "full"
89
+ },
90
+ color: {
91
+ type: String as PropType<ColorBase>,
92
+ required: false,
93
+ default: ColorEnum.Primary
94
+ },
95
+ load: {
96
+ type: Boolean,
97
+ required: false,
98
+ default: false
99
+ },
100
+ editable: {
101
+ type: Boolean,
102
+ required: false,
103
+ default: true
104
+ }
105
+ },
106
+ emits: ["click"],
107
+ setup(props, { emit }) {
108
+ const { getColors } = useColors();
109
+
110
+ const colors = computed(() => getColors(props.color));
111
+
112
+ const width = computed((): string => {
113
+ if (props.label) {
114
+ return "fit-content";
115
+ }
116
+ return "72px";
117
+ });
118
+
119
+ const onClick = (event: MouseEvent) => {
120
+ if (props.editable && !props.load) {
121
+ emit("click", event);
122
+ }
123
+ };
124
+
125
+ return {
126
+ colors,
127
+ width,
128
+ onClick
129
+ };
130
+ }
131
+ })
132
+ </script>
@@ -15,6 +15,7 @@
15
15
  />
16
16
  <FSButtonPreviousIcon
17
17
  :color="ColorEnum.Dark"
18
+ @click="goToPrev"
18
19
  />
19
20
  </template>
20
21
  <template #default>
@@ -28,6 +29,7 @@
28
29
  <template #next>
29
30
  <FSButtonNextIcon
30
31
  :color="ColorEnum.Dark"
32
+ @click="goToNext"
31
33
  />
32
34
  <FSButton
33
35
  v-if="$props.dash"
@@ -71,7 +73,12 @@ export default defineComponent({
71
73
  dash: {
72
74
  type: Boolean,
73
75
  required: false,
74
- default: true
76
+ default: false
77
+ },
78
+ speed: {
79
+ type: Number,
80
+ required: false,
81
+ default: 250
75
82
  }
76
83
  },
77
84
  setup(props) {
@@ -96,6 +103,12 @@ export default defineComponent({
96
103
  }
97
104
  };
98
105
 
106
+ const goToPrev = () => {
107
+ if (slideGroupRef.value) {
108
+ slideGroupRef.value.scrollOffset = Math.max(0, slideGroupRef.value.scrollOffset - props.speed);
109
+ }
110
+ };
111
+
99
112
  const goToEnd = () => {
100
113
  if (slideGroupRef.value) {
101
114
  const contentSize = slideGroupRef.value.$el.children[1].children[0].clientWidth;
@@ -105,12 +118,23 @@ export default defineComponent({
105
118
  }
106
119
  };
107
120
 
121
+ const goToNext = () => {
122
+ if (slideGroupRef.value) {
123
+ const contentSize = slideGroupRef.value.$el.children[1].children[0].clientWidth;
124
+ const containerSize = slideGroupRef.value.$el.clientWidth;
125
+ const arrowsOffset = props.dash ? 104 : 64;
126
+ slideGroupRef.value.scrollOffset = Math.min(contentSize - containerSize + arrowsOffset, slideGroupRef.value.scrollOffset + props.speed);
127
+ }
128
+ };
129
+
108
130
  return {
109
131
  slideGroupRef,
110
132
  ColorEnum,
111
133
  style,
112
134
  getChildren,
113
135
  goToStart,
136
+ goToPrev,
137
+ goToNext,
114
138
  goToEnd
115
139
  };
116
140
  }
@@ -40,23 +40,22 @@ export default defineComponent({
40
40
  }
41
41
  },
42
42
  setup(props) {
43
- const { getColors, getContrasts } = useColors();
44
43
  const { getChildren } = useSlots();
44
+ const { getColors } = useColors();
45
45
 
46
- const textColors = computed(() => getContrasts(props.color));
47
46
  const colors = computed(() => getColors(props.color));
48
47
  const darks = getColors(ColorEnum.Dark);
49
48
 
50
49
  const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => ({
51
50
  "--fs-group-color" : darks.base,
51
+ "--fs-group-disabled-color" : darks.light,
52
52
  "--fs-group-hover-background-color": colors.value.light,
53
53
  "--fs-group-hover-color" : darks.dark,
54
- "--fs-group-disabled-color" : darks.light,
55
54
  "--fs-group-light" : colors.value.light,
56
55
  "--fs-group-base" : colors.value.base,
57
56
  "--fs-group-dark" : colors.value.dark,
58
57
  "--fs-tab-tag-background-color" : colors.value.base,
59
- "--fs-tab-tag-color" : textColors.value.light
58
+ "--fs-tab-tag-color" : colors.value.baseContrast
60
59
  }));
61
60
 
62
61
  return {
@@ -73,28 +73,27 @@ export default defineComponent({
73
73
  },
74
74
  emits: ["remove"],
75
75
  setup(props) {
76
- const { getColors, getContrasts } = useColors();
76
+ const { getColors } = useColors();
77
77
 
78
- const textColors = computed(() => getContrasts(props.color));
79
78
  const colors = computed(() => getColors(props.color));
80
79
 
81
80
  const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
82
81
  switch (props.variant) {
83
82
  case "standard": return {
84
83
  "--fs-tag-background-color" : colors.value.light,
85
- "--fs-tag-color" : textColors.value.base,
84
+ "--fs-tag-color" : colors.value.lightContrast,
86
85
  "--fs-tag-hover-background-color" : colors.value.base,
87
- "--fs-tag-hover-color" : textColors.value.light,
86
+ "--fs-tag-hover-color" : colors.value.baseContrast,
88
87
  "--fs-tag-active-background-color": colors.value.dark,
89
- "--fs-tag-active-color" : textColors.value.light
88
+ "--fs-tag-active-color" : colors.value.darkContrast
90
89
  };
91
90
  case "full": return {
92
91
  "--fs-tag-background-color" : colors.value.base,
93
- "--fs-tag-color" : textColors.value.light,
92
+ "--fs-tag-color" : colors.value.baseContrast,
94
93
  "--fs-tag-hover-background-color" : colors.value.base,
95
- "--fs-tag-hover-color" : textColors.value.light,
94
+ "--fs-tag-hover-color" : colors.value.baseContrast,
96
95
  "--fs-tag-active-background-color": colors.value.dark,
97
- "--fs-tag-active-color" : textColors.value.light
96
+ "--fs-tag-active-color" : colors.value.darkContrast
98
97
  };
99
98
  }
100
99
  });
@@ -16,6 +16,7 @@
16
16
  :color="getColor(item)"
17
17
  :class="getClass(item)"
18
18
  :label="item.label"
19
+ :icon="item.icon"
19
20
  :key="index"
20
21
  @click="toggle(item)"
21
22
  />
@@ -56,6 +57,7 @@
56
57
  :color="getColor(item)"
57
58
  :class="getClass(item)"
58
59
  :label="item.label"
60
+ :icon="item.icon"
59
61
  :key="index"
60
62
  @click="toggle(item)"
61
63
  />
@@ -50,26 +50,10 @@ export default defineComponent({
50
50
  "--fs-group-hover-color": darks.dark
51
51
  }));
52
52
 
53
- const goToStart = () => {
54
- if (wrapGroupRef.value) {
55
- wrapGroupRef.value.scrollOffset = 0;
56
- }
57
- };
58
-
59
- const goToEnd = () => {
60
- if (wrapGroupRef.value) {
61
- const contentSize = wrapGroupRef.value.$el.children[1].children[0].clientWidth;
62
- const containerSize = wrapGroupRef.value.$el.clientWidth;
63
- wrapGroupRef.value.scrollOffset = (contentSize - containerSize);
64
- }
65
- };
66
-
67
53
  return {
68
54
  wrapGroupRef,
69
55
  style,
70
- getChildren,
71
- goToStart,
72
- goToEnd
56
+ getChildren
73
57
  };
74
58
  }
75
59
  });
@@ -123,7 +123,7 @@ export default defineComponent({
123
123
  },
124
124
  emits: ["update:modelValue"],
125
125
  setup(props) {
126
- const {validateOn, blurred, getMessages} = useRules();
126
+ const { validateOn, blurred, getMessages } = useRules();
127
127
  const { getColors } = useColors();
128
128
 
129
129
  const errors = getColors(ColorEnum.Error);
@@ -16,59 +16,89 @@ export const useColors = () => {
16
16
  return maxDiff < 10;
17
17
  };
18
18
 
19
- const lighten = (base: Color): Color => {
19
+ const isPastel = (color: Color): boolean => {
20
+ return color.saturationv() <= 15 && color.value() >= 85;
21
+ };
22
+
23
+ const getLight = (base: Color): Color => {
20
24
  if (isGrayScale(base)) {
21
25
  return base.value(Math.min(base.value() + 10, 100));
22
26
  }
23
27
  return base.saturationv(10).value(100);
24
28
  };
25
29
 
26
- const soften = (base: Color): Color => {
30
+ const getSoft = (base: Color): Color => {
27
31
  return base.value(Math.min(base.value() + 10, 100));
28
32
  };
29
33
 
30
- const darken = (base: Color): Color => {
31
- return base.value(Math.max(base.value() - 15, 0));
34
+ const getBase = (base: Color): Color => {
35
+ if (isGrayScale(base)) {
36
+ return base.saturationv(1);
37
+ }
38
+ return base.saturationv(((base.saturationv() * 30) / 100) + 70).value(90);
32
39
  };
33
40
 
34
- const getColors = (color: ColorBase): ColorVariations => {
35
- const themed = (Object as any).values(ColorEnum).includes(color);
36
-
37
- const base = themed ? new Color(theme.colors[color as ColorEnum]) : new Color(color);
38
- const light = lighten(base);
39
- const soft = soften(base);
40
- const dark = darken(base);
41
-
42
- return {
43
- light: light.hex(),
44
- soft: soft.hex(),
45
- base: base.hex(),
46
- dark: dark.hex()
47
- };
41
+ const getDark = (base: Color): Color => {
42
+ return base.value(Math.max(base.value() - 15, 0));
48
43
  };
49
44
 
50
- const getContrasts = (color: ColorBase): ColorVariations => {
45
+ const getContrast = (color: Color, fallback: Color): Color => {
46
+ if (isGrayScale(color)) {
47
+ if (color.value() > 50) {
48
+ return color.value(Math.max(0, color.value() - 75));
49
+ }
50
+ else {
51
+ return color.value(Math.min(100, color.value() + 75));
52
+ }
53
+ }
54
+ return fallback;
55
+ }
56
+
57
+ const getColors = (color: ColorBase): ColorVariations => {
51
58
  const themed = (Object as any).values(ColorEnum).includes(color);
52
59
 
53
- let base = themed ? new Color(theme.colors[color as ColorEnum]) : new Color(color);
60
+ const seed = themed ? new Color(theme.colors[color as ColorEnum]) : new Color(color);
61
+
62
+ const base = getBase(seed);
63
+ const light = getLight(base);
64
+ const soft = getSoft(base);
65
+ const dark = getDark(base);
66
+
67
+ if (isPastel(seed)) {
68
+ return {
69
+ light: getLight(seed).hex(),
70
+ lightContrast: getContrast(light, dark).hex(),
71
+ soft: getSoft(seed).hex(),
72
+ softContrast: getContrast(seed, dark).hex(),
73
+ base: seed.hex(),
74
+ baseContrast: getContrast(seed, base).hex(),
75
+ dark: dark.hex(),
76
+ darkContrast: getContrast(dark, light).hex()
77
+ };
78
+ }
54
79
 
55
- if (isGrayScale(base)) {
56
- switch (color) {
57
- case ColorEnum.Light:
58
- return getColors(ColorEnum.Dark);
59
- case ColorEnum.Dark:
60
- return getColors(ColorEnum.Light);
61
- default:
62
- if (base.value() > 50) {
63
- base = base.value(Math.max(base.value() - 65, 0));
64
- }
65
- else {
66
- base = base.value(Math.min(base.value() + 65, 100));
67
- }
68
- break;
69
- }
80
+ switch (color) {
81
+ case ColorEnum.Background: return {
82
+ light: base.hex(),
83
+ lightContrast: getContrast(base, base).hex(),
84
+ soft: base.hex(),
85
+ softContrast: getContrast(base, base).hex(),
86
+ base: base.hex(),
87
+ baseContrast: getContrast(base, base).hex(),
88
+ dark: dark.hex(),
89
+ darkContrast: getContrast(dark, base).hex()
90
+ };
91
+ default: return {
92
+ light: light.hex(),
93
+ lightContrast: getContrast(light, dark).hex(),
94
+ soft: soft.hex(),
95
+ softContrast: getContrast(soft, light).hex(),
96
+ base: base.hex(),
97
+ baseContrast: getContrast(base, light).hex(),
98
+ dark: dark.hex(),
99
+ darkContrast: getContrast(dark, light).hex()
100
+ };
70
101
  }
71
- return getColors(base.hex());
72
102
  };
73
103
 
74
104
  const getGradients = (colors: ColorBase | ColorBase[]): ColorVariations => {
@@ -87,7 +117,6 @@ export const useColors = () => {
87
117
 
88
118
  return {
89
119
  getColors,
90
- getContrasts,
91
120
  getGradients
92
121
  };
93
122
  }
@@ -61,6 +61,9 @@ export const useRules = () => {
61
61
  }
62
62
  }
63
63
  }
64
+ for (let i = 1; i < messages.length; i++) {
65
+ messages[i] = messages[i].toLowerCase();
66
+ }
64
67
  return [...new Set(messages)];
65
68
  }
66
69
 
package/models/colors.ts CHANGED
@@ -10,9 +10,13 @@ export enum ColorEnum {
10
10
 
11
11
  export interface ColorVariations {
12
12
  light: string;
13
+ lightContrast?: string;
13
14
  soft: string;
15
+ softContrast?: string;
14
16
  base: string;
17
+ baseContrast?: string;
15
18
  dark: string;
19
+ darkContrast?: string;
16
20
  };
17
21
 
18
22
  export type ColorBase = (String | ColorEnum);
@@ -0,0 +1,36 @@
1
+ export const Errors = [
2
+ { code: "errors.missingorganisation", default: "Missing organisation header", status: 400 },
3
+ { code: "errors.missinglanguage", default: "Missing language header", status: 400 },
4
+ { code: "errors.invalidchart", default: "Invalid chart configuration", status: 400 },
5
+ { code: "errors.invalidscenario", default: "Invalid scenario configuration", status: 400 },
6
+ { code: "errors.passwordtooshort", default: "Password too short", status: 400 },
7
+ { code: "errors.passwordtoolong", default: "Password too long", status: 400 },
8
+ { code: "errors.passwordlowercase", default: "Lowercase character required", status: 400 },
9
+ { code: "errors.passworduppercase", default: "Uppercase character required", status: 400 },
10
+ { code: "errors.passwordnumber", default: "Number required", status: 400 },
11
+ { code: "errors.passwordspecial", default: "Special character required", status: 400 },
12
+ { code: "errors.authenticationfailed", default: "Authentication failed", status: 401 },
13
+ { code: "errors.noregistereduser", default: "No registered user", status: 401 },
14
+ { code: "errors.badcredentials", default: "Bad credentials", status: 401 },
15
+ { code: "errors.unauthorizedorganisation", default: "Unauthorized organisation", status: 403 },
16
+ { code: "errors.unauthorizedextension", default: "Unauthorized extension", status: 403 },
17
+ { code: "errors.unauthorizeduser", default: "Unauthorized user", status: 403 },
18
+ { code: "errors.usernotinorganisation", default: "User not in organisation", status: 403 },
19
+ { code: "errors.noadminprivilege", default: "No admin privilege", status: 403 },
20
+ { code: "errors.dashboardLocked", default: "Dashboard locked", status: 403 },
21
+ { code: "errors.entitynotfound", default: "Entity not found", status: 404 },
22
+ { code: "errors.imagenotfound", default: "Image not found", status: 404 },
23
+ { code: "errors.tokennotfound", default: "Token not found", status: 404 },
24
+ { code: "errors.alreadyregistereduser", default: "Already registered user", status: 409 },
25
+ { code: "errors.devicealreadyinorganisation", default: "Device already in organisation", status: 409 },
26
+ { code: "errors.devicealreadywatched", default: "Device already watched", status: 409 },
27
+ { code: "errors.useralreadyinorganisation", default: "User already in organisation", status: 409 },
28
+ { code: "errors.emailfailure", default: "Email failure", status: 422 },
29
+ { code: "errors.requirevalidation", default: "Require validation", status: 422 },
30
+ { code: "errors.databaseerror", default: "Database error", status: 449 },
31
+ { code: "errors.graphsettingserror", default: "Microsoft graph settings error", status: 500 },
32
+ { code: "errors.graphusererror", default: "Microsoft graph user error", status: 500 },
33
+ { code: "errors.nomappableproperty", default: "No mappable property", status: 500 },
34
+ { code: "errors.unvalidextensioncookie", default: "Unvalid extension cookie", status: 500 },
35
+ { code: "errors.unexpectederror", default: "Unexpected error", status: 500 }
36
+ ];
package/models/index.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./colors";
3
3
  export * from "./deviceAlerts";
4
4
  export * from "./deviceConnectivities";
5
5
  export * from "./deviceStatuses";
6
+ export * from "./errors";
6
7
  export * from "./modelStatuses";
7
8
  export * from "./rules";
8
9
  export * from "./tables";
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.38",
4
+ "version": "0.0.40",
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.38",
14
- "@dative-gpi/foundation-shared-services": "0.0.38",
13
+ "@dative-gpi/foundation-shared-domain": "0.0.40",
14
+ "@dative-gpi/foundation-shared-services": "0.0.40",
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": "6dbe0959177629f0285f2eae895690376a6fa0e1"
35
+ "gitHead": "330530dc723ccb77b6bae29eca20fbafcc16895c"
36
36
  }
@@ -1,6 +1,6 @@
1
1
  .fs-color {
2
- display: flex;
3
2
  background-color: var(--fs-color-background-color) !important;
4
3
  border-color: var(--fs-color-border-color) !important;
5
4
  color: var(--fs-color-color);
5
+ display: flex;
6
6
  }
@@ -1,16 +1,16 @@
1
1
  .fs-container {
2
- display: flex;
3
- padding: var(--fs-container-padding);
4
2
  background-color: var(--fs-container-background-color);
3
+ padding: var(--fs-container-padding);
4
+ display: flex;
5
5
 
6
6
  &-border {
7
- border-radius: 4px;
8
7
  border: 1px solid var(--fs-container-border-color);
8
+ border-radius: 4px;
9
9
  }
10
10
 
11
11
  &-elevation {
12
- margin: 4px;
13
- border-radius: 4px;
14
12
  box-shadow: 0px 1px 8px 0px #00000029;
13
+ border-radius: 4px;
14
+ margin: 4px;
15
15
  }
16
16
  }
@@ -0,0 +1,5 @@
1
+ .fs-error-toast {
2
+ border-radius: var(--fs-error-toast-border-radius);
3
+ background-color: var(--fs-error-toast-background-color);
4
+ color: var(--fs-error-toast-color);
5
+ }
@@ -0,0 +1,7 @@
1
+ .fs-option-group {
2
+ border-radius: var(--fs-option-group-border-radius) !important;
3
+ border: var(--fs-option-group-border-size) solid !important;
4
+ width: fit-content;
5
+
6
+ border-color: var(--fs-option-group-border-color) !important;
7
+ }
@@ -19,6 +19,7 @@
19
19
  @import "fs_date_field.scss";
20
20
  @import "fs_dialog.scss";
21
21
  @import "fs_divider.scss";
22
+ @import "fs_error_toast.scss";
22
23
  @import "fs_fade_out.scss";
23
24
  @import "fs_filter_button.scss";
24
25
  @import "fs_form.scss";
@@ -32,6 +33,7 @@
32
33
  @import "fs_load_data_table.scss";
33
34
  @import "fs_load_tile.scss";
34
35
  @import "fs_loader.scss";
36
+ @import "fs_option_group.scss";
35
37
  @import "fs_pagination.scss";
36
38
  @import "fs_password_field.scss";
37
39
  @import "fs_radio.scss";
package/utils/error.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { Errors } from "../models/errors";
2
+
3
+ export const getError = (code: string): { code: string, default: string, status: number } => {
4
+ return Errors.find(e => e.code === code) || { code: "errors.unexpectederror", default: "Unexpected error", status: 500 };
5
+ };
package/utils/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./color";
2
2
  export * from "./css";
3
3
  export * from "./icons";
4
+ export * from "./error";
4
5
  export * from "./levenshtein";
5
6
  export * from "./lexical";
6
7
  export * from "./sort";