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

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 (153) 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/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.js +46 -0
  24. package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.js +30 -0
  25. package/dist/cjs/modules/AccessibilityUtil/index.js +36 -0
  26. package/dist/cjs/modules/AccessibilityUtil/isDisabled.js +22 -0
  27. package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.js +60 -0
  28. package/dist/cjs/modules/AccessibilityUtil/propsToAriaRole.js +43 -0
  29. package/dist/cjs/modules/AssetRegistry/index.js +28 -0
  30. package/dist/cjs/modules/ImageLoader/index.js +102 -0
  31. package/dist/cjs/modules/InteractionManager.js +68 -0
  32. package/dist/cjs/modules/Platform/__tests__/index-test.js +46 -0
  33. package/dist/cjs/modules/Platform/index.js +26 -0
  34. package/dist/cjs/modules/TextInputState/index.js +59 -0
  35. package/dist/cjs/modules/UIManager/__tests__/index-test.js +66 -0
  36. package/dist/cjs/modules/UIManager/index.js +101 -0
  37. package/dist/cjs/modules/canUseDOM.js +23 -0
  38. package/dist/cjs/modules/createDOMProps/__tests__/index-test.js +106 -0
  39. package/dist/cjs/modules/createDOMProps/index.js +121 -0
  40. package/dist/cjs/modules/createEventHandle/__tests__/index-test.js +242 -0
  41. package/dist/cjs/modules/createEventHandle/index.js +74 -0
  42. package/dist/cjs/modules/dismissKeyboard/index.js +33 -0
  43. package/dist/cjs/modules/forwardedProps/index.js +145 -0
  44. package/dist/cjs/modules/getBoundingClientRect/index.js +25 -0
  45. package/dist/cjs/modules/invariant.js +35 -0
  46. package/dist/cjs/modules/isSelectionValid/index.js +27 -0
  47. package/dist/cjs/modules/isWebColor/index.js +22 -0
  48. package/dist/cjs/modules/mergeRefs/__tests__/index-test.js +34 -0
  49. package/dist/cjs/modules/mergeRefs/index.js +41 -0
  50. package/dist/cjs/modules/modality/__tests__/index-test.js +20 -0
  51. package/dist/cjs/modules/modality/index.js +90 -0
  52. package/dist/cjs/modules/multiplyStyleLengthValue/__tests__/index-test.js +28 -0
  53. package/dist/cjs/modules/multiplyStyleLengthValue/index.js +28 -0
  54. package/dist/cjs/modules/normalizeColor/index.js +40 -0
  55. package/dist/cjs/modules/pick/index.js +26 -0
  56. package/dist/cjs/modules/processColor/__tests__/index-test.js +64 -0
  57. package/dist/cjs/modules/processColor/index.js +36 -0
  58. package/dist/cjs/modules/requestIdleCallback/index.js +44 -0
  59. package/dist/cjs/modules/setValueForStyles/dangerousStyleValue.js +34 -0
  60. package/dist/cjs/modules/setValueForStyles/index.js +39 -0
  61. package/dist/cjs/modules/unitlessNumbers/index.js +80 -0
  62. package/dist/cjs/modules/useElementLayout/index.js +65 -0
  63. package/dist/cjs/modules/useEvent/__tests__/index-test.js +289 -0
  64. package/dist/cjs/modules/useEvent/index.js +45 -0
  65. package/dist/cjs/modules/useHover/__tests__/index-test.js +195 -0
  66. package/dist/cjs/modules/useHover/index.js +81 -0
  67. package/dist/cjs/modules/useLayoutEffect/index.js +31 -0
  68. package/dist/cjs/modules/useLocale/index.js +54 -0
  69. package/dist/cjs/modules/useLocale/isLocaleRTL.js +91 -0
  70. package/dist/cjs/modules/useMergeRefs/__tests__/index-test.js +68 -0
  71. package/dist/cjs/modules/useMergeRefs/index.js +36 -0
  72. package/dist/cjs/modules/usePlatformMethods/index.js +39 -0
  73. package/dist/cjs/modules/useStable/__tests__/index-test.js +69 -0
  74. package/dist/cjs/modules/useStable/index.js +34 -0
  75. package/dist/cjs/styleTypes.js +14 -0
  76. package/dist/cjs/types.js +14 -0
  77. package/package.json +7 -7
  78. /package/dist/cjs/StyleSheet/__tests__/{compiler-createReactDOMStyle-test.cjs.map → compiler-createReactDOMStyle-test.js.map} +0 -0
  79. /package/dist/cjs/StyleSheet/__tests__/{compiler-test.cjs.map → compiler-test.js.map} +0 -0
  80. /package/dist/cjs/StyleSheet/__tests__/{dom-createOrderedCSSStyleSheet-test.cjs.map → dom-createOrderedCSSStyleSheet-test.js.map} +0 -0
  81. /package/dist/cjs/StyleSheet/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  82. /package/dist/cjs/StyleSheet/__tests__/{preprocess-test.cjs.map → preprocess-test.js.map} +0 -0
  83. /package/dist/cjs/StyleSheet/__tests__/{validate-test.cjs.map → validate-test.js.map} +0 -0
  84. /package/dist/cjs/StyleSheet/compiler/{createReactDOMStyle.cjs.map → createReactDOMStyle.js.map} +0 -0
  85. /package/dist/cjs/StyleSheet/compiler/{hash.cjs.map → hash.js.map} +0 -0
  86. /package/dist/cjs/StyleSheet/compiler/{hyphenateStyleName.cjs.map → hyphenateStyleName.js.map} +0 -0
  87. /package/dist/cjs/StyleSheet/compiler/{index.cjs.map → index.js.map} +0 -0
  88. /package/dist/cjs/StyleSheet/compiler/{normalizeColor.cjs.map → normalizeColor.js.map} +0 -0
  89. /package/dist/cjs/StyleSheet/compiler/{normalizeValueWithProperty.cjs.map → normalizeValueWithProperty.js.map} +0 -0
  90. /package/dist/cjs/StyleSheet/compiler/{resolveShadowValue.cjs.map → resolveShadowValue.js.map} +0 -0
  91. /package/dist/cjs/StyleSheet/dom/{createCSSStyleSheet.cjs.map → createCSSStyleSheet.js.map} +0 -0
  92. /package/dist/cjs/StyleSheet/dom/{createOrderedCSSStyleSheet.cjs.map → createOrderedCSSStyleSheet.js.map} +0 -0
  93. /package/dist/cjs/StyleSheet/dom/{index.cjs.map → index.js.map} +0 -0
  94. /package/dist/cjs/StyleSheet/{index.cjs.map → index.js.map} +0 -0
  95. /package/dist/cjs/StyleSheet/{preprocess.cjs.map → preprocess.js.map} +0 -0
  96. /package/dist/cjs/StyleSheet/{validate.cjs.map → validate.js.map} +0 -0
  97. /package/dist/cjs/{TextAncestorContext.cjs.map → TextAncestorContext.js.map} +0 -0
  98. /package/dist/cjs/{colorProps.cjs.map → colorProps.js.map} +0 -0
  99. /package/dist/cjs/{index.cjs.map → index.js.map} +0 -0
  100. /package/dist/cjs/modules/AccessibilityUtil/__tests__/{propsToAccessibilityComponent-test.cjs.map → propsToAccessibilityComponent-test.js.map} +0 -0
  101. /package/dist/cjs/modules/AccessibilityUtil/__tests__/{propsToAriaRole-test.cjs.map → propsToAriaRole-test.js.map} +0 -0
  102. /package/dist/cjs/modules/AccessibilityUtil/{index.cjs.map → index.js.map} +0 -0
  103. /package/dist/cjs/modules/AccessibilityUtil/{isDisabled.cjs.map → isDisabled.js.map} +0 -0
  104. /package/dist/cjs/modules/AccessibilityUtil/{propsToAccessibilityComponent.cjs.map → propsToAccessibilityComponent.js.map} +0 -0
  105. /package/dist/cjs/modules/AccessibilityUtil/{propsToAriaRole.cjs.map → propsToAriaRole.js.map} +0 -0
  106. /package/dist/cjs/modules/AssetRegistry/{index.cjs.map → index.js.map} +0 -0
  107. /package/dist/cjs/modules/ImageLoader/{index.cjs.map → index.js.map} +0 -0
  108. /package/dist/cjs/modules/{InteractionManager.cjs.map → InteractionManager.js.map} +0 -0
  109. /package/dist/cjs/modules/Platform/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  110. /package/dist/cjs/modules/Platform/{index.cjs.map → index.js.map} +0 -0
  111. /package/dist/cjs/modules/TextInputState/{index.cjs.map → index.js.map} +0 -0
  112. /package/dist/cjs/modules/UIManager/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  113. /package/dist/cjs/modules/UIManager/{index.cjs.map → index.js.map} +0 -0
  114. /package/dist/cjs/modules/{canUseDOM.cjs.map → canUseDOM.js.map} +0 -0
  115. /package/dist/cjs/modules/createDOMProps/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  116. /package/dist/cjs/modules/createDOMProps/{index.cjs.map → index.js.map} +0 -0
  117. /package/dist/cjs/modules/createEventHandle/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  118. /package/dist/cjs/modules/createEventHandle/{index.cjs.map → index.js.map} +0 -0
  119. /package/dist/cjs/modules/dismissKeyboard/{index.cjs.map → index.js.map} +0 -0
  120. /package/dist/cjs/modules/forwardedProps/{index.cjs.map → index.js.map} +0 -0
  121. /package/dist/cjs/modules/getBoundingClientRect/{index.cjs.map → index.js.map} +0 -0
  122. /package/dist/cjs/modules/{invariant.cjs.map → invariant.js.map} +0 -0
  123. /package/dist/cjs/modules/isSelectionValid/{index.cjs.map → index.js.map} +0 -0
  124. /package/dist/cjs/modules/isWebColor/{index.cjs.map → index.js.map} +0 -0
  125. /package/dist/cjs/modules/mergeRefs/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  126. /package/dist/cjs/modules/mergeRefs/{index.cjs.map → index.js.map} +0 -0
  127. /package/dist/cjs/modules/modality/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  128. /package/dist/cjs/modules/modality/{index.cjs.map → index.js.map} +0 -0
  129. /package/dist/cjs/modules/multiplyStyleLengthValue/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  130. /package/dist/cjs/modules/multiplyStyleLengthValue/{index.cjs.map → index.js.map} +0 -0
  131. /package/dist/cjs/modules/normalizeColor/{index.cjs.map → index.js.map} +0 -0
  132. /package/dist/cjs/modules/pick/{index.cjs.map → index.js.map} +0 -0
  133. /package/dist/cjs/modules/processColor/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  134. /package/dist/cjs/modules/processColor/{index.cjs.map → index.js.map} +0 -0
  135. /package/dist/cjs/modules/requestIdleCallback/{index.cjs.map → index.js.map} +0 -0
  136. /package/dist/cjs/modules/setValueForStyles/{dangerousStyleValue.cjs.map → dangerousStyleValue.js.map} +0 -0
  137. /package/dist/cjs/modules/setValueForStyles/{index.cjs.map → index.js.map} +0 -0
  138. /package/dist/cjs/modules/unitlessNumbers/{index.cjs.map → index.js.map} +0 -0
  139. /package/dist/cjs/modules/useElementLayout/{index.cjs.map → index.js.map} +0 -0
  140. /package/dist/cjs/modules/useEvent/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  141. /package/dist/cjs/modules/useEvent/{index.cjs.map → index.js.map} +0 -0
  142. /package/dist/cjs/modules/useHover/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  143. /package/dist/cjs/modules/useHover/{index.cjs.map → index.js.map} +0 -0
  144. /package/dist/cjs/modules/useLayoutEffect/{index.cjs.map → index.js.map} +0 -0
  145. /package/dist/cjs/modules/useLocale/{index.cjs.map → index.js.map} +0 -0
  146. /package/dist/cjs/modules/useLocale/{isLocaleRTL.cjs.map → isLocaleRTL.js.map} +0 -0
  147. /package/dist/cjs/modules/useMergeRefs/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  148. /package/dist/cjs/modules/useMergeRefs/{index.cjs.map → index.js.map} +0 -0
  149. /package/dist/cjs/modules/usePlatformMethods/{index.cjs.map → index.js.map} +0 -0
  150. /package/dist/cjs/modules/useStable/__tests__/{index-test.cjs.map → index-test.js.map} +0 -0
  151. /package/dist/cjs/modules/useStable/{index.cjs.map → index.js.map} +0 -0
  152. /package/dist/cjs/{styleTypes.cjs.map → styleTypes.js.map} +0 -0
  153. /package/dist/cjs/{types.cjs.map → types.js.map} +0 -0
