@chipmobilesdk/rn-theme 1.1.0 → 1.3.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.
Files changed (263) hide show
  1. package/CHANGELOG.md +124 -1
  2. package/README.md +17 -12
  3. package/lib/commonjs/color/categorical.js +35 -0
  4. package/lib/commonjs/color/categorical.js.map +1 -0
  5. package/lib/commonjs/color/contrast.js +199 -0
  6. package/lib/commonjs/color/contrast.js.map +1 -0
  7. package/lib/commonjs/color/parse.js +110 -0
  8. package/lib/commonjs/color/parse.js.map +1 -0
  9. package/lib/commonjs/color/roles.js +235 -0
  10. package/lib/commonjs/color/roles.js.map +1 -0
  11. package/lib/commonjs/index.js +94 -0
  12. package/lib/commonjs/index.js.map +1 -0
  13. package/lib/commonjs/integration/navigationTheme.js +43 -0
  14. package/lib/commonjs/integration/navigationTheme.js.map +1 -0
  15. package/lib/commonjs/package.json +1 -0
  16. package/lib/commonjs/presets/byTone.js +28 -0
  17. package/lib/commonjs/presets/byTone.js.map +1 -0
  18. package/lib/commonjs/presets/layout.js +67 -0
  19. package/lib/commonjs/presets/layout.js.map +1 -0
  20. package/lib/commonjs/presets/themePresets.js +115 -0
  21. package/lib/commonjs/presets/themePresets.js.map +1 -0
  22. package/lib/commonjs/theme/buildThemes.js +211 -0
  23. package/lib/commonjs/theme/buildThemes.js.map +1 -0
  24. package/lib/commonjs/theme/errors.js +49 -0
  25. package/lib/commonjs/theme/errors.js.map +1 -0
  26. package/lib/commonjs/theme/overrides.js +125 -0
  27. package/lib/commonjs/theme/overrides.js.map +1 -0
  28. package/lib/commonjs/theme/validateThemeConfig.js +157 -0
  29. package/lib/commonjs/theme/validateThemeConfig.js.map +1 -0
  30. package/lib/commonjs/tokens/defaults.js +132 -0
  31. package/lib/commonjs/tokens/defaults.js.map +1 -0
  32. package/lib/commonjs/tokens/typography.js +136 -0
  33. package/lib/commonjs/tokens/typography.js.map +1 -0
  34. package/lib/commonjs/types/brand.js +2 -0
  35. package/lib/commonjs/types/brand.js.map +1 -0
  36. package/lib/commonjs/types/colors.js +2 -0
  37. package/lib/commonjs/types/colors.js.map +1 -0
  38. package/lib/commonjs/types/index.js +2 -0
  39. package/lib/commonjs/types/index.js.map +1 -0
  40. package/lib/commonjs/types/theme.js +6 -0
  41. package/lib/commonjs/types/theme.js.map +1 -0
  42. package/lib/commonjs/types/tokens.js +2 -0
  43. package/lib/commonjs/types/tokens.js.map +1 -0
  44. package/lib/commonjs/types/typography.js +2 -0
  45. package/lib/commonjs/types/typography.js.map +1 -0
  46. package/lib/commonjs/unistyles/createUnistylesConfig.js +113 -0
  47. package/lib/commonjs/unistyles/createUnistylesConfig.js.map +1 -0
  48. package/lib/commonjs/unistyles/themeMode.js +39 -0
  49. package/lib/commonjs/unistyles/themeMode.js.map +1 -0
  50. package/lib/commonjs/vendor/mcu/LICENSE +191 -0
  51. package/lib/commonjs/vendor/mcu/hct/cam16.js +362 -0
  52. package/lib/commonjs/vendor/mcu/hct/cam16.js.map +1 -0
  53. package/lib/commonjs/vendor/mcu/hct/hct.js +183 -0
  54. package/lib/commonjs/vendor/mcu/hct/hct.js.map +1 -0
  55. package/lib/commonjs/vendor/mcu/hct/hct_solver.js +401 -0
  56. package/lib/commonjs/vendor/mcu/hct/hct_solver.js.map +1 -0
  57. package/lib/commonjs/vendor/mcu/hct/viewing_conditions.js +116 -0
  58. package/lib/commonjs/vendor/mcu/hct/viewing_conditions.js.map +1 -0
  59. package/lib/commonjs/vendor/mcu/index.js +27 -0
  60. package/lib/commonjs/vendor/mcu/index.js.map +1 -0
  61. package/lib/commonjs/vendor/mcu/palettes/tonal_palette.js +177 -0
  62. package/lib/commonjs/vendor/mcu/palettes/tonal_palette.js.map +1 -0
  63. package/lib/commonjs/vendor/mcu/utils/color_utils.js +298 -0
  64. package/lib/commonjs/vendor/mcu/utils/color_utils.js.map +1 -0
  65. package/lib/commonjs/vendor/mcu/utils/math_utils.js +158 -0
  66. package/lib/commonjs/vendor/mcu/utils/math_utils.js.map +1 -0
  67. package/lib/module/color/categorical.js +31 -0
  68. package/lib/module/color/categorical.js.map +1 -0
  69. package/lib/module/color/contrast.js +194 -0
  70. package/lib/module/color/contrast.js.map +1 -0
  71. package/lib/module/color/parse.js +101 -0
  72. package/lib/module/color/parse.js.map +1 -0
  73. package/lib/module/color/roles.js +229 -0
  74. package/lib/module/color/roles.js.map +1 -0
  75. package/lib/module/index.js +23 -0
  76. package/lib/module/index.js.map +1 -0
  77. package/lib/module/integration/navigationTheme.js +39 -0
  78. package/lib/module/integration/navigationTheme.js.map +1 -0
  79. package/lib/module/package.json +1 -0
  80. package/lib/module/presets/byTone.js +24 -0
  81. package/lib/module/presets/byTone.js.map +1 -0
  82. package/lib/module/presets/layout.js +63 -0
  83. package/lib/module/presets/layout.js.map +1 -0
  84. package/lib/module/presets/themePresets.js +110 -0
  85. package/lib/module/presets/themePresets.js.map +1 -0
  86. package/lib/module/theme/buildThemes.js +208 -0
  87. package/lib/module/theme/buildThemes.js.map +1 -0
  88. package/lib/module/theme/errors.js +43 -0
  89. package/lib/module/theme/errors.js.map +1 -0
  90. package/lib/module/theme/overrides.js +119 -0
  91. package/lib/module/theme/overrides.js.map +1 -0
  92. package/lib/module/theme/validateThemeConfig.js +152 -0
  93. package/lib/module/theme/validateThemeConfig.js.map +1 -0
  94. package/lib/module/tokens/defaults.js +120 -0
  95. package/lib/module/tokens/defaults.js.map +1 -0
  96. package/lib/module/tokens/typography.js +129 -0
  97. package/lib/module/tokens/typography.js.map +1 -0
  98. package/lib/module/types/brand.js +2 -0
  99. package/lib/module/types/brand.js.map +1 -0
  100. package/lib/module/types/colors.js +2 -0
  101. package/lib/module/types/colors.js.map +1 -0
  102. package/lib/module/types/index.js +2 -0
  103. package/lib/module/types/index.js.map +1 -0
  104. package/lib/module/types/theme.js +4 -0
  105. package/lib/module/types/theme.js.map +1 -0
  106. package/lib/module/types/tokens.js +2 -0
  107. package/lib/module/types/tokens.js.map +1 -0
  108. package/lib/module/types/typography.js +2 -0
  109. package/lib/module/types/typography.js.map +1 -0
  110. package/lib/module/unistyles/createUnistylesConfig.js +109 -0
  111. package/lib/module/unistyles/createUnistylesConfig.js.map +1 -0
  112. package/lib/module/unistyles/themeMode.js +36 -0
  113. package/lib/module/unistyles/themeMode.js.map +1 -0
  114. package/lib/module/vendor/mcu/LICENSE +191 -0
  115. package/lib/module/vendor/mcu/hct/cam16.js +356 -0
  116. package/lib/module/vendor/mcu/hct/cam16.js.map +1 -0
  117. package/lib/module/vendor/mcu/hct/hct.js +178 -0
  118. package/lib/module/vendor/mcu/hct/hct.js.map +1 -0
  119. package/lib/module/vendor/mcu/hct/hct_solver.js +396 -0
  120. package/lib/module/vendor/mcu/hct/hct_solver.js.map +1 -0
  121. package/lib/module/vendor/mcu/hct/viewing_conditions.js +110 -0
  122. package/lib/module/vendor/mcu/hct/viewing_conditions.js.map +1 -0
  123. package/lib/module/vendor/mcu/index.js +8 -0
  124. package/lib/module/vendor/mcu/index.js.map +1 -0
  125. package/lib/module/vendor/mcu/palettes/tonal_palette.js +172 -0
  126. package/lib/module/vendor/mcu/palettes/tonal_palette.js.map +1 -0
  127. package/lib/module/vendor/mcu/utils/color_utils.js +277 -0
  128. package/lib/module/vendor/mcu/utils/color_utils.js.map +1 -0
  129. package/lib/module/vendor/mcu/utils/math_utils.js +146 -0
  130. package/lib/module/vendor/mcu/utils/math_utils.js.map +1 -0
  131. package/lib/typescript/commonjs/color/categorical.d.ts +7 -0
  132. package/lib/typescript/commonjs/color/categorical.d.ts.map +1 -0
  133. package/lib/typescript/commonjs/color/contrast.d.ts +26 -0
  134. package/lib/typescript/commonjs/color/contrast.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/color/parse.d.ts +25 -0
  136. package/lib/typescript/commonjs/color/parse.d.ts.map +1 -0
  137. package/lib/typescript/commonjs/color/roles.d.ts +26 -0
  138. package/lib/typescript/commonjs/color/roles.d.ts.map +1 -0
  139. package/lib/typescript/commonjs/index.d.ts +18 -0
  140. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/integration/navigationTheme.d.ts +30 -0
  142. package/lib/typescript/commonjs/integration/navigationTheme.d.ts.map +1 -0
  143. package/lib/typescript/commonjs/package.json +1 -0
  144. package/lib/typescript/commonjs/presets/byTone.d.ts +19 -0
  145. package/lib/typescript/commonjs/presets/byTone.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/presets/layout.d.ts +63 -0
  147. package/lib/typescript/commonjs/presets/layout.d.ts.map +1 -0
  148. package/lib/typescript/commonjs/presets/themePresets.d.ts +11 -0
  149. package/lib/typescript/commonjs/presets/themePresets.d.ts.map +1 -0
  150. package/lib/typescript/commonjs/theme/buildThemes.d.ts +18 -0
  151. package/lib/typescript/commonjs/theme/buildThemes.d.ts.map +1 -0
  152. package/lib/typescript/commonjs/theme/errors.d.ts +23 -0
  153. package/lib/typescript/commonjs/theme/errors.d.ts.map +1 -0
  154. package/lib/typescript/commonjs/theme/overrides.d.ts +11 -0
  155. package/lib/typescript/commonjs/theme/overrides.d.ts.map +1 -0
  156. package/lib/typescript/commonjs/theme/validateThemeConfig.d.ts +6 -0
  157. package/lib/typescript/commonjs/theme/validateThemeConfig.d.ts.map +1 -0
  158. package/lib/typescript/commonjs/tokens/defaults.d.ts +23 -0
  159. package/lib/typescript/commonjs/tokens/defaults.d.ts.map +1 -0
  160. package/lib/typescript/commonjs/tokens/typography.d.ts +14 -0
  161. package/lib/typescript/commonjs/tokens/typography.d.ts.map +1 -0
  162. package/lib/typescript/commonjs/types/brand.d.ts +21 -0
  163. package/lib/typescript/commonjs/types/brand.d.ts.map +1 -0
  164. package/lib/typescript/commonjs/types/colors.d.ts +76 -0
  165. package/lib/typescript/commonjs/types/colors.d.ts.map +1 -0
  166. package/lib/typescript/commonjs/types/index.d.ts +6 -0
  167. package/lib/typescript/commonjs/types/index.d.ts.map +1 -0
  168. package/lib/typescript/commonjs/types/theme.d.ts +140 -0
  169. package/lib/typescript/commonjs/types/theme.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/types/tokens.d.ts +79 -0
  171. package/lib/typescript/commonjs/types/tokens.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/types/typography.d.ts +53 -0
  173. package/lib/typescript/commonjs/types/typography.d.ts.map +1 -0
  174. package/lib/typescript/commonjs/unistyles/createUnistylesConfig.d.ts +52 -0
  175. package/lib/typescript/commonjs/unistyles/createUnistylesConfig.d.ts.map +1 -0
  176. package/lib/typescript/commonjs/unistyles/themeMode.d.ts +13 -0
  177. package/lib/typescript/commonjs/unistyles/themeMode.d.ts.map +1 -0
  178. package/lib/typescript/commonjs/vendor/mcu/hct/cam16.d.ts +132 -0
  179. package/lib/typescript/commonjs/vendor/mcu/hct/cam16.d.ts.map +1 -0
  180. package/lib/typescript/commonjs/vendor/mcu/hct/hct.d.ts +93 -0
  181. package/lib/typescript/commonjs/vendor/mcu/hct/hct.d.ts.map +1 -0
  182. package/lib/typescript/commonjs/vendor/mcu/hct/hct_solver.d.ts +147 -0
  183. package/lib/typescript/commonjs/vendor/mcu/hct/hct_solver.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/vendor/mcu/hct/viewing_conditions.d.ts +75 -0
  185. package/lib/typescript/commonjs/vendor/mcu/hct/viewing_conditions.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/vendor/mcu/index.d.ts +4 -0
  187. package/lib/typescript/commonjs/vendor/mcu/index.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/vendor/mcu/palettes/tonal_palette.d.ts +56 -0
  189. package/lib/typescript/commonjs/vendor/mcu/palettes/tonal_palette.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/vendor/mcu/utils/color_utils.d.ts +129 -0
  191. package/lib/typescript/commonjs/vendor/mcu/utils/color_utils.d.ts.map +1 -0
  192. package/lib/typescript/commonjs/vendor/mcu/utils/math_utils.d.ts +83 -0
  193. package/lib/typescript/commonjs/vendor/mcu/utils/math_utils.d.ts.map +1 -0
  194. package/lib/typescript/module/color/categorical.d.ts +7 -0
  195. package/lib/typescript/module/color/categorical.d.ts.map +1 -0
  196. package/lib/typescript/module/color/contrast.d.ts +26 -0
  197. package/lib/typescript/module/color/contrast.d.ts.map +1 -0
  198. package/lib/typescript/module/color/parse.d.ts +25 -0
  199. package/lib/typescript/module/color/parse.d.ts.map +1 -0
  200. package/lib/typescript/module/color/roles.d.ts +26 -0
  201. package/lib/typescript/module/color/roles.d.ts.map +1 -0
  202. package/lib/typescript/module/index.d.ts +18 -0
  203. package/lib/typescript/module/index.d.ts.map +1 -0
  204. package/lib/typescript/module/integration/navigationTheme.d.ts +30 -0
  205. package/lib/typescript/module/integration/navigationTheme.d.ts.map +1 -0
  206. package/lib/typescript/module/package.json +1 -0
  207. package/lib/typescript/module/presets/byTone.d.ts +19 -0
  208. package/lib/typescript/module/presets/byTone.d.ts.map +1 -0
  209. package/lib/typescript/module/presets/layout.d.ts +63 -0
  210. package/lib/typescript/module/presets/layout.d.ts.map +1 -0
  211. package/lib/typescript/module/presets/themePresets.d.ts +11 -0
  212. package/lib/typescript/module/presets/themePresets.d.ts.map +1 -0
  213. package/lib/typescript/module/theme/buildThemes.d.ts +18 -0
  214. package/lib/typescript/module/theme/buildThemes.d.ts.map +1 -0
  215. package/lib/typescript/module/theme/errors.d.ts +23 -0
  216. package/lib/typescript/module/theme/errors.d.ts.map +1 -0
  217. package/lib/typescript/module/theme/overrides.d.ts +11 -0
  218. package/lib/typescript/module/theme/overrides.d.ts.map +1 -0
  219. package/lib/typescript/module/theme/validateThemeConfig.d.ts +6 -0
  220. package/lib/typescript/module/theme/validateThemeConfig.d.ts.map +1 -0
  221. package/lib/typescript/module/tokens/defaults.d.ts +23 -0
  222. package/lib/typescript/module/tokens/defaults.d.ts.map +1 -0
  223. package/lib/typescript/module/tokens/typography.d.ts +14 -0
  224. package/lib/typescript/module/tokens/typography.d.ts.map +1 -0
  225. package/lib/typescript/module/types/brand.d.ts +21 -0
  226. package/lib/typescript/module/types/brand.d.ts.map +1 -0
  227. package/lib/typescript/module/types/colors.d.ts +76 -0
  228. package/lib/typescript/module/types/colors.d.ts.map +1 -0
  229. package/lib/typescript/module/types/index.d.ts +6 -0
  230. package/lib/typescript/module/types/index.d.ts.map +1 -0
  231. package/lib/typescript/module/types/theme.d.ts +140 -0
  232. package/lib/typescript/module/types/theme.d.ts.map +1 -0
  233. package/lib/typescript/module/types/tokens.d.ts +79 -0
  234. package/lib/typescript/module/types/tokens.d.ts.map +1 -0
  235. package/lib/typescript/module/types/typography.d.ts +53 -0
  236. package/lib/typescript/module/types/typography.d.ts.map +1 -0
  237. package/lib/typescript/module/unistyles/createUnistylesConfig.d.ts +52 -0
  238. package/lib/typescript/module/unistyles/createUnistylesConfig.d.ts.map +1 -0
  239. package/lib/typescript/module/unistyles/themeMode.d.ts +13 -0
  240. package/lib/typescript/module/unistyles/themeMode.d.ts.map +1 -0
  241. package/lib/typescript/module/vendor/mcu/hct/cam16.d.ts +132 -0
  242. package/lib/typescript/module/vendor/mcu/hct/cam16.d.ts.map +1 -0
  243. package/lib/typescript/module/vendor/mcu/hct/hct.d.ts +93 -0
  244. package/lib/typescript/module/vendor/mcu/hct/hct.d.ts.map +1 -0
  245. package/lib/typescript/module/vendor/mcu/hct/hct_solver.d.ts +147 -0
  246. package/lib/typescript/module/vendor/mcu/hct/hct_solver.d.ts.map +1 -0
  247. package/lib/typescript/module/vendor/mcu/hct/viewing_conditions.d.ts +75 -0
  248. package/lib/typescript/module/vendor/mcu/hct/viewing_conditions.d.ts.map +1 -0
  249. package/lib/typescript/module/vendor/mcu/index.d.ts +4 -0
  250. package/lib/typescript/module/vendor/mcu/index.d.ts.map +1 -0
  251. package/lib/typescript/module/vendor/mcu/palettes/tonal_palette.d.ts +56 -0
  252. package/lib/typescript/module/vendor/mcu/palettes/tonal_palette.d.ts.map +1 -0
  253. package/lib/typescript/module/vendor/mcu/utils/color_utils.d.ts +129 -0
  254. package/lib/typescript/module/vendor/mcu/utils/color_utils.d.ts.map +1 -0
  255. package/lib/typescript/module/vendor/mcu/utils/math_utils.d.ts +83 -0
  256. package/lib/typescript/module/vendor/mcu/utils/math_utils.d.ts.map +1 -0
  257. package/package.json +40 -16
  258. package/src/color/roles.ts +3 -1
  259. package/src/theme/buildThemes.ts +84 -26
  260. package/src/theme/validateThemeConfig.ts +28 -2
  261. package/src/tokens/defaults.ts +14 -8
  262. package/src/unistyles/createUnistylesConfig.ts +4 -1
  263. package/src/vendor/mcu/index.ts +1 -1
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ import { withAlpha } from "../color/parse.js";
4
+ // Every builder returns a fresh object so no two themes share a reference
5
+ // (spec AC-3.5, plan D-9).
6
+
7
+ export function buildSpacing() {
8
+ return {
9
+ none: 0,
10
+ xxs: 2,
11
+ xs: 4,
12
+ sm: 8,
13
+ smPlus: 12,
14
+ md: 16,
15
+ mdPlus: 20,
16
+ lg: 24,
17
+ xl: 32,
18
+ xlPlus: 40,
19
+ xxl: 48,
20
+ xxxl: 64
21
+ };
22
+ }
23
+ export function buildRadius() {
24
+ return {
25
+ none: 0,
26
+ xs: 2,
27
+ sm: 4,
28
+ md: 8,
29
+ lg: 16,
30
+ xl: 24,
31
+ full: 9999
32
+ };
33
+ }
34
+
35
+ /** `hairline` is the device's thinnest line, resolved by `buildThemes` (THM-04). */
36
+ export function buildBorderWidth(hairline) {
37
+ return {
38
+ hairline,
39
+ thin: 1,
40
+ thick: 2
41
+ };
42
+ }
43
+ export function buildSize() {
44
+ return {
45
+ touchTarget: 44,
46
+ icon: {
47
+ sm: 16,
48
+ md: 20,
49
+ lg: 24
50
+ }
51
+ };
52
+ }
53
+
54
+ /**
55
+ * The opacity scale, as one definition. `color.disabled` is derived from
56
+ * `disabledContent` rather than from a second copy of 0.38 (THM-07).
57
+ */
58
+ export const DEFAULT_OPACITY = {
59
+ hover: 0.08,
60
+ focus: 0.1,
61
+ pressed: 0.1,
62
+ dragged: 0.16,
63
+ disabledContent: 0.38,
64
+ disabledContainer: 0.12
65
+ };
66
+ export function buildOpacity() {
67
+ return {
68
+ ...DEFAULT_OPACITY
69
+ };
70
+ }
71
+ export function buildMotion() {
72
+ return {
73
+ duration: {
74
+ short: 100,
75
+ medium: 250,
76
+ long: 400
77
+ },
78
+ easing: {
79
+ standard: [0.2, 0, 0, 1],
80
+ emphasized: [0.05, 0.7, 0.1, 1],
81
+ decelerate: [0, 0, 0, 1],
82
+ accelerate: [0.3, 0, 1, 1]
83
+ }
84
+ };
85
+ }
86
+ export function buildZIndex() {
87
+ return {
88
+ base: 0,
89
+ raised: 10,
90
+ modal: 100,
91
+ overlay: 200,
92
+ toast: 300
93
+ };
94
+ }
95
+
96
+ /** Material 3 elevation levels 1–3: a key shadow plus an ambient shadow. */
97
+ const ELEVATION_LAYERS = {
98
+ sm: [[1, 2, 0, 0.3], [1, 3, 1, 0.15]],
99
+ md: [[1, 2, 0, 0.3], [2, 6, 2, 0.15]],
100
+ lg: [[1, 3, 0, 0.3], [4, 8, 3, 0.15]]
101
+ };
102
+ export function buildShadows(shadowColor) {
103
+ const shadow = layers => ({
104
+ boxShadow: layers.map(([offsetY, blur, spread, alpha]) => `0px ${offsetY}px ${blur}px ${spread}px ${withAlpha(shadowColor, alpha)}`).join(', ')
105
+ });
106
+ return {
107
+ sm: shadow(ELEVATION_LAYERS.sm),
108
+ md: shadow(ELEVATION_LAYERS.md),
109
+ lg: shadow(ELEVATION_LAYERS.lg)
110
+ };
111
+ }
112
+ export const DEFAULT_MAX_FONT_SCALE = 2;
113
+
114
+ /** Material 3 window size classes, in points. */
115
+ export const DEFAULT_BREAKPOINTS = {
116
+ compact: 0,
117
+ medium: 600,
118
+ expanded: 840
119
+ };
120
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withAlpha","buildSpacing","none","xxs","xs","sm","smPlus","md","mdPlus","lg","xl","xlPlus","xxl","xxxl","buildRadius","full","buildBorderWidth","hairline","thin","thick","buildSize","touchTarget","icon","DEFAULT_OPACITY","hover","focus","pressed","dragged","disabledContent","disabledContainer","buildOpacity","buildMotion","duration","short","medium","long","easing","standard","emphasized","decelerate","accelerate","buildZIndex","base","raised","modal","overlay","toast","ELEVATION_LAYERS","buildShadows","shadowColor","shadow","layers","boxShadow","map","offsetY","blur","spread","alpha","join","DEFAULT_MAX_FONT_SCALE","DEFAULT_BREAKPOINTS","compact","expanded"],"sourceRoot":"../../../src","sources":["tokens/defaults.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,mBAAgB;AAY1C;AACA;;AAEA,OAAO,SAASC,YAAYA,CAAA,EAAkB;EAC7C,OAAO;IACNC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,EAAE,EAAE,CAAC;IACLC,EAAE,EAAE,CAAC;IACLC,MAAM,EAAE,EAAE;IACVC,EAAE,EAAE,EAAE;IACNC,MAAM,EAAE,EAAE;IACVC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,MAAM,EAAE,EAAE;IACVC,GAAG,EAAE,EAAE;IACPC,IAAI,EAAE;EACP,CAAC;AACF;AAEA,OAAO,SAASC,WAAWA,CAAA,EAAiB;EAC3C,OAAO;IAAEZ,IAAI,EAAE,CAAC;IAAEE,EAAE,EAAE,CAAC;IAAEC,EAAE,EAAE,CAAC;IAAEE,EAAE,EAAE,CAAC;IAAEE,EAAE,EAAE,EAAE;IAAEC,EAAE,EAAE,EAAE;IAAEK,IAAI,EAAE;EAAK,CAAC;AACpE;;AAEA;AACA,OAAO,SAASC,gBAAgBA,CAACC,QAAgB,EAAqB;EACrE,OAAO;IAAEA,QAAQ;IAAEC,IAAI,EAAE,CAAC;IAAEC,KAAK,EAAE;EAAE,CAAC;AACvC;AAEA,OAAO,SAASC,SAASA,CAAA,EAAe;EACvC,OAAO;IAAEC,WAAW,EAAE,EAAE;IAAEC,IAAI,EAAE;MAAEjB,EAAE,EAAE,EAAE;MAAEE,EAAE,EAAE,EAAE;MAAEE,EAAE,EAAE;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AE,GAAG,CAAC,EACd,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CACf;EACDE,EAAE,EAAE,CACH,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EACd,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC;AAEjB,CAAU;AAEV,OAAO,SAASuC,YAAYA,CAACC,WAAmB,EAAgB;EAC/D,MAAMC,MAAM,GAAIC,MAAgE,KAAM;IACrFC,SAAS,EAAED,MAAM,CACfE,GAAG,CACH,CAAC,CAACC,OAAO,EAAEC,IAAI,EAAEC,MAAM,EAAEC,KAAK,CAAC,KAC9B,OAAOH,OAAO,MAAMC,IAAI,MAAMC,MAAM,MAAMxD,SAAS,CAACiD,WAAW,EAAEQ,KAAK,CAAC,EACzE,CAAC,CACAC,IAAI,CAAC,IAAI;EACZ,CAAC,CAAC;EAEF,OAAO;IACNrD,EAAE,EAAE6C,MAAM,CAACH,gBAAgB,CAAC1C,EAAE,CAAC;IAC/BE,EAAE,EAAE2C,MAAM,CAACH,gBAAgB,CAACxC,EAAE,CAAC;IAC/BE,EAAE,EAAEyC,MAAM,CAACH,gBAAgB,CAACtC,EAAE;EAC/B,CAAC;AACF;AAEA,OAAO,MAAMkD,sBAAsB,GAAG,CAAC;;AAEvC;AACA,OAAO,MAAMC,mBAAmB,GAAG;EAAEC,OAAO,EAAE,CAAC;EAAE3B,MAAM,EAAE,GAAG;EAAE4B,QAAQ,EAAE;AAAI,CAAC","ignoreList":[]}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ const DEFAULT_FONT_FAMILY = 'System';
4
+ const DEFAULT_BODY_SIZE = 16;
5
+ export const FONT_WEIGHTS = {
6
+ regular: '400',
7
+ medium: '500',
8
+ semibold: '600',
9
+ bold: '700',
10
+ heavy: '800'
11
+ };
12
+ const WEIGHT_ORDER = ['regular', 'medium', 'semibold', 'bold', 'heavy'];
13
+
14
+ /** Android: the per-weight family already carries the weight. */
15
+ const ANDROID_MAPPED_WEIGHT = 'normal';
16
+ const SCALE = {
17
+ display: {
18
+ sizes: [45, 57, 64],
19
+ weight: 'bold',
20
+ lineHeightRatio: 1.12,
21
+ letterSpacing: -0.25
22
+ },
23
+ headline: {
24
+ sizes: [28, 32, 36],
25
+ weight: 'semibold',
26
+ lineHeightRatio: 1.25
27
+ },
28
+ title: {
29
+ sizes: [18, 22, 24],
30
+ weight: 'semibold',
31
+ lineHeightRatio: 1.27
32
+ },
33
+ body: {
34
+ sizes: [14, 16, 18],
35
+ weight: 'regular',
36
+ lineHeightRatio: 1.5
37
+ },
38
+ label: {
39
+ sizes: [12, 14, 16],
40
+ weight: 'medium',
41
+ lineHeightRatio: 1.43,
42
+ letterSpacing: 0.1
43
+ },
44
+ caption: {
45
+ sizes: [11, 12, 13],
46
+ weight: 'regular',
47
+ lineHeightRatio: 1.33,
48
+ letterSpacing: 0.4
49
+ }
50
+ };
51
+ const SIZE_SUFFIXES = ['Small', '', 'Large'];
52
+
53
+ /** The configured weight closest to the requested one; ties go to the heavier. */
54
+ function nearestWeight(requested, available) {
55
+ const target = WEIGHT_ORDER.indexOf(requested);
56
+ return WEIGHT_ORDER.filter(weight => available[weight] != null).sort((a, b) => Math.abs(WEIGHT_ORDER.indexOf(a) - target) - Math.abs(WEIGHT_ORDER.indexOf(b) - target) || WEIGHT_ORDER.indexOf(b) - WEIGHT_ORDER.indexOf(a))[0];
57
+ }
58
+ function warnMissingWeight(platform, weight, used) {
59
+ if (__DEV__) {
60
+ console.warn(`[rn-theme] typography.fonts.${platform} has no "${weight}" font; using "${used}" instead.`);
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Resolves the family and weight a style needs for one named weight on one
66
+ * platform (spec US-2).
67
+ */
68
+ export function buildFonts(config, platform) {
69
+ const fonts = config?.fonts ?? {};
70
+ const family = fonts.family ?? config?.fontFamily ?? DEFAULT_FONT_FAMILY;
71
+ const perWeight = fonts[platform];
72
+ const warned = new Set();
73
+ const resolve = weight => {
74
+ // iOS picks weights inside one family, so a partial iOS map only renames
75
+ // the weights it lists; Android needs a file per weight, hence nearest.
76
+ const nearest = platform === 'ios' ? perWeight?.[weight] && weight : perWeight && nearestWeight(weight, perWeight);
77
+ if (!perWeight || !nearest) {
78
+ return {
79
+ fontFamily: family,
80
+ fontWeight: FONT_WEIGHTS[weight]
81
+ };
82
+ }
83
+ if (nearest !== weight && !warned.has(weight)) {
84
+ warned.add(weight);
85
+ warnMissingWeight(platform, weight, nearest);
86
+ }
87
+ const fontFamily = perWeight[nearest];
88
+ return {
89
+ fontFamily,
90
+ fontWeight: platform === 'android' ? ANDROID_MAPPED_WEIGHT : FONT_WEIGHTS[weight]
91
+ };
92
+ };
93
+ const font = {};
94
+ for (const weight of WEIGHT_ORDER) {
95
+ font[weight] = resolve(weight);
96
+ }
97
+ return {
98
+ family,
99
+ font
100
+ };
101
+ }
102
+ export function buildTypography(config, font, family) {
103
+ const scale = (config?.baseFontSize ?? DEFAULT_BODY_SIZE) / DEFAULT_BODY_SIZE * (config?.fontScale ?? 1);
104
+ const typography = {
105
+ fontFamily: family
106
+ };
107
+ for (const role of Object.keys(SCALE)) {
108
+ const entry = SCALE[role];
109
+ entry.sizes.forEach((size, index) => {
110
+ const fontSize = Math.round(size * scale);
111
+ const token = {
112
+ fontSize,
113
+ lineHeight: Math.round(fontSize * entry.lineHeightRatio),
114
+ ...font[entry.weight],
115
+ ...(entry.letterSpacing != null && {
116
+ letterSpacing: entry.letterSpacing
117
+ })
118
+ };
119
+ typography[`${role}${SIZE_SUFFIXES[index]}`] = token;
120
+ });
121
+ }
122
+ return typography;
123
+ }
124
+ export function buildFontWeight() {
125
+ return {
126
+ ...FONT_WEIGHTS
127
+ };
128
+ }
129
+ //# sourceMappingURL=typography.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DEFAULT_FONT_FAMILY","DEFAULT_BODY_SIZE","FONT_WEIGHTS","regular","medium","semibold","bold","heavy","WEIGHT_ORDER","ANDROID_MAPPED_WEIGHT","SCALE","display","sizes","weight","lineHeightRatio","letterSpacing","headline","title","body","label","caption","SIZE_SUFFIXES","nearestWeight","requested","available","target","indexOf","filter","sort","a","b","Math","abs","warnMissingWeight","platform","used","__DEV__","console","warn","buildFonts","config","fonts","family","fontFamily","perWeight","warned","Set","resolve","nearest","fontWeight","has","add","font","buildTypography","scale","baseFontSize","fontScale","typography","role","Object","keys","entry","forEach","size","index","fontSize","round","token","lineHeight","buildFontWeight"],"sourceRoot":"../../../src","sources":["tokens/typography.ts"],"mappings":";;AAeA,MAAMA,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,iBAAiB,GAAG,EAAE;AAE5B,OAAO,MAAMC,YAAyB,GAAG;EACxCC,OAAO,EAAE,KAAK;EACdC,MAAM,EAAE,KAAK;EACbC,QAAQ,EAAE,KAAK;EACfC,IAAI,EAAE,KAAK;EACXC,KAAK,EAAE;AACR,CAAC;AAED,MAAMC,YAA8B,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;;AAEzF;AACA,MAAMC,qBAAsC,GAAG,QAAQ;AAUvD,MAAMC,KAAwC,GAAG;EAChDC,OAAO,EAAE;IAAEC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAAEC,MAAM,EAAE,MAAM;IAAEC,eAAe,EAAE,IAAI;IAAEC,aAAa,EAAE,CAAC;EAAK,CAAC;EAC7FC,QAAQ,EAAE;IAAEJ,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAAEC,MAAM,EAAE,UAAU;IAAEC,eAAe,EAAE;EAAK,CAAC;EAC5EG,KAAK,EAAE;IAAEL,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAAEC,MAAM,EAAE,UAAU;IAAEC,eAAe,EAAE;EAAK,CAAC;EACzEI,IAAI,EAAE;IAAEN,KAAK,EAAE,C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 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/brand.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/colors.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/theme.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/tokens.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=typography.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/typography.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ import { buildThemes } from "../theme/buildThemes.js";
4
+ import { ThemeConfigError } from "../theme/errors.js";
5
+ import { isPlainObject } from "../theme/overrides.js";
6
+ import { themeNamesOf, validateThemeConfig } from "../theme/validateThemeConfig.js";
7
+ import { DEFAULT_BREAKPOINTS } from "../tokens/defaults.js";
8
+ function validateBreakpoints(value) {
9
+ if (!isPlainObject(value)) {
10
+ throw new ThemeConfigError('options.breakpoints', 'must be an object.');
11
+ }
12
+ const values = Object.entries(value);
13
+ for (const [key, width] of values) {
14
+ if (typeof width !== 'number' || !Number.isFinite(width) || width < 0) {
15
+ throw new ThemeConfigError(`options.breakpoints.${key}`, 'must be a non-negative number.');
16
+ }
17
+ }
18
+ if (!values.some(([, width]) => width === 0)) {
19
+ throw new ThemeConfigError('options.breakpoints', 'must include a breakpoint at 0.');
20
+ }
21
+ }
22
+ function validateOptions(options, themeNames) {
23
+ if (options == null) {
24
+ return;
25
+ }
26
+ if (!isPlainObject(options)) {
27
+ throw new ThemeConfigError('options', 'must be an object.');
28
+ }
29
+ const {
30
+ initialTheme,
31
+ adaptiveThemes,
32
+ CSSVars,
33
+ nativeBreakpointsMode,
34
+ breakpoints
35
+ } = options;
36
+ if (initialTheme != null && adaptiveThemes === true) {
37
+ throw new ThemeConfigError('options', 'use either initialTheme or adaptiveThemes, not both.');
38
+ }
39
+
40
+ // A resolver is only checked for type: invoking it here would run app code
41
+ // before Unistyles does, and twice (spec AC-3.6).
42
+ if (initialTheme != null && typeof initialTheme !== 'function' && !themeNames.includes(initialTheme)) {
43
+ throw new ThemeConfigError('options.initialTheme', `must be a theme name (${themeNames.join(', ')}) or a resolver function.`);
44
+ }
45
+ if (adaptiveThemes != null && typeof adaptiveThemes !== 'boolean') {
46
+ throw new ThemeConfigError('options.adaptiveThemes', 'must be a boolean.');
47
+ }
48
+ if (CSSVars != null && typeof CSSVars !== 'boolean') {
49
+ throw new ThemeConfigError('options.CSSVars', 'must be a boolean.');
50
+ }
51
+ if (nativeBreakpointsMode != null && nativeBreakpointsMode !== 'pixels' && nativeBreakpointsMode !== 'points') {
52
+ throw new ThemeConfigError('options.nativeBreakpointsMode', "must be 'pixels' or 'points'.");
53
+ }
54
+ if (breakpoints != null) {
55
+ validateBreakpoints(breakpoints);
56
+ }
57
+ }
58
+ function createSettings(options) {
59
+ const base = {
60
+ ...(options?.CSSVars != null && {
61
+ CSSVars: options.CSSVars
62
+ }),
63
+ ...(options?.nativeBreakpointsMode != null && {
64
+ nativeBreakpointsMode: options.nativeBreakpointsMode
65
+ })
66
+ };
67
+ if (options?.adaptiveThemes === true) {
68
+ return {
69
+ ...base,
70
+ adaptiveThemes: true
71
+ };
72
+ }
73
+ return {
74
+ ...base,
75
+ initialTheme: options?.initialTheme ?? 'light'
76
+ };
77
+ }
78
+
79
+ /**
80
+ * Builds the object for `StyleSheet.configure`: every theme, settings and
81
+ * breakpoints.
82
+ *
83
+ * ```ts
84
+ * const config = createUnistylesConfig({ brandColors: BRAND_COLORS }, { initialTheme: 'light' });
85
+ *
86
+ * type AppThemes = typeof config.themes;
87
+ * type AppBreakpoints = typeof config.breakpoints;
88
+ * declare module 'react-native-unistyles' {
89
+ * export interface UnistylesThemes extends AppThemes {}
90
+ * export interface UnistylesBreakpoints extends AppBreakpoints {}
91
+ * }
92
+ *
93
+ * StyleSheet.configure(config);
94
+ * ```
95
+ */
96
+ export function createUnistylesConfig(config, options) {
97
+ // The config first: reading `config.themes` for the theme names threw a
98
+ // TypeError with no path when the config itself was not an object (THM-10).
99
+ validateThemeConfig(config);
100
+ validateOptions(options, themeNamesOf(config));
101
+ return {
102
+ themes: buildThemes(config, options),
103
+ settings: createSettings(options),
104
+ breakpoints: {
105
+ ...(options?.breakpoints ?? DEFAULT_BREAKPOINTS)
106
+ }
107
+ };
108
+ }
109
+ //# sourceMappingURL=createUnistylesConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["buildThemes","ThemeConfigError","isPlainObject","themeNamesOf","validateThemeConfig","DEFAULT_BREAKPOINTS","validateBreakpoints","value","values","Object","entries","key","width","Number","isFinite","some","validateOptions","options","themeNames","initialTheme","adaptiveThemes","CSSVars","nativeBreakpointsMode","breakpoints","includes","join","createSettings","base","createUnistylesConfig","config","themes","settings"],"sourceRoot":"../../../src","sources":["unistyles/createUnistylesConfig.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAiC,yBAAsB;AAC3E,SAASC,gBAAgB,QAAQ,oBAAiB;AAClD,SAASC,aAAa,QAAQ,uBAAoB;AAClD,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,iCAA8B;AAChF,SAASC,mBAAmB,QAA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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,qBAAqBA,CAMpCC,MAAuC,EACvCZ,OAA8D,EACV;EACpD;EACA;EACAb,mBAAmB,CAACyB,MAAM,CAAC;EAC3Bb,eAAe,CAACC,OAAO,EAAEd,YAAY,CAAC0B,MAAM,CAAC,CAAC;EAE9C,OAAO;IACNC,MAAM,EAAE9B,WAAW,CAAC6B,MAAM,EAAEZ,OAAO,CAAC;IACpCc,QAAQ,EAAEL,cAAc,CAACT,OAAiE,CAAC;IAC3FM,WAAW,EAAE;MAAE,IAAIN,OAAO,EAAEM,WAAW,IAAIlB,mBAAmB;IAAE;EACjE,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ import { lazyPeer } from '@chipmobilesdk/rn-core';
4
+ import { ThemeConfigError } from "../theme/errors.js";
5
+
6
+ /** The two runtime calls a mode change needs. */
7
+
8
+ // Loaded when a mode is first applied, so importing the package (and building
9
+ // themes) never loads Unistyles (THM-04). The package cannot see the app's
10
+ // augmented `UnistylesThemes`, so the runtime is typed by the two calls it needs.
11
+ const unistyles = lazyPeer('react-native-unistyles', () => {
12
+ // Inside `try`, so Metro bundles an app that leaves this optional peer out.
13
+ try {
14
+ return require('react-native-unistyles');
15
+ } catch (cause) {
16
+ throw cause;
17
+ }
18
+ });
19
+ function defaultRuntime() {
20
+ return unistyles.require(peer => new ThemeConfigError('applyThemeMode', `${peer} is not installed; pass a runtime or install it`)).UnistylesRuntime;
21
+ }
22
+
23
+ /**
24
+ * Applies a light/dark/system preference. Adaptive themes are switched off
25
+ * before a manual theme is set; in the other order the next OS colour-scheme
26
+ * change overrides the user's choice. Persisting the preference is the app's.
27
+ */
28
+ export function applyThemeMode(mode, runtime = defaultRuntime()) {
29
+ if (mode === 'system') {
30
+ runtime.setAdaptiveThemes(true);
31
+ return;
32
+ }
33
+ runtime.setAdaptiveThemes(false);
34
+ runtime.setTheme(mode);
35
+ }
36
+ //# sourceMappingURL=themeMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["lazyPeer","ThemeConfigError","unistyles","require","cause","defaultRuntime","peer","UnistylesRuntime","applyThemeMode","mode","runtime","setAdaptiveThemes","setTheme"],"sourceRoot":"../../../src","sources":["unistyles/themeMode.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,wBAAwB;AAEjD,SAASC,gBAAgB,QAAQ,oBAAiB;;AAIlD;;AAMA;AACA;AACA;AACA,MAAMC,SAAS,GAAGF,QAAQ,CAAC,wBAAwB,EAAE,MAAM;EAC1D;EACA,IAAI;IACH,OAAOG,OAAO,CAAC,wBAAwB,CAAC;EACzC,CAAC,CAAC,OAAOC,KAAK,EAAE;IACf,MAAMA,KAAK;EACZ;AACD,CAAC,CAAC;AAEF,SAASC,cAAcA,CAAA,EAAqB;EAC3C,OAAOH,SAAS,CAACC,OAAO,CACvBG,IAAI,IACH,IAAIL,gBAAgB,CACnB,gBAAgB,EAChB,GAAGK,IAAI,iDACR,CACF,CAAC,CAACC,gBAAgB;AACnB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC7BC,IAAe,EACfC,OAAyB,GAAGL,cAAc,CAAC,CAAC,EACrC;EACP,IAAII,IAAI,KAAK,QAAQ,EAAE;IACtBC,OAAO,CAACC,iBAAiB,CAAC,IAAI,CAAC;IAC/B;EACD;EAEAD,OAAO,CAACC,iBAAiB,CAAC,KAAK,CAAC;EAChCD,OAAO,CAACE,QAAQ,CAACH,IAAI,CAAC;AACvB","ignoreList":[]}