@yamada-ui/pagination 1.0.42-next-20241008193728 → 1.0.43-dev-20241014122238

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,11 @@
1
1
  "use client"
2
2
  import {
3
3
  PaginationItem
4
- } from "./chunk-GOSRKZFX.mjs";
4
+ } from "./chunk-PUQ5FNCP.mjs";
5
5
  import {
6
6
  PaginationProvider,
7
7
  usePagination
8
- } from "./chunk-GKZNNZOM.mjs";
8
+ } from "./chunk-O6EIBNLC.mjs";
9
9
 
10
10
  // src/pagination.tsx
11
11
  import {
@@ -57,14 +57,14 @@ var Pagination = forwardRef((props, ref) => {
57
57
  () => range.map((page2, key) => /* @__PURE__ */ jsx(
58
58
  Component,
59
59
  {
60
- "aria-label": page2 === "dots" ? "Jump to omitted pages" : `Go to page ${page2}`,
60
+ "aria-label": page2 === "ellipsis" ? "Jump to omitted pages" : `Go to page ${page2}`,
61
61
  isActive: currentPage === page2,
62
62
  isDisabled,
63
63
  page: page2,
64
64
  ...itemProps,
65
65
  onClick: handlerAll(
66
66
  itemProps == null ? void 0 : itemProps.onClick,
67
- page2 !== "dots" ? () => onChange(page2) : void 0
67
+ page2 !== "ellipsis" ? () => onChange(page2) : void 0
68
68
  )
69
69
  },
70
70
  key
@@ -174,4 +174,4 @@ Pagination.__ui__ = "Pagination";
174
174
  export {
175
175
  Pagination
176
176
  };
177
- //# sourceMappingURL=chunk-PGW7Y4GO.mjs.map
177
+ //# sourceMappingURL=chunk-E35BXOXS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/pagination.tsx"],"sourcesContent":["import type {\n CSSUIObject,\n HTMLUIProps,\n ThemeProps,\n Token,\n} from \"@yamada-ui/core\"\nimport type { ComponentPropsWithoutRef, FC } from \"react\"\nimport type { PaginationItemProps } from \"./pagination-item\"\nimport type { UsePaginationProps } from \"./use-pagination\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { useValue } from \"@yamada-ui/use-value\"\nimport { cx, dataAttr, handlerAll } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\nimport { PaginationItem } from \"./pagination-item\"\nimport { PaginationProvider, usePagination } from \"./use-pagination\"\n\ninterface PaginationOptions {\n /**\n * The pagination button component to use.\n */\n component?: FC<PaginationItemProps>\n /**\n * If `true`, display the control buttons.\n *\n * @default true\n */\n withControls?: Token<boolean>\n /**\n * If `true`, display the edge buttons.\n *\n * @default false\n */\n withEdges?: Token<boolean>\n /**\n * Props for next of the control button element.\n */\n controlNextProps?: HTMLUIProps<\"button\">\n /**\n * Props for previous of the control button element.\n */\n controlPrevProps?: HTMLUIProps<\"button\">\n /**\n * Props for control button element.\n */\n controlProps?: HTMLUIProps<\"button\">\n /**\n * Props for first of the edge button element.\n */\n edgeFirstProps?: HTMLUIProps<\"button\">\n /**\n * Props for last of the edge button element.\n */\n edgeLastProps?: HTMLUIProps<\"button\">\n /**\n * Props for edge button element.\n */\n edgeProps?: HTMLUIProps<\"button\">\n /**\n * Props for inner element.\n */\n innerProps?: HTMLUIProps\n /**\n * Props for button element.\n */\n itemProps?: HTMLUIProps<\"button\">\n}\n\nexport interface PaginationProps\n extends Omit<HTMLUIProps, \"children\" | \"onChange\" | \"page\">,\n ThemeProps<\"Pagination\">,\n UsePaginationProps,\n PaginationOptions {}\n\n/**\n * `Pagination` is a component for managing the pagination and navigation of content.\n *\n * @see Docs https://yamada-ui.com/components/navigation/pagination\n */\nexport const Pagination = forwardRef<PaginationProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Pagination\", props)\n const {\n className,\n boundaries,\n component: Component = PaginationItem,\n defaultPage,\n isDisabled,\n page,\n siblings,\n total,\n withControls: _withControls = true,\n withEdges: _withEdges = false,\n controlNextProps,\n controlPrevProps,\n controlProps,\n edgeFirstProps,\n edgeLastProps,\n edgeProps,\n innerProps,\n itemProps,\n onChange: onChangeProp,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const withControls = useValue(_withControls)\n const withEdges = useValue(_withEdges)\n\n const { currentPage, range, onChange, onFirst, onLast, onNext, onPrev } =\n usePagination({\n boundaries,\n defaultPage,\n isDisabled,\n page,\n siblings,\n total,\n onChange: onChangeProp,\n })\n\n const children = useMemo(\n () =>\n range.map((page, key) => (\n <Component\n key={key}\n aria-label={\n page === \"ellipsis\" ? \"Jump to omitted pages\" : `Go to page ${page}`\n }\n isActive={currentPage === page}\n isDisabled={isDisabled}\n page={page}\n {...(itemProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n itemProps?.onClick,\n page !== \"ellipsis\" ? () => onChange(page) : undefined,\n )}\n />\n )),\n [Component, currentPage, isDisabled, onChange, range, itemProps],\n )\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n ...styles.container,\n }\n\n return (\n <PaginationProvider value={styles}>\n <ui.div\n ref={ref}\n className={cx(\"ui-pagination\", className)}\n role=\"navigation\"\n __css={css}\n {...rest}\n data-disabled={dataAttr(isDisabled)}\n >\n {withEdges ? (\n <Component\n className=\"ui-pagination__item--first\"\n aria-label=\"Go to first page\"\n isDisabled={isDisabled || currentPage === 1}\n page=\"first\"\n {...(edgeProps as ComponentPropsWithoutRef<\"button\">)}\n {...(edgeFirstProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n edgeProps?.onClick,\n edgeFirstProps?.onClick,\n onFirst,\n )}\n />\n ) : null}\n\n {withControls ? (\n <Component\n className=\"ui-pagination__item--prev\"\n aria-label=\"Go to previous page\"\n isDisabled={isDisabled || currentPage === 1}\n page=\"prev\"\n {...(controlProps as ComponentPropsWithoutRef<\"button\">)}\n {...(controlPrevProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n controlProps?.onClick,\n controlPrevProps?.onClick,\n onPrev,\n )}\n />\n ) : null}\n\n <ui.div\n className=\"ui-pagination-inner\"\n __css={{\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n ...styles.inner,\n }}\n {...innerProps}\n >\n {children}\n </ui.div>\n\n {withControls ? (\n <Component\n className=\"ui-pagination__item--next\"\n aria-label=\"Go to next page\"\n isDisabled={isDisabled || currentPage === total}\n page=\"next\"\n {...(controlProps as ComponentPropsWithoutRef<\"button\">)}\n {...(controlNextProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n controlProps?.onClick,\n controlNextProps?.onClick,\n onNext,\n )}\n />\n ) : null}\n\n {withEdges ? (\n <Component\n className=\"ui-pagination__item--last\"\n aria-label=\"Go to last page\"\n isDisabled={isDisabled || currentPage === total}\n page=\"last\"\n {...(edgeProps as ComponentPropsWithoutRef<\"button\">)}\n {...(edgeLastProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n edgeProps?.onClick,\n edgeLastProps?.onClick,\n onLast,\n )}\n />\n ) : null}\n </ui.div>\n </PaginationProvider>\n )\n})\n\nPagination.displayName = \"Pagination\"\nPagination.__ui__ = \"Pagination\"\n"],"mappings":";;;;;;;;;;AASA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS,IAAI,UAAU,kBAAkB;AACzC,SAAS,eAAe;AA4GhB,cA0BF,YA1BE;AA1CD,IAAM,aAAa,WAAmC,CAAC,OAAO,QAAQ;AAC3E,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,cAAc,KAAK;AACxE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,WAAW,YAAY;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,gBAAgB;AAAA,IAC9B,WAAW,aAAa;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,GAAG;AAAA,EACL,IAAI,eAAe,WAAW;AAE9B,QAAM,eAAe,SAAS,aAAa;AAC3C,QAAM,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AAY,cAAc,gBAAgB;AAAA,YAC1C,MAAK;AAAA,YACJ,GAAI;AAAA,YACJ,GAAI;AAAA,YACL,SAAS;AAAA,cACP,6CAAc;AAAA,cACd,qDAAkB;AAAA,cAClB;AAAA,YACF;AAAA;AAAA,QACF,IACE;AAAA,QAEJ;AAAA,UAAC,GAAG;AAAA,UAAH;AAAA,YACC,WAAU;AAAA,YACV,OAAO;AAAA,cACL,YAAY;AAAA,cACZ,SAAS;AAAA,cACT,gBAAgB;AAAA,cAChB,GAAG,OAAO;AAAA,YACZ;AAAA,YACC,GAAG;AAAA,YAEH;AAAA;AAAA,QACH;AAAA,QAEC,eACC;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,cAAW;AAAA,YACX,YAAY,cAAc,gBAAgB;AAAA,YAC1C,MAAK;AAAA,YACJ,GAAI;AAAA,YACJ,GAAI;AAAA,YACL,SAAS;AAAA,cACP,6CAAc;AAAA,cACd,qDAAkB;AAAA,cAClB;AAAA,YACF;AAAA;AAAA,QACF,IACE;AAAA,QAEH,YACC;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,cAAW;AAAA,YACX,YAAY,cAAc,gBAAgB;AAAA,YAC1C,MAAK;AAAA,YACJ,GAAI;AAAA,YACJ,GAAI;AAAA,YACL,SAAS;AAAA,cACP,uCAAW;AAAA,cACX,+CAAe;AAAA,cACf;AAAA,YACF;AAAA;AAAA,QACF,IACE;AAAA;AAAA;AAAA,EACN,GACF;AAEJ,CAAC;AAED,WAAW,cAAc;AACzB,WAAW,SAAS;","names":["page"]}
@@ -54,7 +54,7 @@ var usePagination = ({
54
54
  const prevPages = siblings * 2 + boundaries + 2;
55
55
  return [
56
56
  ...computedRange(1, prevPages),
57
- "dots",
57
+ "ellipsis",
58
58
  ...computedRange(total - (boundaries - 1), total)
59
59
  ];
60
60
  }
@@ -62,15 +62,15 @@ var usePagination = ({
62
62
  const nextPages = boundaries + 1 + 2 * siblings;
63
63
  return [
64
64
  ...computedRange(1, boundaries),
65
- "dots",
65
+ "ellipsis",
66
66
  ...computedRange(total - nextPages, total)
67
67
  ];
68
68
  }
69
69
  return [
70
70
  ...computedRange(1, boundaries),
71
- "dots",
71
+ "ellipsis",
72
72
  ...computedRange(prevSiblings, nextSiblings),
73
- "dots",
73
+ "ellipsis",
74
74
  ...computedRange(total - boundaries + 1, total)
75
75
  ];
76
76
  }, [boundaries, siblings, currentPage, total]);
@@ -93,4 +93,4 @@ export {
93
93
  computedRange,
94
94
  usePagination
95
95
  };
96
- //# sourceMappingURL=chunk-GKZNNZOM.mjs.map
96
+ //# sourceMappingURL=chunk-O6EIBNLC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-pagination.ts"],"sourcesContent":["import type { CSSUIObject, Token } from \"@yamada-ui/core\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useValue } from \"@yamada-ui/use-value\"\nimport { createContext } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo } from \"react\"\n\ninterface PaginationContext {\n [key: string]: CSSUIObject | undefined\n}\n\nexport const [PaginationProvider, usePaginationContext] =\n createContext<PaginationContext>({\n name: \"PaginationContext\",\n errorMessage: `usePaginationContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Pagination />\"`,\n })\n\nexport const computedRange = (start: number, end: number) =>\n Array.from({ length: end - start + 1 }, (_, index) => index + start)\n\nexport interface UsePaginationProps {\n /**\n * The total number of pages in pagination.\n */\n total: number\n /**\n * Number of elements visible on the left/right edges.\n *\n * @default 1\n */\n boundaries?: Token<number>\n /**\n * The initial page of the pagination.\n * Should be less than `total` and greater than `1`.\n *\n * @default 1\n */\n defaultPage?: number\n /**\n * If `true`, the pagination all item will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n /**\n * The page of the pagination.\n * Should be less than `total` and greater than `1`.\n */\n page?: number\n /** Number of siblings displayed on the left/right side of selected page.\n *\n * @default 1\n */\n siblings?: Token<number>\n /**\n * The callback invoked when the page changes.\n */\n onChange?: (page: number) => void\n}\n\nexport const usePagination = ({\n boundaries: _boundaries = 1,\n defaultPage = 1,\n isDisabled = false,\n page,\n siblings: _siblings = 1,\n total,\n onChange: onChangeProp,\n}: UsePaginationProps) => {\n const siblings = useValue(_siblings)\n const boundaries = useValue(_boundaries)\n\n const [currentPage, setCurrentPage] = useControllableState({\n defaultValue: defaultPage,\n value: page,\n onChange: onChangeProp,\n })\n\n const onFirst = useCallback(() => setCurrentPage(1), [setCurrentPage])\n\n const onLast = useCallback(\n () => setCurrentPage(total),\n [setCurrentPage, total],\n )\n\n const onPrev = useCallback(\n () => setCurrentPage((prev) => (prev === 1 ? prev : prev - 1)),\n [setCurrentPage],\n )\n\n const onNext = useCallback(\n () => setCurrentPage((prev) => (prev === total ? prev : prev + 1)),\n [setCurrentPage, total],\n )\n\n const onChange = useCallback(\n (page: number) => setCurrentPage(page),\n [setCurrentPage],\n )\n\n const range = useMemo((): (\"ellipsis\" | number)[] => {\n const minimumTotal = siblings * 2 + 3 + boundaries * 2\n\n if (minimumTotal >= total) return computedRange(1, total)\n\n const prevSiblings = Math.max(currentPage - siblings, boundaries)\n const nextSiblings = Math.min(currentPage + siblings, total - boundaries)\n\n const prevDots = prevSiblings > boundaries + 2\n const nextDots = nextSiblings < total - (boundaries + 1)\n\n if (!prevDots && nextDots) {\n const prevPages = siblings * 2 + boundaries + 2\n\n return [\n ...computedRange(1, prevPages),\n \"ellipsis\",\n ...computedRange(total - (boundaries - 1), total),\n ]\n }\n\n if (prevDots && !nextDots) {\n const nextPages = boundaries + 1 + 2 * siblings\n\n return [\n ...computedRange(1, boundaries),\n \"ellipsis\",\n ...computedRange(total - nextPages, total),\n ]\n }\n\n return [\n ...computedRange(1, boundaries),\n \"ellipsis\",\n ...computedRange(prevSiblings, nextSiblings),\n \"ellipsis\",\n ...computedRange(total - boundaries + 1, total),\n ]\n }, [boundaries, siblings, currentPage, total])\n\n return {\n currentPage,\n isDisabled,\n range,\n total,\n onChange,\n onFirst,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QAAM,QAAQ,QAAQ,MAA+B;AACnD,UAAM,eAAe,WAAW,IAAI,IAAI,aAAa;AAErD,QAAI,gBAAgB,MAAO,QAAO,cAAc,GAAG,KAAK;AAExD,UAAM,eAAe,KAAK,IAAI,cAAc,UAAU,UAAU;AAChE,UAAM,eAAe,KAAK,IAAI,cAAc,UAAU,QAAQ,UAAU;AAExE,UAAM,WAAW,eAAe,aAAa;AAC7C,UAAM,WAAW,eAAe,SAAS,aAAa;AAEtD,QAAI,CAAC,YAAY,UAAU;AACzB,YAAM,YAAY,WAAW,IAAI,aAAa;AAE9C,aAAO;AAAA,QACL,GAAG,cAAc,GAAG,SAAS;AAAA,QAC7B;AAAA,QACA,GAAG,cAAc,SAAS,aAAa,IAAI,KAAK;AAAA,MAClD;AAAA,IACF;AAEA,QAAI,YAAY,CAAC,UAAU;AACzB,YAAM,YAAY,aAAa,IAAI,IAAI;AAEvC,aAAO;AAAA,QACL,GAAG,cAAc,GAAG,UAAU;AAAA,QAC9B;AAAA,QACA,GAAG,cAAc,QAAQ,WAAW,KAAK;AAAA,MAC3C;AAAA,IACF;AAEA,WAAO;AAAA,MACL,GAAG,cAAc,GAAG,UAAU;AAAA,MAC9B;AAAA,MACA,GAAG,cAAc,cAAc,YAAY;AAAA,MAC3C;AAAA,MACA,GAAG,cAAc,QAAQ,aAAa,GAAG,KAAK;AAAA,IAChD;AAAA,EACF,GAAG,CAAC,YAAY,UAAU,aAAa,KAAK,CAAC;AAE7C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["page"]}
@@ -1,14 +1,14 @@
1
1
  "use client"
2
2
  import {
3
- DotsIcon,
4
- FirstIcon,
5
- LastIcon,
6
- NextIcon,
7
- PrevIcon
8
- } from "./chunk-VPZBFCSD.mjs";
3
+ PaginationEllipsisIcon,
4
+ PaginationFirstIcon,
5
+ PaginationLastIcon,
6
+ PaginationNextIcon,
7
+ PaginationPrevIcon
8
+ } from "./chunk-VZWGYG76.mjs";
9
9
  import {
10
10
  usePaginationContext
11
- } from "./chunk-GKZNNZOM.mjs";
11
+ } from "./chunk-O6EIBNLC.mjs";
12
12
 
13
13
  // src/pagination-item.tsx
14
14
  import { ui } from "@yamada-ui/core";
@@ -16,11 +16,11 @@ import { Ripple, useRipple } from "@yamada-ui/ripple";
16
16
  import { cx, dataAttr } from "@yamada-ui/utils";
17
17
  import { jsx, jsxs } from "react/jsx-runtime";
18
18
  var iconMap = {
19
- dots: /* @__PURE__ */ jsx(DotsIcon, {}),
20
- first: /* @__PURE__ */ jsx(FirstIcon, {}),
21
- last: /* @__PURE__ */ jsx(LastIcon, {}),
22
- next: /* @__PURE__ */ jsx(NextIcon, {}),
23
- prev: /* @__PURE__ */ jsx(PrevIcon, {})
19
+ ellipsis: /* @__PURE__ */ jsx(PaginationEllipsisIcon, {}),
20
+ first: /* @__PURE__ */ jsx(PaginationFirstIcon, {}),
21
+ last: /* @__PURE__ */ jsx(PaginationLastIcon, {}),
22
+ next: /* @__PURE__ */ jsx(PaginationNextIcon, {}),
23
+ prev: /* @__PURE__ */ jsx(PaginationPrevIcon, {})
24
24
  };
25
25
  var PaginationItem = ({
26
26
  className,
@@ -56,7 +56,7 @@ var PaginationItem = ({
56
56
  "data-disabled": dataAttr(isDisabled),
57
57
  "data-selected": dataAttr(isActive),
58
58
  disabled: isDisabled,
59
- tabIndex: page !== "dots" ? 0 : -1,
59
+ tabIndex: page !== "ellipsis" ? 0 : -1,
60
60
  __css: css,
61
61
  ...rest,
62
62
  onPointerDown,
@@ -73,4 +73,4 @@ PaginationItem.__ui__ = "PaginationItem";
73
73
  export {
74
74
  PaginationItem
75
75
  };
76
- //# sourceMappingURL=chunk-GOSRKZFX.mjs.map
76
+ //# sourceMappingURL=chunk-PUQ5FNCP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/pagination-item.tsx"],"sourcesContent":["import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\"\nimport { ui } from \"@yamada-ui/core\"\nimport { Ripple, useRipple } from \"@yamada-ui/ripple\"\nimport { cx, dataAttr } from \"@yamada-ui/utils\"\nimport {\n PaginationEllipsisIcon,\n PaginationFirstIcon,\n PaginationLastIcon,\n PaginationNextIcon,\n PaginationPrevIcon,\n} from \"./pagination-icon\"\nimport { usePaginationContext } from \"./use-pagination\"\n\ninterface PaginationItemOptions {\n /**\n * The type of the page or item assigned to the pagination item.\n */\n page: \"ellipsis\" | \"first\" | \"last\" | \"next\" | \"prev\" | number\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n disableRipple?: boolean\n /**\n * If `true`, the pagination item will be activated.\n *\n * @default false\n */\n isActive?: boolean\n /**\n * If `true`, the pagination item will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n}\n\nexport interface PaginationItemProps\n extends ComponentPropsWithoutRef<\"button\">,\n PaginationItemOptions {}\n\nconst iconMap: {\n [key in \"ellipsis\" | \"first\" | \"last\" | \"next\" | \"prev\" | number]: ReactNode\n} = {\n ellipsis: <PaginationEllipsisIcon />,\n first: <PaginationFirstIcon />,\n last: <PaginationLastIcon />,\n next: <PaginationNextIcon />,\n prev: <PaginationPrevIcon />,\n}\n\nexport const PaginationItem: FC<PaginationItemProps> = ({\n className,\n children,\n disableRipple,\n isActive,\n isDisabled,\n page,\n ...rest\n}) => {\n const styles = usePaginationContext()\n const { onPointerDown, ...rippleProps } = useRipple({\n ...rest,\n isDisabled: disableRipple || isDisabled,\n })\n\n children ??= iconMap[page] ?? page\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n position: \"relative\",\n userSelect: \"none\",\n ...styles.item,\n ...styles[page],\n }\n\n return (\n <ui.button\n type=\"button\"\n className={cx(\"ui-pagination__item\", className)}\n data-disabled={dataAttr(isDisabled)}\n data-selected={dataAttr(isActive)}\n disabled={isDisabled}\n tabIndex={page !== \"ellipsis\" ? 0 : -1}\n __css={css}\n {...rest}\n onPointerDown={onPointerDown}\n >\n {children}\n\n <Ripple isDisabled={disableRipple || isDisabled} {...rippleProps} />\n </ui.button>\n )\n}\nPaginationItem.displayName = \"PaginationItem\"\nPaginationItem.__ui__ = \"PaginationItem\"\n"],"mappings":";;;;;;;;;;;;;AAEA,SAAS,UAAU;AACnB,SAAS,QAAQ,iBAAiB;AAClC,SAAS,IAAI,gBAAgB;AA0CjB,cAoCR,YApCQ;AAHZ,IAAM,UAEF;AAAA,EACF,UAAU,oBAAC,0BAAuB;AAAA,EAClC,OAAO,oBAAC,uBAAoB;AAAA,EAC5B,MAAM,oBAAC,sBAAmB;AAAA,EAC1B,MAAM,oBAAC,sBAAmB;AAAA,EAC1B,MAAM,oBAAC,sBAAmB;AAC5B;AAEO,IAAM,iBAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AA7DN;AA8DE,QAAM,SAAS,qBAAqB;AACpC,QAAM,EAAE,eAAe,GAAG,YAAY,IAAI,UAAU;AAAA,IAClD,GAAG;AAAA,IACH,YAAY,iBAAiB;AAAA,EAC/B,CAAC;AAED,4CAAa,aAAQ,IAAI,MAAZ,YAAiB;AAE9B,QAAM,MAAmB;AAAA,IACvB,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,GAAG,OAAO;AAAA,IACV,GAAG,OAAO,IAAI;AAAA,EAChB;AAEA,SACE;AAAA,IAAC,GAAG;AAAA,IAAH;AAAA,MACC,MAAK;AAAA,MACL,WAAW,GAAG,uBAAuB,SAAS;AAAA,MAC9C,iBAAe,SAAS,UAAU;AAAA,MAClC,iBAAe,SAAS,QAAQ;AAAA,MAChC,UAAU;AAAA,MACV,UAAU,SAAS,aAAa,IAAI;AAAA,MACpC,OAAO;AAAA,MACN,GAAG;AAAA,MACJ;AAAA,MAEC;AAAA;AAAA,QAED,oBAAC,UAAO,YAAY,iBAAiB,YAAa,GAAG,aAAa;AAAA;AAAA;AAAA,EACpE;AAEJ;AACA,eAAe,cAAc;AAC7B,eAAe,SAAS;","names":[]}
@@ -3,7 +3,7 @@
3
3
  // src/pagination-icon.tsx
4
4
  import { Icon } from "@yamada-ui/icon";
5
5
  import { jsx } from "react/jsx-runtime";
6
- var DotsIcon = (props) => {
6
+ var PaginationEllipsisIcon = (props) => {
7
7
  return /* @__PURE__ */ jsx(Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ jsx(
8
8
  "path",
9
9
  {
@@ -12,9 +12,9 @@ var DotsIcon = (props) => {
12
12
  }
13
13
  ) });
14
14
  };
15
- DotsIcon.displayName = "DotIcon";
16
- DotsIcon.__ui__ = "DotIcon";
17
- var FirstIcon = (props) => {
15
+ PaginationEllipsisIcon.displayName = "PaginationEllipsisIcon";
16
+ PaginationEllipsisIcon.__ui__ = "PaginationEllipsisIcon";
17
+ var PaginationFirstIcon = (props) => {
18
18
  return /* @__PURE__ */ jsx(Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ jsx(
19
19
  "path",
20
20
  {
@@ -23,9 +23,9 @@ var FirstIcon = (props) => {
23
23
  }
24
24
  ) });
25
25
  };
26
- FirstIcon.displayName = "LastIcon";
27
- FirstIcon.__ui__ = "LastIcon";
28
- var LastIcon = (props) => {
26
+ PaginationFirstIcon.displayName = "PaginationFirstIcon";
27
+ PaginationFirstIcon.__ui__ = "PaginationFirstIcon";
28
+ var PaginationLastIcon = (props) => {
29
29
  return /* @__PURE__ */ jsx(Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ jsx(
30
30
  "path",
31
31
  {
@@ -34,9 +34,9 @@ var LastIcon = (props) => {
34
34
  }
35
35
  ) });
36
36
  };
37
- LastIcon.displayName = "LastIcon";
38
- LastIcon.__ui__ = "LastIcon";
39
- var PrevIcon = (props) => {
37
+ PaginationLastIcon.displayName = "PaginationLastIcon";
38
+ PaginationLastIcon.__ui__ = "PaginationLastIcon";
39
+ var PaginationPrevIcon = (props) => {
40
40
  return /* @__PURE__ */ jsx(Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ jsx(
41
41
  "path",
42
42
  {
@@ -45,7 +45,9 @@ var PrevIcon = (props) => {
45
45
  }
46
46
  ) });
47
47
  };
48
- var NextIcon = (props) => {
48
+ PaginationPrevIcon.displayName = "PaginationPrevIcon";
49
+ PaginationPrevIcon.__ui__ = "PaginationPrevIcon";
50
+ var PaginationNextIcon = (props) => {
49
51
  return /* @__PURE__ */ jsx(Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ jsx(
50
52
  "path",
51
53
  {
@@ -54,14 +56,14 @@ var NextIcon = (props) => {
54
56
  }
55
57
  ) });
56
58
  };
57
- NextIcon.displayName = "NextIcon";
58
- NextIcon.__ui__ = "NextIcon";
59
+ PaginationNextIcon.displayName = "PaginationNextIcon";
60
+ PaginationNextIcon.__ui__ = "PaginationNextIcon";
59
61
 
60
62
  export {
61
- DotsIcon,
62
- FirstIcon,
63
- LastIcon,
64
- PrevIcon,
65
- NextIcon
63
+ PaginationEllipsisIcon,
64
+ PaginationFirstIcon,
65
+ PaginationLastIcon,
66
+ PaginationPrevIcon,
67
+ PaginationNextIcon
66
68
  };
67
- //# sourceMappingURL=chunk-VPZBFCSD.mjs.map
69
+ //# sourceMappingURL=chunk-VZWGYG76.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/pagination-icon.tsx"],"sourcesContent":["import type { FC } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\n\nexport const PaginationEllipsisIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M2 8c0-.733.6-1.333 1.333-1.333.734 0 1.334.6 1.334 1.333s-.6 1.333-1.334 1.333C2.6 9.333 2 8.733 2 8zm9.333 0c0-.733.6-1.333 1.334-1.333C13.4 6.667 14 7.267 14 8s-.6 1.333-1.333 1.333c-.734 0-1.334-.6-1.334-1.333zM6.667 8c0-.733.6-1.333 1.333-1.333s1.333.6 1.333 1.333S8.733 9.333 8 9.333 6.667 8.733 6.667 8z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nPaginationEllipsisIcon.displayName = \"PaginationEllipsisIcon\"\nPaginationEllipsisIcon.__ui__ = \"PaginationEllipsisIcon\"\n\nexport const PaginationFirstIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nPaginationFirstIcon.displayName = \"PaginationFirstIcon\"\nPaginationFirstIcon.__ui__ = \"PaginationFirstIcon\"\n\nexport const PaginationLastIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nPaginationLastIcon.displayName = \"PaginationLastIcon\"\nPaginationLastIcon.__ui__ = \"PaginationLastIcon\"\n\nexport const PaginationPrevIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nPaginationPrevIcon.displayName = \"PaginationPrevIcon\"\nPaginationPrevIcon.__ui__ = \"PaginationPrevIcon\"\n\nexport const PaginationNextIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nPaginationNextIcon.displayName = \"PaginationNextIcon\"\nPaginationNextIcon.__ui__ = \"PaginationNextIcon\"\n"],"mappings":";;;AAEA,SAAS,YAAY;AAKf;AAHC,IAAM,yBAAwC,CAAC,UAAU;AAC9D,SACE,oBAAC,QAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AAEA,uBAAuB,cAAc;AACrC,uBAAuB,SAAS;AAEzB,IAAM,sBAAqC,CAAC,UAAU;AAC3D,SACE,oBAAC,QAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AAEA,oBAAoB,cAAc;AAClC,oBAAoB,SAAS;AAEtB,IAAM,qBAAoC,CAAC,UAAU;AAC1D,SACE,oBAAC,QAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AAEA,mBAAmB,cAAc;AACjC,mBAAmB,SAAS;AAErB,IAAM,qBAAoC,CAAC,UAAU;AAC1D,SACE,oBAAC,QAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AAEA,mBAAmB,cAAc;AACjC,mBAAmB,SAAS;AAErB,IAAM,qBAAoC,CAAC,UAAU;AAC1D,SACE,oBAAC,QAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AAEA,mBAAmB,cAAc;AACjC,mBAAmB,SAAS;","names":[]}
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ var import_utils2 = require("@yamada-ui/utils");
40
40
  // src/pagination-icon.tsx
41
41
  var import_icon = require("@yamada-ui/icon");
42
42
  var import_jsx_runtime = require("react/jsx-runtime");
43
- var DotsIcon = (props) => {
43
+ var PaginationEllipsisIcon = (props) => {
44
44
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
45
45
  "path",
46
46
  {
@@ -49,9 +49,9 @@ var DotsIcon = (props) => {
49
49
  }
50
50
  ) });
51
51
  };
52
- DotsIcon.displayName = "DotIcon";
53
- DotsIcon.__ui__ = "DotIcon";
54
- var FirstIcon = (props) => {
52
+ PaginationEllipsisIcon.displayName = "PaginationEllipsisIcon";
53
+ PaginationEllipsisIcon.__ui__ = "PaginationEllipsisIcon";
54
+ var PaginationFirstIcon = (props) => {
55
55
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
56
  "path",
57
57
  {
@@ -60,9 +60,9 @@ var FirstIcon = (props) => {
60
60
  }
61
61
  ) });
62
62
  };
63
- FirstIcon.displayName = "LastIcon";
64
- FirstIcon.__ui__ = "LastIcon";
65
- var LastIcon = (props) => {
63
+ PaginationFirstIcon.displayName = "PaginationFirstIcon";
64
+ PaginationFirstIcon.__ui__ = "PaginationFirstIcon";
65
+ var PaginationLastIcon = (props) => {
66
66
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
67
67
  "path",
68
68
  {
@@ -71,9 +71,9 @@ var LastIcon = (props) => {
71
71
  }
72
72
  ) });
73
73
  };
74
- LastIcon.displayName = "LastIcon";
75
- LastIcon.__ui__ = "LastIcon";
76
- var PrevIcon = (props) => {
74
+ PaginationLastIcon.displayName = "PaginationLastIcon";
75
+ PaginationLastIcon.__ui__ = "PaginationLastIcon";
76
+ var PaginationPrevIcon = (props) => {
77
77
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
78
  "path",
79
79
  {
@@ -82,7 +82,9 @@ var PrevIcon = (props) => {
82
82
  }
83
83
  ) });
84
84
  };
85
- var NextIcon = (props) => {
85
+ PaginationPrevIcon.displayName = "PaginationPrevIcon";
86
+ PaginationPrevIcon.__ui__ = "PaginationPrevIcon";
87
+ var PaginationNextIcon = (props) => {
86
88
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
87
89
  "path",
88
90
  {
@@ -91,8 +93,8 @@ var NextIcon = (props) => {
91
93
  }
92
94
  ) });
93
95
  };
94
- NextIcon.displayName = "NextIcon";
95
- NextIcon.__ui__ = "NextIcon";
96
+ PaginationNextIcon.displayName = "PaginationNextIcon";
97
+ PaginationNextIcon.__ui__ = "PaginationNextIcon";
96
98
 
97
99
  // src/use-pagination.ts
98
100
  var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
@@ -148,7 +150,7 @@ var usePagination = ({
148
150
  const prevPages = siblings * 2 + boundaries + 2;
149
151
  return [
150
152
  ...computedRange(1, prevPages),
151
- "dots",
153
+ "ellipsis",
152
154
  ...computedRange(total - (boundaries - 1), total)
153
155
  ];
154
156
  }
@@ -156,15 +158,15 @@ var usePagination = ({
156
158
  const nextPages = boundaries + 1 + 2 * siblings;
157
159
  return [
158
160
  ...computedRange(1, boundaries),
159
- "dots",
161
+ "ellipsis",
160
162
  ...computedRange(total - nextPages, total)
161
163
  ];
162
164
  }
163
165
  return [
164
166
  ...computedRange(1, boundaries),
165
- "dots",
167
+ "ellipsis",
166
168
  ...computedRange(prevSiblings, nextSiblings),
167
- "dots",
169
+ "ellipsis",
168
170
  ...computedRange(total - boundaries + 1, total)
169
171
  ];
170
172
  }, [boundaries, siblings, currentPage, total]);
@@ -184,11 +186,11 @@ var usePagination = ({
184
186
  // src/pagination-item.tsx
185
187
  var import_jsx_runtime2 = require("react/jsx-runtime");
186
188
  var iconMap = {
187
- dots: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DotsIcon, {}),
188
- first: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FirstIcon, {}),
189
- last: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LastIcon, {}),
190
- next: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NextIcon, {}),
191
- prev: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PrevIcon, {})
189
+ ellipsis: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationEllipsisIcon, {}),
190
+ first: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationFirstIcon, {}),
191
+ last: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationLastIcon, {}),
192
+ next: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationNextIcon, {}),
193
+ prev: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationPrevIcon, {})
192
194
  };
