@oxy.so/bloom 2.3.0 → 2.4.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/popover.mdx +73 -19
- package/lib/commonjs/calendar/CalendarViewInboxMenu.js +4 -13
- package/lib/commonjs/calendar/CalendarViewInboxMenu.js.map +1 -1
- package/lib/commonjs/calendar/CalendarViewMonthGrid.js +6 -10
- package/lib/commonjs/calendar/CalendarViewMonthGrid.js.map +1 -1
- package/lib/commonjs/dialog/DialogHeader.js +1 -7
- package/lib/commonjs/dialog/DialogHeader.js.map +1 -1
- package/lib/commonjs/floating/FloatingPanel.js +19 -22
- package/lib/commonjs/floating/FloatingPanel.js.map +1 -1
- package/lib/commonjs/floating/constants.js +12 -56
- package/lib/commonjs/floating/constants.js.map +1 -1
- package/lib/commonjs/floating/menu-sub-flyout.js +3 -3
- package/lib/commonjs/popover/Popover.js +23 -3
- package/lib/commonjs/popover/Popover.js.map +1 -1
- package/lib/commonjs/popover/Popover.web.js +21 -16
- package/lib/commonjs/popover/Popover.web.js.map +1 -1
- package/lib/commonjs/popover/index.js +31 -0
- package/lib/commonjs/popover/index.js.map +1 -1
- package/lib/commonjs/popover/index.web.js +31 -0
- package/lib/commonjs/popover/index.web.js.map +1 -1
- package/lib/commonjs/popover/parts.js +164 -0
- package/lib/commonjs/popover/parts.js.map +1 -0
- package/lib/commonjs/popover/surface.js +102 -0
- package/lib/commonjs/popover/surface.js.map +1 -0
- package/lib/commonjs/sidebar/parts.js +9 -11
- package/lib/commonjs/sidebar/parts.js.map +1 -1
- package/lib/module/calendar/CalendarViewInboxMenu.js +4 -13
- package/lib/module/calendar/CalendarViewInboxMenu.js.map +1 -1
- package/lib/module/calendar/CalendarViewMonthGrid.js +6 -10
- package/lib/module/calendar/CalendarViewMonthGrid.js.map +1 -1
- package/lib/module/dialog/DialogHeader.js +1 -7
- package/lib/module/dialog/DialogHeader.js.map +1 -1
- package/lib/module/floating/FloatingPanel.js +20 -23
- package/lib/module/floating/FloatingPanel.js.map +1 -1
- package/lib/module/floating/constants.js +11 -55
- package/lib/module/floating/constants.js.map +1 -1
- package/lib/module/floating/menu-sub-flyout.js +3 -3
- package/lib/module/popover/Popover.js +23 -3
- package/lib/module/popover/Popover.js.map +1 -1
- package/lib/module/popover/Popover.web.js +22 -17
- package/lib/module/popover/Popover.web.js.map +1 -1
- package/lib/module/popover/index.js +1 -0
- package/lib/module/popover/index.js.map +1 -1
- package/lib/module/popover/index.web.js +1 -0
- package/lib/module/popover/index.web.js.map +1 -1
- package/lib/module/popover/parts.js +154 -0
- package/lib/module/popover/parts.js.map +1 -0
- package/lib/module/popover/surface.js +96 -0
- package/lib/module/popover/surface.js.map +1 -0
- package/lib/module/sidebar/parts.js +9 -11
- package/lib/module/sidebar/parts.js.map +1 -1
- package/lib/typescript/commonjs/calendar/CalendarViewInboxMenu.d.ts.map +1 -1
- package/lib/typescript/commonjs/calendar/CalendarViewMonthGrid.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/DialogHeader.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/FloatingPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/constants.d.ts +11 -50
- package/lib/typescript/commonjs/floating/constants.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/types.d.ts +5 -4
- package/lib/typescript/commonjs/floating/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/Popover.d.ts +1 -1
- package/lib/typescript/commonjs/popover/Popover.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/Popover.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/index.d.ts +2 -1
- package/lib/typescript/commonjs/popover/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/index.web.d.ts +2 -1
- package/lib/typescript/commonjs/popover/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/parts.d.ts +7 -0
- package/lib/typescript/commonjs/popover/parts.d.ts.map +1 -0
- package/lib/typescript/commonjs/popover/surface.d.ts +58 -0
- package/lib/typescript/commonjs/popover/surface.d.ts.map +1 -0
- package/lib/typescript/commonjs/popover/types.d.ts +50 -0
- package/lib/typescript/commonjs/popover/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/parts.d.ts +2 -2
- package/lib/typescript/commonjs/sidebar/parts.d.ts.map +1 -1
- package/lib/typescript/module/calendar/CalendarViewInboxMenu.d.ts.map +1 -1
- package/lib/typescript/module/calendar/CalendarViewMonthGrid.d.ts.map +1 -1
- package/lib/typescript/module/dialog/DialogHeader.d.ts.map +1 -1
- package/lib/typescript/module/floating/FloatingPanel.d.ts.map +1 -1
- package/lib/typescript/module/floating/constants.d.ts +11 -50
- package/lib/typescript/module/floating/constants.d.ts.map +1 -1
- package/lib/typescript/module/floating/types.d.ts +5 -4
- package/lib/typescript/module/floating/types.d.ts.map +1 -1
- package/lib/typescript/module/popover/Popover.d.ts +1 -1
- package/lib/typescript/module/popover/Popover.d.ts.map +1 -1
- package/lib/typescript/module/popover/Popover.web.d.ts.map +1 -1
- package/lib/typescript/module/popover/index.d.ts +2 -1
- package/lib/typescript/module/popover/index.d.ts.map +1 -1
- package/lib/typescript/module/popover/index.web.d.ts +2 -1
- package/lib/typescript/module/popover/index.web.d.ts.map +1 -1
- package/lib/typescript/module/popover/parts.d.ts +7 -0
- package/lib/typescript/module/popover/parts.d.ts.map +1 -0
- package/lib/typescript/module/popover/surface.d.ts +58 -0
- package/lib/typescript/module/popover/surface.d.ts.map +1 -0
- package/lib/typescript/module/popover/types.d.ts +50 -0
- package/lib/typescript/module/popover/types.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/parts.d.ts +2 -2
- package/lib/typescript/module/sidebar/parts.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/calendar/CalendarViewInboxMenu.tsx +3 -12
- package/src/calendar/CalendarViewMonthGrid.tsx +5 -9
- package/src/dialog/DialogHeader.tsx +1 -6
- package/src/floating/FloatingPanel.tsx +19 -27
- package/src/floating/constants.ts +11 -56
- package/src/floating/menu-sub-flyout.tsx +3 -3
- package/src/floating/types.ts +5 -4
- package/src/popover/Popover.tsx +32 -4
- package/src/popover/Popover.web.tsx +31 -17
- package/src/popover/index.ts +17 -1
- package/src/popover/index.web.ts +17 -1
- package/src/popover/parts.tsx +141 -0
- package/src/popover/surface.ts +119 -0
- package/src/popover/types.ts +56 -0
- package/src/sidebar/parts.tsx +8 -11
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The popover PANEL — Bloom's one floating surface, resolved to inline style.
|
|
3
|
+
*
|
|
4
|
+
* Every floating panel (`dropdown/menu-styles.ts`'s `MENU_POPOVER_SURFACE`, the
|
|
5
|
+
* dashboard team/user menus, the calendar inbox menu, the ai-chat menus) spells
|
|
6
|
+
* the same class string:
|
|
7
|
+
*
|
|
8
|
+
* w-[266px] max-w-[calc(100vw-32px)] overflow-y-auto
|
|
9
|
+
* rounded-2xl border border-border-button-default
|
|
10
|
+
* bg-background-primary-default p-2.5 shadow-dropdown
|
|
11
|
+
* transition duration-150 ease-out, entering/exiting opacity-0 scale-95 blur-[2px]
|
|
12
|
+
* origin at the placement side, offset 8 (4 on the select / date pickers)
|
|
13
|
+
*
|
|
14
|
+
* The motion is `FloatingPanel`'s; everything else is resolved here.
|
|
15
|
+
*
|
|
16
|
+
* ── WHY INLINE, AND HOW A CALLER'S `className` STILL WINS ────────────────────
|
|
17
|
+
*
|
|
18
|
+
* The colours are ramp stops (`menu-palette.ts`) that exist as no CSS variable,
|
|
19
|
+
* so they cannot be classes. The geometry is inline too, because a default CLASS
|
|
20
|
+
* competes with the caller's class by Tailwind's emission order, not by the order
|
|
21
|
+
* in the attribute — measured on this very family: `DialogHeader`'s
|
|
22
|
+
* `className="w-auto p-space-4"` rendered 16px of padding, because the old
|
|
23
|
+
* `p-space-16` default was emitted later and won.
|
|
24
|
+
*
|
|
25
|
+
* But an inline style beats ANY class on web, so a naive inline default would
|
|
26
|
+
* silently outrank every `className` a caller passes. {@link classChromeOverrides}
|
|
27
|
+
* closes that: it reads which chrome PROPERTIES the caller's utilities name
|
|
28
|
+
* (`w-*`, `p-*`, `rounded-*`, `bg-*`, …) and the matching inline default is left
|
|
29
|
+
* out, so the caller's class is the only rule for that property. A caller's
|
|
30
|
+
* `style` still comes last and overrides everything.
|
|
31
|
+
*/
|
|
32
|
+
import type { MenuPalette } from '../floating/menu-palette';
|
|
33
|
+
import type { WebCssStyle } from '../styles/web-view-style';
|
|
34
|
+
|
|
35
|
+
/** `w-[266px]` — `MENU_POPOVER_WIDTH`. */
|
|
36
|
+
export const POPOVER_WIDTH = 266;
|
|
37
|
+
/** `rounded-2xl`. */
|
|
38
|
+
export const POPOVER_RADIUS = 16;
|
|
39
|
+
/** `p-2.5` — also what `PopoverSeparator` bleeds back through. */
|
|
40
|
+
export const POPOVER_PADDING = 10;
|
|
41
|
+
/** `max-w-[calc(100vw-32px)]`, as the 32px it subtracts. */
|
|
42
|
+
export const POPOVER_VIEWPORT_INSET = 32;
|
|
43
|
+
/** Popovers sit `offset={8}` from their trigger. */
|
|
44
|
+
export const POPOVER_SIDE_OFFSET = 8;
|
|
45
|
+
|
|
46
|
+
export type PopoverChromeKey =
|
|
47
|
+
| 'width'
|
|
48
|
+
| 'maxWidth'
|
|
49
|
+
| 'padding'
|
|
50
|
+
| 'radius'
|
|
51
|
+
| 'borderWidth'
|
|
52
|
+
| 'borderColor'
|
|
53
|
+
| 'background'
|
|
54
|
+
| 'shadow'
|
|
55
|
+
| 'overflow';
|
|
56
|
+
|
|
57
|
+
const BORDER_WIDTH = /^border(-[xytrblse])?(-\d+(\.\d+)?|-\[[^\]]+px\])?$/;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Which chrome properties a caller's utility classes set. Variants (`dark:`,
|
|
61
|
+
* `md:`, `hover:`), the important `!` and a negative `-` are stripped first, so
|
|
62
|
+
* `md:!p-0` counts as padding.
|
|
63
|
+
*/
|
|
64
|
+
export function classChromeOverrides(className?: string): ReadonlySet<PopoverChromeKey> {
|
|
65
|
+
const keys = new Set<PopoverChromeKey>();
|
|
66
|
+
if (!className) return keys;
|
|
67
|
+
for (const raw of className.split(/\s+/)) {
|
|
68
|
+
if (!raw) continue;
|
|
69
|
+
const token = raw.slice(raw.lastIndexOf(':') + 1).replace(/^!/, '').replace(/^-/, '');
|
|
70
|
+
if (/^(w|size)-/.test(token)) keys.add('width');
|
|
71
|
+
else if (/^max-w-/.test(token)) keys.add('maxWidth');
|
|
72
|
+
else if (/^p[xytrblse]?-/.test(token)) keys.add('padding');
|
|
73
|
+
else if (/^rounded(-|$)/.test(token)) keys.add('radius');
|
|
74
|
+
else if (BORDER_WIDTH.test(token)) keys.add('borderWidth');
|
|
75
|
+
else if (/^border-/.test(token)) keys.add('borderColor');
|
|
76
|
+
else if (/^bg-/.test(token)) keys.add('background');
|
|
77
|
+
else if (/^shadow(-|$)/.test(token)) keys.add('shadow');
|
|
78
|
+
else if (/^overflow-/.test(token)) keys.add('overflow');
|
|
79
|
+
}
|
|
80
|
+
return keys;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The panel's inline chrome, minus every property the caller's `className`
|
|
85
|
+
* names. `maxWidth` is only the default: a numeric `maxWidth` PROP is applied by
|
|
86
|
+
* `FloatingPanel` and must not be overwritten, so the caller passes
|
|
87
|
+
* `viewportWidth` only when no prop was given.
|
|
88
|
+
*/
|
|
89
|
+
export function resolvePopoverSurfaceStyle(
|
|
90
|
+
palette: MenuPalette,
|
|
91
|
+
overridden: ReadonlySet<PopoverChromeKey>,
|
|
92
|
+
viewportWidth?: number,
|
|
93
|
+
): WebCssStyle {
|
|
94
|
+
const style: WebCssStyle = {};
|
|
95
|
+
if (!overridden.has('width')) style.width = POPOVER_WIDTH;
|
|
96
|
+
if (!overridden.has('maxWidth') && viewportWidth !== undefined) {
|
|
97
|
+
style.maxWidth = Math.max(0, viewportWidth - POPOVER_VIEWPORT_INSET);
|
|
98
|
+
}
|
|
99
|
+
if (!overridden.has('padding')) {
|
|
100
|
+
// Longhands: a caller's `style` override of one side must not lose to a
|
|
101
|
+
// shorthand react-native-web ranks above it (AGENTS.md, "Style").
|
|
102
|
+
style.paddingTop = POPOVER_PADDING;
|
|
103
|
+
style.paddingBottom = POPOVER_PADDING;
|
|
104
|
+
style.paddingLeft = POPOVER_PADDING;
|
|
105
|
+
style.paddingRight = POPOVER_PADDING;
|
|
106
|
+
}
|
|
107
|
+
if (!overridden.has('radius')) style.borderRadius = POPOVER_RADIUS;
|
|
108
|
+
if (!overridden.has('borderWidth')) style.borderWidth = 1;
|
|
109
|
+
if (!overridden.has('borderColor')) style.borderColor = palette.border;
|
|
110
|
+
if (!overridden.has('background')) style.backgroundColor = palette.surface;
|
|
111
|
+
if (!overridden.has('shadow')) style.boxShadow = palette.shadow;
|
|
112
|
+
// The panel's `overflow-y-auto` clips a full-bleed child to the 16px corner and
|
|
113
|
+
// scrolls once something bounds the height. React Native types no
|
|
114
|
+
// `overflowY`, and the panel has no default height bound for `auto` to act
|
|
115
|
+
// on, so the default is the clip; a caller that sets `maxHeight` wraps its
|
|
116
|
+
// body in a `ScrollView` (the calendar inbox menu does).
|
|
117
|
+
if (!overridden.has('overflow')) style.overflow = 'hidden';
|
|
118
|
+
return style;
|
|
119
|
+
}
|
package/src/popover/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
1
3
|
import type {
|
|
2
4
|
OverlayOpenProps,
|
|
3
5
|
OverlaySurfaceProps,
|
|
@@ -7,3 +9,57 @@ import type {
|
|
|
7
9
|
export type PopoverProps = React.PropsWithChildren<OverlayOpenProps>;
|
|
8
10
|
export type PopoverTriggerProps = OverlayTriggerProps;
|
|
9
11
|
export type PopoverContentProps = OverlaySurfaceProps;
|
|
12
|
+
|
|
13
|
+
/** Shared by the panel's layout parts. */
|
|
14
|
+
interface PopoverPartProps {
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
/** Utility classes on the part's own node. */
|
|
17
|
+
className?: string;
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
testID?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The panel's heading row — `flex items-center gap-2 px-2 pt-1`:
|
|
24
|
+
* an optional `leading` (avatar, icon) beside a column of
|
|
25
|
+
* `PopoverTitle` / `PopoverDescription`.
|
|
26
|
+
*/
|
|
27
|
+
export interface PopoverHeaderProps extends PopoverPartProps {
|
|
28
|
+
leading?: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `text-body-medium text-text-primary`, or `text-secondary` for a group label. */
|
|
32
|
+
export interface PopoverTitleProps {
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* `'secondary'` is the group-label colour panels use above a list
|
|
36
|
+
* ("Users with access", "Local Folders"). Defaults to `'primary'`.
|
|
37
|
+
*/
|
|
38
|
+
tone?: 'primary' | 'secondary';
|
|
39
|
+
numberOfLines?: number;
|
|
40
|
+
className?: string;
|
|
41
|
+
style?: StyleProp<TextStyle>;
|
|
42
|
+
testID?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** `text-body-regular text-text-secondary`. */
|
|
46
|
+
export interface PopoverDescriptionProps {
|
|
47
|
+
children?: React.ReactNode;
|
|
48
|
+
numberOfLines?: number;
|
|
49
|
+
className?: string;
|
|
50
|
+
style?: StyleProp<TextStyle>;
|
|
51
|
+
testID?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The panel's closing row — `flex items-center gap-3 px-2 pb-2`. */
|
|
55
|
+
export type PopoverFooterProps = PopoverPartProps;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The full-bleed rule between a panel's sections —
|
|
59
|
+
* `-mx-2.5 my-2.5 h-px bg-border-button-default`.
|
|
60
|
+
*/
|
|
61
|
+
export interface PopoverSeparatorProps {
|
|
62
|
+
className?: string;
|
|
63
|
+
style?: StyleProp<ViewStyle>;
|
|
64
|
+
testID?: string;
|
|
65
|
+
}
|
package/src/sidebar/parts.tsx
CHANGED
|
@@ -225,19 +225,16 @@ export function ChevronUpDownSmall({ color, size = 16 }: { color: string; size?:
|
|
|
225
225
|
);
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
/**
|
|
229
|
-
export function menuPanelStyle(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
borderWidth: 1,
|
|
235
|
-
borderColor: palette.menu.border,
|
|
236
|
-
backgroundColor: palette.menu.surface,
|
|
237
|
-
boxShadow: palette.menu.shadow,
|
|
238
|
-
};
|
|
228
|
+
/** The width both sidebar menus give their popover: `w-[265px]`. */
|
|
229
|
+
export function menuPanelStyle(_palette?: SidebarPalette): ViewStyle {
|
|
230
|
+
// `w-[265px]` is the only thing these menus say differently from the popover
|
|
231
|
+
// panel itself — radius, border, surface, `p-2.5` and `shadow-dropdown` are
|
|
232
|
+
// `Popover`'s own defaults now (`popover/surface.ts`).
|
|
233
|
+
return MENU_PANEL;
|
|
239
234
|
}
|
|
240
235
|
|
|
236
|
+
const MENU_PANEL: ViewStyle = { width: 265 };
|
|
237
|
+
|
|
241
238
|
/** Full-bleed menu divider: `-mx-2.5 h-px bg-border-button-default`. */
|
|
242
239
|
export function MenuDivider({ palette, spacing }: { palette: SidebarPalette; spacing: number }) {
|
|
243
240
|
return (
|