@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
|
@@ -7,28 +7,72 @@
|
|
|
7
7
|
* on the panel's own size, which only `translate-x-full` knows. That is why
|
|
8
8
|
* `slideFrom` produces a transition and not a keyframe animation.
|
|
9
9
|
*
|
|
10
|
+
* Sheet({ children: () => html`
|
|
11
|
+
* ${SheetTrigger({ children: "Filters" })}
|
|
12
|
+
* ${SheetContent({ side: "left", children: () => html`
|
|
13
|
+
* ${SheetHeader({ children: SheetTitle({ children: "Filters" }) })}
|
|
14
|
+
* ${SheetFooter({ children: SheetClose({ children: "Done" }) })}
|
|
15
|
+
* ` })}
|
|
16
|
+
* ` })
|
|
17
|
+
*
|
|
10
18
|
* `inset-y-0` for the side panels and `inset-x-0` for the top and bottom ones
|
|
11
19
|
* is what makes the sheet span its edge; the opposite axis takes the width or
|
|
12
20
|
* height. Getting that pair the wrong way round produces a panel floating in a
|
|
13
21
|
* corner, which is the usual first attempt.
|
|
14
22
|
*/
|
|
15
|
-
import type
|
|
16
|
-
import {
|
|
23
|
+
import { type TemplateResult } from "@c9up/aurora";
|
|
24
|
+
import type { Parts, Slot } from "../lib/children.js";
|
|
17
25
|
import { type Reactive } from "../lib/props.js";
|
|
18
26
|
import type { Side } from "../primitives/floating.js";
|
|
19
27
|
export interface SheetProps {
|
|
20
|
-
trigger?: Slot;
|
|
21
|
-
title: Child;
|
|
22
|
-
description?: Child;
|
|
23
|
-
children?: Slot;
|
|
24
|
-
footer?: Slot;
|
|
25
|
-
/** Which edge it comes from. Default `"right"`. */
|
|
26
|
-
side?: Side;
|
|
27
28
|
open?: Reactive<boolean>;
|
|
28
29
|
defaultOpen?: boolean;
|
|
29
30
|
onOpenChange?: (open: boolean) => void;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
children?: Parts;
|
|
32
|
+
}
|
|
33
|
+
export declare const Sheet: (props?: SheetProps | undefined) => TemplateResult;
|
|
34
|
+
export interface SheetTriggerProps {
|
|
35
|
+
children?: Slot;
|
|
36
|
+
class?: Reactive<string>;
|
|
37
|
+
}
|
|
38
|
+
export declare const SheetTrigger: (props?: SheetTriggerProps | undefined) => TemplateResult;
|
|
39
|
+
export interface SheetCloseProps {
|
|
40
|
+
children?: Slot;
|
|
41
|
+
class?: Reactive<string>;
|
|
42
|
+
}
|
|
43
|
+
export declare const SheetClose: (props?: SheetCloseProps | undefined) => TemplateResult;
|
|
44
|
+
export interface SheetOverlayProps {
|
|
45
|
+
class?: Reactive<string>;
|
|
46
|
+
}
|
|
47
|
+
export declare const SheetOverlay: (props?: SheetOverlayProps | undefined) => TemplateResult;
|
|
48
|
+
export interface SheetContentProps {
|
|
49
|
+
children?: Parts;
|
|
50
|
+
/** Which edge it comes from. Default `"right"`. */
|
|
51
|
+
side?: Side;
|
|
52
|
+
showCloseButton?: boolean;
|
|
53
|
+
class?: Reactive<string>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The panel.
|
|
57
|
+
*
|
|
58
|
+
* NAMED DEVIATION FROM NEBULA'S OWN PAST — there is no `sheet-body` wrapper
|
|
59
|
+
* any more. Upstream puts the padding on the header and footer and leaves the
|
|
60
|
+
* middle to the caller, and an extra flex child here would not sit where a
|
|
61
|
+
* design copied from upstream expects it. A long middle scrolls by wrapping it
|
|
62
|
+
* in `flex-1 overflow-y-auto`, which is what upstream's own examples do.
|
|
63
|
+
*/
|
|
64
|
+
export declare const SheetContent: (props?: SheetContentProps | undefined) => TemplateResult;
|
|
65
|
+
export interface SheetSectionProps {
|
|
66
|
+
children?: Slot;
|
|
67
|
+
class?: Reactive<string>;
|
|
68
|
+
}
|
|
69
|
+
export declare const SheetHeader: (props?: SheetSectionProps | undefined) => TemplateResult;
|
|
70
|
+
export declare const SheetFooter: (props?: SheetSectionProps | undefined) => TemplateResult;
|
|
71
|
+
export interface SheetTitleProps {
|
|
72
|
+
children?: Slot;
|
|
73
|
+
/** Keep it for screen readers but out of the layout. */
|
|
74
|
+
srOnly?: boolean;
|
|
75
|
+
class?: Reactive<string>;
|
|
33
76
|
}
|
|
34
|
-
export declare const
|
|
77
|
+
export declare const SheetTitle: (props?: SheetTitleProps | undefined) => TemplateResult;
|
|
78
|
+
export declare const SheetDescription: (props?: SheetSectionProps | undefined) => TemplateResult;
|
package/dist/organisms/Sheet.js
CHANGED
|
@@ -7,12 +7,20 @@
|
|
|
7
7
|
* on the panel's own size, which only `translate-x-full` knows. That is why
|
|
8
8
|
* `slideFrom` produces a transition and not a keyframe animation.
|
|
9
9
|
*
|
|
10
|
+
* Sheet({ children: () => html`
|
|
11
|
+
* ${SheetTrigger({ children: "Filters" })}
|
|
12
|
+
* ${SheetContent({ side: "left", children: () => html`
|
|
13
|
+
* ${SheetHeader({ children: SheetTitle({ children: "Filters" }) })}
|
|
14
|
+
* ${SheetFooter({ children: SheetClose({ children: "Done" }) })}
|
|
15
|
+
* ` })}
|
|
16
|
+
* ` })
|
|
17
|
+
*
|
|
10
18
|
* `inset-y-0` for the side panels and `inset-x-0` for the top and bottom ones
|
|
11
19
|
* is what makes the sheet span its edge; the opposite axis takes the width or
|
|
12
20
|
* height. Getting that pair the wrong way round produces a panel floating in a
|
|
13
21
|
* corner, which is the usual first attempt.
|
|
14
22
|
*/
|
|
15
|
-
import { component, html } from "@c9up/aurora";
|
|
23
|
+
import { component, createContext, html, inject, provide, } from "@c9up/aurora";
|
|
16
24
|
import { slot } from "../lib/children.js";
|
|
17
25
|
import { cn } from "../lib/cn.js";
|
|
18
26
|
import { XIcon } from "../lib/icons.js";
|
|
@@ -22,6 +30,9 @@ import { read } from "../lib/props.js";
|
|
|
22
30
|
import { controllable } from "../primitives/controllable.js";
|
|
23
31
|
import { modalSurface } from "../primitives/modalSurface.js";
|
|
24
32
|
import { dialogBackdropClasses } from "./Dialog.js";
|
|
33
|
+
const panelBaseClasses = "bg-background fixed z-50 flex flex-col gap-4 shadow-lg outline-none transition ease-in-out";
|
|
34
|
+
const closeButtonClasses = "ring-offset-background focus-visible:ring-ring absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none";
|
|
35
|
+
const SheetContext = createContext("Sheet");
|
|
25
36
|
/** Edge placement and the axis the panel is sized on. */
|
|
26
37
|
function panelClassesFor(side) {
|
|
27
38
|
if (side === "left") {
|
|
@@ -35,73 +46,149 @@ function panelClassesFor(side) {
|
|
|
35
46
|
return "inset-x-0 bottom-0 h-auto border-t";
|
|
36
47
|
}
|
|
37
48
|
export const Sheet = component((props) => {
|
|
38
|
-
const side = props.side ?? "right";
|
|
39
49
|
const triggerId = uid("sheet-trigger");
|
|
40
50
|
const panelId = uid("sheet-panel");
|
|
41
51
|
const titleId = uid("sheet-title");
|
|
42
52
|
const descriptionId = uid("sheet-description");
|
|
53
|
+
let hasTitle = false;
|
|
54
|
+
let hasDescription = false;
|
|
55
|
+
let content;
|
|
43
56
|
const state = controllable({
|
|
44
57
|
value: props.open,
|
|
45
58
|
initial: props.defaultOpen ?? false,
|
|
46
59
|
onChange: props.onOpenChange,
|
|
47
60
|
});
|
|
48
|
-
|
|
61
|
+
provide(SheetContext, {
|
|
62
|
+
triggerId,
|
|
63
|
+
panelId,
|
|
64
|
+
titleId,
|
|
65
|
+
descriptionId,
|
|
49
66
|
open: () => state.current(),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
aria-modal="true"
|
|
61
|
-
aria-labelledby="${titleId}"
|
|
62
|
-
aria-describedby="${props.description === undefined ? undefined : descriptionId}"
|
|
63
|
-
tabindex="-1"
|
|
64
|
-
class="${cn("bg-background fixed z-50 flex flex-col gap-4 p-6 shadow-lg outline-none", panelClassesFor(side), slideFrom(side), read(props.contentClass))}"
|
|
65
|
-
>
|
|
66
|
-
<div data-slot="sheet-header" class="flex flex-col gap-1.5">
|
|
67
|
-
<h2
|
|
68
|
-
id="${titleId}"
|
|
69
|
-
class="${cn("text-foreground font-semibold", props.srOnlyTitle === true ? "sr-only" : "")}"
|
|
70
|
-
>${props.title}</h2>
|
|
71
|
-
${props.description === undefined
|
|
72
|
-
? null
|
|
73
|
-
: html `<p id="${descriptionId}" class="text-muted-foreground text-sm">
|
|
74
|
-
${props.description}
|
|
75
|
-
</p>`}
|
|
76
|
-
</div>
|
|
77
|
-
<div data-slot="sheet-body" class="flex-1 overflow-y-auto">${slot(props.children)}</div>
|
|
78
|
-
${props.footer === undefined
|
|
79
|
-
? null
|
|
80
|
-
: html `<div data-slot="sheet-footer" class="mt-auto flex flex-col gap-2">
|
|
81
|
-
${slot(props.footer)}
|
|
82
|
-
</div>`}
|
|
83
|
-
<button
|
|
84
|
-
type="button"
|
|
85
|
-
data-slot="sheet-close"
|
|
86
|
-
class="ring-offset-background focus-visible:ring-ring absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:outline-none"
|
|
87
|
-
@click="${() => state.set(false)}"
|
|
88
|
-
>
|
|
89
|
-
${XIcon({ class: "size-4" })}
|
|
90
|
-
<span class="sr-only">Close</span>
|
|
91
|
-
</button>
|
|
92
|
-
</div>
|
|
93
|
-
</div>`,
|
|
67
|
+
setOpen: (next) => state.set(next),
|
|
68
|
+
declareTitle() {
|
|
69
|
+
hasTitle = true;
|
|
70
|
+
},
|
|
71
|
+
declareDescription() {
|
|
72
|
+
hasDescription = true;
|
|
73
|
+
},
|
|
74
|
+
register(registered) {
|
|
75
|
+
content = registered;
|
|
76
|
+
},
|
|
94
77
|
});
|
|
95
|
-
|
|
96
|
-
|
|
78
|
+
const parts = props.children?.();
|
|
79
|
+
if (content !== undefined) {
|
|
80
|
+
const registered = content;
|
|
81
|
+
if (!hasTitle) {
|
|
82
|
+
console.warn("nebula: a Sheet has no SheetTitle. It will be announced only as “dialog”.");
|
|
83
|
+
}
|
|
84
|
+
modalSurface({
|
|
85
|
+
open: () => state.current(),
|
|
86
|
+
onClose: () => state.set(false),
|
|
87
|
+
panel: (root) => root.querySelector(`#${CSS.escape(panelId)}`),
|
|
88
|
+
returnFocus: () => document.getElementById(triggerId),
|
|
89
|
+
content: () => renderSurface(registered, {
|
|
90
|
+
panelId,
|
|
91
|
+
titleId: hasTitle ? titleId : undefined,
|
|
92
|
+
descriptionId: hasDescription ? descriptionId : undefined,
|
|
93
|
+
close: () => state.set(false),
|
|
94
|
+
}),
|
|
95
|
+
});
|
|
97
96
|
}
|
|
97
|
+
return html `${parts}`;
|
|
98
|
+
});
|
|
99
|
+
export const SheetTrigger = component((props) => {
|
|
100
|
+
const sheet = inject(SheetContext);
|
|
98
101
|
return html `<button
|
|
99
102
|
type="button"
|
|
100
103
|
data-slot="sheet-trigger"
|
|
101
|
-
id="${triggerId}"
|
|
104
|
+
id="${sheet.triggerId}"
|
|
102
105
|
aria-haspopup="dialog"
|
|
103
|
-
aria-expanded="${() => (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
aria-expanded="${() => (sheet.open() ? "true" : "false")}"
|
|
107
|
+
data-state="${() => (sheet.open() ? "open" : "closed")}"
|
|
108
|
+
class="${() => cn(read(props.class))}"
|
|
109
|
+
@click="${() => sheet.setOpen(true)}"
|
|
110
|
+
>${slot(props.children)}</button>`;
|
|
107
111
|
});
|
|
112
|
+
export const SheetClose = component((props) => {
|
|
113
|
+
const sheet = inject(SheetContext);
|
|
114
|
+
return html `<button
|
|
115
|
+
type="button"
|
|
116
|
+
data-slot="sheet-close"
|
|
117
|
+
class="${() => cn(read(props.class))}"
|
|
118
|
+
@click="${() => sheet.setOpen(false)}"
|
|
119
|
+
>${slot(props.children)}</button>`;
|
|
120
|
+
});
|
|
121
|
+
export const SheetOverlay = component((props) => html `<div
|
|
122
|
+
data-slot="sheet-overlay"
|
|
123
|
+
class="${() => cn(dialogBackdropClasses, read(props.class))}"
|
|
124
|
+
></div>`);
|
|
125
|
+
/**
|
|
126
|
+
* The panel.
|
|
127
|
+
*
|
|
128
|
+
* NAMED DEVIATION FROM NEBULA'S OWN PAST — there is no `sheet-body` wrapper
|
|
129
|
+
* any more. Upstream puts the padding on the header and footer and leaves the
|
|
130
|
+
* middle to the caller, and an extra flex child here would not sit where a
|
|
131
|
+
* design copied from upstream expects it. A long middle scrolls by wrapping it
|
|
132
|
+
* in `flex-1 overflow-y-auto`, which is what upstream's own examples do.
|
|
133
|
+
*/
|
|
134
|
+
export const SheetContent = component((props) => {
|
|
135
|
+
const sheet = inject(SheetContext);
|
|
136
|
+
const body = props.children?.();
|
|
137
|
+
sheet.register({
|
|
138
|
+
body,
|
|
139
|
+
side: props.side ?? "right",
|
|
140
|
+
showCloseButton: props.showCloseButton ?? true,
|
|
141
|
+
class: props.class,
|
|
142
|
+
});
|
|
143
|
+
return html ``;
|
|
144
|
+
});
|
|
145
|
+
export const SheetHeader = component((props) => html `<div
|
|
146
|
+
data-slot="sheet-header"
|
|
147
|
+
class="${() => cn("flex flex-col gap-1.5 p-4", read(props.class))}"
|
|
148
|
+
>${slot(props.children)}</div>`);
|
|
149
|
+
export const SheetFooter = component((props) => html `<div
|
|
150
|
+
data-slot="sheet-footer"
|
|
151
|
+
class="${() => cn("mt-auto flex flex-col gap-2 p-4", read(props.class))}"
|
|
152
|
+
>${slot(props.children)}</div>`);
|
|
153
|
+
export const SheetTitle = component((props) => {
|
|
154
|
+
const sheet = inject(SheetContext);
|
|
155
|
+
sheet.declareTitle();
|
|
156
|
+
return html `<h2
|
|
157
|
+
id="${sheet.titleId}"
|
|
158
|
+
data-slot="sheet-title"
|
|
159
|
+
class="${() => cn("text-foreground font-semibold", props.srOnly === true ? "sr-only" : "", read(props.class))}"
|
|
160
|
+
>${slot(props.children)}</h2>`;
|
|
161
|
+
});
|
|
162
|
+
export const SheetDescription = component((props) => {
|
|
163
|
+
const sheet = inject(SheetContext);
|
|
164
|
+
sheet.declareDescription();
|
|
165
|
+
return html `<p
|
|
166
|
+
id="${sheet.descriptionId}"
|
|
167
|
+
data-slot="sheet-description"
|
|
168
|
+
class="${() => cn("text-muted-foreground text-sm", read(props.class))}"
|
|
169
|
+
>${slot(props.children)}</p>`;
|
|
170
|
+
});
|
|
171
|
+
function renderSurface(registered, ids) {
|
|
172
|
+
const corner = registered.showCloseButton
|
|
173
|
+
? html `<button
|
|
174
|
+
type="button"
|
|
175
|
+
data-slot="sheet-close"
|
|
176
|
+
class="${closeButtonClasses}"
|
|
177
|
+
@click="${() => ids.close()}"
|
|
178
|
+
>${XIcon({ class: "size-4" })}<span class="sr-only">Close</span></button>`
|
|
179
|
+
: null;
|
|
180
|
+
return html `<div data-slot="sheet-portal" class="${cn("fixed inset-0 z-50", fadeInOut)}">
|
|
181
|
+
<div data-slot="sheet-overlay" class="${dialogBackdropClasses}"></div>
|
|
182
|
+
<div
|
|
183
|
+
data-slot="sheet-content"
|
|
184
|
+
data-side="${registered.side}"
|
|
185
|
+
id="${ids.panelId}"
|
|
186
|
+
role="dialog"
|
|
187
|
+
aria-modal="true"
|
|
188
|
+
aria-labelledby="${ids.titleId}"
|
|
189
|
+
aria-describedby="${ids.descriptionId}"
|
|
190
|
+
tabindex="-1"
|
|
191
|
+
class="${cn(panelBaseClasses, panelClassesFor(registered.side), slideFrom(registered.side), read(registered.class))}"
|
|
192
|
+
>${registered.body}${corner}</div>
|
|
193
|
+
</div>`;
|
|
194
|
+
}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sidebar — the application shell's navigation column.
|
|
3
3
|
*
|
|
4
|
+
* SidebarProvider({ children: () => html`
|
|
5
|
+
* ${Sidebar({ children: () => SidebarContent({ children:
|
|
6
|
+
* SidebarGroup({ children: SidebarMenu({ children:
|
|
7
|
+
* SidebarMenuItem({ children:
|
|
8
|
+
* SidebarMenuButton({ href: "/", tooltip: "Home", children: "Home" })
|
|
9
|
+
* })
|
|
10
|
+
* }) })
|
|
11
|
+
* }) })}
|
|
12
|
+
* ${SidebarInset({ children: page })}
|
|
13
|
+
* ` })
|
|
14
|
+
*
|
|
4
15
|
* Two presentations from one definition, because a sidebar is not a component
|
|
5
16
|
* so much as a layout decision that changes with the viewport:
|
|
6
17
|
*
|
|
@@ -18,46 +29,124 @@
|
|
|
18
29
|
* `cmd/ctrl + B` toggles it, the convention from every editor that has one.
|
|
19
30
|
*/
|
|
20
31
|
import { type Signal } from "@c9up/aurora";
|
|
21
|
-
import type {
|
|
32
|
+
import type { Parts, Slot } from "../lib/children.js";
|
|
33
|
+
import { type VariantProps } from "../lib/cva.js";
|
|
22
34
|
import { type Reactive } from "../lib/props.js";
|
|
23
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The cookie-backed open state, shared by every sidebar on the page.
|
|
37
|
+
*
|
|
38
|
+
* A module singleton and not a per-provider signal: the shell renders once and
|
|
39
|
+
* the trigger may sit in a header that is not inside the provider's subtree.
|
|
40
|
+
*/
|
|
24
41
|
export declare function sidebarState(defaultOpen?: boolean): Signal<boolean>;
|
|
25
|
-
/** Is the sidebar collapsed to its icon rail right now? */
|
|
26
42
|
export declare function sidebarCollapsed(): boolean;
|
|
43
|
+
export interface SidebarApi {
|
|
44
|
+
readonly open: () => boolean;
|
|
45
|
+
readonly isMobile: () => boolean;
|
|
46
|
+
readonly state: () => "expanded" | "collapsed";
|
|
47
|
+
setOpen(next: boolean): void;
|
|
48
|
+
toggleSidebar(): void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The sidebar's state, from inside it.
|
|
52
|
+
*
|
|
53
|
+
* Call from a component setup, as upstream's hook is called from a render.
|
|
54
|
+
*/
|
|
55
|
+
export declare function useSidebar(): SidebarApi;
|
|
56
|
+
export interface SidebarProviderProps {
|
|
57
|
+
/** Starting state. Read from the cookie when there is one. */
|
|
58
|
+
defaultOpen?: boolean;
|
|
59
|
+
open?: Reactive<boolean>;
|
|
60
|
+
onOpenChange?: (open: boolean) => void;
|
|
61
|
+
class?: Reactive<string>;
|
|
62
|
+
children?: Parts;
|
|
63
|
+
}
|
|
64
|
+
export declare const SidebarProvider: (props?: SidebarProviderProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
27
65
|
export interface SidebarProps {
|
|
28
|
-
children?:
|
|
29
|
-
header?: Slot;
|
|
30
|
-
footer?: Slot;
|
|
66
|
+
children?: Parts;
|
|
31
67
|
/** Which edge. Default `"left"`. */
|
|
32
68
|
side?: "left" | "right";
|
|
33
69
|
/** What collapsing does: shrink to icons, or disappear. Default `"icon"`. */
|
|
34
|
-
collapsible?: "icon" | "offcanvas";
|
|
35
|
-
/** Starting state. Read from the cookie when there is one. */
|
|
36
|
-
defaultOpen?: boolean;
|
|
70
|
+
collapsible?: "icon" | "offcanvas" | "none";
|
|
37
71
|
/** Announced as the navigation landmark's name. */
|
|
38
72
|
label?: string;
|
|
39
73
|
class?: Reactive<string>;
|
|
40
74
|
}
|
|
41
75
|
export declare const Sidebar: (props?: SidebarProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
42
76
|
export interface SidebarTriggerProps {
|
|
43
|
-
|
|
77
|
+
/** Overrides the provider's toggle — for a trigger outside the shell. */
|
|
78
|
+
onToggle?: () => void;
|
|
79
|
+
class?: Reactive<string>;
|
|
80
|
+
}
|
|
81
|
+
export declare const SidebarTrigger: (props?: SidebarTriggerProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
82
|
+
export interface SidebarRailProps {
|
|
44
83
|
class?: Reactive<string>;
|
|
45
84
|
}
|
|
46
85
|
/**
|
|
47
|
-
* The
|
|
86
|
+
* The hit area along the sidebar's edge that toggles it.
|
|
48
87
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
88
|
+
* A wider target than the trigger button and always where the eye already is.
|
|
89
|
+
* `title` rather than a visible label, and it stays out of the tab order: the
|
|
90
|
+
* keyboard has `cmd/ctrl + B` and the trigger, so a third stop on every page
|
|
91
|
+
* would be noise.
|
|
52
92
|
*/
|
|
53
|
-
export declare const
|
|
54
|
-
export
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
93
|
+
export declare const SidebarRail: (props?: SidebarRailProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
94
|
+
export interface SidebarInsetProps {
|
|
95
|
+
children?: Slot;
|
|
96
|
+
class?: Reactive<string>;
|
|
97
|
+
}
|
|
98
|
+
/** The page beside the sidebar. */
|
|
99
|
+
export declare const SidebarInset: (props?: SidebarInsetProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
100
|
+
export interface SidebarInputProps {
|
|
101
|
+
placeholder?: string;
|
|
102
|
+
value?: Reactive<string>;
|
|
103
|
+
onInput?: (value: string) => void;
|
|
104
|
+
class?: Reactive<string>;
|
|
105
|
+
}
|
|
106
|
+
/** A search field sized for the column. */
|
|
107
|
+
export declare const SidebarInput: (props?: SidebarInputProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
108
|
+
export declare const SidebarHeader: (props?: import("../index.js").StyledProps) => import("@c9up/aurora").TemplateResult;
|
|
109
|
+
export declare const SidebarFooter: (props?: import("../index.js").StyledProps) => import("@c9up/aurora").TemplateResult;
|
|
110
|
+
export declare const SidebarContent: (props?: import("../index.js").StyledProps) => import("@c9up/aurora").TemplateResult;
|
|
111
|
+
export interface SidebarSeparatorProps {
|
|
112
|
+
class?: Reactive<string>;
|
|
113
|
+
}
|
|
114
|
+
export declare const SidebarSeparator: (props?: SidebarSeparatorProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
115
|
+
export declare const SidebarGroup: (props?: import("../index.js").StyledProps) => import("@c9up/aurora").TemplateResult;
|
|
116
|
+
export declare const SidebarGroupLabel: (props?: import("../index.js").StyledProps) => import("@c9up/aurora").TemplateResult;
|
|
117
|
+
export declare const SidebarGroupContent: (props?: import("../index.js").StyledProps) => import("@c9up/aurora").TemplateResult;
|
|
118
|
+
export interface SidebarActionProps {
|
|
119
|
+
children?: Slot;
|
|
120
|
+
label?: string;
|
|
121
|
+
onClick?: () => void;
|
|
122
|
+
class?: Reactive<string>;
|
|
123
|
+
}
|
|
124
|
+
/** A control in a group's corner — "add", "filter". */
|
|
125
|
+
export declare const SidebarGroupAction: (props?: SidebarActionProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
126
|
+
export declare const SidebarMenu: (props?: {
|
|
127
|
+
children?: Slot;
|
|
128
|
+
class?: Reactive<string>;
|
|
129
|
+
} | undefined) => import("@c9up/aurora").TemplateResult;
|
|
130
|
+
/** One row. Holds a button, and optionally an action and a badge beside it. */
|
|
131
|
+
export declare const SidebarMenuItem: (props?: {
|
|
132
|
+
children?: Slot;
|
|
133
|
+
class?: Reactive<string>;
|
|
134
|
+
} | undefined) => import("@c9up/aurora").TemplateResult;
|
|
135
|
+
export declare const sidebarMenuButtonVariants: (props?: (import("../index.js").VariantSelection<{
|
|
136
|
+
variant: {
|
|
137
|
+
default: string;
|
|
138
|
+
outline: string;
|
|
139
|
+
};
|
|
140
|
+
size: {
|
|
141
|
+
default: string;
|
|
142
|
+
sm: string;
|
|
143
|
+
lg: string;
|
|
144
|
+
};
|
|
145
|
+
}> & import("../index.js").ClassOverrides) | undefined) => string;
|
|
146
|
+
export type SidebarMenuButtonVariants = VariantProps<typeof sidebarMenuButtonVariants>;
|
|
147
|
+
export interface SidebarMenuButtonProps extends SidebarMenuButtonVariants {
|
|
148
|
+
children?: Slot;
|
|
59
149
|
href?: string;
|
|
60
|
-
icon?: Child;
|
|
61
150
|
active?: Reactive<boolean>;
|
|
62
151
|
/**
|
|
63
152
|
* Shown as a tooltip while the sidebar is collapsed to icons.
|
|
@@ -67,43 +156,44 @@ export interface SidebarMenuItemProps {
|
|
|
67
156
|
* unlabelled glyphs, so give one to every entry that has an icon.
|
|
68
157
|
*/
|
|
69
158
|
tooltip?: string;
|
|
70
|
-
/** A trailing control — the count of unread items, a status dot. */
|
|
71
|
-
badge?: Child;
|
|
72
|
-
/**
|
|
73
|
-
* Extra classes, merged over the defaults.
|
|
74
|
-
*
|
|
75
|
-
* Every other component in this library takes one; this one did not, and a
|
|
76
|
-
* caller who wanted something as ordinary as dimming a disabled entry had
|
|
77
|
-
* to work around it. `cn` is tailwind-merge, so an override wins over the
|
|
78
|
-
* default it collides with rather than fighting it on specificity.
|
|
79
|
-
*/
|
|
80
|
-
class?: Reactive<string>;
|
|
81
159
|
onClick?: () => void;
|
|
160
|
+
class?: Reactive<string>;
|
|
161
|
+
}
|
|
162
|
+
export declare const SidebarMenuButton: (props?: SidebarMenuButtonProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
163
|
+
/** A second control on a row — a "more" menu, a remove button. */
|
|
164
|
+
export declare const SidebarMenuAction: (props?: SidebarActionProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
165
|
+
/** A count or a status dot at the end of a row. */
|
|
166
|
+
export declare const SidebarMenuBadge: (props?: {
|
|
167
|
+
children?: Slot;
|
|
168
|
+
class?: Reactive<string>;
|
|
169
|
+
} | undefined) => import("@c9up/aurora").TemplateResult;
|
|
170
|
+
export interface SidebarMenuSkeletonProps {
|
|
171
|
+
/** Leave room for an icon, as the real rows have. */
|
|
172
|
+
showIcon?: boolean;
|
|
173
|
+
class?: Reactive<string>;
|
|
82
174
|
}
|
|
83
175
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* `aria-current="page"` on the active entry, not just a highlight class. The
|
|
87
|
-
* highlight tells a sighted user where they are; without the attribute nobody
|
|
88
|
-
* else is told at all.
|
|
89
|
-
*/
|
|
90
|
-
export declare const SidebarMenuItem: (props?: SidebarMenuItemProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
91
|
-
/**
|
|
92
|
-
* A second control on a menu row — a "more" menu, a remove button.
|
|
93
|
-
*
|
|
94
|
-
* Absolutely positioned rather than a flex sibling, so it can overlap a long
|
|
95
|
-
* label instead of squeezing it. It disappears with the rail: there is no room
|
|
96
|
-
* for two controls in an icon-width column, and the row's own action is the
|
|
97
|
-
* one that matters.
|
|
98
|
-
*/
|
|
99
|
-
export declare const SidebarMenuAction: (props?: SidebarMenuItemProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
100
|
-
/**
|
|
101
|
-
* A nested list under a menu entry.
|
|
176
|
+
* A placeholder row while the navigation loads.
|
|
102
177
|
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
178
|
+
* The widths vary per row, which is what stops a loading column from reading
|
|
179
|
+
* as a bar chart. Seeded from a random draw the moment the row is built, so it
|
|
180
|
+
* does not shift on every re-render.
|
|
106
181
|
*/
|
|
107
|
-
export declare const
|
|
108
|
-
|
|
109
|
-
|
|
182
|
+
export declare const SidebarMenuSkeleton: (props?: SidebarMenuSkeletonProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
183
|
+
export declare const SidebarMenuSub: (props?: {
|
|
184
|
+
children?: Slot;
|
|
185
|
+
class?: Reactive<string>;
|
|
186
|
+
} | undefined) => import("@c9up/aurora").TemplateResult;
|
|
187
|
+
export declare const SidebarMenuSubItem: (props?: {
|
|
188
|
+
children?: Slot;
|
|
189
|
+
class?: Reactive<string>;
|
|
190
|
+
} | undefined) => import("@c9up/aurora").TemplateResult;
|
|
191
|
+
export interface SidebarMenuSubButtonProps {
|
|
192
|
+
children?: Slot;
|
|
193
|
+
href?: string;
|
|
194
|
+
active?: Reactive<boolean>;
|
|
195
|
+
size?: "sm" | "md";
|
|
196
|
+
onClick?: () => void;
|
|
197
|
+
class?: Reactive<string>;
|
|
198
|
+
}
|
|
199
|
+
export declare const SidebarMenuSubButton: (props?: SidebarMenuSubButtonProps | undefined) => import("@c9up/aurora").TemplateResult;
|