@oxy.so/bloom 7.26.1 → 7.27.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/docs/adoption-matrix.mdx +2 -2
- package/docs/design-tokens.mdx +41 -0
- package/docs/overlay.mdx +4 -0
- package/docs/swipe-row.mdx +30 -3
- package/lib/commonjs/agent-creator/ShapeArc.js +81 -73
- package/lib/commonjs/agent-creator/ShapeArc.js.map +1 -1
- package/lib/commonjs/message-bubble/SwipeToReply.js +6 -1
- package/lib/commonjs/message-bubble/SwipeToReply.js.map +1 -1
- package/lib/commonjs/overlay/ModalKeyboard.js +3 -2
- package/lib/commonjs/overlay/ModalKeyboard.js.map +1 -1
- package/lib/commonjs/portal/Portal.js +11 -2
- package/lib/commonjs/portal/Portal.js.map +1 -1
- package/lib/commonjs/portal/Portal.web.js +10 -1
- package/lib/commonjs/portal/Portal.web.js.map +1 -1
- package/lib/commonjs/swipe-row/SwipeRow.js +10 -2
- package/lib/commonjs/swipe-row/SwipeRow.js.map +1 -1
- package/lib/commonjs/theme/BloomThemeProvider.js +30 -4
- package/lib/commonjs/theme/BloomThemeProvider.js.map +1 -1
- package/lib/commonjs/theme/color-scope/ColorScope.js +14 -27
- package/lib/commonjs/theme/color-scope/ColorScope.js.map +1 -1
- package/lib/commonjs/theme/color-scope/ColorScope.web.js +15 -23
- package/lib/commonjs/theme/color-scope/ColorScope.web.js.map +1 -1
- package/lib/commonjs/theme/color-scope/ThemeScopeBridge.js +36 -0
- package/lib/commonjs/theme/color-scope/ThemeScopeBridge.js.map +1 -0
- package/lib/commonjs/theme/color-scope/context.js +11 -0
- package/lib/commonjs/theme/color-scope/context.js.map +1 -0
- package/lib/commonjs/theme/color-scope/resolve-scope.js +86 -0
- package/lib/commonjs/theme/color-scope/resolve-scope.js.map +1 -0
- package/lib/commonjs/theme/color-scope/types.js +6 -0
- package/lib/commonjs/theme/color-scope/types.js.map +1 -0
- package/lib/commonjs/theme/color-scope/use-scope.js +44 -0
- package/lib/commonjs/theme/color-scope/use-scope.js.map +1 -0
- package/lib/commonjs/theme/seed-scope/SeedScope.js +26 -1
- package/lib/commonjs/theme/seed-scope/SeedScope.js.map +1 -1
- package/lib/commonjs/theme/seed-scope/SeedScope.web.js +26 -1
- package/lib/commonjs/theme/seed-scope/SeedScope.web.js.map +1 -1
- package/lib/module/agent-creator/ShapeArc.js +81 -73
- package/lib/module/agent-creator/ShapeArc.js.map +1 -1
- package/lib/module/message-bubble/SwipeToReply.js +6 -1
- package/lib/module/message-bubble/SwipeToReply.js.map +1 -1
- package/lib/module/overlay/ModalKeyboard.js +3 -2
- package/lib/module/overlay/ModalKeyboard.js.map +1 -1
- package/lib/module/portal/Portal.js +11 -2
- package/lib/module/portal/Portal.js.map +1 -1
- package/lib/module/portal/Portal.web.js +11 -2
- package/lib/module/portal/Portal.web.js.map +1 -1
- package/lib/module/swipe-row/SwipeRow.js +10 -2
- package/lib/module/swipe-row/SwipeRow.js.map +1 -1
- package/lib/module/theme/BloomThemeProvider.js +30 -4
- package/lib/module/theme/BloomThemeProvider.js.map +1 -1
- package/lib/module/theme/color-scope/ColorScope.js +15 -28
- package/lib/module/theme/color-scope/ColorScope.js.map +1 -1
- package/lib/module/theme/color-scope/ColorScope.web.js +15 -23
- package/lib/module/theme/color-scope/ColorScope.web.js.map +1 -1
- package/lib/module/theme/color-scope/ThemeScopeBridge.js +32 -0
- package/lib/module/theme/color-scope/ThemeScopeBridge.js.map +1 -0
- package/lib/module/theme/color-scope/context.js +8 -0
- package/lib/module/theme/color-scope/context.js.map +1 -0
- package/lib/module/theme/color-scope/resolve-scope.js +82 -0
- package/lib/module/theme/color-scope/resolve-scope.js.map +1 -0
- package/lib/module/theme/color-scope/types.js +4 -0
- package/lib/module/theme/color-scope/types.js.map +1 -0
- package/lib/module/theme/color-scope/use-scope.js +40 -0
- package/lib/module/theme/color-scope/use-scope.js.map +1 -0
- package/lib/module/theme/seed-scope/SeedScope.js +26 -1
- package/lib/module/theme/seed-scope/SeedScope.js.map +1 -1
- package/lib/module/theme/seed-scope/SeedScope.web.js +26 -1
- package/lib/module/theme/seed-scope/SeedScope.web.js.map +1 -1
- package/lib/typescript/commonjs/agent-creator/ShapeArc.d.ts.map +1 -1
- package/lib/typescript/commonjs/message-bubble/SwipeToReply.d.ts.map +1 -1
- package/lib/typescript/commonjs/overlay/ModalKeyboard.d.ts.map +1 -1
- package/lib/typescript/commonjs/portal/Portal.d.ts.map +1 -1
- package/lib/typescript/commonjs/portal/Portal.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/swipe-row/SwipeRow.d.ts +9 -2
- package/lib/typescript/commonjs/swipe-row/SwipeRow.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/BloomThemeProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/color-scope/ColorScope.d.ts +7 -2
- package/lib/typescript/commonjs/theme/color-scope/ColorScope.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/color-scope/ColorScope.web.d.ts +7 -2
- package/lib/typescript/commonjs/theme/color-scope/ColorScope.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/color-scope/ThemeScopeBridge.d.ts +9 -0
- package/lib/typescript/commonjs/theme/color-scope/ThemeScopeBridge.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/color-scope/context.d.ts +14 -0
- package/lib/typescript/commonjs/theme/color-scope/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/color-scope/index.d.ts +1 -0
- package/lib/typescript/commonjs/theme/color-scope/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/color-scope/index.web.d.ts +1 -0
- package/lib/typescript/commonjs/theme/color-scope/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/color-scope/resolve-scope.d.ts +5 -0
- package/lib/typescript/commonjs/theme/color-scope/resolve-scope.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/color-scope/types.d.ts +4 -0
- package/lib/typescript/commonjs/theme/color-scope/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/color-scope/use-scope.d.ts +9 -0
- package/lib/typescript/commonjs/theme/color-scope/use-scope.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/index.web.d.ts +1 -1
- package/lib/typescript/commonjs/theme/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/seed-scope/SeedScope.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/seed-scope/SeedScope.web.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/ShapeArc.d.ts.map +1 -1
- package/lib/typescript/module/message-bubble/SwipeToReply.d.ts.map +1 -1
- package/lib/typescript/module/overlay/ModalKeyboard.d.ts.map +1 -1
- package/lib/typescript/module/portal/Portal.d.ts.map +1 -1
- package/lib/typescript/module/portal/Portal.web.d.ts.map +1 -1
- package/lib/typescript/module/swipe-row/SwipeRow.d.ts +9 -2
- package/lib/typescript/module/swipe-row/SwipeRow.d.ts.map +1 -1
- package/lib/typescript/module/theme/BloomThemeProvider.d.ts.map +1 -1
- package/lib/typescript/module/theme/color-scope/ColorScope.d.ts +7 -2
- package/lib/typescript/module/theme/color-scope/ColorScope.d.ts.map +1 -1
- package/lib/typescript/module/theme/color-scope/ColorScope.web.d.ts +7 -2
- package/lib/typescript/module/theme/color-scope/ColorScope.web.d.ts.map +1 -1
- package/lib/typescript/module/theme/color-scope/ThemeScopeBridge.d.ts +9 -0
- package/lib/typescript/module/theme/color-scope/ThemeScopeBridge.d.ts.map +1 -0
- package/lib/typescript/module/theme/color-scope/context.d.ts +14 -0
- package/lib/typescript/module/theme/color-scope/context.d.ts.map +1 -0
- package/lib/typescript/module/theme/color-scope/index.d.ts +1 -0
- package/lib/typescript/module/theme/color-scope/index.d.ts.map +1 -1
- package/lib/typescript/module/theme/color-scope/index.web.d.ts +1 -0
- package/lib/typescript/module/theme/color-scope/index.web.d.ts.map +1 -1
- package/lib/typescript/module/theme/color-scope/resolve-scope.d.ts +5 -0
- package/lib/typescript/module/theme/color-scope/resolve-scope.d.ts.map +1 -0
- package/lib/typescript/module/theme/color-scope/types.d.ts +4 -0
- package/lib/typescript/module/theme/color-scope/types.d.ts.map +1 -0
- package/lib/typescript/module/theme/color-scope/use-scope.d.ts +9 -0
- package/lib/typescript/module/theme/color-scope/use-scope.d.ts.map +1 -0
- package/lib/typescript/module/theme/index.d.ts +1 -1
- package/lib/typescript/module/theme/index.d.ts.map +1 -1
- package/lib/typescript/module/theme/index.web.d.ts +1 -1
- package/lib/typescript/module/theme/index.web.d.ts.map +1 -1
- package/lib/typescript/module/theme/seed-scope/SeedScope.d.ts.map +1 -1
- package/lib/typescript/module/theme/seed-scope/SeedScope.web.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agent-creator/ShapeArc.tsx +5 -1
- package/src/message-bubble/SwipeToReply.tsx +6 -2
- package/src/overlay/ModalKeyboard.tsx +3 -2
- package/src/portal/Portal.tsx +19 -12
- package/src/portal/Portal.web.tsx +7 -2
- package/src/swipe-row/SwipeRow.tsx +13 -3
- package/src/theme/BloomThemeProvider.tsx +14 -2
- package/src/theme/color-scope/ColorScope.tsx +20 -31
- package/src/theme/color-scope/ColorScope.web.tsx +18 -37
- package/src/theme/color-scope/ThemeScopeBridge.tsx +30 -0
- package/src/theme/color-scope/context.ts +20 -0
- package/src/theme/color-scope/index.ts +1 -0
- package/src/theme/color-scope/index.web.ts +1 -0
- package/src/theme/color-scope/resolve-scope.ts +82 -0
- package/src/theme/color-scope/types.ts +4 -0
- package/src/theme/color-scope/use-scope.ts +46 -0
- package/src/theme/index.ts +1 -1
- package/src/theme/index.web.ts +1 -1
- package/src/theme/seed-scope/SeedScope.tsx +11 -1
- package/src/theme/seed-scope/SeedScope.web.tsx +11 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,iFAAiF;AACjF,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AppColorName } from '../color-presets';
|
|
2
|
+
import { type ScopeState } from './context';
|
|
3
|
+
import type { BloomColorScopeTokens } from './types';
|
|
4
|
+
export declare function useScope(colorPreset?: AppColorName, mode?: 'light' | 'dark', tokens?: BloomColorScopeTokens): {
|
|
5
|
+
context: import("..").BloomThemeContextValue;
|
|
6
|
+
state: ScopeState | null;
|
|
7
|
+
vars: Record<string, string> | undefined;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=use-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-scope.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/use-scope.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAwC,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAGlF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,wBAAgB,QAAQ,CACtB,WAAW,CAAC,EAAE,YAAY,EAC1B,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,EACvB,MAAM,CAAC,EAAE,qBAAqB;;;;EAiC/B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BloomThemeProvider } from './BloomThemeProvider';
|
|
2
2
|
export type { BloomThemeProviderProps, BloomThemeContextValue, } from './BloomThemeProvider';
|
|
3
3
|
export { BloomColorScope, useColorScopeStyle } from './color-scope';
|
|
4
|
-
export type { BloomColorScopeProps } from './color-scope';
|
|
4
|
+
export type { BloomColorScopeProps, BloomColorScopeTokens } from './color-scope';
|
|
5
5
|
export { BloomSeedScope } from './seed-scope';
|
|
6
6
|
export type { BloomSeedScopeProps } from './seed-scope';
|
|
7
7
|
export { roleColorsToPresetTokens } from './color-scope/seed-scope';
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAepE,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAClF,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChE,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACnF,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC7G,YAAY,EACV,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/D,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAK/D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAMnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG1D,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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BloomThemeProvider } from './BloomThemeProvider';
|
|
2
2
|
export type { BloomThemeProviderProps, BloomThemeContextValue, } from './BloomThemeProvider';
|
|
3
3
|
export { BloomColorScope, useColorScopeStyle } from './color-scope/index.web';
|
|
4
|
-
export type { BloomColorScopeProps } from './color-scope/index.web';
|
|
4
|
+
export type { BloomColorScopeProps, BloomColorScopeTokens } from './color-scope/index.web';
|
|
5
5
|
export { BloomSeedScope } from './seed-scope/index.web';
|
|
6
6
|
export type { BloomSeedScopeProps } from './seed-scope/index.web';
|
|
7
7
|
export { roleColorsToPresetTokens } from './color-scope/seed-scope';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/theme/index.web.ts"],"names":[],"mappings":"AAKA,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,yBAAyB,CAAC;AAC9E,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/theme/index.web.ts"],"names":[],"mappings":"AAKA,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,yBAAyB,CAAC;AAC9E,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAepE,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAClF,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChE,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACnF,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC7G,YAAY,EACV,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/D,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAK/D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAMnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG1D,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SeedScope.d.ts","sourceRoot":"","sources":["../../../../../src/theme/seed-scope/SeedScope.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAC3F,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAMpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"SeedScope.d.ts","sourceRoot":"","sources":["../../../../../src/theme/seed-scope/SeedScope.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAC3F,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAMpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0GAA0G;IAC1G,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,OAAO,EACP,aAAa,EACb,OAAe,EACf,KAAK,EACL,QAAQ,GACT,EAAE,mBAAmB,2CA0DrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SeedScope.web.d.ts","sourceRoot":"","sources":["../../../../../src/theme/seed-scope/SeedScope.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAK3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"SeedScope.web.d.ts","sourceRoot":"","sources":["../../../../../src/theme/seed-scope/SeedScope.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAK3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yGAAyG;IACzG,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAoBD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,OAAO,EACP,aAAa,EACb,OAAe,EACf,KAAK,EACL,QAAQ,GACT,EAAE,mBAAmB,2CAwDrB"}
|
package/package.json
CHANGED
|
@@ -245,7 +245,11 @@ export function ShapeArc({
|
|
|
245
245
|
(slot) => choices[wrap(slot, choices.length)]?.id === value,
|
|
246
246
|
);
|
|
247
247
|
return (
|
|
248
|
-
|
|
248
|
+
// `touchAction="pan-y"`, not the `touch-pan-y` class below: RNGH writes an
|
|
249
|
+
// INLINE `touch-action: none` on this view on web, which beats the class,
|
|
250
|
+
// so a touch that lands on the arc could never scroll the page. The class
|
|
251
|
+
// stays for the moment before the handler attaches.
|
|
252
|
+
<GestureDetector gesture={drag} touchAction="pan-y">
|
|
249
253
|
<ListboxView
|
|
250
254
|
ref={ref}
|
|
251
255
|
role="listbox"
|
|
@@ -29,7 +29,11 @@ import type { MessageDirection } from './types';
|
|
|
29
29
|
* releases animate home, so the row never stays displaced.
|
|
30
30
|
*
|
|
31
31
|
* The pan activates only after `activeOffsetX`, so a vertical flick through the
|
|
32
|
-
* transcript is still a scroll and a tap is still a tap.
|
|
32
|
+
* transcript is still a scroll and a tap is still a tap. The detector also
|
|
33
|
+
* passes `touchAction="pan-y"`: RNGH's web default is `touch-action: none`,
|
|
34
|
+
* which would stop a touch browser scrolling the transcript from any bubble.
|
|
35
|
+
* The web path above never mounts the detector today, so this is inert until
|
|
36
|
+
* someone enables it — it is here so enabling it cannot freeze the transcript.
|
|
33
37
|
*/
|
|
34
38
|
|
|
35
39
|
const TRAVEL = 64;
|
|
@@ -103,7 +107,7 @@ export function SwipeToReply({
|
|
|
103
107
|
>
|
|
104
108
|
<RiArrowGoBackLine width={18} height={18} fill={paint.muted} />
|
|
105
109
|
</Animated.View>
|
|
106
|
-
<GestureDetector gesture={pan}>
|
|
110
|
+
<GestureDetector gesture={pan} touchAction="pan-y">
|
|
107
111
|
<Animated.View style={rowStyle}>{children}</Animated.View>
|
|
108
112
|
</GestureDetector>
|
|
109
113
|
</View>
|
|
@@ -59,11 +59,12 @@ export function ModalKeyboard({ panelRef, closing = false, dismissible, dismiss
|
|
|
59
59
|
// A frame later, so content that focuses itself on mount has done so.
|
|
60
60
|
const frame = requestAnimationFrame(() => {
|
|
61
61
|
const node = panel();
|
|
62
|
-
|
|
62
|
+
// A fast dismissal can restore the opener before this entry frame runs.
|
|
63
|
+
if (state.current.closing || !node || node.contains(document.activeElement) || !isTopmostOverlayLayer(layer)) return;
|
|
63
64
|
initialFocusWithin(node).focus({ preventScroll: true });
|
|
64
65
|
});
|
|
65
66
|
const onTab = (event: KeyboardEvent) => {
|
|
66
|
-
if (event.defaultPrevented || !isTopmostOverlayLayer(layer)) return;
|
|
67
|
+
if (state.current.closing || event.defaultPrevented || !isTopmostOverlayLayer(layer)) return;
|
|
67
68
|
wrapTab(event, panel());
|
|
68
69
|
};
|
|
69
70
|
// Capture: a text field in the panel stops its own keydowns.
|
package/src/portal/Portal.tsx
CHANGED
|
@@ -12,6 +12,9 @@ import React, {
|
|
|
12
12
|
} from 'react';
|
|
13
13
|
import { View, StyleSheet, Platform } from 'react-native';
|
|
14
14
|
import { Z_INDEX } from '../styles/z-index';
|
|
15
|
+
import { BloomThemeContext } from '../theme/BloomThemeProvider';
|
|
16
|
+
import { ThemeScopeContext } from '../theme/color-scope/context';
|
|
17
|
+
import { ThemeScopeBridge } from '../theme/color-scope/ThemeScopeBridge';
|
|
15
18
|
import { WEB_POSITION_FIXED } from '../styles/web-view-style';
|
|
16
19
|
|
|
17
20
|
type Component = React.ReactElement;
|
|
@@ -48,22 +51,19 @@ function createPortalGroup() {
|
|
|
48
51
|
setOutlet(<>{Object.values(map.current)}</>);
|
|
49
52
|
}, []);
|
|
50
53
|
|
|
51
|
-
const contextValue = useMemo(
|
|
52
|
-
() => ({ outlet, append, remove }),
|
|
53
|
-
[outlet, append, remove],
|
|
54
|
-
);
|
|
54
|
+
const contextValue = useMemo(() => ({ outlet, append, remove }), [outlet, append, remove]);
|
|
55
55
|
|
|
56
|
-
return
|
|
57
|
-
<Context.Provider value={contextValue}>
|
|
58
|
-
{props.children}
|
|
59
|
-
</Context.Provider>
|
|
60
|
-
);
|
|
56
|
+
return <Context.Provider value={contextValue}>{props.children}</Context.Provider>;
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
function Outlet() {
|
|
64
60
|
const ctx = useContext(Context);
|
|
65
61
|
if (Platform.OS === 'web') {
|
|
66
|
-
return
|
|
62
|
+
return (
|
|
63
|
+
<View pointerEvents="box-none" style={styles.portalOutlet}>
|
|
64
|
+
{ctx.outlet}
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
67
|
}
|
|
68
68
|
return ctx.outlet;
|
|
69
69
|
}
|
|
@@ -71,11 +71,18 @@ function createPortalGroup() {
|
|
|
71
71
|
function Portal({ children }: React.PropsWithChildren<object>) {
|
|
72
72
|
const { append, remove } = useContext(Context);
|
|
73
73
|
const id = useId();
|
|
74
|
+
const theme = useContext(BloomThemeContext);
|
|
75
|
+
const scope = useContext(ThemeScopeContext);
|
|
74
76
|
|
|
75
77
|
useEffect(() => {
|
|
76
|
-
append(
|
|
78
|
+
append(
|
|
79
|
+
id,
|
|
80
|
+
<ThemeScopeBridge theme={theme} scope={scope}>
|
|
81
|
+
{children}
|
|
82
|
+
</ThemeScopeBridge>,
|
|
83
|
+
);
|
|
77
84
|
return () => remove(id);
|
|
78
|
-
}, [id, children, append, remove]);
|
|
85
|
+
}, [id, children, append, remove, theme, scope]);
|
|
79
86
|
|
|
80
87
|
return null;
|
|
81
88
|
}
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
* `PortalOutlet` are still exported on web — they just become harmless no-op
|
|
14
14
|
* fragments so consumers that *do* mount them keep compiling.
|
|
15
15
|
*/
|
|
16
|
-
import React, { Fragment, memo, useLayoutEffect, useState } from 'react';
|
|
16
|
+
import React, { Fragment, memo, useContext, useLayoutEffect, useState } from 'react';
|
|
17
17
|
import { createPortal } from 'react-dom';
|
|
18
18
|
import { Z_INDEX } from '../styles/z-index';
|
|
19
|
+
import { ThemeScopeContext } from '../theme/color-scope/context';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Render children into a stable container appended to `document.body`.
|
|
@@ -61,11 +62,15 @@ function getPortalRoot(): HTMLElement | null {
|
|
|
61
62
|
|
|
62
63
|
export function Portal({ children }: React.PropsWithChildren<object>) {
|
|
63
64
|
const [root, setRoot] = useState<HTMLElement | null>(null);
|
|
65
|
+
const scope = useContext(ThemeScopeContext);
|
|
64
66
|
useLayoutEffect(() => {
|
|
65
67
|
setRoot(getPortalRoot());
|
|
66
68
|
}, []);
|
|
67
69
|
if (!root) return null;
|
|
68
|
-
return createPortal(
|
|
70
|
+
return createPortal(
|
|
71
|
+
<div style={{ ...scope?.vars, display: 'contents', pointerEvents: 'none' }}>{children}</div>,
|
|
72
|
+
root,
|
|
73
|
+
);
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
// Native API parity — on web these are inert. `PortalProvider` mounts its
|
|
@@ -35,8 +35,15 @@ import { SWIPE_ROW_MESSAGES } from './messages';
|
|
|
35
35
|
* gesture springs straight back.
|
|
36
36
|
*
|
|
37
37
|
* The gesture activates only past a horizontal threshold and FAILS on vertical
|
|
38
|
-
* travel, so a
|
|
39
|
-
*
|
|
38
|
+
* travel, so a vertical drag never turns into a swipe. That is NOT what keeps the
|
|
39
|
+
* list scrollable on web, though: RNGH stamps `touch-action: none` on the
|
|
40
|
+
* detector's view unless told otherwise, and rows tile the whole list, so a
|
|
41
|
+
* touch browser would be told never to scroll it — `failOffsetY` is a JS
|
|
42
|
+
* decision taken after the browser has already been told not to. The detector
|
|
43
|
+
* therefore passes `touchAction="pan-y"`: vertical panning stays the browser's
|
|
44
|
+
* (it cancels the pointer, and with it the pan, once it scrolls) and horizontal
|
|
45
|
+
* movement still reaches the pan. Native ignores the prop. Panes are laid UNDER
|
|
46
|
+
* the row and grow with it rather than sliding in from outside: the row is what
|
|
40
47
|
* moves, and the action underneath is revealed, not pushed.
|
|
41
48
|
*
|
|
42
49
|
* It owns the gesture and almost nothing else. It draws no row and knows no
|
|
@@ -235,7 +242,10 @@ export function SwipeRow({
|
|
|
235
242
|
{pane(right, 'right')}
|
|
236
243
|
</Animated.View>
|
|
237
244
|
) : null}
|
|
238
|
-
|
|
245
|
+
{/* `pan-y` is load-bearing on touch web — see the doc comment above.
|
|
246
|
+
Without it RNGH's default `none` makes the list unscrollable by touch
|
|
247
|
+
wherever a row is under the finger, which is everywhere. */}
|
|
248
|
+
<GestureDetector gesture={pan} touchAction="pan-y">
|
|
239
249
|
<Animated.View
|
|
240
250
|
style={[
|
|
241
251
|
{ backgroundColor: rowFill },
|
|
@@ -28,6 +28,7 @@ import { useAmbientThemeState } from './ambient-store';
|
|
|
28
28
|
|
|
29
29
|
import { applyDarkClass, applyDocumentTheme, applyVarsToDocument } from './apply-dark-class';
|
|
30
30
|
import { buildTheme } from './build-theme';
|
|
31
|
+
import { ThemeScopeContext, type ScopeState } from './color-scope/context';
|
|
31
32
|
import { buildThemeFromSeed } from './build-theme-from-seed';
|
|
32
33
|
import { buildSeedScopeVars } from './color-scope/seed-scope';
|
|
33
34
|
import { type AppColorName } from './color-presets';
|
|
@@ -431,6 +432,17 @@ export function BloomThemeProvider({
|
|
|
431
432
|
],
|
|
432
433
|
);
|
|
433
434
|
|
|
435
|
+
const scopeState = useMemo<ScopeState>(() => ({
|
|
436
|
+
theme: themeColors,
|
|
437
|
+
vars: themeVars,
|
|
438
|
+
resolveMode: (nextMode) => nextMode === resolved ? { theme: themeColors, vars: themeVars } : effectiveSeed
|
|
439
|
+
? {
|
|
440
|
+
theme: buildThemeFromSeed(effectiveSeed, nextMode, undefined, undefined, { secondarySeed: effectiveSecondary, tertiarySeed: effectiveTertiary }),
|
|
441
|
+
vars: buildSeedScopeVars({ seed: effectiveSeed, mode: nextMode, secondarySeed: effectiveSecondary, tertiarySeed: effectiveTertiary }),
|
|
442
|
+
}
|
|
443
|
+
: { theme: buildTheme(colorPreset, nextMode, isAdaptive, explicitAccents), vars: buildScopeVars(colorPreset, nextMode, explicitAccents) },
|
|
444
|
+
}), [themeColors, themeVars, resolved, effectiveSeed, effectiveSecondary, effectiveTertiary, colorPreset, isAdaptive, explicitAccents]);
|
|
445
|
+
|
|
434
446
|
useIsomorphicLayoutEffect(() => {
|
|
435
447
|
setColorSchemeSafe(effectiveMode);
|
|
436
448
|
applyDarkClass(resolved);
|
|
@@ -480,9 +492,9 @@ export function BloomThemeProvider({
|
|
|
480
492
|
const VariableProvider = getVariableContextProvider();
|
|
481
493
|
|
|
482
494
|
const content = (
|
|
483
|
-
<FontLoader enabled={fonts} fallback={onFontsLoading}>
|
|
495
|
+
<ThemeScopeContext.Provider value={scopeState}><FontLoader enabled={fonts} fallback={onFontsLoading}>
|
|
484
496
|
{isGated ? onHydrating ?? null : children}
|
|
485
|
-
</FontLoader>
|
|
497
|
+
</FontLoader></ThemeScopeContext.Provider>
|
|
486
498
|
);
|
|
487
499
|
|
|
488
500
|
if (Platform.OS === 'web') {
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import React, { Children, cloneElement, isValidElement, useContext, useMemo } from 'react';
|
|
2
2
|
import { View, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import { BloomThemeContext
|
|
5
|
-
import {
|
|
4
|
+
import { BloomThemeContext } from '../BloomThemeProvider';
|
|
5
|
+
import { ThemeScopeContext } from './context';
|
|
6
|
+
import { useScope } from './use-scope';
|
|
7
|
+
import type { BloomColorScopeTokens } from './types';
|
|
6
8
|
import type { AppColorName } from '../color-presets';
|
|
7
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
buildNativePresetStyle,
|
|
11
|
+
buildScopeVars,
|
|
12
|
+
getVariableContextProvider,
|
|
13
|
+
} from './style-builder';
|
|
8
14
|
|
|
9
15
|
/**
|
|
10
16
|
* The variables a scope publishes when it carries no preset of its own.
|
|
@@ -26,7 +32,11 @@ export interface BloomColorScopeProps {
|
|
|
26
32
|
* or not a preset is set, because a preset that arrives late must not remount
|
|
27
33
|
* the subtree.
|
|
28
34
|
*/
|
|
29
|
-
colorPreset
|
|
35
|
+
colorPreset?: AppColorName;
|
|
36
|
+
/** Local resolved mode; does not change the app mode, storage or document. */
|
|
37
|
+
mode?: 'light' | 'dark';
|
|
38
|
+
/** Exact canonical colors. Unspecified roles inherit the selected preset or parent scope. */
|
|
39
|
+
tokens?: BloomColorScopeTokens;
|
|
30
40
|
/**
|
|
31
41
|
* When `true`, do not render a wrapping `<View>`. The single child is cloned
|
|
32
42
|
* with the scope's CSS vars merged into its `style` prop (Radix-style).
|
|
@@ -72,36 +82,13 @@ interface StyleableProps {
|
|
|
72
82
|
*/
|
|
73
83
|
export function BloomColorScope({
|
|
74
84
|
colorPreset,
|
|
85
|
+
mode,
|
|
86
|
+
tokens,
|
|
75
87
|
asChild = false,
|
|
76
88
|
style,
|
|
77
89
|
children,
|
|
78
90
|
}: BloomColorScopeProps) {
|
|
79
|
-
|
|
80
|
-
// never gate a hook behind an early return (rules of hooks). The throw below
|
|
81
|
-
// happens AFTER every hook has run. `resolvedMode` falls back harmlessly when
|
|
82
|
-
// the provider is absent (that render path throws anyway).
|
|
83
|
-
const parent = useContext(BloomThemeContext);
|
|
84
|
-
const resolvedMode = parent?.theme.mode ?? 'light';
|
|
85
|
-
|
|
86
|
-
const contextValue = useMemo<BloomThemeContextValue | null>(() => {
|
|
87
|
-
if (!parent || !colorPreset) return null;
|
|
88
|
-
const theme = buildTheme(colorPreset, resolvedMode);
|
|
89
|
-
return { ...parent, theme, colorPreset };
|
|
90
|
-
}, [colorPreset, resolvedMode, parent]);
|
|
91
|
-
|
|
92
|
-
// Preset vars flow to the subtree through react-native-css's real
|
|
93
|
-
// VariableContext (`VariableContextProvider`), NOT via an inline `vars()`
|
|
94
|
-
// style — under react-native-css@3 inline vars applied to a plain `<View>`
|
|
95
|
-
// (no matched className rules) are dropped silently. See `style-builder.ts`.
|
|
96
|
-
const nativeVars = useMemo<Record<string, string> | null>(
|
|
97
|
-
() => (colorPreset ? buildScopeVars(colorPreset, resolvedMode) : null),
|
|
98
|
-
[colorPreset, resolvedMode],
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
if (!parent) {
|
|
102
|
-
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
103
|
-
}
|
|
104
|
-
|
|
91
|
+
const { context, state, vars: nativeVars } = useScope(colorPreset, mode, tokens);
|
|
105
92
|
const VariableProvider = getVariableContextProvider();
|
|
106
93
|
|
|
107
94
|
let content: React.ReactNode;
|
|
@@ -130,7 +117,9 @@ export function BloomColorScope({
|
|
|
130
117
|
);
|
|
131
118
|
|
|
132
119
|
return (
|
|
133
|
-
<BloomThemeContext.Provider value={
|
|
120
|
+
<BloomThemeContext.Provider value={context}>
|
|
121
|
+
<ThemeScopeContext.Provider value={state}>{scoped}</ThemeScopeContext.Provider>
|
|
122
|
+
</BloomThemeContext.Provider>
|
|
134
123
|
);
|
|
135
124
|
}
|
|
136
125
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React, { Children, cloneElement, isValidElement, useContext, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { BloomThemeContext
|
|
4
|
-
import {
|
|
3
|
+
import { BloomThemeContext } from '../BloomThemeProvider';
|
|
4
|
+
import { ThemeScopeContext } from './context';
|
|
5
|
+
import { useScope } from './use-scope';
|
|
6
|
+
import type { BloomColorScopeTokens } from './types';
|
|
5
7
|
import type { AppColorName } from '../color-presets';
|
|
6
8
|
import { buildScopeVars } from './style-builder';
|
|
7
9
|
|
|
@@ -11,10 +13,7 @@ import { buildScopeVars } from './style-builder';
|
|
|
11
13
|
* utilities. Scoped onto an element's inline `style`, profile-level NativeWind
|
|
12
14
|
* classes resolve against the subtree preset instead of the document root.
|
|
13
15
|
*/
|
|
14
|
-
function buildWebScopeVars(
|
|
15
|
-
colorPreset: AppColorName,
|
|
16
|
-
mode: 'light' | 'dark',
|
|
17
|
-
): React.CSSProperties {
|
|
16
|
+
function buildWebScopeVars(colorPreset: AppColorName, mode: 'light' | 'dark'): React.CSSProperties {
|
|
18
17
|
return buildScopeVars(colorPreset, mode) as React.CSSProperties;
|
|
19
18
|
}
|
|
20
19
|
|
|
@@ -27,7 +26,11 @@ export interface BloomColorScopeProps {
|
|
|
27
26
|
* tree is identical either way, so a preset that arrives late cannot remount
|
|
28
27
|
* the subtree. `ColorScope.tsx` carries the full account.
|
|
29
28
|
*/
|
|
30
|
-
colorPreset
|
|
29
|
+
colorPreset?: AppColorName;
|
|
30
|
+
/** Local resolved mode; does not change the app mode, storage or document. */
|
|
31
|
+
mode?: 'light' | 'dark';
|
|
32
|
+
/** Exact canonical colors. Unspecified roles inherit the selected preset or parent scope. */
|
|
33
|
+
tokens?: BloomColorScopeTokens;
|
|
31
34
|
/**
|
|
32
35
|
* When `true`, do not render a wrapping `<div>`. The single child is cloned
|
|
33
36
|
* with the scope's CSS vars merged into its `style` prop (Radix-style).
|
|
@@ -55,13 +58,7 @@ export interface BloomColorScopeProps {
|
|
|
55
58
|
* So the array form is used only when the child's own style is already
|
|
56
59
|
* RN-shaped; every other child gets a plain object, which both runtimes accept.
|
|
57
60
|
*/
|
|
58
|
-
type WebStyle =
|
|
59
|
-
| React.CSSProperties
|
|
60
|
-
| number
|
|
61
|
-
| null
|
|
62
|
-
| undefined
|
|
63
|
-
| false
|
|
64
|
-
| ReadonlyArray<WebStyle>;
|
|
61
|
+
type WebStyle = React.CSSProperties | number | null | undefined | false | ReadonlyArray<WebStyle>;
|
|
65
62
|
|
|
66
63
|
interface StyleableProps {
|
|
67
64
|
style?: WebStyle;
|
|
@@ -69,32 +66,14 @@ interface StyleableProps {
|
|
|
69
66
|
|
|
70
67
|
export function BloomColorScope({
|
|
71
68
|
colorPreset,
|
|
69
|
+
mode,
|
|
70
|
+
tokens,
|
|
72
71
|
asChild = false,
|
|
73
72
|
style,
|
|
74
73
|
children,
|
|
75
74
|
}: BloomColorScopeProps) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// no-op/throw behavior is applied AFTER every hook has run, using the values
|
|
79
|
-
// the hooks produced. `resolvedMode` falls back harmlessly when the provider
|
|
80
|
-
// is absent (that render path throws below anyway).
|
|
81
|
-
const parent = useContext(BloomThemeContext);
|
|
82
|
-
const resolvedMode = parent?.theme.mode ?? 'light';
|
|
83
|
-
|
|
84
|
-
const contextValue = useMemo<BloomThemeContextValue | null>(() => {
|
|
85
|
-
if (!parent || !colorPreset) return null;
|
|
86
|
-
const theme = buildTheme(colorPreset, resolvedMode);
|
|
87
|
-
return { ...parent, theme, colorPreset };
|
|
88
|
-
}, [colorPreset, resolvedMode, parent]);
|
|
89
|
-
|
|
90
|
-
const varsStyle = useMemo<React.CSSProperties | null>(
|
|
91
|
-
() => (colorPreset ? buildWebScopeVars(colorPreset, resolvedMode) : null),
|
|
92
|
-
[colorPreset, resolvedMode],
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
if (!parent) {
|
|
96
|
-
throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
97
|
-
}
|
|
75
|
+
const { context, state, vars } = useScope(colorPreset, mode, tokens);
|
|
76
|
+
const varsStyle = vars as React.CSSProperties | undefined;
|
|
98
77
|
|
|
99
78
|
let content: React.ReactNode;
|
|
100
79
|
if (asChild) {
|
|
@@ -122,7 +101,9 @@ export function BloomColorScope({
|
|
|
122
101
|
}
|
|
123
102
|
|
|
124
103
|
return (
|
|
125
|
-
<BloomThemeContext.Provider value={
|
|
104
|
+
<BloomThemeContext.Provider value={context}>
|
|
105
|
+
<ThemeScopeContext.Provider value={state}>{content}</ThemeScopeContext.Provider>
|
|
106
|
+
</BloomThemeContext.Provider>
|
|
126
107
|
);
|
|
127
108
|
}
|
|
128
109
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { BloomThemeContext, type BloomThemeContextValue } from '../BloomThemeProvider';
|
|
3
|
+
import { ThemeScopeContext, type ScopeState } from './context';
|
|
4
|
+
import { getVariableContextProvider } from './style-builder';
|
|
5
|
+
|
|
6
|
+
/** Re-publish the source scope when a native portal renders under an unrelated outlet. */
|
|
7
|
+
export function ThemeScopeBridge({
|
|
8
|
+
theme,
|
|
9
|
+
scope,
|
|
10
|
+
children,
|
|
11
|
+
}: React.PropsWithChildren<{
|
|
12
|
+
theme: BloomThemeContextValue | null;
|
|
13
|
+
scope: ScopeState | null;
|
|
14
|
+
}>) {
|
|
15
|
+
const outletTheme = useContext(BloomThemeContext);
|
|
16
|
+
const outletScope = useContext(ThemeScopeContext);
|
|
17
|
+
const sourceTheme = theme ?? outletTheme;
|
|
18
|
+
const sourceScope = scope ?? outletScope;
|
|
19
|
+
const Variables = getVariableContextProvider();
|
|
20
|
+
const content = Variables ? (
|
|
21
|
+
<Variables value={sourceScope?.vars ?? {}}>{children}</Variables>
|
|
22
|
+
) : (
|
|
23
|
+
children
|
|
24
|
+
);
|
|
25
|
+
return (
|
|
26
|
+
<BloomThemeContext.Provider value={sourceTheme}>
|
|
27
|
+
<ThemeScopeContext.Provider value={sourceScope}>{content}</ThemeScopeContext.Provider>
|
|
28
|
+
</BloomThemeContext.Provider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import type { Theme } from '../types';
|
|
3
|
+
|
|
4
|
+
export interface ScopePalette {
|
|
5
|
+
theme: Theme;
|
|
6
|
+
vars: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Private resolved source, retained through scopes and portal outlets. */
|
|
10
|
+
export interface ScopeState extends ScopePalette {
|
|
11
|
+
resolveMode: (mode: 'light' | 'dark') => ScopePalette;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
// eslint-disable-next-line no-var
|
|
16
|
+
var __oxy_so_bloom_scope_context__: React.Context<ScopeState | null> | undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ThemeScopeContext = (globalThis.__oxy_so_bloom_scope_context__ ??=
|
|
20
|
+
createContext<ScopeState | null>(null));
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { processColor } from 'react-native';
|
|
2
|
+
import { CANONICAL_TOKENS, type CanonicalToken } from '../token-registry';
|
|
3
|
+
import { chartColorsFromTokens } from '../chart-colors';
|
|
4
|
+
import type { ThemeColors } from '../types';
|
|
5
|
+
import type { ScopePalette } from './context';
|
|
6
|
+
import { withScopeAliases } from './seed-scope';
|
|
7
|
+
import type { BloomColorScopeTokens } from './types';
|
|
8
|
+
|
|
9
|
+
/** All JS aliases of an exact canonical override share the same supplied value. */
|
|
10
|
+
const COLOR_FIELDS = {
|
|
11
|
+
background: ['background', 'primaryDark'],
|
|
12
|
+
foreground: ['text'],
|
|
13
|
+
surface: ['backgroundSecondary', 'primaryLight'],
|
|
14
|
+
popover: ['backgroundTertiary'],
|
|
15
|
+
'muted-foreground': ['textSecondary', 'textTertiary', 'icon'],
|
|
16
|
+
border: ['border'],
|
|
17
|
+
input: ['borderLight'],
|
|
18
|
+
primary: ['primary', 'tint', 'iconActive'],
|
|
19
|
+
'primary-foreground': ['primaryForeground'],
|
|
20
|
+
'primary-subtle': ['primarySubtle'],
|
|
21
|
+
'primary-text': ['primarySubtleForeground'],
|
|
22
|
+
secondary: ['secondary'],
|
|
23
|
+
'secondary-foreground': ['secondaryForeground'],
|
|
24
|
+
'secondary-subtle': ['secondarySubtle'],
|
|
25
|
+
'secondary-text': ['secondarySubtleForeground'],
|
|
26
|
+
tertiary: ['tertiary'],
|
|
27
|
+
'tertiary-foreground': ['tertiaryForeground'],
|
|
28
|
+
'tertiary-subtle': ['tertiarySubtle'],
|
|
29
|
+
'tertiary-text': ['tertiarySubtleForeground'],
|
|
30
|
+
success: ['success'],
|
|
31
|
+
'success-foreground': ['successForeground'],
|
|
32
|
+
'success-subtle': ['successSubtle'],
|
|
33
|
+
'success-text': ['successSubtleForeground'],
|
|
34
|
+
error: ['error', 'negative'],
|
|
35
|
+
'error-foreground': ['errorForeground', 'negativeForeground'],
|
|
36
|
+
'error-subtle': ['errorSubtle', 'negativeSubtle'],
|
|
37
|
+
'error-text': ['errorSubtleForeground', 'negativeSubtleForeground'],
|
|
38
|
+
warning: ['warning'],
|
|
39
|
+
'warning-foreground': ['warningForeground'],
|
|
40
|
+
'warning-subtle': ['warningSubtle'],
|
|
41
|
+
'warning-text': ['warningSubtleForeground'],
|
|
42
|
+
info: ['info'],
|
|
43
|
+
'info-foreground': ['infoForeground'],
|
|
44
|
+
'info-subtle': ['infoSubtle'],
|
|
45
|
+
'info-text': ['infoSubtleForeground'],
|
|
46
|
+
muted: ['contrast50'],
|
|
47
|
+
card: ['card'],
|
|
48
|
+
} satisfies Partial<Record<CanonicalToken, readonly (keyof ThemeColors)[]>>;
|
|
49
|
+
|
|
50
|
+
/** Preserve unspecified roles; rebuild the full CSS alias layer after exact overrides. */
|
|
51
|
+
export function applyScopeTokens(
|
|
52
|
+
base: ScopePalette,
|
|
53
|
+
overrides?: BloomColorScopeTokens,
|
|
54
|
+
): ScopePalette {
|
|
55
|
+
if (!overrides || Object.keys(overrides).length === 0) return base;
|
|
56
|
+
const vars = { ...base.vars };
|
|
57
|
+
const colors = { ...base.theme.colors };
|
|
58
|
+
let changedCharts = false;
|
|
59
|
+
for (const [name, value] of Object.entries(overrides)) {
|
|
60
|
+
if (value === undefined) continue;
|
|
61
|
+
if (!(CANONICAL_TOKENS as readonly string[]).includes(name)) {
|
|
62
|
+
throw new Error(`BloomColorScope: unknown canonical token "${name}".`);
|
|
63
|
+
}
|
|
64
|
+
if (typeof value !== 'string' || !value.trim() || processColor(value) == null) {
|
|
65
|
+
throw new Error(`BloomColorScope: "${name}" requires a resolved color value.`);
|
|
66
|
+
}
|
|
67
|
+
vars[`--${name}`] = value;
|
|
68
|
+
const fields = COLOR_FIELDS[name as keyof typeof COLOR_FIELDS];
|
|
69
|
+
for (const field of fields ?? []) colors[field] = value;
|
|
70
|
+
if (name.startsWith('chart-')) changedCharts = true;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
vars: withScopeAliases(
|
|
74
|
+
Object.fromEntries(Object.entries(vars).filter(([name]) => !name.startsWith('--color-'))),
|
|
75
|
+
),
|
|
76
|
+
theme: {
|
|
77
|
+
...base.theme,
|
|
78
|
+
colors,
|
|
79
|
+
...(changedCharts ? { chartColors: chartColorsFromTokens(vars) } : {}),
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|