@omnia/velcron 7.0.528-dev → 7.0.530-dev

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.
@@ -5,8 +5,6 @@ export interface ColorDefinition {
5
5
  dark: boolean;
6
6
  color: string;
7
7
  colorToned: string;
8
- colorStyles: ColorStyles;
9
- colorTonedStyles: ColorStyles;
10
8
  }
11
9
  export interface ColorStyles {
12
10
  background: object | string;
@@ -0,0 +1,11 @@
1
+ import { ColorDefinition, ThemeDefinitionV2 } from "./ThemeDefinitionV2";
2
+ import { TypographyType } from "./TypographyDefinition";
3
+ export declare const useThemeMethods: (themedefinition: ThemeDefinitionV2) => {
4
+ colorSchema: (colorSchemaType: string) => import("./ThemeDefinitionV2").ColorSchema;
5
+ typography: (typographyType: string) => TypographyType;
6
+ color: (colorSchemaType: string, colorType: string) => string;
7
+ colorDefinition: (colorSchemaType: string, colorType: string) => ColorDefinition;
8
+ complementaryColorType: (colorType: string) => string;
9
+ complementaryColor: (colorSchemaType: string, colorType: string) => string;
10
+ complementaryColorDefinition: (colorSchemaType: string, colorType: string) => ColorDefinition;
11
+ };
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useThemeMethods = void 0;
4
+ const ThemeDefinitionV2_1 = require("./ThemeDefinitionV2");
5
+ const TypographyDefinition_1 = require("./TypographyDefinition");
6
+ const useThemeMethods = (themedefinition) => {
7
+ const colorSchema = (colorSchemaType) => {
8
+ if (colorSchemaType === ThemeDefinitionV2_1.ColorSchemaTypes.primary) {
9
+ return themedefinition.primary;
10
+ }
11
+ else if (colorSchemaType === ThemeDefinitionV2_1.ColorSchemaTypes.secondary) {
12
+ return themedefinition.secondary;
13
+ }
14
+ else if (colorSchemaType === ThemeDefinitionV2_1.ColorSchemaTypes.accent1) {
15
+ return themedefinition.accent1;
16
+ }
17
+ else if (colorSchemaType === ThemeDefinitionV2_1.ColorSchemaTypes.accent2) {
18
+ return themedefinition.accent2;
19
+ }
20
+ else if (colorSchemaType === ThemeDefinitionV2_1.ColorSchemaTypes.accent3) {
21
+ return themedefinition.accent3;
22
+ }
23
+ else if (colorSchemaType === ThemeDefinitionV2_1.ColorSchemaTypes.background) {
24
+ return themedefinition.background;
25
+ }
26
+ else if (colorSchemaType === ThemeDefinitionV2_1.ColorSchemaTypes.neutral) {
27
+ return themedefinition.neutral;
28
+ }
29
+ else if (colorSchemaType === ThemeDefinitionV2_1.ColorSchemaTypes.error) {
30
+ return themedefinition.error;
31
+ }
32
+ return themedefinition.background;
33
+ };
34
+ const typography = (typographyType) => {
35
+ if (typographyType === TypographyDefinition_1.TypographyTypes.h1) {
36
+ return themedefinition.typography.h1;
37
+ }
38
+ else if (typographyType === TypographyDefinition_1.TypographyTypes.h2) {
39
+ return themedefinition.typography.h2;
40
+ }
41
+ else if (typographyType === TypographyDefinition_1.TypographyTypes.h3) {
42
+ return themedefinition.typography.h3;
43
+ }
44
+ else if (typographyType === TypographyDefinition_1.TypographyTypes.caption) {
45
+ return themedefinition.typography.caption;
46
+ }
47
+ else if (typographyType === TypographyDefinition_1.TypographyTypes.link) {
48
+ return themedefinition.typography.link;
49
+ }
50
+ else if (typographyType === TypographyDefinition_1.TypographyTypes.text) {
51
+ return themedefinition.typography.text;
52
+ }
53
+ return themedefinition.typography.text;
54
+ };
55
+ const color = (colorSchemaType, colorType) => {
56
+ const mappedColorSchema = colorSchema(colorSchemaType);
57
+ if (colorType === ThemeDefinitionV2_1.ColorTypes.base) {
58
+ return mappedColorSchema.base.color;
59
+ }
60
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.baseTone) {
61
+ return mappedColorSchema.base.colorToned;
62
+ }
63
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.onBase) {
64
+ return mappedColorSchema.onBase.color;
65
+ }
66
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.onBaseTone) {
67
+ return mappedColorSchema.onBase.colorToned;
68
+ }
69
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.container) {
70
+ return mappedColorSchema.container.color;
71
+ }
72
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.containerTone) {
73
+ return mappedColorSchema.container.colorToned;
74
+ }
75
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.onContainer) {
76
+ return mappedColorSchema.onContainer.color;
77
+ }
78
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.onContainerTone) {
79
+ return mappedColorSchema.onContainer.colorToned;
80
+ }
81
+ return colorType;
82
+ };
83
+ const colorDefinition = (colorSchemaType, colorType) => {
84
+ const mappedColorSchema = colorSchema(colorSchemaType);
85
+ if (colorType === ThemeDefinitionV2_1.ColorTypes.base
86
+ || colorType === ThemeDefinitionV2_1.ColorTypes.baseTone) {
87
+ return mappedColorSchema.base;
88
+ }
89
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.onBase
90
+ ||
91
+ colorType === ThemeDefinitionV2_1.ColorTypes.onBaseTone) {
92
+ return mappedColorSchema.onBase;
93
+ }
94
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.container
95
+ ||
96
+ colorType === ThemeDefinitionV2_1.ColorTypes.containerTone) {
97
+ return mappedColorSchema.container;
98
+ }
99
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.onContainer
100
+ ||
101
+ colorType === ThemeDefinitionV2_1.ColorTypes.onContainerTone) {
102
+ return mappedColorSchema.onContainer;
103
+ }
104
+ return mappedColorSchema.base;
105
+ };
106
+ const complementaryColorType = (colorType) => {
107
+ if (colorType === ThemeDefinitionV2_1.ColorTypes.base
108
+ || colorType === ThemeDefinitionV2_1.ColorTypes.baseTone) {
109
+ return ThemeDefinitionV2_1.ColorTypes.onBase;
110
+ }
111
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.onBase
112
+ || colorType === ThemeDefinitionV2_1.ColorTypes.onBaseTone) {
113
+ return ThemeDefinitionV2_1.ColorTypes.base;
114
+ }
115
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.container
116
+ || colorType === ThemeDefinitionV2_1.ColorTypes.containerTone) {
117
+ return ThemeDefinitionV2_1.ColorTypes.onContainer;
118
+ }
119
+ else if (colorType === ThemeDefinitionV2_1.ColorTypes.onContainer
120
+ || colorType === ThemeDefinitionV2_1.ColorTypes.onContainerTone) {
121
+ return ThemeDefinitionV2_1.ColorTypes.container;
122
+ }
123
+ return colorType;
124
+ };
125
+ const complementaryColor = (colorSchemaType, colorType) => {
126
+ const matchingColorType = complementaryColorType(colorType);
127
+ return color(colorSchemaType, matchingColorType);
128
+ };
129
+ const complementaryColorDefinition = (colorSchemaType, colorType) => {
130
+ const matchingColorType = complementaryColorType(colorType);
131
+ return colorDefinition(colorSchemaType, matchingColorType);
132
+ };
133
+ return {
134
+ colorSchema,
135
+ typography,
136
+ color,
137
+ colorDefinition,
138
+ complementaryColorType,
139
+ complementaryColor,
140
+ complementaryColorDefinition
141
+ };
142
+ };
143
+ exports.useThemeMethods = useThemeMethods;
@@ -13,7 +13,6 @@ export interface TypographyType {
13
13
  large: TypographyTypeBreakPoint;
14
14
  medium?: TypographyTypeBreakPoint;
15
15
  small?: TypographyTypeBreakPoint;
16
- style: object | string;
17
16
  }
