@codefast/ui 0.9.3 → 0.10.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/CHANGELOG.md +86 -0
- package/README.md +4 -1
- package/dist/components/avatar.js +1 -1
- package/dist/components/breadcrumb.js +2 -2
- package/dist/components/carousel.js +14 -23
- package/dist/components/command.d.ts +7 -1
- package/dist/components/command.js +2 -2
- package/dist/components/dialog.d.ts +14 -2
- package/dist/components/dialog.js +4 -4
- package/dist/components/input-number.d.ts +1 -1
- package/dist/components/input-number.js +2 -2
- package/dist/components/input-password.d.ts +15 -2
- package/dist/components/input-password.js +2 -2
- package/dist/components/input-search.d.ts +7 -1
- package/dist/components/input-search.js +2 -2
- package/dist/components/pagination.js +1 -1
- package/dist/components/progress.d.ts +6 -1
- package/dist/components/progress.js +11 -3
- package/dist/components/select.js +2 -2
- package/dist/components/sheet.d.ts +7 -1
- package/dist/components/sheet.js +2 -2
- package/dist/components/sidebar.d.ts +14 -2
- package/dist/components/sidebar.js +59 -25
- package/dist/hooks/use-media-query.d.ts +3 -3
- package/dist/hooks/use-media-query.js +15 -32
- package/dist/primitives/input-number.d.ts +5 -5
- package/dist/primitives/input-number.js +4 -4
- package/package.json +5 -5
- package/src/css/foundation/source.css +6 -2
- package/src/css/foundation/variants.css +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,91 @@
|
|
|
1
1
|
# @codefast/ui
|
|
2
2
|
|
|
3
|
+
## 0.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1027](https://github.com/codefastlabs/codefast/pull/1027) `Avatar` draws its edge in a translucent `foreground/10` instead of blending `--border` over the image with
|
|
8
|
+
`mix-blend-mode`. In Chromium, a page with a few hundred blended avatars inside a sideways scroller left stretches of
|
|
9
|
+
the scroller unpainted, and they stayed blank after scrolling stopped. Dark mode looks the same, since `lighten` with a
|
|
10
|
+
translucent white composites like a plain overlay. In light mode the edge over white stays within a shade of `--border`,
|
|
11
|
+
and over a darker photo it now darkens the rim slightly where `darken` left it unchanged.
|
|
12
|
+
|
|
13
|
+
- [#1026](https://github.com/codefastlabs/codefast/pull/1026) `SelectContent` insets its list by 4px whether or not the items sit in a `SelectGroup`. The inset lived on the group, so
|
|
14
|
+
items placed straight in `SelectContent` touched the popup's edge and an item-aligned popup opened 4px right of its
|
|
15
|
+
trigger. The viewport now carries the inset and keeps it when the keyboard scrolls an item into view. A group adds 8px
|
|
16
|
+
only after another group, and a `SelectSeparator` between groups keeps 4px on either side, as in the other menus.
|
|
17
|
+
|
|
18
|
+
## 0.10.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [#976](https://github.com/codefastlabs/codefast/pull/976) `engines.node` is now `>=24.0.0`, up from `>=22.12.0`, and Node 22 is no longer supported. Node 24.0.0 is the first
|
|
23
|
+
release with explicit resource management built in (`using`, `await using`, `DisposableStack`, `AsyncDisposableStack`,
|
|
24
|
+
`SuppressedError`) and all of ES2025, so the packages use both as the platform ships them instead of shimming them for
|
|
25
|
+
an older line, and the CI matrix runs the unit suite on 24.0.0 itself. Move to Node 24, or stay on the current minor
|
|
26
|
+
while a deployment still runs Node 22.
|
|
27
|
+
|
|
28
|
+
- [#983](https://github.com/codefastlabs/codefast/pull/983) Every string a component renders on an element the app cannot reach through props now comes from a prop that defaults to
|
|
29
|
+
the English text, so a UI in another language can name those controls: `InputPassword` takes `revealLabel` and
|
|
30
|
+
`concealLabel`; `InputSearch` takes `clearLabel`; `DialogContent`, `DialogFooter`, `SheetContent` and `CommandDialog`
|
|
31
|
+
take `closeLabel`; and `Sidebar` takes `mobileTitle` for its mobile sheet, which drops its filler description.
|
|
32
|
+
`PaginationEllipsis` and `BreadcrumbEllipsis` drop screen-reader text that their `aria-hidden` wrapper kept from ever
|
|
33
|
+
being read.
|
|
34
|
+
|
|
35
|
+
**Breaking:** `InputNumber`'s `ariaIncrementLabel` and `ariaDecrementLabel` are renamed `incrementLabel` and
|
|
36
|
+
`decrementLabel`, so every such prop is named for its action plus `Label`.
|
|
37
|
+
|
|
38
|
+
- [#982](https://github.com/codefastlabs/codefast/pull/982) The width where `Sidebar` switches between the docked panel and the mobile sheet is one theme variable,
|
|
39
|
+
`--breakpoint-sidebar` (default `48rem`), which also mints a `sidebar:` variant. Redefine it in the app's `@theme`,
|
|
40
|
+
before or after the preset, and the docked layout, `SidebarInset`'s inset spacing, `SidebarRail`, the hover-only menu
|
|
41
|
+
actions and the JS switch to the sheet all follow it. The JS side matches `(width < …)`, the exact complement of the CSS
|
|
42
|
+
query, so a fractional width just under 768px no longer shows no sidebar at all; `SidebarRail` no longer shows inside
|
|
43
|
+
the mobile sheet.
|
|
44
|
+
|
|
45
|
+
- [#982](https://github.com/codefastlabs/codefast/pull/982) `SidebarProvider`'s ⌘B / Ctrl+B shortcut leaves the key alone while focus is in an `input`, `textarea`, `select` or
|
|
46
|
+
contenteditable element, during IME composition, on auto-repeat, with Shift or Alt held, and once another handler has
|
|
47
|
+
called `preventDefault()`, so ⌘B in a rich-text editor bolds without collapsing the sidebar. The new `shortcutKey` prop
|
|
48
|
+
picks the key, matched case-insensitively, or turns the shortcut off with `false`.
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- [#977](https://github.com/codefastlabs/codefast/pull/977) The README states the browser floor: Chrome and Edge 136, Firefox 136, and Safari 18.4 or later, the first releases that
|
|
53
|
+
ship every ES2025 builtin. `@codefast/di`'s README also says what a browser program without explicit resource management
|
|
54
|
+
does: it keeps `skipLibCheck` on and calls `dispose()` instead of `await using`.
|
|
55
|
+
|
|
56
|
+
- [#965](https://github.com/codefastlabs/codefast/pull/965) `README.md` now states TypeScript 7 or later as the floor for the package's types — the one compiler every `@codefast/*`
|
|
57
|
+
package is built and checked with. No code or declaration changed.
|
|
58
|
+
|
|
59
|
+
- [#953](https://github.com/codefastlabs/codefast/pull/953) `Carousel` reads Embla's scroll bounds with `useSyncExternalStore` instead of copying them into state from a deferred
|
|
60
|
+
effect. Its cleanup now removes the `reInit` listener as well as `select`; before, an effect re-run on the same Embla
|
|
61
|
+
instance — as React's Strict Mode does in development — left a second `reInit` listener behind. `CarouselPrevious` and
|
|
62
|
+
`CarouselNext` also reflect the real bounds on the first render that has an Embla instance, rather than starting
|
|
63
|
+
disabled until a queued microtask ran, and that update no longer lands outside React's `act` in tests.
|
|
64
|
+
|
|
65
|
+
- [#983](https://github.com/codefastlabs/codefast/pull/983) `InputSearch` keeps its clear button disabled on a read-only field when `disabled={false}` is passed alongside
|
|
66
|
+
`readOnly`; the button stayed enabled there and cleared the read-only value.
|
|
67
|
+
|
|
68
|
+
- [#980](https://github.com/codefastlabs/codefast/pull/980) The preset registers the published `dist` with Tailwind's `@source`, so an installed package styles its components
|
|
69
|
+
again. It registered only `src/**/*.{ts,tsx}`, which the tarball no longer ships, so the Quick start generated none of
|
|
70
|
+
the utilities the components use outside the monorepo.
|
|
71
|
+
|
|
72
|
+
- [#981](https://github.com/codefastlabs/codefast/pull/981) `Progress` forwards `value` and `max` to Radix, so a bar exposes `aria-valuenow`, `aria-valuetext`, `data-value` and a
|
|
73
|
+
`loading`/`complete` `data-state`, and `getValueLabel` takes effect. It kept `value` to place the fill and never passed
|
|
74
|
+
it on, so every bar announced as indeterminate. The fill now scales by `max` and clamps to it, so `value={3} max={5}`
|
|
75
|
+
fills 60% of the bar, not 3%, and what the bar draws is what it announces.
|
|
76
|
+
|
|
77
|
+
- [#984](https://github.com/codefastlabs/codefast/pull/984) `SidebarProvider` registers its shortcut listener once, reading the latest state through an Effect Event, instead of
|
|
78
|
+
re-registering it after every toggle. With several providers on a page, the first one now keeps the shortcut on every
|
|
79
|
+
press. Re-registering moved the provider that had just toggled to the back of the listener queue, so a different sidebar
|
|
80
|
+
toggled on each press.
|
|
81
|
+
|
|
82
|
+
- [#982](https://github.com/codefastlabs/codefast/pull/982) `useMediaQuery` reports `false` while hydrating and then the live match, so markup server-rendered for a desktop
|
|
83
|
+
hydrates on a phone. It read `matchMedia` during the first client render, so a matching query hydrated different markup
|
|
84
|
+
than the server sent and React discarded the tree to render it again; `SidebarProvider`, through `useIsMobile`, did this
|
|
85
|
+
on every phone.
|
|
86
|
+
- Updated dependencies:
|
|
87
|
+
- @codefast/tailwind-variants@0.9.0
|
|
88
|
+
|
|
3
89
|
## 0.9.3
|
|
4
90
|
|
|
5
91
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -33,7 +33,10 @@ Or the equivalent with your package manager: `npm install @codefast/ui`, `yarn a
|
|
|
33
33
|
|
|
34
34
|
`@codefast/ui` requires:
|
|
35
35
|
|
|
36
|
-
- Node.js
|
|
36
|
+
- Node.js 24 or later.
|
|
37
|
+
- TypeScript 7 or later for its types.
|
|
38
|
+
- Chrome and Edge 136, Firefox 136, or Safari 18.4 or later in the browser
|
|
39
|
+
([support policy](../../SUPPORT.md#browsers)).
|
|
37
40
|
- React 19 — `react` and `react-dom` (19 or later) are peer dependencies; `@types/react` and `@types/react-dom` are
|
|
38
41
|
optional peers.
|
|
39
42
|
- Tailwind CSS 4 at build time — the stylesheets are Tailwind source, and rely on your Tailwind pipeline to compile
|
|
@@ -5,7 +5,7 @@ import { cn } from "#lib/utils";
|
|
|
5
5
|
* @since 0.3.16-canary.0
|
|
6
6
|
*/
|
|
7
7
|
function Avatar({ className, size = "default", ...props }) {
|
|
8
|
-
return (_jsx(AvatarPrimitive.Root, { className: cn("group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-
|
|
8
|
+
return (_jsx(AvatarPrimitive.Root, { className: cn("group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-foreground/10 data-[size=lg]:size-10 data-[size=sm]:size-6", className), "data-size": size, "data-slot": "avatar", ...props }));
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* @since 0.3.16-canary.0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react";
|
|
3
3
|
import * as Slot from "radix-ui/slot";
|
|
4
4
|
import { cn } from "#lib/utils";
|
|
@@ -43,7 +43,7 @@ function BreadcrumbSeparator({ children, className, ...props }) {
|
|
|
43
43
|
* @since 0.3.16-canary.0
|
|
44
44
|
*/
|
|
45
45
|
function BreadcrumbEllipsis({ className, ...props }) {
|
|
46
|
-
return (
|
|
46
|
+
return (_jsx("span", { "aria-hidden": "true", className: cn("flex size-5 items-center justify-center [&>svg]:size-4", className), "data-slot": "breadcrumb-ellipsis", role: "presentation", ...props, children: _jsx(MoreHorizontalIcon, {}) }));
|
|
47
47
|
}
|
|
48
48
|
// ── Exports ──────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
49
49
|
export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, };
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import useEmblaCarousel from "embla-carousel-react";
|
|
3
3
|
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
4
4
|
import { Context } from "radix-ui/internal";
|
|
5
|
-
import { useCallback, useEffect,
|
|
5
|
+
import { useCallback, useEffect, useSyncExternalStore } from "react";
|
|
6
6
|
import { Button } from "#components/button";
|
|
7
7
|
import { useDirection } from "#components/direction";
|
|
8
8
|
import { cn } from "#lib/utils";
|
|
@@ -21,15 +21,20 @@ function Carousel({ __scopeCarousel, children, className, opts, orientation, plu
|
|
|
21
21
|
...opts,
|
|
22
22
|
axis: orientation === "vertical" ? "y" : "x",
|
|
23
23
|
}, plugins);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (!carouselApi) {
|
|
28
|
-
return;
|
|
24
|
+
const subscribe = useCallback((onStoreChange) => {
|
|
25
|
+
if (!api) {
|
|
26
|
+
return () => { };
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
api.on("reInit", onStoreChange);
|
|
29
|
+
api.on("select", onStoreChange);
|
|
30
|
+
return () => {
|
|
31
|
+
api.off("reInit", onStoreChange);
|
|
32
|
+
api.off("select", onStoreChange);
|
|
33
|
+
};
|
|
34
|
+
}, [api]);
|
|
35
|
+
// Embla is an external store: read its scroll bounds during render instead of mirroring them into state.
|
|
36
|
+
const canScrollPrevious = useSyncExternalStore(subscribe, () => api?.canScrollPrev() ?? false, () => false);
|
|
37
|
+
const canScrollNext = useSyncExternalStore(subscribe, () => api?.canScrollNext() ?? false, () => false);
|
|
33
38
|
const scrollPrevious = useCallback(() => {
|
|
34
39
|
api?.scrollPrev();
|
|
35
40
|
}, [api]);
|
|
@@ -55,20 +60,6 @@ function Carousel({ __scopeCarousel, children, className, opts, orientation, plu
|
|
|
55
60
|
}
|
|
56
61
|
setApi(api);
|
|
57
62
|
}, [api, setApi]);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (!api) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
// Defer onSelect to avoid synchronous setState in effect
|
|
63
|
-
queueMicrotask(() => {
|
|
64
|
-
onSelect(api);
|
|
65
|
-
});
|
|
66
|
-
api.on("reInit", onSelect);
|
|
67
|
-
api.on("select", onSelect);
|
|
68
|
-
return () => {
|
|
69
|
-
api.off("select", onSelect);
|
|
70
|
-
};
|
|
71
|
-
}, [api, onSelect]);
|
|
72
63
|
return (_jsx(CarouselContextProvider, { api: api, canScrollNext: canScrollNext, canScrollPrev: canScrollPrevious, carouselRef: carouselRef, opts: opts, orientation: orientation ?? (opts?.axis === "y" ? "vertical" : "horizontal"), scope: __scopeCarousel, scrollNext: scrollNext, scrollPrev: scrollPrevious, children: _jsx("div", { "aria-roledescription": "carousel", className: cn("relative", className), "data-slot": "carousel", role: "region", onKeyDownCapture: handleKeyDown, ...props, children: children }) }));
|
|
73
64
|
}
|
|
74
65
|
// ── Component: CarouselContent ───────────────────────────────────────────────────────────────────────────────────────
|
|
@@ -14,6 +14,12 @@ declare function Command({ className, ...props }: CommandProps): JSX.Element;
|
|
|
14
14
|
*/
|
|
15
15
|
interface CommandDialogProps extends ComponentProps<typeof Dialog> {
|
|
16
16
|
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The accessible name of the close button `showCloseButton` adds.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue `"Close"`
|
|
21
|
+
*/
|
|
22
|
+
closeLabel?: string | undefined;
|
|
17
23
|
description?: string;
|
|
18
24
|
showCloseButton?: boolean;
|
|
19
25
|
title?: string;
|
|
@@ -21,7 +27,7 @@ interface CommandDialogProps extends ComponentProps<typeof Dialog> {
|
|
|
21
27
|
/**
|
|
22
28
|
* @since 0.3.16-canary.0
|
|
23
29
|
*/
|
|
24
|
-
declare function CommandDialog({ children, className, description, showCloseButton, title, ...props }: CommandDialogProps): JSX.Element;
|
|
30
|
+
declare function CommandDialog({ children, className, closeLabel, description, showCloseButton, title, ...props }: CommandDialogProps): JSX.Element;
|
|
25
31
|
/**
|
|
26
32
|
* @since 0.3.16-canary.0
|
|
27
33
|
*/
|
|
@@ -13,8 +13,8 @@ function Command({ className, ...props }) {
|
|
|
13
13
|
/**
|
|
14
14
|
* @since 0.3.16-canary.0
|
|
15
15
|
*/
|
|
16
|
-
function CommandDialog({ children, className, description = "Search for a command to run...", showCloseButton = false, title = "Command Palette", ...props }) {
|
|
17
|
-
return (_jsxs(Dialog, { "data-slot": "command-dialog", ...props, children: [_jsxs(DialogHeader, { className: "sr-only", children: [_jsx(DialogTitle, { children: title }), _jsx(DialogDescription, { children: description })] }), _jsx(DialogContent, { className: cn("top-1/3 translate-y-0 overflow-hidden rounded-xl p-0", className), "data-slot": "command-dialog-content", showCloseButton: showCloseButton, children: children })] }));
|
|
16
|
+
function CommandDialog({ children, className, closeLabel, description = "Search for a command to run...", showCloseButton = false, title = "Command Palette", ...props }) {
|
|
17
|
+
return (_jsxs(Dialog, { "data-slot": "command-dialog", ...props, children: [_jsxs(DialogHeader, { className: "sr-only", children: [_jsx(DialogTitle, { children: title }), _jsx(DialogDescription, { children: description })] }), _jsx(DialogContent, { className: cn("top-1/3 translate-y-0 overflow-hidden rounded-xl p-0", className), closeLabel: closeLabel, "data-slot": "command-dialog-content", showCloseButton: showCloseButton, children: children })] }));
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* @since 0.3.16-canary.0
|
|
@@ -20,12 +20,18 @@ declare function DialogTrigger({ ...props }: DialogTriggerProps): JSX.Element;
|
|
|
20
20
|
* @since 0.3.16-canary.0
|
|
21
21
|
*/
|
|
22
22
|
interface DialogContentProps extends ComponentProps<typeof DialogPrimitive.Content> {
|
|
23
|
+
/**
|
|
24
|
+
* The accessible name of the built-in close button.
|
|
25
|
+
*
|
|
26
|
+
* @defaultValue `"Close"`
|
|
27
|
+
*/
|
|
28
|
+
closeLabel?: string | undefined;
|
|
23
29
|
showCloseButton?: boolean;
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* @since 0.3.16-canary.0
|
|
27
33
|
*/
|
|
28
|
-
declare function DialogContent({ children, className, showCloseButton, ...props }: DialogContentProps): JSX.Element;
|
|
34
|
+
declare function DialogContent({ children, className, closeLabel, showCloseButton, ...props }: DialogContentProps): JSX.Element;
|
|
29
35
|
/**
|
|
30
36
|
* @since 0.3.16-canary.0
|
|
31
37
|
*/
|
|
@@ -51,12 +57,18 @@ declare function DialogBody({ className, ...props }: DialogBodyProps): JSX.Eleme
|
|
|
51
57
|
* @since 0.3.16-canary.0
|
|
52
58
|
*/
|
|
53
59
|
interface DialogFooterProps extends ComponentProps<"div"> {
|
|
60
|
+
/**
|
|
61
|
+
* The label of the close button `showCloseButton` adds.
|
|
62
|
+
*
|
|
63
|
+
* @defaultValue `"Close"`
|
|
64
|
+
*/
|
|
65
|
+
closeLabel?: string | undefined;
|
|
54
66
|
showCloseButton?: boolean;
|
|
55
67
|
}
|
|
56
68
|
/**
|
|
57
69
|
* @since 0.3.16-canary.0
|
|
58
70
|
*/
|
|
59
|
-
declare function DialogFooter({ children, className, showCloseButton, ...props }: DialogFooterProps): JSX.Element;
|
|
71
|
+
declare function DialogFooter({ children, className, closeLabel, showCloseButton, ...props }: DialogFooterProps): JSX.Element;
|
|
60
72
|
/**
|
|
61
73
|
* @since 0.3.16-canary.0
|
|
62
74
|
*/
|
|
@@ -18,8 +18,8 @@ function DialogTrigger({ ...props }) {
|
|
|
18
18
|
/**
|
|
19
19
|
* @since 0.3.16-canary.0
|
|
20
20
|
*/
|
|
21
|
-
function DialogContent({ children, className, showCloseButton = true, ...props }) {
|
|
22
|
-
return (_jsxs(DialogPrimitive.Portal, { "data-slot": "dialog-portal", children: [_jsx(DialogPrimitive.Overlay, { className: "fixed inset-0 isolate z-50 bg-black/10 ease-gentle supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:animation-duration-overlay-in data-open:fade-in-0 data-closed:animate-out data-closed:ease-exit data-closed:animation-duration-overlay-out data-closed:fade-out-0", "data-slot": "dialog-overlay" }), _jsxs(DialogPrimitive.Content, { className: cn("fixed inset-s-1/2 top-1/2 z-50 flex max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col gap-4 overflow-y-auto rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 ease-ui outline-none sm:max-w-sm rtl:translate-x-1/2 data-open:animate-in data-open:animation-duration-overlay-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:ease-exit data-closed:animation-duration-overlay-out data-closed:fade-out-0 data-closed:zoom-out-95", className), "data-slot": "dialog-content", ...props, children: [children, showCloseButton ? (_jsx(DialogPrimitive.Close, { asChild: true, "data-slot": "dialog-close", children: _jsxs(Button, { className: "absolute inset-e-2 top-2", size: "icon-sm", variant: "ghost", children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children:
|
|
21
|
+
function DialogContent({ children, className, closeLabel = "Close", showCloseButton = true, ...props }) {
|
|
22
|
+
return (_jsxs(DialogPrimitive.Portal, { "data-slot": "dialog-portal", children: [_jsx(DialogPrimitive.Overlay, { className: "fixed inset-0 isolate z-50 bg-black/10 ease-gentle supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:animation-duration-overlay-in data-open:fade-in-0 data-closed:animate-out data-closed:ease-exit data-closed:animation-duration-overlay-out data-closed:fade-out-0", "data-slot": "dialog-overlay" }), _jsxs(DialogPrimitive.Content, { className: cn("fixed inset-s-1/2 top-1/2 z-50 flex max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col gap-4 overflow-y-auto rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 ease-ui outline-none sm:max-w-sm rtl:translate-x-1/2 data-open:animate-in data-open:animation-duration-overlay-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:ease-exit data-closed:animation-duration-overlay-out data-closed:fade-out-0 data-closed:zoom-out-95", className), "data-slot": "dialog-content", ...props, children: [children, showCloseButton ? (_jsx(DialogPrimitive.Close, { asChild: true, "data-slot": "dialog-close", children: _jsxs(Button, { className: "absolute inset-e-2 top-2", size: "icon-sm", variant: "ghost", children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children: closeLabel })] }) })) : null] })] }));
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* @since 0.3.16-canary.0
|
|
@@ -36,8 +36,8 @@ function DialogBody({ className, ...props }) {
|
|
|
36
36
|
/**
|
|
37
37
|
* @since 0.3.16-canary.0
|
|
38
38
|
*/
|
|
39
|
-
function DialogFooter({ children, className, showCloseButton = false, ...props }) {
|
|
40
|
-
return (_jsxs("div", { className: cn("-mx-4 -mb-4 flex shrink-0 flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end", className), "data-slot": "dialog-footer", ...props, children: [children, showCloseButton ? (_jsx(DialogPrimitive.Close, { asChild: true, children: _jsx(Button, { variant: "outline", children:
|
|
39
|
+
function DialogFooter({ children, className, closeLabel = "Close", showCloseButton = false, ...props }) {
|
|
40
|
+
return (_jsxs("div", { className: cn("-mx-4 -mb-4 flex shrink-0 flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end", className), "data-slot": "dialog-footer", ...props, children: [children, showCloseButton ? (_jsx(DialogPrimitive.Close, { asChild: true, children: _jsx(Button, { variant: "outline", children: closeLabel }) })) : null] }));
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* @since 0.3.16-canary.0
|
|
@@ -11,7 +11,7 @@ type InputNumberProps = ComponentProps<typeof InputNumberPrimitive.Root>;
|
|
|
11
11
|
*
|
|
12
12
|
* @since 0.3.16-canary.0
|
|
13
13
|
*/
|
|
14
|
-
declare function InputNumber({
|
|
14
|
+
declare function InputNumber({ className, decrementLabel, incrementLabel, spinner, ...props }: InputNumberProps): JSX.Element;
|
|
15
15
|
/**
|
|
16
16
|
* @since 0.5.0-canary.6
|
|
17
17
|
*/
|
|
@@ -11,8 +11,8 @@ import { buttonVariants } from "#variants/button";
|
|
|
11
11
|
*
|
|
12
12
|
* @since 0.3.16-canary.0
|
|
13
13
|
*/
|
|
14
|
-
function InputNumber({
|
|
15
|
-
return (_jsx(InputNumberPrimitive.Root, {
|
|
14
|
+
function InputNumber({ className, decrementLabel = "Decrement", incrementLabel = "Increment", spinner, ...props }) {
|
|
15
|
+
return (_jsx(InputNumberPrimitive.Root, { className: cn("group/input-number relative flex h-8 w-full min-w-0 items-center overflow-hidden rounded-lg bg-transparent text-base inset-ring inset-ring-input transition-[color,box-shadow] not-has-[input:disabled]:shadow-xs has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 has-aria-invalid:inset-ring-destructive has-[input:disabled]:bg-input/50 has-[input:disabled]:opacity-50 has-[input:focus-visible]:ring-3 has-[input:focus-visible]:ring-ring/50 has-[input:focus-visible]:inset-ring-ring motion-reduce:transition-none md:text-sm dark:bg-input/30 dark:has-aria-invalid:ring-destructive/40 dark:has-aria-invalid:inset-ring-destructive/50 dark:has-[input:disabled]:bg-input/80 [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), "data-slot": "input-number", decrementLabel: decrementLabel, incrementLabel: incrementLabel, spinner: spinner ?? _jsx(Spinner, {}), ...props }));
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* The editable numeric input.
|
|
@@ -3,10 +3,23 @@ import { InputGroupInput } from "#components/input-group";
|
|
|
3
3
|
/**
|
|
4
4
|
* @since 0.3.16-canary.0
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
interface InputPasswordProps extends Omit<ComponentProps<typeof InputGroupInput>, "type"> {
|
|
7
|
+
/**
|
|
8
|
+
* The accessible name of the reveal toggle while the password is shown.
|
|
9
|
+
*
|
|
10
|
+
* @defaultValue `"Hide password"`
|
|
11
|
+
*/
|
|
12
|
+
concealLabel?: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The accessible name of the reveal toggle while the password is hidden.
|
|
15
|
+
*
|
|
16
|
+
* @defaultValue `"Show password"`
|
|
17
|
+
*/
|
|
18
|
+
revealLabel?: string | undefined;
|
|
19
|
+
}
|
|
7
20
|
/**
|
|
8
21
|
* @since 0.3.16-canary.0
|
|
9
22
|
*/
|
|
10
|
-
declare function InputPassword({ className, disabled, readOnly, ...props }: InputPasswordProps): JSX.Element;
|
|
23
|
+
declare function InputPassword({ className, concealLabel, disabled, readOnly, revealLabel, ...props }: InputPasswordProps): JSX.Element;
|
|
11
24
|
export { InputPassword };
|
|
12
25
|
export type { InputPasswordProps };
|
|
@@ -5,12 +5,12 @@ import { InputGroup, InputGroupButton, InputGroupInput } from "#components/input
|
|
|
5
5
|
/**
|
|
6
6
|
* @since 0.3.16-canary.0
|
|
7
7
|
*/
|
|
8
|
-
function InputPassword({ className, disabled, readOnly, ...props }) {
|
|
8
|
+
function InputPassword({ className, concealLabel = "Hide password", disabled, readOnly, revealLabel = "Show password", ...props }) {
|
|
9
9
|
const [type, setType] = useState("password");
|
|
10
10
|
const togglePasswordVisibility = useCallback(() => {
|
|
11
11
|
setType((previous) => (previous === "password" ? "text" : "password"));
|
|
12
12
|
}, []);
|
|
13
|
-
return (_jsxs(InputGroup, { className: className, "data-disabled": disabled ? "true" : undefined, "data-slot": "input-password", children: [_jsx(InputGroupInput, { autoCapitalize: "none", disabled: disabled, readOnly: readOnly, type: type, ...props }), _jsx(InputGroupButton, { "aria-label": type === "password" ?
|
|
13
|
+
return (_jsxs(InputGroup, { className: className, "data-disabled": disabled ? "true" : undefined, "data-slot": "input-password", children: [_jsx(InputGroupInput, { autoCapitalize: "none", disabled: disabled, readOnly: readOnly, type: type, ...props }), _jsx(InputGroupButton, { "aria-label": type === "password" ? revealLabel : concealLabel, className: "rounded-full", "data-slot": "input-password-toggle", disabled: disabled, size: "icon-sm", type: "button", variant: "ghost", onClick: togglePasswordVisibility, children: type === "password" ? _jsx(EyeOffIcon, {}) : _jsx(EyeIcon, {}) })] }));
|
|
14
14
|
}
|
|
15
15
|
// ── Exports ──────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
16
16
|
export { InputPassword };
|
|
@@ -4,6 +4,12 @@ import { InputGroupInput } from "#components/input-group";
|
|
|
4
4
|
* @since 0.3.16-canary.0
|
|
5
5
|
*/
|
|
6
6
|
interface InputSearchProps extends Omit<ComponentProps<typeof InputGroupInput>, "defaultValue" | "onChange" | "type" | "value"> {
|
|
7
|
+
/**
|
|
8
|
+
* The accessible name of the button that clears the query.
|
|
9
|
+
*
|
|
10
|
+
* @defaultValue `"Clear search"`
|
|
11
|
+
*/
|
|
12
|
+
clearLabel?: string | undefined;
|
|
7
13
|
defaultValue?: string;
|
|
8
14
|
onChange?: (value?: string) => void;
|
|
9
15
|
value?: string;
|
|
@@ -11,6 +17,6 @@ interface InputSearchProps extends Omit<ComponentProps<typeof InputGroupInput>,
|
|
|
11
17
|
/**
|
|
12
18
|
* @since 0.3.16-canary.0
|
|
13
19
|
*/
|
|
14
|
-
declare function InputSearch({ className, defaultValue, disabled, onChange, readOnly, value: valueProperty, ...props }: InputSearchProps): JSX.Element;
|
|
20
|
+
declare function InputSearch({ className, clearLabel, defaultValue, disabled, onChange, readOnly, value: valueProperty, ...props }: InputSearchProps): JSX.Element;
|
|
15
21
|
export { InputSearch };
|
|
16
22
|
export type { InputSearchProps };
|
|
@@ -5,7 +5,7 @@ import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "
|
|
|
5
5
|
/**
|
|
6
6
|
* @since 0.3.16-canary.0
|
|
7
7
|
*/
|
|
8
|
-
function InputSearch({ className, defaultValue, disabled, onChange, readOnly, value: valueProperty, ...props }) {
|
|
8
|
+
function InputSearch({ className, clearLabel = "Clear search", defaultValue, disabled, onChange, readOnly, value: valueProperty, ...props }) {
|
|
9
9
|
const [value, setValue] = useControllableState({
|
|
10
10
|
defaultProp: defaultValue,
|
|
11
11
|
prop: valueProperty,
|
|
@@ -13,7 +13,7 @@ function InputSearch({ className, defaultValue, disabled, onChange, readOnly, va
|
|
|
13
13
|
});
|
|
14
14
|
return (_jsxs(InputGroup, { className: className, "data-disabled": disabled ? "true" : undefined, "data-slot": "input-search", children: [_jsx(InputGroupAddon, { align: "inline-start", children: _jsx(SearchIcon, {}) }), _jsx(InputGroupInput, { disabled: disabled, readOnly: readOnly, type: "search", value: value ?? "", onChange: (event) => {
|
|
15
15
|
setValue(event.target.value);
|
|
16
|
-
}, ...props }), value ? (_jsx(InputGroupButton, { "aria-label":
|
|
16
|
+
}, ...props }), value ? (_jsx(InputGroupButton, { "aria-label": clearLabel, className: "rounded-full", "data-slot": "input-search-clear", disabled: disabled || readOnly, size: "icon-sm", type: "button", variant: "ghost", onClick: () => {
|
|
17
17
|
setValue("");
|
|
18
18
|
}, children: _jsx(XIcon, {}) })) : null] }));
|
|
19
19
|
}
|
|
@@ -42,7 +42,7 @@ function PaginationNext({ className, text = "Next", ...props }) {
|
|
|
42
42
|
* @since 0.3.16-canary.0
|
|
43
43
|
*/
|
|
44
44
|
function PaginationEllipsis({ className, ...props }) {
|
|
45
|
-
return (
|
|
45
|
+
return (_jsx("span", { "aria-hidden": true, className: cn("flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4", className), "data-slot": "pagination-ellipsis", ...props, children: _jsx(MoreHorizontalIcon, {}) }));
|
|
46
46
|
}
|
|
47
47
|
// ── Exports ──────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
48
48
|
export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, };
|
|
@@ -5,8 +5,13 @@ import type { ComponentProps, JSX } from "react";
|
|
|
5
5
|
*/
|
|
6
6
|
type ProgressProps = ComponentProps<typeof ProgressPrimitive.Root>;
|
|
7
7
|
/**
|
|
8
|
+
* A horizontal bar that fills to `value` out of `max`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks `value` defaults to `0` and is clamped to `max`; `null` marks the work indeterminate, which leaves out
|
|
11
|
+
* `aria-valuenow`.
|
|
12
|
+
*
|
|
8
13
|
* @since 0.3.16-canary.0
|
|
9
14
|
*/
|
|
10
|
-
declare function Progress({ className, value, ...props }: ProgressProps): JSX.Element;
|
|
15
|
+
declare function Progress({ className, max, value, ...props }: ProgressProps): JSX.Element;
|
|
11
16
|
export { Progress };
|
|
12
17
|
export type { ProgressProps };
|
|
@@ -2,11 +2,19 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as ProgressPrimitive from "radix-ui/progress";
|
|
3
3
|
import { cn } from "#lib/utils";
|
|
4
4
|
/**
|
|
5
|
+
* A horizontal bar that fills to `value` out of `max`.
|
|
6
|
+
*
|
|
7
|
+
* @remarks `value` defaults to `0` and is clamped to `max`; `null` marks the work indeterminate, which leaves out
|
|
8
|
+
* `aria-valuenow`.
|
|
9
|
+
*
|
|
5
10
|
* @since 0.3.16-canary.0
|
|
6
11
|
*/
|
|
7
|
-
function Progress({ className, value, ...props }) {
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
function Progress({ className, max = 100, value = 0, ...props }) {
|
|
13
|
+
// One clamped value feeds both Radix's ARIA state and the fill, so what is announced is what is drawn.
|
|
14
|
+
const clampedValue = value === null ? null : Math.min(Math.max(value, 0), max);
|
|
15
|
+
const filledPercent = clampedValue === null ? 0 : (clampedValue / max) * 100;
|
|
16
|
+
return (_jsx(ProgressPrimitive.Root, { className: cn("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted", className), "data-slot": "progress", max: max, value: clampedValue, ...props, children: _jsx(ProgressPrimitive.Indicator, { className: "size-full flex-1 bg-primary transition-all", "data-slot": "progress-indicator", style: {
|
|
17
|
+
transform: `translateX(-${(100 - filledPercent).toString()}%)`,
|
|
10
18
|
} }) }));
|
|
11
19
|
}
|
|
12
20
|
// ── Exports ──────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
@@ -12,7 +12,7 @@ function Select({ ...props }) {
|
|
|
12
12
|
* @since 0.3.16-canary.0
|
|
13
13
|
*/
|
|
14
14
|
function SelectGroup({ className, ...props }) {
|
|
15
|
-
return _jsx(SelectPrimitive.Group, { className: cn("
|
|
15
|
+
return (_jsx(SelectPrimitive.Group, { className: cn("[[data-slot=select-group]+&]:mt-2", className), "data-slot": "select-group", ...props }));
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* @since 0.3.16-canary.0
|
|
@@ -43,7 +43,7 @@ function SelectScrollDownButton({ className, ...props }) {
|
|
|
43
43
|
*/
|
|
44
44
|
function SelectContent({ align = "center", children, className, position = "item-aligned", ...props }) {
|
|
45
45
|
return (_jsx(SelectPrimitive.Portal, { "data-slot": "select-portal", children: _jsxs(SelectPrimitive.Content, { align: align, className: cn("relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 ease-snappy data-[align-trigger=true]:animate-none data-open:animate-in data-open:animation-duration-menu-in data-open:fade-in-0 data-open:zoom-in-95 data-open:data-side-top:slide-in-from-bottom-2 data-open:data-side-right:slide-in-from-left-2 data-open:data-side-bottom:slide-in-from-top-2 data-open:data-side-left:slide-in-from-right-2 data-closed:animate-out data-closed:ease-exit data-closed:animation-duration-menu-out data-closed:fade-out-0 data-closed:zoom-out-95 data-closed:data-side-top:slide-out-to-bottom-2 data-closed:data-side-right:slide-out-to-left-2 data-closed:data-side-bottom:slide-out-to-top-2 data-closed:data-side-left:slide-out-to-right-2", position === "popper" &&
|
|
46
|
-
"data-side-top:-translate-y-1 data-side-right:translate-x-1 rtl:data-side-right:-translate-x-1 data-side-bottom:translate-y-1 data-side-left:-translate-x-1 rtl:data-side-left:translate-x-1", className), "data-align-trigger": position === "item-aligned", "data-slot": "select-content", position: position, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { className:
|
|
46
|
+
"data-side-top:-translate-y-1 data-side-right:translate-x-1 rtl:data-side-right:-translate-x-1 data-side-bottom:translate-y-1 data-side-left:-translate-x-1 rtl:data-side-left:translate-x-1", className), "data-align-trigger": position === "item-aligned", "data-slot": "select-content", position: position, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { className: "scroll-py-1 p-1 data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)", "data-position": position, children: children }), _jsx(SelectScrollDownButton, {})] }) }));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* @since 0.3.16-canary.0
|
|
@@ -22,12 +22,18 @@ declare function SheetTrigger({ ...props }: SheetTriggerProps): JSX.Element;
|
|
|
22
22
|
* @since 0.3.16-canary.0
|
|
23
23
|
*/
|
|
24
24
|
interface SheetContentProps extends ComponentProps<typeof SheetPrimitive.Content>, SheetContentVariants {
|
|
25
|
+
/**
|
|
26
|
+
* The accessible name of the built-in close button.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue `"Close"`
|
|
29
|
+
*/
|
|
30
|
+
closeLabel?: string | undefined;
|
|
25
31
|
showCloseButton?: boolean;
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* @since 0.3.16-canary.0
|
|
29
35
|
*/
|
|
30
|
-
declare function SheetContent({ children, className, showCloseButton, side, ...props }: SheetContentProps): JSX.Element;
|
|
36
|
+
declare function SheetContent({ children, className, closeLabel, showCloseButton, side, ...props }: SheetContentProps): JSX.Element;
|
|
31
37
|
/**
|
|
32
38
|
* @since 0.3.16-canary.0
|
|
33
39
|
*/
|
package/dist/components/sheet.js
CHANGED
|
@@ -19,12 +19,12 @@ function SheetTrigger({ ...props }) {
|
|
|
19
19
|
/**
|
|
20
20
|
* @since 0.3.16-canary.0
|
|
21
21
|
*/
|
|
22
|
-
function SheetContent({ children, className, showCloseButton = true, side = "right", ...props }) {
|
|
22
|
+
function SheetContent({ children, className, closeLabel = "Close", showCloseButton = true, side = "right", ...props }) {
|
|
23
23
|
return (_jsxs(SheetPrimitive.Portal, { "data-slot": "sheet-portal", children: [_jsx(SheetPrimitive.Overlay, { className: "fixed inset-0 z-50 bg-black/10 ease-gentle supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:animation-duration-panel-in data-open:fade-in-0 data-closed:animate-out data-closed:ease-exit data-closed:animation-duration-panel-out data-closed:fade-out-0", "data-slot": "sheet-overlay" }), _jsxs(SheetPrimitive.Content, { className: sheetContentVariants({ className, side }), "data-side": side, "data-slot": "sheet-content", ...props, children: [children, showCloseButton ? (_jsxs(SheetPrimitive.Close, { className: buttonVariants({
|
|
24
24
|
className: "absolute top-3 inset-e-3",
|
|
25
25
|
size: "icon-sm",
|
|
26
26
|
variant: "ghost",
|
|
27
|
-
}), "data-slot": "sheet-close", children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children:
|
|
27
|
+
}), "data-slot": "sheet-close", children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children: closeLabel })] })) : null] })] }));
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* @since 0.3.16-canary.0
|
|
@@ -27,23 +27,35 @@ interface SidebarProviderProps extends ComponentProps<"div"> {
|
|
|
27
27
|
defaultOpen?: boolean;
|
|
28
28
|
onOpenChange?: (open: boolean) => void;
|
|
29
29
|
open?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The key that toggles the sidebar together with ⌘ or Ctrl, or `false` for no shortcut.
|
|
32
|
+
*
|
|
33
|
+
* @defaultValue `"b"`
|
|
34
|
+
*/
|
|
35
|
+
shortcutKey?: string | false | undefined;
|
|
30
36
|
}
|
|
31
37
|
/**
|
|
32
38
|
* @since 0.3.16-canary.0
|
|
33
39
|
*/
|
|
34
|
-
declare function SidebarProvider({ children, className, defaultOpen, onOpenChange: setOpenProperty, open: openProperty, style, ...props }: SidebarProviderProps): JSX.Element;
|
|
40
|
+
declare function SidebarProvider({ children, className, defaultOpen, onOpenChange: setOpenProperty, open: openProperty, shortcutKey, style, ...props }: SidebarProviderProps): JSX.Element;
|
|
35
41
|
/**
|
|
36
42
|
* @since 0.3.16-canary.0
|
|
37
43
|
*/
|
|
38
44
|
interface SidebarProps extends ComponentProps<"div"> {
|
|
39
45
|
collapsible?: "icon" | "none" | "offcanvas";
|
|
46
|
+
/**
|
|
47
|
+
* The accessible name of the sheet the sidebar opens as on narrow screens.
|
|
48
|
+
*
|
|
49
|
+
* @defaultValue `"Sidebar"`
|
|
50
|
+
*/
|
|
51
|
+
mobileTitle?: string | undefined;
|
|
40
52
|
side?: "left" | "right";
|
|
41
53
|
variant?: "floating" | "inset" | "sidebar";
|
|
42
54
|
}
|
|
43
55
|
/**
|
|
44
56
|
* @since 0.3.16-canary.0
|
|
45
57
|
*/
|
|
46
|
-
declare function Sidebar({ children, className, collapsible, side, variant, ...props }: SidebarProps): JSX.Element;
|
|
58
|
+
declare function Sidebar({ children, className, collapsible, mobileTitle, side, variant, ...props }: SidebarProps): JSX.Element;
|
|
47
59
|
/**
|
|
48
60
|
* @since 0.3.16-canary.0
|
|
49
61
|
*/
|
|
@@ -2,14 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { PanelLeftIcon } from "lucide-react";
|
|
3
3
|
import { Context } from "radix-ui/internal";
|
|
4
4
|
import * as Slot from "radix-ui/slot";
|
|
5
|
-
import { useCallback, useEffect, useId, useState } from "react";
|
|
5
|
+
import { useCallback, useEffect, useEffectEvent, useId, useState } from "react";
|
|
6
6
|
import { Button } from "#components/button";
|
|
7
7
|
import { Input } from "#components/input";
|
|
8
8
|
import { Separator } from "#components/separator";
|
|
9
|
-
import { Sheet, SheetContent,
|
|
9
|
+
import { Sheet, SheetContent, SheetHeader, SheetTitle } from "#components/sheet";
|
|
10
10
|
import { Skeleton } from "#components/skeleton";
|
|
11
11
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "#components/tooltip";
|
|
12
|
-
import {
|
|
12
|
+
import { useMediaQuery } from "#hooks/use-media-query";
|
|
13
13
|
import { cn } from "#lib/utils";
|
|
14
14
|
import { sidebarMenuButtonVariants } from "#variants/sidebar";
|
|
15
15
|
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
@@ -17,7 +17,9 @@ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
|
17
17
|
const SIDEBAR_WIDTH = "16rem";
|
|
18
18
|
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
19
19
|
const SIDEBAR_WIDTH_ICON = "3.0625rem";
|
|
20
|
-
const
|
|
20
|
+
const SIDEBAR_SHORTCUT_KEY = "b";
|
|
21
|
+
// The preset's `--breakpoint-sidebar` default, for a page that has not loaded the preset.
|
|
22
|
+
const SIDEBAR_BREAKPOINT_FALLBACK = "48rem";
|
|
21
23
|
// ── Context: SidebarProvider ─────────────────────────────────────────────────────────────────────────────────────────
|
|
22
24
|
const SIDEBAR_PROVIDER_NAME = "SidebarProvider";
|
|
23
25
|
const [SidebarContextProvider, useSidebarContext] = Context.createContext(SIDEBAR_PROVIDER_NAME);
|
|
@@ -31,8 +33,8 @@ const useSidebar = useSidebarContext;
|
|
|
31
33
|
/**
|
|
32
34
|
* @since 0.3.16-canary.0
|
|
33
35
|
*/
|
|
34
|
-
function SidebarProvider({ children, className, defaultOpen = true, onOpenChange: setOpenProperty, open: openProperty, style, ...props }) {
|
|
35
|
-
const isMobile =
|
|
36
|
+
function SidebarProvider({ children, className, defaultOpen = true, onOpenChange: setOpenProperty, open: openProperty, shortcutKey = SIDEBAR_SHORTCUT_KEY, style, ...props }) {
|
|
37
|
+
const isMobile = useIsBelowSidebarBreakpoint();
|
|
36
38
|
const [openMobile, setOpenMobile] = useState(false);
|
|
37
39
|
// This is the internal state of the sidebar.
|
|
38
40
|
// We use openProp and setOpenProp for control from outside the component.
|
|
@@ -58,19 +60,24 @@ function SidebarProvider({ children, className, defaultOpen = true, onOpenChange
|
|
|
58
60
|
setOpen((currentValue) => !currentValue);
|
|
59
61
|
}
|
|
60
62
|
}, [isMobile, setOpen]);
|
|
63
|
+
// Reads the latest state through an Effect Event, so the listener stays registered across toggles and, with several
|
|
64
|
+
// providers mounted, the first one keeps the key while the rest see it already handled.
|
|
65
|
+
const onShortcutKeyDown = useEffectEvent((event) => {
|
|
66
|
+
if (shortcutKey !== false && isSidebarShortcut(event, shortcutKey)) {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
toggleSidebar();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
61
71
|
// Adds a keyboard shortcut to toggle the sidebar.
|
|
62
72
|
useEffect(() => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
73
|
+
if (shortcutKey === false) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
window.addEventListener("keydown", onShortcutKeyDown);
|
|
70
77
|
return () => {
|
|
71
|
-
window.removeEventListener("keydown",
|
|
78
|
+
window.removeEventListener("keydown", onShortcutKeyDown);
|
|
72
79
|
};
|
|
73
|
-
}, [
|
|
80
|
+
}, [shortcutKey]);
|
|
74
81
|
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
75
82
|
// This makes it easier to style the sidebar with Tailwind classes.
|
|
76
83
|
const state = open ? "expanded" : "collapsed";
|
|
@@ -85,19 +92,19 @@ const SIDEBAR_NAME = "Sidebar";
|
|
|
85
92
|
/**
|
|
86
93
|
* @since 0.3.16-canary.0
|
|
87
94
|
*/
|
|
88
|
-
function Sidebar({ children, className, collapsible = "offcanvas", side = "left", variant = "sidebar", ...props }) {
|
|
95
|
+
function Sidebar({ children, className, collapsible = "offcanvas", mobileTitle = "Sidebar", side = "left", variant = "sidebar", ...props }) {
|
|
89
96
|
const { isMobile, openMobile, setOpenMobile, state } = useSidebar(SIDEBAR_NAME);
|
|
90
97
|
if (collapsible === "none") {
|
|
91
98
|
return (_jsx("div", { className: cn("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground", className), "data-slot": "sidebar", ...props, children: children }));
|
|
92
99
|
}
|
|
93
100
|
if (isMobile) {
|
|
94
|
-
return (_jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: _jsxs(SheetContent, { className: "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", "data-mobile": "true", "data-sidebar": "sidebar", "data-slot": "sidebar", side: side, style: {
|
|
101
|
+
return (_jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: _jsxs(SheetContent, { "aria-describedby": undefined, className: "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", "data-mobile": "true", "data-sidebar": "sidebar", "data-slot": "sidebar", side: side, style: {
|
|
95
102
|
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
96
|
-
}, children: [
|
|
103
|
+
}, children: [_jsx(SheetHeader, { className: "sr-only", children: _jsx(SheetTitle, { children: mobileTitle }) }), _jsx("div", { className: "flex h-full w-full flex-col", children: children })] }) }));
|
|
97
104
|
}
|
|
98
|
-
return (_jsxs("div", { className: cn("group peer hidden text-sidebar-foreground
|
|
105
|
+
return (_jsxs("div", { className: cn("group peer hidden text-sidebar-foreground sidebar:block", className), "data-collapsible": state === "collapsed" ? collapsible : "", "data-side": side, "data-slot": "sidebar", "data-state": state, "data-variant": variant, children: [_jsx("div", { className: cn("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-gentle group-data-[collapsible=offcanvas]:w-0 group-data-side-right:rotate-180", variant === "floating" || variant === "inset"
|
|
99
106
|
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
|
100
|
-
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"), "data-slot": "sidebar-gap" }), _jsx("div", { className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-gentle
|
|
107
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"), "data-slot": "sidebar-gap" }), _jsx("div", { className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-gentle sidebar:flex data-side-right:right-0 data-side-right:group-data-[collapsible=offcanvas]:-right-(--sidebar-width) data-side-left:left-0 data-side-left:group-data-[collapsible=offcanvas]:-left-(--sidebar-width)", variant === "floating" || variant === "inset"
|
|
101
108
|
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
|
102
109
|
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-side-right:border-l group-data-side-left:border-r", className), "data-side": side, "data-slot": "sidebar-container", ...props, children: _jsx("div", { className: "flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border", "data-sidebar": "sidebar", "data-slot": "sidebar-inner", children: children }) })] }));
|
|
103
110
|
}
|
|
@@ -120,13 +127,13 @@ const SIDEBAR_RAIL_NAME = "SidebarRail";
|
|
|
120
127
|
*/
|
|
121
128
|
function SidebarRail({ className, ...props }) {
|
|
122
129
|
const { toggleSidebar } = useSidebar(SIDEBAR_RAIL_NAME);
|
|
123
|
-
return (_jsx("button", { className: cn("absolute inset-y-0 z-20 hidden w-4 transition-all ease-gentle group-data-[collapsible=offcanvas]:translate-x-0 group-data-side-right:left-0 group-data-side-left:-right-4 after:absolute after:inset-y-0 after:inset-s-1/2 after:w-0.5 group-data-[collapsible=offcanvas]:after:start-full hover:group-data-[collapsible=offcanvas]:bg-sidebar hover:after:bg-sidebar-border in-data-side-right:cursor-e-resize in-data-side-left:cursor-w-resize
|
|
130
|
+
return (_jsx("button", { className: cn("absolute inset-y-0 z-20 hidden w-4 transition-all ease-gentle group-data-[collapsible=offcanvas]:translate-x-0 group-data-side-right:left-0 group-data-side-left:-right-4 after:absolute after:inset-y-0 after:inset-s-1/2 after:w-0.5 group-data-[collapsible=offcanvas]:after:start-full hover:group-data-[collapsible=offcanvas]:bg-sidebar hover:after:bg-sidebar-border in-data-side-right:cursor-e-resize in-data-side-left:cursor-w-resize sidebar:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2 rtl:group-data-[collapsible=offcanvas]:translate-x-0 rtl:in-data-side-right:cursor-w-resize rtl:in-data-side-left:cursor-e-resize [[data-side=left][data-collapsible=offcanvas]_&]:-right-2 [[data-side=left][data-state=collapsed]_&]:cursor-e-resize rtl:[[data-side=left][data-state=collapsed]_&]:cursor-w-resize [[data-side=right][data-collapsible=offcanvas]_&]:-left-2 [[data-side=right][data-state=collapsed]_&]:cursor-w-resize rtl:[[data-side=right][data-state=collapsed]_&]:cursor-e-resize", className), "data-sidebar": "rail", "data-slot": "sidebar-rail", title: "Toggle Sidebar", type: "button", onClick: toggleSidebar, ...props }));
|
|
124
131
|
}
|
|
125
132
|
/**
|
|
126
133
|
* @since 0.3.16-canary.0
|
|
127
134
|
*/
|
|
128
135
|
function SidebarInset({ className, ...props }) {
|
|
129
|
-
return (_jsx("main", { className: cn("relative flex w-full flex-1 flex-col bg-background
|
|
136
|
+
return (_jsx("main", { className: cn("relative flex w-full flex-1 flex-col bg-background sidebar:peer-data-[variant=inset]:m-2 sidebar:peer-data-[variant=inset]:ms-0 sidebar:peer-data-[variant=inset]:rounded-xl sidebar:peer-data-[variant=inset]:shadow-sm sidebar:peer-data-[variant=inset]:peer-data-collapsed:ms-2", className), "data-slot": "sidebar-inset", ...props }));
|
|
130
137
|
}
|
|
131
138
|
/**
|
|
132
139
|
* @since 0.3.16-canary.0
|
|
@@ -176,7 +183,7 @@ function SidebarGroupLabel({ asChild = false, className, ...props }) {
|
|
|
176
183
|
*/
|
|
177
184
|
function SidebarGroupAction({ asChild = false, className, ...props }) {
|
|
178
185
|
const Component = asChild ? Slot.Root : "button";
|
|
179
|
-
return (_jsx(Component, { className: cn("absolute inset-e-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2
|
|
186
|
+
return (_jsx(Component, { className: cn("absolute inset-e-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 sidebar:after:hidden [&>svg]:size-4 [&>svg]:shrink-0", className), "data-sidebar": "group-action", "data-slot": "sidebar-group-action", ...props }));
|
|
180
187
|
}
|
|
181
188
|
/**
|
|
182
189
|
* @since 0.3.16-canary.0
|
|
@@ -220,8 +227,8 @@ function SidebarMenuButton({ asChild = false, className, isActive = false, size
|
|
|
220
227
|
*/
|
|
221
228
|
function SidebarMenuAction({ asChild = false, className, showOnHover = false, ...props }) {
|
|
222
229
|
const Component = asChild ? Slot.Root : "button";
|
|
223
|
-
return (_jsx(Component, { className: cn("absolute inset-e-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2
|
|
224
|
-
"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100
|
|
230
|
+
return (_jsx(Component, { className: cn("absolute inset-e-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 sidebar:after:hidden [&>svg]:size-4 [&>svg]:shrink-0", showOnHover &&
|
|
231
|
+
"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 sidebar:opacity-0", className), "data-sidebar": "menu-action", "data-slot": "sidebar-menu-action", ...props }));
|
|
225
232
|
}
|
|
226
233
|
/**
|
|
227
234
|
* @since 0.3.16-canary.0
|
|
@@ -263,5 +270,32 @@ function SidebarMenuSubButton({ asChild = false, className, isActive = false, si
|
|
|
263
270
|
const Component = asChild ? Slot.Root : "a";
|
|
264
271
|
return (_jsx(Component, { className: cn("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs rtl:translate-x-px data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", className), "data-active": isActive, "data-sidebar": "menu-sub-button", "data-size": size, "data-slot": "sidebar-menu-sub-button", ...props }));
|
|
265
272
|
}
|
|
273
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
274
|
+
// The sheet takes over below the preset's `sidebar:` breakpoint, so JS matches the value that CSS resolved.
|
|
275
|
+
function useIsBelowSidebarBreakpoint() {
|
|
276
|
+
const [breakpoint] = useState(readSidebarBreakpoint);
|
|
277
|
+
return useMediaQuery(`(width < ${breakpoint})`);
|
|
278
|
+
}
|
|
279
|
+
function readSidebarBreakpoint() {
|
|
280
|
+
if (typeof document === "undefined") {
|
|
281
|
+
return SIDEBAR_BREAKPOINT_FALLBACK;
|
|
282
|
+
}
|
|
283
|
+
const breakpoint = getComputedStyle(document.documentElement).getPropertyValue("--sidebar-breakpoint").trim();
|
|
284
|
+
return breakpoint === "" ? SIDEBAR_BREAKPOINT_FALLBACK : breakpoint;
|
|
285
|
+
}
|
|
286
|
+
// Leaves the key to a handler that already took it, to an IME mid-composition, and to fields where it edits text.
|
|
287
|
+
function isSidebarShortcut(event, shortcutKey) {
|
|
288
|
+
if (event.defaultPrevented ||
|
|
289
|
+
event.isComposing ||
|
|
290
|
+
event.repeat ||
|
|
291
|
+
event.altKey ||
|
|
292
|
+
event.shiftKey ||
|
|
293
|
+
!(event.metaKey || event.ctrlKey) ||
|
|
294
|
+
event.key.toLowerCase() !== shortcutKey.toLowerCase()) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
const target = event.composedPath()[0];
|
|
298
|
+
return !(target instanceof HTMLElement && (target.isContentEditable || target.matches("input, select, textarea")));
|
|
299
|
+
}
|
|
266
300
|
// ── Exports ──────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
267
301
|
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Subscribes to a CSS media query and returns whether it matches.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Reports `false` during SSR and hydration, so the first client render matches the server markup, then the live
|
|
5
|
+
* match state, updating whenever the query flips.
|
|
6
6
|
*
|
|
7
7
|
* @param query - A valid media query string (e.g., "(max-width: 768px)").
|
|
8
8
|
* @returns true when the media query currently matches; otherwise false.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useSyncExternalStore } from "react";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Subscribes to a CSS media query and returns whether it matches.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Reports `false` during SSR and hydration, so the first client render matches the server markup, then the live
|
|
6
|
+
* match state, updating whenever the query flips.
|
|
7
7
|
*
|
|
8
8
|
* @param query - A valid media query string (e.g., "(max-width: 768px)").
|
|
9
9
|
* @returns true when the media query currently matches; otherwise false.
|
|
@@ -16,39 +16,22 @@ import { useEffect, useState } from "react";
|
|
|
16
16
|
* @since 0.3.16-canary.0
|
|
17
17
|
*/
|
|
18
18
|
export function useMediaQuery(query) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
const [matches, setMatches] = useState(() => {
|
|
24
|
-
// Ensure initial state matches current media query status
|
|
25
|
-
if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
|
|
26
|
-
return window.matchMedia(query).matches;
|
|
19
|
+
const subscribe = useCallback((onChange) => {
|
|
20
|
+
if (!canMatchMedia()) {
|
|
21
|
+
return () => { };
|
|
27
22
|
}
|
|
28
|
-
return false;
|
|
29
|
-
});
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
// Only run in a browser environment where matchMedia is available
|
|
32
|
-
if (typeof window === "undefined") {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* MediaQueryList to evaluate and observe the provided query.
|
|
37
|
-
*/
|
|
38
23
|
const mediaQueryList = window.matchMedia(query);
|
|
39
|
-
/**
|
|
40
|
-
* Update state when the media query status changes.
|
|
41
|
-
*/
|
|
42
|
-
const onChange = (event) => {
|
|
43
|
-
setMatches(event.matches);
|
|
44
|
-
};
|
|
45
24
|
mediaQueryList.addEventListener("change", onChange);
|
|
46
|
-
/**
|
|
47
|
-
* Removes the event listener on unmount or when the query changes.
|
|
48
|
-
*/
|
|
49
25
|
return () => {
|
|
50
26
|
mediaQueryList.removeEventListener("change", onChange);
|
|
51
27
|
};
|
|
52
28
|
}, [query]);
|
|
53
|
-
|
|
29
|
+
const getSnapshot = useCallback(() => canMatchMedia() && window.matchMedia(query).matches, [query]);
|
|
30
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
31
|
+
}
|
|
32
|
+
function getServerSnapshot() {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
function canMatchMedia() {
|
|
36
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function";
|
|
54
37
|
}
|
|
@@ -20,11 +20,7 @@ interface InputNumberProps extends ComponentProps<typeof InputPrimitive.Root> {
|
|
|
20
20
|
/**
|
|
21
21
|
* Accessible label for the decrement button
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Accessible label for the increment button
|
|
26
|
-
*/
|
|
27
|
-
ariaIncrementLabel?: string;
|
|
23
|
+
decrementLabel?: string;
|
|
28
24
|
/**
|
|
29
25
|
* Initial value when uncontrolled
|
|
30
26
|
*/
|
|
@@ -37,6 +33,10 @@ interface InputNumberProps extends ComponentProps<typeof InputPrimitive.Root> {
|
|
|
37
33
|
* Unique identifier for the input
|
|
38
34
|
*/
|
|
39
35
|
id?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Accessible label for the increment button
|
|
38
|
+
*/
|
|
39
|
+
incrementLabel?: string;
|
|
40
40
|
/**
|
|
41
41
|
* Locale used for number formatting
|
|
42
42
|
*/
|
|
@@ -19,7 +19,7 @@ const [InputNumberContextProvider, useInputNumberContext] = createInputNumberCon
|
|
|
19
19
|
* @since 0.3.16-canary.0
|
|
20
20
|
*/
|
|
21
21
|
function InputNumber(numberInputProps) {
|
|
22
|
-
const { __scopeInputNumber,
|
|
22
|
+
const { __scopeInputNumber, decrementLabel, defaultValue, formatOptions = { minimumFractionDigits: 0, style: "decimal" }, id, incrementLabel, locale, max, min, onChange, step = 1, value: valueProperty, ...props } = numberInputProps;
|
|
23
23
|
/**
|
|
24
24
|
* Context.Scope for the input component
|
|
25
25
|
*/
|
|
@@ -116,7 +116,7 @@ function InputNumber(numberInputProps) {
|
|
|
116
116
|
const handleDecrementToMin = useCallback(() => {
|
|
117
117
|
changeNumberValue((number) => min ?? number - step);
|
|
118
118
|
}, [changeNumberValue, min, step]);
|
|
119
|
-
return (_jsx(InputNumberContextProvider, {
|
|
119
|
+
return (_jsx(InputNumberContextProvider, { decrementLabel: decrementLabel, defaultValue: defaultValue, disabled: props.disabled, formatOptions: stableFormatOptions, formatValue: formatValue, id: id, incrementLabel: incrementLabel, inputRef: inputRef, max: max, min: min, parseValue: parseValue, readOnly: props.readOnly, scope: __scopeInputNumber, value: value, onChange: setValue, onDecrement: handleDecrement, onDecrementToMin: handleDecrementToMin, onIncrement: handleIncrement, onIncrementToMax: handleIncrementToMax, children: _jsx(InputPrimitive.Root, { ...inputScope, ...props }) }));
|
|
120
120
|
}
|
|
121
121
|
// ── Component: InputNumberField ──────────────────────────────────────────────────────────────────────────────────────
|
|
122
122
|
/**
|
|
@@ -320,7 +320,7 @@ function InputNumberField({ __scopeInputNumber, onBlur, onKeyDown, ...props }) {
|
|
|
320
320
|
const NUMBER_STEPPER_BUTTON_NAME = "NumberStepperButton";
|
|
321
321
|
function NumberStepperButton({ __scopeInputNumber, operation, ...props }) {
|
|
322
322
|
// Destructures relevant context values for the button functionality.
|
|
323
|
-
const {
|
|
323
|
+
const { decrementLabel, disabled, id, incrementLabel, max, min, onDecrement, onIncrement, value } = useInputNumberContext(NUMBER_STEPPER_BUTTON_NAME, __scopeInputNumber);
|
|
324
324
|
const isDisabled = useMemo(() => {
|
|
325
325
|
if (disabled) {
|
|
326
326
|
return true;
|
|
@@ -397,7 +397,7 @@ function NumberStepperButton({ __scopeInputNumber, operation, ...props }) {
|
|
|
397
397
|
action();
|
|
398
398
|
}
|
|
399
399
|
}, [onDecrement, onIncrement, operation]);
|
|
400
|
-
return (_jsx("button", { "aria-controls": id, "aria-label": operation === "increment" ?
|
|
400
|
+
return (_jsx("button", { "aria-controls": id, "aria-label": operation === "increment" ? incrementLabel : decrementLabel, disabled: isDisabled, type: "button", onContextMenu: handleContextMenu, onKeyDown: handleKeyDown, onPointerCancel: clearActionInterval, onPointerDown: handlePointerDown, onPointerLeave: clearActionInterval, onPointerUp: clearActionInterval, ...props }));
|
|
401
401
|
}
|
|
402
402
|
/**
|
|
403
403
|
* @since 0.3.16-canary.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Core UI components library built with React and Tailwind CSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -488,16 +488,16 @@
|
|
|
488
488
|
"access": "public"
|
|
489
489
|
},
|
|
490
490
|
"dependencies": {
|
|
491
|
-
"@codefast/tailwind-variants": "0.
|
|
491
|
+
"@codefast/tailwind-variants": "0.9.0",
|
|
492
492
|
"@daypicker/react": "^10.0.1",
|
|
493
493
|
"cmdk": "^1.1.1",
|
|
494
494
|
"embla-carousel-react": "^8.6.0",
|
|
495
495
|
"input-otp": "^1.5.0",
|
|
496
|
-
"lucide-react": "^1.
|
|
496
|
+
"lucide-react": "^1.48.0",
|
|
497
497
|
"next-themes": "^0.4.6",
|
|
498
498
|
"radix-ui": "^1.6.7",
|
|
499
499
|
"react-hook-form": "^7.88.0",
|
|
500
|
-
"react-resizable-panels": "^4.
|
|
500
|
+
"react-resizable-panels": "^4.13.3",
|
|
501
501
|
"recharts": "^3.10.1",
|
|
502
502
|
"sonner": "^2.0.8",
|
|
503
503
|
"tailwind-merge": "^3.7.0",
|
|
@@ -519,6 +519,6 @@
|
|
|
519
519
|
}
|
|
520
520
|
},
|
|
521
521
|
"engines": {
|
|
522
|
-
"node": ">=
|
|
522
|
+
"node": ">=24.0.0"
|
|
523
523
|
}
|
|
524
524
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/* -------------------------------------------------------------------------
|
|
2
2
|
* Source
|
|
3
3
|
*
|
|
4
|
-
* Third-party imports and the Tailwind content
|
|
5
|
-
*
|
|
4
|
+
* Third-party imports and the Tailwind content sources scanned for the
|
|
5
|
+
* class names the components use.
|
|
6
6
|
* ------------------------------------------------------------------------- */
|
|
7
7
|
|
|
8
8
|
@import "tw-animate-css";
|
|
9
9
|
|
|
10
|
+
/* Workspace apps read `src` in dev, through the `source` export condition. */
|
|
10
11
|
@source "../../**/*.{ts,tsx}";
|
|
12
|
+
|
|
13
|
+
/* Consumers read `dist`: the published tarball ships no `src` beyond `src/css`. */
|
|
14
|
+
@source "../../../dist/**/*.js";
|
|
@@ -27,6 +27,19 @@
|
|
|
27
27
|
@custom-variant data-side-bottom (&:where([data-side="bottom"]));
|
|
28
28
|
@custom-variant data-side-left (&:where([data-side="left"]));
|
|
29
29
|
|
|
30
|
+
/* ── Layout — sidebar breakpoint ─────────────────────────────────────────────────────────────────────────────────── */
|
|
31
|
+
|
|
32
|
+
/* Mints the `sidebar:` variant: the width from which `Sidebar` docks instead of opening as a sheet. An app moves it
|
|
33
|
+
with its own `@theme { --breakpoint-sidebar: … }`, placed before or after this preset. */
|
|
34
|
+
@theme default {
|
|
35
|
+
--breakpoint-sidebar: 48rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* The resolved breakpoint, which `SidebarProvider` reads to match the same media query in JS. */
|
|
39
|
+
:root {
|
|
40
|
+
--sidebar-breakpoint: --theme(--breakpoint-sidebar inline);
|
|
41
|
+
}
|
|
42
|
+
|
|
30
43
|
/* -------------------------------------------------------------------------
|
|
31
44
|
* State — boolean & Radix data-state
|
|
32
45
|
*
|