@recursica/mantine-adapter 0.14.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/mantine-adapter.cjs +1 -1
  3. package/dist/mantine-adapter.cjs.map +1 -1
  4. package/dist/mantine-adapter.css +1 -1
  5. package/dist/mantine-adapter.js +1439 -1251
  6. package/dist/mantine-adapter.js.map +1 -1
  7. package/dist/src/components/Button/Button.d.ts +7 -1
  8. package/dist/src/components/Link/Link.d.ts +32 -2
  9. package/dist/src/components/Link/index.d.ts +1 -0
  10. package/dist/src/components/Pagination/Pagination.d.ts +50 -2
  11. package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
  12. package/dist/src/components/Pagination/index.d.ts +1 -0
  13. package/dist/src/components/Panel/Panel.d.ts +10 -2
  14. package/package.json +1 -1
  15. package/src/components/Button/Button.stories.tsx +11 -0
  16. package/src/components/Button/Button.tsx +7 -1
  17. package/src/components/Card/Card.module.css +1 -0
  18. package/src/components/Card/Card.stories.tsx +48 -58
  19. package/src/components/Link/IMPLEMENTATION_NOTES.md +26 -0
  20. package/src/components/Link/Link.module.css +133 -0
  21. package/src/components/Link/Link.stories.tsx +46 -4
  22. package/src/components/Link/Link.tsx +82 -5
  23. package/src/components/Link/index.ts +1 -0
  24. package/src/components/Pagination/IMPLEMENTATION_NOTES.md +16 -0
  25. package/src/components/Pagination/Pagination.icons.tsx +66 -0
  26. package/src/components/Pagination/Pagination.module.css +225 -0
  27. package/src/components/Pagination/Pagination.stories.tsx +44 -4
  28. package/src/components/Pagination/Pagination.tsx +214 -4
  29. package/src/components/Pagination/index.ts +5 -0
  30. package/src/components/Panel/PANEL_IMPLEMENTATION_NOTES.md +3 -3
  31. package/src/components/Panel/Panel.module.css +11 -0
  32. package/src/components/Panel/Panel.stories.tsx +12 -1
  33. package/src/components/Panel/Panel.tsx +12 -2
