@c9up/nebula 0.1.9 → 0.2.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/atoms/Avatar.d.ts +36 -9
- package/dist/atoms/Avatar.js +66 -27
- package/dist/atoms/index.d.ts +1 -1
- package/dist/atoms/index.js +1 -1
- package/dist/lib/children.d.ts +30 -0
- package/dist/lib/motion.d.ts +10 -0
- package/dist/lib/motion.js +10 -0
- package/dist/molecules/Accordion.d.ts +36 -15
- package/dist/molecules/Accordion.js +68 -45
- package/dist/molecules/Breadcrumb.d.ts +29 -11
- package/dist/molecules/Breadcrumb.js +52 -52
- package/dist/molecules/Collapsible.d.ts +18 -17
- package/dist/molecules/Collapsible.js +42 -34
- package/dist/molecules/Field.d.ts +66 -30
- package/dist/molecules/Field.js +106 -55
- package/dist/molecules/InputGroup.d.ts +39 -21
- package/dist/molecules/InputGroup.js +43 -27
- package/dist/molecules/InputOTP.d.ts +26 -3
- package/dist/molecules/InputOTP.js +109 -76
- package/dist/molecules/Message.js +5 -4
- package/dist/molecules/Pagination.d.ts +36 -11
- package/dist/molecules/Pagination.js +58 -74
- package/dist/molecules/RadioGroup.d.ts +25 -17
- package/dist/molecules/RadioGroup.js +47 -43
- package/dist/molecules/Resizable.d.ts +32 -7
- package/dist/molecules/Resizable.js +76 -49
- package/dist/molecules/Tabs.d.ts +49 -11
- package/dist/molecules/Tabs.js +107 -51
- package/dist/molecules/ToggleGroup.d.ts +16 -10
- package/dist/molecules/ToggleGroup.js +37 -21
- package/dist/molecules/index.d.ts +11 -11
- package/dist/molecules/index.js +11 -11
- package/dist/organisms/AlertDialog.d.ts +80 -28
- package/dist/organisms/AlertDialog.js +192 -67
- package/dist/organisms/Carousel.d.ts +25 -3
- package/dist/organisms/Carousel.js +75 -43
- package/dist/organisms/Combobox.d.ts +2 -1
- package/dist/organisms/Combobox.js +46 -16
- package/dist/organisms/Command.d.ts +73 -32
- package/dist/organisms/Command.js +209 -131
- package/dist/organisms/CommandDialog.js +5 -5
- package/dist/organisms/ContextMenu.d.ts +41 -19
- package/dist/organisms/ContextMenu.js +112 -71
- package/dist/organisms/DataTable.js +42 -8
- package/dist/organisms/Dialog.d.ts +97 -31
- package/dist/organisms/Dialog.js +193 -68
- package/dist/organisms/Drawer.d.ts +33 -10
- package/dist/organisms/Drawer.js +130 -52
- package/dist/organisms/DropdownMenu.d.ts +58 -11
- package/dist/organisms/DropdownMenu.js +137 -50
- package/dist/organisms/Form.js +9 -11
- package/dist/organisms/HoverCard.d.ts +39 -19
- package/dist/organisms/HoverCard.js +116 -40
- package/dist/organisms/Menubar.d.ts +55 -19
- package/dist/organisms/Menubar.js +166 -82
- package/dist/organisms/NavigationMenu.d.ts +77 -31
- package/dist/organisms/NavigationMenu.js +169 -98
- package/dist/organisms/Popover.d.ts +72 -12
- package/dist/organisms/Popover.js +132 -25
- package/dist/organisms/Questionnaire.js +5 -5
- package/dist/organisms/Select.d.ts +99 -18
- package/dist/organisms/Select.js +253 -111
- package/dist/organisms/Sheet.d.ts +57 -13
- package/dist/organisms/Sheet.js +141 -54
- package/dist/organisms/Sidebar.d.ts +146 -56
- package/dist/organisms/Sidebar.js +236 -128
- package/dist/organisms/Tooltip.d.ts +88 -14
- package/dist/organisms/Tooltip.js +210 -47
- package/dist/organisms/index.d.ts +15 -15
- package/dist/organisms/index.js +15 -15
- package/dist/primitives/floating.js +25 -0
- package/dist/primitives/floatingSurface.d.ts +11 -0
- package/dist/primitives/floatingSurface.js +8 -0
- package/dist/primitives/menu.d.ts +45 -1
- package/dist/primitives/menu.js +45 -14
- package/dist/primitives/menuParts.d.ts +113 -0
- package/dist/primitives/menuParts.js +207 -0
- package/nebula.css +1 -1
- package/package.json +3 -3
- package/registry.json +18 -6
- package/src/atoms/Avatar.ts +141 -37
- package/src/atoms/index.ts +13 -1
- package/src/lib/children.ts +31 -0
- package/src/lib/motion.ts +12 -0
- package/src/molecules/Accordion.ts +120 -60
- package/src/molecules/Breadcrumb.ts +77 -76
- package/src/molecules/Collapsible.ts +77 -41
- package/src/molecules/Field.ts +187 -72
- package/src/molecules/InputGroup.ts +88 -35
- package/src/molecules/InputOTP.ts +150 -86
- package/src/molecules/Message.ts +6 -4
- package/src/molecules/Pagination.ts +96 -101
- package/src/molecules/RadioGroup.ts +70 -59
- package/src/molecules/Resizable.ts +138 -75
- package/src/molecules/Tabs.ts +187 -74
- package/src/molecules/ToggleGroup.ts +77 -38
- package/src/molecules/index.ts +85 -8
- package/src/organisms/AlertDialog.ts +319 -82
- package/src/organisms/Carousel.ts +129 -52
- package/src/organisms/Combobox.ts +64 -19
- package/src/organisms/Command.ts +342 -159
- package/src/organisms/CommandDialog.ts +6 -6
- package/src/organisms/ContextMenu.ts +185 -83
- package/src/organisms/DataTable.ts +56 -10
- package/src/organisms/Dialog.ts +312 -102
- package/src/organisms/Drawer.ts +219 -71
- package/src/organisms/DropdownMenu.ts +219 -61
- package/src/organisms/Form.ts +48 -34
- package/src/organisms/HoverCard.ts +187 -53
- package/src/organisms/Menubar.ts +247 -87
- package/src/organisms/NavigationMenu.ts +306 -128
- package/src/organisms/Popover.ts +215 -39
- package/src/organisms/Questionnaire.ts +9 -6
- package/src/organisms/Select.ts +397 -130
- package/src/organisms/Sheet.ts +252 -83
- package/src/organisms/Sidebar.ts +438 -185
- package/src/organisms/Tooltip.ts +315 -65
- package/src/organisms/index.ts +284 -14
- package/src/primitives/floating.ts +33 -0
- package/src/primitives/floatingSurface.ts +19 -0
- package/src/primitives/menu.ts +79 -18
- package/src/primitives/menuParts.ts +371 -0
|
@@ -1,102 +1,143 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ContextMenu —
|
|
2
|
+
* ContextMenu — the menu a right-click opens.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* ContextMenu({ children: () => html`
|
|
5
|
+
* ${ContextMenuTrigger({ children: "Right-click me" })}
|
|
6
|
+
* ${ContextMenuContent({ children: () => html`
|
|
7
|
+
* ${ContextMenuItem({ children: "Cut", onSelect: cut })}
|
|
8
|
+
* ` })}
|
|
9
|
+
* ` })
|
|
7
10
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* off screen.
|
|
11
|
+
* The rows come from `createMenuParts`, so a context menu and a dropdown menu
|
|
12
|
+
* cannot drift apart. What is specific here is the anchor: a context menu
|
|
13
|
+
* opens at the POINTER, not against a control, so a zero-size element is moved
|
|
14
|
+
* to the click coordinates and the surface is positioned against that.
|
|
13
15
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* Touch gets a long press, because there is no right button. It is cancelled
|
|
17
|
+
* by movement, so a scroll that starts on the region does not open a menu
|
|
18
|
+
* under the thumb.
|
|
17
19
|
*/
|
|
18
|
-
import { component, html, onUnmount, signal } from "@c9up/aurora";
|
|
20
|
+
import { component, createContext, html, inject, onUnmount, provide, signal, } from "@c9up/aurora";
|
|
19
21
|
import { slot } from "../lib/children.js";
|
|
20
22
|
import { cn } from "../lib/cn.js";
|
|
21
23
|
import { uid } from "../lib/id.js";
|
|
24
|
+
import { slideInFromSide, zoomInOut } from "../lib/motion.js";
|
|
22
25
|
import { read } from "../lib/props.js";
|
|
23
26
|
import { floatingSurface } from "../primitives/floatingSurface.js";
|
|
24
|
-
import {
|
|
27
|
+
import { menuPanelClasses, wireMenu } from "../primitives/menu.js";
|
|
28
|
+
import { createMenuParts } from "../primitives/menuParts.js";
|
|
25
29
|
const LONG_PRESS_MS = 500;
|
|
30
|
+
const ContextMenuContext = createContext("ContextMenu");
|
|
26
31
|
export const ContextMenu = component((props) => {
|
|
27
|
-
const regionId = uid("context-menu-region");
|
|
28
32
|
const anchorId = uid("context-menu-anchor");
|
|
29
33
|
const contentId = uid("context-menu-content");
|
|
30
34
|
const open = signal(false);
|
|
35
|
+
let content;
|
|
31
36
|
let unwire = null;
|
|
32
37
|
let pressTimer;
|
|
33
38
|
function setOpen(next) {
|
|
34
39
|
open(next);
|
|
35
40
|
props.onOpenChange?.(next);
|
|
36
41
|
}
|
|
37
|
-
function
|
|
38
|
-
const anchor = document.getElementById(anchorId);
|
|
39
|
-
if (anchor === null)
|
|
40
|
-
return;
|
|
41
|
-
anchor.style.left = `${x}px`;
|
|
42
|
-
anchor.style.top = `${y}px`;
|
|
43
|
-
}
|
|
44
|
-
function openAt(x, y) {
|
|
45
|
-
moveAnchorTo(x, y);
|
|
46
|
-
setOpen(true);
|
|
47
|
-
}
|
|
48
|
-
function onContextMenu(event) {
|
|
49
|
-
event.preventDefault();
|
|
50
|
-
openAt(event.clientX, event.clientY);
|
|
51
|
-
}
|
|
52
|
-
function onPointerDown(event) {
|
|
53
|
-
if (event.pointerType !== "touch")
|
|
54
|
-
return;
|
|
55
|
-
cancelPress();
|
|
56
|
-
pressTimer = setTimeout(() => openAt(event.clientX, event.clientY), LONG_PRESS_MS);
|
|
57
|
-
}
|
|
58
|
-
function cancelPress() {
|
|
42
|
+
function cancelLongPress() {
|
|
59
43
|
if (pressTimer !== undefined)
|
|
60
44
|
clearTimeout(pressTimer);
|
|
61
45
|
pressTimer = undefined;
|
|
62
46
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
47
|
+
function openAt(x, y) {
|
|
48
|
+
const anchor = document.getElementById(anchorId);
|
|
49
|
+
if (anchor !== null) {
|
|
50
|
+
anchor.style.left = `${x}px`;
|
|
51
|
+
anchor.style.top = `${y}px`;
|
|
52
|
+
}
|
|
53
|
+
setOpen(true);
|
|
54
|
+
}
|
|
55
|
+
onUnmount(cancelLongPress);
|
|
56
|
+
provide(ContextMenuContext, {
|
|
57
|
+
anchorId,
|
|
66
58
|
open: () => open(),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
onCloseAll: () => setOpen(false),
|
|
74
|
-
class: read(props.contentClass),
|
|
75
|
-
}),
|
|
76
|
-
onOpened: (panel) => {
|
|
77
|
-
unwire = wireMenu(panel, { onCloseAll: () => setOpen(false) });
|
|
78
|
-
panel.focus({ preventScroll: true });
|
|
59
|
+
openAt,
|
|
60
|
+
startLongPress(event) {
|
|
61
|
+
if (event.pointerType !== "touch")
|
|
62
|
+
return;
|
|
63
|
+
cancelLongPress();
|
|
64
|
+
pressTimer = setTimeout(() => openAt(event.clientX, event.clientY), LONG_PRESS_MS);
|
|
79
65
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
66
|
+
cancelLongPress,
|
|
67
|
+
closeAll: () => setOpen(false),
|
|
68
|
+
register(registered) {
|
|
69
|
+
content = registered;
|
|
83
70
|
},
|
|
84
71
|
});
|
|
72
|
+
const parts = props.children?.();
|
|
73
|
+
if (content !== undefined) {
|
|
74
|
+
const registered = content;
|
|
75
|
+
floatingSurface({
|
|
76
|
+
anchor: () => document.getElementById(anchorId),
|
|
77
|
+
open: () => open(),
|
|
78
|
+
onClose: () => setOpen(false),
|
|
79
|
+
placement: "bottom-start",
|
|
80
|
+
offset: 2,
|
|
81
|
+
content: () => renderPanel(registered, contentId),
|
|
82
|
+
onOpened: (panel) => {
|
|
83
|
+
unwire = wireMenu(panel, { onCloseAll: () => setOpen(false) });
|
|
84
|
+
panel.focus({ preventScroll: true });
|
|
85
|
+
},
|
|
86
|
+
onClosed: () => {
|
|
87
|
+
unwire?.();
|
|
88
|
+
unwire = null;
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return html `${parts}`;
|
|
93
|
+
});
|
|
94
|
+
/** The region that answers to right-click, and the anchor the menu opens at. */
|
|
95
|
+
export const ContextMenuTrigger = component((props) => {
|
|
96
|
+
const menu = inject(ContextMenuContext);
|
|
97
|
+
function onContextMenu(event) {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
menu.openAt(event.clientX, event.clientY);
|
|
100
|
+
}
|
|
85
101
|
return html `<div
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
class="pointer-events-none fixed size-0"
|
|
100
|
-
></span>
|
|
101
|
-
</div>`;
|
|
102
|
+
data-slot="context-menu-trigger"
|
|
103
|
+
data-state="${() => (menu.open() ? "open" : "closed")}"
|
|
104
|
+
class="${() => cn(read(props.class))}"
|
|
105
|
+
@contextmenu="${onContextMenu}"
|
|
106
|
+
@pointerdown="${(event) => menu.startLongPress(event)}"
|
|
107
|
+
@pointerup="${() => menu.cancelLongPress()}"
|
|
108
|
+
@pointermove="${() => menu.cancelLongPress()}"
|
|
109
|
+
@pointercancel="${() => menu.cancelLongPress()}"
|
|
110
|
+
>${slot(props.children)}<span
|
|
111
|
+
id="${menu.anchorId}"
|
|
112
|
+
aria-hidden="true"
|
|
113
|
+
class="pointer-events-none fixed size-0"
|
|
114
|
+
></span></div>`;
|
|
102
115
|
});
|
|
116
|
+
export const ContextMenuContent = component((props) => {
|
|
117
|
+
const menu = inject(ContextMenuContext);
|
|
118
|
+
menu.register({ body: props.children?.(), class: props.class });
|
|
119
|
+
return html ``;
|
|
120
|
+
});
|
|
121
|
+
const parts = createMenuParts("context-menu", ContextMenuContext);
|
|
122
|
+
export const ContextMenuGroup = parts.Group;
|
|
123
|
+
export const ContextMenuItem = parts.Item;
|
|
124
|
+
export const ContextMenuCheckboxItem = parts.CheckboxItem;
|
|
125
|
+
export const ContextMenuRadioGroup = parts.RadioGroup;
|
|
126
|
+
export const ContextMenuRadioItem = parts.RadioItem;
|
|
127
|
+
export const ContextMenuLabel = parts.Label;
|
|
128
|
+
export const ContextMenuSeparator = parts.Separator;
|
|
129
|
+
export const ContextMenuShortcut = parts.Shortcut;
|
|
130
|
+
export const ContextMenuSub = parts.Sub;
|
|
131
|
+
export const ContextMenuSubTrigger = parts.SubTrigger;
|
|
132
|
+
export const ContextMenuSubContent = parts.SubContent;
|
|
133
|
+
export const ContextMenuPortal = parts.Portal;
|
|
134
|
+
function renderPanel(registered, contentId) {
|
|
135
|
+
return html `<div
|
|
136
|
+
data-slot="context-menu-content"
|
|
137
|
+
id="${contentId}"
|
|
138
|
+
role="menu"
|
|
139
|
+
aria-orientation="vertical"
|
|
140
|
+
tabindex="-1"
|
|
141
|
+
class="${cn(menuPanelClasses, zoomInOut, slideInFromSide, read(registered.class))}"
|
|
142
|
+
>${registered.body}</div>`;
|
|
143
|
+
}
|
|
@@ -24,7 +24,7 @@ import { Checkbox } from "../atoms/Checkbox.js";
|
|
|
24
24
|
import { Input } from "../atoms/Input.js";
|
|
25
25
|
import { cn } from "../lib/cn.js";
|
|
26
26
|
import { ChevronDownIcon, ChevronsUpDownIcon, ChevronUpIcon, } from "../lib/icons.js";
|
|
27
|
-
import { Pagination } from "../molecules/Pagination.js";
|
|
27
|
+
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, pageWindow, } from "../molecules/Pagination.js";
|
|
28
28
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "../molecules/Table.js";
|
|
29
29
|
export function DataTable(props) {
|
|
30
30
|
const sortKey = signal(undefined);
|
|
@@ -205,14 +205,48 @@ export function DataTable(props) {
|
|
|
205
205
|
}),
|
|
206
206
|
],
|
|
207
207
|
})}
|
|
208
|
-
${props.pageSize === undefined
|
|
209
|
-
? null
|
|
210
|
-
: Pagination({
|
|
211
|
-
page: () => Math.min(page(), pageCount()),
|
|
212
|
-
pageCount,
|
|
213
|
-
onPageChange: (next) => page(next),
|
|
214
|
-
})}
|
|
208
|
+
${props.pageSize === undefined ? null : renderPagination()}
|
|
215
209
|
</div>`;
|
|
210
|
+
/**
|
|
211
|
+
* The page links.
|
|
212
|
+
*
|
|
213
|
+
* Composed from `Pagination`'s parts rather than described: `pageWindow`
|
|
214
|
+
* still decides WHICH pages are shown — first, last, a run around the
|
|
215
|
+
* current one and the gaps between — and the parts render that list.
|
|
216
|
+
*/
|
|
217
|
+
function renderPagination() {
|
|
218
|
+
const current = () => Math.min(page(), pageCount());
|
|
219
|
+
const go = (target) => () => {
|
|
220
|
+
page(Math.min(Math.max(target, 1), pageCount()));
|
|
221
|
+
};
|
|
222
|
+
return Pagination({
|
|
223
|
+
children: () => PaginationContent({
|
|
224
|
+
children: [
|
|
225
|
+
PaginationItem({
|
|
226
|
+
children: PaginationPrevious({
|
|
227
|
+
disabled: () => current() <= 1,
|
|
228
|
+
onSelect: go(current() - 1),
|
|
229
|
+
}),
|
|
230
|
+
}),
|
|
231
|
+
...pageWindow(current(), pageCount()).map((entry) => PaginationItem({
|
|
232
|
+
children: entry === null
|
|
233
|
+
? PaginationEllipsis({})
|
|
234
|
+
: PaginationLink({
|
|
235
|
+
children: String(entry),
|
|
236
|
+
isActive: () => current() === entry,
|
|
237
|
+
onSelect: go(entry),
|
|
238
|
+
}),
|
|
239
|
+
})),
|
|
240
|
+
PaginationItem({
|
|
241
|
+
children: PaginationNext({
|
|
242
|
+
disabled: () => current() >= pageCount(),
|
|
243
|
+
onSelect: go(current() + 1),
|
|
244
|
+
}),
|
|
245
|
+
}),
|
|
246
|
+
],
|
|
247
|
+
}),
|
|
248
|
+
});
|
|
249
|
+
}
|
|
216
250
|
function renderRow(row) {
|
|
217
251
|
const key = props.rowKey(row);
|
|
218
252
|
return TableRow({
|
|
@@ -2,8 +2,24 @@
|
|
|
2
2
|
* Dialog — a modal window over the page.
|
|
3
3
|
*
|
|
4
4
|
* `modalSurface` supplies the contract (trap, scroll lock, backdrop dismissal,
|
|
5
|
-
* hiding the page from assistive technology);
|
|
6
|
-
*
|
|
5
|
+
* hiding the page from assistive technology); these parts supply the markup.
|
|
6
|
+
*
|
|
7
|
+
* Dialog({ children: () => html`
|
|
8
|
+
* ${DialogTrigger({ children: "Edit" })}
|
|
9
|
+
* ${DialogContent({ children: () => html`
|
|
10
|
+
* ${DialogHeader({ children: () => html`
|
|
11
|
+
* ${DialogTitle({ children: "Edit profile" })}
|
|
12
|
+
* ${DialogDescription({ children: "Change it." })}
|
|
13
|
+
* ` })}
|
|
14
|
+
* ${DialogFooter({ children: () => Button({ children: "Save" }) })}
|
|
15
|
+
* ` })}
|
|
16
|
+
* ` })
|
|
17
|
+
*
|
|
18
|
+
* Every part is built during `Dialog`'s setup, including the ones inside
|
|
19
|
+
* `DialogContent`. That is not only the context rule — `DialogTitle` has to
|
|
20
|
+
* have registered before the surface is wired, because the panel names itself
|
|
21
|
+
* with the title's id and a panel rendered first would have had nothing to
|
|
22
|
+
* point at.
|
|
7
23
|
*
|
|
8
24
|
* The `panel` callback matters more than it looks. The overlay's root spans
|
|
9
25
|
* the viewport so the backdrop can, which means containment has to be answered
|
|
@@ -12,43 +28,93 @@
|
|
|
12
28
|
*
|
|
13
29
|
* `aria-labelledby` points at the title and `aria-describedby` at the
|
|
14
30
|
* description, so a screen reader announces what the dialog is for on open. A
|
|
15
|
-
* dialog with neither announces only "dialog", which is why
|
|
16
|
-
*
|
|
17
|
-
* no visible heading.
|
|
31
|
+
* dialog with neither announces only "dialog", which is why a missing
|
|
32
|
+
* `DialogTitle` is warned about — as upstream warns — rather than tolerated.
|
|
18
33
|
*/
|
|
19
|
-
import { type
|
|
34
|
+
import { type TemplateResult } from "@c9up/aurora";
|
|
35
|
+
import type { Parts, Slot } from "../lib/children.js";
|
|
20
36
|
import { type Reactive } from "../lib/props.js";
|
|
21
|
-
export declare const dialogBackdropClasses = "fixed inset-0 z-50 bg-black/50";
|
|
22
|
-
export declare const dialogPanelClasses = "bg-background fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border p-6 shadow-lg outline-none sm:max-w-lg";
|
|
37
|
+
export declare const dialogBackdropClasses = "fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0";
|
|
38
|
+
export declare const dialogPanelClasses = "bg-background fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg";
|
|
23
39
|
export interface DialogProps {
|
|
24
|
-
/** Rendered inside the trigger button. Omit to drive `open` yourself. */
|
|
25
|
-
trigger?: Slot;
|
|
26
|
-
/**
|
|
27
|
-
* Announced on open. Hide it visually with `srOnlyTitle`.
|
|
28
|
-
*
|
|
29
|
-
* A `Slot`, so it may be an accessor: one Dialog driven between "create" and
|
|
30
|
-
* "edit" needs a title that follows. It already behaved that way — the
|
|
31
|
-
* renderer binds whatever it is given — while the type said `Child` and
|
|
32
|
-
* refused the function, so the working call did not compile and the type
|
|
33
|
-
* disagreed with `children` beside it for no reason.
|
|
34
|
-
*/
|
|
35
|
-
title: Slot;
|
|
36
|
-
description?: Slot;
|
|
37
|
-
children?: Slot;
|
|
38
|
-
/** Actions, laid out bottom-right. */
|
|
39
|
-
footer?: Slot;
|
|
40
40
|
open?: Reactive<boolean>;
|
|
41
41
|
defaultOpen?: boolean;
|
|
42
42
|
onOpenChange?: (open: boolean) => void;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
children?: Parts;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The state every part reads.
|
|
47
|
+
*
|
|
48
|
+
* Renders no element of its own, as upstream does not: `data-slot="dialog"`
|
|
49
|
+
* sits on a Radix Root that produces no DOM.
|
|
50
|
+
*/
|
|
51
|
+
export declare const Dialog: (props?: DialogProps | undefined) => TemplateResult;
|
|
52
|
+
export interface DialogTriggerProps {
|
|
53
|
+
children?: Slot;
|
|
54
|
+
class?: Reactive<string>;
|
|
55
|
+
}
|
|
56
|
+
export declare const DialogTrigger: (props?: DialogTriggerProps | undefined) => TemplateResult;
|
|
57
|
+
export interface DialogCloseProps {
|
|
58
|
+
children?: Slot;
|
|
59
|
+
class?: Reactive<string>;
|
|
60
|
+
}
|
|
61
|
+
/** Anything that dismisses the dialog — a Cancel button, the corner cross. */
|
|
62
|
+
export declare const DialogClose: (props?: DialogCloseProps | undefined) => TemplateResult;
|
|
63
|
+
export interface DialogOverlayProps {
|
|
64
|
+
class?: Reactive<string>;
|
|
65
|
+
}
|
|
66
|
+
/** The backdrop. Rendered by `DialogContent`; exported to compose your own. */
|
|
67
|
+
export declare const DialogOverlay: (props?: DialogOverlayProps | undefined) => TemplateResult;
|
|
68
|
+
export interface DialogPortalProps {
|
|
69
|
+
children?: Slot;
|
|
70
|
+
/** Where to mount. Defaults to `document.body`. */
|
|
71
|
+
container?: () => Element | null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Mount children outside the component's own DOM position.
|
|
75
|
+
*
|
|
76
|
+
* `DialogContent` does NOT need it — `Dialog` portals the whole overlay
|
|
77
|
+
* through `modalSurface`, which also owns the trap and the scroll lock. It is
|
|
78
|
+
* exported because upstream exports it, and it does here what its name says
|
|
79
|
+
* rather than standing in as a passthrough.
|
|
80
|
+
*/
|
|
81
|
+
export declare const DialogPortal: (props?: DialogPortalProps | undefined) => TemplateResult;
|
|
82
|
+
export interface DialogContentProps {
|
|
83
|
+
children?: Parts;
|
|
84
|
+
/** The corner cross. */
|
|
85
|
+
showCloseButton?: boolean;
|
|
86
|
+
/** A click outside closes. `false` for a decision that must be made. */
|
|
87
|
+
dismissOnOutside?: boolean;
|
|
88
|
+
/** Escape closes. `false` for the same reason. */
|
|
89
|
+
dismissOnEscape?: boolean;
|
|
90
|
+
class?: Reactive<string>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The panel.
|
|
94
|
+
*
|
|
95
|
+
* Renders nothing where it is written: the dialog portals its overlay out of
|
|
96
|
+
* the tree when it opens. Its children are built HERE, during setup, so the
|
|
97
|
+
* parts inside see the context and register before the surface is wired.
|
|
98
|
+
*/
|
|
99
|
+
export declare const DialogContent: (props?: DialogContentProps | undefined) => TemplateResult;
|
|
100
|
+
export interface DialogSectionProps {
|
|
101
|
+
children?: Slot;
|
|
102
|
+
class?: Reactive<string>;
|
|
103
|
+
}
|
|
104
|
+
export declare const DialogHeader: (props?: DialogSectionProps | undefined) => TemplateResult;
|
|
105
|
+
export interface DialogFooterProps extends DialogSectionProps {
|
|
106
|
+
/** Append a "Close" button after the children, as upstream can. */
|
|
107
|
+
showCloseButton?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export declare const DialogFooter: (props?: DialogFooterProps | undefined) => TemplateResult;
|
|
110
|
+
export interface DialogTitleProps {
|
|
111
|
+
children?: Slot;
|
|
112
|
+
/** Keep it for screen readers but out of the layout. */
|
|
113
|
+
srOnly?: boolean;
|
|
47
114
|
class?: Reactive<string>;
|
|
48
|
-
triggerClass?: Reactive<string>;
|
|
49
|
-
contentClass?: Reactive<string>;
|
|
50
115
|
}
|
|
51
|
-
export declare const
|
|
116
|
+
export declare const DialogTitle: (props?: DialogTitleProps | undefined) => TemplateResult;
|
|
117
|
+
export declare const DialogDescription: (props?: DialogSectionProps | undefined) => TemplateResult;
|
|
52
118
|
/** A dialog driven purely by a signal, with no trigger of its own. */
|
|
53
119
|
export declare function useDialog(initial?: boolean): {
|
|
54
120
|
open: () => boolean;
|