@spscommerce/ds-react 5.33.11 → 5.33.13

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
@@ -2401,6 +2401,13 @@ const SpsOptionList = React.forwardRef((props2, ref2) => {
2401
2401
  }, [isOpen]);
2402
2402
  const maxHeight = maxHeightPx ? maxHeightPx / 16 : maxHeightRem;
2403
2403
  const optionsInlineStyles = maxHeight ? { maxHeight: `${maxHeight}rem` } : {};
2404
+ function highlightText(text, pattern2) {
2405
+ return pattern2 ? /* @__PURE__ */ React.createElement(React.Fragment, null, text.split(pattern2).map((part, partIdx) => pattern2.test(part) ? /* @__PURE__ */ React.createElement("u", {
2406
+ key: partIdx
2407
+ }, part) : /* @__PURE__ */ React.createElement(React.Fragment, {
2408
+ key: partIdx
2409
+ }, part))) : /* @__PURE__ */ React.createElement(React.Fragment, null, text);
2410
+ }
2404
2411
  return portal(/* @__PURE__ */ React.createElement("div", __spreadValues({
2405
2412
  className: classes,
2406
2413
  id: id2,
@@ -2439,17 +2446,9 @@ const SpsOptionList = React.forwardRef((props2, ref2) => {
2439
2446
  className: clsx("sps-icon", "sps-option-list__option-icon", `sps-icon-${String(option.value.icon)}`)
2440
2447
  }), (!option.value || !option.value.icon && anyOptionHasIcon) && /* @__PURE__ */ React.createElement("span", {
2441
2448
  className: "sps-option-list__option-icon-spacer"
2442
- }), /* @__PURE__ */ React.createElement("span", {
2443
- dangerouslySetInnerHTML: {
2444
- __html: option.getHtml(searchState.replacementPattern)
2445
- }
2446
- }), option.caption && /* @__PURE__ */ React.createElement("div", {
2449
+ }), /* @__PURE__ */ React.createElement("span", null, highlightText(option.text, searchState.replacementPattern)), option.caption && /* @__PURE__ */ React.createElement("div", {
2447
2450
  className: "sps-option-list__option-caption"
2448
- }, /* @__PURE__ */ React.createElement("span", {
2449
- dangerouslySetInnerHTML: {
2450
- __html: option.caption.replace(searchState.replacementPattern, "<u>$&</u>")
2451
- }
2452
- })));
2451
+ }, /* @__PURE__ */ React.createElement("span", null, highlightText(option.caption, searchState.replacementPattern))));
2453
2452
  })), specialActionOption && specialAction.label && /* @__PURE__ */ React.createElement("a", {
2454
2453
  className: clsx("sps-option-list__option", "sps-option-list__special-action", highlightedOptionIndex === optionList.length && "sps-option-list__option--highlighted", specialAction.disabled && "sps-option-list__special-action--disabled"),
2455
2454
  href: specialActionOption.href,
@@ -31071,13 +31070,15 @@ const propsDoc$L = {
31071
31070
  page: "number",
31072
31071
  numPages: "number",
31073
31072
  onPageChange: "(number) => void",
31074
- disabled: "boolean"
31073
+ disabled: "boolean",
31074
+ unknownPageCount: "boolean"
31075
31075
  };
31076
31076
  const propTypes$N = __spreadValues({
31077
31077
  numPages: propTypes$1O.exports.number,
31078
31078
  onPageChange: fun(),
31079
31079
  page: propTypes$1O.exports.number,
31080
- disabled: propTypes$1O.exports.bool
31080
+ disabled: propTypes$1O.exports.bool,
31081
+ unknownPageCount: propTypes$1O.exports.bool
31081
31082
  }, spsGlobalPropTypes);
31082
31083
  function SpsPageSelector(props2) {
31083
31084
  const _a = props2, {
@@ -31087,7 +31088,8 @@ function SpsPageSelector(props2) {
31087
31088
  unsafelyReplaceClassName,
31088
31089
  className,
31089
31090
  "data-testid": testId,
31090
- disabled = false
31091
+ disabled = false,
31092
+ unknownPageCount = false
31091
31093
  } = _a, rest = __objRest(_a, [
31092
31094
  "numPages",
31093
31095
  "onPageChange",
@@ -31095,7 +31097,8 @@ function SpsPageSelector(props2) {
31095
31097
  "unsafelyReplaceClassName",
31096
31098
  "className",
31097
31099
  "data-testid",
31098
- "disabled"
31100
+ "disabled",
31101
+ "unknownPageCount"
31099
31102
  ]);
31100
31103
  const { t: t2 } = React.useContext(I18nContext);
31101
31104
  const [inputPage, setInputPage] = React.useState(pageProp);
@@ -31122,7 +31125,7 @@ function SpsPageSelector(props2) {
31122
31125
  return /* @__PURE__ */ React.createElement("div", __spreadValues({
31123
31126
  className: classes,
31124
31127
  "data-testid": testId
31125
- }, rest), /* @__PURE__ */ React.createElement("div", {
31128
+ }, rest), !unknownPageCount && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
31126
31129
  className: "sps-pagination__input-wrapper",
31127
31130
  "data-testid": `${testId}__input`
31128
31131
  }, /* @__PURE__ */ React.createElement("div", {
@@ -31145,7 +31148,7 @@ function SpsPageSelector(props2) {
31145
31148
  }))), /* @__PURE__ */ React.createElement("span", {
31146
31149
  className: "sps-page-selector__total-pages",
31147
31150
  "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", {
31151
+ }, Number.isNaN(numPages) ? t2("design-system:pagination.ofMany") : t2("design-system:pagination.ofPageCount", { pageCount: numPages }))), /* @__PURE__ */ React.createElement("div", {
31149
31152
  className: "sps-icon-button-panel",
31150
31153
  "data-testid": `${testId}__buttons`
31151
31154
  }, /* @__PURE__ */ React.createElement("div", {
@@ -31181,7 +31184,8 @@ const propsDoc$K = {
31181
31184
  pageSizeOptions: "Array<number>",
31182
31185
  totalResults: "number",
31183
31186
  onPageChange: "(page: number, pageSize: number, indices: [number, number]) => void",
31184
- disabled: "boolean"
31187
+ disabled: "boolean",
31188
+ unknownPageCount: "boolean"
31185
31189
  };
31186
31190
  const propTypes$M = __spreadValues({
31187
31191
  onPageChange: fun().isRequired,
@@ -31189,7 +31193,8 @@ const propTypes$M = __spreadValues({
31189
31193
  pageSize: propTypes$1O.exports.number,
31190
31194
  pageSizeOptions: propTypes$1O.exports.arrayOf(propTypes$1O.exports.number),
31191
31195
  totalResults: propTypes$1O.exports.number,
31192
- disabled: propTypes$1O.exports.bool
31196
+ disabled: propTypes$1O.exports.bool,
31197
+ unknownPageCount: propTypes$1O.exports.bool
31193
31198
  }, spsGlobalPropTypes);
31194
31199
  function SpsPagination(props2) {
31195
31200
  const _a = props2, {
@@ -31201,7 +31206,8 @@ function SpsPagination(props2) {
31201
31206
  "data-testid": testId,
31202
31207
  totalResults,
31203
31208
  unsafelyReplaceClassName,
31204
- disabled = false
31209
+ disabled = false,
31210
+ unknownPageCount = false
31205
31211
  } = _a, rest = __objRest(_a, [
31206
31212
  "className",
31207
31213
  "onPageChange",
@@ -31211,7 +31217,8 @@ function SpsPagination(props2) {
31211
31217
  "data-testid",
31212
31218
  "totalResults",
31213
31219
  "unsafelyReplaceClassName",
31214
- "disabled"
31220
+ "disabled",
31221
+ "unknownPageCount"
31215
31222
  ]);
31216
31223
  const [state, patchState] = usePatchReducer({
31217
31224
  page: pageProp,
@@ -31289,13 +31296,16 @@ function SpsPagination(props2) {
31289
31296
  value: state.pageSize,
31290
31297
  className: "ml-1 mr-1",
31291
31298
  disabled
31292
- }), "Per Page"), /* @__PURE__ */ React.createElement("div", {
31299
+ }), "Per Page"), unknownPageCount ? /* @__PURE__ */ React.createElement("div", {
31300
+ className: "sps-pagination__details"
31301
+ }, `Viewing ${state.indices[0]} - ${state.indices[1]}`) : /* @__PURE__ */ React.createElement("div", {
31293
31302
  className: "sps-pagination__details"
31294
31303
  }, `Viewing ${state.indices[0]} - ${state.indices[1]} of ${totalResultsString()}`), /* @__PURE__ */ React.createElement(SpsPageSelector, {
31295
31304
  numPages: state.numPages,
31296
31305
  page: state.page,
31297
31306
  onPageChange: handlePageChange,
31298
- disabled
31307
+ disabled,
31308
+ unknownPageCount
31299
31309
  }));
31300
31310
  }
31301
31311
  Object.assign(SpsPagination, {
@@ -31350,6 +31360,35 @@ const SpsPaginationExamples = {
31350
31360
  }
31351
31361
  `
31352
31362
  },
31363
+ situational: {
31364
+ 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.")),
31365
+ react: code`
31366
+ function Component() {
31367
+ const [page, setPage] = React.useState(2);
31368
+ const [pageSize, setPageSize] = React.useState(25);
31369
+
31370
+ function handlePageChange(newPage, newPageSize) {
31371
+ console.log("change", newPage, newPageSize);
31372
+ setPage(newPage);
31373
+ setPageSize(newPageSize);
31374
+ }
31375
+
31376
+ return (
31377
+ <React.Fragment>
31378
+ <SpsPagination id="basic"
31379
+ totalResults={123}
31380
+ page={page}
31381
+ pageSize={pageSize}
31382
+ onPageChange={handlePageChange}
31383
+ unknownPageCount
31384
+ />
31385
+ <span className="mr-2">page: {page}</span>
31386
+ <span>pageSize: {pageSize}</span>
31387
+ </React.Fragment>
31388
+ );
31389
+ }
31390
+ `
31391
+ },
31353
31392
  disabled: {
31354
31393
  description: "Disabled state",
31355
31394
  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.11",
4
+ "version": "5.33.13",
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.11",
32
- "@spscommerce/ds-illustrations": "5.33.11",
33
- "@spscommerce/ds-shared": "5.33.11",
34
- "@spscommerce/positioning": "5.33.11",
35
- "@spscommerce/utils": "5.33.11",
31
+ "@spscommerce/ds-colors": "5.33.13",
32
+ "@spscommerce/ds-illustrations": "5.33.13",
33
+ "@spscommerce/ds-shared": "5.33.13",
34
+ "@spscommerce/positioning": "5.33.13",
35
+ "@spscommerce/utils": "5.33.13",
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.11",
44
- "@spscommerce/ds-illustrations": "5.33.11",
45
- "@spscommerce/ds-shared": "5.33.11",
46
- "@spscommerce/positioning": "5.33.11",
47
- "@spscommerce/utils": "5.33.11",
43
+ "@spscommerce/ds-colors": "5.33.13",
44
+ "@spscommerce/ds-illustrations": "5.33.13",
45
+ "@spscommerce/ds-shared": "5.33.13",
46
+ "@spscommerce/positioning": "5.33.13",
47
+ "@spscommerce/utils": "5.33.13",
48
48
  "@testing-library/react": "^9.3.2",
49
49
  "@types/prop-types": "^15.7.1",
50
50
  "@types/react": "^16.9.0",
@@ -64,6 +64,5 @@
64
64
  "watch": "vite build --watch",
65
65
  "clean": "git clean -fdX",
66
66
  "pub": "pnpm pack && node ../../scripts/publish-package.js"
67
- },
68
- "readme": "[//]: # \"START_AUTOGENERATED\"\n\n## [@spscommerce/ds-react](https://github.com/spscommerce/ui-angular/tree/master/packages/@spscommerce/ds-react#readme)\n\n![release: 1.1.0](https://img.shields.io/badge/release-1.1.0-blue.svg?style=flat-square)\n![build: passing](https://img.shields.io/badge/build-passing-green.svg?style=flat-square)\n![tests: failing](https://img.shields.io/badge/tests-failing-red.svg?style=flat-square)\n\nSPS Design System React components \n \n ### Installation \n \n ```shell\nnpm install --save @spscommerce/ds-react\n```\n\n#### Peer Dependencies\n\n<div class=\"row\">\n <div class=\"col-5\"> \n <table class=\"sps-table\">\n <thead class=\"sps-table__head\">\n <tr class=\"sps-table__row\">\n <th class=\"sps-table__header\">\n <span class=\"sps-table__header-cell-body\"> \n Package\n </span>\n </th>\n <th class=\"sps-table__header text-right\">\n <span class=\"sps-table__header-cell-body\"> \n Version\n </span>\n </th>\n </tr>\n </thead>\n <tbody class=\"sps-table__body\">\n <tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/ds-shared#readme\">@spscommerce/ds-shared</a></td><td class=\"sps-table__cell text-right\">^1.1.0</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/positioning#readme\">@spscommerce/positioning</a></td><td class=\"sps-table__cell text-right\">^1.1.0</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/utils#readme\">@spscommerce/utils</a></td><td class=\"sps-table__cell text-right\">^1.1.0</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"lukeed/clsx\">clsx</a></td><td class=\"sps-table__cell text-right\">^1.0.3</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"https://momentjs.com\">moment</a></td><td class=\"sps-table__cell text-right\">^2.25.3</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"http://momentjs.com/timezone/\">moment-timezone</a></td><td class=\"sps-table__cell text-right\">^0.5.28</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"ai/nanoid\">nanoid</a></td><td class=\"sps-table__cell text-right\">^2.1.6</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"https://facebook.github.io/react/\">prop-types</a></td><td class=\"sps-table__cell text-right\">^15.7.2</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"https://reactjs.org/\">react</a></td><td class=\"sps-table__cell text-right\">^16.9.0</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"https://reactjs.org/\">react-dom</a></td><td class=\"sps-table__cell text-right\">^16.9.0</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"https://scroll-into-view-if-needed.netlify.com\">scroll-into-view-if-needed</a></td><td class=\"sps-table__cell text-right\">^2.2.20</td></tr>\n </tbody>\n </table>\n </div>\n <div class=\"col-7\">\n &nbsp;\n </div>\n</div>\n\n[//]: # \"END_AUTOGENERATED\"\n"
67
+ }
69
68
  }