@nice-digital/nds-prev-next 4.0.2-alpha.0 → 4.0.2

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/es/PrevNext.js CHANGED
@@ -46,6 +46,6 @@ const PrevNext = (props) => {
46
46
  method: previousPageLink === null || previousPageLink === void 0 ? void 0 : previousPageLink.method
47
47
  }
48
48
  : null;
49
- return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, classnames_1.default)("prev-next", className) }, rest, { children: (nextPageLink || previousPageLink) && ((0, jsx_runtime_1.jsxs)("nav", Object.assign({ "aria-label": "Previous and next pages" }, { children: [nextPageLink && nextLinkProps && (0, jsx_runtime_1.jsx)(Link, Object.assign({}, nextLinkProps)), previousPageLink && previousLinkProps && ((0, jsx_runtime_1.jsx)(Link, Object.assign({}, previousLinkProps)))] }))) })));
49
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, classnames_1.default)("prev-next", className), "data-component": "prev-next" }, rest, { children: (nextPageLink || previousPageLink) && ((0, jsx_runtime_1.jsxs)("nav", Object.assign({ "aria-label": "Previous and next pages" }, { children: [nextPageLink && nextLinkProps && (0, jsx_runtime_1.jsx)(Link, Object.assign({}, nextLinkProps)), previousPageLink && previousLinkProps && ((0, jsx_runtime_1.jsx)(Link, Object.assign({}, previousLinkProps)))] }))) })));
50
50
  };
51
51
  exports.PrevNext = PrevNext;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrevNext.js","names":["React","PropTypes","classnames","Link","text","destination","elementType","ElementType","intro","method","linkProps","className","PrevNext","props","nextPageLink","previousPageLink","rest","nextLinkProps","previousLinkProps","propTypes","objectOf","string","isRequired"],"sources":["../src/PrevNext.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport classnames from \"classnames\";\nimport \"./../scss/prev-next.scss\";\n\nconst Link = ({\n\ttext,\n\tdestination,\n\telementType: ElementType = \"a\",\n\tintro,\n\tmethod\n}) => {\n\tlet linkProps = {\n\t\tclassName: \"prev-next__link\",\n\t\t[method || (ElementType === \"a\" && \"href\") || \"to\"]: destination\n\t};\n\treturn (\n\t\t<ElementType {...linkProps}>\n\t\t\t<span className=\"prev-next__link-intro\">{intro}</span>\n\t\t\t<span className=\"prev-next__link-text\">{text}</span>\n\t\t</ElementType>\n\t);\n};\n\nexport const PrevNext = (props) => {\n\tconst { nextPageLink, previousPageLink, className, ...rest } = props;\n\n\tconst nextLinkProps = {\n\t\tintro: nextPageLink?.intro || \"Next page\",\n\t\ttext: nextPageLink?.text,\n\t\tdestination: nextPageLink?.destination,\n\t\telementType: nextPageLink?.elementType,\n\t\tmethod: nextPageLink?.method\n\t};\n\n\tconst previousLinkProps = {\n\t\tintro: previousPageLink?.intro || \"Previous page\",\n\t\ttext: previousPageLink?.text,\n\t\tdestination: previousPageLink?.destination,\n\t\telementType: previousPageLink?.elementType,\n\t\tmethod: previousPageLink?.method\n\t};\n\n\treturn (\n\t\t<div className={classnames(\"prev-next\", className)} {...rest}>\n\t\t\t{(nextPageLink || previousPageLink) && (\n\t\t\t\t<nav aria-label=\"Previous and next pages\">\n\t\t\t\t\t{nextPageLink && <Link {...nextLinkProps} />}\n\t\t\t\t\t{previousPageLink && <Link {...previousLinkProps} />}\n\t\t\t\t</nav>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nPrevNext.propTypes = {\n\tnextPageLink: PropTypes.objectOf(Link),\n\tpreviousPageLink: PropTypes.objectOf(Link),\n\tclassName: PropTypes.string\n};\n\nLink.propTypes = {\n\ttext: PropTypes.string.isRequired,\n\tdestination: PropTypes.string.isRequired,\n\telementType: PropTypes.elementType,\n\tintro: PropTypes.string,\n\tmethod: PropTypes.string\n};\n"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAO,0BAAP;;AAEA,IAAMC,IAAI,GAAG,SAAPA,IAAO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BAAgB,CAAEX,IAFC;IAGzBC,WAAW,EAAEU,gBAAF,oBAAEA,gBAAgB,CAAEV,WAHN;IAIzBC,WAAW,EAAES,gBAAF,oBAAEA,gBAAgB,CAAET,WAJN;IAKzBG,MAAM,EAAEM,gBAAF,oBAAEA,gBAAgB,CAAEN;EALD,CAA1B;EAQA,oBACC;IAAK,SAAS,EAAEP,UAAU,CAAC,WAAD,EAAcS,SAAd;EAA1B,GAAwDK,IAAxD,GACE,CAACF,YAAY,IAAIC,gBAAjB,kBACA;IAAK,cAAW;EAAhB,GACED,YAAY,iBAAI,oBAAC,IAAD,EAAUG,aAAV,CADlB,EAEEF,gBAAgB,iBAAI,oBAAC,IAAD,EAAUG,iBAAV,CAFtB,CAFF,CADD;AAUA,CA7BM;AA+BPN,QAAQ,CAACO,SAAT,GAAqB;EACpBL,YAAY,EAAEb,SAAS,CAACmB,QAAV,CAAmBjB,IAAnB,CADM;EAEpBY,gBAAgB,EAAEd,SAAS,CAACmB,QAAV,CAAmBjB,IAAnB,CAFE;EAGpBQ,SAAS,EAAEV,SAAS,CAACoB;AAHD,CAArB;AAMAlB,IAAI,CAACgB,SAAL,GAAiB;EAChBf,IAAI,EAAEH,SAAS,CAACoB,MAAV,CAAiBC,UADP;EAEhBjB,WAAW,EAAEJ,SAAS,CAACoB,MAAV,CAAiBC,UAFd;EAGhBhB,WAAW,EAAEL,SAAS,CAACK,WAHP;EAIhBE,KAAK,EAAEP,SAAS,CAACoB,MAJD;EAKhBZ,MAAM,EAAER,SAAS,CAACoB;AALF,CAAjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-prev-next",
