@nice-digital/nds-maintain-ratio 4.0.0-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.
@@ -36,6 +36,6 @@ const MaintainRatio = (props) => {
36
36
  "maintain-ratio--stretch": stretchFirstChild,
37
37
  [`${className}`]: className && true
38
38
  });
39
- return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: classNames }, attributes, { children: children })));
39
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: classNames, "data-component": "maintain-ratio" }, attributes, { children: children })));
40
40
  };
41
41
  exports.MaintainRatio = MaintainRatio;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MaintainRatio.js","names":["React","PropTypes","classnames","MaintainRatio","props","ratio","className","stretchFirstChild","children","attributes","classNames","propTypes","oneOf","string","node","isRequired","bool","defaultProps","ratios","square"],"sources":["../src/MaintainRatio.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport classnames from \"classnames\";\n\nimport \"../scss/maintain-ratio.scss\";\n\nexport const MaintainRatio = (props) => {\n\tconst { ratio, className, stretchFirstChild, children, ...attributes } =\n\t\tprops;\n\n\tconst classNames = classnames({\n\t\t\"maintain-ratio\": true,\n\t\t\"maintain-ratio--16-9\": ratio === \"16:9\",\n\t\t\"maintain-ratio--21-9\": ratio === \"21:9\",\n\t\t\"maintain-ratio--4-3\": ratio === \"4:3\",\n\t\t\"maintain-ratio--square\": ratio === \"square\" || ratio === \"1:1\",\n\t\t\"maintain-ratio--stretch\": stretchFirstChild,\n\t\t[className]: className && true\n\t});\n\n\treturn (\n\t\t<div className={classNames} {...attributes}>\n\t\t\t{children}\n\t\t</div>\n\t);\n};\n\nMaintainRatio.propTypes = {\n\tratio: PropTypes.oneOf([\"16:9\", \"21:9\", \"4:3\", \"square\", \"1:1\"]),\n\tclassName: PropTypes.string,\n\tchildren: PropTypes.node.isRequired,\n\tstretchFirstChild: PropTypes.bool\n};\n\nMaintainRatio.defaultProps = {\n\tratio: \"16:9\",\n\tstretchFirstChild: false\n};\n\nMaintainRatio.ratios = {\n\t\"16:9\": \"16:9\",\n\t\"21:9\": \"21:9\",\n\t\"4:3\": \"4:3\",\n\tsquare: \"square\",\n\t\"1:1\": \"square\"\n};\n"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,OAAO,6BAAP;AAEA,OAAO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAAW;EAAA;;EACvC,IAAQC,KAAR,GACCD,KADD,CAAQC,KAAR;EAAA,IAAeC,SAAf,GACCF,KADD,CAAeE,SAAf;EAAA,IAA0BC,iBAA1B,GACCH,KADD,CAA0BG,iBAA1B;EAAA,IAA6CC,QAA7C,GACCJ,KADD,CAA6CI,QAA7C;EAAA,IAA0DC,UAA1D,iCACCL,KADD;;EAGA,IAAMM,UAAU,GAAGR,UAAU;IAC5B,kBAAkB,IADU;IAE5B,wBAAwBG,KAAK,KAAK,MAFN;IAG5B,wBAAwBA,KAAK,KAAK,MAHN;IAI5B,uBAAuBA,KAAK,KAAK,KAJL;IAK5B,0BAA0BA,KAAK,KAAK,QAAV,IAAsBA,KAAK,KAAK,KAL9B;IAM5B,2BAA2BE;EANC,eAO3BD,SAP2B,IAOfA,SAAS,IAAI,IAPE,eAA7B;EAUA,oBACC;IAAK,SAAS,EAAEI;EAAhB,GAAgCD,UAAhC,GACED,QADF,CADD;AAKA,CAnBM;AAqBPL,aAAa,CAACQ,SAAd,GAA0B;EACzBN,KAAK,EAAEJ,SAAS,CAACW,KAAV,CAAgB,CAAC,MAAD,EAAS,MAAT,EAAiB,KAAjB,EAAwB,QAAxB,EAAkC,KAAlC,CAAhB,CADkB;EAEzBN,SAAS,EAAEL,SAAS,CAACY,MAFI;EAGzBL,QAAQ,EAAEP,SAAS,CAACa,IAAV,CAAeC,UAHA;EAIzBR,iBAAiB,EAAEN,SAAS,CAACe;AAJJ,CAA1B;AAOAb,aAAa,CAACc,YAAd,GAA6B;EAC5BZ,KAAK,EAAE,MADqB;EAE5BE,iBAAiB,EAAE;AAFS,CAA7B;AAKAJ,aAAa,CAACe,MAAd,GAAuB;EACtB,QAAQ,MADc;EAEtB,QAAQ,MAFc;EAGtB,OAAO,KAHe;EAItBC,MAAM,EAAE,QAJc;EAKtB,OAAO;AALe,CAAvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-maintain-ratio",
3
- "version": "4.0.0-alpha.0",
3
+ "version": "4.0.2",
4
4
  "description": "Maintain ratio component for the NICE Design System",
5
5
  "author": "Ian Routledge <ian.routledge@nice.org.uk>",
6
6
  "homepage": "https://design-system.nice.org.uk/",
@@ -31,7 +31,7 @@
31
31
  "url": "https://github.com/nice-digital/nice-design-system/issues"
32
32
  },
33
33
  "dependencies": {
34
- "@nice-digital/nds-core": "^4.0.0-alpha.0",
34
+ "@nice-digital/nds-core": "^4.0.2",
35
35
  "classnames": "^2.3.1"
36
36
  },
37
37
  "peerDependencies": {
@@ -46,5 +46,5 @@
46
46
  "@types/node": "^18.11.9",
47
47
  "typescript": "^4.8.4"
48
48
  },
49
- "gitHead": "e225e0b15723013fb3df7309d197590a09cc2ea7"
49
+ "gitHead": "d8feb7beba5fffa49da42d6a550cb8f67a50727d"
50
50
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,28 +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 MaintainRatio_1 = require("./MaintainRatio");
6
- describe("nds-maintain-ratio", () => {
7
- it("should match the snapshot with no options", () => {
8
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(MaintainRatio_1.MaintainRatio, { children: (0, jsx_runtime_1.jsx)("p", { children: "Test" }) }));
9
- expect(wrapper).toMatchSnapshot();
10
- });
11
- it("should pass down classname and extra props", () => {
12
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(MaintainRatio_1.MaintainRatio, Object.assign({ className: "testing", "data-test": "yes" }, { children: (0, jsx_runtime_1.jsx)("p", { children: "Test" }) })));
13
- const ratioDiv = container.querySelector(".testing");
14
- expect(ratioDiv).toBeInTheDocument();
15
- expect(ratioDiv === null || ratioDiv === void 0 ? void 0 : ratioDiv.getAttribute("data-test")).toBe("yes");
16
- });
17
- Object.keys(MaintainRatio_1.ratios).forEach((ratio) => {
18
- it(`should apply the class for the ratio: ${ratio}`, () => {
19
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(MaintainRatio_1.MaintainRatio, Object.assign({ ratio: ratio }, { children: (0, jsx_runtime_1.jsx)("p", { children: "Test" }) })));
20
- if (ratio === "1:1") {
21
- expect(container.querySelector(".maintain-ratio--square")).toBeInTheDocument();
22
- }
23
- else {
24
- expect(container.querySelector(`.maintain-ratio--${ratio.replace(":", "-")}`)).toBeInTheDocument();
25
- }
26
- });
27
- });
28
- });