@omnia/velcron 7.0.521-dev → 7.0.523-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.
- package/actions/Emit.d.ts +2 -0
- package/actions/Emit.js +25 -0
- package/actions/index.d.ts +1 -0
- package/actions/index.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/models/VelcronDefinitions.d.ts +7 -0
- package/package.json +1 -1
- package/parser/VelcronActions.js +1 -3
- package/parser/VelcronData.js +8 -1
- package/parser/VelcronStyles.js +9 -0
- package/stores/VelcronStore.js +2 -11
- package/utilities/ColorUtility.d.ts +1 -0
- package/utilities/ColorUtility.js +45 -0
- package/utilities/index.d.ts +1 -0
- package/utilities/index.js +4 -0
package/actions/Emit.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emit = void 0;
|
|
4
|
+
const parser_1 = require("../parser");
|
|
5
|
+
exports.emit = {
|
|
6
|
+
name: "@emit",
|
|
7
|
+
action: (action, value, ...args) => {
|
|
8
|
+
if (action.eventHandlers?.receiving) {
|
|
9
|
+
let found = false;
|
|
10
|
+
Object.keys(action.eventHandlers?.receiving).forEach((key) => {
|
|
11
|
+
if (value.toLowerCase() == key.toLowerCase()) {
|
|
12
|
+
action.eventHandlers?.receiving[key](...args);
|
|
13
|
+
found = true;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
if (!found) {
|
|
17
|
+
parser_1.VelcronLogger.logActionError(`Could not find incoming event handler for ${value}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
parser_1.VelcronLogger.logActionError("There is no incoming event handlers registered");
|
|
22
|
+
}
|
|
23
|
+
return Promise.resolve(null);
|
|
24
|
+
}
|
|
25
|
+
};
|
package/actions/index.d.ts
CHANGED
package/actions/index.js
CHANGED
|
@@ -11,3 +11,4 @@ tslib_1.__exportStar(require("./Alert"), exports);
|
|
|
11
11
|
tslib_1.__exportStar(require("./Log"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./MsGraph"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./MsSharePoint"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./Emit"), exports);
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,3 +6,4 @@ tslib_1.__exportStar(require("./parser"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./actions"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./stores"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("@omnia/velcron/internal-do-not-import-from-here/shared/models"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./utilities"), exports);
|
|
@@ -47,6 +47,13 @@ export interface VelcronRenderContext {
|
|
|
47
47
|
};
|
|
48
48
|
parent?: VelcronRenderContext;
|
|
49
49
|
hooks?: VelcronRenderContextHooks;
|
|
50
|
+
eventHandlers?: VelcronRenderContextEventHandlers;
|
|
51
|
+
}
|
|
52
|
+
export interface VelcronRenderContextEventHandlers {
|
|
53
|
+
receiving?: {
|
|
54
|
+
[name: string]: (...args: any[]) => void;
|
|
55
|
+
};
|
|
56
|
+
emitting?: <T>(emitter: (i: T) => T) => T;
|
|
50
57
|
}
|
|
51
58
|
export interface VelcronRenderContextHooks {
|
|
52
59
|
dialogVisibilityChanged?: ((visible: boolean) => void);
|
package/package.json
CHANGED
package/parser/VelcronActions.js
CHANGED
|
@@ -102,9 +102,7 @@ class VelcronActions {
|
|
|
102
102
|
const result = {
|
|
103
103
|
id: eventId,
|
|
104
104
|
type: models_1.VelcronActionTypes.getOrSetValue,
|
|
105
|
-
|
|
106
|
-
currentContext: renderContext.currentContext,
|
|
107
|
-
actions: renderContext.actions
|
|
105
|
+
...renderContext
|
|
108
106
|
};
|
|
109
107
|
partialTemplate = partialTemplate.trim();
|
|
110
108
|
if (partialTemplate.trim() === "") {
|
package/parser/VelcronData.js
CHANGED
|
@@ -448,6 +448,10 @@ class VelcronData {
|
|
|
448
448
|
if (typeof path !== "string") {
|
|
449
449
|
return null;
|
|
450
450
|
}
|
|
451
|
+
if (path === "") {
|
|
452
|
+
//If we pass $state = root we just return object
|
|
453
|
+
return object;
|
|
454
|
+
}
|
|
451
455
|
path = path.replace(/\[(\w+)\]/g, ".$1"); // convert indexes to properties
|
|
452
456
|
path = path.replace(/^\./, ""); // strip a leading dot
|
|
453
457
|
const a = path.split(".");
|
|
@@ -490,6 +494,9 @@ class VelcronData {
|
|
|
490
494
|
}
|
|
491
495
|
static getOrSetObjectByPathUsingRenderContext(renderContext, path, value = undefined) {
|
|
492
496
|
let result;
|
|
497
|
+
if (VelcronData.isUndefined(path)) {
|
|
498
|
+
return result;
|
|
499
|
+
}
|
|
493
500
|
const variables = VelcronData.variables;
|
|
494
501
|
if (renderContext.id &&
|
|
495
502
|
variables.hasOwnProperty(renderContext.id) &&
|
|
@@ -518,7 +525,7 @@ class VelcronData {
|
|
|
518
525
|
path = tokens[0];
|
|
519
526
|
}
|
|
520
527
|
let object = null;
|
|
521
|
-
if (path.startsWith(`${VelcronConstants_1.VelcronConstants.state.stateRootToken}.`)) {
|
|
528
|
+
if (path.startsWith(`${VelcronConstants_1.VelcronConstants.state.stateRootToken}.`) || path === VelcronConstants_1.VelcronConstants.state.stateRootToken) {
|
|
522
529
|
//Fetch from the data object
|
|
523
530
|
object = renderContext.rootContext;
|
|
524
531
|
path = path.substring(6);
|
package/parser/VelcronStyles.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.VelcronStyles = void 0;
|
|
|
4
4
|
const VelcronData_1 = require("./VelcronData");
|
|
5
5
|
const models_1 = require("../models");
|
|
6
6
|
const VelcronConstants_1 = require("./VelcronConstants");
|
|
7
|
+
const utilities_1 = require("../utilities");
|
|
7
8
|
class VelcronStyles {
|
|
8
9
|
static registerStyleProvider(fn, unitProvider) {
|
|
9
10
|
VelcronStyles.styleProvider = fn;
|
|
@@ -70,6 +71,14 @@ class VelcronStyles {
|
|
|
70
71
|
//styleBase["backgroundColor"] = renderCtx.theming.get.activeColorSchema().base.color;
|
|
71
72
|
styleBase["backgroundColor"] = renderCtx.colorSchema.base.color;
|
|
72
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
|
+
}
|
|
73
82
|
if (flexViewDefinition.border) {
|
|
74
83
|
styleBase["borderTopStyle"] = "solid";
|
|
75
84
|
styleBase["borderRightStyle"] = "solid";
|
package/stores/VelcronStore.js
CHANGED
|
@@ -14,19 +14,10 @@ const defineVelcronStore = (name, definition) => {
|
|
|
14
14
|
const reactiveState = stateMap.get(name);
|
|
15
15
|
return {
|
|
16
16
|
state: reactiveState.state,
|
|
17
|
-
get: definition.getters(reactiveState.state, reactiveState.privateState),
|
|
18
|
-
actions: definition.actions(reactiveState.state, reactiveState.privateState)
|
|
17
|
+
get: definition.getters?.(reactiveState.state, reactiveState.privateState),
|
|
18
|
+
actions: definition.actions?.(reactiveState.state, reactiveState.privateState)
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
return result;
|
|
22
22
|
};
|
|
23
23
|
exports.defineVelcronStore = defineVelcronStore;
|
|
24
|
-
const pelle = (0, exports.defineVelcronStore)("pelle", {
|
|
25
|
-
setup() {
|
|
26
|
-
return {
|
|
27
|
-
state: {
|
|
28
|
-
test: "Hello"
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useOpacityOnColor: (color: any, opacity: any) => any;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useOpacityOnColor = void 0;
|
|
4
|
+
const useOpacityOnColor = (color, opacity) => {
|
|
5
|
+
const getRGBValues = (color) => {
|
|
6
|
+
const tmpColor = color.replace("rgba", "rgb");
|
|
7
|
+
return tmpColor.substring(4, tmpColor.length - 1)
|
|
8
|
+
.replace(/ /g, "")
|
|
9
|
+
.split(",");
|
|
10
|
+
};
|
|
11
|
+
const getRGBValuesFromHex = (color) => {
|
|
12
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(color);
|
|
13
|
+
if (result) {
|
|
14
|
+
return [
|
|
15
|
+
parseInt(result[1], 16),
|
|
16
|
+
parseInt(result[2], 16),
|
|
17
|
+
parseInt(result[3], 16)
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const isRGBColor = (color) => {
|
|
22
|
+
if (!color) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (color.indexOf("rgb") > -1) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (color.indexOf("rgba") > -1) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
let rgb = null;
|
|
34
|
+
if (!isRGBColor(color)) {
|
|
35
|
+
rgb = getRGBValuesFromHex(color);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
rgb = getRGBValues(color);
|
|
39
|
+
}
|
|
40
|
+
if (rgb) {
|
|
41
|
+
return `rgba(${rgb[0]},${rgb[1]},${rgb[2]},${opacity})`;
|
|
42
|
+
}
|
|
43
|
+
return color;
|
|
44
|
+
};
|
|
45
|
+
exports.useOpacityOnColor = useOpacityOnColor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ColorUtility";
|