@oxy.so/bloom 1.1.1 → 1.2.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.
Files changed (56) hide show
  1. package/docs/rail.mdx +112 -0
  2. package/lib/commonjs/index.js +77 -69
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/index.web.js +77 -69
  5. package/lib/commonjs/index.web.js.map +1 -1
  6. package/lib/commonjs/rail/Rail.js +127 -0
  7. package/lib/commonjs/rail/Rail.js.map +1 -0
  8. package/lib/commonjs/rail/index.js +13 -0
  9. package/lib/commonjs/rail/index.js.map +1 -0
  10. package/lib/commonjs/rail/types.js +6 -0
  11. package/lib/commonjs/rail/types.js.map +1 -0
  12. package/lib/commonjs/styles/web-view-style.js +11 -1
  13. package/lib/commonjs/styles/web-view-style.js.map +1 -1
  14. package/lib/module/index.js +1 -0
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/module/index.web.js +1 -0
  17. package/lib/module/index.web.js.map +1 -1
  18. package/lib/module/rail/Rail.js +121 -0
  19. package/lib/module/rail/Rail.js.map +1 -0
  20. package/lib/module/rail/index.js +4 -0
  21. package/lib/module/rail/index.js.map +1 -0
  22. package/lib/module/rail/types.js +4 -0
  23. package/lib/module/rail/types.js.map +1 -0
  24. package/lib/module/styles/web-view-style.js +10 -0
  25. package/lib/module/styles/web-view-style.js.map +1 -1
  26. package/lib/typescript/commonjs/index.d.ts +2 -0
  27. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/index.web.d.ts +2 -0
  29. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  30. package/lib/typescript/commonjs/rail/Rail.d.ts +46 -0
  31. package/lib/typescript/commonjs/rail/Rail.d.ts.map +1 -0
  32. package/lib/typescript/commonjs/rail/index.d.ts +3 -0
  33. package/lib/typescript/commonjs/rail/index.d.ts.map +1 -0
  34. package/lib/typescript/commonjs/rail/types.d.ts +46 -0
  35. package/lib/typescript/commonjs/rail/types.d.ts.map +1 -0
  36. package/lib/typescript/commonjs/styles/web-view-style.d.ts +9 -0
  37. package/lib/typescript/commonjs/styles/web-view-style.d.ts.map +1 -1
  38. package/lib/typescript/module/index.d.ts +2 -0
  39. package/lib/typescript/module/index.d.ts.map +1 -1
  40. package/lib/typescript/module/index.web.d.ts +2 -0
  41. package/lib/typescript/module/index.web.d.ts.map +1 -1
  42. package/lib/typescript/module/rail/Rail.d.ts +46 -0
  43. package/lib/typescript/module/rail/Rail.d.ts.map +1 -0
  44. package/lib/typescript/module/rail/index.d.ts +3 -0
  45. package/lib/typescript/module/rail/index.d.ts.map +1 -0
  46. package/lib/typescript/module/rail/types.d.ts +46 -0
  47. package/lib/typescript/module/rail/types.d.ts.map +1 -0
  48. package/lib/typescript/module/styles/web-view-style.d.ts +9 -0
  49. package/lib/typescript/module/styles/web-view-style.d.ts.map +1 -1
  50. package/package.json +15 -1
  51. package/src/index.ts +2 -0
  52. package/src/index.web.ts +2 -0
  53. package/src/rail/Rail.tsx +126 -0
  54. package/src/rail/index.ts +2 -0
  55. package/src/rail/types.ts +47 -0
  56. package/src/styles/web-view-style.ts +10 -0
