@mistriwork/ui 1.0.0-rc.29 → 1.0.0-rc.31
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/dist/Drawer.d.ts +10 -2
- package/dist/Drawer.js +24 -2
- package/dist/Popover.js +5 -2
- package/dist/Tooltip.js +5 -2
- package/dist/standalone.css +68 -3
- package/package.json +1 -1
package/dist/Drawer.d.ts
CHANGED
|
@@ -9,8 +9,14 @@
|
|
|
9
9
|
* and the panel is at most 420px wide (a left drawer the same), full
|
|
10
10
|
* width on a phone. The sheet is named by its `title` or, where it draws
|
|
11
11
|
* none, by `ariaLabel`; one of the two is required.
|
|
12
|
+
*
|
|
13
|
+
* It wears what a layer wears: a scrim over the whole window, a head with the
|
|
14
|
+
* title and a close control (`closeLabel` says its word), an edge against the
|
|
15
|
+
* page, and the scope of the component that drew it, so a page's own classes
|
|
16
|
+
* apply to the markup it puts in here as they do in the page (Modal.tsx does
|
|
17
|
+
* the same).
|
|
12
18
|
*/
|
|
13
|
-
import type
|
|
19
|
+
import { type ReactNode } from 'react';
|
|
14
20
|
export type DrawerSide = 'left' | 'right';
|
|
15
21
|
interface DrawerBase {
|
|
16
22
|
open: boolean;
|
|
@@ -20,6 +26,8 @@ interface DrawerBase {
|
|
|
20
26
|
className?: string;
|
|
21
27
|
/** A non-cancellable operation is awaiting acknowledgement. */
|
|
22
28
|
closeDisabled?: boolean;
|
|
29
|
+
/** The close control's name, in the caller's language. */
|
|
30
|
+
closeLabel?: string;
|
|
23
31
|
}
|
|
24
32
|
/** A sheet is named by a title it draws or by an `ariaLabel` it does not; one of the two is required, so none is announced unnamed. */
|
|
25
33
|
export type DrawerProps = DrawerBase & ({
|
|
@@ -29,5 +37,5 @@ export type DrawerProps = DrawerBase & ({
|
|
|
29
37
|
title?: undefined;
|
|
30
38
|
ariaLabel: string;
|
|
31
39
|
});
|
|
32
|
-
export declare function Drawer({ open, onOpenChange, side, title, ariaLabel, children, className, closeDisabled }: DrawerProps): import("react").JSX.Element;
|
|
40
|
+
export declare function Drawer({ open, onOpenChange, side, title, ariaLabel, children, className, closeDisabled, closeLabel, }: DrawerProps): import("react").JSX.Element;
|
|
33
41
|
export {};
|
package/dist/Drawer.js
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A drawer: a sheet that slides in from an edge, over Base UI's Drawer,
|
|
4
|
+
* which gives it the scrim, focus held inside, Escape and a click on the
|
|
5
|
+
* scrim to dismiss, focus handed back on close, and the swipe to dismiss
|
|
6
|
+
* on a phone. Controlled with `open`/`onOpenChange`; a closed drawer is
|
|
7
|
+
* dismissed (its exit animation aside, the sheet stays in the tree only
|
|
8
|
+
* while that runs), so nothing inside it is read while it is shut.
|
|
9
|
+
* `side` is the edge it comes from, right by default,
|
|
10
|
+
* and the panel is at most 420px wide (a left drawer the same), full
|
|
11
|
+
* width on a phone. The sheet is named by its `title` or, where it draws
|
|
12
|
+
* none, by `ariaLabel`; one of the two is required.
|
|
13
|
+
*
|
|
14
|
+
* It wears what a layer wears: a scrim over the whole window, a head with the
|
|
15
|
+
* title and a close control (`closeLabel` says its word), an edge against the
|
|
16
|
+
* page, and the scope of the component that drew it, so a page's own classes
|
|
17
|
+
* apply to the markup it puts in here as they do in the page (Modal.tsx does
|
|
18
|
+
* the same).
|
|
19
|
+
*/
|
|
20
|
+
import { useContext } from 'react';
|
|
2
21
|
import { Drawer as BaseDrawer } from '@base-ui/react/drawer';
|
|
3
|
-
|
|
22
|
+
import { ComponentStyleScope } from './internal/ComponentStyleScope.js';
|
|
23
|
+
import { popupContainer } from './internal/popups.js';
|
|
24
|
+
export function Drawer({ open, onOpenChange, side = 'right', title, ariaLabel, children, className, closeDisabled = false, closeLabel = 'Close', }) {
|
|
25
|
+
const componentScope = useContext(ComponentStyleScope);
|
|
4
26
|
return (_jsx(BaseDrawer.Root, { open: open, disablePointerDismissal: closeDisabled, onOpenChange: (next) => {
|
|
5
27
|
/* A non-cancellable operation: a dismissal request (Escape, a
|
|
6
28
|
click outside) is refused here, as Modal's beforeClose refuses
|
|
@@ -8,5 +30,5 @@ export function Drawer({ open, onOpenChange, side = 'right', title, ariaLabel, c
|
|
|
8
30
|
if (!next && closeDisabled)
|
|
9
31
|
return;
|
|
10
32
|
onOpenChange?.(next);
|
|
11
|
-
}, children: _jsxs(BaseDrawer.Portal, { children: [_jsx(BaseDrawer.Backdrop, { className: "ui-drawer-backdrop" }), _jsx(BaseDrawer.Viewport, { className: ['ui-drawer-viewport', `ui-drawer-${side}`, className].filter(Boolean).join(' '), children: _jsxs(BaseDrawer.Popup, { className: "ui-drawer", "aria-label": ariaLabel ?? (typeof title === 'string' ? title : undefined), children: [title !== undefined ? _jsx(BaseDrawer.Title, { className: "ui-drawer-title", children: title }) : null, children] }) })] }) }));
|
|
33
|
+
}, children: _jsxs(BaseDrawer.Portal, { container: popupContainer(), children: [_jsx(BaseDrawer.Backdrop, { className: "ui-drawer-backdrop" }), _jsx(BaseDrawer.Viewport, { className: ['ui-drawer-viewport', `ui-drawer-${side}`, className].filter(Boolean).join(' '), "data-component": componentScope, children: _jsxs(BaseDrawer.Popup, { className: "ui-drawer", "aria-label": ariaLabel ?? (typeof title === 'string' ? title : undefined), children: [_jsxs("div", { className: "ui-drawer-head", children: [title !== undefined ? _jsx(BaseDrawer.Title, { className: "ui-drawer-title", children: title }) : null, _jsx(BaseDrawer.Close, { className: "ui-drawer-close", "aria-label": closeLabel, disabled: closeDisabled, children: _jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M3.5 3.5l9 9M12.5 3.5l-9 9", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) })] }), children] }) })] }) }));
|
|
12
34
|
}
|
package/dist/Popover.js
CHANGED
|
@@ -13,9 +13,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
* dialog, so the density zoom cannot throw it a room away from its trigger
|
|
14
14
|
* and a dialog's focus trap keeps it as its own.
|
|
15
15
|
*/
|
|
16
|
-
import { isValidElement, useRef } from 'react';
|
|
16
|
+
import { isValidElement, useContext, useRef } from 'react';
|
|
17
17
|
import { Popover as BasePopover } from '@base-ui/react/popover';
|
|
18
18
|
import { layoutViewport, zoomAnchor } from './internal/anchor.js';
|
|
19
|
+
import { ComponentStyleScope } from './internal/ComponentStyleScope.js';
|
|
19
20
|
import { popupContainer, useDialogContainer } from './internal/popups.js';
|
|
20
21
|
export function Popover({ trigger, children, open, defaultOpen, onOpenChange, className, ariaLabel }) {
|
|
21
22
|
/* The trigger is rendered as the trigger, not inside one: a button
|
|
@@ -25,5 +26,7 @@ export function Popover({ trigger, children, open, defaultOpen, onOpenChange, cl
|
|
|
25
26
|
const triggerElement = isValidElement(trigger) ? trigger : _jsx("button", { type: "button", children: trigger });
|
|
26
27
|
const anchor = useRef(null);
|
|
27
28
|
const container = useDialogContainer(anchor);
|
|
28
|
-
|
|
29
|
+
/* The layer is drawn outside the page that opened it; the page's scope goes with it (Modal.tsx). */
|
|
30
|
+
const componentScope = useContext(ComponentStyleScope);
|
|
31
|
+
return (_jsxs(BasePopover.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: onOpenChange, children: [_jsx(BasePopover.Trigger, { className: "ui-popover-trigger", render: triggerElement, ref: anchor }), _jsx(BasePopover.Portal, { container: container ?? popupContainer(), children: _jsx(BasePopover.Positioner, { anchor: () => (anchor.current ? zoomAnchor(anchor.current) : null), positionMethod: "fixed", sideOffset: 8, collisionBoundary: layoutViewport(), collisionPadding: 8, children: _jsx(BasePopover.Popup, { "data-component": componentScope, className: ['ui-popover', className].filter(Boolean).join(' '), "aria-label": ariaLabel, children: children }) }) })] }));
|
|
29
32
|
}
|
package/dist/Tooltip.js
CHANGED
|
@@ -19,9 +19,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
19
19
|
* Placed as Popover.tsx places its layer: on the zoom-aware ruler, fixed to
|
|
20
20
|
* the viewport, and inside an enclosing dialog.
|
|
21
21
|
*/
|
|
22
|
-
import { cloneElement, isValidElement, useId, useRef, useState } from 'react';
|
|
22
|
+
import { cloneElement, isValidElement, useContext, useId, useRef, useState } from 'react';
|
|
23
23
|
import { Tooltip as BaseTooltip } from '@base-ui/react/tooltip';
|
|
24
24
|
import { layoutViewport, zoomAnchor } from './internal/anchor.js';
|
|
25
|
+
import { ComponentStyleScope } from './internal/ComponentStyleScope.js';
|
|
25
26
|
import { popupContainer, useDialogContainer } from './internal/popups.js';
|
|
26
27
|
export function Tooltip({ trigger, children, open, defaultOpen, onOpenChange, className }) {
|
|
27
28
|
const tooltipId = useId();
|
|
@@ -37,10 +38,12 @@ export function Tooltip({ trigger, children, open, defaultOpen, onOpenChange, cl
|
|
|
37
38
|
: base;
|
|
38
39
|
const anchor = useRef(null);
|
|
39
40
|
const container = useDialogContainer(anchor);
|
|
41
|
+
/* The layer is drawn outside the page that opened it; the page's scope goes with it (Modal.tsx). */
|
|
42
|
+
const componentScope = useContext(ComponentStyleScope);
|
|
40
43
|
return (_jsxs(BaseTooltip.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: (next, details) => {
|
|
41
44
|
if (open === undefined)
|
|
42
45
|
setUncontrolledOpen(next);
|
|
43
46
|
onOpenChange?.(next);
|
|
44
47
|
void details;
|
|
45
|
-
}, children: [_jsx(BaseTooltip.Trigger, { className: "ui-tooltip-trigger", render: triggerElement, ref: anchor }), _jsx(BaseTooltip.Portal, { container: container ?? popupContainer(), children: _jsx(BaseTooltip.Positioner, { anchor: () => (anchor.current ? zoomAnchor(anchor.current) : null), positionMethod: "fixed", sideOffset: 8, collisionBoundary: layoutViewport(), collisionPadding: 8, children: _jsx(BaseTooltip.Popup, { id: tooltipId, role: "tooltip", className: ['ui-tooltip', className].filter(Boolean).join(' '), children: children }) }) })] }));
|
|
48
|
+
}, children: [_jsx(BaseTooltip.Trigger, { className: "ui-tooltip-trigger", render: triggerElement, ref: anchor }), _jsx(BaseTooltip.Portal, { container: container ?? popupContainer(), children: _jsx(BaseTooltip.Positioner, { anchor: () => (anchor.current ? zoomAnchor(anchor.current) : null), positionMethod: "fixed", sideOffset: 8, collisionBoundary: layoutViewport(), collisionPadding: 8, children: _jsx(BaseTooltip.Popup, { "data-component": componentScope, id: tooltipId, role: "tooltip", className: ['ui-tooltip', className].filter(Boolean).join(' '), children: children }) }) })] }));
|
|
46
49
|
}
|
package/dist/standalone.css
CHANGED
|
@@ -109,14 +109,21 @@
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/* The Drawer primitive (Drawer.tsx): a sheet from an edge, at most
|
|
112
|
-
420px, full width on a phone,
|
|
112
|
+
420px, full width on a phone, over a scrim that covers the window. It
|
|
113
|
+
stands where a Modal does (z-index 400, the scrim beneath the sheet), so
|
|
114
|
+
a page's own stacking cannot reach over it. */
|
|
113
115
|
.ui-drawer-backdrop {
|
|
116
|
+
position: fixed;
|
|
117
|
+
inset: 0;
|
|
118
|
+
z-index: 400;
|
|
114
119
|
background: var(--scrim);
|
|
115
120
|
}
|
|
116
121
|
.ui-drawer-viewport {
|
|
117
122
|
position: fixed;
|
|
118
123
|
inset: 0;
|
|
124
|
+
z-index: 401;
|
|
119
125
|
display: flex;
|
|
126
|
+
pointer-events: none;
|
|
120
127
|
}
|
|
121
128
|
.ui-drawer-right {
|
|
122
129
|
justify-content: flex-end;
|
|
@@ -125,6 +132,7 @@
|
|
|
125
132
|
justify-content: flex-start;
|
|
126
133
|
}
|
|
127
134
|
.ui-drawer {
|
|
135
|
+
box-sizing: border-box;
|
|
128
136
|
width: min(420px, 100vw);
|
|
129
137
|
max-height: 100dvh;
|
|
130
138
|
overflow-y: auto;
|
|
@@ -132,12 +140,52 @@
|
|
|
132
140
|
background: var(--surface);
|
|
133
141
|
color: var(--ink);
|
|
134
142
|
box-shadow: var(--shadow-pop);
|
|
143
|
+
pointer-events: auto;
|
|
135
144
|
}
|
|
136
|
-
.ui-drawer-
|
|
145
|
+
.ui-drawer-right .ui-drawer {
|
|
146
|
+
border-left: 1px solid var(--line);
|
|
147
|
+
}
|
|
148
|
+
.ui-drawer-left .ui-drawer {
|
|
149
|
+
border-right: 1px solid var(--line);
|
|
150
|
+
}
|
|
151
|
+
.ui-drawer-head {
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: flex-start;
|
|
154
|
+
gap: var(--space-3);
|
|
137
155
|
margin: 0 0 var(--space-4);
|
|
156
|
+
}
|
|
157
|
+
.ui-drawer-title {
|
|
158
|
+
flex: 1;
|
|
159
|
+
min-width: 0;
|
|
160
|
+
margin: 0;
|
|
138
161
|
font-size: var(--text-md);
|
|
139
162
|
font-weight: 600;
|
|
140
163
|
}
|
|
164
|
+
.ui-drawer-close {
|
|
165
|
+
display: inline-grid;
|
|
166
|
+
place-items: center;
|
|
167
|
+
flex: none;
|
|
168
|
+
margin-left: auto;
|
|
169
|
+
width: 32px;
|
|
170
|
+
height: 32px;
|
|
171
|
+
margin-block: calc(-1 * var(--space-2h));
|
|
172
|
+
margin-inline-end: calc(-1 * var(--space-2h));
|
|
173
|
+
border: 0;
|
|
174
|
+
border-radius: var(--radius);
|
|
175
|
+
background: transparent;
|
|
176
|
+
color: var(--ink-muted);
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
}
|
|
179
|
+
@media (hover: hover) {
|
|
180
|
+
.ui-drawer-close:hover {
|
|
181
|
+
background: var(--raised);
|
|
182
|
+
color: var(--ink);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
.ui-drawer-close:focus-visible {
|
|
186
|
+
outline: var(--focus-width) solid var(--focus);
|
|
187
|
+
outline-offset: -2px;
|
|
188
|
+
}
|
|
141
189
|
|
|
142
190
|
/* The Popover primitive (Popover.tsx): a layer on the surface, with
|
|
143
191
|
the popup's edge and shadow, never wider than the viewport. */
|
|
@@ -195,13 +243,23 @@
|
|
|
195
243
|
}
|
|
196
244
|
|
|
197
245
|
/* The Pagination primitive (Pagination.tsx): page buttons on one
|
|
198
|
-
row, the current page in the accent's tint, steps disabled at the ends.
|
|
246
|
+
row, the current page in the accent's tint, steps disabled at the ends.
|
|
247
|
+
Where the room is too narrow for the whole run (a card on a phone) the row
|
|
248
|
+
keeps the steps and the current page, rather than wrapping its tail onto a
|
|
249
|
+
second line of its own ("… 9 Next"). */
|
|
199
250
|
.ui-pagination {
|
|
251
|
+
container-type: inline-size;
|
|
200
252
|
display: flex;
|
|
201
253
|
align-items: center;
|
|
202
254
|
gap: var(--space-1h);
|
|
203
255
|
flex-wrap: wrap;
|
|
204
256
|
}
|
|
257
|
+
@container (max-width: 36rem) {
|
|
258
|
+
.ui-pagination > .ui-page:not(.ui-page-step, [aria-current='page']),
|
|
259
|
+
.ui-pagination > .ui-page-gap {
|
|
260
|
+
display: none;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
205
263
|
.ui-page {
|
|
206
264
|
min-width: 36px;
|
|
207
265
|
min-height: 36px;
|
|
@@ -235,6 +293,13 @@
|
|
|
235
293
|
padding: 0 var(--space-1);
|
|
236
294
|
color: var(--ink-subtle);
|
|
237
295
|
}
|
|
296
|
+
/* A finger's 44px at a phone's width. */
|
|
297
|
+
@media (max-width: 760px) {
|
|
298
|
+
.ui-page {
|
|
299
|
+
min-width: 44px;
|
|
300
|
+
min-height: 44px;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
238
303
|
|
|
239
304
|
/* The Carousel primitive (Carousel.tsx): one slide in a viewport, the
|
|
240
305
|
rest off to the side on a track that slides — only under
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistriwork/ui",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.31",
|
|
4
4
|
"description": "The standalone React primitives both shells are drawn with: Modal, DropMenu, Dropdown, Typeahead, Button, Field, Icon and DateField over Base UI, Switch, Tabs, Drawer, Popover, Avatar, Pagination, Carousel, Resizable, ScrollArea and Tooltip, the form controls built on them (text, masked, money and sensitive boxes, listboxes, choices, slider, progress and action bar; Preview), the landing hero's blocks (badge, photo tiles, icon rows; Preview), their tokens and stylesheet, and the zoom-aware ruler their popups are placed by.",
|
|
5
5
|
"homepage": "https://mistriwork.dev",
|
|
6
6
|
"bugs": {
|