@@ -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
+ );
@@ -0,0 +1,225 @@
1
+ .root {
2
+ display: flex;
3
+ align-items: center;
4
+ gap: var(--recursica_ui-kit_components_pagination_properties_item-gap);
5
+ }
6
+
7
+ .control {
8
+ box-sizing: border-box;
9
+ margin: 0;
10
+ border-style: solid;
11
+ position: relative;
12
+ transition: all 0.2s ease;
13
+ overflow: hidden;
14
+ display: inline-flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+
18
+ /* Typography */
19
+ font-family: var(
20
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_text_font-family,
21
+ var(--recursica_brand_fonts_primary)
22
+ );
23
+ font-size: var(
24
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_text_font-size,
25
+ var(--recursica_brand_dimensions_text-size_default)
26
+ );
27
+ font-style: var(
28
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_text_font-style,
29
+ normal
30
+ );
31
+ font-weight: var(
32
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_text_font-weight,
33
+ 500
34
+ );
35
+ letter-spacing: var(
36
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_text_letter-spacing,
37
+ 0
38
+ );
39
+ line-height: var(
40
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_text_line-height,
41
+ 1.5
42
+ );
43
+ text-decoration: var(
44
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_text_text-decoration,
45
+ none
46
+ );
47
+ text-transform: var(
48
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_text_text-transform,
49
+ none
50
+ );
51
+
52
+ /* Dimensions */
53
+ border-radius: var(
54
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_border-radius
55
+ );
56
+ height: var(
57
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_height
58
+ );
59
+ min-width: var(
60
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_min-width
61
+ );
62
+ padding: 0
63
+ var(
64
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_horizontal-padding
65
+ );
66
+
67
+ /* Base Inactive Style: Outline */
68
+ border-width: var(
69
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_style_properties_border-size
70
+ );
71
+ box-shadow: var(
72
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_style_properties_elevation
73
+ );
74
+ background-color: var(
75
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_style_properties_colors_background
76
+ );
77
+ border-color: var(
78
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_style_properties_colors_border-color
79
+ );
80
+ color: var(
81
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_style_properties_colors_text
82
+ );
83
+ }
84
+
85
+ .control:disabled {
86
+ opacity: var(--recursica_brand_states_disabled);
87
+ cursor: not-allowed;
88
+ }
89
+
90
+ .control:hover:not(:disabled) {
91
+ color: var(
92
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_style_properties_colors_text-hover
93
+ );
94
+ }
95
+
96
+ /* Hover Overlay */
97
+ .control::after {
98
+ content: "";
99
+ position: absolute;
100
+ inset: 0;
101
+ border-radius: inherit;
102
+ z-index: 0;
103
+ pointer-events: none;
104
+ transition: opacity 150ms ease;
105
+ opacity: 0;
106
+ background-color: var(
107
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_hover-color
108
+ );
109
+ }
110
+
111
+ .control:hover:not(:disabled)::after {
112
+ opacity: var(
113
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_hover-opacity,
114
+ 0.1
115
+ );
116
+ }
117
+
118
+ /* Active Style: Solid */
119
+ .control[data-active] {
120
+ border-width: var(
121
+ --recursica_ui-kit_components_pagination_properties_active-pages_style_properties_border-size
122
+ );
123
+ box-shadow: var(
124
+ --recursica_ui-kit_components_pagination_properties_active-pages_style_properties_elevation
125
+ );
126
+ background-color: var(
127
+ --recursica_ui-kit_components_pagination_properties_active-pages_style_properties_colors_background
128
+ );
129
+ border-color: var(
130
+ --recursica_ui-kit_components_pagination_properties_active-pages_style_properties_colors_border-color
131
+ );
132
+ color: var(
133
+ --recursica_ui-kit_components_pagination_properties_active-pages_style_properties_colors_text
134
+ );
135
+ }
136
+
137
+ .control[data-active]:hover:not(:disabled) {
138
+ color: var(
139
+ --recursica_ui-kit_components_pagination_properties_active-pages_style_properties_colors_text-hover
140
+ );
141
+ }
142
+
143
+ /* Navigation Style: Text */
144
+ .control[data-variant="text"] {
145
+ border-width: var(
146
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_style_properties_border-size
147
+ );
148
+ box-shadow: var(
149
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_style_properties_elevation
150
+ );
151
+ background-color: var(
152
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_style_properties_colors_background
153
+ );
154
+ border-color: var(
155
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_style_properties_colors_border-color
156
+ );
157
+ color: var(
158
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_style_properties_colors_text
159
+ );
160
+
161
+ /* Also explicitly inherit navigation sizes incase they differ from pages */
162
+ border-radius: var(
163
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_size_properties_border-radius
164
+ );
165
+ height: var(
166
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_size_properties_height
167
+ );
168
+ min-width: var(
169
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_size_properties_min-width
170
+ );
171
+ padding: 0
172
+ var(
173
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_size_properties_horizontal-padding
174
+ );
175
+ }
176
+
177
+ .control[data-variant="text"]:hover:not(:disabled) {
178
+ color: var(
179
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_style_properties_colors_text-hover
180
+ );
181
+ }
182
+
183
+ /* Hover Overlay for Navigation */
184
+ .control[data-variant="text"]::after {
185
+ background-color: var(
186
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_size_properties_hover-color
187
+ );
188
+ }
189
+ .control[data-variant="text"]:hover:not(:disabled)::after {
190
+ opacity: var(
191
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_size_properties_hover-opacity,
192
+ 0.1
193
+ );
194
+ }
195
+
196
+ /* Dots */
197
+ .dots {
198
+ display: inline-flex;
199
+ align-items: center;
200
+ justify-content: center;
201
+ height: var(
202
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_height
203
+ );
204
+ min-width: var(
205
+ --recursica_ui-kit_components_pagination_properties_inactive-pages_size_properties_min-width
206
+ );
207
+ color: var(
208
+ --recursica_ui-kit_components_pagination_properties_colors_dots-color
209
+ );
210
+ }
211
+
212
+ /* Icon Styles */
213
+ .iconWithLabel {
214
+ display: flex;
215
+ align-items: center;
216
+ gap: var(
217
+ --recursica_ui-kit_components_pagination_properties_navigation-controls_size_properties_icon-text-gap,
218
+ 4px
219
+ );
220
+ }
221
+
222
+ .baseIcon {
223
+ width: calc(var(--pagination-control-size) / 1.8);
224
+ height: calc(var(--pagination-control-size) / 1.8);
225
+ }
@@ -1,17 +1,57 @@
1
+ import React from "react";
1
2
  import type { Meta, StoryObj } from "@storybook/react";
