@spscommerce/ds-react 6.32.2 → 6.33.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/lib/index.es.js
CHANGED
|
@@ -31171,14 +31171,16 @@ const propsDoc$E = {
|
|
|
31171
31171
|
numPages: "number",
|
|
31172
31172
|
onPageChange: "(number) => void",
|
|
31173
31173
|
disabled: "boolean",
|
|
31174
|
-
unknownPageCount: "boolean"
|
|
31174
|
+
unknownPageCount: "boolean",
|
|
31175
|
+
nextPageBtnDisabled: "boolean"
|
|
31175
31176
|
};
|
|
31176
31177
|
const propTypes$E = __spreadValues({
|
|
31177
31178
|
numPages: propTypes$1I.exports.number,
|
|
31178
31179
|
onPageChange: fun(),
|
|
31179
31180
|
page: propTypes$1I.exports.number,
|
|
31180
31181
|
disabled: propTypes$1I.exports.bool,
|
|
31181
|
-
unknownPageCount: propTypes$1I.exports.bool
|
|
31182
|
+
unknownPageCount: propTypes$1I.exports.bool,
|
|
31183
|
+
nextPageBtnDisabled: propTypes$1I.exports.bool
|
|
31182
31184
|
}, spsGlobalPropTypes);
|
|
31183
31185
|
function SpsPageSelector(props2) {
|
|
31184
31186
|
const _a = props2, {
|
|
@@ -31189,7 +31191,8 @@ function SpsPageSelector(props2) {
|
|
|
31189
31191
|
className,
|
|
31190
31192
|
"data-testid": testId,
|
|
31191
31193
|
disabled = false,
|
|
31192
|
-
unknownPageCount = false
|
|
31194
|
+
unknownPageCount = false,
|
|
31195
|
+
nextPageBtnDisabled = false
|
|
31193
31196
|
} = _a, rest = __objRest(_a, [
|
|
31194
31197
|
"numPages",
|
|
31195
31198
|
"onPageChange",
|
|
@@ -31198,7 +31201,8 @@ function SpsPageSelector(props2) {
|
|
|
31198
31201
|
"className",
|
|
31199
31202
|
"data-testid",
|
|
31200
31203
|
"disabled",
|
|
31201
|
-
"unknownPageCount"
|
|
31204
|
+
"unknownPageCount",
|
|
31205
|
+
"nextPageBtnDisabled"
|
|
31202
31206
|
]);
|
|
31203
31207
|
const { t: t2 } = React.useContext(I18nContext);
|
|
31204
31208
|
const [inputPage, setInputPage] = React.useState(pageProp);
|
|
@@ -31262,11 +31266,11 @@ function SpsPageSelector(props2) {
|
|
|
31262
31266
|
className: "sps-icon sps-icon-chevron-left",
|
|
31263
31267
|
"aria-hidden": "true"
|
|
31264
31268
|
}))), /* @__PURE__ */ React.createElement("div", {
|
|
31265
|
-
className: clsx("sps-button", "sps-button--icon", (page === numPages || disabled) && "sps-button--disabled")
|
|
31269
|
+
className: clsx("sps-button", "sps-button--icon", (page === numPages || disabled || nextPageBtnDisabled) && "sps-button--disabled")
|
|
31266
31270
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
31267
31271
|
type: "button",
|
|
31268
31272
|
onClick: () => updatePage(page + 1),
|
|
31269
|
-
disabled: page === numPages || disabled,
|
|
31273
|
+
disabled: page === numPages || disabled || nextPageBtnDisabled,
|
|
31270
31274
|
title: t2("design-system:pagination.nextPage")
|
|
31271
31275
|
}, /* @__PURE__ */ React.createElement("i", {
|
|
31272
31276
|
className: "sps-icon sps-icon-chevron-right",
|
|
@@ -31285,7 +31289,9 @@ const propsDoc$D = {
|
|
|
31285
31289
|
totalResults: "number",
|
|
31286
31290
|
onPageChange: "(page: number, pageSize: number, indices: [number, number]) => void",
|
|
31287
31291
|
disabled: "boolean",
|
|
31288
|
-
unknownPageCount: "boolean"
|
|
31292
|
+
unknownPageCount: "boolean",
|
|
31293
|
+
nextPageBtnDisabled: "boolean",
|
|
31294
|
+
resultsOnPage: "number"
|
|
31289
31295
|
};
|
|
31290
31296
|
const propTypes$D = __spreadValues({
|
|
31291
31297
|
onPageChange: fun().isRequired,
|
|
@@ -31294,7 +31300,9 @@ const propTypes$D = __spreadValues({
|
|
|
31294
31300
|
pageSizeOptions: propTypes$1I.exports.arrayOf(propTypes$1I.exports.number),
|
|
31295
31301
|
totalResults: propTypes$1I.exports.number,
|
|
31296
31302
|
disabled: propTypes$1I.exports.bool,
|
|
31297
|
-
unknownPageCount: propTypes$1I.exports.bool
|
|
31303
|
+
unknownPageCount: propTypes$1I.exports.bool,
|
|
31304
|
+
nextPageBtnDisabled: propTypes$1I.exports.bool,
|
|
31305
|
+
resultsOnPage: propTypes$1I.exports.number
|
|
31298
31306
|
}, spsGlobalPropTypes);
|
|
31299
31307
|
function SpsPagination(props2) {
|
|
31300
31308
|
const _a = props2, {
|
|
@@ -31307,7 +31315,9 @@ function SpsPagination(props2) {
|
|
|
31307
31315
|
totalResults,
|
|
31308
31316
|
unsafelyReplaceClassName,
|
|
31309
31317
|
disabled = false,
|
|
31310
|
-
unknownPageCount = false
|
|
31318
|
+
unknownPageCount = false,
|
|
31319
|
+
nextPageBtnDisabled = false,
|
|
31320
|
+
resultsOnPage
|
|
31311
31321
|
} = _a, rest = __objRest(_a, [
|
|
31312
31322
|
"className",
|
|
31313
31323
|
"onPageChange",
|
|
@@ -31318,7 +31328,9 @@ function SpsPagination(props2) {
|
|
|
31318
31328
|
"totalResults",
|
|
31319
31329
|
"unsafelyReplaceClassName",
|
|
31320
31330
|
"disabled",
|
|
31321
|
-
"unknownPageCount"
|
|
31331
|
+
"unknownPageCount",
|
|
31332
|
+
"nextPageBtnDisabled",
|
|
31333
|
+
"resultsOnPage"
|
|
31322
31334
|
]);
|
|
31323
31335
|
const [state, patchState] = usePatchReducer({
|
|
31324
31336
|
page: pageProp,
|
|
@@ -31332,7 +31344,7 @@ function SpsPagination(props2) {
|
|
|
31332
31344
|
function indices(page = state.page, pageSize = state.pageSize) {
|
|
31333
31345
|
const numPgs = numPages(pageSize);
|
|
31334
31346
|
const resultsVisibleIfThereArePages = page === numPgs ? totalResults % pageSize || pageSize : pageSize;
|
|
31335
|
-
const resultsVisible = numPgs === 0 ? 0 : resultsVisibleIfThereArePages;
|
|
31347
|
+
const resultsVisible = resultsOnPage || (numPgs === 0 ? 0 : resultsVisibleIfThereArePages);
|
|
31336
31348
|
const start = (page - 1) * pageSize;
|
|
31337
31349
|
return numPgs === 0 ? [0, 0] : [start + 1, start + resultsVisible];
|
|
31338
31350
|
}
|
|
@@ -31369,7 +31381,7 @@ function SpsPagination(props2) {
|
|
|
31369
31381
|
numPages: numPages(),
|
|
31370
31382
|
indices: indices()
|
|
31371
31383
|
});
|
|
31372
|
-
}, [totalResults]);
|
|
31384
|
+
}, [totalResults, resultsOnPage]);
|
|
31373
31385
|
function totalResultsString() {
|
|
31374
31386
|
return typeof totalResults === "number" ? totalResults : "many";
|
|
31375
31387
|
}
|
|
@@ -31405,7 +31417,8 @@ function SpsPagination(props2) {
|
|
|
31405
31417
|
page: state.page,
|
|
31406
31418
|
onPageChange: handlePageChange,
|
|
31407
31419
|
disabled,
|
|
31408
|
-
unknownPageCount
|
|
31420
|
+
unknownPageCount,
|
|
31421
|
+
nextPageBtnDisabled
|
|
31409
31422
|
}));
|
|
31410
31423
|
}
|
|
31411
31424
|
Object.assign(SpsPagination, {
|
|
@@ -31422,13 +31435,13 @@ const SpsPaginationExamples = {
|
|
|
31422
31435
|
label: "Standard Pagination Bar",
|
|
31423
31436
|
description: ({ Link }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "The Standard Pagination Bar is comprised of three main sections. The middle section is hidden from view when the width of its container is at the responsive breakpoint of 767 pixels."), /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("span", {
|
|
31424
31437
|
className: "sps-text-semibold"
|
|
31425
|
-
}, "Results-per-page Select"), "
|
|
31438
|
+
}, "Results-per-page Select"), " (left): allows the user to adjust the number of records being displayed per page.*")), /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("span", {
|
|
31426
31439
|
className: "sps-text-semibold"
|
|
31427
31440
|
}, "Viewing details"), " (middle): describes which results are being displayed on the current page.")), /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("span", {
|
|
31428
31441
|
className: "sps-text-semibold"
|
|
31429
31442
|
}, "Page Navigator"), " (right): allows the user to navigate between pages of results"))), /* @__PURE__ */ React.createElement("i", null, "*Note: For Tables and Content Rows, per-page options should be 25, 50, and 100. For Content Tiles, per-page options should be 24, 48, and 100."), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("p", {
|
|
31430
31443
|
className: "mt-2"
|
|
31431
|
-
}, "To see an example of the Standard Pagination Bar in context with a Table, view the Table Lists section on the
|
|
31444
|
+
}, "To see an example of the Standard Pagination Bar in context with a Table, view the Table Lists section on the ", /* @__PURE__ */ React.createElement(Link, {
|
|
31432
31445
|
to: "/style-and-layout/page-types"
|
|
31433
31446
|
}, "Page Types"), " page.")),
|
|
31434
31447
|
examples: {
|
|
@@ -31461,10 +31474,10 @@ const SpsPaginationExamples = {
|
|
|
31461
31474
|
`
|
|
31462
31475
|
},
|
|
31463
31476
|
situational: {
|
|
31464
|
-
description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", null, "Unknown Page Count"), /* @__PURE__ */ React.createElement("p", null, "In cases where the exact page count of results is not able to be determined, a variation of the Pagination component
|
|
31477
|
+
description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", null, "Unknown Page Count"), /* @__PURE__ */ React.createElement("p", null, "In cases where the exact page count of results is not able to be determined, a variation of the Pagination component can be utilized."), /* @__PURE__ */ React.createElement("p", null, "unknownPageCount prop will hide total count from view, resultsOnPage prop will allow to keep track of results count for every page and nextPageBtnDisabled prop will allow to manually disable next page button")),
|
|
31465
31478
|
react: code`
|
|
31466
31479
|
function Component() {
|
|
31467
|
-
const [page, setPage] = React.useState(
|
|
31480
|
+
const [page, setPage] = React.useState(1);
|
|
31468
31481
|
const [pageSize, setPageSize] = React.useState(25);
|
|
31469
31482
|
|
|
31470
31483
|
function handlePageChange(newPage, newPageSize) {
|
|
@@ -31476,11 +31489,12 @@ const SpsPaginationExamples = {
|
|
|
31476
31489
|
return (
|
|
31477
31490
|
<React.Fragment>
|
|
31478
31491
|
<SpsPagination id="basic"
|
|
31479
|
-
totalResults={123}
|
|
31480
31492
|
page={page}
|
|
31481
31493
|
pageSize={pageSize}
|
|
31482
31494
|
onPageChange={handlePageChange}
|
|
31483
31495
|
unknownPageCount
|
|
31496
|
+
resultsOnPage={page === 3 ? 5 : pageSize}
|
|
31497
|
+
nextPageBtnDisabled={page === 3}
|
|
31484
31498
|
/>
|
|
31485
31499
|
<span className="mr-2">page: {page}</span>
|
|
31486
31500
|
<span>pageSize: {pageSize}</span>
|
|
@@ -31509,7 +31523,7 @@ const SpsPaginationExamples = {
|
|
|
31509
31523
|
},
|
|
31510
31524
|
pageSelector: {
|
|
31511
31525
|
label: "Page Navigator",
|
|
31512
|
-
description: ({ Link }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "When navigating through a series of paginated results inside of a container such as a sidebar, a miniature version of the pagination bar can be used. This version utilizes only the page navigation component. Use Mini Pagination inside of a Card Header that also includes a title describing the content contained in the card below."), /* @__PURE__ */ React.createElement("p", null, "To see an example of the Page Navigator in context within a Card Header, view the General Content section on the
|
|
31526
|
+
description: ({ Link }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "When navigating through a series of paginated results inside of a container such as a sidebar, a miniature version of the pagination bar can be used. This version utilizes only the page navigation component. Use Mini Pagination inside of a Card Header that also includes a title describing the content contained in the card below."), /* @__PURE__ */ React.createElement("p", null, "To see an example of the Page Navigator in context within a Card Header, view the General Content section on the ", /* @__PURE__ */ React.createElement(Link, {
|
|
31513
31527
|
to: "/style-and-layout/page-types"
|
|
31514
31528
|
}, "Page Types"), " page.")),
|
|
31515
31529
|
examples: {
|
|
@@ -9,6 +9,7 @@ declare const propTypes: {
|
|
|
9
9
|
page: PropTypes.Requireable<number>;
|
|
10
10
|
disabled: PropTypes.Requireable<boolean>;
|
|
11
11
|
unknownPageCount: PropTypes.Requireable<boolean>;
|
|
12
|
+
nextPageBtnDisabled: PropTypes.Requireable<boolean>;
|
|
12
13
|
};
|
|
13
14
|
export declare type SpsPageSelectorProps = PropTypes.InferTS<typeof propTypes, HTMLDivElement>;
|
|
14
15
|
export declare function SpsPageSelector(props: SpsPageSelectorProps): JSX.Element;
|
|
@@ -11,6 +11,8 @@ declare const propTypes: {
|
|
|
11
11
|
totalResults: PropTypes.Requireable<number>;
|
|
12
12
|
disabled: PropTypes.Requireable<boolean>;
|
|
13
13
|
unknownPageCount: PropTypes.Requireable<boolean>;
|
|
14
|
+
nextPageBtnDisabled: PropTypes.Requireable<boolean>;
|
|
15
|
+
resultsOnPage: PropTypes.Requireable<number>;
|
|
14
16
|
};
|
|
15
17
|
export declare type SpsPaginationProps = PropTypes.InferTS<typeof propTypes, HTMLDivElement>;
|
|
16
18
|
export declare function SpsPagination(props: SpsPaginationProps): JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DSReactExamples } from
|
|
1
|
+
import type { DSReactExamples } from "@spscommerce/ds-shared";
|
|
2
2
|
export declare const SpsPaginationExamples: DSReactExamples;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spscommerce/ds-react",
|
|
3
3
|
"description": "SPS Design System React components",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.33.0",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/ds-react",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@react-stately/collections": "^3.3.3",
|
|
31
|
-
"@spscommerce/ds-colors": "6.
|
|
32
|
-
"@spscommerce/ds-illustrations": "6.
|
|
33
|
-
"@spscommerce/ds-shared": "6.
|
|
34
|
-
"@spscommerce/positioning": "6.
|
|
31
|
+
"@spscommerce/ds-colors": "6.33.0",
|
|
32
|
+
"@spscommerce/ds-illustrations": "6.33.0",
|
|
33
|
+
"@spscommerce/ds-shared": "6.33.0",
|
|
34
|
+
"@spscommerce/positioning": "6.33.0",
|
|
35
35
|
"@spscommerce/utils": "^6.11.3",
|
|
36
36
|
"moment": "^2.25.3",
|
|
37
37
|
"moment-timezone": "^0.5.28",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@react-stately/collections": "^3.3.3",
|
|
43
|
-
"@spscommerce/ds-colors": "6.
|
|
44
|
-
"@spscommerce/ds-illustrations": "6.
|
|
45
|
-
"@spscommerce/ds-shared": "6.
|
|
46
|
-
"@spscommerce/positioning": "6.
|
|
43
|
+
"@spscommerce/ds-colors": "6.33.0",
|
|
44
|
+
"@spscommerce/ds-illustrations": "6.33.0",
|
|
45
|
+
"@spscommerce/ds-shared": "6.33.0",
|
|
46
|
+
"@spscommerce/positioning": "6.33.0",
|
|
47
47
|
"@spscommerce/utils": "^6.11.3",
|
|
48
48
|
"@testing-library/react": "^10.4.0",
|
|
49
49
|
"@types/prop-types": "^15.7.1",
|