@gaulatti/bleecker 0.1.40 → 0.1.42
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/LICENSE +21 -0
- package/README.md +58 -1
- package/dist/components/alert-dialog.js +7 -42
- package/dist/components/attention-surface.d.ts +11 -0
- package/dist/components/attention-surface.js +16 -0
- package/dist/components/command-spotlight.js +34 -49
- package/dist/components/context-menu.js +7 -1
- package/dist/components/drawer.js +2 -2
- package/dist/components/dropdown-menu.js +12 -2
- package/dist/components/modal.js +7 -57
- package/dist/components/popover.js +3 -1
- package/dist/components/select.js +3 -1
- package/dist/components/sheet.js +2 -2
- package/dist/components/tooltip.js +3 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/layout/feed-column.d.ts +12 -0
- package/dist/layout/feed-column.js +12 -0
- package/dist/layout/feed-grid.d.ts +5 -0
- package/dist/layout/feed-grid.js +6 -0
- package/dist/styles.css +1 -1
- package/dist/theme/theme-script.d.ts +1 -1
- package/dist/theme/theme-script.js +1 -1
- package/dist/utils/attention-color.d.ts +25 -0
- package/dist/utils/attention-color.js +27 -0
- package/dist/utils/hooks.d.ts +13 -2
- package/dist/utils/hooks.js +205 -35
- package/package.json +9 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Javier Godoy and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -8,12 +8,51 @@ Bleecker is a refined React component library built around the Encode Sans typef
|
|
|
8
8
|
npm install @gaulatti/bleecker
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Choose one stylesheet integration. Tailwind CSS v4 applications should compile
|
|
12
|
+
Bleecker together with their own utilities:
|
|
13
|
+
|
|
14
|
+
```css
|
|
15
|
+
/* app.css */
|
|
16
|
+
@import "@gaulatti/bleecker/styles.base.css";
|
|
17
|
+
@source "../node_modules/@gaulatti/bleecker/dist/**/*.js";
|
|
18
|
+
@source "./**/*.{ts,tsx}";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Do not also import `@gaulatti/bleecker/styles.css` in a Tailwind application.
|
|
22
|
+
Doing so loads a second compiled utility layer and can change responsive layout
|
|
23
|
+
behavior through the cascade.
|
|
24
|
+
|
|
25
|
+
Applications that do not compile Tailwind should instead import the complete,
|
|
26
|
+
precompiled stylesheet once:
|
|
12
27
|
|
|
13
28
|
```ts
|
|
14
29
|
import '@gaulatti/bleecker/styles.css';
|
|
15
30
|
```
|
|
16
31
|
|
|
32
|
+
## Attention feeds
|
|
33
|
+
|
|
34
|
+
Use Bleecker's feed primitives for multi-column monitoring, event indexes, and
|
|
35
|
+
other continuously updated operational views:
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { AttentionSurface } from '@gaulatti/bleecker/components/attention-surface';
|
|
39
|
+
import { FeedColumn } from '@gaulatti/bleecker/layout/feed-column';
|
|
40
|
+
import { FeedGrid } from '@gaulatti/bleecker/layout/feed-grid';
|
|
41
|
+
|
|
42
|
+
<FeedColumn accent='hsl(285 64% 66%)' count={50} title='Business'>
|
|
43
|
+
<AttentionSurface hue={285} intensity={2}>
|
|
44
|
+
Low-urgency item: 80% column hue, 20% red.
|
|
45
|
+
</AttentionSurface>
|
|
46
|
+
</FeedColumn>;
|
|
47
|
+
|
|
48
|
+
<FeedGrid minColumnWidth={360}>{eventCards}</FeedGrid>;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`AttentionSurface` accepts a continuous intensity from 0–10. Intensity changes
|
|
52
|
+
both the category-to-red color mix and the distance traveled by the gradient.
|
|
53
|
+
Consumers decide what intensity means—relevance, magnitude, risk, confidence,
|
|
54
|
+
or another domain measure—but should not reimplement the visual interpolation.
|
|
55
|
+
|
|
17
56
|
```tsx
|
|
18
57
|
import { Button, Field, Input } from '@gaulatti/bleecker';
|
|
19
58
|
|
|
@@ -65,6 +104,11 @@ Interactive overlays and selection controls use accessible behavioral primitives
|
|
|
65
104
|
|
|
66
105
|
Applications are still responsible for meaningful labels, logical page structure, and testing complete user flows in their own context.
|
|
67
106
|
|
|
107
|
+
Modal surfaces activate keyboard focus when their panels mount, contain Tab
|
|
108
|
+
navigation, and restore focus and scrolling after dismissal, including nested
|
|
109
|
+
panels. See the [modal keyboard lifecycle](docs/modal-keyboard-lifecycle.md) for
|
|
110
|
+
the contract, interaction fixtures, and browser evidence.
|
|
111
|
+
|
|
68
112
|
## Shared foundations
|
|
69
113
|
|
|
70
114
|
Bleecker is the source of truth for platform-neutral component contracts and design tokens. These leaf exports do not import DOM components, CSS, Radix, Recharts, or ReactDOM:
|
|
@@ -76,6 +120,14 @@ import { radii, spacing, themes } from '@gaulatti/bleecker/tokens';
|
|
|
76
120
|
|
|
77
121
|
`src/tokens/source.ts` is canonical. The web CSS token layer is generated from it during the build and checked for drift in CI. [Thompson](https://github.com/gaulatti/thompson), Bleecker's React Native sibling, consumes these exports and supplies native renderers.
|
|
78
122
|
|
|
123
|
+
## Generated contract conformance
|
|
124
|
+
|
|
125
|
+
Bleecker may consume a pinned renderer-neutral artifact as conformance input,
|
|
126
|
+
but generated output never overwrites its hand-authored components. The
|
|
127
|
+
[Kolibri Toggle parity decision](docs/kolibri-toggle-parity.md) documents the
|
|
128
|
+
first bounded proof, its immutable fixture, browser accessibility and visual
|
|
129
|
+
evidence, unsupported `ToggleGroup` boundary, and proceed-with-adapter result.
|
|
130
|
+
|
|
79
131
|
## Development
|
|
80
132
|
|
|
81
133
|
```sh
|
|
@@ -86,3 +138,8 @@ npm run build
|
|
|
86
138
|
```
|
|
87
139
|
|
|
88
140
|
The build cleans generated output before compilation so removed modules cannot remain in published packages.
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
Bleecker, including its published npm versions, is available under the
|
|
145
|
+
[MIT License](LICENSE).
|
|
@@ -5,53 +5,18 @@ import React from 'react';
|
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import { Button } from './button.js';
|
|
7
7
|
import { cn } from '../utils/cn.js';
|
|
8
|
-
import { usePresence } from '../utils/hooks.js';
|
|
8
|
+
import { ModalLayerScope, useModalLayer, usePresence } from '../utils/hooks.js';
|
|
9
9
|
export function AlertDialog({ cancelLabel = 'Cancel', className, confirmLabel = 'Continue', confirmLoading = false, description, isOpen, onCancel, onConfirm, title, variant = 'default' }) {
|
|
10
|
-
const
|
|
10
|
+
const requestCancel = () => { if (isOpen && !confirmLoading)
|
|
11
|
+
onCancel(); };
|
|
12
|
+
const dialogRef = useModalLayer(isOpen, requestCancel);
|
|
11
13
|
const titleId = React.useId();
|
|
12
14
|
const descriptionId = React.useId();
|
|
13
15
|
const { present, visible } = usePresence(isOpen, 150);
|
|
14
|
-
React.useLayoutEffect(() => {
|
|
15
|
-
const dialog = dialogRef.current;
|
|
16
|
-
if (!present || !dialog)
|
|
17
|
-
return;
|
|
18
|
-
if (isOpen && !dialog.open) {
|
|
19
|
-
dialog.showModal();
|
|
20
|
-
}
|
|
21
|
-
return () => {
|
|
22
|
-
if (!isOpen && dialog.open)
|
|
23
|
-
dialog.close();
|
|
24
|
-
};
|
|
25
|
-
}, [isOpen, present]);
|
|
26
|
-
// Trap focus & handle keyboard dismissal
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
if (!isOpen)
|
|
29
|
-
return;
|
|
30
|
-
const handleKeyDown = (event) => {
|
|
31
|
-
if (event.key === 'Escape') {
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
if (!confirmLoading)
|
|
34
|
-
onCancel();
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
document.addEventListener('keydown', handleKeyDown);
|
|
38
|
-
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
39
|
-
}, [isOpen, onCancel, confirmLoading]);
|
|
40
16
|
if (typeof document === 'undefined' || !present) {
|
|
41
17
|
return null;
|
|
42
18
|
}
|
|
43
|
-
return createPortal(_jsx("
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
}, onCancel: (event) => {
|
|
48
|
-
event.preventDefault();
|
|
49
|
-
if (!confirmLoading)
|
|
50
|
-
onCancel();
|
|
51
|
-
}, onClose: () => {
|
|
52
|
-
if (isOpen)
|
|
53
|
-
onCancel();
|
|
54
|
-
}, children: _jsxs("div", { className: 'p-6 md:p-8', children: [_jsxs("div", { className: 'mb-6 flex items-start gap-4', children: [_jsx("div", { className: cn('flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-[9px] border', variant === 'destructive'
|
|
55
|
-
? 'border-terracotta/15 bg-terracotta/[0.07] text-terracotta dark:bg-terracotta/15'
|
|
56
|
-
: 'border-desert/15 bg-desert/[0.07] text-desert dark:bg-desert/15 dark:text-accent-gold'), children: _jsx(AlertTriangle, { size: 20 }) }), _jsxs("div", { className: 'min-w-0 flex-1', children: [_jsx("h2", { id: titleId, className: 'text-xl font-medium leading-tight text-text-primary dark:text-text-primary', children: title }), description ? _jsx("p", { id: descriptionId, className: 'font-secondary mt-2 text-sm leading-relaxed text-text-secondary dark:text-text-secondary', children: description }) : null] })] }), _jsxs("div", { className: 'flex justify-end gap-3 border-t border-sand/20 pt-5 dark:border-white/10', children: [_jsx(Button, { variant: 'secondary', size: 'sm', onClick: onCancel, disabled: confirmLoading, children: cancelLabel }), _jsx(Button, { variant: variant === 'destructive' ? 'destructive' : 'primary', size: 'sm', onClick: onConfirm, disabled: confirmLoading, children: confirmLoading ? (_jsxs("span", { className: 'flex items-center gap-2', children: [_jsx(Loader2, { size: 16, className: 'animate-spin' }), confirmLabel] })) : (confirmLabel) })] })] }) }), document.body);
|
|
19
|
+
return createPortal(_jsx(ModalLayerScope, { layerRef: dialogRef, children: _jsxs("div", { "data-bleecker-modal-overlay": true, className: cn('fixed inset-0 z-50 flex p-4', !isOpen && 'pointer-events-none'), "aria-hidden": !isOpen || undefined, children: [_jsx("div", { "aria-hidden": 'true', onClick: requestCancel, className: cn('absolute inset-0 bg-deep-sea/38 backdrop-blur-[2px] transition-opacity dark:bg-black/65', visible ? 'opacity-100 duration-[var(--motion-control)]' : 'opacity-0 duration-[var(--motion-exit)]') }), _jsx("div", { ref: dialogRef, role: 'alertdialog', "aria-modal": 'true', tabIndex: -1, "aria-labelledby": titleId, "aria-describedby": description ? descriptionId : undefined, "data-state": visible ? 'open' : 'closing', className: cn('modal-motion relative m-auto max-h-[calc(100dvh-2rem)] w-full max-w-md overflow-auto rounded-[var(--radius-dialog)] border border-sand/30 bg-white p-0 text-text-primary shadow-[var(--shadow-overlay)] outline-none dark:border-white/12 dark:bg-deep-sea dark:text-text-primary', className), children: _jsxs("div", { className: 'p-6 md:p-8', children: [_jsxs("div", { className: 'mb-6 flex items-start gap-4', children: [_jsx("div", { className: cn('flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-[9px] border', variant === 'destructive'
|
|
20
|
+
? 'border-terracotta/15 bg-terracotta/[0.07] text-terracotta dark:bg-terracotta/15'
|
|
21
|
+
: 'border-desert/15 bg-desert/[0.07] text-desert dark:bg-desert/15 dark:text-accent-gold'), children: _jsx(AlertTriangle, { size: 20 }) }), _jsxs("div", { className: 'min-w-0 flex-1', children: [_jsx("h2", { id: titleId, className: 'text-xl font-medium leading-tight text-text-primary dark:text-text-primary', children: title }), description ? _jsx("p", { id: descriptionId, className: 'font-secondary mt-2 text-sm leading-relaxed text-text-secondary dark:text-text-secondary', children: description }) : null] })] }), _jsxs("div", { className: 'flex justify-end gap-3 border-t border-sand/20 pt-5 dark:border-white/10', children: [_jsx(Button, { variant: 'secondary', size: 'sm', onClick: onCancel, disabled: confirmLoading, children: cancelLabel }), _jsx(Button, { variant: variant === 'destructive' ? 'destructive' : 'primary', size: 'sm', onClick: onConfirm, disabled: confirmLoading, children: confirmLoading ? (_jsxs("span", { className: 'flex items-center gap-2', children: [_jsx(Loader2, { size: 16, className: 'animate-spin' }), confirmLabel] })) : (confirmLabel) })] })] }) })] }) }), document.body);
|
|
57
22
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type AttentionSurfaceElement = 'article' | 'button' | 'div' | 'li' | 'section';
|
|
3
|
+
export type AttentionSurfaceDensity = 'compact' | 'comfortable';
|
|
4
|
+
export interface AttentionSurfaceProps extends Omit<React.ComponentPropsWithoutRef<'button'>, 'color'> {
|
|
5
|
+
as?: AttentionSurfaceElement;
|
|
6
|
+
density?: AttentionSurfaceDensity;
|
|
7
|
+
hue: number;
|
|
8
|
+
intensity: number;
|
|
9
|
+
interactive?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const AttentionSurface: React.ForwardRefExoticComponent<AttentionSurfaceProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utils/cn.js';
|
|
3
|
+
import { createAttentionColor } from '../utils/attention-color.js';
|
|
4
|
+
export const AttentionSurface = React.forwardRef(function AttentionSurface({ as: Component = 'article', children, className, density = 'comfortable', hue, intensity, interactive, style, type, ...props }, ref) {
|
|
5
|
+
const attention = createAttentionColor({ hue, intensity });
|
|
6
|
+
const isInteractive = interactive ?? Component === 'button';
|
|
7
|
+
return React.createElement(Component, {
|
|
8
|
+
...props,
|
|
9
|
+
...(Component === 'button' ? { type: type ?? 'button' } : {}),
|
|
10
|
+
className: cn('rounded-[11px] border text-left shadow-[0_16px_38px_-30px_rgba(0,0,0,0.92)]', 'transition-[background-color,border-color,box-shadow,transform] duration-[var(--motion-surface)] ease-premium', density === 'compact' ? 'px-4 py-4' : 'px-5 py-5', isInteractive && 'hover:-translate-y-px hover:shadow-[0_24px_48px_-28px_rgba(0,0,0,0.9)] focus:outline-none focus:ring-2 focus:ring-sea/30', className),
|
|
11
|
+
'data-attention-intensity': attention.intensity,
|
|
12
|
+
'data-attention-red-mix': attention.redMix,
|
|
13
|
+
ref,
|
|
14
|
+
style: { ...attention.style, ...style }
|
|
15
|
+
}, children);
|
|
16
|
+
});
|
|
@@ -6,7 +6,7 @@ import { createPortal } from 'react-dom';
|
|
|
6
6
|
import { Button } from './button.js';
|
|
7
7
|
import { Kbd } from './kbd.js';
|
|
8
8
|
import { cn } from '../utils/cn.js';
|
|
9
|
-
import { usePresence } from '../utils/hooks.js';
|
|
9
|
+
import { ModalLayerScope, useModalLayer, usePresence } from '../utils/hooks.js';
|
|
10
10
|
const DEFAULT_GROUP = 'Actions';
|
|
11
11
|
function normalize(text) {
|
|
12
12
|
return text.trim().toLowerCase();
|
|
@@ -108,17 +108,6 @@ export function CommandSpotlight({ actions, className, dialogClassName, emptyMes
|
|
|
108
108
|
}
|
|
109
109
|
setIsMacLike(/mac|iphone|ipad|ipod/i.test(navigator.platform));
|
|
110
110
|
}, []);
|
|
111
|
-
React.useEffect(() => {
|
|
112
|
-
if (!isOpen) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const timeout = window.setTimeout(() => {
|
|
116
|
-
inputRef.current?.focus();
|
|
117
|
-
}, 0);
|
|
118
|
-
return () => {
|
|
119
|
-
window.clearTimeout(timeout);
|
|
120
|
-
};
|
|
121
|
-
}, [isOpen]);
|
|
122
111
|
React.useEffect(() => {
|
|
123
112
|
if (!isOpen) {
|
|
124
113
|
return;
|
|
@@ -155,17 +144,13 @@ export function CommandSpotlight({ actions, className, dialogClassName, emptyMes
|
|
|
155
144
|
}
|
|
156
145
|
return;
|
|
157
146
|
}
|
|
158
|
-
if (!isOpen || pressedKey !== 'escape') {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
event.preventDefault();
|
|
162
|
-
closeSpotlight();
|
|
163
147
|
};
|
|
164
148
|
window.addEventListener('keydown', handleWindowKeyDown);
|
|
165
149
|
return () => {
|
|
166
150
|
window.removeEventListener('keydown', handleWindowKeyDown);
|
|
167
151
|
};
|
|
168
152
|
}, [closeSpotlight, hotkey, isOpen, setIsOpen]);
|
|
153
|
+
const panelRef = useModalLayer(isOpen, closeSpotlight);
|
|
169
154
|
const hotkeyHint = React.useMemo(() => {
|
|
170
155
|
const modifier = isMacLike ? '⌘' : 'Ctrl';
|
|
171
156
|
return [modifier, hotkey.toUpperCase()];
|
|
@@ -174,41 +159,41 @@ export function CommandSpotlight({ actions, className, dialogClassName, emptyMes
|
|
|
174
159
|
setIsOpen(true);
|
|
175
160
|
}, className: cn('border-sand/35 bg-white px-3 py-1.5 text-text-primary shadow-[0_1px_2px_rgba(26,55,77,0.03)] hover:border-sand/65 hover:bg-light-sand/35 dark:border-white/15 dark:bg-deep-sea dark:hover:bg-white/[0.06]', triggerClassName), "aria-label": 'Open command spotlight', children: [_jsx(Search, { size: 15, className: 'text-text-secondary dark:text-text-secondary' }), _jsx("span", { className: 'hidden sm:inline', children: triggerLabel }), _jsx(Kbd, { keys: hotkeyHint, className: 'hidden sm:inline-flex' })] })) : null;
|
|
176
161
|
const renderOverlay = isOverlayPresent && typeof document !== 'undefined'
|
|
177
|
-
? createPortal(_jsxs("div", { className: cn('fixed inset-0 z-9999 flex items-start justify-center px-4 pt-[12vh]', overlayClassName), children: [_jsx("button", { type: 'button', onClick: closeSpotlight, className: cn('absolute inset-0 bg-black/45 backdrop-blur-sm transition-opacity', isOverlayVisible ? 'opacity-100 duration-[var(--motion-overlay)] ease-premium' : 'opacity-0 duration-[160ms] ease-in'), "aria-label": 'Close command spotlight' }), _jsxs("div", { role: 'dialog', "aria-modal": 'true', className: cn('relative z-10 w-full max-w-2xl overflow-hidden rounded-[var(--radius-dialog)] border border-sand/30 bg-white text-text-primary shadow-[var(--shadow-overlay)] transition-[opacity,transform] dark:border-white/12 dark:bg-deep-sea dark:text-text-primary', isOverlayVisible
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (event.key === 'Enter') {
|
|
191
|
-
event.preventDefault();
|
|
192
|
-
if (!selectedActionId) {
|
|
162
|
+
? createPortal(_jsx(ModalLayerScope, { layerRef: panelRef, children: _jsxs("div", { "data-bleecker-modal-overlay": true, "aria-hidden": !isOpen || undefined, className: cn('fixed inset-0 z-9999 flex items-start justify-center px-4 pt-[12vh]', !isOpen && 'pointer-events-none', overlayClassName), children: [_jsx("button", { type: 'button', onClick: closeSpotlight, className: cn('absolute inset-0 bg-black/45 backdrop-blur-sm transition-opacity', isOverlayVisible ? 'opacity-100 duration-[var(--motion-overlay)] ease-premium' : 'opacity-0 duration-[160ms] ease-in'), "aria-label": 'Close command spotlight' }), _jsxs("div", { ref: panelRef, tabIndex: -1, "aria-label": 'Command spotlight', role: 'dialog', "aria-modal": 'true', className: cn('relative z-10 w-full max-w-2xl overflow-hidden rounded-[var(--radius-dialog)] border border-sand/30 bg-white text-text-primary shadow-[var(--shadow-overlay)] transition-[opacity,transform] dark:border-white/12 dark:bg-deep-sea dark:text-text-primary', isOverlayVisible
|
|
163
|
+
? 'translate-y-0 scale-100 opacity-100 duration-[var(--motion-overlay)] ease-premium'
|
|
164
|
+
: '-translate-y-1 scale-[0.992] opacity-0 duration-[160ms] ease-in', dialogClassName), onClick: (event) => event.stopPropagation(), children: [_jsxs("div", { className: 'flex items-center gap-3 border-b border-sand/15 px-4 py-3 dark:border-sand/20', children: [_jsx(Search, { size: 18, className: 'shrink-0 text-text-secondary dark:text-text-secondary' }), _jsx("input", { ref: inputRef, type: 'text', value: query, onChange: (event) => setQuery(event.target.value), onKeyDown: (event) => {
|
|
165
|
+
if (event.key === 'ArrowDown') {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
moveSelection(1);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (event.key === 'ArrowUp') {
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
moveSelection(-1);
|
|
193
173
|
return;
|
|
194
174
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
175
|
+
if (event.key === 'Enter') {
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
if (!selectedActionId) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const selectedAction = filteredActions.find((action) => action.id === selectedActionId);
|
|
181
|
+
if (selectedAction) {
|
|
182
|
+
runAction(selectedAction);
|
|
183
|
+
}
|
|
198
184
|
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}) })] }, group)))) })] })] }), document.body)
|
|
185
|
+
}, placeholder: placeholder, className: 'w-full bg-transparent text-base text-text-primary outline-none placeholder:text-text-secondary dark:text-text-primary dark:placeholder:text-text-secondary' }), _jsx(Kbd, { keys: hotkeyHint })] }), _jsx("div", { className: 'max-h-[55vh] overflow-y-auto p-2', children: groupedActions.length === 0 ? (_jsx("p", { className: 'px-3 py-12 text-center text-sm text-text-secondary dark:text-text-secondary', children: emptyMessage })) : (groupedActions.map(([group, groupActions]) => (_jsxs("section", { className: 'mb-3 last:mb-0', children: [_jsx("p", { className: 'px-3 pb-1 text-[11px] font-semibold uppercase tracking-wider text-text-secondary dark:text-text-secondary', children: group }), _jsx("div", { className: 'space-y-1', children: groupActions.map((action) => {
|
|
186
|
+
const isSelected = action.id === selectedActionId;
|
|
187
|
+
return (_jsxs("button", { type: 'button', ref: (element) => {
|
|
188
|
+
actionRefs.current[action.id] = element;
|
|
189
|
+
}, disabled: action.disabled, onClick: () => runAction(action), onMouseEnter: () => {
|
|
190
|
+
if (!action.disabled) {
|
|
191
|
+
setSelectedActionId(action.id);
|
|
192
|
+
}
|
|
193
|
+
}, className: cn('flex w-full items-center justify-between gap-3 rounded-[var(--radius-ui)] px-3 py-2.5 text-left transition-colors duration-[var(--motion-control)] ease-premium', isSelected
|
|
194
|
+
? 'bg-sea/10 text-sea dark:bg-accent-blue/15 dark:text-accent-blue'
|
|
195
|
+
: 'text-text-primary hover:bg-sand/10 dark:text-text-primary dark:hover:bg-sand/15', action.disabled && 'cursor-not-allowed opacity-40'), children: [_jsxs("div", { className: 'flex min-w-0 items-center gap-3', children: [action.icon ? (_jsx("span", { className: 'flex h-8 w-8 shrink-0 items-center justify-center rounded-[7px] border border-sand/15 bg-light-sand/50 text-text-secondary dark:border-white/[0.06] dark:bg-white/[0.05] dark:text-text-secondary', children: action.icon })) : null, _jsxs("div", { className: 'min-w-0', children: [_jsx("p", { className: 'truncate text-sm font-medium', children: action.title }), action.description ? (_jsx("p", { className: 'truncate text-xs text-text-secondary dark:text-text-secondary', children: action.description })) : null] })] }), action.shortcut && action.shortcut.length > 0 ? _jsx(Kbd, { keys: action.shortcut }) : null] }, action.id));
|
|
196
|
+
}) })] }, group)))) })] })] }) }), document.body)
|
|
212
197
|
: null;
|
|
213
198
|
return (_jsxs("div", { className: className, children: [renderTrigger, renderOverlay] }));
|
|
214
199
|
}
|
|
@@ -2,9 +2,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu';
|
|
4
4
|
import { cn } from '../utils/cn.js';
|
|
5
|
+
import { useModalBranch } from '../utils/hooks.js';
|
|
6
|
+
import { useComposedRefs } from '@radix-ui/react-compose-refs';
|
|
5
7
|
const ContextMenu = ContextMenuPrimitive.Root;
|
|
6
8
|
const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
|
7
|
-
const ContextMenuContent = React.forwardRef(({ className, ...props }, ref) =>
|
|
9
|
+
const ContextMenuContent = React.forwardRef(({ className, ...props }, ref) => {
|
|
10
|
+
const branchRef = useModalBranch();
|
|
11
|
+
const composedRef = useComposedRefs(ref, branchRef);
|
|
12
|
+
return (_jsx(ContextMenuPrimitive.Portal, { children: _jsx(ContextMenuPrimitive.Content, { ref: composedRef, className: cn('z-50 min-w-[10rem] overflow-hidden rounded-[var(--radius-ui)] border border-sand/35 bg-white p-1.5 text-text-primary shadow-[var(--shadow-overlay)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-[0.99] data-[state=closed]:zoom-out-[0.99] data-[state=open]:duration-[var(--motion-surface)] data-[state=closed]:duration-[var(--motion-exit)] data-[state=open]:ease-premium data-[state=closed]:ease-in dark:border-white/15 dark:bg-deep-sea dark:text-text-primary', className), ...props }) }));
|
|
13
|
+
});
|
|
8
14
|
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
9
15
|
const ContextMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => (_jsx(ContextMenuPrimitive.Item, { ref: ref, className: cn('relative flex min-h-9 cursor-default select-none items-center rounded-[5px] px-2.5 py-1.5 text-[13px] text-text-primary outline-none transition-colors duration-[var(--motion-control)] ease-premium focus:bg-light-sand data-[disabled]:pointer-events-none data-[disabled]:opacity-40 dark:text-text-primary dark:focus:bg-white/[0.07]', inset && 'pl-8', className), ...props })));
|
|
10
16
|
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
@@ -4,7 +4,7 @@ import { Minus } from 'lucide-react';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import { cn } from '../utils/cn.js';
|
|
7
|
-
import { useModalLayer, usePresence } from '../utils/hooks.js';
|
|
7
|
+
import { ModalLayerScope, useModalLayer, usePresence } from '../utils/hooks.js';
|
|
8
8
|
export function Drawer({ children, className, description, isOpen, onClose, title }) {
|
|
9
9
|
const { present, visible } = usePresence(isOpen, 180);
|
|
10
10
|
const startYRef = React.useRef(null);
|
|
@@ -24,5 +24,5 @@ export function Drawer({ children, className, description, isOpen, onClose, titl
|
|
|
24
24
|
};
|
|
25
25
|
if (typeof document === 'undefined' || !present)
|
|
26
26
|
return null;
|
|
27
|
-
return createPortal(_jsxs("div", { className: 'fixed inset-0 z-50', children: [_jsx("div", { className: cn('absolute inset-0 bg-deep-sea/38 backdrop-blur-[2px] transition-opacity ease-premium dark:bg-black/65', visible ? 'duration-[var(--motion-overlay)]' : 'duration-[180ms] ease-in', visible ? 'opacity-100' : 'opacity-0'), onClick: onClose, "aria-hidden": 'true' }), _jsxs("div", { ref: panelRef, role: 'dialog', "aria-modal": 'true', "aria-label": title ? undefined : 'Dialog', "aria-labelledby": title ? titleId : undefined, "aria-describedby": description ? descriptionId : undefined, tabIndex: -1, onTouchStart: handleTouchStart, onTouchEnd: handleTouchEnd, className: cn('absolute inset-x-0 bottom-0 flex max-h-[90dvh] flex-col rounded-t-[var(--radius-dialog)] border-t border-sand/30 bg-white shadow-[var(--shadow-overlay)] transition-transform dark:border-white/12 dark:bg-deep-sea', visible ? 'duration-[var(--motion-overlay)] ease-premium' : 'duration-[180ms] ease-in', visible ? 'translate-y-0' : 'translate-y-full', className), children: [_jsx("div", { className: 'flex items-center justify-center pt-3 pb-1', children: _jsx(Minus, { size: 24, className: 'text-sand/40 dark:text-sand/50', strokeWidth: 3, "aria-hidden": 'true' }) }), (title || description) && (_jsxs("div", { className: 'px-6 pb-4 pt-1', children: [title ? _jsx("h2", { id: titleId, className: 'text-lg font-medium text-text-primary dark:text-text-primary', children: title }) : null, description ? _jsx("p", { id: descriptionId, className: 'font-secondary mt-2 text-sm leading-relaxed text-text-secondary dark:text-text-secondary', children: description }) : null] })), _jsx("div", { className: 'flex-1 overflow-y-auto px-6 pb-6 pt-0', children: children })] })] }), document.body);
|
|
27
|
+
return createPortal(_jsx(ModalLayerScope, { layerRef: panelRef, children: _jsxs("div", { "data-bleecker-modal-overlay": true, className: cn('fixed inset-0 z-50', !isOpen && 'pointer-events-none'), "aria-hidden": !isOpen || undefined, children: [_jsx("div", { className: cn('absolute inset-0 bg-deep-sea/38 backdrop-blur-[2px] transition-opacity ease-premium dark:bg-black/65', visible ? 'duration-[var(--motion-overlay)]' : 'duration-[180ms] ease-in', visible ? 'opacity-100' : 'opacity-0'), onClick: onClose, "aria-hidden": 'true' }), _jsxs("div", { ref: panelRef, role: 'dialog', "aria-modal": 'true', "aria-label": title ? undefined : 'Dialog', "aria-labelledby": title ? titleId : undefined, "aria-describedby": description ? descriptionId : undefined, tabIndex: -1, onTouchStart: handleTouchStart, onTouchEnd: handleTouchEnd, className: cn('absolute inset-x-0 bottom-0 flex max-h-[90dvh] flex-col rounded-t-[var(--radius-dialog)] border-t border-sand/30 bg-white shadow-[var(--shadow-overlay)] transition-transform dark:border-white/12 dark:bg-deep-sea', visible ? 'duration-[var(--motion-overlay)] ease-premium' : 'duration-[180ms] ease-in', visible ? 'translate-y-0' : 'translate-y-full', className), children: [_jsx("div", { className: 'flex items-center justify-center pt-3 pb-1', children: _jsx(Minus, { size: 24, className: 'text-sand/40 dark:text-sand/50', strokeWidth: 3, "aria-hidden": 'true' }) }), (title || description) && (_jsxs("div", { className: 'px-6 pb-4 pt-1', children: [title ? _jsx("h2", { id: titleId, className: 'text-lg font-medium text-text-primary dark:text-text-primary', children: title }) : null, description ? _jsx("p", { id: descriptionId, className: 'font-secondary mt-2 text-sm leading-relaxed text-text-secondary dark:text-text-secondary', children: description }) : null] })), _jsx("div", { className: 'flex-1 overflow-y-auto px-6 pb-6 pt-0', children: children })] })] }) }), document.body);
|
|
28
28
|
}
|
|
@@ -3,6 +3,8 @@ import * as React from 'react';
|
|
|
3
3
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
4
4
|
import { Check, ChevronRight, Circle } from 'lucide-react';
|
|
5
5
|
import { cn } from '../utils/cn.js';
|
|
6
|
+
import { useModalBranch } from '../utils/hooks.js';
|
|
7
|
+
import { useComposedRefs } from '@radix-ui/react-compose-refs';
|
|
6
8
|
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
7
9
|
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
8
10
|
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
@@ -11,9 +13,17 @@ const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
|
11
13
|
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
12
14
|
const DropdownMenuSubTrigger = React.forwardRef(({ className, inset, children, ...props }, ref) => (_jsxs(DropdownMenuPrimitive.SubTrigger, { ref: ref, className: cn('flex cursor-default select-none items-center rounded-[var(--radius-ui)] px-2 py-1.5 text-sm text-text-primary outline-none transition-colors duration-[var(--motion-control)] ease-premium focus:bg-sand/10 data-[state=open]:bg-sand/10 dark:text-text-primary dark:focus:bg-sand/15', inset && 'pl-8', className), ...props, children: [children, _jsx(ChevronRight, { size: 16, className: 'ml-auto' })] })));
|
|
13
15
|
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
|
14
|
-
const DropdownMenuSubContent = React.forwardRef(({ className, ...props }, ref) =>
|
|
16
|
+
const DropdownMenuSubContent = React.forwardRef(({ className, ...props }, ref) => {
|
|
17
|
+
const branchRef = useModalBranch();
|
|
18
|
+
const composedRef = useComposedRefs(ref, branchRef);
|
|
19
|
+
return (_jsx(DropdownMenuPrimitive.SubContent, { ref: composedRef, className: cn('z-50 min-w-[9rem] overflow-hidden rounded-[var(--radius-ui)] border border-sand/35 bg-card p-1.5 shadow-[var(--shadow-overlay)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-[0.99] data-[state=open]:zoom-in-[0.99] data-[state=open]:duration-[var(--motion-surface)] data-[state=closed]:duration-[var(--motion-exit)] data-[state=open]:ease-premium data-[state=closed]:ease-in dark:border-white/15 dark:bg-deep-sea', className), ...props }));
|
|
20
|
+
});
|
|
15
21
|
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
|
16
|
-
const DropdownMenuContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) =>
|
|
22
|
+
const DropdownMenuContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
|
|
23
|
+
const branchRef = useModalBranch();
|
|
24
|
+
const composedRef = useComposedRefs(ref, branchRef);
|
|
25
|
+
return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { ref: composedRef, sideOffset: sideOffset, className: cn('z-50 min-w-[11rem] overflow-hidden rounded-[var(--radius-ui)] border border-sand/35 bg-card p-1.5 shadow-[var(--shadow-overlay)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-[0.99] data-[state=open]:zoom-in-[0.99] data-[state=open]:duration-[var(--motion-surface)] data-[state=closed]:duration-[var(--motion-exit)] data-[state=open]:ease-premium data-[state=closed]:ease-in dark:border-white/15 dark:bg-deep-sea', className), ...props }) }));
|
|
26
|
+
});
|
|
17
27
|
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
18
28
|
const DropdownMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => (_jsx(DropdownMenuPrimitive.Item, { ref: ref, className: cn('relative flex cursor-pointer select-none items-center rounded-[var(--radius-ui)] px-2 py-1.5 text-sm text-text-primary outline-none transition-colors duration-[var(--motion-control)] ease-premium focus:bg-sand/10 focus:text-text-primary data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:text-text-primary dark:focus:bg-sand/15', inset && 'pl-8', className), ...props })));
|
|
19
29
|
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
package/dist/components/modal.js
CHANGED
|
@@ -4,66 +4,16 @@ import React from 'react';
|
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
import { DialogCloseButton } from './dialog-close-button.js';
|
|
6
6
|
import { cn } from '../utils/cn.js';
|
|
7
|
+
import { ModalLayerScope, useModalLayer, usePresence } from '../utils/hooks.js';
|
|
7
8
|
export function Modal({ children, className, isOpen, onClose, title }) {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const openTimerRef = React.useRef(null);
|
|
9
|
+
const { present: isPresent, visible } = usePresence(isOpen, 150);
|
|
10
|
+
const dialogRef = useModalLayer(isOpen, onClose);
|
|
11
11
|
const titleId = React.useId();
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
if (isOpen) {
|
|
16
|
-
if (closeTimerRef.current)
|
|
17
|
-
clearTimeout(closeTimerRef.current);
|
|
18
|
-
setIsPresent(true);
|
|
19
|
-
setMotionState('opening');
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (isPresent) {
|
|
23
|
-
setMotionState('closing');
|
|
24
|
-
closeTimerRef.current = setTimeout(() => {
|
|
25
|
-
dialogRef.current?.close();
|
|
26
|
-
setIsPresent(false);
|
|
27
|
-
}, 150);
|
|
28
|
-
}
|
|
29
|
-
}, [isOpen, isPresent]);
|
|
30
|
-
React.useLayoutEffect(() => {
|
|
31
|
-
const dialog = dialogRef.current;
|
|
32
|
-
if (!isPresent || !isOpen || !dialog)
|
|
33
|
-
return;
|
|
34
|
-
if (!dialog.open)
|
|
35
|
-
dialog.showModal();
|
|
36
|
-
openTimerRef.current = setTimeout(() => setMotionState('open'), 20);
|
|
37
|
-
return () => {
|
|
38
|
-
if (openTimerRef.current)
|
|
39
|
-
clearTimeout(openTimerRef.current);
|
|
40
|
-
};
|
|
41
|
-
}, [isOpen, isPresent]);
|
|
42
|
-
React.useEffect(() => {
|
|
43
|
-
return () => {
|
|
44
|
-
if (closeTimerRef.current)
|
|
45
|
-
clearTimeout(closeTimerRef.current);
|
|
46
|
-
if (openTimerRef.current)
|
|
47
|
-
clearTimeout(openTimerRef.current);
|
|
48
|
-
dialogRef.current?.close();
|
|
49
|
-
};
|
|
50
|
-
}, []);
|
|
51
|
-
const requestClose = () => {
|
|
52
|
-
if (motionState !== 'closing')
|
|
53
|
-
onClose();
|
|
54
|
-
};
|
|
12
|
+
const motionState = visible ? 'open' : 'closing';
|
|
13
|
+
const requestClose = () => { if (isOpen)
|
|
14
|
+
onClose(); };
|
|
55
15
|
if (typeof document === 'undefined' || !isPresent) {
|
|
56
16
|
return null;
|
|
57
17
|
}
|
|
58
|
-
return createPortal(_jsx("
|
|
59
|
-
if (event.target === dialogRef.current) {
|
|
60
|
-
requestClose();
|
|
61
|
-
}
|
|
62
|
-
}, onCancel: (event) => {
|
|
63
|
-
event.preventDefault();
|
|
64
|
-
requestClose();
|
|
65
|
-
}, onClose: () => {
|
|
66
|
-
if (isOpen)
|
|
67
|
-
onClose();
|
|
68
|
-
}, children: _jsxs("div", { children: [_jsxs("div", { className: 'flex items-center justify-between gap-4 border-b border-sand/20 px-6 py-5 dark:border-white/[0.08] md:px-7', children: [_jsx("h2", { id: titleId, className: 'text-xl font-semibold tracking-refined text-text-primary dark:text-text-primary', children: title }), _jsx(DialogCloseButton, { onClick: requestClose, "aria-label": 'Close' })] }), _jsx("div", { className: 'px-6 py-6 md:px-7 md:py-7', children: children })] }) }), document.body);
|
|
18
|
+
return createPortal(_jsx(ModalLayerScope, { layerRef: dialogRef, children: _jsxs("div", { "data-bleecker-modal-overlay": true, className: cn('fixed inset-0 z-50 flex p-4', !isOpen && 'pointer-events-none'), "aria-hidden": !isOpen || undefined, children: [_jsx("div", { "aria-hidden": 'true', onClick: requestClose, className: cn('absolute inset-0 bg-deep-sea/38 backdrop-blur-[2px] transition-opacity dark:bg-black/65', visible ? 'opacity-100 duration-[var(--motion-control)]' : 'opacity-0 duration-[var(--motion-exit)]') }), _jsx("div", { ref: dialogRef, role: 'dialog', "aria-modal": 'true', "aria-labelledby": titleId, tabIndex: -1, "data-state": motionState, className: cn('modal-motion relative m-auto max-h-[calc(100dvh-2rem)] w-full max-w-xl overflow-auto rounded-[var(--radius-dialog)] border border-sand/30 bg-white p-0 text-text-primary shadow-[var(--shadow-overlay)] outline-none dark:border-white/12 dark:bg-deep-sea dark:text-text-primary', className), children: _jsxs("div", { children: [_jsxs("div", { className: 'flex items-center justify-between gap-4 border-b border-sand/20 px-6 py-5 dark:border-white/[0.08] md:px-7', children: [_jsx("h2", { id: titleId, className: 'text-xl font-semibold tracking-refined text-text-primary dark:text-text-primary', children: title }), _jsx(DialogCloseButton, { onClick: requestClose, "aria-label": 'Close' })] }), _jsx("div", { className: 'px-6 py-6 md:px-7 md:py-7', children: children })] }) })] }) }), document.body);
|
|
69
19
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
3
3
|
import { cn } from '../utils/cn.js';
|
|
4
|
+
import { useModalBranch } from '../utils/hooks.js';
|
|
4
5
|
export function Popover({ align = 'center', children, className, content, defaultOpen, onOpenChange, open, side = 'bottom', sideOffset = 4 }) {
|
|
5
|
-
|
|
6
|
+
const branchRef = useModalBranch();
|
|
7
|
+
return (_jsxs(PopoverPrimitive.Root, { defaultOpen: defaultOpen, onOpenChange: onOpenChange, open: open, children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: children }), _jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { ref: branchRef, align: align, side: side, sideOffset: sideOffset, collisionPadding: 12, className: cn('z-50 min-w-56 rounded-[var(--radius-ui)] border border-sand/35 bg-white p-2 text-text-primary shadow-[var(--shadow-overlay)] outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-[0.99] data-[state=closed]:zoom-out-[0.99] data-[state=open]:duration-[var(--motion-surface)] data-[state=closed]:duration-[var(--motion-exit)] data-[state=open]:ease-premium data-[state=closed]:ease-in dark:border-white/15 dark:bg-deep-sea dark:text-text-primary', className), children: content }) })] }));
|
|
6
8
|
}
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
4
4
|
import { Check, ChevronDown, ChevronUp } from 'lucide-react';
|
|
5
5
|
import { cn } from '../utils/cn.js';
|
|
6
|
+
import { useModalBranch } from '../utils/hooks.js';
|
|
6
7
|
const EMPTY_OPTION_VALUE = '__bleecker_empty_option__';
|
|
7
8
|
const triggerSizeClasses = {
|
|
8
9
|
sm: 'h-9 gap-2 px-3 text-[13px]',
|
|
@@ -12,5 +13,6 @@ const triggerSizeClasses = {
|
|
|
12
13
|
export function Select({ 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, autoFocus, className, contentClassName, disabled = false, error = false, id, name, onChange, options, placeholder = 'Select…', required, size = 'md', startIcon, value }) {
|
|
13
14
|
const hasEmptyOption = options.some((option) => option.value === '');
|
|
14
15
|
const internalValue = value === '' && hasEmptyOption ? EMPTY_OPTION_VALUE : value || undefined;
|
|
15
|
-
|
|
16
|
+
const branchRef = useModalBranch();
|
|
17
|
+
return (_jsxs(SelectPrimitive.Root, { disabled: disabled, name: name, required: required, value: internalValue, onValueChange: (nextValue) => onChange(nextValue === EMPTY_OPTION_VALUE ? '' : nextValue), children: [_jsxs(SelectPrimitive.Trigger, { id: id, autoFocus: autoFocus, "aria-label": ariaLabel ?? placeholder, "aria-describedby": ariaDescribedBy, "aria-invalid": error || undefined, className: cn('flex w-full items-center rounded-[var(--radius-ui)] border border-sand/40 bg-white text-left text-text-primary shadow-[0_1px_2px_rgba(26,55,77,0.025)] outline-none transition-[background-color,border-color,box-shadow,opacity] duration-[var(--motion-control)] ease-premium hover:border-sand/70 hover:shadow-[0_3px_10px_-8px_rgba(26,55,77,0.25)] focus:border-sea/70 focus:ring-2 focus:ring-sea/10 data-[state=open]:border-sea/70 data-[state=open]:ring-2 data-[state=open]:ring-sea/10 data-[disabled]:cursor-not-allowed data-[disabled]:bg-light-sand/65 data-[disabled]:opacity-60 dark:border-white/15 dark:bg-deep-sea dark:text-text-primary dark:hover:border-white/25 dark:focus:border-accent-blue dark:focus:ring-accent-blue/12 dark:data-[state=open]:border-accent-blue dark:data-[state=open]:ring-accent-blue/12', triggerSizeClasses[size], error && 'border-terracotta focus:border-terracotta focus:ring-terracotta/15 dark:border-terracotta', className), children: [startIcon ? _jsx("span", { className: 'flex shrink-0 items-center text-sea dark:text-accent-blue', "aria-hidden": 'true', children: startIcon }) : null, _jsx("span", { className: 'min-w-0 flex-1 truncate', children: _jsx(SelectPrimitive.Value, { placeholder: placeholder }) }), _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { size: 17, className: 'shrink-0 text-text-secondary', "aria-hidden": 'true' }) })] }), _jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ref: branchRef, position: 'popper', side: 'bottom', align: 'start', sideOffset: 4, collisionPadding: 8, sticky: 'always', updatePositionStrategy: 'always', className: cn('z-50 w-[var(--radix-select-trigger-width)] overflow-hidden rounded-[var(--radius-ui)] border border-sand/40 bg-white shadow-[var(--shadow-overlay)] outline-none data-[side=bottom]:origin-top data-[side=top]:origin-bottom data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-[0.99] data-[state=closed]:zoom-out-[0.99] data-[state=open]:duration-[var(--motion-surface)] data-[state=closed]:duration-[var(--motion-exit)] data-[state=open]:ease-premium data-[state=closed]:ease-in dark:border-white/15 dark:bg-deep-sea', contentClassName), children: [_jsx(SelectPrimitive.ScrollUpButton, { className: 'flex h-7 items-center justify-center border-b border-sand/15 bg-white text-text-secondary dark:border-white/10 dark:bg-deep-sea', children: _jsx(ChevronUp, { size: 15, "aria-hidden": 'true' }) }), _jsx(SelectPrimitive.Viewport, { className: 'max-h-[min(18rem,var(--radix-select-content-available-height))] p-1', children: options.map((option) => (_jsxs(SelectPrimitive.Item, { value: option.value === '' ? EMPTY_OPTION_VALUE : option.value, disabled: option.disabled, className: cn('relative flex cursor-default select-none items-center rounded-[5px] pl-3 pr-9 text-text-primary outline-none transition-[background-color,color,opacity] duration-[var(--motion-control)] ease-premium data-[disabled]:pointer-events-none data-[highlighted]:bg-light-sand data-[disabled]:opacity-40 data-[state=checked]:font-medium data-[state=checked]:text-sea dark:text-text-primary dark:data-[highlighted]:bg-white/[0.07] dark:data-[state=checked]:text-accent-blue', size === 'sm' ? 'min-h-8 py-1.5 text-[13px]' : size === 'lg' ? 'min-h-10 py-2 text-[15px]' : 'min-h-9 py-1.5 text-sm'), children: [_jsx(SelectPrimitive.ItemText, { children: option.label }), _jsx(SelectPrimitive.ItemIndicator, { className: 'absolute right-3 inline-flex items-center', children: _jsx(Check, { size: 15, "aria-hidden": 'true' }) })] }, option.value))) }), _jsx(SelectPrimitive.ScrollDownButton, { className: 'flex h-7 items-center justify-center border-t border-sand/15 bg-white text-text-secondary dark:border-white/10 dark:bg-deep-sea', children: _jsx(ChevronDown, { size: 15, "aria-hidden": 'true' }) })] }) })] }));
|
|
16
18
|
}
|
package/dist/components/sheet.js
CHANGED
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
import { DialogCloseButton } from './dialog-close-button.js';
|
|
6
6
|
import { cn } from '../utils/cn.js';
|
|
7
|
-
import { useModalLayer, usePresence } from '../utils/hooks.js';
|
|
7
|
+
import { ModalLayerScope, useModalLayer, usePresence } from '../utils/hooks.js';
|
|
8
8
|
const sideStyles = {
|
|
9
9
|
right: {
|
|
10
10
|
panel: 'inset-y-0 right-0 h-full w-full max-w-sm',
|
|
@@ -35,5 +35,5 @@ export function Sheet({ children, className, description, isOpen, onClose, scrol
|
|
|
35
35
|
const panelRef = useModalLayer(isOpen, onClose);
|
|
36
36
|
if (typeof document === 'undefined' || !present)
|
|
37
37
|
return null;
|
|
38
|
-
return createPortal(_jsxs("div", { className: 'fixed inset-0 z-50 flex', children: [_jsx("div", { className: cn('absolute inset-0 bg-deep-sea/38 backdrop-blur-[2px] transition-opacity dark:bg-black/65', visible ? 'opacity-100 duration-[var(--motion-overlay)] ease-premium' : 'opacity-0 duration-[180ms] ease-in'), onClick: onClose, "aria-hidden": 'true' }), _jsx("div", { ref: panelRef, role: 'dialog', "aria-modal": 'true', "aria-label": title ? undefined : 'Dialog', "aria-labelledby": title ? titleId : undefined, "aria-describedby": description ? descriptionId : undefined, tabIndex: -1, className: cn('absolute flex flex-col overflow-hidden border border-sand/30 bg-white text-text-primary shadow-[var(--shadow-overlay)] outline-none transition-transform dark:border-white/12 dark:bg-deep-sea dark:text-text-primary', panel, visible ? `${enter} duration-[var(--motion-overlay)] ease-premium` : `${leave} duration-[180ms] ease-in`, (side === 'left' || side === 'right') && 'rounded-none', side === 'top' && 'rounded-b-[var(--radius-dialog)]', side === 'bottom' && 'rounded-t-[var(--radius-dialog)]', className), children: _jsxs("div", { className: 'flex h-full min-h-0 flex-1 flex-col overflow-hidden p-6 md:p-8', children: [title || description ? (_jsxs("div", { className: 'mb-5 flex shrink-0 items-start justify-between gap-4', children: [_jsxs("div", { className: 'min-w-0 flex-1', children: [title ? _jsx("h2", { id: titleId, className: 'text-2xl font-medium text-text-primary dark:text-text-primary', children: title }) : null, description ? _jsx("p", { id: descriptionId, className: 'font-secondary mt-2 text-sm leading-relaxed text-text-secondary dark:text-text-secondary', children: description }) : null] }), _jsx(DialogCloseButton, { onClick: onClose, "aria-label": 'Close' })] })) : (_jsx("div", { className: 'mb-5 flex shrink-0 justify-end', children: _jsx(DialogCloseButton, { onClick: onClose, "aria-label": 'Close' }) })), _jsx("div", { className: cn(scrollContent ? 'min-h-0 flex-1 overflow-y-auto' : 'flex min-h-0 flex-1 flex-col overflow-hidden'), children: children })] }) })] }), document.body);
|
|
38
|
+
return createPortal(_jsx(ModalLayerScope, { layerRef: panelRef, children: _jsxs("div", { "data-bleecker-modal-overlay": true, className: cn('fixed inset-0 z-50 flex', !isOpen && 'pointer-events-none'), "aria-hidden": !isOpen || undefined, children: [_jsx("div", { className: cn('absolute inset-0 bg-deep-sea/38 backdrop-blur-[2px] transition-opacity dark:bg-black/65', visible ? 'opacity-100 duration-[var(--motion-overlay)] ease-premium' : 'opacity-0 duration-[180ms] ease-in'), onClick: onClose, "aria-hidden": 'true' }), _jsx("div", { ref: panelRef, role: 'dialog', "aria-modal": 'true', "aria-label": title ? undefined : 'Dialog', "aria-labelledby": title ? titleId : undefined, "aria-describedby": description ? descriptionId : undefined, tabIndex: -1, className: cn('absolute flex flex-col overflow-hidden border border-sand/30 bg-white text-text-primary shadow-[var(--shadow-overlay)] outline-none transition-transform dark:border-white/12 dark:bg-deep-sea dark:text-text-primary', panel, visible ? `${enter} duration-[var(--motion-overlay)] ease-premium` : `${leave} duration-[180ms] ease-in`, (side === 'left' || side === 'right') && 'rounded-none', side === 'top' && 'rounded-b-[var(--radius-dialog)]', side === 'bottom' && 'rounded-t-[var(--radius-dialog)]', className), children: _jsxs("div", { className: 'flex h-full min-h-0 flex-1 flex-col overflow-hidden p-6 md:p-8', children: [title || description ? (_jsxs("div", { className: 'mb-5 flex shrink-0 items-start justify-between gap-4', children: [_jsxs("div", { className: 'min-w-0 flex-1', children: [title ? _jsx("h2", { id: titleId, className: 'text-2xl font-medium text-text-primary dark:text-text-primary', children: title }) : null, description ? _jsx("p", { id: descriptionId, className: 'font-secondary mt-2 text-sm leading-relaxed text-text-secondary dark:text-text-secondary', children: description }) : null] }), _jsx(DialogCloseButton, { onClick: onClose, "aria-label": 'Close' })] })) : (_jsx("div", { className: 'mb-5 flex shrink-0 justify-end', children: _jsx(DialogCloseButton, { onClick: onClose, "aria-label": 'Close' }) })), _jsx("div", { className: cn(scrollContent ? 'min-h-0 flex-1 overflow-y-auto' : 'flex min-h-0 flex-1 flex-col overflow-hidden'), children: children })] }) })] }) }), document.body);
|
|
39
39
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
3
3
|
import { cn } from '../utils/cn.js';
|
|
4
|
+
import { useModalBranch } from '../utils/hooks.js';
|
|
4
5
|
export function Tooltip({ children, className, content, delayDuration = 400, side = 'top' }) {
|
|
5
|
-
|
|
6
|
+
const branchRef = useModalBranch();
|
|
7
|
+
return (_jsx(TooltipPrimitive.Provider, { delayDuration: delayDuration, skipDelayDuration: 150, children: _jsxs(TooltipPrimitive.Root, { children: [_jsx(TooltipPrimitive.Trigger, { asChild: true, children: children }), _jsx(TooltipPrimitive.Portal, { children: _jsxs(TooltipPrimitive.Content, { ref: branchRef, side: side, sideOffset: 7, collisionPadding: 10, className: cn('z-[180] max-w-56 rounded-md bg-deep-sea px-3 py-2 text-xs leading-relaxed text-white shadow-[var(--shadow-overlay)] data-[state=delayed-open]:animate-in data-[state=closed]:animate-out data-[state=delayed-open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=delayed-open]:zoom-in-[0.98] data-[state=closed]:zoom-out-[0.98] data-[state=delayed-open]:duration-[var(--motion-surface)] data-[state=closed]:duration-[var(--motion-exit)] data-[state=delayed-open]:ease-premium data-[state=closed]:ease-in dark:bg-sand dark:text-text-primary', className), children: [content, _jsx(TooltipPrimitive.Arrow, { className: 'fill-deep-sea dark:fill-sand' })] }) })] }) }));
|
|
6
8
|
}
|