@recursica/mantine-adapter 0.15.0 → 0.16.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.
@@ -11,9 +11,15 @@ export type ButtonProps = RecursicaOverStyled<Omit<MantineButtonProps, "variant"
11
11
  * Recursica Button component wrapping Mantine's Button.
12
12
  *
13
13
  * Supports polymorphism via the `component` prop or `renderRoot` for custom element rendering.
14
+ * This is particularly useful when you need a button that behaves as a hyperlink (rendering an `<a>` tag)
15
+ * or integrates with a routing library (e.g., `react-router-dom` or Next.js), while preserving full visual styling.
16
+ *
14
17
  * @example
15
18
  * ```tsx
16
- * <Button component="a" href="/dashboard">Navigate</Button>
19
+ * // Renders as an <a> tag natively
20
+ * <Button component="a" href="/dashboard" target="_blank">Navigate</Button>
21
+ *
22
+ * // Renders using a custom router link
17
23
  * <Button renderRoot={(props) => <Link to="/home" {...props} />}>Home</Button>
18
24
  * ```
19
25
  */
@@ -1,3 +1,33 @@
1
1
  import { default as React } from 'react';
2
- export type LinkProps = React.HTMLAttributes<HTMLDivElement>;
3
- export declare const Link: React.FC<LinkProps>;
2
+ import { AnchorProps as MantineAnchorProps } from '@mantine/core';
3
+ import { RecursicaOverStyled } from '../../utils/filterStylingProps';
4
+ export interface RecursicaLinkProps {
5
+ /**
6
+ * Optional leading icon to display next to the link text.
7
+ */
8
+ icon?: React.ReactNode;
9
+ /**
10
+ * The text or elements to display inside the link.
11
+ */
12
+ children?: React.ReactNode;
13
+ }
14
+ export type LinkProps = RecursicaOverStyled<Omit<MantineAnchorProps, "underline"> & RecursicaLinkProps>;
15
+ /**
16
+ * Recursica Link component wrapping Mantine's Anchor.
17
+ *
18
+ * Supports polymorphism via the `component` prop or `renderRoot` for custom element rendering (e.g. react-router Link).
19
+ * @example
20
+ * ```tsx
21
+ * <Link component="a" href="https://example.com">External Link</Link>
22
+ * <Link renderRoot={(props) => <RouterLink to="/home" {...props} />}>Home</Link>
23
+ * ```
24
+ */
25
+ export declare const Link: (<C = "a">(props: import('@mantine/core').PolymorphicComponentProps<C, LinkProps>) => React.ReactElement) & Omit<React.FunctionComponent<((LinkProps & {
26
+ component?: any;
27
+ }) & Omit<Omit<any, "ref">, "className" | "classNames" | "style" | "styles" | "vars" | "p" | "px" | "py" | "pt" | "pb" | "pl" | "pr" | "bg" | "c" | "opacity" | "ff" | "fz" | "fw" | "lts" | "ta" | "lh" | "fs" | "tt" | "td" | "bd" | "w" | "miw" | "maw" | "h" | "mih" | "mah" | "m" | "my" | "mx" | "mt" | "mb" | "ml" | "mr" | "top" | "left" | "bottom" | "right" | "color" | "children" | "__vars" | "__size" | "hiddenFrom" | "visibleFrom" | "lightHidden" | "darkHidden" | "mod" | "ms" | "me" | "ps" | "pe" | "bdrs" | "bgsz" | "bgp" | "bgr" | "bga" | "pos" | "inset" | "display" | "flex" | "unstyled" | "variant" | "attributes" | "overStyled" | "icon" | "inherit" | "inline" | "size" | "gradient" | "component" | "__staticSelector" | "lineClamp" | "truncate"> & {
28
+ ref?: any;
29
+ renderRoot?: (props: any) => any;
30
+ }) | (LinkProps & {
31
+ component: React.ElementType;
32
+ renderRoot?: (props: Record<string, any>) => any;
33
+ })>, never> & Record<string, never>;
@@ -0,0 +1 @@
1
+ export * from './Link';
@@ -1,3 +1,51 @@
1
1
  import { default as React } from 'react';
