@dhis2-ui/checkbox 9.11.0 → 9.11.1-beta.2

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.
Files changed (39) hide show
  1. package/build/cjs/checkbox/__tests__/checkbox.test.js +1 -7
  2. package/build/cjs/checkbox/checkbox-icon.js +14 -24
  3. package/build/cjs/checkbox/checkbox.e2e.stories.js +72 -0
  4. package/build/cjs/checkbox/checkbox.js +7 -31
  5. package/build/cjs/checkbox/{checkbox.stories.js → checkbox.prod.stories.js} +54 -74
  6. package/build/cjs/checkbox/features/accepts_initial_focus/index.js +1 -2
  7. package/build/cjs/checkbox/features/accepts_label/index.js +0 -1
  8. package/build/cjs/checkbox/features/can_be_blurred/index.js +1 -2
  9. package/build/cjs/checkbox/features/can_be_changed/index.js +1 -2
  10. package/build/cjs/checkbox/features/can_be_disabled/index.js +1 -2
  11. package/build/cjs/checkbox/features/can_be_focused/index.js +1 -2
  12. package/build/cjs/checkbox/features/has_indeterminate_prop/index.js +0 -1
  13. package/build/cjs/checkbox/index.js +0 -1
  14. package/build/cjs/checkbox-field/__tests__/checkbox-field.test.js +1 -7
  15. package/build/cjs/checkbox-field/checkbox-field.e2e.stories.js +39 -0
  16. package/build/cjs/checkbox-field/checkbox-field.js +4 -30
  17. package/build/cjs/checkbox-field/{checkbox-field.stories.js → checkbox-field.prod.stories.js} +59 -74
  18. package/build/cjs/checkbox-field/features/accepts_help_text/index.js +0 -1
  19. package/build/cjs/checkbox-field/features/accepts_label/index.js +0 -1
  20. package/build/cjs/checkbox-field/features/accepts_validation_text/index.js +0 -1
  21. package/build/cjs/checkbox-field/features/can_be_required/index.js +0 -1
  22. package/build/cjs/checkbox-field/index.js +0 -1
  23. package/build/cjs/index.js +0 -2
  24. package/build/es/checkbox/checkbox-icon.js +13 -13
  25. package/build/es/checkbox/{checkbox.stories.e2e.js → checkbox.e2e.stories.js} +19 -10
  26. package/build/es/checkbox/checkbox.js +4 -19
  27. package/build/es/checkbox/{checkbox.stories.js → checkbox.prod.stories.js} +35 -25
  28. package/build/es/checkbox/features/accepts_initial_focus/index.js +1 -1
  29. package/build/es/checkbox/features/can_be_blurred/index.js +1 -1
  30. package/build/es/checkbox/features/can_be_changed/index.js +1 -1
  31. package/build/es/checkbox/features/can_be_disabled/index.js +1 -1
  32. package/build/es/checkbox/features/can_be_focused/index.js +1 -1
  33. package/build/es/checkbox-field/checkbox-field.e2e.stories.js +28 -0
  34. package/build/es/checkbox-field/checkbox-field.js +3 -22
  35. package/build/es/checkbox-field/{checkbox-field.stories.js → checkbox-field.prod.stories.js} +38 -23
  36. package/package.json +7 -7
  37. package/build/cjs/checkbox/checkbox.stories.e2e.js +0 -55
  38. package/build/cjs/checkbox-field/checkbox-field.stories.e2e.js +0 -30
  39. package/build/es/checkbox-field/checkbox-field.stories.e2e.js +0 -23
