@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.
- package/CHANGELOG.md +6 -0
- package/dist/mantine-adapter.cjs +1 -1
- package/dist/mantine-adapter.cjs.map +1 -1
- package/dist/mantine-adapter.css +1 -1
- package/dist/mantine-adapter.js +1367 -1181
- package/dist/mantine-adapter.js.map +1 -1
- package/dist/src/components/Button/Button.d.ts +7 -1
- package/dist/src/components/Link/Link.d.ts +32 -2
- package/dist/src/components/Link/index.d.ts +1 -0
- package/dist/src/components/Pagination/Pagination.d.ts +50 -2
- package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
- package/dist/src/components/Pagination/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Button/Button.stories.tsx +11 -0
- package/src/components/Button/Button.tsx +7 -1
- package/src/components/Link/IMPLEMENTATION_NOTES.md +26 -0
- package/src/components/Link/Link.module.css +133 -0
- package/src/components/Link/Link.stories.tsx +46 -4
- package/src/components/Link/Link.tsx +82 -5
- package/src/components/Link/index.ts +1 -0
- package/src/components/Pagination/IMPLEMENTATION_NOTES.md +16 -0
- package/src/components/Pagination/Pagination.icons.tsx +66 -0
- package/src/components/Pagination/Pagination.module.css +225 -0
- package/src/components/Pagination/Pagination.stories.tsx +44 -4
- package/src/components/Pagination/Pagination.tsx +214 -4
- package/src/components/Pagination/index.ts +5 -0
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
6
|
-
|
|
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;
|