@passui/react 0.1.45 → 0.1.47
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/README.md +57 -46
- package/dist/types/src/components/accordion/accordion.d.ts +1 -1
- package/dist/types/src/components/breadcrumb/breadcrumb.d.ts +1 -1
- package/dist/types/src/components/inline-disclosure/inline-disclosure.d.ts +1 -1
- package/dist/types/src/components/popover/anchored-surface.d.ts +5 -1
- package/dist/types/src/components/popover/index.d.ts +41 -0
- package/dist/types/src/components/popover/popover-content.d.ts +38 -0
- package/dist/types/src/components/popover/popover-root.d.ts +22 -0
- package/dist/types/src/components/popover/popover-trigger.d.ts +23 -0
- package/dist/types/src/components/stepper/rolling-digit.d.ts +1 -1
- package/dist/types/src/components/table/table.d.ts +1 -1
- package/dist/types/src/components/view-controller/view-controller.d.ts +2 -2
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/machines/popover.machine.d.ts +30 -0
- package/package.json +307 -307
- package/src/appearance/index.ts +2 -2
- package/src/appearance/platform.tsx +76 -60
- package/src/appearance/theme.tsx +409 -377
- package/src/components/accordion/accordion.tsx +58 -49
- package/src/components/ambient/ambient.tsx +25 -25
- package/src/components/ambient/index.ts +1 -1
- package/src/components/aspect-ratio/aspect-ratio.tsx +21 -16
- package/src/components/breadcrumb/breadcrumb.tsx +63 -57
- package/src/components/button/button-styles.ts +39 -32
- package/src/components/button/button.tsx +91 -84
- package/src/components/button/icon-button.tsx +27 -25
- package/src/components/button/pending-spinner.tsx +8 -8
- package/src/components/button/use-pending-indicator.ts +11 -11
- package/src/components/chip/chip.tsx +35 -30
- package/src/components/code-block/code-block.tsx +40 -39
- package/src/components/combo-box/combo-box.tsx +5 -5
- package/src/components/command/command.tsx +124 -94
- package/src/components/compact-date-picker/calendar-month.ts +75 -53
- package/src/components/compact-date-picker/compact-date-picker.tsx +308 -289
- package/src/components/compact-time-picker/compact-time-picker.tsx +288 -281
- package/src/components/compact-time-picker/time-value.ts +32 -29
- package/src/components/content-unavailable-view/content-unavailable-view.tsx +64 -48
- package/src/components/content-view/content-view.tsx +168 -159
- package/src/components/content-view/index.ts +1 -1
- package/src/components/context-menu/conceal-menu-source.ts +25 -25
- package/src/components/context-menu/context-menu-host.tsx +439 -402
- package/src/components/context-menu/context-menu-store.ts +125 -123
- package/src/components/context-menu/menu-navigation.ts +25 -18
- package/src/components/context-menu/menu-position.ts +33 -29
- package/src/components/context-menu/menu-reveal.ts +32 -32
- package/src/components/context-menu/use-context-menu.ts +63 -56
- package/src/components/conversation/conversation.tsx +265 -263
- package/src/components/conversation/index.ts +1 -1
- package/src/components/date-picker/date-picker.tsx +95 -94
- package/src/components/date-picker/date-value.ts +20 -10
- package/src/components/dialog/dialog-host.tsx +105 -103
- package/src/components/dialog/dialog-store.ts +37 -36
- package/src/components/dialog/dialog.tsx +192 -179
- package/src/components/dialog/index.ts +1 -1
- package/src/components/disclosure-group/disclosure-group.tsx +93 -86
- package/src/components/divider/divider.tsx +24 -22
- package/src/components/inline-disclosure/inline-disclosure.tsx +40 -36
- package/src/components/keyboard-shortcut/keyboard-shortcut.tsx +23 -19
- package/src/components/labeled-content/labeled-content.tsx +68 -68
- package/src/components/locale-switcher/index.ts +1 -1
- package/src/components/locale-switcher/locale-switcher.tsx +278 -251
- package/src/components/menu/menu.tsx +75 -58
- package/src/components/morph/index.ts +2 -2
- package/src/components/morph/morph.tsx +227 -201
- package/src/components/morph/use-morph-disclosure.ts +19 -19
- package/src/components/one-time-code/one-time-code.tsx +216 -200
- package/src/components/picker/picker-trigger.ts +16 -13
- package/src/components/picker/picker.tsx +371 -345
- package/src/components/popover/anchored-surface.tsx +253 -229
- package/src/components/popover/index.ts +50 -0
- package/src/components/popover/popover-content.tsx +374 -0
- package/src/components/popover/popover-root.tsx +97 -0
- package/src/components/popover/popover-trigger.tsx +71 -0
- package/src/components/profile-image/profile-image.tsx +80 -64
- package/src/components/progress-view/progress-view.tsx +61 -59
- package/src/components/progress-view/use-liquid-progress.ts +38 -38
- package/src/components/radio-group/radio-group.tsx +71 -68
- package/src/components/search-field/expanding-search-field.tsx +191 -177
- package/src/components/search-field/search-field.tsx +59 -50
- package/src/components/search-list/search-list.tsx +246 -236
- package/src/components/section/section.tsx +58 -58
- package/src/components/secure-field/secure-field.tsx +3 -3
- package/src/components/segmented-control/segmented-control.tsx +136 -136
- package/src/components/sheet/modal-environment.ts +71 -64
- package/src/components/sheet/sheet-portal.tsx +58 -53
- package/src/components/sheet/sheet.tsx +146 -141
- package/src/components/sheet/use-sheet-focus.ts +97 -82
- package/src/components/sidebar/sidebar.tsx +78 -78
- package/src/components/skeleton/skeleton.tsx +30 -21
- package/src/components/slider/slider.tsx +113 -104
- package/src/components/slosh-slider/liquid-step.ts +32 -31
- package/src/components/slosh-slider/slosh-slider.tsx +265 -228
- package/src/components/stat-tile/index.ts +1 -1
- package/src/components/stat-tile/stat-tile.tsx +79 -68
- package/src/components/status-indicator/status-indicator.tsx +40 -37
- package/src/components/stepper/rolling-digit.tsx +82 -68
- package/src/components/stepper/stepper.tsx +122 -113
- package/src/components/swatch-picker/swatch-picker.tsx +120 -120
- package/src/components/tab-bar/tab-bar.tsx +149 -148
- package/src/components/tab-view/tab-view.tsx +140 -137
- package/src/components/table/table.tsx +117 -98
- package/src/components/text-editor/text-editor.tsx +34 -29
- package/src/components/text-field/text-field.tsx +182 -180
- package/src/components/toast/toast-store.ts +127 -115
- package/src/components/toast/toaster.tsx +361 -347
- package/src/components/toggle/toggle.tsx +297 -282
- package/src/components/tooltip/tooltip-host.tsx +157 -150
- package/src/components/view-controller/index.ts +1 -1
- package/src/components/view-controller/view-controller.tsx +64 -53
- package/src/components/wake-slider/wake-slider.tsx +220 -205
- package/src/hooks/scroll/minimize-decision.ts +11 -7
- package/src/hooks/use-anchored-disclosure.ts +19 -19
- package/src/hooks/use-anchored-placement.ts +29 -25
- package/src/hooks/use-dismiss.ts +33 -29
- package/src/hooks/use-floating-dismiss.ts +24 -22
- package/src/hooks/use-media-query.ts +67 -60
- package/src/hooks/use-minimize-on-scroll.ts +69 -60
- package/src/hooks/use-visual-viewport.ts +63 -63
- package/src/hooks/viewport/types.ts +16 -16
- package/src/hooks/viewport/viewport-metrics.ts +16 -10
- package/src/icons/icons.tsx +440 -328
- package/src/index.ts +91 -91
- package/src/lib/anchored-placement.ts +70 -65
- package/src/lib/class-names.ts +14 -13
- package/src/lib/clipboard.ts +8 -7
- package/src/lib/date.ts +61 -60
- package/src/lib/floating-layers.ts +39 -24
- package/src/lib/haptics.ts +10 -10
- package/src/lib/language.ts +9 -9
- package/src/lib/range-value.ts +27 -21
- package/src/lib/screen-edges.ts +33 -30
- package/src/lib/shapes.ts +38 -34
- package/src/machines/popover.machine.ts +51 -0
- package/src/motion/transitions.ts +46 -43
- package/src/styles/code-block.css +69 -43
- package/src/styles/motion-controls.css +393 -191
- package/src/tokens.ts +1 -1
- package/dist/types/src/components/popover/popover-fit.d.ts +0 -21
- package/dist/types/src/components/popover/popover.d.ts +0 -21
- package/src/components/popover/popover-fit.ts +0 -69
- package/src/components/popover/popover.tsx +0 -334
|
@@ -1,240 +1,264 @@
|
|
|
1
|
-
import { springs } from "@passui/tokens/motion"
|
|
2
|
-
import { useMediaQuery } from "../../hooks/use-media-query"
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
1
|
+
import { springs } from "@passui/tokens/motion";
|
|
2
|
+
import { useMediaQuery } from "../../hooks/use-media-query";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef,
|
|
5
|
+
type HTMLAttributes,
|
|
6
|
+
useLayoutEffect,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { useAnchoredPlacement } from "../../hooks/use-anchored-placement";
|
|
11
|
+
import { FLOATING_LAYER } from "../../hooks/use-dismiss";
|
|
12
|
+
import { useFloatingDismiss } from "../../hooks/use-floating-dismiss";
|
|
13
|
+
import { cn } from "../../lib/class-names";
|
|
14
|
+
import { registerFloatingLayer } from "../../lib/floating-layers";
|
|
15
|
+
import { concealMenuSource } from "../context-menu/conceal-menu-source";
|
|
16
|
+
import { menuSurfaceReveal } from "../context-menu/menu-reveal";
|
|
11
17
|
|
|
12
18
|
interface AnchoredSurfaceProps extends HTMLAttributes<HTMLDivElement> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
open: boolean;
|
|
20
|
+
onExited: () => void;
|
|
21
|
+
anchor: HTMLElement;
|
|
22
|
+
width: number;
|
|
23
|
+
needed: number;
|
|
24
|
+
onClose: (restoreFocus: boolean) => void;
|
|
25
|
+
contentClassName?: string;
|
|
20
26
|
}
|
|
21
27
|
|
|
22
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Shared material and lifetime for portaled
|
|
30
|
+
* pickers; their content owns
|
|
31
|
+
* selection.
|
|
32
|
+
* */
|
|
23
33
|
export const AnchoredSurface = forwardRef<HTMLDivElement, AnchoredSurfaceProps>(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
function AnchoredSurface(
|
|
35
|
+
{
|
|
36
|
+
open: present,
|
|
37
|
+
onExited: remove,
|
|
38
|
+
anchor,
|
|
39
|
+
width,
|
|
40
|
+
needed,
|
|
41
|
+
onClose,
|
|
42
|
+
children,
|
|
43
|
+
className,
|
|
44
|
+
contentClassName,
|
|
45
|
+
...props
|
|
46
|
+
},
|
|
47
|
+
forwardedRef,
|
|
48
|
+
) {
|
|
49
|
+
const root = useRef<HTMLDivElement>(null);
|
|
50
|
+
const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
51
|
+
const material = useRef<HTMLDivElement>(null);
|
|
52
|
+
const content = useRef<HTMLDivElement>(null);
|
|
53
|
+
const animated = useRef<{
|
|
54
|
+
values: number[];
|
|
55
|
+
velocities: number[];
|
|
56
|
+
opacity: number;
|
|
57
|
+
materialOpacity: number;
|
|
58
|
+
} | null>(null);
|
|
59
|
+
const placement = useAnchoredPlacement(anchor, width, needed, true);
|
|
60
|
+
const [geometry, setGeometry] = useState<{
|
|
61
|
+
source: ReturnType<typeof menuSurfaceReveal>;
|
|
62
|
+
width: number;
|
|
63
|
+
height: number;
|
|
64
|
+
radius: number;
|
|
65
|
+
} | null>(null);
|
|
56
66
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
67
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: Placement can move without resizing; remeasure the source-relative reveal.
|
|
68
|
+
useLayoutEffect(() => {
|
|
69
|
+
const panel = root.current;
|
|
70
|
+
if (!panel || !present) return;
|
|
71
|
+
const measure = () => {
|
|
72
|
+
const target = panel.getBoundingClientRect();
|
|
73
|
+
const source = anchor.getBoundingClientRect();
|
|
74
|
+
const radius =
|
|
75
|
+
Number.parseFloat(getComputedStyle(panel).borderTopLeftRadius) || 0;
|
|
76
|
+
const reveal = menuSurfaceReveal(source, target);
|
|
77
|
+
setGeometry((current) =>
|
|
78
|
+
current &&
|
|
79
|
+
current.width === target.width &&
|
|
80
|
+
current.height === target.height &&
|
|
81
|
+
current.radius === radius &&
|
|
82
|
+
current.source.x === reveal.x &&
|
|
83
|
+
current.source.y === reveal.y &&
|
|
84
|
+
current.source.width === reveal.width &&
|
|
85
|
+
current.source.height === reveal.height
|
|
86
|
+
? current
|
|
87
|
+
: {
|
|
88
|
+
source: reveal,
|
|
89
|
+
width: target.width,
|
|
90
|
+
height: target.height,
|
|
91
|
+
radius,
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
measure();
|
|
96
|
+
const observer = new ResizeObserver(measure);
|
|
97
|
+
observer.observe(panel);
|
|
98
|
+
return () => observer.disconnect();
|
|
99
|
+
}, [
|
|
100
|
+
anchor,
|
|
101
|
+
present,
|
|
102
|
+
placement.left,
|
|
103
|
+
placement.top,
|
|
104
|
+
placement.bottom,
|
|
105
|
+
placement.width,
|
|
106
|
+
]);
|
|
84
107
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
108
|
+
useLayoutEffect(() => {
|
|
109
|
+
if (!root.current) return;
|
|
110
|
+
const unregister = registerFloatingLayer(root.current, anchor);
|
|
111
|
+
return unregister;
|
|
112
|
+
}, [anchor]);
|
|
90
113
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
114
|
+
useLayoutEffect(() => {
|
|
115
|
+
if (!present) return;
|
|
116
|
+
const restore = concealMenuSource(anchor, false);
|
|
117
|
+
return () => {
|
|
118
|
+
restore();
|
|
119
|
+
};
|
|
120
|
+
}, [anchor, present]);
|
|
98
121
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
122
|
+
useLayoutEffect(() => {
|
|
123
|
+
if (!geometry || !material.current || !content.current) {
|
|
124
|
+
if (!present) remove?.();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const pane = material.current;
|
|
128
|
+
const body = content.current;
|
|
129
|
+
const source = [
|
|
130
|
+
geometry.source.x,
|
|
131
|
+
geometry.source.y,
|
|
132
|
+
geometry.source.width,
|
|
133
|
+
geometry.source.height,
|
|
134
|
+
geometry.source.borderRadius,
|
|
135
|
+
];
|
|
136
|
+
const target = present
|
|
137
|
+
? [0, 0, geometry.width, geometry.height, geometry.radius]
|
|
138
|
+
: source;
|
|
139
|
+
const state = animated.current ?? {
|
|
140
|
+
values: [...source],
|
|
141
|
+
velocities: source.map(() => 0),
|
|
142
|
+
opacity: 0,
|
|
143
|
+
materialOpacity: 1,
|
|
144
|
+
};
|
|
145
|
+
animated.current = state;
|
|
146
|
+
let frame = 0;
|
|
147
|
+
let previous = 0;
|
|
148
|
+
const paint = () => {
|
|
149
|
+
const [x, y, width, height, radius] = state.values;
|
|
150
|
+
pane.style.transform = `translate(${x}px, ${y}px)`;
|
|
151
|
+
pane.style.width = `${Math.max(0, width)}px`;
|
|
152
|
+
pane.style.height = `${Math.max(0, height)}px`;
|
|
153
|
+
pane.style.borderRadius = `${Math.max(0, radius)}px`;
|
|
154
|
+
pane.style.opacity = String(state.materialOpacity);
|
|
155
|
+
body.style.opacity = String(state.opacity);
|
|
156
|
+
};
|
|
157
|
+
const tick = (now: number) => {
|
|
158
|
+
const dt = previous ? Math.min(0.032, (now - previous) / 1000) : 1 / 60;
|
|
159
|
+
previous = now;
|
|
160
|
+
const { stiffness, damping, mass } = springs.smooth;
|
|
161
|
+
let resting = true;
|
|
162
|
+
for (let index = 0; index < target.length; index++) {
|
|
163
|
+
state.velocities[index] +=
|
|
164
|
+
(((target[index] - state.values[index]) * stiffness -
|
|
165
|
+
state.velocities[index] * damping) /
|
|
166
|
+
mass) *
|
|
167
|
+
dt;
|
|
168
|
+
state.values[index] += state.velocities[index] * dt;
|
|
169
|
+
if (
|
|
170
|
+
Math.abs(target[index] - state.values[index]) > 0.05 ||
|
|
171
|
+
Math.abs(state.velocities[index]) > 0.05
|
|
172
|
+
)
|
|
173
|
+
resting = false;
|
|
174
|
+
}
|
|
175
|
+
const progress = Math.max(
|
|
176
|
+
0,
|
|
177
|
+
Math.min(
|
|
178
|
+
1,
|
|
179
|
+
1 -
|
|
180
|
+
Math.abs(geometry.height - state.values[3]) /
|
|
181
|
+
Math.max(1, Math.abs(geometry.height - source[3])),
|
|
182
|
+
),
|
|
183
|
+
);
|
|
184
|
+
const opacity = present ? Math.max(0, (progress - 0.25) / 0.75) : 0;
|
|
185
|
+
state.opacity += (opacity - state.opacity) * (1 - Math.exp(-dt / 0.04));
|
|
186
|
+
state.materialOpacity +=
|
|
187
|
+
((present ? 1 : 0) - state.materialOpacity) *
|
|
188
|
+
(1 - Math.exp(-dt / 0.04));
|
|
189
|
+
paint();
|
|
190
|
+
if (
|
|
191
|
+
resting &&
|
|
192
|
+
Math.abs(opacity - state.opacity) < 0.01 &&
|
|
193
|
+
Math.abs((present ? 1 : 0) - state.materialOpacity) < 0.01
|
|
194
|
+
) {
|
|
195
|
+
state.values = [...target];
|
|
196
|
+
state.velocities.fill(0);
|
|
197
|
+
state.opacity = present ? 1 : 0;
|
|
198
|
+
state.materialOpacity = present ? 1 : 0;
|
|
199
|
+
paint();
|
|
200
|
+
if (!present) remove?.();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
frame = requestAnimationFrame(tick);
|
|
204
|
+
};
|
|
205
|
+
if (reducedMotion) {
|
|
206
|
+
state.values = [...target];
|
|
207
|
+
state.velocities.fill(0);
|
|
208
|
+
state.opacity = present ? 1 : 0;
|
|
209
|
+
state.materialOpacity = present ? 1 : 0;
|
|
210
|
+
paint();
|
|
211
|
+
if (!present) remove?.();
|
|
212
|
+
} else {
|
|
213
|
+
paint();
|
|
214
|
+
frame = requestAnimationFrame(tick);
|
|
215
|
+
}
|
|
216
|
+
return () => cancelAnimationFrame(frame);
|
|
217
|
+
}, [geometry, present, remove, reducedMotion]);
|
|
194
218
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
219
|
+
useFloatingDismiss(root, anchor, (restore) => {
|
|
220
|
+
if (present) onClose(restore);
|
|
221
|
+
});
|
|
198
222
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
)
|
|
223
|
+
return (
|
|
224
|
+
<div
|
|
225
|
+
{...props}
|
|
226
|
+
ref={(node) => {
|
|
227
|
+
root.current = node;
|
|
228
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
229
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
230
|
+
}}
|
|
231
|
+
{...{ [FLOATING_LAYER]: "" }}
|
|
232
|
+
inert={!present}
|
|
233
|
+
className={cn(
|
|
234
|
+
"fixed isolate z-[80] flex min-w-0 flex-col rounded-3xl outline-none",
|
|
235
|
+
!present && "pointer-events-none",
|
|
236
|
+
className,
|
|
237
|
+
)}
|
|
238
|
+
style={{
|
|
239
|
+
left: placement.left,
|
|
240
|
+
top: placement.top,
|
|
241
|
+
bottom: placement.bottom,
|
|
242
|
+
width: placement.width,
|
|
243
|
+
maxHeight: placement.maxHeight ?? 420,
|
|
244
|
+
}}
|
|
245
|
+
>
|
|
246
|
+
<div
|
|
247
|
+
ref={material}
|
|
248
|
+
aria-hidden="true"
|
|
249
|
+
className="glass-menu pointer-events-none absolute top-0 left-0 -z-10"
|
|
250
|
+
/>
|
|
251
|
+
<div
|
|
252
|
+
ref={content}
|
|
253
|
+
style={{ opacity: 0 }}
|
|
254
|
+
className={cn(
|
|
255
|
+
"flex min-h-0 flex-col overflow-y-auto overscroll-contain",
|
|
256
|
+
contentClassName,
|
|
257
|
+
)}
|
|
258
|
+
>
|
|
259
|
+
{children}
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
},
|
|
264
|
+
);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Popover — a glass surface that springs open from its trigger.
|
|
3
|
+
*
|
|
4
|
+
* Compound API (the only API):
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <Popover>
|
|
8
|
+
* <Popover.Trigger render={(props) => <Button {...props}>Open</Button>} />
|
|
9
|
+
* <Popover.Content origin="top-left" className="top-full left-0 mt-2 w-64 p-4">
|
|
10
|
+
* …content…
|
|
11
|
+
* </Popover.Content>
|
|
12
|
+
* </Popover>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* The `Popover.Trigger` clones its child (or uses a `render` prop) and wires
|
|
16
|
+
* up aria-haspopup, aria-expanded, aria-controls, click + keyboard toggling.
|
|
17
|
+
* The `Popover.Content` portals out of the authored layout, morphs its glass
|
|
18
|
+
* surface from the trigger's rect, and keeps itself inside the viewport as
|
|
19
|
+
* it resizes or scrolls. `origin` picks the corner it grows from; pass
|
|
20
|
+
* `placement="center"` for a modal center-screen variant.
|
|
21
|
+
*
|
|
22
|
+
* State is driven by a small pure machine (`popover.machine.ts`) that
|
|
23
|
+
* translates directly to a Rust enum — see the architecture plan.
|
|
24
|
+
*/
|
|
25
|
+
export { PopoverRoot as Root } from "./popover-root";
|
|
26
|
+
export {
|
|
27
|
+
PopoverTrigger as Trigger,
|
|
28
|
+
type PopoverTriggerRenderProps,
|
|
29
|
+
} from "./popover-trigger";
|
|
30
|
+
export {
|
|
31
|
+
PopoverContent as Content,
|
|
32
|
+
type PopoverOrigin,
|
|
33
|
+
} from "./popover-content";
|
|
34
|
+
|
|
35
|
+
import { PopoverRoot } from "./popover-root";
|
|
36
|
+
import { PopoverTrigger } from "./popover-trigger";
|
|
37
|
+
import { PopoverContent } from "./popover-content";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Compound Popover. Use as `<Popover>` with `.Trigger` and `.Content` parts,
|
|
41
|
+
* or import `Root` / `Trigger` / `Content` directly from the barrel.
|
|
42
|
+
*/
|
|
43
|
+
export const Popover = Object.assign(PopoverRoot, {
|
|
44
|
+
Trigger: PopoverTrigger,
|
|
45
|
+
Content: PopoverContent,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export type { PopoverRootProps } from "./popover-root";
|
|
49
|
+
export type { PopoverTriggerProps } from "./popover-trigger";
|
|
50
|
+
export type { PopoverContentProps } from "./popover-content";
|