@c9up/nebula 0.2.2 → 0.2.4
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 +8 -7
- package/dist/atoms/Avatar.d.ts +14 -0
- package/dist/atoms/Avatar.js +46 -8
- package/dist/atoms/Checkbox.d.ts +1 -1
- package/dist/atoms/Checkbox.js +1 -1
- package/dist/atoms/Input.d.ts +5 -0
- package/dist/atoms/Input.js +1 -0
- package/dist/cli/add.d.ts +2 -0
- package/dist/cli/add.js +4 -1
- package/dist/cli/diff.d.ts +2 -0
- package/dist/cli/diff.js +4 -1
- package/dist/cli/projectConfig.d.ts +16 -0
- package/dist/cli/projectConfig.js +61 -0
- package/dist/console/AddCommand.js +6 -1
- package/dist/console/DiffCommand.js +6 -1
- package/dist/lib/children.d.ts +13 -8
- package/dist/lib/children.js +5 -0
- package/dist/lib/icons.d.ts +8 -0
- package/dist/lib/icons.js +8 -0
- package/dist/lib/image.js +12 -1
- package/dist/molecules/Breadcrumb.d.ts +11 -2
- package/dist/molecules/Breadcrumb.js +2 -2
- package/dist/molecules/InputOTP.d.ts +14 -0
- package/dist/molecules/InputOTP.js +71 -28
- package/dist/molecules/Pagination.d.ts +34 -2
- package/dist/molecules/Pagination.js +15 -6
- package/dist/molecules/PieceMap.d.ts +72 -0
- package/dist/molecules/PieceMap.js +78 -0
- package/dist/molecules/Resizable.d.ts +2 -0
- package/dist/molecules/Resizable.js +1 -1
- package/dist/molecules/index.d.ts +4 -3
- package/dist/molecules/index.js +2 -1
- package/dist/organisms/Calendar.d.ts +13 -0
- package/dist/organisms/Calendar.js +2 -2
- package/dist/organisms/Carousel.d.ts +8 -0
- package/dist/organisms/Carousel.js +8 -5
- package/dist/organisms/Combobox.d.ts +13 -0
- package/dist/organisms/Combobox.js +5 -2
- package/dist/organisms/Command.js +56 -8
- package/dist/organisms/DataTable.d.ts +23 -1
- package/dist/organisms/DataTable.js +57 -27
- package/dist/organisms/DatePicker.d.ts +7 -0
- package/dist/organisms/DatePicker.js +2 -1
- package/dist/organisms/DateRangePicker.d.ts +2 -0
- package/dist/organisms/DateRangePicker.js +2 -1
- package/dist/organisms/Dialog.d.ts +13 -3
- package/dist/organisms/Dialog.js +12 -5
- package/dist/organisms/Form.d.ts +15 -0
- package/dist/organisms/Form.js +10 -0
- package/dist/organisms/Questionnaire.d.ts +4 -0
- package/dist/organisms/Questionnaire.js +5 -2
- package/dist/organisms/Select.d.ts +25 -4
- package/dist/organisms/Select.js +116 -15
- package/dist/organisms/Sheet.d.ts +2 -0
- package/dist/organisms/Sheet.js +2 -1
- package/dist/organisms/Sidebar.d.ts +10 -2
- package/dist/organisms/Sidebar.js +62 -29
- package/dist/organisms/Sonner.d.ts +243 -0
- package/dist/organisms/Sonner.js +909 -0
- package/dist/organisms/Toaster.d.ts +11 -0
- package/dist/organisms/Toaster.js +34 -9
- package/dist/organisms/Tooltip.d.ts +4 -0
- package/dist/organisms/index.d.ts +8 -2
- package/dist/organisms/index.js +7 -1
- package/dist/primitives/dismissable.d.ts +11 -4
- package/dist/primitives/dismissable.js +8 -6
- package/dist/primitives/floating.d.ts +5 -1
- package/dist/primitives/floating.js +32 -2
- package/dist/primitives/menu.js +2 -1
- package/dist/primitives/modalSurface.js +70 -36
- package/dist/primitives/presence.js +8 -5
- package/dist/templates/SettingsLayout.d.ts +2 -0
- package/dist/templates/SettingsLayout.js +1 -1
- package/nebula.css +2 -2
- package/package.json +3 -3
- package/registry.json +26 -0
- package/src/atoms/Avatar.ts +54 -7
- package/src/atoms/Checkbox.ts +1 -1
- package/src/atoms/Input.ts +6 -0
- package/src/cli/add.ts +7 -1
- package/src/cli/diff.ts +7 -1
- package/src/cli/projectConfig.ts +71 -0
- package/src/console/AddCommand.ts +6 -1
- package/src/console/DiffCommand.ts +6 -1
- package/src/lib/children.ts +15 -7
- package/src/lib/icons.ts +28 -0
- package/src/lib/image.ts +13 -1
- package/src/molecules/Breadcrumb.ts +15 -4
- package/src/molecules/InputOTP.ts +88 -28
- package/src/molecules/Pagination.ts +50 -8
- package/src/molecules/PieceMap.ts +136 -0
- package/src/molecules/Resizable.ts +3 -1
- package/src/molecules/index.ts +17 -0
- package/src/organisms/Calendar.ts +16 -2
- package/src/organisms/Carousel.ts +17 -5
- package/src/organisms/Combobox.ts +18 -2
- package/src/organisms/Command.ts +66 -7
- package/src/organisms/DataTable.ts +95 -30
- package/src/organisms/DatePicker.ts +10 -2
- package/src/organisms/DateRangePicker.ts +4 -2
- package/src/organisms/Dialog.ts +17 -5
- package/src/organisms/Form.ts +21 -0
- package/src/organisms/Questionnaire.ts +10 -2
- package/src/organisms/Select.ts +140 -16
- package/src/organisms/Sheet.ts +5 -1
- package/src/organisms/Sidebar.ts +62 -23
- package/src/organisms/Sonner.ts +1366 -0
- package/src/organisms/Toaster.ts +38 -10
- package/src/organisms/Tooltip.ts +4 -0
- package/src/organisms/index.ts +30 -1
- package/src/primitives/dismissable.ts +16 -8
- package/src/primitives/floating.ts +40 -3
- package/src/primitives/menu.ts +2 -1
- package/src/primitives/modalSurface.ts +77 -40
- package/src/primitives/presence.ts +12 -9
- package/src/templates/SettingsLayout.ts +3 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Toaster — transient notifications.
|
|
3
3
|
*
|
|
4
|
+
* @deprecated shadcn has deprecated its `toast` component in favour of
|
|
5
|
+
* `sonner`, and so does nebula: use `organisms/Sonner.ts` (`nebula add
|
|
6
|
+
* sonner`), whose `Toaster` and `toast` follow sonner's API. This one stays
|
|
7
|
+
* until apps have moved.
|
|
8
|
+
*
|
|
4
9
|
* shadcn ships two: `sonner`, which wraps a third-party library, and `toast`,
|
|
5
10
|
* its own, built on Base UI. nebula keeps it in-house with zero dependencies
|
|
6
11
|
* and follows the SECOND — the shape is the same: one region mounted once near
|
|
@@ -86,6 +91,8 @@ export type ToastMessage = Child | Omit<ToastOptions, "id" | "variant">;
|
|
|
86
91
|
* Raise a toast. Returns its id, which `dismiss` accepts.
|
|
87
92
|
*
|
|
88
93
|
* Callable from anywhere — no component, no context, no handle.
|
|
94
|
+
*
|
|
95
|
+
* @deprecated Use `toast` from `organisms/Sonner.ts`, shadcn's current toaster.
|
|
89
96
|
*/
|
|
90
97
|
export declare const toast: {
|
|
91
98
|
show: typeof show;
|
|
@@ -122,6 +129,8 @@ export declare const toast: {
|
|
|
122
129
|
export interface ToasterProps {
|
|
123
130
|
/** Which corner. Default `"bottom-right"`. */
|
|
124
131
|
position?: "top-right" | "top-left" | "bottom-right" | "bottom-left";
|
|
132
|
+
/** The dismiss cross's accessible name, as sonner names the prop. */
|
|
133
|
+
closeButtonAriaLabel?: string;
|
|
125
134
|
class?: Reactive<string>;
|
|
126
135
|
}
|
|
127
136
|
/**
|
|
@@ -130,6 +139,8 @@ export interface ToasterProps {
|
|
|
130
139
|
* `data-nebula-live` marks it as exempt from the `aria-hidden` sweep a modal
|
|
131
140
|
* performs over its siblings — a toast raised while a dialog is open still has
|
|
132
141
|
* to be announced.
|
|
142
|
+
*
|
|
143
|
+
* @deprecated Use `Toaster` from `organisms/Sonner.ts`, shadcn's current toaster.
|
|
133
144
|
*/
|
|
134
145
|
export declare const Toaster: (props?: ToasterProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
135
146
|
export {};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Toaster — transient notifications.
|
|
3
3
|
*
|
|
4
|
+
* @deprecated shadcn has deprecated its `toast` component in favour of
|
|
5
|
+
* `sonner`, and so does nebula: use `organisms/Sonner.ts` (`nebula add
|
|
6
|
+
* sonner`), whose `Toaster` and `toast` follow sonner's API. This one stays
|
|
7
|
+
* until apps have moved.
|
|
8
|
+
*
|
|
4
9
|
* shadcn ships two: `sonner`, which wraps a third-party library, and `toast`,
|
|
5
10
|
* its own, built on Base UI. nebula keeps it in-house with zero dependencies
|
|
6
11
|
* and follows the SECOND — the shape is the same: one region mounted once near
|
|
@@ -35,7 +40,7 @@
|
|
|
35
40
|
* - Hovering pauses the timers. A toast that vanishes while being read is the
|
|
36
41
|
* single most common complaint about the pattern.
|
|
37
42
|
*/
|
|
38
|
-
import { component, html, signal } from "@c9up/aurora";
|
|
43
|
+
import { component, html, onMount, signal } from "@c9up/aurora";
|
|
39
44
|
import { cn } from "../lib/cn.js";
|
|
40
45
|
import { LoaderIcon, XIcon } from "../lib/icons.js";
|
|
41
46
|
import { fadeInOut } from "../lib/motion.js";
|
|
@@ -129,6 +134,10 @@ function show(options) {
|
|
|
129
134
|
else {
|
|
130
135
|
id = options.id;
|
|
131
136
|
}
|
|
137
|
+
// No document: the server, rendering one request in a process shared by
|
|
138
|
+
// every user. Kept here, the toast would reach the next user's markup.
|
|
139
|
+
if (typeof document === "undefined")
|
|
140
|
+
return id;
|
|
132
141
|
const variant = options.variant ?? "default";
|
|
133
142
|
const entry = { ...options, id, variant };
|
|
134
143
|
queue([...queue(), entry]);
|
|
@@ -171,16 +180,21 @@ function optionsOf(message) {
|
|
|
171
180
|
}
|
|
172
181
|
return { title: message };
|
|
173
182
|
}
|
|
183
|
+
/** A stage given as a function of the outcome, rather than as the message. */
|
|
184
|
+
function isMessageOf(message) {
|
|
185
|
+
return typeof message === "function";
|
|
186
|
+
}
|
|
174
187
|
function resolveMessage(message, value) {
|
|
175
|
-
if (
|
|
188
|
+
if (isMessageOf(message))
|
|
176
189
|
return optionsOf(message(value));
|
|
177
|
-
}
|
|
178
190
|
return optionsOf(message);
|
|
179
191
|
}
|
|
180
192
|
/**
|
|
181
193
|
* Raise a toast. Returns its id, which `dismiss` accepts.
|
|
182
194
|
*
|
|
183
195
|
* Callable from anywhere — no component, no context, no handle.
|
|
196
|
+
*
|
|
197
|
+
* @deprecated Use `toast` from `organisms/Sonner.ts`, shadcn's current toaster.
|
|
184
198
|
*/
|
|
185
199
|
export const toast = {
|
|
186
200
|
show,
|
|
@@ -257,9 +271,20 @@ const positionClasses = {
|
|
|
257
271
|
* `data-nebula-live` marks it as exempt from the `aria-hidden` sweep a modal
|
|
258
272
|
* performs over its siblings — a toast raised while a dialog is open still has
|
|
259
273
|
* to be announced.
|
|
274
|
+
*
|
|
275
|
+
* @deprecated Use `Toaster` from `organisms/Sonner.ts`, shadcn's current toaster.
|
|
260
276
|
*/
|
|
261
277
|
export const Toaster = component((props) => {
|
|
262
278
|
const position = props.position ?? "bottom-right";
|
|
279
|
+
const closeLabel = props.closeButtonAriaLabel ?? "Dismiss notification";
|
|
280
|
+
const render = (entry) => renderToast(entry, closeLabel);
|
|
281
|
+
// Empty until mounted, so the server's markup carries no toast and the
|
|
282
|
+
// browser adopts the same empty region before filling it.
|
|
283
|
+
const adopted = signal(false);
|
|
284
|
+
onMount(() => {
|
|
285
|
+
adopted(true);
|
|
286
|
+
});
|
|
287
|
+
const shown = () => (adopted() ? queue() : []);
|
|
263
288
|
return html `<div
|
|
264
289
|
data-slot="toaster"
|
|
265
290
|
data-nebula-live
|
|
@@ -268,18 +293,18 @@ export const Toaster = component((props) => {
|
|
|
268
293
|
@pointerleave="${() => resumeAll(1000)}"
|
|
269
294
|
>
|
|
270
295
|
<div role="status" aria-live="polite" aria-atomic="false" class="contents">
|
|
271
|
-
${() =>
|
|
296
|
+
${() => shown()
|
|
272
297
|
.filter((entry) => entry.variant !== "error")
|
|
273
|
-
.map(
|
|
298
|
+
.map(render)}
|
|
274
299
|
</div>
|
|
275
300
|
<div role="alert" aria-live="assertive" aria-atomic="false" class="contents">
|
|
276
|
-
${() =>
|
|
301
|
+
${() => shown()
|
|
277
302
|
.filter((entry) => entry.variant === "error")
|
|
278
|
-
.map(
|
|
303
|
+
.map(render)}
|
|
279
304
|
</div>
|
|
280
305
|
</div>`;
|
|
281
306
|
});
|
|
282
|
-
function renderToast(entry) {
|
|
307
|
+
function renderToast(entry, closeLabel) {
|
|
283
308
|
return html `<div
|
|
284
309
|
data-slot="toast"
|
|
285
310
|
data-variant="${entry.variant}"
|
|
@@ -307,7 +332,7 @@ function renderToast(entry) {
|
|
|
307
332
|
>${entry.action.label}</button>`}
|
|
308
333
|
<button
|
|
309
334
|
type="button"
|
|
310
|
-
aria-label="
|
|
335
|
+
aria-label="${closeLabel}"
|
|
311
336
|
class="opacity-60 transition-opacity hover:opacity-100"
|
|
312
337
|
@click="${() => dismiss(entry.id)}"
|
|
313
338
|
>${XIcon({ class: "size-4" })}</button>
|
|
@@ -99,6 +99,10 @@ export interface TooltipContentProps {
|
|
|
99
99
|
/** Which edge of the trigger to sit on. Flips when there is no room. */
|
|
100
100
|
side?: Side;
|
|
101
101
|
align?: Align;
|
|
102
|
+
/**
|
|
103
|
+
* Gap past the arrow, in px. `0`, as upstream: the arrow's own length is
|
|
104
|
+
* added by the positioner, the way Radix's popper adds it.
|
|
105
|
+
*/
|
|
102
106
|
sideOffset?: number;
|
|
103
107
|
class?: Reactive<string>;
|
|
104
108
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* restoration, hiding the page from assistive technology) exist once.
|
|
14
14
|
*/
|
|
15
15
|
export { AlertDialog, AlertDialogAction, type AlertDialogButtonProps, AlertDialogCancel, AlertDialogContent, type AlertDialogContentProps, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, type AlertDialogPortalProps, type AlertDialogProps, type AlertDialogSectionProps, AlertDialogTitle, AlertDialogTrigger, type AlertDialogTriggerProps, } from "./AlertDialog.js";
|
|
16
|
-
export { addDays, addMonths, Calendar, type CalendarProps, type DateRange, isSameDay, monthGrid, startOfDay, } from "./Calendar.js";
|
|
16
|
+
export { addDays, addMonths, Calendar, type CalendarLabels, type CalendarProps, type DateRange, isSameDay, monthGrid, startOfDay, } from "./Calendar.js";
|
|
17
17
|
export { Carousel, type CarouselButtonProps, CarouselContent, type CarouselContentProps, CarouselItem, type CarouselItemProps, CarouselNext, CarouselPrevious, type CarouselProps, } from "./Carousel.js";
|
|
18
18
|
export { Chart, type ChartDatum, type ChartProps, type ChartSeries, valueRange, } from "./Chart.js";
|
|
19
19
|
export { Combobox, type ComboboxOption, type ComboboxProps, } from "./Combobox.js";
|
|
@@ -21,7 +21,7 @@ export { Command, type CommandCandidate, CommandEmpty, type CommandEmptyProps, C
|
|
|
21
21
|
export { CommandDialog, type CommandDialogProps } from "./CommandDialog.js";
|
|
22
22
|
export { ContextMenu, ContextMenuCheckboxItem, type ContextMenuCheckboxItemProps, ContextMenuContent, type ContextMenuContentProps, ContextMenuGroup, type ContextMenuGroupProps, ContextMenuItem, type ContextMenuItemProps, ContextMenuLabel, type ContextMenuLabelProps, ContextMenuPortal, type ContextMenuPortalProps, type ContextMenuProps, ContextMenuRadioGroup, type ContextMenuRadioGroupProps, ContextMenuRadioItem, type ContextMenuRadioItemProps, ContextMenuSeparator, type ContextMenuSeparatorProps, ContextMenuShortcut, type ContextMenuShortcutProps, ContextMenuSub, ContextMenuSubContent, type ContextMenuSubContentProps, type ContextMenuSubProps, ContextMenuSubTrigger, type ContextMenuSubTriggerProps, ContextMenuTrigger, type ContextMenuTriggerProps, } from "./ContextMenu.js";
|
|
23
23
|
export { type Column, DataTable, type DataTableProps } from "./DataTable.js";
|
|
24
|
-
export { DatePicker, type DatePickerProps, toISODate } from "./DatePicker.js";
|
|
24
|
+
export { DatePicker, type DatePickerLabels, type DatePickerProps, toISODate, } from "./DatePicker.js";
|
|
25
25
|
export { DateRangePicker, type DateRangePickerProps, } from "./DateRangePicker.js";
|
|
26
26
|
export { Dialog, DialogClose, type DialogCloseProps, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, type DialogFooterProps, DialogHeader, DialogOverlay, type DialogOverlayProps, DialogPortal, type DialogPortalProps, type DialogProps, type DialogSectionProps, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerProps, dialogBackdropClasses, dialogPanelClasses, useDialog, } from "./Dialog.js";
|
|
27
27
|
export { Drawer, DrawerClose, type DrawerCloseProps, DrawerContent, type DrawerContentProps, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, type DrawerOverlayProps, type DrawerProps, type DrawerSectionProps, DrawerTitle, DrawerTrigger, type DrawerTriggerProps, } from "./Drawer.js";
|
|
@@ -36,5 +36,11 @@ export { type Answer, type Answers, type FreeformQuestion, isAnswered, type Mult
|
|
|
36
36
|
export { Select, SelectContent, type SelectContentProps, SelectGroup, type SelectGroupProps, SelectItem, type SelectItemProps, SelectLabel, type SelectLabelProps, type SelectProps, type SelectScrollButtonProps, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, type SelectSeparatorProps, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, selectContentClasses, selectTriggerClasses, } from "./Select.js";
|
|
37
37
|
export { Sheet, SheetClose, type SheetCloseProps, SheetContent, type SheetContentProps, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, type SheetOverlayProps, type SheetProps, type SheetSectionProps, SheetTitle, type SheetTitleProps, SheetTrigger, type SheetTriggerProps, } from "./Sheet.js";
|
|
38
38
|
export { Sidebar, type SidebarActionProps, type SidebarApi, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, type SidebarInputProps, SidebarInset, type SidebarInsetProps, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonVariants, SidebarMenuItem, SidebarMenuSkeleton, type SidebarMenuSkeletonProps, SidebarMenuSub, SidebarMenuSubButton, type SidebarMenuSubButtonProps, SidebarMenuSubItem, type SidebarProps, SidebarProvider, type SidebarProviderProps, SidebarRail, type SidebarRailProps, SidebarSeparator, type SidebarSeparatorProps, SidebarTrigger, type SidebarTriggerProps, sidebarCollapsed, sidebarMenuButtonVariants, sidebarState, useSidebar, } from "./Sidebar.js";
|
|
39
|
+
/**
|
|
40
|
+
* shadcn's `sonner`. Its file exports `Toaster` and `toast`, as upstream; the
|
|
41
|
+
* barrel renames them because the deprecated `Toaster` below still owns those
|
|
42
|
+
* names until apps have moved — `nebula add sonner` gives the file itself.
|
|
43
|
+
*/
|
|
44
|
+
export { type Action as SonnerAction, type ExternalToast, type Offset as SonnerOffset, type Position as SonnerPosition, type PromiseData as SonnerPromiseData, type PromiseExtendedResult as SonnerPromiseExtendedResult, type PromiseResult as SonnerPromiseResult, type ToastClassnames, Toaster as Sonner, type ToasterProps as SonnerProps, type ToastIcons, type ToastId as SonnerToastId, type ToastOptions as SonnerToastOptions, type ToastT, type ToastType, toast as sonnerToast, } from "./Sonner.js";
|
|
39
45
|
export { Toaster, type ToasterProps, type ToastId, type ToastMessage, type ToastOptions, type ToastVariant, toast, } from "./Toaster.js";
|
|
40
46
|
export { Tooltip, TooltipContent, type TooltipContentProps, type TooltipProps, TooltipProvider, type TooltipProviderProps, TooltipTrigger, type TooltipTriggerProps, } from "./Tooltip.js";
|
package/dist/organisms/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, Command
|
|
|
21
21
|
export { CommandDialog } from "./CommandDialog.js";
|
|
22
22
|
export { ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, } from "./ContextMenu.js";
|
|
23
23
|
export { DataTable } from "./DataTable.js";
|
|
24
|
-
export { DatePicker, toISODate } from "./DatePicker.js";
|
|
24
|
+
export { DatePicker, toISODate, } from "./DatePicker.js";
|
|
25
25
|
export { DateRangePicker, } from "./DateRangePicker.js";
|
|
26
26
|
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, dialogBackdropClasses, dialogPanelClasses, useDialog, } from "./Dialog.js";
|
|
27
27
|
export { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerTitle, DrawerTrigger, } from "./Drawer.js";
|
|
@@ -36,5 +36,11 @@ export { isAnswered, Questionnaire, } from "./Questionnaire.js";
|
|
|
36
36
|
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, selectContentClasses, selectTriggerClasses, } from "./Select.js";
|
|
37
37
|
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetTitle, SheetTrigger, } from "./Sheet.js";
|
|
38
38
|
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, sidebarCollapsed, sidebarMenuButtonVariants, sidebarState, useSidebar, } from "./Sidebar.js";
|
|
39
|
+
/**
|
|
40
|
+
* shadcn's `sonner`. Its file exports `Toaster` and `toast`, as upstream; the
|
|
41
|
+
* barrel renames them because the deprecated `Toaster` below still owns those
|
|
42
|
+
* names until apps have moved — `nebula add sonner` gives the file itself.
|
|
43
|
+
*/
|
|
44
|
+
export { Toaster as Sonner, toast as sonnerToast, } from "./Sonner.js";
|
|
39
45
|
export { Toaster, toast, } from "./Toaster.js";
|
|
40
46
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "./Tooltip.js";
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* So layers live in one stack and the rules are applied once, globally:
|
|
10
10
|
*
|
|
11
|
-
* - **Escape** reaches only the topmost layer that
|
|
12
|
-
*
|
|
11
|
+
* - **Escape** reaches only the topmost layer, skipping those that pass it
|
|
12
|
+
* through. One that refuses it dismisses nothing below.
|
|
13
13
|
* - **Pointer outside** walks the stack top-down and stops at the first layer
|
|
14
14
|
* the event landed inside. Layers above it close, layers below it stay. A
|
|
15
15
|
* click in a parent menu therefore closes the submenu and nothing else.
|
|
@@ -32,8 +32,15 @@ export interface DismissableOptions {
|
|
|
32
32
|
* immediately reopen on click.
|
|
33
33
|
*/
|
|
34
34
|
exclude?: () => ReadonlyArray<HTMLElement | null | undefined>;
|
|
35
|
-
/**
|
|
36
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Escape dismisses this layer when it is topmost. Default `true`.
|
|
37
|
+
*
|
|
38
|
+
* `false` refuses it: while this layer is on top, Escape dismisses nothing,
|
|
39
|
+
* as a Radix layer that prevents its `onEscapeKeyDown`. `"passthrough"`
|
|
40
|
+
* hands it to the layer below, for a surface that is part of the one under
|
|
41
|
+
* it — a submenu, whose Escape closes the whole menu.
|
|
42
|
+
*/
|
|
43
|
+
escapeKey?: boolean | "passthrough";
|
|
37
44
|
/** A pointer press outside dismisses. Default `true`. */
|
|
38
45
|
outsidePointer?: boolean;
|
|
39
46
|
/** Focus moving outside dismisses. Default `false`. */
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* So layers live in one stack and the rules are applied once, globally:
|
|
11
11
|
*
|
|
12
|
-
* - **Escape** reaches only the topmost layer that
|
|
13
|
-
*
|
|
12
|
+
* - **Escape** reaches only the topmost layer, skipping those that pass it
|
|
13
|
+
* through. One that refuses it dismisses nothing below.
|
|
14
14
|
* - **Pointer outside** walks the stack top-down and stops at the first layer
|
|
15
15
|
* the event landed inside. Layers above it close, layers below it stay. A
|
|
16
16
|
* click in a parent menu therefore closes the submenu and nothing else.
|
|
@@ -76,15 +76,17 @@ function stopListeningIfIdle() {
|
|
|
76
76
|
function onKeyDown(event) {
|
|
77
77
|
if (event.key !== "Escape")
|
|
78
78
|
return;
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
79
|
+
// The topmost layer decides, past the ones that pass Escape through. One
|
|
80
|
+
// that refuses it stops here: falling through would close the sheet behind
|
|
81
|
+
// a dialog that has to be answered.
|
|
82
82
|
for (let i = stack.length - 1; i >= 0; i -= 1) {
|
|
83
83
|
const layer = stack[i];
|
|
84
84
|
if (layer === undefined)
|
|
85
85
|
continue;
|
|
86
|
-
if (layer.escapeKey ===
|
|
86
|
+
if (layer.escapeKey === "passthrough")
|
|
87
87
|
continue;
|
|
88
|
+
if (layer.escapeKey === false)
|
|
89
|
+
return;
|
|
88
90
|
event.stopPropagation();
|
|
89
91
|
layer.onDismiss("escape");
|
|
90
92
|
return;
|
|
@@ -48,7 +48,11 @@ export interface PositionOptions {
|
|
|
48
48
|
flip?: boolean;
|
|
49
49
|
/** Slide along the cross axis to stay on screen. Default `true`. */
|
|
50
50
|
shift?: boolean;
|
|
51
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Arrow size in px; centres the arrow and keeps it off the corners. It is
|
|
53
|
+
* also added to `offset`, so the surface stands an arrow's length away
|
|
54
|
+
* from the anchor (the arrow is square, so its width is its height).
|
|
55
|
+
*/
|
|
52
56
|
arrowSize?: number;
|
|
53
57
|
/**
|
|
54
58
|
* Mirror the placement for a right-to-left writing direction.
|
|
@@ -35,7 +35,10 @@ const DEFAULT_PADDING = 8;
|
|
|
35
35
|
* make room on a side that should have been abandoned entirely.
|
|
36
36
|
*/
|
|
37
37
|
export function resolvePosition(anchor, floating, viewport, options = {}) {
|
|
38
|
-
|
|
38
|
+
// The arrow stands in the gap, so the gap starts past it — Radix's popper
|
|
39
|
+
// offsets by `sideOffset + arrowHeight` for the same reason. That is why
|
|
40
|
+
// shadcn's `sideOffset = 0` still leaves the arrow clear of the trigger.
|
|
41
|
+
const offset = (options.offset ?? DEFAULT_OFFSET) + (options.arrowSize ?? 0);
|
|
39
42
|
const padding = options.padding ?? DEFAULT_PADDING;
|
|
40
43
|
const requested = options.placement ?? "bottom";
|
|
41
44
|
const [physicalSide, physicalAlign] = splitPlacement(requested);
|
|
@@ -222,6 +225,29 @@ function clamp(value, min, max) {
|
|
|
222
225
|
return min;
|
|
223
226
|
return Math.min(Math.max(value, min), max);
|
|
224
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* The surface's size as laid out, before any transform.
|
|
230
|
+
*
|
|
231
|
+
* `getBoundingClientRect()` includes transforms, and every surface opens under
|
|
232
|
+
* `zoom-in-95`: measured on its first frame it is 5% short, and one placed on
|
|
233
|
+
* the `top` side lands that much too low, over the control that opened it. A
|
|
234
|
+
* transform never changes layout, so the `ResizeObserver` would not correct it
|
|
235
|
+
* afterwards either. floating-ui reads the same two sources in the same order
|
|
236
|
+
* (`getCssDimensions`): the computed size, which keeps sub-pixel widths, and
|
|
237
|
+
* the integer offset size when the two disagree.
|
|
238
|
+
*/
|
|
239
|
+
function layoutRect(element) {
|
|
240
|
+
const box = element.getBoundingClientRect();
|
|
241
|
+
const css = getComputedStyle(element);
|
|
242
|
+
let width = Number.parseFloat(css.width) || 0;
|
|
243
|
+
let height = Number.parseFloat(css.height) || 0;
|
|
244
|
+
if (Math.round(width) !== element.offsetWidth ||
|
|
245
|
+
Math.round(height) !== element.offsetHeight) {
|
|
246
|
+
width = element.offsetWidth;
|
|
247
|
+
height = element.offsetHeight;
|
|
248
|
+
}
|
|
249
|
+
return { x: box.x, y: box.y, width, height };
|
|
250
|
+
}
|
|
225
251
|
/**
|
|
226
252
|
* Position `floating` against `anchor` and keep it there.
|
|
227
253
|
*
|
|
@@ -240,7 +266,7 @@ export function autoPosition(anchor, floating, options = {}) {
|
|
|
240
266
|
if (options.matchWidth === true) {
|
|
241
267
|
floating.style.width = `${anchorRect.width}px`;
|
|
242
268
|
}
|
|
243
|
-
const floatingRect = floating
|
|
269
|
+
const floatingRect = layoutRect(floating);
|
|
244
270
|
const position = resolvePosition(anchorRect, floatingRect, { width: window.innerWidth, height: window.innerHeight }, { ...options, rtl });
|
|
245
271
|
floating.style.position = "fixed";
|
|
246
272
|
floating.style.left = `${Math.round(position.x)}px`;
|
|
@@ -260,6 +286,10 @@ export function autoPosition(anchor, floating, options = {}) {
|
|
|
260
286
|
floating.setAttribute("data-side", position.side);
|
|
261
287
|
floating.setAttribute("data-align", position.align);
|
|
262
288
|
const arrowEl = options.arrow?.();
|
|
289
|
+
// The arrow's `data-[side=…]` classes read the arrow's OWN attribute, so it
|
|
290
|
+
// is written here on every placement: without it none of them applied and
|
|
291
|
+
// the arrow sat in the text, and a flip has to turn it around.
|
|
292
|
+
arrowEl?.setAttribute("data-side", position.side);
|
|
263
293
|
if (arrowEl && position.arrow) {
|
|
264
294
|
const { x, y } = position.arrow;
|
|
265
295
|
arrowEl.style.position = "absolute";
|
package/dist/primitives/menu.js
CHANGED
|
@@ -245,7 +245,8 @@ export function wireMenu(panel, options) {
|
|
|
245
245
|
element: () => element,
|
|
246
246
|
exclude: () => [trigger, panel],
|
|
247
247
|
onDismiss: () => closeSubmenusFrom(0),
|
|
248
|
-
|
|
248
|
+
// Escape in a submenu closes the whole menu, as Radix's does.
|
|
249
|
+
escapeKey: "passthrough",
|
|
249
250
|
});
|
|
250
251
|
const inner = wireMenu(element, {
|
|
251
252
|
...options,
|
|
@@ -27,11 +27,39 @@ import { onExitFinished } from "./presence.js";
|
|
|
27
27
|
import { lockScroll } from "./scrollLock.js";
|
|
28
28
|
export function modalSurface(options) {
|
|
29
29
|
let live = null;
|
|
30
|
+
function arm(host, panel) {
|
|
31
|
+
const restoreSiblings = hideSiblingsFrom(host);
|
|
32
|
+
const trap = focusTrap(panel, {
|
|
33
|
+
initialFocus: () => options.initialFocus?.(panel) ?? null,
|
|
34
|
+
returnFocus: options.returnFocus,
|
|
35
|
+
});
|
|
36
|
+
const layer = dismissable({
|
|
37
|
+
element: () => panel,
|
|
38
|
+
onDismiss: options.onClose,
|
|
39
|
+
escapeKey: options.dismissOnEscape !== false,
|
|
40
|
+
outsidePointer: options.dismissOnOutside !== false,
|
|
41
|
+
outsideFocus: false,
|
|
42
|
+
});
|
|
43
|
+
return { layer, trap, restoreSiblings };
|
|
44
|
+
}
|
|
45
|
+
function disarm(current) {
|
|
46
|
+
const armed = current.armed;
|
|
47
|
+
if (armed === null)
|
|
48
|
+
return;
|
|
49
|
+
current.armed = null;
|
|
50
|
+
armed.layer.remove();
|
|
51
|
+
armed.trap.release();
|
|
52
|
+
armed.restoreSiblings();
|
|
53
|
+
}
|
|
30
54
|
function show() {
|
|
31
55
|
if (live !== null) {
|
|
56
|
+
// Reopened while its exit was still playing: the same node comes
|
|
57
|
+
// back, and it is a modal again, not a panel the page reads through.
|
|
32
58
|
live.cancelExit?.();
|
|
33
59
|
live.cancelExit = null;
|
|
34
60
|
live.element.setAttribute("data-state", "open");
|
|
61
|
+
if (live.armed === null)
|
|
62
|
+
live.armed = arm(live.mount.host, live.panel);
|
|
35
63
|
return;
|
|
36
64
|
}
|
|
37
65
|
const mount = portal(options.content());
|
|
@@ -43,36 +71,21 @@ export function modalSurface(options) {
|
|
|
43
71
|
element.setAttribute("data-state", "open");
|
|
44
72
|
const panel = options.panel?.(element) ?? element;
|
|
45
73
|
const unlock = options.lockScroll === false ? () => { } : lockScroll();
|
|
46
|
-
const restoreSiblings = hideSiblingsFrom(mount.host);
|
|
47
|
-
const trap = focusTrap(panel, {
|
|
48
|
-
initialFocus: () => options.initialFocus?.(panel) ?? null,
|
|
49
|
-
returnFocus: options.returnFocus,
|
|
50
|
-
});
|
|
51
|
-
const layer = dismissable({
|
|
52
|
-
element: () => panel,
|
|
53
|
-
onDismiss: options.onClose,
|
|
54
|
-
escapeKey: options.dismissOnEscape !== false,
|
|
55
|
-
outsidePointer: options.dismissOnOutside !== false,
|
|
56
|
-
outsideFocus: false,
|
|
57
|
-
});
|
|
58
74
|
live = {
|
|
59
75
|
mount,
|
|
60
76
|
element,
|
|
61
|
-
|
|
62
|
-
trap,
|
|
77
|
+
panel,
|
|
63
78
|
unlock,
|
|
64
|
-
|
|
79
|
+
armed: arm(mount.host, panel),
|
|
65
80
|
cancelExit: null,
|
|
66
81
|
};
|
|
67
82
|
options.onOpened?.(panel);
|
|
68
83
|
}
|
|
69
84
|
function hide() {
|
|
70
85
|
const current = live;
|
|
71
|
-
if (current === null)
|
|
86
|
+
if (current === null || current.armed === null)
|
|
72
87
|
return;
|
|
73
|
-
current
|
|
74
|
-
current.trap.release();
|
|
75
|
-
current.restoreSiblings();
|
|
88
|
+
disarm(current);
|
|
76
89
|
current.element.setAttribute("data-state", "closed");
|
|
77
90
|
options.onClosed?.();
|
|
78
91
|
// Scroll stays locked through the exit animation. Releasing it first
|
|
@@ -90,9 +103,7 @@ export function modalSurface(options) {
|
|
|
90
103
|
return;
|
|
91
104
|
live = null;
|
|
92
105
|
current.cancelExit?.();
|
|
93
|
-
current
|
|
94
|
-
current.trap.release();
|
|
95
|
-
current.restoreSiblings();
|
|
106
|
+
disarm(current);
|
|
96
107
|
current.unlock();
|
|
97
108
|
current.mount.close();
|
|
98
109
|
}
|
|
@@ -109,38 +120,61 @@ export function modalSurface(options) {
|
|
|
109
120
|
};
|
|
110
121
|
});
|
|
111
122
|
}
|
|
123
|
+
/** How many open modals hide each node; it is shown again at zero. */
|
|
124
|
+
const hiddenBy = new WeakMap();
|
|
125
|
+
/** Nodes that were already `aria-hidden` when the first modal reached them. */
|
|
126
|
+
const hiddenBefore = new WeakSet();
|
|
112
127
|
/**
|
|
113
128
|
* Hide everything except the overlay from assistive technology.
|
|
114
129
|
*
|
|
115
|
-
* Marks each sibling of the portal host
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
130
|
+
* Marks each sibling of the portal host. Counted per node, as the
|
|
131
|
+
* `aria-hidden` package Radix modals use does: stacked modals hide the same
|
|
132
|
+
* page, and they close in any order — a confirm that closes its parent sheet
|
|
133
|
+
* before itself is enough — so a node is shown again only when the last
|
|
134
|
+
* modal hiding it lets go. A node the application had hidden itself is never
|
|
135
|
+
* touched.
|
|
119
136
|
*
|
|
120
|
-
* Only siblings of the host, not the whole page: a second modal
|
|
121
|
-
*
|
|
122
|
-
*
|
|
137
|
+
* Only siblings of the host, not the whole page: a second modal hides the
|
|
138
|
+
* first one's host along with the page, and shows it again when it closes.
|
|
139
|
+
*
|
|
140
|
+
* The returned release runs once, however many paths reach it.
|
|
123
141
|
*/
|
|
124
142
|
function hideSiblingsFrom(host) {
|
|
125
143
|
const parent = host.parentElement;
|
|
126
144
|
if (parent === null)
|
|
127
145
|
return () => { };
|
|
128
|
-
const
|
|
146
|
+
const hidden = [];
|
|
129
147
|
for (const sibling of parent.children) {
|
|
130
148
|
if (sibling === host)
|
|
131
149
|
continue;
|
|
132
150
|
// A live region announcing outside the dialog (a toast) is deliberate.
|
|
133
151
|
if (sibling.hasAttribute("data-nebula-live"))
|
|
134
152
|
continue;
|
|
135
|
-
|
|
136
|
-
|
|
153
|
+
const count = (hiddenBy.get(sibling) ?? 0) + 1;
|
|
154
|
+
hiddenBy.set(sibling, count);
|
|
155
|
+
hidden.push(sibling);
|
|
156
|
+
const attribute = sibling.getAttribute("aria-hidden");
|
|
157
|
+
const alreadyHidden = attribute !== null && attribute !== "false";
|
|
158
|
+
if (count === 1 && alreadyHidden)
|
|
159
|
+
hiddenBefore.add(sibling);
|
|
160
|
+
if (!alreadyHidden)
|
|
161
|
+
sibling.setAttribute("aria-hidden", "true");
|
|
137
162
|
}
|
|
163
|
+
let released = false;
|
|
138
164
|
return () => {
|
|
139
|
-
|
|
140
|
-
|
|
165
|
+
if (released)
|
|
166
|
+
return;
|
|
167
|
+
released = true;
|
|
168
|
+
for (const element of hidden) {
|
|
169
|
+
const count = (hiddenBy.get(element) ?? 1) - 1;
|
|
170
|
+
if (count > 0) {
|
|
171
|
+
hiddenBy.set(element, count);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
hiddenBy.delete(element);
|
|
175
|
+
if (!hiddenBefore.has(element))
|
|
141
176
|
element.removeAttribute("aria-hidden");
|
|
142
|
-
|
|
143
|
-
element.setAttribute("aria-hidden", previous);
|
|
177
|
+
hiddenBefore.delete(element);
|
|
144
178
|
}
|
|
145
179
|
};
|
|
146
180
|
}
|
|
@@ -372,15 +372,18 @@ function containsKeyframes(rules, name) {
|
|
|
372
372
|
return true;
|
|
373
373
|
// `cssRules` on a group rule (media, supports, layer); absent on others.
|
|
374
374
|
const nested = Reflect.get(rule, "cssRules");
|
|
375
|
-
if (nested
|
|
376
|
-
typeof nested === "object" &&
|
|
377
|
-
typeof Reflect.get(nested, "length") === "number" &&
|
|
378
|
-
containsKeyframes(nested, name)) {
|
|
375
|
+
if (isRuleList(nested) && containsKeyframes(nested, name))
|
|
379
376
|
return true;
|
|
380
|
-
}
|
|
381
377
|
}
|
|
382
378
|
return false;
|
|
383
379
|
}
|
|
380
|
+
/** A `CSSRuleList`, read structurally: not every DOM exposes the class. */
|
|
381
|
+
function isRuleList(value) {
|
|
382
|
+
return (typeof value === "object" &&
|
|
383
|
+
value !== null &&
|
|
384
|
+
typeof Reflect.get(value, "length") === "number" &&
|
|
385
|
+
typeof Reflect.get(value, "item") === "function");
|
|
386
|
+
}
|
|
384
387
|
/**
|
|
385
388
|
* Are all the animations this element declares actually defined?
|
|
386
389
|
*
|
|
@@ -21,6 +21,8 @@ export interface SettingsLayoutProps {
|
|
|
21
21
|
title: Child;
|
|
22
22
|
description?: Child;
|
|
23
23
|
sections: readonly SettingsSection[];
|
|
24
|
+
/** The section list's accessible name. Default `"Settings sections"`. */
|
|
25
|
+
navLabel?: string;
|
|
24
26
|
children?: Slot;
|
|
25
27
|
class?: Reactive<string>;
|
|
26
28
|
}
|
|
@@ -27,7 +27,7 @@ export const SettingsLayout = component((props) => {
|
|
|
27
27
|
<div class="flex flex-col gap-8 md:flex-row md:gap-12">
|
|
28
28
|
<nav
|
|
29
29
|
data-slot="settings-nav"
|
|
30
|
-
aria-label="Settings sections"
|
|
30
|
+
aria-label="${props.navLabel ?? "Settings sections"}"
|
|
31
31
|
class="flex gap-2 overflow-x-auto md:w-48 md:shrink-0 md:flex-col md:overflow-visible"
|
|
32
32
|
>
|
|
33
33
|
${props.sections.map((section) => html `<a
|