jaci-ui 0.4.0 → 0.6.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/CHANGELOG.md +14 -0
- package/README.md +68 -0
- package/dist/components/command/command.cjs +55 -34
- package/dist/components/command/command.cjs.map +1 -1
- package/dist/components/command/command.d.cts +1 -0
- package/dist/components/command/command.d.ts +1 -0
- package/dist/components/command/command.js +55 -34
- package/dist/components/command/command.js.map +1 -1
- package/dist/components/data-toolbar/data-toolbar.cjs +141 -0
- package/dist/components/data-toolbar/data-toolbar.cjs.map +1 -0
- package/dist/components/data-toolbar/data-toolbar.d.cts +50 -0
- package/dist/components/data-toolbar/data-toolbar.d.ts +50 -0
- package/dist/components/data-toolbar/data-toolbar.js +132 -0
- package/dist/components/data-toolbar/data-toolbar.js.map +1 -0
- package/dist/components/data-toolbar/index.d.cts +2 -0
- package/dist/components/data-toolbar/index.d.ts +2 -0
- package/dist/components/data-view/data-view.cjs +33 -1
- package/dist/components/data-view/data-view.cjs.map +1 -1
- package/dist/components/data-view/data-view.d.cts +12 -1
- package/dist/components/data-view/data-view.d.ts +12 -1
- package/dist/components/data-view/data-view.js +31 -2
- package/dist/components/data-view/data-view.js.map +1 -1
- package/dist/components/data-view/index.d.cts +2 -2
- package/dist/components/data-view/index.d.ts +2 -2
- package/dist/components/list/list.cjs +3 -1
- package/dist/components/list/list.cjs.map +1 -1
- package/dist/components/list/list.d.cts +3 -1
- package/dist/components/list/list.d.ts +3 -1
- package/dist/components/list/list.js +3 -1
- package/dist/components/list/list.js.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.cjs +3 -3
- package/dist/components/navigation-menu/navigation-menu.cjs.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.js +3 -3
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/pagination/index.d.cts +2 -2
- package/dist/components/pagination/index.d.ts +2 -2
- package/dist/components/pagination/pagination.cjs +122 -21
- package/dist/components/pagination/pagination.cjs.map +1 -1
- package/dist/components/pagination/pagination.d.cts +25 -13
- package/dist/components/pagination/pagination.d.ts +25 -13
- package/dist/components/pagination/pagination.js +122 -23
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/sidebar/sidebar.cjs +59 -11
- package/dist/components/sidebar/sidebar.cjs.map +1 -1
- package/dist/components/sidebar/sidebar.d.cts +13 -0
- package/dist/components/sidebar/sidebar.d.ts +13 -0
- package/dist/components/sidebar/sidebar.js +59 -13
- package/dist/components/sidebar/sidebar.js.map +1 -1
- package/dist/components/stepper/index.d.cts +2 -0
- package/dist/components/stepper/index.d.ts +2 -0
- package/dist/components/stepper/stepper.cjs +341 -0
- package/dist/components/stepper/stepper.cjs.map +1 -0
- package/dist/components/stepper/stepper.d.cts +52 -0
- package/dist/components/stepper/stepper.d.ts +52 -0
- package/dist/components/stepper/stepper.js +330 -0
- package/dist/components/stepper/stepper.js.map +1 -0
- package/dist/components/table/index.d.cts +2 -2
- package/dist/components/table/index.d.ts +2 -2
- package/dist/components/table/table.cjs +265 -46
- package/dist/components/table/table.cjs.map +1 -1
- package/dist/components/table/table.d.cts +41 -8
- package/dist/components/table/table.d.ts +41 -8
- package/dist/components/table/table.js +264 -48
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/toast/toast.cjs +3 -1
- package/dist/components/toast/toast.cjs.map +1 -1
- package/dist/components/toast/toast.js +3 -1
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/tree-view/index.d.cts +2 -2
- package/dist/components/tree-view/index.d.ts +2 -2
- package/dist/components/tree-view/tree-view.cjs +60 -3
- package/dist/components/tree-view/tree-view.cjs.map +1 -1
- package/dist/components/tree-view/tree-view.d.cts +12 -1
- package/dist/components/tree-view/tree-view.d.ts +12 -1
- package/dist/components/tree-view/tree-view.js +58 -4
- package/dist/components/tree-view/tree-view.js.map +1 -1
- package/dist/index.cjs +35 -0
- package/dist/index.d.cts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +7 -5
- package/dist/styled-system/recipes/data-toolbar.cjs +40 -0
- package/dist/styled-system/recipes/data-toolbar.cjs.map +1 -0
- package/dist/styled-system/recipes/data-toolbar.js +40 -0
- package/dist/styled-system/recipes/data-toolbar.js.map +1 -0
- package/dist/styled-system/recipes/data-view.cjs +3 -0
- package/dist/styled-system/recipes/data-view.cjs.map +1 -1
- package/dist/styled-system/recipes/data-view.js +3 -0
- package/dist/styled-system/recipes/data-view.js.map +1 -1
- package/dist/styled-system/recipes/list.cjs +7 -1
- package/dist/styled-system/recipes/list.cjs.map +1 -1
- package/dist/styled-system/recipes/list.js +7 -1
- package/dist/styled-system/recipes/list.js.map +1 -1
- package/dist/styled-system/recipes/pagination.cjs +9 -1
- package/dist/styled-system/recipes/pagination.cjs.map +1 -1
- package/dist/styled-system/recipes/pagination.js +9 -1
- package/dist/styled-system/recipes/pagination.js.map +1 -1
- package/dist/styled-system/recipes/sidebar.cjs +3 -0
- package/dist/styled-system/recipes/sidebar.cjs.map +1 -1
- package/dist/styled-system/recipes/sidebar.js +3 -0
- package/dist/styled-system/recipes/sidebar.js.map +1 -1
- package/dist/styled-system/recipes/stepper.cjs +53 -0
- package/dist/styled-system/recipes/stepper.cjs.map +1 -0
- package/dist/styled-system/recipes/stepper.js +53 -0
- package/dist/styled-system/recipes/stepper.js.map +1 -0
- package/dist/styled-system/recipes/table.cjs +15 -2
- package/dist/styled-system/recipes/table.cjs.map +1 -1
- package/dist/styled-system/recipes/table.js +15 -2
- package/dist/styled-system/recipes/table.js.map +1 -1
- package/dist/styled-system/recipes/tree-view.cjs +4 -1
- package/dist/styled-system/recipes/tree-view.cjs.map +1 -1
- package/dist/styled-system/recipes/tree-view.js +4 -1
- package/dist/styled-system/recipes/tree-view.js.map +1 -1
- package/dist/styles.css +602 -18
- package/package.json +1 -1
|
@@ -1,44 +1,56 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
2
|
//#region src/components/pagination/pagination.d.ts
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type PaginationDensity = "compact" | "comfortable";
|
|
4
|
+
interface PaginationRootProps extends Omit<ComponentPropsWithoutRef<"nav">, "children"> {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
defaultPage?: number;
|
|
7
|
+
density?: PaginationDensity;
|
|
8
|
+
onPageChange?: (page: number) => void;
|
|
9
|
+
page?: number;
|
|
10
|
+
pageCount?: number;
|
|
11
|
+
showFirstLast?: boolean;
|
|
12
|
+
siblingCount?: number;
|
|
13
|
+
}
|
|
14
|
+
declare const PaginationRoot: import("react").ForwardRefExoticComponent<PaginationRootProps & import("react").RefAttributes<HTMLElement>>;
|
|
6
15
|
type PaginationListProps = ComponentPropsWithoutRef<"ul">;
|
|
7
|
-
/** An unordered list of page controls. */
|
|
8
16
|
declare const PaginationList: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
|
|
9
17
|
type PaginationItemProps = ComponentPropsWithoutRef<"li">;
|
|
10
|
-
/** A list item that wraps a page link, direction control, or ellipsis. */
|
|
11
18
|
declare const PaginationItem: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
12
19
|
interface PaginationLinkProps extends ComponentPropsWithoutRef<"a"> {
|
|
13
|
-
/** Marks the link as the current page. */
|
|
14
20
|
active?: boolean;
|
|
15
|
-
/** Presents a non-navigable control when no destination is available. */
|
|
16
21
|
disabled?: boolean;
|
|
22
|
+
page?: number | undefined;
|
|
17
23
|
}
|
|
18
|
-
/** A link to a numbered page. Set `active` on the current destination. */
|
|
19
24
|
declare const PaginationLink: import("react").ForwardRefExoticComponent<PaginationLinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
20
25
|
interface PaginationPreviousProps extends PaginationLinkProps {
|
|
21
26
|
children?: ReactNode;
|
|
22
27
|
}
|
|
23
|
-
/** A directional link to the preceding page. */
|
|
24
28
|
declare const PaginationPrevious: import("react").ForwardRefExoticComponent<PaginationPreviousProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
25
29
|
interface PaginationNextProps extends PaginationLinkProps {
|
|
26
30
|
children?: ReactNode;
|
|
27
31
|
}
|
|
28
|
-
/** A directional link to the following page. */
|
|
29
32
|
declare const PaginationNext: import("react").ForwardRefExoticComponent<PaginationNextProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
33
|
+
interface PaginationFirstProps extends PaginationLinkProps {
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
declare const PaginationFirst: import("react").ForwardRefExoticComponent<PaginationFirstProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
37
|
+
interface PaginationLastProps extends PaginationLinkProps {
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
declare const PaginationLast: import("react").ForwardRefExoticComponent<PaginationLastProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
30
41
|
type PaginationEllipsisProps = ComponentPropsWithoutRef<"span">;
|
|
31
|
-
/** A non-interactive marker for omitted page ranges. */
|
|
32
42
|
declare const PaginationEllipsis: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
33
43
|
declare const Pagination: {
|
|
34
|
-
Root: import("react").ForwardRefExoticComponent<
|
|
44
|
+
Root: import("react").ForwardRefExoticComponent<PaginationRootProps & import("react").RefAttributes<HTMLElement>>;
|
|
35
45
|
List: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
|
|
36
46
|
Item: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
37
47
|
Link: import("react").ForwardRefExoticComponent<PaginationLinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
48
|
+
First: import("react").ForwardRefExoticComponent<PaginationFirstProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
38
49
|
Previous: import("react").ForwardRefExoticComponent<PaginationPreviousProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
39
50
|
Next: import("react").ForwardRefExoticComponent<PaginationNextProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
51
|
+
Last: import("react").ForwardRefExoticComponent<PaginationLastProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
40
52
|
Ellipsis: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
41
53
|
};
|
|
42
54
|
//#endregion
|
|
43
|
-
export { Pagination, PaginationEllipsis, PaginationEllipsisProps, PaginationItem, PaginationItemProps, PaginationLink, PaginationLinkProps, PaginationList, PaginationListProps, PaginationNext, PaginationNextProps, PaginationPrevious, PaginationPreviousProps, PaginationRoot, PaginationRootProps };
|
|
55
|
+
export { Pagination, PaginationDensity, PaginationEllipsis, PaginationEllipsisProps, PaginationFirst, PaginationFirstProps, PaginationItem, PaginationItemProps, PaginationLast, PaginationLastProps, PaginationLink, PaginationLinkProps, PaginationList, PaginationListProps, PaginationNext, PaginationNextProps, PaginationPrevious, PaginationPreviousProps, PaginationRoot, PaginationRootProps };
|
|
44
56
|
//# sourceMappingURL=pagination.d.cts.map
|
|
@@ -1,44 +1,56 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
2
|
//#region src/components/pagination/pagination.d.ts
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type PaginationDensity = "compact" | "comfortable";
|
|
4
|
+
interface PaginationRootProps extends Omit<ComponentPropsWithoutRef<"nav">, "children"> {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
defaultPage?: number;
|
|
7
|
+
density?: PaginationDensity;
|
|
8
|
+
onPageChange?: (page: number) => void;
|
|
9
|
+
page?: number;
|
|
10
|
+
pageCount?: number;
|
|
11
|
+
showFirstLast?: boolean;
|
|
12
|
+
siblingCount?: number;
|
|
13
|
+
}
|
|
14
|
+
declare const PaginationRoot: import("react").ForwardRefExoticComponent<PaginationRootProps & import("react").RefAttributes<HTMLElement>>;
|
|
6
15
|
type PaginationListProps = ComponentPropsWithoutRef<"ul">;
|
|
7
|
-
/** An unordered list of page controls. */
|
|
8
16
|
declare const PaginationList: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
|
|
9
17
|
type PaginationItemProps = ComponentPropsWithoutRef<"li">;
|
|
10
|
-
/** A list item that wraps a page link, direction control, or ellipsis. */
|
|
11
18
|
declare const PaginationItem: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
12
19
|
interface PaginationLinkProps extends ComponentPropsWithoutRef<"a"> {
|
|
13
|
-
/** Marks the link as the current page. */
|
|
14
20
|
active?: boolean;
|
|
15
|
-
/** Presents a non-navigable control when no destination is available. */
|
|
16
21
|
disabled?: boolean;
|
|
22
|
+
page?: number | undefined;
|
|
17
23
|
}
|
|
18
|
-
/** A link to a numbered page. Set `active` on the current destination. */
|
|
19
24
|
declare const PaginationLink: import("react").ForwardRefExoticComponent<PaginationLinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
20
25
|
interface PaginationPreviousProps extends PaginationLinkProps {
|
|
21
26
|
children?: ReactNode;
|
|
22
27
|
}
|
|
23
|
-
/** A directional link to the preceding page. */
|
|
24
28
|
declare const PaginationPrevious: import("react").ForwardRefExoticComponent<PaginationPreviousProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
25
29
|
interface PaginationNextProps extends PaginationLinkProps {
|
|
26
30
|
children?: ReactNode;
|
|
27
31
|
}
|
|
28
|
-
/** A directional link to the following page. */
|
|
29
32
|
declare const PaginationNext: import("react").ForwardRefExoticComponent<PaginationNextProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
33
|
+
interface PaginationFirstProps extends PaginationLinkProps {
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
declare const PaginationFirst: import("react").ForwardRefExoticComponent<PaginationFirstProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
37
|
+
interface PaginationLastProps extends PaginationLinkProps {
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
declare const PaginationLast: import("react").ForwardRefExoticComponent<PaginationLastProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
30
41
|
type PaginationEllipsisProps = ComponentPropsWithoutRef<"span">;
|
|
31
|
-
/** A non-interactive marker for omitted page ranges. */
|
|
32
42
|
declare const PaginationEllipsis: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
33
43
|
declare const Pagination: {
|
|
34
|
-
Root: import("react").ForwardRefExoticComponent<
|
|
44
|
+
Root: import("react").ForwardRefExoticComponent<PaginationRootProps & import("react").RefAttributes<HTMLElement>>;
|
|
35
45
|
List: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
|
|
36
46
|
Item: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
37
47
|
Link: import("react").ForwardRefExoticComponent<PaginationLinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
48
|
+
First: import("react").ForwardRefExoticComponent<PaginationFirstProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
38
49
|
Previous: import("react").ForwardRefExoticComponent<PaginationPreviousProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
39
50
|
Next: import("react").ForwardRefExoticComponent<PaginationNextProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
51
|
+
Last: import("react").ForwardRefExoticComponent<PaginationLastProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
40
52
|
Ellipsis: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
41
53
|
};
|
|
42
54
|
//#endregion
|
|
43
|
-
export { Pagination, PaginationEllipsis, PaginationEllipsisProps, PaginationItem, PaginationItemProps, PaginationLink, PaginationLinkProps, PaginationList, PaginationListProps, PaginationNext, PaginationNextProps, PaginationPrevious, PaginationPreviousProps, PaginationRoot, PaginationRootProps };
|
|
55
|
+
export { Pagination, PaginationDensity, PaginationEllipsis, PaginationEllipsisProps, PaginationFirst, PaginationFirstProps, PaginationItem, PaginationItemProps, PaginationLast, PaginationLastProps, PaginationLink, PaginationLinkProps, PaginationList, PaginationListProps, PaginationNext, PaginationNextProps, PaginationPrevious, PaginationPreviousProps, PaginationRoot, PaginationRootProps };
|
|
44
56
|
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -1,29 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { cx } from "../../styled-system/css/cx.js";
|
|
2
3
|
import { pagination } from "../../styled-system/recipes/pagination.js";
|
|
3
|
-
import { forwardRef } from "react";
|
|
4
|
+
import { createContext, forwardRef, useCallback, useContext, useMemo, useState } from "react";
|
|
4
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
//#region src/components/pagination/pagination.tsx
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const PaginationContext = createContext(null);
|
|
8
|
+
function usePaginationContext() {
|
|
9
|
+
return useContext(PaginationContext);
|
|
10
|
+
}
|
|
11
|
+
const PaginationRoot = forwardRef(function PaginationRoot({ children, "aria-label": ariaLabel, className, defaultPage = 1, density = "comfortable", onPageChange, page: controlledPage, pageCount, showFirstLast = false, siblingCount = 1, ...props }, ref) {
|
|
12
|
+
const [uncontrolledPage, setUncontrolledPage] = useState(defaultPage);
|
|
13
|
+
const page = pageCount ? Math.min(Math.max(controlledPage ?? uncontrolledPage, 1), pageCount) : controlledPage;
|
|
14
|
+
const goTo = useCallback((nextPage) => {
|
|
15
|
+
if (!pageCount) return;
|
|
16
|
+
const next = Math.min(Math.max(nextPage, 1), pageCount);
|
|
17
|
+
if (controlledPage === void 0) setUncontrolledPage(next);
|
|
18
|
+
onPageChange?.(next);
|
|
19
|
+
}, [
|
|
20
|
+
controlledPage,
|
|
21
|
+
onPageChange,
|
|
22
|
+
pageCount
|
|
23
|
+
]);
|
|
24
|
+
const context = useMemo(() => ({
|
|
25
|
+
density,
|
|
26
|
+
goTo,
|
|
27
|
+
page,
|
|
28
|
+
pageCount
|
|
29
|
+
}), [
|
|
30
|
+
density,
|
|
31
|
+
goTo,
|
|
32
|
+
page,
|
|
33
|
+
pageCount
|
|
34
|
+
]);
|
|
35
|
+
return /* @__PURE__ */ jsx(PaginationContext.Provider, {
|
|
36
|
+
value: context,
|
|
37
|
+
children: /* @__PURE__ */ jsx("nav", {
|
|
38
|
+
...props,
|
|
39
|
+
"aria-label": ariaLabel ?? "Pagination",
|
|
40
|
+
ref,
|
|
41
|
+
className: cx(pagination({ density }).root, className),
|
|
42
|
+
"data-density": density,
|
|
43
|
+
"data-jaci-component": "pagination",
|
|
44
|
+
"data-slot": "pagination",
|
|
45
|
+
children: children ?? (pageCount ? /* @__PURE__ */ jsx(PaginationGenerated, {
|
|
46
|
+
page: page ?? 1,
|
|
47
|
+
pageCount,
|
|
48
|
+
showFirstLast,
|
|
49
|
+
siblingCount
|
|
50
|
+
}) : null)
|
|
51
|
+
})
|
|
15
52
|
});
|
|
16
53
|
});
|
|
17
|
-
/** An unordered list of page controls. */
|
|
18
54
|
const PaginationList = forwardRef(function PaginationList({ className, ...props }, ref) {
|
|
55
|
+
const context = usePaginationContext();
|
|
19
56
|
return /* @__PURE__ */ jsx("ul", {
|
|
20
57
|
...props,
|
|
21
58
|
ref,
|
|
22
|
-
className: cx(pagination().list, className),
|
|
59
|
+
className: cx(pagination({ density: context?.density }).list, className),
|
|
23
60
|
"data-slot": "pagination-list"
|
|
24
61
|
});
|
|
25
62
|
});
|
|
26
|
-
/** A list item that wraps a page link, direction control, or ellipsis. */
|
|
27
63
|
const PaginationItem = forwardRef(function PaginationItem({ className, ...props }, ref) {
|
|
28
64
|
return /* @__PURE__ */ jsx("li", {
|
|
29
65
|
...props,
|
|
@@ -32,24 +68,31 @@ const PaginationItem = forwardRef(function PaginationItem({ className, ...props
|
|
|
32
68
|
"data-slot": "pagination-item"
|
|
33
69
|
});
|
|
34
70
|
});
|
|
35
|
-
function getAnchorClassName(active, disabled, slot) {
|
|
71
|
+
function getAnchorClassName(active, disabled, density, slot) {
|
|
36
72
|
const styles = pagination({
|
|
37
73
|
active,
|
|
74
|
+
density,
|
|
38
75
|
disabled
|
|
39
76
|
});
|
|
40
77
|
if (slot === "pagination-previous") return cx(styles.link, styles.previous);
|
|
41
78
|
if (slot === "pagination-next") return cx(styles.link, styles.next);
|
|
79
|
+
if (slot === "pagination-first") return cx(styles.link, styles.first);
|
|
80
|
+
if (slot === "pagination-last") return cx(styles.link, styles.last);
|
|
42
81
|
return styles.link;
|
|
43
82
|
}
|
|
44
|
-
const PaginationAnchor = forwardRef(function PaginationAnchor({ active
|
|
83
|
+
const PaginationAnchor = forwardRef(function PaginationAnchor({ active: activeProp, "aria-current": ariaCurrent, className, disabled: disabledProp = false, href, onClick, page, slot, tabIndex, ...props }, ref) {
|
|
84
|
+
const context = usePaginationContext();
|
|
85
|
+
const active = activeProp ?? (page !== void 0 && context?.page === page);
|
|
86
|
+
const disabled = Boolean(disabledProp || page !== void 0 && context?.pageCount === 1);
|
|
45
87
|
return /* @__PURE__ */ jsx("a", {
|
|
46
88
|
...props,
|
|
47
89
|
"aria-current": ariaCurrent ?? (active ? "page" : void 0),
|
|
48
90
|
"aria-disabled": disabled || void 0,
|
|
49
91
|
ref,
|
|
50
|
-
className: cx(getAnchorClassName(active, disabled, slot), className),
|
|
92
|
+
className: cx(getAnchorClassName(Boolean(active), disabled, context?.density, slot), className),
|
|
51
93
|
"data-active": active || void 0,
|
|
52
94
|
"data-disabled": disabled || void 0,
|
|
95
|
+
"data-page": page,
|
|
53
96
|
"data-slot": slot,
|
|
54
97
|
href: disabled ? void 0 : href,
|
|
55
98
|
onClick: (event) => {
|
|
@@ -58,12 +101,15 @@ const PaginationAnchor = forwardRef(function PaginationAnchor({ active = false,
|
|
|
58
101
|
event.stopPropagation();
|
|
59
102
|
return;
|
|
60
103
|
}
|
|
104
|
+
if (page !== void 0 && context?.pageCount) {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
context.goTo(page);
|
|
107
|
+
}
|
|
61
108
|
onClick?.(event);
|
|
62
109
|
},
|
|
63
110
|
tabIndex: disabled ? -1 : tabIndex
|
|
64
111
|
});
|
|
65
112
|
});
|
|
66
|
-
/** A link to a numbered page. Set `active` on the current destination. */
|
|
67
113
|
const PaginationLink = forwardRef(function PaginationLink(props, ref) {
|
|
68
114
|
return /* @__PURE__ */ jsx(PaginationAnchor, {
|
|
69
115
|
...props,
|
|
@@ -71,11 +117,14 @@ const PaginationLink = forwardRef(function PaginationLink(props, ref) {
|
|
|
71
117
|
slot: "pagination-link"
|
|
72
118
|
});
|
|
73
119
|
});
|
|
74
|
-
|
|
75
|
-
const
|
|
120
|
+
const PaginationPrevious = forwardRef(function PaginationPrevious({ "aria-label": ariaLabel, children, page, rel, ...props }, ref) {
|
|
121
|
+
const context = usePaginationContext();
|
|
122
|
+
const targetPage = page ?? (context?.page ? context.page - 1 : void 0);
|
|
76
123
|
return /* @__PURE__ */ jsx(PaginationAnchor, {
|
|
77
124
|
...props,
|
|
78
125
|
"aria-label": ariaLabel ?? "Go to previous page",
|
|
126
|
+
disabled: props.disabled ?? (targetPage !== void 0 && targetPage < 1),
|
|
127
|
+
page: targetPage,
|
|
79
128
|
ref,
|
|
80
129
|
rel: rel ?? "prev",
|
|
81
130
|
slot: "pagination-previous",
|
|
@@ -85,11 +134,14 @@ const PaginationPrevious = forwardRef(function PaginationPrevious({ "aria-label"
|
|
|
85
134
|
}), /* @__PURE__ */ jsx("span", { children: "Previous" })] })
|
|
86
135
|
});
|
|
87
136
|
});
|
|
88
|
-
|
|
89
|
-
const
|
|
137
|
+
const PaginationNext = forwardRef(function PaginationNext({ "aria-label": ariaLabel, children, page, rel, ...props }, ref) {
|
|
138
|
+
const context = usePaginationContext();
|
|
139
|
+
const targetPage = page ?? (context?.page ? context.page + 1 : void 0);
|
|
90
140
|
return /* @__PURE__ */ jsx(PaginationAnchor, {
|
|
91
141
|
...props,
|
|
92
142
|
"aria-label": ariaLabel ?? "Go to next page",
|
|
143
|
+
disabled: props.disabled ?? (targetPage !== void 0 && targetPage > (context?.pageCount ?? Infinity)),
|
|
144
|
+
page: targetPage,
|
|
93
145
|
ref,
|
|
94
146
|
rel: rel ?? "next",
|
|
95
147
|
slot: "pagination-next",
|
|
@@ -99,7 +151,27 @@ const PaginationNext = forwardRef(function PaginationNext({ "aria-label": ariaLa
|
|
|
99
151
|
})] })
|
|
100
152
|
});
|
|
101
153
|
});
|
|
102
|
-
|
|
154
|
+
const PaginationFirst = forwardRef(function PaginationFirst({ "aria-label": ariaLabel, children, page, ...props }, ref) {
|
|
155
|
+
return /* @__PURE__ */ jsx(PaginationAnchor, {
|
|
156
|
+
...props,
|
|
157
|
+
"aria-label": ariaLabel ?? "Go to first page",
|
|
158
|
+
page: page ?? 1,
|
|
159
|
+
ref,
|
|
160
|
+
slot: "pagination-first",
|
|
161
|
+
children: children ?? "First"
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
const PaginationLast = forwardRef(function PaginationLast({ "aria-label": ariaLabel, children, page, ...props }, ref) {
|
|
165
|
+
const context = usePaginationContext();
|
|
166
|
+
return /* @__PURE__ */ jsx(PaginationAnchor, {
|
|
167
|
+
...props,
|
|
168
|
+
"aria-label": ariaLabel ?? "Go to last page",
|
|
169
|
+
page: page ?? context?.pageCount,
|
|
170
|
+
ref,
|
|
171
|
+
slot: "pagination-last",
|
|
172
|
+
children: children ?? "Last"
|
|
173
|
+
});
|
|
174
|
+
});
|
|
103
175
|
const PaginationEllipsis = forwardRef(function PaginationEllipsis({ children = "…", className, ...props }, ref) {
|
|
104
176
|
return /* @__PURE__ */ jsx("span", {
|
|
105
177
|
...props,
|
|
@@ -110,16 +182,43 @@ const PaginationEllipsis = forwardRef(function PaginationEllipsis({ children = "
|
|
|
110
182
|
children
|
|
111
183
|
});
|
|
112
184
|
});
|
|
185
|
+
function getPageItems(page, pageCount, siblingCount) {
|
|
186
|
+
const visible = /* @__PURE__ */ new Set([1, pageCount]);
|
|
187
|
+
for (let index = page - siblingCount; index <= page + siblingCount; index += 1) if (index > 0 && index <= pageCount) visible.add(index);
|
|
188
|
+
const pages = [...visible].sort((left, right) => left - right);
|
|
189
|
+
const items = [];
|
|
190
|
+
pages.forEach((value, index) => {
|
|
191
|
+
const previous = pages[index - 1];
|
|
192
|
+
if (previous !== void 0 && value - previous > 1) items.push("ellipsis");
|
|
193
|
+
items.push(value);
|
|
194
|
+
});
|
|
195
|
+
return items;
|
|
196
|
+
}
|
|
197
|
+
function PaginationGenerated({ page, pageCount, showFirstLast, siblingCount }) {
|
|
198
|
+
const pageItems = getPageItems(page, pageCount, siblingCount);
|
|
199
|
+
return /* @__PURE__ */ jsxs(PaginationList, { children: [
|
|
200
|
+
showFirstLast ? /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationFirst, { disabled: page <= 1 }) }) : null,
|
|
201
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationPrevious, { disabled: page <= 1 }) }),
|
|
202
|
+
pageItems.map((item, index) => item === "ellipsis" ? /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationEllipsis, {}) }, `ellipsis-${pageItems.slice(0, index).filter((value) => value === "ellipsis").length + 1}`) : /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, {
|
|
203
|
+
page: item,
|
|
204
|
+
children: item
|
|
205
|
+
}) }, item)),
|
|
206
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationNext, { disabled: page >= pageCount }) }),
|
|
207
|
+
showFirstLast ? /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLast, { disabled: page >= pageCount }) }) : null
|
|
208
|
+
] });
|
|
209
|
+
}
|
|
113
210
|
const Pagination = {
|
|
114
211
|
Root: PaginationRoot,
|
|
115
212
|
List: PaginationList,
|
|
116
213
|
Item: PaginationItem,
|
|
117
214
|
Link: PaginationLink,
|
|
215
|
+
First: PaginationFirst,
|
|
118
216
|
Previous: PaginationPrevious,
|
|
119
217
|
Next: PaginationNext,
|
|
218
|
+
Last: PaginationLast,
|
|
120
219
|
Ellipsis: PaginationEllipsis
|
|
121
220
|
};
|
|
122
221
|
//#endregion
|
|
123
|
-
export { Pagination, PaginationEllipsis, PaginationItem, PaginationLink, PaginationList, PaginationNext, PaginationPrevious, PaginationRoot };
|
|
222
|
+
export { Pagination, PaginationEllipsis, PaginationFirst, PaginationItem, PaginationLast, PaginationLink, PaginationList, PaginationNext, PaginationPrevious, PaginationRoot };
|
|
124
223
|
|
|
125
224
|
//# sourceMappingURL=pagination.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","names":[],"sources":["../../../src/components/pagination/pagination.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { pagination } from \"../../styled-system/recipes\";\n\nexport type PaginationRootProps = ComponentPropsWithoutRef<\"nav\">;\n\n/** A navigation landmark for moving between pages of a result set. */\nexport const PaginationRoot = forwardRef<HTMLElement, PaginationRootProps>(function PaginationRoot(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n return (\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Pagination\"}\n ref={ref}\n className={cx(pagination().root, className)}\n data-jaci-component=\"pagination\"\n data-slot=\"pagination\"\n />\n );\n});\n\nexport type PaginationListProps = ComponentPropsWithoutRef<\"ul\">;\n\n/** An unordered list of page controls. */\nexport const PaginationList = forwardRef<HTMLUListElement, PaginationListProps>(\n function PaginationList({ className, ...props }, ref) {\n return (\n <ul\n {...props}\n ref={ref}\n className={cx(pagination().list, className)}\n data-slot=\"pagination-list\"\n />\n );\n },\n);\n\nexport type PaginationItemProps = ComponentPropsWithoutRef<\"li\">;\n\n/** A list item that wraps a page link, direction control, or ellipsis. */\nexport const PaginationItem = forwardRef<HTMLLIElement, PaginationItemProps>(\n function PaginationItem({ className, ...props }, ref) {\n return (\n <li\n {...props}\n ref={ref}\n className={cx(pagination().item, className)}\n data-slot=\"pagination-item\"\n />\n );\n },\n);\n\nexport interface PaginationLinkProps extends ComponentPropsWithoutRef<\"a\"> {\n /** Marks the link as the current page. */\n active?: boolean;\n /** Presents a non-navigable control when no destination is available. */\n disabled?: boolean;\n}\n\ntype PaginationAnchorSlot = \"pagination-link\" | \"pagination-previous\" | \"pagination-next\";\n\ninterface PaginationAnchorProps extends PaginationLinkProps {\n children?: ReactNode;\n slot: PaginationAnchorSlot;\n}\n\nfunction getAnchorClassName(active: boolean, disabled: boolean, slot: PaginationAnchorSlot) {\n const styles = pagination({ active, disabled });\n\n if (slot === \"pagination-previous\") {\n return cx(styles.link, styles.previous);\n }\n\n if (slot === \"pagination-next\") {\n return cx(styles.link, styles.next);\n }\n\n return styles.link;\n}\n\nconst PaginationAnchor = forwardRef<HTMLAnchorElement, PaginationAnchorProps>(\n function PaginationAnchor(\n {\n active = false,\n \"aria-current\": ariaCurrent,\n className,\n disabled = false,\n href,\n onClick,\n slot,\n tabIndex,\n ...props\n },\n ref,\n ) {\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n aria-disabled={disabled || undefined}\n ref={ref}\n className={cx(getAnchorClassName(active, disabled, slot), className)}\n data-active={active || undefined}\n data-disabled={disabled || undefined}\n data-slot={slot}\n href={disabled ? undefined : href}\n onClick={(event) => {\n if (disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n onClick?.(event);\n }}\n tabIndex={disabled ? -1 : tabIndex}\n />\n );\n },\n);\n\n/** A link to a numbered page. Set `active` on the current destination. */\nexport const PaginationLink = forwardRef<HTMLAnchorElement, PaginationLinkProps>(\n function PaginationLink(props, ref) {\n return <PaginationAnchor {...props} ref={ref} slot=\"pagination-link\" />;\n },\n);\n\nexport interface PaginationPreviousProps extends PaginationLinkProps {\n children?: ReactNode;\n}\n\n/** A directional link to the preceding page. */\nexport const PaginationPrevious = forwardRef<HTMLAnchorElement, PaginationPreviousProps>(\n function PaginationPrevious({ \"aria-label\": ariaLabel, children, rel, ...props }, ref) {\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to previous page\"}\n ref={ref}\n rel={rel ?? \"prev\"}\n slot=\"pagination-previous\"\n >\n {children ?? (\n <>\n <span aria-hidden=\"true\">‹</span>\n <span>Previous</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationNextProps extends PaginationLinkProps {\n children?: ReactNode;\n}\n\n/** A directional link to the following page. */\nexport const PaginationNext = forwardRef<HTMLAnchorElement, PaginationNextProps>(\n function PaginationNext({ \"aria-label\": ariaLabel, children, rel, ...props }, ref) {\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to next page\"}\n ref={ref}\n rel={rel ?? \"next\"}\n slot=\"pagination-next\"\n >\n {children ?? (\n <>\n <span>Next</span>\n <span aria-hidden=\"true\">›</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport type PaginationEllipsisProps = ComponentPropsWithoutRef<\"span\">;\n\n/** A non-interactive marker for omitted page ranges. */\nexport const PaginationEllipsis = forwardRef<HTMLSpanElement, PaginationEllipsisProps>(\n function PaginationEllipsis({ children = \"…\", className, ...props }, ref) {\n return (\n <span\n {...props}\n aria-hidden=\"true\"\n ref={ref}\n className={cx(pagination().ellipsis, className)}\n data-slot=\"pagination-ellipsis\"\n >\n {children}\n </span>\n );\n },\n);\n\nexport const Pagination = {\n Root: PaginationRoot,\n List: PaginationList,\n Item: PaginationItem,\n Link: PaginationLink,\n Previous: PaginationPrevious,\n Next: PaginationNext,\n Ellipsis: PaginationEllipsis,\n};\n"],"mappings":";;;;;;AASA,MAAa,iBAAiB,WAA6C,SAAS,eAClF,EAAE,cAAc,WAAW,WAAW,GAAG,SACzC,KACA;CACA,OACE,oBAAC,OAAD;EACE,GAAI;EACJ,cAAY,aAAa;EACpB;EACL,WAAW,GAAG,WAAW,CAAC,CAAC,MAAM,SAAS;EAC1C,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CAAC;;AAKD,MAAa,iBAAiB,WAC5B,SAAS,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK;CACpD,OACE,oBAAC,MAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,WAAW,CAAC,CAAC,MAAM,SAAS;EAC1C,aAAU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kBAAD;EACE,GAAI;EACJ,cAAY,aAAa;EACpB;EACL,KAAK,OAAO;EACZ,MAAK;YAEJ,YACC,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;GAAM,eAAY;aAAO;EAAO,CAAA,GAChC,oBAAC,QAAD,EAAA,UAAM,WAAc,CAAA,CACpB,EAAA,CAAA;CAEY,CAAA;AAEtB,CACF;;AAOA,MAAa,iBAAiB,WAC5B,SAAS,eAAe,EAAE,cAAc,WAAW,UAAU,KAAK,GAAG,SAAS,KAAK;CACjF,OACE,oBAAC,kBAAD;EACE,GAAI;EACJ,cAAY,aAAa;EACpB;EACL,KAAK,OAAO;EACZ,MAAK;YAEJ,YACC,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD,EAAA,UAAM,OAAU,CAAA,GAChB,oBAAC,QAAD;GAAM,eAAY;aAAO;EAAO,CAAA,CAChC,EAAA,CAAA;CAEY,CAAA;AAEtB,CACF;;AAKA,MAAa,qBAAqB,WAChC,SAAS,mBAAmB,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS,KAAK;CACxE,OACE,oBAAC,QAAD;EACE,GAAI;EACJ,eAAY;EACP;EACL,WAAW,GAAG,WAAW,CAAC,CAAC,UAAU,SAAS;EAC9C,aAAU;EAET;CACG,CAAA;AAEV,CACF;AAEA,MAAa,aAAa;CACxB,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,UAAU;CACV,MAAM;CACN,UAAU;AACZ"}
|
|
1
|
+
{"version":3,"file":"pagination.js","names":[],"sources":["../../../src/components/pagination/pagination.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { pagination } from \"../../styled-system/recipes\";\n\nexport type PaginationDensity = \"compact\" | \"comfortable\";\n\ninterface PaginationContextValue {\n density: PaginationDensity;\n goTo: (page: number) => void;\n page: number | undefined;\n pageCount: number | undefined;\n}\n\nconst PaginationContext = createContext<PaginationContextValue | null>(null);\n\nfunction usePaginationContext() {\n return useContext(PaginationContext);\n}\n\nexport interface PaginationRootProps extends Omit<ComponentPropsWithoutRef<\"nav\">, \"children\"> {\n children?: ReactNode;\n defaultPage?: number;\n density?: PaginationDensity;\n onPageChange?: (page: number) => void;\n page?: number;\n pageCount?: number;\n showFirstLast?: boolean;\n siblingCount?: number;\n}\n\nexport const PaginationRoot = forwardRef<HTMLElement, PaginationRootProps>(function PaginationRoot(\n {\n children,\n \"aria-label\": ariaLabel,\n className,\n defaultPage = 1,\n density = \"comfortable\",\n onPageChange,\n page: controlledPage,\n pageCount,\n showFirstLast = false,\n siblingCount = 1,\n ...props\n },\n ref,\n) {\n const [uncontrolledPage, setUncontrolledPage] = useState(defaultPage);\n const page = pageCount\n ? Math.min(Math.max(controlledPage ?? uncontrolledPage, 1), pageCount)\n : controlledPage;\n const goTo = useCallback(\n (nextPage: number) => {\n if (!pageCount) return;\n const next = Math.min(Math.max(nextPage, 1), pageCount);\n if (controlledPage === undefined) setUncontrolledPage(next);\n onPageChange?.(next);\n },\n [controlledPage, onPageChange, pageCount],\n );\n const context = useMemo(\n () => ({ density, goTo, page, pageCount }),\n [density, goTo, page, pageCount],\n );\n\n return (\n <PaginationContext.Provider value={context}>\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Pagination\"}\n ref={ref}\n className={cx(pagination({ density }).root, className)}\n data-density={density}\n data-jaci-component=\"pagination\"\n data-slot=\"pagination\"\n >\n {children ??\n (pageCount ? (\n <PaginationGenerated\n page={page ?? 1}\n pageCount={pageCount}\n showFirstLast={showFirstLast}\n siblingCount={siblingCount}\n />\n ) : null)}\n </nav>\n </PaginationContext.Provider>\n );\n});\n\nexport type PaginationListProps = ComponentPropsWithoutRef<\"ul\">;\nexport const PaginationList = forwardRef<HTMLUListElement, PaginationListProps>(\n function PaginationList({ className, ...props }, ref) {\n const context = usePaginationContext();\n return (\n <ul\n {...props}\n ref={ref}\n className={cx(pagination({ density: context?.density }).list, className)}\n data-slot=\"pagination-list\"\n />\n );\n },\n);\n\nexport type PaginationItemProps = ComponentPropsWithoutRef<\"li\">;\nexport const PaginationItem = forwardRef<HTMLLIElement, PaginationItemProps>(\n function PaginationItem({ className, ...props }, ref) {\n return (\n <li\n {...props}\n ref={ref}\n className={cx(pagination().item, className)}\n data-slot=\"pagination-item\"\n />\n );\n },\n);\n\nexport interface PaginationLinkProps extends ComponentPropsWithoutRef<\"a\"> {\n active?: boolean;\n disabled?: boolean;\n page?: number | undefined;\n}\n\ntype PaginationAnchorSlot =\n | \"pagination-link\"\n | \"pagination-first\"\n | \"pagination-last\"\n | \"pagination-previous\"\n | \"pagination-next\";\n\ninterface PaginationAnchorProps extends PaginationLinkProps {\n slot: PaginationAnchorSlot;\n}\n\nfunction getAnchorClassName(\n active: boolean,\n disabled: boolean,\n density: PaginationDensity | undefined,\n slot: PaginationAnchorSlot,\n) {\n const styles = pagination({ active, density, disabled });\n if (slot === \"pagination-previous\") return cx(styles.link, styles.previous);\n if (slot === \"pagination-next\") return cx(styles.link, styles.next);\n if (slot === \"pagination-first\") return cx(styles.link, styles.first);\n if (slot === \"pagination-last\") return cx(styles.link, styles.last);\n return styles.link;\n}\n\nconst PaginationAnchor = forwardRef<HTMLAnchorElement, PaginationAnchorProps>(\n function PaginationAnchor(\n {\n active: activeProp,\n \"aria-current\": ariaCurrent,\n className,\n disabled: disabledProp = false,\n href,\n onClick,\n page,\n slot,\n tabIndex,\n ...props\n },\n ref,\n ) {\n const context = usePaginationContext();\n const active = activeProp ?? (page !== undefined && context?.page === page);\n const disabled = Boolean(disabledProp || (page !== undefined && context?.pageCount === 1));\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n aria-disabled={disabled || undefined}\n ref={ref}\n className={cx(\n getAnchorClassName(Boolean(active), disabled, context?.density, slot),\n className,\n )}\n data-active={active || undefined}\n data-disabled={disabled || undefined}\n data-page={page}\n data-slot={slot}\n href={disabled ? undefined : href}\n onClick={(event) => {\n if (disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n if (page !== undefined && context?.pageCount) {\n event.preventDefault();\n context.goTo(page);\n }\n onClick?.(event);\n }}\n tabIndex={disabled ? -1 : tabIndex}\n />\n );\n },\n);\n\nexport const PaginationLink = forwardRef<HTMLAnchorElement, PaginationLinkProps>(\n function PaginationLink(props, ref) {\n return <PaginationAnchor {...props} ref={ref} slot=\"pagination-link\" />;\n },\n);\n\nexport interface PaginationPreviousProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationPrevious = forwardRef<HTMLAnchorElement, PaginationPreviousProps>(\n function PaginationPrevious({ \"aria-label\": ariaLabel, children, page, rel, ...props }, ref) {\n const context = usePaginationContext();\n const targetPage = page ?? (context?.page ? context.page - 1 : undefined);\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to previous page\"}\n disabled={props.disabled ?? (targetPage !== undefined && targetPage < 1)}\n page={targetPage}\n ref={ref}\n rel={rel ?? \"prev\"}\n slot=\"pagination-previous\"\n >\n {children ?? (\n <>\n <span aria-hidden=\"true\">‹</span>\n <span>Previous</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationNextProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationNext = forwardRef<HTMLAnchorElement, PaginationNextProps>(\n function PaginationNext({ \"aria-label\": ariaLabel, children, page, rel, ...props }, ref) {\n const context = usePaginationContext();\n const targetPage = page ?? (context?.page ? context.page + 1 : undefined);\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to next page\"}\n disabled={\n props.disabled ??\n (targetPage !== undefined && targetPage > (context?.pageCount ?? Infinity))\n }\n page={targetPage}\n ref={ref}\n rel={rel ?? \"next\"}\n slot=\"pagination-next\"\n >\n {children ?? (\n <>\n <span>Next</span>\n <span aria-hidden=\"true\">›</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationFirstProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationFirst = forwardRef<HTMLAnchorElement, PaginationFirstProps>(\n function PaginationFirst({ \"aria-label\": ariaLabel, children, page, ...props }, ref) {\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to first page\"}\n page={page ?? 1}\n ref={ref}\n slot=\"pagination-first\"\n >\n {children ?? \"First\"}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationLastProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationLast = forwardRef<HTMLAnchorElement, PaginationLastProps>(\n function PaginationLast({ \"aria-label\": ariaLabel, children, page, ...props }, ref) {\n const context = usePaginationContext();\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to last page\"}\n page={page ?? context?.pageCount}\n ref={ref}\n slot=\"pagination-last\"\n >\n {children ?? \"Last\"}\n </PaginationAnchor>\n );\n },\n);\n\nexport type PaginationEllipsisProps = ComponentPropsWithoutRef<\"span\">;\nexport const PaginationEllipsis = forwardRef<HTMLSpanElement, PaginationEllipsisProps>(\n function PaginationEllipsis({ children = \"…\", className, ...props }, ref) {\n return (\n <span\n {...props}\n aria-hidden=\"true\"\n ref={ref}\n className={cx(pagination().ellipsis, className)}\n data-slot=\"pagination-ellipsis\"\n >\n {children}\n </span>\n );\n },\n);\n\ntype PaginationPageItem = number | \"ellipsis\";\n\nfunction getPageItems(page: number, pageCount: number, siblingCount: number): PaginationPageItem[] {\n const visible = new Set<number>([1, pageCount]);\n for (let index = page - siblingCount; index <= page + siblingCount; index += 1) {\n if (index > 0 && index <= pageCount) visible.add(index);\n }\n const pages = [...visible].sort((left, right) => left - right);\n const items: PaginationPageItem[] = [];\n pages.forEach((value, index) => {\n const previous = pages[index - 1];\n if (previous !== undefined && value - previous > 1) items.push(\"ellipsis\");\n items.push(value);\n });\n return items;\n}\n\nfunction PaginationGenerated({\n page,\n pageCount,\n showFirstLast,\n siblingCount,\n}: {\n page: number;\n pageCount: number;\n showFirstLast: boolean;\n siblingCount: number;\n}) {\n const pageItems = getPageItems(page, pageCount, siblingCount);\n return (\n <PaginationList>\n {showFirstLast ? (\n <PaginationItem>\n <PaginationFirst disabled={page <= 1} />\n </PaginationItem>\n ) : null}\n <PaginationItem>\n <PaginationPrevious disabled={page <= 1} />\n </PaginationItem>\n {pageItems.map((item, index) =>\n item === \"ellipsis\" ? (\n <PaginationItem\n key={`ellipsis-${pageItems.slice(0, index).filter((value) => value === \"ellipsis\").length + 1}`}\n >\n <PaginationEllipsis />\n </PaginationItem>\n ) : (\n <PaginationItem key={item}>\n <PaginationLink page={item}>{item}</PaginationLink>\n </PaginationItem>\n ),\n )}\n <PaginationItem>\n <PaginationNext disabled={page >= pageCount} />\n </PaginationItem>\n {showFirstLast ? (\n <PaginationItem>\n <PaginationLast disabled={page >= pageCount} />\n </PaginationItem>\n ) : null}\n </PaginationList>\n );\n}\n\nexport const Pagination = {\n Root: PaginationRoot,\n List: PaginationList,\n Item: PaginationItem,\n Link: PaginationLink,\n First: PaginationFirst,\n Previous: PaginationPrevious,\n Next: PaginationNext,\n Last: PaginationLast,\n Ellipsis: PaginationEllipsis,\n};\n"],"mappings":";;;;;;AAiBA,MAAM,oBAAoB,cAA6C,IAAI;AAE3E,SAAS,uBAAuB;CAC9B,OAAO,WAAW,iBAAiB;AACrC;AAaA,MAAa,iBAAiB,WAA6C,SAAS,eAClF,EACE,UACA,cAAc,WACd,WACA,cAAc,GACd,UAAU,eACV,cACA,MAAM,gBACN,WACA,gBAAgB,OAChB,eAAe,GACf,GAAG,SAEL,KACA;CACA,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,WAAW;CACpE,MAAM,OAAO,YACT,KAAK,IAAI,KAAK,IAAI,kBAAkB,kBAAkB,CAAC,GAAG,SAAS,IACnE;CACJ,MAAM,OAAO,aACV,aAAqB;EACpB,IAAI,CAAC,WAAW;EAChB,MAAM,OA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oBAAD,CAAqB,CAAA,EACP,GAHT,YAAY,UAAU,MAAM,GAAG,KAAK,CAAC,CAAC,QAAQ,UAAU,UAAU,UAAU,CAAC,CAAC,SAAS,GAG9E,IAEhB,oBAAC,gBAAD,EAAA,UACE,oBAAC,gBAAD;GAAgB,MAAM;aAAO;EAAqB,CAAA,EACpC,GAFK,IAEL,CAEpB;EACA,oBAAC,gBAAD,EAAA,UACE,oBAAC,gBAAD,EAAgB,UAAU,QAAQ,UAAY,CAAA,EAChC,CAAA;EACf,gBACC,oBAAC,gBAAD,EAAA,UACE,oBAAC,gBAAD,EAAgB,UAAU,QAAQ,UAAY,CAAA,EAChC,CAAA,IACd;CACU,EAAA,CAAA;AAEpB;AAEA,MAAa,aAAa;CACxB,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,UAAU;CACV,MAAM;CACN,MAAM;CACN,UAAU;AACZ"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_cx = require("../../styled-system/css/cx.cjs");
|
|
3
|
+
const require_base_ui = require("../base-ui.cjs");
|
|
3
4
|
const require_sidebar = require("../../styled-system/recipes/sidebar.cjs");
|
|
4
5
|
let react = require("react");
|
|
5
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _base_ui_react_dialog = require("@base-ui/react/dialog");
|
|
6
8
|
//#region src/components/sidebar/sidebar.tsx
|
|
7
9
|
const SidebarContext = (0, react.createContext)(null);
|
|
8
10
|
/**
|
|
@@ -22,7 +24,7 @@ function useSidebarStyles() {
|
|
|
22
24
|
/**
|
|
23
25
|
* The sidebar container. It supports both controlled and uncontrolled state.
|
|
24
26
|
*/
|
|
25
|
-
const SidebarRoot = (0, react.forwardRef)(function SidebarRoot({ children, className, defaultOpen = true, onOpenChange, open: controlledOpen, ...props }, ref) {
|
|
27
|
+
const SidebarRoot = (0, react.forwardRef)(function SidebarRoot({ children, className, closeOnEscape = true, closeOnOutsidePress = true, defaultOpen = true, modal = true, mode = "static", onOpenChange, open: controlledOpen, restoreFocus = true, ...props }, ref) {
|
|
26
28
|
const [uncontrolledOpen, setUncontrolledOpen] = (0, react.useState)(defaultOpen);
|
|
27
29
|
const isControlled = controlledOpen !== void 0;
|
|
28
30
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
@@ -43,19 +45,61 @@ const SidebarRoot = (0, react.forwardRef)(function SidebarRoot({ children, class
|
|
|
43
45
|
toggle
|
|
44
46
|
]);
|
|
45
47
|
const styles = require_sidebar.sidebar({ open });
|
|
46
|
-
|
|
48
|
+
const surface = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
|
|
49
|
+
...props,
|
|
50
|
+
ref,
|
|
51
|
+
className: require_cx.cx(styles.root, className),
|
|
52
|
+
"data-jaci-component": "sidebar",
|
|
53
|
+
"data-open": open,
|
|
54
|
+
"data-slot": "sidebar",
|
|
55
|
+
"data-state": open ? "open" : "closed",
|
|
56
|
+
children
|
|
57
|
+
});
|
|
58
|
+
if (mode === "overlay") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarContext.Provider, {
|
|
47
59
|
value: context,
|
|
48
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Root, {
|
|
61
|
+
open,
|
|
62
|
+
modal,
|
|
63
|
+
onOpenChange: (nextOpen, details) => {
|
|
64
|
+
if (!nextOpen && (!closeOnEscape && details.reason === "escape-key" || !closeOnOutsidePress && details.reason === "outside-press")) {
|
|
65
|
+
details.cancel();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setOpen(nextOpen);
|
|
69
|
+
},
|
|
70
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_dialog.Dialog.Portal, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Backdrop, {
|
|
71
|
+
className: require_cx.cx(styles.backdrop),
|
|
72
|
+
"data-jaci-component": "sidebar",
|
|
73
|
+
"data-slot": "sidebar-backdrop"
|
|
74
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Viewport, {
|
|
75
|
+
className: require_cx.cx(styles.viewport),
|
|
76
|
+
"data-slot": "sidebar-viewport",
|
|
77
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Popup, {
|
|
78
|
+
"aria-label": props["aria-label"] ?? "Sidebar navigation",
|
|
79
|
+
className: require_cx.cx(styles.popup),
|
|
80
|
+
"data-jaci-component": "sidebar",
|
|
81
|
+
"data-slot": "sidebar-popup",
|
|
82
|
+
finalFocus: restoreFocus,
|
|
83
|
+
initialFocus: true,
|
|
84
|
+
children: surface
|
|
85
|
+
})
|
|
86
|
+
})] })
|
|
57
87
|
})
|
|
58
88
|
});
|
|
89
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarContext.Provider, {
|
|
90
|
+
value: context,
|
|
91
|
+
children: surface
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
const SidebarPortal = _base_ui_react_dialog.Dialog.Portal;
|
|
95
|
+
const SidebarBackdrop = (0, react.forwardRef)(function SidebarBackdrop({ className, ...props }, ref) {
|
|
96
|
+
const { open } = useSidebar();
|
|
97
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Backdrop, {
|
|
98
|
+
...props,
|
|
99
|
+
className: require_base_ui.withRecipeClassName(require_sidebar.sidebar({ open }).backdrop, className),
|
|
100
|
+
"data-slot": "sidebar-backdrop",
|
|
101
|
+
ref
|
|
102
|
+
});
|
|
59
103
|
});
|
|
60
104
|
/**
|
|
61
105
|
* A floating, accessible control that expands or collapses the sidebar.
|
|
@@ -141,6 +185,8 @@ const SidebarLabel = (0, react.forwardRef)(function SidebarLabel({ className, ..
|
|
|
141
185
|
});
|
|
142
186
|
const Sidebar = {
|
|
143
187
|
Root: SidebarRoot,
|
|
188
|
+
Portal: SidebarPortal,
|
|
189
|
+
Backdrop: SidebarBackdrop,
|
|
144
190
|
Toggle: SidebarToggle,
|
|
145
191
|
Header: SidebarHeader,
|
|
146
192
|
Content: SidebarContent,
|
|
@@ -150,11 +196,13 @@ const Sidebar = {
|
|
|
150
196
|
};
|
|
151
197
|
//#endregion
|
|
152
198
|
exports.Sidebar = Sidebar;
|
|
199
|
+
exports.SidebarBackdrop = SidebarBackdrop;
|
|
153
200
|
exports.SidebarContent = SidebarContent;
|
|
154
201
|
exports.SidebarFooter = SidebarFooter;
|
|
155
202
|
exports.SidebarHeader = SidebarHeader;
|
|
156
203
|
exports.SidebarItem = SidebarItem;
|
|
157
204
|
exports.SidebarLabel = SidebarLabel;
|
|
205
|
+
exports.SidebarPortal = SidebarPortal;
|
|
158
206
|
exports.SidebarRoot = SidebarRoot;
|
|
159
207
|
exports.SidebarToggle = SidebarToggle;
|
|
160
208
|
exports.useSidebar = useSidebar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.cjs","names":["sidebar","cx"],"sources":["../../../src/components/sidebar/sidebar.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { sidebar } from \"../../styled-system/recipes\";\n\nexport interface SidebarContextValue {\n /** Whether the sidebar is visually expanded. */\n open: boolean;\n /** Updates the expanded state, respecting controlled usage. */\n setOpen: (open: boolean) => void;\n /** Convenience callback for toggles placed anywhere in the sidebar. */\n toggle: () => void;\n}\n\nconst SidebarContext = createContext<SidebarContextValue | null>(null);\n\n/**\n * Reads the state exposed by `Sidebar.Root`.\n *\n * Use it in custom sidebar parts when the built-in composition is not enough.\n */\nexport function useSidebar() {\n const context = useContext(SidebarContext);\n\n if (!context) {\n throw new Error(\"useSidebar must be used within a Sidebar.Root component.\");\n }\n\n return context;\n}\n\nfunction useSidebarStyles() {\n const { open } = useSidebar();\n return sidebar({ open });\n}\n\nexport interface SidebarRootProps extends ComponentPropsWithoutRef<\"aside\"> {\n /** Controlled expanded state. */\n open?: boolean;\n /** Initial expanded state for uncontrolled use. */\n defaultOpen?: boolean;\n /** Called after the requested expanded state changes. */\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n}\n\n/**\n * The sidebar container. It supports both controlled and uncontrolled state.\n */\nexport const SidebarRoot = forwardRef<HTMLElement, SidebarRootProps>(function SidebarRoot(\n { children, className, defaultOpen = true, onOpenChange, open: controlledOpen, ...props },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isControlled = controlledOpen !== undefined;\n const open = controlledOpen ?? uncontrolledOpen;\n\n const setOpen = useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(nextOpen);\n }\n\n onOpenChange?.(nextOpen);\n },\n [isControlled, onOpenChange],\n );\n\n const toggle = useCallback(() => {\n setOpen(!open);\n }, [open, setOpen]);\n\n const context = useMemo<SidebarContextValue>(\n () => ({ open, setOpen, toggle }),\n [open, setOpen, toggle],\n );\n const styles = sidebar({ open });\n\n return (\n <SidebarContext.Provider value={context}>\n <aside\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-jaci-component=\"sidebar\"\n data-open={open}\n data-slot=\"sidebar\"\n data-state={open ? \"open\" : \"closed\"}\n >\n {children}\n </aside>\n </SidebarContext.Provider>\n );\n});\n\nexport type SidebarToggleProps = ComponentPropsWithoutRef<\"button\">;\n\n/**\n * A floating, accessible control that expands or collapses the sidebar.\n */\nexport const SidebarToggle = forwardRef<HTMLButtonElement, SidebarToggleProps>(\n function SidebarToggle(\n { \"aria-label\": ariaLabel, children, className, onClick, type = \"button\", ...props },\n ref,\n ) {\n const { open, toggle } = useSidebar();\n const styles = useSidebarStyles();\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n\n if (!event.defaultPrevented) {\n toggle();\n }\n };\n\n return (\n <button\n {...props}\n aria-expanded={open}\n aria-label={ariaLabel ?? (open ? \"Collapse sidebar\" : \"Expand sidebar\")}\n className={cx(styles.toggle, className)}\n data-slot=\"sidebar-toggle\"\n onClick={handleClick}\n ref={ref}\n type={type}\n >\n {children ?? <span aria-hidden=\"true\">{open ? \"‹\" : \"›\"}</span>}\n </button>\n );\n },\n);\n\nexport type SidebarHeaderProps = ComponentPropsWithoutRef<\"header\">;\n\nexport const SidebarHeader = forwardRef<HTMLElement, SidebarHeaderProps>(function SidebarHeader(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <header\n {...props}\n ref={ref}\n className={cx(styles.header, className)}\n data-slot=\"sidebar-header\"\n />\n );\n});\n\nexport type SidebarContentProps = ComponentPropsWithoutRef<\"nav\">;\n\nexport const SidebarContent = forwardRef<HTMLElement, SidebarContentProps>(function SidebarContent(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Sidebar navigation\"}\n ref={ref}\n className={cx(styles.content, className)}\n data-slot=\"sidebar-content\"\n />\n );\n});\n\nexport type SidebarFooterProps = ComponentPropsWithoutRef<\"footer\">;\n\nexport const SidebarFooter = forwardRef<HTMLElement, SidebarFooterProps>(function SidebarFooter(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <footer\n {...props}\n ref={ref}\n className={cx(styles.footer, className)}\n data-slot=\"sidebar-footer\"\n />\n );\n});\n\nexport interface SidebarItemProps extends ComponentPropsWithoutRef<\"a\"> {\n /** Marks the current navigation destination. */\n active?: boolean;\n}\n\n/**\n * A semantic navigation item. Pair its icon/content with `Sidebar.Label` so\n * the text transitions out of view while remaining available to assistive\n * technology when the sidebar is collapsed.\n */\nexport const SidebarItem = forwardRef<HTMLAnchorElement, SidebarItemProps>(function SidebarItem(\n { \"aria-current\": ariaCurrent, active = false, className, ...props },\n ref,\n) {\n const { open } = useSidebar();\n const styles = sidebar({ active, open });\n\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n ref={ref}\n className={cx(styles.item, className)}\n data-active={active || undefined}\n data-slot=\"sidebar-item\"\n />\n );\n});\n\nexport type SidebarLabelProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const SidebarLabel = forwardRef<HTMLSpanElement, SidebarLabelProps>(function SidebarLabel(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <span {...props} ref={ref} className={cx(styles.label, className)} data-slot=\"sidebar-label\" />\n );\n});\n\nexport const Sidebar = {\n Root: SidebarRoot,\n Toggle: SidebarToggle,\n Header: SidebarHeader,\n Content: SidebarContent,\n Footer: SidebarFooter,\n Item: SidebarItem,\n Label: SidebarLabel,\n};\n"],"mappings":";;;;;;AAiBA,MAAM,kBAAA,GAAA,MAAA,cAAA,CAA2D,IAAI;;;;;;AAOrE,SAAgB,aAAa;CAC3B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,cAAc;CAEzC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,0DAA0D;CAG5E,OAAO;AACT;AAEA,SAAS,mBAAmB;CAC1B,MAAM,EAAE,SAAS,WAAW;CAC5B,OAAOA,gBAAAA,QAAQ,EAAE,KAAK,CAAC;AACzB;;;;AAeA,MAAa,eAAA,GAAA,MAAA,WAAA,CAAwD,SAAS,YAC5E,EAAE,UAAU,WAAW,cAAc,MAAM,cAAc,MAAM,gBAAgB,GAAG,SAClF,KACA;CACA,MAAM,CAAC,kBAAkB,wBAAA,GAAA,MAAA,SAAA,CAAgC,WAAW;CACpE,MAAM,eAAe,mBAAmB,KAAA;CACxC,MAAM,O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CAAA;AAEL,CAAC;AAID,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA8D,SAAS,aAClF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,MAAM,SAAS,iBAAiB;CAEhC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAAM,GAAI;EAAY;EAAK,WAAWA,WAAAA,GAAG,OAAO,OAAO,SAAS;EAAG,aAAU;CAAiB,CAAA;AAElG,CAAC;AAED,MAAa,UAAU;CACrB,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,MAAM;CACN,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"sidebar.cjs","names":["sidebar","cx","BaseDialog","withRecipeClassName"],"sources":["../../../src/components/sidebar/sidebar.tsx"],"sourcesContent":["\"use client\";\n\nimport { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { sidebar } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\nexport interface SidebarContextValue {\n /** Whether the sidebar is visually expanded. */\n open: boolean;\n /** Updates the expanded state, respecting controlled usage. */\n setOpen: (open: boolean) => void;\n /** Convenience callback for toggles placed anywhere in the sidebar. */\n toggle: () => void;\n}\n\nconst SidebarContext = createContext<SidebarContextValue | null>(null);\n\n/**\n * Reads the state exposed by `Sidebar.Root`.\n *\n * Use it in custom sidebar parts when the built-in composition is not enough.\n */\nexport function useSidebar() {\n const context = useContext(SidebarContext);\n\n if (!context) {\n throw new Error(\"useSidebar must be used within a Sidebar.Root component.\");\n }\n\n return context;\n}\n\nfunction useSidebarStyles() {\n const { open } = useSidebar();\n return sidebar({ open });\n}\n\nexport interface SidebarRootProps extends ComponentPropsWithoutRef<\"aside\"> {\n /** Controlled expanded state. */\n open?: boolean;\n /** Initial expanded state for uncontrolled use. */\n defaultOpen?: boolean;\n /** Called after the requested expanded state changes. */\n onOpenChange?: (open: boolean) => void;\n /** Renders the sidebar as a modal mobile surface when set to overlay. */\n mode?: \"static\" | \"overlay\";\n /** Allows Escape to be disabled for overlay mode. */\n closeOnEscape?: boolean;\n /** Allows outside presses to be disabled for overlay mode. */\n closeOnOutsidePress?: boolean;\n /** Restores focus to the element that opened the overlay. */\n restoreFocus?: boolean;\n /** Controls whether the overlay traps focus and locks page scroll. */\n modal?: boolean | \"trap-focus\";\n children?: ReactNode;\n}\n\n/**\n * The sidebar container. It supports both controlled and uncontrolled state.\n */\nexport const SidebarRoot = forwardRef<HTMLElement, SidebarRootProps>(function SidebarRoot(\n {\n children,\n className,\n closeOnEscape = true,\n closeOnOutsidePress = true,\n defaultOpen = true,\n modal = true,\n mode = \"static\",\n onOpenChange,\n open: controlledOpen,\n restoreFocus = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isControlled = controlledOpen !== undefined;\n const open = controlledOpen ?? uncontrolledOpen;\n\n const setOpen = useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(nextOpen);\n }\n\n onOpenChange?.(nextOpen);\n },\n [isControlled, onOpenChange],\n );\n\n const toggle = useCallback(() => {\n setOpen(!open);\n }, [open, setOpen]);\n\n const context = useMemo<SidebarContextValue>(\n () => ({ open, setOpen, toggle }),\n [open, setOpen, toggle],\n );\n const styles = sidebar({ open });\n\n const surface = (\n <aside\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-jaci-component=\"sidebar\"\n data-open={open}\n data-slot=\"sidebar\"\n data-state={open ? \"open\" : \"closed\"}\n >\n {children}\n </aside>\n );\n\n if (mode === \"overlay\") {\n return (\n <SidebarContext.Provider value={context}>\n <BaseDialog.Root\n open={open}\n modal={modal}\n onOpenChange={(nextOpen, details) => {\n if (\n !nextOpen &&\n ((!closeOnEscape && details.reason === \"escape-key\") ||\n (!closeOnOutsidePress && details.reason === \"outside-press\"))\n ) {\n details.cancel();\n return;\n }\n setOpen(nextOpen);\n }}\n >\n <BaseDialog.Portal>\n <BaseDialog.Backdrop\n className={cx(styles.backdrop)}\n data-jaci-component=\"sidebar\"\n data-slot=\"sidebar-backdrop\"\n />\n <BaseDialog.Viewport className={cx(styles.viewport)} data-slot=\"sidebar-viewport\">\n <BaseDialog.Popup\n aria-label={props[\"aria-label\"] ?? \"Sidebar navigation\"}\n className={cx(styles.popup)}\n data-jaci-component=\"sidebar\"\n data-slot=\"sidebar-popup\"\n finalFocus={restoreFocus}\n initialFocus\n >\n {surface}\n </BaseDialog.Popup>\n </BaseDialog.Viewport>\n </BaseDialog.Portal>\n </BaseDialog.Root>\n </SidebarContext.Provider>\n );\n }\n\n return <SidebarContext.Provider value={context}>{surface}</SidebarContext.Provider>;\n});\n\nexport type SidebarPortalProps = ComponentPropsWithoutRef<typeof BaseDialog.Portal>;\nexport const SidebarPortal: typeof BaseDialog.Portal = BaseDialog.Portal;\n\nexport type SidebarBackdropProps = ComponentPropsWithoutRef<typeof BaseDialog.Backdrop>;\nexport const SidebarBackdrop = forwardRef<HTMLDivElement, SidebarBackdropProps>(\n function SidebarBackdrop({ className, ...props }, ref) {\n const { open } = useSidebar();\n return (\n <BaseDialog.Backdrop\n {...props}\n className={withRecipeClassName(sidebar({ open }).backdrop, className)}\n data-slot=\"sidebar-backdrop\"\n ref={ref}\n />\n );\n },\n);\n\nexport type SidebarToggleProps = ComponentPropsWithoutRef<\"button\">;\n\n/**\n * A floating, accessible control that expands or collapses the sidebar.\n */\nexport const SidebarToggle = forwardRef<HTMLButtonElement, SidebarToggleProps>(\n function SidebarToggle(\n { \"aria-label\": ariaLabel, children, className, onClick, type = \"button\", ...props },\n ref,\n ) {\n const { open, toggle } = useSidebar();\n const styles = useSidebarStyles();\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n\n if (!event.defaultPrevented) {\n toggle();\n }\n };\n\n return (\n <button\n {...props}\n aria-expanded={open}\n aria-label={ariaLabel ?? (open ? \"Collapse sidebar\" : \"Expand sidebar\")}\n className={cx(styles.toggle, className)}\n data-slot=\"sidebar-toggle\"\n onClick={handleClick}\n ref={ref}\n type={type}\n >\n {children ?? <span aria-hidden=\"true\">{open ? \"‹\" : \"›\"}</span>}\n </button>\n );\n },\n);\n\nexport type SidebarHeaderProps = ComponentPropsWithoutRef<\"header\">;\n\nexport const SidebarHeader = forwardRef<HTMLElement, SidebarHeaderProps>(function SidebarHeader(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <header\n {...props}\n ref={ref}\n className={cx(styles.header, className)}\n data-slot=\"sidebar-header\"\n />\n );\n});\n\nexport type SidebarContentProps = ComponentPropsWithoutRef<\"nav\">;\n\nexport const SidebarContent = forwardRef<HTMLElement, SidebarContentProps>(function SidebarContent(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Sidebar navigation\"}\n ref={ref}\n className={cx(styles.content, className)}\n data-slot=\"sidebar-content\"\n />\n );\n});\n\nexport type SidebarFooterProps = ComponentPropsWithoutRef<\"footer\">;\n\nexport const SidebarFooter = forwardRef<HTMLElement, SidebarFooterProps>(function SidebarFooter(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <footer\n {...props}\n ref={ref}\n className={cx(styles.footer, className)}\n data-slot=\"sidebar-footer\"\n />\n );\n});\n\nexport interface SidebarItemProps extends ComponentPropsWithoutRef<\"a\"> {\n /** Marks the current navigation destination. */\n active?: boolean;\n}\n\n/**\n * A semantic navigation item. Pair its icon/content with `Sidebar.Label` so\n * the text transitions out of view while remaining available to assistive\n * technology when the sidebar is collapsed.\n */\nexport const SidebarItem = forwardRef<HTMLAnchorElement, SidebarItemProps>(function SidebarItem(\n { \"aria-current\": ariaCurrent, active = false, className, ...props },\n ref,\n) {\n const { open } = useSidebar();\n const styles = sidebar({ active, open });\n\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n ref={ref}\n className={cx(styles.item, className)}\n data-active={active || undefined}\n data-slot=\"sidebar-item\"\n />\n );\n});\n\nexport type SidebarLabelProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const SidebarLabel = forwardRef<HTMLSpanElement, SidebarLabelProps>(function SidebarLabel(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <span {...props} ref={ref} className={cx(styles.label, className)} data-slot=\"sidebar-label\" />\n );\n});\n\nexport const Sidebar = {\n Root: SidebarRoot,\n Portal: SidebarPortal,\n Backdrop: SidebarBackdrop,\n Toggle: SidebarToggle,\n Header: SidebarHeader,\n Content: SidebarContent,\n Footer: SidebarFooter,\n Item: SidebarItem,\n Label: SidebarLabel,\n};\n"],"mappings":";;;;;;;;AAmBA,MAAM,kBAAA,GAAA,MAAA,cAAA,CAA2D,IAAI;;;;;;AAOrE,SAAgB,aAAa;CAC3B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,cAAc;CAEzC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,0DAA0D;CAG5E,OAAO;AACT;AAEA,SAAS,mBAAmB;CAC1B,MAAM,EAAE,SAAS,WAAW;CAC5B,OAAOA,gBAAAA,QAAQ,EAAE,KAAK,CAAC;AACzB;;;;AAyBA,MAAa,eAAA,GAAA,MAAA,WAAA,CAAwD,SAAS,YAC5E,EACE,UACA,WACA,gBAAgB,MAChB,sBAAsB,MACtB,cAAc,MACd,QAAQ,MACR,OAAO,UACP,cACA,MAAM,gBACN,eAAe,MACf,GAAG,SAEL,KACA;CACA,MAAM,CAAC,kBAAkB,wBAAA,GAAA,MAAA,SAAA,CAAgC,WAAW;CACpE,MAAM,eAAe,mBAAmB,KAAA;CACxC,MAAM,OAAO,kBAAkB;CAE/B,MAAM,WAAA,GAAA,MAAA,YAAA,EACH,aAAsB;EACrB,IAAI,CAA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