@minimalstuff/ui 5.9.0 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -1
- package/dist/index.d.ts +148 -0
- package/dist/minimalstuff-ui.css +1 -1
- package/dist/minimalstuff-ui.js +1236 -596
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -113,10 +113,101 @@ node --input-type=module -e "import { THEME_INIT_SCRIPT } from '@minimalstuff/ui
|
|
|
113
113
|
|
|
114
114
|
The hash changes if a release changes the script: recompute it when you upgrade.
|
|
115
115
|
|
|
116
|
+
### Bottom sheets
|
|
117
|
+
|
|
118
|
+
`BottomSheet` is a modal sheet attached to the bottom edge at every viewport width. Set its height per sheet with the `--ms-sheet-height` custom property (default `85svh`): `height="auto"` fits the content up to that height, `height="fixed"` uses exactly that height.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
<BottomSheet
|
|
122
|
+
isOpen={isOpen}
|
|
123
|
+
onClose={close}
|
|
124
|
+
title="Comments"
|
|
125
|
+
height="fixed"
|
|
126
|
+
panelClassName="[--ms-sheet-height:76svh]"
|
|
127
|
+
footer={<CommentComposer />}
|
|
128
|
+
expandable
|
|
129
|
+
>
|
|
130
|
+
…
|
|
131
|
+
</BottomSheet>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Drag the handle (mouse, pen) or the header and body (touch, once the body is scrolled to the top) down to close it; the close button, Escape and the backdrop stay available. With `expandable`, dragging the handle or the header up expands the sheet to full screen like the header button; an upward move in the body stays a scroll. Put `data-sheet-no-drag` on an element, such as a custom slider, to keep touches there from dragging the sheet. While a sheet is open it follows the virtual keyboard (`window.visualViewport`), and bottom toasts move to the top.
|
|
135
|
+
|
|
116
136
|
### Modals and drawers lock page scroll
|
|
117
137
|
|
|
118
138
|
While a `Modal` or `Drawer` is open, page scroll is locked on `<html>`. The scrollbar width this frees is compensated with right padding on `<html>`, so the page does not shift. That padding does not move `position: fixed` elements: anchor right-aligned ones with `right: var(--scrollbar-compensation, 0px)`. Paint the page background on `<html>` or `<body>` rather than only on a wrapper element, or the padding shows the root's background as a strip on the right.
|
|
119
139
|
|
|
140
|
+
### Touch targets
|
|
141
|
+
|
|
142
|
+
Controls keep their compact size unless you opt in. Set `--ms-control-min-height` and every styled control grows to at least that height: `Button`, `IconButton` (width too, so it stays square), `Input`, `Select`, `Combobox`, `MultiCombobox`, the tabs of `Tabs`, and so `SplitButton` and `CopyButton`, which are built from them. Components with `unstyled` do not read it. `Textarea`, `Checkbox`, `RadioOptions`, `Switch`, `Badge` and `Kbd` are left out.
|
|
143
|
+
|
|
144
|
+
```css
|
|
145
|
+
@media (pointer: coarse) {
|
|
146
|
+
:root {
|
|
147
|
+
--ms-control-min-height: 2.75rem;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The variable inherits, so you can scope it to a container, or reset it to `0px` in a dense toolbar. Without it nothing changes. Every control already meets the 24 px minimum of WCAG 2.5.8 (AA); 44 px is WCAG 2.5.5 (AAA), which this variable lets you reach on touch screens.
|
|
153
|
+
|
|
154
|
+
### Side panel
|
|
155
|
+
|
|
156
|
+
`SidePanel` is a non-modal panel docked to one side, for something the user works with beside the page (an assistant, a details column). Use `Drawer` instead when the panel should block the page: `SidePanel` has no backdrop, no focus trap and no scroll lock, and the page stays usable. From the `overlayBelow` breakpoint up (`xl`, 1280 px, by default) it is a sticky column of the layout, so put it in a flex row next to `<main>` and the page reflows. Below it, the panel covers part of the page without a backdrop: do not open it by default at that width, since it can hide the focused control (WCAG 2.4.11). It unmounts after its exit, so keep its open state in your own store.
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<div className="flex">
|
|
160
|
+
<main className="min-w-0 flex-1">…</main>
|
|
161
|
+
<SidePanel isOpen={isOpen} onClose={close} title="Details" footer={<NoteComposer />}>
|
|
162
|
+
…
|
|
163
|
+
</SidePanel>
|
|
164
|
+
</div>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Focus never moves on its own. Pass `focusOnOpen` when the user opened the panel (a button press), not when it opens by default or on a route change; focus then goes to `initialFocusRef`, else the heading. On close, focus moves only if it was inside the panel: to `returnFocusRef`, else to the element focused when the panel opened, else to `<main>`. A floating button that unmounts while the panel is open needs `returnFocusRef`:
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
const openerRef = useRef<HTMLButtonElement>(null)
|
|
171
|
+
|
|
172
|
+
{!isOpen && <IconButton ref={openerRef} icon="i-mdi-information-outline" aria-label="Show details" onClick={open} />}
|
|
173
|
+
<SidePanel isOpen={isOpen} onClose={close} title="Details" focusOnOpen returnFocusRef={openerRef}>
|
|
174
|
+
…
|
|
175
|
+
</SidePanel>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Escape inside the panel closes it, unless a `Modal`, `Drawer` or `BottomSheet` is open.
|
|
179
|
+
|
|
180
|
+
### Tab bar
|
|
181
|
+
|
|
182
|
+
`TabBar` is a bottom navigation for a few top-level destinations on a phone. It is site navigation (a `<nav>` holding a list of links), not an ARIA `tablist`. `TabBarLink` renders an `<a>` with an icon and a short label; mark the current page with `aria-current="page"`.
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
<TabBar aria-label="Main" className="fixed inset-x-0 bottom-0">
|
|
186
|
+
<TabBarLink href="/" icon="i-mdi-home" aria-current="page">Home</TabBarLink>
|
|
187
|
+
<TabBarLink href="/search" icon="i-mdi-magnify">Search</TabBarLink>
|
|
188
|
+
<TabBarLink href="/inbox" icon="i-mdi-inbox">Inbox</TabBarLink>
|
|
189
|
+
</TabBar>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
With TanStack Router, wrap the link once. The router sets `aria-current="page"` on the active link; give the `/` link `activeOptions={{ exact: true }}`, or it is current on every route.
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
const TabBarRouterLink = createLink(TabBarLink)
|
|
196
|
+
|
|
197
|
+
<TabBarRouterLink to="/" activeOptions={{ exact: true }} icon="i-mdi-home">Home</TabBarRouterLink>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The bar is static: you position it. When it is fixed, keep focused controls and bottom toasts clear of it with `scroll-padding-bottom` on `html` and `--ms-toast-offset-bottom`:
|
|
201
|
+
|
|
202
|
+
```css
|
|
203
|
+
html {
|
|
204
|
+
scroll-padding-bottom: 5rem;
|
|
205
|
+
}
|
|
206
|
+
:root {
|
|
207
|
+
--ms-toast-offset-bottom: calc(5rem + env(safe-area-inset-bottom));
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
120
211
|
## Develop
|
|
121
212
|
|
|
122
213
|
```bash
|
|
@@ -124,7 +215,7 @@ pnpm install
|
|
|
124
215
|
pnpm dev
|
|
125
216
|
```
|
|
126
217
|
|
|
127
|
-
`pnpm dev` starts Storybook on port 6006.
|
|
218
|
+
`pnpm dev` starts Storybook on port 6006, or on `STORYBOOK_PORT` when set (devslot sets it per checkout).
|
|
128
219
|
|
|
129
220
|
Before pushing, run what CI runs (see [`ci.yml`](.github/workflows/ci.yml)):
|
|
130
221
|
|
package/dist/index.d.ts
CHANGED
|
@@ -135,6 +135,52 @@ export declare type BadgeVariant = 'solid' | 'outline' | 'subtle';
|
|
|
135
135
|
|
|
136
136
|
export declare const BASE_INPUT_STYLES = "w-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-hidden focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed";
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* A modal sheet attached to the bottom edge at every viewport width, with the
|
|
140
|
+
* same focus handling, stacking and footer slot as `Modal`. Drag the handle
|
|
141
|
+
* (mouse, pen) or the header and body (touch, when the body is scrolled to the
|
|
142
|
+
* top) down to close it. While open it sits above the virtual keyboard, and
|
|
143
|
+
* bottom toasts move to the top.
|
|
144
|
+
*/
|
|
145
|
+
export declare function BottomSheet({ isOpen, onClose, height, radius, dismissible, expandable, onExited, ...dialogProps }: Readonly<BottomSheetProps>): JSX.Element | null;
|
|
146
|
+
|
|
147
|
+
export declare type BottomSheetHeight = 'auto' | 'fixed';
|
|
148
|
+
|
|
149
|
+
export declare interface BottomSheetProps {
|
|
150
|
+
isOpen: boolean;
|
|
151
|
+
onClose: () => void;
|
|
152
|
+
/** Names the dialog. */
|
|
153
|
+
title: ReactNode;
|
|
154
|
+
children: ReactNode;
|
|
155
|
+
/** Pinned below the body; a `ModalFooter` inside `children` renders in the same place. */
|
|
156
|
+
footer?: ReactNode;
|
|
157
|
+
/**
|
|
158
|
+
* `auto` fits the content, up to `var(--ms-sheet-height, 85svh)`; `fixed` is exactly that height. Set `--ms-sheet-height` per sheet, e.g. `panelClassName="[--ms-sheet-height:76svh]"`. The body scrolls inside.
|
|
159
|
+
*/
|
|
160
|
+
height?: BottomSheetHeight;
|
|
161
|
+
/** Adds a header button that toggles full screen (the full dynamic viewport height, no top radius, no handle). The state is internal and starts collapsed on every open. Escape, the close button and the backdrop close the sheet even when expanded; a drag past the threshold only collapses it. Dragging the sheet up expands it too: from the handle (mouse, pen) and, by touch, from the header only, so an upward move in the body stays a scroll. The panel grows with the finger and expands past a quarter of the room left or on an upward flick; otherwise it springs back. A sheet that is not `dismissible` has no handle, so the drag-up is by touch from the header only. The height change animates with `transition-property: height` and `interpolate-size: allow-keywords`, so it also animates from an `auto` height in browsers that support it, and jumps in the others. */
|
|
162
|
+
expandable?: boolean;
|
|
163
|
+
/** Called with the new state when the full-screen button is used, when a drag collapses the sheet, and with `false` when an expanded sheet closes. */
|
|
164
|
+
onExpandedChange?: (isExpanded: boolean) => void;
|
|
165
|
+
/** Applied to the top corners only. `full` caps at the panel scale. */
|
|
166
|
+
radius?: Radius;
|
|
167
|
+
/** Applied to the scrollable body. */
|
|
168
|
+
className?: string;
|
|
169
|
+
/** Applied to the `role=dialog` element. A `transform`, `filter` or `backdrop-filter` on the open panel makes it the containing block of `position: fixed` descendants, so Menus opened inside it get clipped. Keep these off the open state. Carries `data-bottom-sheet` and `data-state="open"` or `"closed"`, so `data-[state=closed]:` variants can animate it. Put your own transitions behind `motion-reduce:` variants, since `unstyled` drops the library's reduced-motion handling along with its animations. */
|
|
170
|
+
panelClassName?: string;
|
|
171
|
+
/** Applied to the backdrop element, which carries the click-to-dismiss. */
|
|
172
|
+
backdropClassName?: string;
|
|
173
|
+
/** Strips the library's visual styling (background, shadow, radius, slide transition, backdrop tint, handle colour, header and body typography and padding), keeping layout, `height`, drag, scrolling and behaviour. `radius` is ignored. The header buttons keep a 24px minimum target size. */
|
|
174
|
+
unstyled?: boolean;
|
|
175
|
+
/** `false` hides the close button and the handle, and blocks Escape, backdrop and drag dismissal. */
|
|
176
|
+
dismissible?: boolean;
|
|
177
|
+
closeLabel?: string;
|
|
178
|
+
/** Called once per close, when the exit has finished and the panel is unmounted. Not called when the sheet reopens during the exit, nor on an initial render with `isOpen={false}`. */
|
|
179
|
+
onExited?: () => void;
|
|
180
|
+
/** Wins over the first-tabbable rule for where focus lands on open; may point at an element in the body or in the footer. */
|
|
181
|
+
initialFocusRef?: RefObject<HTMLElement | null>;
|
|
182
|
+
}
|
|
183
|
+
|
|
138
184
|
export declare function Button(buttonProps: Readonly<ButtonProps>): JSX.Element;
|
|
139
185
|
|
|
140
186
|
/**
|
|
@@ -1044,6 +1090,61 @@ export declare interface SelectProps extends Omit<ComponentPropsWithRef<'select'
|
|
|
1044
1090
|
wrapperClassName?: string;
|
|
1045
1091
|
}
|
|
1046
1092
|
|
|
1093
|
+
/**
|
|
1094
|
+
* A non-modal panel docked to one side of the page, such as an assistant or a
|
|
1095
|
+
* details column. Unlike `Drawer` it has no backdrop, no focus trap and no
|
|
1096
|
+
* scroll lock: the page stays usable beside it. It renders in place as an
|
|
1097
|
+
* `<aside>` (a `complementary` landmark named by its title). From the
|
|
1098
|
+
* `overlayBelow` breakpoint up it is a sticky column of the layout, so put it
|
|
1099
|
+
* in a flex row next to `<main>` and the page reflows; below it, it is fixed
|
|
1100
|
+
* over the page and slides in. It unmounts after its exit, so keep its open
|
|
1101
|
+
* state in your own store.
|
|
1102
|
+
*/
|
|
1103
|
+
export declare function SidePanel({ isOpen, side, size, overlayBelow, radius, ...panelProps }: Readonly<SidePanelProps>): JSX.Element | null;
|
|
1104
|
+
|
|
1105
|
+
/** The viewport width below which the panel overlays the page instead of sitting in its flow: `lg` is 1024px, `xl` 1280px, `never` keeps it in the flow at every width. */
|
|
1106
|
+
export declare type SidePanelOverlayBelow = 'lg' | 'xl' | 'never';
|
|
1107
|
+
|
|
1108
|
+
export declare type SidePanelProps = {
|
|
1109
|
+
isOpen: boolean;
|
|
1110
|
+
/** Called by the collapse button and by Escape pressed inside the panel. */
|
|
1111
|
+
onClose: () => void;
|
|
1112
|
+
/** Names the panel: it is the `<h2>` the `complementary` landmark is labelled by. */
|
|
1113
|
+
title: ReactNode;
|
|
1114
|
+
/** The scrolling body. */
|
|
1115
|
+
children: ReactNode;
|
|
1116
|
+
/** Pinned below the body, for example a note composer. */
|
|
1117
|
+
footer?: ReactNode;
|
|
1118
|
+
/** Header content between the title and the collapse button, for example a count of items to review. */
|
|
1119
|
+
actions?: ReactNode;
|
|
1120
|
+
/** The edge of the page the panel is docked to. */
|
|
1121
|
+
side?: SidePanelSide;
|
|
1122
|
+
/** Fixed width: `sm` 360px, `md` 420px, `lg` 520px, never wider than its container. */
|
|
1123
|
+
size?: SidePanelSize;
|
|
1124
|
+
/** The width below which the panel covers the page (fixed, with a shadow, sliding in) instead of sitting in the layout flow: `xl` is 1280px, `lg` 1024px, `never` keeps it in the flow at every width. It has no backdrop, so below the breakpoint it hides part of the page: do not open it by default there. */
|
|
1125
|
+
overlayBelow?: SidePanelOverlayBelow;
|
|
1126
|
+
/** Moves focus into the panel when it opens: to `initialFocusRef`, else the heading. Leave it `false` (the default) when the panel opens by itself, on page load or a route change: focus then never moves. Read at the moment the panel opens. */
|
|
1127
|
+
focusOnOpen?: boolean;
|
|
1128
|
+
/** Where focus lands when the panel opens with `focusOnOpen`. */
|
|
1129
|
+
initialFocusRef?: RefObject<HTMLElement | null>;
|
|
1130
|
+
/** Where focus goes when the panel closes while it holds focus, when it is still in the document. Otherwise focus goes back to the element focused when the panel opened, then to `<main>`. Use it when the opener unmounts while the panel is open, such as a floating button. */
|
|
1131
|
+
returnFocusRef?: RefObject<HTMLElement | null>;
|
|
1132
|
+
/** Accessible name of the collapse button. */
|
|
1133
|
+
collapseLabel?: string;
|
|
1134
|
+
/** Applied to the corners on the edge facing the page only. */
|
|
1135
|
+
radius?: Radius;
|
|
1136
|
+
/** Applied to the scrollable body. */
|
|
1137
|
+
className?: string;
|
|
1138
|
+
/** Applied to the `<aside>`. It carries `data-state="open"` or `"closed"`, so `data-[state=closed]:` variants can style the exit. A `transform` on the open panel makes it the containing block of `position: fixed` descendants: keep it off the open state. */
|
|
1139
|
+
panelClassName?: string;
|
|
1140
|
+
/** Strips the library's visual styling (surface, border, shadow, radius, slide transition, header and body typography and padding), keeping the layout, `side`, `size`, `overlayBelow`, scrolling and behaviour. `radius` is ignored. */
|
|
1141
|
+
unstyled?: boolean;
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
export declare type SidePanelSide = 'right' | 'left';
|
|
1145
|
+
|
|
1146
|
+
export declare type SidePanelSize = 'sm' | 'md' | 'lg';
|
|
1147
|
+
|
|
1047
1148
|
/**
|
|
1048
1149
|
* A loading indicator exposed as a `role="status"` live region. It uses the
|
|
1049
1150
|
* icon `Button` shows while loading; under `prefers-reduced-motion` it swaps
|
|
@@ -1161,6 +1262,47 @@ export declare interface SwitchProps extends Omit<ComponentPropsWithRef<'input'>
|
|
|
1161
1262
|
wrapperClassName?: string;
|
|
1162
1263
|
}
|
|
1163
1264
|
|
|
1265
|
+
/**
|
|
1266
|
+
* A bottom navigation bar for a handful of top-level destinations on a phone.
|
|
1267
|
+
* It is site navigation, not a WAI-ARIA `tablist`: a `<nav>` landmark holding a
|
|
1268
|
+
* list of links, where the link for the current page carries
|
|
1269
|
+
* `aria-current="page"`. The links share the width in equal columns, however
|
|
1270
|
+
* many there are. It is static: position it yourself (`fixed inset-x-0
|
|
1271
|
+
* bottom-0` or `sticky bottom-0`) and keep page content clear of it. Its
|
|
1272
|
+
* left, right and bottom padding honours the device safe area. A full-bleed
|
|
1273
|
+
* bar has no corners, so it takes no `radius`.
|
|
1274
|
+
*/
|
|
1275
|
+
export declare function TabBar(tabBarProps: Readonly<TabBarProps>): JSX.Element;
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* One destination of a `TabBar`: a list item holding a link, with an icon in a
|
|
1279
|
+
* pill above a short label. Mark the link of the current page with
|
|
1280
|
+
* `aria-current="page"` (a router link such as TanStack Router's `createLink`
|
|
1281
|
+
* sets it for you): the label turns bold and blue and the pill fills, so the
|
|
1282
|
+
* state never relies on colour alone. `ref` and every other prop reach the `<a>`.
|
|
1283
|
+
*/
|
|
1284
|
+
export declare function TabBarLink(tabBarLinkProps: Readonly<TabBarLinkProps>): JSX.Element;
|
|
1285
|
+
|
|
1286
|
+
export declare type TabBarLinkProps = Omit<ComponentPropsWithRef<'a'>, 'children'> & {
|
|
1287
|
+
/** UnoCSS icon class, for example `i-mdi-home`. Decorative: the label names the link. */
|
|
1288
|
+
icon: string;
|
|
1289
|
+
/** The short label. It wraps onto a second line instead of being cut off. */
|
|
1290
|
+
children: ReactNode;
|
|
1291
|
+
/** Corners of the pill behind the icon. */
|
|
1292
|
+
radius?: Radius;
|
|
1293
|
+
/** Strips colours, pill and typography, keeping the column layout and the icon size. */
|
|
1294
|
+
unstyled?: boolean;
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
export declare type TabBarProps = Omit<ComponentPropsWithRef<'nav'>, 'aria-label' | 'children'> & {
|
|
1298
|
+
/** Names the navigation landmark, for example "Main". Required: a page with another `nav` needs them told apart. */
|
|
1299
|
+
'aria-label': string;
|
|
1300
|
+
/** `TabBarLink`s. */
|
|
1301
|
+
children: ReactNode;
|
|
1302
|
+
/** Strips the surface, border and padding, keeping the equal-width column layout. */
|
|
1303
|
+
unstyled?: boolean;
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1164
1306
|
export declare interface TabItem {
|
|
1165
1307
|
title: string;
|
|
1166
1308
|
content: ReactNode;
|
|
@@ -1489,10 +1631,16 @@ export declare interface TooltipProps {
|
|
|
1489
1631
|
export declare interface UILabels {
|
|
1490
1632
|
/** Accessible name of the modal close button. */
|
|
1491
1633
|
close: string;
|
|
1634
|
+
/** Accessible name of the `BottomSheet` button that expands it to full screen. Optional: the English "Full screen" is used when omitted. */
|
|
1635
|
+
enterFullScreen?: string;
|
|
1636
|
+
/** Accessible name of the `BottomSheet` button that collapses it back. Optional: the English "Exit full screen" is used when omitted. */
|
|
1637
|
+
exitFullScreen?: string;
|
|
1492
1638
|
/** Confirm button of `ConfirmModal`. */
|
|
1493
1639
|
confirm: string;
|
|
1494
1640
|
/** Cancel button of `ConfirmModal`. */
|
|
1495
1641
|
cancel: string;
|
|
1642
|
+
/** Accessible name of the `SidePanel` collapse button. Optional: the English "Collapse panel" is used when omitted. */
|
|
1643
|
+
collapsePanel?: string;
|
|
1496
1644
|
/** Empty state of `Combobox` and `MultiCombobox`. */
|
|
1497
1645
|
noResults: string;
|
|
1498
1646
|
/** Accessible name of the button clearing a selection. */
|