@viewfly/core 0.0.1-alpha.10 → 0.0.1-alpha.11
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/bundles/foundation/_utils.d.ts +1 -0
- package/bundles/index.esm.js +19 -5
- package/bundles/index.js +19 -5
- package/package.json +2 -2
|
@@ -6,3 +6,4 @@ export interface ObjectChanges {
|
|
|
6
6
|
export declare const refKey = "ref";
|
|
7
7
|
export declare function getObjectChanges(newProps?: Record<string, any>, oldProps?: Record<string, any>): ObjectChanges;
|
|
8
8
|
export declare function classToString(config: unknown): any;
|
|
9
|
+
export declare function styleToObject(style: string | Record<string, any>): Record<string, any>;
|
package/bundles/index.esm.js
CHANGED
|
@@ -601,6 +601,19 @@ function classToString(config) {
|
|
|
601
601
|
return classes.join(' ');
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
|
+
function styleToObject(style) {
|
|
605
|
+
if (typeof style !== 'string') {
|
|
606
|
+
return style;
|
|
607
|
+
}
|
|
608
|
+
const obj = {};
|
|
609
|
+
style.split(';').map(s => s.split(':')).forEach(v => {
|
|
610
|
+
if (!v[0] || !v[1]) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
obj[v[0].trim()] = v[1].trim();
|
|
614
|
+
});
|
|
615
|
+
return obj;
|
|
616
|
+
}
|
|
604
617
|
|
|
605
618
|
class RootComponentRef {
|
|
606
619
|
}
|
|
@@ -1003,7 +1016,7 @@ let Renderer = class Renderer {
|
|
|
1003
1016
|
continue;
|
|
1004
1017
|
}
|
|
1005
1018
|
if (key === 'style') {
|
|
1006
|
-
const style = props.style;
|
|
1019
|
+
const style = styleToObject(props.style);
|
|
1007
1020
|
Object.keys(style).forEach(key => {
|
|
1008
1021
|
this.nativeRenderer.setStyle(nativeNode, key, style[key]);
|
|
1009
1022
|
});
|
|
@@ -1045,7 +1058,7 @@ let Renderer = class Renderer {
|
|
|
1045
1058
|
continue;
|
|
1046
1059
|
}
|
|
1047
1060
|
if (key === 'style') {
|
|
1048
|
-
Object.keys(value).forEach(styleName => {
|
|
1061
|
+
Object.keys(styleToObject(value)).forEach(styleName => {
|
|
1049
1062
|
this.nativeRenderer.removeStyle(nativeNode, styleName);
|
|
1050
1063
|
});
|
|
1051
1064
|
continue;
|
|
@@ -1075,7 +1088,7 @@ let Renderer = class Renderer {
|
|
|
1075
1088
|
continue;
|
|
1076
1089
|
}
|
|
1077
1090
|
if (key === 'style') {
|
|
1078
|
-
const styleChanges = getObjectChanges(newValue, oldValue);
|
|
1091
|
+
const styleChanges = getObjectChanges(styleToObject(newValue), styleToObject(oldValue));
|
|
1079
1092
|
for (const [styleName] of styleChanges.remove) {
|
|
1080
1093
|
this.nativeRenderer.removeStyle(nativeNode, styleName);
|
|
1081
1094
|
}
|
|
@@ -1110,8 +1123,9 @@ let Renderer = class Renderer {
|
|
|
1110
1123
|
continue;
|
|
1111
1124
|
}
|
|
1112
1125
|
if (key === 'style') {
|
|
1113
|
-
|
|
1114
|
-
|
|
1126
|
+
const styleObj = styleToObject(value);
|
|
1127
|
+
Object.keys(styleObj).forEach(styleName => {
|
|
1128
|
+
this.nativeRenderer.setStyle(nativeNode, styleName, styleObj[styleName]);
|
|
1115
1129
|
});
|
|
1116
1130
|
continue;
|
|
1117
1131
|
}
|
package/bundles/index.js
CHANGED
|
@@ -602,6 +602,19 @@ function classToString(config) {
|
|
|
602
602
|
return classes.join(' ');
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
|
+
function styleToObject(style) {
|
|
606
|
+
if (typeof style !== 'string') {
|
|
607
|
+
return style;
|
|
608
|
+
}
|
|
609
|
+
const obj = {};
|
|
610
|
+
style.split(';').map(s => s.split(':')).forEach(v => {
|
|
611
|
+
if (!v[0] || !v[1]) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
obj[v[0].trim()] = v[1].trim();
|
|
615
|
+
});
|
|
616
|
+
return obj;
|
|
617
|
+
}
|
|
605
618
|
|
|
606
619
|
class RootComponentRef {
|
|
607
620
|
}
|
|
@@ -1004,7 +1017,7 @@ exports.Renderer = class Renderer {
|
|
|
1004
1017
|
continue;
|
|
1005
1018
|
}
|
|
1006
1019
|
if (key === 'style') {
|
|
1007
|
-
const style = props.style;
|
|
1020
|
+
const style = styleToObject(props.style);
|
|
1008
1021
|
Object.keys(style).forEach(key => {
|
|
1009
1022
|
this.nativeRenderer.setStyle(nativeNode, key, style[key]);
|
|
1010
1023
|
});
|
|
@@ -1046,7 +1059,7 @@ exports.Renderer = class Renderer {
|
|
|
1046
1059
|
continue;
|
|
1047
1060
|
}
|
|
1048
1061
|
if (key === 'style') {
|
|
1049
|
-
Object.keys(value).forEach(styleName => {
|
|
1062
|
+
Object.keys(styleToObject(value)).forEach(styleName => {
|
|
1050
1063
|
this.nativeRenderer.removeStyle(nativeNode, styleName);
|
|
1051
1064
|
});
|
|
1052
1065
|
continue;
|
|
@@ -1076,7 +1089,7 @@ exports.Renderer = class Renderer {
|
|
|
1076
1089
|
continue;
|
|
1077
1090
|
}
|
|
1078
1091
|
if (key === 'style') {
|
|
1079
|
-
const styleChanges = getObjectChanges(newValue, oldValue);
|
|
1092
|
+
const styleChanges = getObjectChanges(styleToObject(newValue), styleToObject(oldValue));
|
|
1080
1093
|
for (const [styleName] of styleChanges.remove) {
|
|
1081
1094
|
this.nativeRenderer.removeStyle(nativeNode, styleName);
|
|
1082
1095
|
}
|
|
@@ -1111,8 +1124,9 @@ exports.Renderer = class Renderer {
|
|
|
1111
1124
|
continue;
|
|
1112
1125
|
}
|
|
1113
1126
|
if (key === 'style') {
|
|
1114
|
-
|
|
1115
|
-
|
|
1127
|
+
const styleObj = styleToObject(value);
|
|
1128
|
+
Object.keys(styleObj).forEach(styleName => {
|
|
1129
|
+
this.nativeRenderer.setStyle(nativeNode, styleName, styleObj[styleName]);
|
|
1116
1130
|
});
|
|
1117
1131
|
continue;
|
|
1118
1132
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.11",
|
|
4
4
|
"description": "Viewfly is a simple and easy-to-use JavaScript framework with an intuitive development experience.",
|
|
5
5
|
"main": "./bundles/index.js",
|
|
6
6
|
"module": "./bundles/index.esm.js",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"bugs": {
|
|
38
38
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "38e6182b1ae82b0f9626742507ca7a4583d182f9"
|
|
41
41
|
}
|