@oxyhq/bloom 0.6.20 → 0.6.22
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/scroll/index.js +39 -0
- package/lib/commonjs/scroll/index.js.map +1 -0
- package/lib/commonjs/scroll/index.web.js +143 -0
- package/lib/commonjs/scroll/index.web.js.map +1 -0
- package/lib/commonjs/scroll/scrollable.web.js +64 -0
- package/lib/commonjs/scroll/scrollable.web.js.map +1 -0
- package/lib/commonjs/scroll/store.js +90 -0
- package/lib/commonjs/scroll/store.js.map +1 -0
- package/lib/commonjs/scroll/types.js +6 -0
- package/lib/commonjs/scroll/types.js.map +1 -0
- package/lib/commonjs/theme/color-scope/index.web.js +18 -5
- package/lib/commonjs/theme/color-scope/index.web.js.map +1 -1
- package/lib/module/scroll/index.js +34 -0
- package/lib/module/scroll/index.js.map +1 -0
- package/lib/module/scroll/index.web.js +137 -0
- package/lib/module/scroll/index.web.js.map +1 -0
- package/lib/module/scroll/scrollable.web.js +60 -0
- package/lib/module/scroll/scrollable.web.js.map +1 -0
- package/lib/module/scroll/store.js +84 -0
- package/lib/module/scroll/store.js.map +1 -0
- package/lib/module/scroll/types.js +4 -0
- package/lib/module/scroll/types.js.map +1 -0
- package/lib/module/theme/color-scope/index.web.js +18 -5
- package/lib/module/theme/color-scope/index.web.js.map +1 -1
- package/lib/typescript/commonjs/scroll/index.d.ts +27 -0
- package/lib/typescript/commonjs/scroll/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/scroll/index.web.d.ts +22 -0
- package/lib/typescript/commonjs/scroll/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/scroll/scrollable.web.d.ts +17 -0
- package/lib/typescript/commonjs/scroll/scrollable.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/scroll/store.d.ts +46 -0
- package/lib/typescript/commonjs/scroll/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/scroll/types.d.ts +46 -0
- package/lib/typescript/commonjs/scroll/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme/color-scope/index.web.d.ts.map +1 -1
- package/lib/typescript/module/scroll/index.d.ts +27 -0
- package/lib/typescript/module/scroll/index.d.ts.map +1 -0
- package/lib/typescript/module/scroll/index.web.d.ts +22 -0
- package/lib/typescript/module/scroll/index.web.d.ts.map +1 -0
- package/lib/typescript/module/scroll/scrollable.web.d.ts +17 -0
- package/lib/typescript/module/scroll/scrollable.web.d.ts.map +1 -0
- package/lib/typescript/module/scroll/store.d.ts +46 -0
- package/lib/typescript/module/scroll/store.d.ts.map +1 -0
- package/lib/typescript/module/scroll/types.d.ts +46 -0
- package/lib/typescript/module/scroll/types.d.ts.map +1 -0
- package/lib/typescript/module/theme/color-scope/index.web.d.ts.map +1 -1
- package/package.json +22 -1
- package/src/__tests__/BloomColorScope.test.tsx +67 -0
- package/src/__tests__/scroll-native.test.ts +25 -0
- package/src/__tests__/scroll-store.test.ts +85 -0
- package/src/scroll/index.ts +47 -0
- package/src/scroll/index.web.tsx +167 -0
- package/src/scroll/scrollable.web.ts +75 -0
- package/src/scroll/store.ts +84 -0
- package/src/scroll/types.ts +48 -0
- package/src/theme/color-scope/index.web.tsx +26 -2
|
@@ -21,8 +21,25 @@ export interface BloomColorScopeProps {
|
|
|
21
21
|
children: React.ReactNode;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* On web, the single `asChild` child is frequently a react-native-web
|
|
26
|
+
* component (e.g. RN `<View>`) whose `style` prop is a *style array* (or a
|
|
27
|
+
* numeric registered-style id), not a plain `React.CSSProperties` object.
|
|
28
|
+
* react-native-web flattens nested style arrays, so the cloned child must
|
|
29
|
+
* receive an array — spreading an array into an object literal would copy its
|
|
30
|
+
* numeric indices as keys and crash RNW when it commits them to the DOM
|
|
31
|
+
* (`Failed to set an indexed property [0] on 'CSSStyleDeclaration'`).
|
|
32
|
+
*/
|
|
33
|
+
type WebStyle =
|
|
34
|
+
| React.CSSProperties
|
|
35
|
+
| number
|
|
36
|
+
| null
|
|
37
|
+
| undefined
|
|
38
|
+
| false
|
|
39
|
+
| ReadonlyArray<WebStyle>;
|
|
40
|
+
|
|
24
41
|
interface StyleableProps {
|
|
25
|
-
style?:
|
|
42
|
+
style?: WebStyle;
|
|
26
43
|
}
|
|
27
44
|
|
|
28
45
|
export function BloomColorScope({
|
|
@@ -58,10 +75,17 @@ export function BloomColorScope({
|
|
|
58
75
|
'BloomColorScope with `asChild` requires a single React element child that accepts a `style` prop.',
|
|
59
76
|
);
|
|
60
77
|
}
|
|
78
|
+
// Merge as a style ARRAY (the RNW-safe form): scope vars first, then the
|
|
79
|
+
// caller's `style`, then the child's own `style` last so its explicit
|
|
80
|
+
// styles win. react-native-web flattens nested arrays correctly; spreading
|
|
81
|
+
// the child's style (which is often an RN style array or numeric id) into an
|
|
82
|
+
// object literal would copy numeric indices as keys and crash RNW.
|
|
61
83
|
const childStyle = child.props.style;
|
|
62
|
-
const mergedStyle:
|
|
84
|
+
const mergedStyle: WebStyle = [varsStyle, style, childStyle];
|
|
63
85
|
content = cloneElement(child, { style: mergedStyle });
|
|
64
86
|
} else {
|
|
87
|
+
// A plain DOM `<div>` does NOT accept style arrays — only the cloned child
|
|
88
|
+
// path can, so the wrapper keeps using an object spread.
|
|
65
89
|
const mergedStyle: React.CSSProperties = { ...varsStyle, ...style };
|
|
66
90
|
content = <div style={mergedStyle}>{children}</div>;
|
|
67
91
|
}
|