@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
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sonner — toasts, the way shadcn ships them now.
|
|
3
|
+
*
|
|
4
|
+
* shadcn deprecated its own `toast` component in favour of `sonner`, a thin
|
|
5
|
+
* wrapper over Emil Kowalski's library of the same name. This is that pair in
|
|
6
|
+
* one file, ported to aurora without the library: a `Toaster` region mounted
|
|
7
|
+
* once near the root, and a `toast` function callable from anywhere in the
|
|
8
|
+
* browser — a route handler's error branch included — with no reference to
|
|
9
|
+
* the region. On the server a toast is not kept: the region renders empty
|
|
10
|
+
* there, and page code that raises one runs again in the browser.
|
|
11
|
+
*
|
|
12
|
+
* Toaster({ richColors: true, closeButton: true })
|
|
13
|
+
*
|
|
14
|
+
* toast('Event created', { description: 'Sunday, 9:00' })
|
|
15
|
+
* toast.error('Could not save', { action: { label: 'Retry', onClick: save } })
|
|
16
|
+
* toast.promise(save(form), {
|
|
17
|
+
* loading: 'Saving…',
|
|
18
|
+
* success: (saved) => `Saved ${saved.name}`,
|
|
19
|
+
* error: 'Could not save',
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* The API is sonner's, read from its published source: the same `toast`
|
|
23
|
+
* methods, the same options, the same Toaster props, the same defaults (four
|
|
24
|
+
* seconds on screen, three toasts visible, a 14px gap, 356px wide, `Alt+T` to
|
|
25
|
+
* reach the region). The look is shadcn's: the surface takes the popover
|
|
26
|
+
* colours, and the icons are the lucide set shadcn hands to sonner. The stack
|
|
27
|
+
* is sonner's too — toasts pile up behind the newest one, scaled down, and fan
|
|
28
|
+
* out while the pointer is over them, which also pauses their timers.
|
|
29
|
+
*
|
|
30
|
+
* NAMED DEVIATIONS, all deliberate:
|
|
31
|
+
*
|
|
32
|
+
* - **Announcements go through two hidden live regions**, mounted empty with
|
|
33
|
+
* the region: `polite` for every toast, `assertive` for an error. sonner
|
|
34
|
+
* makes its whole list one polite region, so an error waits its turn behind
|
|
35
|
+
* whatever is being read, and a list inserted with content in it is not
|
|
36
|
+
* announced by most screen readers at all.
|
|
37
|
+
* - **The layout is computed, not styled.** sonner drives its stack from a
|
|
38
|
+
* stylesheet it injects, reading custom properties it sets per toast. Here
|
|
39
|
+
* the same rules produce an inline `transform`, `opacity` and `height`, so
|
|
40
|
+
* the stack works under every adapter — nothing depends on a stylesheet that
|
|
41
|
+
* might not be there, or on compound selectors an engine might not emit.
|
|
42
|
+
* - **`class`, `descriptionClass`**, where React says `className`. Every
|
|
43
|
+
* nebula component spells it that way.
|
|
44
|
+
* - **`toast.promise` returns `{ id, unwrap }`**, not the id with `unwrap`
|
|
45
|
+
* grafted on: a number or a string cannot carry a method without being
|
|
46
|
+
* boxed into something that is no longer equal to the id.
|
|
47
|
+
* - **No swipe to dismiss, no `getHistory`, no focus hand-back on blur.**
|
|
48
|
+
* The close button, the timer and `Alt+T` remain; an app that needs a swipe
|
|
49
|
+
* gesture has the `data-*` attributes sonner's own CSS reads.
|
|
50
|
+
* - `action` and `cancel` take `{ label, onClick }` only, not an arbitrary
|
|
51
|
+
* element; `toast.custom` is the way to render something of your own.
|
|
52
|
+
*/
|
|
53
|
+
import type { Child, Slot } from "../lib/children.js";
|
|
54
|
+
import { type Reactive } from "../lib/props.js";
|
|
55
|
+
/** `undefined` is a plain `toast()`: no icon, no rich colour. */
|
|
56
|
+
export type ToastType = "default" | "success" | "info" | "warning" | "error" | "loading";
|
|
57
|
+
export type Position = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "top-center" | "bottom-center";
|
|
58
|
+
/** A number when `toast` minted it, the caller's own when one was given. */
|
|
59
|
+
export type ToastId = number | string;
|
|
60
|
+
export interface Action {
|
|
61
|
+
label: Child;
|
|
62
|
+
onClick: (event: MouseEvent) => void;
|
|
63
|
+
}
|
|
64
|
+
/** Extra classes per part, merged after nebula's own. */
|
|
65
|
+
export interface ToastClassnames {
|
|
66
|
+
toast?: string;
|
|
67
|
+
title?: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
loader?: string;
|
|
70
|
+
closeButton?: string;
|
|
71
|
+
cancelButton?: string;
|
|
72
|
+
actionButton?: string;
|
|
73
|
+
success?: string;
|
|
74
|
+
error?: string;
|
|
75
|
+
info?: string;
|
|
76
|
+
warning?: string;
|
|
77
|
+
loading?: string;
|
|
78
|
+
default?: string;
|
|
79
|
+
content?: string;
|
|
80
|
+
icon?: string;
|
|
81
|
+
}
|
|
82
|
+
/** Replaces shadcn's icons. `null` for a type shows none. */
|
|
83
|
+
export interface ToastIcons {
|
|
84
|
+
success?: Child;
|
|
85
|
+
info?: Child;
|
|
86
|
+
warning?: Child;
|
|
87
|
+
error?: Child;
|
|
88
|
+
loading?: Child;
|
|
89
|
+
close?: Child;
|
|
90
|
+
}
|
|
91
|
+
/** What every `toast` call takes after its message. */
|
|
92
|
+
export interface ExternalToast {
|
|
93
|
+
/**
|
|
94
|
+
* A stable id. A toast raised under an id already on screen UPDATES it —
|
|
95
|
+
* which is how a loading toast becomes its outcome, and how "you are
|
|
96
|
+
* offline", raised on every failed request, stays one toast.
|
|
97
|
+
*/
|
|
98
|
+
id?: ToastId;
|
|
99
|
+
/** Shown only by the `Toaster` whose `id` is this. */
|
|
100
|
+
toasterId?: string;
|
|
101
|
+
description?: Slot;
|
|
102
|
+
/** Replaces the type's icon; `null` shows none. */
|
|
103
|
+
icon?: Child;
|
|
104
|
+
richColors?: boolean;
|
|
105
|
+
invert?: boolean;
|
|
106
|
+
closeButton?: boolean;
|
|
107
|
+
/** `false` keeps the close button and the timer from removing it. */
|
|
108
|
+
dismissible?: boolean;
|
|
109
|
+
/** Milliseconds on screen. `Infinity` keeps it until dismissed. */
|
|
110
|
+
duration?: number;
|
|
111
|
+
action?: Action;
|
|
112
|
+
cancel?: Action;
|
|
113
|
+
/** Called when it is dismissed: the close button, `cancel`, `toast.dismiss`. */
|
|
114
|
+
onDismiss?: (toast: ToastT) => void;
|
|
115
|
+
/** Called when its time runs out. */
|
|
116
|
+
onAutoClose?: (toast: ToastT) => void;
|
|
117
|
+
class?: string;
|
|
118
|
+
descriptionClass?: string;
|
|
119
|
+
classNames?: ToastClassnames;
|
|
120
|
+
/** Drops nebula's look, keeping only the layout. */
|
|
121
|
+
unstyled?: boolean;
|
|
122
|
+
/** A corner of its own, other than the Toaster's. */
|
|
123
|
+
position?: Position;
|
|
124
|
+
testId?: string;
|
|
125
|
+
}
|
|
126
|
+
/** A toast as the region holds it. */
|
|
127
|
+
export interface ToastT extends ExternalToast {
|
|
128
|
+
readonly id: ToastId;
|
|
129
|
+
title?: Slot;
|
|
130
|
+
type?: ToastType;
|
|
131
|
+
/** What `toast.custom` rendered, in place of the title and the styling. */
|
|
132
|
+
custom?: Child;
|
|
133
|
+
/** Raised by `toast.promise`. */
|
|
134
|
+
promise?: boolean;
|
|
135
|
+
}
|
|
136
|
+
/** A stage of `toast.promise` that says more than its message. */
|
|
137
|
+
export interface PromiseExtendedResult extends ExternalToast {
|
|
138
|
+
message: Child;
|
|
139
|
+
}
|
|
140
|
+
type StageValue = Child | PromiseExtendedResult;
|
|
141
|
+
/** A stage of `toast.promise`: its message, or a function of the outcome. */
|
|
142
|
+
export type PromiseResult<Value> = StageValue | ((value: Value) => StageValue | Promise<StageValue>);
|
|
143
|
+
export interface PromiseData<Value> extends Omit<ExternalToast, "description"> {
|
|
144
|
+
loading?: Child;
|
|
145
|
+
success?: PromiseResult<Value>;
|
|
146
|
+
error?: PromiseResult<unknown>;
|
|
147
|
+
description?: Child | ((value: unknown) => Child | Promise<Child>);
|
|
148
|
+
finally?: () => void | Promise<void>;
|
|
149
|
+
}
|
|
150
|
+
declare function dismiss(id?: ToastId): ToastId | undefined;
|
|
151
|
+
declare function promise<Value>(work: Promise<Value> | (() => Promise<Value>), data?: PromiseData<Value>): {
|
|
152
|
+
id: ToastId | undefined;
|
|
153
|
+
unwrap: () => Promise<Value>;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Raise a toast. Returns its id, which `toast.dismiss` takes.
|
|
157
|
+
*
|
|
158
|
+
* Callable from anywhere — no component, no context, no handle.
|
|
159
|
+
*/
|
|
160
|
+
export declare const toast: ((message: Slot, data?: ExternalToast) => ToastId) & {
|
|
161
|
+
/** A plain toast; on an existing id, resets its type. */
|
|
162
|
+
message: (message: Slot, data?: ExternalToast) => ToastId;
|
|
163
|
+
success: (message: Slot, data?: ExternalToast) => ToastId;
|
|
164
|
+
info: (message: Slot, data?: ExternalToast) => ToastId;
|
|
165
|
+
warning: (message: Slot, data?: ExternalToast) => ToastId;
|
|
166
|
+
error: (message: Slot, data?: ExternalToast) => ToastId;
|
|
167
|
+
/** Stays until it is updated or dismissed. */
|
|
168
|
+
loading: (message: Slot, data?: ExternalToast) => ToastId;
|
|
169
|
+
/** Render your own content, unstyled; `render` gets the toast's id. */
|
|
170
|
+
custom(render: (id: ToastId) => Child, data?: ExternalToast): ToastId;
|
|
171
|
+
/**
|
|
172
|
+
* One toast for the whole life of an async call: loading, then its outcome.
|
|
173
|
+
*
|
|
174
|
+
* A rejection is reported, not swallowed: `unwrap()` hands it back to the
|
|
175
|
+
* caller's own error path.
|
|
176
|
+
*/
|
|
177
|
+
promise: typeof promise;
|
|
178
|
+
/** Dismiss one toast, or every toast when no id is given. */
|
|
179
|
+
dismiss: typeof dismiss;
|
|
180
|
+
/** The toasts on screen, newest first. */
|
|
181
|
+
getToasts(): ToastT[];
|
|
182
|
+
};
|
|
183
|
+
export type Offset = {
|
|
184
|
+
top?: string | number;
|
|
185
|
+
right?: string | number;
|
|
186
|
+
bottom?: string | number;
|
|
187
|
+
left?: string | number;
|
|
188
|
+
} | string | number;
|
|
189
|
+
/** Defaults for every toast this region shows. */
|
|
190
|
+
export interface ToastOptions {
|
|
191
|
+
class?: string;
|
|
192
|
+
closeButton?: boolean;
|
|
193
|
+
descriptionClass?: string;
|
|
194
|
+
duration?: number;
|
|
195
|
+
unstyled?: boolean;
|
|
196
|
+
classNames?: ToastClassnames;
|
|
197
|
+
/** The close cross's accessible name. Default `"Close toast"`. */
|
|
198
|
+
closeButtonAriaLabel?: string;
|
|
199
|
+
}
|
|
200
|
+
export interface ToasterProps {
|
|
201
|
+
/** Shows only the toasts raised with this `toasterId`. */
|
|
202
|
+
id?: string;
|
|
203
|
+
invert?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* `"system"` follows the app's `dark` variant, which is what shadcn hands
|
|
206
|
+
* sonner from `next-themes`. Default `"system"`.
|
|
207
|
+
*/
|
|
208
|
+
theme?: "light" | "dark" | "system";
|
|
209
|
+
/** Default `"bottom-right"`. */
|
|
210
|
+
position?: Position;
|
|
211
|
+
/** `KeyboardEvent` keys and codes that reach the region. Default Alt+T. */
|
|
212
|
+
hotkey?: string[];
|
|
213
|
+
richColors?: boolean;
|
|
214
|
+
/** Keep the stack fanned out instead of piled up. */
|
|
215
|
+
expand?: boolean;
|
|
216
|
+
/** Milliseconds on screen. Default 4000. */
|
|
217
|
+
duration?: number;
|
|
218
|
+
/** Space between fanned-out toasts. Default 14. */
|
|
219
|
+
gap?: number;
|
|
220
|
+
/** How many show at once. Default 3. */
|
|
221
|
+
visibleToasts?: number;
|
|
222
|
+
closeButton?: boolean;
|
|
223
|
+
toastOptions?: ToastOptions;
|
|
224
|
+
class?: Reactive<string>;
|
|
225
|
+
/** From the viewport's edges. Default `24px`. */
|
|
226
|
+
offset?: Offset;
|
|
227
|
+
/** The same, at 600px wide and under. Default `16px`. */
|
|
228
|
+
mobileOffset?: Offset;
|
|
229
|
+
dir?: "rtl" | "ltr" | "auto";
|
|
230
|
+
icons?: ToastIcons;
|
|
231
|
+
/** Replaces the region's whole accessible name. */
|
|
232
|
+
customAriaLabel?: string;
|
|
233
|
+
/** The region's name, before the hotkey. Default `"Notifications"`. */
|
|
234
|
+
containerAriaLabel?: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Mount once, near the root of the app.
|
|
238
|
+
*
|
|
239
|
+
* `data-nebula-live` exempts it from the `aria-hidden` sweep a modal performs
|
|
240
|
+
* over its siblings: a toast raised while a dialog is open is still announced.
|
|
241
|
+
*/
|
|
242
|
+
export declare const Toaster: (props?: ToasterProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
243
|
+
export {};
|