@@ -0,0 +1,46 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { StyleProp, ViewStyle } from 'react-native';
3
+ /** One destination in a {@link RailProps.items} list. */
4
+ export interface RailItem {
5
+ /** Stable identity for the item, matched against `RailProps.activeId`. */
6
+ id: string;
7
+ /** Text under the icon. */
8
+ label: string;
9
+ /**
10
+ * The glyph, as any node. Bloom owns no icon set here — a consumer's own
11
+ * icon component (or a Bloom `Icons.*` element) is passed in directly, the
12
+ * same convention `TabBarItem.icon` uses.
13
+ */
14
+ icon: ReactNode;
15
+ /**
16
+ * Optional node rendered instead of `icon` while this item is active.
17
+ * Without it the item renders `icon` in both states.
18
+ *
19
+ * The escape hatch for an icon set whose selected state is a different
20
+ * SHAPE or COLOR rather than something `Rail` could tint on its behalf —
21
+ * same convention as `TabBarItem.activeIcon`, resolved directly against
22
+ * `activeId` here rather than crossfading, since `Rail` has no shared
23
+ * highlight animation to drive.
24
+ */
25
+ activeIcon?: ReactNode;
26
+ }
27
+ export interface RailProps {
28
+ /** The destinations to render, top to bottom. */
29
+ items: RailItem[];
30
+ /**
31
+ * `id` of the active item. An id naming no item (including `undefined`)
32
+ * leaves nothing selected — every item renders in its inactive state.
33
+ */
34
+ activeId?: string;
35
+ /** Called with an item's `id` when it is pressed. */
36
+ onSelect: (id: string) => void;
37
+ /**
38
+ * Width of the rail, in px. Defaults to `80`, a comfortable column for an
39
+ * icon-plus-label item.
40
+ */
41
+ width?: number;
42
+ /** Container style override, merged after the rail's own positioning. */
43
+ style?: StyleProp<ViewStyle>;
44
+ testID?: string;
45
+ }
46
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/rail/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,yDAAyD;AACzD,MAAM,WAAW,QAAQ;IACvB,0EAA0E;IAC1E,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,EAAE,SAAS,CAAC;IAChB;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,iDAAiD;IACjD,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -18,6 +18,15 @@ import type { ViewStyle } from 'react-native';
18
18
  * where Yoga silently ignores it.
19
19
  */
20
20
  export declare const WEB_POSITION_FIXED: ViewStyle["position"];
