@pontive/pontkit-core 1.39.0 → 1.41.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.
Files changed (66) hide show
  1. package/catalog.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/index.js +1846 -1289
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +17059 -12690
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/pont2/core/context-root.d.ts +1 -0
  8. package/dist/pont2/core/events.d.ts +1 -1
  9. package/dist/pont2/core/format.d.ts +46 -0
  10. package/dist/pont2/core/icons.d.ts +11 -0
  11. package/dist/pont2/core/index.d.ts +2 -0
  12. package/dist/pont2/core/messages.d.ts +128 -2
  13. package/dist/pont2/core/popup/index.d.ts +1 -0
  14. package/dist/pont2/core/popup/modal.d.ts +56 -0
  15. package/dist/pont2/core/popup/popup-content.d.ts +7 -0
  16. package/dist/pont2/core/popup/story-helpers.d.ts +6 -0
  17. package/dist/pont2/custom-elements.json +55405 -24958
  18. package/dist/pont2/index.d.ts +7 -0
  19. package/dist/pont2/index.mjs +6600 -2376
  20. package/dist/pont2/index.mjs.map +1 -1
  21. package/dist/pont2/kit/account-menu/account-menu.d.ts +115 -0
  22. package/dist/pont2/kit/account-settings/account-settings.d.ts +157 -0
  23. package/dist/pont2/kit/account-settings/profile.d.ts +74 -0
  24. package/dist/pont2/kit/badge-selector/badge-selector.d.ts +65 -0
  25. package/dist/pont2/kit/consent/consent.d.ts +3 -2
  26. package/dist/pont2/kit/data-table/data-table.d.ts +120 -0
  27. package/dist/pont2/kit/data-table/rows.d.ts +25 -0
  28. package/dist/pont2/kit/flow-widget/flow-widget.d.ts +21 -8
  29. package/dist/pont2/kit/index.d.ts +11 -0
  30. package/dist/pont2/kit/layout/layout.d.ts +7 -0
  31. package/dist/pont2/kit/member-management/errors.d.ts +60 -0
  32. package/dist/pont2/kit/member-management/member-management.d.ts +237 -0
  33. package/dist/pont2/kit/member-management/roles.d.ts +42 -0
  34. package/dist/pont2/kit/multi-email-input/emails.d.ts +19 -0
  35. package/dist/pont2/kit/multi-email-input/multi-email-input.d.ts +78 -0
  36. package/dist/pont2/kit/multi-select-filter/multi-select-filter.d.ts +53 -0
  37. package/dist/pont2/kit/organization-switcher/organization-switcher.d.ts +111 -0
  38. package/dist/pont2/kit/pagination/pagination.d.ts +61 -0
  39. package/dist/pont2/kit/pagination/range.d.ts +17 -0
  40. package/dist/pont2/kit/provider/account-client.d.ts +355 -0
  41. package/dist/pont2/kit/provider/account-controller.d.ts +47 -0
  42. package/dist/pont2/kit/provider/account-user.d.ts +16 -0
  43. package/dist/pont2/kit/provider/coexistence.d.ts +19 -0
  44. package/dist/pont2/kit/provider/contexts.d.ts +46 -0
  45. package/dist/pont2/kit/provider/provider.d.ts +219 -0
  46. package/dist/pont2/kit/provider/redirect.d.ts +122 -0
  47. package/dist/pont2/kit/provider/runtime-config.d.ts +24 -0
  48. package/dist/pont2/kit/provider/sdk.d.ts +100 -0
  49. package/dist/pont2/kit/provider/signed-in.d.ts +81 -0
  50. package/dist/pont2/kit/provider/widget-messages.d.ts +35 -0
  51. package/dist/pont2/primitives/alert-dialog/alert-dialog.d.ts +132 -0
  52. package/dist/pont2/primitives/combobox/combobox.d.ts +82 -14
  53. package/dist/pont2/primitives/dialog/dialog.d.ts +195 -0
  54. package/dist/pont2/primitives/drawer/drawer.d.ts +112 -0
  55. package/dist/pont2/primitives/hover-card/hover-card.d.ts +83 -0
  56. package/dist/pont2/primitives/pagination/pagination.d.ts +120 -0
  57. package/dist/pont2/primitives/sheet/sheet.d.ts +92 -0
  58. package/dist/pont2/primitives/sonner/sonner.d.ts +86 -0
  59. package/dist/pont2/primitives/sonner/toast-store.d.ts +81 -0
  60. package/dist/pont2/styles.css +2489 -760
  61. package/dist/pont2/theme/tokens.json.d.ts +700 -1
  62. package/dist/pont2/theme-golden.json +45 -45
  63. package/dist/pont2/theme.mjs +119 -119
  64. package/dist/pont2/tokens.json +700 -1
  65. package/dist/styles.css +2475 -746
  66. package/package.json +2 -2