@@ -0,0 +1,192 @@
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_createReactDOMStyle = __toESM(require("../compiler/createReactDOMStyle"));
21
+ const reactNativeStyle = {
22
+ boxShadow: "1px 1px 1px 1px #000",
23
+ borderWidthLeft: 2,
24
+ borderWidth: 1,
25
+ borderWidthRight: 3,
26
+ display: "flex",
27
+ marginVertical: 0,
28
+ opacity: 0,
29
+ shadowColor: "red",
30
+ shadowOffset: { width: 1, height: 2 },
31
+ resizeMode: "contain"
32
+ };
33
+ describe("compiler/createReactDOMStyle", () => {
34
+ test("noop on DOM styles", () => {
35
+ const firstStyle = (0, import_createReactDOMStyle.default)(reactNativeStyle), secondStyle = (0, import_createReactDOMStyle.default)(firstStyle);
36
+ expect(firstStyle).toEqual(secondStyle);
37
+ }), test("shortform -> longform for inline styles", () => {
38
+ const style = {
39
+ borderStyle: "solid",
40
+ boxSizing: "border-box",
41
+ borderBottomColor: "white",
42
+ borderBottomWidth: 1,
43
+ borderWidth: 0,
44
+ marginTop: 50,
45
+ marginVertical: 25,
46
+ margin: 10,
47
+ overflow: "hidden",
48
+ overscrollBehavior: "contain",
49
+ paddingLeft: 50,
50
+ paddingHorizontal: 25,
51
+ padding: 10
52
+ };
53
+ expect((0, import_createReactDOMStyle.default)(style, !0)).toMatchInlineSnapshot(`
54
+ {
55
+ "borderBottomColor": "rgba(255,255,255,1.00)",
56
+ "borderBottomStyle": "solid",
57
+ "borderBottomWidth": "1px",
58
+ "borderLeftStyle": "solid",
59
+ "borderLeftWidth": "0px",
60
+ "borderRightStyle": "solid",
61
+ "borderRightWidth": "0px",
62
+ "borderTopStyle": "solid",
63
+ "borderTopWidth": "0px",
64
+ "boxSizing": "border-box",
65
+ "marginBottom": "25px",
66
+ "marginLeft": "10px",
67
+ "marginRight": "10px",
68
+ "marginTop": "50px",
69
+ "overflowX": "hidden",
70
+ "overflowY": "hidden",
71
+ "overscrollBehaviorX": "contain",
72
+ "overscrollBehaviorY": "contain",
73
+ "paddingBottom": "10px",
74
+ "paddingLeft": "50px",
75
+ "paddingRight": "25px",
76
+ "paddingTop": "10px",
77
+ }
78
+ `);
79
+ }), test("aspectRatio", () => {
80
+ expect((0, import_createReactDOMStyle.default)({ aspectRatio: 9 / 16 })).toEqual({
81
+ aspectRatio: "0.5625"
82
+ });
83
+ }), describe("flexbox styles", () => {
84
+ test("flex: -1", () => {
85
+ expect((0, import_createReactDOMStyle.default)({ flex: -1 })).toEqual({
86
+ flexGrow: 0,
87
+ flexShrink: 1,
88
+ flexBasis: "auto"
89
+ });
90
+ }), test("flex: 0", () => {
91
+ expect((0, import_createReactDOMStyle.default)({ flex: 0 })).toEqual({
92
+ flex: 0
93
+ });
94
+ }), test("flex: 1", () => {
95
+ expect((0, import_createReactDOMStyle.default)({ flex: 1 })).toEqual({
96
+ flex: 1
97
+ });
98
+ }), test("flex: 10", () => {
99
+ expect((0, import_createReactDOMStyle.default)({ flex: 10 })).toEqual({
100
+ flex: 10
101
+ });
102
+ }), test("flexBasis overrides", () => {
103
+ expect((0, import_createReactDOMStyle.default)({ flexBasis: "25%" })).toEqual({
104
+ flexBasis: "25%"
105
+ }), expect((0, import_createReactDOMStyle.default)({ flex: 1, flexBasis: "25%" })).toEqual({
106
+ flex: 1,
107
+ flexBasis: "25%"
108
+ });
109
+ }), test("flexShrink overrides", () => {
110
+ expect((0, import_createReactDOMStyle.default)({ flexShrink: 1 })).toEqual({
111
+ flexShrink: 1
112
+ }), expect((0, import_createReactDOMStyle.default)({ flex: 1, flexShrink: 2 })).toEqual({
113
+ flex: 1,
114
+ flexShrink: 2
115
+ });
116
+ });
117
+ }), describe("fontFamily", () => {
118
+ test("general case", () => {
119
+ expect((0, import_createReactDOMStyle.default)({ fontFamily: "Georgia, Times, serif" })).toMatchInlineSnapshot(`
120
+ {
121
+ "fontFamily": "Georgia, Times, serif",
122
+ }
123
+ `);
124
+ }), test('"monospace"', () => {
125
+ expect((0, import_createReactDOMStyle.default)({ fontFamily: "monospace" })).toMatchInlineSnapshot(`
126
+ {
127
+ "fontFamily": "monospace,monospace",
128
+ }
129
+ `);
130
+ }), test('"System"', () => {
131
+ expect((0, import_createReactDOMStyle.default)({ fontFamily: "System" })).toMatchInlineSnapshot(`
132
+ {
133
+ "fontFamily": "-apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif",
134
+ }
135
+ `), expect((0, import_createReactDOMStyle.default)({ font: "14px System" })).toMatchInlineSnapshot(`
136
+ {
137
+ "font": "14px -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif",
138
+ }
139
+ `);
140
+ }), test('"Noto, System"', () => {
141
+ expect((0, import_createReactDOMStyle.default)({ fontFamily: "Noto, System" })).toMatchInlineSnapshot(`
142
+ {
143
+ "fontFamily": "Noto,-apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif",
144
+ }
145
+ `), expect((0, import_createReactDOMStyle.default)({ font: "14px Noto, System" })).toMatchInlineSnapshot(`
146
+ {
147
+ "font": "14px Noto, -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif",
148
+ }
149
+ `);
150
+ }), test('"Noto, BlinkMacSystemFont"', () => {
151
+ expect((0, import_createReactDOMStyle.default)({ fontFamily: "Noto, BlinkMacSystemFont" })).toMatchInlineSnapshot(`
152
+ {
153
+ "fontFamily": "Noto,BlinkMacSystemFont",
154
+ }
155
+ `);
156
+ });
157
+ }), test("fontVariant", () => {
158
+ expect(
159
+ (0, import_createReactDOMStyle.default)({ fontVariant: ["common-ligatures", "small-caps"] })
160
+ ).toEqual({
161
+ fontVariant: "common-ligatures small-caps"
162
+ });
163
+ }), test("textAlignVertical", () => {
164
+ expect(
165
+ (0, import_createReactDOMStyle.default)({
166
+ textAlignVertical: "center"
167
+ })
168
+ ).toEqual({
169
+ verticalAlign: "middle"
170
+ });
171
+ }), describe("transform", () => {
172
+ test("string", () => {
173
+ const transform = "perspective(50px) scaleX(20) translateX(20px) rotate(20deg)", resolved = (0, import_createReactDOMStyle.default)({ transform });
174
+ expect(resolved).toEqual({ transform });
175
+ }), test("array", () => {
176
+ const resolved = (0, import_createReactDOMStyle.default)({
177
+ transform: [
178
+ { perspective: 50 },
179
+ { scaleX: 20 },
180
+ { translateX: 20 },
181
+ { rotate: "20deg" },
182
+ { matrix: [1, 2, 3, 4, 5, 6] },
183
+ { matrix3d: [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4] }
184
+ ]
185
+ });
186
+ expect(resolved).toEqual({
187
+ transform: "perspective(50px) scaleX(20) translateX(20px) rotate(20deg) matrix(1,2,3,4,5,6) matrix3d(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4)"
188
+ });
189
+ });
190
+ });
191
+ });
192
+ //# sourceMappingURL=compiler-createReactDOMStyle-test.js.map
@@ -0,0 +1,378 @@
1
+ var import_compiler = require("../compiler");
2
+ describe("StyleSheet/compile", () => {
3
+ describe("atomic", () => {
4
+ test("converts style to atomic CSS", () => {
5
+ const result = (0, import_compiler.atomic)({
6
+ animationDirection: ["alternate", "alternate-reverse"],
7
+ animationKeyframes: [
8
+ { "0%": { top: 0 }, "50%": { top: 5 }, "100%": { top: 10 } },
9
+ { from: { left: 0 }, to: { left: 10 } }
10
+ ],
11
+ fontFamily: "System",
12
+ marginHorizontal: 10,
13
+ marginStart: 1,
14
+ marginEnd: 2,
15
+ placeholderTextColor: "gray",
16
+ scrollbarWidth: "none",
17
+ pointerEvents: "box-only",
18
+ start: "12.34%",
19
+ textAlign: "start",
20
+ transform: [
21
+ {
22
+ translateX: 50,
23
+ scale: -1
24
+ }
25
+ ]
26
+ });
27
+ expect(result).toMatchInlineSnapshot(`
28
+ [
29
+ {
30
+ "$$css": true,
31
+ "$$css$localize": true,
32
+ "animationDirection": "r-animationDirection-1kmv48j",
33
+ "animationKeyframes": "r-animationKeyframes-zacbmr",
34
+ "fontFamily": "r-fontFamily-1qd0xha",
35
+ "marginEnd": [
36
+ "r-marginRight-a5pmau",
37
+ "r-marginLeft-9cviqr",
38
+ ],
39
+ "marginHorizontal": "r-marginHorizontal-vlx1xi",
40
+ "marginStart": [
41
+ "r-marginLeft-13kc5u0",
42
+ "r-marginRight-1knfw1x",
43
+ ],
44
+ "placeholderTextColor": "r-placeholderTextColor-1418aci",
45
+ "pointerEvents": "r-pointerEvents-ah5dr5",
46
+ "scrollbarWidth": "r-scrollbarWidth-2eszeu",
47
+ "start": [
48
+ "r-left-2s0hu9",
49
+ "r-right-1bnbe1j",
50
+ ],
51
+ "textAlign": [
52
+ "r-textAlign-fdjqy7",
53
+ "r-textAlign-1ff274t",
54
+ ],
55
+ "transform": "r-transform-1ehiua4",
56
+ },
57
+ [
58
+ [
59
+ [
60
+ ".r-animationDirection-1kmv48j{animation-direction:alternate,alternate-reverse;}",
61
+ ],
62
+ 2.2,
63
+ ],
64
+ [
65
+ [
66
+ ".r-animationKeyframes-zacbmr{animation-name:r-animation-8jhqzh,r-animation-5azpl5;}",
67
+ "@-webkit-keyframes r-animation-8jhqzh{0%{top:0px;}50%{top:5px;}100%{top:10px;}}",
68
+ "@keyframes r-animation-8jhqzh{0%{top:0px;}50%{top:5px;}100%{top:10px;}}",
69
+ "@-webkit-keyframes r-animation-5azpl5{from{left:0px;}to{left:10px;}}",
70
+ "@keyframes r-animation-5azpl5{from{left:0px;}to{left:10px;}}",
71
+ ],
72
+ 2.2,
73
+ ],
74
+ [
75
+ [
76
+ ".r-fontFamily-1qd0xha{font-family:-apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif;}",
77
+ ],
78
+ 2.2,
79
+ ],
80
+ [
81
+ [
82
+ ".r-marginRight-a5pmau{margin-right:2px;}",
83
+ ],
84
+ 2.2,
85
+ ],
86
+ [
87
+ [
88
+ ".r-marginLeft-9cviqr{margin-left:2px;}",
89
+ ],
90
+ 2.2,
91
+ ],
92
+ [
93
+ [
94
+ ".r-marginHorizontal-vlx1xi{margin-left:10px;margin-right:10px;}",
95
+ ],
96
+ 2.1,
97
+ ],
98
+ [
99
+ [
100
+ ".r-marginLeft-13kc5u0{margin-left:1px;}",
101
+ ],
102
+ 2.2,
103
+ ],
104
+ [
105
+ [
106
+ ".r-marginRight-1knfw1x{margin-right:1px;}",
107
+ ],
108
+ 2.2,
109
+ ],
110
+ [
111
+ [
112
+ ".r-placeholderTextColor-1418aci::-webkit-input-placeholder{color:rgba(128,128,128,1.00);opacity:1;}",
113
+ ".r-placeholderTextColor-1418aci::-moz-placeholder{color:rgba(128,128,128,1.00);opacity:1;}",
114
+ ".r-placeholderTextColor-1418aci:-ms-input-placeholder{color:rgba(128,128,128,1.00);opacity:1;}",
115
+ ".r-placeholderTextColor-1418aci::placeholder{color:rgba(128,128,128,1.00);opacity:1;}",
116
+ ],
117
+ 2.2,
118
+ ],
119
+ [
120
+ [
121
+ ".r-pointerEvents-ah5dr5>*{pointer-events:none;}",
122
+ ".r-pointerEvents-ah5dr5{pointer-events:auto!important;}",
123
+ ],
124
+ 2.2,
125
+ ],
126
+ [
127
+ [
128
+ ".r-scrollbarWidth-2eszeu::-webkit-scrollbar{display:none}",
129
+ ".r-scrollbarWidth-2eszeu{scrollbar-width:none;}",
130
+ ],
131
+ 2.2,
132
+ ],
133
+ [
134
+ [
135
+ ".r-left-2s0hu9{left:12.34%;}",
136
+ ],
137
+ 2.2,
138
+ ],
139
+ [
140
+ [
141
+ ".r-right-1bnbe1j{right:12.34%;}",
142
+ ],
143
+ 2.2,
144
+ ],
145
+ [
146
+ [
147
+ ".r-textAlign-fdjqy7{text-align:left;}",
148
+ ],
149
+ 2.2,
150
+ ],
151
+ [
152
+ [
153
+ ".r-textAlign-1ff274t{text-align:right;}",
154
+ ],
155
+ 2.2,
156
+ ],
157
+ [
158
+ [
159
+ ".r-transform-1ehiua4{transform:translateX(50px);}",
160
+ ],
161
+ 2.2,
162
+ ],
163
+ ],
164
+ ]
165
+ `);
166
+ });
167
+ }), describe("classic", () => {
168
+ test("converts style to classic CSS", () => {
169
+ const result = (0, import_compiler.classic)(
170
+ {
171
+ animationDirection: ["alternate", "alternate-reverse"],
172
+ animationKeyframes: [
173
+ { "0%": { top: 0 }, "50%": { top: 5 }, "100%": { top: 10 } },
174
+ { from: { left: 0 }, to: { left: 10 } }
175
+ ],
176
+ marginHorizontal: 10,
177
+ font: "14px System",
178
+ transform: [
179
+ {
180
+ translateX: 50,
181
+ scale: -1
182
+ }
183
+ ]
184
+ },
185
+ "text"
186
+ );
187
+ expect(result).toMatchInlineSnapshot(`
188
+ [
189
+ {
190
+ "$$css": true,
191
+ "css-text-1jr0ypv": "css-text-1jr0ypv",
192
+ },
193
+ [
194
+ [
195
+ [
196
+ "@-webkit-keyframes r-animation-8jhqzh{0%{top:0px;}50%{top:5px;}100%{top:10px;}}",
197
+ "@keyframes r-animation-8jhqzh{0%{top:0px;}50%{top:5px;}100%{top:10px;}}",
198
+ "@-webkit-keyframes r-animation-5azpl5{from{left:0px;}to{left:10px;}}",
199
+ "@keyframes r-animation-5azpl5{from{left:0px;}to{left:10px;}}",
200
+ ".css-text-1jr0ypv{animation-direction:alternate,alternate-reverse;animation-name:r-animation-8jhqzh,r-animation-5azpl5;font:14px -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif;margin-left:10px;margin-right:10px;transform:translateX(50px);}",
201
+ ],
202
+ 1,
203
+ ],
204
+ ],
205
+ ]
206
+ `);
207
+ });
208
+ }), describe("inline", () => {
209
+ test("converts style to inline styles", () => {
210
+ const result = (0, import_compiler.inline)({
211
+ marginHorizontal: 10,
212
+ display: "flex",
213
+ flexShrink: 1
214
+ });
215
+ expect(result).toMatchInlineSnapshot(`
216
+ {
217
+ "display": "flex",
218
+ "flexShrink": 1,
219
+ "marginLeft": "10px",
220
+ "marginRight": "10px",
221
+ }
222
+ `);
223
+ }), describe("logical style polyfill", () => {
224
+ [!1, !0].forEach((isRTL) => {
225
+ const dir = isRTL ? "rtl" : "ltr";
226
+ test(`ignores "left" properties for ${dir}`, () => {
227
+ const initial = {
228
+ borderLeftColor: "rgba(255,0,0,1.00)",
229
+ borderLeftStyle: "solid",
230
+ borderLeftWidth: "1px",
231
+ left: "1px",
232
+ marginLeft: "5px",
233
+ paddingLeft: "10px"
234
+ };
235
+ expect((0, import_compiler.inline)(initial, isRTL)).toEqual(initial);
236
+ }), test(`ignores "right" properties for ${dir}`, () => {
237
+ const initial = {
238
+ borderRightColor: "rgba(255,0,0,1.00)",
239
+ borderRightStyle: "solid",
240
+ borderRightWidth: "1px",
241
+ right: "1px",
242
+ marginRight: "5px",
243
+ paddingRight: "10px"
244
+ };
245
+ expect((0, import_compiler.inline)(initial, isRTL)).toEqual(initial);
246
+ }), test(`ignores "left" values for ${dir}`, () => {
247
+ const initial = {
248
+ clear: "left",
249
+ float: "left",
250
+ textAlign: "left",
251
+ transitionProperty: "left"
252
+ };
253
+ expect((0, import_compiler.inline)(initial, isRTL)).toEqual(initial);
254
+ }), test(`ignores "right" values for ${dir}`, () => {
255
+ const initial = {
256
+ clear: "right",
257
+ float: "right",
258
+ textAlign: "right",
259
+ transitionProperty: "right"
260
+ };
261
+ expect((0, import_compiler.inline)(initial, isRTL)).toEqual(initial);
262
+ }), test(`converts "start" properties for ${dir}`, () => {
263
+ const initial = {
264
+ borderStartColor: "red",
265
+ borderStartStyle: "solid",
266
+ borderStartWidth: 1,
267
+ start: 1,
268
+ marginStart: 5,
269
+ paddingStart: 10
270
+ }, expectedLTR = {
271
+ borderLeftColor: "rgba(255,0,0,1.00)",
272
+ borderLeftStyle: "solid",
273
+ borderLeftWidth: "1px",
274
+ left: "1px",
275
+ marginLeft: "5px",
276
+ paddingLeft: "10px"
277
+ }, expectedRTL = {
278
+ borderRightColor: "rgba(255,0,0,1.00)",
279
+ borderRightStyle: "solid",
280
+ borderRightWidth: "1px",
281
+ right: "1px",
282
+ marginRight: "5px",
283
+ paddingRight: "10px"
284
+ };
285
+ expect((0, import_compiler.inline)(initial, isRTL)).toEqual(isRTL ? expectedRTL : expectedLTR);
286
+ }), test(`converts "end" properties for ${dir}`, () => {
287
+ const initial = {
288
+ borderEndColor: "red",
289
+ borderEndStyle: "solid",
290
+ borderEndWidth: 1,
291
+ end: 1,
292
+ marginEnd: 5,
293
+ paddingEnd: 10
294
+ }, expectedLTR = {
295
+ borderRightColor: "rgba(255,0,0,1.00)",
296
+ borderRightStyle: "solid",
297
+ borderRightWidth: "1px",
298
+ right: "1px",
299
+ marginRight: "5px",
300
+ paddingRight: "10px"
301
+ }, expectedRTL = {
302
+ borderLeftColor: "rgba(255,0,0,1.00)",
303
+ borderLeftStyle: "solid",
304
+ borderLeftWidth: "1px",
305
+ left: "1px",
306
+ marginLeft: "5px",
307
+ paddingLeft: "10px"
308
+ };
309
+ expect((0, import_compiler.inline)(initial, isRTL)).toEqual(isRTL ? expectedRTL : expectedLTR);
310
+ }), test(`converts "start" values for ${dir}`, () => {
311
+ const initial = {
312
+ clear: "start",
313
+ float: "start",
314
+ textAlign: "start",
315
+ transitionProperty: "start"
316
+ }, expectedLTR = {
317
+ clear: "left",
318
+ float: "left",
319
+ textAlign: "left",
320
+ transitionProperty: "left"
321
+ }, expectedRTL = {
322
+ clear: "right",
323
+ float: "right",
324
+ textAlign: "right",
325
+ transitionProperty: "right"
326
+ };
327
+ expect((0, import_compiler.inline)(initial, isRTL)).toEqual(isRTL ? expectedRTL : expectedLTR);
328
+ }), test(`converts "end" values for ${dir}`, () => {
329
+ const initial = {
330
+ clear: "end",
331
+ float: "end",
332
+ textAlign: "end",
333
+ transitionProperty: "end"
334
+ }, expectedLTR = {
335
+ clear: "right",
336
+ float: "right",
337
+ textAlign: "right",
338
+ transitionProperty: "right"
339
+ }, expectedRTL = {
340
+ clear: "left",
341
+ float: "left",
342
+ textAlign: "left",
343
+ transitionProperty: "left"
344
+ };
345
+ expect((0, import_compiler.inline)(initial, isRTL)).toEqual(isRTL ? expectedRTL : expectedLTR);
346
+ }), test("end/start properties take precedence over left/right", () => {
347
+ const initialLTR = {
348
+ borderStartWidth: 10,
349
+ borderLeftWidth: 0,
350
+ end: 10,
351
+ right: 0,
352
+ marginStart: 10,
353
+ marginLeft: 0
354
+ }, expectedLTR = {
355
+ borderLeftWidth: "10px",
356
+ marginLeft: "10px",
357
+ right: "10px"
358
+ }, initialRTL = {
359
+ borderStartWidth: 10,
360
+ borderRightWidth: 0,
361
+ end: 10,
362
+ left: 0,
363
+ marginStart: 10,
364
+ marginRight: 0
365
+ }, expectedRTL = {
366
+ borderRightWidth: "10px",
367
+ marginRight: "10px",
368
+ left: "10px"
369
+ };
370
+ expect((0, import_compiler.inline)(isRTL ? initialRTL : initialLTR, isRTL)).toEqual(
371
+ isRTL ? expectedRTL : expectedLTR
372
+ );
373
+ });
374
+ });
375
+ });
376
+ });
377
+ });
378
+ //# sourceMappingURL=compiler-test.js.map
@@ -0,0 +1,117 @@
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_createOrderedCSSStyleSheet = __toESM(require("../dom/createOrderedCSSStyleSheet"));
21
+ const insertStyleElement = () => {
22
+ const element = document.createElement("style"), head = document.head;
23
+ return head.insertBefore(element, head.firstChild), element;
24
+ }, removeStyleElement = (element) => {
25
+ document.head.removeChild(element);
26
+ };
27
+ describe("createOrderedCSSStyleSheet", () => {
28
+ describe("#insert", () => {
29
+ test("insertion order for same group", () => {
30
+ const sheet = (0, import_createOrderedCSSStyleSheet.default)();
31
+ expect(sheet.getTextContent()).toMatchInlineSnapshot('""'), sheet.insert(".a {}", 0), expect(sheet.getTextContent()).toMatchInlineSnapshot(`
32
+ "[stylesheet-group=\\"0\\"]{}
33
+ .a {}"
34
+ `), sheet.insert(".b {}", 0), expect(sheet.getTextContent()).toMatchInlineSnapshot(`
35
+ "[stylesheet-group=\\"0\\"]{}
36
+ .a {}
37
+ .b {}"
38
+ `), sheet.insert(".c {}", 0), expect(sheet.getTextContent()).toMatchInlineSnapshot(`
39
+ "[stylesheet-group=\\"0\\"]{}
40
+ .a {}
41
+ .b {}
42
+ .c {}"
43
+ `);
44
+ }), test("deduplication for same group", () => {
45
+ const sheet = (0, import_createOrderedCSSStyleSheet.default)();
46
+ sheet.insert(".a {}", 0), sheet.insert(".a {}", 0), sheet.insert(".a {}", 0), expect(sheet.getTextContent()).toMatchInlineSnapshot(`
47
+ "[stylesheet-group=\\"0\\"]{}
48
+ .a {}"
49
+ `);
50
+ }), test("order for same group", () => {
51
+ const sheet = (0, import_createOrderedCSSStyleSheet.default)();
52
+ sheet.insert(".c {}", 0), sheet.insert(".b {}", 0), sheet.insert(".a {}", 0), expect(sheet.getTextContent()).toMatchInlineSnapshot(`
53
+ "[stylesheet-group=\\"0\\"]{}
54
+ .a {}
55
+ .b {}
56
+ .c {}"
57
+ `);
58
+ }), test("insertion order for different groups", () => {
59
+ const sheet = (0, import_createOrderedCSSStyleSheet.default)();
60
+ sheet.insert(".nine-1 {}", 9.9), sheet.insert(".nine-2 {}", 9.9), sheet.insert(".three {}", 3), sheet.insert(".one {}", 1), sheet.insert(".two {}", 2.2), sheet.insert(".four-1 {}", 4), sheet.insert(".four-2 {}", 4), sheet.insert(".twenty {}", 20), sheet.insert(".ten {}", 10), sheet.insert(".twenty-point2 {}", 20.2), expect(sheet.getTextContent()).toMatchInlineSnapshot(`
61
+ "[stylesheet-group=\\"1\\"]{}
62
+ .one {}
63
+ [stylesheet-group=\\"2.2\\"]{}
64
+ .two {}
65
+ [stylesheet-group=\\"3\\"]{}
66
+ .three {}
67
+ [stylesheet-group=\\"4\\"]{}
68
+ .four-1 {}
69
+ .four-2 {}
70
+ [stylesheet-group=\\"9.9\\"]{}
71
+ .nine-1 {}
72
+ .nine-2 {}
73
+ [stylesheet-group=\\"10\\"]{}
74
+ .ten {}
75
+ [stylesheet-group=\\"20\\"]{}
76
+ .twenty {}
77
+ [stylesheet-group=\\"20.2\\"]{}
78
+ .twenty-point2 {}"
79
+ `);
80
+ });
81
+ }), describe("client-side hydration", () => {
82
+ let element;
83
+ beforeEach(() => {
84
+ element != null && removeStyleElement(element), element = insertStyleElement();
85
+ }), test("from SSR CSS", () => {
86
+ const serverSheet = (0, import_createOrderedCSSStyleSheet.default)();
87
+ serverSheet.insert(".one { width: 10px; }", 1), serverSheet.insert(".two-1 { height: 20px; }", 2), serverSheet.insert(".two-2 { color: red; }", 2), serverSheet.insert("@keyframes anim { 0% { opacity: 1; } }", 2);
88
+ const textContent = serverSheet.getTextContent();
89
+ element.appendChild(document.createTextNode(textContent));
90
+ const clientSheet = (0, import_createOrderedCSSStyleSheet.default)(element.sheet);
91
+ expect(clientSheet.getTextContent()).toMatchInlineSnapshot(`
92
+ "[stylesheet-group=\\"1\\"] {}
93
+ .one {width: 10px;}
94
+ [stylesheet-group=\\"2\\"] {}
95
+ .two-1 {height: 20px;}
96
+ .two-2 {color: red;}
97
+ @keyframes anim {
98
+ 0% {opacity: 1;}
99
+ }"
100
+ `);
101
+ }), test("works when the group marker is in single quotes", () => {
102
+ const serverSheet = (0, import_createOrderedCSSStyleSheet.default)();
103
+ serverSheet.insert(".a { color: red }", 0), serverSheet.insert(".b { color: red }", 1);
104
+ const textContent = serverSheet.getTextContent().replace(/"/g, "'");
105
+ element.appendChild(document.createTextNode(textContent));
106
+ const clientSheet = (0, import_createOrderedCSSStyleSheet.default)(element.sheet);
107
+ clientSheet.insert(".c { color: red }", 0), expect(clientSheet.getTextContent()).toMatchInlineSnapshot(`
108
+ "[stylesheet-group='0'] {}
109
+ .a {color: red;}
110
+ .c { color: red }
111
+ [stylesheet-group='1'] {}
112
+ .b {color: red;}"
113
+ `);
114
+ });
115
+ });
116
+ });
117
+ //# sourceMappingURL=dom-createOrderedCSSStyleSheet-test.js.map