@tamagui/react-native-web-internals 1.114.4 → 1.115.0
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/dist/cjs/StyleSheet/__tests__/{compiler-createReactDOMStyle-test.js → compiler-createReactDOMStyle-test.cjs} +98 -50
- package/dist/cjs/StyleSheet/__tests__/{compiler-test.js → compiler-test.cjs} +158 -129
- package/dist/cjs/StyleSheet/__tests__/{dom-createOrderedCSSStyleSheet-test.js → dom-createOrderedCSSStyleSheet-test.cjs} +23 -19
- package/dist/cjs/StyleSheet/__tests__/{index-test.js → index-test.cjs} +173 -116
- package/dist/cjs/StyleSheet/__tests__/preprocess-test.cjs +108 -0
- package/dist/cjs/StyleSheet/__tests__/validate-test.cjs +36 -0
- package/dist/cjs/StyleSheet/compiler/createReactDOMStyle.cjs +99 -0
- package/dist/cjs/StyleSheet/compiler/hash.cjs +26 -0
- package/dist/cjs/StyleSheet/compiler/hyphenateStyleName.cjs +37 -0
- package/dist/cjs/StyleSheet/compiler/index.cjs +329 -0
- package/dist/cjs/StyleSheet/compiler/{normalizeColor.js → normalizeColor.cjs} +30 -20
- package/dist/cjs/StyleSheet/compiler/{normalizeValueWithProperty.js → normalizeValueWithProperty.cjs} +24 -15
- package/dist/cjs/StyleSheet/compiler/resolveShadowValue.cjs +60 -0
- package/dist/cjs/StyleSheet/dom/createCSSStyleSheet.cjs +48 -0
- package/dist/cjs/StyleSheet/dom/{createOrderedCSSStyleSheet.js → createOrderedCSSStyleSheet.cjs} +36 -20
- package/dist/cjs/StyleSheet/dom/index.cjs +78 -0
- package/dist/cjs/StyleSheet/{index.js → index.cjs} +24 -19
- package/dist/cjs/StyleSheet/preprocess.cjs +112 -0
- package/dist/cjs/StyleSheet/validate.cjs +69 -0
- package/dist/cjs/TextAncestorContext.cjs +29 -0
- package/dist/cjs/{colorProps.js → colorProps.cjs} +16 -11
- package/dist/cjs/index.cjs +113 -0
- package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.cjs +50 -0
- package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.cjs +40 -0
- package/dist/cjs/modules/AccessibilityUtil/{index.js → index.cjs} +25 -15
- package/dist/cjs/modules/AccessibilityUtil/isDisabled.cjs +27 -0
- package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.cjs +69 -0
- package/dist/cjs/modules/AccessibilityUtil/propsToAriaRole.cjs +48 -0
- package/dist/cjs/modules/AssetRegistry/{index.js → index.cjs} +16 -11
- package/dist/cjs/modules/ImageLoader/index.cjs +112 -0
- package/dist/cjs/modules/{InteractionManager.js → InteractionManager.cjs} +26 -20
- package/dist/cjs/modules/Platform/__tests__/index-test.cjs +48 -0
- package/dist/cjs/modules/Platform/index.cjs +31 -0
- package/dist/cjs/modules/TextInputState/{index.js → index.cjs} +23 -15
- package/dist/cjs/modules/UIManager/__tests__/{index-test.js → index-test.cjs} +56 -32
- package/dist/cjs/modules/UIManager/index.cjs +138 -0
- package/dist/cjs/modules/canUseDOM.cjs +28 -0
- package/dist/cjs/modules/createDOMProps/__tests__/index-test.cjs +156 -0
- package/dist/cjs/modules/createDOMProps/index.cjs +138 -0
- package/dist/cjs/modules/createEventHandle/__tests__/index-test.cjs +344 -0
- package/dist/cjs/modules/createEventHandle/{index.js → index.cjs} +38 -34
- package/dist/cjs/modules/dismissKeyboard/{index.js → index.cjs} +23 -15
- package/dist/cjs/modules/forwardedProps/index.cjs +160 -0
- package/dist/cjs/modules/getBoundingClientRect/index.cjs +29 -0
- package/dist/cjs/modules/invariant.cjs +36 -0
- package/dist/cjs/modules/isSelectionValid/index.cjs +35 -0
- package/dist/cjs/modules/isWebColor/index.cjs +27 -0
- package/dist/cjs/modules/mergeRefs/__tests__/index-test.cjs +42 -0
- package/dist/cjs/modules/mergeRefs/index.cjs +42 -0
- package/dist/cjs/modules/modality/__tests__/{index-test.js → index-test.cjs} +20 -8
- package/dist/cjs/modules/modality/{index.js → index.cjs} +75 -19
- package/dist/cjs/modules/multiplyStyleLengthValue/__tests__/{index-test.js → index-test.cjs} +16 -14
- package/dist/cjs/modules/multiplyStyleLengthValue/index.cjs +36 -0
- package/dist/cjs/modules/normalizeColor/{index.js → index.cjs} +29 -18
- package/dist/cjs/modules/pick/index.cjs +30 -0
- package/dist/cjs/modules/processColor/__tests__/{index-test.js → index-test.cjs} +17 -15
- package/dist/cjs/modules/processColor/{index.js → index.cjs} +25 -19
- package/dist/cjs/modules/requestIdleCallback/index.cjs +56 -0
- package/dist/cjs/modules/setValueForStyles/{dangerousStyleValue.js → dangerousStyleValue.cjs} +23 -15
- package/dist/cjs/modules/setValueForStyles/{index.js → index.cjs} +26 -18
- package/dist/cjs/modules/unitlessNumbers/index.cjs +87 -0
- package/dist/cjs/modules/useElementLayout/{index.js → index.cjs} +40 -23
- package/dist/cjs/modules/useEvent/__tests__/{index-test.js → index-test.cjs} +218 -99
- package/dist/cjs/modules/useEvent/index.cjs +56 -0
- package/dist/cjs/modules/useHover/__tests__/{index-test.js → index-test.cjs} +118 -40
- package/dist/cjs/modules/useHover/index.cjs +108 -0
- package/dist/cjs/modules/useLayoutEffect/{index.js → index.cjs} +24 -15
- package/dist/cjs/modules/useLocale/index.cjs +66 -0
- package/dist/cjs/modules/useLocale/{isLocaleRTL.js → isLocaleRTL.cjs} +23 -31
- package/dist/cjs/modules/useMergeRefs/__tests__/index-test.cjs +102 -0
- package/dist/cjs/modules/useMergeRefs/index.cjs +43 -0
- package/dist/cjs/modules/usePlatformMethods/index.cjs +48 -0
- package/dist/cjs/modules/useStable/__tests__/{index-test.js → index-test.cjs} +46 -23
- package/dist/cjs/modules/useStable/{index.js → index.cjs} +22 -14
- package/dist/cjs/styleTypes.cjs +16 -0
- package/dist/cjs/types.cjs +16 -0
- package/package.json +9 -8
- package/dist/cjs/StyleSheet/__tests__/preprocess-test.js +0 -77
- package/dist/cjs/StyleSheet/__tests__/validate-test.js +0 -18
- package/dist/cjs/StyleSheet/compiler/createReactDOMStyle.js +0 -121
- package/dist/cjs/StyleSheet/compiler/hash.js +0 -21
- package/dist/cjs/StyleSheet/compiler/hyphenateStyleName.js +0 -31
- package/dist/cjs/StyleSheet/compiler/index.js +0 -253
- package/dist/cjs/StyleSheet/compiler/resolveShadowValue.js +0 -35
- package/dist/cjs/StyleSheet/dom/createCSSStyleSheet.js +0 -44
- package/dist/cjs/StyleSheet/dom/index.js +0 -74
- package/dist/cjs/StyleSheet/preprocess.js +0 -67
- package/dist/cjs/StyleSheet/validate.js +0 -66
- package/dist/cjs/TextAncestorContext.js +0 -24
- package/dist/cjs/index.js +0 -73
- package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.js +0 -46
- package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.js +0 -30
- package/dist/cjs/modules/AccessibilityUtil/isDisabled.js +0 -22
- package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.js +0 -60
- package/dist/cjs/modules/AccessibilityUtil/propsToAriaRole.js +0 -43
- package/dist/cjs/modules/ImageLoader/index.js +0 -102
- package/dist/cjs/modules/Platform/__tests__/index-test.js +0 -46
- package/dist/cjs/modules/Platform/index.js +0 -26
- package/dist/cjs/modules/UIManager/index.js +0 -101
- package/dist/cjs/modules/canUseDOM.js +0 -23
- package/dist/cjs/modules/createDOMProps/__tests__/index-test.js +0 -106
- package/dist/cjs/modules/createDOMProps/index.js +0 -121
- package/dist/cjs/modules/createEventHandle/__tests__/index-test.js +0 -242
- package/dist/cjs/modules/forwardedProps/index.js +0 -145
- package/dist/cjs/modules/getBoundingClientRect/index.js +0 -25
- package/dist/cjs/modules/invariant.js +0 -35
- package/dist/cjs/modules/isSelectionValid/index.js +0 -27
- package/dist/cjs/modules/isWebColor/index.js +0 -22
- package/dist/cjs/modules/mergeRefs/__tests__/index-test.js +0 -34
- package/dist/cjs/modules/mergeRefs/index.js +0 -41
- package/dist/cjs/modules/multiplyStyleLengthValue/index.js +0 -28
- package/dist/cjs/modules/pick/index.js +0 -26
- package/dist/cjs/modules/requestIdleCallback/index.js +0 -44
- package/dist/cjs/modules/unitlessNumbers/index.js +0 -80
- package/dist/cjs/modules/useEvent/index.js +0 -45
- package/dist/cjs/modules/useHover/index.js +0 -81
- package/dist/cjs/modules/useLocale/index.js +0 -54
- package/dist/cjs/modules/useMergeRefs/__tests__/index-test.js +0 -68
- package/dist/cjs/modules/useMergeRefs/index.js +0 -36
- package/dist/cjs/modules/usePlatformMethods/index.js +0 -39
- package/dist/cjs/styleTypes.js +0 -14
- package/dist/cjs/types.js +0 -14
- /package/dist/cjs/StyleSheet/__tests__/{compiler-createReactDOMStyle-test.js.map → compiler-createReactDOMStyle-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/__tests__/{compiler-test.js.map → compiler-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/__tests__/{dom-createOrderedCSSStyleSheet-test.js.map → dom-createOrderedCSSStyleSheet-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/__tests__/{preprocess-test.js.map → preprocess-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/__tests__/{validate-test.js.map → validate-test.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{createReactDOMStyle.js.map → createReactDOMStyle.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{hash.js.map → hash.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{hyphenateStyleName.js.map → hyphenateStyleName.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{normalizeColor.js.map → normalizeColor.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{normalizeValueWithProperty.js.map → normalizeValueWithProperty.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/compiler/{resolveShadowValue.js.map → resolveShadowValue.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/dom/{createCSSStyleSheet.js.map → createCSSStyleSheet.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/dom/{createOrderedCSSStyleSheet.js.map → createOrderedCSSStyleSheet.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/dom/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/{preprocess.js.map → preprocess.cjs.map} +0 -0
- /package/dist/cjs/StyleSheet/{validate.js.map → validate.cjs.map} +0 -0
- /package/dist/cjs/{TextAncestorContext.js.map → TextAncestorContext.cjs.map} +0 -0
- /package/dist/cjs/{colorProps.js.map → colorProps.cjs.map} +0 -0
- /package/dist/cjs/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/__tests__/{propsToAccessibilityComponent-test.js.map → propsToAccessibilityComponent-test.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/__tests__/{propsToAriaRole-test.js.map → propsToAriaRole-test.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/{isDisabled.js.map → isDisabled.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/{propsToAccessibilityComponent.js.map → propsToAccessibilityComponent.cjs.map} +0 -0
- /package/dist/cjs/modules/AccessibilityUtil/{propsToAriaRole.js.map → propsToAriaRole.cjs.map} +0 -0
- /package/dist/cjs/modules/AssetRegistry/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/ImageLoader/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/{InteractionManager.js.map → InteractionManager.cjs.map} +0 -0
- /package/dist/cjs/modules/Platform/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/Platform/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/TextInputState/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/UIManager/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/UIManager/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/{canUseDOM.js.map → canUseDOM.cjs.map} +0 -0
- /package/dist/cjs/modules/createDOMProps/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/createDOMProps/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/createEventHandle/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/createEventHandle/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/dismissKeyboard/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/forwardedProps/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/getBoundingClientRect/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/{invariant.js.map → invariant.cjs.map} +0 -0
- /package/dist/cjs/modules/isSelectionValid/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/isWebColor/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/mergeRefs/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/mergeRefs/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/modality/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/modality/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/multiplyStyleLengthValue/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/multiplyStyleLengthValue/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/normalizeColor/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/pick/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/processColor/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/processColor/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/requestIdleCallback/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/setValueForStyles/{dangerousStyleValue.js.map → dangerousStyleValue.cjs.map} +0 -0
- /package/dist/cjs/modules/setValueForStyles/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/unitlessNumbers/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useElementLayout/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useEvent/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/useEvent/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useHover/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/useHover/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useLayoutEffect/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useLocale/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useLocale/{isLocaleRTL.js.map → isLocaleRTL.cjs.map} +0 -0
- /package/dist/cjs/modules/useMergeRefs/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/useMergeRefs/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/usePlatformMethods/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/modules/useStable/__tests__/{index-test.js.map → index-test.cjs.map} +0 -0
- /package/dist/cjs/modules/useStable/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/{styleTypes.js.map → styleTypes.cjs.map} +0 -0
- /package/dist/cjs/{types.js.map → types.cjs.map} +0 -0
|
@@ -2,22 +2,25 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
7
|
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
10
12
|
return to;
|
|
11
13
|
};
|
|
12
14
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
mod
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
16
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
17
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
18
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
19
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: !0
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
var import__ = __toESM(require("../index.cjs"));
|
|
21
24
|
describe("StyleSheet", () => {
|
|
22
25
|
test("getSheet", () => {
|
|
23
26
|
expect(import__.default.getSheet()).toMatchInlineSnapshot(`
|
|
@@ -60,14 +63,22 @@ describe("StyleSheet", () => {
|
|
|
60
63
|
expect(import__.default.compose(1, 2)).toEqual([1, 2]), expect(import__.default.compose(1, null)).toBe(1), expect(import__.default.compose(null, 2)).toBe(2);
|
|
61
64
|
}), describe("create", () => {
|
|
62
65
|
test("returns original style objects", () => {
|
|
63
|
-
const style = import__.default.create({
|
|
66
|
+
const style = import__.default.create({
|
|
67
|
+
root: {
|
|
68
|
+
position: "absolute"
|
|
69
|
+
}
|
|
70
|
+
});
|
|
64
71
|
expect(style.root).toMatchInlineSnapshot(`
|
|
65
72
|
{
|
|
66
73
|
"position": "absolute",
|
|
67
74
|
}
|
|
68
75
|
`);
|
|
69
76
|
}), test("e2e resolves to classname", () => {
|
|
70
|
-
const style = import__.default.create({
|
|
77
|
+
const style = import__.default.create({
|
|
78
|
+
root: {
|
|
79
|
+
position: "absolute"
|
|
80
|
+
}
|
|
81
|
+
});
|
|
71
82
|
expect((0, import__.default)(style.root)).toMatchInlineSnapshot(`
|
|
72
83
|
[
|
|
73
84
|
"r-position-u8s1d",
|
|
@@ -78,11 +89,17 @@ describe("StyleSheet", () => {
|
|
|
78
89
|
const style = import__.default.create({
|
|
79
90
|
root: {
|
|
80
91
|
shadowColor: "rgba(50,60,70,0.5)",
|
|
81
|
-
shadowOffset: {
|
|
92
|
+
shadowOffset: {
|
|
93
|
+
width: 1,
|
|
94
|
+
height: 2
|
|
95
|
+
},
|
|
82
96
|
shadowOpacity: 0.5,
|
|
83
97
|
shadowRadius: 3,
|
|
84
98
|
textShadowColor: "rgba(50,60,70,0.50)",
|
|
85
|
-
textShadowOffset: {
|
|
99
|
+
textShadowOffset: {
|
|
100
|
+
width: 5,
|
|
101
|
+
height: 10
|
|
102
|
+
},
|
|
86
103
|
textShadowRadius: 15
|
|
87
104
|
}
|
|
88
105
|
});
|
|
@@ -95,7 +112,11 @@ describe("StyleSheet", () => {
|
|
|
95
112
|
});
|
|
96
113
|
}), describe("flatten", () => {
|
|
97
114
|
test("should merge style objects", () => {
|
|
98
|
-
const style = import__.default.flatten([{
|
|
115
|
+
const style = import__.default.flatten([{
|
|
116
|
+
opacity: 1
|
|
117
|
+
}, {
|
|
118
|
+
order: 2
|
|
119
|
+
}]);
|
|
99
120
|
expect(style).toMatchInlineSnapshot(`
|
|
100
121
|
{
|
|
101
122
|
"opacity": 1,
|
|
@@ -103,10 +124,13 @@ describe("StyleSheet", () => {
|
|
|
103
124
|
}
|
|
104
125
|
`);
|
|
105
126
|
}), test("should override style properties", () => {
|
|
106
|
-
const style = import__.default.flatten([
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
const style = import__.default.flatten([{
|
|
128
|
+
backgroundColor: "#000",
|
|
129
|
+
order: 1
|
|
130
|
+
}, {
|
|
131
|
+
backgroundColor: "#023c69",
|
|
132
|
+
order: null
|
|
133
|
+
}]);
|
|
110
134
|
expect(style).toMatchInlineSnapshot(`
|
|
111
135
|
{
|
|
112
136
|
"backgroundColor": "#023c69",
|
|
@@ -114,10 +138,11 @@ describe("StyleSheet", () => {
|
|
|
114
138
|
}
|
|
115
139
|
`);
|
|
116
140
|
}), test("should overwrite properties with `undefined`", () => {
|
|
117
|
-
const style = import__.default.flatten([
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
141
|
+
const style = import__.default.flatten([{
|
|
142
|
+
backgroundColor: "#000"
|
|
143
|
+
}, {
|
|
144
|
+
backgroundColor: void 0
|
|
145
|
+
}]);
|
|
121
146
|
expect(style).toMatchInlineSnapshot(`
|
|
122
147
|
{
|
|
123
148
|
"backgroundColor": undefined,
|
|
@@ -126,12 +151,13 @@ describe("StyleSheet", () => {
|
|
|
126
151
|
}), test("should not fail on falsy values", () => {
|
|
127
152
|
expect(() => import__.default.flatten([null, !1, void 0])).not.toThrow();
|
|
128
153
|
}), test("should recursively flatten arrays", () => {
|
|
129
|
-
const style = import__.default.flatten([
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
154
|
+
const style = import__.default.flatten([null, [], [{
|
|
155
|
+
order: 2
|
|
156
|
+
}, {
|
|
157
|
+
opacity: 1
|
|
158
|
+
}], {
|
|
159
|
+
order: 3
|
|
160
|
+
}]);
|
|
135
161
|
expect(style).toMatchInlineSnapshot(`
|
|
136
162
|
{
|
|
137
163
|
"opacity": 1,
|
|
@@ -160,44 +186,32 @@ describe("StyleSheet", () => {
|
|
|
160
186
|
]
|
|
161
187
|
`);
|
|
162
188
|
}), test("transforms compiled object to className", () => {
|
|
163
|
-
expect(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
width: "width-200"
|
|
170
|
-
}
|
|
171
|
-
])
|
|
172
|
-
).toMatchInlineSnapshot(`
|
|
189
|
+
expect((0, import__.default)([{
|
|
190
|
+
$$css: !0,
|
|
191
|
+
position: "position-absolute",
|
|
192
|
+
opacity: "opacity-05",
|
|
193
|
+
width: "width-200"
|
|
194
|
+
}])).toMatchInlineSnapshot(`
|
|
173
195
|
[
|
|
174
196
|
"position-absolute opacity-05 width-200",
|
|
175
197
|
null,
|
|
176
198
|
]
|
|
177
199
|
`);
|
|
178
200
|
}), test("transforms array of compiled objects to className", () => {
|
|
179
|
-
expect(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
[
|
|
194
|
-
{
|
|
195
|
-
$$css: !0,
|
|
196
|
-
width: "width-200"
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
])
|
|
200
|
-
).toMatchInlineSnapshot(`
|
|
201
|
+
expect((0, import__.default)([{
|
|
202
|
+
$$css: !0,
|
|
203
|
+
borderWidth: "borderWidth-0",
|
|
204
|
+
borderColor: "borderColor-red",
|
|
205
|
+
display: "display-flex",
|
|
206
|
+
width: "width-100"
|
|
207
|
+
}, {
|
|
208
|
+
$$css: !0,
|
|
209
|
+
position: "position-absolute",
|
|
210
|
+
opacity: "opacity-05"
|
|
211
|
+
}, [{
|
|
212
|
+
$$css: !0,
|
|
213
|
+
width: "width-200"
|
|
214
|
+
}]])).toMatchInlineSnapshot(`
|
|
201
215
|
[
|
|
202
216
|
"borderWidth-0 borderColor-red display-flex position-absolute opacity-05 width-200",
|
|
203
217
|
null,
|
|
@@ -205,32 +219,35 @@ describe("StyleSheet", () => {
|
|
|
205
219
|
`);
|
|
206
220
|
}), test("dedupes class names and inline styles", () => {
|
|
207
221
|
const styleACompiled = {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
styleBInline
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
styleBInline,
|
|
227
|
-
styleBCompiled
|
|
228
|
-
]);
|
|
222
|
+
$$css: !0,
|
|
223
|
+
backgroundColor: "backgroundColor-red",
|
|
224
|
+
display: "display-block"
|
|
225
|
+
},
|
|
226
|
+
styleBCompiled = {
|
|
227
|
+
$$css: !0,
|
|
228
|
+
backgroundColor: "backgroundColor-green",
|
|
229
|
+
color: "color-green"
|
|
230
|
+
},
|
|
231
|
+
styleBInline = {
|
|
232
|
+
backgroundColor: "rgba(0,0,255,1.00)",
|
|
233
|
+
color: null
|
|
234
|
+
},
|
|
235
|
+
[className1, inlineStyle1] = (0, import__.default)([styleACompiled, styleBCompiled, styleBInline]);
|
|
236
|
+
expect(className1).toBe("display-block"), expect(inlineStyle1).toEqual({
|
|
237
|
+
backgroundColor: "rgba(0,0,255,1.00)"
|
|
238
|
+
});
|
|
239
|
+
const [className2, inlineStyle2] = (0, import__.default)([styleACompiled, styleBInline, styleBCompiled]);
|
|
229
240
|
expect(className2).toBe("display-block backgroundColor-green color-green"), expect(inlineStyle2).toEqual(null);
|
|
230
241
|
}), test("long form inline style properties take precedence over static shorthand properties", () => {
|
|
231
242
|
const styles1 = import__.default.create({
|
|
232
|
-
|
|
233
|
-
|
|
243
|
+
test: {
|
|
244
|
+
paddingHorizontal: "40px"
|
|
245
|
+
}
|
|
246
|
+
}),
|
|
247
|
+
inlineStyle1 = {
|
|
248
|
+
padding: "8px",
|
|
249
|
+
paddingHorizontal: "40px"
|
|
250
|
+
};
|
|
234
251
|
expect((0, import__.default)([styles1.test, inlineStyle1])).toMatchInlineSnapshot(`
|
|
235
252
|
[
|
|
236
253
|
"",
|
|
@@ -242,7 +259,15 @@ describe("StyleSheet", () => {
|
|
|
242
259
|
},
|
|
243
260
|
]
|
|
244
261
|
`);
|
|
245
|
-
const styles2 = import__.default.create({
|
|
262
|
+
const styles2 = import__.default.create({
|
|
263
|
+
test: {
|
|
264
|
+
marginVertical: "40px"
|
|
265
|
+
}
|
|
266
|
+
}),
|
|
267
|
+
inlineStyle2 = {
|
|
268
|
+
margin: "8px",
|
|
269
|
+
marginVertical: "40px"
|
|
270
|
+
};
|
|
246
271
|
expect((0, import__.default)([styles2.test, inlineStyle2])).toMatchInlineSnapshot(`
|
|
247
272
|
[
|
|
248
273
|
"",
|
|
@@ -255,7 +280,32 @@ describe("StyleSheet", () => {
|
|
|
255
280
|
]
|
|
256
281
|
`);
|
|
257
282
|
}), test("polyfills logical styles", () => {
|
|
258
|
-
const inlineA = {
|
|
283
|
+
const inlineA = {
|
|
284
|
+
start: "12.34%"
|
|
285
|
+
},
|
|
286
|
+
inlineB = {
|
|
287
|
+
textAlign: "start"
|
|
288
|
+
},
|
|
289
|
+
inlineC = {
|
|
290
|
+
marginEnd: 10
|
|
291
|
+
},
|
|
292
|
+
a = import__.default.create({
|
|
293
|
+
x: {
|
|
294
|
+
...inlineA
|
|
295
|
+
}
|
|
296
|
+
}).x,
|
|
297
|
+
b = import__.default.create({
|
|
298
|
+
x: {
|
|
299
|
+
...inlineB
|
|
300
|
+
}
|
|
301
|
+
}).x,
|
|
302
|
+
c = import__.default.create({
|
|
303
|
+
x: {
|
|
304
|
+
...inlineC
|
|
305
|
+
}
|
|
306
|
+
}).x,
|
|
307
|
+
writingDirection = "rtl",
|
|
308
|
+
inlineStyle = [inlineA, inlineB, inlineC];
|
|
259
309
|
expect((0, import__.default)(inlineStyle)).toMatchInlineSnapshot(`
|
|
260
310
|
[
|
|
261
311
|
"",
|
|
@@ -265,7 +315,9 @@ describe("StyleSheet", () => {
|
|
|
265
315
|
"textAlign": "left",
|
|
266
316
|
},
|
|
267
317
|
]
|
|
268
|
-
`), expect((0, import__.default)(inlineStyle, {
|
|
318
|
+
`), expect((0, import__.default)(inlineStyle, {
|
|
319
|
+
writingDirection
|
|
320
|
+
})).toMatchInlineSnapshot(`
|
|
269
321
|
[
|
|
270
322
|
"",
|
|
271
323
|
{
|
|
@@ -274,12 +326,14 @@ describe("StyleSheet", () => {
|
|
|
274
326
|
"textAlign": "right",
|
|
275
327
|
},
|
|
276
328
|
]
|
|
277
|
-
`), expect(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
329
|
+
`), expect((0, import__.default)([inlineStyle, {
|
|
330
|
+
marginLeft: 1,
|
|
331
|
+
marginEnd: 0,
|
|
332
|
+
marginStart: 0,
|
|
333
|
+
marginRight: 11
|
|
334
|
+
}], {
|
|
335
|
+
writingDirection
|
|
336
|
+
})).toMatchInlineSnapshot(`
|
|
283
337
|
[
|
|
284
338
|
"",
|
|
285
339
|
{
|
|
@@ -289,11 +343,12 @@ describe("StyleSheet", () => {
|
|
|
289
343
|
"textAlign": "right",
|
|
290
344
|
},
|
|
291
345
|
]
|
|
292
|
-
`), expect(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
346
|
+
`), expect((0, import__.default)([inlineStyle, {
|
|
347
|
+
marginEnd: null,
|
|
348
|
+
marginLeft: 11
|
|
349
|
+
}], {
|
|
350
|
+
writingDirection
|
|
351
|
+
})).toMatchInlineSnapshot(`
|
|
297
352
|
[
|
|
298
353
|
"",
|
|
299
354
|
{
|
|
@@ -309,19 +364,21 @@ describe("StyleSheet", () => {
|
|
|
309
364
|
"r-left-2s0hu9 r-textAlign-fdjqy7 r-marginRight-zso239",
|
|
310
365
|
null,
|
|
311
366
|
]
|
|
312
|
-
`), expect((0, import__.default)(staticStyle, {
|
|
367
|
+
`), expect((0, import__.default)(staticStyle, {
|
|
368
|
+
writingDirection
|
|
369
|
+
})).toMatchInlineSnapshot(`
|
|
313
370
|
[
|
|
314
371
|
"r-right-1bnbe1j r-textAlign-1ff274t r-marginLeft-1n0xq6e",
|
|
315
372
|
null,
|
|
316
373
|
]
|
|
317
|
-
`), expect(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
).toMatchInlineSnapshot(`
|
|
374
|
+
`), expect((0, import__.default)([staticStyle, {
|
|
375
|
+
marginLeft: 1,
|
|
376
|
+
marginEnd: 0,
|
|
377
|
+
marginStart: 0,
|
|
378
|
+
marginRight: 11
|
|
379
|
+
}], {
|
|
380
|
+
writingDirection
|
|
381
|
+
})).toMatchInlineSnapshot(`
|
|
325
382
|
[
|
|
326
383
|
"r-right-1bnbe1j r-textAlign-1ff274t",
|
|
327
384
|
{
|
|
@@ -329,11 +386,12 @@ describe("StyleSheet", () => {
|
|
|
329
386
|
"marginRight": "0px",
|
|
330
387
|
},
|
|
331
388
|
]
|
|
332
|
-
`), expect(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
389
|
+
`), expect((0, import__.default)([staticStyle, {
|
|
390
|
+
marginEnd: null,
|
|
391
|
+
marginLeft: 11
|
|
392
|
+
}], {
|
|
393
|
+
writingDirection
|
|
394
|
+
})).toMatchInlineSnapshot(`
|
|
337
395
|
[
|
|
338
396
|
"r-right-1bnbe1j r-textAlign-1ff274t",
|
|
339
397
|
{
|
|
@@ -343,5 +401,4 @@ describe("StyleSheet", () => {
|
|
|
343
401
|
`);
|
|
344
402
|
});
|
|
345
403
|
});
|
|
346
|
-
});
|
|
347
|
-
//# sourceMappingURL=index-test.js.map
|
|
404
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var import_preprocess = require("../preprocess.cjs");
|
|
2
|
+
describe("StyleSheet/preprocess", () => {
|
|
3
|
+
describe("preprocesses multiple shadow styles into a single declaration", () => {
|
|
4
|
+
test("shadowColor only", () => {
|
|
5
|
+
expect((0, import_preprocess.preprocess)({
|
|
6
|
+
shadowColor: "red"
|
|
7
|
+
})).toEqual({
|
|
8
|
+
boxShadow: "0px 0px 0px rgba(255,0,0,1.00)"
|
|
9
|
+
});
|
|
10
|
+
}), test("shadowColor and shadowOpacity only", () => {
|
|
11
|
+
expect((0, import_preprocess.preprocess)({
|
|
12
|
+
shadowColor: "red",
|
|
13
|
+
shadowOpacity: 0.5
|
|
14
|
+
})).toEqual({
|
|
15
|
+
boxShadow: "0px 0px 0px rgba(255,0,0,0.50)"
|
|
16
|
+
});
|
|
17
|
+
}), test("shadowOffset only", () => {
|
|
18
|
+
expect((0, import_preprocess.preprocess)({
|
|
19
|
+
shadowOffset: {
|
|
20
|
+
width: 1,
|
|
21
|
+
height: 2
|
|
22
|
+
}
|
|
23
|
+
})).toEqual({
|
|
24
|
+
boxShadow: "1px 2px 0px rgba(0,0,0,1.00)"
|
|
25
|
+
});
|
|
26
|
+
}), test("shadowRadius only", () => {
|
|
27
|
+
expect((0, import_preprocess.preprocess)({
|
|
28
|
+
shadowRadius: 5
|
|
29
|
+
})).toEqual({
|
|
30
|
+
boxShadow: "0px 0px 5px rgba(0,0,0,1.00)"
|
|
31
|
+
});
|
|
32
|
+
}), test("shadowOffset, shadowRadius, shadowColor", () => {
|
|
33
|
+
expect((0, import_preprocess.preprocess)({
|
|
34
|
+
shadowColor: "rgba(50,60,70,0.5)",
|
|
35
|
+
shadowOffset: {
|
|
36
|
+
width: 1,
|
|
37
|
+
height: 2
|
|
38
|
+
},
|
|
39
|
+
shadowOpacity: 0.5,
|
|
40
|
+
shadowRadius: 3
|
|
41
|
+
})).toEqual({
|
|
42
|
+
boxShadow: "1px 2px 3px rgba(50,60,70,0.25)"
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}), describe("preprocesses multiple textShadow styles into a single declaration", () => {
|
|
46
|
+
test("textShadowColor only", () => {
|
|
47
|
+
expect((0, import_preprocess.preprocess)({
|
|
48
|
+
textShadowColor: "red"
|
|
49
|
+
})).toEqual({});
|
|
50
|
+
}), test("textShadowOffset only", () => {
|
|
51
|
+
expect((0, import_preprocess.preprocess)({
|
|
52
|
+
textShadowOffset: {
|
|
53
|
+
width: 1,
|
|
54
|
+
height: 2
|
|
55
|
+
}
|
|
56
|
+
})).toEqual({});
|
|
57
|
+
}), test("textShadowRadius only", () => {
|
|
58
|
+
expect((0, import_preprocess.preprocess)({
|
|
59
|
+
textShadowRadius: 5
|
|
60
|
+
})).toEqual({});
|
|
61
|
+
}), test("textShadowColor and textShadowOffset only", () => {
|
|
62
|
+
expect((0, import_preprocess.preprocess)({
|
|
63
|
+
textShadowColor: "red",
|
|
64
|
+
textShadowOffset: {
|
|
65
|
+
width: 0,
|
|
66
|
+
height: 0
|
|
67
|
+
}
|
|
68
|
+
})).toEqual({}), expect((0, import_preprocess.preprocess)({
|
|
69
|
+
textShadowColor: "red",
|
|
70
|
+
textShadowOffset: {
|
|
71
|
+
width: -1,
|
|
72
|
+
height: 0
|
|
73
|
+
}
|
|
74
|
+
})).toEqual({
|
|
75
|
+
textShadow: "-1px 0px 0px rgba(255,0,0,1.00)"
|
|
76
|
+
}), expect((0, import_preprocess.preprocess)({
|
|
77
|
+
textShadowColor: "red",
|
|
78
|
+
textShadowOffset: {
|
|
79
|
+
width: 1,
|
|
80
|
+
height: 2
|
|
81
|
+
}
|
|
82
|
+
})).toEqual({
|
|
83
|
+
textShadow: "1px 2px 0px rgba(255,0,0,1.00)"
|
|
84
|
+
});
|
|
85
|
+
}), test("textShadowColor and textShadowRadius only", () => {
|
|
86
|
+
expect((0, import_preprocess.preprocess)({
|
|
87
|
+
textShadowColor: "red",
|
|
88
|
+
textShadowRadius: 0
|
|
89
|
+
})).toEqual({}), expect((0, import_preprocess.preprocess)({
|
|
90
|
+
textShadowColor: "red",
|
|
91
|
+
textShadowRadius: 5
|
|
92
|
+
})).toEqual({
|
|
93
|
+
textShadow: "0px 0px 5px rgba(255,0,0,1.00)"
|
|
94
|
+
});
|
|
95
|
+
}), test("textShadowColor, textShadowOffset, textShadowRadius", () => {
|
|
96
|
+
expect((0, import_preprocess.preprocess)({
|
|
97
|
+
textShadowColor: "rgba(50,60,70,0.50)",
|
|
98
|
+
textShadowOffset: {
|
|
99
|
+
width: 5,
|
|
100
|
+
height: 10
|
|
101
|
+
},
|
|
102
|
+
textShadowRadius: 15
|
|
103
|
+
})).toEqual({
|
|
104
|
+
textShadow: "5px 10px 15px rgba(50,60,70,0.50)"
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var import_validate = require("../validate.cjs");
|
|
2
|
+
describe("validate", () => {
|
|
3
|
+
beforeAll(() => {
|
|
4
|
+
jest.spyOn(console, "error").mockImplementation(() => {});
|
|
5
|
+
}), afterAll(() => {
|
|
6
|
+
console.error.mockRestore();
|
|
7
|
+
}), afterEach(() => {
|
|
8
|
+
console.error.mockClear();
|
|
9
|
+
}), test("invalid shortform properties", () => {
|
|
10
|
+
(0, import_validate.validate)({
|
|
11
|
+
background: "red"
|
|
12
|
+
}), (0, import_validate.validate)({
|
|
13
|
+
font: "arial"
|
|
14
|
+
}), (0, import_validate.validate)({
|
|
15
|
+
borderTop: "1px solid red"
|
|
16
|
+
}), expect(console.error).toHaveBeenCalled();
|
|
17
|
+
}), test("valid shortform values", () => {
|
|
18
|
+
(0, import_validate.validate)({
|
|
19
|
+
flex: 1
|
|
20
|
+
}), (0, import_validate.validate)({
|
|
21
|
+
margin: 10
|
|
22
|
+
}), (0, import_validate.validate)({
|
|
23
|
+
margin: "calc(10 * 1px)"
|
|
24
|
+
}), (0, import_validate.validate)({
|
|
25
|
+
margin: "calc(10 * calc(10 * 1px))"
|
|
26
|
+
}), expect(console.error).not.toHaveBeenCalled();
|
|
27
|
+
}), test("invalid shortform multi-values", () => {
|
|
28
|
+
(0, import_validate.validate)({
|
|
29
|
+
flex: "1 1 25%"
|
|
30
|
+
}), (0, import_validate.validate)({
|
|
31
|
+
margin: "10px 20px"
|
|
32
|
+
}), (0, import_validate.validate)({
|
|
33
|
+
margin: "calc(10 * 1px) var(--test)"
|
|
34
|
+
}), expect(console.error).toHaveBeenCalledTimes(3);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var createReactDOMStyle_exports = {};
|
|
33
|
+
__export(createReactDOMStyle_exports, {
|
|
34
|
+
createTransformValue: () => createTransformValue,
|
|
35
|
+
default: () => createReactDOMStyle_default
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(createReactDOMStyle_exports);
|
|
38
|
+
var import_canUseDOM = __toESM(require("../../modules/canUseDOM.cjs")),
|
|
39
|
+
import_normalizeValueWithProperty = __toESM(require("./normalizeValueWithProperty.cjs"));
|
|
40
|
+
const emptyObject = {},
|
|
41
|
+
supportsCSS3TextDecoration = !import_canUseDOM.default || window.CSS != null && window.CSS.supports != null && (window.CSS.supports("text-decoration-line", "none") || window.CSS.supports("-webkit-text-decoration-line", "none")),
|
|
42
|
+
ignoredProps = {
|
|
43
|
+
elevation: !0,
|
|
44
|
+
overlayColor: !0,
|
|
45
|
+
resizeMode: !0,
|
|
46
|
+
tintColor: !0
|
|
47
|
+
},
|
|
48
|
+
MONOSPACE_FONT_STACK = "monospace,monospace",
|
|
49
|
+
SYSTEM_FONT_STACK = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif',
|
|
50
|
+
STYLE_SHORT_FORM_EXPANSIONS = {
|
|
51
|
+
borderColor: ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"],
|
|
52
|
+
borderRadius: ["borderTopLeftRadius", "borderTopRightRadius", "borderBottomRightRadius", "borderBottomLeftRadius"],
|
|
53
|
+
borderStyle: ["borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle"],
|
|
54
|
+
borderWidth: ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"],
|
|
55
|
+
marginHorizontal: ["marginRight", "marginLeft"],
|
|
56
|
+
marginVertical: ["marginTop", "marginBottom"],
|
|
57
|
+
overflow: ["overflowX", "overflowY"],
|
|
58
|
+
overscrollBehavior: ["overscrollBehaviorX", "overscrollBehaviorY"],
|
|
59
|
+
paddingHorizontal: ["paddingRight", "paddingLeft"],
|
|
60
|
+
paddingVertical: ["paddingTop", "paddingBottom"]
|
|
61
|
+
},
|
|
62
|
+
mapTransform = transform => {
|
|
63
|
+
const type = Object.keys(transform)[0],
|
|
64
|
+
value = transform[type];
|
|
65
|
+
if (type === "matrix" || type === "matrix3d") return `${type}(${value.join(",")})`;
|
|
66
|
+
{
|
|
67
|
+
const normalizedValue = (0, import_normalizeValueWithProperty.default)(value, type);
|
|
68
|
+
return `${type}(${normalizedValue})`;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
createTransformValue = style => {
|
|
72
|
+
let transform = style.transform;
|
|
73
|
+
return Array.isArray(style.transform) && (transform = style.transform.map(mapTransform).join(" ")), transform;
|
|
74
|
+
},
|
|
75
|
+
createReactDOMStyle = (style, isInline) => {
|
|
76
|
+
if (!style) return emptyObject;
|
|
77
|
+
const resolvedStyle = {};
|
|
78
|
+
for (const prop in style) {
|
|
79
|
+
const value = style[prop];
|
|
80
|
+
if (
|
|
81
|
+
// Ignore everything with a null value
|
|
82
|
+
!(value == null ||
|
|
83
|
+
// Ignore some React Native styles
|
|
84
|
+
ignoredProps[prop])) if (prop === "aspectRatio") resolvedStyle[prop] = value.toString();else if (prop === "backgroundClip") value === "text" && (resolvedStyle.backgroundClip = value, resolvedStyle.WebkitBackgroundClip = value);else if (prop === "flex") value === -1 ? (resolvedStyle.flexGrow = 0, resolvedStyle.flexShrink = 1, resolvedStyle.flexBasis = "auto") : resolvedStyle.flex = value;else if (prop === "font") resolvedStyle[prop] = value.replace("System", SYSTEM_FONT_STACK);else if (prop === "fontFamily") {
|
|
85
|
+
if (value.indexOf("System") > -1) {
|
|
86
|
+
const stack = value.split(/,\s*/);
|
|
87
|
+
stack[stack.indexOf("System")] = SYSTEM_FONT_STACK, resolvedStyle[prop] = stack.join(",");
|
|
88
|
+
} else value === "monospace" ? resolvedStyle[prop] = MONOSPACE_FONT_STACK : resolvedStyle[prop] = value;
|
|
89
|
+
} else if (prop === "fontVariant") Array.isArray(value) && value.length > 0 && (resolvedStyle.fontVariant = value.join(" "));else if (prop === "textAlignVertical") resolvedStyle.verticalAlign = value === "center" ? "middle" : value;else if (prop === "textDecorationLine") supportsCSS3TextDecoration ? resolvedStyle.textDecorationLine = value : resolvedStyle.textDecoration = value;else if (prop === "transform" || prop === "transformMatrix") resolvedStyle.transform = createTransformValue(style);else if (prop === "writingDirection") resolvedStyle.direction = value;else {
|
|
90
|
+
const value2 = (0, import_normalizeValueWithProperty.default)(style[prop], prop),
|
|
91
|
+
longFormProperties = STYLE_SHORT_FORM_EXPANSIONS[prop];
|
|
92
|
+
isInline && prop === "margin" ? (style.marginHorizontal == null && (resolvedStyle.marginLeft = value2, resolvedStyle.marginRight = value2), style.marginVertical == null && (resolvedStyle.marginTop = value2, resolvedStyle.marginBottom = value2)) : isInline && prop === "padding" ? (style.paddingHorizontal == null && (resolvedStyle.paddingLeft = value2, resolvedStyle.paddingRight = value2), style.paddingVertical == null && (resolvedStyle.paddingTop = value2, resolvedStyle.paddingBottom = value2)) : longFormProperties ? longFormProperties.forEach((longForm, i) => {
|
|
93
|
+
style[longForm] == null && (resolvedStyle[longForm] = value2);
|
|
94
|
+
}) : resolvedStyle[prop] = Array.isArray(value2) ? value2.join(",") : value2;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return resolvedStyle;
|
|
98
|
+
};
|
|
99
|
+
var createReactDOMStyle_default = createReactDOMStyle;
|