@axa-fr/design-system-apollo-react 3.1.2-alpha.2 → 3.1.2-alpha.3
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/Pagination/ItemPagination/ItemPaginationApollo.d.ts +3 -0
- package/dist/Pagination/ItemPagination/ItemPaginationApollo.js +3 -0
- package/dist/Pagination/ItemPagination/ItemPaginationCommon.d.ts +10 -0
- package/dist/Pagination/ItemPagination/ItemPaginationCommon.js +11 -0
- package/dist/Pagination/ItemPagination/ItemPaginationLF.d.ts +3 -0
- package/dist/Pagination/ItemPagination/ItemPaginationLF.js +3 -0
- package/dist/Pagination/Pagination.helper.d.ts +9 -0
- package/dist/Pagination/Pagination.helper.js +34 -0
- package/dist/Pagination/PaginationApollo.d.ts +4 -0
- package/dist/Pagination/PaginationApollo.js +5 -0
- package/dist/Pagination/PaginationCommon.d.ts +14 -0
- package/dist/Pagination/PaginationCommon.js +20 -0
- package/dist/Pagination/PaginationLF.d.ts +4 -0
- package/dist/Pagination/PaginationLF.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/indexLF.d.ts +2 -0
- package/dist/indexLF.js +2 -0
- package/dist/utilities/types/PolymorphicComponent.d.ts +8 -0
- package/dist/utilities/types/PolymorphicComponent.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "@axa-fr/design-system-apollo-css/dist/Pagination/ItemPagination/ItemPaginationApollo.css";
|
|
2
|
+
export { type ItemPaginationCommonProps as ItemPaginationProps } from "./ItemPaginationCommon";
|
|
3
|
+
export declare const ItemPagination: <T extends import("react").ElementType = "a">({ as, page, isCurrentPage, className, ...props }: import("./ItemPaginationCommon").ItemPaginationCommonProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ElementType } from "react";
|
|
2
|
+
import { type PolymorphicComponent } from "../../utilities/types/PolymorphicComponent";
|
|
3
|
+
export declare const ELLIPSIS = "...";
|
|
4
|
+
type ItemPaginationCustomProps = {
|
|
5
|
+
page: number | typeof ELLIPSIS;
|
|
6
|
+
isCurrentPage: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ItemPaginationCommonProps<T extends ElementType> = PolymorphicComponent<T, ItemPaginationCustomProps>;
|
|
9
|
+
export declare const ItemPaginationCommon: <T extends ElementType = "a">({ as, page, isCurrentPage, className, ...props }: ItemPaginationCommonProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getClassName } from "../../utilities/getClassName";
|
|
3
|
+
export const ELLIPSIS = "...";
|
|
4
|
+
export const ItemPaginationCommon = ({ as, page, isCurrentPage, className, ...props }) => {
|
|
5
|
+
const Component = page === ELLIPSIS ? "span" : as || "a";
|
|
6
|
+
return (_jsx(Component, { href: Component === "a" ? `/${page}` : undefined, type: Component === "button" ? "button" : undefined, "aria-current": Component === "a" && isCurrentPage ? "page" : undefined, className: getClassName({
|
|
7
|
+
baseClassName: "af-item-pagination",
|
|
8
|
+
className,
|
|
9
|
+
modifiers: [isCurrentPage ? "current" : undefined],
|
|
10
|
+
}), ...props, children: page }));
|
|
11
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "@axa-fr/design-system-apollo-css/dist/Pagination/ItemPagination/ItemPaginationLF.css";
|
|
2
|
+
export { type ItemPaginationCommonProps as ItemPaginationProps } from "./ItemPaginationCommon";
|
|
3
|
+
export declare const ItemPagination: <T extends import("react").ElementType = "a">({ as, page, isCurrentPage, className, ...props }: import("./ItemPaginationCommon").ItemPaginationCommonProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ElementType } from "react";
|
|
2
|
+
import type { ItemPaginationCommonProps } from "./ItemPagination/ItemPaginationCommon";
|
|
3
|
+
export type getItemsProps = {
|
|
4
|
+
numberPages: number;
|
|
5
|
+
onChangePage: (page: number) => void;
|
|
6
|
+
currentPage: number;
|
|
7
|
+
asItem?: ElementType;
|
|
8
|
+
};
|
|
9
|
+
export declare const getItems: ({ numberPages, currentPage, asItem, onChangePage, }: getItemsProps) => ItemPaginationCommonProps<ElementType>[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ELLIPSIS } from "./ItemPagination/ItemPaginationCommon";
|
|
2
|
+
const MAX_PAGE = 7;
|
|
3
|
+
const ellipsisItem = {
|
|
4
|
+
page: ELLIPSIS,
|
|
5
|
+
isCurrentPage: false,
|
|
6
|
+
};
|
|
7
|
+
export const getItems = ({ numberPages, currentPage, asItem, onChangePage, }) => {
|
|
8
|
+
const items = Array.from({ length: numberPages }, (_, index) => ({
|
|
9
|
+
page: index + 1,
|
|
10
|
+
isCurrentPage: index + 1 === currentPage,
|
|
11
|
+
as: asItem,
|
|
12
|
+
onClick: () => onChangePage(index + 1),
|
|
13
|
+
}));
|
|
14
|
+
if (numberPages <= MAX_PAGE) {
|
|
15
|
+
return items;
|
|
16
|
+
}
|
|
17
|
+
if (currentPage && currentPage < MAX_PAGE - 1) {
|
|
18
|
+
return items.toSpliced(MAX_PAGE - 1, numberPages - 1, ellipsisItem, items[numberPages - 1]);
|
|
19
|
+
}
|
|
20
|
+
if (currentPage && currentPage > numberPages - (MAX_PAGE - 2)) {
|
|
21
|
+
return [
|
|
22
|
+
items[0],
|
|
23
|
+
ellipsisItem,
|
|
24
|
+
...items.toSpliced(0, numberPages - (MAX_PAGE - 1)),
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
return [
|
|
28
|
+
items[0],
|
|
29
|
+
ellipsisItem,
|
|
30
|
+
...items.toSpliced(0, currentPage - 2).toSpliced(3, numberPages - 1),
|
|
31
|
+
ellipsisItem,
|
|
32
|
+
items[numberPages - 1],
|
|
33
|
+
];
|
|
34
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import "@axa-fr/design-system-apollo-css/dist/Pagination/PaginationApollo.css";
|
|
2
|
+
import { type PaginationProps } from "./PaginationCommon";
|
|
3
|
+
export { type PaginationProps } from "./PaginationCommon";
|
|
4
|
+
export declare const Pagination: (props: PaginationProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@axa-fr/design-system-apollo-css/dist/Pagination/PaginationApollo.css";
|
|
3
|
+
import { ItemPagination } from "./ItemPagination/ItemPaginationApollo";
|
|
4
|
+
import { PaginationCommon } from "./PaginationCommon";
|
|
5
|
+
export const Pagination = (props) => (_jsx(PaginationCommon, { ...props, ItemPaginationComponent: ItemPagination }));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentProps, ComponentType, type ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { ClickIcon } from "../ClickIcon/ClickIconApollo";
|
|
3
|
+
import { ItemPaginationCommon } from "./ItemPagination/ItemPaginationCommon";
|
|
4
|
+
import { type getItemsProps } from "./Pagination.helper";
|
|
5
|
+
export type PaginationProps = getItemsProps & ComponentPropsWithoutRef<"nav"> & {
|
|
6
|
+
hidePrevNext?: boolean;
|
|
7
|
+
prevButtonProps?: ComponentProps<typeof ClickIcon>;
|
|
8
|
+
nextButtonProps?: ComponentProps<typeof ClickIcon>;
|
|
9
|
+
};
|
|
10
|
+
type PaginationCommonProps = PaginationProps & {
|
|
11
|
+
ItemPaginationComponent: ComponentType<ComponentProps<typeof ItemPaginationCommon>>;
|
|
12
|
+
};
|
|
13
|
+
export declare const PaginationCommon: ({ numberPages, onChangePage, className, currentPage, asItem, hidePrevNext, "aria-label": ariaLabel, ItemPaginationComponent, prevButtonProps, nextButtonProps, }: PaginationCommonProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import chevronBackward from "@material-symbols/svg-400/rounded/chevron_backward.svg";
|
|
3
|
+
import chevronForward from "@material-symbols/svg-400/rounded/chevron_forward.svg";
|
|
4
|
+
import { getClassName } from "../utilities/getClassName";
|
|
5
|
+
import { ClickIcon } from "../ClickIcon/ClickIconApollo";
|
|
6
|
+
import { ELLIPSIS, } from "./ItemPagination/ItemPaginationCommon";
|
|
7
|
+
import { getItems } from "./Pagination.helper";
|
|
8
|
+
export const PaginationCommon = ({ numberPages = 1, onChangePage, className, currentPage = 1, asItem, hidePrevNext = false, "aria-label": ariaLabel = "Pagination", ItemPaginationComponent, prevButtonProps, nextButtonProps, }) => {
|
|
9
|
+
const items = getItems({
|
|
10
|
+
numberPages,
|
|
11
|
+
currentPage,
|
|
12
|
+
asItem,
|
|
13
|
+
onChangePage,
|
|
14
|
+
});
|
|
15
|
+
return (_jsx("nav", { className: getClassName({
|
|
16
|
+
baseClassName: "af-pagination",
|
|
17
|
+
className,
|
|
18
|
+
modifiers: [hidePrevNext ? "hide-prev-next" : undefined],
|
|
19
|
+
}), "aria-label": ariaLabel, children: _jsxs("ol", { className: "af-pagination-list", children: [_jsx("li", { children: _jsx(ClickIcon, { src: chevronBackward, onClick: () => onChangePage(currentPage - 1), disabled: currentPage === 1, "aria-label": "Page pr\u00E9c\u00E9dente", ...prevButtonProps }) }), _jsx("li", { children: _jsx("span", { className: "af-pagination-counter", children: `Page ${currentPage} sur ${numberPages}` }) }), items.map((item, index) => (_jsx("li", { children: _jsx(ItemPaginationComponent, { ...item }) }, item.page === ELLIPSIS ? `ellipsis-${index}` : item.page))), _jsx("li", { children: _jsx(ClickIcon, { src: chevronForward, onClick: () => onChangePage(currentPage + 1), disabled: currentPage === numberPages, "aria-label": "Page suivante", ...nextButtonProps }) })] }) }));
|
|
20
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import "@axa-fr/design-system-apollo-css/dist/Pagination/PaginationLF.css";
|
|
2
|
+
import { type PaginationProps } from "./PaginationCommon";
|
|
3
|
+
export { type PaginationProps } from "./PaginationCommon";
|
|
4
|
+
export declare const Pagination: (props: PaginationProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@axa-fr/design-system-apollo-css/dist/Pagination/PaginationLF.css";
|
|
3
|
+
import { ItemPagination } from "./ItemPagination/ItemPaginationLF";
|
|
4
|
+
import { PaginationCommon } from "./PaginationCommon";
|
|
5
|
+
export const Pagination = (props) => (_jsx(PaginationCommon, { ...props, ItemPaginationComponent: ItemPagination }));
|
package/dist/index.d.ts
CHANGED
|
@@ -52,3 +52,5 @@ export { TabBar, tabBarDirection, type TabBarDirection, type TabBarProps, } from
|
|
|
52
52
|
export { Tag, tagVariants, type TagVariants } from "./Tag/TagApollo";
|
|
53
53
|
export { TimelineVertical } from "./TimelineVertical/TimelineVerticalApollo";
|
|
54
54
|
export { Toggle } from "./Toggle/ToggleApollo";
|
|
55
|
+
export { Pagination } from "./Pagination/PaginationApollo";
|
|
56
|
+
export { ItemPagination, type ItemPaginationProps, } from "./Pagination/ItemPagination/ItemPaginationApollo";
|
package/dist/index.js
CHANGED
|
@@ -51,3 +51,5 @@ export { TabBar, tabBarDirection, } from "./TabBar/TabBarApollo";
|
|
|
51
51
|
export { Tag, tagVariants } from "./Tag/TagApollo";
|
|
52
52
|
export { TimelineVertical } from "./TimelineVertical/TimelineVerticalApollo";
|
|
53
53
|
export { Toggle } from "./Toggle/ToggleApollo";
|
|
54
|
+
export { Pagination } from "./Pagination/PaginationApollo";
|
|
55
|
+
export { ItemPagination, } from "./Pagination/ItemPagination/ItemPaginationApollo";
|
package/dist/indexLF.d.ts
CHANGED
|
@@ -56,3 +56,5 @@ export { TabBar, tabBarDirection, type TabBarDirection, type TabBarProps, } from
|
|
|
56
56
|
export { Tag, tagVariants, type TagVariants } from "./Tag/TagLF";
|
|
57
57
|
export { TimelineVertical } from "./TimelineVertical/TimelineVerticalLF";
|
|
58
58
|
export { Toggle } from "./Toggle/ToggleLF";
|
|
59
|
+
export { Pagination } from "./Pagination/PaginationLF";
|
|
60
|
+
export { ItemPagination, type ItemPaginationProps, } from "./Pagination/ItemPagination/ItemPaginationLF";
|
package/dist/indexLF.js
CHANGED
|
@@ -55,3 +55,5 @@ export { TabBar, tabBarDirection, } from "./TabBar/TabBarLF";
|
|
|
55
55
|
export { Tag, tagVariants } from "./Tag/TagLF";
|
|
56
56
|
export { TimelineVertical } from "./TimelineVertical/TimelineVerticalLF";
|
|
57
57
|
export { Toggle } from "./Toggle/ToggleLF";
|
|
58
|
+
export { Pagination } from "./Pagination/PaginationLF";
|
|
59
|
+
export { ItemPagination, } from "./Pagination/ItemPagination/ItemPaginationLF";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ElementType } from "react";
|
|
2
|
+
type PolymorphicRef<C extends ElementType> = ComponentPropsWithRef<C>["ref"];
|
|
3
|
+
export type PolymorphicComponent<C extends ElementType, Props = object> = Props & Omit<ComponentPropsWithRef<C>, keyof Props | "as"> & {
|
|
4
|
+
as?: C;
|
|
5
|
+
} & {
|
|
6
|
+
ref?: PolymorphicRef<C>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/design-system-apollo-react",
|
|
3
|
-
"version": "3.1.2-alpha.
|
|
3
|
+
"version": "3.1.2-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@axa-fr/design-system-apollo-css": "3.1.2-alpha.
|
|
49
|
+
"@axa-fr/design-system-apollo-css": "3.1.2-alpha.3",
|
|
50
50
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
51
51
|
"react": ">= 18"
|
|
52
52
|
},
|