@recursica/adapter-mui-v7 1.1.0 → 1.3.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 +17 -0
- package/OVERSTYLING.md +1 -1
- package/SETUP.md +26 -3
- package/dist/adapter-mui-v7.cjs +69 -69
- package/dist/adapter-mui-v7.cjs.map +1 -1
- package/dist/adapter-mui-v7.css +1 -1
- package/dist/adapter-mui-v7.js +5955 -5739
- package/dist/adapter-mui-v7.js.map +1 -1
- package/dist/index.d.ts +69 -51
- package/llms.txt +1 -1
- package/package.json +4 -4
- package/recursica_brand.json +2 -2
- package/recursica_tokens.json +2 -2
- package/recursica_ui-kit.json +2 -2
- package/recursica_variables_scoped.css +7 -3
- package/src/components/Checkbox/Checkbox.module.css +1 -3
- package/src/components/Container/USAGE.md +0 -1
- package/src/components/FileInput/FileInput.module.css +8 -0
- package/src/components/FileUpload/FileUpload.module.css +1 -0
- package/src/components/FileUpload/FileUpload.tsx +1 -0
- package/src/components/Flex/USAGE.md +2 -1
- package/src/components/Group/USAGE.md +2 -1
- package/src/components/LayoutGrid/LAYOUT_GRID_IMPLEMENTATION_NOTES.md +82 -0
- package/src/components/LayoutGrid/LayoutGrid.columns.dom.test.tsx +78 -0
- package/src/components/{Grid/Grid.module.css → LayoutGrid/LayoutGrid.module.css} +11 -10
- package/src/components/LayoutGrid/LayoutGrid.stories.tsx +61 -0
- package/src/components/LayoutGrid/LayoutGrid.test.tsx +1 -0
- package/src/components/LayoutGrid/LayoutGrid.tsx +181 -0
- package/src/components/LayoutGrid/USAGE.md +79 -0
- package/src/components/LayoutGrid/index.ts +1 -0
- package/src/components/Menu/Menu.stories.tsx +0 -3
- package/src/components/Pagination/IMPLEMENTATION_NOTES.md +42 -38
- package/src/components/Pagination/Pagination.icons.tsx +0 -32
- package/src/components/Pagination/Pagination.manifest.dom.test.tsx +105 -0
- package/src/components/Pagination/Pagination.module.css +25 -164
- package/src/components/Pagination/Pagination.tsx +221 -97
- package/src/components/Pagination/USAGE.md +8 -1
- package/src/components/Panel/Panel.module.css +24 -1
- package/src/components/Panel/Panel.stories.tsx +4 -4
- package/src/components/Panel/Panel.tsx +10 -1
- package/src/components/Radio/Radio.module.css +2 -2
- package/src/components/SegmentedControl/SegmentedControl.module.css +18 -0
- package/src/components/Stack/USAGE.md +2 -1
- package/src/components/Stepper/Stepper.module.css +0 -21
- package/src/components/index.ts +1 -1
- package/src/index.ts +1 -0
- package/src/utils/breakpointsFromRecManifest.test.ts +40 -0
- package/src/utils/breakpointsFromRecManifest.ts +72 -0
- package/src/utils/index.ts +1 -0
- package/src/components/Grid/Grid.stories.tsx +0 -151
- package/src/components/Grid/Grid.test.tsx +0 -1
- package/src/components/Grid/Grid.tsx +0 -189
- package/src/components/Grid/IMPLEMENTATION_NOTES.md +0 -99
- package/src/components/Grid/USAGE.md +0 -57
- package/src/components/Grid/index.ts +0 -1
|
@@ -1,197 +1,58 @@
|
|
|
1
|
-
/*
|
|
2
|
-
*
|
|
3
|
-
* recursica-allow-brand: --recursica_brand_states_disabled
|
|
4
|
-
* recursica-allow-brand: --recursica_brand_states_hover_color
|
|
5
|
-
* recursica-allow-brand: --recursica_brand_states_hover_opacity
|
|
6
|
-
*/
|
|
1
|
+
/* The page and navigation buttons are Recursica Buttons (see Pagination.tsx), so this file only
|
|
2
|
+
* lays out the row and styles the dots and the labelled-icon wrapper. */
|
|
7
3
|
|
|
8
4
|
.root {
|
|
9
5
|
display: flex;
|
|
10
6
|
align-items: center;
|
|
11
7
|
gap: var(--recursica_ui-kit_components_pagination_properties_item-gap);
|
|
12
|
-
|
|
13
|
-
/* Mantine's own native Pagination CSS defines `--pagination-control-size` (their
|
|
14
|
-
internal size scale) on the DOM already, which mantine-adapter's `.baseIcon`
|
|
15
|
-
below reads directly. MUI has no equivalent variable, so it's bridged here to
|
|
16
|
-
the same Button height token `.control` itself is sized from, keeping the
|
|
17
|
-
chevron glyphs proportional to the actual rendered circle size. */
|
|
18
|
-
--pagination-control-size: var(
|
|
19
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_height
|
|
20
|
-
);
|
|
21
8
|
}
|
|
22
9
|
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
margin: 0;
|
|
26
|
-
border-style: solid;
|
|
27
|
-
position: relative;
|
|
28
|
-
transition: all 0.2s ease;
|
|
29
|
-
overflow: hidden;
|
|
10
|
+
/* Dots: sized like the page buttons around them (the inactive-pages size from the manifest). */
|
|
11
|
+
.dots {
|
|
30
12
|
display: inline-flex;
|
|
31
13
|
align-items: center;
|
|
32
14
|
justify-content: center;
|
|
33
|
-
|
|
34
|
-
/* Typography */
|
|
35
|
-
font-family: var(
|
|
36
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_text_font-family
|
|
37
|
-
);
|
|
38
|
-
font-size: var(
|
|
39
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_text_font-size
|
|
40
|
-
);
|
|
41
|
-
font-style: var(
|
|
42
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_text_font-style
|
|
43
|
-
);
|
|
44
|
-
font-weight: var(
|
|
45
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_text_font-weight
|
|
46
|
-
);
|
|
47
|
-
letter-spacing: var(
|
|
48
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_text_letter-spacing
|
|
49
|
-
);
|
|
50
|
-
line-height: var(
|
|
51
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_text_line-height
|
|
52
|
-
);
|
|
53
|
-
text-decoration: var(
|
|
54
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_text_text-decoration
|
|
55
|
-
);
|
|
56
|
-
text-transform: var(
|
|
57
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_text_text-transform
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
/* Dimensions */
|
|
61
|
-
border-radius: var(
|
|
62
|
-
--recursica_ui-kit_components_button_variants_content_icon-only_variants_sizes_default_properties_border-radius
|
|
63
|
-
);
|
|
64
15
|
height: var(
|
|
65
16
|
--recursica_ui-kit_components_button_variants_sizes_default_properties_height
|
|
66
17
|
);
|
|
67
18
|
min-width: var(
|
|
68
19
|
--recursica_ui-kit_components_button_variants_sizes_default_properties_min-width
|
|
69
20
|
);
|
|
70
|
-
padding: 0
|
|
71
|
-
var(
|
|
72
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_horizontal-padding
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
/* Base Inactive Style: Outline */
|
|
76
|
-
border-width: var(
|
|
77
|
-
--recursica_ui-kit_components_button_variants_styles_outline_properties_border-size
|
|
78
|
-
);
|
|
79
|
-
box-shadow: var(
|
|
80
|
-
--recursica_ui-kit_components_button_variants_styles_outline_properties_elevation
|
|
81
|
-
);
|
|
82
|
-
background-color: var(
|
|
83
|
-
--recursica_ui-kit_components_button_variants_styles_outline_properties_colors_background-color
|
|
84
|
-
);
|
|
85
|
-
border-color: var(
|
|
86
|
-
--recursica_ui-kit_components_button_variants_styles_outline_properties_colors_border-color
|
|
87
|
-
);
|
|
88
|
-
color: var(
|
|
89
|
-
--recursica_ui-kit_components_button_variants_styles_outline_properties_colors_text-color
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.control:disabled {
|
|
94
|
-
opacity: var(--recursica_brand_states_disabled);
|
|
95
|
-
cursor: not-allowed;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/* Hover Overlay: no per-variant hover-color/hover-opacity tokens exist anymore; use the
|
|
99
|
-
generic overlay tokens shared across components (same as Button). */
|
|
100
|
-
.control::after {
|
|
101
|
-
content: "";
|
|
102
|
-
position: absolute;
|
|
103
|
-
inset: 0;
|
|
104
|
-
border-radius: inherit;
|
|
105
|
-
z-index: 0;
|
|
106
|
-
pointer-events: none;
|
|
107
|
-
transition: opacity 150ms ease;
|
|
108
|
-
opacity: 0;
|
|
109
|
-
background-color: var(--recursica_brand_states_hover_color);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.control:hover:not(:disabled)::after {
|
|
113
|
-
opacity: var(--recursica_brand_states_hover_opacity);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/* Active Style: Solid */
|
|
117
|
-
.control[data-active] {
|
|
118
|
-
border-width: var(
|
|
119
|
-
--recursica_ui-kit_components_button_variants_styles_solid_properties_border-size
|
|
120
|
-
);
|
|
121
|
-
box-shadow: var(
|
|
122
|
-
--recursica_ui-kit_components_button_variants_styles_solid_properties_elevation
|
|
123
|
-
);
|
|
124
|
-
background-color: var(
|
|
125
|
-
--recursica_ui-kit_components_button_variants_styles_solid_properties_colors_background-color
|
|
126
|
-
);
|
|
127
|
-
border-color: var(
|
|
128
|
-
--recursica_ui-kit_components_button_variants_styles_solid_properties_colors_border-color
|
|
129
|
-
);
|
|
130
21
|
color: var(
|
|
131
|
-
--recursica_ui-
|
|
22
|
+
--recursica_ui-kit_components_pagination_properties_colors_dots-color
|
|
132
23
|
);
|
|
133
24
|
}
|
|
134
25
|
|
|
135
|
-
|
|
136
|
-
.control[data-variant="text"] {
|
|
137
|
-
border-width: var(
|
|
138
|
-
--recursica_ui-kit_components_button_variants_styles_text_properties_border-size
|
|
139
|
-
);
|
|
140
|
-
box-shadow: var(
|
|
141
|
-
--recursica_ui-kit_components_button_variants_styles_text_properties_elevation
|
|
142
|
-
);
|
|
143
|
-
background-color: var(
|
|
144
|
-
--recursica_ui-kit_components_button_variants_styles_text_properties_colors_background-color
|
|
145
|
-
);
|
|
146
|
-
border-color: var(
|
|
147
|
-
--recursica_ui-kit_components_button_variants_styles_text_properties_colors_border-color
|
|
148
|
-
);
|
|
149
|
-
color: var(
|
|
150
|
-
--recursica_ui-kit_components_button_variants_styles_text_properties_colors_text-color
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
/* Also explicitly inherit navigation sizes incase they differ from pages */
|
|
154
|
-
border-radius: var(
|
|
155
|
-
--recursica_ui-kit_components_button_variants_content_icon-only_variants_sizes_default_properties_border-radius
|
|
156
|
-
);
|
|
26
|
+
.dots[data-size="small"] {
|
|
157
27
|
height: var(
|
|
158
|
-
--recursica_ui-
|
|
28
|
+
--recursica_ui-kit_components_button_variants_sizes_small_properties_height
|
|
159
29
|
);
|
|
160
30
|
min-width: var(
|
|
161
|
-
--recursica_ui-
|
|
31
|
+
--recursica_ui-kit_components_button_variants_sizes_small_properties_min-width
|
|
162
32
|
);
|
|
163
|
-
padding: 0
|
|
164
|
-
var(
|
|
165
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_horizontal-padding
|
|
166
|
-
);
|
|
167
33
|
}
|
|
168
34
|
|
|
169
|
-
/*
|
|
170
|
-
.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
justify-content: center;
|
|
174
|
-
height: var(
|
|
175
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_height
|
|
176
|
-
);
|
|
177
|
-
min-width: var(
|
|
178
|
-
--recursica_ui-kit_components_button_variants_sizes_default_properties_min-width
|
|
179
|
-
);
|
|
180
|
-
color: var(
|
|
181
|
-
--recursica_ui-kit_components_pagination_properties_colors_dots-color
|
|
182
|
-
);
|
|
35
|
+
/* Icons: sized by the Button's own icon wrapper (left icons) or by its size (right icons). */
|
|
36
|
+
.baseIcon {
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: 100%;
|
|
183
39
|
}
|
|
184
40
|
|
|
185
|
-
|
|
186
|
-
.iconWithLabel {
|
|
41
|
+
.rightIcon {
|
|
187
42
|
display: flex;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
43
|
+
width: var(
|
|
44
|
+
--recursica_ui-kit_components_button_variants_sizes_default_properties_icon
|
|
45
|
+
);
|
|
46
|
+
height: var(
|
|
47
|
+
--recursica_ui-kit_components_button_variants_sizes_default_properties_icon
|
|
191
48
|
);
|
|
192
49
|
}
|
|
193
50
|
|
|
194
|
-
.
|
|
195
|
-
width:
|
|
196
|
-
|
|
51
|
+
[data-size="small"] .rightIcon {
|
|
52
|
+
width: var(
|
|
53
|
+
--recursica_ui-kit_components_button_variants_sizes_small_properties_icon
|
|
54
|
+
);
|
|
55
|
+
height: var(
|
|
56
|
+
--recursica_ui-kit_components_button_variants_sizes_small_properties_icon
|
|
57
|
+
);
|
|
197
58
|
}
|
|
@@ -1,123 +1,247 @@
|
|
|
1
|
-
import { forwardRef, type ComponentProps } from "react";
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
forwardRef,
|
|
3
|
+
type ComponentPropsWithoutRef,
|
|
4
|
+
type ReactNode,
|
|
5
|
+
} from "react";
|
|
6
|
+
import usePagination, {
|
|
7
|
+
type UsePaginationItem,
|
|
8
|
+
type UsePaginationProps,
|
|
9
|
+
} from "@mui/material/usePagination";
|
|
10
|
+
import {
|
|
11
|
+
useRecursicaManifest,
|
|
12
|
+
type RecursicaPaginationProps,
|
|
13
|
+
} from "@recursica/adapter-common";
|
|
8
14
|
import {
|
|
9
15
|
filterStylingProps,
|
|
10
|
-
mergeClassNames,
|
|
11
16
|
type RecursicaOverStyled,
|
|
12
17
|
} from "../../utils/filterStylingProps";
|
|
18
|
+
import { Button, type ButtonProps } from "../Button/Button";
|
|
13
19
|
import styles from "./Pagination.module.css";
|
|
14
|
-
import {
|
|
15
|
-
PaginationIcon,
|
|
16
|
-
NextWithLabel,
|
|
17
|
-
PrevWithLabel,
|
|
18
|
-
FirstWithLabel,
|
|
19
|
-
LastWithLabel,
|
|
20
|
-
} from "./Pagination.icons";
|
|
21
|
-
|
|
22
|
-
import { type RecursicaPaginationProps } from "@recursica/adapter-common";
|
|
20
|
+
import { PaginationIcon } from "./Pagination.icons";
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
>;
|
|
22
|
+
type PaginationRole = "active-pages" | "inactive-pages" | "navigation-controls";
|
|
23
|
+
type NavControl = "first" | "previous" | "next" | "last";
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
const mergedClassNames = mergeClassNames(
|
|
33
|
-
{ root: styles.root, ul: styles.ul },
|
|
34
|
-
restRecord.classNames as Partial<Record<string, string>> | undefined,
|
|
35
|
-
);
|
|
25
|
+
interface RoleVariant {
|
|
26
|
+
variant: NonNullable<ButtonProps["variant"]>;
|
|
27
|
+
size: NonNullable<ButtonProps["size"]>;
|
|
28
|
+
}
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
interface ManifestPagination {
|
|
31
|
+
"ui-kit"?: {
|
|
32
|
+
components?: {
|
|
33
|
+
pagination?: {
|
|
34
|
+
properties?: Record<
|
|
35
|
+
string,
|
|
36
|
+
{
|
|
37
|
+
$extensions?: {
|
|
38
|
+
"recursica.component"?: {
|
|
39
|
+
"selected-variants"?: Record<string, unknown>;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
>;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
41
48
|
|
|
42
|
-
|
|
49
|
+
/** Reads which Button style and size the manifest selects for a Pagination role. */
|
|
50
|
+
function usePaginationRole(role: PaginationRole): RoleVariant {
|
|
51
|
+
const manifest = useRecursicaManifest() as ManifestPagination;
|
|
52
|
+
const selected =
|
|
53
|
+
manifest["ui-kit"]?.components?.pagination?.properties?.[role]
|
|
54
|
+
?.$extensions?.["recursica.component"]?.["selected-variants"];
|
|
55
|
+
if (!selected) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Pagination: manifest has no ui-kit.components.pagination.properties.${role} selected-variants`,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
variant: selected.style as RoleVariant["variant"],
|
|
62
|
+
size: selected.size as RoleVariant["size"],
|
|
63
|
+
};
|
|
43
64
|
}
|
|
44
65
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
const NAV_ICON = {
|
|
67
|
+
first: "first",
|
|
68
|
+
previous: "prev",
|
|
69
|
+
next: "next",
|
|
70
|
+
last: "last",
|
|
71
|
+
} as const;
|
|
72
|
+
|
|
73
|
+
const NAV_ARIA_LABEL: Record<NavControl, string> = {
|
|
74
|
+
first: "First page",
|
|
75
|
+
previous: "Previous page",
|
|
76
|
+
next: "Next page",
|
|
77
|
+
last: "Last page",
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const NAV_LABEL: Record<NavControl, string> = {
|
|
81
|
+
first: "First",
|
|
82
|
+
previous: "Prev",
|
|
83
|
+
next: "Next",
|
|
84
|
+
last: "Last",
|
|
53
85
|
};
|
|
54
86
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
87
|
+
// Next/Last put the icon after the label; First/Previous put it before.
|
|
88
|
+
const ICON_AFTER_LABEL: Record<NavControl, boolean> = {
|
|
89
|
+
first: false,
|
|
90
|
+
previous: false,
|
|
91
|
+
next: true,
|
|
92
|
+
last: true,
|
|
60
93
|
};
|
|
61
94
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
95
|
+
export type PaginationProps = RecursicaOverStyled<
|
|
96
|
+
RecursicaPaginationProps &
|
|
97
|
+
Pick<
|
|
98
|
+
UsePaginationProps,
|
|
99
|
+
| "page"
|
|
100
|
+
| "defaultPage"
|
|
101
|
+
| "onChange"
|
|
102
|
+
| "siblingCount"
|
|
103
|
+
| "boundaryCount"
|
|
104
|
+
| "disabled"
|
|
105
|
+
> & {
|
|
106
|
+
/** Extra props for each page button */
|
|
107
|
+
getItemProps?: (page: number) => Record<string, unknown>;
|
|
108
|
+
/** Extra props for each first/previous/next/last button */
|
|
109
|
+
getControlProps?: (control: NavControl) => Record<string, unknown>;
|
|
110
|
+
/** Replaces the dots between page ranges */
|
|
111
|
+
dotsIcon?: ReactNode;
|
|
112
|
+
} & Omit<ComponentPropsWithoutRef<"nav">, "onChange" | "children">
|
|
113
|
+
>;
|
|
114
|
+
|
|
115
|
+
interface ItemProps {
|
|
116
|
+
item: UsePaginationItem;
|
|
117
|
+
disabled?: boolean;
|
|
118
|
+
withLabels?: boolean;
|
|
119
|
+
dotsIcon?: ReactNode;
|
|
120
|
+
getItemProps?: PaginationProps["getItemProps"];
|
|
121
|
+
getControlProps?: PaginationProps["getControlProps"];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function PaginationItem({
|
|
125
|
+
item,
|
|
126
|
+
disabled,
|
|
127
|
+
withLabels,
|
|
128
|
+
dotsIcon,
|
|
129
|
+
getItemProps,
|
|
130
|
+
getControlProps,
|
|
131
|
+
}: ItemProps) {
|
|
132
|
+
const active = usePaginationRole("active-pages");
|
|
133
|
+
const inactive = usePaginationRole("inactive-pages");
|
|
134
|
+
const navigation = usePaginationRole("navigation-controls");
|
|
135
|
+
|
|
136
|
+
if (item.type === "start-ellipsis" || item.type === "end-ellipsis") {
|
|
137
|
+
return (
|
|
138
|
+
<div className={styles.dots} data-size={inactive.size}>
|
|
139
|
+
{dotsIcon ?? "…"}
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (item.type === "page") {
|
|
145
|
+
const role = item.selected ? active : inactive;
|
|
146
|
+
const extra = getItemProps?.(item.page as number);
|
|
147
|
+
return (
|
|
148
|
+
<Button
|
|
149
|
+
variant={role.variant}
|
|
150
|
+
size={role.size}
|
|
151
|
+
disabled={item.disabled || disabled}
|
|
152
|
+
aria-current={item.selected ? "page" : undefined}
|
|
153
|
+
aria-label={`Page ${item.page}`}
|
|
154
|
+
onClick={item.onClick}
|
|
155
|
+
{...(extra as ButtonProps)}
|
|
156
|
+
>
|
|
157
|
+
{(extra?.children as ReactNode) ?? item.page}
|
|
158
|
+
</Button>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const control = item.type as NavControl;
|
|
163
|
+
const iconElement = <PaginationIcon type={NAV_ICON[control]} />;
|
|
164
|
+
const sections =
|
|
165
|
+
withLabels && ICON_AFTER_LABEL[control]
|
|
166
|
+
? { endIcon: <span className={styles.rightIcon}>{iconElement}</span> }
|
|
167
|
+
: { icon: iconElement };
|
|
168
|
+
return (
|
|
169
|
+
<Button
|
|
170
|
+
variant={navigation.variant}
|
|
171
|
+
size={navigation.size}
|
|
172
|
+
aria-label={NAV_ARIA_LABEL[control]}
|
|
173
|
+
disabled={item.disabled || disabled}
|
|
174
|
+
onClick={item.onClick}
|
|
175
|
+
{...({ ...sections, ...getControlProps?.(control) } as ButtonProps)}
|
|
176
|
+
>
|
|
177
|
+
{withLabels ? NAV_LABEL[control] : undefined}
|
|
178
|
+
</Button>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Recursica Pagination. Its page and navigation buttons are Recursica `Button`s whose style and
|
|
184
|
+
* size come from the manifest's `ui-kit.components.pagination` selected variants. Requires the
|
|
185
|
+
* `manifest` prop on `RecursicaThemeProvider`.
|
|
186
|
+
*/
|
|
187
|
+
export const Pagination = forwardRef<HTMLElement, PaginationProps>(
|
|
188
|
+
function Pagination(
|
|
189
|
+
{
|
|
65
190
|
overStyled = false,
|
|
66
|
-
withLabels = false,
|
|
67
191
|
total,
|
|
68
192
|
withEdges,
|
|
69
|
-
withControls,
|
|
193
|
+
withControls = true,
|
|
194
|
+
withLabels,
|
|
195
|
+
page,
|
|
196
|
+
defaultPage,
|
|
197
|
+
onChange,
|
|
198
|
+
siblingCount,
|
|
199
|
+
boundaryCount,
|
|
200
|
+
disabled,
|
|
201
|
+
getItemProps,
|
|
202
|
+
getControlProps,
|
|
203
|
+
dotsIcon,
|
|
70
204
|
...rest
|
|
71
|
-
}
|
|
72
|
-
|
|
205
|
+
},
|
|
206
|
+
ref,
|
|
207
|
+
) {
|
|
208
|
+
const { items } = usePagination({
|
|
209
|
+
count: total,
|
|
210
|
+
page,
|
|
211
|
+
defaultPage,
|
|
212
|
+
onChange,
|
|
213
|
+
siblingCount,
|
|
214
|
+
boundaryCount,
|
|
215
|
+
showFirstButton: withEdges,
|
|
216
|
+
showLastButton: withEdges,
|
|
217
|
+
hidePrevButton: !withControls,
|
|
218
|
+
hideNextButton: !withControls,
|
|
219
|
+
});
|
|
73
220
|
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
74
|
-
const
|
|
75
|
-
sanitizedProps as Record<string, unknown>,
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const renderItem = (item: PaginationRenderItemParams) => {
|
|
79
|
-
if (item.type === "start-ellipsis" || item.type === "end-ellipsis") {
|
|
80
|
-
return <PaginationItem {...item} className={styles.dots} />;
|
|
81
|
-
}
|
|
82
|
-
const isNavigation = item.type !== "page";
|
|
83
|
-
// `disableRipple` is a genuine `ButtonBase` prop `PaginationItemPage` forwards
|
|
84
|
-
// at runtime, but MUI's own `PaginationItem` type declarations don't expose it
|
|
85
|
-
// (same category of MUI type-gap other components in this adapter cast around,
|
|
86
|
-
// e.g. `Card.tsx`/`Radio.tsx`'s `as unknown as MuiXProps`).
|
|
87
|
-
const itemProps: Record<string, unknown> = {
|
|
88
|
-
...item,
|
|
89
|
-
disableRipple: true,
|
|
90
|
-
className: styles.control,
|
|
91
|
-
"data-active": item.selected || undefined,
|
|
92
|
-
"data-variant": isNavigation ? "text" : undefined,
|
|
93
|
-
slots: withLabels ? labeledIconSlots : iconSlots,
|
|
94
|
-
};
|
|
95
|
-
return (
|
|
96
|
-
<PaginationItem
|
|
97
|
-
{...(itemProps as unknown as ComponentProps<typeof PaginationItem>)}
|
|
98
|
-
/>
|
|
99
|
-
);
|
|
100
|
-
};
|
|
221
|
+
const classNameProp = (sanitizedProps as { className?: string }).className;
|
|
101
222
|
|
|
102
223
|
return (
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
224
|
+
<nav
|
|
225
|
+
ref={ref}
|
|
226
|
+
aria-label="Pagination"
|
|
227
|
+
{...sanitizedProps}
|
|
228
|
+
className={
|
|
229
|
+
classNameProp ? `${styles.root} ${classNameProp}` : styles.root
|
|
230
|
+
}
|
|
231
|
+
>
|
|
232
|
+
{items.map((item, index) => (
|
|
233
|
+
<PaginationItem
|
|
234
|
+
key={index}
|
|
235
|
+
item={item}
|
|
236
|
+
disabled={disabled}
|
|
237
|
+
withLabels={withLabels}
|
|
238
|
+
dotsIcon={dotsIcon}
|
|
239
|
+
getItemProps={getItemProps}
|
|
240
|
+
getControlProps={getControlProps}
|
|
241
|
+
/>
|
|
242
|
+
))}
|
|
243
|
+
</nav>
|
|
115
244
|
);
|
|
116
245
|
},
|
|
117
246
|
);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Recursica Pagination component wrapping Mui's Pagination.
|
|
122
|
-
*/
|
|
123
|
-
export const Pagination = _Pagination;
|
|
247
|
+
Pagination.displayName = "Pagination";
|
|
@@ -19,7 +19,13 @@ import React from "react";
|
|
|
19
19
|
import { Pagination } from "@recursica/adapter-mui-v7";
|
|
20
20
|
|
|
21
21
|
export default function Demo() {
|
|
22
|
-
return
|
|
22
|
+
return (
|
|
23
|
+
<Pagination
|
|
24
|
+
total={10}
|
|
25
|
+
page={activePage}
|
|
26
|
+
onChange={(_, page) => setPage(page)}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
23
29
|
}
|
|
24
30
|
```
|
|
25
31
|
|
|
@@ -31,6 +37,7 @@ All Recursica components in the `@recursica/adapter-mui-v7` package adhere stric
|
|
|
31
37
|
|
|
32
38
|
> [!IMPORTANT]
|
|
33
39
|
>
|
|
40
|
+
> - **Requires the manifest**: Pagination reads which Button `style` and `size` to use for its pages and navigation controls from the Forge manifest, so `RecursicaThemeProvider` must be given `manifest={manifest}` (the parsed `recursica_manifest.json`). It throws without it. See [SETUP.md](../../../SETUP.md).
|
|
34
41
|
> - **Anti-override protection**: Rogues style injections (like inline `style` or arbitrary `className`) are automatically blocked by our prop layer unless `overStyled={true}` is explicitly provided.
|
|
35
42
|
> - **No Direct Layers**: Do not pass a `layer` prop to this component. To place it on a specific visual layer, wrap it in a `<Layer layer={0|1|2|3}>` component natively.
|
|
36
43
|
> - **Variables and Theming**: Styling is entirely determined by local CSS variables defined in `recursica_variables_scoped.css` and mapped in the component's CSS module.
|
|
@@ -38,13 +38,36 @@
|
|
|
38
38
|
);
|
|
39
39
|
box-shadow: var(--recursica_ui-kit_components_panel_properties_elevation);
|
|
40
40
|
min-width: var(--recursica_ui-kit_components_panel_properties_min-width);
|
|
41
|
-
|
|
41
|
+
width: var(--recursica_ui-kit_components_panel_properties_max-width);
|
|
42
|
+
max-width: 100vw;
|
|
42
43
|
|
|
43
44
|
display: flex;
|
|
44
45
|
flex-direction: column;
|
|
45
46
|
height: 100%;
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
/* Round only the edge facing the page: a panel anchored right rounds its left corners; anchored
|
|
50
|
+
left, its right corners. */
|
|
51
|
+
.contentRight {
|
|
52
|
+
border-top-right-radius: 0;
|
|
53
|
+
border-bottom-right-radius: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.contentLeft {
|
|
57
|
+
border-top-left-radius: 0;
|
|
58
|
+
border-bottom-left-radius: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.contentTop {
|
|
62
|
+
border-top-left-radius: 0;
|
|
63
|
+
border-top-right-radius: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.contentBottom {
|
|
67
|
+
border-bottom-left-radius: 0;
|
|
68
|
+
border-bottom-right-radius: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
48
71
|
/* ======================================
|
|
49
72
|
PANEL HEADER
|
|
50
73
|
====================================== */
|
|
@@ -86,7 +86,7 @@ export const Default: Story = {
|
|
|
86
86
|
},
|
|
87
87
|
render: ({ wrapHeaderText, ...args }: PanelStoryArgs) => {
|
|
88
88
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
89
|
-
const [opened, setOpened] = useState(
|
|
89
|
+
const [opened, setOpened] = useState(true);
|
|
90
90
|
|
|
91
91
|
return (
|
|
92
92
|
<>
|
|
@@ -129,7 +129,7 @@ export const LeftPlacement: Story = {
|
|
|
129
129
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
130
130
|
render: ({ withLayer, layer, ...args }: PanelStoryArgs) => {
|
|
131
131
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
132
|
-
const [opened, setOpened] = useState(
|
|
132
|
+
const [opened, setOpened] = useState(true);
|
|
133
133
|
|
|
134
134
|
return (
|
|
135
135
|
<>
|
|
@@ -162,7 +162,7 @@ export const ScrollableContent: Story = {
|
|
|
162
162
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
163
163
|
render: ({ withLayer, layer, ...args }: PanelStoryArgs) => {
|
|
164
164
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
165
|
-
const [opened, setOpened] = useState(
|
|
165
|
+
const [opened, setOpened] = useState(true);
|
|
166
166
|
|
|
167
167
|
return (
|
|
168
168
|
<>
|
|
@@ -204,7 +204,7 @@ export const LongTitle: Story = {
|
|
|
204
204
|
},
|
|
205
205
|
render: ({ ...args }: PanelStoryArgs) => {
|
|
206
206
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
207
|
-
const [opened, setOpened] = useState(
|
|
207
|
+
const [opened, setOpened] = useState(true);
|
|
208
208
|
|
|
209
209
|
return (
|
|
210
210
|
<>
|
|
@@ -119,7 +119,16 @@ const PanelBase = function Panel({
|
|
|
119
119
|
{...(sanitizedProps as unknown as MuiDrawerProps)}
|
|
120
120
|
classes={mergedClassNames as unknown as MuiDrawerProps["classes"]}
|
|
121
121
|
>
|
|
122
|
-
<div
|
|
122
|
+
<div
|
|
123
|
+
className={`${styles.content} ${
|
|
124
|
+
{
|
|
125
|
+
right: styles.contentRight,
|
|
126
|
+
left: styles.contentLeft,
|
|
127
|
+
top: styles.contentTop,
|
|
128
|
+
bottom: styles.contentBottom,
|
|
129
|
+
}[placement]
|
|
130
|
+
}`}
|
|
131
|
+
>
|
|
123
132
|
{(title || withCloseButton) && (
|
|
124
133
|
<div className={styles.header}>
|
|
125
134
|
{title && (
|