@@ -0,0 +1,83 @@
1
+ import { PropertyDeclarations } from 'lit';
2
+ import { PopupContent } from '../../core/popup/popup-content';
3
+ import { PopupRoot, PopupTrigger } from '../../core/popup/popup-root';
4
+ type Reason = "trigger-hover" | "trigger-focus" | "focus-out";
5
+ /**
6
+ * # HoverCard (Base UI Preview Card)
7
+ *
8
+ * shadcn: `<HoverCard>` = Base UI `PreviewCard.Root` (renders nothing) >
9
+ * `<HoverCardTrigger>` (an `<a>`) + `<HoverCardContent>` (Portal > Positioner
10
+ * > Popup).
11
+ *
12
+ * ```html
13
+ * <pont2-prim-hover-card>
14
+ * <pont2-prim-hover-card-trigger><a href="https://github.com/nextjs" data-pont2-button data-variant="link">@nextjs</a></pont2-prim-hover-card-trigger>
15
+ * <pont2-prim-hover-card-content>The React Framework – created and maintained by @vercel.</pont2-prim-hover-card-content>
16
+ * </pont2-prim-hover-card>
17
+ * ```
18
+ *
19
+ * A preview of what the trigger points at, for sighted pointer users: it
20
+ * opens after `delay` when the pointer rests on the trigger (or the trigger
21
+ * gets keyboard focus), stays open while the pointer is over the trigger or
22
+ * the card, and closes `close-delay` after it leaves both, on Escape, on a
23
+ * press outside, or when focus leaves. Like Base UI's, it is not announced
24
+ * and takes no focus: put nothing in it that is only there.
25
+ *
26
+ * @tag pont2-prim-hover-card
27
+ * @attr delay - ms before opening (default 600, Base UI's)
28
+ * @attr close-delay - ms before closing (default 300)
29
+ * @fires pont2-open-change - cancelable `{ open, reason }`
30
+ */
31
+ export declare class HoverCard extends PopupRoot {
32
+ static identity: string;
33
+ static properties: PropertyDeclarations;
34
+ delay: number;
35
+ closeDelay: number;
36
+ private timer;
37
+ constructor();
38
+ get triggerElement(): HTMLElement | null;
39
+ get contentElement(): HoverCardContent | null;
40
+ protected get popupKind(): "true";
41
+ /** A preview card is not a popup the trigger "has": no aria-haspopup / aria-expanded (Base UI). */
42
+ wire(): void;
43
+ /** Open or close after the delay; a later call replaces a pending one. */
44
+ schedule(open: boolean, reason: Reason): void;
45
+ /** Keep the current state (the pointer moved between trigger and card). */
46
+ cancelScheduled(): void;
47
+ disconnectedCallback(): void;
48
+ protected afterClose(): void;
49
+ }
50
+ /**
51
+ * Tier 3 enhancer around the native `<a>` (Base UI renders a link) or `<button>`.
52
+ *
53
+ * @tag pont2-prim-hover-card-trigger
54
+ */
55
+ export declare class HoverCardTrigger extends PopupTrigger {
56
+ static nativeSelector: string;
57
+ static rootTag: string;
58
+ static controlSlot: string;
59
+ constructor();
60
+ protected apply(control: HTMLButtonElement): void;
61
+ /** Activating the trigger follows the link; it never toggles the card (Base UI). */
62
+ protected onClick(): void;
63
+ }
64
+ /**
65
+ * The card. `side="bottom"`, `side-offset` 4, `align="center"`, `align-offset` 4 (shadcn).
66
+ *
67
+ * @tag pont2-prim-hover-card-content
68
+ * @cssprop --pont2-hover-card-bg, --pont2-hover-card-fg, --pont2-hover-card-border-color, --pont2-hover-card-radius, --pont2-hover-card-shadow - see docs/11-tokens.md
69
+ * @cssprop --pont2-hover-card-width, --pont2-hover-card-padding-x, --pont2-hover-card-padding-y - sizes (defaults 16rem, 1rem, 1rem)
70
+ */
71
+ export declare class HoverCardContent extends PopupContent {
72
+ static identity: string;
73
+ static slotName: string;
74
+ constructor();
75
+ }
76
+ declare global {
77
+ interface HTMLElementTagNameMap {
78
+ "pont2-prim-hover-card": HoverCard;
79
+ "pont2-prim-hover-card-trigger": HoverCardTrigger;
80
+ "pont2-prim-hover-card-content": HoverCardContent;
81
+ }
82
+ }
83
+ export {};
@@ -0,0 +1,120 @@
1
+ import { PropertyDeclarations } from 'lit';
2
+ import { HostElement, NativeEnhancer } from '../../core/host-element';
3
+ import { MessagesController } from '../../core/messages';
4
+ import { ButtonSize } from '../button/button';
5
+ /**
6
+ * # Pagination
7
+ *
8
+ * shadcn: `<Pagination>` (`<nav aria-label="pagination">`) > `<PaginationContent>`
9
+ * (`<ul>`) > `<PaginationItem>` (`<li>`) > `<PaginationLink isActive>` (a Button
10
+ * rendered as `<a>`), `<PaginationPrevious>`, `<PaginationNext>`,
11
+ * `<PaginationEllipsis>`.
12
+ *
13
+ * pont2: the nav, list and items are hosts with their native roles; links are
14
+ * Tier 3 enhancers around the native `<a>` (or `<button>`) you write, styled
15
+ * with the Button recipe.
16
+ *
17
+ * ```html
18
+ * <pont2-prim-pagination>
19
+ * <pont2-prim-pagination-content>
20
+ * <pont2-prim-pagination-item><pont2-prim-pagination-previous><a href="?page=1">Previous</a></pont2-prim-pagination-previous></pont2-prim-pagination-item>
21
+ * <pont2-prim-pagination-item><pont2-prim-pagination-link><a href="?page=1">1</a></pont2-prim-pagination-link></pont2-prim-pagination-item>
22
+ * <pont2-prim-pagination-item><pont2-prim-pagination-link active><a href="?page=2">2</a></pont2-prim-pagination-link></pont2-prim-pagination-item>
23
+ * <pont2-prim-pagination-item><pont2-prim-pagination-ellipsis></pont2-prim-pagination-ellipsis></pont2-prim-pagination-item>
24
+ * <pont2-prim-pagination-item><pont2-prim-pagination-next><a href="?page=3">Next</a></pont2-prim-pagination-next></pont2-prim-pagination-item>
25
+ * </pont2-prim-pagination-content>
26
+ * </pont2-prim-pagination>
27
+ * ```
28
+ *
29
+ * For a pager driven by `page` / `page-count`, use the kit's `<pont2-pagination>`.
30
+ *
31
+ * @tag pont2-prim-pagination
32
+ */
33
+ export declare class Pagination extends HostElement {
34
+ static identity: string;
35
+ static slotName: string;
36
+ static role: string;
37
+ protected readonly messages: MessagesController;
38
+ protected updated(): void;
39
+ connectedCallback(): void;
40
+ }
41
+ /** shadcn `<ul data-slot="pagination-content">`. @tag pont2-prim-pagination-content */
42
+ export declare class PaginationContent extends HostElement {
43
+ static identity: string;
44
+ static slotName: string;
45
+ static role: string;
46
+ }
47
+ /** shadcn `<li data-slot="pagination-item">`. @tag pont2-prim-pagination-item */
48
+ export declare class PaginationItem extends HostElement {
49
+ static identity: string;
50
+ static slotName: string;
51
+ static role: string;
52
+ }
53
+ /**
54
+ * shadcn `PaginationLink`: a Button (`ghost`, or `outline` when active) on
55
+ * the native `<a>` or `<button>` inside, with `aria-current="page"` and
56
+ * `data-active` when active.
57
+ *
58
+ * @tag pont2-prim-pagination-link
59
+ * @attr active - the current page (shadcn `isActive`)
60
+ * @attr size - Button size (default `icon`)
61
+ * @attr disabled
62
+ */
63
+ export declare class PaginationLink extends NativeEnhancer<HTMLAnchorElement | HTMLButtonElement> {
64
+ static nativeSelector: string;
65
+ /** `data-slot` on the native element. */
66
+ static controlSlot: string;
67
+ static defaultSize: ButtonSize;
68
+ static properties: PropertyDeclarations;
69
+ active: boolean;
70
+ size: ButtonSize;
71
+ disabled: boolean;
72
+ constructor();
73
+ protected apply(control: HTMLAnchorElement | HTMLButtonElement): void;
74
+ }
75
+ /**
76
+ * shadcn `PaginationPrevious`: a default-size link labelled "Go to previous
77
+ * page", with a chevron before your text (drawn by CSS, so the native
78
+ * element's content stays yours). Wrap the text in
79
+ * `<span data-slot="pagination-previous-text">` to hide it below 640px, as
80
+ * shadcn does.
81
+ *
82
+ * @tag pont2-prim-pagination-previous
83
+ */
84
+ export declare class PaginationPrevious extends PaginationLink {
85
+ static controlSlot: string;
86
+ static defaultSize: ButtonSize;
87
+ protected readonly messages: MessagesController;
88
+ protected apply(control: HTMLAnchorElement | HTMLButtonElement): void;
89
+ }
90
+ /** shadcn `PaginationNext`: as Previous, chevron after the text. @tag pont2-prim-pagination-next */
91
+ export declare class PaginationNext extends PaginationLink {
92
+ static controlSlot: string;
93
+ static defaultSize: ButtonSize;
94
+ protected readonly messages: MessagesController;
95
+ protected apply(control: HTMLAnchorElement | HTMLButtonElement): void;
96
+ }
97
+ /**
98
+ * shadcn `PaginationEllipsis`: `<span aria-hidden>` with a "more" icon and
99
+ * a screen-reader "More pages" (rendered by the host).
100
+ *
101
+ * @tag pont2-prim-pagination-ellipsis
102
+ */
103
+ export declare class PaginationEllipsis extends HostElement {
104
+ static identity: string;
105
+ static slotName: string;
106
+ protected readonly messages: MessagesController;
107
+ connectedCallback(): void;
108
+ render(): import('lit-html').TemplateResult<1>;
109
+ }
110
+ declare global {
111
+ interface HTMLElementTagNameMap {
112
+ "pont2-prim-pagination": Pagination;
113
+ "pont2-prim-pagination-content": PaginationContent;
114
+ "pont2-prim-pagination-item": PaginationItem;
115
+ "pont2-prim-pagination-link": PaginationLink;
116
+ "pont2-prim-pagination-previous": PaginationPrevious;
117
+ "pont2-prim-pagination-next": PaginationNext;
118
+ "pont2-prim-pagination-ellipsis": PaginationEllipsis;
119
+ }
120
+ }
@@ -0,0 +1,92 @@
1
+ import { PropertyValues } from 'lit';
2
+ import { HostElement } from '../../core/host-element';
3
+ import { ModalClose, ModalContent, ModalRoot, ModalTitle, ModalTrigger } from '../dialog/dialog';
4
+ export type SheetSide = "top" | "right" | "bottom" | "left";
5
+ /**
6
+ * # Sheet
7
+ *
8
+ * shadcn: `<Sheet>` is Base UI's `Dialog.Root` again, with a popup that
9
+ * slides in from one edge of the screen (`<SheetContent side>`). In pont2 it
10
+ * is the Dialog machine (dialog.ts: modal, inert page, scroll lock, focus
11
+ * trap, Escape and outside press close it) with the sheet's layout.
12
+ *
13
+ * ```html
14
+ * <pont2-prim-sheet>
15
+ * <pont2-prim-sheet-trigger><button data-pont2-button data-variant="outline">Invite members</button></pont2-prim-sheet-trigger>
16
+ * <pont2-prim-sheet-content side="right">
17
+ * <pont2-prim-sheet-header>
18
+ * <pont2-prim-sheet-title>Invite members</pont2-prim-sheet-title>
19
+ * <pont2-prim-sheet-description>They get an email with a link.</pont2-prim-sheet-description>
20
+ * </pont2-prim-sheet-header>
21
+ * …
22
+ * <pont2-prim-sheet-footer>…</pont2-prim-sheet-footer>
23
+ * </pont2-prim-sheet-content>
24
+ * </pont2-prim-sheet>
25
+ * ```
26
+ *
27
+ * @tag pont2-prim-sheet
28
+ * @attr open, modal
29
+ * @fires pont2-open-change - cancelable, `{ open, reason }`
30
+ */
31
+ export declare class Sheet extends ModalRoot {
32
+ static identity: string;
33
+ static family: string;
34
+ }
35
+ /** @tag pont2-prim-sheet-trigger */
36
+ export declare class SheetTrigger extends ModalTrigger {
37
+ static rootTag: string;
38
+ static controlSlot: string;
39
+ }
40
+ /**
41
+ * The sliding panel.
42
+ *
43
+ * @tag pont2-prim-sheet-content
44
+ * @attr side - right (default) | left | top | bottom
45
+ * @attr show-close-button - default true
46
+ * @cssprop --pont2-sheet-bg, --pont2-sheet-fg, --pont2-sheet-border-color, --pont2-sheet-shadow - see docs/11-tokens.md
47
+ * @cssprop --pont2-sheet-width, --pont2-sheet-max-width - left/right sheets (defaults 75%, 24rem)
48
+ * @cssprop --pont2-sheet-overlay-bg - the overlay colour
49
+ */
50
+ export declare class SheetContent extends ModalContent {
51
+ static identity: string;
52
+ static slotName: string;
53
+ static family: string;
54
+ constructor();
55
+ protected willUpdate(changed: PropertyValues): void;
56
+ }
57
+ /** @tag pont2-prim-sheet-header */
58
+ export declare class SheetHeader extends HostElement {
59
+ static identity: string;
60
+ static slotName: string;
61
+ }
62
+ /** @tag pont2-prim-sheet-footer */
63
+ export declare class SheetFooter extends HostElement {
64
+ static identity: string;
65
+ static slotName: string;
66
+ }
67
+ /** @tag pont2-prim-sheet-title */
68
+ export declare class SheetTitle extends ModalTitle {
69
+ static identity: string;
70
+ static slotName: string;
71
+ }
72
+ /** @tag pont2-prim-sheet-description */
73
+ export declare class SheetDescription extends HostElement {
74
+ static identity: string;
75
+ static slotName: string;
76
+ }
77
+ /** @tag pont2-prim-sheet-close */
78
+ export declare class SheetClose extends ModalClose {
79
+ static controlSlot: string;
80
+ }
81
+ declare global {
82
+ interface HTMLElementTagNameMap {
83
+ "pont2-prim-sheet": Sheet;
84
+ "pont2-prim-sheet-trigger": SheetTrigger;
85
+ "pont2-prim-sheet-content": SheetContent;
86
+ "pont2-prim-sheet-header": SheetHeader;
87
+ "pont2-prim-sheet-footer": SheetFooter;
88
+ "pont2-prim-sheet-title": SheetTitle;
89
+ "pont2-prim-sheet-description": SheetDescription;
90
+ "pont2-prim-sheet-close": SheetClose;
91
+ }
92
+ }
@@ -0,0 +1,86 @@
1
+ import { PropertyDeclarations, PropertyValues, TemplateResult } from 'lit';
2
+ import { HostElement } from '../../core/host-element';
3
+ import { MessagesController } from '../../core/messages';
4
+ import { ToastData } from './toast-store';
5
+ export { toast, toasts, ToastStore, type ToastAction, type ToastData, type ToastOptions, type ToastType } from './toast-store';
6
+ export type ToasterPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
7
+ /**
8
+ * # Toaster (shadcn's Sonner)
9
+ *
10
+ * shadcn: `<Toaster />` (`components/ui/sonner.tsx`, Sonner themed with the
11
+ * popover colours and lucide icons) + `toast()` from `sonner`.
12
+ *
13
+ * pont2: `<pont2-prim-toaster>` once per page, and `toast()` exported from
14
+ * pont2 (toast-store.ts), with Sonner's API:
15
+ *
16
+ * ```html
17
+ * <pont2-prim-toaster></pont2-prim-toaster>
18
+ * <script type="module">
19
+ * import { toast } from "@pontive/pontkit-core/pont2";
20
+ * toast.success("Invitation sent", { description: "ann@example.com" });
21
+ * const id = toast.loading("Saving…"); toast.success("Saved", { id });
22
+ * toast.error("We couldn't remove this member.", { action: { label: "Retry", onClick: retry } });
23
+ * </script>
24
+ * ```
25
+ *
26
+ * The host **is** Sonner's `<section aria-label="Notifications alt+T">`
27
+ * (`role=region`), holding the `<ol>` of toasts. It shows itself in the top
28
+ * layer (Popover API) while it has toasts, so toasts sit above dialogs, and
29
+ * a modal dialog leaves it interactive (core/popup/modal.ts exempts it).
30
+ *
31
+ * - Toasts close after `duration` (loading toasts stay until updated);
32
+ * hovering or focusing the toaster pauses every timer, as does a hidden tab.
33
+ * - Alt+T moves focus to the toaster (Sonner's hotkey); Escape there
34
+ * dismisses the focused toast.
35
+ * - Toasts are announced politely (`aria-live="polite"` on the list).
36
+ * - The newest `visible-toasts` (default 3) show.
37
+ *
38
+ * Not yet: Sonner's collapsed stack (toasts here are always listed, Sonner's
39
+ * `expand`), swipe to dismiss, `richColors`, custom JSX toasts.
40
+ *
41
+ * @tag pont2-prim-toaster
42
+ * @attr position - bottom-right (default) | bottom-left | bottom-center | top-right | top-left | top-center
43
+ * @attr duration - ms before a toast closes itself (default 4000)
44
+ * @attr visible-toasts - how many show at once (default 3)
45
+ * @attr close-button - show the × button on every toast
46
+ * @cssprop --pont2-toast-bg, --pont2-toast-fg, --pont2-toast-border-color, --pont2-toast-radius, --pont2-toast-shadow, --pont2-toast-width - see docs/11-tokens.md
47
+ */
48
+ export declare class Toaster extends HostElement {
49
+ static identity: string;
50
+ static slotName: string;
51
+ static role: string;
52
+ static properties: PropertyDeclarations;
53
+ position: ToasterPosition;
54
+ duration: number;
55
+ visibleToasts: number;
56
+ closeButton: boolean;
57
+ protected items: readonly ToastData[];
58
+ protected readonly messages: MessagesController;
59
+ private unsubscribe?;
60
+ /** Per toast: the timer, when it started and how long was left. */
61
+ private timers;
62
+ private removing;
63
+ private paused;
64
+ private hovered;
65
+ private focusedWithin;
66
+ constructor();
67
+ connectedCallback(): void;
68
+ disconnectedCallback(): void;
69
+ private onHotkey;
70
+ private onVisibility;
71
+ private syncPause;
72
+ private durationOf;
73
+ private startTimer;
74
+ private dismiss;
75
+ /** The toasts shown: the newest `visible-toasts`, not counting those already leaving. */
76
+ get shown(): ToastData[];
77
+ protected willUpdate(changed: PropertyValues): void;
78
+ protected updated(changed: PropertyValues): void;
79
+ private renderToast;
80
+ render(): TemplateResult<1>;
81
+ }
82
+ declare global {
83
+ interface HTMLElementTagNameMap {
84
+ "pont2-prim-toaster": Toaster;
85
+ }
86
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * # The toast queue behind `toast()` (Sonner's `toast` function)
3
+ *
4
+ * Page-wide, like Sonner's: `toast("Saved")` anywhere reaches every mounted
5
+ * `<pont2-prim-toaster>`. The queue holds data only (no DOM, no timers), so it
6
+ * is unit-tested (toast-store.test.ts); the toaster renders it and runs the
7
+ * auto-dismiss timers.
8
+ */
9
+ export type ToastType = "default" | "success" | "info" | "warning" | "error" | "loading";
10
+ export interface ToastAction {
11
+ label: string;
12
+ onClick: (event: MouseEvent) => void;
13
+ }
14
+ export interface ToastOptions {
15
+ /** Reuse an id to update a toast in place (e.g. loading → success). */
16
+ id?: string | number;
17
+ description?: string;
18
+ type?: ToastType;
19
+ /** ms before it closes itself; `Infinity` keeps it. Default: the toaster's `duration` (loading: Infinity). */
20
+ duration?: number;
21
+ /** A button in the toast; pressing it runs `onClick` and closes the toast unless the handler calls `preventDefault()`. */
22
+ action?: ToastAction;
23
+ /** A secondary, outline button that closes the toast. */
24
+ cancel?: ToastAction;
25
+ /** Show the × button on this toast (also a toaster-wide attribute). */
26
+ closeButton?: boolean;
27
+ /** Whether a press of × or a timeout may close it (default true). */
28
+ dismissible?: boolean;
29
+ onDismiss?: (toast: ToastData) => void;
30
+ onAutoClose?: (toast: ToastData) => void;
31
+ }
32
+ export interface ToastData extends ToastOptions {
33
+ id: string | number;
34
+ title: string;
35
+ type: ToastType;
36
+ /** Set when the toast is leaving (its exit animation runs before it is removed). */
37
+ dismissed?: boolean;
38
+ /** Increases on every update, so a toaster restarts the timer. */
39
+ version: number;
40
+ createdAt: number;
41
+ }
42
+ type Listener = (toasts: readonly ToastData[]) => void;
43
+ export declare class ToastStore {
44
+ private toasts;
45
+ private listeners;
46
+ private counter;
47
+ get all(): readonly ToastData[];
48
+ subscribe(listener: Listener): () => void;
49
+ private emit;
50
+ /** Adds a toast, or updates the one with the same `id`. Returns the id. */
51
+ add(title: string, options?: ToastOptions): string | number;
52
+ /** Starts closing one toast (or all): it is marked `dismissed`, then `remove()`d by the toaster. */
53
+ dismiss(id?: string | number): void;
54
+ /** Drops a toast for good (after its exit animation). */
55
+ remove(id: string | number): void;
56
+ /** Forgets every toast. For tests and stories. */
57
+ clear(): void;
58
+ }
59
+ /** The page's queue. */
60
+ export declare const toasts: ToastStore;
61
+ type Typed = (title: string, options?: Omit<ToastOptions, "type">) => string | number;
62
+ /**
63
+ * Sonner's `toast()`: `toast("Event created")`, `toast.success(…)`,
64
+ * `toast.error(…)`, `toast.info(…)`, `toast.warning(…)`, `toast.loading(…)`,
65
+ * `toast.dismiss(id?)`, `toast.promise(p, { loading, success, error })`.
66
+ */
67
+ export declare const toast: ((title: string, options?: ToastOptions) => string | number) & {
68
+ success: Typed;
69
+ info: Typed;
70
+ warning: Typed;
71
+ error: Typed;
72
+ loading: Typed;
73
+ dismiss: (id?: string | number) => void;
74
+ /** One toast that says "loading", then success or error, as Sonner's `toast.promise`. */
75
+ promise<T>(promise: Promise<T>, messages: {
76
+ loading: string;
77
+ success: string | ((value: T) => string);
78
+ error: string | ((error: unknown) => string);
79
+ }, options?: Omit<ToastOptions, "type" | "id">): string | number;
80
+ };
81
+ export {};