2
- export type PaginationProps = React.HTMLAttributes<HTMLDivElement>;
3
- export declare const Pagination: React.FC<PaginationProps>;
2
+ import { Pagination as MantinePagination, PaginationProps as MantinePaginationProps, PaginationRootProps as MantinePaginationRootProps } from '@mantine/core';
3
+ import { RecursicaOverStyled } from '../../utils/filterStylingProps';
4
+ import { PaginationIcon } from './Pagination.icons';
5
+ export type PaginationProps = RecursicaOverStyled<MantinePaginationProps> & {
6
+ /** If set to true, displays text labels alongside the icons for next/previous/first/last edges. */
7
+ withLabels?: boolean;
8
+ };
9
+ export type PaginationRootProps = RecursicaOverStyled<MantinePaginationRootProps>;
10
+ export type PaginationEdgeProps<T extends React.ElementType> = React.ComponentProps<T> & {
11
+ /** If set to true, displays text labels alongside the icon. */
12
+ withLabel?: boolean;
13
+ icon?: any;
14
+ };
15
+ declare const _PaginationRoot: React.ForwardRefExoticComponent<PaginationRootProps & React.RefAttributes<HTMLDivElement>>;
16
+ declare const _PaginationNext: React.ForwardRefExoticComponent<{
17
+ /** If set to true, displays text labels alongside the icon. */
18
+ withLabel?: boolean;
19
+ icon?: any;
20
+ } & React.RefAttributes<HTMLButtonElement>>;
21
+ declare const _PaginationPrevious: React.ForwardRefExoticComponent<{
22
+ /** If set to true, displays text labels alongside the icon. */
23
+ withLabel?: boolean;
24
+ icon?: any;
25
+ } & React.RefAttributes<HTMLButtonElement>>;
26
+ declare const _PaginationFirst: React.ForwardRefExoticComponent<{
27
+ /** If set to true, displays text labels alongside the icon. */
28
+ withLabel?: boolean;
29
+ icon?: any;
30
+ } & React.RefAttributes<HTMLButtonElement>>;
31
+ declare const _PaginationLast: React.ForwardRefExoticComponent<{
32
+ /** If set to true, displays text labels alongside the icon. */
33
+ withLabel?: boolean;
34
+ icon?: any;
35
+ } & React.RefAttributes<HTMLButtonElement>>;
36
+ declare const _Pagination: React.ForwardRefExoticComponent<PaginationProps & React.RefAttributes<HTMLDivElement>>;
37
+ /**
38
+ * Recursica Pagination component wrapping Mantine's Pagination.
39
+ */
40
+ export declare const Pagination: typeof _Pagination & {
41
+ Root: typeof _PaginationRoot;
42
+ Items: typeof MantinePagination.Items;
43
+ Control: typeof MantinePagination.Control;
44
+ Dots: typeof MantinePagination.Dots;
45
+ Next: typeof _PaginationNext;
46
+ Previous: typeof _PaginationPrevious;
47
+ First: typeof _PaginationFirst;
48
+ Last: typeof _PaginationLast;
49
+ Icon: typeof PaginationIcon;
50
+ };
51
+ export {};
@@ -0,0 +1,8 @@
1
+ export type PaginationIconType = "next" | "prev" | "first" | "last";
2
+ export declare const PaginationIcon: ({ type, className, ...props }: React.ComponentProps<"svg"> & {
3
+ type: PaginationIconType;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const NextWithLabel: (props: any) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const PrevWithLabel: (props: any) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const FirstWithLabel: (props: any) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const LastWithLabel: (props: any) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { Pagination, type PaginationProps, type PaginationRootProps, } from './Pagination';
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "git+https://github.com/borderux/recursica.git"
13
13
  },
14
- "version": "0.15.0",
14
+ "version": "0.16.0",
15
15
  "type": "module",
16
16
  "main": "./dist/mantine-adapter.cjs",
17
17
  "module": "./dist/mantine-adapter.js",
@@ -101,3 +101,14 @@ export const DisabledSolid: Story = {
101
101
  disabled: true,
102
102
  },
103
103
  };
104
+
105
+ export const PolymorphicAsLink: Story = {
106
+ args: {
107
+ children: "Button as Link",
108
+ variant: "solid",
109
+ size: "default",
110
+ component: "a",
111
+ href: "https://example.com",
112
+ target: "_blank",
113
+ },
114
+ };
@@ -123,9 +123,15 @@ _Button.displayName = "Button";
123
123
  * Recursica Button component wrapping Mantine's Button.
