@charcoal-ui/react 5.5.0-beta.0 → 5.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Pagination/helper.d.ts +1 -1
- package/dist/components/Pagination/helper.d.ts.map +1 -1
- package/dist/components/Pagination/index.d.ts +34 -7
- package/dist/components/Pagination/index.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/Modal/index.tsx +1 -1
- package/src/components/Pagination/Pagination.story.tsx +48 -7
- package/src/components/Pagination/helper.test.ts +58 -0
- package/src/components/Pagination/helper.ts +13 -12
- package/src/components/Pagination/index.tsx +120 -125
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function usePaginationWindow(page: number, pageCount: number, pageRangeDisplayed?: number): (number | "...")[];
|
|
2
2
|
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/helper.ts"],"names":[],"mappings":"AAGA,wBAAgB,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/helper.ts"],"names":[],"mappings":"AAGA,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,kBAAkB,SAAI,sBAgEvB"}
|
|
@@ -4,13 +4,40 @@ interface CommonProps {
|
|
|
4
4
|
pageCount: number;
|
|
5
5
|
pageRangeDisplayed?: number;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
type LinkComponentProps = {
|
|
8
|
+
href: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
type NavProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'onChange'>;
|
|
13
|
+
/**
|
|
14
|
+
* Pagination component. Use either `onChange` (button mode) or `makeUrl` (link mode).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Button mode - for client-side state
|
|
18
|
+
* <Pagination page={1} pageCount={10} onChange={setPage} />
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Link mode - for server routing / static pages
|
|
22
|
+
* <Pagination page={1} pageCount={10} makeUrl={(p) => `?page=${p}`} />
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Link mode with custom component (e.g. Next.js Link)
|
|
26
|
+
* <Pagination page={1} pageCount={10} makeUrl={(p) => `?page=${p}`} component={Link} />
|
|
27
|
+
*/
|
|
28
|
+
export type PaginationProps = CommonProps & NavProps & ({
|
|
8
29
|
onChange(newPage: number): void;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export interface LinkPaginationProps extends CommonProps {
|
|
30
|
+
makeUrl?: never;
|
|
31
|
+
component?: never;
|
|
32
|
+
} | {
|
|
13
33
|
makeUrl(page: number): string;
|
|
14
|
-
|
|
15
|
-
|
|
34
|
+
onChange?: never;
|
|
35
|
+
/**
|
|
36
|
+
* The component used for link elements. Receives `href`, `className`, and `children`.
|
|
37
|
+
* @default 'a'
|
|
38
|
+
*/
|
|
39
|
+
component?: React.ElementType<LinkComponentProps>;
|
|
40
|
+
});
|
|
41
|
+
export default function Pagination({ page, pageCount, pageRangeDisplayed, onChange, makeUrl, component: LinkComponent, className, ...navProps }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export {};
|
|
16
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAMpB,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAA;AAEvE;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GACvC,QAAQ,GACR,CACI;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,CAAA;CAAE,GACvE;IACE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAA;CAClD,CACJ,CAAA;AAEH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,SAAS,EACT,kBAAkB,EAClB,QAAQ,EACR,OAAO,EACP,SAAS,EAAE,aAAmB,EAC9B,SAAS,EACT,GAAG,QAAQ,EACZ,EAAE,eAAe,2CA6FjB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@react-aria/ssr`);c=s(c);let l=require(`react`);l=s(l);let u=require(`@react-aria/overlays`);u=s(u);let d=require(`react/jsx-runtime`);d=s(d);let f=require(`warning`);f=s(f),require(`@charcoal-ui/icons`);let p=require(`@react-aria/utils`);p=s(p);let m=require(`@react-aria/visually-hidden`);m=s(m);let h=require(
|
|
1
|
+
"use client";var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@react-aria/ssr`);c=s(c);let l=require(`react`);l=s(l);let u=require(`@react-aria/overlays`);u=s(u);let d=require(`react/jsx-runtime`);d=s(d);let f=require(`warning`);f=s(f),require(`@charcoal-ui/icons`);let p=require(`@react-aria/utils`);p=s(p);let m=require(`@react-aria/visually-hidden`);m=s(m);let h=require(`@react-spring/web`);h=s(h);let g=require(`@react-aria/dialog`);g=s(g);let _=require(`@react-stately/radio`);_=s(_);let v=require(`@react-aria/radio`);v=s(v);let y=require(`react-compiler-runtime`);y=s(y);function b(e){let t=parseInt(l.version.split(`.`)[0],10);return Number.isFinite(t)?t>=e:!1}const x=b(18)?l.Fragment:c.SSRProvider;function S({children:e}){return(0,d.jsx)(x,{children:(0,d.jsx)(u.OverlayProvider,{children:e})})}const C=`charcoal-theme`,w=`theme`,T=new RegExp(/^(\w|-)+$/);function E(e){if(!T.test(e))throw Error(`Unexpected key :${e}, expect: /^(\\w|-)+$/`)}const D=(e=w)=>t=>{E(e),t===void 0?delete document.documentElement.dataset[e]:document.documentElement.dataset[e]=t};function O(e,t){return`:root[data-${t??w}='${e}']`}function k(e){return`@media (prefers-color-scheme: ${e})`}function A({key:e=C,setter:t=D()}={}){let[n,,r]=M(e);(0,l.useEffect)(()=>{n!==void 0&&t(r?void 0:n)},[t,r,n])}function j(e=C){return localStorage.getItem(e)}const M=(e=C)=>{E(e);let t=I(`(prefers-color-scheme: dark)`),n=t===void 0?void 0:t?`dark`:`light`,[r,i,a]=N(e);return[!a||n===void 0?void 0:r??n,i,r===void 0]};function N(e,t){let[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(),o=(0,l.useMemo)(()=>t?.(),[t]);(0,l.useEffect)(()=>(c(),window.addEventListener(`storage`,s),()=>{window.removeEventListener(`storage`,s)}));let s=t=>{t.storageArea===localStorage&&t.key===e&&c()},c=()=>{let t=localStorage.getItem(e);a((t===null?null:P(t))??o),r(!0)};return[i??o,t=>{if(t===void 0)localStorage.removeItem(e);else{let n=F(t);localStorage.setItem(e,n)}let n=new StorageEvent(`storage`,{bubbles:!0,cancelable:!1,key:e,url:location.href,storageArea:localStorage});dispatchEvent(n)},n]}function P(e){try{return JSON.parse(e)}catch{return e}}function F(e){return typeof e==`string`?e:JSON.stringify(e)}function I(e){let[t,n]=(0,l.useState)();return(0,l.useEffect)(()=>{let t=window.matchMedia(e),r=()=>{n(t.matches)};return t.addEventListener(`change`,r),n(t.matches),()=>{t.removeEventListener(`change`,r)}},[e]),t}function L({localStorageKey:e=R.localStorageKey,rootAttribute:t=R.rootAttribute}=R){return E(e),E(t),`'use strict';
|
|
2
2
|
(function () {
|
|
3
3
|
var localStorageKey = '${e}'
|
|
4
4
|
var rootAttribute = '${t}'
|