@zonsh/ui 0.2.0 → 0.5.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/LICENSE +22 -0
- package/README.md +19 -13
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/ascii-field.d.ts +1 -1
- package/dist/components/ascii-field.js +2 -1
- package/dist/components/bottom-nav.d.ts +86 -0
- package/dist/components/bottom-nav.js +175 -0
- package/dist/components/breadcrumb.d.ts +9 -0
- package/dist/components/breadcrumb.js +6 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button-group.js +2 -2
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.d.ts +1 -1
- package/dist/components/calendar.js +18 -3
- package/dist/components/carousel.d.ts +22 -3
- package/dist/components/carousel.js +25 -7
- package/dist/components/chart.d.ts +20 -0
- package/dist/components/chart.js +52 -3
- package/dist/components/code-block.d.ts +20 -10
- package/dist/components/code-block.js +54 -12
- package/dist/components/collapsible.js +3 -3
- package/dist/components/color-picker.d.ts +30 -8
- package/dist/components/color-picker.js +48 -27
- package/dist/components/combobox.d.ts +21 -3
- package/dist/components/combobox.js +79 -7
- package/dist/components/command.d.ts +23 -3
- package/dist/components/command.js +63 -18
- package/dist/components/conversation.d.ts +10 -1
- package/dist/components/conversation.js +24 -7
- package/dist/components/copy-button.d.ts +15 -6
- package/dist/components/copy-button.js +27 -10
- package/dist/components/data-table.d.ts +66 -6
- package/dist/components/data-table.js +376 -23
- package/dist/components/date-picker.d.ts +73 -4
- package/dist/components/date-picker.js +138 -7
- package/dist/components/dialog.d.ts +10 -1
- package/dist/components/dialog.js +6 -3
- package/dist/components/drawer.d.ts +10 -1
- package/dist/components/drawer.js +6 -3
- package/dist/components/feature-list.js +2 -2
- package/dist/components/field.d.ts +27 -8
- package/dist/components/field.js +49 -4
- package/dist/components/file-drop.d.ts +26 -4
- package/dist/components/file-drop.js +125 -64
- package/dist/components/filter-bar.d.ts +50 -3
- package/dist/components/filter-bar.js +71 -33
- package/dist/components/form.d.ts +4 -2
- package/dist/components/form.js +24 -2
- package/dist/components/graph.d.ts +41 -0
- package/dist/components/graph.js +106 -50
- package/dist/components/illustration.js +51 -4
- package/dist/components/input-group.d.ts +18 -7
- package/dist/components/input-group.js +41 -19
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +3 -3
- package/dist/components/kbd.d.ts +17 -0
- package/dist/components/kbd.js +8 -1
- package/dist/components/layout.d.ts +2 -1
- package/dist/components/layout.js +55 -11
- package/dist/components/lightbox.d.ts +100 -0
- package/dist/components/lightbox.js +457 -0
- package/dist/components/locale.d.ts +44 -0
- package/dist/components/locale.js +37 -0
- package/dist/components/logo.js +1 -1
- package/dist/components/menu.js +3 -1
- package/dist/components/menubar.js +60 -13
- package/dist/components/message.d.ts +3 -3
- package/dist/components/message.js +12 -8
- package/dist/components/meter.js +3 -1
- package/dist/components/money-input.d.ts +80 -0
- package/dist/components/money-input.js +253 -0
- package/dist/components/navigation-menu.js +4 -2
- package/dist/components/number-field.d.ts +21 -2
- package/dist/components/number-field.js +53 -28
- package/dist/components/otp-field.d.ts +14 -1
- package/dist/components/otp-field.js +10 -2
- package/dist/components/pagination.d.ts +13 -7
- package/dist/components/pagination.js +18 -7
- package/dist/components/pdf-viewer.d.ts +67 -2
- package/dist/components/pdf-viewer.js +88 -21
- package/dist/components/phone-input.d.ts +79 -0
- package/dist/components/phone-input.js +282 -0
- package/dist/components/popover.js +1 -1
- package/dist/components/progress.js +3 -1
- package/dist/components/prompt-input.d.ts +34 -9
- package/dist/components/prompt-input.js +37 -17
- package/dist/components/radio-group.js +7 -2
- package/dist/components/rating.d.ts +73 -0
- package/dist/components/rating.js +124 -0
- package/dist/components/reasoning.d.ts +16 -1
- package/dist/components/reasoning.js +10 -7
- package/dist/components/resizable.d.ts +10 -1
- package/dist/components/resizable.js +4 -1
- package/dist/components/response.d.ts +17 -5
- package/dist/components/response.js +58 -18
- package/dist/components/scroll-area.d.ts +1 -1
- package/dist/components/select.js +14 -3
- package/dist/components/separator.js +1 -1
- package/dist/components/sidebar.d.ts +20 -4
- package/dist/components/sidebar.js +70 -35
- package/dist/components/site-header.d.ts +46 -12
- package/dist/components/site-header.js +78 -19
- package/dist/components/skeleton.d.ts +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.js +3 -1
- package/dist/components/sortable.d.ts +178 -0
- package/dist/components/sortable.js +1282 -0
- package/dist/components/sources.d.ts +17 -2
- package/dist/components/sources.js +11 -4
- package/dist/components/spinner.d.ts +13 -1
- package/dist/components/spinner.js +5 -2
- package/dist/components/stat.d.ts +91 -0
- package/dist/components/stat.js +141 -0
- package/dist/components/stepper.d.ts +71 -0
- package/dist/components/stepper.js +101 -0
- package/dist/components/switch.d.ts +2 -2
- package/dist/components/switch.js +2 -2
- package/dist/components/table.d.ts +13 -3
- package/dist/components/table.js +231 -41
- package/dist/components/tabs.js +8 -4
- package/dist/components/tags-input.d.ts +18 -2
- package/dist/components/tags-input.js +66 -34
- package/dist/components/theme.d.ts +16 -2
- package/dist/components/theme.js +34 -8
- package/dist/components/time-field.d.ts +24 -4
- package/dist/components/time-field.js +32 -9
- package/dist/components/timeline.d.ts +18 -2
- package/dist/components/timeline.js +13 -4
- package/dist/components/tippy.d.ts +48 -0
- package/dist/components/tippy.js +648 -0
- package/dist/components/toast.d.ts +18 -2
- package/dist/components/toast.js +12 -3
- package/dist/components/toggle-group.js +1 -0
- package/dist/components/tool-call.d.ts +19 -8
- package/dist/components/tool-call.js +23 -7
- package/dist/components/toolbar.d.ts +1 -1
- package/dist/components/toolbar.js +10 -2
- package/dist/components/tooltip.d.ts +4 -2
- package/dist/components/tooltip.js +10 -4
- package/dist/components/tour.d.ts +127 -0
- package/dist/components/tour.js +673 -0
- package/dist/components/tree.js +45 -9
- package/dist/components/video-player.d.ts +10 -2
- package/dist/components/video-player.js +134 -38
- package/dist/illustration.d.ts +2 -0
- package/dist/illustration.js +7 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.js +11 -3
- package/dist/lib/code-highlight.d.ts +3 -16
- package/dist/lib/code-highlight.js +160 -10
- package/dist/lib/code-theme.js +3 -3
- package/dist/lib/digit-roll.js +8 -8
- package/dist/lib/field-errors.d.ts +28 -0
- package/dist/lib/field-errors.js +24 -0
- package/dist/lib/field-value.d.ts +13 -0
- package/dist/lib/field-value.js +44 -0
- package/dist/lib/glide.d.ts +5 -4
- package/dist/lib/glide.js +5 -4
- package/dist/lib/graph-layout.js +11 -2
- package/dist/lib/money.d.ts +73 -0
- package/dist/lib/money.js +343 -0
- package/dist/lib/phone-countries.d.ts +1 -0
- package/dist/lib/phone-countries.js +281 -0
- package/dist/lib/phone.d.ts +90 -0
- package/dist/lib/phone.js +286 -0
- package/dist/lib/platform.d.ts +8 -3
- package/dist/lib/platform.js +13 -6
- package/dist/lib/row-index.d.ts +15 -0
- package/dist/lib/row-index.js +136 -0
- package/dist/lib/table-fit.d.ts +3 -2
- package/dist/lib/table-fit.js +52 -23
- package/dist/lib/theme-script.d.ts +15 -2
- package/dist/lib/theme-script.js +23 -3
- package/dist/lib/tippy/pixels.d.ts +47 -0
- package/dist/lib/tippy/pixels.js +187 -0
- package/dist/lib/tippy/sprite.d.ts +86 -0
- package/dist/lib/tippy/sprite.js +753 -0
- package/dist/messages/de.d.ts +12 -0
- package/dist/messages/de.js +326 -0
- package/dist/styles/expressive.css +60 -26
- package/dist/styles/index.css +11 -2
- package/dist/styles/material.css +47 -23
- package/dist/styles/parts/ai.css +4 -2
- package/dist/styles/parts/controls.css +85 -32
- package/dist/styles/parts/data.css +33 -5
- package/dist/styles/parts/feedback.css +110 -13
- package/dist/styles/parts/foundations.css +1 -1
- package/dist/styles/parts/navigation.css +230 -5
- package/dist/styles/parts/overlays.css +98 -11
- package/dist/styles/parts/pdf.css +13 -7
- package/dist/styles/tokens.css +28 -4
- package/dist/vite.d.ts +0 -50
- package/dist/vite.js +0 -100
- package/package.json +28 -33
- package/dist/components/code-highlight.d.ts +0 -13
- package/dist/components/code-highlight.js +0 -107
- package/dist/components/whiteboard.d.ts +0 -80
- package/dist/components/whiteboard.js +0 -389
- package/dist/styles/parts/whiteboard.css +0 -855
package/LICENSE
CHANGED
|
@@ -19,3 +19,25 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Third-party data
|
|
26
|
+
|
|
27
|
+
packages/ui/src/lib/phone-countries.ts (dist/lib/phone-countries.js in the package), the table of
|
|
28
|
+
phone numbering plans PhoneInput uses, is derived from libphonenumber's
|
|
29
|
+
resources/PhoneNumberMetadata.xml (https://github.com/google/libphonenumber):
|
|
30
|
+
|
|
31
|
+
Copyright (C) 2009 The Libphonenumber Authors
|
|
32
|
+
|
|
33
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
|
34
|
+
except in compliance with the License. You may obtain a copy of the License at
|
|
35
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
36
|
+
|
|
37
|
+
Unless required by applicable law or agreed to in writing, software distributed under the
|
|
38
|
+
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
39
|
+
express or implied. See the License for the specific language governing permissions and
|
|
40
|
+
limitations under the License.
|
|
41
|
+
|
|
42
|
+
It was changed: only calling codes, possible lengths, national prefixes, leading digits and
|
|
43
|
+
digit groups are kept, rewritten as a compact table. libphonenumber has no NOTICE file.
|
package/README.md
CHANGED
|
@@ -51,19 +51,21 @@ async rewrites() {
|
|
|
51
51
|
Components that bring a heavy library of their own have their own entry. Add the library when
|
|
52
52
|
you use one; the package lists it as an optional peer dependency.
|
|
53
53
|
|
|
54
|
-
| Import
|
|
55
|
-
|
|
|
56
|
-
| `@zonsh/ui/calendar`
|
|
57
|
-
| `@zonsh/ui/carousel`
|
|
58
|
-
| `@zonsh/ui/chart`
|
|
59
|
-
| `@zonsh/ui/
|
|
60
|
-
| `@zonsh/ui/
|
|
61
|
-
| `@zonsh/ui/
|
|
62
|
-
| `@zonsh/ui/
|
|
63
|
-
| `@zonsh/ui/
|
|
64
|
-
| `@zonsh/ui/
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
| Import | Add |
|
|
55
|
+
| ----------------------- | ------------------------------------------- |
|
|
56
|
+
| `@zonsh/ui/calendar` | `react-day-picker` |
|
|
57
|
+
| `@zonsh/ui/carousel` | `embla-carousel-react` |
|
|
58
|
+
| `@zonsh/ui/chart` | `recharts` |
|
|
59
|
+
| `@zonsh/ui/data-table` | `@tanstack/react-table` |
|
|
60
|
+
| `@zonsh/ui/date-picker` | `react-day-picker` `date-fns` |
|
|
61
|
+
| `@zonsh/ui/filter-bar` | `react-day-picker` |
|
|
62
|
+
| `@zonsh/ui/graph` | `@xyflow/react` `@dagrejs/dagre` `d3-force` |
|
|
63
|
+
| `@zonsh/ui/pdf-viewer` | `pdfjs-dist` |
|
|
64
|
+
| `@zonsh/ui/resizable` | `react-resizable-panels` |
|
|
65
|
+
|
|
66
|
+
`@zonsh/ui/illustration` has its own path too, with nothing to add: its editorial images are
|
|
67
|
+
files, which every app's build would otherwise carry. Code colours need no setup: Shiki comes
|
|
68
|
+
with the package and loads the first time a code block appears.
|
|
67
69
|
|
|
68
70
|
## Docs and agents
|
|
69
71
|
|
|
@@ -74,4 +76,8 @@ agents, the same docs come as [llms.txt](https://zon.sh/ui/llms.txt) and as an M
|
|
|
74
76
|
claude mcp add zon-ui -- npx -y @zonsh/ui-mcp
|
|
75
77
|
```
|
|
76
78
|
|
|
79
|
+
Versions: while the library is `0.x`, a minor release may break, always with a migration note in
|
|
80
|
+
the changelog, and a patch never does —
|
|
81
|
+
[the versioning policy](https://github.com/zonsh/ui/blob/main/docs/versioning.md).
|
|
82
|
+
|
|
77
83
|
MIT licensed.
|
|
@@ -35,5 +35,5 @@ export function AccordionTrigger({ index, headerProps, className, children, ...p
|
|
|
35
35
|
}
|
|
36
36
|
/** The disclosed content. Height animates from `--accordion-panel-height`. */
|
|
37
37
|
export function AccordionPanel({ inset = false, className, children, ...props }) {
|
|
38
|
-
return (_jsx(BaseAccordion.Panel, { "data-slot": "accordion-panel", className: sx("h-(--accordion-panel-height) overflow-hidden transition-[height] duration-(--duration) ease-(--ease) data-ending-style:h-0 data-starting-style:h-0", className), ...props, children: _jsx("div", { className: cn("max-w-[68ch] pe-10 pb-6 text-body text-foreground-soft", inset && "ps-11 sm:ps-14"), children: children }) }));
|
|
38
|
+
return (_jsx(BaseAccordion.Panel, { "data-slot": "accordion-panel", className: sx("h-(--accordion-panel-height) overflow-hidden transition-[height] duration-(--duration-glide) ease-(--ease-glide) data-ending-style:h-0 data-starting-style:h-0", className), ...props, children: _jsx("div", { className: cn("max-w-[68ch] pe-10 pb-6 text-body text-foreground-soft", inset && "ps-11 sm:ps-14"), children: children }) }));
|
|
39
39
|
}
|
|
@@ -52,5 +52,5 @@ export function AlertDialogFooter({ className, ...props }) {
|
|
|
52
52
|
* Compose with a button: `render={<Button variant="secondary" />}`.
|
|
53
53
|
*/
|
|
54
54
|
export function AlertDialogClose(props) {
|
|
55
|
-
return _jsx(BaseAlertDialog.Close, { "
|
|
55
|
+
return _jsx(BaseAlertDialog.Close, { ...triggerSlot("alert-dialog-close", props.render), ...props });
|
|
56
56
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ComponentProps } from "react";
|
|
2
2
|
export interface AsciiFieldProps extends Omit<ComponentProps<"div">, "children"> {
|
|
3
|
-
/** Character density, 0.5–
|
|
3
|
+
/** Character density, 0.5–1.6 (cells stop shrinking at 8px). Higher means smaller cells. Default `1` (13px Licht Mono). */
|
|
4
4
|
density?: number;
|
|
5
5
|
/** Ink strength, 0–1.5. Default `1`. Keep it low enough that the headline above stays the first read. */
|
|
6
6
|
intensity?: number;
|
|
@@ -347,7 +347,8 @@ export function AsciiField({ density = 1, intensity = 1, mask = "brackets", spre
|
|
|
347
347
|
draw(0, false);
|
|
348
348
|
}
|
|
349
349
|
function onPointerMove(e) {
|
|
350
|
-
|
|
350
|
+
// Off screen (or stopped) nothing is drawn: skip the layout read every move would cost.
|
|
351
|
+
if (!onScreen || !raf || e.pointerType === "touch" || isStill())
|
|
351
352
|
return;
|
|
352
353
|
const rect = root.getBoundingClientRect();
|
|
353
354
|
const x = e.clientX - rect.left;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export interface BottomNavMessages {
|
|
4
|
+
/** The `nav` landmark's name, when the bar has no `aria-label`. */
|
|
5
|
+
nav: string;
|
|
6
|
+
/** A badge count, read after the item's label: "3 new". */
|
|
7
|
+
count: (count: number) => string;
|
|
8
|
+
/** A badge dot, read after the item's label. */
|
|
9
|
+
dot: string;
|
|
10
|
+
}
|
|
11
|
+
declare module "./locale" {
|
|
12
|
+
interface Messages {
|
|
13
|
+
bottomNav: BottomNavMessages;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** At and above this width the bar is hidden: `sm` 40rem, `md` 48rem, `lg` 64rem. */
|
|
17
|
+
export type BottomNavBreakpoint = "sm" | "md" | "lg";
|
|
18
|
+
export interface BottomNavProps extends Omit<React.ComponentProps<"nav">, "defaultValue" | "onChange"> {
|
|
19
|
+
/** The current destination's `value`, for app state. Router-driven pages set `current` per item instead. */
|
|
20
|
+
value?: string;
|
|
21
|
+
/** The destination current at first, when uncontrolled. */
|
|
22
|
+
defaultValue?: string;
|
|
23
|
+
/** Called with an item's `value` when it is chosen. */
|
|
24
|
+
onValueChange?: (value: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* `fixed` (default): pinned to the bottom of the viewport, and the page reserves its height
|
|
27
|
+
* through `--bottom-nav-h`. `absolute`: pinned to the bottom of its positioned parent — a
|
|
28
|
+
* phone-sized preview, an embedded screen.
|
|
29
|
+
*/
|
|
30
|
+
position?: "fixed" | "absolute";
|
|
31
|
+
/**
|
|
32
|
+
* Hidden at and above this width, where a sidebar or a header takes over. Defaults to `md`
|
|
33
|
+
* (48rem) when fixed and to `false` — always shown — when absolute.
|
|
34
|
+
*/
|
|
35
|
+
breakpoint?: BottomNavBreakpoint | false;
|
|
36
|
+
/**
|
|
37
|
+
* Slides the bar away while the page scrolls down and back as soon as it scrolls up, reaches
|
|
38
|
+
* the top, or a key moves focus into it. Fixed bars follow the window; absolute ones the
|
|
39
|
+
* scrolling inside their positioned parent.
|
|
40
|
+
*/
|
|
41
|
+
hideOnScroll?: boolean;
|
|
42
|
+
/** Replaces the bar's interface text (the landmark's name, the words read for a badge). */
|
|
43
|
+
labels?: Partial<BottomNavMessages>;
|
|
44
|
+
ref?: React.Ref<HTMLElement>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* BottomNav — the bar of destinations at the bottom of a phone screen: 3–5 items, each an icon
|
|
48
|
+
* over a short Licht Sans label, on the page ground behind a hairline. The current item is in the
|
|
49
|
+
* foreground ink on a raised 12px tile that glides to the next one; the others rest muted. It
|
|
50
|
+
* clears the home indicator (`env(safe-area-inset-bottom)`), and while it is shown the page
|
|
51
|
+
* reserves its height as `--bottom-nav-h` — put `pb-(--bottom-nav-h)` on the content's container.
|
|
52
|
+
* Hidden from `md` up by default, where a `Sidebar` or `SiteHeader` takes over.
|
|
53
|
+
*
|
|
54
|
+
* Use it for the top-level places of an app on a phone, the ones people switch between all day.
|
|
55
|
+
* The rule people break: putting actions (Compose, Log out) or more than five destinations in
|
|
56
|
+
* it — an action is a `Button`, and a sixth place belongs in a sidebar sheet or an account menu.
|
|
57
|
+
*/
|
|
58
|
+
export declare function BottomNav({ value: valueProp, defaultValue, onValueChange, position, breakpoint, hideOnScroll, labels, className, children, ref, onFocus, ...props }: BottomNavProps): React.JSX.Element;
|
|
59
|
+
export interface BottomNavItemProps extends Omit<useRender.ComponentProps<"a">, "children"> {
|
|
60
|
+
/** A 20px lucide icon over the label. */
|
|
61
|
+
icon: React.ReactNode;
|
|
62
|
+
/** One short word ("Home", "Search", "Orders"). Always shown: the bar is never icon-only. */
|
|
63
|
+
label: React.ReactNode;
|
|
64
|
+
/** The item's value, for `BottomNav value`. Choosing the item reports it to `onValueChange`. */
|
|
65
|
+
value?: string;
|
|
66
|
+
/**
|
|
67
|
+
* The current page, for router-driven bars. Sets `aria-current="page"` and the raised tile.
|
|
68
|
+
* Wins over the bar's `value`.
|
|
69
|
+
*/
|
|
70
|
+
current?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* A count on the icon (`3`, shown as "99+" above 99, nothing at 0) or `true` for a dot. Read
|
|
73
|
+
* after the label in words: "Inbox, 3 new".
|
|
74
|
+
*/
|
|
75
|
+
badge?: number | boolean;
|
|
76
|
+
/** What a screen reader hears for the badge, instead of "3 new" / "New": "3 in your basket". */
|
|
77
|
+
badgeLabel?: string;
|
|
78
|
+
/** Dimmed, and does nothing when chosen. It stays focusable, so it is still found and read. */
|
|
79
|
+
disabled?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* BottomNavItem — one destination: an icon over a label, at least 44px to touch (the whole cell
|
|
83
|
+
* of the bar). Renders an `<a>` with `href`, `render={<Link to="…" />}` for a router link, or a
|
|
84
|
+
* `<button>` for app state with neither. Never icon-only, and never an action.
|
|
85
|
+
*/
|
|
86
|
+
export declare function BottomNavItem({ icon, label, value, current: currentProp, badge, badgeLabel, disabled, render, ref, className, onClick, ...props }: BottomNavItemProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { glideMotion, glideStyle, useGlide, useMergedRef } from "../lib/glide.js";
|
|
7
|
+
import { Badge, BadgeAnchor } from "./badge.js";
|
|
8
|
+
import { useMessages } from "./locale.js";
|
|
9
|
+
const defaultMessages = {
|
|
10
|
+
nav: "Main",
|
|
11
|
+
count: (count) => `${count} new`,
|
|
12
|
+
dot: "New",
|
|
13
|
+
};
|
|
14
|
+
const BottomNavContext = React.createContext({
|
|
15
|
+
value: undefined,
|
|
16
|
+
select: () => { },
|
|
17
|
+
});
|
|
18
|
+
const hiddenFrom = {
|
|
19
|
+
sm: "sm:hidden",
|
|
20
|
+
md: "md:hidden",
|
|
21
|
+
lg: "lg:hidden",
|
|
22
|
+
};
|
|
23
|
+
const ITEM = '[data-slot="bottom-nav-item"]';
|
|
24
|
+
const TILE = '[data-slot="bottom-nav-item-tile"]';
|
|
25
|
+
const findCurrent = (row) => row.querySelector(`${ITEM}[aria-current="page"] > ${TILE}`);
|
|
26
|
+
/** How far the page scrolls down before the bar goes, and up before it comes back (px). */
|
|
27
|
+
const HIDE_AFTER = 24;
|
|
28
|
+
const SHOW_AFTER = 8;
|
|
29
|
+
/**
|
|
30
|
+
* Hides the bar while its scroller moves down and shows it again on the way up. Vertical moves
|
|
31
|
+
* only: a carousel scrolling sideways leaves it be.
|
|
32
|
+
*/
|
|
33
|
+
function useHideOnScroll(nav, enabled, contained) {
|
|
34
|
+
const [hidden, setHidden] = React.useState(false);
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
const el = nav.current;
|
|
37
|
+
if (!enabled || !el) {
|
|
38
|
+
setHidden(false);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const scope = contained ? el.parentElement : window;
|
|
42
|
+
if (!scope)
|
|
43
|
+
return;
|
|
44
|
+
const last = new WeakMap();
|
|
45
|
+
const start = document.scrollingElement?.scrollTop ?? 0;
|
|
46
|
+
let travelled = 0;
|
|
47
|
+
const onScroll = (event) => {
|
|
48
|
+
const target = event.target;
|
|
49
|
+
// A fixed bar follows the page; an absolute one any scroller inside its parent but itself.
|
|
50
|
+
const scroller = target === document || target === window
|
|
51
|
+
? document.scrollingElement
|
|
52
|
+
: target instanceof HTMLElement && !el.contains(target)
|
|
53
|
+
? target
|
|
54
|
+
: null;
|
|
55
|
+
if (!scroller || (!contained && scroller !== document.scrollingElement))
|
|
56
|
+
return;
|
|
57
|
+
// Clamped to the scroll range, so a rubber-band bounce past either end is no move at all:
|
|
58
|
+
// springing back from the bottom would otherwise read as scrolling up.
|
|
59
|
+
const y = Math.min(Math.max(scroller.scrollTop, 0), scroller.scrollHeight - scroller.clientHeight);
|
|
60
|
+
// A scroller seen for the first time moved from where it was when the bar mounted: the
|
|
61
|
+
// page's position then, or the top for one inside a preview.
|
|
62
|
+
const before = last.get(scroller) ?? (scroller === document.scrollingElement ? start : 0);
|
|
63
|
+
last.set(scroller, y);
|
|
64
|
+
const delta = y - before;
|
|
65
|
+
if (delta === 0)
|
|
66
|
+
return;
|
|
67
|
+
// At the top the bar is always there. At the end it stays away: the page reserves its
|
|
68
|
+
// space, so nothing is under it, and a swipe that reaches the end would otherwise bring it
|
|
69
|
+
// straight back.
|
|
70
|
+
if (y <= 0) {
|
|
71
|
+
travelled = 0;
|
|
72
|
+
setHidden(false);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
travelled = delta > 0 ? Math.max(0, travelled) + delta : Math.min(0, travelled) + delta;
|
|
76
|
+
if (travelled > HIDE_AFTER && y > el.offsetHeight)
|
|
77
|
+
setHidden(true);
|
|
78
|
+
else if (travelled < -SHOW_AFTER)
|
|
79
|
+
setHidden(false);
|
|
80
|
+
};
|
|
81
|
+
scope.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
82
|
+
return () => scope.removeEventListener("scroll", onScroll, { capture: true });
|
|
83
|
+
}, [nav, enabled, contained]);
|
|
84
|
+
return [hidden, setHidden];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* BottomNav — the bar of destinations at the bottom of a phone screen: 3–5 items, each an icon
|
|
88
|
+
* over a short Licht Sans label, on the page ground behind a hairline. The current item is in the
|
|
89
|
+
* foreground ink on a raised 12px tile that glides to the next one; the others rest muted. It
|
|
90
|
+
* clears the home indicator (`env(safe-area-inset-bottom)`), and while it is shown the page
|
|
91
|
+
* reserves its height as `--bottom-nav-h` — put `pb-(--bottom-nav-h)` on the content's container.
|
|
92
|
+
* Hidden from `md` up by default, where a `Sidebar` or `SiteHeader` takes over.
|
|
93
|
+
*
|
|
94
|
+
* Use it for the top-level places of an app on a phone, the ones people switch between all day.
|
|
95
|
+
* The rule people break: putting actions (Compose, Log out) or more than five destinations in
|
|
96
|
+
* it — an action is a `Button`, and a sixth place belongs in a sidebar sheet or an account menu.
|
|
97
|
+
*/
|
|
98
|
+
export function BottomNav({ value: valueProp, defaultValue, onValueChange, position = "fixed", breakpoint = position === "fixed" ? "md" : false, hideOnScroll = false, labels, className, children, ref, onFocus, ...props }) {
|
|
99
|
+
const text = useMessages("bottomNav", defaultMessages, labels);
|
|
100
|
+
const [navRef, setNavRef] = useMergedRef(ref);
|
|
101
|
+
const rowRef = React.useRef(null);
|
|
102
|
+
const [own, setOwn] = React.useState(defaultValue);
|
|
103
|
+
const value = valueProp ?? own;
|
|
104
|
+
const contained = position === "absolute";
|
|
105
|
+
const [hidden, setHidden] = useHideOnScroll(navRef, hideOnScroll, contained);
|
|
106
|
+
const glide = useGlide(rowRef, findCurrent, { attributes: ["aria-current"], items: ITEM });
|
|
107
|
+
const context = React.useMemo(() => ({
|
|
108
|
+
value,
|
|
109
|
+
select: (next) => {
|
|
110
|
+
if (valueProp === undefined)
|
|
111
|
+
setOwn(next);
|
|
112
|
+
onValueChange?.(next);
|
|
113
|
+
},
|
|
114
|
+
text,
|
|
115
|
+
}), [value, valueProp, onValueChange, text]);
|
|
116
|
+
return (_jsx(BottomNavContext.Provider, { value: context, children: _jsxs("nav", { ref: setNavRef, "aria-label": text.nav, "data-slot": "bottom-nav", "data-position": position, "data-breakpoint": breakpoint || undefined, "data-hidden": hidden ? "" : undefined, "data-indicator": glide.visible ? "" : undefined, onFocus: (event) => {
|
|
117
|
+
onFocus?.(event);
|
|
118
|
+
// Tabbing into a bar that slid away brings it back.
|
|
119
|
+
setHidden(false);
|
|
120
|
+
}, className: cn("group/bottom-nav inset-x-0 bottom-0 isolate z-40 border-t border-border/60", contained ? "absolute" : "fixed",
|
|
121
|
+
// Clear of the home indicator, and of the notch on a phone on its side (viewport-fit=cover).
|
|
122
|
+
"pr-[env(safe-area-inset-right,0px)] pb-[env(safe-area-inset-bottom,0px)] pl-[env(safe-area-inset-left,0px)]",
|
|
123
|
+
// Leaving eases in, coming back eases out: 300ms either way, instant under reduced motion.
|
|
124
|
+
"transition-[translate] duration-[calc(var(--duration)*2)] ease-(--ease-glide)", "data-hidden:translate-y-full data-hidden:ease-[cubic-bezier(0.32,0,0.67,0)]", breakpoint && hiddenFrom[breakpoint], className), ...props, children: [_jsx("span", { "aria-hidden": true, "data-slot": "bottom-nav-ground" }), _jsxs("div", { ref: rowRef, "data-slot": "bottom-nav-list", className: "relative mx-auto flex h-(--bottom-nav-bar) w-full max-w-lg items-stretch px-1", children: [_jsx("span", { "aria-hidden": true, "data-slot": "bottom-nav-indicator", "data-visible": glide.visible ? "" : undefined, "data-instant": glide.instant ? "" : undefined, className: cn(
|
|
125
|
+
// The glide crosses the bar at the one speed of every gliding indicator.
|
|
126
|
+
glideMotion, "rounded-button border border-transparent bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-raised"), style: glideStyle(glide) }), children] })] }) }));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* BottomNavItem — one destination: an icon over a label, at least 44px to touch (the whole cell
|
|
130
|
+
* of the bar). Renders an `<a>` with `href`, `render={<Link to="…" />}` for a router link, or a
|
|
131
|
+
* `<button>` for app state with neither. Never icon-only, and never an action.
|
|
132
|
+
*/
|
|
133
|
+
export function BottomNavItem({ icon, label, value, current: currentProp, badge, badgeLabel, disabled = false, render, ref, className, onClick, ...props }) {
|
|
134
|
+
const nav = React.useContext(BottomNavContext);
|
|
135
|
+
const own = useMessages("bottomNav", defaultMessages);
|
|
136
|
+
const text = nav.text ?? own;
|
|
137
|
+
const current = currentProp ?? (value !== undefined && nav.value === value);
|
|
138
|
+
const link = render !== undefined || props.href !== undefined;
|
|
139
|
+
const count = typeof badge === "number" && badge > 0 ? badge : undefined;
|
|
140
|
+
const dot = badge === true;
|
|
141
|
+
// Only what is drawn is read: a `badgeLabel` with a count of 0 says nothing.
|
|
142
|
+
const announced = count !== undefined ? (badgeLabel ?? text.count(count)) : dot ? (badgeLabel ?? text.dot) : undefined;
|
|
143
|
+
// The badge is read after the label: "Inbox, 3 new". A text label makes that the item's name
|
|
144
|
+
// exactly; any other label carries the words in hidden text after it.
|
|
145
|
+
const named = announced !== undefined && (typeof label === "string" || typeof label === "number");
|
|
146
|
+
return useRender({
|
|
147
|
+
defaultTagName: link ? "a" : "button",
|
|
148
|
+
render,
|
|
149
|
+
ref,
|
|
150
|
+
props: {
|
|
151
|
+
"data-slot": "bottom-nav-item",
|
|
152
|
+
"aria-current": current ? "page" : undefined,
|
|
153
|
+
"aria-disabled": disabled || undefined,
|
|
154
|
+
"aria-label": named ? `${label}, ${announced}` : undefined,
|
|
155
|
+
...(link ? {} : { type: "button" }),
|
|
156
|
+
...props,
|
|
157
|
+
onClick: (event) => {
|
|
158
|
+
if (disabled) {
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
onClick?.(event);
|
|
163
|
+
if (!event.defaultPrevented && value !== undefined)
|
|
164
|
+
nav.select(value);
|
|
165
|
+
},
|
|
166
|
+
className: cn("group/bottom-nav-item relative flex min-w-0 flex-1 basis-0 cursor-pointer items-center justify-center no-underline outline-none select-none [-webkit-tap-highlight-color:transparent]", "aria-disabled:pointer-events-none aria-disabled:opacity-50", className),
|
|
167
|
+
children: (_jsxs("span", { "data-slot": "bottom-nav-item-tile", className: cn(
|
|
168
|
+
// The label comes first in the source and the icon is drawn above it: what is seen reads
|
|
169
|
+
// "Inbox 3", the start of the name "Inbox, 3 new" (WCAG 2.5.3).
|
|
170
|
+
"relative flex min-h-(--control-h-lg) max-w-full min-w-16 flex-col-reverse items-center justify-center gap-1 rounded-button border border-transparent px-1",
|
|
171
|
+
// Muted at rest, the full ink when hovered or current (styles in parts/navigation.css).
|
|
172
|
+
"group-focus-visible/bottom-nav-item:outline-2 group-focus-visible/bottom-nav-item:outline-offset-0 group-focus-visible/bottom-nav-item:outline-control-focus group-focus-visible/bottom-nav-item:outline-solid", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-5"), children: [_jsxs("span", { "data-slot": "bottom-nav-item-label", className: "max-w-full truncate font-body text-xs leading-[14px] font-medium", children: [label, announced && !named && _jsxs("span", { className: "sr-only", children: [", ", announced] })] }), count !== undefined && " ", _jsx("span", { "aria-hidden": true, "data-slot": "bottom-nav-item-icon", className: "inline-flex", children: count !== undefined || dot ? (_jsxs(BadgeAnchor, { shape: "rect", children: [icon, _jsx(Badge, { size: "sm", count: count, dot: dot })] })) : (icon) })] })),
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
export interface BreadcrumbMessages {
|
|
3
|
+
/** The name of the trail's `nav` landmark. */
|
|
4
|
+
nav: string;
|
|
5
|
+
}
|
|
6
|
+
declare module "./locale" {
|
|
7
|
+
interface Messages {
|
|
8
|
+
breadcrumb: BreadcrumbMessages;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
2
11
|
export interface BreadcrumbItem {
|
|
3
12
|
label: React.ReactNode;
|
|
4
13
|
/** Omit on the current page. */
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { useMessages } from "./locale.js";
|
|
6
|
+
const defaultMessages = { nav: "Breadcrumb" };
|
|
5
7
|
/**
|
|
6
8
|
* Breadcrumb — where this page sits, as a mono trail: `Shop / Outerwear / Waxed cotton jacket`.
|
|
7
9
|
*
|
|
@@ -10,7 +12,8 @@ import { cn } from "../lib/cn.js";
|
|
|
10
12
|
* one level deep, a breadcrumb only repeats the header.
|
|
11
13
|
*/
|
|
12
14
|
export function Breadcrumb({ items, separator = "/", className, ...props }) {
|
|
13
|
-
|
|
15
|
+
const text = useMessages("breadcrumb", defaultMessages);
|
|
16
|
+
return (_jsx("nav", { "aria-label": text.nav, "data-slot": "breadcrumb", className: cn("min-w-0", className), ...props, children: _jsx("ol", { className: "m-0 flex list-none flex-wrap items-center gap-x-2 gap-y-3 p-0 font-mono text-[12px] leading-none [overflow-wrap:anywhere] text-muted-foreground", children: items.map((item, i) => {
|
|
14
17
|
const current = i === items.length - 1;
|
|
15
18
|
const linkClass = "text-muted-foreground no-underline transition-colors duration-(--duration) ease-(--ease) hover:text-foreground focus-ring";
|
|
16
19
|
let content;
|
|
@@ -19,6 +22,8 @@ export function Breadcrumb({ items, separator = "/", className, ...props }) {
|
|
|
19
22
|
}
|
|
20
23
|
else if (item.render) {
|
|
21
24
|
content = React.cloneElement(item.render, {
|
|
25
|
+
// The element's own slot wins: a Button rendered here keeps its material.
|
|
26
|
+
"data-slot": item.render.props["data-slot"] ?? "breadcrumb-link",
|
|
22
27
|
href: item.href,
|
|
23
28
|
className: cn(linkClass, item.render.props.className),
|
|
24
29
|
children: item.label,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
2
|
declare const orientations: {
|
|
3
|
-
readonly horizontal: readonly ["flex-row", "[&>*:not(:nth-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-
|
|
3
|
+
readonly horizontal: readonly ["flex-row", "[&>*:not(:nth-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-s-none", "[&>*:not(:nth-last-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-e-none"];
|
|
4
4
|
readonly vertical: readonly ["flex-col", "[&>*:not(:nth-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-t-none", "[&>*:not(:nth-last-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-b-none"];
|
|
5
5
|
};
|
|
6
6
|
export interface ButtonGroupProps extends React.ComponentProps<"div"> {
|
|
@@ -13,8 +13,8 @@ const orientations = {
|
|
|
13
13
|
horizontal: [
|
|
14
14
|
"flex-row",
|
|
15
15
|
// Inner corners collapse; the outer corners keep each control's own radius.
|
|
16
|
-
"[&>*:not(:nth-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-
|
|
17
|
-
"[&>*:not(:nth-last-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-
|
|
16
|
+
"[&>*:not(:nth-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-s-none",
|
|
17
|
+
"[&>*:not(:nth-last-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-e-none",
|
|
18
18
|
],
|
|
19
19
|
vertical: [
|
|
20
20
|
"flex-col",
|
|
@@ -122,7 +122,7 @@ export function Button({ variant = "primary", size = "default", collapsible = fa
|
|
|
122
122
|
folds && [
|
|
123
123
|
"gap-0 data-collapse-instant:transition-none!",
|
|
124
124
|
// The fold's padding and corners; an expandable button waits out its hover intent first.
|
|
125
|
-
"[--material-motion:
|
|
125
|
+
"[--material-motion:padding_var(--expand-time,calc(var(--duration)*2))_var(--ease)_var(--expand-delay,0s),border-radius_var(--expand-time,calc(var(--duration)*2))_var(--ease)_var(--expand-delay,0s)]",
|
|
126
126
|
collapsibleGaps[size],
|
|
127
127
|
],
|
|
128
128
|
variants[variant],
|
|
@@ -23,4 +23,4 @@ export type CalendarProps = React.ComponentProps<typeof DayPicker> & {
|
|
|
23
23
|
* The rule people break: using a calendar to enter a date of birth — type it in an `Input`,
|
|
24
24
|
* or at least use `captionLayout="dropdown"` so nobody clicks back forty years.
|
|
25
25
|
*/
|
|
26
|
-
export declare function Calendar({ showOutsideDays, className, classNames, components, dropdown, dir, formatters, ...props }: CalendarProps): React.JSX.Element;
|
|
26
|
+
export declare function Calendar({ showOutsideDays, className, classNames, components, dropdown, dir, formatters, labels, ...props }: CalendarProps): React.JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { useDirection } from "@base-ui/react/direction-provider";
|
|
|
4
4
|
import { Field as BaseField } from "@base-ui/react/field";
|
|
5
5
|
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon } from "lucide-react";
|
|
6
6
|
import * as React from "react";
|
|
7
|
-
import { DateLib, DayPicker, getDefaultClassNames, } from "react-day-picker";
|
|
7
|
+
import { DateLib, DayPicker, getDefaultClassNames, labelDayButton, } from "react-day-picker";
|
|
8
8
|
import { cn } from "../lib/cn.js";
|
|
9
9
|
import { NativeSelect } from "./native-select.js";
|
|
10
10
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
|
|
@@ -126,6 +126,20 @@ function CalendarSelectDropdown({ options = [], value, onChange, disabled, class
|
|
|
126
126
|
onChange?.({ target: { value: next } });
|
|
127
127
|
}, children: [_jsx(SelectTrigger, { size: "sm", "aria-label": ariaLabel, className: cn("w-auto min-w-0 tabular-nums", className), children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { positioner: { alignItemWithTrigger: true }, children: options.map((option) => (_jsx(SelectItem, { value: String(option.value), disabled: option.disabled, className: "tabular-nums", children: option.label }, option.value))) })] }) }));
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* A day's name with its number as the grid draws it — "Friday, October 16, 2026", not "16th" — so
|
|
131
|
+
* the "16" on the button is part of what it is called, for voice control (WCAG 2.5.3). Wraps the
|
|
132
|
+
* locale's own label, translated "Today" and "selected" included.
|
|
133
|
+
*/
|
|
134
|
+
function plainDayNumber(locale) {
|
|
135
|
+
const own = locale?.labels?.labelDayButton;
|
|
136
|
+
const label = typeof own === "function" ? own : typeof own === "string" ? () => own : labelDayButton;
|
|
137
|
+
return (date, modifiers, options, dateLib) => {
|
|
138
|
+
const text = label(date, modifiers, options, dateLib);
|
|
139
|
+
const day = String(date.getDate());
|
|
140
|
+
return text.replace(new RegExp(`\\b${day}(?:st|nd|rd|th)\\b`), day);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
129
143
|
/**
|
|
130
144
|
* Calendar — react-day-picker v10 in the zon material. The month caption is set in Licht,
|
|
131
145
|
* weekdays are 11px mono eyebrows and days are 38px cells with 7px corners and Licht Sans tabular
|
|
@@ -140,8 +154,9 @@ function CalendarSelectDropdown({ options = [], value, onChange, disabled, class
|
|
|
140
154
|
* The rule people break: using a calendar to enter a date of birth — type it in an `Input`,
|
|
141
155
|
* or at least use `captionLayout="dropdown"` so nobody clicks back forty years.
|
|
142
156
|
*/
|
|
143
|
-
export function Calendar({ showOutsideDays = true, className, classNames, components, dropdown = "native", dir, formatters, ...props }) {
|
|
157
|
+
export function Calendar({ showOutsideDays = true, className, classNames, components, dropdown = "native", dir, formatters, labels, ...props }) {
|
|
144
158
|
const direction = useDirection();
|
|
159
|
+
const dayLabel = React.useMemo(() => plainDayNumber(props.locale), [props.locale]);
|
|
145
160
|
/*
|
|
146
161
|
* Weekday names too wide for their column — Arabic's short names are whole words — give way to
|
|
147
162
|
* the narrow ones, per locale. Measured before the first paint; your own weekday formatter is
|
|
@@ -152,7 +167,7 @@ export function Calendar({ showOutsideDays = true, className, classNames, compon
|
|
|
152
167
|
const ownFormatter = !!formatters?.formatWeekdayName;
|
|
153
168
|
const tooWide = React.useCallback(() => setNarrowFor(localeCode), [localeCode]);
|
|
154
169
|
const narrow = narrowFor === localeCode && !ownFormatter;
|
|
155
|
-
return (_jsx(WeekdayTooWideContext.Provider, { value: ownFormatter ? null : tooWide, children: _jsx(DayPicker, { navLayout: "around", dir: dir ?? (direction === "rtl" ? "rtl" : undefined), showOutsideDays: showOutsideDays, className: cn(rootClassName, classNames?.root, className), classNames: mergeClassNames(classNames), formatters: narrow ? { ...formatters, formatWeekdayName: formatNarrowWeekday } : formatters, components: {
|
|
170
|
+
return (_jsx(WeekdayTooWideContext.Provider, { value: ownFormatter ? null : tooWide, children: _jsx(DayPicker, { navLayout: "around", dir: dir ?? (direction === "rtl" ? "rtl" : undefined), showOutsideDays: showOutsideDays, className: cn(rootClassName, classNames?.root, className), classNames: mergeClassNames(classNames), formatters: narrow ? { ...formatters, formatWeekdayName: formatNarrowWeekday } : formatters, labels: { ...labels, labelDayButton: labels?.labelDayButton ?? dayLabel }, components: {
|
|
156
171
|
Root: CalendarRoot,
|
|
157
172
|
Chevron: CalendarChevron,
|
|
158
173
|
Day: CalendarDay,
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import useEmblaCarousel, { type UseEmblaCarouselType } from "embla-carousel-react";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { type ButtonProps } from "./button.js";
|
|
4
|
+
export interface CarouselMessages {
|
|
5
|
+
/** What screen readers call the carousel region. */
|
|
6
|
+
carousel: string;
|
|
7
|
+
/** What screen readers call each slide. */
|
|
8
|
+
slide: string;
|
|
9
|
+
previous: string;
|
|
10
|
+
next: string;
|
|
11
|
+
/** Each tick of `CarouselDots`, by its 1-based slide number. */
|
|
12
|
+
goTo: (slide: number, total: number) => string;
|
|
13
|
+
/** Read between the numbers of the "01 / 07" index: "1 of 7". */
|
|
14
|
+
of: string;
|
|
15
|
+
}
|
|
16
|
+
declare module "./locale" {
|
|
17
|
+
interface Messages {
|
|
18
|
+
carousel: CarouselMessages;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
4
21
|
/** The Embla instance, for `setApi` and `useCarousel().api`. */
|
|
5
22
|
export type CarouselApi = UseEmblaCarouselType[1];
|
|
6
23
|
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
@@ -41,6 +58,8 @@ export interface CarouselProps extends React.ComponentProps<"div"> {
|
|
|
41
58
|
setApi?: (api: CarouselApi) => void;
|
|
42
59
|
/** Accessible name of the carousel region, e.g. "Spec sheets". */
|
|
43
60
|
"aria-label"?: string;
|
|
61
|
+
/** The words its parts read out; a LocaleProvider sets them for every Carousel. */
|
|
62
|
+
labels?: Partial<CarouselMessages>;
|
|
44
63
|
}
|
|
45
64
|
/**
|
|
46
65
|
* Carousel — a row of slides moved one at a time: a wall of spec sheets, a series of
|
|
@@ -54,7 +73,7 @@ export interface CarouselProps extends React.ComponentProps<"div"> {
|
|
|
54
73
|
* The rule people break: hiding content people need inside it. A carousel shows one thing at a
|
|
55
74
|
* time; anything that must be compared or read in full belongs on the page as a grid or list.
|
|
56
75
|
*/
|
|
57
|
-
export declare function Carousel({ orientation, opts, plugins, setApi, className, children, onKeyDownCapture, ...props }: CarouselProps): React.JSX.Element;
|
|
76
|
+
export declare function Carousel({ orientation, opts, plugins, setApi, className, children, onKeyDownCapture, labels, ...props }: CarouselProps): React.JSX.Element;
|
|
58
77
|
export interface CarouselContentProps extends React.ComponentProps<"div"> {
|
|
59
78
|
/** Class for the clipping viewport (set a height here for a vertical carousel). */
|
|
60
79
|
viewportClassName?: string;
|
|
@@ -78,7 +97,7 @@ export interface CarouselDotsProps extends React.ComponentProps<"div"> {
|
|
|
78
97
|
* foreground ink, and every tick is a button. `index` — a mono "01 / 07" counter.
|
|
79
98
|
*/
|
|
80
99
|
variant?: "ticks" | "index";
|
|
81
|
-
/** Accessible name for the tick buttons; receives the 1-based slide number. */
|
|
100
|
+
/** Accessible name for the tick buttons; receives the 1-based slide number. Default: `labels.goTo`. */
|
|
82
101
|
getLabel?: (slide: number, total: number) => string;
|
|
83
102
|
}
|
|
84
103
|
/**
|
|
@@ -86,5 +105,5 @@ export interface CarouselDotsProps extends React.ComponentProps<"div"> {
|
|
|
86
105
|
* slide) or a mono "01 / 07" index. Never round dots. The long tick moves with the slides, so a
|
|
87
106
|
* drag or a glide hands it from one tick to the next rather than switching it at the start.
|
|
88
107
|
*/
|
|
89
|
-
export declare function CarouselDots({ variant, getLabel, className, ...props }: CarouselDotsProps): React.JSX.Element;
|
|
108
|
+
export declare function CarouselDots({ variant, getLabel: getLabelProp, className, ...props }: CarouselDotsProps): React.JSX.Element;
|
|
90
109
|
export {};
|