@oxyhq/bloom 0.6.16 → 0.6.17
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/lib/commonjs/theme/BloomThemeProvider.js +0 -28
- package/lib/commonjs/theme/BloomThemeProvider.js.map +1 -1
- package/lib/commonjs/theme/color-scope/index.js +66 -0
- package/lib/commonjs/theme/color-scope/index.js.map +1 -0
- package/lib/commonjs/theme/color-scope/index.web.js +56 -0
- package/lib/commonjs/theme/color-scope/index.web.js.map +1 -0
- package/lib/commonjs/theme/color-scope/style-builder.js +18 -0
- package/lib/commonjs/theme/color-scope/style-builder.js.map +1 -0
- package/lib/commonjs/theme/index.js +8 -1
- package/lib/commonjs/theme/index.js.map +1 -1
- package/lib/module/theme/BloomThemeProvider.js +1 -28
- package/lib/module/theme/BloomThemeProvider.js.map +1 -1
- package/lib/module/theme/color-scope/index.js +60 -0
- package/lib/module/theme/color-scope/index.js.map +1 -0
- package/lib/module/theme/color-scope/index.web.js +50 -0
- package/lib/module/theme/color-scope/index.web.js.map +1 -0
- package/lib/module/theme/color-scope/style-builder.js +14 -0
- package/lib/module/theme/color-scope/style-builder.js.map +1 -0
- package/lib/module/theme/index.js +2 -1
- package/lib/module/theme/index.js.map +1 -1
- package/lib/typescript/commonjs/icons/common.d.ts +12 -12
- package/lib/typescript/commonjs/theme/BloomThemeProvider.d.ts +0 -9
- package/lib/typescript/commonjs/theme/BloomThemeProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/color-scope/index.d.ts +23 -0
- package/lib/typescript/commonjs/theme/color-scope/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/color-scope/index.web.d.ts +22 -0
- package/lib/typescript/commonjs/theme/color-scope/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/color-scope/style-builder.d.ts +8 -0
- package/lib/typescript/commonjs/theme/color-scope/style-builder.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/index.d.ts +4 -2
- package/lib/typescript/commonjs/theme/index.d.ts.map +1 -1
- package/lib/typescript/module/icons/common.d.ts +12 -12
- package/lib/typescript/module/theme/BloomThemeProvider.d.ts +0 -9
- package/lib/typescript/module/theme/BloomThemeProvider.d.ts.map +1 -1
- package/lib/typescript/module/theme/color-scope/index.d.ts +23 -0
- package/lib/typescript/module/theme/color-scope/index.d.ts.map +1 -0
- package/lib/typescript/module/theme/color-scope/index.web.d.ts +22 -0
- package/lib/typescript/module/theme/color-scope/index.web.d.ts.map +1 -0
- package/lib/typescript/module/theme/color-scope/style-builder.d.ts +8 -0
- package/lib/typescript/module/theme/color-scope/style-builder.d.ts.map +1 -0
- package/lib/typescript/module/theme/index.d.ts +4 -2
- package/lib/typescript/module/theme/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/BloomColorScope.test.tsx +53 -0
- package/src/theme/BloomThemeProvider.tsx +0 -23
- package/src/theme/color-scope/index.tsx +80 -0
- package/src/theme/color-scope/index.web.tsx +62 -0
- package/src/theme/color-scope/style-builder.ts +14 -0
- package/src/theme/index.ts +3 -2
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.BloomColorScope = BloomColorScope;
|
|
7
6
|
exports.BloomThemeContext = void 0;
|
|
8
7
|
exports.BloomThemeProvider = BloomThemeProvider;
|
|
9
8
|
require("./init-css-interop.js");
|
|
@@ -193,31 +192,4 @@ function BloomThemeProvider({
|
|
|
193
192
|
})
|
|
194
193
|
});
|
|
195
194
|
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Scoped color override for a subtree. Inherits the resolved mode from the
|
|
199
|
-
* parent `BloomThemeProvider` but renders descendants with a different preset.
|
|
200
|
-
*/
|
|
201
|
-
|
|
202
|
-
function BloomColorScope({
|
|
203
|
-
colorPreset,
|
|
204
|
-
children
|
|
205
|
-
}) {
|
|
206
|
-
const parent = (0, _react.useContext)(BloomThemeContext);
|
|
207
|
-
if (!parent) {
|
|
208
|
-
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
209
|
-
}
|
|
210
|
-
const contextValue = (0, _react.useMemo)(() => {
|
|
211
|
-
const theme = (0, _buildTheme.buildTheme)(colorPreset, parent.theme.mode);
|
|
212
|
-
return {
|
|
213
|
-
...parent,
|
|
214
|
-
theme,
|
|
215
|
-
colorPreset
|
|
216
|
-
};
|
|
217
|
-
}, [colorPreset, parent]);
|
|
218
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(BloomThemeContext.Provider, {
|
|
219
|
-
value: contextValue,
|
|
220
|
-
children: children
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
195
|
//# sourceMappingURL=BloomThemeProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","_react","_interopRequireWildcard","_reactNative","_useControllableState","_FontLoader","_applyDarkClass","_buildTheme","_persistence","_setColorSchemeSafe","_useIsomorphicLayoutEffect","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DEFAULT_PRESET","DEFAULT_MODE","BloomThemeContext","exports","createContext","useThemeState","controlledMode","controlledPreset","defaultMode","defaultPreset","persistKey","storage","onModeChange","onColorPresetChange","syncResult","useState","readPersistedThemeSync","syncState","kind","state","initialMode","mode","initialPreset","colorPreset","hydrated","setHydrated","setModeInternal","useControllableState","value","defaultValue","setPresetInternal","modeRef","useRef","current","presetRef","useEffect","cancelled","readPersistedTheme","then","undefined","setMode","useCallback","next","writePersistedTheme","setColorPreset","resetTheme","removePersistedTheme","BloomThemeProvider","defaultColorPreset","awaitHydration","onHydrating","fonts","onFontsLoading","children","rnScheme","useRNColorScheme","isAdaptive","effectiveMode","resolved","useIsomorphicLayoutEffect","setColorSchemeSafe","applyDarkClass","applyColorPresetVars","contextValue","useMemo","theme","buildTheme","shouldAwait","Boolean","isGated","jsx","Provider","FontLoader","enabled","fallback"
|
|
1
|
+
{"version":3,"names":["require","_react","_interopRequireWildcard","_reactNative","_useControllableState","_FontLoader","_applyDarkClass","_buildTheme","_persistence","_setColorSchemeSafe","_useIsomorphicLayoutEffect","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DEFAULT_PRESET","DEFAULT_MODE","BloomThemeContext","exports","createContext","useThemeState","controlledMode","controlledPreset","defaultMode","defaultPreset","persistKey","storage","onModeChange","onColorPresetChange","syncResult","useState","readPersistedThemeSync","syncState","kind","state","initialMode","mode","initialPreset","colorPreset","hydrated","setHydrated","setModeInternal","useControllableState","value","defaultValue","setPresetInternal","modeRef","useRef","current","presetRef","useEffect","cancelled","readPersistedTheme","then","undefined","setMode","useCallback","next","writePersistedTheme","setColorPreset","resetTheme","removePersistedTheme","BloomThemeProvider","defaultColorPreset","awaitHydration","onHydrating","fonts","onFontsLoading","children","rnScheme","useRNColorScheme","isAdaptive","effectiveMode","resolved","useIsomorphicLayoutEffect","setColorSchemeSafe","applyDarkClass","applyColorPresetVars","contextValue","useMemo","theme","buildTheme","shouldAwait","Boolean","isGated","jsx","Provider","FontLoader","enabled","fallback"],"sourceRoot":"../../../src","sources":["theme/BloomThemeProvider.tsx"],"mappings":";;;;;;;AAIAA,OAAA;AAEA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,YAAA,GAAAH,OAAA;AAEA,IAAAI,qBAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAEA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAEA,IAAAQ,YAAA,GAAAR,OAAA;AAQA,IAAAS,mBAAA,GAAAT,OAAA;AACA,IAAAU,0BAAA,GAAAV,OAAA;AAA2E,IAAAW,WAAA,GAAAX,OAAA;AAAA,SAAAE,wBAAAU,CAAA,EAAAC,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I,IAAI,GAAGG;IAAQ,CAC/B;EAAC,CACa,CAAC;AAEjC","ignoreList":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BloomColorScope = BloomColorScope;
|
|
7
|
+
exports.useColorScopeStyle = useColorScopeStyle;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _BloomThemeProvider = require("../BloomThemeProvider.js");
|
|
11
|
+
var _buildTheme = require("../build-theme.js");
|
|
12
|
+
var _lazyRequire = require("../../utils/lazy-require.js");
|
|
13
|
+
var _styleBuilder = require("./style-builder.js");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
+
const getNativeWindVars = (0, _lazyRequire.lazyRequire)('nativewind');
|
|
17
|
+
function presetStyle(colorPreset, mode) {
|
|
18
|
+
const module = getNativeWindVars();
|
|
19
|
+
if (!module || typeof module.vars !== 'function') return undefined;
|
|
20
|
+
return module.vars((0, _styleBuilder.buildScopeVars)(colorPreset, mode));
|
|
21
|
+
}
|
|
22
|
+
function BloomColorScope({
|
|
23
|
+
colorPreset,
|
|
24
|
+
asChild = false,
|
|
25
|
+
style,
|
|
26
|
+
children
|
|
27
|
+
}) {
|
|
28
|
+
const parent = (0, _react.useContext)(_BloomThemeProvider.BloomThemeContext);
|
|
29
|
+
if (!parent) {
|
|
30
|
+
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
31
|
+
}
|
|
32
|
+
const resolvedMode = parent.theme.mode;
|
|
33
|
+
const contextValue = (0, _react.useMemo)(() => {
|
|
34
|
+
const theme = (0, _buildTheme.buildTheme)(colorPreset, resolvedMode);
|
|
35
|
+
return {
|
|
36
|
+
...parent,
|
|
37
|
+
theme,
|
|
38
|
+
colorPreset
|
|
39
|
+
};
|
|
40
|
+
}, [colorPreset, resolvedMode, parent]);
|
|
41
|
+
const varsStyle = (0, _react.useMemo)(() => presetStyle(colorPreset, resolvedMode), [colorPreset, resolvedMode]);
|
|
42
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_BloomThemeProvider.BloomThemeContext.Provider, {
|
|
43
|
+
value: contextValue,
|
|
44
|
+
children: asChild ? children : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
45
|
+
style: [{
|
|
46
|
+
flex: 1
|
|
47
|
+
}, varsStyle, style],
|
|
48
|
+
children: children
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Escape hatch for advanced cases where the wrapping element is owned by the
|
|
55
|
+
* caller. Returns a stable native style object carrying the preset's CSS vars.
|
|
56
|
+
* Returns `undefined` when nativewind is not installed.
|
|
57
|
+
*/
|
|
58
|
+
function useColorScopeStyle(colorPreset) {
|
|
59
|
+
const parent = (0, _react.useContext)(_BloomThemeProvider.BloomThemeContext);
|
|
60
|
+
if (!parent) {
|
|
61
|
+
throw new Error('useColorScopeStyle must be used within a <BloomThemeProvider>');
|
|
62
|
+
}
|
|
63
|
+
const resolvedMode = parent.theme.mode;
|
|
64
|
+
return (0, _react.useMemo)(() => presetStyle(colorPreset, resolvedMode), [colorPreset, resolvedMode]);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_BloomThemeProvider","_buildTheme","_lazyRequire","_styleBuilder","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","getNativeWindVars","lazyRequire","presetStyle","colorPreset","mode","module","vars","undefined","buildScopeVars","BloomColorScope","asChild","style","children","parent","useContext","BloomThemeContext","Error","resolvedMode","theme","contextValue","useMemo","buildTheme","varsStyle","jsx","Provider","value","View","flex","useColorScopeStyle"],"sourceRoot":"../../../../src","sources":["theme/color-scope/index.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAAiD,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAD,wBAAAQ,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAQ,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAA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,KAAK;MAAEf;IAAY,CAAC;EAC1C,CAAC,EAAE,CAACA,WAAW,EAAEc,YAAY,EAAEJ,MAAM,CAAC,CAAC;EAEvC,MAAMS,SAAS,GAAG,IAAAF,cAAO,EACvB,MAAMlB,WAAW,CAACC,WAAW,EAAEc,YAAY,CAAC,EAC5C,CAACd,WAAW,EAAEc,YAAY,CAC5B,CAAC;EAED,oBACE,IAAArC,WAAA,CAAA2C,GAAA,EAAC/C,mBAAA,CAAAuC,iBAAiB,CAACS,QAAQ;IAACC,KAAK,EAAEN,YAAa;IAAAP,QAAA,EAC7CF,OAAO,GAAGE,QAAQ,gBAAG,IAAAhC,WAAA,CAAA2C,GAAA,EAAChD,YAAA,CAAAmD,IAAI;MAACf,KAAK,EAAE,CAAC;QAAEgB,IAAI,EAAE;MAAE,CAAC,EAAEL,SAAS,EAAEX,KAAK,CAAE;MAAAC,QAAA,EAAEA;IAAQ,CAAO;EAAC,CAC3D,CAAC;AAEjC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASgB,kBAAkBA,CAACzB,WAAyB,EAAwB;EAClF,MAAMU,MAAM,GAAG,IAAAC,iBAAU,EAACC,qCAAiB,CAAC;EAC5C,IAAI,CAACF,MAAM,EAAE;IACX,MAAM,IAAIG,KAAK,CAAC,+DAA+D,CAAC;EAClF;EACA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK,CAACd,IAAI;EACtC,OAAO,IAAAgB,cAAO,EACZ,MAAMlB,WAAW,CAACC,WAAW,EAAEc,YAAY,CAAC,EAC5C,CAACd,WAAW,EAAEc,YAAY,CAC5B,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BloomColorScope = BloomColorScope;
|
|
7
|
+
exports.useColorScopeStyle = useColorScopeStyle;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _BloomThemeProvider = require("../BloomThemeProvider.js");
|
|
10
|
+
var _buildTheme = require("../build-theme.js");
|
|
11
|
+
var _styleBuilder = require("./style-builder.js");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
function BloomColorScope({
|
|
15
|
+
colorPreset,
|
|
16
|
+
asChild = false,
|
|
17
|
+
children
|
|
18
|
+
}) {
|
|
19
|
+
const parent = (0, _react.useContext)(_BloomThemeProvider.BloomThemeContext);
|
|
20
|
+
if (!parent) {
|
|
21
|
+
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
22
|
+
}
|
|
23
|
+
const resolvedMode = parent.theme.mode;
|
|
24
|
+
const contextValue = (0, _react.useMemo)(() => {
|
|
25
|
+
const theme = (0, _buildTheme.buildTheme)(colorPreset, resolvedMode);
|
|
26
|
+
return {
|
|
27
|
+
...parent,
|
|
28
|
+
theme,
|
|
29
|
+
colorPreset
|
|
30
|
+
};
|
|
31
|
+
}, [colorPreset, resolvedMode, parent]);
|
|
32
|
+
const style = (0, _react.useMemo)(() => (0, _styleBuilder.buildScopeVars)(colorPreset, resolvedMode), [colorPreset, resolvedMode]);
|
|
33
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_BloomThemeProvider.BloomThemeContext.Provider, {
|
|
34
|
+
value: contextValue,
|
|
35
|
+
children: asChild ? children : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
36
|
+
style: style,
|
|
37
|
+
children: children
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Escape hatch for advanced cases where the wrapping element is owned by the
|
|
44
|
+
* caller (e.g. a Pressable, a NativeWind-styled View that already has a style
|
|
45
|
+
* prop). Returns a stable React `style` object carrying every CSS custom
|
|
46
|
+
* property of the preset.
|
|
47
|
+
*/
|
|
48
|
+
function useColorScopeStyle(colorPreset) {
|
|
49
|
+
const parent = (0, _react.useContext)(_BloomThemeProvider.BloomThemeContext);
|
|
50
|
+
if (!parent) {
|
|
51
|
+
throw new Error('useColorScopeStyle must be used within a <BloomThemeProvider>');
|
|
52
|
+
}
|
|
53
|
+
const resolvedMode = parent.theme.mode;
|
|
54
|
+
return (0, _react.useMemo)(() => (0, _styleBuilder.buildScopeVars)(colorPreset, resolvedMode), [colorPreset, resolvedMode]);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=index.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_BloomThemeProvider","_buildTheme","_styleBuilder","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","BloomColorScope","colorPreset","asChild","children","parent","useContext","BloomThemeContext","Error","resolvedMode","theme","mode","contextValue","useMemo","buildTheme","style","buildScopeVars","jsx","Provider","value","useColorScopeStyle"],"sourceRoot":"../../../../src","sources":["theme/color-scope/index.web.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAGA,IAAAG,aAAA,GAAAH,OAAA;AAAiD,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAD,wBAAA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opeVars = buildScopeVars;
|
|
7
|
+
var _presetVars = require("../preset-vars.js");
|
|
8
|
+
/**
|
|
9
|
+
* Build the CSS custom-property map for a preset, ready to be applied to a
|
|
10
|
+
* subtree. Always includes the resolved `--color-*` vars so Tailwind v4
|
|
11
|
+
* `@theme` utilities (e.g. `bg-background`) honour the scope.
|
|
12
|
+
*/
|
|
13
|
+
function buildScopeVars(colorPreset, mode) {
|
|
14
|
+
return (0, _presetVars.getPresetVars)(colorPreset, mode, {
|
|
15
|
+
includeResolvedColorVars: true
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=style-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_presetVars","require","buildScopeVars","colorPreset","mode","getPresetVars","includeResolvedColorVars"],"sourceRoot":"../../../../src","sources":["theme/color-scope/style-builder.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAC5BC,WAAyB,EACzBC,IAAsB,EACE;EACxB,OAAO,IAAAC,yBAAa,EAACF,WAAW,EAAEC,IAAI,EAAE;IAAEE,wBAAwB,EAAE;EAAK,CAAC,CAAC;AAC7E","ignoreList":[]}
|
|
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "APP_COLOR_PRESETS", {
|
|
|
18
18
|
Object.defineProperty(exports, "BloomColorScope", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _colorScope.BloomColorScope;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "BloomThemeProvider", {
|
|
@@ -93,6 +93,12 @@ Object.defineProperty(exports, "useBloomTheme", {
|
|
|
93
93
|
return _useTheme.useBloomTheme;
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
|
+
Object.defineProperty(exports, "useColorScopeStyle", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _colorScope.useColorScopeStyle;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
96
102
|
Object.defineProperty(exports, "useTheme", {
|
|
97
103
|
enumerable: true,
|
|
98
104
|
get: function () {
|
|
@@ -112,6 +118,7 @@ Object.defineProperty(exports, "webLocalStorage", {
|
|
|
112
118
|
}
|
|
113
119
|
});
|
|
114
120
|
var _BloomThemeProvider = require("./BloomThemeProvider.js");
|
|
121
|
+
var _colorScope = require("./color-scope");
|
|
115
122
|
var _buildTheme = require("./build-theme.js");
|
|
116
123
|
var _useTheme = require("./use-theme.js");
|
|
117
124
|
var _colorPresets = require("./color-presets.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_BloomThemeProvider","require","_buildTheme","_useTheme","_colorPresets","_presetVars","_applyDarkClass","_setColorSchemeSafe","_initCssInterop","_persistence"],"sourceRoot":"../../../src","sources":["theme/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_BloomThemeProvider","require","_colorScope","_buildTheme","_useTheme","_colorPresets","_presetVars","_applyDarkClass","_setColorSchemeSafe","_initCssInterop","_persistence"],"sourceRoot":"../../../src","sources":["theme/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAGA,IAAAI,aAAA,GAAAJ,OAAA;AAOA,IAAAK,WAAA,GAAAL,OAAA;AAKA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,mBAAA,GAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAR,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// throw "Cannot manually set color scheme, as dark mode is type 'media'" the
|
|
6
6
|
// first time Bloom toggles the dark class on <html>. See ./init-css-interop.
|
|
7
7
|
import "./init-css-interop.js";
|
|
8
|
-
import React, { createContext, useCallback,
|
|
8
|
+
import React, { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
9
|
import { useColorScheme as useRNColorScheme } from 'react-native';
|
|
10
10
|
import { useControllableState } from "../hooks/useControllableState.js";
|
|
11
11
|
import { FontLoader } from '../fonts/FontLoader';
|
|
@@ -185,31 +185,4 @@ export function BloomThemeProvider({
|
|
|
185
185
|
})
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Scoped color override for a subtree. Inherits the resolved mode from the
|
|
191
|
-
* parent `BloomThemeProvider` but renders descendants with a different preset.
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
|
-
export function BloomColorScope({
|
|
195
|
-
colorPreset,
|
|
196
|
-
children
|
|
197
|
-
}) {
|
|
198
|
-
const parent = useContext(BloomThemeContext);
|
|
199
|
-
if (!parent) {
|
|
200
|
-
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
201
|
-
}
|
|
202
|
-
const contextValue = useMemo(() => {
|
|
203
|
-
const theme = buildTheme(colorPreset, parent.theme.mode);
|
|
204
|
-
return {
|
|
205
|
-
...parent,
|
|
206
|
-
theme,
|
|
207
|
-
colorPreset
|
|
208
|
-
};
|
|
209
|
-
}, [colorPreset, parent]);
|
|
210
|
-
return /*#__PURE__*/_jsx(BloomThemeContext.Provider, {
|
|
211
|
-
value: contextValue,
|
|
212
|
-
children: children
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
188
|
//# sourceMappingURL=BloomThemeProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","createContext","useCallback","
|
|
1
|
+
{"version":3,"names":["React","createContext","useCallback","useEffect","useMemo","useRef","useState","useColorScheme","useRNColorScheme","useControllableState","FontLoader","applyDarkClass","applyColorPresetVars","buildTheme","readPersistedTheme","readPersistedThemeSync","removePersistedTheme","writePersistedTheme","setColorSchemeSafe","useIsomorphicLayoutEffect","jsx","_jsx","DEFAULT_PRESET","DEFAULT_MODE","BloomThemeContext","useThemeState","controlledMode","controlledPreset","defaultMode","defaultPreset","persistKey","storage","onModeChange","onColorPresetChange","syncResult","syncState","kind","state","initialMode","mode","initialPreset","colorPreset","hydrated","setHydrated","setModeInternal","value","defaultValue","setPresetInternal","modeRef","current","presetRef","cancelled","then","undefined","setMode","next","setColorPreset","resetTheme","BloomThemeProvider","defaultColorPreset","awaitHydration","onHydrating","fonts","onFontsLoading","children","rnScheme","isAdaptive","effectiveMode","resolved","contextValue","theme","shouldAwait","Boolean","isGated","Provider","enabled","fallback"],"sourceRoot":"../../../src","sources":["theme/BloomThemeProvider.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,OAAO,uBAAoB;AAE3B,OAAOA,KAAK,IACVC,aAAa,EACbC,WAAW,EAEXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,cAAc,IAAIC,gBAAgB,QAAQ,cAAc;AAEjE,SAASC,oBAAoB,QAAQ,kCAA+B;AACpE,SAASC,UAAU,QAAQ,qBAAqB;AAEhD,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,uBAAoB;AACzE,SAASC,UAAU,QAAQ,kBAAe;AAE1C,SACEC,kBAAkB,EAClBC,sBAAsB,EACtBC,oBAAoB,EACpBC,mBAAmB,QAGd,kBAAe;AACtB,SAASC,kBAAkB,QAAQ,4BAAyB;AAC5D,SAASC,yBAAyB,QAAQ,mCAAgC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG3E,MAAMC,cAA4B,GAAG,KAAK;AAC1C,MAAMC,YAAuB,GAAG,QAAQ;AAgBxC,OAAO,MAAMC,iBAAiB,gBAAGvB,aAAa,CAAgC,IAAI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EjC","ignoreList":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useContext, useMemo } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { BloomThemeContext } from "../BloomThemeProvider.js";
|
|
6
|
+
import { buildTheme } from "../build-theme.js";
|
|
7
|
+
import { lazyRequire } from "../../utils/lazy-require.js";
|
|
8
|
+
import { buildScopeVars } from "./style-builder.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const getNativeWindVars = lazyRequire('nativewind');
|
|
11
|
+
function presetStyle(colorPreset, mode) {
|
|
12
|
+
const module = getNativeWindVars();
|
|
13
|
+
if (!module || typeof module.vars !== 'function') return undefined;
|
|
14
|
+
return module.vars(buildScopeVars(colorPreset, mode));
|
|
15
|
+
}
|
|
16
|
+
export function BloomColorScope({
|
|
17
|
+
colorPreset,
|
|
18
|
+
asChild = false,
|
|
19
|
+
style,
|
|
20
|
+
children
|
|
21
|
+
}) {
|
|
22
|
+
const parent = useContext(BloomThemeContext);
|
|
23
|
+
if (!parent) {
|
|
24
|
+
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
25
|
+
}
|
|
26
|
+
const resolvedMode = parent.theme.mode;
|
|
27
|
+
const contextValue = useMemo(() => {
|
|
28
|
+
const theme = buildTheme(colorPreset, resolvedMode);
|
|
29
|
+
return {
|
|
30
|
+
...parent,
|
|
31
|
+
theme,
|
|
32
|
+
colorPreset
|
|
33
|
+
};
|
|
34
|
+
}, [colorPreset, resolvedMode, parent]);
|
|
35
|
+
const varsStyle = useMemo(() => presetStyle(colorPreset, resolvedMode), [colorPreset, resolvedMode]);
|
|
36
|
+
return /*#__PURE__*/_jsx(BloomThemeContext.Provider, {
|
|
37
|
+
value: contextValue,
|
|
38
|
+
children: asChild ? children : /*#__PURE__*/_jsx(View, {
|
|
39
|
+
style: [{
|
|
40
|
+
flex: 1
|
|
41
|
+
}, varsStyle, style],
|
|
42
|
+
children: children
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Escape hatch for advanced cases where the wrapping element is owned by the
|
|
49
|
+
* caller. Returns a stable native style object carrying the preset's CSS vars.
|
|
50
|
+
* Returns `undefined` when nativewind is not installed.
|
|
51
|
+
*/
|
|
52
|
+
export function useColorScopeStyle(colorPreset) {
|
|
53
|
+
const parent = useContext(BloomThemeContext);
|
|
54
|
+
if (!parent) {
|
|
55
|
+
throw new Error('useColorScopeStyle must be used within a <BloomThemeProvider>');
|
|
56
|
+
}
|
|
57
|
+
const resolvedMode = parent.theme.mode;
|
|
58
|
+
return useMemo(() => presetStyle(colorPreset, resolvedMode), [colorPreset, resolvedMode]);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useContext","useMemo","View","BloomThemeContext","buildTheme","lazyRequire","buildScopeVars","jsx","_jsx","getNativeWindVars","presetStyle","colorPreset","mode","module","vars","undefined","BloomColorScope","asChild","style","children","parent","Error","resolvedMode","theme","contextValue","varsStyle","Provider","value","flex","useColorScopeStyle"],"sourceRoot":"../../../../src","sources":["theme/color-scope/index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAClD,SAASC,IAAI,QAAwC,cAAc;AAEnE,SAASC,iBAAiB,QAAqC,0BAAuB;AACtF,SAASC,UAAU,QAAQ,mBAAgB;AAE3C,SAASC,WAAW,QAAQ,6BAA0B;AACtD,SAASC,cAAc,QAAQ,oBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAMjD,MAAMC,iBAAiB,GAAGJ,WAAW,CAAuB,YAAY,CAAC;AAEzE,SAASK,WAAWA,CAACC,WAAyB,EAAEC,IAAsB,EAAwB;EAC5F,MAAMC,MAAM,GAAGJ,iBAAiB,CAAC,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AAMS,MAAM,GAAGpB,UAAU,CAACG,iBAAiB,CAAC;EAC5C,IAAI,CAACiB,MAAM,EAAE;IACX,MAAM,IAAIC,KAAK,CAAC,+DAA+D,CAAC;EAClF;EACA,MAAMC,YAAY,GAAGF,MAAM,CAACG,KAAK,CAACX,IAAI;EACtC,OAAOX,OAAO,CACZ,MAAMS,WAAW,CAACC,WAAW,EAAEW,YAAY,CAAC,EAC5C,CAACX,WAAW,EAAEW,YAAY,CAC5B,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useContext, useMemo } from 'react';
|
|
4
|
+
import { BloomThemeContext } from "../BloomThemeProvider.js";
|
|
5
|
+
import { buildTheme } from "../build-theme.js";
|
|
6
|
+
import { buildScopeVars } from "./style-builder.js";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export function BloomColorScope({
|
|
9
|
+
colorPreset,
|
|
10
|
+
asChild = false,
|
|
11
|
+
children
|
|
12
|
+
}) {
|
|
13
|
+
const parent = useContext(BloomThemeContext);
|
|
14
|
+
if (!parent) {
|
|
15
|
+
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
16
|
+
}
|
|
17
|
+
const resolvedMode = parent.theme.mode;
|
|
18
|
+
const contextValue = useMemo(() => {
|
|
19
|
+
const theme = buildTheme(colorPreset, resolvedMode);
|
|
20
|
+
return {
|
|
21
|
+
...parent,
|
|
22
|
+
theme,
|
|
23
|
+
colorPreset
|
|
24
|
+
};
|
|
25
|
+
}, [colorPreset, resolvedMode, parent]);
|
|
26
|
+
const style = useMemo(() => buildScopeVars(colorPreset, resolvedMode), [colorPreset, resolvedMode]);
|
|
27
|
+
return /*#__PURE__*/_jsx(BloomThemeContext.Provider, {
|
|
28
|
+
value: contextValue,
|
|
29
|
+
children: asChild ? children : /*#__PURE__*/_jsx("div", {
|
|
30
|
+
style: style,
|
|
31
|
+
children: children
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Escape hatch for advanced cases where the wrapping element is owned by the
|
|
38
|
+
* caller (e.g. a Pressable, a NativeWind-styled View that already has a style
|
|
39
|
+
* prop). Returns a stable React `style` object carrying every CSS custom
|
|
40
|
+
* property of the preset.
|
|
41
|
+
*/
|
|
42
|
+
export function useColorScopeStyle(colorPreset) {
|
|
43
|
+
const parent = useContext(BloomThemeContext);
|
|
44
|
+
if (!parent) {
|
|
45
|
+
throw new Error('useColorScopeStyle must be used within a <BloomThemeProvider>');
|
|
46
|
+
}
|
|
47
|
+
const resolvedMode = parent.theme.mode;
|
|
48
|
+
return useMemo(() => buildScopeVars(colorPreset, resolvedMode), [colorPreset, resolvedMode]);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=index.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useContext","useMemo","BloomThemeContext","buildTheme","buildScopeVars","jsx","_jsx","BloomColorScope","colorPreset","asChild","children","parent","Error","resolvedMode","theme","mode","contextValue","style","Provider","value","useColorScopeStyle"],"sourceRoot":"../../../../src","sources":["theme/color-scope/index.web.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAElD,SAASC,iBAAiB,QAAQ,0BAAuB;AACzD,SAASC,UAAU,QAAQ,mBAAgB;AAG3C,SAASC,cAAc,QAAQ,oBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAcjD,OAAO,SAASC,eAAeA,CAAC;EAAEC,WAAW;EAAEC,OAAO,GAAG,KAAK;EAAEC;AAA+B,CAAC,EAAE;EAChG,MAAMC,MAAM,GAAGX,UAAU,CAACE,iBAAiB,CAAC;EAC5C,IAAI,CAACS,MAAM,EAAE;IACX,MAAM,IAAIC,KAAK,CAAC,4DAA4D,CAAC;EAC/E;EAEA,MAAMC,YAAY,GAAGF,MAAM,CAACG,KAAK,CAACC,IAAI;EAEtC,MAAMC,YAAY,GAAGf,OAAO,CAAyB,MAAM;IACzD,MAAMa,KAAK,GAAGX,UAAU,CAACK,WAAW,EAAEK,YAAY,CAAC;IACnD,OAAO;MAAE,GAAGF,MAAM;MAAEG,KAAK;MAAEN;IAAY,CAAC;EAC1C,CAAC,EAAE,CAACA,WAAW,EAAEK,YAAY,EAAEF,MAAM,CAAC,CAAC;EAEvC,MAAMM,KAAK,GAAGhB,OAAO,CACnB,MAAMG,cAAc,CAACI,WAAW,EAAEK,YAAY,CAAwB,EACtE,CAACL,WAAW,EAAEK,YAAY,CAC5B,CAAC;EAED,oBACEP,IAAA,CAACJ,iBAAiB,CAACgB,QAAQ;IAACC,KAAK,EAAEH,YAAa;IAAAN,QAAA,EAC7CD,OAAO,GAAGC,QAAQ,gBAAGJ,IAAA;MAAKW,KAAK,EAAEA,KAAM;MAAAP,QAAA,EAAEA;IAAQ,CAAM;EAAC,CAC/B,CAAC;AAEjC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASU,kBAAkBA,CAACZ,WAAyB,EAAuB;EACjF,MAAMG,MAAM,GAAGX,UAAU,CAACE,iBAAiB,CAAC;EAC5C,IAAI,CAACS,MAAM,EAAE;IACX,MAAM,IAAIC,KAAK,CAAC,+DAA+D,CAAC;EAClF;EACA,MAAMC,YAAY,GAAGF,MAAM,CAACG,KAAK,CAACC,IAAI;EACtC,OAAOd,OAAO,CACZ,MAAMG,cAAc,CAACI,WAAW,EAAEK,YAAY,CAAwB,EACtE,CAACL,WAAW,EAAEK,YAAY,CAC5B,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { getPresetVars } from "../preset-vars.js";
|
|
4
|
+
/**
|
|
5
|
+
* Build the CSS custom-property map for a preset, ready to be applied to a
|
|
6
|
+
* subtree. Always includes the resolved `--color-*` vars so Tailwind v4
|
|
7
|
+
* `@theme` utilities (e.g. `bg-background`) honour the scope.
|
|
8
|
+
*/
|
|
9
|
+
export function buildScopeVars(colorPreset, mode) {
|
|
10
|
+
return getPresetVars(colorPreset, mode, {
|
|
11
|
+
includeResolvedColorVars: true
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=style-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getPresetVars","buildScopeVars","colorPreset","mode","includeResolvedColorVars"],"sourceRoot":"../../../../src","sources":["theme/color-scope/style-builder.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,mBAAgB;AAG9C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,WAAyB,EACzBC,IAAsB,EACE;EACxB,OAAOH,aAAa,CAACE,WAAW,EAAEC,IAAI,EAAE;IAAEC,wBAAwB,EAAE;EAAK,CAAC,CAAC;AAC7E","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export { BloomThemeProvider
|
|
3
|
+
export { BloomThemeProvider } from "./BloomThemeProvider.js";
|
|
4
|
+
export { BloomColorScope, useColorScopeStyle } from './color-scope';
|
|
4
5
|
export { buildTheme, STATUS_COLORS } from "./build-theme.js";
|
|
5
6
|
export { useTheme, useThemeColor, useBloomTheme } from "./use-theme.js";
|
|
6
7
|
export { APP_COLOR_NAMES, PREMIUM_COLOR_NAMES, APP_COLOR_PRESETS, HEX_TO_APP_COLOR, hexToAppColorName } from "./color-presets.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BloomThemeProvider","BloomColorScope","buildTheme","STATUS_COLORS","useTheme","useThemeColor","useBloomTheme","APP_COLOR_NAMES","PREMIUM_COLOR_NAMES","APP_COLOR_PRESETS","HEX_TO_APP_COLOR","hexToAppColorName","getPresetVars","applyPresetVarsToDocument","applyDarkClass","setColorSchemeSafe","initCssInteropDarkMode","webLocalStorage"],"sourceRoot":"../../../src","sources":["theme/index.ts"],"mappings":";;AAAA,SAASA,kBAAkB,
|
|
1
|
+
{"version":3,"names":["BloomThemeProvider","BloomColorScope","useColorScopeStyle","buildTheme","STATUS_COLORS","useTheme","useThemeColor","useBloomTheme","APP_COLOR_NAMES","PREMIUM_COLOR_NAMES","APP_COLOR_PRESETS","HEX_TO_APP_COLOR","hexToAppColorName","getPresetVars","applyPresetVarsToDocument","applyDarkClass","setColorSchemeSafe","initCssInteropDarkMode","webLocalStorage"],"sourceRoot":"../../../src","sources":["theme/index.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,yBAAsB;AAKzD,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,eAAe;AAEnE,SAASC,UAAU,EAAEC,aAAa,QAAQ,kBAAe;AACzD,SAASC,QAAQ,EAAEC,aAAa,EAAEC,aAAa,QAAQ,gBAAa;AAGpE,SACEC,eAAe,EACfC,mBAAmB,EACnBC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,QACZ,oBAAiB;AACxB,SACEC,aAAa,EACbC,yBAAyB,QACpB,kBAAe;AAEtB,SAASC,cAAc,QAAQ,uBAAoB;AACnD,SAASC,kBAAkB,QAAQ,4BAAyB;AAC5D,SAASC,sBAAsB,QAAQ,uBAAoB;AAE3D,SAASC,eAAe,QAAQ,kBAAe","ignoreList":[]}
|
|
@@ -37,22 +37,11 @@ export declare function useCommonSVGProps(props: Props): {
|
|
|
37
37
|
title?: string | undefined;
|
|
38
38
|
children?: React.ReactNode;
|
|
39
39
|
filter?: string | undefined;
|
|
40
|
-
pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
|
|
41
|
-
color?: ColorValue | undefined;
|
|
42
|
-
fontSize?: import("react-native-svg").NumberProp | undefined;
|
|
43
|
-
fontWeight?: import("react-native-svg").FontWeight | undefined;
|
|
44
|
-
fontStyle?: import("react-native-svg").FontStyle | undefined;
|
|
45
|
-
scale?: import("react-native-svg").NumberArray | undefined;
|
|
46
|
-
scaleX?: import("react-native-svg").NumberProp | undefined;
|
|
47
|
-
scaleY?: import("react-native-svg").NumberProp | undefined;
|
|
48
|
-
translateX?: import("react-native-svg").NumberProp | undefined;
|
|
49
|
-
translateY?: import("react-native-svg").NumberProp | undefined;
|
|
50
|
-
skewX?: import("react-native-svg").NumberProp | undefined;
|
|
51
|
-
skewY?: import("react-native-svg").NumberProp | undefined;
|
|
52
40
|
hitSlop?: number | import("react-native").Insets | undefined;
|
|
53
41
|
id?: string | undefined;
|
|
54
42
|
needsOffscreenAlphaCompositing?: boolean | undefined | undefined;
|
|
55
43
|
onLayout?: ((event: import("react-native").LayoutChangeEvent) => void) | undefined;
|
|
44
|
+
pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
|
|
56
45
|
removeClippedSubviews?: boolean | undefined | undefined;
|
|
57
46
|
testID?: string | undefined;
|
|
58
47
|
nativeID?: string | undefined | undefined;
|
|
@@ -139,6 +128,17 @@ export declare function useCommonSVGProps(props: Props): {
|
|
|
139
128
|
accessibilityShowsLargeContentViewer?: boolean | undefined | undefined;
|
|
140
129
|
accessibilityLargeContentTitle?: string | undefined | undefined;
|
|
141
130
|
accessibilityRespondsToUserInteraction?: boolean | undefined | undefined;
|
|
131
|
+
color?: ColorValue | undefined;
|
|
132
|
+
scale?: import("react-native-svg").NumberArray | undefined;
|
|
133
|
+
scaleX?: import("react-native-svg").NumberProp | undefined;
|
|
134
|
+
scaleY?: import("react-native-svg").NumberProp | undefined;
|
|
135
|
+
translateX?: import("react-native-svg").NumberProp | undefined;
|
|
136
|
+
translateY?: import("react-native-svg").NumberProp | undefined;
|
|
137
|
+
skewX?: import("react-native-svg").NumberProp | undefined;
|
|
138
|
+
skewY?: import("react-native-svg").NumberProp | undefined;
|
|
139
|
+
fontSize?: import("react-native-svg").NumberProp | undefined;
|
|
140
|
+
fontWeight?: import("react-native-svg").FontWeight | undefined;
|
|
141
|
+
fontStyle?: import("react-native-svg").FontStyle | undefined;
|
|
142
142
|
width?: import("react-native-svg").NumberProp | undefined;
|
|
143
143
|
height?: import("react-native-svg").NumberProp | undefined;
|
|
144
144
|
viewBox?: string | undefined;
|
|
@@ -55,13 +55,4 @@ export interface BloomThemeProviderProps {
|
|
|
55
55
|
children: React.ReactNode;
|
|
56
56
|
}
|
|
57
57
|
export declare function BloomThemeProvider({ mode: controlledMode, colorPreset: controlledPreset, defaultMode, defaultColorPreset, onModeChange, onColorPresetChange, persistKey, storage, awaitHydration, onHydrating, fonts, onFontsLoading, children, }: BloomThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
58
|
-
/**
|
|
59
|
-
* Scoped color override for a subtree. Inherits the resolved mode from the
|
|
60
|
-
* parent `BloomThemeProvider` but renders descendants with a different preset.
|
|
61
|
-
*/
|
|
62
|
-
export interface BloomColorScopeProps {
|
|
63
|
-
colorPreset: AppColorName;
|
|
64
|
-
children: React.ReactNode;
|
|
65
|
-
}
|
|
66
|
-
export declare function BloomColorScope({ colorPreset, children }: BloomColorScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
67
58
|
//# sourceMappingURL=BloomThemeProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BloomThemeProvider.d.ts","sourceRoot":"","sources":["../../../../src/theme/BloomThemeProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAQN,MAAM,OAAO,CAAC;AAQf,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAKL,KAAK,iBAAiB,EAEvB,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKhD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,YAAY,CAAC;IAC1B,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,K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,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,wDAAwD;IACxD,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEjC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAkJD,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EAAE,cAAc,EACpB,WAAW,EAAE,gBAAgB,EAC7B,WAA0B,EAC1B,kBAAmC,EACnC,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,OAAO,EACP,cAAc,EACd,WAAW,EACX,KAAY,EACZ,cAAc,EACd,QAAQ,GACT,EAAE,uBAAuB,2CAkDzB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import type { AppColorName } from '../color-presets';
|
|
4
|
+
export interface BloomColorScopeProps {
|
|
5
|
+
/** Preset to apply within this subtree. */
|
|
6
|
+
colorPreset: AppColorName;
|
|
7
|
+
/**
|
|
8
|
+
* When `true`, do not render a wrapping `<View>`. The caller owns the
|
|
9
|
+
* element that receives the CSS vars (via `useColorScopeStyle`).
|
|
10
|
+
*/
|
|
11
|
+
asChild?: boolean;
|
|
12
|
+
/** Additional style applied to the wrapping `<View>`. Ignored with `asChild`. */
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare function BloomColorScope({ colorPreset, asChild, style, children, }: BloomColorScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Escape hatch for advanced cases where the wrapping element is owned by the
|
|
19
|
+
* caller. Returns a stable native style object carrying the preset's CSS vars.
|
|
20
|
+
* Returns `undefined` when nativewind is not installed.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useColorScopeStyle(colorPreset: AppColorName): StyleProp<ViewStyle>;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAIpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgBrD,MAAM,WAAW,oBAAoB;IACnC,2CAA2C;IAC3C,WAAW,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iFAAiF;IACjF,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,OAAe,EACf,KAAK,EACL,QAAQ,GACT,EAAE,oBAAoB,2CAuBtB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC,CAUlF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AppColorName } from '../color-presets';
|
|
3
|
+
export interface BloomColorScopeProps {
|
|
4
|
+
/** Preset to apply within this subtree. */
|
|
5
|
+
colorPreset: AppColorName;
|
|
6
|
+
/**
|
|
7
|
+
* When `true`, do not render a wrapping element. The caller is responsible
|
|
8
|
+
* for placing the returned context provider over a DOM node that owns the
|
|
9
|
+
* CSS vars (via `useColorScopeStyle`).
|
|
10
|
+
*/
|
|
11
|
+
asChild?: boolean;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare function BloomColorScope({ colorPreset, asChild, children }: BloomColorScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
/**
|
|
16
|
+
* Escape hatch for advanced cases where the wrapping element is owned by the
|
|
17
|
+
* caller (e.g. a Pressable, a NativeWind-styled View that already has a style
|
|
18
|
+
* prop). Returns a stable React `style` object carrying every CSS custom
|
|
19
|
+
* property of the preset.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useColorScopeStyle(colorPreset: AppColorName): React.CSSProperties;
|
|
22
|
+
//# sourceMappingURL=index.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIrD,MAAM,WAAW,oBAAoB;IACnC,2CAA2C;IAC3C,WAAW,EAAE,YAAY,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,OAAe,EAAE,QAAQ,EAAE,EAAE,oBAAoB,2CAuB/F;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAAC,aAAa,CAUjF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppColorName } from '../color-presets';
|
|
2
|
+
/**
|
|
3
|
+
* Build the CSS custom-property map for a preset, ready to be applied to a
|
|
4
|
+
* subtree. Always includes the resolved `--color-*` vars so Tailwind v4
|
|
5
|
+
* `@theme` utilities (e.g. `bg-background`) honour the scope.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildScopeVars(colorPreset: AppColorName, mode: 'light' | 'dark'): Record<string, string>;
|
|
8
|
+
//# sourceMappingURL=style-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-builder.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/style-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,OAAO,GAAG,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { BloomThemeProvider
|
|
2
|
-
export type { BloomThemeProviderProps, BloomThemeContextValue,
|
|
1
|
+
export { BloomThemeProvider } from './BloomThemeProvider';
|
|
2
|
+
export type { BloomThemeProviderProps, BloomThemeContextValue, } from './BloomThemeProvider';
|
|
3
|
+
export { BloomColorScope, useColorScopeStyle } from './color-scope';
|
|
4
|
+
export type { BloomColorScopeProps } from './color-scope';
|
|
3
5
|
export { buildTheme, STATUS_COLORS } from './build-theme';
|
|
4
6
|
export { useTheme, useThemeColor, useBloomTheme } from './use-theme';
|
|
5
7
|
export type { Theme, ThemeColors, ThemeMode } from './types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EACV,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -37,22 +37,11 @@ export declare function useCommonSVGProps(props: Props): {
|
|
|
37
37
|
title?: string | undefined;
|
|
38
38
|
children?: React.ReactNode;
|
|
39
39
|
filter?: string | undefined;
|
|
40
|
-
pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
|
|
41
|
-
color?: ColorValue | undefined;
|
|
42
|
-
fontSize?: import("react-native-svg").NumberProp | undefined;
|
|
43
|
-
fontWeight?: import("react-native-svg").FontWeight | undefined;
|
|
44
|
-
fontStyle?: import("react-native-svg").FontStyle | undefined;
|
|
45
|
-
scale?: import("react-native-svg").NumberArray | undefined;
|
|
46
|
-
scaleX?: import("react-native-svg").NumberProp | undefined;
|
|
47
|
-
scaleY?: import("react-native-svg").NumberProp | undefined;
|
|
48
|
-
translateX?: import("react-native-svg").NumberProp | undefined;
|
|
49
|
-
translateY?: import("react-native-svg").NumberProp | undefined;
|
|
50
|
-
skewX?: import("react-native-svg").NumberProp | undefined;
|
|
51
|
-
skewY?: import("react-native-svg").NumberProp | undefined;
|
|
52
40
|
hitSlop?: number | import("react-native").Insets | undefined;
|
|
53
41
|
id?: string | undefined;
|
|
54
42
|
needsOffscreenAlphaCompositing?: boolean | undefined | undefined;
|
|
55
43
|
onLayout?: ((event: import("react-native").LayoutChangeEvent) => void) | undefined;
|
|
44
|
+
pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
|
|
56
45
|
removeClippedSubviews?: boolean | undefined | undefined;
|
|
57
46
|
testID?: string | undefined;
|
|
58
47
|
nativeID?: string | undefined | undefined;
|
|
@@ -139,6 +128,17 @@ export declare function useCommonSVGProps(props: Props): {
|
|
|
139
128
|
accessibilityShowsLargeContentViewer?: boolean | undefined | undefined;
|
|
140
129
|
accessibilityLargeContentTitle?: string | undefined | undefined;
|
|
141
130
|
accessibilityRespondsToUserInteraction?: boolean | undefined | undefined;
|
|
131
|
+
color?: ColorValue | undefined;
|
|
132
|
+
scale?: import("react-native-svg").NumberArray | undefined;
|
|
133
|
+
scaleX?: import("react-native-svg").NumberProp | undefined;
|
|
134
|
+
scaleY?: import("react-native-svg").NumberProp | undefined;
|
|
135
|
+
translateX?: import("react-native-svg").NumberProp | undefined;
|
|
136
|
+
translateY?: import("react-native-svg").NumberProp | undefined;
|
|
137
|
+
skewX?: import("react-native-svg").NumberProp | undefined;
|
|
138
|
+
skewY?: import("react-native-svg").NumberProp | undefined;
|
|
139
|
+
fontSize?: import("react-native-svg").NumberProp | undefined;
|
|
140
|
+
fontWeight?: import("react-native-svg").FontWeight | undefined;
|
|
141
|
+
fontStyle?: import("react-native-svg").FontStyle | undefined;
|
|
142
142
|
width?: import("react-native-svg").NumberProp | undefined;
|
|
143
143
|
height?: import("react-native-svg").NumberProp | undefined;
|
|
144
144
|
viewBox?: string | undefined;
|
|
@@ -55,13 +55,4 @@ export interface BloomThemeProviderProps {
|
|
|
55
55
|
children: React.ReactNode;
|
|
56
56
|
}
|
|
57
57
|
export declare function BloomThemeProvider({ mode: controlledMode, colorPreset: controlledPreset, defaultMode, defaultColorPreset, onModeChange, onColorPresetChange, persistKey, storage, awaitHydration, onHydrating, fonts, onFontsLoading, children, }: BloomThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
58
|
-
/**
|
|
59
|
-
* Scoped color override for a subtree. Inherits the resolved mode from the
|
|
60
|
-
* parent `BloomThemeProvider` but renders descendants with a different preset.
|
|
61
|
-
*/
|
|
62
|
-
export interface BloomColorScopeProps {
|
|
63
|
-
colorPreset: AppColorName;
|
|
64
|
-
children: React.ReactNode;
|
|
65
|
-
}
|
|
66
|
-
export declare function BloomColorScope({ colorPreset, children }: BloomColorScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
67
58
|
//# sourceMappingURL=BloomThemeProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BloomThemeProvider.d.ts","sourceRoot":"","sources":["../../../../src/theme/BloomThemeProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAQN,MAAM,OAAO,CAAC;AAQf,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAKL,KAAK,iBAAiB,EAEvB,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKhD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,YAAY,CAAC;IAC1B,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACnC,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC/C;;;;OAIG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,iBAAiB,8CAAqD,CAAC;AAEpF,MAAM,WAAW,uBAAuB;IACtC,uFAAuF;IACvF,IA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,EAC7B,WAA0B,EAC1B,kBAAmC,EACnC,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,OAAO,EACP,cAAc,EACd,WAAW,EACX,KAAY,EACZ,cAAc,EACd,QAAQ,GACT,EAAE,uBAAuB,2CAkDzB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import type { AppColorName } from '../color-presets';
|
|
4
|
+
export interface BloomColorScopeProps {
|
|
5
|
+
/** Preset to apply within this subtree. */
|
|
6
|
+
colorPreset: AppColorName;
|
|
7
|
+
/**
|
|
8
|
+
* When `true`, do not render a wrapping `<View>`. The caller owns the
|
|
9
|
+
* element that receives the CSS vars (via `useColorScopeStyle`).
|
|
10
|
+
*/
|
|
11
|
+
asChild?: boolean;
|
|
12
|
+
/** Additional style applied to the wrapping `<View>`. Ignored with `asChild`. */
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare function BloomColorScope({ colorPreset, asChild, style, children, }: BloomColorScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Escape hatch for advanced cases where the wrapping element is owned by the
|
|
19
|
+
* caller. Returns a stable native style object carrying the preset's CSS vars.
|
|
20
|
+
* Returns `undefined` when nativewind is not installed.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useColorScopeStyle(colorPreset: AppColorName): StyleProp<ViewStyle>;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAIpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgBrD,MAAM,WAAW,oBAAoB;IACnC,2CAA2C;IAC3C,WAAW,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iFAAiF;IACjF,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,OAAe,EACf,KAAK,EACL,QAAQ,GACT,EAAE,oBAAoB,2CAuBtB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC,CAUlF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AppColorName } from '../color-presets';
|
|
3
|
+
export interface BloomColorScopeProps {
|
|
4
|
+
/** Preset to apply within this subtree. */
|
|
5
|
+
colorPreset: AppColorName;
|
|
6
|
+
/**
|
|
7
|
+
* When `true`, do not render a wrapping element. The caller is responsible
|
|
8
|
+
* for placing the returned context provider over a DOM node that owns the
|
|
9
|
+
* CSS vars (via `useColorScopeStyle`).
|
|
10
|
+
*/
|
|
11
|
+
asChild?: boolean;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare function BloomColorScope({ colorPreset, asChild, children }: BloomColorScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
/**
|
|
16
|
+
* Escape hatch for advanced cases where the wrapping element is owned by the
|
|
17
|
+
* caller (e.g. a Pressable, a NativeWind-styled View that already has a style
|
|
18
|
+
* prop). Returns a stable React `style` object carrying every CSS custom
|
|
19
|
+
* property of the preset.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useColorScopeStyle(colorPreset: AppColorName): React.CSSProperties;
|
|
22
|
+
//# sourceMappingURL=index.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIrD,MAAM,WAAW,oBAAoB;IACnC,2CAA2C;IAC3C,WAAW,EAAE,YAAY,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,OAAe,EAAE,QAAQ,EAAE,EAAE,oBAAoB,2CAuB/F;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAAC,aAAa,CAUjF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppColorName } from '../color-presets';
|
|
2
|
+
/**
|
|
3
|
+
* Build the CSS custom-property map for a preset, ready to be applied to a
|
|
4
|
+
* subtree. Always includes the resolved `--color-*` vars so Tailwind v4
|
|
5
|
+
* `@theme` utilities (e.g. `bg-background`) honour the scope.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildScopeVars(colorPreset: AppColorName, mode: 'light' | 'dark'): Record<string, string>;
|
|
8
|
+
//# sourceMappingURL=style-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-builder.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/style-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,OAAO,GAAG,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { BloomThemeProvider
|
|
2
|
-
export type { BloomThemeProviderProps, BloomThemeContextValue,
|
|
1
|
+
export { BloomThemeProvider } from './BloomThemeProvider';
|
|
2
|
+
export type { BloomThemeProviderProps, BloomThemeContextValue, } from './BloomThemeProvider';
|
|
3
|
+
export { BloomColorScope, useColorScopeStyle } from './color-scope';
|
|
4
|
+
export type { BloomColorScopeProps } from './color-scope';
|
|
3
5
|
export { buildTheme, STATUS_COLORS } from './build-theme';
|
|
4
6
|
export { useTheme, useThemeColor, useBloomTheme } from './use-theme';
|
|
5
7
|
export type { Theme, ThemeColors, ThemeMode } from './types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EACV,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { render } from '@testing-library/react-native';
|
|
4
|
+
|
|
5
|
+
import { BloomThemeProvider } from '../theme/BloomThemeProvider';
|
|
6
|
+
import { BloomColorScope } from '../theme/color-scope';
|
|
7
|
+
import { useBloomTheme } from '../theme/use-theme';
|
|
8
|
+
|
|
9
|
+
function CurrentPreset() {
|
|
10
|
+
const { colorPreset } = useBloomTheme();
|
|
11
|
+
return <Text testID="preset">{colorPreset}</Text>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe('BloomColorScope', () => {
|
|
15
|
+
it('overrides the colorPreset of its subtree without affecting the parent', () => {
|
|
16
|
+
const { getAllByTestId } = render(
|
|
17
|
+
<BloomThemeProvider defaultColorPreset="blue" fonts={false}>
|
|
18
|
+
<CurrentPreset />
|
|
19
|
+
<BloomColorScope colorPreset="green">
|
|
20
|
+
<CurrentPreset />
|
|
21
|
+
</BloomColorScope>
|
|
22
|
+
</BloomThemeProvider>,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const presets = getAllByTestId('preset').map((node) => node.props.children);
|
|
26
|
+
expect(presets[0]).toBe('blue');
|
|
27
|
+
expect(presets[1]).toBe('green');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders children directly with asChild (no wrapper element)', () => {
|
|
31
|
+
const { getByTestId } = render(
|
|
32
|
+
<BloomThemeProvider defaultColorPreset="blue" fonts={false}>
|
|
33
|
+
<BloomColorScope colorPreset="purple" asChild>
|
|
34
|
+
<CurrentPreset />
|
|
35
|
+
</BloomColorScope>
|
|
36
|
+
</BloomThemeProvider>,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
expect(getByTestId('preset').props.children).toBe('purple');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('throws when used outside BloomThemeProvider', () => {
|
|
43
|
+
const consoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
44
|
+
expect(() =>
|
|
45
|
+
render(
|
|
46
|
+
<BloomColorScope colorPreset="red">
|
|
47
|
+
<CurrentPreset />
|
|
48
|
+
</BloomColorScope>,
|
|
49
|
+
),
|
|
50
|
+
).toThrow('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
51
|
+
consoleError.mockRestore();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -304,27 +304,4 @@ export function BloomThemeProvider({
|
|
|
304
304
|
);
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
/**
|
|
308
|
-
* Scoped color override for a subtree. Inherits the resolved mode from the
|
|
309
|
-
* parent `BloomThemeProvider` but renders descendants with a different preset.
|
|
310
|
-
*/
|
|
311
|
-
export interface BloomColorScopeProps {
|
|
312
|
-
colorPreset: AppColorName;
|
|
313
|
-
children: React.ReactNode;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
export function BloomColorScope({ colorPreset, children }: BloomColorScopeProps) {
|
|
317
|
-
const parent = useContext(BloomThemeContext);
|
|
318
|
-
if (!parent) {
|
|
319
|
-
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
320
|
-
}
|
|
321
307
|
|
|
322
|
-
const contextValue = useMemo<BloomThemeContextValue>(() => {
|
|
323
|
-
const theme = buildTheme(colorPreset, parent.theme.mode);
|
|
324
|
-
return { ...parent, theme, colorPreset };
|
|
325
|
-
}, [colorPreset, parent]);
|
|
326
|
-
|
|
327
|
-
return (
|
|
328
|
-
<BloomThemeContext.Provider value={contextValue}>{children}</BloomThemeContext.Provider>
|
|
329
|
-
);
|
|
330
|
-
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
|
+
import { View, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { BloomThemeContext, type BloomThemeContextValue } from '../BloomThemeProvider';
|
|
5
|
+
import { buildTheme } from '../build-theme';
|
|
6
|
+
import type { AppColorName } from '../color-presets';
|
|
7
|
+
import { lazyRequire } from '../../utils/lazy-require';
|
|
8
|
+
import { buildScopeVars } from './style-builder';
|
|
9
|
+
|
|
10
|
+
interface NativeWindVarsModule {
|
|
11
|
+
vars: (record: Record<string, string>) => StyleProp<ViewStyle>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const getNativeWindVars = lazyRequire<NativeWindVarsModule>('nativewind');
|
|
15
|
+
|
|
16
|
+
function presetStyle(colorPreset: AppColorName, mode: 'light' | 'dark'): StyleProp<ViewStyle> {
|
|
17
|
+
const module = getNativeWindVars();
|
|
18
|
+
if (!module || typeof module.vars !== 'function') return undefined;
|
|
19
|
+
return module.vars(buildScopeVars(colorPreset, mode));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface BloomColorScopeProps {
|
|
23
|
+
/** Preset to apply within this subtree. */
|
|
24
|
+
colorPreset: AppColorName;
|
|
25
|
+
/**
|
|
26
|
+
* When `true`, do not render a wrapping `<View>`. The caller owns the
|
|
27
|
+
* element that receives the CSS vars (via `useColorScopeStyle`).
|
|
28
|
+
*/
|
|
29
|
+
asChild?: boolean;
|
|
30
|
+
/** Additional style applied to the wrapping `<View>`. Ignored with `asChild`. */
|
|
31
|
+
style?: StyleProp<ViewStyle>;
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function BloomColorScope({
|
|
36
|
+
colorPreset,
|
|
37
|
+
asChild = false,
|
|
38
|
+
style,
|
|
39
|
+
children,
|
|
40
|
+
}: BloomColorScopeProps) {
|
|
41
|
+
const parent = useContext(BloomThemeContext);
|
|
42
|
+
if (!parent) {
|
|
43
|
+
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const resolvedMode = parent.theme.mode;
|
|
47
|
+
|
|
48
|
+
const contextValue = useMemo<BloomThemeContextValue>(() => {
|
|
49
|
+
const theme = buildTheme(colorPreset, resolvedMode);
|
|
50
|
+
return { ...parent, theme, colorPreset };
|
|
51
|
+
}, [colorPreset, resolvedMode, parent]);
|
|
52
|
+
|
|
53
|
+
const varsStyle = useMemo(
|
|
54
|
+
() => presetStyle(colorPreset, resolvedMode),
|
|
55
|
+
[colorPreset, resolvedMode],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<BloomThemeContext.Provider value={contextValue}>
|
|
60
|
+
{asChild ? children : <View style={[{ flex: 1 }, varsStyle, style]}>{children}</View>}
|
|
61
|
+
</BloomThemeContext.Provider>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Escape hatch for advanced cases where the wrapping element is owned by the
|
|
67
|
+
* caller. Returns a stable native style object carrying the preset's CSS vars.
|
|
68
|
+
* Returns `undefined` when nativewind is not installed.
|
|
69
|
+
*/
|
|
70
|
+
export function useColorScopeStyle(colorPreset: AppColorName): StyleProp<ViewStyle> {
|
|
71
|
+
const parent = useContext(BloomThemeContext);
|
|
72
|
+
if (!parent) {
|
|
73
|
+
throw new Error('useColorScopeStyle must be used within a <BloomThemeProvider>');
|
|
74
|
+
}
|
|
75
|
+
const resolvedMode = parent.theme.mode;
|
|
76
|
+
return useMemo(
|
|
77
|
+
() => presetStyle(colorPreset, resolvedMode),
|
|
78
|
+
[colorPreset, resolvedMode],
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { BloomThemeContext } from '../BloomThemeProvider';
|
|
4
|
+
import { buildTheme } from '../build-theme';
|
|
5
|
+
import type { AppColorName } from '../color-presets';
|
|
6
|
+
import { BloomThemeContextValue } from '../BloomThemeProvider';
|
|
7
|
+
import { buildScopeVars } from './style-builder';
|
|
8
|
+
|
|
9
|
+
export interface BloomColorScopeProps {
|
|
10
|
+
/** Preset to apply within this subtree. */
|
|
11
|
+
colorPreset: AppColorName;
|
|
12
|
+
/**
|
|
13
|
+
* When `true`, do not render a wrapping element. The caller is responsible
|
|
14
|
+
* for placing the returned context provider over a DOM node that owns the
|
|
15
|
+
* CSS vars (via `useColorScopeStyle`).
|
|
16
|
+
*/
|
|
17
|
+
asChild?: boolean;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function BloomColorScope({ colorPreset, asChild = false, children }: BloomColorScopeProps) {
|
|
22
|
+
const parent = useContext(BloomThemeContext);
|
|
23
|
+
if (!parent) {
|
|
24
|
+
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const resolvedMode = parent.theme.mode;
|
|
28
|
+
|
|
29
|
+
const contextValue = useMemo<BloomThemeContextValue>(() => {
|
|
30
|
+
const theme = buildTheme(colorPreset, resolvedMode);
|
|
31
|
+
return { ...parent, theme, colorPreset };
|
|
32
|
+
}, [colorPreset, resolvedMode, parent]);
|
|
33
|
+
|
|
34
|
+
const style = useMemo(
|
|
35
|
+
() => buildScopeVars(colorPreset, resolvedMode) as React.CSSProperties,
|
|
36
|
+
[colorPreset, resolvedMode],
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<BloomThemeContext.Provider value={contextValue}>
|
|
41
|
+
{asChild ? children : <div style={style}>{children}</div>}
|
|
42
|
+
</BloomThemeContext.Provider>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Escape hatch for advanced cases where the wrapping element is owned by the
|
|
48
|
+
* caller (e.g. a Pressable, a NativeWind-styled View that already has a style
|
|
49
|
+
* prop). Returns a stable React `style` object carrying every CSS custom
|
|
50
|
+
* property of the preset.
|
|
51
|
+
*/
|
|
52
|
+
export function useColorScopeStyle(colorPreset: AppColorName): React.CSSProperties {
|
|
53
|
+
const parent = useContext(BloomThemeContext);
|
|
54
|
+
if (!parent) {
|
|
55
|
+
throw new Error('useColorScopeStyle must be used within a <BloomThemeProvider>');
|
|
56
|
+
}
|
|
57
|
+
const resolvedMode = parent.theme.mode;
|
|
58
|
+
return useMemo(
|
|
59
|
+
() => buildScopeVars(colorPreset, resolvedMode) as React.CSSProperties,
|
|
60
|
+
[colorPreset, resolvedMode],
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getPresetVars } from '../preset-vars';
|
|
2
|
+
import type { AppColorName } from '../color-presets';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Build the CSS custom-property map for a preset, ready to be applied to a
|
|
6
|
+
* subtree. Always includes the resolved `--color-*` vars so Tailwind v4
|
|
7
|
+
* `@theme` utilities (e.g. `bg-background`) honour the scope.
|
|
8
|
+
*/
|
|
9
|
+
export function buildScopeVars(
|
|
10
|
+
colorPreset: AppColorName,
|
|
11
|
+
mode: 'light' | 'dark',
|
|
12
|
+
): Record<string, string> {
|
|
13
|
+
return getPresetVars(colorPreset, mode, { includeResolvedColorVars: true });
|
|
14
|
+
}
|
package/src/theme/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { BloomThemeProvider
|
|
1
|
+
export { BloomThemeProvider } from './BloomThemeProvider';
|
|
2
2
|
export type {
|
|
3
3
|
BloomThemeProviderProps,
|
|
4
4
|
BloomThemeContextValue,
|
|
5
|
-
BloomColorScopeProps,
|
|
6
5
|
} from './BloomThemeProvider';
|
|
6
|
+
export { BloomColorScope, useColorScopeStyle } from './color-scope';
|
|
7
|
+
export type { BloomColorScopeProps } from './color-scope';
|
|
7
8
|
export { buildTheme, STATUS_COLORS } from './build-theme';
|
|
8
9
|
export { useTheme, useThemeColor, useBloomTheme } from './use-theme';
|
|
9
10
|
export type { Theme, ThemeColors, ThemeMode } from './types';
|