@ledgerhq/lumen-ui-react 0.1.38 → 0.1.40

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.
Files changed (56) hide show
  1. package/dist/i18n/locales/de.json.d.ts +15 -0
  2. package/dist/i18n/locales/de.json.js +1 -1
  3. package/dist/i18n/locales/en.json.d.ts +11 -0
  4. package/dist/i18n/locales/en.json.js +2 -2
  5. package/dist/i18n/locales/es.json.d.ts +15 -0
  6. package/dist/i18n/locales/es.json.js +1 -1
  7. package/dist/i18n/locales/fr.json.d.ts +11 -0
  8. package/dist/i18n/locales/fr.json.js +1 -1
  9. package/dist/i18n/locales/ja.json.d.ts +15 -0
  10. package/dist/i18n/locales/ja.json.js +2 -2
  11. package/dist/i18n/locales/ko.json.d.ts +15 -0
  12. package/dist/i18n/locales/ko.json.js +2 -2
  13. package/dist/i18n/locales/pt.json.d.ts +15 -0
  14. package/dist/i18n/locales/pt.json.js +1 -1
  15. package/dist/i18n/locales/ru.json.d.ts +15 -0
  16. package/dist/i18n/locales/ru.json.js +2 -2
  17. package/dist/i18n/locales/th.json.d.ts +15 -0
  18. package/dist/i18n/locales/th.json.js +2 -2
  19. package/dist/i18n/locales/tr.json.d.ts +15 -0
  20. package/dist/i18n/locales/tr.json.js +2 -2
  21. package/dist/i18n/locales/zh.json.d.ts +15 -0
  22. package/dist/i18n/locales/zh.json.js +2 -2
  23. package/dist/index.js +90 -88
  24. package/dist/lib/Components/AmountDisplay/AmountDisplay.d.ts.map +1 -1
  25. package/dist/lib/Components/AmountDisplay/AmountDisplay.js +47 -44
  26. package/dist/lib/Components/AmountInput/AmountInput.d.ts.map +1 -1
  27. package/dist/lib/Components/AmountInput/AmountInput.js +63 -92
  28. package/dist/lib/Components/AmountInput/useAmountInputValue/useAmountInputValue.d.ts +21 -0
  29. package/dist/lib/Components/AmountInput/useAmountInputValue/useAmountInputValue.d.ts.map +1 -0
  30. package/dist/lib/Components/AmountInput/useAmountInputValue/useAmountInputValue.js +28 -0
  31. package/dist/lib/Components/AmountInput/useAutoWidthInput/useAutoWidthInput.d.ts +13 -0
  32. package/dist/lib/Components/AmountInput/useAutoWidthInput/useAutoWidthInput.d.ts.map +1 -0
  33. package/dist/lib/Components/AmountInput/useAutoWidthInput/useAutoWidthInput.js +29 -0
  34. package/dist/lib/Components/Avatar/Avatar.d.ts +1 -1
  35. package/dist/lib/Components/Avatar/Avatar.d.ts.map +1 -1
  36. package/dist/lib/Components/Avatar/Avatar.js +32 -26
  37. package/dist/lib/Components/Avatar/types.d.ts +7 -1
  38. package/dist/lib/Components/Avatar/types.d.ts.map +1 -1
  39. package/dist/lib/Components/Button/BaseButton.d.ts +1 -1
  40. package/dist/lib/Components/IconButton/IconButton.d.ts.map +1 -1
  41. package/dist/lib/Components/IconButton/IconButton.js +17 -16
  42. package/dist/lib/Components/Pagination/Pagination.d.ts +13 -0
  43. package/dist/lib/Components/Pagination/Pagination.d.ts.map +1 -0
  44. package/dist/lib/Components/Pagination/Pagination.js +93 -0
  45. package/dist/lib/Components/Pagination/getPaginationRange.d.ts +6 -0
  46. package/dist/lib/Components/Pagination/getPaginationRange.d.ts.map +1 -0
  47. package/dist/lib/Components/Pagination/getPaginationRange.js +25 -0
  48. package/dist/lib/Components/Pagination/index.d.ts +3 -0
  49. package/dist/lib/Components/Pagination/index.d.ts.map +1 -0
  50. package/dist/lib/Components/Pagination/types.d.ts +26 -0
  51. package/dist/lib/Components/Pagination/types.d.ts.map +1 -0
  52. package/dist/lib/Components/Table/Table.js +37 -37
  53. package/dist/lib/Components/index.d.ts +1 -0
  54. package/dist/lib/Components/index.d.ts.map +1 -1
  55. package/dist/package.json +1 -1
  56. package/package.json +2 -2
