@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,46 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import { BloomThemeContext } from '../BloomThemeProvider';
|
|
3
|
+
import { buildTheme } from '../build-theme';
|
|
4
|
+
import type { AppColorName } from '../color-presets';
|
|
5
|
+
import { ThemeScopeContext, type ScopePalette, type ScopeState } from './context';
|
|
6
|
+
import { buildScopeVars } from './style-builder';
|
|
7
|
+
import { applyScopeTokens } from './resolve-scope';
|
|
8
|
+
import type { BloomColorScopeTokens } from './types';
|
|
9
|
+
|
|
10
|
+
export function useScope(
|
|
11
|
+
colorPreset?: AppColorName,
|
|
12
|
+
mode?: 'light' | 'dark',
|
|
13
|
+
tokens?: BloomColorScopeTokens,
|
|
14
|
+
) {
|
|
15
|
+
const parent = useContext(BloomThemeContext);
|
|
16
|
+
const inherited = useContext(ThemeScopeContext);
|
|
17
|
+
const active = colorPreset !== undefined || mode !== undefined || tokens !== undefined;
|
|
18
|
+
const state = useMemo<ScopeState | null>(() => {
|
|
19
|
+
if (!parent || !active) return inherited;
|
|
20
|
+
const resolveMode = (resolved: 'light' | 'dark'): ScopePalette => {
|
|
21
|
+
const base =
|
|
22
|
+
colorPreset !== undefined || !inherited
|
|
23
|
+
? {
|
|
24
|
+
theme: buildTheme(colorPreset ?? parent.colorPreset, resolved),
|
|
25
|
+
vars: buildScopeVars(colorPreset ?? parent.colorPreset, resolved),
|
|
26
|
+
}
|
|
27
|
+
: inherited.resolveMode(resolved);
|
|
28
|
+
return applyScopeTokens(base, tokens);
|
|
29
|
+
};
|
|
30
|
+
return { ...resolveMode(mode ?? parent.theme.mode), resolveMode };
|
|
31
|
+
}, [parent, inherited, active, colorPreset, mode, tokens]);
|
|
32
|
+
const context = useMemo(
|
|
33
|
+
() =>
|
|
34
|
+
parent && active && state
|
|
35
|
+
? {
|
|
36
|
+
...parent,
|
|
37
|
+
theme: state.theme,
|
|
38
|
+
colorPreset: colorPreset ?? parent.colorPreset,
|
|
39
|
+
mode: mode ?? parent.mode,
|
|
40
|
+
}
|
|
41
|
+
: parent,
|
|
42
|
+
[parent, active, state, colorPreset, mode],
|
|
43
|
+
);
|
|
44
|
+
if (!parent) throw new Error('BloomColorScope must be used within a <BloomThemeProvider>');
|
|
45
|
+
return { context: context!, state, vars: active ? state?.vars : undefined };
|
|
46
|
+
}
|
package/src/theme/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type {
|
|
|
4
4
|
BloomThemeContextValue,
|
|
5
5
|
} from './BloomThemeProvider';
|
|
6
6
|
export { BloomColorScope, useColorScopeStyle } from './color-scope';
|
|
7
|
-
export type { BloomColorScopeProps } from './color-scope';
|
|
7
|
+
export type { BloomColorScopeProps, BloomColorScopeTokens } from './color-scope';
|
|
8
8
|
export { BloomSeedScope } from './seed-scope';
|
|
9
9
|
export type { BloomSeedScopeProps } from './seed-scope';
|
|
10
10
|
export { roleColorsToPresetTokens } from './color-scope/seed-scope';
|
package/src/theme/index.web.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type {
|
|
|
9
9
|
BloomThemeContextValue,
|
|
10
10
|
} from './BloomThemeProvider';
|
|
11
11
|
export { BloomColorScope, useColorScopeStyle } from './color-scope/index.web';
|
|
12
|
-
export type { BloomColorScopeProps } from './color-scope/index.web';
|
|
12
|
+
export type { BloomColorScopeProps, BloomColorScopeTokens } from './color-scope/index.web';
|
|
13
13
|
export { BloomSeedScope } from './seed-scope/index.web';
|
|
14
14
|
export type { BloomSeedScopeProps } from './seed-scope/index.web';
|
|
15
15
|
export { roleColorsToPresetTokens } from './color-scope/seed-scope';
|
|
@@ -6,6 +6,7 @@ import { buildSeedScopeVars } from '../color-scope/seed-scope';
|
|
|
6
6
|
import { getVariableContextProvider } from '../color-scope/style-builder';
|
|
7
7
|
import { buildThemeFromSeed } from '../build-theme-from-seed';
|
|
8
8
|
import type { SchemeVariant } from '../color-engine';
|
|
9
|
+
import { ThemeScopeContext, type ScopeState } from '../color-scope/context';
|
|
9
10
|
|
|
10
11
|
export interface BloomSeedScopeProps {
|
|
11
12
|
/**
|
|
@@ -80,6 +81,15 @@ export function BloomSeedScope({
|
|
|
80
81
|
return { ...parent, theme };
|
|
81
82
|
}, [parent, seed, resolvedMode, variant, contrastLevel, secondarySeed, tertiarySeed]);
|
|
82
83
|
|
|
84
|
+
const scopeState = useMemo<ScopeState | null>(() => {
|
|
85
|
+
if (!seed) return null;
|
|
86
|
+
const resolveMode = (mode: 'light' | 'dark') => ({
|
|
87
|
+
theme: buildThemeFromSeed(seed, mode, variant, contrastLevel, { secondarySeed, tertiarySeed }),
|
|
88
|
+
vars: buildSeedScopeVars({ seed, mode, variant, contrastLevel, secondarySeed, tertiarySeed }),
|
|
89
|
+
});
|
|
90
|
+
return { ...resolveMode(resolvedMode), resolveMode };
|
|
91
|
+
}, [seed, resolvedMode, variant, contrastLevel, secondarySeed, tertiarySeed]);
|
|
92
|
+
|
|
83
93
|
if (!parent) {
|
|
84
94
|
throw new Error('BloomSeedScope must be used within a <BloomThemeProvider>');
|
|
85
95
|
}
|
|
@@ -109,5 +119,5 @@ export function BloomSeedScope({
|
|
|
109
119
|
content
|
|
110
120
|
);
|
|
111
121
|
|
|
112
|
-
return <BloomThemeContext.Provider value={contextValue}>{scoped}</BloomThemeContext.Provider>;
|
|
122
|
+
return <BloomThemeContext.Provider value={contextValue}><ThemeScopeContext.Provider value={scopeState}>{scoped}</ThemeScopeContext.Provider></BloomThemeContext.Provider>;
|
|
113
123
|
}
|
|
@@ -4,6 +4,7 @@ import { BloomThemeContext, type BloomThemeContextValue } from '../BloomThemePro
|
|
|
4
4
|
import { buildSeedScopeVars } from '../color-scope/seed-scope';
|
|
5
5
|
import { buildThemeFromSeed } from '../build-theme-from-seed';
|
|
6
6
|
import type { SchemeVariant } from '../color-engine';
|
|
7
|
+
import { ThemeScopeContext, type ScopeState } from '../color-scope/context';
|
|
7
8
|
|
|
8
9
|
export interface BloomSeedScopeProps {
|
|
9
10
|
/**
|
|
@@ -97,6 +98,15 @@ export function BloomSeedScope({
|
|
|
97
98
|
return { ...parent, theme };
|
|
98
99
|
}, [parent, seed, resolvedMode, variant, contrastLevel, secondarySeed, tertiarySeed]);
|
|
99
100
|
|
|
101
|
+
const scopeState = useMemo<ScopeState | null>(() => {
|
|
102
|
+
if (!seed) return null;
|
|
103
|
+
const resolveMode = (mode: 'light' | 'dark') => ({
|
|
104
|
+
theme: buildThemeFromSeed(seed, mode, variant, contrastLevel, { secondarySeed, tertiarySeed }),
|
|
105
|
+
vars: buildSeedScopeVars({ seed, mode, variant, contrastLevel, secondarySeed, tertiarySeed }),
|
|
106
|
+
});
|
|
107
|
+
return { ...resolveMode(resolvedMode), resolveMode };
|
|
108
|
+
}, [seed, resolvedMode, variant, contrastLevel, secondarySeed, tertiarySeed]);
|
|
109
|
+
|
|
100
110
|
if (!parent) {
|
|
101
111
|
throw new Error('BloomSeedScope must be used within a <BloomThemeProvider>');
|
|
102
112
|
}
|
|
@@ -118,5 +128,5 @@ export function BloomSeedScope({
|
|
|
118
128
|
content = <div style={mergedStyle}>{children}</div>;
|
|
119
129
|
}
|
|
120
130
|
|
|
121
|
-
return <BloomThemeContext.Provider value={contextValue}>{content}</BloomThemeContext.Provider>;
|
|
131
|
+
return <BloomThemeContext.Provider value={contextValue}><ThemeScopeContext.Provider value={scopeState}>{content}</ThemeScopeContext.Provider></BloomThemeContext.Provider>;
|
|
122
132
|
}
|