@nice-digital/nds-grid 4.0.3-alpha.0 → 4.0.4

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/GridItem.js CHANGED
@@ -43,6 +43,6 @@ const GridItem = (props) => {
43
43
  .concat(bpGridDefKeys)
44
44
  .filter((col) => col)
45
45
  .join(" ");
46
- return ((0, jsx_runtime_1.jsx)(GridItemElementType, Object.assign({ "data-g": gridColsAttr, className: className }, rest, { children: children })));
46
+ return ((0, jsx_runtime_1.jsx)(GridItemElementType, Object.assign({ "data-g": gridColsAttr, "data-component": "grid-item", className: className }, rest, { children: children })));
47
47
  };
48
48
  exports.GridItem = GridItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-grid",
3
- "version": "4.0.3-alpha.0",
3
+ "version": "4.0.4",
4
4
  "description": "Grid component for the NICE Design System",
5
5
  "keywords": [
6
6
  "grid"
@@ -33,13 +33,13 @@
33
33
  "url": "https://github.com/nice-digital/nice-design-system/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@nice-digital/nds-core": "^4.0.2-alpha.0",
36
+ "@nice-digital/nds-core": "^4.0.3",
37
37
  "classnames": "^2.2.6"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "^16 || ^17 || ^18"
41
41
  },
