@ngrok/mantle 0.81.0 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion.d.ts +6 -6
- package/dist/accordion.js +1 -1
- package/dist/agent.json +4 -1
- package/dist/alert-BWwNPOMI.d.ts +391 -0
- package/dist/alert-QMs0PqMq.js +1 -0
- package/dist/alert-center.d.ts +449 -0
- package/dist/alert-center.js +1 -0
- package/dist/alert-dialog.js +1 -1
- package/dist/alert.d.ts +1 -288
- package/dist/alert.js +1 -1
- package/dist/{anchor-DfeXTpKW.js → anchor-DvbNsphX.js} +1 -1
- package/dist/anchor.js +1 -1
- package/dist/app-layout.d.ts +483 -0
- package/dist/app-layout.js +1 -0
- package/dist/area-chart.d.ts +4 -3
- package/dist/area-chart.js +1 -1
- package/dist/badge.js +1 -1
- package/dist/bar-chart.d.ts +4 -3
- package/dist/bar-chart.js +1 -1
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/browser-only-CmEEzfU3.js +1 -0
- package/dist/browser-only.js +1 -1
- package/dist/{button-D9n09xUg.js → button-BO2CKsz6.js} +1 -1
- package/dist/{button-DjpEKt2X.js → button-BUospUB3.js} +1 -1
- package/dist/{button-BAno7KIU.js → button-C0S8RbaJ.js} +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar.d.ts +1 -1
- package/dist/calendar.js +1 -1
- package/dist/card.js +1 -1
- package/dist/centered-layout.d.ts +9 -9
- package/dist/centered-layout.js +1 -1
- package/dist/{chart-BcOC6Qj0.d.ts → chart-1cVjAcj8.d.ts} +81 -22
- package/dist/chart-DdBQ3xwx.js +2 -0
- package/dist/checkbox.d.ts +12 -0
- package/dist/{choice-BHwFSSyv.js → choice-C9gLKECf.js} +1 -1
- package/dist/choice.js +1 -1
- package/dist/code-block.d.ts +46 -0
- package/dist/code-block.js +1 -1
- package/dist/code.js +1 -1
- package/dist/combobox.js +1 -1
- package/dist/command.d.ts +67 -9
- package/dist/command.js +1 -1
- package/dist/{copy-to-clipboard-BsCQ9m6K.js → copy-to-clipboard-B4UB6pts.js} +1 -1
- package/dist/data-slot-EM6s2WEU.js +1 -0
- package/dist/data-table.d.ts +1 -1
- package/dist/data-table.js +1 -1
- package/dist/description-list.d.ts +36 -16
- package/dist/description-list.js +1 -1
- package/dist/{dialog-DWZWd5Jt.js → dialog-Bsj_dX6r.js} +1 -1
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dropdown-menu-BbbQuae2.d.ts +1 -0
- package/dist/{dropdown-menu-DZg-Cd69.d.ts → dropdown-menu-D6pMAY7I.d.ts} +138 -0
- package/dist/dropdown-menu-fUMqjRC0.js +1 -0
- package/dist/dropdown-menu.d.ts +2 -2
- package/dist/dropdown-menu.js +1 -1
- package/dist/empty.js +1 -1
- package/dist/field.d.ts +12 -9
- package/dist/field.js +1 -1
- package/dist/flag.d.ts +1 -1
- package/dist/hooks.js +1 -1
- package/dist/{icons-DLCs1hLP.js → icons-CPbOq7cF.js} +1 -1
- package/dist/icons.d.ts +52 -1
- package/dist/icons.js +1 -1
- package/dist/input.js +1 -1
- package/dist/line-chart.d.ts +4 -3
- package/dist/line-chart.js +1 -1
- package/dist/{list-51KQvENW.js → list-CQFWx6Z8.js} +1 -1
- package/dist/list.js +1 -1
- package/dist/llms.txt +4 -1
- package/dist/main.d.ts +4 -1
- package/dist/main.js +1 -1
- package/dist/mantle.css +21 -1
- package/dist/media-object.d.ts +42 -0
- package/dist/media-object.js +1 -1
- package/dist/multi-select.d.ts +10 -2
- package/dist/multi-select.js +1 -1
- package/dist/otp-input.js +1 -1
- package/dist/pagination.d.ts +6 -7
- package/dist/pagination.js +1 -1
- package/dist/{primitive-trJDqIXJ.js → primitive-Dv-3snU3.js} +1 -1
- package/dist/progress.d.ts +8 -8
- package/dist/qr-code.js +1 -1
- package/dist/radio-group.d.ts +129 -0
- package/dist/radio-group.js +1 -1
- package/dist/sandboxed-on-click.d.ts +2 -2
- package/dist/sandboxed-on-click.js +1 -1
- package/dist/scatter-plot.d.ts +4 -3
- package/dist/scatter-plot.js +1 -1
- package/dist/{select-BCHWvmyC.js → select-B-9yWrif.js} +1 -1
- package/dist/select.js +1 -1
- package/dist/selectable-list.js +1 -1
- package/dist/{separator-bpE_kooz.js → separator-BepAcFFy.js} +1 -1
- package/dist/separator.js +1 -1
- package/dist/sheet-_fXLjiq2.js +1 -0
- package/dist/sheet.d.ts +11 -11
- package/dist/sheet.js +1 -1
- package/dist/sidebar.d.ts +2084 -0
- package/dist/sidebar.js +1 -0
- package/dist/{skeleton-CsbUHbBA.js → skeleton-DsHXIa9j.js} +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/skip-to-main-link.js +1 -1
- package/dist/slot-Dpsqz16D.js +1 -0
- package/dist/slot.js +1 -1
- package/dist/split-button.d.ts +147 -8
- package/dist/split-button.js +1 -1
- package/dist/{table-Bo0vNxIJ.d.ts → table-CZBYEmyK.d.ts} +2 -2
- package/dist/table.d.ts +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text-area.d.ts +1 -1
- package/dist/{theme-CYNpplwN.d.ts → theme-FbfjYiD3.d.ts} +16 -0
- package/dist/{theme-C26-Xolp.js → theme-IAnQ35bd.js} +1 -1
- package/dist/theme-switcher.d.ts +2 -2
- package/dist/theme-switcher.js +1 -1
- package/dist/theme.d.ts +42 -2
- package/dist/theme.js +1 -1
- package/dist/toast.d.ts +4 -0
- package/dist/toast.js +1 -1
- package/dist/types.js +1 -1
- package/dist/use-breakpoint-Wd7_5-Mu.js +1 -0
- package/dist/use-copy-to-clipboard-CSyp4Zk0.js +1 -0
- package/dist/use-is-hydrated-DDCqXmju.js +1 -0
- package/dist/{use-prefers-reduced-motion-CagaNRgm.js → use-prefers-reduced-motion-Bk5zAfHY.js} +1 -1
- package/dist/utils.js +1 -1
- package/dist/well.js +1 -1
- package/package.json +18 -15
- package/dist/browser-only-CPH56Xw_.js +0 -1
- package/dist/chart-BROa2gqt.js +0 -2
- package/dist/dropdown-menu-Dw-OtXPm.d.ts +0 -1
- package/dist/dropdown-menu-RyDWoKHx.js +0 -1
- package/dist/slot-CDk0Bb9z.js +0 -1
- package/dist/use-copy-to-clipboard-DqQ0_N3E.js +0 -1
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { t as Alert } from "./alert-BWwNPOMI.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
//#region src/components/alert-center/alert-center.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The tone an alert's color communicates — identical to `Alert`'s intent axis,
|
|
6
|
+
* so an item's `intent` flows straight through to the `Alert` chrome that
|
|
7
|
+
* renders it. Also the severity ranking key: `danger` › `warning` ›
|
|
8
|
+
* `important` › `info` › `success` decides which item the bar shows.
|
|
9
|
+
*
|
|
10
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <AlertCenter.Item id="payment-failed" intent="danger">…</AlertCenter.Item>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
type AlertCenterIntent = "danger" | "important" | "info" | "success" | "warning";
|
|
18
|
+
/**
|
|
19
|
+
* Props for {@link AlertCenter.Root} — the expansion's open state. The alerts
|
|
20
|
+
* themselves are authored as `AlertCenter.Item` children.
|
|
21
|
+
*
|
|
22
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcenterroot
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <AlertCenter.Root open={expanded} onOpenChange={setExpanded}>
|
|
27
|
+
* <AlertCenter.Bar />
|
|
28
|
+
* <AlertCenter.Content />
|
|
29
|
+
* <AlertCenter.Item id="payment-failed" intent="danger">…</AlertCenter.Item>
|
|
30
|
+
* </AlertCenter.Root>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
type AlertCenterRootProps = {
|
|
34
|
+
/** Controlled expanded state of the additional-alert list. */
|
|
35
|
+
open?: boolean;
|
|
36
|
+
/** Uncontrolled initial expanded state of the additional-alert list. */
|
|
37
|
+
defaultOpen?: boolean;
|
|
38
|
+
/** Called when the additional-alert list expands or collapses. */
|
|
39
|
+
onOpenChange?: (open: boolean) => void;
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The renderless state owner. It creates the registration store the
|
|
44
|
+
* `AlertCenter.Item` children register into, owns the inline expansion's open
|
|
45
|
+
* state, and mounts the persistent live-region announcer. Compose its `Bar`
|
|
46
|
+
* (and `Content`) inside `AppLayout.Notice`, alongside any other window-level
|
|
47
|
+
* notice, so all top-of-viewport messaging shares one layout slot.
|
|
48
|
+
*
|
|
49
|
+
* Items register client-side (from layout effects), so server-rendered HTML
|
|
50
|
+
* contains no bar; it enters with its height animation after hydration — the
|
|
51
|
+
* same entrance every arriving alert gets by design.
|
|
52
|
+
*
|
|
53
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcenterroot
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <AlertCenter.Root>
|
|
58
|
+
* <AlertCenter.Bar />
|
|
59
|
+
* <AlertCenter.Content />
|
|
60
|
+
* {paymentFailed && (
|
|
61
|
+
* <AlertCenter.Item id="payment-failed" intent="danger">
|
|
62
|
+
* <Alert.Icon />
|
|
63
|
+
* <Alert.Content>
|
|
64
|
+
* <Alert.Title>
|
|
65
|
+
* Payment failed — <a href="/billing">update your card</a>
|
|
66
|
+
* </Alert.Title>
|
|
67
|
+
* </Alert.Content>
|
|
68
|
+
* </AlertCenter.Item>
|
|
69
|
+
* )}
|
|
70
|
+
* </AlertCenter.Root>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare const Root: ({ children, defaultOpen, onOpenChange, open }: AlertCenterRootProps) => import("react").JSX.Element;
|
|
74
|
+
/**
|
|
75
|
+
* Props for {@link AlertCenter.Item}: the coordination facts the center needs
|
|
76
|
+
* to rank, announce, and label an alert — everything presentational is the
|
|
77
|
+
* authored `children`.
|
|
78
|
+
*
|
|
79
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcenteritem
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* <AlertCenter.Root>
|
|
84
|
+
* <AlertCenter.Bar />
|
|
85
|
+
* <AlertCenter.Content />
|
|
86
|
+
* <AlertCenter.Item id="transfer-limit" intent="warning">
|
|
87
|
+
* <Alert.Icon />
|
|
88
|
+
* <Alert.Content>
|
|
89
|
+
* <Alert.Title>Approaching your data transfer limit</Alert.Title>
|
|
90
|
+
* <AlertCenter.DismissIconButton onClick={() => dismiss("transfer-limit")} />
|
|
91
|
+
* </Alert.Content>
|
|
92
|
+
* </AlertCenter.Item>
|
|
93
|
+
* </AlertCenter.Root>
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
type AlertCenterItemProps = {
|
|
97
|
+
/**
|
|
98
|
+
* Stable identity. It keys the item's stable host element (children keep
|
|
99
|
+
* their state as the host moves between the bar and a row), pins the
|
|
100
|
+
* item's arrival order (a returning id resumes its original position), and
|
|
101
|
+
* is stamped on the chrome as `data-alert-id` for styling. Two mounted
|
|
102
|
+
* items sharing an id is an authoring error — the last registration wins.
|
|
103
|
+
*/
|
|
104
|
+
id: string;
|
|
105
|
+
/**
|
|
106
|
+
* The tone the alert's color communicates. Drives both the severity ranking
|
|
107
|
+
* and the intent of the `Alert.Root` chrome the children render inside.
|
|
108
|
+
*/
|
|
109
|
+
intent: AlertCenterIntent;
|
|
110
|
+
/** Optional classes for this item's chrome `Alert.Root`, in both placements. */
|
|
111
|
+
className?: string;
|
|
112
|
+
/**
|
|
113
|
+
* The banner content: compose `Alert.Icon`, `Alert.Content`, `Alert.Title`,
|
|
114
|
+
* `Alert.Description`, and `AlertCenter.DismissIconButton`. Do NOT include
|
|
115
|
+
* `Alert.Root` — the center provides the chrome (with this item's `intent`)
|
|
116
|
+
* at whichever placement the item ranks into.
|
|
117
|
+
*/
|
|
118
|
+
children: ReactNode;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* One account alert, authored as JSX. It registers its coordination facts
|
|
122
|
+
* with the center and renders its children through a portal into a stable
|
|
123
|
+
* per-id host element that `AlertCenter.Bar` / `AlertCenter.Content`
|
|
124
|
+
* physically adopt into their chrome. Mount it to show the alert, unmount it
|
|
125
|
+
* to remove it — dismissal is just your state flipping the condition off.
|
|
126
|
+
*
|
|
127
|
+
* Because the children stay in YOUR React tree (only their DOM lands in the
|
|
128
|
+
* chrome), context providers and error boundaries around the item work, and
|
|
129
|
+
* router-aware links resolve at the authoring location. The host element is
|
|
130
|
+
* stable and moved — not remounted — between the bar and a row, so authored
|
|
131
|
+
* content keeps its state (and, in engines with `Element.moveBefore`, even
|
|
132
|
+
* focus) across re-ranks. While an item ranks nowhere visible (e.g. the
|
|
133
|
+
* expansion is not composed), its children stay mounted on a detached host —
|
|
134
|
+
* rendered by React, contributing nothing to the document.
|
|
135
|
+
*
|
|
136
|
+
* Server rendering emits no alert DOM — the bar enters after hydration with
|
|
137
|
+
* its height animation, the same entrance every arriving alert gets.
|
|
138
|
+
*
|
|
139
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcenteritem
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```tsx
|
|
143
|
+
* <AlertCenter.Root>
|
|
144
|
+
* <AlertCenter.Bar />
|
|
145
|
+
* <AlertCenter.Content />
|
|
146
|
+
* <AlertCenter.Item id="transfer-limit" intent="warning">
|
|
147
|
+
* <Alert.Icon />
|
|
148
|
+
* <Alert.Content>
|
|
149
|
+
* <Alert.Title>
|
|
150
|
+
* You've used 92% of your monthly transfer. <a href="/billing">Upgrade</a>
|
|
151
|
+
* </Alert.Title>
|
|
152
|
+
* <Alert.Description>Free accounts include 5 GB of transfer per month.</Alert.Description>
|
|
153
|
+
* <AlertCenter.DismissIconButton onClick={() => dismiss("transfer-limit")} />
|
|
154
|
+
* </Alert.Content>
|
|
155
|
+
* </AlertCenter.Item>
|
|
156
|
+
* </AlertCenter.Root>
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
declare const Item: ({ children, className, id, intent }: AlertCenterItemProps) => import("react").ReactPortal | null;
|
|
160
|
+
type AlertCenterDismissIconButtonProps = ComponentProps<typeof Alert.DismissIconButton> & {
|
|
161
|
+
/**
|
|
162
|
+
* Dismissal is consumer-owned: remove the alert by unmounting its
|
|
163
|
+
* `AlertCenter.Item` (and persist that however you like). Required because a
|
|
164
|
+
* dismiss affordance that does nothing is always an authoring error.
|
|
165
|
+
*/
|
|
166
|
+
onClick: NonNullable<ComponentProps<typeof Alert.DismissIconButton>["onClick"]>;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* The dismiss affordance for the item it's composed inside. A thin wrapper over
|
|
170
|
+
* `Alert.DismissIconButton` whose label defaults to `Dismiss ${title}`, derived
|
|
171
|
+
* from the enclosing banner's RENDERED `Alert.Title` text and re-read on every
|
|
172
|
+
* commit so the accessible name stays in lockstep with the visible copy (pass
|
|
173
|
+
* `label` to override, e.g. when the title is long). Compose it — or leave it
|
|
174
|
+
* out — per alert; its presence IS the alert's dismissability.
|
|
175
|
+
*
|
|
176
|
+
* Where the control sits in each placement is the chrome's business, not this
|
|
177
|
+
* wrapper's: `Alert.Root`'s existing expand-aware CSS seats it beside the bar's
|
|
178
|
+
* expand control, and {@link singleLineBarControls} re-centers it in a
|
|
179
|
+
* single-line bar.
|
|
180
|
+
*
|
|
181
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcenterdismissiconbutton
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```tsx
|
|
185
|
+
* <AlertCenter.Root>
|
|
186
|
+
* <AlertCenter.Bar />
|
|
187
|
+
* <AlertCenter.Content />
|
|
188
|
+
* <AlertCenter.Item id="transfer-limit" intent="warning">
|
|
189
|
+
* <Alert.Icon />
|
|
190
|
+
* <Alert.Content>
|
|
191
|
+
* <Alert.Title>Approaching your data transfer limit</Alert.Title>
|
|
192
|
+
* <AlertCenter.DismissIconButton onClick={() => dismiss("transfer-limit")} />
|
|
193
|
+
* </Alert.Content>
|
|
194
|
+
* </AlertCenter.Item>
|
|
195
|
+
* </AlertCenter.Root>
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare const DismissIconButton: ({ label, ref, ...props }: AlertCenterDismissIconButtonProps) => import("react").JSX.Element;
|
|
199
|
+
type AlertCenterBarProps = Omit<ComponentProps<typeof Alert.Root>, "appearance" | "intent" | "children"> & {
|
|
200
|
+
/** The bar renders the top-ranked item's authored children — it takes none of its own. */
|
|
201
|
+
children?: never;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* The always-visible, full-width strip. It renders the single highest-severity
|
|
205
|
+
* item's authored children INLINE — icon, title, description, and its
|
|
206
|
+
* call-to-action — so the top CTA is one glance (and zero extra clicks) away,
|
|
207
|
+
* then appends a count-and-caret control that expands the additional alerts
|
|
208
|
+
* below the bar. Collapses to nothing when there are no alerts (like
|
|
209
|
+
* `AppLayout.Notice`), so it can stay mounted and render unconditionally.
|
|
210
|
+
*
|
|
211
|
+
* The bar renders the top alert as authored, so it is exactly as tall as that
|
|
212
|
+
* content: single-line for a title alone, two lines once an `Alert.Description`
|
|
213
|
+
* is composed (matching how the same alert renders as an expansion row). Its
|
|
214
|
+
* chrome carries `data-placement="bar"` and `data-alert-id` as styling hooks for
|
|
215
|
+
* placement-aware authored content — `in-data-[placement=bar]:hidden` keeps a
|
|
216
|
+
* given element out of the bar and shows it only in the expansion.
|
|
217
|
+
*
|
|
218
|
+
* The bar itself claims NO ARIA landmark (deliberately, like `AppLayout.Notice`)
|
|
219
|
+
* — arrivals and re-ranks are announced by the persistent visually-hidden
|
|
220
|
+
* `role="status"` region that `AlertCenter.Root` mounts.
|
|
221
|
+
*
|
|
222
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcenterbar
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```tsx
|
|
226
|
+
* <AlertCenter.Root>
|
|
227
|
+
* <AlertCenter.Bar />
|
|
228
|
+
* <AlertCenter.Content />
|
|
229
|
+
* <AlertCenter.Item id="payment-failed" intent="danger">
|
|
230
|
+
* …
|
|
231
|
+
* </AlertCenter.Item>
|
|
232
|
+
* </AlertCenter.Root>
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
declare const Bar: ({ className, ref, ...props }: AlertCenterBarProps) => import("react").JSX.Element | null;
|
|
236
|
+
type AlertCenterContentProps = Omit<ComponentProps<"div">, "children" | "id"> & {
|
|
237
|
+
/** Rows are the registered items' authored children — Content takes none of its own. */
|
|
238
|
+
children?: never;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* The inline expansion below `AlertCenter.Bar`. It renders the additional
|
|
242
|
+
* alerts (every registered item except the bar's top one), ranked
|
|
243
|
+
* highest-severity-first, as full-width banner rows that push the app shell
|
|
244
|
+
* down while expanded. Each row is the item's authored children inside an
|
|
245
|
+
* `Alert.Root` chrome stamped with `data-placement="list"` and
|
|
246
|
+
* `data-alert-id`.
|
|
247
|
+
*
|
|
248
|
+
* `aria-label` (default `"More alerts"`) and `aria-labelledby` name the row
|
|
249
|
+
* list itself — the outer wrapper is `role="generic"`, where ARIA prohibits
|
|
250
|
+
* accessible names, so a name passed here would otherwise be dropped.
|
|
251
|
+
*
|
|
252
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcentercontent
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```tsx
|
|
256
|
+
* <AlertCenter.Root>
|
|
257
|
+
* <AlertCenter.Bar />
|
|
258
|
+
* <AlertCenter.Content aria-label="Autres alertes" />
|
|
259
|
+
* <AlertCenter.Item id="transfer-limit" intent="warning">
|
|
260
|
+
* …
|
|
261
|
+
* </AlertCenter.Item>
|
|
262
|
+
* </AlertCenter.Root>
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
declare const Content: ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, className, ref, ...props }: AlertCenterContentProps) => import("react").JSX.Element | null;
|
|
266
|
+
/**
|
|
267
|
+
* A single, top-level entry point for one-to-many account alerts and their
|
|
268
|
+
* upgrade CTAs — the aggregation layer that replaces a stack of independent
|
|
269
|
+
* window banners. Alerts are AUTHORED as `AlertCenter.Item` JSX (mount to
|
|
270
|
+
* show, unmount to dismiss); each item registers its coordination facts, and
|
|
271
|
+
* the center derives the count, the top alert, and the severity ranking from
|
|
272
|
+
* the registrations. `AlertCenter.Bar` shows the highest-severity item inline
|
|
273
|
+
* (with its CTA) and a count-and-caret control; `AlertCenter.Content` expands
|
|
274
|
+
* the remaining items as full-width banners.
|
|
275
|
+
*
|
|
276
|
+
* Ranking is deterministic: severity first (`danger` › `warning` ›
|
|
277
|
+
* `important` › `info` › `success`), then arrival order within an intent —
|
|
278
|
+
* items mounting together rank in tree order, later arrivals append after
|
|
279
|
+
* their same-intent peers, and a dismissed-then-returning id resumes its
|
|
280
|
+
* original position.
|
|
281
|
+
*
|
|
282
|
+
* Compose `Bar` and `Content` into `AppLayout.Notice`, alongside any other
|
|
283
|
+
* window-level notice. Items may be authored anywhere under `Root`: their
|
|
284
|
+
* children stay in the author's React tree (context providers and error
|
|
285
|
+
* boundaries around an item work; router links resolve where the item is
|
|
286
|
+
* written) while their DOM renders through a stable per-id host that the bar
|
|
287
|
+
* and rows physically adopt — so content keeps its state across re-ranks.
|
|
288
|
+
*
|
|
289
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* Composition (items render no DOM in place; their children portal into a
|
|
293
|
+
* stable host the bar or a row adopts):
|
|
294
|
+
* ```
|
|
295
|
+
* AlertCenter.Root
|
|
296
|
+
* ├── AlertCenter.Bar ← the top-ranked item's children, in Alert chrome
|
|
297
|
+
* ├── AlertCenter.Content ← every other item's children, as ranked rows
|
|
298
|
+
* └── AlertCenter.Item (0..n, renderless)
|
|
299
|
+
* └── Alert.Icon / Alert.Content / Alert.Title / Alert.Description /
|
|
300
|
+
* AlertCenter.DismissIconButton
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```tsx
|
|
305
|
+
* <AppLayout.Root className="fixed inset-0">
|
|
306
|
+
* <AppLayout.Notice>
|
|
307
|
+
* {showPreviewNotice && <PreviewNotice />}
|
|
308
|
+
* <AlertCenter.Root>
|
|
309
|
+
* <AlertCenter.Bar />
|
|
310
|
+
* <AlertCenter.Content />
|
|
311
|
+
* <AlertCenter.Item id="payment-failed" intent="danger">
|
|
312
|
+
* <Alert.Icon />
|
|
313
|
+
* <Alert.Content>
|
|
314
|
+
* <Alert.Title>
|
|
315
|
+
* Payment failed — we couldn't charge your card.{" "}
|
|
316
|
+
* <a href="/billing">Update payment method</a>
|
|
317
|
+
* </Alert.Title>
|
|
318
|
+
* <Alert.Description>
|
|
319
|
+
* Update your payment method to avoid a service interruption.
|
|
320
|
+
* </Alert.Description>
|
|
321
|
+
* </Alert.Content>
|
|
322
|
+
* </AlertCenter.Item>
|
|
323
|
+
* {!dismissed.has("transfer-limit") && (
|
|
324
|
+
* <AlertCenter.Item id="transfer-limit" intent="warning">
|
|
325
|
+
* <Alert.Icon />
|
|
326
|
+
* <Alert.Content>
|
|
327
|
+
* <Alert.Title>
|
|
328
|
+
* You've used 92% of your monthly transfer.{" "}
|
|
329
|
+
* <a href="/billing/choose-a-plan">Upgrade</a>
|
|
330
|
+
* </Alert.Title>
|
|
331
|
+
* <AlertCenter.DismissIconButton onClick={() => dismiss("transfer-limit")} />
|
|
332
|
+
* </Alert.Content>
|
|
333
|
+
* </AlertCenter.Item>
|
|
334
|
+
* )}
|
|
335
|
+
* </AlertCenter.Root>
|
|
336
|
+
* </AppLayout.Notice>
|
|
337
|
+
* <AppLayout.Body>…</AppLayout.Body>
|
|
338
|
+
* </AppLayout.Root>
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
declare const AlertCenter: {
|
|
342
|
+
/**
|
|
343
|
+
* The renderless state owner: creates the registration store, owns the
|
|
344
|
+
* expansion's open state, and mounts the persistent live-region announcer.
|
|
345
|
+
*
|
|
346
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcenterroot
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```tsx
|
|
350
|
+
* <AlertCenter.Root>
|
|
351
|
+
* <AlertCenter.Bar />
|
|
352
|
+
* <AlertCenter.Content />
|
|
353
|
+
* <AlertCenter.Item id="payment-failed" intent="danger">
|
|
354
|
+
* …
|
|
355
|
+
* </AlertCenter.Item>
|
|
356
|
+
* </AlertCenter.Root>
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
readonly Root: typeof Root;
|
|
360
|
+
/**
|
|
361
|
+
* The always-visible strip: the highest-severity item's children inline
|
|
362
|
+
* (icon, title, description, CTA) plus the count-and-caret expansion control.
|
|
363
|
+
* Collapses to nothing when empty. Claims no ARIA landmark; arrivals are
|
|
364
|
+
* announced by Root's persistent live region.
|
|
365
|
+
*
|
|
366
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcenterbar
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```tsx
|
|
370
|
+
* <AlertCenter.Root>
|
|
371
|
+
* <AlertCenter.Bar />
|
|
372
|
+
* <AlertCenter.Content />
|
|
373
|
+
* <AlertCenter.Item id="payment-failed" intent="danger">
|
|
374
|
+
* …
|
|
375
|
+
* </AlertCenter.Item>
|
|
376
|
+
* </AlertCenter.Root>
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
readonly Bar: typeof Bar;
|
|
380
|
+
/**
|
|
381
|
+
* The inline expansion listing every alert hidden by the bar, ranked
|
|
382
|
+
* highest-severity-first as full-width banner rows of the items' authored
|
|
383
|
+
* children.
|
|
384
|
+
*
|
|
385
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcentercontent
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```tsx
|
|
389
|
+
* <AlertCenter.Root>
|
|
390
|
+
* <AlertCenter.Bar />
|
|
391
|
+
* <AlertCenter.Content />
|
|
392
|
+
* <AlertCenter.Item id="transfer-limit" intent="warning">
|
|
393
|
+
* …
|
|
394
|
+
* </AlertCenter.Item>
|
|
395
|
+
* </AlertCenter.Root>
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
readonly Content: typeof Content;
|
|
399
|
+
/**
|
|
400
|
+
* One authored alert: registers its `{id, intent}` facts and renders its
|
|
401
|
+
* children through a portal into a stable per-id host that the bar or an
|
|
402
|
+
* expansion row adopts by rank — children stay in the author's React tree
|
|
403
|
+
* and keep their state across re-ranks. Mount to show; unmount to dismiss.
|
|
404
|
+
*
|
|
405
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcenteritem
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```tsx
|
|
409
|
+
* <AlertCenter.Root>
|
|
410
|
+
* <AlertCenter.Bar />
|
|
411
|
+
* <AlertCenter.Content />
|
|
412
|
+
* <AlertCenter.Item id="payment-failed" intent="danger">
|
|
413
|
+
* <Alert.Icon />
|
|
414
|
+
* <Alert.Content>
|
|
415
|
+
* <Alert.Title>
|
|
416
|
+
* Payment failed — <a href="/billing">update your card</a>
|
|
417
|
+
* </Alert.Title>
|
|
418
|
+
* </Alert.Content>
|
|
419
|
+
* </AlertCenter.Item>
|
|
420
|
+
* </AlertCenter.Root>
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
readonly Item: typeof Item;
|
|
424
|
+
/**
|
|
425
|
+
* The per-item dismiss affordance: `Alert.DismissIconButton` wired to the
|
|
426
|
+
* enclosing banner's rendered title and the bar's control centering. Its
|
|
427
|
+
* presence in an item's children is what makes that alert dismissable.
|
|
428
|
+
*
|
|
429
|
+
* @see https://mantle.ngrok.com/components/feedback/alert-center#alertcenterdismissiconbutton
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```tsx
|
|
433
|
+
* <AlertCenter.Root>
|
|
434
|
+
* <AlertCenter.Bar />
|
|
435
|
+
* <AlertCenter.Content />
|
|
436
|
+
* <AlertCenter.Item id="transfer-limit" intent="warning">
|
|
437
|
+
* <Alert.Icon />
|
|
438
|
+
* <Alert.Content>
|
|
439
|
+
* <Alert.Title>Approaching your data transfer limit</Alert.Title>
|
|
440
|
+
* <AlertCenter.DismissIconButton onClick={() => dismiss("transfer-limit")} />
|
|
441
|
+
* </Alert.Content>
|
|
442
|
+
* </AlertCenter.Item>
|
|
443
|
+
* </AlertCenter.Root>
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
readonly DismissIconButton: typeof DismissIconButton;
|
|
447
|
+
};
|
|
448
|
+
//#endregion
|
|
449
|
+
export { AlertCenter, type AlertCenterIntent, type AlertCenterItemProps, type AlertCenterRootProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./use-isomorphic-layout-effect-DdTRtMY-.js";import{n as t}from"./compose-refs-BdBMM9ga.js";import{t as n}from"./cx-IiQEAKf5.js";import{n as r,t as i}from"./alert-QMs0PqMq.js";import{createContext as a,useCallback as o,useContext as s,useEffect as c,useId as l,useMemo as u,useReducer as d,useRef as f,useState as p,useSyncExternalStore as m}from"react";import h from"tiny-invariant";import{jsx as g,jsxs as _}from"react/jsx-runtime";import{createPortal as v}from"react-dom";const y={danger:5,warning:4,important:3,info:2,success:1};function b(e,t){if(t.parentElement===e)return!1;if(typeof e.moveBefore==`function`&&t.isConnected&&e.isConnected)try{return e.moveBefore(t,null),!0}catch{}return e.appendChild(t),!0}function x(e){return e.replace(/\s+/g,` `).trim()}function S(e){let t=e.querySelector(`[data-slot="alert-title"]`);if(t==null)return``;let n=t.cloneNode(!0);if(!(n instanceof Element))return x(t.textContent??``);for(let e of n.querySelectorAll(`button`))e.remove();let r=x(n.textContent??``);for(let e of n.querySelectorAll(`a`))e.remove();let i=x(n.textContent??``);return i===``?r:i}function C(e){return e.toSorted((e,t)=>y[t.intent]-y[e.intent]||e.sequence-t.sequence)}function w(e,t){if(t===0)return``;if(e===``)return`${t} alert${t===1?``:`s`}`;let n=t-1;return n===0?e:`${e}, and ${n} more alert${n===1?``:`s`}`}const T=[];var E=class{#e=new Set;#t=new Map;#n=new Map;#r=new Map;#i=0;#a=T;#o=``;#s=!1;getHost(e){let t=this.#r.get(e);if(t!=null)return t;let n=document.createElement(`div`);return n.style.display=`contents`,n.setAttribute(`data-slot`,`alert-center-item-host`),n.setAttribute(`data-alert-host`,e),this.#r.set(e,n),n}#c=null;captureHostSnapshot(e){if(e!==this.#a[0]?.id)return;let t=this.#r.get(e);t!=null&&t.hasChildNodes()&&(this.#c={id:e,content:t.cloneNode(!0)})}getHostSnapshot=e=>this.#c?.id===e?this.#c.content:null;subscribe=e=>(this.#e.add(e),()=>{this.#e.delete(e)});getSnapshot=()=>this.#a;hasAlert=e=>this.#t.has(e);getTopLabel=()=>this.#o;setTopLabel(e){this.#o!==e&&(this.#o=e,this.#p())}#l=null;requestFocusRestore(e){this.#l=e}flushFocusRestore(){let e=this.#l;e==null||!e.isConnected||(this.#l=null,document.activeElement!==e&&e.focus({preventScroll:!0}))}#u=null;#d=0;getPlacementVersion=()=>this.#d;notifyPlacementChange(){this.#d++,this.#p()}setBarElement(e){this.#u=e}getBarElement=()=>this.#u;getContentMounted=()=>this.#s;setContentMounted(e){this.#s!==e&&(this.#s=e,this.#p())}register(e){let t=this.#n.get(e.id)??this.#i++;this.#n.set(e.id,t);let n={...e,sequence:t};return this.#t.set(e.id,n),this.#f(),()=>{this.#t.get(e.id)===n&&(this.#t.delete(e.id),this.#f())}}#f(){this.#a=C([...this.#t.values()]),this.#p()}#p(){for(let e of this.#e)e()}};const D=a(null),O=a(null);function k(e){let t=s(D);return h(t,`${e} must be rendered inside <AlertCenter.Root>.`),t}function A(e){let t=s(O);return h(t,`${e} must be rendered inside <AlertCenter.Root>.`),t}const j=e=>m(e.subscribe,e.getSnapshot,e.getSnapshot),M=a(!1);function N({store:e}){let t=j(e);return g(`div`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:w(m(e.subscribe,e.getTopLabel,e.getTopLabel),t.length)})}const P=({children:e,defaultOpen:t,onOpenChange:n,open:r})=>{let[i]=p(()=>new E),a=l(),[s,c]=p(t??!1),d=r??s,f=o(e=>{r??c(e),n?.(e)},[r,n]),m=u(()=>({store:i,contentId:a}),[i,a]),h=u(()=>({isExpanded:d,setExpanded:f}),[d,f]);return _(D.Provider,{value:m,children:[g(O.Provider,{value:h,children:e}),g(N,{store:i})]})},F=({children:t,className:n,id:i,intent:a})=>{let{store:o}=k(`AlertCenter.Item`);h(!s(M),`AlertCenter.Item cannot be rendered inside another item's children.`);let[c,l]=p(null);return e(()=>{l(o.getHost(i))},[o,i]),e(()=>o.register({id:i,intent:a,className:n}),[o,i,a,n]),e(()=>{o.captureHostSnapshot(i)}),c==null?null:v(g(r,{intent:a,children:g(M.Provider,{value:!0,children:t})}),c)},I=({label:n,ref:r,...a})=>{h(s(M),`AlertCenter.DismissIconButton must be composed inside an <AlertCenter.Item>'s children.`);let{store:o}=k(`AlertCenter.DismissIconButton`);m(o.subscribe,o.getPlacementVersion,o.getPlacementVersion);let c=f(null),l=t(c,r),[u,d]=p(null);return e(()=>{if(n!=null)return;let e=c.current?.closest(`[data-alert-id]`),t=e==null?``:S(e);d(t===``?null:`Dismiss ${t}`)}),g(i.DismissIconButton,{ref:l,label:n??u??void 0,...a})};function L(e,t){switch(t){case`show`:return`open`;case`hide`:return e===`closed`?`closed`:`closing`;case`exited`:return e===`closing`?`closed`:e}}function R({present:t}){let[n,r]=d(L,t?`open`:`closed`);e(()=>{r(t?`show`:`hide`)},[t]),c(()=>{if(n!==`closing`)return;let e=window.setTimeout(()=>r(`exited`),200);return()=>window.clearTimeout(e)},[n]);let i=o(e=>{e.target===e.currentTarget&&e.propertyName===`height`&&r(`exited`)},[]);return{isMounted:n!==`closed`,dataState:n===`open`?`open`:`closed`,onExitTransitionEnd:i}}function z({containerRef:t,isAttached:n}){let r=f(null);return e(()=>{let e=t.current;if(!n||e==null)return;let i=e=>{e.target instanceof Element&&(r.current=e.target)},a=t=>{t.relatedTarget instanceof Node&&!e.contains(t.relatedTarget)&&(r.current=null)};return e.addEventListener(`focusin`,i),e.addEventListener(`focusout`,a),()=>{e.removeEventListener(`focusin`,i),e.removeEventListener(`focusout`,a)}},[t,n]),{lastFocusedWithinRef:r}}function B(){let e=document.querySelector(`main, [role="main"]`);e!=null&&(e.hasAttribute(`tabindex`)||(e.tabIndex=-1),e.focus({preventScroll:!0}))}function V({isMounted:t,store:n,topId:r}){let i=f(null),{lastFocusedWithinRef:a}=z({containerRef:i,isAttached:t}),o=f(r);return e(()=>{let e=o.current;if(o.current=r,e==null||r===e)return;let t=a.current;if(n.hasAlert(e)){t instanceof HTMLElement&&document.activeElement!==t&&n.requestFocusRestore(t);return}if(t==null||t.isConnected)return;a.current=null;let s=i.current;if(r==null){B();return}s!=null&&(s.querySelector(`[data-slot="alert-dismiss-icon-button"], [data-slot="alert-expand-button"]`)??s).focus()},[n,r]),{wrapperRef:i}}const H=`gap-2 py-2 pr-2 [&_[data-slot=alert-icon]]:shrink-0`,U={Root:P,Bar:({className:t,ref:r,...a})=>{let{store:o,contentId:s}=k(`AlertCenter.Bar`),{isExpanded:c,setExpanded:l}=A(`AlertCenter.Bar`),u=j(o),d=m(o.subscribe,o.getContentMounted,o.getContentMounted),p=u[0]??null,h=p!=null,{isMounted:v,dataState:y,onExitTransitionEnd:x}=R({present:h}),C=f(p);e(()=>{p!=null&&(C.current=p)},[p]);let w=p??C.current,T=f(null);e(()=>{let e=T.current;if(e==null)return;if(p!=null){let t=o.getHost(p.id);t.parentElement!==e&&e.childNodes.length>0&&e.replaceChildren(),b(e,t)&&o.notifyPlacementChange(),o.flushFocusRestore();return}let t=w==null?null:o.getHostSnapshot(w.id);t!=null&&t.parentNode!==e&&e.replaceChildren(t)});let{wrapperRef:E}=V({isMounted:v,store:o,topId:p?.id});if(e(()=>{let e=E.current;o.setTopLabel(h&&e!=null?S(e):``)}),e(()=>{let e=E.current;if(e==null)return;let t=new MutationObserver(()=>{o.setTopLabel(h?S(e):``)});return t.observe(e,{subtree:!0,childList:!0,characterData:!0}),()=>{t.disconnect()}},[o,h,v]),e(()=>()=>{o.setTopLabel(``)},[o]),e(()=>{o.setBarElement(E.current)}),e(()=>()=>{o.setBarElement(null)},[o]),!v||w==null)return null;let D=h?u.length-1:0;return g(`div`,{ref:E,tabIndex:-1,inert:!h,className:`shrink-0 overflow-hidden transition-[height,opacity] duration-200 ease-out [interpolate-size:allow-keywords] starting:h-0 starting:opacity-0 data-state-closed:h-0 data-state-closed:opacity-0 data-state-closed:duration-150 motion-reduce:transition-none`,"data-state":y,onTransitionEnd:x,children:_(i.Root,{ref:r,appearance:`banner`,intent:w.intent,className:n(H,`not-has-data-[slot=alert-description]:[&_[data-alert-dismiss],&_[data-alert-expand]]:top-1/2 not-has-data-[slot=alert-description]:[&_[data-alert-dismiss],&_[data-alert-expand]]:-translate-y-1/2`,t,w.className),...a,"data-slot":`alert-center-bar`,"data-placement":`bar`,"data-alert-id":w.id,children:[g(`div`,{ref:T,className:`contents`,"data-slot":`alert-center-bar-mount`}),D>0&&d&&g(i.ExpandButton,{count:D,expanded:c,"aria-controls":s,onClick:()=>l(!c)})]})})},Content:({"aria-label":r=`More alerts`,"aria-labelledby":a,className:o,ref:s,...c})=>{let{store:l,contentId:u}=k(`AlertCenter.Content`),{isExpanded:d,setExpanded:p}=A(`AlertCenter.Content`),m=j(l).slice(1),h=m.length>0;e(()=>(l.setContentMounted(!0),()=>{l.setContentMounted(!1)}),[l]);let _=f(h);e(()=>{let e=_.current&&!h;_.current=h,e&&d&&p(!1)},[h,d,p]);let v=f(null),y=t(v,s),{lastFocusedWithinRef:x}=z({containerRef:v,isAttached:h}),S=m.map(e=>e.id).join(` `);return e(()=>{let e=v.current;if(e==null)return;let t=!1;for(let n of e.querySelectorAll(`[data-alert-mount]`)){let e=n.getAttribute(`data-alert-mount`);e!=null&&b(n,l.getHost(e))&&(t=!0)}t&&l.notifyPlacementChange(),l.flushFocusRestore()},[l,S]),e(()=>{let e=x.current;if(e==null)return;if(e.isConnected){let t=v.current;e instanceof HTMLElement&&document.activeElement!==e&&(t==null||!t.contains(e))&&(x.current=null,e.focus({preventScroll:!0}));return}x.current=null;let t=v.current?.querySelector(`[data-slot="alert-dismiss-icon-button"]`);if(t!=null){t.focus();return}let n=l.getBarElement()?.querySelector(`[data-slot="alert-dismiss-icon-button"], [data-slot="alert-expand-button"]`);if(n!=null){n.focus();return}B()},[l,S]),m.length===0?null:g(`div`,{...c,ref:y,"data-slot":`alert-center-content`,id:u,"data-state":d?`open`:`closed`,className:n(`h-0 overflow-hidden invisible [content-visibility:hidden] transition-[height,visibility,content-visibility] transition-discrete duration-200 ease-out [interpolate-size:allow-keywords] data-state-open:h-auto data-state-open:visible data-state-open:[content-visibility:visible] motion-reduce:transition-none`,o),children:g(`ul`,{"aria-label":a==null?r:void 0,"aria-labelledby":a,className:`flex w-full flex-col`,children:m.map(e=>g(`li`,{children:g(i.Root,{appearance:`banner`,intent:e.intent,className:n(H,e.className),"data-slot":`alert-center-item`,"data-placement":`list`,"data-alert-id":e.id,children:g(`div`,{className:`contents`,"data-alert-mount":e.id})})},e.id))})})},Item:F,DismissIconButton:I};export{U as AlertCenter};
|
package/dist/alert-dialog.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./cx-IiQEAKf5.js";import{t}from"./icon-d-nMCfAI.js";import{t as n}from"./slot-
|
|
1
|
+
import{t as e}from"./cx-IiQEAKf5.js";import{t}from"./icon-d-nMCfAI.js";import{t as n}from"./slot-Dpsqz16D.js";import{t as r}from"./button-BUospUB3.js";import{a as i,c as a,i as o,n as s,o as c,r as l,s as u,t as d}from"./primitive-Dv-3snU3.js";import{createContext as f,useContext as p,useMemo as m}from"react";import h from"tiny-invariant";import{jsx as g,jsxs as _}from"react/jsx-runtime";import{InfoIcon as v}from"@phosphor-icons/react/Info";import{WarningIcon as y}from"@phosphor-icons/react/Warning";const b=f(null);function x(){let e=p(b);return h(e,`AlertDialog child component used outside of AlertDialog parent!`),e}function S({intent:e,...t}){let n=m(()=>({intent:e}),[e]);return g(b.Provider,{value:n,children:g(c,{...t})})}const C=({ref:e,...t})=>g(a,{ref:e,"data-slot":`alert-dialog-trigger`,...t}),w=i,T=({className:t,ref:n,...r})=>g(o,{"data-slot":`alert-dialog-overlay`,className:e(`data-state-open:animate-in data-state-closed:animate-out data-state-closed:fade-out-0 data-state-open:fade-in-0 bg-overlay fixed inset-0 z-50 backdrop-blur-xs`,t),...r,ref:n}),E=({className:t,preferredWidth:n=`max-w-md`,ref:r,...i})=>_(w,{children:[g(T,{}),g(`div`,{className:`fixed inset-4 z-50 flex items-center justify-center`,children:g(s,{"data-slot":`alert-dialog-content`,"data-mantle-modal-content":!0,ref:r,className:e(`flex w-full flex-1 flex-col items-center gap-4 sm:flex-row sm:items-start`,`outline-hidden focus-within:outline-hidden`,`p-6`,`border-dialog bg-dialog rounded-xl border shadow-lg transition-transform duration-200`,`data-state-closed:animate-out data-state-closed:fade-out-0 data-state-closed:zoom-out-95 data-state-open:animate-in data-state-open:fade-in-0 data-state-open:zoom-in-95`,n,t),...i})})]}),D=({asChild:t=!1,className:r,ref:i,...a})=>g(t?n:`div`,{"data-slot":`alert-dialog-body`,className:e(`flex-1 space-y-4`,r),ref:i,...a}),O=({asChild:t=!1,className:r,ref:i,...a})=>g(t?n:`div`,{"data-slot":`alert-dialog-header`,className:e(`flex flex-col space-y-2 text-center sm:text-start`,r),ref:i,...a}),k=({asChild:t=!1,className:r,ref:i,...a})=>g(t?n:`div`,{"data-slot":`alert-dialog-footer`,className:e(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,r),ref:i,...a}),A=({className:t,ref:n,...r})=>g(u,{ref:n,"data-slot":`alert-dialog-title`,className:e(`text-strong text-center text-lg font-medium sm:text-start`,t),...r}),j=({className:t,ref:n,...r})=>g(l,{ref:n,"data-slot":`alert-dialog-description`,className:e(`text-body text-center text-sm font-normal sm:text-start`,t),...r}),M={danger:`danger`,info:`neutral`},N=({appearance:e=`filled`,intent:t,ref:n,...i})=>{let a=x(),o=M[a.intent];return g(r,{appearance:e,"data-slot":`alert-dialog-action`,intent:t??o,ref:n,...i})},P=({appearance:t=`outlined`,className:n,intent:i=`neutral`,ref:a,...o})=>g(d,{asChild:!0,children:g(r,{appearance:t,"data-slot":`alert-dialog-cancel`,className:e(`mt-2 sm:mt-0`,n),intent:i,ref:a,...o})}),F={danger:g(y,{}),info:g(v,{})},I={danger:`text-danger-600`,info:`text-accent-600`},L={Root:S,Action:N,Body:D,Cancel:P,Close:({ref:e,...t})=>g(d,{ref:e,"data-slot":`alert-dialog-close`,...t}),Content:E,Description:j,Footer:k,Header:O,Icon:({className:n,ref:r,svg:i,...a})=>{let o=x(),s=I[o.intent],c=F[o.intent];return g(t,{ref:r,"data-slot":`alert-dialog-icon`,className:e(`size-12 sm:size-7`,s,n),svg:i??c,...a})},Title:A,Trigger:C};export{L as AlertDialog};
|