@@ -0,0 +1,21 @@
1
+ import { ChangeEvent } from 'react';
2
+ type FormatOptions = {
3
+ allowDecimals: boolean;
4
+ thousandsSeparator: boolean;
5
+ maxIntegerLength: number;
6
+ maxDecimalLength: number;
7
+ };
8
+ type UseAmountInputValueArgs = {
9
+ value: string | number;
10
+ onChange: (event: ChangeEvent<HTMLInputElement>) => void;
11
+ formatOptions: FormatOptions;
12
+ };
13
+ type UseAmountInputValueReturn = {
14
+ inputValue: string;
15
+ isChanging: boolean;
16
+ setIsChanging: React.Dispatch<React.SetStateAction<boolean>>;
17
+ handleChange: (e: ChangeEvent<HTMLInputElement>) => void;
18
+ };
19
+ export declare const useAmountInputValue: ({ value, onChange, formatOptions, }: UseAmountInputValueArgs) => UseAmountInputValueReturn;
20
+ export {};
21
+ //# sourceMappingURL=useAmountInputValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAmountInputValue.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/AmountInput/useAmountInputValue/useAmountInputValue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGzC,KAAK,aAAa,GAAG;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACzD,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7D,YAAY,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC1D,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,qCAIjC,uBAAuB,KAAG,yBAiC5B,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { textFormatter as m } from "../../../../libs/utils-shared/dist/index.js";
2
+ import { useCallback as f, useState as g, useRef as i, useEffect as d } from "react";
3
+ const I = ({
4
+ value: r,
5
+ onChange: o,
6
+ formatOptions: t
7
+ }) => {
8
+ const a = f(
9
+ (e) => m(String(e), t),
10
+ // eslint-disable-next-line react-hooks/exhaustive-deps
11
+ [
12
+ t.allowDecimals,
13
+ t.thousandsSeparator,
14
+ t.maxIntegerLength,
15
+ t.maxDecimalLength
16
+ ]
17
+ ), [s, c] = g(() => a(r)), [h, l] = g(!1), u = i(s);
18
+ return d(() => {
19
+ const e = a(r);
20
+ c(e), u.current = e;
21
+ }, [r, a]), { inputValue: s, isChanging: h, setIsChanging: l, handleChange: (e) => {
22
+ const n = a(e.target.value);
23
+ c(n), o({ ...e, target: { ...e.target, value: n } }), n !== u.current && l(!0), u.current = n;
24
+ } };
25
+ };
26
+ export {
27
+ I as useAmountInputValue
28
+ };
@@ -0,0 +1,13 @@
1
+ import { AmountInputSize } from '../types';
2
+ type UseAutoWidthInputArgs = {
3
+ inputValue: string;
4
+ currencyText: string | undefined;
5
+ size: AmountInputSize;
6
+ };
7
+ type UseAutoWidthInputReturn = {
8
+ spanRef: React.RefObject<HTMLSpanElement | null>;
9
+ inputRef: React.RefObject<HTMLInputElement | null>;
10
+ };
11
+ export declare const useAutoWidthInput: ({ inputValue, currencyText, size, }: UseAutoWidthInputArgs) => UseAutoWidthInputReturn;
12
+ export {};
13
+ //# sourceMappingURL=useAutoWidthInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAutoWidthInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/AmountInput/useAutoWidthInput/useAutoWidthInput.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA+BhD,KAAK,qBAAqB,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IACjD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CACpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,qCAI/B,qBAAqB,KAAG,uBA0B1B,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { useRef as _, useCallback as i, useLayoutEffect as I, useEffect as d } from "react";
2
+ const D = 33, f = 8, N = 24, P = 16, a = {
3
+ md: N,
4
+ sm: P
5
+ }, R = (n, e, r) => {
6
+ const t = n === "" ? D : f;
7
+ return e ? t : t + a[r];
8
+ }, W = ({
9
+ inputValue: n,
10
+ currencyText: e,
11
+ size: r
12
+ }) => {
13
+ const t = _(null), u = _(null), s = i(() => {
14
+ if (!t.current || !u.current) return;
15
+ const c = Math.ceil(
16
+ Math.max(t.current.scrollWidth, t.current.offsetWidth)
17
+ ), o = R(n, e, r);
18
+ u.current.style.width = `${c + o}px`;
19
+ }, [n, e, r]);
20
+ return I(s, [s]), d(() => {
21
+ const c = t.current;
22
+ if (!c || typeof ResizeObserver > "u") return;
23
+ const o = new ResizeObserver(s);
24
+ return o.observe(c), () => o.disconnect();
25
+ }, [s]), { spanRef: t, inputRef: u };
26
+ };
27
+ export {
28
+ W as useAutoWidthInput
29
+ };
@@ -15,5 +15,5 @@ import { AvatarProps } from './types';
15
15
  * // With notification indicator