42
- "gitHead": "0a6b742ccd11300f0586abf5dc3790e217f70c21",
42
+ "gitHead": "ae51389ba2e51dbe9ee3849e71d44fd567fb2822",
43
43
  "devDependencies": {
44
44
  "@testing-library/jest-dom": "^5.16.5",
45
45
  "@testing-library/react": "^13.4.0",
package/es/Grid.test.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/es/Grid.test.js DELETED
@@ -1,75 +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 Grid_1 = require("./Grid");
6
- describe("Grid", () => {
7
- it("should match snapshot", () => {
8
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsxs)(Grid_1.Grid, { children: [(0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })), (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" }))] }));
9
- expect(wrapper).toMatchSnapshot();
10
- });
11
- it("should add rev class name to grid with reverse prop", () => {
12
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ reverse: true }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
13
- expect(container.querySelector(".grid")).toHaveClass("grid grid--rev");
14
- });
15
- describe("gutters", () => {
16
- const gutterTest = (gutter, expectedClassName) => {
17
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ gutter: gutter }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
18
- expect(container.querySelector(".grid")).toHaveClass(expectedClassName);
19
- };
20
- it("shouldn't add any class to grid with gutter prop as standard", () => {
21
- gutterTest(Grid_1.GutterEnum.standard, "grid");
22
- });
23
- it("should add gutterless class to grid with gutter prop as none", () => {
24
- gutterTest(Grid_1.GutterEnum.none, "grid grid--gutterless");
25
- });
26
- it("should add compact class to grid with gutter prop as compact", () => {
27
- gutterTest(Grid_1.GutterEnum.compact, "grid grid--compact");
28
- });
29
- it("should add compact class to grid with gutter prop as compact", () => {
30
- gutterTest(Grid_1.GutterEnum.loose, "grid grid--loose");
31
- });
32
- });
33
- describe("horizontal alignment", () => {
34
- const horizontalAlignmentTest = (hAlignment, expectedClassName) => {
35
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ horizontalAlignment: hAlignment }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
36
- expect(container.querySelector(".grid")).toHaveClass(expectedClassName);
37
- };
38
- it("shouldn't add any class to grid with horizontalAlignment prop as left", () => {
39
- horizontalAlignmentTest(Grid_1.HorizontalAlignmentEnum.left, "grid");
40
- });
41
- it("should add center modifier class to grid when horizontalAlignment prop set to center", () => {
42
- horizontalAlignmentTest(Grid_1.HorizontalAlignmentEnum.center, "grid grid--center");
43
- });
44
- it("should add right modifier class to grid when horizontalAlignment prop set to right", () => {
45
- horizontalAlignmentTest(Grid_1.HorizontalAlignmentEnum.right, "grid grid--right");
46
- });
47
- });
48
- describe("vertical alignment", () => {
49
- const verticalAlignmentTest = (vAlignment, expectedClassName) => {
50
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ verticalAlignment: vAlignment }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
51
- expect(container.querySelector(".grid")).toHaveClass(expectedClassName);
52
- };
53
- it("shouldn't add any class to grid with vertical alignment prop as top", () => {
54
- verticalAlignmentTest(Grid_1.VerticalAlignmentEnum.top, "grid");
55
- });
56
- it("should add middle modifier class to grid when verticalAlignment prop set to middle", () => {
57
- verticalAlignmentTest(Grid_1.VerticalAlignmentEnum.middle, "grid grid--middle");
58
- });
59
- it("should add bottom modifier class to grid when verticalAlignment prop set to bottom", () => {
60
- verticalAlignmentTest(Grid_1.VerticalAlignmentEnum.bottom, "grid grid--bottom");
61
- });
62
- });
63
- it("should add a debug modifier class when debug prop set to true", () => {
64
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ debug: true }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
65
- expect(container.querySelector(".grid")).toHaveClass("grid grid--debug");
66
- });
67
- it("should add given additional class names to rendered grid class names", () => {
68
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ className: "mt--d" }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
69
- expect(container.querySelector(".grid")).toHaveClass("grid mt--d");
70
- });
71
- it("should use elementType prop as rendered DOM node type", () => {
72
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ elementType: "ul" }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
73
- expect(wrapper.getByRole("list")).toBeInTheDocument();
74
- });
75
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,63 +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 Grid_1 = require("../src/Grid");
6
- describe("GridItem", () => {
7
- it("should match snapshot", () => {
8
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })));
9
- expect(wrapper).toMatchSnapshot();
10
- });
11
- it("should add push columns to data attribute", () => {
12
- var _a;
13
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6, push: 2 }, { children: "Test" })));
14
- expect((_a = container.querySelector("div")) === null || _a === void 0 ? void 0 : _a.getAttribute("data-g")).toBe("6 push:2");
15
- });
16
- it("should add pull columns to data attribute", () => {
17
- var _a;
18
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6, pull: 2 }, { children: "Test" })));
19
- expect((_a = container.querySelector("div")) === null || _a === void 0 ? void 0 : _a.getAttribute("data-g")).toBe("6 pull:2");
20
- });
21
- describe("breakpoints", () => {
22
- const pushDef = { cols: 4, push: 2, toString: () => "push 2" };
23
- const pullDef = { cols: 3, pull: 1, toString: () => "pull 1" };
24
- it.each([
25
- ["xs", 8, "xs:8"],
26
- ["xs", pushDef, "xs:4 xs:push:2"],
27
- ["xs", pullDef, "xs:3 xs:pull:1"],
28
- ["sm", 8, "sm:8"],
29
- ["sm", pushDef, "sm:4 sm:push:2"],
30
- ["sm", pullDef, "sm:3 sm:pull:1"],
31
- ["md", 8, "md:8"],
32
- ["md", pushDef, "md:4 md:push:2"],
33
- ["md", pullDef, "md:3 md:pull:1"],
34
- ["lg", 8, "lg:8"],
35
- ["lg", pushDef, "lg:4 lg:push:2"],
36
- ["lg", pullDef, "lg:3 lg:pull:1"],
37
- ["xl", 8, "xl:8"],
38
- ["xl", pushDef, "xl:4 xl:push:2"],
39
- ["xl", pullDef, "xl:3 xl:pull:1"]
40
- ])("for breakpoint '%s' and grid definition '%s' should set data-g to '%s'", (breakpointName, breakpointGridDef, expected) => {
41
- var _a;
42
- const cols = 6;
43
- const breakPointProps = {
44
- [breakpointName]: breakpointGridDef
45
- };
46
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: cols }, breakPointProps, { children: "Test" })));
47
- expect((_a = container.querySelector("div")) === null || _a === void 0 ? void 0 : _a.getAttribute("data-g")).toBe(cols + " " + expected);
48
- });
49
- });
50
- it("should add given additional class names to rendered grid item class names", () => {
51
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6, className: "mt--d" }, { children: "Test" })));
52
- expect(container.querySelector("[data-g]")).toHaveClass("mt--d");
53
- });
54
- it("should add other props to rendered grid item", () => {
55
- var _a;
56
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6, "aria-label": "test" }, { children: "Test" })));
57
- expect((_a = container.querySelector("[data-g]")) === null || _a === void 0 ? void 0 : _a.getAttribute("aria-label")).toBe("test");
58
- });
59
- it("should use elementType prop as rendered DOM node type", () => {
60
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6, elementType: "li" }, { children: "Test" })));
61
- expect(wrapper.getByRole("listitem")).toBeInTheDocument();
62
- });
63
- });