@omnia/velcron 7.0.524-dev → 7.0.526-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.
@@ -0,0 +1,27 @@
1
+ import { Guid } from "../Guid";
2
+ export interface BoxDimensions {
3
+ top: number;
4
+ right: number;
5
+ bottom: number;
6
+ left: number;
7
+ }
8
+ export interface BoxBorder extends BoxDimensions {
9
+ color: string;
10
+ }
11
+ export interface BlueprintDefinition {
12
+ id: Guid;
13
+ card?: {
14
+ border?: BoxBorder;
15
+ borderRadius?: BoxDimensions;
16
+ };
17
+ image?: {
18
+ borderRadius?: BoxDimensions;
19
+ };
20
+ chip?: {
21
+ borderRadius?: BoxDimensions;
22
+ };
23
+ icon?: {
24
+ borderRadius?: BoxDimensions;
25
+ round?: boolean;
26
+ };
27
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  import { Guid } from "../Guid";
2
+ import { BlueprintDefinition } from "./BlueprintDefinition";
2
3
  import { TypographyDefinition } from "./TypographyDefinition";
3
4
  export interface ColorDefinition {
4
5
  dark: boolean;
@@ -8,9 +9,9 @@ export interface ColorDefinition {
8
9
  colorTonedStyles: ColorStyles;
9
10
  }
10
11
  export interface ColorStyles {
11
- background: object;
12
- color: object;
13
- all: object;
12
+ background: object | string;
13
+ color: object | string;
14
+ all: object | string;
14
15
  }
15
16
  export interface ColorSchema {
16
17
  name: string;
@@ -25,6 +26,7 @@ export interface ColorGroup {
25
26
  }
26
27
  export interface ThemeDefinitionV2 {
27
28
  id: Guid;
29
+ name: string;
28
30
  dark: boolean;
29
31
  primary: ColorSchema;
30
32
  secondary: ColorSchema;
@@ -36,6 +38,7 @@ export interface ThemeDefinitionV2 {
36
38
  error: ColorSchema;
37
39
  info: ColorSchema;
38
40
  typography: TypographyDefinition;
41
+ blueprint: BlueprintDefinition;
39
42
  }
40
43
  export declare const ColorSchemaTypes: {
41
44
  primary: string;
@@ -13,6 +13,7 @@ export interface TypographyType {
13
13
  large: TypographyTypeBreakPoint;
14
14
  medium?: TypographyTypeBreakPoint;
15
15
  small?: TypographyTypeBreakPoint;
16
+ style: object | string;
16
17
  }
17
18
  export interface TypographyTypeBreakPoint {
18
19
  weight: number;
package/models/Enums.d.ts CHANGED
@@ -38,7 +38,8 @@ export declare enum VelcronComponentPropertyEditors {
38
38
  slider = 2,
39
39
  colorPicker = 3,
40
40
  typographyPicker = 4,
41
- ratioPicker = 5
41
+ ratioPicker = 5,
42
+ booleanPicker = 6
42
43
  }
43
44
  export declare enum VelcronDataTypes {
44
45
  unknown = "unknown",
package/models/Enums.js CHANGED
@@ -49,6 +49,7 @@ var VelcronComponentPropertyEditors;
49
49
  VelcronComponentPropertyEditors[VelcronComponentPropertyEditors["colorPicker"] = 3] = "colorPicker";
50
50
  VelcronComponentPropertyEditors[VelcronComponentPropertyEditors["typographyPicker"] = 4] = "typographyPicker";
51
51
  VelcronComponentPropertyEditors[VelcronComponentPropertyEditors["ratioPicker"] = 5] = "ratioPicker";
52
+ VelcronComponentPropertyEditors[VelcronComponentPropertyEditors["booleanPicker"] = 6] = "booleanPicker";
52
53
  })(VelcronComponentPropertyEditors = exports.VelcronComponentPropertyEditors || (exports.VelcronComponentPropertyEditors = {}));
53
54
  var VelcronDataTypes;
54
55
  (function (VelcronDataTypes) {
@@ -23,15 +23,23 @@ export interface BuiltInComponentRenderers {
23
23
  "Icon": unknown;
24
24
  "Chip": unknown;
25
25
  }
26
- export type DynamicViewModel = object;
26
+ export interface ColorSchemaReference {
27
+ name: string;
28
+ schema: string;
29
+ }
30
+ export interface VelcronState {
31
+ colorSchemas?: {
32
+ [key: string]: ColorSchemaReference;
33
+ };
34
+ }
27
35
  export interface OnItemRenderedHookResult {
28
36
  cssClass: string;
29
37
  containerRenderer?: VelcronContainerRenderer;
30
38
  }
31
39
  export interface VelcronRenderContext {
32
40
  id?: string;
33
- rootContext: DynamicViewModel;
34
- currentContext: DynamicViewModel;
41
+ rootContext: VelcronState;
42
+ currentContext: VelcronState;
35
43
  theming?: ReturnType<typeof useVelcronThemingStore>;
36
44
  colorSchemaName?: string;
37
45
  colorSchema?: ColorSchema;
@@ -102,6 +110,8 @@ export interface VelcronDefinitionBase {
102
110
  }
103
111
  export interface VelcronCustomThemeSettings {
104
112
  colorSchema?: string;
113
+ color?: string;
114
+ opacity?: number;
105
115
  }
106
116
  export interface VelcronDefinition extends VelcronDefinitionBase {
107
117
  body?: Array<VelcronDefinition>;
@@ -145,7 +155,7 @@ export interface VelcronAppDefinition extends VelcronDefinitionBase {
145
155
  [name: string]: [];
146
156
  };
147
157
  components?: Array<VelcronCustomComponentDefinition>;
148
- state?: DynamicViewModel;
158
+ state?: VelcronState;
149
159
  computed?: {
150
160
  [name: string]: [];
151
161
  };
@@ -160,7 +170,7 @@ export interface VelcronViewDefinition extends VelcronDefinition {
160
170
  style?: VelcronStyling;
161
171
  events?: VelcronOnPressEvent;
162
172
  }
163
- export interface VelcronCardDefinition extends VelcronDefinition {
173
+ export interface VelcronCardDefinition extends VelcronDefinition, VelcronCustomThemeSettings {
164
174
  type: "Card";
165
175
  style?: VelcronCardStyling;
166
176
  footer?: Array<VelcronDefinition>;
@@ -215,10 +225,10 @@ export interface VelcronDialogDefinition extends VelcronDefinition {
215
225
  visible: string;
216
226
  events?: VelcronOnCloseRequestedEvent & VelcronOnClosedEvent;
217
227
  }
218
- export interface VelcronIconDefinition extends VelcronDefinition {
228
+ export interface VelcronIconDefinition extends VelcronDefinition, VelcronCustomThemeSettings {
219
229
  type: "Icon";
220
230
  icon: string;
221
- color: string;
231
+ background?: boolean;
222
232
  size?: number;
223
233
  events?: VelcronOnPressEvent;
224
234
  }
@@ -232,7 +242,6 @@ export interface VelcronFlexViewDefinition extends VelcronDefinition, VelcronCus
232
242
  grow?: number;
233
243
  border?: VelcronBorder;
234
244
  borderRadius?: VelcronDimensions;
235
- opacity: number;
236
245
  width: string;
237
246
  }
238
247
  export interface VelcronDimensions {
@@ -244,10 +253,9 @@ export interface VelcronDimensions {
244
253
  export interface VelcronBorder extends VelcronDimensions {
245
254
  color: string;
246
255
  }
247
- export interface VelcronChipDefinition extends VelcronDefinition {
256
+ export interface VelcronChipDefinition extends VelcronDefinition, VelcronCustomThemeSettings {
248
257
  type: "Chip";
249
258
  text: string;
250
- colorSchema: string;
251
259
  icon?: VelcronIcon;
252
260
  disabled?: boolean;
253
261
  events?: VelcronOnPressEvent;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@omnia/velcron",
3
3
  "license": "MIT",
4
- "version": "7.0.524-dev",
4
+ "version": "7.0.526-dev",
5
5
  "description": "Provide Omnia Velcron Stuffs.",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,4 +1,4 @@
1
- import { BuiltInComponentRenderers, DynamicViewModel, ResolvedComponentRenderer, VelcronCustomComponentDefinition, VelcronDefinition, VelcronRenderContext } from "../models";
1
+ import { BuiltInComponentRenderers, VelcronState, ResolvedComponentRenderer, VelcronCustomComponentDefinition, VelcronDefinition, VelcronRenderContext } from "../models";
2
2
  export declare class VelcronRenderers {
3
3
  private static components;
4
4
  static registerComponent(type: string, component: any): void;
@@ -7,8 +7,8 @@ export declare class VelcronRenderers {
7
7
  static registerComponents(components: BuiltInComponentRenderers): void;
8
8
  static getComponent(definition: VelcronDefinition, renderContext: VelcronRenderContext): ResolvedComponentRenderer;
9
9
  static definitionContainsCustomColorSchema(definition: VelcronDefinition): boolean;
10
- static createNewRendererContext(currentRenderCtx: VelcronRenderContext, definition: VelcronDefinition, newViewModel?: DynamicViewModel): {
11
- rootContext: object;
10
+ static createNewRendererContext(currentRenderCtx: VelcronRenderContext, definition: VelcronDefinition, newViewModel?: VelcronState): {
11
+ rootContext: VelcronState;
12
12
  theming: {
13
13
  state: {
14
14
  currentTheme: import("@omnia/fx-models").ThemeDefinitionV2;
@@ -17,12 +17,13 @@ export declare class VelcronRenderers {
17
17
  colorSchema: (schema: string) => import("@omnia/fx-models").ColorSchema;
18
18
  typography: (name: string) => import("@omnia/fx-models").TypographyType;
19
19
  color: (schemaName: string, colorType: string) => string;
20
+ complementaryColor: (colorType: string) => string;
20
21
  };
21
22
  actions: {
22
23
  setTheme(newTheme: import("@omnia/fx-models").ThemeDefinitionV2): void;
23
24
  };
24
25
  };
25
- currentContext: object;
26
+ currentContext: VelcronState;
26
27
  actions: {
27
28
  [name: string]: [];
28
29
  };
@@ -32,5 +33,5 @@ export declare class VelcronRenderers {
32
33
  [name: string]: [];
33
34
  };
34
35
  };
35
- static ensureRenderContext(rendererInfo: ResolvedComponentRenderer, definition: VelcronDefinition, currentRenderCtx: VelcronRenderContext, newViewModel?: DynamicViewModel): VelcronRenderContext;
36
+ static ensureRenderContext(rendererInfo: ResolvedComponentRenderer, definition: VelcronDefinition, currentRenderCtx: VelcronRenderContext, newViewModel?: VelcronState): VelcronRenderContext;
36
37
  }
@@ -1,9 +1,12 @@
1
- import { VelcronDefinition, VelcronRenderContext } from "../models";
1
+ import { VelcronBorder, VelcronCustomThemeSettings, VelcronDefinition, VelcronDimensions, VelcronRenderContext } from "../models";
2
2
  import { VelcronUnitProvider } from "../models/VelcronUnitProvider";
3
3
  export declare class VelcronStyles {
4
4
  static styleProvider: (baseStyles: object, definition: VelcronDefinition, renderCtx: VelcronRenderContext) => any;
5
5
  static unitProvider: VelcronUnitProvider;
6
6
  static registerStyleProvider(fn: (styleBase: object, definition: VelcronDefinition, renderCtx: VelcronRenderContext) => object | string, unitProvider: VelcronUnitProvider): void;
7
+ static insertBackgroundColor(styleBase: any, definition: VelcronCustomThemeSettings, renderCtx: VelcronRenderContext): void;
8
+ static insertBorderRadiusStyles(styleBase: any, settings: VelcronDimensions): void;
9
+ static insertBorderStyles(styleBase: any, borderSettings: VelcronBorder, renderCtx: VelcronRenderContext): void;
7
10
  static create(definition: VelcronDefinition, renderCtx: VelcronRenderContext): object | string;
8
11
  static dataBindStyles(styles: object, renderCtx: VelcronRenderContext): object;
9
12
  }
@@ -10,18 +10,66 @@ class VelcronStyles {
10
10
  VelcronStyles.styleProvider = fn;
11
11
  VelcronStyles.unitProvider = unitProvider;
12
12
  }
13
+ static insertBackgroundColor(styleBase, definition, renderCtx) {
14
+ if (definition.colorSchema && definition.colorSchema != "") {
15
+ //styleBase["backgroundColor"] = renderCtx.theming.get.activeColorSchema().base.color;
16
+ styleBase["backgroundColor"] = renderCtx.colorSchema.base.color;
17
+ }
18
+ if (definition.opacity || definition.opacity === 0) {
19
+ if (definition.opacity === 0) {
20
+ styleBase["backgroundColor"] = undefined;
21
+ }
22
+ else {
23
+ styleBase["backgroundColor"] = (0, utilities_1.useOpacityOnColor)(styleBase["backgroundColor"], definition.opacity / 100);
24
+ }
25
+ }
26
+ }
27
+ static insertBorderRadiusStyles(styleBase, settings) {
28
+ if (!settings) {
29
+ return;
30
+ }
31
+ if (settings.top || settings.top === 0) {
32
+ styleBase["borderTopLeftRadius"] = this.unitProvider.formatDimension(settings.top);
33
+ }
34
+ if (settings.right || settings.right === 0) {
35
+ styleBase["borderTopRightRadius"] = this.unitProvider.formatDimension(settings.right);
36
+ }
37
+ if (settings.bottom || settings.bottom === 0) {
38
+ styleBase["borderBottomRightRadius"] = this.unitProvider.formatDimension(settings.bottom);
39
+ }
40
+ if (settings.left || settings.left === 0) {
41
+ styleBase["borderBottomLeftRadius"] = this.unitProvider.formatDimension(settings.left);
42
+ }
43
+ }
44
+ static insertBorderStyles(styleBase, borderSettings, renderCtx) {
45
+ if (!borderSettings) {
46
+ return;
47
+ }
48
+ if (borderSettings.top || borderSettings.top === 0) {
49
+ styleBase["borderTopStyle"] = "solid";
50
+ styleBase["borderTopColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, borderSettings.color);
51
+ }
52
+ if (borderSettings.right || borderSettings.right === 0) {
53
+ styleBase["borderRightStyle"] = "solid";
54
+ styleBase["borderRightColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, borderSettings.color);
55
+ }
56
+ if (borderSettings.bottom || borderSettings.bottom === 0) {
57
+ styleBase["borderBottomStyle"] = "solid";
58
+ styleBase["borderBottomColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, borderSettings.color);
59
+ }
60
+ if (borderSettings.left || borderSettings.left === 0) {
61
+ styleBase["borderLeftStyle"] = "solid";
62
+ styleBase["borderLeftColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, borderSettings.color);
63
+ }
64
+ }
13
65
  static create(definition, renderCtx) {
14
66
  const styleBase = { ...definition.style };
15
- if (definition.borderRadius) {
67
+ if (definition.type === VelcronConstants_1.VelcronConstants.components.image) {
16
68
  const imageDefinition = definition;
17
- if (imageDefinition.borderRadius) {
18
- styleBase["borderTopLeftRadius"] = this.unitProvider.formatDimension(imageDefinition.borderRadius.top);
19
- styleBase["borderTopRightRadius"] = this.unitProvider.formatDimension(imageDefinition.borderRadius.right);
20
- styleBase["borderBottomRightRadius"] = this.unitProvider.formatDimension(imageDefinition.borderRadius.bottom);
21
- styleBase["borderBottomLeftRadius"] = this.unitProvider.formatDimension(imageDefinition.borderRadius.left);
69
+ if (renderCtx.theming.state.currentTheme.blueprint?.image?.borderRadius) {
70
+ const settings = renderCtx.theming.state.currentTheme.blueprint.image.borderRadius;
71
+ this.insertBorderRadiusStyles(styleBase, settings);
22
72
  }
23
- }
24
- if (definition.type === VelcronConstants_1.VelcronConstants.components.image) {
25
73
  // if (styleBase.width) {
26
74
  // styleBase.width = this.unitProvider.formatDimension(200);
27
75
  // }
@@ -29,6 +77,18 @@ class VelcronStyles {
29
77
  // styleBase.height = this.unitProvider.formatDimension(400);
30
78
  // }
31
79
  }
80
+ if (definition.type === VelcronConstants_1.VelcronConstants.components.card) {
81
+ const cardDefinition = definition;
82
+ if (renderCtx.theming.state.currentTheme.blueprint?.card?.borderRadius) {
83
+ const settings = renderCtx.theming.state.currentTheme.blueprint.card.borderRadius;
84
+ this.insertBorderRadiusStyles(styleBase, settings);
85
+ }
86
+ if (renderCtx.theming.state.currentTheme.blueprint?.card?.border) {
87
+ const settings = renderCtx.theming.state.currentTheme.blueprint.card.border;
88
+ this.insertBorderStyles(styleBase, settings, renderCtx);
89
+ }
90
+ this.insertBackgroundColor(styleBase, cardDefinition, renderCtx);
91
+ }
32
92
  else if (definition.type === VelcronConstants_1.VelcronConstants.components.text) {
33
93
  const textDefinition = definition;
34
94
  if (textDefinition.color) {
@@ -67,27 +127,21 @@ class VelcronStyles {
67
127
  else {
68
128
  styleBase[propertyName] = "flex-start";
69
129
  }
70
- if (flexViewDefinition.colorSchema && flexViewDefinition.colorSchema != "") {
71
- //styleBase["backgroundColor"] = renderCtx.theming.get.activeColorSchema().base.color;
72
- styleBase["backgroundColor"] = renderCtx.colorSchema.base.color;
73
- }
74
- if (flexViewDefinition.opacity || flexViewDefinition.opacity === 0) {
75
- if (flexViewDefinition.opacity === 0) {
76
- styleBase["backgroundColor"] = undefined;
77
- }
78
- else {
79
- styleBase["backgroundColor"] = (0, utilities_1.useOpacityOnColor)(styleBase["backgroundColor"], flexViewDefinition.opacity / 100);
80
- }
81
- }
82
- if (flexViewDefinition.border) {
83
- styleBase["borderTopStyle"] = "solid";
84
- styleBase["borderRightStyle"] = "solid";
85
- styleBase["borderBottomStyle"] = "solid";
86
- styleBase["borderLeftStyle"] = "solid";
87
- styleBase["borderTopColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, flexViewDefinition.border.color);
88
- styleBase["borderRightColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, flexViewDefinition.border.color);
89
- styleBase["borderBottomColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, flexViewDefinition.border.color);
90
- styleBase["borderLeftColor"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, flexViewDefinition.border.color);
130
+ this.insertBackgroundColor(styleBase, flexViewDefinition, renderCtx);
131
+ }
132
+ /**
133
+ *
134
+ * Generic styles for all components
135
+ *
136
+ */
137
+ if (definition.border) {
138
+ const typedDefinition = definition;
139
+ this.insertBorderStyles(styleBase, typedDefinition.border, renderCtx);
140
+ }
141
+ if (definition.borderRadius) {
142
+ const typedDefinition = definition;
143
+ if (typedDefinition.borderRadius) {
144
+ this.insertBorderRadiusStyles(styleBase, typedDefinition.borderRadius);
91
145
  }
92
146
  }
93
147
  return VelcronStyles.styleProvider(styleBase, definition, renderCtx);
@@ -7,6 +7,7 @@ export declare const useVelcronThemingStore: (newStateWithName?: string) => {
7
7
  colorSchema: (schema: string) => import("..").ColorSchema;
8
8
  typography: (name: string) => TypographyType;
9
9
  color: (schemaName: string, colorType: string) => string;
10
+ complementaryColor: (colorType: string) => string;
10
11
  };
11
12
  actions: {
12
13
  setTheme(newTheme: ThemeDefinitionV2): void;
@@ -60,6 +60,25 @@ exports.useVelcronThemingStore = (0, VelcronStore_1.defineVelcronStore)("Velcron
60
60
  }
61
61
  return state.currentTheme.typography.text;
62
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
+ };
63
82
  const color = (schemaName, colorType) => {
64
83
  const mappedColorSchema = colorSchema(schemaName);
65
84
  if (colorType === __1.ColorTypes.base) {
@@ -91,7 +110,8 @@ exports.useVelcronThemingStore = (0, VelcronStore_1.defineVelcronStore)("Velcron
91
110
  return {
92
111
  colorSchema,
93
112
  typography,
94
- color
113
+ color,
114
+ complementaryColor
95
115
  };
96
116
  },
97
117
  actions(state) {