16
16
  * <Avatar src="https://example.com/photo.jpg" showNotification />
17
17
  */
18
- export declare const Avatar: ({ ref, className, src, alt, size, imgLoading, showNotification: showNotificationProp, ...props }: AvatarProps) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const Avatar: ({ ref, className, src, alt, appearance, size, imgLoading, showNotification: showNotificationProp, ...props }: AvatarProps) => import("react/jsx-runtime").JSX.Element;
19
19
  //# sourceMappingURL=Avatar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAqC3C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM,GAAI,kGASpB,WAAW,4CAuDb,CAAC"}
1
+ {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA0C3C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM,GAAI,8GAUpB,WAAW,4CAuDb,CAAC"}
@@ -1,14 +1,18 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
2
  import { cva as h } from "class-variance-authority";
3
- import { useState as g, useEffect as z } from "react";
4
- import { useCommonTranslation as x } from "../../../i18n/useCommonTranslation.js";
5
- import { User as A } from "../../Symbols/Icons/User.js";
6
- import { DotIndicator as N } from "../DotIndicator/DotIndicator.js";
7
- const j = {
3
+ import { useState as z, useEffect as x } from "react";
4
+ import { useCommonTranslation as A } from "../../../i18n/useCommonTranslation.js";
5
+ import { User as N } from "../../Symbols/Icons/User.js";
6
+ import { DotIndicator as j } from "../DotIndicator/DotIndicator.js";
7
+ const k = {
8
8
  root: h(
9
- "relative inline-flex items-center justify-center rounded-full bg-muted-transparent transition-colors",
9
+ "relative inline-flex items-center justify-center rounded-full transition-colors",
10
10
  {
11
11
  variants: {
12
+ appearance: {
13
+ gray: "bg-muted",
14
+ transparent: "bg-muted-transparent"
15
+ },
12
16
  size: {
13
17
  sm: "size-40 p-4",
14
18
  md: "size-48 p-4",
@@ -17,61 +21,63 @@ const j = {
17
21
  }
18
22
  },
19
23
  defaultVariants: {
24
+ appearance: "transparent",
20
25
  size: "md"
21
26
  }
22
27
  }
23
28
  )
24
- }, k = {
29
+ }, w = {
25
30
  sm: 16,
26
31
  md: 24,
27
32
  lg: 32,
28
33
  xl: 40
29
- }, w = {
34
+ }, E = {
30
35
  sm: "lg",
31
36
  md: "xl"
32
37
  }, V = ({
33
38
  ref: l,
34
- className: m,
35
- src: o,
36
- alt: c,
39
+ className: c,
40
+ src: r,
41
+ alt: m,
42
+ appearance: d = "transparent",
37
43
  size: a = "md",
38
- imgLoading: d,
39
- showNotification: f = !1,
44
+ imgLoading: f,
45
+ showNotification: p = !1,
40
46
  ...u
41
47
  }) => {
42
- const { t: r } = x(), [p, e] = g(!1), v = !o || p, i = c || r("components.avatar.defaultAlt"), n = f && (a === "sm" || a === "md"), b = n ? `${i}, ${r("components.avatar.notificationAriaLabel")}` : i;
43
- z(() => {
44
- e(!1);
45
- }, [o]);
48
+ const { t: e } = A(), [v, o] = z(!1), b = !r || v, n = m || e("components.avatar.defaultAlt"), i = p && (a === "sm" || a === "md"), g = i ? `${n}, ${e("components.avatar.notificationAriaLabel")}` : n;
49
+ x(() => {
50
+ o(!1);
51
+ }, [r]);
46
52
  const s = /* @__PURE__ */ t(
47
53
  "div",
48
54
  {
49
55
  ref: l,
50
- className: j.root({ size: a, className: m }),
56
+ className: k.root({ appearance: d, size: a, className: c }),
51
57
  role: "img",
52
- "aria-label": b,
58
+ "aria-label": g,
53
59
  ...u,
54
- children: v ? /* @__PURE__ */ t(
55
- A,
60
+ children: b ? /* @__PURE__ */ t(
61
+ N,
56
62
  {
57
- size: k[a],
63
+ size: w[a],
58
64
  "aria-label": "Fallback Icon",
59
65
  "aria-hidden": "true"
60
66
  }
61
67
  ) : /* @__PURE__ */ t(
62
68
  "img",
63
69
  {
64
- src: o,
70
+ src: r,
65
71
  alt: "",
66
- loading: d,
67
- onError: () => e(!0),
72
+ loading: f,
73
+ onError: () => o(!0),
68
74
  className: "size-full overflow-hidden rounded-full object-cover",
69
75
  "aria-hidden": "true"
70
76
  }
71
77
  )
72
78
  }
73
79
  );
74
- return n ? /* @__PURE__ */ t(N, { size: w[a], appearance: "red", children: s }) : s;
80
+ return i ? /* @__PURE__ */ t(j, { size: E[a], appearance: "red", children: s }) : s;
75
81
  };
76
82
  export {
77
83
  V as Avatar
@@ -11,7 +11,13 @@ export type AvatarProps = {
11
11
  */
12
12
  alt?: string;
13
13
  /**
14
- * The size variant of the avatar.
14
+ * The visual appearance of the avatar background: `gray` or `transparent`.
15
+ * @optional
16
+ * @default transparent
17
+ */
18
+ appearance?: 'gray' | 'transparent';
19
+ /**
20
+ * The size variant of the avatar: `sm`, `md`, `lg`, `xl`.
15
21
  * @optional
16
22
  * @default md
17
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Avatar/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC/B,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Avatar/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IAEpC;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC/B,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { BaseButtonProps } from './types';
2
2
  export declare const baseButtonVariants: (props?: ({
3
- appearance?: "base" | "red" | "gray" | "accent" | "transparent" | "no-background" | null | undefined;
3
+ appearance?: "base" | "red" | "gray" | "transparent" | "accent" | "no-background" | null | undefined;
4
4
  disabled?: boolean | null | undefined;
5
5
  loading?: boolean | null | undefined;
6
6
  size?: "md" | "sm" | "lg" | "xs" | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/IconButton/IconButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,UAAU,GAAI,0HAUxB,eAAe,4CAuBjB,CAAC"}
1
+ {"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/IconButton/IconButton.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,UAAU,GAAI,0HAUxB,eAAe,4CAuBjB,CAAC"}
@@ -1,32 +1,33 @@
1
- import { jsxs as m, jsx as o } from "react/jsx-runtime";
2
- import { Tooltip as u, TooltipTrigger as d, TooltipContent as f } from "../Tooltip/Tooltip.js";
3
- import { BaseButton as h } from "../Button/BaseButton.js";
4
- const B = ({
1
+ import { jsx as o, jsxs as c } from "react/jsx-runtime";
2
+ import { cn as f } from "../../../libs/utils-shared/dist/index.js";
3
+ import { Tooltip as h, TooltipTrigger as u, TooltipContent as d } from "../Tooltip/Tooltip.js";
4
+ import { BaseButton as T } from "../Button/BaseButton.js";
5
+ const b = ({
5
6
  ref: n,
6
7
  className: e,
7
8
  icon: i,
8
- tooltip: l = !1,
9
- tooltipPlacement: p = "top",
10
- tooltipText: s,
11
- onTooltipOpenChange: a,
9
+ tooltip: s = !1,
10
+ tooltipPlacement: l = "top",
11
+ tooltipText: a,
12
+ onTooltipOpenChange: p,
12
13
  "aria-label": t,
13
- ...c
14
+ ...m
14
15
  }) => {
15
16
  const r = /* @__PURE__ */ o(
16
- h,
17
+ T,
17
18
  {
18
19
  ref: n,
19
20
  icon: i,
20
- className: e,
21
+ className: f("shrink-0", e),
21
22
  "aria-label": t,
22
- ...c
23
+ ...m
23
24
  }
24
25
  );
25
- return l ? /* @__PURE__ */ m(u, { onOpenChange: a, children: [
26
- /* @__PURE__ */ o(d, { asChild: !0, children: r }),
27
- /* @__PURE__ */ o(f, { side: p, children: s || t })
26
+ return s ? /* @__PURE__ */ c(h, { onOpenChange: p, children: [
27
+ /* @__PURE__ */ o(u, { asChild: !0, children: r }),
28
+ /* @__PURE__ */ o(d, { side: l, children: a || t })
28
29
  ] }) : r;
29
30
  };
30
31
  export {
31
- B as IconButton
32
+ b as IconButton
32
33
  };
@@ -0,0 +1,13 @@
1
+ import { PaginationProps } from './types';
2
+ /**
3
+ * Pagination navigation for tables and other paginated content.
4
+ *
5
+ * @example
6
+ * <Pagination
7
+ * page={page}
8
+ * totalPages={10}
9
+ * onPageChange={setPage}
10
+ * />
11
+ */
12
+ export declare const Pagination: ({ page, totalPages, onPageChange, siblingCount, className, ref, ...props }: PaginationProps) => import("react/jsx-runtime").JSX.Element | null;
13
+ //# sourceMappingURL=Pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Pagination/Pagination.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,GAAI,4EAQxB,eAAe,mDA0EjB,CAAC"}
@@ -0,0 +1,93 @@
1
+ import { jsxs as g, jsx as o } from "react/jsx-runtime";
2
+ import { cn as x } from "../../../libs/utils-shared/dist/index.js";
3
+ import { getPaginationRange as h } from "./getPaginationRange.js";
4
+ import { useCommonTranslation as v } from "../../../i18n/useCommonTranslation.js";
5
+ import { IconButton as s } from "../IconButton/IconButton.js";
6
+ import { ChevronLeft as y } from "../../Symbols/Icons/ChevronLeft.js";
7
+ import { Button as k } from "../Button/Button.js";
8
+ import { ChevronRight as A } from "../../Symbols/Icons/ChevronRight.js";
9
+ const R = ({
10
+ page: p,
11
+ totalPages: e,
12
+ onPageChange: r,
13
+ siblingCount: c = 1,
14
+ className: l,
15
+ ref: m,
16
+ ...u
17
+ }) => {
18
+ const { t: i } = v();
19
+ if (e <= 0)
20
+ return null;
21
+ const a = Math.min(Math.max(p, 1), e), b = Math.max(c, 0), d = h(
22
+ a,
23
+ e,
24
+ b
25
+ );
26
+ return /* @__PURE__ */ g(
27
+ "nav",
28
+ {
29
+ ref: m,
30
+ "aria-label": i("components.pagination.navigationAriaLabel"),
31
+ className: x("flex items-center gap-8 overflow-x-auto p-4", l),
32
+ ...u,
33
+ children: [
34
+ /* @__PURE__ */ o(
35
+ s,
36
+ {
37
+ type: "button",
38
+ icon: y,
39
+ size: "sm",
40
+ appearance: "gray",
41
+ disabled: a <= 1,
42
+ "aria-label": i("components.pagination.previousPageAriaLabel"),
43
+ onClick: () => r(a - 1)
44
+ }
45
+ ),
46
+ d.map((n, f) => {
47
+ if (n === "ellipsis")
48
+ return /* @__PURE__ */ o(
49
+ "span",
50
+ {
51
+ "aria-hidden": !0,
52
+ className: "inline-flex w-40 items-center justify-center body-2 text-muted",
53
+ children: "…"
54
+ },
55
+ `ellipsis-${f}`
56
+ );
57
+ const t = n === a;
58
+ return /* @__PURE__ */ o(
59
+ k,
60
+ {
61
+ type: "button",
62
+ size: "sm",
63
+ appearance: t ? "gray" : "no-background",
64
+ className: "shrink-0",
65
+ "aria-label": i("components.pagination.pageAriaLabel", {
66
+ page: n
67
+ }),
68
+ "aria-current": t ? "page" : void 0,
69
+ onClick: () => r(n),
70
+ children: n
71
+ },
72
+ n
73
+ );
74
+ }),
75
+ /* @__PURE__ */ o(
76
+ s,
77
+ {
78
+ type: "button",
79
+ icon: A,
80
+ size: "sm",
81
+ appearance: "gray",
82
+ disabled: a >= e,
83
+ "aria-label": i("components.pagination.nextPageAriaLabel"),
84
+ onClick: () => r(a + 1)
85
+ }
86
+ )
87
+ ]
88
+ }
89
+ );
90
+ };
91
+ export {
92
+ R as Pagination
93
+ };
@@ -0,0 +1,6 @@
1
+ export type PaginationRangeItem = number | 'ellipsis';
2
+ /**
3
+ * Builds the list of page numbers and ellipsis markers to display.
4
+ */
5
+ export declare const getPaginationRange: (page: number, totalPages: number, siblingCount?: number) => PaginationRangeItem[];
6
+ //# sourceMappingURL=getPaginationRange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPaginationRange.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Pagination/getPaginationRange.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,UAAU,CAAC;AAkBtD;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,YAAY,MAAM,EAClB,qBAAgB,KACf,mBAAmB,EA4CrB,CAAC"}
@@ -0,0 +1,25 @@
1
+ const _ = (S, n) => Array.from({ length: n - S + 1 }, (e, E) => S + E), t = (S) => S * 2 + 5, R = (S) => 3 + S * 2, A = (S, n, e = 1) => {
2
+ if (n < 1)
3
+ return [];
4
+ if (n === 1)
5
+ return [1];
6
+ if (t(e) >= n)
7
+ return _(1, n);
8
+ const E = Math.max(S - e, 1), i = Math.min(S + e, n), r = E > 2, s = i < n - 1;
9
+ if (!r && s)
10
+ return [..._(
11
+ 1,
12
+ R(e)
13
+ ), "ellipsis", n];
14
+ if (r && !s) {
15
+ const I = R(e);
16
+ return [1, "ellipsis", ..._(
17
+ n - I + 1,
18
+ n
19
+ )];
20
+ }
21
+ return r && s ? [1, "ellipsis", ..._(E, i), "ellipsis", n] : _(1, n);
22
+ };
23
+ export {
24
+ A as getPaginationRange
25
+ };
@@ -0,0 +1,3 @@
1
+ export * from './Pagination';
2
+ export type { PaginationProps } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Pagination/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export type PaginationProps = {
3
+ /**
4
+ * Current page, 1-indexed.
5
+ */
6
+ page: number;
7
+ /**
8
+ * Total number of pages.
9
+ * If `<= 0`, the component returns `null`.
10
+ */
11
+ totalPages: number;
12
+ /**
13
+ * Callback fired when the user selects a different page.
14
+ */
15
+ onPageChange: (page: number) => void;
16
+ /**
17
+ * Number of page buttons shown on each side of the current page.
18
+ * @default 1
19
+ */
20
+ siblingCount?: number;
21
+ /**
22
+ * Custom classname for the root nav element.
23
+ */
24
+ className?: string;
25
+ } & Omit<ComponentPropsWithRef<'nav'>, 'children'>;
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Pagination/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC"}