18
17
  export interface TypographyTypeBreakPoint {
19
18
  weight: number;
@@ -1,3 +1,4 @@
1
1
  export * from "./ThemeDefinitionV2";
2
2
  export * from "./TypographyDefinition";
3
3
  export * from "./OmniaThemes";
4
+ export * from "./ThemeMethods";
@@ -4,3 +4,4 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./ThemeDefinitionV2"), exports);
5
5
  tslib_1.__exportStar(require("./TypographyDefinition"), exports);
6
6
  tslib_1.__exportStar(require("./OmniaThemes"), exports);
7
+ tslib_1.__exportStar(require("./ThemeMethods"), exports);
@@ -41,7 +41,7 @@ export interface VelcronRenderContext {
41
41
  rootContext: VelcronState;
42
42
  currentContext: VelcronState;
43
43
  theming?: ReturnType<typeof useVelcronThemingStore>;
44
- colorSchemaName?: string;
44
+ colorSchemaType?: string;
45
45
  colorSchema?: ColorSchema;
46
46
  actions?: {
47
47
  [name: string]: [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@omnia/velcron",
3
3
  "license": "MIT",
4
- "version": "7.0.528-dev",
4
+ "version": "7.0.530-dev",
5
5
  "description": "Provide Omnia Velcron Stuffs.",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -14,10 +14,14 @@ export declare class VelcronRenderers {
14
14
  currentTheme: import("@omnia/fx-models").ThemeDefinitionV2;
15
15
  };
16
16
  get: {
17
- colorSchema: (schema: string) => import("@omnia/fx-models").ColorSchema;
18
- typography: (name: string) => import("@omnia/fx-models").TypographyType;
19
- color: (schemaName: string, colorType: string) => string;
20
- complementaryColor: (colorType: string) => string;
17
+ colorSchema: (colorSchemaType: string) => import("@omnia/fx-models").ColorSchema;
18
+ typography: (typographyType: string) => import("@omnia/fx-models").TypographyType;
19
+ color: (colorSchemaType: string, colorType: string) => string;
20
+ colorDefinition: (colorSchemaType: string, colorType: string) => import("@omnia/fx-models").ColorDefinition;
21
+ complementaryColorType: (colorType: string) => string;
22
+ complementaryColor: (colorSchemaType: string, colorType: string) => string;
23
+ complementaryColorDefinition: (colorSchemaType: string, colorType: string) => import("@omnia/fx-models").ColorDefinition;
24
+ currentTheme: () => import("@omnia/fx-models").ThemeDefinitionV2;
21
25
  };
22
26
  actions: {
23
27
  setTheme(newTheme: import("@omnia/fx-models").ThemeDefinitionV2): void;
@@ -75,11 +75,11 @@ class VelcronRenderers {
75
75
  };
76
76
  if (VelcronRenderers.definitionContainsCustomColorSchema(definition)) {
77
77
  const schema = VelcronData_1.VelcronData.dataBind(result, definition.colorSchema);
78
- result.colorSchemaName = stores_1.ReactivitySystem.makeReactive(schema);
79
- result.colorSchema = result.theming.get.colorSchema(result.colorSchemaName);
78
+ result.colorSchemaType = stores_1.ReactivitySystem.makeReactive(schema);
79
+ result.colorSchema = result.theming.get.colorSchema(result.colorSchemaType);
80
80
  }
81
81
  else {
82
- result.colorSchemaName = currentRenderCtx.colorSchemaName;
82
+ result.colorSchemaType = currentRenderCtx.colorSchemaType;
83
83
  result.colorSchema = currentRenderCtx.colorSchema;
84
84
  }
85
85
  return result;
@@ -47,19 +47,19 @@ class VelcronStyles {
47
47
  }
48
48
  if (borderSettings.top || borderSettings.top === 0) {
49
49
  styleBase["borderTopStyle"] = "solid";
50
- styleBase["borderTopColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, borderSettings.color);
50
+ styleBase["borderTopColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaType, borderSettings.color);
51
51
  }
52
52
  if (borderSettings.right || borderSettings.right === 0) {
53
53
  styleBase["borderRightStyle"] = "solid";
54
- styleBase["borderRightColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, borderSettings.color);
54
+ styleBase["borderRightColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaType, borderSettings.color);
55
55
  }
56
56
  if (borderSettings.bottom || borderSettings.bottom === 0) {
57
57
  styleBase["borderBottomStyle"] = "solid";
58
- styleBase["borderBottomColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, borderSettings.color);
58
+ styleBase["borderBottomColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaType, borderSettings.color);
59
59
  }
60
60
  if (borderSettings.left || borderSettings.left === 0) {
61
61
  styleBase["borderLeftStyle"] = "solid";
62
- styleBase["borderLeftColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, borderSettings.color);
62
+ styleBase["borderLeftColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaType, borderSettings.color);
63
63
  }
64
64
  }
65
65
  static create(definition, renderCtx) {
@@ -92,7 +92,7 @@ class VelcronStyles {
92
92
  else if (definition.type === VelcronConstants_1.VelcronConstants.components.text) {
93
93
  const textDefinition = definition;
94
94
  if (textDefinition.color) {
95
- styleBase["color"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, textDefinition.color);
95
+ styleBase["color"] = renderCtx.theming.get.color(renderCtx.colorSchemaType, textDefinition.color);
96
96
  }
97
97
  else {
98
98
  styleBase["color"] = renderCtx.colorSchema.onBase.color;
@@ -1,13 +1,17 @@
1
- import { ThemeDefinitionV2, TypographyType } from "..";
1
+ import { ThemeDefinitionV2 } from "..";
2
2
  export declare const useVelcronThemingStore: (newStateWithName?: string) => {
3
3
  state: {
4
4
  currentTheme: ThemeDefinitionV2;
5
5
  };
6
6
  get: {
7
- colorSchema: (schema: string) => import("..").ColorSchema;
8
- typography: (name: string) => TypographyType;
9
- color: (schemaName: string, colorType: string) => string;
10
- complementaryColor: (colorType: string) => string;
7
+ colorSchema: (colorSchemaType: string) => import("..").ColorSchema;
8
+ typography: (typographyType: string) => import("..").TypographyType;
9
+ color: (colorSchemaType: string, colorType: string) => string;
10
+ colorDefinition: (colorSchemaType: string, colorType: string) => import("..").ColorDefinition;
11
+ complementaryColorType: (colorType: string) => string;
12
+ complementaryColor: (colorSchemaType: string, colorType: string) => string;
13
+ complementaryColorDefinition: (colorSchemaType: string, colorType: string) => import("..").ColorDefinition;
14
+ currentTheme: () => ThemeDefinitionV2;
11
15
  };
12
16
  actions: {
13
17
  setTheme(newTheme: ThemeDefinitionV2): void;
@@ -12,106 +12,31 @@ exports.useVelcronThemingStore = (0, VelcronStore_1.defineVelcronStore)("Velcron
12
12
  };
13
13
  },
14
14
  getters(state) {
15
- const colorSchema = (schema) => {
16
- if (schema === __1.ColorSchemaTypes.primary) {
17
- return state.currentTheme?.primary;
18
- }
19
- else if (schema === __1.ColorSchemaTypes.secondary) {
20
- return state.currentTheme?.secondary;
21
- }
22
- else if (schema === __1.ColorSchemaTypes.accent1) {
23
- return state.currentTheme?.accent1;
24
- }
25
- else if (schema === __1.ColorSchemaTypes.accent2) {
26
- return state.currentTheme?.accent2;
27
- }
28
- else if (schema === __1.ColorSchemaTypes.accent3) {
29
- return state.currentTheme?.accent3;
30
- }
31
- else if (schema === __1.ColorSchemaTypes.background) {
32
- return state.currentTheme?.background;
33
- }
34
- else if (schema === __1.ColorSchemaTypes.neutral) {
35
- return state.currentTheme?.neutral;
36
- }
37
- else if (schema === __1.ColorSchemaTypes.error) {
38
- return state.currentTheme?.error;
39
- }
40
- return state.currentTheme?.background;
41
- };
42
- const typography = (name) => {
43
- if (name === __1.TypographyTypes.h1) {
44
- return state.currentTheme.typography.h1;
45
- }
46
- else if (name === __1.TypographyTypes.h2) {
47
- return state.currentTheme.typography.h2;
48
- }
49
- else if (name === __1.TypographyTypes.h3) {
50
- return state.currentTheme.typography.h3;
51
- }
52
- else if (name === __1.TypographyTypes.caption) {
53
- return state.currentTheme.typography.caption;
54
- }
55
- else if (name === __1.TypographyTypes.link) {
56
- return state.currentTheme.typography.link;
57
- }
58
- else if (name === __1.TypographyTypes.text) {
59
- return state.currentTheme.typography.text;
60
- }
61
- return state.currentTheme.typography.text;
62
- };
63
- const complementaryColor = (colorType) => {
64
- if (colorType === __1.ColorTypes.base
65
- || colorType === __1.ColorTypes.baseTone) {
66
- return __1.ColorTypes.onBase;
67
- }
68
- else if (colorType === __1.ColorTypes.onBase
69
- || colorType === __1.ColorTypes.onBaseTone) {
70
- return __1.ColorTypes.base;
71
- }
72
- else if (colorType === __1.ColorTypes.container
73
- || colorType === __1.ColorTypes.containerTone) {
74
- return __1.ColorTypes.onContainer;
75
- }
76
- else if (colorType === __1.ColorTypes.onContainer
77
- || colorType === __1.ColorTypes.onContainerTone) {
78
- return __1.ColorTypes.container;
79
- }
80
- return colorType;
81
- };
82
- const color = (schemaName, colorType) => {
83
- const mappedColorSchema = colorSchema(schemaName);
84
- if (colorType === __1.ColorTypes.base) {
85
- return mappedColorSchema.base.color;
86
- }
87
- else if (colorType === __1.ColorTypes.baseTone) {
88
- return mappedColorSchema.base.colorToned;
89
- }
90
- else if (colorType === __1.ColorTypes.onBase) {
91
- return mappedColorSchema.onBase.color;
92
- }
93
- else if (colorType === __1.ColorTypes.onBaseTone) {
94
- return mappedColorSchema.onBase.colorToned;
95
- }
96
- else if (colorType === __1.ColorTypes.container) {
97
- return mappedColorSchema.container.color;
98
- }
99
- else if (colorType === __1.ColorTypes.containerTone) {
100
- return mappedColorSchema.container.colorToned;
101
- }
102
- else if (colorType === __1.ColorTypes.onContainer) {
103
- return mappedColorSchema.onContainer.color;
104
- }
105
- else if (colorType === __1.ColorTypes.onContainerTone) {
106
- return mappedColorSchema.onContainer.colorToned;
107
- }
108
- return colorType;
109
- };
110
15
  return {
111
- colorSchema,
112
- typography,
113
- color,
114
- complementaryColor
16
+ colorSchema: (colorSchemaType) => {
17
+ return (0, __1.useThemeMethods)(state.currentTheme).colorSchema(colorSchemaType);
18
+ },
19
+ typography: (typographyType) => {
20
+ return (0, __1.useThemeMethods)(state.currentTheme).typography(typographyType);
21
+ },
22
+ color: (colorSchemaType, colorType) => {
23
+ return (0, __1.useThemeMethods)(state.currentTheme).color(colorSchemaType, colorType);
24
+ },
25
+ colorDefinition: (colorSchemaType, colorType) => {
26
+ return (0, __1.useThemeMethods)(state.currentTheme).colorDefinition(colorSchemaType, colorType);
27
+ },
28
+ complementaryColorType: (colorType) => {
29
+ return (0, __1.useThemeMethods)(state.currentTheme).complementaryColorType(colorType);
30
+ },
31
+ complementaryColor: (colorSchemaType, colorType) => {
32
+ return (0, __1.useThemeMethods)(state.currentTheme).complementaryColor(colorSchemaType, colorType);
33
+ },
34
+ complementaryColorDefinition: (colorSchemaType, colorType) => {
35
+ return (0, __1.useThemeMethods)(state.currentTheme).complementaryColorDefinition(colorSchemaType, colorType);
36
+ },
37
+ currentTheme: () => {
38
+ return this.currentTheme.state;
39
+ }
115
40
  };
116
41
  },
117
42
  actions(state) {