@spscommerce/ds-react 5.33.11 → 5.33.12
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.cjs.js +361 -336
- package/lib/index.es.js +52 -12
- package/lib/pagination/SpsPageSelector.d.ts +1 -0
- package/lib/pagination/SpsPagination.d.ts +1 -0
- package/package.json +11 -11
package/lib/index.es.js
CHANGED
|
@@ -31071,13 +31071,15 @@ const propsDoc$L = {
|
|
|
31071
31071
|
page: "number",
|
|
31072
31072
|
numPages: "number",
|
|
31073
31073
|
onPageChange: "(number) => void",
|
|
31074
|
-
disabled: "boolean"
|
|
31074
|
+
disabled: "boolean",
|
|
31075
|
+
unknownPageCount: "boolean"
|
|
31075
31076
|
};
|
|
31076
31077
|
const propTypes$N = __spreadValues({
|
|
31077
31078
|
numPages: propTypes$1O.exports.number,
|
|
31078
31079
|
onPageChange: fun(),
|
|
31079
31080
|
page: propTypes$1O.exports.number,
|
|
31080
|
-
disabled: propTypes$1O.exports.bool
|
|
31081
|
+
disabled: propTypes$1O.exports.bool,
|
|
31082
|
+
unknownPageCount: propTypes$1O.exports.bool
|
|
31081
31083
|
}, spsGlobalPropTypes);
|
|
31082
31084
|
function SpsPageSelector(props2) {
|
|
31083
31085
|
const _a = props2, {
|
|
@@ -31087,7 +31089,8 @@ function SpsPageSelector(props2) {
|
|
|
31087
31089
|
unsafelyReplaceClassName,
|
|
31088
31090
|
className,
|
|
31089
31091
|
"data-testid": testId,
|
|
31090
|
-
disabled = false
|
|
31092
|
+
disabled = false,
|
|
31093
|
+
unknownPageCount = false
|
|
31091
31094
|
} = _a, rest = __objRest(_a, [
|
|
31092
31095
|
"numPages",
|
|
31093
31096
|
"onPageChange",
|
|
@@ -31095,7 +31098,8 @@ function SpsPageSelector(props2) {
|
|
|
31095
31098
|
"unsafelyReplaceClassName",
|
|
31096
31099
|
"className",
|
|
31097
31100
|
"data-testid",
|
|
31098
|
-
"disabled"
|
|
31101
|
+
"disabled",
|
|
31102
|
+
"unknownPageCount"
|
|
31099
31103
|
]);
|
|
31100
31104
|
const { t: t2 } = React.useContext(I18nContext);
|
|
31101
31105
|
const [inputPage, setInputPage] = React.useState(pageProp);
|
|
@@ -31122,7 +31126,7 @@ function SpsPageSelector(props2) {
|
|
|
31122
31126
|
return /* @__PURE__ */ React.createElement("div", __spreadValues({
|
|
31123
31127
|
className: classes,
|
|
31124
31128
|
"data-testid": testId
|
|
31125
|
-
}, rest), /* @__PURE__ */ React.createElement("div", {
|
|
31129
|
+
}, rest), !unknownPageCount && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
31126
31130
|
className: "sps-pagination__input-wrapper",
|
|
31127
31131
|
"data-testid": `${testId}__input`
|
|
31128
31132
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -31145,7 +31149,7 @@ function SpsPageSelector(props2) {
|
|
|
31145
31149
|
}))), /* @__PURE__ */ React.createElement("span", {
|
|
31146
31150
|
className: "sps-page-selector__total-pages",
|
|
31147
31151
|
"data-testid": `${testId}_page-count`
|
|
31148
|
-
}, Number.isNaN(numPages) ? t2("design-system:pagination.ofMany") : t2("design-system:pagination.ofPageCount", { pageCount: numPages })), /* @__PURE__ */ React.createElement("div", {
|
|
31152
|
+
}, Number.isNaN(numPages) ? t2("design-system:pagination.ofMany") : t2("design-system:pagination.ofPageCount", { pageCount: numPages }))), /* @__PURE__ */ React.createElement("div", {
|
|
31149
31153
|
className: "sps-icon-button-panel",
|
|
31150
31154
|
"data-testid": `${testId}__buttons`
|
|
31151
31155
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -31181,7 +31185,8 @@ const propsDoc$K = {
|
|
|
31181
31185
|
pageSizeOptions: "Array<number>",
|
|
31182
31186
|
totalResults: "number",
|
|
31183
31187
|
onPageChange: "(page: number, pageSize: number, indices: [number, number]) => void",
|
|
31184
|
-
disabled: "boolean"
|
|
31188
|
+
disabled: "boolean",
|
|
31189
|
+
unknownPageCount: "boolean"
|
|
31185
31190
|
};
|
|
31186
31191
|
const propTypes$M = __spreadValues({
|
|
31187
31192
|
onPageChange: fun().isRequired,
|
|
@@ -31189,7 +31194,8 @@ const propTypes$M = __spreadValues({
|
|
|
31189
31194
|
pageSize: propTypes$1O.exports.number,
|
|
31190
31195
|
pageSizeOptions: propTypes$1O.exports.arrayOf(propTypes$1O.exports.number),
|
|
31191
31196
|
totalResults: propTypes$1O.exports.number,
|
|
31192
|
-
disabled: propTypes$1O.exports.bool
|
|
31197
|
+
disabled: propTypes$1O.exports.bool,
|
|
31198
|
+
unknownPageCount: propTypes$1O.exports.bool
|
|
31193
31199
|
}, spsGlobalPropTypes);
|
|
31194
31200
|
function SpsPagination(props2) {
|
|
31195
31201
|
const _a = props2, {
|
|
@@ -31201,7 +31207,8 @@ function SpsPagination(props2) {
|
|
|
31201
31207
|
"data-testid": testId,
|
|
31202
31208
|
totalResults,
|
|
31203
31209
|
unsafelyReplaceClassName,
|
|
31204
|
-
disabled = false
|
|
31210
|
+
disabled = false,
|
|
31211
|
+
unknownPageCount = false
|
|
31205
31212
|
} = _a, rest = __objRest(_a, [
|
|
31206
31213
|
"className",
|
|
31207
31214
|
"onPageChange",
|
|
@@ -31211,7 +31218,8 @@ function SpsPagination(props2) {
|
|
|
31211
31218
|
"data-testid",
|
|
31212
31219
|
"totalResults",
|
|
31213
31220
|
"unsafelyReplaceClassName",
|
|
31214
|
-
"disabled"
|
|
31221
|
+
"disabled",
|
|
31222
|
+
"unknownPageCount"
|
|
31215
31223
|
]);
|
|
31216
31224
|
const [state, patchState] = usePatchReducer({
|
|
31217
31225
|
page: pageProp,
|
|
@@ -31289,13 +31297,16 @@ function SpsPagination(props2) {
|
|
|
31289
31297
|
value: state.pageSize,
|
|
31290
31298
|
className: "ml-1 mr-1",
|
|
31291
31299
|
disabled
|
|
31292
|
-
}), "Per Page"), /* @__PURE__ */ React.createElement("div", {
|
|
31300
|
+
}), "Per Page"), unknownPageCount ? /* @__PURE__ */ React.createElement("div", {
|
|
31301
|
+
className: "sps-pagination__details"
|
|
31302
|
+
}, `Viewing ${state.indices[0]} - ${state.indices[1]}`) : /* @__PURE__ */ React.createElement("div", {
|
|
31293
31303
|
className: "sps-pagination__details"
|
|
31294
31304
|
}, `Viewing ${state.indices[0]} - ${state.indices[1]} of ${totalResultsString()}`), /* @__PURE__ */ React.createElement(SpsPageSelector, {
|
|
31295
31305
|
numPages: state.numPages,
|
|
31296
31306
|
page: state.page,
|
|
31297
31307
|
onPageChange: handlePageChange,
|
|
31298
|
-
disabled
|
|
31308
|
+
disabled,
|
|
31309
|
+
unknownPageCount
|
|
31299
31310
|
}));
|
|
31300
31311
|
}
|
|
31301
31312
|
Object.assign(SpsPagination, {
|
|
@@ -31350,6 +31361,35 @@ const SpsPaginationExamples = {
|
|
|
31350
31361
|
}
|
|
31351
31362
|
`
|
|
31352
31363
|
},
|
|
31364
|
+
situational: {
|
|
31365
|
+
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 with limited features can be utilized.")),
|
|
31366
|
+
react: code`
|
|
31367
|
+
function Component() {
|
|
31368
|
+
const [page, setPage] = React.useState(2);
|
|
31369
|
+
const [pageSize, setPageSize] = React.useState(25);
|
|
31370
|
+
|
|
31371
|
+
function handlePageChange(newPage, newPageSize) {
|
|
31372
|
+
console.log("change", newPage, newPageSize);
|
|
31373
|
+
setPage(newPage);
|
|
31374
|
+
setPageSize(newPageSize);
|
|
31375
|
+
}
|
|
31376
|
+
|
|
31377
|
+
return (
|
|
31378
|
+
<React.Fragment>
|
|
31379
|
+
<SpsPagination id="basic"
|
|
31380
|
+
totalResults={123}
|
|
31381
|
+
page={page}
|
|
31382
|
+
pageSize={pageSize}
|
|
31383
|
+
onPageChange={handlePageChange}
|
|
31384
|
+
unknownPageCount
|
|
31385
|
+
/>
|
|
31386
|
+
<span className="mr-2">page: {page}</span>
|
|
31387
|
+
<span>pageSize: {pageSize}</span>
|
|
31388
|
+
</React.Fragment>
|
|
31389
|
+
);
|
|
31390
|
+
}
|
|
31391
|
+
`
|
|
31392
|
+
},
|
|
31353
31393
|
disabled: {
|
|
31354
31394
|
description: "Disabled state",
|
|
31355
31395
|
react: code`
|
|
@@ -8,6 +8,7 @@ declare const propTypes: {
|
|
|
8
8
|
onPageChange: PropTypes.Requireable<(number: any) => void>;
|
|
9
9
|
page: PropTypes.Requireable<number>;
|
|
10
10
|
disabled: PropTypes.Requireable<boolean>;
|
|
11
|
+
unknownPageCount: PropTypes.Requireable<boolean>;
|
|
11
12
|
};
|
|
12
13
|
export declare type SpsPageSelectorProps = PropTypes.InferTS<typeof propTypes, HTMLDivElement>;
|
|
13
14
|
export declare function SpsPageSelector(props: SpsPageSelectorProps): JSX.Element;
|
|
@@ -10,6 +10,7 @@ declare const propTypes: {
|
|
|
10
10
|
pageSizeOptions: PropTypes.Requireable<number[]>;
|
|
11
11
|
totalResults: PropTypes.Requireable<number>;
|
|
12
12
|
disabled: PropTypes.Requireable<boolean>;
|
|
13
|
+
unknownPageCount: PropTypes.Requireable<boolean>;
|
|
13
14
|
};
|
|
14
15
|
export declare type SpsPaginationProps = PropTypes.InferTS<typeof propTypes, HTMLDivElement>;
|
|
15
16
|
export declare function SpsPagination(props: SpsPaginationProps): JSX.Element;
|
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": "5.33.
|
|
4
|
+
"version": "5.33.12",
|
|
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,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@react-stately/collections": "^3.3.3",
|
|
31
|
-
"@spscommerce/ds-colors": "5.33.
|
|
32
|
-
"@spscommerce/ds-illustrations": "5.33.
|
|
33
|
-
"@spscommerce/ds-shared": "5.33.
|
|
34
|
-
"@spscommerce/positioning": "5.33.
|
|
35
|
-
"@spscommerce/utils": "5.33.
|
|
31
|
+
"@spscommerce/ds-colors": "5.33.12",
|
|
32
|
+
"@spscommerce/ds-illustrations": "5.33.12",
|
|
33
|
+
"@spscommerce/ds-shared": "5.33.12",
|
|
34
|
+
"@spscommerce/positioning": "5.33.12",
|
|
35
|
+
"@spscommerce/utils": "5.33.12",
|
|
36
36
|
"moment": "^2.25.3",
|
|
37
37
|
"moment-timezone": "^0.5.28",
|
|
38
38
|
"react": "^16.9.0",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@react-stately/collections": "^3.3.3",
|
|
43
|
-
"@spscommerce/ds-colors": "5.33.
|
|
44
|
-
"@spscommerce/ds-illustrations": "5.33.
|
|
45
|
-
"@spscommerce/ds-shared": "5.33.
|
|
46
|
-
"@spscommerce/positioning": "5.33.
|
|
47
|
-
"@spscommerce/utils": "5.33.
|
|
43
|
+
"@spscommerce/ds-colors": "5.33.12",
|
|
44
|
+
"@spscommerce/ds-illustrations": "5.33.12",
|
|
45
|
+
"@spscommerce/ds-shared": "5.33.12",
|
|
46
|
+
"@spscommerce/positioning": "5.33.12",
|
|
47
|
+
"@spscommerce/utils": "5.33.12",
|
|
48
48
|
"@testing-library/react": "^9.3.2",
|
|
49
49
|
"@types/prop-types": "^15.7.1",
|
|
50
50
|
"@types/react": "^16.9.0",
|