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

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.
@@ -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.37",
4
+ "version": "0.0.39",
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.37",
14
- "@dative-gpi/foundation-shared-services": "0.0.37",
13
+ "@dative-gpi/foundation-shared-domain": "0.0.39",
14
+ "@dative-gpi/foundation-shared-services": "0.0.39",
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": "60d7b514ce598dccaef07b4696e957ea2165a7a3"
35
+ "gitHead": "f4259f72e37e80ea5276d61fa030956976738397"
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
+ }
@@ -7,7 +7,7 @@
7
7
  overflow: hidden;
8
8
  display: -webkit-box;
9
9
  -webkit-box-orient: vertical;
10
- -webkit-line-clamp: 2;
10
+ -webkit-line-clamp: var(--fs-span-line-clamp);
11
11
  }
12
12
 
13
13
  .fs-span-ellipsis {
@@ -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";