@c9up/nebula 0.2.4 → 0.2.5
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/README.md +2 -2
- package/dist/atoms/AspectRatio.d.ts +10 -4
- package/dist/atoms/AspectRatio.js +21 -6
- package/dist/atoms/NativeSelect.d.ts +10 -0
- package/dist/atoms/NativeSelect.js +4 -1
- package/dist/atoms/Progress.d.ts +9 -1
- package/dist/atoms/Progress.js +21 -5
- package/dist/atoms/Switch.d.ts +7 -1
- package/dist/atoms/Switch.js +7 -1
- package/dist/cli/diff.d.ts +46 -0
- package/dist/cli/diff.js +73 -2
- package/dist/console/DiffCommand.js +6 -11
- package/dist/molecules/Accordion.js +1 -2
- package/dist/molecules/Collapsible.js +1 -2
- package/dist/molecules/Resizable.d.ts +6 -0
- package/dist/molecules/Resizable.js +8 -2
- package/dist/organisms/AlertDialog.js +4 -5
- package/dist/organisms/Chart.d.ts +103 -15
- package/dist/organisms/Chart.js +518 -99
- package/dist/organisms/Dialog.js +7 -7
- package/dist/organisms/Sidebar.d.ts +5 -7
- package/dist/organisms/Sidebar.js +23 -6
- package/dist/organisms/Sonner.js +11 -4
- package/dist/organisms/index.d.ts +1 -1
- package/dist/organisms/index.js +1 -1
- package/dist/primitives/menuParts.js +3 -3
- package/dist/primitives/portal.d.ts +15 -0
- package/dist/primitives/portal.js +18 -1
- package/nebula.css +1 -1
- package/package.json +1 -1
- package/src/atoms/AspectRatio.ts +21 -6
- package/src/atoms/NativeSelect.ts +14 -1
- package/src/atoms/Progress.ts +21 -5
- package/src/atoms/Switch.ts +7 -1
- package/src/cli/diff.ts +123 -2
- package/src/console/DiffCommand.ts +12 -15
- package/src/molecules/Accordion.ts +1 -2
- package/src/molecules/Collapsible.ts +1 -3
- package/src/molecules/Resizable.ts +8 -2
- package/src/organisms/AlertDialog.ts +3 -5
- package/src/organisms/Chart.ts +633 -125
- package/src/organisms/Dialog.ts +6 -7
- package/src/organisms/Sidebar.ts +28 -6
- package/src/organisms/Sonner.ts +11 -4
- package/src/organisms/index.ts +6 -0
- package/src/primitives/menuParts.ts +3 -3
- package/src/primitives/portal.ts +27 -1
package/src/organisms/Dialog.ts
CHANGED
|
@@ -43,12 +43,11 @@ import {
|
|
|
43
43
|
createContext,
|
|
44
44
|
html,
|
|
45
45
|
inject,
|
|
46
|
-
onUnmount,
|
|
47
46
|
provide,
|
|
48
47
|
signal,
|
|
49
48
|
type TemplateResult,
|
|
50
49
|
} from "@c9up/aurora";
|
|
51
|
-
import {
|
|
50
|
+
import { buttonVariants } from "../atoms/Button.js";
|
|
52
51
|
import type { Child, Parts, Slot } from "../lib/children.js";
|
|
53
52
|
import { slot } from "../lib/children.js";
|
|
54
53
|
import { cn } from "../lib/cn.js";
|
|
@@ -58,7 +57,7 @@ import { fadeInOut, zoomInOut } from "../lib/motion.js";
|
|
|
58
57
|
import { type Reactive, read } from "../lib/props.js";
|
|
59
58
|
import { controllable } from "../primitives/controllable.js";
|
|
60
59
|
import { modalSurface } from "../primitives/modalSurface.js";
|
|
61
|
-
import {
|
|
60
|
+
import { portalOnMount } from "../primitives/portal.js";
|
|
62
61
|
|
|
63
62
|
export const dialogBackdropClasses =
|
|
64
63
|
"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";
|
|
@@ -233,11 +232,10 @@ export interface DialogPortalProps {
|
|
|
233
232
|
* rather than standing in as a passthrough.
|
|
234
233
|
*/
|
|
235
234
|
export const DialogPortal = component<DialogPortalProps>((props) => {
|
|
236
|
-
|
|
235
|
+
portalOnMount(html`${slot(props.children)}`, {
|
|
237
236
|
container: props.container,
|
|
237
|
+
slot: "dialog-portal",
|
|
238
238
|
});
|
|
239
|
-
mounted.host.setAttribute("data-slot", "dialog-portal");
|
|
240
|
-
onUnmount(() => mounted.close());
|
|
241
239
|
return html``;
|
|
242
240
|
});
|
|
243
241
|
|
|
@@ -301,8 +299,9 @@ export const DialogFooter = component<DialogFooterProps>((props) => {
|
|
|
301
299
|
? html`<button
|
|
302
300
|
type="button"
|
|
303
301
|
data-slot="dialog-close"
|
|
302
|
+
class="${buttonVariants({ variant: "outline" })}"
|
|
304
303
|
@click="${() => dialog.setOpen(false)}"
|
|
305
|
-
>${
|
|
304
|
+
>${props.closeLabel ?? "Close"}</button>`
|
|
306
305
|
: null;
|
|
307
306
|
return html`<div
|
|
308
307
|
data-slot="dialog-footer"
|
package/src/organisms/Sidebar.ts
CHANGED
|
@@ -89,10 +89,15 @@ export function sidebarCollapsed(): boolean {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export interface SidebarApi {
|
|
92
|
+
/** The column's state: persisted, and what the wide layout shows. */
|
|
92
93
|
readonly open: () => boolean;
|
|
94
|
+
/** The drawer's state on a phone: closed on every load, never persisted. */
|
|
95
|
+
readonly openMobile: () => boolean;
|
|
93
96
|
readonly isMobile: () => boolean;
|
|
94
97
|
readonly state: () => "expanded" | "collapsed";
|
|
95
98
|
setOpen(next: boolean): void;
|
|
99
|
+
setOpenMobile(next: boolean): void;
|
|
100
|
+
/** The drawer on a phone, the column otherwise. */
|
|
96
101
|
toggleSidebar(): void;
|
|
97
102
|
}
|
|
98
103
|
|
|
@@ -124,6 +129,10 @@ export interface SidebarProviderProps {
|
|
|
124
129
|
export const SidebarProvider = component<SidebarProviderProps>((props) => {
|
|
125
130
|
const open = sidebarState(props.defaultOpen ?? true);
|
|
126
131
|
const mobile = signal(false);
|
|
132
|
+
// Apart from the column's, as upstream: sharing it opened the drawer over
|
|
133
|
+
// the page on every load, since the column is open by default and its
|
|
134
|
+
// state outlives the page in the cookie.
|
|
135
|
+
const openMobile = signal(false);
|
|
127
136
|
|
|
128
137
|
function setOpen(next: boolean): void {
|
|
129
138
|
open(next);
|
|
@@ -131,7 +140,8 @@ export const SidebarProvider = component<SidebarProviderProps>((props) => {
|
|
|
131
140
|
}
|
|
132
141
|
|
|
133
142
|
function toggleSidebar(): void {
|
|
134
|
-
|
|
143
|
+
if (mobile()) openMobile(!openMobile());
|
|
144
|
+
else setOpen(!open());
|
|
135
145
|
}
|
|
136
146
|
|
|
137
147
|
function onKeyDown(event: KeyboardEvent): void {
|
|
@@ -167,9 +177,11 @@ export const SidebarProvider = component<SidebarProviderProps>((props) => {
|
|
|
167
177
|
|
|
168
178
|
const api = provide<SidebarApi>(SidebarContext, {
|
|
169
179
|
open: current,
|
|
180
|
+
openMobile: () => openMobile(),
|
|
170
181
|
isMobile: () => mobile(),
|
|
171
182
|
state: () => (current() ? "expanded" : "collapsed"),
|
|
172
183
|
setOpen,
|
|
184
|
+
setOpenMobile: (next) => openMobile(next),
|
|
173
185
|
toggleSidebar,
|
|
174
186
|
});
|
|
175
187
|
provide(NearestSidebar, api);
|
|
@@ -202,8 +214,8 @@ export const Sidebar = component<SidebarProps>((props) => {
|
|
|
202
214
|
return html`<div data-slot="sidebar-root">${() =>
|
|
203
215
|
sidebar.isMobile()
|
|
204
216
|
? Sheet({
|
|
205
|
-
open: () => sidebar.
|
|
206
|
-
onOpenChange: (next) => sidebar.
|
|
217
|
+
open: () => sidebar.openMobile(),
|
|
218
|
+
onOpenChange: (next) => sidebar.setOpenMobile(next),
|
|
207
219
|
children: () =>
|
|
208
220
|
SheetContent({
|
|
209
221
|
side,
|
|
@@ -562,18 +574,28 @@ export interface SidebarMenuSkeletonProps {
|
|
|
562
574
|
*
|
|
563
575
|
* The widths vary per row, which is what stops a loading column from reading
|
|
564
576
|
* as a bar chart. Seeded from a random draw the moment the row is built, so it
|
|
565
|
-
* does not shift on every re-render.
|
|
577
|
+
* does not shift on every re-render. The draw picks a class, not a `style`
|
|
578
|
+
* attribute, which a Content-Security-Policy without `'unsafe-inline'` blocks.
|
|
566
579
|
*/
|
|
580
|
+
const SKELETON_WIDTHS: readonly string[] = [
|
|
581
|
+
"max-w-[50%]",
|
|
582
|
+
"max-w-[60%]",
|
|
583
|
+
"max-w-[70%]",
|
|
584
|
+
"max-w-[80%]",
|
|
585
|
+
"max-w-[90%]",
|
|
586
|
+
];
|
|
587
|
+
|
|
567
588
|
export const SidebarMenuSkeleton = component<SidebarMenuSkeletonProps>(
|
|
568
589
|
(props) => {
|
|
569
|
-
const width =
|
|
590
|
+
const width =
|
|
591
|
+
SKELETON_WIDTHS[Math.floor(Math.random() * SKELETON_WIDTHS.length)];
|
|
570
592
|
return html`<div
|
|
571
593
|
data-slot="sidebar-menu-skeleton"
|
|
572
594
|
class="${() =>
|
|
573
595
|
cn("flex h-8 items-center gap-2 rounded-md px-2", read(props.class))}"
|
|
574
596
|
>${
|
|
575
597
|
props.showIcon === true ? Skeleton({ class: "size-4 rounded-md" }) : null
|
|
576
|
-
}<div class="flex-1"
|
|
598
|
+
}<div class="${cn("flex-1", width)}">${Skeleton({
|
|
577
599
|
class: "h-4 w-full",
|
|
578
600
|
})}</div></div>`;
|
|
579
601
|
},
|
package/src/organisms/Sonner.ts
CHANGED
|
@@ -872,6 +872,13 @@ export const Toaster = component<ToasterProps>((props) => {
|
|
|
872
872
|
const resolvedTheme = (): "light" | "dark" =>
|
|
873
873
|
state.theme === "system" ? (prefersDark() ? "dark" : "light") : state.theme;
|
|
874
874
|
|
|
875
|
+
/**
|
|
876
|
+
* The list's placement, bound as a `.style` property: the CSSOM is not
|
|
877
|
+
* subject to a Content-Security-Policy, where a `style` attribute is blocked
|
|
878
|
+
* by any policy without `'unsafe-inline'` — and the list then fell into the
|
|
879
|
+
* page flow. The server writes no property, so the list also carries `fixed`
|
|
880
|
+
* as a class: before hydration it is empty, and still out of the flow.
|
|
881
|
+
*/
|
|
875
882
|
function listStyle(corner: Position): string {
|
|
876
883
|
const { x, y } = axesOf(corner);
|
|
877
884
|
const rules = [
|
|
@@ -910,8 +917,8 @@ export const Toaster = component<ToasterProps>((props) => {
|
|
|
910
917
|
data-x-position="${() => axesOf(corner()).x}"
|
|
911
918
|
dir="${props.dir === "auto" ? undefined : props.dir}"
|
|
912
919
|
tabindex="-1"
|
|
913
|
-
class="${() => cn("m-0 box-border list-none p-0 outline-none", read(props.class))}"
|
|
914
|
-
style="${() => listStyle(corner())}"
|
|
920
|
+
class="${() => cn("fixed z-[999999999] m-0 box-border list-none p-0 outline-none", read(props.class))}"
|
|
921
|
+
.style="${() => listStyle(corner())}"
|
|
915
922
|
@pointerenter="${() => expanded(true)}"
|
|
916
923
|
@pointermove="${() => expanded(true)}"
|
|
917
924
|
@pointerleave="${() => {
|
|
@@ -1338,7 +1345,7 @@ const ToastRow = component<ToastRowProps>((props) => {
|
|
|
1338
1345
|
data-expanded="${() => String(isExpanded())}"
|
|
1339
1346
|
data-testid="${() => record().testId}"
|
|
1340
1347
|
class="${surfaceClasses}"
|
|
1341
|
-
style="${style}"
|
|
1348
|
+
.style="${style}"
|
|
1342
1349
|
>${renderClose}${renderIcon}<div
|
|
1343
1350
|
data-content
|
|
1344
1351
|
class="${() =>
|
|
@@ -1360,7 +1367,7 @@ const ToastRow = component<ToastRowProps>((props) => {
|
|
|
1360
1367
|
? html`<span
|
|
1361
1368
|
aria-hidden="true"
|
|
1362
1369
|
class="absolute left-0 bottom-full w-full"
|
|
1363
|
-
style="${`height:${state.gap + 1}px`}"
|
|
1370
|
+
.style="${`height:${state.gap + 1}px`}"
|
|
1364
1371
|
></span>`
|
|
1365
1372
|
: null}</li>`;
|
|
1366
1373
|
});
|
package/src/organisms/index.ts
CHANGED
|
@@ -57,10 +57,16 @@ export {
|
|
|
57
57
|
} from "./Carousel.js";
|
|
58
58
|
export {
|
|
59
59
|
Chart,
|
|
60
|
+
type ChartBound,
|
|
61
|
+
type ChartCategory,
|
|
60
62
|
type ChartDatum,
|
|
61
63
|
type ChartProps,
|
|
62
64
|
type ChartSeries,
|
|
65
|
+
niceTicks,
|
|
66
|
+
type ValueAxisOptions,
|
|
67
|
+
valueAxis,
|
|
63
68
|
valueRange,
|
|
69
|
+
visibleCategories,
|
|
64
70
|
} from "./Chart.js";
|
|
65
71
|
export {
|
|
66
72
|
Combobox,
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
menuSubTriggerClasses,
|
|
50
50
|
registerSubmenu,
|
|
51
51
|
} from "./menu.js";
|
|
52
|
-
import {
|
|
52
|
+
import { portalOnMount } from "./portal.js";
|
|
53
53
|
|
|
54
54
|
/** What a row needs from the menu it is in. */
|
|
55
55
|
export interface MenuOwner {
|
|
@@ -347,10 +347,10 @@ export function createMenuParts(
|
|
|
347
347
|
});
|
|
348
348
|
|
|
349
349
|
const Portal = component<MenuPortalProps>((props) => {
|
|
350
|
-
|
|
350
|
+
portalOnMount(html`${slot(props.children)}`, {
|
|
351
351
|
container: props.container,
|
|
352
|
+
slot: `${prefix}-portal`,
|
|
352
353
|
});
|
|
353
|
-
mounted.host.setAttribute("data-slot", `${prefix}-portal`);
|
|
354
354
|
return html``;
|
|
355
355
|
});
|
|
356
356
|
|
package/src/primitives/portal.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* content and the discipline to tear both down together.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { render, type TemplateResult } from "@c9up/aurora";
|
|
15
|
+
import { onMount, render, type TemplateResult } from "@c9up/aurora";
|
|
16
16
|
|
|
17
17
|
export interface PortalOptions {
|
|
18
18
|
/** Where to mount. Defaults to `document.body`. */
|
|
@@ -59,3 +59,29 @@ export function portal(
|
|
|
59
59
|
},
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
export interface PortalPartOptions extends PortalOptions {
|
|
64
|
+
/** The host's `data-slot`, naming the part that put it there. */
|
|
65
|
+
slot: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Portal `content` once the calling component is mounted, and close it when
|
|
70
|
+
* the component unmounts. Call it from a component's setup.
|
|
71
|
+
*
|
|
72
|
+
* Setup also runs inside `renderToString`, where there is no document to
|
|
73
|
+
* append a host to, so the portal waits for the mount: the server renders
|
|
74
|
+
* nothing in place and the content is client-only, as a portal that renders
|
|
75
|
+
* only after its mount effect is. The close rides on the same hook, so a part
|
|
76
|
+
* cannot open a portal without also taking it away.
|
|
77
|
+
*/
|
|
78
|
+
export function portalOnMount(
|
|
79
|
+
content: TemplateResult,
|
|
80
|
+
options: PortalPartOptions,
|
|
81
|
+
): void {
|
|
82
|
+
onMount(() => {
|
|
83
|
+
const mounted = portal(content, options);
|
|
84
|
+
mounted.host.setAttribute("data-slot", options.slot);
|
|
85
|
+
return () => mounted.close();
|
|
86
|
+
});
|
|
87
|
+
}
|