@calcifer-design/ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Alert/Alert.js +4 -15
- package/dist/components/Alert/Alert.module.js +1 -2
- package/dist/components/Alert/Alert_module.css +0 -12
- package/dist/components/Avatar/Avatar.js +2 -1
- package/dist/components/Avatar/Avatar.module.js +1 -2
- package/dist/components/Avatar/Avatar_module.css +0 -12
- package/dist/components/DataTable/DataTable.js +7 -2
- package/dist/components/DataTable/DataTable_module.css +0 -16
- package/dist/components/Dialog/Dialog.d.ts +44 -0
- package/dist/components/Dialog/Dialog.js +82 -0
- package/dist/components/Dialog/Dialog.module.js +10 -0
- package/dist/components/Dialog/Dialog_module.css +51 -0
- package/dist/components/LiveRegion/LiveRegion.js +2 -2
- package/dist/components/Menu/Menu.d.ts +35 -0
- package/dist/components/Menu/Menu.js +44 -0
- package/dist/components/Menu/Menu.module.js +6 -0
- package/dist/components/Menu/Menu_module.css +29 -0
- package/dist/components/NavMenu/NavMenu.js +4 -2
- package/dist/components/NavMenu/NavMenu.module.js +0 -2
- package/dist/components/NavMenu/NavMenu_module.css +0 -15
- package/dist/components/Popover/Popover.d.ts +42 -0
- package/dist/components/Popover/Popover.js +61 -0
- package/dist/components/Popover/Popover.module.js +6 -0
- package/dist/components/Popover/Popover_module.css +13 -0
- package/dist/components/Spinner/Spinner.js +2 -1
- package/dist/components/Spinner/Spinner.module.js +1 -2
- package/dist/components/Spinner/Spinner_module.css +0 -12
- package/dist/components/StatusDot/StatusDot.js +6 -1
- package/dist/components/StatusDot/StatusDot_module.css +0 -12
- package/dist/components/ToastRegion/ToastRegion.d.ts +72 -0
- package/dist/components/ToastRegion/ToastRegion.js +85 -0
- package/dist/components/ToastRegion/ToastRegion.module.js +10 -0
- package/dist/components/ToastRegion/ToastRegion_module.css +104 -0
- package/dist/components/Tooltip/Tooltip.d.ts +33 -0
- package/dist/components/Tooltip/Tooltip.js +28 -0
- package/dist/components/Tooltip/TooltipProvider.d.ts +24 -0
- package/dist/components/Tooltip/TooltipProvider.js +11 -0
- package/dist/icons/CloseIcon.d.ts +10 -0
- package/dist/icons/CloseIcon.js +21 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +6 -0
- package/dist/styles/a11y.module.js +5 -0
- package/dist/{components/LiveRegion/LiveRegion_module.css → styles/a11y_module.css} +1 -1
- package/dist/styles/base.css +21 -15
- package/dist/styles/popup.module.js +9 -0
- package/dist/styles/popup_module.css +103 -0
- package/package.json +2 -2
- package/dist/components/LiveRegion/LiveRegion.module.js +0 -5
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.heading-d0Ysc {
|
|
2
|
+
color: var(--color-text);
|
|
3
|
+
font-size: var(--text-sm);
|
|
4
|
+
font-weight: 600;
|
|
5
|
+
line-height: var(--leading-snug);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.description-IgC4A {
|
|
9
|
+
color: var(--color-text-muted);
|
|
10
|
+
font-size: var(--text-sm);
|
|
11
|
+
line-height: var(--leading-prose);
|
|
12
|
+
}
|
|
13
|
+
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import a11y_module from "../../styles/a11y.module.js";
|
|
2
3
|
import Spinner_module from "./Spinner.module.js";
|
|
3
4
|
function Spinner({ size = 'md', label }) {
|
|
4
5
|
const ring = /*#__PURE__*/ jsx("span", {
|
|
@@ -14,7 +15,7 @@ function Spinner({ size = 'md', label }) {
|
|
|
14
15
|
children: [
|
|
15
16
|
ring,
|
|
16
17
|
/*#__PURE__*/ jsx("span", {
|
|
17
|
-
className:
|
|
18
|
+
className: a11y_module.visuallyHidden,
|
|
18
19
|
children: label
|
|
19
20
|
})
|
|
20
21
|
]
|
|
@@ -30,18 +30,6 @@
|
|
|
30
30
|
display: inline-flex;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
.label-RTZW7 {
|
|
34
|
-
clip-path: inset(50%);
|
|
35
|
-
white-space: nowrap;
|
|
36
|
-
border: 0;
|
|
37
|
-
width: 1px;
|
|
38
|
-
height: 1px;
|
|
39
|
-
margin: -1px;
|
|
40
|
-
padding: 0;
|
|
41
|
-
position: absolute;
|
|
42
|
-
overflow: hidden;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
33
|
@keyframes spin-yXQPz {
|
|
46
34
|
to {
|
|
47
35
|
transform: rotate(360deg);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import a11y_module from "../../styles/a11y.module.js";
|
|
2
3
|
import StatusDot_module from "./StatusDot.module.js";
|
|
3
4
|
function StatusDot({ status, label, labelStyle = 'mono', showLabel = true }) {
|
|
5
|
+
const labelClassName = [
|
|
6
|
+
StatusDot_module.label,
|
|
7
|
+
showLabel ? null : a11y_module.visuallyHidden
|
|
8
|
+
].filter(Boolean).join(' ');
|
|
4
9
|
return /*#__PURE__*/ jsxs("span", {
|
|
5
10
|
className: StatusDot_module.root,
|
|
6
11
|
"data-status": status,
|
|
@@ -12,7 +17,7 @@ function StatusDot({ status, label, labelStyle = 'mono', showLabel = true }) {
|
|
|
12
17
|
"aria-hidden": "true"
|
|
13
18
|
}),
|
|
14
19
|
/*#__PURE__*/ jsx("span", {
|
|
15
|
-
className:
|
|
20
|
+
className: labelClassName,
|
|
16
21
|
"data-hidden": showLabel ? void 0 : '',
|
|
17
22
|
children: label
|
|
18
23
|
}),
|
|
@@ -35,18 +35,6 @@
|
|
|
35
35
|
overflow: hidden;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.label-m8svl[data-hidden] {
|
|
39
|
-
clip-path: inset(50%);
|
|
40
|
-
white-space: nowrap;
|
|
41
|
-
border: 0;
|
|
42
|
-
width: 1px;
|
|
43
|
-
height: 1px;
|
|
44
|
-
margin: -1px;
|
|
45
|
-
padding: 0;
|
|
46
|
-
position: absolute;
|
|
47
|
-
overflow: hidden;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
38
|
.root-tgMEi[data-label-style="text"] .label-m8svl {
|
|
51
39
|
font-family: var(--font-sans);
|
|
52
40
|
color: var(--color-text);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ToastManager as BaseToastManager } from '@base-ui/react/toast';
|
|
2
|
+
export type ToastTone = 'info' | 'success' | 'warning' | 'danger';
|
|
3
|
+
export interface ToastAction {
|
|
4
|
+
label: string;
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
}
|
|
7
|
+
export interface ToastOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The manager's data payload, spread into Base UI's `add()`, which expects
|
|
10
|
+
* `title`/`description`; kept as `title` rather than the library's `heading` convention
|
|
11
|
+
* because the cross-repository Bridge contract carries the same `title: string`.
|
|
12
|
+
*/
|
|
13
|
+
title: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
tone?: ToastTone;
|
|
16
|
+
/** Milliseconds before the toast dismisses itself. `0` keeps it until it is closed. */
|
|
17
|
+
timeout?: number;
|
|
18
|
+
/** `high` also mirrors the toast into a hidden `role="alert"` region, so it interrupts. */
|
|
19
|
+
priority?: 'low' | 'high';
|
|
20
|
+
/** Reusing an id updates that toast in place and restarts its dismiss timer. */
|
|
21
|
+
id?: string;
|
|
22
|
+
action?: ToastAction;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The object a host hands to a remote so the remote can raise a toast in the host's single
|
|
26
|
+
* viewport. Deliberately narrower than Base UI's own manager: `title` and `description` are
|
|
27
|
+
* `string`, not `ReactNode`, because an element authored in a remote would render inside the
|
|
28
|
+
* host's React root and under the host's CSS.
|
|
29
|
+
*/
|
|
30
|
+
export interface ToastManager {
|
|
31
|
+
add: (options: ToastOptions) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Closes one toast by id. Omitting `toastId` closes every toast in the store (Base UI's
|
|
34
|
+
* `closeAll` path) — a caller that wants a no-op must pass an id.
|
|
35
|
+
*/
|
|
36
|
+
close: (toastId?: string) => void;
|
|
37
|
+
update: (toastId: string, options: Omit<Partial<ToastOptions>, 'id'>) => void;
|
|
38
|
+
/**
|
|
39
|
+
* The Base UI manager `ToastRegion` subscribes to. Not part of the surface a remote is given —
|
|
40
|
+
* the Bridge contract declares only `add`, `close` and `update`.
|
|
41
|
+
*/
|
|
42
|
+
readonly baseManager: BaseToastManager;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a toast manager outside React. It is a plain object over a listener set: no context,
|
|
46
|
+
* no hooks, no module-identity requirement — which is exactly why it survives the trip across
|
|
47
|
+
* the Bridge into a remote's separate React root, where a provider's context could not.
|
|
48
|
+
*
|
|
49
|
+
* A call made while no `ToastRegion` is mounted is dropped: `add` still returns an id, and the
|
|
50
|
+
* toast is never shown.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createToastManager(): ToastManager;
|
|
53
|
+
export interface ToastRegionProps {
|
|
54
|
+
/** The manager this region renders. One region per manager, and one manager per page. */
|
|
55
|
+
manager: ToastManager;
|
|
56
|
+
/** The landmark's accessible name. */
|
|
57
|
+
label?: string;
|
|
58
|
+
/** How many toasts are on screen at once; the rest wait, marked `data-limited`. */
|
|
59
|
+
limit?: number;
|
|
60
|
+
/** Default milliseconds before a toast dismisses itself. `0` keeps every toast until closed. */
|
|
61
|
+
timeout?: number;
|
|
62
|
+
/** The accessible name of each toast's close control. */
|
|
63
|
+
closeLabel?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The whole toast apparatus as one component: provider, portal and viewport together, so no
|
|
67
|
+
* consumer can mount a second viewport by accident. That matters because it is the viewport —
|
|
68
|
+
* not the provider — that renders the `role="region"` landmark, the hidden `role="alert"` mirror
|
|
69
|
+
* for high-priority toasts, and four window-level listeners. Two of them overlap in the same
|
|
70
|
+
* screen corner, and the last-committed one silently wins.
|
|
71
|
+
*/
|
|
72
|
+
export declare function ToastRegion({ manager, label, limit, timeout, closeLabel, }: ToastRegionProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Toast } from "@base-ui/react/toast";
|
|
3
|
+
import { CloseIcon } from "../../icons/CloseIcon.js";
|
|
4
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
5
|
+
import popup_module from "../../styles/popup.module.js";
|
|
6
|
+
import ToastRegion_module from "./ToastRegion.module.js";
|
|
7
|
+
function toBaseOptions(options) {
|
|
8
|
+
const { tone, action, ...rest } = options;
|
|
9
|
+
return {
|
|
10
|
+
...rest,
|
|
11
|
+
...void 0 === tone ? {} : {
|
|
12
|
+
type: tone
|
|
13
|
+
},
|
|
14
|
+
...void 0 === action ? {} : {
|
|
15
|
+
actionProps: {
|
|
16
|
+
children: action.label,
|
|
17
|
+
onClick: action.onClick
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function createToastManager() {
|
|
23
|
+
const baseManager = Toast.createToastManager();
|
|
24
|
+
return {
|
|
25
|
+
baseManager,
|
|
26
|
+
add: (options)=>baseManager.add(toBaseOptions(options)),
|
|
27
|
+
close: (toastId)=>{
|
|
28
|
+
baseManager.close(toastId);
|
|
29
|
+
},
|
|
30
|
+
update: (toastId, options)=>{
|
|
31
|
+
baseManager.update(toastId, toBaseOptions(options));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function ToastList({ closeLabel }) {
|
|
36
|
+
const { toasts } = Toast.useToastManager();
|
|
37
|
+
return toasts.map((toastObject)=>/*#__PURE__*/ jsxs(Toast.Root, {
|
|
38
|
+
toast: toastObject,
|
|
39
|
+
className: ToastRegion_module.toast,
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ jsxs(Toast.Content, {
|
|
42
|
+
className: ToastRegion_module.content,
|
|
43
|
+
children: [
|
|
44
|
+
/*#__PURE__*/ jsx(Toast.Title, {
|
|
45
|
+
className: ToastRegion_module.heading
|
|
46
|
+
}),
|
|
47
|
+
/*#__PURE__*/ jsx(Toast.Description, {
|
|
48
|
+
className: ToastRegion_module.description
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ jsx(Toast.Action, {
|
|
53
|
+
className: ToastRegion_module.action
|
|
54
|
+
}),
|
|
55
|
+
/*#__PURE__*/ jsx(Toast.Close, {
|
|
56
|
+
render: /*#__PURE__*/ jsx(IconButton, {
|
|
57
|
+
label: closeLabel,
|
|
58
|
+
variant: "ghost",
|
|
59
|
+
size: "sm",
|
|
60
|
+
children: /*#__PURE__*/ jsx(CloseIcon, {})
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
}, toastObject.id));
|
|
65
|
+
}
|
|
66
|
+
function ToastRegion({ manager, label = 'Notifications', limit = 3, timeout = 5000, closeLabel = 'Close' }) {
|
|
67
|
+
return /*#__PURE__*/ jsx(Toast.Provider, {
|
|
68
|
+
toastManager: manager.baseManager,
|
|
69
|
+
limit: limit,
|
|
70
|
+
timeout: timeout,
|
|
71
|
+
children: /*#__PURE__*/ jsx(Toast.Portal, {
|
|
72
|
+
children: /*#__PURE__*/ jsx(Toast.Viewport, {
|
|
73
|
+
className: [
|
|
74
|
+
popup_module.toastLayer,
|
|
75
|
+
ToastRegion_module.viewport
|
|
76
|
+
].join(' '),
|
|
77
|
+
"aria-label": label,
|
|
78
|
+
children: /*#__PURE__*/ jsx(ToastList, {
|
|
79
|
+
closeLabel: closeLabel
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
export { ToastRegion, createToastManager };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./ToastRegion_module.css";
|
|
2
|
+
const ToastRegion_module = {
|
|
3
|
+
viewport: "viewport-v4Y5F",
|
|
4
|
+
toast: "toast-G4ytY",
|
|
5
|
+
content: "content-tQIoA",
|
|
6
|
+
heading: "heading-BAZ9J",
|
|
7
|
+
description: "description-a9oJ4",
|
|
8
|
+
action: "action-NmziC"
|
|
9
|
+
};
|
|
10
|
+
export default ToastRegion_module;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
.viewport-v4Y5F {
|
|
2
|
+
right: var(--space-5);
|
|
3
|
+
bottom: var(--space-5);
|
|
4
|
+
width: min(22rem, calc(100vw - var(--space-6)));
|
|
5
|
+
position: fixed;
|
|
6
|
+
left: auto;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.toast-G4ytY {
|
|
10
|
+
align-items: flex-start;
|
|
11
|
+
gap: var(--space-3);
|
|
12
|
+
width: 100%;
|
|
13
|
+
padding: var(--space-3) var(--space-4);
|
|
14
|
+
border: 1px solid var(--color-border);
|
|
15
|
+
border-inline-start: var(--border-width-strong) solid var(--color-neutral);
|
|
16
|
+
border-radius: var(--radius-lg);
|
|
17
|
+
background: var(--color-surface-raised);
|
|
18
|
+
color: var(--color-text);
|
|
19
|
+
box-shadow: var(--elevation-2);
|
|
20
|
+
transition-property: transform, opacity;
|
|
21
|
+
transition-duration: var(--motion-duration-3);
|
|
22
|
+
transition-timing-function: var(--motion-ease);
|
|
23
|
+
transform: translateY(calc(var(--toast-index) * -.5rem))
|
|
24
|
+
scale(calc(1 - var(--toast-index) * .04));
|
|
25
|
+
z-index: calc(100 - var(--toast-index));
|
|
26
|
+
display: flex;
|
|
27
|
+
position: absolute;
|
|
28
|
+
bottom: 0;
|
|
29
|
+
left: auto;
|
|
30
|
+
right: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.toast-G4ytY[data-expanded] {
|
|
34
|
+
transform: translateY(calc((var(--toast-offset-y) + var(--toast-index) * var(--space-2)) * -1));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.toast-G4ytY[data-limited] {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.toast-G4ytY[data-starting-style] {
|
|
42
|
+
opacity: 0;
|
|
43
|
+
transform: translateY(100%);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.toast-G4ytY[data-ending-style] {
|
|
47
|
+
opacity: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.toast-G4ytY[data-type="info"] {
|
|
51
|
+
border-inline-start-color: var(--color-accent);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.toast-G4ytY[data-type="success"] {
|
|
55
|
+
border-inline-start-color: var(--color-success);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.toast-G4ytY[data-type="warning"] {
|
|
59
|
+
border-inline-start-color: var(--color-warning);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.toast-G4ytY[data-type="danger"] {
|
|
63
|
+
border-inline-start-color: var(--color-danger);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.content-tQIoA {
|
|
67
|
+
gap: var(--space-1);
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
flex: auto;
|
|
70
|
+
min-width: 0;
|
|
71
|
+
display: flex;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.heading-BAZ9J {
|
|
75
|
+
color: var(--color-text);
|
|
76
|
+
font-size: var(--text-sm);
|
|
77
|
+
font-weight: 600;
|
|
78
|
+
line-height: var(--leading-snug);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.description-a9oJ4 {
|
|
82
|
+
color: var(--color-text-muted);
|
|
83
|
+
font-size: var(--text-sm);
|
|
84
|
+
line-height: var(--leading-prose);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.action-NmziC {
|
|
88
|
+
padding: var(--space-1) var(--space-3);
|
|
89
|
+
border: 1px solid var(--color-border-strong);
|
|
90
|
+
border-radius: var(--radius-md);
|
|
91
|
+
color: var(--color-text);
|
|
92
|
+
font-size: var(--text-sm);
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
background: none;
|
|
95
|
+
flex: none;
|
|
96
|
+
align-self: center;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@media (hover: hover) {
|
|
100
|
+
.action-NmziC:hover {
|
|
101
|
+
background: var(--color-surface-2);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { PopupAlign, PopupSide } from '../Popover/Popover.js';
|
|
3
|
+
export interface TooltipProps {
|
|
4
|
+
/**
|
|
5
|
+
* The control the tip describes, rendered as the trigger itself: it must be a single element
|
|
6
|
+
* that produces a native `<button>`.
|
|
7
|
+
*/
|
|
8
|
+
trigger: ReactElement;
|
|
9
|
+
/**
|
|
10
|
+
* The tip's text, applied to the trigger as `aria-label`. Base UI merges the render element's
|
|
11
|
+
* own props last, so this becomes the trigger's accessible name only when the trigger carries
|
|
12
|
+
* no `aria-label` of its own — a trigger that already has one (as `IconButton` always does,
|
|
13
|
+
* from its required `label`) keeps its own, and the two must then be kept identical by hand;
|
|
14
|
+
* nothing here enforces that.
|
|
15
|
+
*
|
|
16
|
+
* Base UI's tooltip puts nothing in the accessibility tree: the popup carries no
|
|
17
|
+
* `role="tooltip"`, the trigger gets no `aria-describedby`, and it is disabled on touch
|
|
18
|
+
* devices. This is therefore a label for a control that has no visible text, not a place for
|
|
19
|
+
* prose — for a sentence of help use `Popover`, and for feedback about something that just
|
|
20
|
+
* happened use a toast.
|
|
21
|
+
*/
|
|
22
|
+
label: string;
|
|
23
|
+
side?: PopupSide;
|
|
24
|
+
align?: PopupAlign;
|
|
25
|
+
/** Gap between the trigger and the popup, in pixels. */
|
|
26
|
+
sideOffset?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Hover delay in milliseconds for this trigger alone. Leave it out and the tooltip takes the
|
|
29
|
+
* delay from the nearest `TooltipProvider`, falling back to Base UI's own 600ms.
|
|
30
|
+
*/
|
|
31
|
+
delay?: number;
|
|
32
|
+
}
|
|
33
|
+
export declare function Tooltip({ trigger, label, side, align, sideOffset, delay, }: TooltipProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip } from "@base-ui/react/tooltip";
|
|
3
|
+
import popup_module from "../../styles/popup.module.js";
|
|
4
|
+
function Tooltip_Tooltip({ trigger, label, side = 'top', align = 'center', sideOffset = 8, delay }) {
|
|
5
|
+
return /*#__PURE__*/ jsxs(Tooltip.Root, {
|
|
6
|
+
children: [
|
|
7
|
+
/*#__PURE__*/ jsx(Tooltip.Trigger, {
|
|
8
|
+
render: trigger,
|
|
9
|
+
"aria-label": label,
|
|
10
|
+
delay: delay
|
|
11
|
+
}),
|
|
12
|
+
/*#__PURE__*/ jsx(Tooltip.Portal, {
|
|
13
|
+
children: /*#__PURE__*/ jsx(Tooltip.Positioner, {
|
|
14
|
+
className: popup_module.layer,
|
|
15
|
+
side: side,
|
|
16
|
+
align: align,
|
|
17
|
+
sideOffset: sideOffset,
|
|
18
|
+
children: /*#__PURE__*/ jsx(Tooltip.Popup, {
|
|
19
|
+
className: popup_module.surface,
|
|
20
|
+
"data-popup": "tooltip",
|
|
21
|
+
children: label
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export { Tooltip_Tooltip as Tooltip };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Base UI's own default hover delay, in milliseconds, re-exported as a constant so the shell and
|
|
4
|
+
* every remote use one value across the federation seam. A remote that mounts its own provider
|
|
5
|
+
* with this number produces the same feel as the host's, which is the whole point: the seam
|
|
6
|
+
* should be invisible to someone moving the pointer across it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TOOLTIP_DELAY = 600;
|
|
9
|
+
export interface TooltipProviderProps {
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
/** Hover delay in milliseconds shared by every tooltip below this provider. */
|
|
12
|
+
delay?: number;
|
|
13
|
+
/** How long a tooltip waits before closing, in milliseconds. */
|
|
14
|
+
closeDelay?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Groups the tooltips below it, so that once one has opened its neighbours open instantly.
|
|
18
|
+
*
|
|
19
|
+
* It renders no DOM, mounts no portal and attaches no window listeners — two React contexts and
|
|
20
|
+
* a timer — which is why every federated remote mounts its own instead of trying to reach the
|
|
21
|
+
* host's through context, which cannot cross a React root boundary. It is also optional: without
|
|
22
|
+
* one, each trigger falls back to this same delay on its own.
|
|
23
|
+
*/
|
|
24
|
+
export declare function TooltipProvider({ children, delay, closeDelay, }: TooltipProviderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip } from "@base-ui/react/tooltip";
|
|
3
|
+
const TOOLTIP_DELAY = 600;
|
|
4
|
+
function TooltipProvider({ children, delay = TOOLTIP_DELAY, closeDelay }) {
|
|
5
|
+
return /*#__PURE__*/ jsx(Tooltip.Provider, {
|
|
6
|
+
delay: delay,
|
|
7
|
+
closeDelay: closeDelay,
|
|
8
|
+
children: children
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export { TOOLTIP_DELAY, TooltipProvider };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The library's one close glyph. `Alert`'s dismiss control, `Dialog`'s header control and each
|
|
3
|
+
* toast's close control all draw it; each authored its own copy before this module existed.
|
|
4
|
+
*
|
|
5
|
+
* Internal on purpose: the barrel does not export it, so it is no part of the published surface
|
|
6
|
+
* and consumers bring their own icon set. It is decorative everywhere it is used — the button
|
|
7
|
+
* around it carries the accessible name — which is why it is `aria-hidden` and not focusable.
|
|
8
|
+
* It declares no size; the control that holds it sizes it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function CloseIcon(): import("react").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
function CloseIcon() {
|
|
3
|
+
return /*#__PURE__*/ jsxs("svg", {
|
|
4
|
+
viewBox: "0 0 16 16",
|
|
5
|
+
fill: "none",
|
|
6
|
+
stroke: "currentColor",
|
|
7
|
+
strokeWidth: "1.5",
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
"aria-hidden": "true",
|
|
10
|
+
focusable: "false",
|
|
11
|
+
children: [
|
|
12
|
+
/*#__PURE__*/ jsx("path", {
|
|
13
|
+
d: "m4.5 4.5 7 7"
|
|
14
|
+
}),
|
|
15
|
+
/*#__PURE__*/ jsx("path", {
|
|
16
|
+
d: "m11.5 4.5-7 7"
|
|
17
|
+
})
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export { CloseIcon };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,3 +33,15 @@ export { Avatar } from './components/Avatar/Avatar.js';
|
|
|
33
33
|
export type { AvatarProps } from './components/Avatar/Avatar.js';
|
|
34
34
|
export { ErrorBoundary } from './components/ErrorBoundary/ErrorBoundary.js';
|
|
35
35
|
export type { ErrorBoundaryProps, ErrorBoundaryFallbackDetails, } from './components/ErrorBoundary/ErrorBoundary.js';
|
|
36
|
+
export { Popover } from './components/Popover/Popover.js';
|
|
37
|
+
export type { PopoverProps, PopupSide, PopupAlign } from './components/Popover/Popover.js';
|
|
38
|
+
export { Dialog } from './components/Dialog/Dialog.js';
|
|
39
|
+
export type { DialogProps, DialogVariant, SheetSide } from './components/Dialog/Dialog.js';
|
|
40
|
+
export { Menu } from './components/Menu/Menu.js';
|
|
41
|
+
export type { MenuProps, MenuItem } from './components/Menu/Menu.js';
|
|
42
|
+
export { Tooltip } from './components/Tooltip/Tooltip.js';
|
|
43
|
+
export type { TooltipProps } from './components/Tooltip/Tooltip.js';
|
|
44
|
+
export { TooltipProvider, TOOLTIP_DELAY } from './components/Tooltip/TooltipProvider.js';
|
|
45
|
+
export type { TooltipProviderProps } from './components/Tooltip/TooltipProvider.js';
|
|
46
|
+
export { ToastRegion, createToastManager } from './components/ToastRegion/ToastRegion.js';
|
|
47
|
+
export type { ToastRegionProps, ToastManager, ToastOptions, ToastTone, ToastAction, } from './components/ToastRegion/ToastRegion.js';
|
package/dist/index.js
CHANGED
|
@@ -16,3 +16,9 @@ export { IconButton } from "./components/IconButton/IconButton.js";
|
|
|
16
16
|
export { Alert } from "./components/Alert/Alert.js";
|
|
17
17
|
export { Avatar } from "./components/Avatar/Avatar.js";
|
|
18
18
|
export { ErrorBoundary } from "./components/ErrorBoundary/ErrorBoundary.js";
|
|
19
|
+
export { Popover } from "./components/Popover/Popover.js";
|
|
20
|
+
export { Dialog } from "./components/Dialog/Dialog.js";
|
|
21
|
+
export { Menu } from "./components/Menu/Menu.js";
|
|
22
|
+
export { Tooltip } from "./components/Tooltip/Tooltip.js";
|
|
23
|
+
export { TOOLTIP_DELAY, TooltipProvider } from "./components/Tooltip/TooltipProvider.js";
|
|
24
|
+
export { ToastRegion, createToastManager } from "./components/ToastRegion/ToastRegion.js";
|
package/dist/styles/base.css
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/* Base styles shared by every app and by Storybook. Tokens come from @calcifer-design/tokens/tokens.css. */
|
|
2
|
+
*,
|
|
3
|
+
*::before,
|
|
4
|
+
*::after {
|
|
2
5
|
box-sizing: border-box;
|
|
3
6
|
}
|
|
4
7
|
|
|
@@ -13,16 +16,20 @@ html {
|
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
body {
|
|
16
|
-
min-height: 100dvh;
|
|
17
19
|
margin: 0;
|
|
20
|
+
min-height: 100dvh;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
img,
|
|
23
|
+
img,
|
|
24
|
+
video {
|
|
21
25
|
max-width: 100%;
|
|
22
26
|
height: auto;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
button,
|
|
29
|
+
button,
|
|
30
|
+
input,
|
|
31
|
+
select,
|
|
32
|
+
textarea {
|
|
26
33
|
font: inherit;
|
|
27
34
|
color: inherit;
|
|
28
35
|
}
|
|
@@ -32,31 +39,30 @@ button, input, select, textarea {
|
|
|
32
39
|
outline-offset: var(--focus-ring-offset);
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
h1,
|
|
42
|
+
h1,
|
|
43
|
+
h2,
|
|
44
|
+
h3 {
|
|
36
45
|
line-height: var(--leading-tight);
|
|
37
46
|
letter-spacing: var(--tracking-heading);
|
|
38
47
|
margin: 0;
|
|
39
48
|
}
|
|
40
49
|
|
|
41
50
|
p {
|
|
42
|
-
max-width: var(--measure);
|
|
43
51
|
margin: 0;
|
|
52
|
+
max-width: var(--measure);
|
|
44
53
|
}
|
|
45
54
|
|
|
46
|
-
code,
|
|
55
|
+
code,
|
|
56
|
+
pre {
|
|
47
57
|
font-family: var(--font-mono);
|
|
48
58
|
}
|
|
49
59
|
|
|
50
60
|
@media (prefers-reduced-motion: reduce) {
|
|
51
|
-
*,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
animation-duration: .01ms !important;
|
|
61
|
+
*,
|
|
62
|
+
*::before,
|
|
63
|
+
*::after {
|
|
64
|
+
animation-duration: 0.01ms !important;
|
|
55
65
|
animation-iteration-count: 1 !important;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
on-iteration-count: 1 !important;
|
|
60
66
|
transition-duration: 0.01ms !important;
|
|
61
67
|
scroll-behavior: auto !important;
|
|
62
68
|
}
|