124
124
  *
125
125
  * Supports polymorphism via the `component` prop or `renderRoot` for custom element rendering.
126
+ * This is particularly useful when you need a button that behaves as a hyperlink (rendering an `<a>` tag)
127
+ * or integrates with a routing library (e.g., `react-router-dom` or Next.js), while preserving full visual styling.
128
+ *
126
129
  * @example
127
130
  * ```tsx
128
- * <Button component="a" href="/dashboard">Navigate</Button>
131
+ * // Renders as an <a> tag natively
132
+ * <Button component="a" href="/dashboard" target="_blank">Navigate</Button>
133
+ *
134
+ * // Renders using a custom router link
129
135
  * <Button renderRoot={(props) => <Link to="/home" {...props} />}>Home</Button>
130
136
  * ```
131
137
  */
@@ -0,0 +1,26 @@
1
+ # Link Component Implementation Notes
2
+
3
+ ## Missing States in Design Tokens
4
+
5
+ Currently, the design tokens (`recursica_variables_scoped.css`) only provide states for:
6
+
7
+ - `default`
8
+ - `hover`
9
+ - `visited`
10
+ - `visited-hover`
11
+
12
+ There are no tokens for the `active` or `focus` states. If these are needed, they must be added to the Figma variables and exported via the token pipeline. The component relies on the browser's default focus outline for accessibility unless overriden by a global reset.
13
+
14
+ ## Overriding Mantine's underline Prop
15
+
16
+ Mantine's `Anchor` component uses `underline="hover"` by default. Because our design system specifies exact `text-decoration` styles via CSS tokens, we explicitly pass `underline="never"` to the underlying Mantine component. This prevents Mantine from injecting its own text-decoration inline or via generic classnames, ensuring our scoped CSS remains the single source of truth.
17
+
18
+ ## Base Layout
19
+
20
+ Mantine's `Anchor` renders an inline element by default and does not natively support `leftSection` like the `Button` component. To support an optional `icon` alongside the text, we enforce a baseline layout of `display: inline-flex` and `align-items: center` in `Link.module.css`.
21
+
22
+ When an icon is present, the component conditionally passes a `data-has-icon` attribute to the root element. The CSS module uses this attribute to apply the `icon-text-gap` token via the CSS `gap` property.
23
+
24
+ ## Inner Wrappers
25
+
26
+ The icon and children are wrapped in internal `<span>` tags (`.iconWrapper` and `.labelText` respectively). This follows the component development guide for structural robustness, allowing us to enforce specific sizing on the icon and intrinsic text truncation behavior if the link is placed in a bounded container.
@@ -0,0 +1,133 @@
1
+ /*
2
+ HARDCODED VALUES:
3
+ - display: inline-flex; (Base layout to align icon and text correctly)
4
+ - align-items: center;
5
+ - cursor: pointer;
6
+ - text-decoration: none; (Overridden by our design tokens instead of using Mantine's underline prop)
7
+ - color: inherit; (Reset before applying token)
8
+ */
9
+
10
+ .root {
11
+ /* HARDCODE: base layout to support optional icon gaps */
12
+ display: inline-flex;
13
+ align-items: center;
14
+ cursor: pointer;
15
+
16
+ /* HARDCODE: Reset underline and color so we can explicitly use our tokens */
17
+ text-decoration: none;
18
+ color: inherit;
19
+
20
+ /* Typography Default Tokens */
21
+ font-family: var(
22
+ --recursica_ui-kit_components_link_properties_text_font-family
23
+ );
24
+ font-size: var(--recursica_ui-kit_components_link_properties_text_font-size);
25
+ letter-spacing: var(
26
+ --recursica_ui-kit_components_link_properties_text_letter-spacing
27
+ );
28
+ line-height: var(
29
+ --recursica_ui-kit_components_link_properties_text_line-height
30
+ );
31
+
32
+ /* Default State Tokens */
33
+ font-style: var(
34
+ --recursica_ui-kit_components_link_variants_states_default_properties_text_font-style
35
+ );
36
+ font-weight: var(
37
+ --recursica_ui-kit_components_link_variants_states_default_properties_text_font-weight
38
+ );
39
+ text-decoration: var(
40
+ --recursica_ui-kit_components_link_variants_states_default_properties_text_text-decoration
41
+ );
42
+ color: var(
43
+ --recursica_ui-kit_components_link_variants_states_default_properties_colors_text
44
+ );
45
+ }
46
+
47
+ .root[data-has-icon] {
48
+ gap: var(--recursica_ui-kit_components_link_properties_icon-text-gap);
49
+ }
50
+
51
+ .root:hover {
52
+ /* Reset Mantine's potential hover override */
53
+ text-decoration: var(
54
+ --recursica_ui-kit_components_link_variants_states_hover_properties_text_text-decoration
55
+ );
56
+ font-style: var(
57
+ --recursica_ui-kit_components_link_variants_states_hover_properties_text_font-style
58
+ );
59
+ font-weight: var(
60
+ --recursica_ui-kit_components_link_variants_states_hover_properties_text_font-weight
61
+ );
62
+ color: var(
63
+ --recursica_ui-kit_components_link_variants_states_hover_properties_colors_text
64
+ );
65
+ }
66
+
67
+ .root:visited {
68
+ text-decoration: var(
69
+ --recursica_ui-kit_components_link_variants_states_visited_properties_text_text-decoration
70
+ );
71
+ font-style: var(
72
+ --recursica_ui-kit_components_link_variants_states_visited_properties_text_font-style
73
+ );
74
+ font-weight: var(
75
+ --recursica_ui-kit_components_link_variants_states_visited_properties_text_font-weight
76
+ );
77
+ color: var(
78
+ --recursica_ui-kit_components_link_variants_states_visited_properties_colors_text
79
+ );
80
+ }
81
+
82
+ .root:visited:hover {
83
+ text-decoration: var(
84
+ --recursica_ui-kit_components_link_variants_states_visited-hover_properties_text_text-decoration
85
+ );
86
+ font-style: var(
87
+ --recursica_ui-kit_components_link_variants_states_visited-hover_properties_text_font-style
88
+ );
89
+ font-weight: var(
90
+ --recursica_ui-kit_components_link_variants_states_visited-hover_properties_text_font-weight
91
+ );
92
+ color: var(
93
+ --recursica_ui-kit_components_link_variants_states_visited-hover_properties_colors_text
94
+ );
95
+ }
96
+
97
+ /* Icon Support */
98
+ .iconWrapper {
99
+ /* HARDCODE: maintain intrinsic icon bounds */
100
+ display: flex;
101
+ align-items: center;
102
+ justify-content: center;
103
+
104
+ width: var(--recursica_ui-kit_components_link_properties_icon-size);
105
+ height: var(--recursica_ui-kit_components_link_properties_icon-size);
106
+ color: var(
107
+ --recursica_ui-kit_components_link_variants_states_default_properties_colors_icon
108
+ );
109
+ }
110
+
111
+ .root:hover .iconWrapper {
112
+ color: var(
113
+ --recursica_ui-kit_components_link_variants_states_hover_properties_colors_icon
114
+ );
115
+ }
116
+
117
+ .root:visited .iconWrapper {
118
+ color: var(
119
+ --recursica_ui-kit_components_link_variants_states_visited_properties_colors_icon
120
+ );
121
+ }
122
+
123
+ .root:visited:hover .iconWrapper {
124
+ color: var(
125
+ --recursica_ui-kit_components_link_variants_states_visited-hover_properties_colors_icon
126
+ );
127
+ }
128
+
129
+ /* Label text wrapper */
130
+ .labelText {
131
+ /* HARDCODE: allows text truncation if bounded */
132
+ min-width: 0;
133
+ }
@@ -1,17 +1,59 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1
3
  import type { Meta, StoryObj } from "@storybook/react";
