@openwarelabs/ui 0.13.0 → 0.14.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 +7 -7
- package/dist/components/AspectRatio/AspectRatio.d.cts +7 -0
- package/dist/components/AspectRatio/AspectRatio.d.ts +7 -0
- package/dist/components/AspectRatio/AspectRatio.types.d.cts +7 -0
- package/dist/components/AspectRatio/AspectRatio.types.d.ts +7 -0
- package/dist/components/Banner/Banner.d.cts +7 -0
- package/dist/components/Banner/Banner.d.ts +7 -0
- package/dist/components/Banner/Banner.types.d.cts +44 -0
- package/dist/components/Banner/Banner.types.d.ts +44 -0
- package/dist/components/Carousel/Carousel.d.cts +9 -0
- package/dist/components/Carousel/Carousel.d.ts +9 -0
- package/dist/components/Carousel/Carousel.types.d.cts +63 -0
- package/dist/components/Carousel/Carousel.types.d.ts +63 -0
- package/dist/components/ContextMenu/ContextMenu.d.cts +7 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +7 -0
- package/dist/components/ContextMenu/ContextMenu.types.d.cts +32 -0
- package/dist/components/ContextMenu/ContextMenu.types.d.ts +32 -0
- package/dist/components/DescriptionList/DescriptionList.d.cts +9 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts +9 -0
- package/dist/components/DescriptionList/DescriptionList.types.d.cts +32 -0
- package/dist/components/DescriptionList/DescriptionList.types.d.ts +32 -0
- package/dist/components/HoverCard/HoverCard.d.cts +8 -0
- package/dist/components/HoverCard/HoverCard.d.ts +8 -0
- package/dist/components/HoverCard/HoverCard.types.d.cts +28 -0
- package/dist/components/HoverCard/HoverCard.types.d.ts +28 -0
- package/dist/components/Image/Image.d.cts +7 -0
- package/dist/components/Image/Image.d.ts +7 -0
- package/dist/components/Image/Image.types.d.cts +28 -0
- package/dist/components/Image/Image.types.d.ts +28 -0
- package/dist/components/Menu/Menu.context.d.cts +3 -0
- package/dist/components/Menu/Menu.context.d.ts +3 -0
- package/dist/components/Menu/Menu.d.cts +4 -34
- package/dist/components/Menu/Menu.d.ts +4 -34
- package/dist/components/Menu/Menu.types.d.cts +39 -0
- package/dist/components/Menu/Menu.types.d.ts +39 -0
- package/dist/components/PasswordInput/PasswordInput.d.cts +9 -0
- package/dist/components/PasswordInput/PasswordInput.d.ts +9 -0
- package/dist/components/PasswordInput/PasswordInput.types.d.cts +47 -0
- package/dist/components/PasswordInput/PasswordInput.types.d.ts +47 -0
- package/dist/components/PasswordInput/passwordStrength.d.cts +9 -0
- package/dist/components/PasswordInput/passwordStrength.d.ts +9 -0
- package/dist/components/Rating/Rating.d.cts +8 -0
- package/dist/components/Rating/Rating.d.ts +8 -0
- package/dist/components/Rating/Rating.types.d.cts +59 -0
- package/dist/components/Rating/Rating.types.d.ts +59 -0
- package/dist/components/Splitter/Splitter.d.cts +14 -0
- package/dist/components/Splitter/Splitter.d.ts +14 -0
- package/dist/components/Splitter/Splitter.layout.d.cts +12 -0
- package/dist/components/Splitter/Splitter.layout.d.ts +12 -0
- package/dist/components/Splitter/Splitter.types.d.cts +69 -0
- package/dist/components/Splitter/Splitter.types.d.ts +69 -0
- package/dist/components/TagInput/TagInput.d.cts +7 -0
- package/dist/components/TagInput/TagInput.d.ts +7 -0
- package/dist/components/TagInput/TagInput.types.d.cts +78 -0
- package/dist/components/TagInput/TagInput.types.d.ts +78 -0
- package/dist/components/Timeline/Timeline.d.cts +6 -0
- package/dist/components/Timeline/Timeline.d.ts +6 -0
- package/dist/components/Timeline/Timeline.types.d.cts +42 -0
- package/dist/components/Timeline/Timeline.types.d.ts +42 -0
- package/dist/components/Tour/Tour.d.cts +9 -0
- package/dist/components/Tour/Tour.d.ts +9 -0
- package/dist/components/Tour/Tour.types.d.cts +119 -0
- package/dist/components/Tour/Tour.types.d.ts +119 -0
- package/dist/components.css +1479 -33
- package/dist/icons.d.cts +6 -0
- package/dist/icons.d.ts +6 -0
- package/dist/index.cjs +3500 -1357
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +3516 -1354
- package/dist/index.js.map +4 -4
- package/dist/openware-ui.iife.js +8 -7
- package/dist/styles.css +1479 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,21 +54,21 @@ import { Button, Field, Input, Toaster, toast } from "@openwarelabs/ui";
|
|
|
54
54
|
|
|
55
55
|
## Components
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
106 components, each with a page in the docs.
|
|
58
58
|
|
|
59
59
|
| Group | Components |
|
|
60
60
|
| --- | --- |
|
|
61
61
|
| Typography | `Text` (each style on the Typography page as a variant: hero to caption, code and kbd; tones, `truncate`, `as`), `Link`, `Kbd`, `Code`, `CodeBlock`, `Snippet`, `Prose` (styles rendered Markdown or HTML, at chat or article size) |
|
|
62
62
|
| Actions | `Button` (primary, secondary, ghost, danger; sm, md, lg; `loading`; `shape="pill"`), `buttonClassName()` for links, `ButtonGroup`, `CloseButton`, `CopyButton`, `ToggleButton`, `SegmentedControl`, `ToggleButtonGroup` (one or several on), `Toolbar` + `ToolbarSeparator` (arrow keys across its controls) |
|
|
63
|
-
| Inputs | `Form` (the browser's checks, your own and the server's errors, under each field; `useFormStatus`), `Field`, `Fieldset`, `Input` (start and end content), `Textarea` (`autoGrow`), `NumberField`, `SearchField`, `InputOTP`, `ColorField`, `DateField` and `TimeField` (typed in segments, in the locale's order) |
|
|
64
|
-
| Choices | `Checkbox`, `CheckboxGroup`, `RadioGroup` (plain or cards), `Switch`, `Select`, `Combobox`, `Slider` (one value or a range), `ChoiceCard`, `ListBox` (one or many, on the page) |
|
|
63
|
+
| Inputs | `Form` (the browser's checks, your own and the server's errors, under each field; `useFormStatus`), `Field`, `Fieldset`, `Input` (start and end content), `Textarea` (`autoGrow`), `NumberField`, `SearchField`, `InputOTP`, `ColorField`, `DateField` and `TimeField` (typed in segments, in the locale's order), `TagInput` (several values as tags, typed or picked from suggestions), `PasswordInput` (show and hide, a strength meter, a checklist of rules; `passwordStrength()`) |
|
|
64
|
+
| Choices | `Checkbox`, `CheckboxGroup`, `RadioGroup` (plain or cards), `Switch`, `Select`, `Combobox`, `Slider` (one value or a range), `Rating` (pick a score or show one), `ChoiceCard`, `ListBox` (one or many, on the page) |
|
|
65
65
|
| Pickers | `Calendar`, `DatePicker`, `RangeCalendar`, `DateRangePicker` (with presets), `ColorPicker`, `ColorArea`, `ColorSlider`, `ColorSwatchPicker`, `FileDropZone` |
|
|
66
|
-
| Feedback | `Alert`, `Badge`, `ProgressBar`, `ProgressCircle`, `Meter` (an amount in a range, toned by thresholds), `Spinner`, `Skeleton`, `SkeletonRows`, `Toaster` + `toast()` (sonner: stacked, swipeable, with actions and promises), `Tooltip` |
|
|
67
|
-
| Overlays | `Dialog`, `ConfirmDialog`, `Drawer`, `Popover`, `Menu` + `MenuItem`, `CommandPalette` |
|
|
66
|
+
| Feedback | `Alert`, `Badge`, `ProgressBar`, `ProgressCircle`, `Meter` (an amount in a range, toned by thresholds), `Spinner`, `Skeleton`, `SkeletonRows`, `Toaster` + `toast()` (sonner: stacked, swipeable, with actions and promises), `Tooltip`, `Banner` (an announcement bar across the top, dismissible and remembered) |
|
|
67
|
+
| Overlays | `Dialog`, `ConfirmDialog`, `Drawer`, `Popover`, `HoverCard` (a preview when the pointer rests on a link), `Menu` + `MenuItem`, `CommandPalette`, `ContextMenu` (right-click, long press or Shift+F10, with the same items), `Tour` (steps that point at parts of the page, with an optional spotlight) + `Coachmark` |
|
|
68
68
|
| Navigation | `Tabs`, `Accordion`, `Disclosure`, `Breadcrumbs`, `Pagination`, `Steps`, `NavList` + `NavItem` |
|
|
69
|
-
| Data display | `Table` (sorting, selection), `Stat`, `FileTree`, `EmptyState`, `Tag`, `ColorSwatch`, `Avatar`, `AvatarGroup`, `User` |
|
|
69
|
+
| Data display | `Table` (sorting, selection), `Stat`, `FileTree`, `EmptyState`, `Tag`, `ColorSwatch`, `Avatar`, `AvatarGroup`, `User`, `Image` (a placeholder while it loads, a fallback if it fails, `ratio`, `caption`), `Timeline` + `TimelineItem`, `DescriptionList` + `DescriptionItem`, `Carousel` + `CarouselSlide` (scroll-snap, arrows, dots, autoplay) |
|
|
70
70
|
| AI | `PromptInput` (attachments, stop while streaming) + `PromptSuggestion`, `ChatConversation` (follows the newest message, jump to latest), `ChatMessage` + `ChatMessageActions`, `ChatLoader`, `ChatTool` (a tool call with its status, input, output and approval), `ChainOfThought`, `ChatSource` + `ChatSources`, `TextShimmer` |
|
|
71
|
-
| Layout | `Card`, `SettingsRow`, `Stack`, `Separator`, `ScrollShadow`, `VisuallyHidden` |
|
|
71
|
+
| Layout | `Card`, `SettingsRow`, `Stack`, `Separator`, `ScrollShadow`, `VisuallyHidden`, `AspectRatio`, `Splitter` + `SplitterPanel` + `SplitterHandle` (panels you resize by dragging or with the arrow keys, collapsible, remembered) |
|
|
72
72
|
| Marketing | `SiteHeader`, `SectionHeading`, `Chip`, `DotGrid` |
|
|
73
73
|
|
|
74
74
|
Hooks for your own components: `useControllableState`, `useFloating` (top-layer positioning that flips), `usePresence` (keeps a layer mounted while it animates out), `useDismiss`, `useModalDialog`, `useMenuKeyboard`. Every prop is typed and described, so your editor explains it on hover.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AspectRatioProps } from "./AspectRatio.types.cjs";
|
|
2
|
+
export type { AspectRatioProps } from "./AspectRatio.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* A box that keeps a shape as its width changes, such as 16:9 for a video or 1:1 for a thumbnail. Whatever is inside
|
|
5
|
+
* fills it; an image, video, iframe or embed is cropped to cover it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function AspectRatio({ ratio, as: Element, className, style, ...props }: AspectRatioProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AspectRatioProps } from "./AspectRatio.types.js";
|
|
2
|
+
export type { AspectRatioProps } from "./AspectRatio.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A box that keeps a shape as its width changes, such as 16:9 for a video or 1:1 for a thumbnail. Whatever is inside
|
|
5
|
+
* fills it; an image, video, iframe or embed is cropped to cover it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function AspectRatio({ ratio, as: Element, className, style, ...props }: AspectRatioProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes } from "react";
|
|
2
|
+
export interface AspectRatioProps extends HTMLAttributes<HTMLElement> {
|
|
3
|
+
/** Width over height, such as `16 / 9`, `4 / 3` or `1` for a square. The box is as wide as its container. @default 16 / 9 */
|
|
4
|
+
ratio?: number;
|
|
5
|
+
/** The element to render, such as `figure` or `span`. @default "div" */
|
|
6
|
+
as?: ElementType;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes } from "react";
|
|
2
|
+
export interface AspectRatioProps extends HTMLAttributes<HTMLElement> {
|
|
3
|
+
/** Width over height, such as `16 / 9`, `4 / 3` or `1` for a square. The box is as wide as its container. @default 16 / 9 */
|
|
4
|
+
ratio?: number;
|
|
5
|
+
/** The element to render, such as `figure` or `span`. @default "div" */
|
|
6
|
+
as?: ElementType;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BannerProps } from "./Banner.types.cjs";
|
|
2
|
+
export type { BannerProps, BannerTone } from "./Banner.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* A bar across the top of a page or app for news and notices that concern all of it: a launch, being offline, a
|
|
5
|
+
* trial running out. It's a named region, not an alert, unless you make it `live`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Banner({ tone, icon, action, dismissible, onDismiss, dismissKey, sticky, align, contained, live, label, dismissLabel, className, children, ...props }: BannerProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BannerProps } from "./Banner.types.js";
|
|
2
|
+
export type { BannerProps, BannerTone } from "./Banner.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A bar across the top of a page or app for news and notices that concern all of it: a launch, being offline, a
|
|
5
|
+
* trial running out. It's a named region, not an alert, unless you make it `live`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Banner({ tone, icon, action, dismissible, onDismiss, dismissKey, sticky, align, contained, live, label, dismissLabel, className, children, ...props }: BannerProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { ContainerSize } from "../Container/Container.types.cjs";
|
|
3
|
+
export type BannerTone = "brand" | "neutral" | "info" | "success" | "warning" | "danger";
|
|
4
|
+
export interface BannerProps extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
|
|
5
|
+
/**
|
|
6
|
+
* The bar's colour: `brand` a solid bar in the brand colour for news, `neutral` a quiet grey one, `info`, `success`,
|
|
7
|
+
* `warning` and `danger` the tinted grounds Alert uses, for notices about the app itself.
|
|
8
|
+
* @default "brand"
|
|
9
|
+
*/
|
|
10
|
+
tone?: BannerTone;
|
|
11
|
+
/** Replaces the tone's icon; `false` hides it. */
|
|
12
|
+
icon?: ReactNode | false;
|
|
13
|
+
/** A link or a small button after the message, such as `<Link href="…">Read the post</Link>`. It moves below the message on narrow screens. */
|
|
14
|
+
action?: ReactNode;
|
|
15
|
+
/** Shows a ✕ that hides the bar. @default false */
|
|
16
|
+
dismissible?: boolean;
|
|
17
|
+
/** Called when the person dismisses the bar. */
|
|
18
|
+
onDismiss?(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Remembers the dismissal in this browser (localStorage, as `ow-banner:<key>`), so the bar stays hidden on the next
|
|
21
|
+
* visit. Change the key for a new announcement.
|
|
22
|
+
*/
|
|
23
|
+
dismissKey?: string;
|
|
24
|
+
/** Keeps the bar at the top of the window as the page scrolls. @default false */
|
|
25
|
+
sticky?: boolean;
|
|
26
|
+
/** Where the message sits: in the middle of the bar, or at its start. @default "center" */
|
|
27
|
+
align?: "center" | "start";
|
|
28
|
+
/**
|
|
29
|
+
* Lines the content up with a Container of this size, so it starts where the page below does. `true` is `page`.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
contained?: boolean | ContainerSize;
|
|
33
|
+
/**
|
|
34
|
+
* Reads the message out when it appears: `polite` (role="status") waits for a pause, `assertive` (role="alert")
|
|
35
|
+
* interrupts, for something urgent like going offline. Leave it out for an announcement that's there when the page
|
|
36
|
+
* loads: it's then a region the person can find.
|
|
37
|
+
*/
|
|
38
|
+
live?: "polite" | "assertive";
|
|
39
|
+
/** The region's name for screen readers, when it isn't live. @default "Announcement" */
|
|
40
|
+
label?: string;
|
|
41
|
+
/** The ✕'s name for screen readers. @default "Dismiss" */
|
|
42
|
+
dismissLabel?: string;
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { ContainerSize } from "../Container/Container.types.js";
|
|
3
|
+
export type BannerTone = "brand" | "neutral" | "info" | "success" | "warning" | "danger";
|
|
4
|
+
export interface BannerProps extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
|
|
5
|
+
/**
|
|
6
|
+
* The bar's colour: `brand` a solid bar in the brand colour for news, `neutral` a quiet grey one, `info`, `success`,
|
|
7
|
+
* `warning` and `danger` the tinted grounds Alert uses, for notices about the app itself.
|
|
8
|
+
* @default "brand"
|
|
9
|
+
*/
|
|
10
|
+
tone?: BannerTone;
|
|
11
|
+
/** Replaces the tone's icon; `false` hides it. */
|
|
12
|
+
icon?: ReactNode | false;
|
|
13
|
+
/** A link or a small button after the message, such as `<Link href="…">Read the post</Link>`. It moves below the message on narrow screens. */
|
|
14
|
+
action?: ReactNode;
|
|
15
|
+
/** Shows a ✕ that hides the bar. @default false */
|
|
16
|
+
dismissible?: boolean;
|
|
17
|
+
/** Called when the person dismisses the bar. */
|
|
18
|
+
onDismiss?(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Remembers the dismissal in this browser (localStorage, as `ow-banner:<key>`), so the bar stays hidden on the next
|
|
21
|
+
* visit. Change the key for a new announcement.
|
|
22
|
+
*/
|
|
23
|
+
dismissKey?: string;
|
|
24
|
+
/** Keeps the bar at the top of the window as the page scrolls. @default false */
|
|
25
|
+
sticky?: boolean;
|
|
26
|
+
/** Where the message sits: in the middle of the bar, or at its start. @default "center" */
|
|
27
|
+
align?: "center" | "start";
|
|
28
|
+
/**
|
|
29
|
+
* Lines the content up with a Container of this size, so it starts where the page below does. `true` is `page`.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
contained?: boolean | ContainerSize;
|
|
33
|
+
/**
|
|
34
|
+
* Reads the message out when it appears: `polite` (role="status") waits for a pause, `assertive` (role="alert")
|
|
35
|
+
* interrupts, for something urgent like going offline. Leave it out for an announcement that's there when the page
|
|
36
|
+
* loads: it's then a region the person can find.
|
|
37
|
+
*/
|
|
38
|
+
live?: "polite" | "assertive";
|
|
39
|
+
/** The region's name for screen readers, when it isn't live. @default "Announcement" */
|
|
40
|
+
label?: string;
|
|
41
|
+
/** The ✕'s name for screen readers. @default "Dismiss" */
|
|
42
|
+
dismissLabel?: string;
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CarouselProps, CarouselSlideProps } from "./Carousel.types.cjs";
|
|
2
|
+
export type { CarouselLabels, CarouselProps, CarouselSlideProps } from "./Carousel.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Slides in a row that scroll and snap into place: swipe them, or use the previous and next buttons, the dots or the
|
|
5
|
+
* arrow keys. It's the browser's own scrolling, so it follows a finger or a trackpad exactly.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Carousel({ label, children, slidesPerView, gap, align, index, defaultIndex, onIndexChange, loop, autoplay, arrows, indicators, labels, className, style, onPointerEnter, onPointerLeave, onFocus, onBlur, ...props }: CarouselProps): import("react").JSX.Element;
|
|
8
|
+
/** One slide of a Carousel. Screen readers hear it as a slide, named "2 of 5" unless you give it a `label`. */
|
|
9
|
+
export declare function CarouselSlide({ label, className, ...props }: CarouselSlideProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CarouselProps, CarouselSlideProps } from "./Carousel.types.js";
|
|
2
|
+
export type { CarouselLabels, CarouselProps, CarouselSlideProps } from "./Carousel.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Slides in a row that scroll and snap into place: swipe them, or use the previous and next buttons, the dots or the
|
|
5
|
+
* arrow keys. It's the browser's own scrolling, so it follows a finger or a trackpad exactly.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Carousel({ label, children, slidesPerView, gap, align, index, defaultIndex, onIndexChange, loop, autoplay, arrows, indicators, labels, className, style, onPointerEnter, onPointerLeave, onFocus, onBlur, ...props }: CarouselProps): import("react").JSX.Element;
|
|
8
|
+
/** One slide of a Carousel. Screen readers hear it as a slide, named "2 of 5" unless you give it a `label`. */
|
|
9
|
+
export declare function CarouselSlide({ label, className, ...props }: CarouselSlideProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { SpaceToken } from "../Layout/Layout.cjs";
|
|
3
|
+
export interface CarouselProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
|
|
4
|
+
/** Names the carousel for screen readers, e.g. "Featured projects". */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The slides: one CarouselSlide each. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** How many slides show at once. A fraction (1.2) lets the next one peek in. To change it with the screen's width,
|
|
9
|
+
* set `--ow-carousel-per-view` in your own CSS instead.
|
|
10
|
+
* @default 1 */
|
|
11
|
+
slidesPerView?: number;
|
|
12
|
+
/** The space between slides.
|
|
13
|
+
* @default "md" */
|
|
14
|
+
gap?: SpaceToken;
|
|
15
|
+
/** Where a slide comes to rest: at the `start` of the carousel, or in its `center` with its neighbours either side.
|
|
16
|
+
* @default "start" */
|
|
17
|
+
align?: "start" | "center";
|
|
18
|
+
/** The slide at the start (or centre), from 0, when you control it. */
|
|
19
|
+
index?: number;
|
|
20
|
+
/** The slide it starts on, when it controls itself.
|
|
21
|
+
* @default 0 */
|
|
22
|
+
defaultIndex?: number;
|
|
23
|
+
/** Called when another slide comes to rest, from the buttons, the dots, the keys or a swipe. */
|
|
24
|
+
onIndexChange?(index: number): void;
|
|
25
|
+
/** Next from the last slide goes back to the first, and previous from the first goes to the last.
|
|
26
|
+
* @default false */
|
|
27
|
+
loop?: boolean;
|
|
28
|
+
/** Moves on by itself every this many milliseconds (`true` is 5000), with a button to pause. It waits while the
|
|
29
|
+
* pointer is over it or focus is in it, and starts paused when the system asks for reduced motion.
|
|
30
|
+
* @default false */
|
|
31
|
+
autoplay?: boolean | number;
|
|
32
|
+
/** Where the previous and next buttons go: `overlay` on the slides' edges, `outside` beside them (it takes room
|
|
33
|
+
* either side), or `false` for none.
|
|
34
|
+
* @default "overlay" */
|
|
35
|
+
arrows?: "overlay" | "outside" | false;
|
|
36
|
+
/** Shows a dot for each place it can rest, to go straight there.
|
|
37
|
+
* @default true */
|
|
38
|
+
indicators?: boolean;
|
|
39
|
+
/** The words it uses, for other languages. */
|
|
40
|
+
labels?: CarouselLabels;
|
|
41
|
+
}
|
|
42
|
+
export interface CarouselLabels {
|
|
43
|
+
/** @default "Previous slide" */
|
|
44
|
+
previous?: string;
|
|
45
|
+
/** @default "Next slide" */
|
|
46
|
+
next?: string;
|
|
47
|
+
/** The button that stops autoplay. @default "Pause slides" */
|
|
48
|
+
pause?: string;
|
|
49
|
+
/** The button that starts it again. @default "Play slides" */
|
|
50
|
+
play?: string;
|
|
51
|
+
/** Names the dots. @default "Choose a slide" */
|
|
52
|
+
indicators?: string;
|
|
53
|
+
/** Names a dot, and is read out when another slide comes to rest. @default (n, count) => `Slide ${n} of ${count}` */
|
|
54
|
+
slide?(n: number, count: number): string;
|
|
55
|
+
/** Names a slide, which screen readers already call a slide. @default (n, count) => `${n} of ${count}` */
|
|
56
|
+
position?(n: number, count: number): string;
|
|
57
|
+
}
|
|
58
|
+
export interface CarouselSlideProps extends HTMLAttributes<HTMLDivElement> {
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
/** Names the slide for screen readers.
|
|
61
|
+
* @default its place, e.g. "2 of 5" */
|
|
62
|
+
label?: string;
|
|
63
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { SpaceToken } from "../Layout/Layout.js";
|
|
3
|
+
export interface CarouselProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
|
|
4
|
+
/** Names the carousel for screen readers, e.g. "Featured projects". */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The slides: one CarouselSlide each. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** How many slides show at once. A fraction (1.2) lets the next one peek in. To change it with the screen's width,
|
|
9
|
+
* set `--ow-carousel-per-view` in your own CSS instead.
|
|
10
|
+
* @default 1 */
|
|
11
|
+
slidesPerView?: number;
|
|
12
|
+
/** The space between slides.
|
|
13
|
+
* @default "md" */
|
|
14
|
+
gap?: SpaceToken;
|
|
15
|
+
/** Where a slide comes to rest: at the `start` of the carousel, or in its `center` with its neighbours either side.
|
|
16
|
+
* @default "start" */
|
|
17
|
+
align?: "start" | "center";
|
|
18
|
+
/** The slide at the start (or centre), from 0, when you control it. */
|
|
19
|
+
index?: number;
|
|
20
|
+
/** The slide it starts on, when it controls itself.
|
|
21
|
+
* @default 0 */
|
|
22
|
+
defaultIndex?: number;
|
|
23
|
+
/** Called when another slide comes to rest, from the buttons, the dots, the keys or a swipe. */
|
|
24
|
+
onIndexChange?(index: number): void;
|
|
25
|
+
/** Next from the last slide goes back to the first, and previous from the first goes to the last.
|
|
26
|
+
* @default false */
|
|
27
|
+
loop?: boolean;
|
|
28
|
+
/** Moves on by itself every this many milliseconds (`true` is 5000), with a button to pause. It waits while the
|
|
29
|
+
* pointer is over it or focus is in it, and starts paused when the system asks for reduced motion.
|
|
30
|
+
* @default false */
|
|
31
|
+
autoplay?: boolean | number;
|
|
32
|
+
/** Where the previous and next buttons go: `overlay` on the slides' edges, `outside` beside them (it takes room
|
|
33
|
+
* either side), or `false` for none.
|
|
34
|
+
* @default "overlay" */
|
|
35
|
+
arrows?: "overlay" | "outside" | false;
|
|
36
|
+
/** Shows a dot for each place it can rest, to go straight there.
|
|
37
|
+
* @default true */
|
|
38
|
+
indicators?: boolean;
|
|
39
|
+
/** The words it uses, for other languages. */
|
|
40
|
+
labels?: CarouselLabels;
|
|
41
|
+
}
|
|
42
|
+
export interface CarouselLabels {
|
|
43
|
+
/** @default "Previous slide" */
|
|
44
|
+
previous?: string;
|
|
45
|
+
/** @default "Next slide" */
|
|
46
|
+
next?: string;
|
|
47
|
+
/** The button that stops autoplay. @default "Pause slides" */
|
|
48
|
+
pause?: string;
|
|
49
|
+
/** The button that starts it again. @default "Play slides" */
|
|
50
|
+
play?: string;
|
|
51
|
+
/** Names the dots. @default "Choose a slide" */
|
|
52
|
+
indicators?: string;
|
|
53
|
+
/** Names a dot, and is read out when another slide comes to rest. @default (n, count) => `Slide ${n} of ${count}` */
|
|
54
|
+
slide?(n: number, count: number): string;
|
|
55
|
+
/** Names a slide, which screen readers already call a slide. @default (n, count) => `${n} of ${count}` */
|
|
56
|
+
position?(n: number, count: number): string;
|
|
57
|
+
}
|
|
58
|
+
export interface CarouselSlideProps extends HTMLAttributes<HTMLDivElement> {
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
/** Names the slide for screen readers.
|
|
61
|
+
* @default its place, e.g. "2 of 5" */
|
|
62
|
+
label?: string;
|
|
63
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ContextMenuProps } from "./ContextMenu.types.cjs";
|
|
2
|
+
export type { ContextMenuProps } from "./ContextMenu.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* A menu of actions for an area, opened where you right-click it, with a long press on a touch screen, or with
|
|
5
|
+
* Shift+F10 or the context menu key when focus is inside it. It uses Menu's items and keyboard, and looks the same.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ContextMenu({ children, menu, label, width, disabled, onOpenChange, className }: ContextMenuProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ContextMenuProps } from "./ContextMenu.types.js";
|
|
2
|
+
export type { ContextMenuProps } from "./ContextMenu.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A menu of actions for an area, opened where you right-click it, with a long press on a touch screen, or with
|
|
5
|
+
* Shift+F10 or the context menu key when focus is inside it. It uses Menu's items and keyboard, and looks the same.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ContextMenu({ children, menu, label, width, disabled, onOpenChange, className }: ContextMenuProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode, RefObject } from "react";
|
|
2
|
+
export interface ContextMenuProps {
|
|
3
|
+
/** The area that opens the menu: one element or several. Give it something focusable, so the keyboard can reach it. */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** The menu: MenuItem, MenuLabel and MenuSeparator, as in a Menu. */
|
|
6
|
+
menu: ReactNode;
|
|
7
|
+
/** Names the menu for screen readers, e.g. "File actions". */
|
|
8
|
+
label: string;
|
|
9
|
+
/** CSS width; default fits the items, at least 200px. */
|
|
10
|
+
width?: number | string;
|
|
11
|
+
/** Leaves the browser's own context menu in place and opens nothing.
|
|
12
|
+
* @default false */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Called when it opens or closes, e.g. to highlight the row it's for. */
|
|
15
|
+
onOpenChange?(open: boolean): void;
|
|
16
|
+
/** Classes for the menu panel. */
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
/** The panel inside a ContextMenu, remade for each opening. Internal. */
|
|
20
|
+
export interface ContextMenuPanelProps extends Pick<ContextMenuProps, "label" | "width" | "className"> {
|
|
21
|
+
/** Where it opens: a point for the pointer, the focused element's box for the keyboard. */
|
|
22
|
+
anchor: () => DOMRect;
|
|
23
|
+
open: boolean;
|
|
24
|
+
state: "open" | "closed";
|
|
25
|
+
menuRef: RefObject<HTMLDivElement>;
|
|
26
|
+
/** The element to return focus to on Escape. */
|
|
27
|
+
restoreRef: RefObject<HTMLElement | null>;
|
|
28
|
+
id: string;
|
|
29
|
+
/** Escape or Tab in the menu. */
|
|
30
|
+
onClose(): void;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode, RefObject } from "react";
|
|
2
|
+
export interface ContextMenuProps {
|
|
3
|
+
/** The area that opens the menu: one element or several. Give it something focusable, so the keyboard can reach it. */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** The menu: MenuItem, MenuLabel and MenuSeparator, as in a Menu. */
|
|
6
|
+
menu: ReactNode;
|
|
7
|
+
/** Names the menu for screen readers, e.g. "File actions". */
|
|
8
|
+
label: string;
|
|
9
|
+
/** CSS width; default fits the items, at least 200px. */
|
|
10
|
+
width?: number | string;
|
|
11
|
+
/** Leaves the browser's own context menu in place and opens nothing.
|
|
12
|
+
* @default false */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Called when it opens or closes, e.g. to highlight the row it's for. */
|
|
15
|
+
onOpenChange?(open: boolean): void;
|
|
16
|
+
/** Classes for the menu panel. */
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
/** The panel inside a ContextMenu, remade for each opening. Internal. */
|
|
20
|
+
export interface ContextMenuPanelProps extends Pick<ContextMenuProps, "label" | "width" | "className"> {
|
|
21
|
+
/** Where it opens: a point for the pointer, the focused element's box for the keyboard. */
|
|
22
|
+
anchor: () => DOMRect;
|
|
23
|
+
open: boolean;
|
|
24
|
+
state: "open" | "closed";
|
|
25
|
+
menuRef: RefObject<HTMLDivElement>;
|
|
26
|
+
/** The element to return focus to on Escape. */
|
|
27
|
+
restoreRef: RefObject<HTMLElement | null>;
|
|
28
|
+
id: string;
|
|
29
|
+
/** Escape or Tab in the menu. */
|
|
30
|
+
onClose(): void;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DescriptionItemProps, DescriptionListProps } from "./DescriptionList.types.cjs";
|
|
2
|
+
export type { DescriptionItemProps, DescriptionListLayout, DescriptionListProps } from "./DescriptionList.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Terms and their values, for detail pages, settings summaries and receipts: a `<dl>` with a DescriptionItem for each
|
|
5
|
+
* pair. Horizontal by default, stacking in a narrow container; vertical; or a grid of columns.
|
|
6
|
+
*/
|
|
7
|
+
export declare function DescriptionList({ layout, columns, divided, density, termWidth, className, style, ...props }: DescriptionListProps): import("react").JSX.Element;
|
|
8
|
+
/** One term and its value in a DescriptionList, with an optional action at the end of the row. */
|
|
9
|
+
export declare function DescriptionItem({ term, children, action, span, className, ...props }: DescriptionItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DescriptionItemProps, DescriptionListProps } from "./DescriptionList.types.js";
|
|
2
|
+
export type { DescriptionItemProps, DescriptionListLayout, DescriptionListProps } from "./DescriptionList.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Terms and their values, for detail pages, settings summaries and receipts: a `<dl>` with a DescriptionItem for each
|
|
5
|
+
* pair. Horizontal by default, stacking in a narrow container; vertical; or a grid of columns.
|
|
6
|
+
*/
|
|
7
|
+
export declare function DescriptionList({ layout, columns, divided, density, termWidth, className, style, ...props }: DescriptionListProps): import("react").JSX.Element;
|
|
8
|
+
/** One term and its value in a DescriptionList, with an optional action at the end of the row. */
|
|
9
|
+
export declare function DescriptionItem({ term, children, action, span, className, ...props }: DescriptionItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type DescriptionListLayout = "horizontal" | "vertical" | "grid";
|
|
3
|
+
export interface DescriptionListProps extends HTMLAttributes<HTMLDListElement> {
|
|
4
|
+
/**
|
|
5
|
+
* `horizontal` puts each term in a column on the left and its value on the right, and stacks them when the list is
|
|
6
|
+
* narrower than 420px; `vertical` puts each term above its value, one pair under another; `grid` lays the pairs out
|
|
7
|
+
* in `columns`, term above value, for a summary at a glance.
|
|
8
|
+
* @default "horizontal"
|
|
9
|
+
*/
|
|
10
|
+
layout?: DescriptionListLayout;
|
|
11
|
+
/** How many columns a `grid` has, at most: a column is at least 160px wide, so a narrow list has fewer. @default 2 */
|
|
12
|
+
columns?: 2 | 3 | 4;
|
|
13
|
+
/** A hairline between rows. In a grid, every row has one above it. @default false */
|
|
14
|
+
divided?: boolean;
|
|
15
|
+
/** `compact` rows have 8px above and below; `comfortable` 12px.
|
|
16
|
+
* @default "comfortable" */
|
|
17
|
+
density?: "compact" | "comfortable";
|
|
18
|
+
/** How wide the term column is in a `horizontal` list: a number of pixels, or any CSS width. @default 160 */
|
|
19
|
+
termWidth?: number | string;
|
|
20
|
+
/** DescriptionItems. */
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export interface DescriptionItemProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
24
|
+
/** What the value is, in a word or two: "Email", "Plan". It renders a `<dt>`. */
|
|
25
|
+
term: ReactNode;
|
|
26
|
+
/** The value: text, or a Badge, User, Link or Code. It renders a `<dd>`. */
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
/** Something to do with the value, at the end of the row: an "Edit" ghost Button or a CopyButton. Name it, as it's read after the value. */
|
|
29
|
+
action?: ReactNode;
|
|
30
|
+
/** How many columns it takes in a `grid`; `full` takes the whole row. It takes the whole row where the grid has fewer columns. @default 1 */
|
|
31
|
+
span?: 1 | 2 | 3 | 4 | "full";
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type DescriptionListLayout = "horizontal" | "vertical" | "grid";
|
|
3
|
+
export interface DescriptionListProps extends HTMLAttributes<HTMLDListElement> {
|
|
4
|
+
/**
|
|
5
|
+
* `horizontal` puts each term in a column on the left and its value on the right, and stacks them when the list is
|
|
6
|
+
* narrower than 420px; `vertical` puts each term above its value, one pair under another; `grid` lays the pairs out
|
|
7
|
+
* in `columns`, term above value, for a summary at a glance.
|
|
8
|
+
* @default "horizontal"
|
|
9
|
+
*/
|
|
10
|
+
layout?: DescriptionListLayout;
|
|
11
|
+
/** How many columns a `grid` has, at most: a column is at least 160px wide, so a narrow list has fewer. @default 2 */
|
|
12
|
+
columns?: 2 | 3 | 4;
|
|
13
|
+
/** A hairline between rows. In a grid, every row has one above it. @default false */
|
|
14
|
+
divided?: boolean;
|
|
15
|
+
/** `compact` rows have 8px above and below; `comfortable` 12px.
|
|
16
|
+
* @default "comfortable" */
|
|
17
|
+
density?: "compact" | "comfortable";
|
|
18
|
+
/** How wide the term column is in a `horizontal` list: a number of pixels, or any CSS width. @default 160 */
|
|
19
|
+
termWidth?: number | string;
|
|
20
|
+
/** DescriptionItems. */
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export interface DescriptionItemProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
24
|
+
/** What the value is, in a word or two: "Email", "Plan". It renders a `<dt>`. */
|
|
25
|
+
term: ReactNode;
|
|
26
|
+
/** The value: text, or a Badge, User, Link or Code. It renders a `<dd>`. */
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
/** Something to do with the value, at the end of the row: an "Edit" ghost Button or a CopyButton. Name it, as it's read after the value. */
|
|
29
|
+
action?: ReactNode;
|
|
30
|
+
/** How many columns it takes in a `grid`; `full` takes the whole row. It takes the whole row where the grid has fewer columns. @default 1 */
|
|
31
|
+
span?: 1 | 2 | 3 | 4 | "full";
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HoverCardProps } from "./HoverCard.types.cjs";
|
|
2
|
+
export type { HoverCardProps } from "./HoverCard.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* A preview card that opens when the pointer rests on its trigger (a link to a person or a page) or the trigger gets
|
|
5
|
+
* keyboard focus, and closes when the pointer leaves both, on Escape, or when focus moves away. It's extra: whatever
|
|
6
|
+
* it shows must also be reachable through the trigger, as touch screens never open it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function HoverCard({ trigger, children, open, defaultOpen, onOpenChange, placement, openDelay, closeDelay, width, className, }: HoverCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HoverCardProps } from "./HoverCard.types.js";
|
|
2
|
+
export type { HoverCardProps } from "./HoverCard.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A preview card that opens when the pointer rests on its trigger (a link to a person or a page) or the trigger gets
|
|
5
|
+
* keyboard focus, and closes when the pointer leaves both, on Escape, or when focus moves away. It's extra: whatever
|
|
6
|
+
* it shows must also be reachable through the trigger, as touch screens never open it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function HoverCard({ trigger, children, open, defaultOpen, onOpenChange, placement, openDelay, closeDelay, width, className, }: HoverCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { Placement } from "../../hooks/useFloating.cjs";
|
|
3
|
+
export interface HoverCardProps {
|
|
4
|
+
/** What people point at or tab to: usually a Link to a profile or a page. It keeps working as it is; touch opens the link, not the card. */
|
|
5
|
+
trigger: ReactElement;
|
|
6
|
+
/** The card's content: a preview of what the trigger leads to. It may hold links and buttons. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Whether it's showing, when you keep that in your own state. */
|
|
9
|
+
open?: boolean;
|
|
10
|
+
/** Whether it's showing at first, when it keeps its own state.
|
|
11
|
+
* @default false */
|
|
12
|
+
defaultOpen?: boolean;
|
|
13
|
+
/** Called when it opens or closes. */
|
|
14
|
+
onOpenChange?(open: boolean): void;
|
|
15
|
+
/** Where it opens relative to the trigger; it flips when there's no room.
|
|
16
|
+
* @default "bottom" */
|
|
17
|
+
placement?: Placement;
|
|
18
|
+
/** Milliseconds the pointer rests on the trigger before it opens. Keyboard focus opens it at once.
|
|
19
|
+
* @default 500 */
|
|
20
|
+
openDelay?: number;
|
|
21
|
+
/** Milliseconds it waits after the pointer leaves before it closes, so the pointer can cross into the card.
|
|
22
|
+
* @default 250 */
|
|
23
|
+
closeDelay?: number;
|
|
24
|
+
/** Pixels, or any CSS width.
|
|
25
|
+
* @default 320 */
|
|
26
|
+
width?: number | string;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { Placement } from "../../hooks/useFloating.js";
|
|
3
|
+
export interface HoverCardProps {
|
|
4
|
+
/** What people point at or tab to: usually a Link to a profile or a page. It keeps working as it is; touch opens the link, not the card. */
|
|
5
|
+
trigger: ReactElement;
|
|
6
|
+
/** The card's content: a preview of what the trigger leads to. It may hold links and buttons. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Whether it's showing, when you keep that in your own state. */
|
|
9
|
+
open?: boolean;
|
|
10
|
+
/** Whether it's showing at first, when it keeps its own state.
|
|
11
|
+
* @default false */
|
|
12
|
+
defaultOpen?: boolean;
|
|
13
|
+
/** Called when it opens or closes. */
|
|
14
|
+
onOpenChange?(open: boolean): void;
|
|
15
|
+
/** Where it opens relative to the trigger; it flips when there's no room.
|
|
16
|
+
* @default "bottom" */
|
|
17
|
+
placement?: Placement;
|
|
18
|
+
/** Milliseconds the pointer rests on the trigger before it opens. Keyboard focus opens it at once.
|
|
19
|
+
* @default 500 */
|
|
20
|
+
openDelay?: number;
|
|
21
|
+
/** Milliseconds it waits after the pointer leaves before it closes, so the pointer can cross into the card.
|
|
22
|
+
* @default 250 */
|
|
23
|
+
closeDelay?: number;
|
|
24
|
+
/** Pixels, or any CSS width.
|
|
25
|
+
* @default 320 */
|
|
26
|
+
width?: number | string;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ImageProps } from "./Image.types.cjs";
|
|
2
|
+
export type { ImageFit, ImageProps, ImageRadius } from "./Image.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* An `<img>` with a pulsing placeholder while it loads and a fallback if it fails, lazy loaded by default. Give it a
|
|
5
|
+
* `ratio` to fill a box of that shape, and a `caption` to put it in a figure.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Image: import("react").ForwardRefExoticComponent<ImageProps & import("react").RefAttributes<HTMLImageElement>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ImageProps } from "./Image.types.js";
|
|
2
|
+
export type { ImageFit, ImageProps, ImageRadius } from "./Image.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* An `<img>` with a pulsing placeholder while it loads and a fallback if it fails, lazy loaded by default. Give it a
|
|
5
|
+
* `ratio` to fill a box of that shape, and a `caption` to put it in a figure.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Image: import("react").ForwardRefExoticComponent<ImageProps & import("react").RefAttributes<HTMLImageElement>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CSSProperties, ImgHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type ImageFit = "cover" | "contain";
|
|
3
|
+
export type ImageRadius = "none" | "control" | "container";
|
|
4
|
+
export interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "alt"> {
|
|
5
|
+
/**
|
|
6
|
+
* What the image shows, for screen readers and when it can't load. Required: pass `alt=""` for a decorative image
|
|
7
|
+
* that adds nothing to the text around it.
|
|
8
|
+
*/
|
|
9
|
+
alt: string;
|
|
10
|
+
/** Width over height, such as `16 / 9` or `1`: the image fills a box of that shape as wide as its container. Leave it out to keep the image's own size. */
|
|
11
|
+
ratio?: number;
|
|
12
|
+
/** `cover` fills the box and crops what's over; `contain` shows the whole image, with space around it if the shapes differ. @default "cover" */
|
|
13
|
+
fit?: ImageFit;
|
|
14
|
+
/** The corners: `control` matches inputs and buttons (8px), `container` matches cards (12px). @default "none" */
|
|
15
|
+
radius?: ImageRadius;
|
|
16
|
+
/** Shown instead when the image fails to load or there's no `src`. @default an image icon on a muted ground */
|
|
17
|
+
fallback?: ReactNode;
|
|
18
|
+
/** A line under the image. With it, the image and the caption come in a `<figure>`. */
|
|
19
|
+
caption?: ReactNode;
|
|
20
|
+
/** Lazy loads the image only as it nears the screen; pass `"eager"` for one at the top of the page. @default "lazy" */
|
|
21
|
+
loading?: "lazy" | "eager";
|
|
22
|
+
/** @default "async" */
|
|
23
|
+
decoding?: "async" | "sync" | "auto";
|
|
24
|
+
/** Goes on the outer box (or the figure), not the `<img>`, so you can size and place it. */
|
|
25
|
+
className?: string;
|
|
26
|
+
/** Goes on the outer box (or the figure), not the `<img>`, so you can size and place it. */
|
|
27
|
+
style?: CSSProperties;
|
|
28
|
+
}
|