@@ -4,47 +4,44 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.WarningDense = exports.Warning = exports.ValidDense = exports.Valid = exports.RTL = exports.IndeterminateDense = exports.Indeterminate = exports.ImageLabelDense = exports.ImageLabel = exports.FocusedUncheckedDense = exports.FocusedUnchecked = exports.FocusedCheckedDense = exports.FocusedChecked = exports.ErrorDense = exports.Error = exports.DisabledDense = exports.Disabled = exports.DefaultDense = exports.Default = exports.CheckedDense = exports.Checked = void 0;
7
-
8
7
  var _uiConstants = require("@dhis2/ui-constants");
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _index = require("./index.js");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
12
+ const subtitle = 'A checkbox is a control that allows a user to toggle an option.';
13
+ const description = `
14
+ Checkboxes are used when an option can be toggled on or off. Toggling a checkbox on (true) is always considered a positive action and should reflect a positive/true/on state. Multiple checkboxes can be used in a list where a user can toggle multiple elements.
13
15
 
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
16
+ Do not use checkboxes in a list of several options where only a single option can be toggled, use [radio buttons](../?path=/docs/forms-radio-radio--default) here instead.
17
17
 
18
- const subtitle = 'A checkbox is a control that allows a user to toggle an option.';
19
- const description = "\nCheckboxes are used when an option can be toggled on or off. Toggling a checkbox on (true) is always considered a positive action and should reflect a positive/true/on state. Multiple checkboxes can be used in a list where a user can toggle multiple elements.\n\nDo not use checkboxes in a list of several options where only a single option can be toggled, use [radio buttons](../?path=/docs/forms-radio-radio--default) here instead.\n\nIf there are many options that need to select from, consider using a [select](../?path=/docs/forms-single-select-single-select--with-options) instead.\n\n```js\nimport { Checkbox } from '@dhis2/ui'\n```\n";
18
+ If there are many options that need to select from, consider using a [select](../?path=/docs/forms-single-select-single-select--with-options) instead.
20
19
 
20
+ \`\`\`js
21
+ import { Checkbox } from '@dhis2/ui'
22
+ \`\`\`
23
+ `;
21
24
  window.onChange = (payload, event) => {
22
25
  console.log('onClick payload', payload);
23
26
  console.log('onClick event', event);
24
27
  };
25
-
26
28
  window.onFocus = (payload, event) => {
27
29
  console.log('onFocus payload', payload);
28
30
  console.log('onFocus event', event);
29
31
  };
30
-
31
32
  window.onBlur = (payload, event) => {
32
33
  console.log('onBlur payload', payload);
33
34
  console.log('onBlur event', event);
34
35
  };
35
-
36
36
  const onChange = function () {
37
37
  return window.onChange(...arguments);
38
38
  };
39
-
40
39
  const onFocus = function () {
41
40
  return window.onFocus(...arguments);
42
41
  };
43
-
44
42
  const onBlur = function () {
45
43
  return window.onBlur(...arguments);
46
44
  };
47
-
48
45
  const defaultArgs = {
49
46
  name: 'Ex',
50
47
  label: 'Checkbox',
@@ -63,7 +60,7 @@ const uniqueOnStateArgType = {
63
60
  type: 'boolean'
64
61
  }
65
62
  };
