@ngrok/mantle 0.10.2 → 0.12.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.
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentProps } from 'react';
3
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
4
- import { V as VariantProps } from './variant-props-Dc9PJLzN.js';
4
+ import { V as VariantProps } from './variant-props-oDo2u-We.js';
5
5
 
6
6
  declare const buttonGroupVariants: (props?: ({
7
7
  appearance?: "ghost" | "outlined" | "panel" | null | undefined;
package/dist/button.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { ButtonHTMLAttributes, ReactNode } from 'react';
3
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
4
- import { V as VariantProps } from './variant-props-Dc9PJLzN.js';
5
- export { I as IconButton, a as IconButtonProps } from './icon-button-C887Pif0.js';
6
- export { B as ButtonGroup, a as ButtonGroupProps } from './button-group-CKDEXxVI.js';
4
+ import { V as VariantProps } from './variant-props-oDo2u-We.js';
5
+ export { I as IconButton, a as IconButtonProps } from './icon-button-CZzW1XWB.js';
6
+ export { B as ButtonGroup, a as ButtonGroupProps } from './button-group-B6YpBIE8.js';
7
7
  import 'class-variance-authority';
8
8
  import './deep-non-nullable-SmpSvoSd.js';
9
9
  import './as-child-Cvu56SuO.js';
package/dist/dialog.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import * as DialogPrimitive from '@radix-ui/react-dialog';
4
- import { a as IconButtonProps } from './icon-button-C887Pif0.js';
4
+ import { a as IconButtonProps } from './icon-button-CZzW1XWB.js';
5
5
  import 'class-variance-authority/types';
6
6
  import './as-child-Cvu56SuO.js';
7
- import './variant-props-Dc9PJLzN.js';
7
+ import './variant-props-oDo2u-We.js';
8
8
  import 'class-variance-authority';
9
9
  import './deep-non-nullable-SmpSvoSd.js';
10
10
 
package/dist/hooks.d.ts CHANGED
@@ -1,4 +1,14 @@
1
- import { useLayoutEffect } from 'react';
1
+ import { useEffect } from 'react';
2
+
3
+ /**
4
+ * Returns a memoized callback that will always refer to the latest callback
5
+ * passed to the hook.
6
+ *
7
+ * This is useful when you want to pass a callback which may or may not be
8
+ * memoized (have a stable identity) to a child component that will be updated
9
+ * without causing the child component to re-render.
10
+ */
11
+ declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
2
12
 
3
13
  /**
4
14
  * A hook that allows you to copy a string to the clipboard.
@@ -7,10 +17,28 @@ import { useLayoutEffect } from 'react';
7
17
  */
8
18
  declare function useCopyToClipboard(): readonly [string, (value: string) => void];
9
19
 
20
+ type Options = {
21
+ /**
22
+ * The delay in milliseconds to wait before calling the callback.
23
+ */
24
+ waitMs: number;
25
+ };
26
+ /**
27
+ * Create a debounced version of a callback function.
28
+ *
29
+ * It allows you to delay the execution of a function until a certain period of
30
+ * inactivity has passed (the `options.waitMs`), which can be useful for limiting rapid
31
+ * invocations of a function (like in search inputs or button clicks)
32
+ *
33
+ * Note: The debounced callback will always refer to the latest callback passed
34
+ * even without memoization, so it's stable and safe to use in dependency arrays.
35
+ */
36
+ declare function useDebouncedCallback<T extends (...args: any[]) => any>(callbackFn: T, options: Options): (...args: Parameters<T>) => void;
37
+
10
38
  /**
11
39
  * useIsomorphicLayoutEffect is a hook that uses useLayoutEffect on the client and useEffect on the server.
12
40
  */
13
- declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
41
+ declare const useIsomorphicLayoutEffect: typeof useEffect;
14
42
 
15
43
  declare function useMatchesMediaQuery(query: string): boolean;
16
44
 
@@ -26,4 +54,4 @@ declare function usePrefersReducedMotion(): boolean;
26
54
  */
27
55
  declare const useRandomStableId: (prefix?: string) => string;
28
56
 
29
- export { useCopyToClipboard, useIsomorphicLayoutEffect, useMatchesMediaQuery, usePrefersReducedMotion, useRandomStableId };
57
+ export { useCallbackRef, useCopyToClipboard, useDebouncedCallback, useIsomorphicLayoutEffect, useMatchesMediaQuery, usePrefersReducedMotion, useRandomStableId };
package/dist/hooks.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as u}from"./chunk-D3XF6J5A.js";import{a as s}from"./chunk-IWKI4XHM.js";import{useEffect as i,useLayoutEffect as f}from"react";var c=typeof window<"u"?f:i;import{useEffect as d,useState as m}from"react";var a="(prefers-reduced-motion: no-preference)";function p(){let[e,t]=m(!0);return d(()=>{let o=window.matchMedia(a);t(!o.matches);function r(n){t(!n.matches)}return o.addEventListener("change",r),()=>{o.removeEventListener("change",r)}},[]),e}import{useMemo as x}from"react";var M=(e="mantle")=>x(()=>h(e),[e]);function h(e="mantle"){return[e.trim()||"mantle",y()].join("-")}function y(){return Math.random().toString(36).substring(2,9)}export{s as useCopyToClipboard,c as useIsomorphicLayoutEffect,u as useMatchesMediaQuery,p as usePrefersReducedMotion,M as useRandomStableId};
1
+ import{a}from"./chunk-D3XF6J5A.js";import{a as u}from"./chunk-IWKI4XHM.js";import{useEffect as c,useMemo as f,useRef as i}from"react";function s(e){let t=i(e);return c(()=>{t.current=e}),f(()=>(...r)=>t.current?.(...r),[])}import{useCallback as m,useEffect as d,useRef as p}from"react";function l(e,t){let r=s(e),o=p(0);return d(()=>()=>window.clearTimeout(o.current),[]),m((...n)=>{window.clearTimeout(o.current),o.current=window.setTimeout(()=>r(...n),t.waitMs)},[r,t.waitMs])}import{useEffect as b,useLayoutEffect as x}from"react";var y=typeof window<"u"?x:b;import{useEffect as M,useState as w}from"react";var R="(prefers-reduced-motion: no-preference)";function T(){let[e,t]=w(!0);return M(()=>{let r=window.matchMedia(R);t(!r.matches);function o(n){t(!n.matches)}return r.addEventListener("change",o),()=>{r.removeEventListener("change",o)}},[]),e}import{useMemo as E}from"react";var h=(e="mantle")=>E(()=>C(e),[e]);function C(e="mantle"){return[e.trim()||"mantle",k()].join("-")}function k(){return Math.random().toString(36).substring(2,9)}export{s as useCallbackRef,u as useCopyToClipboard,l as useDebouncedCallback,y as useIsomorphicLayoutEffect,a as useMatchesMediaQuery,T as usePrefersReducedMotion,h as useRandomStableId};
2
2
  //# sourceMappingURL=hooks.js.map
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/use-isomorphic-layout-effect.tsx","../src/hooks/use-prefers-reduced-motion.tsx","../src/hooks/use-random-stable-id.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect } from \"react\";\n\n/**\n * useIsomorphicLayoutEffect is a hook that uses useLayoutEffect on the client and useEffect on the server.\n */\nexport const useIsomorphicLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n","import { useEffect, useState } from \"react\";\n\n/**\n * no-preference is the default value for the prefers-reduced-motion media query.\n * Users who have never fiddled with their a11y settings will still see animations\n * (no explicit opt-in required from a user's perspective)\n */\nconst query = \"(prefers-reduced-motion: no-preference)\";\n\n/**\n * usePrefersReducedMotion returns true if the user has opted out of animations\n */\nexport function usePrefersReducedMotion() {\n\t// default to no animations, since we don't know what the user's preference is on the server\n\tconst [prefersReducedMotion, setPrefersReducedMotion] = useState(true);\n\n\tuseEffect(() => {\n\t\tconst mediaQueryList = window.matchMedia(query);\n\n\t\t// set the _real_ initial value now that we're on the client\n\t\tsetPrefersReducedMotion(!mediaQueryList.matches);\n\n\t\t// register for updates\n\t\tfunction listener(event: MediaQueryListEvent) {\n\t\t\tsetPrefersReducedMotion(!event.matches);\n\t\t}\n\n\t\tmediaQueryList.addEventListener(\"change\", listener);\n\n\t\treturn () => {\n\t\t\tmediaQueryList.removeEventListener(\"change\", listener);\n\t\t};\n\t}, []);\n\n\treturn prefersReducedMotion;\n}\n","import { useMemo } from \"react\";\n\n/**\n * Hook to generate a random, stable id.\n * This is similar to `useId`, but generates a stable id client side which can also\n * be used for css selectors and element ids.\n */\nconst useRandomStableId = (prefix = \"mantle\") => useMemo(() => randomStableId(prefix), [prefix]);\n\nexport {\n\t//,\n\tuseRandomStableId,\n};\n\nfunction randomStableId(prefix = \"mantle\") {\n\tconst _prefix = prefix.trim() || \"mantle\";\n\treturn [_prefix, randomPostfix()].join(\"-\");\n}\n\nfunction randomPostfix() {\n\treturn Math.random().toString(36).substring(2, 9);\n}\n"],"mappings":"gFAAA,OAAS,aAAAA,EAAW,mBAAAC,MAAuB,QAKpC,IAAMC,EAA4B,OAAO,OAAW,IAAcD,EAAkBD,ECL3F,OAAS,aAAAG,EAAW,YAAAC,MAAgB,QAOpC,IAAMC,EAAQ,0CAKP,SAASC,GAA0B,CAEzC,GAAM,CAACC,EAAsBC,CAAuB,EAAIJ,EAAS,EAAI,EAErE,OAAAD,EAAU,IAAM,CACf,IAAMM,EAAiB,OAAO,WAAWJ,CAAK,EAG9CG,EAAwB,CAACC,EAAe,OAAO,EAG/C,SAASC,EAASC,EAA4B,CAC7CH,EAAwB,CAACG,EAAM,OAAO,CACvC,CAEA,OAAAF,EAAe,iBAAiB,SAAUC,CAAQ,EAE3C,IAAM,CACZD,EAAe,oBAAoB,SAAUC,CAAQ,CACtD,CACD,EAAG,CAAC,CAAC,EAEEH,CACR,CCnCA,OAAS,WAAAK,MAAe,QAOxB,IAAMC,EAAoB,CAACC,EAAS,WAAaF,EAAQ,IAAMG,EAAeD,CAAM,EAAG,CAACA,CAAM,CAAC,EAO/F,SAASE,EAAeC,EAAS,SAAU,CAE1C,MAAO,CADSA,EAAO,KAAK,GAAK,SAChBC,EAAc,CAAC,EAAE,KAAK,GAAG,CAC3C,CAEA,SAASA,GAAgB,CACxB,OAAO,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,EAAG,CAAC,CACjD","names":["useEffect","useLayoutEffect","useIsomorphicLayoutEffect","useEffect","useState","query","usePrefersReducedMotion","prefersReducedMotion","setPrefersReducedMotion","mediaQueryList","listener","event","useMemo","useRandomStableId","prefix","randomStableId","randomStableId","prefix","randomPostfix"]}
1
+ {"version":3,"sources":["../src/hooks/use-callback-ref.tsx","../src/hooks/use-debounced-callback.tsx","../src/hooks/use-isomorphic-layout-effect.tsx","../src/hooks/use-prefers-reduced-motion.tsx","../src/hooks/use-random-stable-id.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from \"react\";\n\n/**\n * Returns a memoized callback that will always refer to the latest callback\n * passed to the hook.\n *\n * This is useful when you want to pass a callback which may or may not be\n * memoized (have a stable identity) to a child component that will be updated\n * without causing the child component to re-render.\n */\nfunction useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T {\n\tconst callbackRef = useRef(callback);\n\n\tuseEffect(() => {\n\t\tcallbackRef.current = callback;\n\t});\n\n\treturn useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n\nexport {\n\t//,\n\tuseCallbackRef,\n};\n","import { useCallback, useEffect, useRef } from \"react\";\nimport { useCallbackRef } from \"./use-callback-ref.js\";\n\ntype Options = {\n\t/**\n\t * The delay in milliseconds to wait before calling the callback.\n\t */\n\twaitMs: number;\n};\n\n/**\n * Create a debounced version of a callback function.\n *\n * It allows you to delay the execution of a function until a certain period of\n * inactivity has passed (the `options.waitMs`), which can be useful for limiting rapid\n * invocations of a function (like in search inputs or button clicks)\n *\n * Note: The debounced callback will always refer to the latest callback passed\n * even without memoization, so it's stable and safe to use in dependency arrays.\n */\nfunction useDebouncedCallback<T extends (...args: any[]) => any>(callbackFn: T, options: Options) {\n\tconst stableCallbackFn = useCallbackRef(callbackFn);\n\tconst debounceTimerRef = useRef(0);\n\tuseEffect(() => () => window.clearTimeout(debounceTimerRef.current), []);\n\n\treturn useCallback(\n\t\t(...args: Parameters<T>) => {\n\t\t\twindow.clearTimeout(debounceTimerRef.current);\n\t\t\tdebounceTimerRef.current = window.setTimeout(() => stableCallbackFn(...args), options.waitMs);\n\t\t},\n\t\t[stableCallbackFn, options.waitMs],\n\t);\n}\n\nexport {\n\t//,\n\tuseDebouncedCallback,\n};\n","import { useEffect, useLayoutEffect } from \"react\";\n\n/**\n * useIsomorphicLayoutEffect is a hook that uses useLayoutEffect on the client and useEffect on the server.\n */\nexport const useIsomorphicLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n","import { useEffect, useState } from \"react\";\n\n/**\n * no-preference is the default value for the prefers-reduced-motion media query.\n * Users who have never fiddled with their a11y settings will still see animations\n * (no explicit opt-in required from a user's perspective)\n */\nconst query = \"(prefers-reduced-motion: no-preference)\";\n\n/**\n * usePrefersReducedMotion returns true if the user has opted out of animations\n */\nexport function usePrefersReducedMotion() {\n\t// default to no animations, since we don't know what the user's preference is on the server\n\tconst [prefersReducedMotion, setPrefersReducedMotion] = useState(true);\n\n\tuseEffect(() => {\n\t\tconst mediaQueryList = window.matchMedia(query);\n\n\t\t// set the _real_ initial value now that we're on the client\n\t\tsetPrefersReducedMotion(!mediaQueryList.matches);\n\n\t\t// register for updates\n\t\tfunction listener(event: MediaQueryListEvent) {\n\t\t\tsetPrefersReducedMotion(!event.matches);\n\t\t}\n\n\t\tmediaQueryList.addEventListener(\"change\", listener);\n\n\t\treturn () => {\n\t\t\tmediaQueryList.removeEventListener(\"change\", listener);\n\t\t};\n\t}, []);\n\n\treturn prefersReducedMotion;\n}\n","import { useMemo } from \"react\";\n\n/**\n * Hook to generate a random, stable id.\n * This is similar to `useId`, but generates a stable id client side which can also\n * be used for css selectors and element ids.\n */\nconst useRandomStableId = (prefix = \"mantle\") => useMemo(() => randomStableId(prefix), [prefix]);\n\nexport {\n\t//,\n\tuseRandomStableId,\n};\n\nfunction randomStableId(prefix = \"mantle\") {\n\tconst _prefix = prefix.trim() || \"mantle\";\n\treturn [_prefix, randomPostfix()].join(\"-\");\n}\n\nfunction randomPostfix() {\n\treturn Math.random().toString(36).substring(2, 9);\n}\n"],"mappings":"2EAAA,OAAS,aAAAA,EAAW,WAAAC,EAAS,UAAAC,MAAc,QAU3C,SAASC,EAAkDC,EAA4B,CACtF,IAAMC,EAAcH,EAAOE,CAAQ,EAEnC,OAAAJ,EAAU,IAAM,CACfK,EAAY,QAAUD,CACvB,CAAC,EAEMH,E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,EAAE,KAAK,GAAG,CAC3C,CAEA,SAASA,GAAgB,CACxB,OAAO,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,EAAG,CAAC,CACjD","names":["useEffect","useMemo","useRef","useCallbackRef","callback","callbackRef","args","useCallback","useEffect","useRef","useDebouncedCallback","callbackFn","options","stableCallbackFn","useCallbackRef","debounceTimerRef","useRef","useEffect","useCallback","args","useEffect","useLayoutEffect","useIsomorphicLayoutEffect","useEffect","useState","query","usePrefersReducedMotion","prefersReducedMotion","setPrefersReducedMotion","mediaQueryList","listener","event","useMemo","useRandomStableId","prefix","randomStableId","randomStableId","prefix","randomPostfix"]}
@@ -2,7 +2,7 @@ import * as react from 'react';
2
2
  import { ButtonHTMLAttributes, ReactNode } from 'react';