2
4
  import { Link } from "./Link";
3
- import { ComingSoon } from "@recursica/storybook-template";
5
+ import { Text } from "@mantine/core";
4
6
 
5
7
  const meta: Meta<typeof Link> = {
6
- title: "UI-Kit/🚧 Link",
8
+ title: "UI-Kit/Link",
7
9
  component: Link,
8
10
  tags: ["autodocs"],
11
+ args: {
12
+ children: "Link text",
13
+ href: "#",
14
+ },
15
+ render: ({ withLayer, layer, ...args }: any) => <Link {...args} />,
9
16
  };
10
17
 
11
18
  export default meta;
12
19
 
13
20
  type Story = StoryObj<typeof Link>;
14
21
 
15
- export const Default: Story = {
16
- render: () => <ComingSoon componentName="Link" />,
22
+ export const Default: Story = {};
23
+
24
+ export const WithIcon: Story = {
25
+ args: {
26
+ icon: (
27
+ <svg
28
+ width="24"
29
+ height="24"
30
+ viewBox="0 0 24 24"
31
+ fill="none"
32
+ stroke="currentColor"
33
+ strokeWidth="2"
34
+ strokeLinecap="round"
35
+ strokeLinejoin="round"
36
+ >
37
+ <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
38
+ <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
39
+ </svg>
40
+ ),
41
+ children: "Link with Icon",
42
+ },
43
+ };
44
+
45
+ export const Polymorphic: Story = {
46
+ args: {
47
+ component: "button",
48
+ onClick: () => alert("Button clicked!"),
49
+ children: "Rendered as <button>",
50
+ },
51
+ };
52
+
53
+ export const InlineText: Story = {
54
+ render: () => (
55
+ <Text>
56
+ Here is some text with an <Link href="#">inline link</Link> inside it.
57
+ </Text>
58
+ ),
17
59
  };
@@ -1,7 +1,84 @@
1
- import React from "react";
1
+ import React, { forwardRef } from "react";
2
+ import {
3
+ Anchor as MantineAnchor,
4
+ type AnchorProps as MantineAnchorProps,
5
+ createPolymorphicComponent,
6
+ } from "@mantine/core";
7
+ import {
8
+ filterStylingProps,
9
+ type RecursicaOverStyled,
10
+ } from "../../utils/filterStylingProps";
11
+ import styles from "./Link.module.css";
2
12
 
3
- export type LinkProps = React.HTMLAttributes<HTMLDivElement>;
13
+ export interface RecursicaLinkProps {
14
+ /**
15
+ * Optional leading icon to display next to the link text.
16
+ */
17
+ icon?: React.ReactNode;
18
+ /**
19
+ * The text or elements to display inside the link.
20
+ */
21
+ children?: React.ReactNode;
22
+ }
4
23
 
5
- export const Link: React.FC<LinkProps> = (props) => {
6
- return <div {...props}>Link</div>;
7
- };
24
+ export type LinkProps = RecursicaOverStyled<
25
+ Omit<MantineAnchorProps, "underline"> & RecursicaLinkProps
26
+ >;
27
+
28
+ const _Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
29
+ { icon, children, overStyled = false, ...rest },
30
+ ref,
31
+ ) {
32
+ const sanitizedProps = filterStylingProps(rest, overStyled);
33
+ const restRecord = sanitizedProps as Record<string, unknown>;
34
+
35
+ const mergedClassNames: Partial<Record<string, string>> = {
36
+ root: styles.root,
37
+ };
38
+
39
+ const classNamesProp = restRecord.classNames;
40
+ if (
41
+ classNamesProp &&
42
+ typeof classNamesProp === "object" &&
43
+ !Array.isArray(classNamesProp)
44
+ ) {
45
+ const o = classNamesProp as Partial<Record<string, string>>;
46
+ mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
47
+ }
48
+
49
+ const classNameProp = restRecord.className as string | undefined;
50
+ const finalClass = classNameProp
51
+ ? `${styles.root} ${classNameProp}`
52
+ : styles.root;
53
+
54
+ return (
55
+ <MantineAnchor
56
+ ref={ref}
57
+ className={finalClass}
58
+ classNames={mergedClassNames}
59
+ underline="never"
60
+ {...(icon ? { "data-has-icon": "" } : {})}
61
+ {...sanitizedProps}
62
+ >
63
+ {icon && (
64
+ <span className={styles.iconWrapper} aria-hidden>
65
+ {icon}
66
+ </span>
67
+ )}
68
+ <span className={styles.labelText}>{children}</span>
69
+ </MantineAnchor>
70
+ );
71
+ });
72
+ _Link.displayName = "Link";
73
+
74
+ /**
75
+ * Recursica Link component wrapping Mantine's Anchor.
76
+ *
77
+ * Supports polymorphism via the `component` prop or `renderRoot` for custom element rendering (e.g. react-router Link).
78
+ * @example
79
+ * ```tsx
80
+ * <Link component="a" href="https://example.com">External Link</Link>
81
+ * <Link renderRoot={(props) => <RouterLink to="/home" {...props} />}>Home</Link>
82
+ * ```
83
+ */
84
+ export const Link = createPolymorphicComponent<"a", LinkProps>(_Link);
@@ -0,0 +1 @@
1
+ export * from "./Link";
@@ -0,0 +1,16 @@
1
+ # Pagination Implementation Notes
2
+
3
+ ## Architecture Decision: CSS Inheritance vs. Composition
4
+
5
+ The Figma design tokens for the `Pagination` component dictate that pagination pages perfectly mimic `Button` variants (e.g. `active-pages_style: "solid"`, `inactive-pages_style: "outline"`, `navigation-controls_style: "text"`).
6
+
7
+ As of the `1.2.0` scoped CSS update, the Figma exporter automatically handles these variants. It flattens and aliases the referenced Button properties directly into the `Pagination` component's variable namespace.
8
+
9
+ We opted to use Mantine's native `PaginationControl` components to ensure all DOM structure, focus management, and accessibility attributes are preserved natively without us needing to carefully rebuild `Pagination.Items` mappings.
10
+
11
+ To honor the Figma design intents while using Mantine's raw `<button>` elements:
12
+
13
+ 1. We inherit and map all natively scoped `Pagination` variant styles (small typography, outline/solid/text colors, and hover overlays) directly into `.control` and `.control[data-active]` within `Pagination.module.css`. We do not need to manually reference `Button` variables cross-component.
14
+ 2. We inject `data-variant="text"` via `getControlProps` onto the navigation buttons so that they inherit the explicitly aliased text style variables (`navigation-controls`) defined by the UI Kit for pagination.
15
+
16
+ This achieves exact optical alignment with the tokens while maintaining Mantine's robust internal event handling for pagination.
@@ -0,0 +1,66 @@
1
+ import styles from "./Pagination.module.css";
2
+
3
+ const NextPath =
4
+ "M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z";
5
+ const PrevPath =
6
+ "M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z";
7
+ const FirstPath =
8
+ "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";
9
+ const LastPath =
10
+ "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";
11
+
12
+ export type PaginationIconType = "next" | "prev" | "first" | "last";
13
+
14
+ const paths: Record<PaginationIconType, string> = {
15
+ next: NextPath,
16
+ prev: PrevPath,
17
+ first: FirstPath,
18
+ last: LastPath,
19
+ };
20
+
21
+ export const PaginationIcon = ({
22
+ type,
23
+ className,
24
+ ...props
25
+ }: React.ComponentProps<"svg"> & { type: PaginationIconType }) => (
26
+ <svg
27
+ viewBox="0 0 16 16"
28
+ xmlns="http://www.w3.org/2000/svg"
29
+ className={`${styles.baseIcon} ${className || ""}`.trim()}
30
+ {...props}
31
+ >
32
+ <path d={paths[type as PaginationIconType]} fill="currentColor" />
33
+ </svg>
34
+ );
35
+
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ export const NextWithLabel = (props: any) => (
38
+ <div className={styles.iconWithLabel}>
39
+ <span>Next</span>
40
+ <PaginationIcon type="next" {...props} />
41
+ </div>
42
+ );
43
+
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ export const PrevWithLabel = (props: any) => (
46
+ <div className={styles.iconWithLabel}>
47
+ <PaginationIcon type="prev" {...props} />
48
+ <span>Prev</span>
49
+ </div>
50
+ );
51
+
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ export const FirstWithLabel = (props: any) => (
54
+ <div className={styles.iconWithLabel}>
55
+ <PaginationIcon type="first" {...props} />
56
+ <span>First</span>
57
+ </div>
58
+ );
59
+
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ export const LastWithLabel = (props: any) => (
62
+ <div className={styles.iconWithLabel}>
63
+ <span>Last</span>
64
+ <PaginationIcon type="last" {...props} />
65
+ </div>
66
+ );