193
195
  var PaginationItem = ({
194
196
  className,
@@ -224,7 +226,7 @@ var PaginationItem = ({
224
226
  "data-disabled": (0, import_utils2.dataAttr)(isDisabled),
225
227
  "data-selected": (0, import_utils2.dataAttr)(isActive),
226
228
  disabled: isDisabled,
227
- tabIndex: page !== "dots" ? 0 : -1,
229
+ tabIndex: page !== "ellipsis" ? 0 : -1,
228
230
  __css: css,
229
231
  ...rest,
230
232
  onPointerDown,
@@ -279,14 +281,14 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
279
281
  () => range.map((page2, key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
280
282
  Component,
281
283
  {
282
- "aria-label": page2 === "dots" ? "Jump to omitted pages" : `Go to page ${page2}`,
284
+ "aria-label": page2 === "ellipsis" ? "Jump to omitted pages" : `Go to page ${page2}`,
283
285
  isActive: currentPage === page2,
284
286
  isDisabled,
285
287
  page: page2,
286
288
  ...itemProps,
287
289
  onClick: (0, import_utils3.handlerAll)(
288
290
  itemProps == null ? void 0 : itemProps.onClick,
289
- page2 !== "dots" ? () => onChange(page2) : void 0
291
+ page2 !== "ellipsis" ? () => onChange(page2) : void 0
290
292
  )
291
293
  },
292
294
  key
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/pagination.tsx","../src/pagination-item.tsx","../src/pagination-icon.tsx","../src/use-pagination.ts"],"sourcesContent":["export { Pagination } from \"./pagination\"\nexport type { PaginationProps } from \"./pagination\"\nexport { usePagination } from \"./use-pagination\"\nexport type { UsePaginationProps, UsePaginationReturn } from \"./use-pagination\"\n","import type {\n CSSUIObject,\n HTMLUIProps,\n ThemeProps,\n Token,\n} from \"@yamada-ui/core\"\nimport type { ComponentPropsWithoutRef, FC } from \"react\"\nimport type { PaginationItemProps } from \"./pagination-item\"\nimport type { UsePaginationProps } from \"./use-pagination\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { useValue } from \"@yamada-ui/use-value\"\nimport { cx, dataAttr, handlerAll } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\nimport { PaginationItem } from \"./pagination-item\"\nimport { PaginationProvider, usePagination } from \"./use-pagination\"\n\ninterface PaginationOptions {\n /**\n * The pagination button component to use.\n */\n component?: FC<PaginationItemProps>\n /**\n * If `true`, display the control buttons.\n *\n * @default true\n */\n withControls?: Token<boolean>\n /**\n * If `true`, display the edge buttons.\n *\n * @default false\n */\n withEdges?: Token<boolean>\n /**\n * Props for next of the control button element.\n */\n controlNextProps?: HTMLUIProps<\"button\">\n /**\n * Props for previous of the control button element.\n */\n controlPrevProps?: HTMLUIProps<\"button\">\n /**\n * Props for control button element.\n */\n controlProps?: HTMLUIProps<\"button\">\n /**\n * Props for first of the edge button element.\n */\n edgeFirstProps?: HTMLUIProps<\"button\">\n /**\n * Props for last of the edge button element.\n */\n edgeLastProps?: HTMLUIProps<\"button\">\n /**\n * Props for edge button element.\n */\n edgeProps?: HTMLUIProps<\"button\">\n /**\n * Props for inner element.\n */\n innerProps?: HTMLUIProps\n /**\n * Props for button element.\n */\n itemProps?: HTMLUIProps<\"button\">\n}\n\nexport interface PaginationProps\n extends Omit<HTMLUIProps, \"children\" | \"onChange\" | \"page\">,\n ThemeProps<\"Pagination\">,\n UsePaginationProps,\n PaginationOptions {}\n\n/**\n * `Pagination` is a component for managing the pagination and navigation of content.\n *\n * @see Docs https://yamada-ui.com/components/navigation/pagination\n */\nexport const Pagination = forwardRef<PaginationProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Pagination\", props)\n const {\n className,\n boundaries,\n component: Component = PaginationItem,\n defaultPage,\n isDisabled,\n page,\n siblings,\n total,\n withControls: _withControls = true,\n withEdges: _withEdges = false,\n controlNextProps,\n controlPrevProps,\n controlProps,\n edgeFirstProps,\n edgeLastProps,\n edgeProps,\n innerProps,\n itemProps,\n onChange: onChangeProp,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const withControls = useValue(_withControls)\n const withEdges = useValue(_withEdges)\n\n const { currentPage, range, onChange, onFirst, onLast, onNext, onPrev } =\n usePagination({\n boundaries,\n defaultPage,\n isDisabled,\n page,\n siblings,\n total,\n onChange: onChangeProp,\n })\n\n const children = useMemo(\n () =>\n range.map((page, key) => (\n <Component\n key={key}\n aria-label={\n page === \"dots\" ? \"Jump to omitted pages\" : `Go to page ${page}`\n }\n isActive={currentPage === page}\n isDisabled={isDisabled}\n page={page}\n {...(itemProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n itemProps?.onClick,\n page !== \"dots\" ? () => onChange(page) : undefined,\n )}\n />\n )),\n [Component, currentPage, isDisabled, onChange, range, itemProps],\n )\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n ...styles.container,\n }\n\n return (\n <PaginationProvider value={styles}>\n <ui.div\n ref={ref}\n className={cx(\"ui-pagination\", className)}\n role=\"navigation\"\n __css={css}\n {...rest}\n data-disabled={dataAttr(isDisabled)}\n >\n {withEdges ? (\n <Component\n className=\"ui-pagination__item--first\"\n aria-label=\"Go to first page\"\n isDisabled={isDisabled || currentPage === 1}\n page=\"first\"\n {...(edgeProps as ComponentPropsWithoutRef<\"button\">)}\n {...(edgeFirstProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n edgeProps?.onClick,\n edgeFirstProps?.onClick,\n onFirst,\n )}\n />\n ) : null}\n\n {withControls ? (\n <Component\n className=\"ui-pagination__item--prev\"\n aria-label=\"Go to previous page\"\n isDisabled={isDisabled || currentPage === 1}\n page=\"prev\"\n {...(controlProps as ComponentPropsWithoutRef<\"button\">)}\n {...(controlPrevProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n controlProps?.onClick,\n controlPrevProps?.onClick,\n onPrev,\n )}\n />\n ) : null}\n\n <ui.div\n className=\"ui-pagination-inner\"\n __css={{\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n ...styles.inner,\n }}\n {...innerProps}\n >\n {children}\n </ui.div>\n\n {withControls ? (\n <Component\n className=\"ui-pagination__item--next\"\n aria-label=\"Go to next page\"\n isDisabled={isDisabled || currentPage === total}\n page=\"next\"\n {...(controlProps as ComponentPropsWithoutRef<\"button\">)}\n {...(controlNextProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n controlProps?.onClick,\n controlNextProps?.onClick,\n onNext,\n )}\n />\n ) : null}\n\n {withEdges ? (\n <Component\n className=\"ui-pagination__item--last\"\n aria-label=\"Go to last page\"\n isDisabled={isDisabled || currentPage === total}\n page=\"last\"\n {...(edgeProps as ComponentPropsWithoutRef<\"button\">)}\n {...(edgeLastProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n edgeProps?.onClick,\n edgeLastProps?.onClick,\n onLast,\n )}\n />\n ) : null}\n </ui.div>\n </PaginationProvider>\n )\n})\n\nPagination.displayName = \"Pagination\"\nPagination.__ui__ = \"Pagination\"\n","import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\"\nimport { ui } from \"@yamada-ui/core\"\nimport { Ripple, useRipple } from \"@yamada-ui/ripple\"\nimport { cx, dataAttr } from \"@yamada-ui/utils\"\nimport {\n DotsIcon,\n FirstIcon,\n LastIcon,\n NextIcon,\n PrevIcon,\n} from \"./pagination-icon\"\nimport { usePaginationContext } from \"./use-pagination\"\n\ninterface PaginationItemOptions {\n /**\n * The type of the page or item assigned to the pagination item.\n */\n page: \"dots\" | \"first\" | \"last\" | \"next\" | \"prev\" | number\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n disableRipple?: boolean\n /**\n * If `true`, the pagination item will be activated.\n *\n * @default false\n */\n isActive?: boolean\n /**\n * If `true`, the pagination item will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n}\n\nexport interface PaginationItemProps\n extends ComponentPropsWithoutRef<\"button\">,\n PaginationItemOptions {}\n\nconst iconMap: {\n [key in \"dots\" | \"first\" | \"last\" | \"next\" | \"prev\" | number]: ReactNode\n} = {\n dots: <DotsIcon />,\n first: <FirstIcon />,\n last: <LastIcon />,\n next: <NextIcon />,\n prev: <PrevIcon />,\n}\n\nexport const PaginationItem: FC<PaginationItemProps> = ({\n className,\n children,\n disableRipple,\n isActive,\n isDisabled,\n page,\n ...rest\n}) => {\n const styles = usePaginationContext()\n const { onPointerDown, ...rippleProps } = useRipple({\n ...rest,\n isDisabled: disableRipple || isDisabled,\n })\n\n children ??= iconMap[page] ?? page\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n position: \"relative\",\n userSelect: \"none\",\n ...styles.item,\n ...styles[page],\n }\n\n return (\n <ui.button\n type=\"button\"\n className={cx(\"ui-pagination__item\", className)}\n data-disabled={dataAttr(isDisabled)}\n data-selected={dataAttr(isActive)}\n disabled={isDisabled}\n tabIndex={page !== \"dots\" ? 0 : -1}\n __css={css}\n {...rest}\n onPointerDown={onPointerDown}\n >\n {children}\n\n <Ripple isDisabled={disableRipple || isDisabled} {...rippleProps} />\n </ui.button>\n )\n}\nPaginationItem.displayName = \"PaginationItem\"\nPaginationItem.__ui__ = \"PaginationItem\"\n","import type { FC } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\n\nexport const DotsIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M2 8c0-.733.6-1.333 1.333-1.333.734 0 1.334.6 1.334 1.333s-.6 1.333-1.334 1.333C2.6 9.333 2 8.733 2 8zm9.333 0c0-.733.6-1.333 1.334-1.333C13.4 6.667 14 7.267 14 8s-.6 1.333-1.333 1.333c-.734 0-1.334-.6-1.334-1.333zM6.667 8c0-.733.6-1.333 1.333-1.333s1.333.6 1.333 1.333S8.733 9.333 8 9.333 6.667 8.733 6.667 8z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\nDotsIcon.displayName = \"DotIcon\"\nDotsIcon.__ui__ = \"DotIcon\"\n\nexport const FirstIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nFirstIcon.displayName = \"LastIcon\"\nFirstIcon.__ui__ = \"LastIcon\"\n\nexport const LastIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\nLastIcon.displayName = \"LastIcon\"\nLastIcon.__ui__ = \"LastIcon\"\n\nexport const PrevIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nexport const NextIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\nNextIcon.displayName = \"NextIcon\"\nNextIcon.__ui__ = \"NextIcon\"\n","import type { CSSUIObject, Token } from \"@yamada-ui/core\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useValue } from \"@yamada-ui/use-value\"\nimport { createContext } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo } from \"react\"\n\ninterface PaginationContext {\n [key: string]: CSSUIObject | undefined\n}\n\nexport const [PaginationProvider, usePaginationContext] =\n createContext<PaginationContext>({\n name: \"PaginationContext\",\n errorMessage: `usePaginationContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Pagination />\"`,\n })\n\nexport const computedRange = (start: number, end: number) =>\n Array.from({ length: end - start + 1 }, (_, index) => index + start)\n\nexport interface UsePaginationProps {\n /**\n * The total number of pages in pagination.\n */\n total: number\n /**\n * Number of elements visible on the left/right edges.\n *\n * @default 1\n */\n boundaries?: Token<number>\n /**\n * The initial page of the pagination.\n * Should be less than `total` and greater than `1`.\n *\n * @default 1\n */\n defaultPage?: number\n /**\n * If `true`, the pagination all item will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n /**\n * The page of the pagination.\n * Should be less than `total` and greater than `1`.\n */\n page?: number\n /** Number of siblings displayed on the left/right side of selected page.\n *\n * @default 1\n */\n siblings?: Token<number>\n /**\n * The callback invoked when the page changes.\n */\n onChange?: (page: number) => void\n}\n\nexport const usePagination = ({\n boundaries: _boundaries = 1,\n defaultPage = 1,\n isDisabled = false,\n page,\n siblings: _siblings = 1,\n total,\n onChange: onChangeProp,\n}: UsePaginationProps) => {\n const siblings = useValue(_siblings)\n const boundaries = useValue(_boundaries)\n\n const [currentPage, setCurrentPage] = useControllableState({\n defaultValue: defaultPage,\n value: page,\n onChange: onChangeProp,\n })\n\n const onFirst = useCallback(() => setCurrentPage(1), [setCurrentPage])\n\n const onLast = useCallback(\n () => setCurrentPage(total),\n [setCurrentPage, total],\n )\n\n const onPrev = useCallback(\n () => setCurrentPage((prev) => (prev === 1 ? prev : prev - 1)),\n [setCurrentPage],\n )\n\n const onNext = useCallback(\n () => setCurrentPage((prev) => (prev === total ? prev : prev + 1)),\n [setCurrentPage, total],\n )\n\n const onChange = useCallback(\n (page: number) => setCurrentPage(page),\n [setCurrentPage],\n )\n\n const range = useMemo((): (\"dots\" | number)[] => {\n const minimumTotal = siblings * 2 + 3 + boundaries * 2\n\n if (minimumTotal >= total) return computedRange(1, total)\n\n const prevSiblings = Math.max(currentPage - siblings, boundaries)\n const nextSiblings = Math.min(currentPage + siblings, total - boundaries)\n\n const prevDots = prevSiblings > boundaries + 2\n const nextDots = nextSiblings < total - (boundaries + 1)\n\n if (!prevDots && nextDots) {\n const prevPages = siblings * 2 + boundaries + 2\n\n return [\n ...computedRange(1, prevPages),\n \"dots\",\n ...computedRange(total - (boundaries - 1), total),\n ]\n }\n\n if (prevDots && !nextDots) {\n const nextPages = boundaries + 1 + 2 * siblings\n\n return [\n ...computedRange(1, boundaries),\n \"dots\",\n ...computedRange(total - nextPages, total),\n ]\n }\n\n return [\n ...computedRange(1, boundaries),\n \"dots\",\n ...computedRange(prevSiblings, nextSiblings),\n \"dots\",\n ...computedRange(total - boundaries + 1, total),\n ]\n }, [boundaries, siblings, currentPage, total])\n\n return {\n currentPage,\n isDisabled,\n range,\n total,\n onChange,\n onFirst,\n onLast,\n onNext,\n onPrev,\n }\n}\n\nexport type UsePaginationReturn = ReturnType<typeof usePagination>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSA,IAAAA,eAKO;AACP,IAAAC,oBAAyB;AACzB,IAAAC,gBAAyC;AACzC,IAAAC,gBAAwB;;;ACfxB,kBAAmB;AACnB,oBAAkC;AAClC,IAAAC,gBAA6B;;;ACF7B,kBAAqB;AAKf;AAHC,IAAM,WAA0B,CAAC,UAAU;AAChD,SACE,4CAAC,oBAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AACA,SAAS,cAAc;AACvB,SAAS,SAAS;AAEX,IAAM,YAA2B,CAAC,UAAU;AACjD,SACE,4CAAC,oBAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ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ACL,aAAS;AAAA,cACP,6CAAc;AAAA,cACd,qDAAkB;AAAA,cAClB;AAAA,YACF;AAAA;AAAA,QACF,IACE;AAAA,QAEH,YACC;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,cAAW;AAAA,YACX,YAAY,cAAc,gBAAgB;AAAA,YAC1C,MAAK;AAAA,YACJ,GAAI;AAAA,YACJ,GAAI;AAAA,YACL,aAAS;AAAA,cACP,uCAAW;AAAA,cACX,+CAAe;AAAA,cACf;AAAA,YACF;AAAA;AAAA,QACF,IACE;AAAA;AAAA;AAAA,EACN,GACF;AAEJ,CAAC;AAED,WAAW,cAAc;AACzB,WAAW,SAAS;","names":["import_core","import_use_value","import_utils","import_react","import_utils","page","import_jsx_runtime","import_jsx_runtime","page"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/pagination.tsx","../src/pagination-item.tsx","../src/pagination-icon.tsx","../src/use-pagination.ts"],"sourcesContent":["export { Pagination } from \"./pagination\"\nexport type { PaginationProps } from \"./pagination\"\nexport { usePagination } from \"./use-pagination\"\nexport type { UsePaginationProps, UsePaginationReturn } from \"./use-pagination\"\n","import type {\n CSSUIObject,\n HTMLUIProps,\n ThemeProps,\n Token,\n} from \"@yamada-ui/core\"\nimport type { ComponentPropsWithoutRef, FC } from \"react\"\nimport type { PaginationItemProps } from \"./pagination-item\"\nimport type { UsePaginationProps } from \"./use-pagination\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { useValue } from \"@yamada-ui/use-value\"\nimport { cx, dataAttr, handlerAll } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\nimport { PaginationItem } from \"./pagination-item\"\nimport { PaginationProvider, usePagination } from \"./use-pagination\"\n\ninterface PaginationOptions {\n /**\n * The pagination button component to use.\n */\n component?: FC<PaginationItemProps>\n /**\n * If `true`, display the control buttons.\n *\n * @default true\n */\n withControls?: Token<boolean>\n /**\n * If `true`, display the edge buttons.\n *\n * @default false\n */\n withEdges?: Token<boolean>\n /**\n * Props for next of the control button element.\n */\n controlNextProps?: HTMLUIProps<\"button\">\n /**\n * Props for previous of the control button element.\n */\n controlPrevProps?: HTMLUIProps<\"button\">\n /**\n * Props for control button element.\n */\n controlProps?: HTMLUIProps<\"button\">\n /**\n * Props for first of the edge button element.\n */\n edgeFirstProps?: HTMLUIProps<\"button\">\n /**\n * Props for last of the edge button element.\n */\n edgeLastProps?: HTMLUIProps<\"button\">\n /**\n * Props for edge button element.\n */\n edgeProps?: HTMLUIProps<\"button\">\n /**\n * Props for inner element.\n */\n innerProps?: HTMLUIProps\n /**\n * Props for button element.\n */\n itemProps?: HTMLUIProps<\"button\">\n}\n\nexport interface PaginationProps\n extends Omit<HTMLUIProps, \"children\" | \"onChange\" | \"page\">,\n ThemeProps<\"Pagination\">,\n UsePaginationProps,\n PaginationOptions {}\n\n/**\n * `Pagination` is a component for managing the pagination and navigation of content.\n *\n * @see Docs https://yamada-ui.com/components/navigation/pagination\n */\nexport const Pagination = forwardRef<PaginationProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Pagination\", props)\n const {\n className,\n boundaries,\n component: Component = PaginationItem,\n defaultPage,\n isDisabled,\n page,\n siblings,\n total,\n withControls: _withControls = true,\n withEdges: _withEdges = false,\n controlNextProps,\n controlPrevProps,\n controlProps,\n edgeFirstProps,\n edgeLastProps,\n edgeProps,\n innerProps,\n itemProps,\n onChange: onChangeProp,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const withControls = useValue(_withControls)\n const withEdges = useValue(_withEdges)\n\n const { currentPage, range, onChange, onFirst, onLast, onNext, onPrev } =\n usePagination({\n boundaries,\n defaultPage,\n isDisabled,\n page,\n siblings,\n total,\n onChange: onChangeProp,\n })\n\n const children = useMemo(\n () =>\n range.map((page, key) => (\n <Component\n key={key}\n aria-label={\n page === \"ellipsis\" ? \"Jump to omitted pages\" : `Go to page ${page}`\n }\n isActive={currentPage === page}\n isDisabled={isDisabled}\n page={page}\n {...(itemProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n itemProps?.onClick,\n page !== \"ellipsis\" ? () => onChange(page) : undefined,\n )}\n />\n )),\n [Component, currentPage, isDisabled, onChange, range, itemProps],\n )\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n ...styles.container,\n }\n\n return (\n <PaginationProvider value={styles}>\n <ui.div\n ref={ref}\n className={cx(\"ui-pagination\", className)}\n role=\"navigation\"\n __css={css}\n {...rest}\n data-disabled={dataAttr(isDisabled)}\n >\n {withEdges ? (\n <Component\n className=\"ui-pagination__item--first\"\n aria-label=\"Go to first page\"\n isDisabled={isDisabled || currentPage === 1}\n page=\"first\"\n {...(edgeProps as ComponentPropsWithoutRef<\"button\">)}\n {...(edgeFirstProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n edgeProps?.onClick,\n edgeFirstProps?.onClick,\n onFirst,\n )}\n />\n ) : null}\n\n {withControls ? (\n <Component\n className=\"ui-pagination__item--prev\"\n aria-label=\"Go to previous page\"\n isDisabled={isDisabled || currentPage === 1}\n page=\"prev\"\n {...(controlProps as ComponentPropsWithoutRef<\"button\">)}\n {...(controlPrevProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n controlProps?.onClick,\n controlPrevProps?.onClick,\n onPrev,\n )}\n />\n ) : null}\n\n <ui.div\n className=\"ui-pagination-inner\"\n __css={{\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n ...styles.inner,\n }}\n {...innerProps}\n >\n {children}\n </ui.div>\n\n {withControls ? (\n <Component\n className=\"ui-pagination__item--next\"\n aria-label=\"Go to next page\"\n isDisabled={isDisabled || currentPage === total}\n page=\"next\"\n {...(controlProps as ComponentPropsWithoutRef<\"button\">)}\n {...(controlNextProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n controlProps?.onClick,\n controlNextProps?.onClick,\n onNext,\n )}\n />\n ) : null}\n\n {withEdges ? (\n <Component\n className=\"ui-pagination__item--last\"\n aria-label=\"Go to last page\"\n isDisabled={isDisabled || currentPage === total}\n page=\"last\"\n {...(edgeProps as ComponentPropsWithoutRef<\"button\">)}\n {...(edgeLastProps as ComponentPropsWithoutRef<\"button\">)}\n onClick={handlerAll(\n edgeProps?.onClick,\n edgeLastProps?.onClick,\n onLast,\n )}\n />\n ) : null}\n </ui.div>\n </PaginationProvider>\n )\n})\n\nPagination.displayName = \"Pagination\"\nPagination.__ui__ = \"Pagination\"\n","import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\"\nimport { ui } from \"@yamada-ui/core\"\nimport { Ripple, useRipple } from \"@yamada-ui/ripple\"\nimport { cx, dataAttr } from \"@yamada-ui/utils\"\nimport {\n PaginationEllipsisIcon,\n PaginationFirstIcon,\n PaginationLastIcon,\n PaginationNextIcon,\n PaginationPrevIcon,\n} from \"./pagination-icon\"\nimport { usePaginationContext } from \"./use-pagination\"\n\ninterface PaginationItemOptions {\n /**\n * The type of the page or item assigned to the pagination item.\n */\n page: \"ellipsis\" | \"first\" | \"last\" | \"next\" | \"prev\" | number\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n disableRipple?: boolean\n /**\n * If `true`, the pagination item will be activated.\n *\n * @default false\n */\n isActive?: boolean\n /**\n * If `true`, the pagination item will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n}\n\nexport interface PaginationItemProps\n extends ComponentPropsWithoutRef<\"button\">,\n PaginationItemOptions {}\n\nconst iconMap: {\n [key in \"ellipsis\" | \"first\" | \"last\" | \"next\" | \"prev\" | number]: ReactNode\n} = {\n ellipsis: <PaginationEllipsisIcon />,\n first: <PaginationFirstIcon />,\n last: <PaginationLastIcon />,\n next: <PaginationNextIcon />,\n prev: <PaginationPrevIcon />,\n}\n\nexport const PaginationItem: FC<PaginationItemProps> = ({\n className,\n children,\n disableRipple,\n isActive,\n isDisabled,\n page,\n ...rest\n}) => {\n const styles = usePaginationContext()\n const { onPointerDown, ...rippleProps } = useRipple({\n ...rest,\n isDisabled: disableRipple || isDisabled,\n })\n\n children ??= iconMap[page] ?? page\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n position: \"relative\",\n userSelect: \"none\",\n ...styles.item,\n ...styles[page],\n }\n\n return (\n <ui.button\n type=\"button\"\n className={cx(\"ui-pagination__item\", className)}\n data-disabled={dataAttr(isDisabled)}\n data-selected={dataAttr(isActive)}\n disabled={isDisabled}\n tabIndex={page !== \"ellipsis\" ? 0 : -1}\n __css={css}\n {...rest}\n onPointerDown={onPointerDown}\n >\n {children}\n\n <Ripple isDisabled={disableRipple || isDisabled} {...rippleProps} />\n </ui.button>\n )\n}\nPaginationItem.displayName = \"PaginationItem\"\nPaginationItem.__ui__ = \"PaginationItem\"\n","import type { FC } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\n\nexport const PaginationEllipsisIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M2 8c0-.733.6-1.333 1.333-1.333.734 0 1.334.6 1.334 1.333s-.6 1.333-1.334 1.333C2.6 9.333 2 8.733 2 8zm9.333 0c0-.733.6-1.333 1.334-1.333C13.4 6.667 14 7.267 14 8s-.6 1.333-1.333 1.333c-.734 0-1.334-.6-1.334-1.333zM6.667 8c0-.733.6-1.333 1.333-1.333s1.333.6 1.333 1.333S8.733 9.333 8 9.333 6.667 8.733 6.667 8z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nPaginationEllipsisIcon.displayName = \"PaginationEllipsisIcon\"\nPaginationEllipsisIcon.__ui__ = \"PaginationEllipsisIcon\"\n\nexport const PaginationFirstIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nPaginationFirstIcon.displayName = \"PaginationFirstIcon\"\nPaginationFirstIcon.__ui__ = \"PaginationFirstIcon\"\n\nexport const PaginationLastIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nPaginationLastIcon.displayName = \"PaginationLastIcon\"\nPaginationLastIcon.__ui__ = \"PaginationLastIcon\"\n\nexport const PaginationPrevIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nPaginationPrevIcon.displayName = \"PaginationPrevIcon\"\nPaginationPrevIcon.__ui__ = \"PaginationPrevIcon\"\n\nexport const PaginationNextIcon: FC<IconProps> = (props) => {\n return (\n <Icon viewBox=\"0 0 16 16\" {...props}>\n <path\n d=\"M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z\"\n fill=\"currentColor\"\n />\n </Icon>\n )\n}\n\nPaginationNextIcon.displayName = \"PaginationNextIcon\"\nPaginationNextIcon.__ui__ = \"PaginationNextIcon\"\n","import type { CSSUIObject, Token } from \"@yamada-ui/core\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useValue } from \"@yamada-ui/use-value\"\nimport { createContext } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo } from \"react\"\n\ninterface PaginationContext {\n [key: string]: CSSUIObject | undefined\n}\n\nexport const [PaginationProvider, usePaginationContext] =\n createContext<PaginationContext>({\n name: \"PaginationContext\",\n errorMessage: `usePaginationContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Pagination />\"`,\n })\n\nexport const computedRange = (start: number, end: number) =>\n Array.from({ length: end - start + 1 }, (_, index) => index + start)\n\nexport interface UsePaginationProps {\n /**\n * The total number of pages in pagination.\n */\n total: number\n /**\n * Number of elements visible on the left/right edges.\n *\n * @default 1\n */\n boundaries?: Token<number>\n /**\n * The initial page of the pagination.\n * Should be less than `total` and greater than `1`.\n *\n * @default 1\n */\n defaultPage?: number\n /**\n * If `true`, the pagination all item will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n /**\n * The page of the pagination.\n * Should be less than `total` and greater than `1`.\n */\n page?: number\n /** Number of siblings displayed on the left/right side of selected page.\n *\n * @default 1\n */\n siblings?: Token<number>\n /**\n * The callback invoked when the page changes.\n */\n onChange?: (page: number) => void\n}\n\nexport const usePagination = ({\n boundaries: _boundaries = 1,\n defaultPage = 1,\n isDisabled = false,\n page,\n siblings: _siblings = 1,\n total,\n onChange: onChangeProp,\n}: UsePaginationProps) => {\n const siblings = useValue(_siblings)\n const boundaries = useValue(_boundaries)\n\n const [currentPage, setCurrentPage] = useControllableState({\n defaultValue: defaultPage,\n value: page,\n onChange: onChangeProp,\n })\n\n const onFirst = useCallback(() => setCurrentPage(1), [setCurrentPage])\n\n const onLast = useCallback(\n () => setCurrentPage(total),\n [setCurrentPage, total],\n )\n\n const onPrev = useCallback(\n () => setCurrentPage((prev) => (prev === 1 ? prev : prev - 1)),\n [setCurrentPage],\n )\n\n const onNext = useCallback(\n () => setCurrentPage((prev) => (prev === total ? prev : prev + 1)),\n [setCurrentPage, total],\n )\n\n const onChange = useCallback(\n (page: number) => setCurrentPage(page),\n [setCurrentPage],\n )\n\n const range = useMemo((): (\"ellipsis\" | number)[] => {\n const minimumTotal = siblings * 2 + 3 + boundaries * 2\n\n if (minimumTotal >= total) return computedRange(1, total)\n\n const prevSiblings = Math.max(currentPage - siblings, boundaries)\n const nextSiblings = Math.min(currentPage + siblings, total - boundaries)\n\n const prevDots = prevSiblings > boundaries + 2\n const nextDots = nextSiblings < total - (boundaries + 1)\n\n if (!prevDots && nextDots) {\n const prevPages = siblings * 2 + boundaries + 2\n\n return [\n ...computedRange(1, prevPages),\n \"ellipsis\",\n ...computedRange(total - (boundaries - 1), total),\n ]\n }\n\n if (prevDots && !nextDots) {\n const nextPages = boundaries + 1 + 2 * siblings\n\n return [\n ...computedRange(1, boundaries),\n \"ellipsis\",\n ...computedRange(total - nextPages, total),\n ]\n }\n\n return [\n ...computedRange(1, boundaries),\n \"ellipsis\",\n ...computedRange(prevSiblings, nextSiblings),\n \"ellipsis\",\n ...computedRange(total - boundaries + 1, total),\n ]\n }, [boundaries, siblings, currentPage, total])\n\n return {\n currentPage,\n isDisabled,\n range,\n total,\n onChange,\n onFirst,\n onLast,\n onNext,\n onPrev,\n }\n}\n\nexport type UsePaginationReturn = ReturnType<typeof usePagination>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSA,IAAAA,eAKO;AACP,IAAAC,oBAAyB;AACzB,IAAAC,gBAAyC;AACzC,IAAAC,gBAAwB;;;ACfxB,kBAAmB;AACnB,oBAAkC;AAClC,IAAAC,gBAA6B;;;ACF7B,kBAAqB;AAKf;AAHC,IAAM,yBAAwC,CAAC,UAAU;AAC9D,SACE,4CAAC,oBAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AAEA,uBAAuB,cAAc;AACrC,uBAAuB,SAAS;AAEzB,IAAM,sBAAqC,CAAC,UAAU;AAC3D,SACE,4CAAC,oBAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AAEA,oBAAoB,cAAc;AAClC,oBAAoB,SAAS;AAEtB,IAAM,qBAAoC,CAAC,UAAU;AAC1D,SACE,4CAAC,oBAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AAEA,mBAAmB,cAAc;AACjC,mBAAmB,SAAS;AAErB,IAAM,qBAAoC,CAAC,UAAU;AAC1D,SACE,4CAAC,oBAAK,SAAQ,aAAa,GAAG,OAC5B;AAAA,IAAC;AAAA;AAAA,MACC,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;AAEA,mBAAmB,cAAc;AACjC,mBAAmB,SAAS;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,CAAC;AAED,WAAW,cAAc;AACzB,WAAW,SAAS;","names":["import_core","import_use_value","import_utils","import_react","import_utils","page","import_jsx_runtime","import_jsx_runtime","page"]}
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  "use client"
2
2
  import {
3
3
  Pagination
4
- } from "./chunk-PGW7Y4GO.mjs";
5
- import "./chunk-GOSRKZFX.mjs";
6
- import "./chunk-VPZBFCSD.mjs";
4
+ } from "./chunk-E35BXOXS.mjs";
5
+ import "./chunk-PUQ5FNCP.mjs";
6
+ import "./chunk-VZWGYG76.mjs";
7
7
  import {
8
8
  usePagination
9
- } from "./chunk-GKZNNZOM.mjs";
9
+ } from "./chunk-O6EIBNLC.mjs";
10
10
  export {
11
11
  Pagination,
12
12
  usePagination
@@ -1,10 +1,10 @@
1
1
  import { FC } from '@yamada-ui/core';
2
2
  import { IconProps } from '@yamada-ui/icon';
3
3
 
4
- declare const DotsIcon: FC<IconProps>;
5
- declare const FirstIcon: FC<IconProps>;
6
- declare const LastIcon: FC<IconProps>;
7
- declare const PrevIcon: FC<IconProps>;
8
- declare const NextIcon: FC<IconProps>;
4
+ declare const PaginationEllipsisIcon: FC<IconProps>;
5
+ declare const PaginationFirstIcon: FC<IconProps>;
6
+ declare const PaginationLastIcon: FC<IconProps>;
7
+ declare const PaginationPrevIcon: FC<IconProps>;
8
+ declare const PaginationNextIcon: FC<IconProps>;
9
9
 
10
- export { DotsIcon, FirstIcon, LastIcon, NextIcon, PrevIcon };
10
+ export { PaginationEllipsisIcon, PaginationFirstIcon, PaginationLastIcon, PaginationNextIcon, PaginationPrevIcon };
@@ -1,10 +1,10 @@
1
1
  import { FC } from '@yamada-ui/core';
2
2
  import { IconProps } from '@yamada-ui/icon';
3
3
 
4
- declare const DotsIcon: FC<IconProps>;
5
- declare const FirstIcon: FC<IconProps>;
6
- declare const LastIcon: FC<IconProps>;
7
- declare const PrevIcon: FC<IconProps>;
8
- declare const NextIcon: FC<IconProps>;
4
+ declare const PaginationEllipsisIcon: FC<IconProps>;
5
+ declare const PaginationFirstIcon: FC<IconProps>;
6
+ declare const PaginationLastIcon: FC<IconProps>;
7
+ declare const PaginationPrevIcon: FC<IconProps>;
8
+ declare const PaginationNextIcon: FC<IconProps>;
9
9
 
10
- export { DotsIcon, FirstIcon, LastIcon, NextIcon, PrevIcon };
10
+ export { PaginationEllipsisIcon, PaginationFirstIcon, PaginationLastIcon, PaginationNextIcon, PaginationPrevIcon };