@nice-digital/nds-checkbox 4.0.2-alpha.0 → 4.0.3

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/Checkbox.js CHANGED
@@ -28,7 +28,7 @@ const Checkbox = (props) => {
28
28
  "checkbox--inline": inline,
29
29
  "checkbox--error": error
30
30
  });
31
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [error && error.toString().length && ((0, jsx_runtime_1.jsx)("p", Object.assign({ className: "checkbox__error-message" }, { children: error }))), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: classNames }, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("input", Object.assign({ type: "checkbox", className: "checkbox__input", id: unique, name: name, value: value }, rest)), (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "checkbox__label", htmlFor: unique }, { children: label ? label : value })), hint && (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "checkbox__hint" }, { children: hint }))] }) }))] }));
31
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [error && error.toString().length && ((0, jsx_runtime_1.jsx)("p", Object.assign({ className: "checkbox__error-message" }, { children: error }))), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: classNames, "data-component": "checkbox" }, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("input", Object.assign({ type: "checkbox", className: "checkbox__input", id: unique, name: name, value: value }, rest)), (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "checkbox__label", htmlFor: unique }, { children: label ? label : value })), hint && (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "checkbox__hint" }, { children: hint }))] }) }))] }));
32
32
  };
33
33
  exports.Checkbox = Checkbox;
34
34
  exports.default = exports.Checkbox;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-checkbox",
3
- "version": "4.0.2-alpha.0",
3
+ "version": "4.0.3",
4
4
  "description": "Checkbox component for the NICE Design System",
5
5
  "author": "Warren Keith <warren.keith@nice.org.uk>",
6
6
  "homepage": "https://design-system.nice.org.uk/",
@@ -30,7 +30,7 @@
30
30
  "url": "https://github.com/nice-digital/nice-design-system/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@nice-digital/nds-core": "^4.0.2-alpha.0",
33
+ "@nice-digital/nds-core": "^4.0.3",
34
34
  "classnames": "^2.2.6"
35
35
  },
36
36
  "peerDependencies": {
@@ -45,5 +45,5 @@
45
45
  "@types/node": "^18.11.9",
46
46
  "typescript": "^4.8.4"
47
47
  },
48
- "gitHead": "4e9cad8a2b94cdf4af05b18a6610835883bedf0e"
48
+ "gitHead": "ae51389ba2e51dbe9ee3849e71d44fd567fb2822"
49
49
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,58 +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 Checkbox_1 = require("./../src/Checkbox");
6
- const props = {
7
- name: "contact-preference",
8
- label: "Email",
9
- value: "email",
10
- disabled: false,
11
- error: false
12
- };
13
- describe("Checkbox", () => {
14
- it("should match snapshot with some default attributes", () => {
15
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, Object.assign({}, props)));
16
- expect(wrapper).toMatchSnapshot();
17
- });
18
- it("should match snapshot with hint text supplied", () => {
19
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, Object.assign({}, props, { hint: "This is a hint to appear." })));
20
- expect(wrapper).toMatchSnapshot();
21
- });
22
- it("should not render a checkbox control if it doesn't have a value", () => {
23
- const localProps = Object.assign({}, props);
24
- localProps.value = "";
25
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, Object.assign({}, localProps)));
26
- expect(wrapper.queryByRole("checkbox")).toBe(null);
27
- });
28
- it("should prevent actions if the button is disabled", () => {
29
- const localProps = Object.assign({}, props);
30
- localProps.disabled = true;
31
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, Object.assign({}, localProps)));
32
- const input = wrapper.getByRole("checkbox");
33
- expect(input.disabled).toBe(true);
34
- });
35
- it("should add an error class to the parent if the error prop is true", () => {
36
- const localProps = Object.assign({}, props);
37
- localProps.error = true;
38
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, Object.assign({}, localProps)));
39
- const parent = container.querySelector("div.checkbox--error");
40
- expect(parent).toBeInTheDocument();
41
- });
42
- it("should add display error text above the control if an error string is supplied", () => {
43
- const localProps = Object.assign({}, props);
44
- localProps.error = "Error message here.";
45
- const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, Object.assign({}, localProps)));
46
- const parent = container.querySelector("p.checkbox__error-message");
47
- expect(parent === null || parent === void 0 ? void 0 : parent.textContent).toBe("Error message here.");
48
- });
49
- it("should pass through any additional attributes supplied", () => {
50
- const localProps = Object.assign({}, props);
51
- localProps.defaultChecked = true;
52
- localProps["data-something"] = "test";
53
- const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, Object.assign({}, localProps)));
54
- const checked = wrapper.getByRole("checkbox");
55
- expect(checked.checked).toBe(true);
56
- expect(checked.getAttribute("data-something")).toBe("test");
57
- });
58
- });