@tamagui/react-native-web-internals 1.116.1 → 1.116.3

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