@nice-digital/nds-container 3.0.2 → 4.0.1-alpha.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.
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import "../scss/container.scss";
3
+ export interface ContainerProps {
4
+ /** Allow any additional props to be passed and applied to the container */
5
+ [prop: string]: unknown;
6
+ /** Contents for the container element */
7
+ children: React.ReactNode;
8
+ /** Additional classes to add to the container */
9
+ className?: string;
10
+ /** Allow the container to defy the max-width and extend to the edges of the viewport */
11
+ fullWidth?: boolean;
12
+ /** The type of DOM node to render for the container item. Leave blank to default to div. */
13
+ elementType?: React.ElementType;
14
+ }
15
+ export declare const Container: React.FC<ContainerProps>;
package/es/Container.js CHANGED
@@ -1,27 +1,30 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- var _excluded = ["children", "className", "elementType", "fullWidth"];
4
- import React from "react";
5
- import PropTypes from "prop-types";
6
- import classnames from "classnames";
7
- import "../scss/container.scss";
8
- export var Container = function Container(props) {
9
- var children = props.children,
10
- className = props.className,
11
- _props$elementType = props.elementType,
12
- ElementType = _props$elementType === void 0 ? "div" : _props$elementType,
13
- fullWidth = props.fullWidth,
14
- rest = _objectWithoutPropertiesLoose(props, _excluded);
15
-
16
- var classes = classnames(["container", fullWidth && "container--full", className]);
17
- return /*#__PURE__*/React.createElement(ElementType, _extends({
18
- className: classes
19
- }, rest), children);
20
- };
21
- Container.propTypes = {
22
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
23
- className: PropTypes.string,
24
- elementType: PropTypes.elementType,
25
- fullWidth: PropTypes.bool
26
- };
27
- //# sourceMappingURL=Container.js.map
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Container = void 0;
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
+ const classnames_1 = __importDefault(require("classnames"));
20
+ require("../scss/container.scss");
21
+ const Container = (props) => {
22
+ const { children, className, elementType: ElementType = "div", fullWidth } = props, rest = __rest(props, ["children", "className", "elementType", "fullWidth"]);
23
+ const classes = (0, classnames_1.default)([
24
+ "container",
25
+ fullWidth && "container--full",
26
+ className
27
+ ]);
28
+ return ((0, jsx_runtime_1.jsx)(ElementType, Object.assign({ className: classes }, rest, { children: children })));
29
+ };
30
+ exports.Container = Container;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
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 Container_1 = require("./Container");
6
+ const Content = () => (0, jsx_runtime_1.jsx)("p", { children: "Test" });
7
+ describe("Container", () => {
8
+ it("should match snapshot", () => {
9
+ const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Container_1.Container, { children: (0, jsx_runtime_1.jsx)(Content, {}) }));
10
+ expect(wrapper).toMatchSnapshot();
11
+ });
12
+ it("should add additional classNames", () => {
13
+ const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Container_1.Container, Object.assign({ className: "testclass" }, { children: (0, jsx_runtime_1.jsx)(Content, {}) })));
14
+ expect(container.querySelector(".container")).toHaveClass("testclass");
15
+ });
16
+ it("should add full width class if bool supplied", () => {
17
+ const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Container_1.Container, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Content, {}) })));
18
+ expect(container.querySelector(".container")).toHaveClass("container--full");
19
+ });
20
+ it("should use elementType prop as rendered DOM node type", () => {
21
+ const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Container_1.Container, Object.assign({ elementType: "main" }, { children: (0, jsx_runtime_1.jsx)(Content, {}) })));
22
+ expect(wrapper.getByRole("main")).toHaveClass("container");
23
+ });
24
+ it("should spread other props against the container", () => {
25
+ var _a;
26
+ const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Container_1.Container, Object.assign({ "data-track": "trackme" }, { children: (0, jsx_runtime_1.jsx)(Content, {}) })));
27
+ expect((_a = container.querySelector(".container")) === null || _a === void 0 ? void 0 : _a.getAttribute("data-track")).toBe("trackme");
28
+ });
29
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-container",
3
- "version": "3.0.2",
3
+ "version": "4.0.1-alpha.0",
4
4
  "description": "Container component for the NICE Design System",
