react-native-unistyles 3.0.0-alpha.7 → 3.0.0-alpha.9
Sign up to get free protection for your applications and to get access to all the features.
- package/cxx/common/Helpers.h +58 -0
- package/cxx/core/Unistyle.h +0 -6
- package/cxx/core/UnistyleData.h +3 -2
- package/cxx/core/UnistyleWrapper.h +6 -6
- package/cxx/core/UnistylesRegistry.cpp +11 -10
- package/cxx/core/UnistylesRegistry.h +4 -3
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +4 -2
- package/cxx/parser/Parser.cpp +24 -78
- package/cxx/parser/Parser.h +1 -2
- package/lib/commonjs/specs/ShadowRegistry/index.js +2 -2
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/index.web.js +1 -1
- package/lib/commonjs/web/convert/boxShadow.js +77 -0
- package/lib/commonjs/web/convert/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/breakpoint.js +25 -0
- package/lib/commonjs/web/convert/breakpoint.js.map +1 -0
- package/lib/commonjs/web/convert/index.js +76 -0
- package/lib/commonjs/web/convert/index.js.map +1 -0
- package/lib/commonjs/web/convert/module.d.js +2 -0
- package/lib/commonjs/web/convert/module.d.js.map +1 -0
- package/lib/commonjs/web/convert/shadow.js +68 -0
- package/lib/commonjs/web/convert/shadow.js.map +1 -0
- package/lib/commonjs/web/convert/style.js +89 -0
- package/lib/commonjs/web/convert/style.js.map +1 -0
- package/lib/commonjs/web/convert/textShadow.js +73 -0
- package/lib/commonjs/web/convert/textShadow.js.map +1 -0
- package/lib/commonjs/web/convert/transform.js +72 -0
- package/lib/commonjs/web/convert/transform.js.map +1 -0
- package/lib/commonjs/web/convert/types.js +9 -0
- package/lib/commonjs/web/convert/types.js.map +1 -0
- package/lib/commonjs/web/convert/utils.js +55 -0
- package/lib/commonjs/web/convert/utils.js.map +1 -0
- package/lib/commonjs/web/create.js +89 -0
- package/lib/commonjs/web/create.js.map +1 -0
- package/lib/commonjs/web/index.js +51 -0
- package/lib/commonjs/web/index.js.map +1 -0
- package/lib/commonjs/web/listener/index.js +13 -0
- package/lib/commonjs/web/listener/index.js.map +1 -0
- package/lib/commonjs/web/listener/listener.js +36 -0
- package/lib/commonjs/web/listener/listener.js.map +1 -0
- package/lib/commonjs/web/mock.js +37 -0
- package/lib/commonjs/web/mock.js.map +1 -0
- package/lib/commonjs/web/mq.js +23 -0
- package/lib/commonjs/web/mq.js.map +1 -0
- package/lib/commonjs/web/pseudo.js +11 -0
- package/lib/commonjs/web/pseudo.js.map +1 -0
- package/lib/commonjs/web/registry.js +37 -0
- package/lib/commonjs/web/registry.js.map +1 -0
- package/lib/commonjs/web/runtime.js +164 -0
- package/lib/commonjs/web/runtime.js.map +1 -0
- package/lib/commonjs/web/state.js +121 -0
- package/lib/commonjs/web/state.js.map +1 -0
- package/lib/commonjs/web/utils.js +78 -0
- package/lib/commonjs/web/utils.js.map +1 -0
- package/lib/commonjs/web/variants/getVariants.js +39 -0
- package/lib/commonjs/web/variants/getVariants.js.map +1 -0
- package/lib/commonjs/web/variants/index.js +28 -0
- package/lib/commonjs/web/variants/index.js.map +1 -0
- package/lib/commonjs/web/variants/useVariants.js +75 -0
- package/lib/commonjs/web/variants/useVariants.js.map +1 -0
- package/lib/module/specs/ShadowRegistry/index.js +2 -2
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/index.web.js +1 -1
- package/lib/module/specs/index.web.js.map +1 -1
- package/lib/module/web/convert/boxShadow.js +72 -0
- package/lib/module/web/convert/boxShadow.js.map +1 -0
- package/lib/module/web/convert/breakpoint.js +20 -0
- package/lib/module/web/convert/breakpoint.js.map +1 -0
- package/lib/module/web/convert/index.js +71 -0
- package/lib/module/web/convert/index.js.map +1 -0
- package/lib/module/web/convert/module.d.js +2 -0
- package/lib/module/web/convert/module.d.js.map +1 -0
- package/lib/module/web/convert/shadow.js +63 -0
- package/lib/module/web/convert/shadow.js.map +1 -0
- package/lib/module/web/convert/style.js +84 -0
- package/lib/module/web/convert/style.js.map +1 -0
- package/lib/module/web/convert/textShadow.js +68 -0
- package/lib/module/web/convert/textShadow.js.map +1 -0
- package/lib/module/web/convert/transform.js +67 -0
- package/lib/module/web/convert/transform.js.map +1 -0
- package/lib/module/web/convert/types.js +5 -0
- package/lib/module/web/convert/types.js.map +1 -0
- package/lib/module/web/convert/utils.js +43 -0
- package/lib/module/web/convert/utils.js.map +1 -0
- package/lib/module/web/create.js +84 -0
- package/lib/module/web/create.js.map +1 -0
- package/lib/module/web/index.js +24 -0
- package/lib/module/web/index.js.map +1 -0
- package/lib/module/web/listener/index.js +4 -0
- package/lib/module/web/listener/index.js.map +1 -0
- package/lib/module/web/listener/listener.js +31 -0
- package/lib/module/web/listener/listener.js.map +1 -0
- package/lib/module/web/mock.js +33 -0
- package/lib/module/web/mock.js.map +1 -0
- package/lib/module/web/mq.js +17 -0
- package/lib/module/web/mq.js.map +1 -0
- package/lib/module/web/pseudo.js +6 -0
- package/lib/module/web/pseudo.js.map +1 -0
- package/lib/module/web/registry.js +33 -0
- package/lib/module/web/registry.js.map +1 -0
- package/lib/module/web/runtime.js +160 -0
- package/lib/module/web/runtime.js.map +1 -0
- package/lib/module/web/state.js +117 -0
- package/lib/module/web/state.js.map +1 -0
- package/lib/module/web/utils.js +65 -0
- package/lib/module/web/utils.js.map +1 -0
- package/lib/module/web/variants/getVariants.js +34 -0
- package/lib/module/web/variants/getVariants.js.map +1 -0
- package/lib/module/web/variants/index.js +5 -0
- package/lib/module/web/variants/index.js.map +1 -0
- package/lib/module/web/variants/useVariants.js +70 -0
- package/lib/module/web/variants/useVariants.js.map +1 -0
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -2
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.web.d.ts +1 -1
- package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/breakpoint.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/convert/index.d.ts +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/transform.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/convert/types.d.ts +1 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/create.d.ts +11 -11
- package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
- package/lib/typescript/{web → src/web}/index.d.ts +12 -12
- package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener/index.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/listener/listener.d.ts +1 -1
- package/lib/typescript/src/web/listener/listener.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/mock.d.ts +2 -2
- package/lib/typescript/src/web/mock.d.ts.map +1 -0
- package/lib/typescript/src/web/mq.d.ts.map +1 -0
- package/lib/typescript/src/web/pseudo.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/registry.d.ts +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/runtime.d.ts +6 -6
- package/lib/typescript/src/web/runtime.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/state.d.ts +4 -4
- package/lib/typescript/src/web/state.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/utils.d.ts +5 -3
- package/lib/typescript/src/web/utils.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
- package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/index.d.ts +3 -0
- package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
- package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
- package/package.json +1 -1
- package/plugin/__tests__/dependencies.spec.js +5 -5
- package/plugin/__tests__/ref.spec.js +132 -17
- package/plugin/__tests__/stylesheet.spec.js +9 -9
- package/plugin/index.js +12 -13
- package/plugin/ref.js +18 -14
- package/plugin/style.js +13 -7
- package/src/specs/ShadowRegistry/index.ts +4 -4
- package/src/specs/index.web.ts +1 -1
- package/src/types/stylesheet.ts +1 -1
- package/{web → src/web}/convert/breakpoint.ts +1 -1
- package/{web → src/web}/convert/index.ts +1 -1
- package/{web → src/web}/convert/types.ts +1 -1
- package/{web → src/web}/create.ts +36 -33
- package/{web → src/web}/listener/listener.ts +1 -1
- package/{web → src/web}/mock.ts +2 -2
- package/{web → src/web}/registry.ts +1 -1
- package/{web → src/web}/runtime.ts +4 -4
- package/{web → src/web}/state.ts +5 -5
- package/{web → src/web}/utils.ts +5 -5
- package/src/web/variants/getVariants.ts +42 -0
- package/src/web/variants/index.ts +2 -0
- package/{web → src/web/variants}/useVariants.ts +24 -44
- package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
- package/lib/typescript/web/convert/index.d.ts.map +0 -1
- package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/style.d.ts.map +0 -1
- package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/transform.d.ts.map +0 -1
- package/lib/typescript/web/convert/types.d.ts.map +0 -1
- package/lib/typescript/web/convert/utils.d.ts.map +0 -1
- package/lib/typescript/web/listener/index.d.ts.map +0 -1
- package/lib/typescript/web/listener/listener.d.ts.map +0 -1
- package/lib/typescript/web/mock.d.ts.map +0 -1
- package/lib/typescript/web/mq.d.ts.map +0 -1
- package/lib/typescript/web/pseudo.d.ts.map +0 -1
- package/lib/typescript/web/registry.d.ts.map +0 -1
- package/lib/typescript/web/runtime.d.ts.map +0 -1
- package/lib/typescript/web/state.d.ts.map +0 -1
- package/lib/typescript/web/useVariants.d.ts +0 -3
- package/lib/typescript/web/useVariants.d.ts.map +0 -1
- package/lib/typescript/web/utils.d.ts.map +0 -1
- /package/lib/typescript/{web → src/web}/convert/boxShadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/breakpoint.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/shadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/style.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/textShadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/transform.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/utils.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/listener/index.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/mq.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/pseudo.d.ts +0 -0
- /package/{web → src/web}/convert/boxShadow.ts +0 -0
- /package/{web → src/web}/convert/module.d.ts +0 -0
- /package/{web → src/web}/convert/shadow.ts +0 -0
- /package/{web → src/web}/convert/style.ts +0 -0
- /package/{web → src/web}/convert/textShadow.ts +0 -0
- /package/{web → src/web}/convert/transform.ts +0 -0
- /package/{web → src/web}/convert/utils.ts +0 -0
- /package/{web → src/web}/index.ts +0 -0
- /package/{web → src/web}/listener/index.ts +0 -0
- /package/{web → src/web}/mq.ts +0 -0
- /package/{web → src/web}/pseudo.ts +0 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
var _useVariants = require("./useVariants");
|
7
|
+
Object.keys(_useVariants).forEach(function (key) {
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
9
|
+
if (key in exports && exports[key] === _useVariants[key]) return;
|
10
|
+
Object.defineProperty(exports, key, {
|
11
|
+
enumerable: true,
|
12
|
+
get: function () {
|
13
|
+
return _useVariants[key];
|
14
|
+
}
|
15
|
+
});
|
16
|
+
});
|
17
|
+
var _getVariants = require("./getVariants");
|
18
|
+
Object.keys(_getVariants).forEach(function (key) {
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
20
|
+
if (key in exports && exports[key] === _getVariants[key]) return;
|
21
|
+
Object.defineProperty(exports, key, {
|
22
|
+
enumerable: true,
|
23
|
+
get: function () {
|
24
|
+
return _getVariants[key];
|
25
|
+
}
|
26
|
+
});
|
27
|
+
});
|
28
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_useVariants","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_getVariants"],"sourceRoot":"../../../../src","sources":["web/variants/index.ts"],"mappings":";;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,YAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,YAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,YAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,YAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,YAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,YAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createUseVariants = void 0;
|
7
|
+
var _react = require("react");
|
8
|
+
var _utils = require("../utils");
|
9
|
+
var _registry = require("../registry");
|
10
|
+
var _getVariants = require("./getVariants");
|
11
|
+
const createUseVariants = (styles, setSelectedVariants) => {
|
12
|
+
const useVariants = selectedVariants => {
|
13
|
+
const [unistylesMap] = (0, _react.useState)(() => new Map());
|
14
|
+
const [classNameMap] = (0, _react.useState)(() => new Map());
|
15
|
+
const [selectedVariantStylesMap] = (0, _react.useState)(() => new Map());
|
16
|
+
const lastSelectedVariantsRef = (0, _react.useRef)();
|
17
|
+
// Variable that determines if variants have changed and we need to recalculate styles
|
18
|
+
const variantsChanged = !(0, _utils.equal)(lastSelectedVariantsRef.current, selectedVariants);
|
19
|
+
if (variantsChanged) {
|
20
|
+
lastSelectedVariantsRef.current = selectedVariants;
|
21
|
+
setSelectedVariants(selectedVariants);
|
22
|
+
}
|
23
|
+
const combinedVariantStyles = (0, _react.useMemo)(() => {
|
24
|
+
const result = (0, _getVariants.getVariants)(styles, selectedVariants);
|
25
|
+
result.forEach(([key, value]) => {
|
26
|
+
selectedVariantStylesMap.set(key, value);
|
27
|
+
});
|
28
|
+
return result;
|
29
|
+
}, [lastSelectedVariantsRef.current]);
|
30
|
+
if (unistylesMap.size === 0 && combinedVariantStyles.length > 0) {
|
31
|
+
combinedVariantStyles.forEach(([key, value]) => {
|
32
|
+
const {
|
33
|
+
className,
|
34
|
+
unistyles
|
35
|
+
} = _registry.UnistylesRegistry.createStyles(value, `variant-${key}`);
|
36
|
+
unistylesMap.set(key, unistyles);
|
37
|
+
classNameMap.set(key, className);
|
38
|
+
});
|
39
|
+
}
|
40
|
+
combinedVariantStyles.forEach(([key, value]) => {
|
41
|
+
const styleEntry = styles[key];
|
42
|
+
const unistyles = unistylesMap.get(key);
|
43
|
+
const className = classNameMap.get(key);
|
44
|
+
const selectedVariantStyles = selectedVariantStylesMap.get(key);
|
45
|
+
if (!unistyles || !className) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
if (variantsChanged) {
|
49
|
+
_registry.UnistylesRegistry.updateStyles(unistyles, value, className);
|
50
|
+
}
|
51
|
+
Object.defineProperties(styleEntry, (0, _utils.reduceObject)(selectedVariantStyles ?? {}, value => ({
|
52
|
+
value,
|
53
|
+
enumerable: false,
|
54
|
+
configurable: true
|
55
|
+
})));
|
56
|
+
if (styleEntry) {
|
57
|
+
Object.keys(styleEntry ?? {}).forEach(key => {
|
58
|
+
if (!key.startsWith('variant-')) {
|
59
|
+
return;
|
60
|
+
}
|
61
|
+
|
62
|
+
// @ts-expect-error - remove old variants
|
63
|
+
delete styleEntry[key];
|
64
|
+
});
|
65
|
+
// @ts-expect-error - apply variant className
|
66
|
+
styleEntry[className] = className;
|
67
|
+
}
|
68
|
+
});
|
69
|
+
};
|
70
|
+
Object.defineProperty(styles, 'useVariants', {
|
71
|
+
value: useVariants
|
72
|
+
});
|
73
|
+
};
|
74
|
+
exports.createUseVariants = createUseVariants;
|
75
|
+
//# sourceMappingURL=useVariants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","require","_utils","_registry","_getVariants","createUseVariants","styles","setSelectedVariants","useVariants","selectedVariants","unistylesMap","useState","Map","classNameMap","selectedVariantStylesMap","lastSelectedVariantsRef","useRef","variantsChanged","equal","current","combinedVariantStyles","useMemo","result","getVariants","forEach","key","value","set","size","length","className","unistyles","UnistylesRegistry","createStyles","styleEntry","get","selectedVariantStyles","updateStyles","Object","defineProperties","reduceObject","enumerable","configurable","keys","startsWith","defineProperty","exports"],"sourceRoot":"../../../../src","sources":["web/variants/useVariants.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE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AU,CAACJ,SAAS,CAAC,GAAGA,SAAS;MACrC;IACJ,CAAC,CAAC;EACN,CAAC;EAEDQ,MAAM,CAACO,cAAc,CAACvC,MAAM,EAAE,aAAa,EAAE;IACzCoB,KAAK,EAAElB;EACX,CAAC,CAAC;AACN,CAAC;AAAAsC,OAAA,CAAAzC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
@@ -10,11 +10,11 @@ const findShadowNodeForHandle = handle => {
|
|
10
10
|
}
|
11
11
|
return node;
|
12
12
|
};
|
13
|
-
HybridShadowRegistry.add = (handle, style, variants) => {
|
13
|
+
HybridShadowRegistry.add = (handle, style, variants, args) => {
|
14
14
|
if (!handle || !style?.__unid) {
|
15
15
|
return;
|
16
16
|
}
|
17
|
-
HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {});
|
17
|
+
HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
|
18
18
|
};
|
19
19
|
HybridShadowRegistry.remove = (handle, style) => {
|
20
20
|
if (!handle || !style?.__unid) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","__unid","link","remove","unlink","UnistylesShadowRegistry"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAazD,MAAMC,oBAAoB,GAAGD,YAAY,CAACE,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP;IACA,MAAM,IAAIK,KAAK,CAAC,uDAAuD,CAAC;EAC5E;EAEA,OAAOL,IAAI;AACf,CAAC;AAEDJ,oBAAoB,CAACU,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,KAAK;
|
1
|
+
{"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","__unid","link","remove","unlink","UnistylesShadowRegistry"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAazD,MAAMC,oBAAoB,GAAGD,YAAY,CAACE,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP;IACA,MAAM,IAAIK,KAAK,CAAC,uDAAuD,CAAC;EAC5E;EAEA,OAAOL,IAAI;AACf,CAAC;AAEDJ,oBAAoB,CAACU,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;EAC1D,IAAI,CAACV,MAAM,IAAI,CAACQ,KAAK,EAAEG,MAAM,EAAE;IAC3B;EACJ;EAEAd,oBAAoB,CAACe,IAAI,CAACb,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,EAAEC,QAAQ,IAAI,CAAC,CAAC,EAAEC,IAAI,IAAI,EAAE,CAAC;AACjG,CAAC;AAEDb,oBAAoB,CAACgB,MAAM,GAAG,CAACb,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEG,MAAM,EAAE;IAC3B;EACJ;EAEAd,oBAAoB,CAACiB,MAAM,CAACf,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQD,OAAO,MAAMO,uBAAuB,GAAGlB,oBAA4D","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getSSRUnistyles"],"sourceRoot":"../../../src","sources":["specs/index.web.ts"],"mappings":";;AAEA,OAAO,MAAMA,eAAe,GAAGA,CAAA,KAAM,EAAyB;AAE9D,cAAc,
|
1
|
+
{"version":3,"names":["getSSRUnistyles"],"sourceRoot":"../../../src","sources":["specs/index.web.ts"],"mappings":";;AAEA,OAAO,MAAMA,eAAe,GAAGA,CAAA,KAAM,EAAyB;AAE9D,cAAc,QAAQ","ignoreList":[]}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { media } from 'typestyle';
|
4
|
+
import { deepMergeObjects, warn } from '../utils';
|
5
|
+
import { validateShadow } from './shadow';
|
6
|
+
import { convertBreakpoint } from './breakpoint';
|
7
|
+
import { BOX_SHADOW_STYLES } from './types';
|
8
|
+
import { extractShadowValue, normalizeColor, normalizeNumericValue } from './utils';
|
9
|
+
const createBoxShadowValue = style => {
|
10
|
+
// at this point every prop is present
|
11
|
+
const {
|
12
|
+
shadowColor,
|
13
|
+
shadowOffset,
|
14
|
+
shadowOpacity,
|
15
|
+
shadowRadius
|
16
|
+
} = style;
|
17
|
+
const offsetX = normalizeNumericValue(shadowOffset.width);
|
18
|
+
const offsetY = normalizeNumericValue(shadowOffset.height);
|
19
|
+
const radius = normalizeNumericValue(shadowRadius);
|
20
|
+
const color = normalizeColor(shadowColor, shadowOpacity);
|
21
|
+
return `${offsetX} ${offsetY} ${radius} ${color}`;
|
22
|
+
};
|
23
|
+
export const getBoxShadowStyle = styles => {
|
24
|
+
const missingStyles = BOX_SHADOW_STYLES.filter(key => !(key in styles));
|
25
|
+
if (missingStyles.length) {
|
26
|
+
warn(`can't apply box shadow as you miss these properties: ${missingStyles.join(', ')}`);
|
27
|
+
return {};
|
28
|
+
}
|
29
|
+
const breakpointsSet = new Set();
|
30
|
+
try {
|
31
|
+
validateShadow(BOX_SHADOW_STYLES, styles, breakpointsSet);
|
32
|
+
} catch (error) {
|
33
|
+
if (typeof error === 'string') {
|
34
|
+
warn(error);
|
35
|
+
}
|
36
|
+
return {};
|
37
|
+
}
|
38
|
+
const breakpoints = Array.from(breakpointsSet);
|
39
|
+
|
40
|
+
// If no breakpoints were used return styles without media queries
|
41
|
+
if (breakpoints.length === 0) {
|
42
|
+
return {
|
43
|
+
boxShadow: createBoxShadowValue(styles)
|
44
|
+
};
|
45
|
+
}
|
46
|
+
|
47
|
+
// Create boxShadow for each breakpoint
|
48
|
+
const breakpointStyles = breakpoints.map(breakpoint => {
|
49
|
+
const color = extractShadowValue('shadowColor', breakpoint, styles);
|
50
|
+
const {
|
51
|
+
width,
|
52
|
+
height
|
53
|
+
} = extractShadowValue('shadowOffset', breakpoint, styles);
|
54
|
+
const radius = extractShadowValue('shadowRadius', breakpoint, styles);
|
55
|
+
const opacity = extractShadowValue('shadowOpacity', breakpoint, styles);
|
56
|
+
return media(convertBreakpoint(breakpoint), {
|
57
|
+
boxShadow: createBoxShadowValue({
|
58
|
+
shadowColor: color,
|
59
|
+
shadowOffset: {
|
60
|
+
width,
|
61
|
+
height
|
62
|
+
},
|
63
|
+
shadowRadius: radius,
|
64
|
+
shadowOpacity: opacity
|
65
|
+
})
|
66
|
+
});
|
67
|
+
});
|
68
|
+
|
69
|
+
// Merge all breakpoints styles into one
|
70
|
+
return deepMergeObjects(...breakpointStyles);
|
71
|
+
};
|
72
|
+
//# sourceMappingURL=boxShadow.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["media","deepMergeObjects","warn","validateShadow","convertBreakpoint","BOX_SHADOW_STYLES","extractShadowValue","normalizeColor","normalizeNumericValue","createBoxShadowValue","style","shadowColor","shadowOffset","shadowOpacity","shadowRadius","offsetX","width","offsetY","height","radius","color","getBoxShadowStyle","styles","missingStyles","filter","key","length","join","breakpointsSet","Set","error","breakpoints","Array","from","boxShadow","breakpointStyles","map","breakpoint","opacity"],"sourceRoot":"../../../../src","sources":["web/convert/boxShadow.ts"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,WAAW;AAEjC,SAASC,gBAAgB,EAAEC,IAAI,QAAQ,UAAU;AACjD,SAASC,cAAc,QAAQ,UAAU;AACzC,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SAASC,iBAAiB,QAAwB,SAAS;AAC3D,SAASC,kBAAkB,EAAEC,cAAc,EAAEC,qBAAqB,QAAQ,SAAS;AAEnF,MAAMC,oBAAoB,GAAIC,KAAgB,IAAK;EAC/C;EACA,MAAM;IAAEC,WAAW;IAAEC,YAAY;IAAEC,aAAa;IAAEC;EAAa,CAAC,GAAGJ,KAAK;EACxE,MAAMK,OAAO,GAAGP,qBAAqB,CAACI,YAAY,CAACI,KAAK,CAAC;EACzD,MAAMC,OAAO,GAAGT,qBAAqB,CAACI,YAAY,CAACM,MAAM,CAAC;EAC1D,MAAMC,MAAM,GAAGX,qBAAqB,CAACM,YAAY,CAAC;EAClD,MAAMM,KAAK,GAAGb,cAAc,CAACI,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAO,GAAGE,OAAO,IAAIE,OAAO,IAAIE,MAAM,IAAIC,KAAK,EAAE;AACrD,CAAC;AAED,OAAO,MAAMC,iBAAiB,GAAIC,MAA2B,IAA0B;EACnF,MAAMC,aAAa,GAAGlB,iBAAiB,CAACmB,MAAM,CAACC,GAAG,I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,KAAK;UACLE;QACJ,CAAC;QACDJ,YAAY,EAAEK,MAAM;QACpBN,aAAa,EAAEyB;MACnB,CAAC;IACL,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;EACA,OAAOrC,gBAAgB,CAAC,GAAGkC,gBAAgB,CAAC;AAChD,CAAC","ignoreList":[]}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { UnistylesState } from '../state';
|
4
|
+
import { keyInObject } from '../utils';
|
5
|
+
import { isUnistylesMq, parseMq } from '../mq';
|
6
|
+
import { Orientation } from '../../specs/types';
|
7
|
+
export const convertBreakpoint = breakpoint => {
|
8
|
+
if (Object.values(Orientation).includes(breakpoint)) {
|
9
|
+
return {
|
10
|
+
orientation: breakpoint
|
11
|
+
};
|
12
|
+
}
|
13
|
+
if (isUnistylesMq(breakpoint)) {
|
14
|
+
return parseMq(breakpoint);
|
15
|
+
}
|
16
|
+
return {
|
17
|
+
minWidth: UnistylesState.breakpoints && keyInObject(UnistylesState.breakpoints, breakpoint) ? UnistylesState.breakpoints[breakpoint] : undefined
|
18
|
+
};
|
19
|
+
};
|
20
|
+
//# sourceMappingURL=breakpoint.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesState","keyInObject","isUnistylesMq","parseMq","Orientation","convertBreakpoint","breakpoint","Object","values","includes","orientation","minWidth","breakpoints","undefined"],"sourceRoot":"../../../../src","sources":["web/convert/breakpoint.ts"],"mappings":";;AACA,SAASA,cAAc,QAAQ,UAAU;AACzC,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,aAAa,EAAEC,OAAO,QAAQ,OAAO;AAC9C,SAASC,WAAW,QAAQ,mBAAmB;AAE/C,OAAO,MAAMC,iBAAiB,GAAIC,UAAkB,IAAiB;EACjE,IAAIC,MAAM,CAACC,MAAM,CAACJ,WAAW,CAAC,CAACK,QAAQ,CAACH,UAAyB,CAAC,EAAE;IAChE,OAAO;MACHI,WAAW,EAAEJ;IACjB,CAAC;EACL;EAEA,IAAIJ,aAAa,CAACI,UAAU,CAAC,EAAE;IAC3B,OAAOH,OAAO,CAACG,UAAU,CAAC;EAC9B;EAEA,OAAO;IACHK,QAAQ,EAAEX,cAAc,CAACY,WAAW,IAAIX,WAAW,CAACD,cAAc,CAACY,WAAW,EAAEN,UAAU,CAAC,GAAGN,cAAc,CAACY,WAAW,CAACN,UAAU,CAAC,GAAGO;EAC3I,CAAC;AACL,CAAC","ignoreList":[]}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { media } from 'typestyle';
|
4
|
+
import { isPseudo } from '../pseudo';
|
5
|
+
import { convertBreakpoint } from './breakpoint';
|
6
|
+
import { getStyle } from './style';
|
7
|
+
import { deepMergeObjects } from '../utils';
|
8
|
+
import { getTransformStyle } from './transform';
|
9
|
+
import { isBoxShadow, isTextShadow, isTransform } from './utils';
|
10
|
+
import { getTextShadowStyle } from './textShadow';
|
11
|
+
import { getBoxShadowStyle } from './boxShadow';
|
12
|
+
export const convertToTypeStyle = value => {
|
13
|
+
// Flag to mark if textShadow is already created
|
14
|
+
let hasTextShadow = false;
|
15
|
+
// Flag to mark if boxShadow is already created
|
16
|
+
let hasBoxShadow = false;
|
17
|
+
const stylesArray = Object.entries({
|
18
|
+
...value,
|
19
|
+
...value._web
|
20
|
+
}).flatMap(([unistylesKey, unistylesValue]) => {
|
21
|
+
// Keys to omit
|
22
|
+
if (['_css', '_web', 'variants', 'compoundVariants', 'uni__dependencies'].includes(unistylesKey)) {
|
23
|
+
return [];
|
24
|
+
}
|
25
|
+
|
26
|
+
// Pseudo classes :hover, :before etc.
|
27
|
+
if (isPseudo(unistylesKey)) {
|
28
|
+
const typestyleValues = convertToTypeStyle(unistylesValue);
|
29
|
+
return {
|
30
|
+
$nest: {
|
31
|
+
[unistylesKey.replace('_', '&:')]: typestyleValues
|
32
|
+
}
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
// Text shadow
|
37
|
+
if (isTextShadow(unistylesKey)) {
|
38
|
+
if (hasTextShadow) {
|
39
|
+
return [];
|
40
|
+
}
|
41
|
+
hasTextShadow = true;
|
42
|
+
return getTextShadowStyle(value);
|
43
|
+
}
|
44
|
+
|
45
|
+
// Box shadow
|
46
|
+
if (isBoxShadow(unistylesKey)) {
|
47
|
+
if (hasBoxShadow) {
|
48
|
+
return [];
|
49
|
+
}
|
50
|
+
hasBoxShadow = true;
|
51
|
+
return getBoxShadowStyle(value);
|
52
|
+
}
|
53
|
+
|
54
|
+
// Transforms
|
55
|
+
if (isTransform(unistylesKey, unistylesValue)) {
|
56
|
+
return getTransformStyle(unistylesValue);
|
57
|
+
}
|
58
|
+
|
59
|
+
// Breakpoints
|
60
|
+
if (typeof unistylesValue === 'object' && unistylesValue !== null) {
|
61
|
+
return Object.entries(unistylesValue).map(([breakpointKey, breakpointValue]) => {
|
62
|
+
return media(convertBreakpoint(breakpointKey), getStyle(unistylesKey, breakpointValue));
|
63
|
+
});
|
64
|
+
}
|
65
|
+
|
66
|
+
// Regular styles
|
67
|
+
return getStyle(unistylesKey, unistylesValue);
|
68
|
+
});
|
69
|
+
return deepMergeObjects(...stylesArray);
|
70
|
+
};
|
71
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["media","isPseudo","convertBreakpoint","getStyle","deepMergeObjects","getTransformStyle","isBoxShadow","isTextShadow","isTransform","getTextShadowStyle","getBoxShadowStyle","convertToTypeStyle","value","hasTextShadow","hasBoxShadow","stylesArray","Object","entries","_web","flatMap","unistylesKey","unistylesValue","includes","typestyleValues","$nest","replace","map","breakpointKey","breakpointValue"],"sourceRoot":"../../../../src","sources":["web/convert/index.ts"],"mappings":";;AAEA,SAASA,KAAK,QAAQ,WAAW;AACjC,SAASC,QAAQ,QAAQ,WAAW;AACpC,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SAASC,QAAQ,QAAQ,SAAS;AAClC,SAASC,gB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AAY,EAAEC,cAAc,CAAC,EAAE;MAC3C,OAAOhB,iBAAiB,CAACgB,cAAc,CAAC;IAC5C;;IAEA;IACA,IAAI,OAAOA,cAAc,KAAK,QAAQ,IAAIA,cAAc,KAAK,IAAI,EAAE;MAC/D,OAAOL,MAAM,CAACC,OAAO,CAACI,cAAc,CAAC,CAACK,GAAG,CAAC,CAAC,CAACC,aAAa,EAAEC,eAAe,CAAC,KAAK;QAC5E,OAAO5B,KAAK,CAACE,iBAAiB,CAACyB,aAAa,CAAC,EAAExB,QAAQ,CAACiB,YAAY,EAAEQ,eAAe,CAAC,CAAC;MAC3F,CAAC,CAAC;IACN;;IAEA;IACA,OAAOzB,QAAQ,CAACiB,YAAY,EAAEC,cAAc,CAAC;EACjD,CAAC,CAA+B;EAEhC,OAAOjB,gBAAgB,CAAC,GAAGW,WAAW,CAAC;AAC3C,CAAC","ignoreList":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["web/convert/module.d.ts"],"mappings":"","ignoreList":[]}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
export const validateShadow = (shadowProperties, styles, breakpoints) => {
|
4
|
+
// Collect breakpoints
|
5
|
+
shadowProperties.forEach(key => {
|
6
|
+
const value = styles[key];
|
7
|
+
if (typeof value !== 'object') {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
if (key === 'shadowOffset' || key === 'textShadowOffset') {
|
11
|
+
const {
|
12
|
+
width,
|
13
|
+
height
|
14
|
+
} = value;
|
15
|
+
|
16
|
+
// If shadowOffset.width has breakpoints
|
17
|
+
if (typeof width === 'object') {
|
18
|
+
Object.keys(width).forEach(breakpoint => breakpoints.add(breakpoint));
|
19
|
+
}
|
20
|
+
|
21
|
+
// If shadowOffset.height has breakpoints
|
22
|
+
if (typeof height === 'object') {
|
23
|
+
Object.keys(height).forEach(breakpoint => breakpoints.add(breakpoint));
|
24
|
+
}
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
|
28
|
+
// Collect regular breakpoints
|
29
|
+
Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint));
|
30
|
+
});
|
31
|
+
|
32
|
+
// Validate if all breakpoints are present
|
33
|
+
shadowProperties.forEach(key => {
|
34
|
+
const value = styles[key];
|
35
|
+
if (typeof value !== 'object') {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
if (key === 'shadowOffset' || key === 'textShadowOffset') {
|
39
|
+
const {
|
40
|
+
width,
|
41
|
+
height
|
42
|
+
} = value;
|
43
|
+
if (typeof width === 'object') {
|
44
|
+
const missingBreakpoints = Array.from(breakpoints).filter(breakpoint => !(breakpoint in width));
|
45
|
+
if (missingBreakpoints.length) {
|
46
|
+
throw `missing breakpoints in ${key}.width: ${missingBreakpoints.join(', ')}`;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
if (typeof height === 'object') {
|
50
|
+
const missingBreakpoints = Array.from(breakpoints).filter(breakpoint => !(breakpoint in height));
|
51
|
+
if (missingBreakpoints.length) {
|
52
|
+
throw `missing breakpoints in ${key}.height: ${missingBreakpoints.join(', ')}`;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
const missingBreakpoints = Array.from(breakpoints).filter(breakpoint => !(breakpoint in value));
|
58
|
+
if (missingBreakpoints.length) {
|
59
|
+
throw `missing breakpoints in ${key}: ${missingBreakpoints.join(', ')}`;
|
60
|
+
}
|
61
|
+
});
|
62
|
+
};
|
63
|
+
//# sourceMappingURL=shadow.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["validateShadow","shadowProperties","styles","breakpoints","forEach","key","value","width","height","Object","keys","breakpoint","add","missingBreakpoints","Array","from","filter","length","join"],"sourceRoot":"../../../../src","sources":["web/convert/shadow.ts"],"mappings":";;AAEA,OAAO,MAAMA,cAAc,GAAGA,CAACC,gBAAuC,EAAEC,MAA2B,EAAEC,WAAwB,KAAK;EAC9H;EACAF,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AAK,CAAC,CAAC;QAE/F,IAAIM,kBAAkB,CAACI,MAAM,EAAE;UAC3B,MAAM,0BAA0BZ,GAAG,WAAWQ,kBAAkB,CAACK,IAAI,CAAC,IAAI,CAAC,EAAE;QACjF;MACJ;MAEA,IAAI,OAAOV,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAMK,kBAAkB,GAAGC,KAAK,CAACC,IAAI,CAACZ,WAAW,CAAC,CAACa,MAAM,CAACL,UAAU,IAAI,EAAEA,UAAU,IAAIH,MAAM,CAAC,CAAC;QAEhG,IAAIK,kBAAkB,CAACI,MAAM,EAAE;UAC3B,MAAM,0BAA0BZ,GAAG,YAAYQ,kBAAkB,CAACK,IAAI,CAAC,IAAI,CAAC,EAAE;QAClF;MACJ;MAEA;IACJ;IAEA,MAAML,kBAAkB,GAAGC,KAAK,CAACC,IAAI,CAACZ,WAAW,CAAC,CAACa,MAAM,CAACL,UAAU,IAAI,EAAEA,UAAU,IAAIL,KAAK,CAAC,CAAC;IAE/F,IAAIO,kBAAkB,CAACI,MAAM,EAAE;MAC3B,MAAM,0BAA0BZ,GAAG,KAAKQ,kBAAkB,CAACK,IAAI,CAAC,IAAI,CAAC,EAAE;IAC3E;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { keyInObject } from '../utils';
|
4
|
+
const stylesToSkip = ['borderCurve', 'elevation', 'textAlignVertical', 'includeFontPadding', 'overlayColor', 'tintColor'];
|
5
|
+
const convertMap = {
|
6
|
+
marginHorizontal: value => ({
|
7
|
+
marginInline: value
|
8
|
+
}),
|
9
|
+
marginVertical: value => ({
|
10
|
+
marginBlock: value
|
11
|
+
}),
|
12
|
+
paddingHorizontal: value => ({
|
13
|
+
paddingInline: value
|
14
|
+
}),
|
15
|
+
paddingVertical: value => ({
|
16
|
+
paddingBlock: value
|
17
|
+
}),
|
18
|
+
writingDirection: value => ({
|
19
|
+
direction: value
|
20
|
+
}),
|
21
|
+
borderBottomEndRadius: value => ({
|
22
|
+
borderBottomRightRadius: value
|
23
|
+
}),
|
24
|
+
borderBottomStartRadius: value => ({
|
25
|
+
borderBottomLeftRadius: value
|
26
|
+
}),
|
27
|
+
borderEndColor: value => ({
|
28
|
+
borderInlineEndColor: value
|
29
|
+
}),
|
30
|
+
borderStartColor: value => ({
|
31
|
+
borderInlineStartColor: value
|
32
|
+
}),
|
33
|
+
borderTopEndRadius: value => ({
|
34
|
+
borderTopRightRadius: value
|
35
|
+
}),
|
36
|
+
borderTopStartRadius: value => ({
|
37
|
+
borderTopLeftRadius: value
|
38
|
+
}),
|
39
|
+
borderEndWidth: value => ({
|
40
|
+
borderInlineEndWidth: value
|
41
|
+
}),
|
42
|
+
borderStartWidth: value => ({
|
43
|
+
borderInlineStartWidth: value
|
44
|
+
}),
|
45
|
+
end: value => ({
|
46
|
+
right: value
|
47
|
+
}),
|
48
|
+
start: value => ({
|
49
|
+
left: value
|
50
|
+
}),
|
51
|
+
marginEnd: value => ({
|
52
|
+
marginRight: value
|
53
|
+
}),
|
54
|
+
marginStart: value => ({
|
55
|
+
marginLeft: value
|
56
|
+
}),
|
57
|
+
paddingEnd: value => ({
|
58
|
+
paddingRight: value
|
59
|
+
}),
|
60
|
+
paddingStart: value => ({
|
61
|
+
paddingLeft: value
|
62
|
+
}),
|
63
|
+
transformMatrix: value => ({
|
64
|
+
transform: `matrix(${value.join(', ')})`
|
65
|
+
}),
|
66
|
+
resizeMode: value => ({
|
67
|
+
backgroundSize: value
|
68
|
+
}),
|
69
|
+
lineHeight: value => ({
|
70
|
+
lineHeight: `${value}px`
|
71
|
+
})
|
72
|
+
};
|
73
|
+
export const getStyle = (key, value) => {
|
74
|
+
if (stylesToSkip.includes(key)) {
|
75
|
+
return {};
|
76
|
+
}
|
77
|
+
if (keyInObject(convertMap, key)) {
|
78
|
+
return convertMap[key]?.(value) ?? {};
|
79
|
+
}
|
80
|
+
return {
|
81
|
+
[key]: value
|
82
|
+
};
|
83
|
+
};
|
84
|
+
//# sourceMappingURL=style.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["keyInObject","stylesToSkip","convertMap","marginHorizontal","value","marginInline","marginVertical","marginBlock","paddingHorizontal","paddingInline","paddingVertical","paddingBlock","writingDirection","direction","borderBottomEndRadius","borderBottomRightRadius","borderBottomStartRadius","borderBottomLeftRadius","borderEndColor","borderInlineEndColor","borderStartColor","borderInlineStartColor","borderTopEndRadius","borderTopRightRadius","borderTopStartRadius","borderTopLeftRadius","borderEndWidth","borderInlineEndWidth","borderStartWidth","borderInlineStartWidth","end","right","start","left","marginEnd","marginRight","marginStart","marginLeft","paddingEnd","paddingRight","paddingStart","paddingLeft","transformMatrix","transform","join","resizeMode","backgroundSize","lineHeight","getStyle","key","includes"],"sourceRoot":"../../../../src","sources":["web/convert/style.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,UAAU;AAGtC,MAAMC,YAAY,GAAG,CACjB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,WAAW,CACd;AAED,MAAMC,UAAU,GAAG;EACfC,gBAAgB,EAAGC,KAAa,KAAM;IAClCC,YAAY,EAAED;EAClB,CAAC,CAAC;EACFE,cAAc,EAAGF,KAAa,KAAM;IAChCG,WAAW,EAAEH;EACjB,CAAC,CAAC;EACFI,iBAAiB,EAAGJ,KAAa,KAAM;IACnCK,aAAa,EAAEL;EACnB,CAAC,CAAC;EACFM,eAAe,EAAGN,KAAa,KAAM;IACjCO,YAAY,EAAEP;EAClB,CAAC,CAAC;EACFQ,gBAAgB,EAAGR,KAAa,KAAM;IAClCS,SAAS,EAAET;EACf,CAAC,CAAC;EACFU,qBAAqB,EAAGV,KAAa,KAAM;IACvCW,uBAAuB,EAAEX;EAC7B,CAAC,CAAC;EACFY,uBAAuB,EAAGZ,KAAa,KAAM;IACzCa,sBAAsB,EAAEb;EAC5B,CAAC,CAAC;EACFc,cAAc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,CAACC,GAAW,EAAE7C,KAAU,KAAK;EACjD,IAAIH,YAAY,CAACiD,QAAQ,CAACD,GAAG,CAAC,EAAE;IAC5B,OAAO,CAAC,CAAC;EACb;EAEA,IAAIjD,WAAW,CAACE,UAAU,EAAE+C,GAAG,CAAC,EAAE;IAC9B,OAAO/C,UAAU,CAAC+C,GAAG,CAAC,GAAG7C,KAAK,CAAC,IAAI,CAAC,CAAC;EACzC;EAEA,OAAO;IACH,CAAC6C,GAAG,GAAG7C;EACX,CAAC;AACL,CAAC","ignoreList":[]}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { media } from 'typestyle';
|
4
|
+
import { deepMergeObjects, warn } from '../utils';
|
5
|
+
import { validateShadow } from './shadow';
|
6
|
+
import { convertBreakpoint } from './breakpoint';
|
7
|
+
import { TEXT_SHADOW_STYLES } from './types';
|
8
|
+
import { extractShadowValue, normalizeColor, normalizeNumericValue } from './utils';
|
9
|
+
const createTextShadowValue = style => {
|
10
|
+
const {
|
11
|
+
textShadowColor,
|
12
|
+
textShadowOffset,
|
13
|
+
textShadowRadius
|
14
|
+
} = style;
|
15
|
+
const offsetX = normalizeNumericValue(textShadowOffset.width);
|
16
|
+
const offsetY = normalizeNumericValue(textShadowOffset.height);
|
17
|
+
const radius = normalizeNumericValue(textShadowRadius);
|
18
|
+
const color = normalizeColor(textShadowColor);
|
19
|
+
return `${offsetX} ${offsetY} ${radius} ${color}`;
|
20
|
+
};
|
21
|
+
export const getTextShadowStyle = styles => {
|
22
|
+
const missingStyles = TEXT_SHADOW_STYLES.filter(key => !(key in styles));
|
23
|
+
if (missingStyles.length) {
|
24
|
+
warn(`can't apply text shadow as you miss these properties: ${missingStyles.join(', ')}`);
|
25
|
+
return {};
|
26
|
+
}
|
27
|
+
const breakpointsSet = new Set();
|
28
|
+
try {
|
29
|
+
validateShadow(TEXT_SHADOW_STYLES, styles, breakpointsSet);
|
30
|
+
} catch (error) {
|
31
|
+
if (typeof error === 'string') {
|
32
|
+
warn(error);
|
33
|
+
}
|
34
|
+
return {};
|
35
|
+
}
|
36
|
+
const breakpoints = Array.from(breakpointsSet);
|
37
|
+
|
38
|
+
// If no breakpoints were used return styles without media queries
|
39
|
+
if (breakpoints.length === 0) {
|
40
|
+
return {
|
41
|
+
textShadow: createTextShadowValue(styles)
|
42
|
+
};
|
43
|
+
}
|
44
|
+
|
45
|
+
// Create textShadow for each breakpoint
|
46
|
+
const breakpointStyles = breakpoints.map(breakpoint => {
|
47
|
+
const color = extractShadowValue('textShadowColor', breakpoint, styles);
|
48
|
+
const {
|
49
|
+
width,
|
50
|
+
height
|
51
|
+
} = extractShadowValue('textShadowOffset', breakpoint, styles);
|
52
|
+
const radius = extractShadowValue('textShadowRadius', breakpoint, styles);
|
53
|
+
return media(convertBreakpoint(breakpoint), {
|
54
|
+
textShadow: createTextShadowValue({
|
55
|
+
textShadowColor: color,
|
56
|
+
textShadowOffset: {
|
57
|
+
width,
|
58
|
+
height
|
59
|
+
},
|
60
|
+
textShadowRadius: radius
|
61
|
+
})
|
62
|
+
});
|
63
|
+
});
|
64
|
+
|
65
|
+
// Merge all breakpoints styles into one
|
66
|
+
return deepMergeObjects(...breakpointStyles);
|
67
|
+
};
|
68
|
+
//# sourceMappingURL=textShadow.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["media","deepMergeObjects","warn","validateShadow","convertBreakpoint","TEXT_SHADOW_STYLES","extractShadowValue","normalizeColor","normalizeNumericValue","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","color","getTextShadowStyle","styles","missingStyles","filter","key","length","join","breakpointsSet","Set","error","breakpoints","Array","from","textShadow","breakpointStyles","map","breakpoint"],"sourceRoot":"../../../../src","sources":["web/convert/textShadow.ts"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,WAAW;AAEjC,SAASC,gBAAgB,EAAEC,IAAI,QAAQ,UAAU;AACjD,SAASC,cAAc,QA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AE9C;EACA,IAAIG,WAAW,CAACL,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAO;MACHQ,UAAU,EAAExB,qBAAqB,CAACY,MAAoB;IAC1D,CAAC;EACL;;EAEA;EACA,MAAMa,gBAAgB,GAAGJ,WAAW,CAACK,GAAG,CAACC,UAAU,IAAI;IACnD,MAAMjB,KAAK,GAAGb,kBAAkB,CAAC,iBAAiB,EAAE8B,UAAU,EAAEf,MAAM,CAAC;IACvE,MAAM;MAAEN,KAAK;MAAEE;IAAO,CAAC,GAAGX,kBAAkB,CAAC,kBAAkB,EAAE8B,UAAU,EAAEf,MAAM,CAAC;IACpF,MAAMH,MAAM,GAAGZ,kBAAkB,CAAC,kBAAkB,EAAE8B,UAAU,EAAEf,MAAM,CAAC;IAEzE,OAAOrB,KAAK,CAACI,iBAAiB,CAACgC,UAAU,CAAC,EAAE;MACxCH,UAAU,EAAExB,qBAAqB,CAAC;QAC9BE,eAAe,EAAEQ,KAAK;QACtBP,gBAAgB,EAAE;UACdG,KAAK;UACLE;QACJ,CAAC;QACDJ,gBAAgB,EAAEK;MACtB,CAAC;IACL,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;EACA,OAAOjB,gBAAgB,CAAC,GAAGiC,gBAAgB,CAAC;AAChD,CAAC","ignoreList":[]}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { media } from 'typestyle';
|
4
|
+
import { deepMergeObjects, keyInObject } from '../utils';
|
5
|
+
import { normalizeNumericValue } from './utils';
|
6
|
+
import { convertBreakpoint } from './breakpoint';
|
7
|
+
const normalizeTransform = (key, value) => {
|
8
|
+
if (key.includes('scale')) {
|
9
|
+
return value;
|
10
|
+
}
|
11
|
+
if (typeof value === 'number') {
|
12
|
+
return normalizeNumericValue(value);
|
13
|
+
}
|
14
|
+
return value;
|
15
|
+
};
|
16
|
+
const createTransformValue = transforms => transforms.map(transform => {
|
17
|
+
const [key] = Object.keys(transform);
|
18
|
+
if (!key) {
|
19
|
+
return undefined;
|
20
|
+
}
|
21
|
+
const value = transform[key];
|
22
|
+
switch (key) {
|
23
|
+
case 'matrix':
|
24
|
+
case 'matrix3d':
|
25
|
+
return `${key}(${value.join(',')})`;
|
26
|
+
default:
|
27
|
+
return `${key}(${normalizeTransform(key, value)})`;
|
28
|
+
}
|
29
|
+
}).filter(Boolean).join(' ');
|
30
|
+
export const getTransformStyle = transforms => {
|
31
|
+
const breakpoints = new Set();
|
32
|
+
const normalTransforms = [];
|
33
|
+
transforms.forEach(transform => {
|
34
|
+
const [property] = Object.keys(transform);
|
35
|
+
if (!property) {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
const value = transform[property];
|
39
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
40
|
+
Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint));
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
normalTransforms.push(transform);
|
44
|
+
});
|
45
|
+
const breakpointTransforms = Array.from(breakpoints).flatMap(breakpoint => {
|
46
|
+
const transformsPerBreakpoint = transforms.flatMap(transform => {
|
47
|
+
const [property] = Object.keys(transform);
|
48
|
+
if (!property) {
|
49
|
+
return [];
|
50
|
+
}
|
51
|
+
const value = transform[property];
|
52
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
53
|
+
return keyInObject(value, breakpoint) ? [{
|
54
|
+
[property]: value[breakpoint]
|
55
|
+
}] : [];
|
56
|
+
}
|
57
|
+
return [];
|
58
|
+
});
|
59
|
+
return media(convertBreakpoint(breakpoint), {
|
60
|
+
transform: createTransformValue(transformsPerBreakpoint)
|
61
|
+
});
|
62
|
+
});
|
63
|
+
return deepMergeObjects({
|
64
|
+
transform: createTransformValue(normalTransforms)
|
65
|
+
}, ...breakpointTransforms);
|
66
|
+
};
|
67
|
+
//# sourceMappingURL=transform.js.map
|