@dhis2-ui/switch 9.5.0 → 9.7.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.
@@ -31,4 +31,14 @@ describe('<Switch />', () => {
31
31
  }, expect.objectContaining({}));
32
32
  expect(onKeyDown).toHaveBeenCalledTimes(1);
33
33
  });
34
+ it('renders the switch with aria label', () => {
35
+ const ariaLabel = 'test switch';
36
+ (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_switch.Switch, {
37
+ "aria-label": ariaLabel,
38
+ name: "foo",
39
+ value: "bar",
40
+ checked: false
41
+ }));
42
+ expect(_react.screen.getAllByLabelText(ariaLabel)).toHaveLength(1);
43
+ });
34
44
  });
@@ -72,7 +72,7 @@ class Switch extends _react.Component {
72
72
 
73
73
  render() {
74
74
  const {
75
- ariaLabel,
75
+ 'aria-label': ariaLabel,
76
76
  checked,
77
77
  className,
78
78
  disabled,
@@ -138,7 +138,7 @@ Switch.defaultProps = {
138
138
  };
139
139
  Switch.propTypes = {
140
140
  /** Sets an aria-label attribute on the input */
141
- ariaLabel: _propTypes.default.string,
141
+ 'aria-label': _propTypes.default.string,
142
142
  checked: _propTypes.default.bool,
143
143
  className: _propTypes.default.string,
144
144
  dataTest: _propTypes.default.string,
@@ -22,4 +22,14 @@ describe('<Switch />', () => {
22
22
  }, expect.objectContaining({}));
23
23
  expect(onKeyDown).toHaveBeenCalledTimes(1);
24
24
  });
25
+ it('renders the switch with aria label', () => {
26
+ const ariaLabel = 'test switch';
27
+ render( /*#__PURE__*/React.createElement(Switch, {
28
+ "aria-label": ariaLabel,
29
+ name: "foo",
30
+ value: "bar",
31
+ checked: false
32
+ }));
33
+ expect(screen.getAllByLabelText(ariaLabel)).toHaveLength(1);
34
+ });
25
35
  });
@@ -55,7 +55,7 @@ class Switch extends Component {
55
55
 
56
56
  render() {
57
57
  const {
58
- ariaLabel,
58
+ 'aria-label': ariaLabel,
59
59
  checked,
60
60
  className,
61
61
  disabled,
@@ -120,7 +120,7 @@ Switch.defaultProps = {
120
120
  };
121
121
  Switch.propTypes = {
122
122
  /** Sets an aria-label attribute on the input */
123
- ariaLabel: PropTypes.string,
123
+ 'aria-label': PropTypes.string,
124
124
  checked: PropTypes.bool,
125
125
  className: PropTypes.string,
126
126
  dataTest: PropTypes.string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/switch",
3
- "version": "9.5.0",
3
+ "version": "9.7.0",
4
4
  "description": "UI Switch",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,9 +33,9 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2-ui/field": "9.5.0",
37
- "@dhis2-ui/required": "9.5.0",
38
- "@dhis2/ui-constants": "9.5.0",
36
+ "@dhis2-ui/field": "9.7.0",
37
+ "@dhis2-ui/required": "9.7.0",
38
+ "@dhis2/ui-constants": "9.7.0",
39
39
  "classnames": "^2.3.1",
40
40
  "prop-types": "^15.7.2"
41
41
  },
package/types/index.d.ts CHANGED
@@ -23,7 +23,7 @@ export interface SwitchProps {
23
23
  /**
24
24
  * Sets an aria-label attribute on the input
25
25
  */
26
- ariaLabel?: string
26
+ 'aria-label'?: string
27
27
  checked?: boolean
28
28
  className?: string
29
29
  dataTest?: string