5
5
  "keywords": [
6
6
  "container"
@@ -8,16 +8,12 @@
8
8
  "author": "Warren Keith <warren.keith@nice.org.uk>",
9
9
  "homepage": "https://design-system.nice.org.uk/",
10
10
  "license": "MIT",
11
- "main": "lib/Container.js",
12
- "module": "es/Container.js",
11
+ "main": "es/Container.js",
13
12
  "style": "scss/container.scss",
14
- "types": "nds-container.d.ts",
15
13
  "directories": {
16
- "lib": "lib",
17
14
  "test": "__tests__"
18
15
  },
19
16
  "files": [
20
- "lib",
21
17
  "es",
22
18
  "scss",
23
19
  "*.d.ts"
@@ -37,12 +33,19 @@
37
33
  "url": "https://github.com/nice-digital/nice-design-system/issues"
38
34
  },
39
35
  "dependencies": {
40
- "@nice-digital/nds-core": "^3.0.2",
41
- "classnames": "^2.2.6",
42
- "prop-types": "^15.7.2"
36
+ "@nice-digital/nds-core": "^4.0.1-alpha.0",
37
+ "classnames": "^2.2.6"
43
38
  },
44
39
  "peerDependencies": {
45
40
  "react": "^16 || ^17 || ^18"
46
41
  },
47
- "gitHead": "88329347c4985509b2347ecc27daec0a33aef607"
42
+ "gitHead": "e75957040c9acfbd7eeb164cad724e3b48760679",
43
+ "devDependencies": {
44
+ "@testing-library/jest-dom": "^5.16.5",
45
+ "@testing-library/react": "^13.4.0",
46
+ "@testing-library/user-event": "^14.4.3",
47
+ "@types/jest": "^29.2.2",
48
+ "@types/node": "^18.11.9",
49
+ "typescript": "^4.8.4"
50
+ }
48
51
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"Container.js","names":["React","PropTypes","classnames","Container","props","children","className","elementType","ElementType","fullWidth","rest","classes","propTypes","oneOfType","arrayOf","node","isRequired","string","bool"],"sources":["../src/Container.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport classnames from \"classnames\";\nimport \"../scss/container.scss\";\n\nexport const Container = (props) => {\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\telementType: ElementType = \"div\",\n\t\tfullWidth,\n\t\t...rest\n\t} = props;\n\n\tconst classes = classnames([\n\t\t\"container\",\n\t\tfullWidth && \"container--full\",\n\t\tclassName\n\t]);\n\n\treturn (\n\t\t<ElementType className={classes} {...rest}>\n\t\t\t{children}\n\t\t</ElementType>\n\t);\n};\n\nContainer.propTypes = {\n\tchildren: PropTypes.oneOfType([\n\t\tPropTypes.arrayOf(PropTypes.node),\n\t\tPropTypes.node\n\t]).isRequired,\n\tclassName: PropTypes.string,\n\telementType: PropTypes.elementType,\n\tfullWidth: PropTypes.bool\n};\n"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAO,wBAAP;AAEA,OAAO,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,KAAD,EAAW;EACnC,IACCC,QADD,GAMID,KANJ,CACCC,QADD;EAAA,IAECC,SAFD,GAMIF,KANJ,CAECE,SAFD;EAAA,yBAMIF,KANJ,CAGCG,WAHD;EAAA,IAGcC,WAHd,mCAG4B,KAH5B;EAAA,IAICC,SAJD,GAMIL,KANJ,CAICK,SAJD;EAAA,IAKIC,IALJ,iCAMIN,KANJ;;EAQA,IAAMO,OAAO,GAAGT,UAAU,CAAC,CAC1B,WAD0B,EAE1BO,SAAS,IAAI,iBAFa,EAG1BH,SAH0B,CAAD,CAA1B;EAMA,oBACC,oBAAC,WAAD;IAAa,SAAS,EAAEK;EAAxB,GAAqCD,IAArC,GACEL,QADF,CADD;AAKA,CApBM;AAsBPF,SAAS,CAACS,SAAV,GAAsB;EACrBP,QAAQ,EAAEJ,SAAS,CAACY,SAAV,CAAoB,CAC7BZ,SAAS,CAACa,OAAV,CAAkBb,SAAS,CAACc,IAA5B,CAD6B,EAE7Bd,SAAS,CAACc,IAFmB,CAApB,EAGPC,UAJkB;EAKrBV,SAAS,EAAEL,SAAS,CAACgB,MALA;EAMrBV,WAAW,EAAEN,SAAS,CAACM,WANF;EAOrBE,SAAS,EAAER,SAAS,CAACiB;AAPA,CAAtB"}
package/lib/Container.js DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
6
- exports.Container = void 0;
7
-
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
-
10
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
-
12
- var _react = _interopRequireDefault(require("react"));
13
-
14
- var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
- var _classnames = _interopRequireDefault(require("classnames"));
17
-
18
- require("../scss/container.scss");
19
-
20
- var _excluded = ["children", "className", "elementType", "fullWidth"];
21
-
22
- var _jsxFileName = "C:\\dev\\nice-design-system\\components\\nds-container\\src\\Container.js",
23
- _this = void 0;
24
-
25
- var Container = function Container(props) {
26
- var children = props.children,
27
- className = props.className,
28
- _props$elementType = props.elementType,
29
- ElementType = _props$elementType === void 0 ? "div" : _props$elementType,
30
- fullWidth = props.fullWidth,
31
- rest = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
32
- var classes = (0, _classnames["default"])(["container", fullWidth && "container--full", className]);
33
- return /*#__PURE__*/_react["default"].createElement(ElementType, (0, _extends2["default"])({
34
- className: classes
35
- }, rest, {
36
- __self: _this,
37
- __source: {
38
- fileName: _jsxFileName,
39
- lineNumber: 22,
40
- columnNumber: 3
41
- }
42
- }), children);
43
- };
44
-
45
- exports.Container = Container;
46
- Container.propTypes = {
47
- children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired,
48
- className: _propTypes["default"].string,
49
- elementType: _propTypes["default"].elementType,
50
- fullWidth: _propTypes["default"].bool
51
- };
52
- //# sourceMappingURL=Container.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Container.js","names":["Container","props","children","className","elementType","ElementType","fullWidth","rest","classes","classnames","propTypes","PropTypes","oneOfType","arrayOf","node","isRequired","string","bool"],"sources":["../src/Container.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport classnames from \"classnames\";\nimport \"../scss/container.scss\";\n\nexport const Container = (props) => {\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\telementType: ElementType = \"div\",\n\t\tfullWidth,\n\t\t...rest\n\t} = props;\n\n\tconst classes = classnames([\n\t\t\"container\",\n\t\tfullWidth && \"container--full\",\n\t\tclassName\n\t]);\n\n\treturn (\n\t\t<ElementType className={classes} {...rest}>\n\t\t\t{children}\n\t\t</ElementType>\n\t);\n};\n\nContainer.propTypes = {\n\tchildren: PropTypes.oneOfType([\n\t\tPropTypes.arrayOf(PropTypes.node),\n\t\tPropTypes.node\n\t]).isRequired,\n\tclassName: PropTypes.string,\n\telementType: PropTypes.elementType,\n\tfullWidth: PropTypes.bool\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;AAEO,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,KAAD,EAAW;EACnC,IACCC,QADD,GAMID,KANJ,CACCC,QADD;EAAA,IAECC,SAFD,GAMIF,KANJ,CAECE,SAFD;EAAA,yBAMIF,KANJ,CAGCG,WAHD;EAAA,IAGcC,WAHd,mCAG4B,KAH5B;EAAA,IAICC,SAJD,GAMIL,KANJ,CAICK,SAJD;EAAA,IAKIC,IALJ,kDAMIN,KANJ;EAQA,IAAMO,OAAO,GAAG,IAAAC,sBAAA,EAAW,CAC1B,WAD0B,EAE1BH,SAAS,IAAI,iBAFa,EAG1BH,SAH0B,CAAX,CAAhB;EAMA,oBACC,gCAAC,WAAD;IAAa,SAAS,EAAEK;EAAxB,GAAqCD,IAArC;IAAA;IAAA;MAAA;MAAA;MAAA;IAAA;EAAA,IACEL,QADF,CADD;AAKA,CApBM;;;AAsBPF,SAAS,CAACU,SAAV,GAAsB;EACrBR,QAAQ,EAAES,qBAAA,CAAUC,SAAV,CAAoB,CAC7BD,qBAAA,CAAUE,OAAV,CAAkBF,qBAAA,CAAUG,IAA5B,CAD6B,EAE7BH,qBAAA,CAAUG,IAFmB,CAApB,EAGPC,UAJkB;EAKrBZ,SAAS,EAAEQ,qBAAA,CAAUK,MALA;EAMrBZ,WAAW,EAAEO,qBAAA,CAAUP,WANF;EAOrBE,SAAS,EAAEK,qBAAA,CAAUM;AAPA,CAAtB"}
@@ -1,19 +0,0 @@
1
- declare module "@nice-digital/nds-container" {
2
- import React = require("react");
3
-
4
- export interface ContainerProps {
5
- /** Allow any additional props to be passed and applied to the container */
6
- [prop: string]: unknown;
7
- /** Contents for the container element */
8
- children: React.ReactNode;
9
- /** Additional classes to add to the container */
10
- className?: string;
11
- /** Allow the container to defy the max-width and extend to the edges of the viewport */
12
- fullWidth?: boolean;
13
- /** The type of DOM node to render for the container item. Leave blank to default to div. */
14
- elementType?: React.ElementType;
15
- }
16
-
17
- /** A wrapper to house child grids */
18
- export const Container: React.FC<ContainerProps>;
19
- }