@dhis2-ui/switch 9.12.0-alpha.4 → 9.13.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.
@@ -7,7 +7,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
7
7
  describe('<Switch />', () => {
8
8
  it('should call the onKeyDown callback when provided', () => {
9
9
  const onKeyDown = jest.fn();
10
- (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_switch.Switch, {
10
+ (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_switch.Switch, {
11
11
  name: "foo",
12
12
  value: "bar",
13
13
  checked: false,
@@ -27,7 +27,7 @@ describe('<Switch />', () => {
27
27
  });
28
28
  it('renders the switch with aria label', () => {
29
29
  const ariaLabel = 'test switch';
30
- (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_switch.Switch, {
30
+ (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_switch.Switch, {
31
31
  "aria-label": ariaLabel,
32
32
  name: "foo",
33
33
  value: "bar",
@@ -56,7 +56,7 @@ class Switch extends _react.Component {
56
56
  render() {
57
57
  const {
58
58
  'aria-label': ariaLabel,
59
- checked,
59
+ checked = false,
60
60
  className,
61
61
  disabled,
62
62
  error,
@@ -67,8 +67,8 @@ class Switch extends _react.Component {
67
67
  value,
68
68
  warning,
69
69
  dense,
70
- dataTest,
71
- role
70
+ dataTest = 'dhis2-uicore-switch',
71
+ role = 'switch'
72
72
  } = this.props;
73
73
  const classes = (0, _classnames.default)({
74
74
  checked,
@@ -112,11 +112,11 @@ class Switch extends _react.Component {
112
112
  }
113
113
  }
114
114
  exports.Switch = Switch;
115
- Switch.defaultProps = {
115
+ _defineProperty(Switch, "defaultProps", {
116
116
  checked: false,
117
117
  dataTest: 'dhis2-uicore-switch',
118
118
  role: 'switch'
119
- };
119
+ });
120
120
  Switch.propTypes = {
121
121
  /** Sets an aria-label attribute on the input */
122
122
  'aria-label': _propTypes.default.string,
@@ -7,7 +7,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
7
7
  describe('<Switch />', () => {
8
8
  it('should call the onKeyDown callback when provided', () => {
9
9
  const onKeyDown = jest.fn();
10
- (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_switchField.SwitchField, {
10
+ (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_switchField.SwitchField, {
11
11
  label: "label",
12
12
  name: "foo",
13
13
  value: "bar",
@@ -47,7 +47,7 @@ const SwitchField = _ref2 => {
47
47
  required,
48
48
  helpText,
49
49
  validationText,
50
- dataTest
50
+ dataTest = 'dhis2-uiwidgets-switchfield'
51
51
  } = _ref2;
52
52
  return /*#__PURE__*/_react.default.createElement(_field.Field, {
53
53
  className: className,
@@ -83,9 +83,6 @@ const SwitchField = _ref2 => {
83
83
  }));
84
84
  };
85
85
  exports.SwitchField = SwitchField;
86
- SwitchField.defaultProps = {
87
- dataTest: 'dhis2-uiwidgets-switchfield'
88
- };
89
86
  SwitchField.propTypes = {
90
87
  checked: _propTypes.default.bool,
91
88
  className: _propTypes.default.string,
@@ -4,7 +4,7 @@ import { Switch } from '../switch.js';
4
4
  describe('<Switch />', () => {
5
5
  it('should call the onKeyDown callback when provided', () => {
6
6
  const onKeyDown = jest.fn();
7
- render( /*#__PURE__*/React.createElement(Switch, {
7
+ render(/*#__PURE__*/React.createElement(Switch, {
8
8
  name: "foo",
9
9
  value: "bar",
10
10
  checked: false,
@@ -24,7 +24,7 @@ describe('<Switch />', () => {
24
24
  });
25
25
  it('renders the switch with aria label', () => {
26
26
  const ariaLabel = 'test switch';
27
- render( /*#__PURE__*/React.createElement(Switch, {
27
+ render(/*#__PURE__*/React.createElement(Switch, {
28
28
  "aria-label": ariaLabel,
29
29
  name: "foo",
30
30
  value: "bar",
@@ -47,7 +47,7 @@ class Switch extends Component {
47
47
  render() {
48
48
  const {
49
49
  'aria-label': ariaLabel,
50
- checked,
50
+ checked = false,
51
51
  className,
52
52
  disabled,
53
53
  error,
@@ -58,8 +58,8 @@ class Switch extends Component {
58
58
  value,
59
59
  warning,
60
60
  dense,
61
- dataTest,
62
- role
61
+ dataTest = 'dhis2-uicore-switch',
62
+ role = 'switch'
63
63
  } = this.props;
64
64
  const classes = cx({
65
65
  checked,
@@ -102,11 +102,11 @@ class Switch extends Component {
102
102
  }, [`label.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;color:${colors.grey900};font-size:14px;line-height:19px;}`, "label.dense.__jsx-style-dynamic-selector{font-size:14px;line-height:16px;}", `label.disabled.__jsx-style-dynamic-selector{cursor:not-allowed;color:${theme.disabled};}`, "input.__jsx-style-dynamic-selector{opacity:0;position:absolute;height:18px;width:35px;margin-left:3px;}", "label.dense.__jsx-style-dynamic-selector input.__jsx-style-dynamic-selector{height:14px;width:27px;}", ".icon.__jsx-style-dynamic-selector{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;margin-right:5px;border:2px solid transparent;padding:1px;border-radius:14px;}", "label.dense.__jsx-style-dynamic-selector .icon.__jsx-style-dynamic-selector{margin-right:3px;border-radius:12px;}", `input.__jsx-style-dynamic-selector:focus+.icon.__jsx-style-dynamic-selector{outline:3px solid ${theme.focus};outline-offset:-3px;}`]));
103
103
  }
104
104
  }
105
- Switch.defaultProps = {
105
+ _defineProperty(Switch, "defaultProps", {
106
106
  checked: false,
107
107
  dataTest: 'dhis2-uicore-switch',
108
108
  role: 'switch'
109
- };
109
+ });
110
110
  Switch.propTypes = {
111
111
  /** Sets an aria-label attribute on the input */
112
112
  'aria-label': PropTypes.string,
@@ -4,7 +4,7 @@ import { SwitchField } from '../switch-field.js';
4
4
  describe('<Switch />', () => {
5
5
  it('should call the onKeyDown callback when provided', () => {
6
6
  const onKeyDown = jest.fn();
7
- render( /*#__PURE__*/React.createElement(SwitchField, {
7
+ render(/*#__PURE__*/React.createElement(SwitchField, {
8
8
  label: "label",
9
9
  name: "foo",
10
10
  value: "bar",
@@ -40,7 +40,7 @@ const SwitchField = _ref2 => {
40
40
  required,
41
41
  helpText,
42
42
  validationText,
43
- dataTest
43
+ dataTest = 'dhis2-uiwidgets-switchfield'
44
44
  } = _ref2;
45
45
  return /*#__PURE__*/React.createElement(Field, {
46
46
  className: className,
@@ -75,9 +75,6 @@ const SwitchField = _ref2 => {
75
75
  initialFocus: initialFocus
76
76
  }));
77
77
  };
78
- SwitchField.defaultProps = {
79
- dataTest: 'dhis2-uiwidgets-switchfield'
80
- };
81
78
  SwitchField.propTypes = {
82
79
  checked: PropTypes.bool,
83
80
  className: PropTypes.string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/switch",
3
- "version": "9.12.0-alpha.4",
3
+ "version": "9.13.0",
4
4
  "description": "UI Switch",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,15 +27,15 @@
27
27
  "test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
28
28
  },
29
29
  "peerDependencies": {
30
- "react": "^16.13",
31
- "react-dom": "^16.13",
30
+ "react": "^16.13 || ^18",
31
+ "react-dom": "^16.13 || ^18",
32
32
  "styled-jsx": "^4"
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2-ui/field": "9.12.0-alpha.4",
37
- "@dhis2-ui/required": "9.12.0-alpha.4",
38
- "@dhis2/ui-constants": "9.12.0-alpha.4",
36
+ "@dhis2-ui/field": "9.13.0",
37
+ "@dhis2-ui/required": "9.13.0",
38
+ "@dhis2/ui-constants": "9.13.0",
39
39
  "classnames": "^2.3.1",
40
40
  "prop-types": "^15.7.2"
41
41
  },
@@ -44,8 +44,8 @@
44
44
  "types"
45
45
  ],
46
46
  "devDependencies": {
47
- "react": "16.13",
48
- "react-dom": "16.13",
47
+ "react": "^18.3.1",
48
+ "react-dom": "^18.3.1",
49
49
  "styled-jsx": "^4.0.1"
50
50
  },
51
51
  "types": "types"