@chipmobilesdk/rn-theme 1.2.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.
- package/CHANGELOG.md +111 -0
- package/README.md +3 -1
- package/lib/commonjs/color/categorical.js +35 -0
- package/lib/commonjs/color/categorical.js.map +1 -0
- package/lib/commonjs/color/contrast.js +199 -0
- package/lib/commonjs/color/contrast.js.map +1 -0
- package/lib/commonjs/color/parse.js +110 -0
- package/lib/commonjs/color/parse.js.map +1 -0
- package/lib/commonjs/color/roles.js +235 -0
- package/lib/commonjs/color/roles.js.map +1 -0
- package/lib/commonjs/index.js +94 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/integration/navigationTheme.js +43 -0
- package/lib/commonjs/integration/navigationTheme.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/presets/byTone.js +28 -0
- package/lib/commonjs/presets/byTone.js.map +1 -0
- package/lib/commonjs/presets/layout.js +67 -0
- package/lib/commonjs/presets/layout.js.map +1 -0
- package/lib/commonjs/presets/themePresets.js +115 -0
- package/lib/commonjs/presets/themePresets.js.map +1 -0
- package/lib/commonjs/theme/buildThemes.js +211 -0
- package/lib/commonjs/theme/buildThemes.js.map +1 -0
- package/lib/commonjs/theme/errors.js +49 -0
- package/lib/commonjs/theme/errors.js.map +1 -0
- package/lib/commonjs/theme/overrides.js +125 -0
- package/lib/commonjs/theme/overrides.js.map +1 -0
- package/lib/commonjs/theme/validateThemeConfig.js +157 -0
- package/lib/commonjs/theme/validateThemeConfig.js.map +1 -0
- package/lib/commonjs/tokens/defaults.js +132 -0
- package/lib/commonjs/tokens/defaults.js.map +1 -0
- package/lib/commonjs/tokens/typography.js +136 -0
- package/lib/commonjs/tokens/typography.js.map +1 -0
- package/lib/commonjs/types/brand.js +2 -0
- package/lib/commonjs/types/brand.js.map +1 -0
- package/lib/commonjs/types/colors.js +2 -0
- package/lib/commonjs/types/colors.js.map +1 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/theme.js +6 -0
- package/lib/commonjs/types/theme.js.map +1 -0
- package/lib/commonjs/types/tokens.js +2 -0
- package/lib/commonjs/types/tokens.js.map +1 -0
- package/lib/commonjs/types/typography.js +2 -0
- package/lib/commonjs/types/typography.js.map +1 -0
- package/lib/commonjs/unistyles/createUnistylesConfig.js +113 -0
- package/lib/commonjs/unistyles/createUnistylesConfig.js.map +1 -0
- package/lib/commonjs/unistyles/themeMode.js +39 -0
- package/lib/commonjs/unistyles/themeMode.js.map +1 -0
- package/lib/commonjs/vendor/mcu/LICENSE +191 -0
- package/lib/commonjs/vendor/mcu/hct/cam16.js +362 -0
- package/lib/commonjs/vendor/mcu/hct/cam16.js.map +1 -0
- package/lib/commonjs/vendor/mcu/hct/hct.js +183 -0
- package/lib/commonjs/vendor/mcu/hct/hct.js.map +1 -0
- package/lib/commonjs/vendor/mcu/hct/hct_solver.js +401 -0
- package/lib/commonjs/vendor/mcu/hct/hct_solver.js.map +1 -0
- package/lib/commonjs/vendor/mcu/hct/viewing_conditions.js +116 -0
- package/lib/commonjs/vendor/mcu/hct/viewing_conditions.js.map +1 -0
- package/lib/commonjs/vendor/mcu/index.js +27 -0
- package/lib/commonjs/vendor/mcu/index.js.map +1 -0
- package/lib/commonjs/vendor/mcu/palettes/tonal_palette.js +177 -0
- package/lib/commonjs/vendor/mcu/palettes/tonal_palette.js.map +1 -0
- package/lib/commonjs/vendor/mcu/utils/color_utils.js +298 -0
- package/lib/commonjs/vendor/mcu/utils/color_utils.js.map +1 -0
- package/lib/commonjs/vendor/mcu/utils/math_utils.js +158 -0
- package/lib/commonjs/vendor/mcu/utils/math_utils.js.map +1 -0
- package/lib/module/color/categorical.js +31 -0
- package/lib/module/color/categorical.js.map +1 -0
- package/lib/module/color/contrast.js +194 -0
- package/lib/module/color/contrast.js.map +1 -0
- package/lib/module/color/parse.js +101 -0
- package/lib/module/color/parse.js.map +1 -0
- package/lib/module/color/roles.js +229 -0
- package/lib/module/color/roles.js.map +1 -0
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/integration/navigationTheme.js +39 -0
- package/lib/module/integration/navigationTheme.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/presets/byTone.js +24 -0
- package/lib/module/presets/byTone.js.map +1 -0
- package/lib/module/presets/layout.js +63 -0
- package/lib/module/presets/layout.js.map +1 -0
- package/lib/module/presets/themePresets.js +110 -0
- package/lib/module/presets/themePresets.js.map +1 -0
- package/lib/module/theme/buildThemes.js +208 -0
- package/lib/module/theme/buildThemes.js.map +1 -0
- package/lib/module/theme/errors.js +43 -0
- package/lib/module/theme/errors.js.map +1 -0
- package/lib/module/theme/overrides.js +119 -0
- package/lib/module/theme/overrides.js.map +1 -0
- package/lib/module/theme/validateThemeConfig.js +152 -0
- package/lib/module/theme/validateThemeConfig.js.map +1 -0
- package/lib/module/tokens/defaults.js +120 -0
- package/lib/module/tokens/defaults.js.map +1 -0
- package/lib/module/tokens/typography.js +129 -0
- package/lib/module/tokens/typography.js.map +1 -0
- package/lib/module/types/brand.js +2 -0
- package/lib/module/types/brand.js.map +1 -0
- package/lib/module/types/colors.js +2 -0
- package/lib/module/types/colors.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/theme.js +4 -0
- package/lib/module/types/theme.js.map +1 -0
- package/lib/module/types/tokens.js +2 -0
- package/lib/module/types/tokens.js.map +1 -0
- package/lib/module/types/typography.js +2 -0
- package/lib/module/types/typography.js.map +1 -0
- package/lib/module/unistyles/createUnistylesConfig.js +109 -0
- package/lib/module/unistyles/createUnistylesConfig.js.map +1 -0
- package/lib/module/unistyles/themeMode.js +36 -0
- package/lib/module/unistyles/themeMode.js.map +1 -0
- package/lib/module/vendor/mcu/LICENSE +191 -0
- package/lib/module/vendor/mcu/hct/cam16.js +356 -0
- package/lib/module/vendor/mcu/hct/cam16.js.map +1 -0
- package/lib/module/vendor/mcu/hct/hct.js +178 -0
- package/lib/module/vendor/mcu/hct/hct.js.map +1 -0
- package/lib/module/vendor/mcu/hct/hct_solver.js +396 -0
- package/lib/module/vendor/mcu/hct/hct_solver.js.map +1 -0
- package/lib/module/vendor/mcu/hct/viewing_conditions.js +110 -0
- package/lib/module/vendor/mcu/hct/viewing_conditions.js.map +1 -0
- package/lib/module/vendor/mcu/index.js +8 -0
- package/lib/module/vendor/mcu/index.js.map +1 -0
- package/lib/module/vendor/mcu/palettes/tonal_palette.js +172 -0
- package/lib/module/vendor/mcu/palettes/tonal_palette.js.map +1 -0
- package/lib/module/vendor/mcu/utils/color_utils.js +277 -0
- package/lib/module/vendor/mcu/utils/color_utils.js.map +1 -0
- package/lib/module/vendor/mcu/utils/math_utils.js +146 -0
- package/lib/module/vendor/mcu/utils/math_utils.js.map +1 -0
- package/lib/typescript/commonjs/color/categorical.d.ts +7 -0
- package/lib/typescript/commonjs/color/categorical.d.ts.map +1 -0
- package/lib/typescript/commonjs/color/contrast.d.ts +26 -0
- package/lib/typescript/commonjs/color/contrast.d.ts.map +1 -0
- package/lib/typescript/commonjs/color/parse.d.ts +25 -0
- package/lib/typescript/commonjs/color/parse.d.ts.map +1 -0
- package/lib/typescript/commonjs/color/roles.d.ts +26 -0
- package/lib/typescript/commonjs/color/roles.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +18 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/integration/navigationTheme.d.ts +30 -0
- package/lib/typescript/commonjs/integration/navigationTheme.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/presets/byTone.d.ts +19 -0
- package/lib/typescript/commonjs/presets/byTone.d.ts.map +1 -0
- package/lib/typescript/commonjs/presets/layout.d.ts +63 -0
- package/lib/typescript/commonjs/presets/layout.d.ts.map +1 -0
- package/lib/typescript/commonjs/presets/themePresets.d.ts +11 -0
- package/lib/typescript/commonjs/presets/themePresets.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/buildThemes.d.ts +18 -0
- package/lib/typescript/commonjs/theme/buildThemes.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/errors.d.ts +23 -0
- package/lib/typescript/commonjs/theme/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/overrides.d.ts +11 -0
- package/lib/typescript/commonjs/theme/overrides.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/validateThemeConfig.d.ts +6 -0
- package/lib/typescript/commonjs/theme/validateThemeConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/tokens/defaults.d.ts +23 -0
- package/lib/typescript/commonjs/tokens/defaults.d.ts.map +1 -0
- package/lib/typescript/commonjs/tokens/typography.d.ts +14 -0
- package/lib/typescript/commonjs/tokens/typography.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/brand.d.ts +21 -0
- package/lib/typescript/commonjs/types/brand.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/colors.d.ts +76 -0
- package/lib/typescript/commonjs/types/colors.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/index.d.ts +6 -0
- package/lib/typescript/commonjs/types/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/theme.d.ts +140 -0
- package/lib/typescript/commonjs/types/theme.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/tokens.d.ts +79 -0
- package/lib/typescript/commonjs/types/tokens.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/typography.d.ts +53 -0
- package/lib/typescript/commonjs/types/typography.d.ts.map +1 -0
- package/lib/typescript/commonjs/unistyles/createUnistylesConfig.d.ts +52 -0
- package/lib/typescript/commonjs/unistyles/createUnistylesConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/unistyles/themeMode.d.ts +13 -0
- package/lib/typescript/commonjs/unistyles/themeMode.d.ts.map +1 -0
- package/lib/typescript/commonjs/vendor/mcu/hct/cam16.d.ts +132 -0
- package/lib/typescript/commonjs/vendor/mcu/hct/cam16.d.ts.map +1 -0
- package/lib/typescript/commonjs/vendor/mcu/hct/hct.d.ts +93 -0
- package/lib/typescript/commonjs/vendor/mcu/hct/hct.d.ts.map +1 -0
- package/lib/typescript/commonjs/vendor/mcu/hct/hct_solver.d.ts +147 -0
- package/lib/typescript/commonjs/vendor/mcu/hct/hct_solver.d.ts.map +1 -0
- package/lib/typescript/commonjs/vendor/mcu/hct/viewing_conditions.d.ts +75 -0
- package/lib/typescript/commonjs/vendor/mcu/hct/viewing_conditions.d.ts.map +1 -0
- package/lib/typescript/commonjs/vendor/mcu/index.d.ts +4 -0
- package/lib/typescript/commonjs/vendor/mcu/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/vendor/mcu/palettes/tonal_palette.d.ts +56 -0
- package/lib/typescript/commonjs/vendor/mcu/palettes/tonal_palette.d.ts.map +1 -0
- package/lib/typescript/commonjs/vendor/mcu/utils/color_utils.d.ts +129 -0
- package/lib/typescript/commonjs/vendor/mcu/utils/color_utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/vendor/mcu/utils/math_utils.d.ts +83 -0
- package/lib/typescript/commonjs/vendor/mcu/utils/math_utils.d.ts.map +1 -0
- package/lib/typescript/module/color/categorical.d.ts +7 -0
- package/lib/typescript/module/color/categorical.d.ts.map +1 -0
- package/lib/typescript/module/color/contrast.d.ts +26 -0
- package/lib/typescript/module/color/contrast.d.ts.map +1 -0
- package/lib/typescript/module/color/parse.d.ts +25 -0
- package/lib/typescript/module/color/parse.d.ts.map +1 -0
- package/lib/typescript/module/color/roles.d.ts +26 -0
- package/lib/typescript/module/color/roles.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +18 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/integration/navigationTheme.d.ts +30 -0
- package/lib/typescript/module/integration/navigationTheme.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/presets/byTone.d.ts +19 -0
- package/lib/typescript/module/presets/byTone.d.ts.map +1 -0
- package/lib/typescript/module/presets/layout.d.ts +63 -0
- package/lib/typescript/module/presets/layout.d.ts.map +1 -0
- package/lib/typescript/module/presets/themePresets.d.ts +11 -0
- package/lib/typescript/module/presets/themePresets.d.ts.map +1 -0
- package/lib/typescript/module/theme/buildThemes.d.ts +18 -0
- package/lib/typescript/module/theme/buildThemes.d.ts.map +1 -0
- package/lib/typescript/module/theme/errors.d.ts +23 -0
- package/lib/typescript/module/theme/errors.d.ts.map +1 -0
- package/lib/typescript/module/theme/overrides.d.ts +11 -0
- package/lib/typescript/module/theme/overrides.d.ts.map +1 -0
- package/lib/typescript/module/theme/validateThemeConfig.d.ts +6 -0
- package/lib/typescript/module/theme/validateThemeConfig.d.ts.map +1 -0
- package/lib/typescript/module/tokens/defaults.d.ts +23 -0
- package/lib/typescript/module/tokens/defaults.d.ts.map +1 -0
- package/lib/typescript/module/tokens/typography.d.ts +14 -0
- package/lib/typescript/module/tokens/typography.d.ts.map +1 -0
- package/lib/typescript/module/types/brand.d.ts +21 -0
- package/lib/typescript/module/types/brand.d.ts.map +1 -0
- package/lib/typescript/module/types/colors.d.ts +76 -0
- package/lib/typescript/module/types/colors.d.ts.map +1 -0
- package/lib/typescript/module/types/index.d.ts +6 -0
- package/lib/typescript/module/types/index.d.ts.map +1 -0
- package/lib/typescript/module/types/theme.d.ts +140 -0
- package/lib/typescript/module/types/theme.d.ts.map +1 -0
- package/lib/typescript/module/types/tokens.d.ts +79 -0
- package/lib/typescript/module/types/tokens.d.ts.map +1 -0
- package/lib/typescript/module/types/typography.d.ts +53 -0
- package/lib/typescript/module/types/typography.d.ts.map +1 -0
- package/lib/typescript/module/unistyles/createUnistylesConfig.d.ts +52 -0
- package/lib/typescript/module/unistyles/createUnistylesConfig.d.ts.map +1 -0
- package/lib/typescript/module/unistyles/themeMode.d.ts +13 -0
- package/lib/typescript/module/unistyles/themeMode.d.ts.map +1 -0
- package/lib/typescript/module/vendor/mcu/hct/cam16.d.ts +132 -0
- package/lib/typescript/module/vendor/mcu/hct/cam16.d.ts.map +1 -0
- package/lib/typescript/module/vendor/mcu/hct/hct.d.ts +93 -0
- package/lib/typescript/module/vendor/mcu/hct/hct.d.ts.map +1 -0
- package/lib/typescript/module/vendor/mcu/hct/hct_solver.d.ts +147 -0
- package/lib/typescript/module/vendor/mcu/hct/hct_solver.d.ts.map +1 -0
- package/lib/typescript/module/vendor/mcu/hct/viewing_conditions.d.ts +75 -0
- package/lib/typescript/module/vendor/mcu/hct/viewing_conditions.d.ts.map +1 -0
- package/lib/typescript/module/vendor/mcu/index.d.ts +4 -0
- package/lib/typescript/module/vendor/mcu/index.d.ts.map +1 -0
- package/lib/typescript/module/vendor/mcu/palettes/tonal_palette.d.ts +56 -0
- package/lib/typescript/module/vendor/mcu/palettes/tonal_palette.d.ts.map +1 -0
- package/lib/typescript/module/vendor/mcu/utils/color_utils.d.ts +129 -0
- package/lib/typescript/module/vendor/mcu/utils/color_utils.d.ts.map +1 -0
- package/lib/typescript/module/vendor/mcu/utils/math_utils.d.ts +83 -0
- package/lib/typescript/module/vendor/mcu/utils/math_utils.d.ts.map +1 -0
- package/package.json +40 -16
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DEFAULT_OPACITY = exports.DEFAULT_MAX_FONT_SCALE = exports.DEFAULT_BREAKPOINTS = void 0;
|
|
7
|
+
exports.buildBorderWidth = buildBorderWidth;
|
|
8
|
+
exports.buildMotion = buildMotion;
|
|
9
|
+
exports.buildOpacity = buildOpacity;
|
|
10
|
+
exports.buildRadius = buildRadius;
|
|
11
|
+
exports.buildShadows = buildShadows;
|
|
12
|
+
exports.buildSize = buildSize;
|
|
13
|
+
exports.buildSpacing = buildSpacing;
|
|
14
|
+
exports.buildZIndex = buildZIndex;
|
|
15
|
+
var _parse = require("../color/parse.js");
|
|
16
|
+
// Every builder returns a fresh object so no two themes share a reference
|
|
17
|
+
// (spec AC-3.5, plan D-9).
|
|
18
|
+
|
|
19
|
+
function buildSpacing() {
|
|
20
|
+
return {
|
|
21
|
+
none: 0,
|
|
22
|
+
xxs: 2,
|
|
23
|
+
xs: 4,
|
|
24
|
+
sm: 8,
|
|
25
|
+
smPlus: 12,
|
|
26
|
+
md: 16,
|
|
27
|
+
mdPlus: 20,
|
|
28
|
+
lg: 24,
|
|
29
|
+
xl: 32,
|
|
30
|
+
xlPlus: 40,
|
|
31
|
+
xxl: 48,
|
|
32
|
+
xxxl: 64
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function buildRadius() {
|
|
36
|
+
return {
|
|
37
|
+
none: 0,
|
|
38
|
+
xs: 2,
|
|
39
|
+
sm: 4,
|
|
40
|
+
md: 8,
|
|
41
|
+
lg: 16,
|
|
42
|
+
xl: 24,
|
|
43
|
+
full: 9999
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** `hairline` is the device's thinnest line, resolved by `buildThemes` (THM-04). */
|
|
48
|
+
function buildBorderWidth(hairline) {
|
|
49
|
+
return {
|
|
50
|
+
hairline,
|
|
51
|
+
thin: 1,
|
|
52
|
+
thick: 2
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function buildSize() {
|
|
56
|
+
return {
|
|
57
|
+
touchTarget: 44,
|
|
58
|
+
icon: {
|
|
59
|
+
sm: 16,
|
|
60
|
+
md: 20,
|
|
61
|
+
lg: 24
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The opacity scale, as one definition. `color.disabled` is derived from
|
|
68
|
+
* `disabledContent` rather than from a second copy of 0.38 (THM-07).
|
|
69
|
+
*/
|
|
70
|
+
const DEFAULT_OPACITY = exports.DEFAULT_OPACITY = {
|
|
71
|
+
hover: 0.08,
|
|
72
|
+
focus: 0.1,
|
|
73
|
+
pressed: 0.1,
|
|
74
|
+
dragged: 0.16,
|
|
75
|
+
disabledContent: 0.38,
|
|
76
|
+
disabledContainer: 0.12
|
|
77
|
+
};
|
|
78
|
+
function buildOpacity() {
|
|
79
|
+
return {
|
|
80
|
+
...DEFAULT_OPACITY
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function buildMotion() {
|
|
84
|
+
return {
|
|
85
|
+
duration: {
|
|
86
|
+
short: 100,
|
|
87
|
+
medium: 250,
|
|
88
|
+
long: 400
|
|
89
|
+
},
|
|
90
|
+
easing: {
|
|
91
|
+
standard: [0.2, 0, 0, 1],
|
|
92
|
+
emphasized: [0.05, 0.7, 0.1, 1],
|
|
93
|
+
decelerate: [0, 0, 0, 1],
|
|
94
|
+
accelerate: [0.3, 0, 1, 1]
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function buildZIndex() {
|
|
99
|
+
return {
|
|
100
|
+
base: 0,
|
|
101
|
+
raised: 10,
|
|
102
|
+
modal: 100,
|
|
103
|
+
overlay: 200,
|
|
104
|
+
toast: 300
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Material 3 elevation levels 1–3: a key shadow plus an ambient shadow. */
|
|
109
|
+
const ELEVATION_LAYERS = {
|
|
110
|
+
sm: [[1, 2, 0, 0.3], [1, 3, 1, 0.15]],
|
|
111
|
+
md: [[1, 2, 0, 0.3], [2, 6, 2, 0.15]],
|
|
112
|
+
lg: [[1, 3, 0, 0.3], [4, 8, 3, 0.15]]
|
|
113
|
+
};
|
|
114
|
+
function buildShadows(shadowColor) {
|
|
115
|
+
const shadow = layers => ({
|
|
116
|
+
boxShadow: layers.map(([offsetY, blur, spread, alpha]) => `0px ${offsetY}px ${blur}px ${spread}px ${(0, _parse.withAlpha)(shadowColor, alpha)}`).join(', ')
|
|
117
|
+
});
|
|
118
|
+
return {
|
|
119
|
+
sm: shadow(ELEVATION_LAYERS.sm),
|
|
120
|
+
md: shadow(ELEVATION_LAYERS.md),
|
|
121
|
+
lg: shadow(ELEVATION_LAYERS.lg)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const DEFAULT_MAX_FONT_SCALE = exports.DEFAULT_MAX_FONT_SCALE = 2;
|
|
125
|
+
|
|
126
|
+
/** Material 3 window size classes, in points. */
|
|
127
|
+
const DEFAULT_BREAKPOINTS = exports.DEFAULT_BREAKPOINTS = {
|
|
128
|
+
compact: 0,
|
|
129
|
+
medium: 600,
|
|
130
|
+
expanded: 840
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_parse","require","buildSpacing","none","xxs","xs","sm","smPlus","md","mdPlus","lg","xl","xlPlus","xxl","xxxl","buildRadius","full","buildBorderWidth","hairline","thin","thick","buildSize","touchTarget","icon","DEFAULT_OPACITY","exports","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","withAlpha","join","DEFAULT_MAX_FONT_SCALE","DEFAULT_BREAKPOINTS","compact","expanded"],"sourceRoot":"../../../src","sources":["tokens/defaults.ts"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAYA;AACA;;AAEO,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,IA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CAACH,gBAAgB,CAACzC,EAAE,CAAC;IAC/BE,EAAE,EAAE0C,MAAM,CAACH,gBAAgB,CAACvC,EAAE;EAC/B,CAAC;AACF;AAEO,MAAMoD,sBAAsB,GAAArC,OAAA,CAAAqC,sBAAA,GAAG,CAAC;;AAEvC;AACO,MAAMC,mBAAmB,GAAAtC,OAAA,CAAAsC,mBAAA,GAAG;EAAEC,OAAO,EAAE,CAAC;EAAE5B,MAAM,EAAE,GAAG;EAAE6B,QAAQ,EAAE;AAAI,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FONT_WEIGHTS = void 0;
|
|
7
|
+
exports.buildFontWeight = buildFontWeight;
|
|
8
|
+
exports.buildFonts = buildFonts;
|
|
9
|
+
exports.buildTypography = buildTypography;
|
|
10
|
+
const DEFAULT_FONT_FAMILY = 'System';
|
|
11
|
+
const DEFAULT_BODY_SIZE = 16;
|
|
12
|
+
const FONT_WEIGHTS = exports.FONT_WEIGHTS = {
|
|
13
|
+
regular: '400',
|
|
14
|
+
medium: '500',
|
|
15
|
+
semibold: '600',
|
|
16
|
+
bold: '700',
|
|
17
|
+
heavy: '800'
|
|
18
|
+
};
|
|
19
|
+
const WEIGHT_ORDER = ['regular', 'medium', 'semibold', 'bold', 'heavy'];
|
|
20
|
+
|
|
21
|
+
/** Android: the per-weight family already carries the weight. */
|
|
22
|
+
const ANDROID_MAPPED_WEIGHT = 'normal';
|
|
23
|
+
const SCALE = {
|
|
24
|
+
display: {
|
|
25
|
+
sizes: [45, 57, 64],
|
|
26
|
+
weight: 'bold',
|
|
27
|
+
lineHeightRatio: 1.12,
|
|
28
|
+
letterSpacing: -0.25
|
|
29
|
+
},
|
|
30
|
+
headline: {
|
|
31
|
+
sizes: [28, 32, 36],
|
|
32
|
+
weight: 'semibold',
|
|
33
|
+
lineHeightRatio: 1.25
|
|
34
|
+
},
|
|
35
|
+
title: {
|
|
36
|
+
sizes: [18, 22, 24],
|
|
37
|
+
weight: 'semibold',
|
|
38
|
+
lineHeightRatio: 1.27
|
|
39
|
+
},
|
|
40
|
+
body: {
|
|
41
|
+
sizes: [14, 16, 18],
|
|
42
|
+
weight: 'regular',
|
|
43
|
+
lineHeightRatio: 1.5
|
|
44
|
+
},
|
|
45
|
+
label: {
|
|
46
|
+
sizes: [12, 14, 16],
|
|
47
|
+
weight: 'medium',
|
|
48
|
+
lineHeightRatio: 1.43,
|
|
49
|
+
letterSpacing: 0.1
|
|
50
|
+
},
|
|
51
|
+
caption: {
|
|
52
|
+
sizes: [11, 12, 13],
|
|
53
|
+
weight: 'regular',
|
|
54
|
+
lineHeightRatio: 1.33,
|
|
55
|
+
letterSpacing: 0.4
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const SIZE_SUFFIXES = ['Small', '', 'Large'];
|
|
59
|
+
|
|
60
|
+
/** The configured weight closest to the requested one; ties go to the heavier. */
|
|
61
|
+
function nearestWeight(requested, available) {
|
|
62
|
+
const target = WEIGHT_ORDER.indexOf(requested);
|
|
63
|
+
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];
|
|
64
|
+
}
|
|
65
|
+
function warnMissingWeight(platform, weight, used) {
|
|
66
|
+
if (__DEV__) {
|
|
67
|
+
console.warn(`[rn-theme] typography.fonts.${platform} has no "${weight}" font; using "${used}" instead.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Resolves the family and weight a style needs for one named weight on one
|
|
73
|
+
* platform (spec US-2).
|
|
74
|
+
*/
|
|
75
|
+
function buildFonts(config, platform) {
|
|
76
|
+
const fonts = config?.fonts ?? {};
|
|
77
|
+
const family = fonts.family ?? config?.fontFamily ?? DEFAULT_FONT_FAMILY;
|
|
78
|
+
const perWeight = fonts[platform];
|
|
79
|
+
const warned = new Set();
|
|
80
|
+
const resolve = weight => {
|
|
81
|
+
// iOS picks weights inside one family, so a partial iOS map only renames
|
|
82
|
+
// the weights it lists; Android needs a file per weight, hence nearest.
|
|
83
|
+
const nearest = platform === 'ios' ? perWeight?.[weight] && weight : perWeight && nearestWeight(weight, perWeight);
|
|
84
|
+
if (!perWeight || !nearest) {
|
|
85
|
+
return {
|
|
86
|
+
fontFamily: family,
|
|
87
|
+
fontWeight: FONT_WEIGHTS[weight]
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (nearest !== weight && !warned.has(weight)) {
|
|
91
|
+
warned.add(weight);
|
|
92
|
+
warnMissingWeight(platform, weight, nearest);
|
|
93
|
+
}
|
|
94
|
+
const fontFamily = perWeight[nearest];
|
|
95
|
+
return {
|
|
96
|
+
fontFamily,
|
|
97
|
+
fontWeight: platform === 'android' ? ANDROID_MAPPED_WEIGHT : FONT_WEIGHTS[weight]
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const font = {};
|
|
101
|
+
for (const weight of WEIGHT_ORDER) {
|
|
102
|
+
font[weight] = resolve(weight);
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
family,
|
|
106
|
+
font
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function buildTypography(config, font, family) {
|
|
110
|
+
const scale = (config?.baseFontSize ?? DEFAULT_BODY_SIZE) / DEFAULT_BODY_SIZE * (config?.fontScale ?? 1);
|
|
111
|
+
const typography = {
|
|
112
|
+
fontFamily: family
|
|
113
|
+
};
|
|
114
|
+
for (const role of Object.keys(SCALE)) {
|
|
115
|
+
const entry = SCALE[role];
|
|
116
|
+
entry.sizes.forEach((size, index) => {
|
|
117
|
+
const fontSize = Math.round(size * scale);
|
|
118
|
+
const token = {
|
|
119
|
+
fontSize,
|
|
120
|
+
lineHeight: Math.round(fontSize * entry.lineHeightRatio),
|
|
121
|
+
...font[entry.weight],
|
|
122
|
+
...(entry.letterSpacing != null && {
|
|
123
|
+
letterSpacing: entry.letterSpacing
|
|
124
|
+
})
|
|
125
|
+
};
|
|
126
|
+
typography[`${role}${SIZE_SUFFIXES[index]}`] = token;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return typography;
|
|
130
|
+
}
|
|
131
|
+
function buildFontWeight() {
|
|
132
|
+
return {
|
|
133
|
+
...FONT_WEIGHTS
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=typography.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_FONT_FAMILY","DEFAULT_BODY_SIZE","FONT_WEIGHTS","exports","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;AAErB,MAAMC,YAAyB,GAAAC,OAAA,CAAAD,YAAA,GAAG;EACxCE,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,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ACRG,UAAU,EAAErC,IAAI,CAACmC,KAAK,CAACD,QAAQ,GAAGJ,KAAK,CAAC/C,eAAe,CAAC;QACxD,GAAGsC,IAAI,CAACS,KAAK,CAAChD,MAAM,CAAC;QACrB,IAAIgD,KAAK,CAAC9C,aAAa,IAAI,IAAI,IAAI;UAAEA,aAAa,EAAE8C,KAAK,CAAC9C;QAAc,CAAC;MAC1E,CAAC;MAED0C,UAAU,CAAC,GAAGC,IAAI,GAAGrC,aAAa,CAAC2C,KAAK,CAAC,EAAE,CAAwB,GAAGG,KAAK;IAC5E,CAAC,CAAC;EACH;EAEA,OAAOV,UAAU;AAClB;AAEO,SAASY,eAAeA,CAAA,EAAgB;EAC9C,OAAO;IAAE,GAAGpE;EAAa,CAAC;AAC3B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/brand.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/colors.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/theme.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/tokens.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/typography.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createUnistylesConfig = createUnistylesConfig;
|
|
7
|
+
var _buildThemes = require("../theme/buildThemes.js");
|
|
8
|
+
var _errors = require("../theme/errors.js");
|
|
9
|
+
var _overrides = require("../theme/overrides.js");
|
|
10
|
+
var _validateThemeConfig = require("../theme/validateThemeConfig.js");
|
|
11
|
+
var _defaults = require("../tokens/defaults.js");
|
|
12
|
+
function validateBreakpoints(value) {
|
|
13
|
+
if (!(0, _overrides.isPlainObject)(value)) {
|
|
14
|
+
throw new _errors.ThemeConfigError('options.breakpoints', 'must be an object.');
|
|
15
|
+
}
|
|
16
|
+
const values = Object.entries(value);
|
|
17
|
+
for (const [key, width] of values) {
|
|
18
|
+
if (typeof width !== 'number' || !Number.isFinite(width) || width < 0) {
|
|
19
|
+
throw new _errors.ThemeConfigError(`options.breakpoints.${key}`, 'must be a non-negative number.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!values.some(([, width]) => width === 0)) {
|
|
23
|
+
throw new _errors.ThemeConfigError('options.breakpoints', 'must include a breakpoint at 0.');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function validateOptions(options, themeNames) {
|
|
27
|
+
if (options == null) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!(0, _overrides.isPlainObject)(options)) {
|
|
31
|
+
throw new _errors.ThemeConfigError('options', 'must be an object.');
|
|
32
|
+
}
|
|
33
|
+
const {
|
|
34
|
+
initialTheme,
|
|
35
|
+
adaptiveThemes,
|
|
36
|
+
CSSVars,
|
|
37
|
+
nativeBreakpointsMode,
|
|
38
|
+
breakpoints
|
|
39
|
+
} = options;
|
|
40
|
+
if (initialTheme != null && adaptiveThemes === true) {
|
|
41
|
+
throw new _errors.ThemeConfigError('options', 'use either initialTheme or adaptiveThemes, not both.');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// A resolver is only checked for type: invoking it here would run app code
|
|
45
|
+
// before Unistyles does, and twice (spec AC-3.6).
|
|
46
|
+
if (initialTheme != null && typeof initialTheme !== 'function' && !themeNames.includes(initialTheme)) {
|
|
47
|
+
throw new _errors.ThemeConfigError('options.initialTheme', `must be a theme name (${themeNames.join(', ')}) or a resolver function.`);
|
|
48
|
+
}
|
|
49
|
+
if (adaptiveThemes != null && typeof adaptiveThemes !== 'boolean') {
|
|
50
|
+
throw new _errors.ThemeConfigError('options.adaptiveThemes', 'must be a boolean.');
|
|
51
|
+
}
|
|
52
|
+
if (CSSVars != null && typeof CSSVars !== 'boolean') {
|
|
53
|
+
throw new _errors.ThemeConfigError('options.CSSVars', 'must be a boolean.');
|
|
54
|
+
}
|
|
55
|
+
if (nativeBreakpointsMode != null && nativeBreakpointsMode !== 'pixels' && nativeBreakpointsMode !== 'points') {
|
|
56
|
+
throw new _errors.ThemeConfigError('options.nativeBreakpointsMode', "must be 'pixels' or 'points'.");
|
|
57
|
+
}
|
|
58
|
+
if (breakpoints != null) {
|
|
59
|
+
validateBreakpoints(breakpoints);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function createSettings(options) {
|
|
63
|
+
const base = {
|
|
64
|
+
...(options?.CSSVars != null && {
|
|
65
|
+
CSSVars: options.CSSVars
|
|
66
|
+
}),
|
|
67
|
+
...(options?.nativeBreakpointsMode != null && {
|
|
68
|
+
nativeBreakpointsMode: options.nativeBreakpointsMode
|
|
69
|
+
})
|
|
70
|
+
};
|
|
71
|
+
if (options?.adaptiveThemes === true) {
|
|
72
|
+
return {
|
|
73
|
+
...base,
|
|
74
|
+
adaptiveThemes: true
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...base,
|
|
79
|
+
initialTheme: options?.initialTheme ?? 'light'
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Builds the object for `StyleSheet.configure`: every theme, settings and
|
|
85
|
+
* breakpoints.
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* const config = createUnistylesConfig({ brandColors: BRAND_COLORS }, { initialTheme: 'light' });
|
|
89
|
+
*
|
|
90
|
+
* type AppThemes = typeof config.themes;
|
|
91
|
+
* type AppBreakpoints = typeof config.breakpoints;
|
|
92
|
+
* declare module 'react-native-unistyles' {
|
|
93
|
+
* export interface UnistylesThemes extends AppThemes {}
|
|
94
|
+
* export interface UnistylesBreakpoints extends AppBreakpoints {}
|
|
95
|
+
* }
|
|
96
|
+
*
|
|
97
|
+
* StyleSheet.configure(config);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
function createUnistylesConfig(config, options) {
|
|
101
|
+
// The config first: reading `config.themes` for the theme names threw a
|
|
102
|
+
// TypeError with no path when the config itself was not an object (THM-10).
|
|
103
|
+
(0, _validateThemeConfig.validateThemeConfig)(config);
|
|
104
|
+
validateOptions(options, (0, _validateThemeConfig.themeNamesOf)(config));
|
|
105
|
+
return {
|
|
106
|
+
themes: (0, _buildThemes.buildThemes)(config, options),
|
|
107
|
+
settings: createSettings(options),
|
|
108
|
+
breakpoints: {
|
|
109
|
+
...(options?.breakpoints ?? _defaults.DEFAULT_BREAKPOINTS)
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=createUnistylesConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_buildThemes","require","_errors","_overrides","_validateThemeConfig","_defaults","validateBreakpoints","value","isPlainObject","ThemeConfigError","values","Object","entries","key","width","Number","isFinite","some","validateOptions","options","themeNames","initialTheme","adaptiveThemes","CSSVars","nativeBreakpointsMode","breakpoints","includes","join","createSettings","base","createUnistylesConfig","config","validateThemeConfig","themeNamesOf","themes","buildThemes","settings","DEFAULT_BREAKPOINTS"],"sourceRoot":"../../../src","sources":["unistyles/createUnistylesConfig.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;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CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,qBAAqBA,CAMpCC,MAAuC,EACvCZ,OAA8D,EACV;EACpD;EACA;EACA,IAAAa,wCAAmB,EAACD,MAAM,CAAC;EAC3Bb,eAAe,CAACC,OAAO,EAAE,IAAAc,iCAAY,EAACF,MAAM,CAAC,CAAC;EAE9C,OAAO;IACNG,MAAM,EAAE,IAAAC,wBAAW,EAACJ,MAAM,EAAEZ,OAAO,CAAC;IACpCiB,QAAQ,EAAER,cAAc,CAACT,OAAiE,CAAC;IAC3FM,WAAW,EAAE;MAAE,IAAIN,OAAO,EAAEM,WAAW,IAAIY,6BAAmB;IAAE;EACjE,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyThemeMode = applyThemeMode;
|
|
7
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
8
|
+
var _errors = require("../theme/errors.js");
|
|
9
|
+
/** The two runtime calls a mode change needs. */
|
|
10
|
+
|
|
11
|
+
// Loaded when a mode is first applied, so importing the package (and building
|
|
12
|
+
// themes) never loads Unistyles (THM-04). The package cannot see the app's
|
|
13
|
+
// augmented `UnistylesThemes`, so the runtime is typed by the two calls it needs.
|
|
14
|
+
const unistyles = (0, _rnCore.lazyPeer)('react-native-unistyles', () => {
|
|
15
|
+
// Inside `try`, so Metro bundles an app that leaves this optional peer out.
|
|
16
|
+
try {
|
|
17
|
+
return require('react-native-unistyles');
|
|
18
|
+
} catch (cause) {
|
|
19
|
+
throw cause;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
function defaultRuntime() {
|
|
23
|
+
return unistyles.require(peer => new _errors.ThemeConfigError('applyThemeMode', `${peer} is not installed; pass a runtime or install it`)).UnistylesRuntime;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Applies a light/dark/system preference. Adaptive themes are switched off
|
|
28
|
+
* before a manual theme is set; in the other order the next OS colour-scheme
|
|
29
|
+
* change overrides the user's choice. Persisting the preference is the app's.
|
|
30
|
+
*/
|
|
31
|
+
function applyThemeMode(mode, runtime = defaultRuntime()) {
|
|
32
|
+
if (mode === 'system') {
|
|
33
|
+
runtime.setAdaptiveThemes(true);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
runtime.setAdaptiveThemes(false);
|
|
37
|
+
runtime.setTheme(mode);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=themeMode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","_errors","unistyles","lazyPeer","cause","defaultRuntime","peer","ThemeConfigError","UnistylesRuntime","applyThemeMode","mode","runtime","setAdaptiveThemes","setTheme"],"sourceRoot":"../../../src","sources":["unistyles/themeMode.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAIA;;AAMA;AACA;AACA;AACA,MAAME,SAAS,GAAG,IAAAC,gBAAQ,EAAC,wBAAwB,EAAE,MAAM;EAC1D;EACA,IAAI;IACH,OAAOH,OAAO,CAAC,wBAAwB,CAAC;EACzC,CAAC,CAAC,OAAOI,KAAK,EAAE;IACf,MAAMA,KAAK;EACZ;AACD,CAAC,CAAC;AAEF,SAASC,cAAcA,CAAA,EAAqB;EAC3C,OAAOH,SAAS,CAACF,OAAO,CACvBM,IAAI,IACH,IAAIC,wBAAgB,CACnB,gBAAgB,EAChB,GAAGD,IAAI,iDACR,CACF,CAAC,CAACE,gBAAgB;AACnB;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAC7BC,IAAe,EACfC,OAAyB,GAAGN,cAAc,CAAC,CAAC,EACrC;EACP,IAAIK,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":[]}
|