@forte-ui/react 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +240 -0
- package/dist/Accordion-9JunkjgY.js +111 -0
- package/dist/Alert-Cn_WUF3L.js +183 -0
- package/dist/AspectRatio-gSjpTVk-.js +39 -0
- package/dist/Avatar-BuitDluH.js +87 -0
- package/dist/Badge-sArNWMre.js +33 -0
- package/dist/Breadcrumb-Cq7tFtMX.js +170 -0
- package/dist/Button-AiyKnx5I.js +42 -0
- package/dist/ButtonGroup-C-CrwPXP.js +54 -0
- package/dist/Calendar-D7Q-QJ_e.js +503 -0
- package/dist/Checkbox-DfNbmOed.js +56 -0
- package/dist/Collapsible-D8UKiGip.js +86 -0
- package/dist/ColorPicker-B-eCI31W.js +612 -0
- package/dist/Combobox-D-BN-Tvp.js +302 -0
- package/dist/ContextMenu-D81uDaMG.js +44 -0
- package/dist/DatePicker-CfkMsaI-.js +192 -0
- package/dist/Dialog-_n8FpFs5.js +432 -0
- package/dist/Drawer-DKQF3OO7.js +158 -0
- package/dist/Field-FLFEO70D.js +58 -0
- package/dist/Fieldset-CYhh71Qt.js +28 -0
- package/dist/Form-DVPmW9XV.js +17 -0
- package/dist/Input-BgGWhO2q.js +18 -0
- package/dist/InputGroup-DsZyDXNn.js +89 -0
- package/dist/Menu-CKu9xE2h.js +261 -0
- package/dist/Menubar-Dax027Db.js +19 -0
- package/dist/NavList-DGvcIoJm.js +176 -0
- package/dist/NavigationMenu-BayQkUUb.js +209 -0
- package/dist/NumberField-P55SA8T7.js +191 -0
- package/dist/OTPField-CjHvBNSN.js +55 -0
- package/dist/Popover-BXhn2Wwt.js +142 -0
- package/dist/PreviewCard-Dnitrky0.js +99 -0
- package/dist/Progress-BlomDp-X.js +81 -0
- package/dist/ProgressCircle-j6XBl0fk.js +112 -0
- package/dist/Radio-BIcX4INJ.js +37 -0
- package/dist/Resizable-7nJJM97e.js +609 -0
- package/dist/ScrollArea-CBMGJ6hh.js +83 -0
- package/dist/Select-BP-zvdXm.js +237 -0
- package/dist/Separator-DewJBzaJ.js +21 -0
- package/dist/Skeleton-zr6ObCCq.js +79 -0
- package/dist/Slider-Bh8_cti1.js +104 -0
- package/dist/Spinner-BF0uD4hR.js +53 -0
- package/dist/Switch-OBewMMvM.js +39 -0
- package/dist/Tabs-LgkSbPSF.js +132 -0
- package/dist/Textarea-CqZJL41e.js +51 -0
- package/dist/Toast-BWayxAcd.js +304 -0
- package/dist/Toggle-BrhMnkF5.js +45 -0
- package/dist/Toolbar-OmOVCk3i.js +88 -0
- package/dist/Tooltip-CI4chsRw.js +101 -0
- package/dist/clsx-By2n9mTe.js +16 -0
- package/dist/cn.d.ts +8 -0
- package/dist/cn.js +11 -0
- package/dist/components/accordion/Accordion.d.ts +117 -0
- package/dist/components/accordion/Accordion.js +3 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +2 -0
- package/dist/components/alert/Alert.d.ts +167 -0
- package/dist/components/alert/Alert.js +3 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +2 -0
- package/dist/components/aspect-ratio/AspectRatio.d.ts +128 -0
- package/dist/components/aspect-ratio/AspectRatio.js +3 -0
- package/dist/components/aspect-ratio/index.d.ts +2 -0
- package/dist/components/aspect-ratio/index.js +2 -0
- package/dist/components/avatar/Avatar.d.ts +176 -0
- package/dist/components/avatar/Avatar.js +3 -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 +117 -0
- package/dist/components/badge/Badge.js +3 -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 +244 -0
- package/dist/components/breadcrumb/Breadcrumb.js +3 -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 +73 -0
- package/dist/components/button/Button.js +3 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +2 -0
- package/dist/components/button-group/ButtonGroup.d.ts +113 -0
- package/dist/components/button-group/ButtonGroup.js +3 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/button-group/index.js +2 -0
- package/dist/components/calendar/Calendar.d.ts +201 -0
- package/dist/components/calendar/Calendar.js +3 -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 +130 -0
- package/dist/components/checkbox/Checkbox.js +3 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +2 -0
- package/dist/components/collapsible/Collapsible.d.ts +91 -0
- package/dist/components/collapsible/Collapsible.js +3 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/collapsible/index.js +2 -0
- package/dist/components/color-picker/ColorPicker.d.ts +553 -0
- package/dist/components/color-picker/ColorPicker.js +4 -0
- package/dist/components/color-picker/color.d.ts +102 -0
- package/dist/components/color-picker/color.js +249 -0
- package/dist/components/color-picker/index.d.ts +2 -0
- package/dist/components/color-picker/index.js +3 -0
- package/dist/components/combobox/Combobox.d.ts +553 -0
- package/dist/components/combobox/Combobox.js +3 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +2 -0
- package/dist/components/context-menu/ContextMenu.d.ts +103 -0
- package/dist/components/context-menu/ContextMenu.js +3 -0
- package/dist/components/context-menu/index.d.ts +3 -0
- package/dist/components/context-menu/index.js +2 -0
- package/dist/components/date-picker/DatePicker.d.ts +268 -0
- package/dist/components/date-picker/DatePicker.js +3 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +2 -0
- package/dist/components/dialog/Dialog.d.ts +567 -0
- package/dist/components/dialog/Dialog.js +3 -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 +351 -0
- package/dist/components/drawer/Drawer.js +3 -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 +170 -0
- package/dist/components/field/Field.js +3 -0
- package/dist/components/field/index.d.ts +2 -0
- package/dist/components/field/index.js +2 -0
- package/dist/components/fieldset/Fieldset.d.ts +60 -0
- package/dist/components/fieldset/Fieldset.js +3 -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 +76 -0
- package/dist/components/form/Form.js +3 -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 +67 -0
- package/dist/components/input/Input.js +3 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.js +2 -0
- package/dist/components/input-group/InputGroup.d.ts +214 -0
- package/dist/components/input-group/InputGroup.js +3 -0
- package/dist/components/input-group/index.d.ts +2 -0
- package/dist/components/input-group/index.js +2 -0
- package/dist/components/menu/Menu.d.ts +587 -0
- package/dist/components/menu/Menu.js +3 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/index.js +2 -0
- package/dist/components/menubar/Menubar.d.ts +104 -0
- package/dist/components/menubar/Menubar.js +3 -0
- package/dist/components/menubar/index.d.ts +2 -0
- package/dist/components/menubar/index.js +2 -0
- package/dist/components/nav-list/NavList.d.ts +290 -0
- package/dist/components/nav-list/NavList.js +3 -0
- package/dist/components/nav-list/index.d.ts +2 -0
- package/dist/components/nav-list/index.js +2 -0
- package/dist/components/navigation-menu/NavigationMenu.d.ts +483 -0
- package/dist/components/navigation-menu/NavigationMenu.js +3 -0
- package/dist/components/navigation-menu/index.d.ts +2 -0
- package/dist/components/navigation-menu/index.js +2 -0
- package/dist/components/number-field/NumberField.d.ts +303 -0
- package/dist/components/number-field/NumberField.js +3 -0
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/index.js +2 -0
- package/dist/components/otp-field/OTPField.d.ts +206 -0
- package/dist/components/otp-field/OTPField.js +3 -0
- package/dist/components/otp-field/index.d.ts +2 -0
- package/dist/components/otp-field/index.js +2 -0
- package/dist/components/popover/Popover.d.ts +394 -0
- package/dist/components/popover/Popover.js +3 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +2 -0
- package/dist/components/preview-card/PreviewCard.d.ts +307 -0
- package/dist/components/preview-card/PreviewCard.js +3 -0
- package/dist/components/preview-card/index.d.ts +2 -0
- package/dist/components/preview-card/index.js +2 -0
- package/dist/components/progress/Progress.d.ts +156 -0
- package/dist/components/progress/Progress.js +3 -0
- package/dist/components/progress/ProgressCircle.d.ts +166 -0
- package/dist/components/progress/ProgressCircle.js +3 -0
- package/dist/components/progress/index.d.ts +4 -0
- package/dist/components/progress/index.js +3 -0
- package/dist/components/radio/Radio.d.ts +144 -0
- package/dist/components/radio/Radio.js +3 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/index.js +2 -0
- package/dist/components/resizable/Resizable.d.ts +211 -0
- package/dist/components/resizable/Resizable.js +3 -0
- package/dist/components/resizable/index.d.ts +2 -0
- package/dist/components/resizable/index.js +2 -0
- package/dist/components/scroll-area/ScrollArea.d.ts +113 -0
- package/dist/components/scroll-area/ScrollArea.js +3 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.js +2 -0
- package/dist/components/select/Select.d.ts +345 -0
- package/dist/components/select/Select.js +3 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/separator/Separator.d.ts +75 -0
- package/dist/components/separator/Separator.js +3 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/separator/index.js +2 -0
- package/dist/components/skeleton/Skeleton.d.ts +169 -0
- package/dist/components/skeleton/Skeleton.js +3 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +2 -0
- package/dist/components/slider/Slider.d.ts +208 -0
- package/dist/components/slider/Slider.js +3 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +2 -0
- package/dist/components/spinner/Spinner.d.ts +92 -0
- package/dist/components/spinner/Spinner.js +3 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.js +2 -0
- package/dist/components/switch/Switch.d.ts +80 -0
- package/dist/components/switch/Switch.js +3 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +2 -0
- package/dist/components/tabs/Tabs.d.ts +125 -0
- package/dist/components/tabs/Tabs.js +3 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/index.js +2 -0
- package/dist/components/textarea/Textarea.d.ts +119 -0
- package/dist/components/textarea/Textarea.js +3 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.js +2 -0
- package/dist/components/toast/Toast.d.ts +517 -0
- package/dist/components/toast/Toast.js +3 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/index.js +2 -0
- package/dist/components/toggle/Toggle.d.ts +171 -0
- package/dist/components/toggle/Toggle.js +3 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/index.js +2 -0
- package/dist/components/toolbar/Toolbar.d.ts +318 -0
- package/dist/components/toolbar/Toolbar.js +3 -0
- package/dist/components/toolbar/index.d.ts +2 -0
- package/dist/components/toolbar/index.js +2 -0
- package/dist/components/tooltip/Tooltip.d.ts +361 -0
- package/dist/components/tooltip/Tooltip.js +3 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +2 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +86 -0
- package/dist/styles/Accordion.css +1 -0
- package/dist/styles/Alert.css +1 -0
- package/dist/styles/AspectRatio.css +1 -0
- package/dist/styles/Avatar.css +1 -0
- package/dist/styles/Badge.css +1 -0
- package/dist/styles/Breadcrumb.css +1 -0
- package/dist/styles/Button.css +1 -0
- package/dist/styles/ButtonGroup.css +1 -0
- package/dist/styles/Calendar.css +1 -0
- package/dist/styles/Checkbox.css +1 -0
- package/dist/styles/Collapsible.css +1 -0
- package/dist/styles/ColorPicker.css +1 -0
- package/dist/styles/Combobox.css +1 -0
- package/dist/styles/ContextMenu.css +1 -0
- package/dist/styles/DatePicker.css +1 -0
- package/dist/styles/Dialog.css +1 -0
- package/dist/styles/Drawer.css +1 -0
- package/dist/styles/Field.css +1 -0
- package/dist/styles/Fieldset.css +1 -0
- package/dist/styles/Form.css +1 -0
- package/dist/styles/Input.css +1 -0
- package/dist/styles/InputGroup.css +1 -0
- package/dist/styles/Menu.css +1 -0
- package/dist/styles/Menubar.css +1 -0
- package/dist/styles/NavList.css +1 -0
- package/dist/styles/NavigationMenu.css +1 -0
- package/dist/styles/NumberField.css +1 -0
- package/dist/styles/OTPField.css +1 -0
- package/dist/styles/Popover.css +1 -0
- package/dist/styles/PreviewCard.css +1 -0
- package/dist/styles/Progress.css +1 -0
- package/dist/styles/ProgressCircle.css +1 -0
- package/dist/styles/Radio.css +1 -0
- package/dist/styles/Resizable.css +1 -0
- package/dist/styles/ScrollArea.css +1 -0
- package/dist/styles/Select.css +1 -0
- package/dist/styles/Separator.css +1 -0
- package/dist/styles/Skeleton.css +1 -0
- package/dist/styles/Slider.css +1 -0
- package/dist/styles/Spinner.css +1 -0
- package/dist/styles/Switch.css +1 -0
- package/dist/styles/Tabs.css +1 -0
- package/dist/styles/Textarea.css +1 -0
- package/dist/styles/Toast.css +1 -0
- package/dist/styles/Toggle.css +1 -0
- package/dist/styles/Toolbar.css +1 -0
- package/dist/styles/Tooltip.css +1 -0
- package/dist/styles/a11y.css +119 -0
- package/dist/styles/layers.css +39 -0
- package/dist/styles/motion.css +194 -0
- package/dist/styles/patterns.css +236 -0
- package/dist/styles/properties.css +62 -0
- package/dist/styles/reset.css +11 -0
- package/dist/styles/tailwind.css +281 -0
- package/dist/styles/theme.css +57 -0
- package/dist/styles/tokens.color.css +223 -0
- package/dist/styles/tokens.css +460 -0
- package/dist/tailwind-merge.d.ts +52 -0
- package/dist/tailwind-merge.js +52 -0
- package/docs-data/props.json +8047 -0
- package/docs-data/theming.json +9600 -0
- package/docs-data/tokens.json +4070 -0
- package/package.json +78 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Field as BaseField } from '@base-ui/react/field';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export type TextareaSize = "sm" | "md" | "lg";
|
|
4
|
+
export type TextareaVariant = "outline" | "soft" | "ghost";
|
|
5
|
+
export type TextareaResize = "vertical" | "none" | "both";
|
|
6
|
+
type BaseControlProps = React.ComponentPropsWithoutRef<typeof BaseField.Control>;
|
|
7
|
+
type TextareaElementProps = Omit<React.ComponentPropsWithoutRef<"textarea">, "className">;
|
|
8
|
+
export interface TextareaProps extends TextareaElementProps {
|
|
9
|
+
/**
|
|
10
|
+
* Size of the control. Inline padding, block padding and font size move
|
|
11
|
+
* together, and the numbers come from the same `--forte-control-*` tokens
|
|
12
|
+
* `Input` and `Select.Trigger` read — so a textarea stacked under an input
|
|
13
|
+
* shares its optical inset at every `data-forte-density` setting.
|
|
14
|
+
*
|
|
15
|
+
* A `<textarea>` has no native `size` attribute, so unlike `Input` this
|
|
16
|
+
* shadows nothing.
|
|
17
|
+
* @default "md"
|
|
18
|
+
*/
|
|
19
|
+
size?: TextareaSize;
|
|
20
|
+
/**
|
|
21
|
+
* How much visual weight the control carries. `outline` reads as a form
|
|
22
|
+
* control, `soft` as a filled field, `ghost` as an inline affordance — the
|
|
23
|
+
* same three `Input` has.
|
|
24
|
+
* @default "outline"
|
|
25
|
+
*/
|
|
26
|
+
variant?: TextareaVariant;
|
|
27
|
+
/**
|
|
28
|
+
* The number of rows the box is at its shortest. Sets the native `rows`
|
|
29
|
+
* attribute and the floor the control can never shrink below — including
|
|
30
|
+
* under `autoResize`, and including a drag on the resize handle.
|
|
31
|
+
* @default 3
|
|
32
|
+
*/
|
|
33
|
+
rows?: number;
|
|
34
|
+
/**
|
|
35
|
+
* The number of rows the box may grow to before it starts scrolling
|
|
36
|
+
* instead. Only a ceiling: a textarea shorter than this is unaffected.
|
|
37
|
+
* Unset means no ceiling.
|
|
38
|
+
*/
|
|
39
|
+
maxRows?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Grow with the content as the user types, between `rows` and `maxRows`.
|
|
42
|
+
*
|
|
43
|
+
* Implemented with the CSS `field-sizing` property where the browser has it,
|
|
44
|
+
* so there is no measurement, no reflow per keystroke and no inline height
|
|
45
|
+
* on the element. Older engines fall back to a resize observer and a
|
|
46
|
+
* `scrollHeight` read, which behaves identically and costs a layout per
|
|
47
|
+
* change.
|
|
48
|
+
*
|
|
49
|
+
* Forces `resize` to `"none"`: a handle whose value the next keystroke
|
|
50
|
+
* overwrites is not a control.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
autoResize?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Which axes the user may drag the control along. `vertical` is the default
|
|
56
|
+
* because `both` lets the box escape the column it sits in — legitimate for
|
|
57
|
+
* a full-width composer, wrong for a field in a form.
|
|
58
|
+
* @default "vertical"
|
|
59
|
+
*/
|
|
60
|
+
resize?: TextareaResize;
|
|
61
|
+
/**
|
|
62
|
+
* Stretch the control to fill the width of its container. Only needed
|
|
63
|
+
* outside a `Field.Root` — a field is a flex column, so a textarea inside
|
|
64
|
+
* one already stretches.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
fullWidth?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
70
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
71
|
+
*/
|
|
72
|
+
className?: string;
|
|
73
|
+
/** Replace the rendered element. Defaults to a `<textarea>`. */
|
|
74
|
+
render?: BaseControlProps["render"];
|
|
75
|
+
/** Callback fired when the value changes. Use when controlled. */
|
|
76
|
+
onValueChange?: BaseControlProps["onValueChange"];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The `autoResize` fallback for engines without `field-sizing` — Chrome landed
|
|
80
|
+
* it in 123, Firefox in 152 and Safari in 26.2, which still leaves a real
|
|
81
|
+
* share of users on a textarea that would silently not grow.
|
|
82
|
+
*
|
|
83
|
+
* Deliberately a no-op where the property IS supported: one CSS declaration
|
|
84
|
+
* does the whole job during layout, and an inline `block-size` written on top
|
|
85
|
+
* of it would fight the stylesheet's own min/max clamps.
|
|
86
|
+
*
|
|
87
|
+
* Exported for `InputGroup.Textarea`, which is the same control rendered bare
|
|
88
|
+
* inside a group shell and must grow by exactly the same rules — but NOT
|
|
89
|
+
* re-exported from the package: it is shared implementation, not API.
|
|
90
|
+
*/
|
|
91
|
+
export declare function useAutoSize(enabled: boolean): React.RefObject<HTMLTextAreaElement | null>;
|
|
92
|
+
/**
|
|
93
|
+
* A multi-line text control.
|
|
94
|
+
*
|
|
95
|
+
* Base UI has no textarea primitive, so this is built on `Field.Control` — the
|
|
96
|
+
* same component `Input` is — rendered as a `<textarea>`. That is what makes it
|
|
97
|
+
* participate in a `Field` with no wiring: drop one inside a `Field.Root` and
|
|
98
|
+
* it picks up the label, the description, the error message, the `name` used on
|
|
99
|
+
* submit, and the validity attributes.
|
|
100
|
+
*
|
|
101
|
+
* ```tsx
|
|
102
|
+
* <Field.Root name="bio">
|
|
103
|
+
* <Field.Label>Bio</Field.Label>
|
|
104
|
+
* <Textarea rows={4} placeholder="Tell us about yourself" />
|
|
105
|
+
* <Field.Error />
|
|
106
|
+
* </Field.Root>
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* Height is expressed in rows rather than pixels — `rows` is the floor,
|
|
110
|
+
* `maxRows` the ceiling, and `autoResize` moves between them as the user types.
|
|
111
|
+
*
|
|
112
|
+
* State is exposed on `data-*` (`data-disabled`, `data-invalid`, `data-valid`,
|
|
113
|
+
* `data-dirty`, `data-touched`, `data-filled`, `data-focused`) and every visual
|
|
114
|
+
* decision is a `--forte-textarea-*` custom property, so it can be re-skinned
|
|
115
|
+
* from plain CSS or targeted with Tailwind arbitrary variants
|
|
116
|
+
* (`data-[invalid]:...`) without wrapping.
|
|
117
|
+
*/
|
|
118
|
+
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
119
|
+
export {};
|
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import { ToastObject as BaseToastObject, ToastManager as BaseToastManager, ToastPortalProps as BaseToastPortalProps, ToastRootProps as BaseToastRootProps, ToastTitleProps as BaseToastTitleProps, ToastDescriptionProps as BaseToastDescriptionProps, ToastActionProps as BaseToastActionProps, ToastCloseProps as BaseToastCloseProps } from '@base-ui/react/toast';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* The five types the library styles. `type` is a plain string in Base UI, so
|
|
5
|
+
* any other value passes through unharmed — it lands on `data-type` and gets
|
|
6
|
+
* the neutral treatment, which is what you want for an app-specific type
|
|
7
|
+
* styled from your own CSS.
|
|
8
|
+
*/
|
|
9
|
+
export type ToastType = "success" | "error" | "warning" | "info" | "loading";
|
|
10
|
+
/**
|
|
11
|
+
* Where the stack sits. `start` / `end` are the *inline* edges, so a
|
|
12
|
+
* `bottom-end` viewport is bottom-right in LTR and bottom-left in RTL without
|
|
13
|
+
* anything being configured.
|
|
14
|
+
*/
|
|
15
|
+
export type ToastPosition = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end";
|
|
16
|
+
/** A direction a toast can be flicked in to dismiss it. */
|
|
17
|
+
export type ToastSwipeDirection = "up" | "down" | "left" | "right";
|
|
18
|
+
/**
|
|
19
|
+
* Custom data carried on a toast.
|
|
20
|
+
*
|
|
21
|
+
* `icon` and `dismissible` are read by `Toast.Item`; everything else is yours
|
|
22
|
+
* and reaches a custom renderer untouched through `toast.data`. They live here
|
|
23
|
+
* rather than as top-level fields because `data` is the one field Base UI
|
|
24
|
+
* hands through verbatim — inventing a sibling of `title` would mean patching
|
|
25
|
+
* Base UI's own object type, and that breaks the moment it gains a field of
|
|
26
|
+
* the same name.
|
|
27
|
+
*/
|
|
28
|
+
export interface ToastData {
|
|
29
|
+
/**
|
|
30
|
+
* Replaces the type's default glyph. `false` removes it — and removes the
|
|
31
|
+
* icon column with it, so the text starts at the padding edge.
|
|
32
|
+
*/
|
|
33
|
+
icon?: React.ReactNode | false;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the close button renders. Turn it off for a toast that must be
|
|
36
|
+
* answered through its action button.
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
dismissible?: boolean;
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
/** A toast as it exists in the store — what a custom renderer receives. */
|
|
43
|
+
export type ToastObject = BaseToastObject<ToastData>;
|
|
44
|
+
/** The action button, if the toast has one. */
|
|
45
|
+
export interface ToastActionOptions extends Omit<React.ComponentPropsWithoutRef<"button">, "children"> {
|
|
46
|
+
/** The button's text. */
|
|
47
|
+
label: React.ReactNode;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Everything you can say about a toast.
|
|
51
|
+
*
|
|
52
|
+
* Every field is optional, including `title` — a toast with only a
|
|
53
|
+
* `description` is a valid one-line message, and `Toast.Title` renders nothing
|
|
54
|
+
* rather than an empty heading.
|
|
55
|
+
*/
|
|
56
|
+
export interface ToastOptions {
|
|
57
|
+
/** The headline. Becomes the toast's accessible name. */
|
|
58
|
+
title?: React.ReactNode;
|
|
59
|
+
/** A second line under the title. Becomes the accessible description. */
|
|
60
|
+
description?: React.ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* Which glyph and accent colour to use, and what lands on `data-type`.
|
|
63
|
+
* The named methods on `useToast()` set this for you.
|
|
64
|
+
*/
|
|
65
|
+
type?: ToastType | (string & {});
|
|
66
|
+
/**
|
|
67
|
+
* How long before the toast dismisses itself, in milliseconds. `0` keeps it
|
|
68
|
+
* on screen until it is closed. Falls back to the provider's `timeout`.
|
|
69
|
+
*
|
|
70
|
+
* Ignored for `type="loading"`, which never auto-dismisses — resolve it with
|
|
71
|
+
* `update()` or close it through the handle.
|
|
72
|
+
*/
|
|
73
|
+
timeout?: number;
|
|
74
|
+
/**
|
|
75
|
+
* `"high"` announces the toast assertively, interrupting whatever the screen
|
|
76
|
+
* reader is saying, and renders it as an `alertdialog` rather than a
|
|
77
|
+
* `dialog`. Reserve it for something the user has to hear *now*; routine
|
|
78
|
+
* confirmations are `"low"`.
|
|
79
|
+
* @default "low"
|
|
80
|
+
*/
|
|
81
|
+
priority?: "low" | "high";
|
|
82
|
+
/**
|
|
83
|
+
* A stable identifier. Showing a toast with an id that is already on screen
|
|
84
|
+
* updates that toast in place and restarts its timer, instead of stacking a
|
|
85
|
+
* second copy — which is how you keep a save-status or connection toast to
|
|
86
|
+
* one card however often the event fires.
|
|
87
|
+
*/
|
|
88
|
+
id?: string;
|
|
89
|
+
/** A single button inside the toast: `{ label: "Undo", onClick: undo }`. */
|
|
90
|
+
action?: ToastActionOptions;
|
|
91
|
+
/** Called when the toast closes, however it was closed. */
|
|
92
|
+
onClose?: () => void;
|
|
93
|
+
/** Called once the toast has finished animating out and left the DOM. */
|
|
94
|
+
onRemove?: () => void;
|
|
95
|
+
/** Custom data. `icon` and `dismissible` are read by `Toast.Item`. */
|
|
96
|
+
data?: ToastData;
|
|
97
|
+
/**
|
|
98
|
+
* Replaces the type's default glyph. `false` removes it. Shorthand for
|
|
99
|
+
* `data.icon`.
|
|
100
|
+
*/
|
|
101
|
+
icon?: React.ReactNode | false;
|
|
102
|
+
/**
|
|
103
|
+
* Whether the close button renders. Shorthand for `data.dismissible`.
|
|
104
|
+
* @default true
|
|
105
|
+
*/
|
|
106
|
+
dismissible?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* What the shorthand methods accept: a message, or the full options object.
|
|
110
|
+
*
|
|
111
|
+
* `toast.success("Saved")` and `toast.success({ title: "Saved" })` are the
|
|
112
|
+
* same call — a bare message becomes the `title`, because that is the field
|
|
113
|
+
* that gets announced and the one that carries the meaning.
|
|
114
|
+
*/
|
|
115
|
+
export type ToastMessage = React.ReactNode | ToastOptions;
|
|
116
|
+
/**
|
|
117
|
+
* The value `show()` and the named methods return.
|
|
118
|
+
*
|
|
119
|
+
* An object rather than a bare `hide` function, because dismissing is only one
|
|
120
|
+
* of the three things you want to do with a toast you have just raised: the id
|
|
121
|
+
* is what identifies it across a reload or in a map, and `update` is what
|
|
122
|
+
* turns "Uploading…" into "Uploaded" without a second card appearing.
|
|
123
|
+
*/
|
|
124
|
+
export interface ToastHandle {
|
|
125
|
+
/** The toast's id, generated unless `options.id` was given. */
|
|
126
|
+
readonly id: string;
|
|
127
|
+
/** Closes this toast. Safe to call after it has already gone. */
|
|
128
|
+
close: () => void;
|
|
129
|
+
/**
|
|
130
|
+
* Rewrites this toast in place. Only the fields you pass change, and the
|
|
131
|
+
* toast keeps its position in the stack — so "Uploading…" becomes "Uploaded"
|
|
132
|
+
* without a second card appearing.
|
|
133
|
+
*
|
|
134
|
+
* Each field you pass REPLACES the old one; nothing is merged, `data`
|
|
135
|
+
* included. Restate `icon` or `dismissible` if the updated toast should keep
|
|
136
|
+
* them.
|
|
137
|
+
*
|
|
138
|
+
* The running timer is left alone unless the update changes `timeout`, or
|
|
139
|
+
* resolves a `loading` toast into a type that auto-dismisses.
|
|
140
|
+
*/
|
|
141
|
+
update: (message: ToastMessage, options?: ToastOptions) => void;
|
|
142
|
+
}
|
|
143
|
+
/** How `promise()` describes each of the three states. */
|
|
144
|
+
export interface ToastPromiseOptions<Value> {
|
|
145
|
+
/** Shown immediately, and never auto-dismissed. */
|
|
146
|
+
loading: ToastMessage;
|
|
147
|
+
/** Replaces it when the promise resolves. */
|
|
148
|
+
success: ToastMessage | ((value: Value) => ToastMessage);
|
|
149
|
+
/** Replaces it when the promise rejects. */
|
|
150
|
+
error: ToastMessage | ((error: unknown) => ToastMessage);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The toast API — what `useToast()` returns, and what `Toast.createManager()`
|
|
154
|
+
* gives you outside React.
|
|
155
|
+
*/
|
|
156
|
+
export interface ToastApi {
|
|
157
|
+
/** Shows a toast of any type. `type` decides the glyph and the accent. */
|
|
158
|
+
show: (message: ToastMessage, options?: ToastOptions) => ToastHandle;
|
|
159
|
+
/** Shows a `success` toast. */
|
|
160
|
+
success: (message: ToastMessage, options?: ToastOptions) => ToastHandle;
|
|
161
|
+
/** Shows an `error` toast. */
|
|
162
|
+
error: (message: ToastMessage, options?: ToastOptions) => ToastHandle;
|
|
163
|
+
/** Shows a `warning` toast. */
|
|
164
|
+
warning: (message: ToastMessage, options?: ToastOptions) => ToastHandle;
|
|
165
|
+
/** Shows an `info` toast. */
|
|
166
|
+
info: (message: ToastMessage, options?: ToastOptions) => ToastHandle;
|
|
167
|
+
/** Shows a `loading` toast. It never auto-dismisses. */
|
|
168
|
+
loading: (message: ToastMessage, options?: ToastOptions) => ToastHandle;
|
|
169
|
+
/**
|
|
170
|
+
* Raises a loading toast and swaps it for a success or error one when the
|
|
171
|
+
* promise settles. Returns the promise, with the rejection intact — so this
|
|
172
|
+
* is a pass-through you can `await` and still `catch`.
|
|
173
|
+
*/
|
|
174
|
+
promise: <Value>(promise: Promise<Value>, options: ToastPromiseOptions<Value>) => Promise<Value>;
|
|
175
|
+
/** Rewrites a toast in place by id. */
|
|
176
|
+
update: (id: string, message: ToastMessage, options?: ToastOptions) => void;
|
|
177
|
+
/** Closes one toast, or every toast when called with no argument. */
|
|
178
|
+
close: (id?: string) => void;
|
|
179
|
+
}
|
|
180
|
+
/** A manager created with `Toast.createManager()`. */
|
|
181
|
+
export interface ToastManager extends ToastApi {
|
|
182
|
+
/**
|
|
183
|
+
* The Base UI manager underneath. Pass it to `Toast.Provider`'s
|
|
184
|
+
* `toastManager` prop — that is what connects the two.
|
|
185
|
+
*/
|
|
186
|
+
readonly base: BaseToastManager<ToastData>;
|
|
187
|
+
}
|
|
188
|
+
/** What `useToast()` returns: the API, plus the live list of toasts. */
|
|
189
|
+
export interface UseToastReturn extends ToastApi {
|
|
190
|
+
/**
|
|
191
|
+
* Every toast currently in the store, newest first, including the ones
|
|
192
|
+
* animating out. Read it to render your own stack, or to show a count.
|
|
193
|
+
*/
|
|
194
|
+
toasts: ToastObject[];
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Raises toasts from inside a component.
|
|
198
|
+
*
|
|
199
|
+
* ```tsx
|
|
200
|
+
* const toast = useToast();
|
|
201
|
+
*
|
|
202
|
+
* toast.success("Profile saved");
|
|
203
|
+
* toast.error("Could not save", { description: "Check your connection." });
|
|
204
|
+
*
|
|
205
|
+
* const { close } = toast.info("Uploading…", { timeout: 0 });
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* Must be called under a `Toast.Provider`.
|
|
209
|
+
*
|
|
210
|
+
* Every method on it keeps the same identity for the life of the provider, so
|
|
211
|
+
* one pulled out by destructuring is safe in a dependency array. The object
|
|
212
|
+
* itself is rebuilt whenever `toasts` changes, since that is the only way a
|
|
213
|
+
* live list can be live — destructure what you need rather than depending on
|
|
214
|
+
* the whole thing.
|
|
215
|
+
*/
|
|
216
|
+
export declare function useToast(): UseToastReturn;
|
|
217
|
+
/**
|
|
218
|
+
* Creates a toast manager that works outside React.
|
|
219
|
+
*
|
|
220
|
+
* ```ts
|
|
221
|
+
* // toaster.ts
|
|
222
|
+
* export const toaster = Toast.createManager();
|
|
223
|
+
*
|
|
224
|
+
* // anywhere — an API client, a store, an event handler
|
|
225
|
+
* toaster.error("Request failed");
|
|
226
|
+
*
|
|
227
|
+
* // app root
|
|
228
|
+
* <Toast.Provider toastManager={toaster.base}>…</Toast.Provider>
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* Same methods as `useToast()`, minus `toasts` — a plain object has nothing to
|
|
232
|
+
* re-render when the list changes, so reading it there would hand back a
|
|
233
|
+
* snapshot that is already stale. Use the hook when you need the list.
|
|
234
|
+
*
|
|
235
|
+
* A manager delivers to a MOUNTED provider and nowhere else: the provider
|
|
236
|
+
* subscribes in an effect, and a call made before that runs — at module load,
|
|
237
|
+
* during the first server render — is dropped rather than queued. Raise toasts
|
|
238
|
+
* from events, which is where they belong anyway.
|
|
239
|
+
*/
|
|
240
|
+
export declare function createToastManager(): ToastManager;
|
|
241
|
+
export interface ToastViewportProps extends Omit<React.ComponentPropsWithoutRef<"div">, "className" | "children"> {
|
|
242
|
+
/**
|
|
243
|
+
* Which corner or edge the stack sits at. `start` and `end` are the inline
|
|
244
|
+
* edges, so `bottom-end` is bottom-right in LTR and bottom-left in RTL.
|
|
245
|
+
* @default "bottom-end"
|
|
246
|
+
*/
|
|
247
|
+
position?: ToastPosition;
|
|
248
|
+
/**
|
|
249
|
+
* An element to render the stack into instead of `<body>`.
|
|
250
|
+
*
|
|
251
|
+
* Setting it also switches the viewport from `position: fixed` to
|
|
252
|
+
* `position: absolute`, so the stack pins to the container rather than to
|
|
253
|
+
* the screen — give that container `position: relative`. There is no
|
|
254
|
+
* separate prop for that, because a contained viewport that stayed fixed
|
|
255
|
+
* would be a silent bug: the toasts would sit in the screen corner while
|
|
256
|
+
* the container they were scoped to sat somewhere else entirely.
|
|
257
|
+
*
|
|
258
|
+
* The usual reason to reach for it is a preview or an embedded surface that
|
|
259
|
+
* has its own theme scope — a portal to `<body>` escapes the scope, and the
|
|
260
|
+
* toasts come out in the page's colours.
|
|
261
|
+
*/
|
|
262
|
+
container?: BaseToastPortalProps["container"];
|
|
263
|
+
/**
|
|
264
|
+
* Which way a toast may be flicked away. Defaults to the direction away from
|
|
265
|
+
* the viewport's own edge plus both inline directions; pass `[]` to turn
|
|
266
|
+
* swipe-to-dismiss off.
|
|
267
|
+
*/
|
|
268
|
+
swipeDirection?: ToastSwipeDirection | ToastSwipeDirection[];
|
|
269
|
+
/**
|
|
270
|
+
* Renders one toast. Return a `Toast.Item` — it is what carries the stacking
|
|
271
|
+
* geometry and the swipe gesture.
|
|
272
|
+
*
|
|
273
|
+
* ```tsx
|
|
274
|
+
* renderToast={(toast) => (
|
|
275
|
+
* <Toast.Item toast={toast}>
|
|
276
|
+
* <Toast.Icon />
|
|
277
|
+
* <Toast.Title />
|
|
278
|
+
* <Toast.Close />
|
|
279
|
+
* </Toast.Item>
|
|
280
|
+
* )}
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* Defaults to `<Toast.Item toast={toast} />`, which supplies the standard
|
|
284
|
+
* layout from the toast's own fields.
|
|
285
|
+
*/
|
|
286
|
+
renderToast?: (toast: ToastObject) => React.ReactNode;
|
|
287
|
+
/**
|
|
288
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
289
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
290
|
+
*/
|
|
291
|
+
className?: string;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* The stack itself: Base UI's `Portal` → `Viewport`, plus the loop over the
|
|
295
|
+
* toasts. Collapsing the three keeps the common case to one element, the way
|
|
296
|
+
* `Dialog.Popup` collapses its four.
|
|
297
|
+
*
|
|
298
|
+
* `Toast.Provider` renders one of these for you. Render it yourself only when
|
|
299
|
+
* it has to go somewhere specific — inside a `container`, or after some other
|
|
300
|
+
* portalled chrome — and pass `viewport={false}` to the provider so there is
|
|
301
|
+
* not a second one.
|
|
302
|
+
*/
|
|
303
|
+
export declare const ToastViewport: React.ForwardRefExoticComponent<ToastViewportProps & React.RefAttributes<HTMLDivElement>>;
|
|
304
|
+
export interface ToastProviderProps extends ToastViewportProps {
|
|
305
|
+
/** The app. */
|
|
306
|
+
children?: React.ReactNode;
|
|
307
|
+
/**
|
|
308
|
+
* How long a toast stays on screen by default, in milliseconds. `0` keeps
|
|
309
|
+
* every toast until it is closed. A toast can override it with its own
|
|
310
|
+
* `timeout`.
|
|
311
|
+
* @default 5000
|
|
312
|
+
*/
|
|
313
|
+
timeout?: number;
|
|
314
|
+
/**
|
|
315
|
+
* How many toasts are visible at once. The rest stay in the store and take
|
|
316
|
+
* their turn as the front ones are dismissed, so nothing is lost — they are
|
|
317
|
+
* marked `data-limited` and hidden rather than dropped.
|
|
318
|
+
* @default 3
|
|
319
|
+
*/
|
|
320
|
+
limit?: number;
|
|
321
|
+
/**
|
|
322
|
+
* A manager from `Toast.createManager()`, for raising toasts outside React.
|
|
323
|
+
* Pass the manager's `base`.
|
|
324
|
+
*/
|
|
325
|
+
toastManager?: BaseToastManager;
|
|
326
|
+
/**
|
|
327
|
+
* Whether to render the stack. Turn it off when you are placing
|
|
328
|
+
* `Toast.Viewport` yourself.
|
|
329
|
+
* @default true
|
|
330
|
+
*/
|
|
331
|
+
viewport?: boolean;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Owns every toast below it, and renders the stack.
|
|
335
|
+
*
|
|
336
|
+
* Mount it once, near the root of the app:
|
|
337
|
+
*
|
|
338
|
+
* ```tsx
|
|
339
|
+
* <Toast.Provider position="bottom-end" timeout={5000}>
|
|
340
|
+
* <App />
|
|
341
|
+
* </Toast.Provider>
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* The viewport comes with it deliberately. Base UI keeps the two apart, which
|
|
345
|
+
* is the right primitive but the wrong default here: a provider without a
|
|
346
|
+
* viewport swallows every toast silently — the calls succeed, the store fills
|
|
347
|
+
* up, and nothing is ever drawn. Rendering it here means the failure cannot
|
|
348
|
+
* happen, and `viewport={false}` is one prop away when you need to place it
|
|
349
|
+
* yourself.
|
|
350
|
+
*
|
|
351
|
+
* Renders no DOM element of its own; the stack is portalled.
|
|
352
|
+
*/
|
|
353
|
+
export declare function ToastProvider({ children, timeout, limit, toastManager, viewport, ...viewportProps }: ToastProviderProps): React.JSX.Element;
|
|
354
|
+
export interface ToastItemProps extends Omit<BaseToastRootProps, "className" | "toast"> {
|
|
355
|
+
/** The toast to render — the object a `renderToast` callback receives. */
|
|
356
|
+
toast: ToastObject;
|
|
357
|
+
/**
|
|
358
|
+
* Which way this toast may be flicked away. Inherited from the viewport;
|
|
359
|
+
* set it here to override one toast, or pass `[]` to pin it in place.
|
|
360
|
+
*/
|
|
361
|
+
swipeDirection?: ToastSwipeDirection | ToastSwipeDirection[];
|
|
362
|
+
/**
|
|
363
|
+
* The toast's contents. Omit it for the standard layout — icon, title,
|
|
364
|
+
* description, action, close — assembled from the toast's own fields.
|
|
365
|
+
*
|
|
366
|
+
* Passing children replaces that layout entirely. Compose it from the parts
|
|
367
|
+
* (`Toast.Icon`, `Toast.Title`, `Toast.Description`, `Toast.Action`,
|
|
368
|
+
* `Toast.Close`), each of which defaults its content from the toast, so a
|
|
369
|
+
* custom arrangement does not mean restating the text.
|
|
370
|
+
*/
|
|
371
|
+
children?: React.ReactNode;
|
|
372
|
+
/**
|
|
373
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
374
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
375
|
+
*/
|
|
376
|
+
className?: string;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* One toast: Base UI's `Root` wrapping its `Content`.
|
|
380
|
+
*
|
|
381
|
+
* `Root` carries the stacking geometry, the swipe gesture and the focus
|
|
382
|
+
* handling; `Content` is what fades when the toast is behind another one, and
|
|
383
|
+
* is why the two are separate elements rather than one.
|
|
384
|
+
*/
|
|
385
|
+
export declare const ToastItem: React.ForwardRefExoticComponent<Omit<ToastItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
386
|
+
export interface ToastIconProps extends Omit<React.ComponentPropsWithoutRef<"span">, "className" | "children"> {
|
|
387
|
+
/**
|
|
388
|
+
* The glyph to draw. Defaults to `data.icon` if the toast carries one, and
|
|
389
|
+
* otherwise to the standard glyph for its `type`.
|
|
390
|
+
*/
|
|
391
|
+
children?: React.ReactNode;
|
|
392
|
+
/**
|
|
393
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
394
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
395
|
+
*/
|
|
396
|
+
className?: string;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* The status glyph, coloured by the toast's type.
|
|
400
|
+
*
|
|
401
|
+
* A `loading` toast gets a `Spinner` instead of a static glyph. The spinner is
|
|
402
|
+
* a child of the toast root rather than the root itself, which is load-bearing
|
|
403
|
+
* — Base UI waits on `root.getAnimations()` before removing a dismissed toast,
|
|
404
|
+
* and an infinite animation's promise never settles, so a spinning root would
|
|
405
|
+
* stay in the DOM for the lifetime of the page. `getAnimations()` is not
|
|
406
|
+
* called with `subtree: true`, so a descendant is safe.
|
|
407
|
+
*
|
|
408
|
+
* Renders nothing when there is no glyph to draw, so the icon column collapses
|
|
409
|
+
* on a typeless toast rather than leaving a gap where an icon would be.
|
|
410
|
+
*/
|
|
411
|
+
export declare const ToastIcon: React.ForwardRefExoticComponent<ToastIconProps & React.RefAttributes<HTMLSpanElement>>;
|
|
412
|
+
export interface ToastTitleProps extends Omit<BaseToastTitleProps, "className"> {
|
|
413
|
+
/**
|
|
414
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
415
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
416
|
+
*/
|
|
417
|
+
className?: string;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* The toast's headline, and its accessible name.
|
|
421
|
+
*
|
|
422
|
+
* Renders an `<h2>` whose text defaults to the toast's `title`. Renders
|
|
423
|
+
* nothing at all when there is no title, so a description-only toast does not
|
|
424
|
+
* carry an empty heading.
|
|
425
|
+
*/
|
|
426
|
+
export declare const ToastTitle: React.ForwardRefExoticComponent<Omit<ToastTitleProps, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
427
|
+
export interface ToastDescriptionProps extends Omit<BaseToastDescriptionProps, "className"> {
|
|
428
|
+
/**
|
|
429
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
430
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
431
|
+
*/
|
|
432
|
+
className?: string;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* The second line, and the toast's accessible description.
|
|
436
|
+
*
|
|
437
|
+
* Renders a `<p>` whose text defaults to the toast's `description`, and
|
|
438
|
+
* renders nothing when there is none.
|
|
439
|
+
*/
|
|
440
|
+
export declare const ToastDescription: React.ForwardRefExoticComponent<Omit<ToastDescriptionProps, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
441
|
+
export interface ToastActionProps extends Omit<BaseToastActionProps, "className"> {
|
|
442
|
+
/**
|
|
443
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
444
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
445
|
+
*/
|
|
446
|
+
className?: string;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The toast's action button.
|
|
450
|
+
*
|
|
451
|
+
* Renders a `<button>` whose label and `onClick` default to the toast's
|
|
452
|
+
* `action`, and renders nothing when the toast has none — so the default
|
|
453
|
+
* layout can include it unconditionally.
|
|
454
|
+
*
|
|
455
|
+
* Clicking it does not close the toast. That is deliberate: an action that
|
|
456
|
+
* fails should be able to say so, and closing is one `handle.close()` away
|
|
457
|
+
* inside the handler.
|
|
458
|
+
*/
|
|
459
|
+
export declare const ToastAction: React.ForwardRefExoticComponent<Omit<ToastActionProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
460
|
+
export interface ToastCloseProps extends Omit<BaseToastCloseProps, "className"> {
|
|
461
|
+
/**
|
|
462
|
+
* Additional class name(s). Applied after the internal styles so consumer
|
|
463
|
+
* utilities (e.g. Tailwind) win without needing `!important`.
|
|
464
|
+
*/
|
|
465
|
+
className?: string;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* The button that dismisses the toast.
|
|
469
|
+
*
|
|
470
|
+
* Renders a `<button>` with a "×" and an `aria-label` of "Close", both
|
|
471
|
+
* overridable through `children` and `aria-label`. Base UI hides it from
|
|
472
|
+
* assistive technology while the stack is collapsed and reveals it once the
|
|
473
|
+
* viewport is hovered or focused, so it is announced exactly when it is
|
|
474
|
+
* reachable.
|
|
475
|
+
*/
|
|
476
|
+
export declare const ToastClose: React.ForwardRefExoticComponent<Omit<ToastCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
477
|
+
/**
|
|
478
|
+
* Transient messages, built on Base UI's `Toast`.
|
|
479
|
+
*
|
|
480
|
+
* ```tsx
|
|
481
|
+
* // once, at the root
|
|
482
|
+
* <Toast.Provider position="bottom-end">
|
|
483
|
+
* <App />
|
|
484
|
+
* </Toast.Provider>
|
|
485
|
+
*
|
|
486
|
+
* // anywhere below it
|
|
487
|
+
* const toast = useToast();
|
|
488
|
+
* toast.success("Profile saved");
|
|
489
|
+
* ```
|
|
490
|
+
*
|
|
491
|
+
* Two things are worth knowing before reaching for one.
|
|
492
|
+
*
|
|
493
|
+
* **A toast is not a place for anything the user must not miss.** It is
|
|
494
|
+
* announced once and then it is gone; it cannot be scrolled back to, and on a
|
|
495
|
+
* phone it may be covered by the keyboard. An error the user has to act on
|
|
496
|
+
* belongs next to the thing that failed.
|
|
497
|
+
*
|
|
498
|
+
* **Timers pause while the stack is hovered, focused, or the window is in the
|
|
499
|
+
* background,** so a toast raised while the user was in another tab is still
|
|
500
|
+
* there when they come back.
|
|
501
|
+
*
|
|
502
|
+
* Styling is driven by `data-*` attributes and `--forte-toast-*` custom
|
|
503
|
+
* properties, so it can be re-skinned from plain CSS or targeted with Tailwind
|
|
504
|
+
* arbitrary variants (`data-[type=error]:...`) without wrapping anything.
|
|
505
|
+
*/
|
|
506
|
+
export declare const Toast: {
|
|
507
|
+
Provider: typeof ToastProvider;
|
|
508
|
+
Viewport: React.ForwardRefExoticComponent<ToastViewportProps & React.RefAttributes<HTMLDivElement>>;
|
|
509
|
+
Item: React.ForwardRefExoticComponent<Omit<ToastItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
510
|
+
Icon: React.ForwardRefExoticComponent<ToastIconProps & React.RefAttributes<HTMLSpanElement>>;
|
|
511
|
+
Title: React.ForwardRefExoticComponent<Omit<ToastTitleProps, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
512
|
+
Description: React.ForwardRefExoticComponent<Omit<ToastDescriptionProps, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
513
|
+
Action: React.ForwardRefExoticComponent<Omit<ToastActionProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
514
|
+
Close: React.ForwardRefExoticComponent<Omit<ToastCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
515
|
+
/** Creates a manager for raising toasts outside React. */
|
|
516
|
+
createManager: typeof createToastManager;
|
|
517
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "../../Toast-BWayxAcd.js";
|
|
3
|
+
export { l as Toast, a as ToastAction, s as ToastClose, r as ToastDescription, e as ToastIcon, o as ToastItem, c as ToastProvider, t as ToastTitle, i as ToastViewport, u as createToastManager, n as useToast };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { Toast, useToast } from './Toast';
|
|
2
|
+
export type { ToastType, ToastPosition, ToastSwipeDirection, ToastData, ToastObject, ToastActionOptions, ToastOptions, ToastMessage, ToastHandle, ToastPromiseOptions, ToastApi, ToastManager, UseToastReturn, ToastProviderProps, ToastViewportProps, ToastItemProps, ToastIconProps, ToastTitleProps, ToastDescriptionProps, ToastActionProps, ToastCloseProps, } from './Toast';
|