@arcfusionz/arc-primitive-ui 0.1.0 → 0.2.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/components/AILoader/AILoader.d.ts +32 -0
- package/dist/components/AILoader/AILoader.js +157 -0
- package/dist/components/AILoader/index.d.ts +2 -0
- package/dist/components/AILoader/index.js +2 -0
- package/dist/components/Accordion/Accordion.d.ts +96 -0
- package/dist/components/Accordion/Accordion.js +149 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/Accordion/index.js +2 -0
- package/dist/components/Avatar/Avatar.d.ts +152 -0
- package/dist/components/Avatar/Avatar.js +216 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Avatar/index.js +2 -0
- package/dist/components/Badge/Badge.d.ts +87 -0
- package/dist/components/Badge/Badge.js +118 -0
- package/dist/components/Badge/index.d.ts +2 -0
- package/dist/components/Badge/index.js +2 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +109 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +182 -0
- package/dist/components/Breadcrumb/index.d.ts +2 -0
- package/dist/components/Breadcrumb/index.js +2 -0
- package/dist/components/Button/Button.d.ts +57 -0
- package/dist/components/Button/Button.js +177 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Button/index.js +2 -0
- package/dist/components/Calendar/Calendar.d.ts +140 -0
- package/dist/components/Calendar/Calendar.js +468 -0
- package/dist/components/Calendar/index.d.ts +2 -0
- package/dist/components/Calendar/index.js +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +60 -0
- package/dist/components/Checkbox/Checkbox.js +129 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/Checkbox/index.js +2 -0
- package/dist/components/Combobox/Combobox.d.ts +251 -0
- package/dist/components/Combobox/Combobox.js +354 -0
- package/dist/components/Combobox/index.d.ts +2 -0
- package/dist/components/Combobox/index.js +2 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +129 -0
- package/dist/components/ContextMenu/ContextMenu.js +93 -0
- package/dist/components/ContextMenu/index.d.ts +2 -0
- package/dist/components/ContextMenu/index.js +2 -0
- package/dist/components/DatePicker/DatePicker.d.ts +109 -0
- package/dist/components/DatePicker/DatePicker.js +145 -0
- package/dist/components/DatePicker/index.d.ts +2 -0
- package/dist/components/DatePicker/index.js +2 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +107 -0
- package/dist/components/DateRangePicker/DateRangePicker.js +161 -0
- package/dist/components/DateRangePicker/index.d.ts +2 -0
- package/dist/components/DateRangePicker/index.js +2 -0
- package/dist/components/Dialog/Dialog.d.ts +112 -0
- package/dist/components/Dialog/Dialog.js +141 -0
- package/dist/components/Dialog/index.d.ts +2 -0
- package/dist/components/Dialog/index.js +2 -0
- package/dist/components/Drawer/Drawer.d.ts +188 -0
- package/dist/components/Drawer/Drawer.js +268 -0
- package/dist/components/Drawer/index.d.ts +2 -0
- package/dist/components/Drawer/index.js +2 -0
- package/dist/components/Field/Field.d.ts +123 -0
- package/dist/components/Field/Field.js +241 -0
- package/dist/components/Field/FieldContext.d.ts +43 -0
- package/dist/components/Field/FieldContext.js +28 -0
- package/dist/components/Field/index.d.ts +3 -0
- package/dist/components/Field/index.js +3 -0
- package/dist/components/Fieldset/Fieldset.d.ts +43 -0
- package/dist/components/Fieldset/Fieldset.js +48 -0
- package/dist/components/Fieldset/index.d.ts +2 -0
- package/dist/components/Fieldset/index.js +2 -0
- package/dist/components/Form/Form.d.ts +54 -0
- package/dist/components/Form/Form.js +57 -0
- package/dist/components/Form/index.d.ts +2 -0
- package/dist/components/Form/index.js +2 -0
- package/dist/components/Input/Input.d.ts +64 -0
- package/dist/components/Input/Input.js +111 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Input/index.js +2 -0
- package/dist/components/Menu/Menu.d.ts +212 -0
- package/dist/components/Menu/Menu.js +255 -0
- package/dist/components/Menu/index.d.ts +2 -0
- package/dist/components/Menu/index.js +2 -0
- package/dist/components/Popover/Popover.d.ts +122 -0
- package/dist/components/Popover/Popover.js +116 -0
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/components/Popover/index.js +2 -0
- package/dist/components/Progress/Progress.d.ts +87 -0
- package/dist/components/Progress/Progress.js +73 -0
- package/dist/components/Progress/index.d.ts +2 -0
- package/dist/components/Progress/index.js +2 -0
- package/dist/components/Radio/Radio.d.ts +65 -0
- package/dist/components/Radio/Radio.js +93 -0
- package/dist/components/Radio/index.d.ts +2 -0
- package/dist/components/Radio/index.js +2 -0
- package/dist/components/Select/Select.d.ts +136 -0
- package/dist/components/Select/Select.js +219 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Select/index.js +2 -0
- package/dist/components/Skeleton/Skeleton.d.ts +39 -0
- package/dist/components/Skeleton/Skeleton.js +44 -0
- package/dist/components/Skeleton/index.d.ts +2 -0
- package/dist/components/Skeleton/index.js +2 -0
- package/dist/components/Stepper/Stepper.d.ts +161 -0
- package/dist/components/Stepper/Stepper.js +344 -0
- package/dist/components/Stepper/index.d.ts +2 -0
- package/dist/components/Stepper/index.js +2 -0
- package/dist/components/Switch/Switch.d.ts +56 -0
- package/dist/components/Switch/Switch.js +87 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/index.js +2 -0
- package/dist/components/Table/Table.d.ts +116 -0
- package/dist/components/Table/Table.js +143 -0
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/Table/index.js +2 -0
- package/dist/components/Tabs/Tabs.d.ts +116 -0
- package/dist/components/Tabs/Tabs.js +158 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Timeline/Timeline.d.ts +137 -0
- package/dist/components/Timeline/Timeline.js +243 -0
- package/dist/components/Timeline/index.d.ts +2 -0
- package/dist/components/Timeline/index.js +2 -0
- package/dist/components/Toast/Toast.d.ts +135 -0
- package/dist/components/Toast/Toast.js +314 -0
- package/dist/components/Toast/index.d.ts +2 -0
- package/dist/components/Toast/index.js +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +104 -0
- package/dist/components/Tooltip/Tooltip.js +95 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/components/Tooltip/index.js +2 -0
- package/dist/components/Typography/Typography.d.ts +38 -0
- package/dist/components/Typography/Typography.js +53 -0
- package/dist/components/Typography/index.d.ts +2 -0
- package/dist/components/Typography/index.js +2 -0
- package/dist/index.d.ts +66 -3398
- package/dist/index.js +34 -5343
- package/dist/lib/cn.d.ts +6 -0
- package/dist/lib/cn.js +9 -0
- package/package.json +6 -2
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import { createContext, forwardRef, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
5
|
+
//#region src/components/Timeline/Timeline.tsx
|
|
6
|
+
const TimelineContext = createContext({ size: "md" });
|
|
7
|
+
const itemGapClasses = {
|
|
8
|
+
sm: "gap-x-2",
|
|
9
|
+
md: "gap-x-3",
|
|
10
|
+
lg: "gap-x-4"
|
|
11
|
+
};
|
|
12
|
+
const connectorClasses = "flex flex-col items-center gap-1 pb-1";
|
|
13
|
+
const connectorSizeClasses = {
|
|
14
|
+
sm: "pt-0.5",
|
|
15
|
+
md: "",
|
|
16
|
+
lg: ""
|
|
17
|
+
};
|
|
18
|
+
const indicatorClasses = "flex shrink-0 select-none items-center justify-center rounded-full font-sans text-xs font-medium tabular-nums [&_svg]:pointer-events-none [&_svg]:shrink-0";
|
|
19
|
+
const indicatorSizeClasses = {
|
|
20
|
+
sm: "size-4 [&_svg:not([class*='size-'])]:size-2.5",
|
|
21
|
+
md: "size-5 [&_svg:not([class*='size-'])]:size-3",
|
|
22
|
+
lg: "size-6 [&_svg:not([class*='size-'])]:size-3.5"
|
|
23
|
+
};
|
|
24
|
+
const indicatorAppearanceClasses = {
|
|
25
|
+
solid: {
|
|
26
|
+
neutral: "bg-foreground text-background",
|
|
27
|
+
primary: "bg-primary text-primary-foreground",
|
|
28
|
+
success: "bg-success-700 text-success-foreground",
|
|
29
|
+
warning: "bg-warning text-warning-950",
|
|
30
|
+
destructive: "bg-destructive text-destructive-foreground"
|
|
31
|
+
},
|
|
32
|
+
soft: {
|
|
33
|
+
neutral: "bg-muted text-slate-700",
|
|
34
|
+
primary: "bg-primary-50 text-primary-700",
|
|
35
|
+
success: "bg-success-50 text-success-700",
|
|
36
|
+
warning: "bg-warning-50 text-warning-800",
|
|
37
|
+
destructive: "bg-error-50 text-error-700"
|
|
38
|
+
},
|
|
39
|
+
outline: {
|
|
40
|
+
neutral: "border border-slate-400 bg-background text-slate-700",
|
|
41
|
+
primary: "border border-primary-400 bg-background text-primary-700",
|
|
42
|
+
success: "border border-success-400 bg-background text-success-700",
|
|
43
|
+
warning: "border border-warning-400 bg-background text-warning-800",
|
|
44
|
+
destructive: "border border-error-400 bg-background text-error-700"
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const separatorClasses = "w-0 flex-1 border-s border-border";
|
|
48
|
+
const separatorVariantClasses = {
|
|
49
|
+
solid: "",
|
|
50
|
+
dashed: "border-dashed"
|
|
51
|
+
};
|
|
52
|
+
const contentClasses = "min-w-0 flex-1 group-last/item:pb-0";
|
|
53
|
+
const contentSizeClasses = {
|
|
54
|
+
sm: "pb-4",
|
|
55
|
+
md: "pb-6",
|
|
56
|
+
lg: "pb-8"
|
|
57
|
+
};
|
|
58
|
+
const titleClasses = "block font-sans font-medium text-foreground";
|
|
59
|
+
const titleSizeClasses = {
|
|
60
|
+
sm: "text-sm",
|
|
61
|
+
md: "text-sm",
|
|
62
|
+
lg: "text-base"
|
|
63
|
+
};
|
|
64
|
+
const descriptionClasses = "block font-sans text-muted-foreground";
|
|
65
|
+
const descriptionSizeClasses = {
|
|
66
|
+
sm: "text-xs",
|
|
67
|
+
md: "text-sm",
|
|
68
|
+
lg: "text-sm"
|
|
69
|
+
};
|
|
70
|
+
const timeClasses = "block font-sans text-muted-foreground tabular-nums";
|
|
71
|
+
const timeSizeClasses = {
|
|
72
|
+
sm: "text-xs",
|
|
73
|
+
md: "text-xs",
|
|
74
|
+
lg: "text-sm"
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* A chronological list of events, marked up as an ordered list. The timeline
|
|
78
|
+
* is display-only — it holds no current-step state (progress through a flow
|
|
79
|
+
* is Stepper's job) and renders whatever order it receives; feeds usually
|
|
80
|
+
* pass newest-first. Give the list an accessible name (`aria-label` or
|
|
81
|
+
* `aria-labelledby`, e.g. "Deployment history") when the surrounding context
|
|
82
|
+
* doesn't already announce one.
|
|
83
|
+
*/
|
|
84
|
+
const Timeline = forwardRef(({ size = "md", render, className, ...rest }, ref) => {
|
|
85
|
+
const element = useRender({
|
|
86
|
+
defaultTagName: "ol",
|
|
87
|
+
render,
|
|
88
|
+
ref,
|
|
89
|
+
props: {
|
|
90
|
+
role: "list",
|
|
91
|
+
...rest,
|
|
92
|
+
className: cn("flex flex-col", className)
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return /* @__PURE__ */ jsx(TimelineContext.Provider, {
|
|
96
|
+
value: { size },
|
|
97
|
+
children: element
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
Timeline.displayName = "Timeline";
|
|
101
|
+
/**
|
|
102
|
+
* One event: a flex row of an optional leading `TimelineContent` (opposite
|
|
103
|
+
* side), the `TimelineConnector` column, and the trailing `TimelineContent`.
|
|
104
|
+
*/
|
|
105
|
+
const TimelineItem = forwardRef(({ render, className, ...rest }, ref) => {
|
|
106
|
+
const { size } = useContext(TimelineContext);
|
|
107
|
+
return useRender({
|
|
108
|
+
defaultTagName: "li",
|
|
109
|
+
render,
|
|
110
|
+
ref,
|
|
111
|
+
props: {
|
|
112
|
+
...rest,
|
|
113
|
+
className: cn("group/item flex", itemGapClasses[size], className)
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
TimelineItem.displayName = "TimelineItem";
|
|
118
|
+
/**
|
|
119
|
+
* The marker column: it stretches to the item's height and stacks the
|
|
120
|
+
* `TimelineIndicator` above the `TimelineSeparator`, which fills the rest —
|
|
121
|
+
* so the rail always reaches the next item's marker, however tall the
|
|
122
|
+
* content grows.
|
|
123
|
+
*/
|
|
124
|
+
const TimelineConnector = forwardRef(({ render, className, ...rest }, ref) => {
|
|
125
|
+
const { size } = useContext(TimelineContext);
|
|
126
|
+
return useRender({
|
|
127
|
+
defaultTagName: "div",
|
|
128
|
+
render,
|
|
129
|
+
ref,
|
|
130
|
+
props: {
|
|
131
|
+
...rest,
|
|
132
|
+
className: cn(connectorClasses, connectorSizeClasses[size], className)
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
TimelineConnector.displayName = "TimelineConnector";
|
|
137
|
+
/**
|
|
138
|
+
* The event's marker. Empty it renders as a plain dot; children (an icon, a
|
|
139
|
+
* spinner, a letter) center inside it. Glyphs are decorative next to the
|
|
140
|
+
* event's own text — mark them `aria-hidden`; when the marker alone carries
|
|
141
|
+
* meaning (a bare status dot), pair it with visually-hidden text in the
|
|
142
|
+
* content instead.
|
|
143
|
+
*/
|
|
144
|
+
const TimelineIndicator = forwardRef(({ variant = "neutral", appearance = "solid", render, className, ...rest }, ref) => {
|
|
145
|
+
const { size } = useContext(TimelineContext);
|
|
146
|
+
return useRender({
|
|
147
|
+
defaultTagName: "span",
|
|
148
|
+
render,
|
|
149
|
+
ref,
|
|
150
|
+
props: {
|
|
151
|
+
...rest,
|
|
152
|
+
className: cn(indicatorClasses, indicatorSizeClasses[size], indicatorAppearanceClasses[appearance][variant], className)
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
TimelineIndicator.displayName = "TimelineIndicator";
|
|
157
|
+
/**
|
|
158
|
+
* The rail segment below a marker, connecting it to the next event. Omit it
|
|
159
|
+
* on the last item so the timeline ends at its final marker.
|
|
160
|
+
*/
|
|
161
|
+
const TimelineSeparator = forwardRef(({ variant = "solid", render, className, ...rest }, ref) => {
|
|
162
|
+
return useRender({
|
|
163
|
+
defaultTagName: "span",
|
|
164
|
+
render,
|
|
165
|
+
ref,
|
|
166
|
+
props: {
|
|
167
|
+
role: "presentation",
|
|
168
|
+
"aria-hidden": "true",
|
|
169
|
+
...rest,
|
|
170
|
+
className: cn(separatorClasses, separatorVariantClasses[variant], className)
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
TimelineSeparator.displayName = "TimelineSeparator";
|
|
175
|
+
/**
|
|
176
|
+
* The event's body, holding `TimelineTitle` / `TimelineTime` /
|
|
177
|
+
* `TimelineDescription` or any richer blocks. It carries the spacing between
|
|
178
|
+
* items, so the connector's rail spans the full distance to the next marker.
|
|
179
|
+
* Place one before the connector for opposite-side content (dates in a
|
|
180
|
+
* roadmap, alternating layouts).
|
|
181
|
+
*/
|
|
182
|
+
const TimelineContent = forwardRef(({ render, className, ...rest }, ref) => {
|
|
183
|
+
const { size } = useContext(TimelineContext);
|
|
184
|
+
return useRender({
|
|
185
|
+
defaultTagName: "div",
|
|
186
|
+
render,
|
|
187
|
+
ref,
|
|
188
|
+
props: {
|
|
189
|
+
...rest,
|
|
190
|
+
className: cn(contentClasses, contentSizeClasses[size], className)
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
TimelineContent.displayName = "TimelineContent";
|
|
195
|
+
/** The event's one-line headline. */
|
|
196
|
+
const TimelineTitle = forwardRef(({ render, className, ...rest }, ref) => {
|
|
197
|
+
const { size } = useContext(TimelineContext);
|
|
198
|
+
return useRender({
|
|
199
|
+
defaultTagName: "span",
|
|
200
|
+
render,
|
|
201
|
+
ref,
|
|
202
|
+
props: {
|
|
203
|
+
...rest,
|
|
204
|
+
className: cn(titleClasses, titleSizeClasses[size], className)
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
TimelineTitle.displayName = "TimelineTitle";
|
|
209
|
+
/** Supporting copy under the title. */
|
|
210
|
+
const TimelineDescription = forwardRef(({ render, className, ...rest }, ref) => {
|
|
211
|
+
const { size } = useContext(TimelineContext);
|
|
212
|
+
return useRender({
|
|
213
|
+
defaultTagName: "span",
|
|
214
|
+
render,
|
|
215
|
+
ref,
|
|
216
|
+
props: {
|
|
217
|
+
...rest,
|
|
218
|
+
className: cn(descriptionClasses, descriptionSizeClasses[size], className)
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
TimelineDescription.displayName = "TimelineDescription";
|
|
223
|
+
/**
|
|
224
|
+
* The event's timestamp as a real `<time>` element. Feeds abbreviate the
|
|
225
|
+
* visible text ("3h", "May 12") — keep the absolute moment machine-readable
|
|
226
|
+
* in `dateTime`, and put it in the human-readable `title` when the visible
|
|
227
|
+
* form is relative.
|
|
228
|
+
*/
|
|
229
|
+
const TimelineTime = forwardRef(({ render, className, ...rest }, ref) => {
|
|
230
|
+
const { size } = useContext(TimelineContext);
|
|
231
|
+
return useRender({
|
|
232
|
+
defaultTagName: "time",
|
|
233
|
+
render,
|
|
234
|
+
ref,
|
|
235
|
+
props: {
|
|
236
|
+
...rest,
|
|
237
|
+
className: cn(timeClasses, timeSizeClasses[size], className)
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
TimelineTime.displayName = "TimelineTime";
|
|
242
|
+
//#endregion
|
|
243
|
+
export { Timeline, TimelineConnector, TimelineContent, TimelineDescription, TimelineIndicator, TimelineItem, TimelineSeparator, TimelineTime, TimelineTitle };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Timeline, TimelineConnector, TimelineConnectorProps, TimelineContent, TimelineContentProps, TimelineDescription, TimelineDescriptionProps, TimelineIndicator, TimelineIndicatorAppearance, TimelineIndicatorProps, TimelineIndicatorVariant, TimelineItem, TimelineItemProps, TimelineProps, TimelineSeparator, TimelineSeparatorProps, TimelineSeparatorVariant, TimelineSize, TimelineTime, TimelineTimeProps, TimelineTitle, TimelineTitleProps } from "./Timeline.js";
|
|
2
|
+
export { Timeline, TimelineConnector, type TimelineConnectorProps, TimelineContent, type TimelineContentProps, TimelineDescription, type TimelineDescriptionProps, TimelineIndicator, type TimelineIndicatorAppearance, type TimelineIndicatorProps, type TimelineIndicatorVariant, TimelineItem, type TimelineItemProps, type TimelineProps, TimelineSeparator, type TimelineSeparatorProps, type TimelineSeparatorVariant, type TimelineSize, TimelineTime, type TimelineTimeProps, TimelineTitle, type TimelineTitleProps };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Timeline, TimelineConnector, TimelineContent, TimelineDescription, TimelineIndicator, TimelineItem, TimelineSeparator, TimelineTime, TimelineTitle } from "./Timeline.js";
|
|
2
|
+
export { Timeline, TimelineConnector, TimelineContent, TimelineDescription, TimelineIndicator, TimelineItem, TimelineSeparator, TimelineTime, TimelineTitle };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { Toast, ToastManager, ToastManagerAddOptions, ToastManagerPromiseOptions, ToastManagerUpdateOptions, ToastObject } from "@base-ui/react/toast";
|
|
3
|
+
//#region src/components/Toast/Toast.d.ts
|
|
4
|
+
type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
5
|
+
/**
|
|
6
|
+
* The severity values the built-in styling recognizes (icon + color, and
|
|
7
|
+
* `loading` renders a spinner). Base UI's `type` field is an open string —
|
|
8
|
+
* unknown values render the neutral look with no icon.
|
|
9
|
+
*/
|
|
10
|
+
type ToastType = "success" | "error" | "warning" | "info" | "loading";
|
|
11
|
+
/** Per-toast extension data the ArcFusion `Toaster` understands. */
|
|
12
|
+
interface ToastData {
|
|
13
|
+
/**
|
|
14
|
+
* Custom leading icon, replacing the automatic `type` icon. Sized to the
|
|
15
|
+
* 20px slot unless the node carries its own `size-*` class.
|
|
16
|
+
*/
|
|
17
|
+
icon?: ReactNode;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** Options for `toast.add` — Base UI's add options with ArcFusion `data`. */
|
|
21
|
+
interface ToastOptions extends ToastManagerAddOptions<ToastData> {}
|
|
22
|
+
/** Options for `toast.update` and the object states of `toast.promise`. */
|
|
23
|
+
interface ToastUpdateOptions extends ToastManagerUpdateOptions<ToastData> {}
|
|
24
|
+
/** State map for `toast.promise` — strings are shorthand for `{ title }`. */
|
|
25
|
+
type ToastPromiseOptions<Value> = ToastManagerPromiseOptions<Value, ToastData>;
|
|
26
|
+
/** A toast manager, as returned by `createToastManager()`. */
|
|
27
|
+
type ToastManager$1<Data extends object = any> = ToastManager<Data>;
|
|
28
|
+
/** A queued toast as the manager tracks it (id, content, type, timing). */
|
|
29
|
+
type ToastObject$1<Data extends object = ToastData> = ToastObject<Data>;
|
|
30
|
+
/**
|
|
31
|
+
* Creates an isolated toast manager for a scoped `<Toaster />` (a preview
|
|
32
|
+
* frame, a second stack with different placement, tests). Pass it to that
|
|
33
|
+
* Toaster's `toastManager` prop and call `manager.add/close/update/promise`
|
|
34
|
+
* on it directly — the `toast` helpers always target the built-in default
|
|
35
|
+
* manager, not scoped ones.
|
|
36
|
+
*/
|
|
37
|
+
declare const createToastManager: typeof Toast.createToastManager;
|
|
38
|
+
type ToastHelperOptions = Omit<ToastOptions, "title" | "type">;
|
|
39
|
+
/**
|
|
40
|
+
* Imperative toast API, callable from anywhere — components, stores, fetch
|
|
41
|
+
* wrappers. Requires one default `<Toaster />` (no `toastManager` prop)
|
|
42
|
+
* mounted in the app. Every method accepts Base UI's full option set
|
|
43
|
+
* (`description`, `timeout`, `priority`, `onClose`, `actionProps`,
|
|
44
|
+
* `data.icon`, …); `add` with an existing `id` updates that toast in place,
|
|
45
|
+
* which is how repeated events deduplicate.
|
|
46
|
+
*/
|
|
47
|
+
declare const toast: {
|
|
48
|
+
/** Queue a toast with full control over its options. Returns the toast id. */
|
|
49
|
+
add(options: ToastOptions): string;
|
|
50
|
+
/** Success feedback: green check icon, polite announcement. */
|
|
51
|
+
success(title: ReactNode, options?: ToastHelperOptions): string;
|
|
52
|
+
/** Informational notice: blue info icon, polite announcement. */
|
|
53
|
+
info(title: ReactNode, options?: ToastHelperOptions): string;
|
|
54
|
+
/** Warning: amber triangle icon, polite announcement. */
|
|
55
|
+
warning(title: ReactNode, options?: ToastHelperOptions): string;
|
|
56
|
+
/**
|
|
57
|
+
* Failure feedback: red icon, announced assertively (`priority: "high"`)
|
|
58
|
+
* so screen readers interrupt with it, as errors warrant. For critical
|
|
59
|
+
* errors the user must act on, add `timeout: 0` so the toast persists.
|
|
60
|
+
*/
|
|
61
|
+
error(title: ReactNode, options?: ToastHelperOptions): string;
|
|
62
|
+
/**
|
|
63
|
+
* Spinner toast for manual async flows. Never auto-dismisses (the
|
|
64
|
+
* operation decides when it ends) — resolve it via
|
|
65
|
+
* `toast.update(id, { type: "success", … })` or `toast.close(id)`.
|
|
66
|
+
* Prefer `toast.promise` when a promise already models the operation.
|
|
67
|
+
*/
|
|
68
|
+
loading(title: ReactNode, options?: ToastHelperOptions): string;
|
|
69
|
+
/**
|
|
70
|
+
* One toast tracking a promise through loading → success/error, switching
|
|
71
|
+
* `type` (spinner → check/cross) at each step. States take a string
|
|
72
|
+
* (shorthand for the title), an options object, or — for
|
|
73
|
+
* `success`/`error` — a function of the resolved value/rejection reason.
|
|
74
|
+
* Returns the input promise's result, so it can be awaited in place.
|
|
75
|
+
*/
|
|
76
|
+
promise<Value>(promise: Promise<Value>, options: ToastPromiseOptions<Value>): Promise<Value>;
|
|
77
|
+
/** Update a queued toast in place (content, type, timing) by id. */
|
|
78
|
+
update(toastId: string, options: ToastUpdateOptions): void;
|
|
79
|
+
/** Close one toast by id, or every toast when called with no argument. */
|
|
80
|
+
close(toastId?: string): void;
|
|
81
|
+
};
|
|
82
|
+
interface ToasterProps extends Omit<ComponentPropsWithoutRef<typeof Toast.Viewport>, "className" | "children"> {
|
|
83
|
+
/**
|
|
84
|
+
* Screen corner or edge the stack anchors to. Toasts enter from, exit
|
|
85
|
+
* toward, and swipe-dismiss past the nearest edges. `bottom-right` is the
|
|
86
|
+
* desktop convention; prefer a `*-center` position on mobile-first
|
|
87
|
+
* surfaces.
|
|
88
|
+
*/
|
|
89
|
+
position?: ToastPosition;
|
|
90
|
+
/**
|
|
91
|
+
* Maximum number of toasts shown at once — older ones hide (`inert`)
|
|
92
|
+
* until room frees up. The cap keeps bursts from covering the page.
|
|
93
|
+
*/
|
|
94
|
+
limit?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Default auto-dismiss delay in ms; per-toast `timeout` overrides it and
|
|
97
|
+
* `0` persists until dismissed. Timers pause while the stack is hovered
|
|
98
|
+
* or focused, so reading is never raced.
|
|
99
|
+
*/
|
|
100
|
+
timeout?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Render toasts from this manager (see `createToastManager`) instead of
|
|
103
|
+
* the built-in one the `toast` helpers target. Mount exactly one Toaster
|
|
104
|
+
* per manager — two Toasters on the same manager render every toast
|
|
105
|
+
* twice.
|
|
106
|
+
*/
|
|
107
|
+
toastManager?: ToastManager$1;
|
|
108
|
+
/** Element the stack portals into instead of `<body>` — for scoped stacking contexts or inline previews. */
|
|
109
|
+
container?: ComponentPropsWithoutRef<typeof Toast.Portal>["container"];
|
|
110
|
+
/** Accessible name of each toast's dismiss button — localize it alongside your content. */
|
|
111
|
+
closeLabel?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Applied to the viewport. Sizing hook: the stack is 22.5rem wide on
|
|
114
|
+
* `sm+` (full-width minus margins below) — override with `sm:w-*`.
|
|
115
|
+
*/
|
|
116
|
+
className?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The toast stack. Mount one per app (typically at the root); after that,
|
|
120
|
+
* `toast.success("Saved")` & co. work from anywhere. Bundles Base UI's
|
|
121
|
+
* Provider, Portal, and Viewport with fully styled toasts: severity icon,
|
|
122
|
+
* title, description, optional action button, and an always-visible
|
|
123
|
+
* dismiss button.
|
|
124
|
+
*
|
|
125
|
+
* Collapsed toasts stack with a peek; hovering or focusing the stack
|
|
126
|
+
* expands it and pauses dismiss timers. Every toast can be dismissed by
|
|
127
|
+
* pointer (×), swipe, or keyboard, and F6 jumps focus into the stack.
|
|
128
|
+
* Announcements use the toast's `title`/`description` strings — polite by
|
|
129
|
+
* default, assertive for `priority: "high"`. The stack portals to `<body>`;
|
|
130
|
+
* consumer apps should set `isolation: isolate` on their root so page
|
|
131
|
+
* stacking contexts stay below it.
|
|
132
|
+
*/
|
|
133
|
+
declare const Toaster: import("react").ForwardRefExoticComponent<ToasterProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
134
|
+
//#endregion
|
|
135
|
+
export { ToastData, ToastManager$1 as ToastManager, ToastObject$1 as ToastObject, ToastOptions, ToastPosition, ToastPromiseOptions, ToastType, ToastUpdateOptions, Toaster, ToasterProps, createToastManager, toast };
|