@guardian/stand 0.0.72 → 0.0.73
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/dist/AlertBanner.d.cts +2 -2
- package/dist/AlertBanner.d.ts +2 -2
- package/dist/Grid.d.cts +2 -2
- package/dist/Grid.d.ts +2 -2
- package/dist/HtmlPreviewLoader.d.cts +3 -1
- package/dist/HtmlPreviewLoader.d.ts +3 -1
- package/dist/Pagination.cjs +5 -0
- package/dist/Pagination.d.cts +5 -0
- package/dist/Pagination.d.ts +5 -0
- package/dist/Pagination.js +3 -0
- package/dist/Typography.d.cts +2 -2
- package/dist/Typography.d.ts +2 -2
- package/dist/UserMenu.d.cts +2 -1
- package/dist/UserMenu.d.ts +2 -1
- package/dist/components/AlertBanner/styles.d.cts +3 -2
- package/dist/components/AlertBanner/styles.d.ts +3 -2
- package/dist/components/Badge/types.d.cts +1 -1
- package/dist/components/Badge/types.d.ts +1 -1
- package/dist/components/Byline/lib.cjs +0 -1
- package/dist/components/Byline/lib.d.cts +0 -1
- package/dist/components/Byline/lib.d.ts +0 -1
- package/dist/components/Byline/lib.js +1 -1
- package/dist/components/HtmlPreviewLoader/styles.d.cts +3 -2
- package/dist/components/HtmlPreviewLoader/styles.d.ts +3 -2
- package/dist/components/Pagination/Pagination.cjs +97 -0
- package/dist/components/Pagination/Pagination.d.cts +5 -0
- package/dist/components/Pagination/Pagination.d.ts +5 -0
- package/dist/components/Pagination/Pagination.js +97 -0
- package/dist/components/Pagination/lib.cjs +30 -0
- package/dist/components/Pagination/lib.js +28 -0
- package/dist/components/Pagination/styles.cjs +112 -0
- package/dist/components/Pagination/styles.d.cts +8 -0
- package/dist/components/Pagination/styles.d.ts +8 -0
- package/dist/components/Pagination/styles.js +105 -0
- package/dist/components/Pagination/types.d.cts +59 -0
- package/dist/components/Pagination/types.d.ts +59 -0
- package/dist/components/UserMenu/UserMenu.d.cts +2 -3
- package/dist/components/UserMenu/UserMenu.d.ts +2 -3
- package/dist/components/UserMenu/theme.d.cts +6 -0
- package/dist/components/UserMenu/theme.d.ts +6 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/styleD/build/css/component/pagination.css +51 -0
- package/dist/styleD/build/typescript/component/pagination.cjs +72 -0
- package/dist/styleD/build/typescript/component/pagination.d.cts +75 -0
- package/dist/styleD/build/typescript/component/pagination.d.ts +75 -0
- package/dist/styleD/build/typescript/component/pagination.js +72 -0
- package/package.json +32 -17
- package/dist/styleD/build/css/component/previewFrame.css +0 -10
package/dist/AlertBanner.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentAlertBanner, componentAlertBanner } from "./styleD/build/typescript/component/alertBanner.cjs";
|
|
2
|
-
import {
|
|
2
|
+
import { PartialAlertBannerTheme } from "./components/AlertBanner/styles.cjs";
|
|
3
3
|
import { AlertBannerProps } from "./components/AlertBanner/types.cjs";
|
|
4
4
|
import { AlertBanner } from "./components/AlertBanner/AlertBanner.cjs";
|
|
5
|
-
export { AlertBanner, type AlertBannerProps, type AlertBannerTheme, type ComponentAlertBanner, componentAlertBanner };
|
|
5
|
+
export { AlertBanner, type AlertBannerProps, type PartialAlertBannerTheme as AlertBannerTheme, type ComponentAlertBanner, componentAlertBanner };
|
package/dist/AlertBanner.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentAlertBanner, componentAlertBanner } from "./styleD/build/typescript/component/alertBanner.js";
|
|
2
|
-
import {
|
|
2
|
+
import { PartialAlertBannerTheme } from "./components/AlertBanner/styles.js";
|
|
3
3
|
import { AlertBannerProps } from "./components/AlertBanner/types.js";
|
|
4
4
|
import { AlertBanner } from "./components/AlertBanner/AlertBanner.js";
|
|
5
|
-
export { AlertBanner, type AlertBannerProps, type AlertBannerTheme, type ComponentAlertBanner, componentAlertBanner };
|
|
5
|
+
export { AlertBanner, type AlertBannerProps, type PartialAlertBannerTheme as AlertBannerTheme, type ComponentAlertBanner, componentAlertBanner };
|
package/dist/Grid.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentGrid, componentGrid } from "./styleD/build/typescript/component/grid.cjs";
|
|
2
2
|
import { PartialGridTheme } from "./components/Grid/styles.cjs";
|
|
3
|
-
import { GridProps, ItemProps } from "./components/Grid/types.cjs";
|
|
3
|
+
import { GridOffsetValue, GridProps, GridSizeValue, ItemProps, ResponsiveGridValue } from "./components/Grid/types.cjs";
|
|
4
4
|
import { Grid, Item } from "./components/Grid/Grid.cjs";
|
|
5
|
-
export { type ComponentGrid, Grid, type GridProps, type PartialGridTheme as GridTheme, Item, type ItemProps, componentGrid };
|
|
5
|
+
export { type ComponentGrid, Grid, type GridOffsetValue, type GridProps, type GridSizeValue, type PartialGridTheme as GridTheme, Item, type ItemProps, type ResponsiveGridValue, componentGrid };
|
package/dist/Grid.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentGrid, componentGrid } from "./styleD/build/typescript/component/grid.js";
|
|
2
2
|
import { PartialGridTheme } from "./components/Grid/styles.js";
|
|
3
|
-
import { GridProps, ItemProps } from "./components/Grid/types.js";
|
|
3
|
+
import { GridOffsetValue, GridProps, GridSizeValue, ItemProps, ResponsiveGridValue } from "./components/Grid/types.js";
|
|
4
4
|
import { Grid, Item } from "./components/Grid/Grid.js";
|
|
5
|
-
export { type ComponentGrid, Grid, type GridProps, type PartialGridTheme as GridTheme, Item, type ItemProps, componentGrid };
|
|
5
|
+
export { type ComponentGrid, Grid, type GridOffsetValue, type GridProps, type GridSizeValue, type PartialGridTheme as GridTheme, Item, type ItemProps, type ResponsiveGridValue, componentGrid };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ComponentHtmlPreviewLoader, componentHtmlPreviewLoader } from "./styleD/build/typescript/component/htmlPreviewLoader.cjs";
|
|
2
|
+
import { PartialHtmlPreviewLoaderTheme } from "./components/HtmlPreviewLoader/styles.cjs";
|
|
3
|
+
import { HtmlPreviewLoaderProps, HtmlPreviewProps } from "./components/HtmlPreviewLoader/types.cjs";
|
|
2
4
|
import { HtmlPreviewLoader } from "./components/HtmlPreviewLoader/HtmlPreviewLoader.cjs";
|
|
3
5
|
import { HtmlPreview } from "./components/HtmlPreviewLoader/HtmlPreview.cjs";
|
|
4
|
-
export { type ComponentHtmlPreviewLoader, HtmlPreview, HtmlPreviewLoader, componentHtmlPreviewLoader };
|
|
6
|
+
export { type ComponentHtmlPreviewLoader, HtmlPreview, HtmlPreviewLoader, type HtmlPreviewLoaderProps, type PartialHtmlPreviewLoaderTheme as HtmlPreviewLoaderTheme, type HtmlPreviewProps, componentHtmlPreviewLoader };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ComponentHtmlPreviewLoader, componentHtmlPreviewLoader } from "./styleD/build/typescript/component/htmlPreviewLoader.js";
|
|
2
|
+
import { PartialHtmlPreviewLoaderTheme } from "./components/HtmlPreviewLoader/styles.js";
|
|
3
|
+
import { HtmlPreviewLoaderProps, HtmlPreviewProps } from "./components/HtmlPreviewLoader/types.js";
|
|
2
4
|
import { HtmlPreviewLoader } from "./components/HtmlPreviewLoader/HtmlPreviewLoader.js";
|
|
3
5
|
import { HtmlPreview } from "./components/HtmlPreviewLoader/HtmlPreview.js";
|
|
4
|
-
export { type ComponentHtmlPreviewLoader, HtmlPreview, HtmlPreviewLoader, componentHtmlPreviewLoader };
|
|
6
|
+
export { type ComponentHtmlPreviewLoader, HtmlPreview, HtmlPreviewLoader, type HtmlPreviewLoaderProps, type PartialHtmlPreviewLoaderTheme as HtmlPreviewLoaderTheme, type HtmlPreviewProps, componentHtmlPreviewLoader };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_pagination = require("./styleD/build/typescript/component/pagination.cjs");
|
|
3
|
+
const require_Pagination = require("./components/Pagination/Pagination.cjs");
|
|
4
|
+
exports.Pagination = require_Pagination.Pagination;
|
|
5
|
+
exports.componentPagination = require_pagination.componentPagination;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentPagination, componentPagination } from "./styleD/build/typescript/component/pagination.cjs";
|
|
2
|
+
import { PartialPaginationTheme } from "./components/Pagination/styles.cjs";
|
|
3
|
+
import { PaginationLabels, PaginationProps, PaginationSummaryInfo } from "./components/Pagination/types.cjs";
|
|
4
|
+
import { Pagination } from "./components/Pagination/Pagination.cjs";
|
|
5
|
+
export { type ComponentPagination, Pagination, type PaginationLabels, type PaginationProps, type PaginationSummaryInfo, type PartialPaginationTheme as PaginationTheme, componentPagination };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentPagination, componentPagination } from "./styleD/build/typescript/component/pagination.js";
|
|
2
|
+
import { PartialPaginationTheme } from "./components/Pagination/styles.js";
|
|
3
|
+
import { PaginationLabels, PaginationProps, PaginationSummaryInfo } from "./components/Pagination/types.js";
|
|
4
|
+
import { Pagination } from "./components/Pagination/Pagination.js";
|
|
5
|
+
export { type ComponentPagination, Pagination, type PaginationLabels, type PaginationProps, type PaginationSummaryInfo, type PartialPaginationTheme as PaginationTheme, componentPagination };
|
package/dist/Typography.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentTypography, componentTypography } from "./styleD/build/typescript/component/typography.cjs";
|
|
2
2
|
import { PartialTypographyTheme } from "./components/Typography/styles.cjs";
|
|
3
|
-
import { TypographyProps } from "./components/Typography/types.cjs";
|
|
3
|
+
import { TypographyElement, TypographyProps, TypographyVariant } from "./components/Typography/types.cjs";
|
|
4
4
|
import { Typography } from "./components/Typography/Typography.cjs";
|
|
5
|
-
export { type ComponentTypography, Typography, type TypographyProps, type PartialTypographyTheme as TypographyTheme, componentTypography };
|
|
5
|
+
export { type ComponentTypography, Typography, type TypographyElement, type TypographyProps, type PartialTypographyTheme as TypographyTheme, type TypographyVariant, componentTypography };
|
package/dist/Typography.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentTypography, componentTypography } from "./styleD/build/typescript/component/typography.js";
|
|
2
2
|
import { PartialTypographyTheme } from "./components/Typography/styles.js";
|
|
3
|
-
import { TypographyProps } from "./components/Typography/types.js";
|
|
3
|
+
import { TypographyElement, TypographyProps, TypographyVariant } from "./components/Typography/types.js";
|
|
4
4
|
import { Typography } from "./components/Typography/Typography.js";
|
|
5
|
-
export { type ComponentTypography, Typography, type TypographyProps, type PartialTypographyTheme as TypographyTheme, componentTypography };
|
|
5
|
+
export { type ComponentTypography, Typography, type TypographyElement, type TypographyProps, type PartialTypographyTheme as TypographyTheme, type TypographyVariant, componentTypography };
|
package/dist/UserMenu.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ComponentUserMenu, componentUserMenu } from "./styleD/build/typescript/component/userMenu.cjs";
|
|
2
|
+
import { PartialUserMenuTheme } from "./components/UserMenu/theme.cjs";
|
|
2
3
|
import { UserMenu } from "./components/UserMenu/UserMenu.cjs";
|
|
3
|
-
export { type ComponentUserMenu, UserMenu, componentUserMenu };
|
|
4
|
+
export { type ComponentUserMenu, UserMenu, type PartialUserMenuTheme as UserMenuTheme, componentUserMenu };
|
package/dist/UserMenu.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ComponentUserMenu, componentUserMenu } from "./styleD/build/typescript/component/userMenu.js";
|
|
2
|
+
import { PartialUserMenuTheme } from "./components/UserMenu/theme.js";
|
|
2
3
|
import { UserMenu } from "./components/UserMenu/UserMenu.js";
|
|
3
|
-
export { type ComponentUserMenu, UserMenu, componentUserMenu };
|
|
4
|
+
export { type ComponentUserMenu, UserMenu, type PartialUserMenuTheme as UserMenuTheme, componentUserMenu };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Prettify } from "../../util/types.cjs";
|
|
1
|
+
import { DeepPartial, Prettify } from "../../util/types.cjs";
|
|
2
2
|
import { ComponentAlertBanner } from "../../styleD/build/typescript/component/alertBanner.cjs";
|
|
3
3
|
import "./types.cjs";
|
|
4
4
|
import { SerializedStyles } from "@emotion/react";
|
|
5
5
|
//#region src/components/AlertBanner/styles.d.ts
|
|
6
6
|
type AlertBannerTheme = Prettify<ComponentAlertBanner>;
|
|
7
|
+
type PartialAlertBannerTheme = Prettify<DeepPartial<AlertBannerTheme>>;
|
|
7
8
|
//#endregion
|
|
8
|
-
export { AlertBannerTheme };
|
|
9
|
+
export { AlertBannerTheme, PartialAlertBannerTheme };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Prettify } from "../../util/types.js";
|
|
1
|
+
import { DeepPartial, Prettify } from "../../util/types.js";
|
|
2
2
|
import { ComponentAlertBanner } from "../../styleD/build/typescript/component/alertBanner.js";
|
|
3
3
|
import "./types.js";
|
|
4
4
|
import { SerializedStyles } from "@emotion/react";
|
|
5
5
|
//#region src/components/AlertBanner/styles.d.ts
|
|
6
6
|
type AlertBannerTheme = Prettify<ComponentAlertBanner>;
|
|
7
|
+
type PartialAlertBannerTheme = Prettify<DeepPartial<AlertBannerTheme>>;
|
|
7
8
|
//#endregion
|
|
8
|
-
export { AlertBannerTheme };
|
|
9
|
+
export { AlertBannerTheme, PartialAlertBannerTheme };
|
|
@@ -168,4 +168,4 @@ const convertNodeToBylineModel = (doc) => {
|
|
|
168
168
|
return model;
|
|
169
169
|
};
|
|
170
170
|
//#endregion
|
|
171
|
-
export { addTaggedContributor, addUntaggedContributor, convertBylineModelToNode, convertNodeToBylineModel, detectNameInText, getCurrentText, hasHitContributorLimit
|
|
171
|
+
export { addTaggedContributor, addUntaggedContributor, convertBylineModelToNode, convertNodeToBylineModel, detectNameInText, getCurrentText, hasHitContributorLimit };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Prettify } from "../../util/types.cjs";
|
|
1
|
+
import { DeepPartial, Prettify } from "../../util/types.cjs";
|
|
2
2
|
import { ComponentHtmlPreviewLoader } from "../../styleD/build/typescript/component/htmlPreviewLoader.cjs";
|
|
3
3
|
import { SerializedStyles } from "@emotion/react";
|
|
4
4
|
//#region src/components/HtmlPreviewLoader/styles.d.ts
|
|
5
5
|
type HtmlPreviewLoaderTheme = Prettify<ComponentHtmlPreviewLoader>;
|
|
6
|
+
type PartialHtmlPreviewLoaderTheme = Prettify<DeepPartial<HtmlPreviewLoaderTheme>>;
|
|
6
7
|
//#endregion
|
|
7
|
-
export { HtmlPreviewLoaderTheme };
|
|
8
|
+
export { HtmlPreviewLoaderTheme, PartialHtmlPreviewLoaderTheme };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Prettify } from "../../util/types.js";
|
|
1
|
+
import { DeepPartial, Prettify } from "../../util/types.js";
|
|
2
2
|
import { ComponentHtmlPreviewLoader } from "../../styleD/build/typescript/component/htmlPreviewLoader.js";
|
|
3
3
|
import { SerializedStyles } from "@emotion/react";
|
|
4
4
|
//#region src/components/HtmlPreviewLoader/styles.d.ts
|
|
5
5
|
type HtmlPreviewLoaderTheme = Prettify<ComponentHtmlPreviewLoader>;
|
|
6
|
+
type PartialHtmlPreviewLoaderTheme = Prettify<DeepPartial<HtmlPreviewLoaderTheme>>;
|
|
6
7
|
//#endregion
|
|
7
|
-
export { HtmlPreviewLoaderTheme };
|
|
8
|
+
export { HtmlPreviewLoaderTheme, PartialHtmlPreviewLoaderTheme };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const require_mergeDeep = require("../../util/mergeDeep.cjs");
|
|
2
|
+
const require_IconButton = require("../IconButton/IconButton.cjs");
|
|
3
|
+
const require_lib = require("./lib.cjs");
|
|
4
|
+
const require_styles = require("./styles.cjs");
|
|
5
|
+
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
6
|
+
let react_aria_components = require("react-aria-components");
|
|
7
|
+
//#region src/components/Pagination/Pagination.tsx
|
|
8
|
+
const defaultLabels = {
|
|
9
|
+
nav: "Pagination",
|
|
10
|
+
previous: "Go to previous page",
|
|
11
|
+
next: "Go to next page",
|
|
12
|
+
page: (page) => `Go to page ${page}`,
|
|
13
|
+
status: (currentPage, totalPages) => `Page ${currentPage} of ${totalPages}`
|
|
14
|
+
};
|
|
15
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
16
|
+
const Pagination = ({ currentPage, totalItems, pageSize, onPageChange, siblingCount = 1, boundaryCount = 1, showSummary = true, renderSummary, collapseBelow = "md", labels, theme, cssOverrides, className }) => {
|
|
17
|
+
const mergedTheme = require_mergeDeep.mergeDeep(require_styles.defaultPaginationTheme, theme ?? {});
|
|
18
|
+
const mergedLabels = {
|
|
19
|
+
...defaultLabels,
|
|
20
|
+
...labels
|
|
21
|
+
};
|
|
22
|
+
const safePageSize = Math.max(1, pageSize);
|
|
23
|
+
const totalPages = require_lib.getTotalPages(totalItems, safePageSize);
|
|
24
|
+
const page = clamp(currentPage, 1, totalPages);
|
|
25
|
+
const items = require_lib.getPageRange({
|
|
26
|
+
currentPage: page,
|
|
27
|
+
totalPages,
|
|
28
|
+
siblingCount,
|
|
29
|
+
boundaryCount
|
|
30
|
+
});
|
|
31
|
+
const goTo = (next) => onPageChange(clamp(next, 1, totalPages));
|
|
32
|
+
const startItem = totalItems === 0 ? 0 : (page - 1) * safePageSize + 1;
|
|
33
|
+
const endItem = Math.min(page * safePageSize, totalItems);
|
|
34
|
+
const summary = renderSummary ? renderSummary({
|
|
35
|
+
currentPage: page,
|
|
36
|
+
totalPages,
|
|
37
|
+
totalItems,
|
|
38
|
+
pageSize: safePageSize,
|
|
39
|
+
startItem,
|
|
40
|
+
endItem
|
|
41
|
+
}) : `Results: ${startItem}\u2013${endItem} of ${totalItems}`;
|
|
42
|
+
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("nav", {
|
|
43
|
+
"aria-label": mergedLabels.nav,
|
|
44
|
+
className,
|
|
45
|
+
css: [require_styles.paginationStyles(mergedTheme), cssOverrides],
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_IconButton.IconButton, {
|
|
48
|
+
variant: "secondary",
|
|
49
|
+
size: "xs",
|
|
50
|
+
symbol: "chevron_left",
|
|
51
|
+
ariaLabel: mergedLabels.previous,
|
|
52
|
+
isDisabled: page <= 1,
|
|
53
|
+
onPress: () => goTo(page - 1),
|
|
54
|
+
cssOverrides: require_styles.arrowStyles(mergedTheme)
|
|
55
|
+
}),
|
|
56
|
+
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("ul", {
|
|
57
|
+
css: require_styles.listStyles(mergedTheme, collapseBelow),
|
|
58
|
+
children: items.map((item, index) => {
|
|
59
|
+
if (item === "ellipsis") return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("li", {
|
|
60
|
+
"aria-hidden": "true",
|
|
61
|
+
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
|
|
62
|
+
css: require_styles.ellipsisStyles(mergedTheme),
|
|
63
|
+
children: "…"
|
|
64
|
+
})
|
|
65
|
+
}, `ellipsis-${index}`);
|
|
66
|
+
const isCurrent = item === page;
|
|
67
|
+
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Button, {
|
|
68
|
+
"aria-label": mergedLabels.page(item),
|
|
69
|
+
"aria-current": isCurrent ? "page" : void 0,
|
|
70
|
+
onPress: () => !isCurrent && goTo(item),
|
|
71
|
+
css: require_styles.itemStyles(mergedTheme, isCurrent),
|
|
72
|
+
children: item
|
|
73
|
+
}) }, item);
|
|
74
|
+
})
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
|
|
77
|
+
css: require_styles.compactStatusStyles(mergedTheme, collapseBelow),
|
|
78
|
+
children: mergedLabels.status(page, totalPages)
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_IconButton.IconButton, {
|
|
81
|
+
variant: "secondary",
|
|
82
|
+
size: "xs",
|
|
83
|
+
symbol: "chevron_right",
|
|
84
|
+
ariaLabel: mergedLabels.next,
|
|
85
|
+
isDisabled: page >= totalPages,
|
|
86
|
+
onPress: () => goTo(page + 1),
|
|
87
|
+
cssOverrides: require_styles.arrowStyles(mergedTheme)
|
|
88
|
+
}),
|
|
89
|
+
showSummary && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
|
|
90
|
+
css: require_styles.summaryStyles(mergedTheme, collapseBelow),
|
|
91
|
+
children: summary
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
exports.Pagination = Pagination;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PaginationProps } from "./types.cjs";
|
|
2
|
+
//#region src/components/Pagination/Pagination.d.ts
|
|
3
|
+
declare const Pagination: ({ currentPage, totalItems, pageSize, onPageChange, siblingCount, boundaryCount, showSummary, renderSummary, collapseBelow, labels, theme, cssOverrides, className }: PaginationProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { Pagination };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PaginationProps } from "./types.js";
|
|
2
|
+
//#region src/components/Pagination/Pagination.d.ts
|
|
3
|
+
declare const Pagination: ({ currentPage, totalItems, pageSize, onPageChange, siblingCount, boundaryCount, showSummary, renderSummary, collapseBelow, labels, theme, cssOverrides, className }: PaginationProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { Pagination };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { mergeDeep } from "../../util/mergeDeep.js";
|
|
2
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
3
|
+
import { getPageRange, getTotalPages } from "./lib.js";
|
|
4
|
+
import { arrowStyles, compactStatusStyles, defaultPaginationTheme, ellipsisStyles, itemStyles, listStyles, paginationStyles, summaryStyles } from "./styles.js";
|
|
5
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
6
|
+
import { Button } from "react-aria-components";
|
|
7
|
+
//#region src/components/Pagination/Pagination.tsx
|
|
8
|
+
const defaultLabels = {
|
|
9
|
+
nav: "Pagination",
|
|
10
|
+
previous: "Go to previous page",
|
|
11
|
+
next: "Go to next page",
|
|
12
|
+
page: (page) => `Go to page ${page}`,
|
|
13
|
+
status: (currentPage, totalPages) => `Page ${currentPage} of ${totalPages}`
|
|
14
|
+
};
|
|
15
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
16
|
+
const Pagination = ({ currentPage, totalItems, pageSize, onPageChange, siblingCount = 1, boundaryCount = 1, showSummary = true, renderSummary, collapseBelow = "md", labels, theme, cssOverrides, className }) => {
|
|
17
|
+
const mergedTheme = mergeDeep(defaultPaginationTheme, theme ?? {});
|
|
18
|
+
const mergedLabels = {
|
|
19
|
+
...defaultLabels,
|
|
20
|
+
...labels
|
|
21
|
+
};
|
|
22
|
+
const safePageSize = Math.max(1, pageSize);
|
|
23
|
+
const totalPages = getTotalPages(totalItems, safePageSize);
|
|
24
|
+
const page = clamp(currentPage, 1, totalPages);
|
|
25
|
+
const items = getPageRange({
|
|
26
|
+
currentPage: page,
|
|
27
|
+
totalPages,
|
|
28
|
+
siblingCount,
|
|
29
|
+
boundaryCount
|
|
30
|
+
});
|
|
31
|
+
const goTo = (next) => onPageChange(clamp(next, 1, totalPages));
|
|
32
|
+
const startItem = totalItems === 0 ? 0 : (page - 1) * safePageSize + 1;
|
|
33
|
+
const endItem = Math.min(page * safePageSize, totalItems);
|
|
34
|
+
const summary = renderSummary ? renderSummary({
|
|
35
|
+
currentPage: page,
|
|
36
|
+
totalPages,
|
|
37
|
+
totalItems,
|
|
38
|
+
pageSize: safePageSize,
|
|
39
|
+
startItem,
|
|
40
|
+
endItem
|
|
41
|
+
}) : `Results: ${startItem}\u2013${endItem} of ${totalItems}`;
|
|
42
|
+
return /* @__PURE__ */ jsxs("nav", {
|
|
43
|
+
"aria-label": mergedLabels.nav,
|
|
44
|
+
className,
|
|
45
|
+
css: [paginationStyles(mergedTheme), cssOverrides],
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
48
|
+
variant: "secondary",
|
|
49
|
+
size: "xs",
|
|
50
|
+
symbol: "chevron_left",
|
|
51
|
+
ariaLabel: mergedLabels.previous,
|
|
52
|
+
isDisabled: page <= 1,
|
|
53
|
+
onPress: () => goTo(page - 1),
|
|
54
|
+
cssOverrides: arrowStyles(mergedTheme)
|
|
55
|
+
}),
|
|
56
|
+
/* @__PURE__ */ jsx("ul", {
|
|
57
|
+
css: listStyles(mergedTheme, collapseBelow),
|
|
58
|
+
children: items.map((item, index) => {
|
|
59
|
+
if (item === "ellipsis") return /* @__PURE__ */ jsx("li", {
|
|
60
|
+
"aria-hidden": "true",
|
|
61
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
62
|
+
css: ellipsisStyles(mergedTheme),
|
|
63
|
+
children: "…"
|
|
64
|
+
})
|
|
65
|
+
}, `ellipsis-${index}`);
|
|
66
|
+
const isCurrent = item === page;
|
|
67
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Button, {
|
|
68
|
+
"aria-label": mergedLabels.page(item),
|
|
69
|
+
"aria-current": isCurrent ? "page" : void 0,
|
|
70
|
+
onPress: () => !isCurrent && goTo(item),
|
|
71
|
+
css: itemStyles(mergedTheme, isCurrent),
|
|
72
|
+
children: item
|
|
73
|
+
}) }, item);
|
|
74
|
+
})
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ jsx("span", {
|
|
77
|
+
css: compactStatusStyles(mergedTheme, collapseBelow),
|
|
78
|
+
children: mergedLabels.status(page, totalPages)
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
81
|
+
variant: "secondary",
|
|
82
|
+
size: "xs",
|
|
83
|
+
symbol: "chevron_right",
|
|
84
|
+
ariaLabel: mergedLabels.next,
|
|
85
|
+
isDisabled: page >= totalPages,
|
|
86
|
+
onPress: () => goTo(page + 1),
|
|
87
|
+
cssOverrides: arrowStyles(mergedTheme)
|
|
88
|
+
}),
|
|
89
|
+
showSummary && /* @__PURE__ */ jsx("span", {
|
|
90
|
+
css: summaryStyles(mergedTheme, collapseBelow),
|
|
91
|
+
children: summary
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { Pagination };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/components/Pagination/lib.ts
|
|
2
|
+
const ELLIPSIS = "ellipsis";
|
|
3
|
+
const range = (start, end) => Array.from({ length: Math.max(0, end - start + 1) }, (_, i) => start + i);
|
|
4
|
+
/** Derive the total number of pages from a total item count and page size. */
|
|
5
|
+
const getTotalPages = (totalItems, pageSize) => Math.max(1, Math.ceil(Math.max(0, totalItems) / Math.max(1, pageSize)));
|
|
6
|
+
/**
|
|
7
|
+
* Build the list of page numbers and ellipsis markers to render, keeping the
|
|
8
|
+
* first/last boundary pages and a window of siblings around the current page.
|
|
9
|
+
*/
|
|
10
|
+
const getPageRange = ({ currentPage, totalPages, siblingCount = 1, boundaryCount = 1 }) => {
|
|
11
|
+
if (totalPages <= 1) return range(1, totalPages);
|
|
12
|
+
if (siblingCount * 2 + 3 + boundaryCount * 2 >= totalPages) return range(1, totalPages);
|
|
13
|
+
const startPages = range(1, boundaryCount);
|
|
14
|
+
const endPages = range(totalPages - boundaryCount + 1, totalPages);
|
|
15
|
+
const siblingsStart = Math.max(Math.min(currentPage - siblingCount, totalPages - boundaryCount - siblingCount * 2 - 1), boundaryCount + 2);
|
|
16
|
+
const siblingsEnd = Math.min(Math.max(currentPage + siblingCount, boundaryCount + siblingCount * 2 + 2), endPages.length > 0 ? endPages[0] - 2 : totalPages - 1);
|
|
17
|
+
const startEllipsis = siblingsStart > boundaryCount + 2 ? [ELLIPSIS] : boundaryCount + 1 < totalPages - boundaryCount ? [boundaryCount + 1] : [];
|
|
18
|
+
const endEllipsis = siblingsEnd < totalPages - boundaryCount - 1 ? [ELLIPSIS] : totalPages - boundaryCount > boundaryCount ? [totalPages - boundaryCount] : [];
|
|
19
|
+
return [
|
|
20
|
+
...startPages,
|
|
21
|
+
...startEllipsis,
|
|
22
|
+
...range(siblingsStart, siblingsEnd),
|
|
23
|
+
...endEllipsis,
|
|
24
|
+
...endPages
|
|
25
|
+
];
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.ELLIPSIS = ELLIPSIS;
|
|
29
|
+
exports.getPageRange = getPageRange;
|
|
30
|
+
exports.getTotalPages = getTotalPages;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/components/Pagination/lib.ts
|
|
2
|
+
const ELLIPSIS = "ellipsis";
|
|
3
|
+
const range = (start, end) => Array.from({ length: Math.max(0, end - start + 1) }, (_, i) => start + i);
|
|
4
|
+
/** Derive the total number of pages from a total item count and page size. */
|
|
5
|
+
const getTotalPages = (totalItems, pageSize) => Math.max(1, Math.ceil(Math.max(0, totalItems) / Math.max(1, pageSize)));
|
|
6
|
+
/**
|
|
7
|
+
* Build the list of page numbers and ellipsis markers to render, keeping the
|
|
8
|
+
* first/last boundary pages and a window of siblings around the current page.
|
|
9
|
+
*/
|
|
10
|
+
const getPageRange = ({ currentPage, totalPages, siblingCount = 1, boundaryCount = 1 }) => {
|
|
11
|
+
if (totalPages <= 1) return range(1, totalPages);
|
|
12
|
+
if (siblingCount * 2 + 3 + boundaryCount * 2 >= totalPages) return range(1, totalPages);
|
|
13
|
+
const startPages = range(1, boundaryCount);
|
|
14
|
+
const endPages = range(totalPages - boundaryCount + 1, totalPages);
|
|
15
|
+
const siblingsStart = Math.max(Math.min(currentPage - siblingCount, totalPages - boundaryCount - siblingCount * 2 - 1), boundaryCount + 2);
|
|
16
|
+
const siblingsEnd = Math.min(Math.max(currentPage + siblingCount, boundaryCount + siblingCount * 2 + 2), endPages.length > 0 ? endPages[0] - 2 : totalPages - 1);
|
|
17
|
+
const startEllipsis = siblingsStart > boundaryCount + 2 ? [ELLIPSIS] : boundaryCount + 1 < totalPages - boundaryCount ? [boundaryCount + 1] : [];
|
|
18
|
+
const endEllipsis = siblingsEnd < totalPages - boundaryCount - 1 ? [ELLIPSIS] : totalPages - boundaryCount > boundaryCount ? [totalPages - boundaryCount] : [];
|
|
19
|
+
return [
|
|
20
|
+
...startPages,
|
|
21
|
+
...startEllipsis,
|
|
22
|
+
...range(siblingsStart, siblingsEnd),
|
|
23
|
+
...endEllipsis,
|
|
24
|
+
...endPages
|
|
25
|
+
];
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ELLIPSIS, getPageRange, getTotalPages };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const require_typography = require("../../styleD/utils/semantic/typography.cjs");
|
|
2
|
+
const require_mq = require("../../styleD/utils/semantic/mq.cjs");
|
|
3
|
+
const require_pagination = require("../../styleD/build/typescript/component/pagination.cjs");
|
|
4
|
+
let _emotion_react = require("@emotion/react");
|
|
5
|
+
//#region src/components/Pagination/styles.ts
|
|
6
|
+
const defaultPaginationTheme = require_pagination.componentPagination;
|
|
7
|
+
const paginationStyles = (theme) => _emotion_react.css`
|
|
8
|
+
display: ${theme.shared.display};
|
|
9
|
+
align-items: ${theme.shared.alignItems};
|
|
10
|
+
gap: ${theme.shared.gap};
|
|
11
|
+
`;
|
|
12
|
+
const listStyles = (theme, collapseBelow) => _emotion_react.css`
|
|
13
|
+
display: ${theme.shared.display};
|
|
14
|
+
align-items: ${theme.shared.alignItems};
|
|
15
|
+
gap: ${theme.shared.gap};
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
list-style: none;
|
|
19
|
+
|
|
20
|
+
${require_mq.until[collapseBelow]} {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
const itemStyles = (theme, isCurrent) => {
|
|
25
|
+
const item = theme.item;
|
|
26
|
+
const typography = isCurrent ? item.current.typography : item.typography;
|
|
27
|
+
return _emotion_react.css`
|
|
28
|
+
display: inline-flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
min-width: ${item.minWidth};
|
|
33
|
+
height: ${item.height};
|
|
34
|
+
padding: ${item.paddingY} ${item.paddingX};
|
|
35
|
+
border-radius: ${item.borderRadius};
|
|
36
|
+
border: ${item.borderWidth} ${item.borderStyle}
|
|
37
|
+
${isCurrent ? item.current.borderColor : item.borderColor};
|
|
38
|
+
background-color: ${isCurrent ? item.current.backgroundColor : item.backgroundColor};
|
|
39
|
+
color: ${isCurrent ? item.current.color : item.color};
|
|
40
|
+
cursor: ${isCurrent ? "default" : item.cursor};
|
|
41
|
+
${require_typography.convertTypographyToEmotionStringStyle(typography)}
|
|
42
|
+
|
|
43
|
+
&[data-hovered]:not([aria-current='page']) {
|
|
44
|
+
background-color: ${item.hover.backgroundColor};
|
|
45
|
+
border-color: ${item.hover.borderColor};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&[data-pressed]:not([aria-current='page']) {
|
|
49
|
+
background-color: ${item.active.backgroundColor};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&[data-focus-visible] {
|
|
53
|
+
outline: ${item.focusVisible.outlineWidth} solid
|
|
54
|
+
${item.focusVisible.outlineColor};
|
|
55
|
+
outline-offset: ${item.focusVisible.outlineOffset};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&[data-disabled] {
|
|
59
|
+
color: ${item.disabled.color};
|
|
60
|
+
background-color: ${item.disabled.backgroundColor};
|
|
61
|
+
border-color: ${item.disabled.borderColor};
|
|
62
|
+
cursor: ${item.disabled.cursor};
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
};
|
|
66
|
+
const ellipsisStyles = (theme) => _emotion_react.css`
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
width: ${theme.ellipsis.minWidth};
|
|
72
|
+
min-width: ${theme.ellipsis.minWidth};
|
|
73
|
+
height: ${theme.item.height};
|
|
74
|
+
color: ${theme.ellipsis.color};
|
|
75
|
+
`;
|
|
76
|
+
const arrowStyles = (theme) => _emotion_react.css`
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
width: ${theme.item.height};
|
|
79
|
+
min-width: ${theme.item.height};
|
|
80
|
+
height: ${theme.item.height};
|
|
81
|
+
`;
|
|
82
|
+
const summaryStyles = (theme, collapseBelow) => _emotion_react.css`
|
|
83
|
+
margin-left: ${theme.summary.marginLeft};
|
|
84
|
+
color: ${theme.summary.color};
|
|
85
|
+
white-space: nowrap;
|
|
86
|
+
${require_typography.convertTypographyToEmotionStringStyle(theme.summary.typography)}
|
|
87
|
+
|
|
88
|
+
${require_mq.until[collapseBelow]} {
|
|
89
|
+
display: none;
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
92
|
+
const compactStatusStyles = (theme, collapseBelow) => _emotion_react.css`
|
|
93
|
+
display: none;
|
|
94
|
+
flex: 1;
|
|
95
|
+
text-align: center;
|
|
96
|
+
white-space: nowrap;
|
|
97
|
+
color: ${theme.summary.color};
|
|
98
|
+
${require_typography.convertTypographyToEmotionStringStyle(theme.summary.typography)}
|
|
99
|
+
|
|
100
|
+
${require_mq.until[collapseBelow]} {
|
|
101
|
+
display: block;
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
//#endregion
|
|
105
|
+
exports.arrowStyles = arrowStyles;
|
|
106
|
+
exports.compactStatusStyles = compactStatusStyles;
|
|
107
|
+
exports.defaultPaginationTheme = defaultPaginationTheme;
|
|
108
|
+
exports.ellipsisStyles = ellipsisStyles;
|
|
109
|
+
exports.itemStyles = itemStyles;
|
|
110
|
+
exports.listStyles = listStyles;
|
|
111
|
+
exports.paginationStyles = paginationStyles;
|
|
112
|
+
exports.summaryStyles = summaryStyles;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DeepPartial, Prettify } from "../../util/types.cjs";
|
|
2
|
+
import { ComponentPagination } from "../../styleD/build/typescript/component/pagination.cjs";
|
|
3
|
+
import { SerializedStyles } from "@emotion/react";
|
|
4
|
+
//#region src/components/Pagination/styles.d.ts
|
|
5
|
+
type PaginationTheme = Prettify<ComponentPagination>;
|
|
6
|
+
type PartialPaginationTheme = Prettify<DeepPartial<PaginationTheme>>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { PaginationTheme, PartialPaginationTheme };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DeepPartial, Prettify } from "../../util/types.js";
|
|
2
|
+
import { ComponentPagination } from "../../styleD/build/typescript/component/pagination.js";
|
|
3
|
+
import { SerializedStyles } from "@emotion/react";
|
|
4
|
+
//#region src/components/Pagination/styles.d.ts
|
|
5
|
+
type PaginationTheme = Prettify<ComponentPagination>;
|
|
6
|
+
type PartialPaginationTheme = Prettify<DeepPartial<PaginationTheme>>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { PaginationTheme, PartialPaginationTheme };
|