66
- var _default = {
63
+ var _default = exports.default = {
67
64
  title: 'Checkbox',
68
65
  component: _index.Checkbox,
69
66
  parameters: {
@@ -75,35 +72,35 @@ var _default = {
75
72
  }
76
73
  },
77
74
  // Sets default args on all stories unless overridden
78
- args: { ...defaultArgs
75
+ args: {
76
+ ...defaultArgs
79
77
  },
80
78
  argTypes: {
81
- checked: { ...uniqueOnStateArgType
79
+ checked: {
80
+ ...uniqueOnStateArgType
82
81
  },
83
- indeterminate: { ...uniqueOnStateArgType
82
+ indeterminate: {
83
+ ...uniqueOnStateArgType
84
84
  },
85
- valid: { ..._uiConstants.sharedPropTypes.statusArgType
85
+ valid: {
86
+ ..._uiConstants.sharedPropTypes.statusArgType
86
87
  },
87
- warning: { ..._uiConstants.sharedPropTypes.statusArgType
88
+ warning: {
89
+ ..._uiConstants.sharedPropTypes.statusArgType
88
90
  },
89
- error: { ..._uiConstants.sharedPropTypes.statusArgType
91
+ error: {
92
+ ..._uiConstants.sharedPropTypes.statusArgType
90
93
  }
91
94
  }
92
95
  };
93
- exports.default = _default;
94
-
95
96
  const Template = args => /*#__PURE__*/_react.default.createElement(_index.Checkbox, args);
96
-
97
97
  const CheckedUncheckedTemplate = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.Checkbox, args), /*#__PURE__*/_react.default.createElement(_index.Checkbox, _extends({
98
98
  checked: true
99
99
  }, args)));
100
-
101
- const Default = Template.bind({});
102
- exports.Default = Default;
100
+ const Default = exports.Default = Template.bind({});
103
101
  Default.args = {
104
102
  value: 'default'
105
103
  };
106
-
107
104
  const FocusedUnchecked = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.Checkbox, _extends({
108
105
  initialFocus: true,
109
106
  value: "default",
@@ -112,20 +109,17 @@ const FocusedUnchecked = args => /*#__PURE__*/_react.default.createElement(_reac
112
109
  value: "default2",
113
110
  className: "initially-unfocused"
114
111
  }, args)));
115
-
116
112
  exports.FocusedUnchecked = FocusedUnchecked;
117
113
  FocusedUnchecked.storyName = 'Focused unchecked';
118
114
  /**
119
115
  * 'initialFocus' causes docs page to scroll away every time a control is
120
116
  * changed, so it's disabled
121
117
  */
122
-
123
118
  FocusedUnchecked.parameters = {
124
119
  docs: {
125
120
  disable: true
126
121
  }
127
122
  };
128
-
129
123
  const FocusedChecked = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.Checkbox, _extends({
130
124
  initialFocus: true,
131
125
  checked: true,
@@ -134,7 +128,6 @@ const FocusedChecked = args => /*#__PURE__*/_react.default.createElement(_react.
134
128
  checked: true,
135
129
  value: "default2"
136
130
  }, args)));
137
-
138
131
  exports.FocusedChecked = FocusedChecked;
139
132
  FocusedChecked.storyName = 'Focused checked';
140
133
  FocusedChecked.parameters = {
@@ -142,59 +135,50 @@ FocusedChecked.parameters = {
142
135
  disable: true
143
136
  }
144
137
  };
145
- const Checked = Template.bind({});
146
- exports.Checked = Checked;
138
+ const Checked = exports.Checked = Template.bind({});
147
139
  Checked.args = {
148
140
  checked: true,
149
141
  value: 'checked'
150
142
  };
151
- const Indeterminate = Template.bind({});
152
- exports.Indeterminate = Indeterminate;
143
+ const Indeterminate = exports.Indeterminate = Template.bind({});
153
144
  Indeterminate.args = {
154
145
  indeterminate: true,
155
146
  value: 'checked'
156
147
  };
157
- const Disabled = CheckedUncheckedTemplate.bind({});
158
- exports.Disabled = Disabled;
148
+ const Disabled = exports.Disabled = CheckedUncheckedTemplate.bind({});
159
149
  Disabled.args = {
160
150
  disabled: true,
161
151
  value: 'disabled'
162
152
  };
163
- const Valid = CheckedUncheckedTemplate.bind({});
164
- exports.Valid = Valid;
153
+ const Valid = exports.Valid = CheckedUncheckedTemplate.bind({});
165
154
  Valid.args = {
166
155
  valid: true,
167
156
  value: 'valid'
168
157
  };
169
- const Warning = CheckedUncheckedTemplate.bind({});
170
- exports.Warning = Warning;
158
+ const Warning = exports.Warning = CheckedUncheckedTemplate.bind({});
171
159
  Warning.args = {
172
160
  warning: true,
173
161
  value: 'warning'
174
162
  };
175
- const Error = CheckedUncheckedTemplate.bind({});
176
- exports.Error = Error;
163
+ const Error = exports.Error = CheckedUncheckedTemplate.bind({});
177
164
  Error.args = {
178
165
  error: true,
179
166
  value: 'error'
180
167
  };
181
- const ImageLabel = Template.bind({});
182
- exports.ImageLabel = ImageLabel;
168
+ const ImageLabel = exports.ImageLabel = Template.bind({});
183
169
  ImageLabel.args = {
184
170
  label: /*#__PURE__*/_react.default.createElement("img", {
185
171
  src: "https://picsum.photos/id/82/200/100"
186
172
  }),
187
173
  value: 'with-help'
188
174
  };
189
- const DefaultDense = Template.bind({});
190
- exports.DefaultDense = DefaultDense;
175
+ const DefaultDense = exports.DefaultDense = Template.bind({});
191
176
  DefaultDense.args = {
192
177
  dense: true,
193
178
  value: 'default'
194
179
  };
195
180
  DefaultDense.storyName = 'Default - Dense';
196
- const FocusedUncheckedDense = Template.bind({});
197
- exports.FocusedUncheckedDense = FocusedUncheckedDense;
181
+ const FocusedUncheckedDense = exports.FocusedUncheckedDense = Template.bind({});
198
182
  FocusedUncheckedDense.args = {
199
183
  dense: true,
200
184
  initialFocus: true,
@@ -206,9 +190,9 @@ FocusedUncheckedDense.parameters = {
206
190
  disable: true
207
191
  }
208
192
  };
209
- const FocusedCheckedDense = Template.bind({});
210
- exports.FocusedCheckedDense = FocusedCheckedDense;
211
- FocusedCheckedDense.args = { ...FocusedUncheckedDense.args,
193
+ const FocusedCheckedDense = exports.FocusedCheckedDense = Template.bind({});
194
+ FocusedCheckedDense.args = {
195
+ ...FocusedUncheckedDense.args,
212
196
  checked: true
213
197
  };
214
198
  FocusedCheckedDense.storyName = 'Focused checked - Dense';
@@ -217,55 +201,51 @@ FocusedCheckedDense.parameters = {
217
201
  disable: true
218
202
  }
219
203
  };
220
- const CheckedDense = Template.bind({});
221
- exports.CheckedDense = CheckedDense;
204
+ const CheckedDense = exports.CheckedDense = Template.bind({});
222
205
  CheckedDense.args = {
223
206
  dense: true,
224
207
  checked: true,
225
208
  value: 'checked'
226
209
  };
227
210
  CheckedDense.storyName = 'Checked - Dense';
228
- const IndeterminateDense = Template.bind({});
229
- exports.IndeterminateDense = IndeterminateDense;
211
+ const IndeterminateDense = exports.IndeterminateDense = Template.bind({});
230
212
  IndeterminateDense.args = {
231
213
  dense: true,
232
214
  indeterminate: true,
233
215
  value: 'checked'
234
216
  };
235
217
  IndeterminateDense.storyName = 'Indeterminate - Dense';
236
- const DisabledDense = CheckedUncheckedTemplate.bind({});
237
- exports.DisabledDense = DisabledDense;
238
- DisabledDense.args = { ...Disabled.args,
218
+ const DisabledDense = exports.DisabledDense = CheckedUncheckedTemplate.bind({});
219
+ DisabledDense.args = {
220
+ ...Disabled.args,
239
221
  dense: true
240
222
  };
241
223
  DisabledDense.storyName = 'Disabled - Dense';
242
- const ValidDense = CheckedUncheckedTemplate.bind({});
243
- exports.ValidDense = ValidDense;
244
- ValidDense.args = { ...Valid.args,
224
+ const ValidDense = exports.ValidDense = CheckedUncheckedTemplate.bind({});
225
+ ValidDense.args = {
226
+ ...Valid.args,
245
227
  dense: true
246
228
  };
247
229
  ValidDense.storyName = 'Valid - Dense';
248
- const WarningDense = CheckedUncheckedTemplate.bind({});
249
- exports.WarningDense = WarningDense;
250
- WarningDense.args = { ...Warning.args,
230
+ const WarningDense = exports.WarningDense = CheckedUncheckedTemplate.bind({});
231
+ WarningDense.args = {
232
+ ...Warning.args,
251
233
  dense: true
252
234
  };
253
235
  WarningDense.storyName = 'Warning - Dense';
254
- const ErrorDense = CheckedUncheckedTemplate.bind({});
255
- exports.ErrorDense = ErrorDense;
256
- ErrorDense.args = { ...Error.args,
236
+ const ErrorDense = exports.ErrorDense = CheckedUncheckedTemplate.bind({});
237
+ ErrorDense.args = {
238
+ ...Error.args,
257
239
  dense: true
258
240
  };
259
241
  ErrorDense.storyName = 'Error - Dense';
260
- const ImageLabelDense = Template.bind({});
261
- exports.ImageLabelDense = ImageLabelDense;
262
- ImageLabelDense.args = { ...ImageLabel.args,
242
+ const ImageLabelDense = exports.ImageLabelDense = Template.bind({});
243
+ ImageLabelDense.args = {
244
+ ...ImageLabel.args,
263
245
  dense: true
264
246
  };
265
247
  ImageLabelDense.storyName = 'Image label - Dense';
266
-
267
248
  const RTL = args => /*#__PURE__*/_react.default.createElement("div", {
268
249
  dir: "rtl"
269
250
  }, /*#__PURE__*/_react.default.createElement(_index.Checkbox, args));
270
-
271
251
  exports.RTL = RTL;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a Checkbox with initialFocus is rendered', () => {
6
- cy.visitStory('Checkbox', 'With initialFocus');
5
+ cy.visitStory('Checkbox', 'With initial focus');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.Then)('the Checkbox is focused', () => {
9
8
  cy.focused().parent('[data-test="dhis2-uicore-checkbox"]').should('exist');
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a Checkbox with a label is rendered', () => {
6
5
  cy.visitStory('Checkbox', 'With label');
7
6
  });
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a Checkbox with initialFocus and onBlur handler is rendered', () => {
6
- cy.visitStory('Checkbox', 'With initialFocus and onBlur');
5
+ cy.visitStory('Checkbox', 'With initial focus and on blur');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.When)('the Checkbox is blurred', () => {
9
8
  cy.get('[data-test="dhis2-uicore-checkbox"] input').blur();
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a Checkbox with onChange handler is rendered', () => {
6
- cy.visitStory('Checkbox', 'With onChange');
5
+ cy.visitStory('Checkbox', 'With on change');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.When)('the Checkbox is clicked', () => {
9
8
  cy.get('[data-test="dhis2-uicore-checkbox"]').click();
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a disabled Checkbox with onClick handler is rendered', () => {
6
- cy.visitStory('Checkbox', 'Disabled with onClick');
5
+ cy.visitStory('Checkbox', 'Disabled with on click');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.When)('the Checkbox is clicked', () => {
9
8
  cy.get('[data-test="dhis2-uicore-checkbox"] input').click({
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a Checkbox with onFocus handler is rendered', () => {
6
- cy.visitStory('Checkbox', 'With onFocus');
5
+ cy.visitStory('Checkbox', 'With on focus');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.When)('the Checkbox is focused', () => {
9
8
  cy.get('[data-test="dhis2-uicore-checkbox"] input').focus();
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('the checkbox is marked as indeterminate', () => {
6
5
  cy.visitStory('Checkbox', 'Indeterminate prop');
7
6
  });
@@ -9,5 +9,4 @@ Object.defineProperty(exports, "Checkbox", {
9
9
  return _checkbox.Checkbox;
10
10
  }
11
11
  });
12
-
13
12
  var _checkbox = require("./checkbox.js");
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _react = require("@testing-library/react");
4
-
5
4
  var _react2 = _interopRequireDefault(require("react"));
6
-
7
5
  var _checkboxField = require("../checkbox-field.js");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
6
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
7
  describe('<CheckboxField />', () => {
12
8
  it('should call the onKeyDown callback when provided', () => {
13
9
  const onKeyDown = jest.fn();
@@ -18,13 +14,11 @@ describe('<CheckboxField />', () => {
18
14
  checked: false,
19
15
  onKeyDown: onKeyDown
20
16
  }));
21
-
22
17
  _react.fireEvent.keyDown(_react.screen.getByRole('checkbox'), {
23
18
  key: 'Enter',
24
19
  code: 'Enter',
25
20
  charCode: 13
26
21
  });
27
-
28
22
  expect(onKeyDown).toHaveBeenCalledWith({
29
23
  name: 'foo',
30
24
  value: 'bar',
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.WithValidationText = exports.WithLabelAndRequired = exports.WithLabel = exports.WithHelpText = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _index = require("./index.js");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ var _default = exports.default = {
11
+ title: 'CheckboxField'
12
+ };
13
+ const WithLabelAndRequired = () => /*#__PURE__*/_react.default.createElement(_index.CheckboxField, {
14
+ name: "Ex",
15
+ label: "CheckboxField",
16
+ required: true,
17
+ value: "checked"
18
+ });
19
+ exports.WithLabelAndRequired = WithLabelAndRequired;
20
+ const WithHelpText = () => /*#__PURE__*/_react.default.createElement(_index.CheckboxField, {
21
+ name: "Ex",
22
+ label: "CheckboxField",
23
+ value: "checked",
24
+ helpText: "Help text"
25
+ });
26
+ exports.WithHelpText = WithHelpText;
27
+ const WithLabel = () => /*#__PURE__*/_react.default.createElement(_index.CheckboxField, {
28
+ name: "Ex",
29
+ label: "The label",
30
+ value: "checked"
31
+ });
32
+ exports.WithLabel = WithLabel;
33
+ const WithValidationText = () => /*#__PURE__*/_react.default.createElement(_index.CheckboxField, {
34
+ name: "Ex",
35
+ label: "The label",
36
+ value: "checked",
37
+ validationText: "Validation text"
38
+ });
39
+ exports.WithValidationText = WithValidationText;
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.CheckboxField = void 0;
7
-
7
+ var _uiConstants = require("@dhis2/ui-constants");
8
8
  var _field = require("@dhis2-ui/field");
9
-
10
9
  var _required = require("@dhis2-ui/required");
11
-
12
- var _uiConstants = require("@dhis2/ui-constants");
13
-
14
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
11
  var _react = _interopRequireDefault(require("react"));
17
-
18
- var _index = require("../index.js");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
12
+ var _index = require("../checkbox/index.js");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
14
  const AddRequired = _ref => {
23
15
  let {
24
16
  label,
@@ -26,16 +18,14 @@ const AddRequired = _ref => {
26
18
  dataTest
27
19
  } = _ref;
28
20
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, label, required && /*#__PURE__*/_react.default.createElement(_required.Required, {
29
- dataTest: "".concat(dataTest, "-required")
21
+ dataTest: `${dataTest}-required`
30
22
  }));
31
23
  };
32
-
33
24
  AddRequired.propTypes = {
34
25
  dataTest: _propTypes.default.string,
35
26
  label: _propTypes.default.node,
36
27
  required: _propTypes.default.bool
37
28
  };
38
-
39
29
  const CheckboxField = _ref2 => {
40
30
  let {
41
31
  value,
@@ -90,7 +80,6 @@ const CheckboxField = _ref2 => {
90
80
  initialFocus: initialFocus
91
81
  }));
92
82
  };
93
-
94
83
  exports.CheckboxField = CheckboxField;
95
84
  CheckboxField.defaultProps = {
96
85
  dataTest: 'dhis2-uiwidgets-checkboxfield'
@@ -99,51 +88,36 @@ CheckboxField.propTypes = {
99
88
  checked: _propTypes.default.bool,
100
89
  className: _propTypes.default.string,
101
90
  dataTest: _propTypes.default.string,
102
-
103
91
  /** Smaller dimensions for information-dense layouts */
104
92
  dense: _propTypes.default.bool,
105
-
106
93
  /** Disables the checkbox */
107
94
  disabled: _propTypes.default.bool,
108
-
109
95
  /** Applies 'error' styling to checkbox and validation text for feedback. Mutually exclusive with `warning` and `valid` props */
110
96
  error: _uiConstants.sharedPropTypes.statusPropType,
111
-
112
97
  /** Useful instructions for the user */
113
98
  helpText: _propTypes.default.string,
114
99
  initialFocus: _propTypes.default.bool,
115
-
116
100
  /** Labels the checkbox */
117
101
  label: _propTypes.default.node,
118
-
119
102
  /** Name associate with the checkbox. Passed in object as argument to event handlers */
120
103
  name: _propTypes.default.string,
121
-
122
104
  /** Adds an asterisk to indicate this field is required */
123
105
  required: _propTypes.default.bool,
124
106
  tabIndex: _propTypes.default.string,
125
-
126
107
  /** Applies 'valid' styling to checkbox and validation text for feedback. Mutually exclusive with `warning` and `error` props */
127
108
  valid: _uiConstants.sharedPropTypes.statusPropType,
128
-
129
109
  /** Adds text below the checkbox to provide validation feedback. Acquires styles from `valid`, `warning` and `error` statuses */
130
110
  validationText: _propTypes.default.string,
131
-
132
111
  /** Value associated with the checkbox. Passed in object as argument to event handlers */
133
112
  value: _propTypes.default.string,
134
-
135
113
  /** Applies 'warning' styling to checkbox and validation text for feedback. Mutually exclusive with `valid` and `error` props */
136
114
  warning: _uiConstants.sharedPropTypes.statusPropType,
137
-
138
115
  /** Called with signature `({ name: string, value: string, checked: bool }, event)` */
139
116
  onBlur: _propTypes.default.func,
140
-
141
117
  /** Called with signature `({ name: string, value: string, checked: bool }, event)` */
142
118
  onChange: _propTypes.default.func,
143
-
144
119
  /** Called with signature `({ name: string, value: string, checked: bool }, event)` */
145
120
  onFocus: _propTypes.default.func,
146
-
147
121
  /** Called with signature `({ name: string, value: string, checked: bool }, event)` */
148
122
  onKeyDown: _propTypes.default.func
149
123
  };