3
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
4
4
  import { W as WithAsChild } from './as-child-Cvu56SuO.js';
5
- import { V as VariantProps } from './variant-props-Dc9PJLzN.js';
5
+ import { V as VariantProps } from './variant-props-oDo2u-We.js';
6
6
 
7
7
  declare const iconButtonVariants: (props?: ({
8
8
  appearance?: "ghost" | "outlined" | null | undefined;
@@ -2,10 +2,10 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { ComponentProps } from 'react';
4
4
  import { W as WithAsChild } from './as-child-Cvu56SuO.js';
5
- import { B as ButtonGroup } from './button-group-CKDEXxVI.js';
5
+ import { B as ButtonGroup } from './button-group-B6YpBIE8.js';
6
6
  import { SelectTrigger } from './select.js';
7
7
  import 'class-variance-authority/types';
8
- import './variant-props-Dc9PJLzN.js';
8
+ import './variant-props-oDo2u-We.js';
9
9
  import 'class-variance-authority';
10
10
  import './deep-non-nullable-SmpSvoSd.js';
11
11
  import '@radix-ui/react-separator';
@@ -1,2 +1,2 @@
1
- import{a as b,c as v,d as x,e as y,g as h}from"./chunk-E6LNHWJ3.js";import{b as z}from"./chunk-CXQLUXDJ.js";import{a as d}from"./chunk-VTEPKCRP.js";import{a as m}from"./chunk-E4ORUHXM.js";import"./chunk-LGKHTPYA.js";import"./chunk-4LSFAAZW.js";import"./chunk-RDMTCZPT.js";import"./chunk-BGJBYKS4.js";import"./chunk-JTS7CKVJ.js";import"./chunk-5E73VWJX.js";import{a as p}from"./chunk-EW5CFGXT.js";import{CaretLeft as j}from"@phosphor-icons/react/dist/icons/CaretLeft";import{CaretRight as k}from"@phosphor-icons/react/dist/icons/CaretRight";import{Slot as A}from"@radix-ui/react-slot";import{createContext as F,forwardRef as f,useContext as N,useState as W}from"react";import P from"tiny-invariant";import{jsx as s,jsxs as l}from"react/jsx-runtime";var c=F(void 0),O=f(({className:n,children:o,defaultPageSize:a,...e},i)=>{let[t,r]=W(a);return s(c.Provider,{value:{defaultPageSize:a,pageSize:t,setPageSize:r},children:s("div",{className:p("inline-flex items-center justify-between gap-2",n),ref:i,...e,children:o})})});O.displayName="CursorPagination";var B=f(({hasNextPage:n,hasPreviousPage:o,onNextPage:a,onPreviousPage:e,...i},t)=>l(d,{appearance:"panel",ref:t,...i,children:[s(m,{appearance:"ghost",disabled:!o,icon:s(j,{}),label:"Previous page",onClick:e,size:"sm",type:"button"}),s(z,{orientation:"vertical",className:"min-h-5"}),s(m,{appearance:"ghost",disabled:!n,icon:s(k,{}),label:"Next page",onClick:a,size:"sm",type:"button"})]}));B.displayName="CursorButtons";var $=[5,10,20,50,100],T=f(({className:n,pageSizes:o=$,onChangePageSize:a,...e},i)=>{let t=N(c);return P(t,"CursorPageSizeSelect must be used as a child of a CursorPagination component"),P(o.includes(t.defaultPageSize),"CursorPagination.defaultPageSize must be included in CursorPageSizeSelect.pageSizes"),P(o.includes(t.pageSize),"CursorPagination.pageSize must be included in CursorPageSizeSelect.pageSizes"),l(b,{defaultValue:`${t.pageSize}`,onChange:r=>{let g=Number.parseInt(r,10);Number.isNaN(g)&&(g=t.defaultPageSize),t.setPageSize(g),a?.(g)},children:[s(x,{ref:i,className:p("w-auto min-w-36",n),value:t.pageSize,...e,children:s(v,{})}),s(y,{width:"trigger",children:o.map(r=>l(h,{value:`${r}`,children:[r," per page"]},r))})]})});T.displayName="CursorPageSizeSelect";function D({asChild:n=!1,className:o,...a}){let e=N(c);return P(e,"CursorPageSizeValue must be used as a child of a CursorPagination component"),l(n?A:"span",{className:p("text-muted text-sm font-normal",o),...a,children:[e.pageSize," per page"]})}import{useEffect as V,useState as w}from"react";function H({listSize:n,pageSize:o}){let[a,e]=w(1),[i,t]=w(o);V(()=>{t(o),e(1)},[o]),V(()=>{e(1)},[n]);let r=Math.ceil(n/i),g=(a-1)*i,S=a>1,C=a<r;function M(u){let U=Math.max(1,Math.min(u,r));e(U)}function E(){C&&e(u=>Math.min(u+1,r))}function R(){S&&e(u=>Math.max(u-1,1))}function G(u){t(u),e(1)}function I(){e(r)}function L(){e(1)}return{currentPage:a,goToFirstPage:L,goToLastPage:I,goToPage:M,hasNextPage:C,hasPreviousPage:S,nextPage:E,offset:g,pageSize:i,previousPage:R,setPageSize:G,totalPages:r}}export{B as CursorButtons,T as CursorPageSizeSelect,D as CursorPageSizeValue,O as CursorPagination,H as useOffsetPagination};
1
+ import{a as b,c as v,d as x,e as y,g as h}from"./chunk-E6LNHWJ3.js";import{b as z}from"./chunk-CXQLUXDJ.js";import{a as d}from"./chunk-VTEPKCRP.js";import{a as f}from"./chunk-E4ORUHXM.js";import"./chunk-LGKHTPYA.js";import"./chunk-4LSFAAZW.js";import"./chunk-RDMTCZPT.js";import"./chunk-BGJBYKS4.js";import"./chunk-JTS7CKVJ.js";import"./chunk-5E73VWJX.js";import{a as p}from"./chunk-EW5CFGXT.js";import{CaretLeft as j}from"@phosphor-icons/react/dist/icons/CaretLeft";import{CaretRight as k}from"@phosphor-icons/react/dist/icons/CaretRight";import{Slot as A}from"@radix-ui/react-slot";import{createContext as F,forwardRef as m,useContext as N,useState as W}from"react";import P from"tiny-invariant";import{jsx as s,jsxs as l}from"react/jsx-runtime";var c=F(void 0),O=m(({className:n,children:o,defaultPageSize:a,...e},i)=>{let[t,r]=W(a);return s(c.Provider,{value:{defaultPageSize:a,pageSize:t,setPageSize:r},children:s("div",{className:p("inline-flex items-center justify-between gap-2",n),ref:i,...e,children:o})})});O.displayName="CursorPagination";var T=m(({hasNextPage:n,hasPreviousPage:o,onNextPage:a,onPreviousPage:e,...i},t)=>l(d,{appearance:"panel",ref:t,...i,children:[s(f,{appearance:"ghost",disabled:!o,icon:s(j,{}),label:"Previous page",onClick:e,size:"sm",type:"button"}),s(z,{orientation:"vertical",className:"min-h-5"}),s(f,{appearance:"ghost",disabled:!n,icon:s(k,{}),label:"Next page",onClick:a,size:"sm",type:"button"})]}));T.displayName="CursorButtons";var $=[5,10,20,50,100],B=m(({className:n,pageSizes:o=$,onChangePageSize:a,...e},i)=>{let t=N(c);return P(t,"CursorPageSizeSelect must be used as a child of a CursorPagination component"),P(o.includes(t.defaultPageSize),"CursorPagination.defaultPageSize must be included in CursorPageSizeSelect.pageSizes"),P(o.includes(t.pageSize),"CursorPagination.pageSize must be included in CursorPageSizeSelect.pageSizes"),l(b,{defaultValue:`${t.pageSize}`,onChange:r=>{let g=Number.parseInt(r,10);Number.isNaN(g)&&(g=t.defaultPageSize),t.setPageSize(g),a?.(g)},children:[s(x,{ref:i,className:p("w-auto min-w-36",n),value:t.pageSize,...e,children:s(v,{})}),s(y,{width:"trigger",children:o.map(r=>l(h,{value:`${r}`,children:[r," per page"]},r))})]})});B.displayName="CursorPageSizeSelect";function D({asChild:n=!1,className:o,...a}){let e=N(c);return P(e,"CursorPageSizeValue must be used as a child of a CursorPagination component"),l(n?A:"span",{className:p("text-muted text-sm font-normal",o),...a,children:[e.pageSize," per page"]})}import{useEffect as V,useState as w}from"react";function H({listSize:n,pageSize:o}){let[a,e]=w(1),[i,t]=w(o);V(()=>{t(o),e(1)},[o]),V(()=>{e(1)},[n]);let r=Math.ceil(n/i),g=(a-1)*i,S=a>1,C=a<r;function M(u){let U=Math.max(1,Math.min(u,r));e(U)}function E(){C&&e(u=>Math.min(u+1,r))}function R(){S&&e(u=>Math.max(u-1,1))}function G(u){t(u),e(1)}function I(){e(r)}function L(){e(1)}return{currentPage:a,goToFirstPage:L,goToLastPage:I,goToPage:M,hasNextPage:C,hasPreviousPage:S,nextPage:E,offset:g,pageSize:i,previousPage:R,setPageSize:G,totalPages:r}}export{T as CursorButtons,B as CursorPageSizeSelect,D as CursorPageSizeValue,O as CursorPagination,H as useOffsetPagination};
2
2
  //# sourceMappingURL=pagination.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/pagination/cursor-pagination.tsx","../src/components/pagination/use-offset-pagination.tsx"],"sourcesContent":["import { CaretLeft } from \"@phosphor-icons/react/dist/icons/CaretLeft\";\nimport { CaretRight } from \"@phosphor-icons/react/dist/icons/CaretRight\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { createContext, forwardRef, useContext, useState, type ComponentProps, type ElementRef } from \"react\";\nimport invariant from \"tiny-invariant\";\nimport type { WithAsChild } from \"../../types/as-child.js\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { ButtonGroup, IconButton } from \"../button/index.js\";\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from \"../select/select.js\";\nimport { Separator } from \"../separator/separator.js\";\n\ntype CursorPaginationContextValue = {\n\t/**\n\t * The default number of items per page.\n\t */\n\tdefaultPageSize: number;\n\t/**\n\t * The current number of items per page.\n\t */\n\tpageSize: number;\n\t/**\n\t * A function to set the number of items per page.\n\t */\n\tsetPageSize: (value: number) => void;\n};\n\nconst CursorPaginationContext = createContext<CursorPaginationContextValue | undefined>(undefined);\n\ntype CursorPaginationProps = ComponentProps<\"div\"> & {\n\t/**\n\t * The default number of items per page.\n\t */\n\tdefaultPageSize: number;\n};\n\n/**\n * A pagination component for use with cursor-based pagination.\n *\n * Cursor-based pagination is a way of loading data in chunks by using a cursor\n * from the last item on the current page to know where to start the next set,\n * making sure nothing is missed or repeated. Like a linked list, but for chunks\n * of data. It doesn't let you jump to a specific page or know how many total pages\n * there are, but it's more efficient for large or real-time data sets.\n */\nconst CursorPagination = forwardRef<HTMLDivElement, CursorPaginationProps>(\n\t({ className, children, defaultPageSize, ...props }, ref) => {\n\t\tconst [pageSize, setPageSize] = useState<number>(defaultPageSize);\n\n\t\treturn (\n\t\t\t<CursorPaginationContext.Provider value={{ defaultPageSize, pageSize, setPageSize }}>\n\t\t\t\t<div className={cx(\"inline-flex items-center justify-between gap-2\", className)} ref={ref} {...props}>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</CursorPaginationContext.Provider>\n\t\t);\n\t},\n);\nCursorPagination.displayName = \"CursorPagination\";\n\ntype CursorButtonsProps = Omit<ComponentProps<typeof ButtonGroup>, \"appearance\"> & {\n\t/**\n\t * Whether there is a next page of data to load.\n\t */\n\thasNextPage: boolean;\n\t/**\n\t * Whether there is a previous page of data to load.\n\t */\n\thasPreviousPage: boolean;\n\t/**\n\t * A callback that is called when the next page button is clicked.\n\t */\n\tonNextPage?: () => void;\n\t/**\n\t * A callback that is called when the previous page button is clicked.\n\t */\n\tonPreviousPage?: () => void;\n};\n\n/**\n * A pair of buttons for navigating between pages of data when using cursor-based pagination.\n */\nconst CursorButtons = forwardRef<ElementRef<typeof ButtonGroup>, CursorButtonsProps>(\n\t({ hasNextPage, hasPreviousPage, onNextPage, onPreviousPage, ...props }, ref) => {\n\t\t// TODO(cody): this _feels_ like a good spot for left and right arrow keys to navigate between pages when focused on the buttons\n\n\t\treturn (\n\t\t\t<ButtonGroup appearance=\"panel\" ref={ref} {...props}>\n\t\t\t\t<IconButton\n\t\t\t\t\tappearance=\"ghost\"\n\t\t\t\t\tdisabled={!hasPreviousPage}\n\t\t\t\t\ticon={<CaretLeft />}\n\t\t\t\t\tlabel=\"Previous page\"\n\t\t\t\t\tonClick={onPreviousPage}\n\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t/>\n\t\t\t\t<Separator orientation=\"vertical\" className=\"min-h-5\" />\n\t\t\t\t<IconButton\n\t\t\t\t\tappearance=\"ghost\"\n\t\t\t\t\tdisabled={!hasNextPage}\n\t\t\t\t\ticon={<CaretRight />}\n\t\t\t\t\tlabel=\"Next page\"\n\t\t\t\t\tonClick={onNextPage}\n\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t/>\n\t\t\t</ButtonGroup>\n\t\t);\n\t},\n);\nCursorButtons.displayName = \"CursorButtons\";\n\nconst defaultPageSizes = [5, 10, 20, 50, 100] as const;\n\ntype CursorPageSizeSelectProps = Omit<ComponentProps<typeof SelectTrigger>, \"children\"> & {\n\t/**\n\t * A list of page sizes to choose from. The default page size must be included in this list.\n\t */\n\tpageSizes?: typeof defaultPageSizes | readonly number[];\n\t/**\n\t * A callback that is called when the page size is changed.\n\t */\n\tonChangePageSize?: (value: number) => void;\n};\n\n/**\n * A select input for changing the number of items per page when using cursor-based pagination.\n */\nconst CursorPageSizeSelect = forwardRef<ElementRef<typeof SelectTrigger>, CursorPageSizeSelectProps>(\n\t({ className, pageSizes = defaultPageSizes, onChangePageSize, ...rest }, ref) => {\n\t\tconst ctx = useContext(CursorPaginationContext);\n\n\t\tinvariant(ctx, \"CursorPageSizeSelect must be used as a child of a CursorPagination component\");\n\n\t\tinvariant(\n\t\t\tpageSizes.includes(ctx.defaultPageSize),\n\t\t\t\"CursorPagination.defaultPageSize must be included in CursorPageSizeSelect.pageSizes\",\n\t\t);\n\n\t\tinvariant(\n\t\t\tpageSizes.includes(ctx.pageSize),\n\t\t\t\"CursorPagination.pageSize must be included in CursorPageSizeSelect.pageSizes\",\n\t\t);\n\n\t\treturn (\n\t\t\t<Select\n\t\t\t\tdefaultValue={`${ctx.pageSize}`}\n\t\t\t\tonChange={(value) => {\n\t\t\t\t\tlet newPageSize = Number.parseInt(value, 10);\n\t\t\t\t\tif (Number.isNaN(newPageSize)) {\n\t\t\t\t\t\tnewPageSize = ctx.defaultPageSize;\n\t\t\t\t\t}\n\t\t\t\t\tctx.setPageSize(newPageSize);\n\t\t\t\t\tonChangePageSize?.(newPageSize);\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<SelectTrigger ref={ref} className={cx(\"w-auto min-w-36\", className)} value={ctx.pageSize} {...rest}>\n\t\t\t\t\t<SelectValue />\n\t\t\t\t</SelectTrigger>\n\t\t\t\t<SelectContent width=\"trigger\">\n\t\t\t\t\t{pageSizes.map((size) => (\n\t\t\t\t\t\t<SelectItem key={size} value={`${size}`}>\n\t\t\t\t\t\t\t{size} per page\n\t\t\t\t\t\t</SelectItem>\n\t\t\t\t\t))}\n\t\t\t\t</SelectContent>\n\t\t\t</Select>\n\t\t);\n\t},\n);\nCursorPageSizeSelect.displayName = \"CursorPageSizeSelect\";\n\ntype CursorPageSizeValueProps = Omit<ComponentProps<\"span\">, \"children\"> & WithAsChild;\n\n/**\n * Displays the current page size when using cursor-based pagination as a read-only value.\n */\nfunction CursorPageSizeValue({ asChild = false, className, ...props }: CursorPageSizeValueProps) {\n\tconst ctx = useContext(CursorPaginationContext);\n\n\tinvariant(ctx, \"CursorPageSizeValue must be used as a child of a CursorPagination component\");\n\n\tconst Component = asChild ? Slot : \"span\";\n\n\treturn (\n\t\t<Component className={cx(\"text-muted text-sm font-normal\", className)} {...props}>\n\t\t\t{ctx.pageSize} per page\n\t\t</Component>\n\t);\n}\n\nexport {\n\t//,\n\tCursorButtons,\n\tCursorPageSizeSelect,\n\tCursorPageSizeValue,\n\tCursorPagination,\n};\n\nexport type {\n\t//,\n\tCursorButtonsProps,\n\tCursorPageSizeSelectProps,\n\tCursorPageSizeValueProps,\n\tCursorPaginationProps,\n};\n","import { useEffect, useState } from \"react\";\n\ntype UseOffsetPaginationProps = {\n\t/**\n\t * The total number of items in the list to be paginated.\n\t */\n\tlistSize: number;\n\t/**\n\t * The number of items per page.\n\t */\n\tpageSize: number;\n};\n\ntype OffsetPaginationState = {\n\t/**\n\t * The current page number, 1-indexed (starting at 1).\n\t */\n\tcurrentPage: number;\n\t/**\n\t * Whether there is a previous page.\n\t */\n\thasPreviousPage: boolean;\n\t/**\n\t * Whether there is a next page.\n\t */\n\thasNextPage: boolean;\n\t/**\n\t * Go to a specific page.\n\t */\n\tgoToPage: (page: number) => void;\n\t/**\n\t * Go to the first page.\n\t */\n\tgoToFirstPage: () => void;\n\t/**\n\t * Go to the last page.\n\t */\n\tgoToLastPage: () => void;\n\t/**\n\t * Go to the next page.\n\t */\n\tnextPage: () => void;\n\t/**\n\t * The offset of the current page in the list.\n\t */\n\toffset: number;\n\t/**\n\t * The number of items per page.\n\t */\n\tpageSize: number;\n\t/**\n\t * Go to the previous page.\n\t */\n\tpreviousPage: () => void;\n\t/**\n\t * Set the number of items per page. This will reset the current page to the first page.\n\t */\n\tsetPageSize: (size: number) => void;\n\t/**\n\t * The total number of pages.\n\t */\n\ttotalPages: number;\n};\n\n/**\n * A headless hook for managing offset-based pagination state\n */\nfunction useOffsetPagination({ listSize, pageSize }: UseOffsetPaginationProps): OffsetPaginationState {\n\tconst [currentPage, setCurrentPage] = useState(1);\n\tconst [currentPageSize, setCurrentPageSize] = useState(pageSize);\n\n\t// Reset the current page to 1 when the page size prop changes\n\tuseEffect(() => {\n\t\tsetCurrentPageSize(pageSize);\n\t\tsetCurrentPage(1);\n\t}, [pageSize]);\n\n\t// Reset the current page to 1 when the list size prop changes\n\tuseEffect(() => {\n\t\tsetCurrentPage(1);\n\t}, [listSize]);\n\n\tconst totalPages = Math.ceil(listSize / currentPageSize);\n\tconst offset = (currentPage - 1) * currentPageSize;\n\n\tconst hasPreviousPage = currentPage > 1;\n\tconst hasNextPage = currentPage < totalPages;\n\n\tfunction goToPage(page: number) {\n\t\tconst nextPage = Math.max(1, Math.min(page, totalPages));\n\t\tsetCurrentPage(nextPage);\n\t}\n\n\tfunction nextPage() {\n\t\tif (hasNextPage) {\n\t\t\tsetCurrentPage((prev) => Math.min(prev + 1, totalPages));\n\t\t}\n\t}\n\n\tfunction previousPage() {\n\t\tif (hasPreviousPage) {\n\t\t\tsetCurrentPage((prev) => Math.max(prev - 1, 1));\n\t\t}\n\t}\n\n\tfunction setPageSize(size: number) {\n\t\tsetCurrentPageSize(size);\n\t\tsetCurrentPage(1); // reset to the first page when page size changes\n\t}\n\n\tfunction goToLastPage() {\n\t\tsetCurrentPage(totalPages);\n\t}\n\n\tfunction goToFirstPage() {\n\t\tsetCurrentPage(1);\n\t}\n\n\treturn {\n\t\tcurrentPage,\n\t\tgoToFirstPage,\n\t\tgoToLastPage,\n\t\tgoToPage,\n\t\thasNextPage,\n\t\thasPreviousPage,\n\t\tnextPage,\n\t\toffset,\n\t\tpageSize: currentPageSize,\n\t\tpreviousPage,\n\t\tsetPageSize,\n\t\ttotalPages,\n\t};\n}\n\nexport {\n\t//,\n\tuseOffsetPagination,\n};\n\nexport type {\n\t//,\n\tUseOffsetPaginationProps,\n\tOffsetPaginationState,\n};\n"],"mappings":"4YAAA,OAAS,aAAAA,MAAiB,6CAC1B,OAAS,cAAAC,MAAkB,8CAC3B,OAAS,QAAAC,MAAY,uBACrB,OAAS,iBAAAC,EAAe,cAAAC,EAAY,cAAAC,EAAY,YAAAC,MAAsD,QACtG,OAAOC,MAAe,iBA8ClB,cAAAC,EAoCD,QAAAC,MApCC,oBAxBJ,IAAMC,EAA0BC,EAAwD,MAAS,EAkB3FC,EAAmBC,EACxB,CAAC,CAAE,UAAAC,EAAW,SAAAC,EAAU,gBAAAC,EAAiB,GAAGC,CAAM,EAAGC,IAAQ,CAC5D,GAAM,CAACC,EAAUC,CAAW,EAAIC,EAAiBL,CAAe,EAEhE,OACCR,EAACE,EAAwB,SAAxB,CAAiC,MAAO,CAAE,gBAAAM,EAAiB,SAAAG,EAAU,YAAAC,CAAY,EACjF,SAAAZ,EAAC,OAAI,UAAWc,EAAG,iDAAkDR,CAAS,EAAG,IAAKI,EAAM,GAAGD,EAC7F,SAAAF,EACF,EACD,CAEF,CACD,EACAH,EAAiB,YAAc,mBAwB/B,IAAMW,EAAgBV,EACrB,CAAC,CAAE,YAAAW,E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AASE,EAAYC,EAAc,CAClCX,EAAmBW,CAAI,EACvBb,EAAe,CAAC,CACjB,CAEA,SAASc,GAAe,CACvBd,EAAeG,CAAU,CAC1B,CAEA,SAASY,GAAgB,CACxBf,EAAe,CAAC,CACjB,CAEA,MAAO,CACN,YAAAD,EACA,cAAAgB,EACA,aAAAD,EACA,SAAAP,EACA,YAAAD,EACA,gBAAAD,EACA,SAAAI,EACA,OAAAL,EACA,SAAUH,EACV,aAAAU,EACA,YAAAC,EACA,WAAAT,CACD,CACD","names":["CaretLeft","CaretRight","Slot","createContext","forwardRef","useContext","useState","invariant","jsx","jsxs","CursorPaginationContext","createContext","CursorPagination","forwardRef","className","children","defaultPageSize","props","ref","pageSize","setPageSize","useState","cx","CursorButtons","hasNextPage","hasPreviousPage","onNextPage","onPreviousPage","ButtonGroup","IconButton","CaretLeft","Separator","CaretRight","defaultPageSizes","CursorPageSizeSelect","pageSizes","onChangePageSize","rest","ctx","useContext","invariant","Select","value","newPageSize","SelectTrigger","SelectValue","SelectContent","size","SelectItem","CursorPageSizeValue","asChild","Slot","useEffect","useState","useOffsetPagination","listSize","pageSize","currentPage","setCurrentPage","currentPageSize","setCurrentPageSize","totalPages","offset","hasPreviousPage","hasNextPage","goToPage","page","nextPage","prev","previousPage","setPageSize","size","goToLastPage","goToFirstPage"]}
1
+ {"version":3,"sources":["../src/components/pagination/cursor-pagination.tsx","../src/components/pagination/use-offset-pagination.tsx"],"sourcesContent":["import { CaretLeft } from \"@phosphor-icons/react/dist/icons/CaretLeft\";\nimport { CaretRight } from \"@phosphor-icons/react/dist/icons/CaretRight\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { createContext, forwardRef, useContext, useState, type ComponentProps, type ElementRef } from \"react\";\nimport invariant from \"tiny-invariant\";\nimport type { WithAsChild } from \"../../types/as-child.js\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { ButtonGroup, IconButton } from \"../button/index.js\";\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from \"../select/select.js\";\nimport { Separator } from \"../separator/separator.js\";\n\ntype CursorPaginationContextValue = {\n\t/**\n\t * The default number of items per page.\n\t */\n\tdefaultPageSize: number;\n\t/**\n\t * The current number of items per page.\n\t */\n\tpageSize: number;\n\t/**\n\t * A function to set the number of items per page.\n\t */\n\tsetPageSize: (value: number) => void;\n};\n\nconst CursorPaginationContext = createContext<CursorPaginationContextValue | undefined>(undefined);\n\ntype CursorPaginationProps = ComponentProps<\"div\"> & {\n\t/**\n\t * The default number of items per page.\n\t */\n\tdefaultPageSize: number;\n};\n\n/**\n * A pagination component for use with cursor-based pagination.\n *\n * Cursor-based pagination is a way of loading data in chunks by using a cursor\n * from the last item on the current page to know where to start the next set,\n * making sure nothing is missed or repeated. Like a linked list, but for chunks\n * of data. It doesn't let you jump to a specific page or know how many total pages\n * there are, but it's more efficient for large or real-time data sets.\n */\nconst CursorPagination = forwardRef<HTMLDivElement, CursorPaginationProps>(\n\t({ className, children, defaultPageSize, ...props }, ref) => {\n\t\tconst [pageSize, setPageSize] = useState<number>(defaultPageSize);\n\n\t\treturn (\n\t\t\t<CursorPaginationContext.Provider value={{ defaultPageSize, pageSize, setPageSize }}>\n\t\t\t\t<div className={cx(\"inline-flex items-center justify-between gap-2\", className)} ref={ref} {...props}>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</CursorPaginationContext.Provider>\n\t\t);\n\t},\n);\nCursorPagination.displayName = \"CursorPagination\";\n\ntype CursorButtonsProps = Omit<ComponentProps<typeof ButtonGroup>, \"appearance\"> & {\n\t/**\n\t * Whether there is a next page of data to load.\n\t */\n\thasNextPage: boolean;\n\t/**\n\t * Whether there is a previous page of data to load.\n\t */\n\thasPreviousPage: boolean;\n\t/**\n\t * A callback that is called when the next page button is clicked.\n\t */\n\tonNextPage?: () => void;\n\t/**\n\t * A callback that is called when the previous page button is clicked.\n\t */\n\tonPreviousPage?: () => void;\n};\n\n/**\n * A pair of buttons for navigating between pages of data when using cursor-based pagination.\n */\nconst CursorButtons = forwardRef<ElementRef<typeof ButtonGroup>, CursorButtonsProps>(\n\t({ hasNextPage, hasPreviousPage, onNextPage, onPreviousPage, ...props }, ref) => {\n\t\t// TODO(cody): this _feels_ like a good spot for left and right arrow keys to navigate between pages when focused on the buttons\n\n\t\treturn (\n\t\t\t<ButtonGroup appearance=\"panel\" ref={ref} {...props}>\n\t\t\t\t<IconButton\n\t\t\t\t\tappearance=\"ghost\"\n\t\t\t\t\tdisabled={!hasPreviousPage}\n\t\t\t\t\ticon={<CaretLeft />}\n\t\t\t\t\tlabel=\"Previous page\"\n\t\t\t\t\tonClick={onPreviousPage}\n\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t/>\n\t\t\t\t<Separator orientation=\"vertical\" className=\"min-h-5\" />\n\t\t\t\t<IconButton\n\t\t\t\t\tappearance=\"ghost\"\n\t\t\t\t\tdisabled={!hasNextPage}\n\t\t\t\t\ticon={<CaretRight />}\n\t\t\t\t\tlabel=\"Next page\"\n\t\t\t\t\tonClick={onNextPage}\n\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t/>\n\t\t\t</ButtonGroup>\n\t\t);\n\t},\n);\nCursorButtons.displayName = \"CursorButtons\";\n\nconst defaultPageSizes = [5, 10, 20, 50, 100] as const;\n\ntype CursorPageSizeSelectProps = Omit<ComponentProps<typeof SelectTrigger>, \"children\"> & {\n\t/**\n\t * A list of page sizes to choose from. The default page size must be included in this list.\n\t */\n\tpageSizes?: typeof defaultPageSizes | readonly number[];\n\t/**\n\t * A callback that is called when the page size is changed.\n\t */\n\tonChangePageSize?: (value: number) => void;\n};\n\n/**\n * A select input for changing the number of items per page when using cursor-based pagination.\n */\nconst CursorPageSizeSelect = forwardRef<ElementRef<typeof SelectTrigger>, CursorPageSizeSelectProps>(\n\t({ className, pageSizes = defaultPageSizes, onChangePageSize, ...rest }, ref) => {\n\t\tconst ctx = useContext(CursorPaginationContext);\n\n\t\tinvariant(ctx, \"CursorPageSizeSelect must be used as a child of a CursorPagination component\");\n\n\t\tinvariant(\n\t\t\tpageSizes.includes(ctx.defaultPageSize),\n\t\t\t\"CursorPagination.defaultPageSize must be included in CursorPageSizeSelect.pageSizes\",\n\t\t);\n\n\t\tinvariant(\n\t\t\tpageSizes.includes(ctx.pageSize),\n\t\t\t\"CursorPagination.pageSize must be included in CursorPageSizeSelect.pageSizes\",\n\t\t);\n\n\t\treturn (\n\t\t\t<Select\n\t\t\t\tdefaultValue={`${ctx.pageSize}`}\n\t\t\t\tonChange={(value) => {\n\t\t\t\t\tlet newPageSize = Number.parseInt(value, 10);\n\t\t\t\t\tif (Number.isNaN(newPageSize)) {\n\t\t\t\t\t\tnewPageSize = ctx.defaultPageSize;\n\t\t\t\t\t}\n\t\t\t\t\tctx.setPageSize(newPageSize);\n\t\t\t\t\tonChangePageSize?.(newPageSize);\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<SelectTrigger ref={ref} className={cx(\"w-auto min-w-36\", className)} value={ctx.pageSize} {...rest}>\n\t\t\t\t\t<SelectValue />\n\t\t\t\t</SelectTrigger>\n\t\t\t\t<SelectContent width=\"trigger\">\n\t\t\t\t\t{pageSizes.map((size) => (\n\t\t\t\t\t\t<SelectItem key={size} value={`${size}`}>\n\t\t\t\t\t\t\t{size} per page\n\t\t\t\t\t\t</SelectItem>\n\t\t\t\t\t))}\n\t\t\t\t</SelectContent>\n\t\t\t</Select>\n\t\t);\n\t},\n);\nCursorPageSizeSelect.displayName = \"CursorPageSizeSelect\";\n\ntype CursorPageSizeValueProps = Omit<ComponentProps<\"span\">, \"children\"> & WithAsChild;\n\n/**\n * Displays the current page size when using cursor-based pagination as a read-only value.\n */\nfunction CursorPageSizeValue({ asChild = false, className, ...props }: CursorPageSizeValueProps) {\n\tconst ctx = useContext(CursorPaginationContext);\n\n\tinvariant(ctx, \"CursorPageSizeValue must be used as a child of a CursorPagination component\");\n\n\tconst Component = asChild ? Slot : \"span\";\n\n\treturn (\n\t\t<Component className={cx(\"text-muted text-sm font-normal\", className)} {...props}>\n\t\t\t{ctx.pageSize} per page\n\t\t</Component>\n\t);\n}\n\nexport {\n\t//,\n\tCursorButtons,\n\tCursorPageSizeSelect,\n\tCursorPageSizeValue,\n\tCursorPagination,\n};\n\nexport type {\n\t//,\n\tCursorButtonsProps,\n\tCursorPageSizeSelectProps,\n\tCursorPageSizeValueProps,\n\tCursorPaginationProps,\n};\n","import { useEffect, useState } from \"react\";\n\ntype UseOffsetPaginationProps = {\n\t/**\n\t * The total number of items in the list to be paginated.\n\t */\n\tlistSize: number;\n\t/**\n\t * The number of items per page.\n\t */\n\tpageSize: number;\n};\n\ntype OffsetPaginationState = {\n\t/**\n\t * The current page number, 1-indexed (starting at 1).\n\t */\n\tcurrentPage: number;\n\t/**\n\t * Whether there is a previous page.\n\t */\n\thasPreviousPage: boolean;\n\t/**\n\t * Whether there is a next page.\n\t */\n\thasNextPage: boolean;\n\t/**\n\t * Go to a specific page.\n\t */\n\tgoToPage: (page: number) => void;\n\t/**\n\t * Go to the first page.\n\t */\n\tgoToFirstPage: () => void;\n\t/**\n\t * Go to the last page.\n\t */\n\tgoToLastPage: () => void;\n\t/**\n\t * Go to the next page.\n\t */\n\tnextPage: () => void;\n\t/**\n\t * The offset of the current page in the list.\n\t */\n\toffset: number;\n\t/**\n\t * The number of items per page.\n\t */\n\tpageSize: number;\n\t/**\n\t * Go to the previous page.\n\t */\n\tpreviousPage: () => void;\n\t/**\n\t * Set the number of items per page. This will reset the current page to the first page.\n\t */\n\tsetPageSize: (size: number) => void;\n\t/**\n\t * The total number of pages.\n\t */\n\ttotalPages: number;\n};\n\n/**\n * A headless hook for managing offset-based pagination state\n */\nfunction useOffsetPagination({ listSize, pageSize }: UseOffsetPaginationProps): OffsetPaginationState {\n\tconst [currentPage, setCurrentPage] = useState(1);\n\tconst [currentPageSize, setCurrentPageSize] = useState(pageSize);\n\n\t// Reset the current page to 1 when the page size prop changes\n\tuseEffect(() => {\n\t\tsetCurrentPageSize(pageSize);\n\t\tsetCurrentPage(1);\n\t}, [pageSize]);\n\n\t// Reset the current page to 1 when the list size prop changes\n\tuseEffect(() => {\n\t\tsetCurrentPage(1);\n\t}, [listSize]);\n\n\tconst totalPages = Math.ceil(listSize / currentPageSize);\n\tconst offset = (currentPage - 1) * currentPageSize;\n\n\tconst hasPreviousPage = currentPage > 1;\n\tconst hasNextPage = currentPage < totalPages;\n\n\tfunction goToPage(page: number) {\n\t\tconst nextPage = Math.max(1, Math.min(page, totalPages));\n\t\tsetCurrentPage(nextPage);\n\t}\n\n\tfunction nextPage() {\n\t\tif (hasNextPage) {\n\t\t\tsetCurrentPage((prev) => Math.min(prev + 1, totalPages));\n\t\t}\n\t}\n\n\tfunction previousPage() {\n\t\tif (hasPreviousPage) {\n\t\t\tsetCurrentPage((prev) => Math.max(prev - 1, 1));\n\t\t}\n\t}\n\n\tfunction setPageSize(size: number) {\n\t\tsetCurrentPageSize(size);\n\t\tsetCurrentPage(1); // reset to the first page when page size changes\n\t}\n\n\tfunction goToLastPage() {\n\t\tsetCurrentPage(totalPages);\n\t}\n\n\tfunction goToFirstPage() {\n\t\tsetCurrentPage(1);\n\t}\n\n\treturn {\n\t\tcurrentPage,\n\t\tgoToFirstPage,\n\t\tgoToLastPage,\n\t\tgoToPage,\n\t\thasNextPage,\n\t\thasPreviousPage,\n\t\tnextPage,\n\t\toffset,\n\t\tpageSize: currentPageSize,\n\t\tpreviousPage,\n\t\tsetPageSize,\n\t\ttotalPages,\n\t};\n}\n\n/**\n * Get a paginated slice of a list based on the current offset pagination state.\n */\nfunction getOffsetPaginatedSlice<T>(list: readonly T[], pagination: OffsetPaginationState): T[] {\n\treturn list.slice(pagination.offset, pagination.offset + pagination.pageSize);\n}\n\nexport {\n\t//,\n\tuseOffsetPagination,\n\tgetOffsetPaginatedSlice,\n};\n\nexport type {\n\t//,\n\tUseOffsetPaginationProps,\n\tOffsetPaginationState,\n};\n"],"mappings":"4YAA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AM,CAACC,EAAaC,CAAc,EAAIL,EAAS,CAAC,EAC1C,CAACM,EAAiBC,CAAkB,EAAIP,EAASG,CAAQ,EAG/DJ,EAAU,IAAM,CACfQ,EAAmBJ,CAAQ,EAC3BE,EAAe,CAAC,CACjB,EAAG,CAACF,CAAQ,CAAC,EAGbJ,EAAU,IAAM,CACfM,EAAe,CAAC,CACjB,EAAG,CAACH,CAAQ,CAAC,EAEb,IAAMM,EAAa,KAAK,KAAKN,EAAWI,CAAe,EACjDG,GAAUL,EAAc,GAAKE,EAE7BI,EAAkBN,EAAc,EAChCO,EAAcP,EAAcI,EAElC,SAASI,EAASC,EAAc,CAC/B,IAAMC,EAAW,KAAK,IAAI,EAAG,KAAK,IAAID,EAAML,CAAU,CAAC,EACvDH,EAAeS,CAAQ,CACxB,CAEA,SAASA,GAAW,CACfH,GACHN,EAAgBU,GAAS,KAAK,IAAIA,EAAO,EAAGP,CAAU,CAAC,CAEzD,CAEA,SAASQ,GAAe,CACnBN,GACHL,EAAgBU,GAAS,KAAK,IAAIA,EAAO,EAAG,CAAC,CAAC,CAEhD,CAEA,SAASE,EAAYC,EAAc,CAClCX,EAAmBW,CAAI,EACvBb,EAAe,CAAC,CACjB,CAEA,SAASc,GAAe,CACvBd,EAAeG,CAAU,CAC1B,CAEA,SAASY,GAAgB,CACxBf,EAAe,CAAC,CACjB,CAEA,MAAO,CACN,YAAAD,EACA,cAAAgB,EACA,aAAAD,EACA,SAAAP,EACA,YAAAD,EACA,gBAAAD,EACA,SAAAI,EACA,OAAAL,EACA,SAAUH,EACV,aAAAU,EACA,YAAAC,EACA,WAAAT,CACD,CACD","names":["CaretLeft","CaretRight","Slot","createContext","forwardRef","useContext","useState","invariant","jsx","jsxs","CursorPaginationContext","createContext","CursorPagination","forwardRef","className","children","defaultPageSize","props","ref","pageSize","setPageSize","useState","cx","CursorButtons","hasNextPage","hasPreviousPage","onNextPage","onPreviousPage","ButtonGroup","IconButton","CaretLeft","Separator","CaretRight","defaultPageSizes","CursorPageSizeSelect","pageSizes","onChangePageSize","rest","ctx","useContext","invariant","Select","value","newPageSize","SelectTrigger","SelectValue","SelectContent","size","SelectItem","CursorPageSizeValue","asChild","Slot","useEffect","useState","useOffsetPagination","listSize","pageSize","currentPage","setCurrentPage","currentPageSize","setCurrentPageSize","totalPages","offset","hasPreviousPage","hasNextPage","goToPage","page","nextPage","prev","previousPage","setPageSize","size","goToLastPage","goToFirstPage"]}
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ComponentProps, HTMLAttributes } from 'react';
2
+ import { HTMLAttributes, ComponentProps } from 'react';
3
3
 
4
4
  type RemValue = `${number}rem`;
5
5
  type StrokeWidth = number | RemValue;
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { ReactNode, HTMLAttributes } from 'react';
4
- import { RadioGroupProps, RadioProps } from '@headlessui/react';
4
+ import { RadioProps, RadioGroupProps } from '@headlessui/react';
5
5
  import { W as WithAsChild } from './as-child-Cvu56SuO.js';
6
6
 
7
7
  /**
package/dist/select.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _radix_ui_react_separator from '@radix-ui/react-separator';
2
2
  import * as react from 'react';
3
- import { FocusEvent, SelectHTMLAttributes } from 'react';
3
+ import { SelectHTMLAttributes, FocusEvent } from 'react';
4
4
  import * as SelectPrimitive from '@radix-ui/react-select';
5
5
  import { W as WithValidation } from './types-Cs5ck3Vt.js';
6
6
 
package/dist/sheet.d.ts CHANGED
@@ -4,9 +4,9 @@ import * as react from 'react';
4
4
  import { HTMLAttributes } from 'react';
5
5
  import * as DialogPrimitive from '@radix-ui/react-dialog';
6
6
  import { VariantProps } from 'class-variance-authority';
7
- import { a as IconButtonProps } from './icon-button-C887Pif0.js';
7
+ import { a as IconButtonProps } from './icon-button-CZzW1XWB.js';
8
8
  import './as-child-Cvu56SuO.js';
9
- import './variant-props-Dc9PJLzN.js';
9
+ import './variant-props-oDo2u-We.js';
10
10
  import './deep-non-nullable-SmpSvoSd.js';
11
11
 
12
12
  /**
package/dist/table.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { HTMLAttributes, ThHTMLAttributes, TdHTMLAttributes } from 'react';
2
+ import { HTMLAttributes, TdHTMLAttributes, ThHTMLAttributes } from 'react';
3
3
 
4
4
  declare const Table: react.ForwardRefExoticComponent<HTMLAttributes<HTMLTableElement> & react.RefAttributes<HTMLTableElement>>;
5
5
  declare const TableHeader: react.ForwardRefExoticComponent<HTMLAttributes<HTMLTableSectionElement> & react.RefAttributes<HTMLTableSectionElement>>;
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { PropsWithChildren, ComponentProps } from 'react';
2
+ import { ComponentProps, PropsWithChildren } from 'react';
3
3
 
4
4
  type Props = {
5
5
  /**
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { W as WithAsChild } from './as-child-Cvu56SuO.js';
2
2
  export { W as WithStyleProps } from './with-style-props-VnLWm0Yd.js';
3
- export { V as VariantProps } from './variant-props-Dc9PJLzN.js';
3
+ export { V as VariantProps } from './variant-props-oDo2u-We.js';
4
4
  export { D as DeepNonNullable } from './deep-non-nullable-SmpSvoSd.js';
5
5
  import 'react';
6
6
  import 'class-variance-authority';
@@ -6,6 +6,6 @@ import { D as DeepNonNullable } from './deep-non-nullable-SmpSvoSd.js';
6
6
  *
7
7
  * Using VariantProps directly from CVA produces that can be `null`, which is not what we want.
8
8
  */
9
- type VariantProps<Variants extends (props?: Record<PropertyKey, unknown> | undefined) => string> = Partial<DeepNonNullable<VariantProps$1<Variants>>>;
9
+ type VariantProps<Variants extends (props: Record<PropertyKey, unknown> | undefined) => string> = Partial<DeepNonNullable<VariantProps$1<Variants>>>;
10
10
 
11
11
  export type { VariantProps as V };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "mantle is ngrok's UI library and design system.",
4
4
  "author": "ngrok",
5
5
  "license": "MIT",
6
- "version": "0.10.2",
6
+ "version": "0.12.0",
7
7
  "homepage": "https://mantle.ngrok.com",
8
8
  "repository": {
9
9
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "@radix-ui/react-slot": "1.1.0",
35
35
  "@radix-ui/react-switch": "1.1.1",
36
36
  "@radix-ui/react-tabs": "1.1.1",
37
- "@radix-ui/react-tooltip": "1.1.3",
37
+ "@radix-ui/react-tooltip": "1.1.4",
38
38
  "@uidotdev/usehooks": "2.4.1",
39
39
  "class-variance-authority": "0.7.0",
40
40
  "clsx": "2.1.1",
@@ -50,35 +50,35 @@
50
50
  "@testing-library/jest-dom": "6.6.3",
51
51
  "@testing-library/react": "16.0.1",
52
52
  "@testing-library/user-event": "14.5.2",
53
- "@types/node": "20.17.5",
53
+ "@types/node": "20.17.6",
54
54
  "@types/prismjs": "1.26.5",
55
55
  "@types/react": "18.3.12",
56
56
  "@types/react-dom": "18.3.1",
57
57
  "@vitejs/plugin-react": "4.3.3",
58
- "@vitest/ui": "2.1.4",
58
+ "@vitest/ui": "2.1.5",
59
59
  "autoprefixer": "10.4.20",
60
60
  "browserslist": "4.24.2",
61
61
  "date-fns": "3.6.0",
62
62
  "jsdom": "25.0.1",
63
- "postcss": "8.4.47",
63
+ "postcss": "8.4.49",
64
64
  "react": "18.3.1",
65
65
  "react-dom": "18.3.1",
66
- "react-router-dom": "6.27.0",
67
- "tailwindcss": "3.4.14",
66
+ "react-router-dom": "6.28.0",
67
+ "tailwindcss": "3.4.15",
68
68
  "tsup": "8.3.5",
69
69
  "typescript": "5.6.3",
70
- "vite": "5.4.10",
71
- "vitest": "2.1.4",
70
+ "vite": "5.4.11",
71
+ "vitest": "2.1.5",
72
72
  "zod": "3.23.8",
73
73
  "@cfg/tsconfig": "1.0.0"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@phosphor-icons/react": "2.1.7",
77
77
  "date-fns": "^3.6.0",
78
- "postcss": "^8.4.47",
78
+ "postcss": "^8.4.49",
79
79
  "react": "^18.3.1",
80
80
  "react-dom": "^18.3.1",
81
- "tailwindcss": "^3.4.14",
81
+ "tailwindcss": "^3.4.15",
82
82
  "zod": "^3.23.8"
83
83
  },
84
84
  "exports": {