21
+ /**
22
+ * `position: sticky`, typed for React Native's `ViewStyle`. Same gap as
23
+ * {@link WEB_POSITION_FIXED} — RN's `position` union has no `'sticky'` member
24
+ * at all, while react-native-web passes it straight through as real CSS. Used
25
+ * by a surface that pins itself within its own scroll container (a desktop
26
+ * sidebar, a framed panel's overlay chrome) rather than to the viewport,
27
+ * which is what `'fixed'` is for.
28
+ */
29
+ export declare const WEB_POSITION_STICKY: ViewStyle["position"];
21
30
  /**
22
31
  * A `ViewStyle` that may ALSO carry CSS react-native-web forwards straight to the
23
32
  * DOM node but React Native does not model at all.
@@ -1 +1 @@
1
- {"version":3,"file":"web-view-style.d.ts","sourceRoot":"","sources":["../../../../src/styles/web-view-style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,kBAAkB,EAAc,SAAS,CAAC,UAAU,CAAC,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eA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AAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC;IAC1D;;;;;;;;;OASG;IACH,CAAC,cAAc,EAAE,KAAK,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;CACrD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxy.so/bloom",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "packageManager": "bun@1.3.14",
5
5
  "description": "Bloom UI — Oxy ecosystem component library for React Native + Expo + Web",
6
6
  "main": "lib/commonjs/index.js",
@@ -1428,6 +1428,20 @@
1428
1428
  "default": "./lib/commonjs/list/index.js"
1429
1429
  }
1430
1430
  },
1431
+ "./rail": {
1432
+ "react-native": {
1433
+ "types": "./lib/typescript/module/rail/index.d.ts",
1434
+ "default": "./src/rail/index.ts"
1435
+ },
1436
+ "import": {
1437
+ "types": "./lib/typescript/module/rail/index.d.ts",
1438
+ "default": "./lib/module/rail/index.js"
1439
+ },
1440
+ "require": {
1441
+ "types": "./lib/typescript/commonjs/rail/index.d.ts",
1442
+ "default": "./lib/commonjs/rail/index.js"
1443
+ }
1444
+ },
1431
1445
  "./tab-bar": {
1432
1446
  "react-native": {
1433
1447
  "types": "./lib/typescript/module/tab-bar/index.d.ts",
package/src/index.ts CHANGED
@@ -216,6 +216,8 @@ export type {
216
216
  VirtualListRenderItemInfo,
217
217
  VirtualListSlot,
218
218
  } from './list';
219
+ export { Rail } from './rail';
220
+ export type { RailItem, RailProps } from './rail';
219
221
 
220
222
  // Interaction primitives
221
223
  export { PressableScale } from './pressable-scale';
package/src/index.web.ts CHANGED
@@ -221,6 +221,8 @@ export type {
221
221
  VirtualListRenderItemInfo,
222
222
  VirtualListSlot,
223
223
  } from './list/index.web';
224
+ export { Rail } from './rail';
225
+ export type { RailItem, RailProps } from './rail';
224
226
 
225
227
  // Interaction primitives
226
228
  export { PressableScale } from './pressable-scale';
@@ -0,0 +1,126 @@
1
+ /**
2
+ * `Rail` — a full-height, sticky desktop sidebar navigation column.
3
+ *
4
+ * The vertical sibling of `TabBar`: a fixed set of destinations, one active
5
+ * at a time, a selection callback. It carries no router of its own (a
6
+ * consumer resolves `activeId` from its own routing state, the same shape
7
+ * `bottom-nav`-style consumers already compute for `TabBar`'s `activeIndex`)
8
+ * and no crossfade animation — a rail is a static column a user picks a
9
+ * destination from, not a pill that slides between taps, so each item simply
10
+ * swaps its icon and label styling when it becomes active.
11
+ *
12
+ * ## Sticky positioning
13
+ *
14
+ * On WEB, `Rail` pins itself to the viewport with `position: sticky; top: 0;
15
+ * height: 100vh` so it stays full-height and in view while a document-scroll
16
+ * shell (no fixed-height app container, the window/document is the real
17
+ * scroller) scrolls the content beside it. This is load-bearing, not
18
+ * cosmetic: a plain flow sibling in that layout scrolls away with the
19
+ * document past the height of one screen. Native has no document scroll to
20
+ * defend against — a `Rail` there is already a plain flex sibling that
21
+ * reserves its own space — so the sticky style is web-only, applied inline
22
+ * behind a `Platform.OS` check rather than a `.web` file fork, matching
23
+ * `Label`/`Kbd`'s single-file convention for a component whose platform
24
+ * delta is one conditional style object, not a different render tree.
25
+ *
26
+ * Two RN/react-native-web gaps meet in that one style object, and they get two
27
+ * different escape hatches on purpose:
28
+ *
29
+ * - `position: 'sticky'` has no member on RN's narrow `ViewStyle['position']`
30
+ * union (`'absolute' | 'relative' | 'static'`), so it routes through
31
+ * `WEB_POSITION_STICKY`, Bloom's shared constant for this exact gap (see
32
+ * `styles/web-view-style.ts`) — the one documented crossing point for
33
+ * `position`, same as `WEB_POSITION_FIXED`.
34
+ * - `height: '100vh'` hits the same shape of gap — RN's `DimensionValue` is
35
+ * `number | 'auto' | \`${number}%\` | AnimatedNode | null`, no bare CSS unit
36
+ * string — but `'100vh'` has no OTHER consumer in the package the way
37
+ * `'fixed'`/`'sticky'` do, so it is a local, single-property
38
+ * `as ViewStyle['height']` cast rather than a new shared constant. Gated by
39
+ * `web-css-style.test.ts`'s `ALLOWED` ledger, which pins exactly this cast
40
+ * in this file rather than letting an inline `as ViewStyle` cast come back
41
+ * unnoticed anywhere else.
42
+ */
43
+ import React, { memo } from 'react';
44
+ import { Platform, ScrollView, type ViewStyle } from 'react-native';
45
+
46
+ import { StyledPressable, StyledView } from '../styles/styled-primitives';
47
+ import { WEB_POSITION_STICKY } from '../styles/web-view-style';
48
+ import { Text } from '../typography';
49
+ import type { RailProps } from './types';
50
+
51
+ const webStickyStyle: ViewStyle | undefined =
52
+ Platform.OS === 'web'
53
+ ? {
54
+ position: WEB_POSITION_STICKY,
55
+ top: 0,
56
+ alignSelf: 'flex-start',
57
+ overflow: 'hidden',
58
+ height: '100vh' as ViewStyle['height'],
59
+ }
60
+ : undefined;
61
+
62
+ const DEFAULT_WIDTH = 80;
63
+
64
+ const RailComponent: React.FC<RailProps> = ({
65
+ items,
66
+ activeId,
67
+ onSelect,
68
+ width = DEFAULT_WIDTH,
69
+ style,
70
+ testID,
71
+ }) => {
72
+ return (
73
+ <StyledView
74
+ testID={testID}
75
+ className="h-full shrink-0"
76
+ style={[webStickyStyle, { width }, style]}
77
+ >
78
+ <ScrollView
79
+ style={{ flex: 1 }}
80
+ contentInsetAdjustmentBehavior="never"
81
+ showsVerticalScrollIndicator={false}
82
+ contentContainerStyle={{
83
+ flexGrow: 1,
84
+ justifyContent: 'center',
85
+ paddingHorizontal: 8,
86
+ paddingVertical: 24,
87
+ gap: 8,
88
+ }}
89
+ >
90
+ {items.map((item) => {
91
+ const active = item.id === activeId;
92
+ return (
93
+ <StyledPressable
94
+ key={item.id}
95
+ accessibilityRole="tab"
96
+ accessibilityLabel={item.label}
97
+ accessibilityState={{ selected: active }}
98
+ // `aria-selected` is the state ARIA defines for `role="tab"`, and
99
+ // the one spelling react-native-web actually reads —
100
+ // `accessibilityState` reaches native only. Same pairing
101
+ // `TabBarButtonBody` uses. Gate: `aria-state-source-census.test.ts`.
102
+ aria-selected={active}
103
+ onPress={() => onSelect(item.id)}
104
+ className="min-h-[64px] items-center rounded-[20px] py-2 active:opacity-60"
105
+ style={{ flexDirection: 'column', gap: 5, paddingHorizontal: 0 }}
106
+ >
107
+ <StyledView
108
+ className={`h-8 w-12 items-center justify-center rounded-full ${active ? 'bg-primary-subtle' : ''}`}
109
+ >
110
+ {active ? (item.activeIcon ?? item.icon) : item.icon}
111
+ </StyledView>
112
+ <Text
113
+ className={`max-w-full text-center text-[10px] ${active ? 'font-medium text-primary-text' : 'text-muted-foreground'}`}
114
+ >
115
+ {item.label}
116
+ </Text>
117
+ </StyledPressable>
118
+ );
119
+ })}
120
+ </ScrollView>
121
+ </StyledView>
122
+ );
123
+ };
124
+
125
+ export const Rail = memo(RailComponent);
126
+ Rail.displayName = 'Rail';
@@ -0,0 +1,2 @@
1
+ export { Rail } from './Rail';
2
+ export type { RailItem, RailProps } from './types';
@@ -0,0 +1,47 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { StyleProp, ViewStyle } from 'react-native';
3
+
4
+ /** One destination in a {@link RailProps.items} list. */
5
+ export interface RailItem {
6
+ /** Stable identity for the item, matched against `RailProps.activeId`. */
7
+ id: string;
8
+ /** Text under the icon. */
9
+ label: string;
10
+ /**
11
+ * The glyph, as any node. Bloom owns no icon set here — a consumer's own
12
+ * icon component (or a Bloom `Icons.*` element) is passed in directly, the
13
+ * same convention `TabBarItem.icon` uses.
14
+ */
15
+ icon: ReactNode;
16
+ /**
17
+ * Optional node rendered instead of `icon` while this item is active.
18
+ * Without it the item renders `icon` in both states.
19
+ *
20
+ * The escape hatch for an icon set whose selected state is a different
21
+ * SHAPE or COLOR rather than something `Rail` could tint on its behalf —
22
+ * same convention as `TabBarItem.activeIcon`, resolved directly against
23
+ * `activeId` here rather than crossfading, since `Rail` has no shared
24
+ * highlight animation to drive.
25
+ */
26
+ activeIcon?: ReactNode;
27
+ }
28
+
29
+ export interface RailProps {
30
+ /** The destinations to render, top to bottom. */
31
+ items: RailItem[];
32
+ /**
33
+ * `id` of the active item. An id naming no item (including `undefined`)
34
+ * leaves nothing selected — every item renders in its inactive state.
35
+ */
36
+ activeId?: string;
37
+ /** Called with an item's `id` when it is pressed. */
38
+ onSelect: (id: string) => void;
39
+ /**
40
+ * Width of the rail, in px. Defaults to `80`, a comfortable column for an
41
+ * icon-plus-label item.
42
+ */
43
+ width?: number;
44
+ /** Container style override, merged after the rail's own positioning. */
45
+ style?: StyleProp<ViewStyle>;
46
+ testID?: string;
47
+ }
@@ -20,6 +20,16 @@ import type { ViewStyle } from 'react-native';
20
20
  */
21
21
  export const WEB_POSITION_FIXED = 'fixed' as ViewStyle['position'];
22
22
 
23
+ /**
24
+ * `position: sticky`, typed for React Native's `ViewStyle`. Same gap as
25
+ * {@link WEB_POSITION_FIXED} — RN's `position` union has no `'sticky'` member
26
+ * at all, while react-native-web passes it straight through as real CSS. Used
27
+ * by a surface that pins itself within its own scroll container (a desktop
28
+ * sidebar, a framed panel's overlay chrome) rather than to the viewport,
29
+ * which is what `'fixed'` is for.
30
+ */
31
+ export const WEB_POSITION_STICKY = 'sticky' as ViewStyle['position'];
32
+
23
33
  /**
24
34
  * A `ViewStyle` that may ALSO carry CSS react-native-web forwards straight to the
25
35
  * DOM node but React Native does not model at all.