2
3
  import { Pagination } from "./Pagination";
3
- import { ComingSoon } from "@recursica/storybook-template";
4
4
 
5
5
  const meta: Meta<typeof Pagination> = {
6
- title: "UI-Kit/🚧 Pagination",
6
+ title: "UI-Kit/Pagination",
7
7
  component: Pagination,
8
8
  tags: ["autodocs"],
9
+ argTypes: {
10
+ total: { control: "number" },
11
+ withEdges: { control: "boolean" },
12
+ withControls: { control: "boolean" },
13
+ disabled: { control: "boolean" },
14
+ withLabels: {
15
+ control: "boolean",
16
+ description: "Toggle text labels alongside icons",
17
+ },
18
+ defaultChecked: { table: { disable: true } },
19
+ },
20
+ args: {
21
+ total: 10,
22
+ withEdges: false,
23
+ withControls: true,
24
+ withLabels: false,
25
+ },
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
27
+ render: ({ withLayer, layer, ...args }: any) => {
28
+ return <Pagination {...args} />;
29
+ },
9
30
  };
10
31
 
11
32
  export default meta;
12
33
 
13
34
  type Story = StoryObj<typeof Pagination>;
14
35
 
15
- export const Default: Story = {
16
- render: () => <ComingSoon componentName="Pagination" />,
36
+ export const Default: Story = {};
37
+
38
+ export const WithEdges: Story = {
39
+ args: {
40
+ withEdges: true,
41
+ },
42
+ };
43
+
44
+ export const Compositional: Story = {
45
+ render: () => (
46
+ <Pagination.Root total={10}>
47
+ <Pagination.Items />
48
+ </Pagination.Root>
49
+ ),
50
+ };
51
+
52
+ export const WithTextLabels: Story = {
53
+ args: {
54
+ withEdges: true,
55
+ withLabels: true,
56
+ },
17
57
  };
@@ -1,7 +1,217 @@
1
- import React from "react";
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import React, { forwardRef } from "react";
3
+ import {
4
+ Pagination as MantinePagination,
5
+ type PaginationProps as MantinePaginationProps,
6
+ type PaginationRootProps as MantinePaginationRootProps,
7
+ } from "@mantine/core";
8
+ import {
9
+ filterStylingProps,
10
+ type RecursicaOverStyled,
11
+ } from "../../utils/filterStylingProps";
12
+ import styles from "./Pagination.module.css";
13
+ import {
14
+ NextWithLabel,
15
+ PrevWithLabel,
16
+ FirstWithLabel,
17
+ LastWithLabel,
18
+ PaginationIcon,
19
+ } from "./Pagination.icons";
2
20
 
3
- export type PaginationProps = React.HTMLAttributes<HTMLDivElement>;
21
+ export type PaginationProps = RecursicaOverStyled<MantinePaginationProps> & {
22
+ /** If set to true, displays text labels alongside the icons for next/previous/first/last edges. */
23
+ withLabels?: boolean;
24
+ };
25
+
26
+ export type PaginationRootProps =
27
+ RecursicaOverStyled<MantinePaginationRootProps>;
28
+
29
+ export type PaginationEdgeProps<T extends React.ElementType> =
30
+ React.ComponentProps<T> & {
31
+ /** If set to true, displays text labels alongside the icon. */
32
+ withLabel?: boolean;
33
+ icon?: any;
34
+ };
35
+
36
+ function usePaginationClassNames(restRecord: Record<string, unknown>): {
37
+ className: string;
38
+ classNames: Partial<Record<string, string>>;
39
+ } {
40
+ const mergedClassNames: Partial<Record<string, string>> = {
41
+ root: styles.root,
42
+ control: styles.control,
43
+ dots: styles.dots,
44
+ };
45
+
46
+ const classNamesProp = restRecord.classNames;
47
+ if (
48
+ classNamesProp &&
49
+ typeof classNamesProp === "object" &&
50
+ !Array.isArray(classNamesProp)
51
+ ) {
52
+ const o = classNamesProp as Partial<Record<string, string>>;
53
+ mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
54
+ mergedClassNames.control = o.control
55
+ ? `${styles.control} ${o.control}`
56
+ : styles.control;
57
+ mergedClassNames.dots = o.dots ? `${styles.dots} ${o.dots}` : styles.dots;
58
+ }
59
+
60
+ const classNameProp = restRecord.className as string | undefined;
61
+ const finalClass = classNameProp
62
+ ? `${styles.root} ${classNameProp}`
63
+ : styles.root;
64
+
65
+ return { className: finalClass, classNames: mergedClassNames };
66
+ }
67
+
68
+ const _PaginationRoot = forwardRef<HTMLDivElement, PaginationRootProps>(
69
+ function PaginationRoot({ overStyled = false, ...rest }, ref) {
70
+ const sanitizedProps = filterStylingProps(rest, overStyled);
71
+ const stylingParams = usePaginationClassNames(
72
+ sanitizedProps as Record<string, unknown>,
73
+ );
74
+
75
+ return (
76
+ <MantinePagination.Root
77
+ ref={ref}
78
+ className={stylingParams.className}
79
+ classNames={stylingParams.classNames}
80
+ {...(sanitizedProps as MantinePaginationRootProps)}
81
+ />
82
+ );
83
+ },
84
+ );
85
+ _PaginationRoot.displayName = "Pagination.Root";
4
86
 
5
- export const Pagination: React.FC<PaginationProps> = (props) => {
6
- return <div {...props}>Pagination</div>;
87
+ const _PaginationNext = forwardRef<
88
+ HTMLButtonElement,
89
+ PaginationEdgeProps<typeof MantinePagination.Next>
90
+ >(function PaginationNext({ withLabel, icon, ...props }, ref) {
91
+ const renderIcon = icon || (withLabel ? NextWithLabel : undefined);
92
+ return (
93
+ <MantinePagination.Next
94
+ ref={ref}
95
+ data-variant="text"
96
+ icon={renderIcon as any}
97
+ {...props}
98
+ />
99
+ );
100
+ });
101
+ _PaginationNext.displayName = "Pagination.Next";
102
+
103
+ const _PaginationPrevious = forwardRef<
104
+ HTMLButtonElement,
105
+ PaginationEdgeProps<typeof MantinePagination.Previous>
106
+ >(function PaginationPrevious({ withLabel, icon, ...props }, ref) {
107
+ const renderIcon = icon || (withLabel ? PrevWithLabel : undefined);
108
+ return (
109
+ <MantinePagination.Previous
110
+ ref={ref}
111
+ data-variant="text"
112
+ icon={renderIcon as any}
113
+ {...props}
114
+ />
115
+ );
116
+ });
117
+ _PaginationPrevious.displayName = "Pagination.Previous";
118
+
119
+ const _PaginationFirst = forwardRef<
120
+ HTMLButtonElement,
121
+ PaginationEdgeProps<typeof MantinePagination.First>
122
+ >(function PaginationFirst({ withLabel, icon, ...props }, ref) {
123
+ const renderIcon = icon || (withLabel ? FirstWithLabel : undefined);
124
+ return (
125
+ <MantinePagination.First
126
+ ref={ref}
127
+ data-variant="text"
128
+ icon={renderIcon as any}
129
+ {...props}
130
+ />
131
+ );
132
+ });
133
+ _PaginationFirst.displayName = "Pagination.First";
134
+
135
+ const _PaginationLast = forwardRef<
136
+ HTMLButtonElement,
137
+ PaginationEdgeProps<typeof MantinePagination.Last>
138
+ >(function PaginationLast({ withLabel, icon, ...props }, ref) {
139
+ const renderIcon = icon || (withLabel ? LastWithLabel : undefined);
140
+ return (
141
+ <MantinePagination.Last
142
+ ref={ref}
143
+ data-variant="text"
144
+ icon={renderIcon as any}
145
+ {...props}
146
+ />
147
+ );
148
+ });
149
+ _PaginationLast.displayName = "Pagination.Last";
150
+
151
+ const _Pagination = forwardRef<HTMLDivElement, PaginationProps>(
152
+ function Pagination(
153
+ { overStyled = false, getControlProps, withLabels, ...rest },
154
+ ref,
155
+ ) {
156
+ const sanitizedProps = filterStylingProps(rest, overStyled);
157
+ const stylingParams = usePaginationClassNames(
158
+ sanitizedProps as Record<string, unknown>,
159
+ );
160
+
161
+ const mergedGetControlProps = (
162
+ control: "first" | "previous" | "last" | "next",
163
+ ) => {
164
+ const baseProps = { "data-variant": "text" };
165
+ if (getControlProps) {
166
+ return { ...baseProps, ...getControlProps(control) };
167
+ }
168
+ return baseProps;
169
+ };
170
+
171
+ const labelsIcons = withLabels
172
+ ? {
173
+ nextIcon: NextWithLabel,
174
+ previousIcon: PrevWithLabel,
175
+ firstIcon: FirstWithLabel,
176
+ lastIcon: LastWithLabel,
177
+ }
178
+ : {};
179
+
180
+ return (
181
+ <MantinePagination
182
+ ref={ref}
183
+ className={stylingParams.className}
184
+ classNames={stylingParams.classNames}
185
+ getControlProps={mergedGetControlProps}
186
+ {...labelsIcons}
187
+ {...(sanitizedProps as MantinePaginationProps)}
188
+ />
189
+ );
190
+ },
191
+ );
192
+ _Pagination.displayName = "Pagination";
193
+
194
+ /**
195
+ * Recursica Pagination component wrapping Mantine's Pagination.
196
+ */
197
+ export const Pagination = _Pagination as typeof _Pagination & {
198
+ Root: typeof _PaginationRoot;
199
+ Items: typeof MantinePagination.Items;
200
+ Control: typeof MantinePagination.Control;
201
+ Dots: typeof MantinePagination.Dots;
202
+ Next: typeof _PaginationNext;
203
+ Previous: typeof _PaginationPrevious;
204
+ First: typeof _PaginationFirst;
205
+ Last: typeof _PaginationLast;
206
+ Icon: typeof PaginationIcon;
7
207
  };
208
+
209
+ Pagination.Root = _PaginationRoot;
210
+ Pagination.Items = MantinePagination.Items;
211
+ Pagination.Control = MantinePagination.Control;
212
+ Pagination.Dots = MantinePagination.Dots;
213
+ Pagination.Next = _PaginationNext;
214
+ Pagination.Previous = _PaginationPrevious;
215
+ Pagination.First = _PaginationFirst;
216
+ Pagination.Last = _PaginationLast;
217
+ Pagination.Icon = PaginationIcon;
@@ -0,0 +1,5 @@
1
+ export {
2
+ Pagination,
3
+ type PaginationProps,
4
+ type PaginationRootProps,
5
+ } from "./Pagination";