3
- "version": "4.0.2-alpha.0",
3
+ "version": "4.0.2",
4
4
  "description": "Previous and next navigation component for the NICE Design System",
5
5
  "author": "Warren Keith <w@rren.dev>",
6
6
  "keywords": [
@@ -34,7 +34,7 @@
34
34
  "url": "https://github.com/nice-digital/nice-design-system/issues"
35
35
  },
36
36
  "dependencies": {
37
- "@nice-digital/nds-core": "^4.0.2-alpha.0",
37
+ "@nice-digital/nds-core": "^4.0.2",
38
38
  "classnames": "^2.2.6"
39
39
  },
40
40
  "peerDependencies": {
@@ -49,5 +49,5 @@
49
49
  "@types/node": "^18.11.9",
50
50
  "typescript": "^4.8.4"
51
51
  },
52
- "gitHead": "4e9cad8a2b94cdf4af05b18a6610835883bedf0e"
52
+ "gitHead": "d8feb7beba5fffa49da42d6a550cb8f67a50727d"
53
53
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("@testing-library/react");
5
- const PrevNext_1 = require("./PrevNext");
6
- const Link = () => (0, jsx_runtime_1.jsx)("a", Object.assign({ href: "#" }, { children: "I am a link" }));
7
- const nextPageLink = {
8
- text: "Page Header",
9
- destination: "/pageheader",
10
- elementType: Link,
11
- intro: "Show me the next one"
12
- };
13
- const previousPageLink = {
14
- text: "Alert",
15
- destination: "/alert"
16
- };
17
- describe("Previous & Next", () => {
18
- it("should match snapshot with both links supplied", () => {
19
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(PrevNext_1.PrevNext, { nextPageLink: nextPageLink, previousPageLink: previousPageLink }));
20
- expect(wrapper).toMatchSnapshot();
21
- });
22
- it("should match snapshot with one link supplied", () => {
23
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(PrevNext_1.PrevNext, { previousPageLink: previousPageLink }));
24
- expect(wrapper).toMatchSnapshot();
25
- });
26
- it("link should render an href attribute if the elementType is an anchor", () => {
27
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(PrevNext_1.PrevNext, { previousPageLink: previousPageLink }));
28
- const anchor = wrapper.getByRole("link");
29
- expect(anchor.getAttribute("href")).toBe("/alert");
30
- });
31
- it("should pass extra props to the containing element", () => {
32
- var _a;
33
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(PrevNext_1.PrevNext, { nextPageLink: nextPageLink, "data-tracker": "my-tracker" }));
34
- expect((_a = container.querySelector(".prev-next")) === null || _a === void 0 ? void 0 : _a.getAttribute("data-tracker")).toBe("my-tracker");
35
- });
36
- it("should merge additional classnames with the component classname", () => {
37
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(PrevNext_1.PrevNext, { nextPageLink: nextPageLink, className: "extra-class" }));
38
- expect(container.querySelector(".prev-next")).toHaveClass("prev-next extra-class");
39
- });
40
- });