@payfit/unity-components 1.2.0 → 2.0.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/dist/esm/components/action-bar/ActionBar.js +14 -14
- package/dist/esm/components/actionable/Actionable.js +31 -28
- package/dist/esm/components/app-layout/AppLayout.js +17 -17
- package/dist/esm/components/app-menu/parts/AppMenuHeader.d.ts +86 -4
- package/dist/esm/components/app-menu/parts/AppMenuHeader.js +25 -25
- package/dist/esm/components/breadcrumbs/Breadcrumbs.context.js +3 -3
- package/dist/esm/components/breadcrumbs/Breadcrumbs.d.ts +19 -11
- package/dist/esm/components/breadcrumbs/Breadcrumbs.js +29 -18
- package/dist/esm/components/breadcrumbs/parts/Breadcrumb.d.ts +30 -5
- package/dist/esm/components/breadcrumbs/parts/Breadcrumb.js +35 -27
- package/dist/esm/components/breadcrumbs/parts/RawBreadcrumbLink.d.ts +37 -0
- package/dist/esm/components/breadcrumbs/parts/RawBreadcrumbLink.js +36 -0
- package/dist/esm/components/client-side-pagination/ClientSidePagination.d.ts +103 -0
- package/dist/esm/components/client-side-pagination/ClientSidePagination.js +177 -0
- package/dist/esm/components/client-side-pagination/parts/PaginationEllipsis.d.ts +11 -0
- package/dist/esm/components/client-side-pagination/parts/PaginationEllipsis.js +30 -0
- package/dist/esm/components/client-side-pagination/parts/PaginationJumpDialog.d.ts +8 -0
- package/dist/esm/components/{pagination/parts/PaginationLink.d.ts → client-side-pagination/parts/RawPaginationLink.d.ts} +2 -2
- package/dist/esm/components/{pagination/parts/PaginationLink.js → client-side-pagination/parts/RawPaginationLink.js} +2 -2
- package/dist/esm/components/client-side-pagination/utils/pagination-window.d.ts +8 -0
- package/dist/esm/components/client-side-pagination/utils/pagination-window.js +33 -0
- package/dist/esm/components/error-state/ErrorState.d.ts +13 -1
- package/dist/esm/components/error-state/ErrorState.js +133 -92
- package/dist/esm/components/error-state/initConfig.js +1 -1
- package/dist/esm/components/fieldset/Fieldset.d.ts +19 -0
- package/dist/esm/components/fieldset/Fieldset.js +32 -26
- package/dist/esm/components/flex/Flex.js +52 -37
- package/dist/esm/components/form-field/FormField.js +12 -12
- package/dist/esm/components/form-field/parts/{FormContextualLink.d.ts → RawFormContextualLink.d.ts} +2 -2
- package/dist/esm/components/form-field/parts/RawFormContextualLink.js +39 -0
- package/dist/esm/components/funnel-layout/parts/FunnelSidebar.d.ts +2 -2
- package/dist/esm/components/icon/Icon.js +23 -19
- package/dist/esm/components/link/{Link.variants.d.ts → RawLink.d.ts} +92 -0
- package/dist/esm/components/link/{Link.variants.js → RawLink.js} +70 -4
- package/dist/esm/components/menu/parts/{MenuItem.d.ts → RawMenuItem.d.ts} +3 -4
- package/dist/esm/components/menu/parts/{MenuItem.js → RawMenuItem.js} +9 -9
- package/dist/esm/components/nav/parts/NavGroup.d.ts +3 -3
- package/dist/esm/components/nav/parts/NavGroup.js +62 -51
- package/dist/esm/components/nav/parts/{NavItem.d.ts → RawNavItem.d.ts} +102 -5
- package/dist/esm/components/nav/parts/RawNavItem.js +106 -0
- package/dist/esm/components/page/Page.js +1 -1
- package/dist/esm/components/page/parts/PageHeader.d.ts +79 -9
- package/dist/esm/components/page/parts/PageHeader.js +22 -20
- package/dist/esm/components/pagination/Pagination.d.ts +23 -44
- package/dist/esm/components/pagination/Pagination.js +89 -163
- package/dist/esm/components/pagination/PaginationContext.d.ts +11 -0
- package/dist/esm/components/pagination/PaginationContext.js +15 -0
- package/dist/esm/components/pagination/hooks/use-pagination-state.d.ts +63 -0
- package/dist/esm/components/pagination/hooks/use-pagination-state.js +27 -0
- package/dist/esm/components/pagination/hooks/use-pagination-window.d.ts +64 -0
- package/dist/esm/components/pagination/hooks/use-pagination-window.js +15 -0
- package/dist/esm/components/pagination/parts/PaginationContent.d.ts +30 -0
- package/dist/esm/components/pagination/parts/PaginationContent.js +37 -0
- package/dist/esm/components/pagination/parts/PaginationEllipsis.d.ts +23 -4
- package/dist/esm/components/pagination/parts/PaginationEllipsis.js +20 -16
- package/dist/esm/components/pagination/parts/PaginationItem.d.ts +38 -0
- package/dist/esm/components/pagination/parts/PaginationItem.js +22 -0
- package/dist/esm/components/pagination/parts/RawPaginationLink.d.ts +11 -0
- package/dist/esm/components/pagination/parts/RawPaginationLink.js +60 -0
- package/dist/esm/components/pagination/parts/RawPaginationNext.d.ts +22 -0
- package/dist/esm/components/pagination/parts/RawPaginationNext.js +70 -0
- package/dist/esm/components/pagination/parts/RawPaginationPrevious.d.ts +22 -0
- package/dist/esm/components/pagination/parts/RawPaginationPrevious.js +67 -0
- package/dist/esm/components/pagination/utils/pagination-window.js +29 -20
- package/dist/esm/components/select/Select.js +63 -45
- package/dist/esm/components/select/parts/SelectOption.js +9 -9
- package/dist/esm/components/skip-links/SkipLinks.js +1 -1
- package/dist/esm/components/table/Table.d.ts +1 -0
- package/dist/esm/components/table/Table.js +82 -73
- package/dist/esm/components/table/hooks/useTableKeyboardNavigation.js +6 -6
- package/dist/esm/components/table/parts/TableCell.js +29 -26
- package/dist/esm/components/table/parts/TablePagination.d.ts +5 -5
- package/dist/esm/components/table/parts/TablePagination.js +10 -10
- package/dist/esm/components/table/parts/TableRow.js +21 -18
- package/dist/esm/components/tabs/parts/{Tab.d.ts → RawTab.d.ts} +2 -2
- package/dist/esm/components/tabs/parts/{Tab.js → RawTab.js} +6 -6
- package/dist/esm/components/task-menu/TaskMenu.d.ts +4 -4
- package/dist/esm/components/task-menu/parts/{SubTask.d.ts → RawSubTask.d.ts} +7 -7
- package/dist/esm/components/task-menu/parts/{SubTask.js → RawSubTask.js} +19 -19
- package/dist/esm/components/task-menu/parts/{Task.d.ts → RawTask.d.ts} +7 -7
- package/dist/esm/components/task-menu/parts/{Task.js → RawTask.js} +17 -17
- package/dist/esm/components/task-menu/parts/TaskGroup.d.ts +5 -5
- package/dist/esm/components/text/Text.js +30 -27
- package/dist/esm/hooks/use-container-query-level.d.ts +42 -0
- package/dist/esm/hooks/use-container-query-level.js +33 -0
- package/dist/esm/index.d.ts +21 -11
- package/dist/esm/index.js +424 -399
- package/dist/esm/integrations/tanstack-router/components/breadcrumbs/Breadcrumb.d.ts +23 -0
- package/dist/esm/integrations/tanstack-router/components/breadcrumbs/BreadcrumbLink.d.ts +38 -0
- package/dist/esm/integrations/tanstack-router/components/breadcrumbs/BreadcrumbLink.js +7 -0
- package/dist/esm/integrations/tanstack-router/components/breadcrumbs/Breadcrumbs.d.ts +23 -0
- package/dist/esm/integrations/tanstack-router/components/breadcrumbs/use-route-breadcrumb.d.ts +53 -0
- package/dist/esm/integrations/tanstack-router/components/form-contextual-link/FormContextualLink.d.ts +40 -0
- package/dist/esm/integrations/tanstack-router/components/form-contextual-link/FormContextualLink.js +7 -0
- package/dist/esm/integrations/tanstack-router/components/link/Link.d.ts +33 -0
- package/dist/esm/integrations/tanstack-router/components/link/Link.js +7 -0
- package/dist/esm/integrations/tanstack-router/components/menu-item/MenuItem.d.ts +49 -0
- package/dist/esm/integrations/tanstack-router/components/menu-item/MenuItem.js +16 -0
- package/dist/esm/integrations/tanstack-router/components/nav-item/NavItem.d.ts +52 -0
- package/dist/esm/integrations/tanstack-router/components/nav-item/NavItem.js +29 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationLink.d.ts +54 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationLink.js +21 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationNext.d.ts +52 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationNext.js +22 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationPrevious.d.ts +51 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationPrevious.js +22 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/Tabs.d.ts +82 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/Tabs.js +41 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/parts/Tab.d.ts +52 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/parts/Tab.js +15 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/parts/TabList.d.ts +5 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/parts/TabPanel.d.ts +77 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/parts/TabPanel.js +16 -0
- package/dist/esm/integrations/tanstack-router/components/task-menu/SubTask.d.ts +69 -0
- package/dist/esm/integrations/tanstack-router/components/task-menu/SubTask.js +14 -0
- package/dist/esm/integrations/tanstack-router/components/task-menu/Task.d.ts +64 -0
- package/dist/esm/integrations/tanstack-router/components/task-menu/Task.js +14 -0
- package/dist/esm/integrations/tanstack-router/index.d.ts +16 -0
- package/dist/esm/integrations/tanstack-router/utils/decorators.d.ts +23 -0
- package/dist/esm/integrations/tanstack-router.js +34 -0
- package/dist/esm/providers/router/RouterProvider.d.ts +7 -2
- package/dist/esm/providers/router/RouterProvider.js +14 -10
- package/dist/esm/types/DataAttributes.d.ts +1 -1
- package/i18n/en-GB.json +1 -0
- package/i18n/es-ES.json +1 -0
- package/i18n/fr-FR.json +1 -0
- package/package.json +47 -25
- package/dist/esm/components/form-field/parts/FormContextualLink.js +0 -37
- package/dist/esm/components/link/Link.d.ts +0 -93
- package/dist/esm/components/link/Link.js +0 -68
- package/dist/esm/components/nav/parts/NavItem.js +0 -95
- /package/dist/esm/components/{pagination → client-side-pagination}/hooks/use-pagination.d.ts +0 -0
- /package/dist/esm/components/{pagination → client-side-pagination}/hooks/use-pagination.js +0 -0
- /package/dist/esm/components/{pagination → client-side-pagination}/parts/PaginationJumpDialog.js +0 -0
- /package/dist/esm/components/{pagination → client-side-pagination}/parts/PaginationNavButton.d.ts +0 -0
- /package/dist/esm/components/{pagination → client-side-pagination}/parts/PaginationNavButton.js +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
export interface PaginationContextValue {
|
|
3
|
+
pageCount: number;
|
|
4
|
+
currentPage: number;
|
|
5
|
+
onPageChange: (page: number, previous: number, direction: -1 | 1) => void;
|
|
6
|
+
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
7
|
+
a11yIds: Record<string, string>;
|
|
8
|
+
pageRefs: MutableRefObject<Map<number, HTMLElement | null>>;
|
|
9
|
+
}
|
|
10
|
+
export declare const PaginationContext: import('react').Context<PaginationContextValue | null>;
|
|
11
|
+
export declare const usePaginationContext: () => PaginationContextValue;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext as n, useContext as o } from "react";
|
|
2
|
+
const e = n(
|
|
3
|
+
null
|
|
4
|
+
), a = () => {
|
|
5
|
+
const t = o(e);
|
|
6
|
+
if (!t)
|
|
7
|
+
throw new Error(
|
|
8
|
+
"usePaginationContext must be used within a Pagination component"
|
|
9
|
+
);
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
e as PaginationContext,
|
|
14
|
+
a as usePaginationContext
|
|
15
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface UsePaginationStateOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The total number of pages.
|
|
4
|
+
* Use -1 to indicate an unknown page count (e.g., for server-paginated data where total pages are not known upfront).
|
|
5
|
+
*/
|
|
6
|
+
pageCount: number;
|
|
7
|
+
/**
|
|
8
|
+
* The initial page to start at (1-based)
|
|
9
|
+
* @default 1
|
|
10
|
+
*/
|
|
11
|
+
initialPage?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Callback fired when the page changes
|
|
14
|
+
* @param page - The new page number
|
|
15
|
+
* @param previous - The previous page number
|
|
16
|
+
* @param direction - The direction of navigation (1 for forward, -1 for backward)
|
|
17
|
+
*/
|
|
18
|
+
onPageChange?: (page: number, previous: number, direction: -1 | 1) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Hook that manages pagination state for client-side pagination.
|
|
22
|
+
* This hook provides state management and navigation helpers for pagination components.
|
|
23
|
+
* @param options - Configuration options for pagination state
|
|
24
|
+
* @param options.pageCount - The total number of pages.
|
|
25
|
+
* @param options.initialPage - The initial page to start at (1-based)
|
|
26
|
+
* @param options.onPageChange - Callback fired when the page changes
|
|
27
|
+
* @returns Object containing current pagination state and navigation functions: currentPage (current active page), previousPage (page before current), nextPage (page after current), and goToPage (navigation function accepting page number or 'next'/'previous')
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { usePaginationState, Pagination, PaginationContent, PaginationItem, RawPaginationLink } from '@payfit/unity-components'
|
|
31
|
+
*
|
|
32
|
+
* function MyPagination() {
|
|
33
|
+
* const { currentPage, goToPage } = usePaginationState({
|
|
34
|
+
* pageCount: 10,
|
|
35
|
+
* initialPage: 1,
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* return (
|
|
39
|
+
* <Pagination
|
|
40
|
+
* pageCount={10}
|
|
41
|
+
* currentPage={currentPage}
|
|
42
|
+
* onPageChange={goToPage}
|
|
43
|
+
* >
|
|
44
|
+
* <PaginationContent>
|
|
45
|
+
* {Array.from({ length: 10 }, (_, i) => i + 1).map(page => (
|
|
46
|
+
* <PaginationItem key={page}>
|
|
47
|
+
* <RawPaginationLink value={page}>
|
|
48
|
+
* {page}
|
|
49
|
+
* </RawPaginationLink>
|
|
50
|
+
* </PaginationItem>
|
|
51
|
+
* ))}
|
|
52
|
+
* </PaginationContent>
|
|
53
|
+
* </Pagination>
|
|
54
|
+
* )
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function usePaginationState({ pageCount, initialPage, onPageChange, }: UsePaginationStateOptions): {
|
|
59
|
+
currentPage: number;
|
|
60
|
+
previousPage: number;
|
|
61
|
+
nextPage: number;
|
|
62
|
+
goToPage: (page: "previous" | "next" | number) => void;
|
|
63
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useState as l, useCallback as o } from "react";
|
|
2
|
+
function m({
|
|
3
|
+
pageCount: i,
|
|
4
|
+
initialPage: r = 1,
|
|
5
|
+
onPageChange: n
|
|
6
|
+
}) {
|
|
7
|
+
const [t, a] = l(r), c = t - 1, u = t + 1, s = o(
|
|
8
|
+
(e) => {
|
|
9
|
+
n && n(e, t, Math.sign(e - t)), a(Math.max(1, Math.min(i, e)));
|
|
10
|
+
},
|
|
11
|
+
[t, i, n]
|
|
12
|
+
), f = o(
|
|
13
|
+
(e) => {
|
|
14
|
+
s(e === "previous" ? t - 1 : e === "next" ? t + 1 : e);
|
|
15
|
+
},
|
|
16
|
+
[t, s]
|
|
17
|
+
);
|
|
18
|
+
return {
|
|
19
|
+
currentPage: t,
|
|
20
|
+
previousPage: c,
|
|
21
|
+
nextPage: u,
|
|
22
|
+
goToPage: f
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
m as usePaginationState
|
|
27
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type PaginationWindowItem = {
|
|
2
|
+
type: 'page';
|
|
3
|
+
value: number;
|
|
4
|
+
} | {
|
|
5
|
+
type: 'ellipsis';
|
|
6
|
+
value: [number, number];
|
|
7
|
+
};
|
|
8
|
+
export interface UsePaginationWindowOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The total number of pages.
|
|
11
|
+
* Use -1 to indicate an unknown page count (e.g., for infinite scroll or server-paginated data).
|
|
12
|
+
* When -1, the hook will show pages from 1 to currentPage + offset, ending with an ellipsis indicating unknown pages beyond.
|
|
13
|
+
*/
|
|
14
|
+
pageCount: number;
|
|
15
|
+
/**
|
|
16
|
+
* The current page (1-based)
|
|
17
|
+
*/
|
|
18
|
+
currentPage: number;
|
|
19
|
+
/**
|
|
20
|
+
* The maximum number of pages to show in the window
|
|
21
|
+
* @default 7
|
|
22
|
+
*/
|
|
23
|
+
windowSize?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hook that generates a pagination window with ellipsis for large page counts.
|
|
27
|
+
* This hook provides the logic for determining which pages to show in a pagination component.
|
|
28
|
+
* @param options - Configuration options for the pagination window
|
|
29
|
+
* @param options.pageCount - The total number of pages.
|
|
30
|
+
* @param options.currentPage - The current page (1-based).
|
|
31
|
+
* @param options.windowSize - The maximum number of pages to show in the window.
|
|
32
|
+
* @returns Array of pagination items (pages and ellipsis)
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { usePaginationWindow } from '@payfit/unity-components'
|
|
36
|
+
*
|
|
37
|
+
* function MyPagination() {
|
|
38
|
+
* const pages = usePaginationWindow({
|
|
39
|
+
* pageCount: 20,
|
|
40
|
+
* currentPage: 5,
|
|
41
|
+
* windowSize: 7
|
|
42
|
+
* })
|
|
43
|
+
*
|
|
44
|
+
* return (
|
|
45
|
+
* <Pagination>
|
|
46
|
+
* <PaginationContent>
|
|
47
|
+
* {pages.map((page, index) => (
|
|
48
|
+
* <PaginationItem key={index}>
|
|
49
|
+
* {page.type === 'page' ? (
|
|
50
|
+
* <RawPaginationLink href={`/page/${page.value}`}>
|
|
51
|
+
* {page.value}
|
|
52
|
+
* </RawPaginationLink>
|
|
53
|
+
* ) : (
|
|
54
|
+
* <PaginationEllipsis />
|
|
55
|
+
* )}
|
|
56
|
+
* </PaginationItem>
|
|
57
|
+
* ))}
|
|
58
|
+
* </PaginationContent>
|
|
59
|
+
* </Pagination>
|
|
60
|
+
* )
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function usePaginationWindow({ pageCount, currentPage, windowSize, }: UsePaginationWindowOptions): PaginationWindowItem[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMemo as t } from "react";
|
|
2
|
+
import { generatePaginationWithWindow as r } from "../utils/pagination-window.js";
|
|
3
|
+
function a({
|
|
4
|
+
pageCount: o,
|
|
5
|
+
currentPage: i,
|
|
6
|
+
windowSize: n = 7
|
|
7
|
+
}) {
|
|
8
|
+
return t(
|
|
9
|
+
() => r(o, i, n),
|
|
10
|
+
[o, i, n]
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
a as usePaginationWindow
|
|
15
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { VariantProps } from '@payfit/unity-themes';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
export declare const paginationContent: import('tailwind-variants').TVReturnType<{} | {} | {}, undefined, "uy:flex uy:gap-100 uy:list-none uy:m-0 uy:p-0", {} | {}, undefined, import('tailwind-variants').TVReturnType<unknown, undefined, "uy:flex uy:gap-100 uy:list-none uy:m-0 uy:p-0", unknown, unknown, undefined>>;
|
|
4
|
+
export interface PaginationContentProps extends VariantProps<typeof paginationContent>, ComponentPropsWithoutRef<'ul'> {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The PaginationContent component provides a list container for pagination items.
|
|
9
|
+
* This component renders as a ul element with proper list semantics.
|
|
10
|
+
* @param props.children - The children to render.
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { PaginationContent, PaginationItem, RawPaginationLink } from '@payfit/unity-components'
|
|
14
|
+
*
|
|
15
|
+
* function MyPaginationContent() {
|
|
16
|
+
* return (
|
|
17
|
+
* <PaginationContent>
|
|
18
|
+
* <PaginationItem>
|
|
19
|
+
* <RawPaginationLink href="/page/1">1</RawPaginationLink>
|
|
20
|
+
* </PaginationItem>
|
|
21
|
+
* <PaginationItem>
|
|
22
|
+
* <RawPaginationLink href="/page/2">2</RawPaginationLink>
|
|
23
|
+
* </PaginationItem>
|
|
24
|
+
* </PaginationContent>
|
|
25
|
+
* )
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare const PaginationContent: import('react').ForwardRefExoticComponent<PaginationContentProps & import('react').RefAttributes<HTMLUListElement>>;
|
|
30
|
+
export { PaginationContent };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as m, useMemo as p } from "react";
|
|
3
|
+
import { uyTv as g } from "@payfit/unity-themes";
|
|
4
|
+
import { useIntl as c } from "react-intl";
|
|
5
|
+
import { usePaginationContext as f } from "../PaginationContext.js";
|
|
6
|
+
const y = g({
|
|
7
|
+
base: "uy:flex uy:gap-100 uy:list-none uy:m-0 uy:p-0"
|
|
8
|
+
}), d = m(
|
|
9
|
+
({ children: t, ...o }, a) => {
|
|
10
|
+
const n = c(), { pageCount: e, currentPage: i, a11yIds: r } = f(), s = n.formatMessage(
|
|
11
|
+
{
|
|
12
|
+
id: "unity:component:pagination:page-list:label",
|
|
13
|
+
defaultMessage: "Page {current} of {total}"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
current: i,
|
|
17
|
+
total: e
|
|
18
|
+
}
|
|
19
|
+
), u = p(() => y(), []);
|
|
20
|
+
return /* @__PURE__ */ l(
|
|
21
|
+
"ul",
|
|
22
|
+
{
|
|
23
|
+
...o,
|
|
24
|
+
ref: a,
|
|
25
|
+
id: r.pagesList,
|
|
26
|
+
className: u,
|
|
27
|
+
"aria-label": s,
|
|
28
|
+
children: t
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
d.displayName = "PaginationContent";
|
|
34
|
+
export {
|
|
35
|
+
d as PaginationContent,
|
|
36
|
+
y as paginationContent
|
|
37
|
+
};
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import { VariantProps } from '@payfit/unity-themes';
|
|
2
2
|
import { ButtonProps } from 'react-aria-components';
|
|
3
|
-
import {
|
|
4
|
-
export interface PaginationEllipsisProps extends Omit<ButtonProps, 'value' | 'children' | 'className' | 'style' | 'slot'
|
|
5
|
-
|
|
3
|
+
declare const paginationEllipsis: import('tailwind-variants').TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import('tailwind-variants').TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>;
|
|
4
|
+
export interface PaginationEllipsisProps extends VariantProps<typeof paginationEllipsis>, Omit<ButtonProps, 'value' | 'children' | 'className' | 'style' | 'slot'> {
|
|
5
|
+
/**
|
|
6
|
+
* The id of the ellipsis element
|
|
7
|
+
*/
|
|
6
8
|
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the ellipsis is disabled
|
|
11
|
+
*/
|
|
7
12
|
isDisabled?: boolean;
|
|
8
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The range of pages represented by this ellipsis [start, end]
|
|
15
|
+
* When end is Infinity, it indicates an unknown page count
|
|
16
|
+
*/
|
|
17
|
+
value: [number, number];
|
|
9
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The PaginationEllipsis component renders an ellipsis indicator for pagination.
|
|
21
|
+
* This component is used to indicate that there are more pages between the visible range.
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { PaginationEllipsis } from '@payfit/unity-components'
|
|
25
|
+
*
|
|
26
|
+
* <PaginationEllipsis value={[5, 10]} />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
10
29
|
declare const PaginationEllipsis: import('react').ForwardRefExoticComponent<PaginationEllipsisProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
11
30
|
export { PaginationEllipsis };
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as a, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as r } from "react";
|
|
3
|
-
import { uyTv as
|
|
4
|
-
import { Button as
|
|
5
|
-
import { useIntl as p } from "react-intl";
|
|
6
|
-
const
|
|
3
|
+
import { uyTv as y } from "@payfit/unity-themes";
|
|
4
|
+
import { Button as c } from "react-aria-components";
|
|
5
|
+
import { useIntl as p, FormattedMessage as f } from "react-intl";
|
|
6
|
+
const m = y({
|
|
7
7
|
base: [
|
|
8
8
|
"uy:min-w-300 uy:h-300 uy:p-25 uy:flex uy:justify-center uy:items-center uy:typography-action uy:rounded-pill uy:cursor-default",
|
|
9
9
|
"uy:focus-visible:outline-2 uy:focus-visible:outline-solid uy:focus-visible:outline-utility-focus-ring uy:focus-visible:outline-offset-2"
|
|
10
10
|
]
|
|
11
|
-
}),
|
|
12
|
-
const t = p(), [
|
|
13
|
-
|
|
11
|
+
}), d = r(({ value: n, ...s }, o) => {
|
|
12
|
+
const t = p(), [u, e] = n, l = e === 1 / 0 ? t.formatMessage({
|
|
13
|
+
id: "unity:component:common:unknown",
|
|
14
|
+
defaultMessage: "unknown"
|
|
15
|
+
}) : e;
|
|
16
|
+
return /* @__PURE__ */ a(c, { ref: o, className: m(), ...s, children: [
|
|
14
17
|
/* @__PURE__ */ i("span", { "aria-hidden": !0, children: "…" }),
|
|
15
|
-
/* @__PURE__ */ i("span", { className: "uy:sr-only", children:
|
|
18
|
+
/* @__PURE__ */ i("span", { className: "uy:sr-only", children: /* @__PURE__ */ i(
|
|
19
|
+
f,
|
|
16
20
|
{
|
|
17
21
|
id: "unity:component:pagination:ellipsis:label",
|
|
18
|
-
defaultMessage: "More pages"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
defaultMessage: "More pages",
|
|
23
|
+
values: {
|
|
24
|
+
start: u,
|
|
25
|
+
end: l
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
) })
|
|
25
29
|
] });
|
|
26
30
|
});
|
|
27
|
-
|
|
31
|
+
d.displayName = "PaginationEllipsis";
|
|
28
32
|
export {
|
|
29
|
-
|
|
33
|
+
d as PaginationEllipsis
|
|
30
34
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
export interface PaginationItemProps extends ComponentPropsWithoutRef<'li'> {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* The position of this item in the set (for aria-posinset)
|
|
6
|
+
* If not provided, will be calculated from context
|
|
7
|
+
*/
|
|
8
|
+
pageNumber?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The total number of pages (for aria-setsize)
|
|
11
|
+
* If not provided, will be calculated from context
|
|
12
|
+
*/
|
|
13
|
+
pageCount?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The PaginationItem component provides a list item wrapper for individual pagination controls.
|
|
17
|
+
* This component renders as a li element and should contain pagination links or buttons.
|
|
18
|
+
* It automatically gets pageCount from context and calculates aria attributes.
|
|
19
|
+
* @param props.children - The children to render.
|
|
20
|
+
* @param props.pageNumber - The position of this item in the set (for aria-posinset).
|
|
21
|
+
* @param props.pageCount - The total number of pages (for aria-setsize).
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { PaginationItem, RawPaginationLink } from '@payfit/unity-components'
|
|
25
|
+
*
|
|
26
|
+
* function MyPaginationItem() {
|
|
27
|
+
* return (
|
|
28
|
+
* <PaginationItem pageNumber={1}>
|
|
29
|
+
* <RawPaginationLink href="/page/1" isActive>
|
|
30
|
+
* 1
|
|
31
|
+
* </RawPaginationLink>
|
|
32
|
+
* </PaginationItem>
|
|
33
|
+
* )
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare const PaginationItem: import('react').ForwardRefExoticComponent<PaginationItemProps & import('react').RefAttributes<HTMLLIElement>>;
|
|
38
|
+
export { PaginationItem };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as m } from "react";
|
|
3
|
+
import { usePaginationContext as p } from "../PaginationContext.js";
|
|
4
|
+
const f = m(
|
|
5
|
+
({ children: o, pageNumber: a, pageCount: i, ...e }, n) => {
|
|
6
|
+
const { pageCount: r } = p(), t = i ?? r;
|
|
7
|
+
return /* @__PURE__ */ s(
|
|
8
|
+
"li",
|
|
9
|
+
{
|
|
10
|
+
...e,
|
|
11
|
+
ref: n,
|
|
12
|
+
"aria-setsize": t !== -1 ? t : void 0,
|
|
13
|
+
"aria-posinset": a,
|
|
14
|
+
children: o
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
f.displayName = "PaginationItem";
|
|
20
|
+
export {
|
|
21
|
+
f as PaginationItem
|
|
22
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { VariantProps } from '@payfit/unity-themes';
|
|
2
|
+
import { LinkProps } from 'react-aria-components';
|
|
3
|
+
export declare const paginationLink: import('tailwind-variants').TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import('tailwind-variants').TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>;
|
|
4
|
+
export interface PaginationLinkProps extends LinkProps, VariantProps<typeof paginationLink> {
|
|
5
|
+
value: number;
|
|
6
|
+
id?: string;
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
isCurrent?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const RawPaginationLink: import('react').ForwardRefExoticComponent<PaginationLinkProps & import('react').RefAttributes<HTMLAnchorElement>>;
|
|
11
|
+
export { RawPaginationLink };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as h, useRef as v, useCallback as o } from "react";
|
|
3
|
+
import { uyTv as x } from "@payfit/unity-themes";
|
|
4
|
+
import { Link as P } from "react-aria-components";
|
|
5
|
+
import { useIntl as k } from "react-intl";
|
|
6
|
+
import { usePaginationContext as w } from "../PaginationContext.js";
|
|
7
|
+
const R = x({
|
|
8
|
+
base: [
|
|
9
|
+
"uy:min-w-300 uy:h-300 uy:p-25 uy:flex uy:justify-center uy:items-center uy:typography-action uy:rounded-pill uy:transition-colors",
|
|
10
|
+
"uy:enabled:text-content-neutral-enabled uy:enabled:bg-transparent uy:cursor-pointer",
|
|
11
|
+
"uy:data-[disabled]:text-content-neutral-disabled uy:data-[disabled]:bg-surface-neutral-disabled uy:data-[disabled]:cursor-not-allowed",
|
|
12
|
+
"uy:hover:text-content-neutral-hover uy:hover:bg-surface-neutral-hover",
|
|
13
|
+
"uy:active:text-content-neutral-pressed uy:active:bg-surface-neutral-pressed uy:data-[pressed]:text-content-neutral-pressed uy:data-[pressed]:bg-surface-neutral-pressed",
|
|
14
|
+
"uy:aria-[current=page]:bg-surface-neutral-active",
|
|
15
|
+
"uy:focus-visible:outline-2 uy:focus-visible:outline-solid uy:focus-visible:outline-utility-focus-ring uy:focus-visible:outline-offset-2",
|
|
16
|
+
"uy:data-[focus-visible]:outline-2 uy:data-[focus-visible]:outline-solid uy:data-[focus-visible]:outline-utility-focus-ring uy:data-[focus-visible]:outline-offset-2"
|
|
17
|
+
]
|
|
18
|
+
}), C = h(
|
|
19
|
+
({ isCurrent: r, isDisabled: l, value: t, onPress: c, ...i }, n) => {
|
|
20
|
+
const y = k(), { currentPage: a, onKeyDown: f, pageRefs: s, onPageChange: u } = w(), d = v(null), g = o(
|
|
21
|
+
(e) => {
|
|
22
|
+
d.current = e, e ? s.current.set(t, e) : s.current.delete(t), typeof n == "function" ? n(e) : n && (n.current = e);
|
|
23
|
+
},
|
|
24
|
+
[t, s, n]
|
|
25
|
+
), b = r ?? a === t, p = o(() => {
|
|
26
|
+
if (!i.href) {
|
|
27
|
+
const e = t > a ? 1 : -1;
|
|
28
|
+
u(t, a, e);
|
|
29
|
+
}
|
|
30
|
+
}, [t, a, u, i.href]);
|
|
31
|
+
return /* @__PURE__ */ m(
|
|
32
|
+
P,
|
|
33
|
+
{
|
|
34
|
+
...i,
|
|
35
|
+
ref: g,
|
|
36
|
+
className: R(),
|
|
37
|
+
isDisabled: l,
|
|
38
|
+
onPress: c ?? p,
|
|
39
|
+
"aria-current": b ? "page" : void 0,
|
|
40
|
+
"aria-label": y.formatMessage(
|
|
41
|
+
{
|
|
42
|
+
id: "unity:component:pagination:link:label",
|
|
43
|
+
defaultMessage: "Page {page}"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
page: t
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
onKeyDown: (e) => {
|
|
50
|
+
f(e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
C.displayName = "RawPaginationLink";
|
|
57
|
+
export {
|
|
58
|
+
C as RawPaginationLink,
|
|
59
|
+
R as paginationLink
|
|
60
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { VariantProps } from '@payfit/unity-themes';
|
|
2
|
+
import { LinkProps } from 'react-aria-components';
|
|
3
|
+
declare const paginationNavButton: import('tailwind-variants').TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import('tailwind-variants').TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>;
|
|
4
|
+
export interface RawPaginationNextProps extends Omit<LinkProps, 'children' | 'className' | 'style' | 'isDisabled' | 'aria-label' | 'title'>, VariantProps<typeof paginationNavButton> {
|
|
5
|
+
id?: string;
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
href?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The RawPaginationNext component renders a "Next" link for pagination.
|
|
11
|
+
* This component is always a link for consistent integration with routing libraries.
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { RawPaginationNext } from '@payfit/unity-components'
|
|
15
|
+
*
|
|
16
|
+
* <RawPaginationNext href="/page/3" isDisabled={currentPage === pageCount}>
|
|
17
|
+
* Next
|
|
18
|
+
* </RawPaginationNext>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const RawPaginationNext: import('react').ForwardRefExoticComponent<RawPaginationNextProps & import('react').RefAttributes<HTMLAnchorElement>>;
|
|
22
|
+
export { RawPaginationNext };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as g } from "react";
|
|
3
|
+
import { uyTv as b } from "@payfit/unity-themes";
|
|
4
|
+
import { Link as x } from "react-aria-components";
|
|
5
|
+
import { useIntl as v } from "react-intl";
|
|
6
|
+
import { Icon as h } from "../../icon/Icon.js";
|
|
7
|
+
import { Tooltip as w } from "../../tooltip/Tooltip.js";
|
|
8
|
+
import { usePaginationContext as P } from "../PaginationContext.js";
|
|
9
|
+
const N = b({
|
|
10
|
+
base: [
|
|
11
|
+
"uy:min-w-300 uy:h-300 uy:p-25 uy:flex uy:justify-center uy:items-center uy:typography-action uy:rounded-circle uy:transition-colors",
|
|
12
|
+
"uy:text-content-neutral-lowest uy:enabled:bg-transparent uy:cursor-pointer",
|
|
13
|
+
"uy:hover:text-content-neutral-hover uy:hover:bg-surface-neutral-hover",
|
|
14
|
+
"uy:active:text-content-neutral-pressed uy:active:bg-surface-neutral-pressed",
|
|
15
|
+
"uy:data-[pressed]:text-content-neutral-pressed uy:data-[pressed]:bg-surface-neutral-pressed",
|
|
16
|
+
"uy:data-[disabled]:text-content-neutral-disabled uy:data-[disabled]:bg-transparent uy:data-[disabled]:cursor-not-allowed",
|
|
17
|
+
"uy:focus-visible:outline-2 uy:focus-visible:outline-solid uy:focus-visible:outline-utility-focus-ring uy:focus-visible:outline-offset-2"
|
|
18
|
+
]
|
|
19
|
+
}), D = g(
|
|
20
|
+
({ isDisabled: i, href: o, onPress: s, ...u }, l) => {
|
|
21
|
+
const a = v(), {
|
|
22
|
+
onKeyDown: c,
|
|
23
|
+
currentPage: e,
|
|
24
|
+
pageCount: r,
|
|
25
|
+
onPageChange: y
|
|
26
|
+
} = P(), t = a.formatMessage({
|
|
27
|
+
id: "unity:component:common:next",
|
|
28
|
+
defaultMessage: "Next"
|
|
29
|
+
}), d = a.formatMessage(
|
|
30
|
+
{
|
|
31
|
+
id: "unity:component:pagination:nav-button:description",
|
|
32
|
+
defaultMessage: "Go to next page"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
variant: t
|
|
36
|
+
}
|
|
37
|
+
), p = (m) => {
|
|
38
|
+
c(m);
|
|
39
|
+
}, f = () => {
|
|
40
|
+
!o && (r === -1 || e < r) && y(e + 1, e, 1);
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ n(w, { title: t, children: /* @__PURE__ */ n(
|
|
43
|
+
x,
|
|
44
|
+
{
|
|
45
|
+
ref: l,
|
|
46
|
+
href: o,
|
|
47
|
+
className: N(),
|
|
48
|
+
isDisabled: i,
|
|
49
|
+
onPress: s ?? f,
|
|
50
|
+
"aria-label": t,
|
|
51
|
+
"aria-description": d,
|
|
52
|
+
onKeyDown: p,
|
|
53
|
+
...u,
|
|
54
|
+
children: /* @__PURE__ */ n(
|
|
55
|
+
h,
|
|
56
|
+
{
|
|
57
|
+
src: "CaretRightOutlined",
|
|
58
|
+
size: 20,
|
|
59
|
+
color: "inherit",
|
|
60
|
+
role: "presentation"
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
) });
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
D.displayName = "RawPaginationNext";
|
|
68
|
+
export {
|
|
69
|
+
D as RawPaginationNext
|
|
70
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { VariantProps } from '@payfit/unity-themes';
|
|
2
|
+
import { LinkProps } from 'react-aria-components';
|
|
3
|
+
declare const paginationNavButton: import('tailwind-variants').TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import('tailwind-variants').TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>;
|
|
4
|
+
export interface RawPaginationPreviousProps extends Omit<LinkProps, 'children' | 'className' | 'style' | 'isDisabled' | 'aria-label' | 'title'>, VariantProps<typeof paginationNavButton> {
|
|
5
|
+
id?: string;
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
href?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The RawPaginationPrevious component renders a "Next" link for pagination.
|
|
11
|
+
* This component is always a link for consistent integration with routing libraries.
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { RawPaginationPrevious } from '@payfit/unity-components'
|
|
15
|
+
*
|
|
16
|
+
* <RawPaginationPrevious href="/page/3" isDisabled={currentPage === pageCount}>
|
|
17
|
+
* Next
|
|
18
|
+
* </RawPaginationPrevious>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const RawPaginationPrevious: import('react').ForwardRefExoticComponent<RawPaginationPreviousProps & import('react').RefAttributes<HTMLAnchorElement>>;
|
|
22
|
+
export { RawPaginationPrevious };
|