@dhis2-ui/input 9.11.0 → 9.11.1-beta.10

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 (32) hide show
  1. package/build/cjs/index.js +0 -2
  2. package/build/cjs/input/__tests__/input.test.js +2 -10
  3. package/build/cjs/input/features/accepts_initial_focus/index.js +1 -2
  4. package/build/cjs/input/features/can_be_blurred/index.js +1 -2
  5. package/build/cjs/input/features/can_be_changed/index.js +1 -2
  6. package/build/cjs/input/features/can_be_disabled/index.js +0 -1
  7. package/build/cjs/input/features/can_be_focused/index.js +1 -2
  8. package/build/cjs/input/index.js +0 -1
  9. package/build/cjs/input/input.e2e.stories.js +51 -0
  10. package/build/cjs/input/input.js +10 -50
  11. package/build/cjs/input/{input.stories.js → input.prod.stories.js} +38 -48
  12. package/build/cjs/input-field/__tests__/input-field.test.js +1 -7
  13. package/build/cjs/input-field/features/can_be_required/index.js +0 -1
  14. package/build/cjs/input-field/index.js +0 -1
  15. package/build/cjs/input-field/input-field.e2e.stories.js +18 -0
  16. package/build/cjs/input-field/input-field.js +3 -38
  17. package/build/cjs/input-field/{input-field.stories.js → input-field.prod.stories.js} +41 -55
  18. package/build/es/input/__tests__/input.test.js +1 -2
  19. package/build/es/input/features/accepts_initial_focus/index.js +1 -1
  20. package/build/es/input/features/can_be_blurred/index.js +1 -1
  21. package/build/es/input/features/can_be_changed/index.js +1 -1
  22. package/build/es/input/features/can_be_focused/index.js +1 -1
  23. package/build/es/input/{input.stories.e2e.js → input.e2e.stories.js} +13 -7
  24. package/build/es/input/input.js +7 -36
  25. package/build/es/input/{input.stories.js → input.prod.stories.js} +24 -12
  26. package/build/es/input-field/input-field.e2e.stories.js +10 -0
  27. package/build/es/input-field/input-field.js +1 -28
  28. package/build/es/input-field/{input-field.stories.js → input-field.prod.stories.js} +24 -14
  29. package/package.json +11 -11
  30. package/build/cjs/input/input.stories.e2e.js +0 -40
  31. package/build/cjs/input-field/input-field.stories.e2e.js +0 -15
  32. package/build/es/input-field/input-field.stories.e2e.js +0 -8
@@ -21,7 +21,5 @@ Object.defineProperty(exports, "InputFieldProps", {
21
21
  return _index2.InputFieldProps;
22
22
  }
23
23
  });
24
-
25
24
  var _index = require("./input/index.js");
26
-
27
25
  var _index2 = require("./input-field/index.js");
@@ -1,17 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _react = require("@testing-library/react");
4
-
5
4
  var _enzyme = require("enzyme");
6
-
7
5
  var _react2 = _interopRequireDefault(require("react"));
8
-
9
6
  var _input = require("../input.js");
10
-
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
13
- 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); }
14
-
7
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ 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); }
15
9
  describe('<Input>', () => {
16
10
  it('passes min, max, and step props as attributes to the native <input> element', () => {
17
11
  const testProps = {
@@ -32,9 +26,7 @@ describe('<Input>', () => {
32
26
  value: "bar",
33
27
  onKeyDown: onKeyDown
34
28
  }));
35
-
36
29
  _react.fireEvent.keyDown(_react.screen.getByRole('textbox'), {});
37
-
38
30
  expect(onKeyDown).toHaveBeenCalledWith({
39
31
  name: 'foo',
40
32
  value: 'bar'
@@ -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 Input with initialFocus is rendered', () => {
6
- cy.visitStory('Input', 'With initialFocus');
5
+ cy.visitStory('Input', 'With initial focus');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.Then)('the Input is focused', () => {
9
8
  cy.focused().parent('[data-test="dhis2-uicore-input"]').should('exist');
@@ -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)('an Input with initialFocus and onBlur handler is rendered', () => {
6
- cy.visitStory('Input', 'With initialFocus and onBlur');
5
+ cy.visitStory('Input', 'With initial focus and on blur');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.When)('the Input is blurred', () => {
9
8
  cy.get('[data-test="dhis2-uicore-input"] 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 Input with onChange handler is rendered', () => {
6
- cy.visitStory('Input', 'With onChange');
5
+ cy.visitStory('Input', 'With on change');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.When)('the Input is filled with a character', () => {
9
8
  cy.get('[data-test="dhis2-uicore-input"]').click().type('a');
@@ -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 disabled Input is rendered', () => {
6
5
  cy.visitStory('Input', 'With disabled');
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 Input with onFocus handler is rendered', () => {
6
- cy.visitStory('Input', 'With onFocus');
5
+ cy.visitStory('Input', 'With on focus');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.When)('the Input is focused', () => {
9
8
  cy.get('[data-test="dhis2-uicore-input"] input').focus();
@@ -9,5 +9,4 @@ Object.defineProperty(exports, "Input", {
9
9
  return _input.Input;
10
10
  }
11
11
  });
12
-
13
12
  var _input = require("./input.js");
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.WithOnFocus = exports.WithOnChange = exports.WithInitialFocusAndOnBlur = exports.WithInitialFocus = exports.WithDisabled = 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
+ window.onChange = window.Cypress && window.Cypress.cy.stub();
11
+ window.onBlur = window.Cypress && window.Cypress.cy.stub();
12
+ window.onFocus = window.Cypress && window.Cypress.cy.stub();
13
+ var _default = exports.default = {
14
+ title: 'Input'
15
+ };
16
+ const WithOnChange = () => /*#__PURE__*/_react.default.createElement(_index.Input, {
17
+ label: "Default label",
18
+ name: "Default",
19
+ value: "",
20
+ onChange: window.onChange
21
+ });
22
+ exports.WithOnChange = WithOnChange;
23
+ const WithInitialFocusAndOnBlur = () => /*#__PURE__*/_react.default.createElement(_index.Input, {
24
+ label: "Default label",
25
+ name: "Default",
26
+ value: "",
27
+ initialFocus: true,
28
+ onBlur: window.onBlur
29
+ });
30
+ exports.WithInitialFocusAndOnBlur = WithInitialFocusAndOnBlur;
31
+ const WithOnFocus = () => /*#__PURE__*/_react.default.createElement(_index.Input, {
32
+ label: "Default label",
33
+ name: "Default",
34
+ value: "",
35
+ onFocus: window.onFocus
36
+ });
37
+ exports.WithOnFocus = WithOnFocus;
38
+ const WithInitialFocus = () => /*#__PURE__*/_react.default.createElement(_index.Input, {
39
+ label: "Default label",
40
+ name: "Default",
41
+ value: "",
42
+ initialFocus: true
43
+ });
44
+ exports.WithInitialFocus = WithInitialFocus;
45
+ const WithDisabled = () => /*#__PURE__*/_react.default.createElement(_index.Input, {
46
+ label: "Default label",
47
+ name: "Default",
48
+ value: "",
49
+ disabled: true
50
+ });
51
+ exports.WithDisabled = WithDisabled;
@@ -4,74 +4,56 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Input = void 0;
7
-
8
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
-
10
- var _statusIcon = require("@dhis2-ui/status-icon");
11
-
12
8
  var _uiConstants = require("@dhis2/ui-constants");
13
-
9
+ var _statusIcon = require("@dhis2-ui/status-icon");
14
10
  var _classnames = _interopRequireDefault(require("classnames"));
15
-
16
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
17
-
18
12
  var _react = _interopRequireWildcard(require("react"));
19
-
20
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
-
22
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
-
28
- const styles = [".input.jsx-31445346{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:".concat(_uiConstants.spacers.dp8, ";}"), "input.jsx-31445346{box-sizing:border-box;font-size:14px;line-height:16px;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;color:".concat(_uiConstants.colors.grey900, ";background-color:white;padding:11px 12px;max-height:40px;outline:0;border:1px solid ").concat(_uiConstants.colors.grey500, ";border-radius:3px;box-shadow:inset 0 0 1px 0 rgba(48,54,60,0.1);text-overflow:ellipsis;}"), "input.dense.jsx-31445346{max-height:32px;padding:7px 8px;}", "input.jsx-31445346:focus{outline:none;box-shadow:inset 0 0 0 2px ".concat(_uiConstants.theme.focus, ";border-color:").concat(_uiConstants.theme.focus, ";}"), "input.jsx-31445346::-webkit-input-placeholder{color:".concat(_uiConstants.colors.grey600, ";opacity:1;}"), "input.jsx-31445346::-moz-placeholder{color:".concat(_uiConstants.colors.grey600, ";opacity:1;}"), "input.jsx-31445346:-ms-input-placeholder{color:".concat(_uiConstants.colors.grey600, ";opacity:1;}"), "input.jsx-31445346::placeholder{color:".concat(_uiConstants.colors.grey600, ";opacity:1;}"), "input[type='date'].jsx-31445346::-webkit-inner-spin-button,input[type='date'].jsx-31445346::-webkit-calendar-picker-indicator,input[type='time'].jsx-31445346::-webkit-inner-spin-button,input[type='time'].jsx-31445346::-webkit-calendar-picker-indicator,input[type='datetime-local'].jsx-31445346::-webkit-inner-spin-button,input[type='datetime-local'].jsx-31445346::-webkit-calendar-picker-indicator{height:14px;padding-top:1px;padding-bottom:1px;}", "input[type='date'].jsx-31445346::-webkit-datetime-edit-fields-wrapper,input[type='datetime-local'].jsx-31445346::-webkit-datetime-edit-fields-wrapper,input[type='time'].jsx-31445346::-webkit-datetime-edit-fields-wrapper{padding:0;}", "input.warning.jsx-31445346{border-color:".concat(_uiConstants.theme.warning, ";}"), "input.error.jsx-31445346{border-color:".concat(_uiConstants.theme.error, ";}"), "input.read-only.jsx-31445346{background-color:".concat(_uiConstants.colors.grey050, ";border-color:").concat(_uiConstants.colors.grey300, ";box-shadow:none;cursor:text;}"), "input.disabled.jsx-31445346{background-color:".concat(_uiConstants.colors.grey100, ";border-color:").concat(_uiConstants.colors.grey500, ";color:").concat(_uiConstants.theme.disabled, ";cursor:not-allowed;}")];
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
18
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
+ const styles = [`.input.jsx-31445346{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:${_uiConstants.spacers.dp8};}`, `input.jsx-31445346{box-sizing:border-box;font-size:14px;line-height:16px;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;color:${_uiConstants.colors.grey900};background-color:white;padding:11px 12px;max-height:40px;outline:0;border:1px solid ${_uiConstants.colors.grey500};border-radius:3px;box-shadow:inset 0 0 1px 0 rgba(48,54,60,0.1);text-overflow:ellipsis;}`, "input.dense.jsx-31445346{max-height:32px;padding:7px 8px;}", `input.jsx-31445346:focus{outline:none;box-shadow:inset 0 0 0 2px ${_uiConstants.theme.focus};border-color:${_uiConstants.theme.focus};}`, `input.jsx-31445346::-webkit-input-placeholder{color:${_uiConstants.colors.grey600};opacity:1;}`, `input.jsx-31445346::-moz-placeholder{color:${_uiConstants.colors.grey600};opacity:1;}`, `input.jsx-31445346:-ms-input-placeholder{color:${_uiConstants.colors.grey600};opacity:1;}`, `input.jsx-31445346::placeholder{color:${_uiConstants.colors.grey600};opacity:1;}`, "input[type='date'].jsx-31445346::-webkit-inner-spin-button,input[type='date'].jsx-31445346::-webkit-calendar-picker-indicator,input[type='time'].jsx-31445346::-webkit-inner-spin-button,input[type='time'].jsx-31445346::-webkit-calendar-picker-indicator,input[type='datetime-local'].jsx-31445346::-webkit-inner-spin-button,input[type='datetime-local'].jsx-31445346::-webkit-calendar-picker-indicator{height:14px;padding-top:1px;padding-bottom:1px;}", "input[type='date'].jsx-31445346::-webkit-datetime-edit-fields-wrapper,input[type='datetime-local'].jsx-31445346::-webkit-datetime-edit-fields-wrapper,input[type='time'].jsx-31445346::-webkit-datetime-edit-fields-wrapper{padding:0;}", `input.warning.jsx-31445346{border-color:${_uiConstants.theme.warning};}`, `input.error.jsx-31445346{border-color:${_uiConstants.theme.error};}`, `input.read-only.jsx-31445346{background-color:${_uiConstants.colors.grey050};border-color:${_uiConstants.colors.grey300};box-shadow:none;cursor:text;}`, `input.disabled.jsx-31445346{background-color:${_uiConstants.colors.grey100};border-color:${_uiConstants.colors.grey500};color:${_uiConstants.theme.disabled};cursor:not-allowed;}`];
29
20
  styles.__hash = "31445346";
30
-
31
21
  class Input extends _react.Component {
32
22
  constructor() {
33
23
  super(...arguments);
34
-
35
24
  _defineProperty(this, "inputRef", /*#__PURE__*/_react.default.createRef());
36
-
37
25
  _defineProperty(this, "handleChange", e => {
38
26
  if (this.props.onChange) {
39
27
  this.props.onChange(this.createHandlerPayload(e), e);
40
28
  }
41
29
  });
42
-
43
30
  _defineProperty(this, "handleBlur", e => {
44
31
  if (this.props.onBlur) {
45
32
  this.props.onBlur(this.createHandlerPayload(e), e);
46
33
  }
47
34
  });
48
-
49
35
  _defineProperty(this, "handleFocus", e => {
50
36
  if (this.props.onFocus) {
51
37
  this.props.onFocus(this.createHandlerPayload(e), e);
52
38
  }
53
39
  });
54
-
55
40
  _defineProperty(this, "handleKeyDown", e => {
56
41
  if (this.props.onKeyDown) {
57
42
  this.props.onKeyDown(this.createHandlerPayload(e), e);
58
43
  }
59
44
  });
60
45
  }
61
-
62
46
  componentDidMount() {
63
47
  if (this.props.initialFocus) {
64
48
  this.inputRef.current.focus();
65
49
  }
66
50
  }
67
-
68
51
  createHandlerPayload(e) {
69
52
  return {
70
53
  value: e.target.value,
71
54
  name: this.props.name
72
55
  };
73
56
  }
74
-
75
57
  render() {
76
58
  const {
77
59
  role,
@@ -96,7 +78,7 @@ class Input extends _react.Component {
96
78
  } = this.props;
97
79
  return /*#__PURE__*/_react.default.createElement("div", {
98
80
  "data-test": dataTest,
99
- className: "jsx-3353877153 " + "jsx-".concat(styles.__hash) + " " + ((0, _classnames.default)('input', className) || "")
81
+ className: "jsx-3353877153 " + `jsx-${styles.__hash}` + " " + ((0, _classnames.default)('input', className) || "")
100
82
  }, /*#__PURE__*/_react.default.createElement("input", {
101
83
  role: role,
102
84
  id: name,
@@ -116,7 +98,7 @@ class Input extends _react.Component {
116
98
  onBlur: this.handleBlur,
117
99
  onChange: this.handleChange,
118
100
  onKeyDown: this.handleKeyDown,
119
- className: "jsx-3353877153 " + "jsx-".concat(styles.__hash) + " " + ((0, _classnames.default)({
101
+ className: "jsx-3353877153 " + `jsx-${styles.__hash}` + " " + ((0, _classnames.default)({
120
102
  dense,
121
103
  disabled,
122
104
  error,
@@ -135,9 +117,7 @@ class Input extends _react.Component {
135
117
  id: "3353877153"
136
118
  }, ["input.jsx-3353877153{width:100%;}"]));
137
119
  }
138
-
139
120
  }
140
-
141
121
  exports.Input = Input;
142
122
  Input.defaultProps = {
143
123
  type: 'text',
@@ -148,65 +128,45 @@ Input.propTypes = {
148
128
  autoComplete: _propTypes.default.string,
149
129
  className: _propTypes.default.string,
150
130
  dataTest: _propTypes.default.string,
151
-
152
131
  /** Makes the input smaller */
153
132
  dense: _propTypes.default.bool,
154
-
155
133
  /** Disables the input */
156
134
  disabled: _propTypes.default.bool,
157
-
158
135
  /** Applies 'error' appearance for validation feedback. Mutually exclusive with `valid` and `warning` props */
159
136
  error: _uiConstants.sharedPropTypes.statusPropType,
160
-
161
137
  /** The input grabs initial focus on the page */
162
138
  initialFocus: _propTypes.default.bool,
163
-
164
139
  /** Adds a loading indicator beside the input */
165
140
  loading: _propTypes.default.bool,
166
-
167
141
  /** The [native `max` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max), for use when `type` is `'number'` */
168
142
  max: _propTypes.default.string,
169
-
170
143
  /** The [native `min` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min), for use when `type` is `'number'` */
171
144
  min: _propTypes.default.string,
172
-
173
145
  /** Name associated with the input. Passed to event handler callbacks in object */
174
146
  name: _propTypes.default.string,
175
-
176
147
  /** Placeholder text for the input */
177
148
  placeholder: _propTypes.default.string,
178
-
179
149
  /** Makes the input read-only */
180
150
  readOnly: _propTypes.default.bool,
181
-
182
151
  /** Sets a role attribute on the input */
183
152
  role: _propTypes.default.string,
184
-
185
153
  /** The [native `step` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step), for use when `type` is `'number'` */
186
154
  step: _propTypes.default.string,
187
155
  tabIndex: _propTypes.default.string,
188
-
189
156
  /** The native input `type` attribute */
190
157
  type: _propTypes.default.oneOf(['text', 'number', 'password', 'email', 'url', 'tel', 'date', 'datetime', 'datetime-local', 'month', 'week', 'time', 'search']),
191
-
192
158
  /** Applies 'valid' appearance for validation feedback. Mutually exclusive with `error` and `warning` props */
193
159
  valid: _uiConstants.sharedPropTypes.statusPropType,
194
-
195
160
  /** Value in the input. Can be used to control the component (recommended). Passed to event handler callbacks in object */
196
161
  value: _propTypes.default.string,
197
-
198
162
  /** Applies 'warning' appearance for validation feedback. Mutually exclusive with `valid` and `error` props */
199
163
  warning: _uiConstants.sharedPropTypes.statusPropType,
200
-
201
164
  /** Called with signature `({ name: string, value: string }, event)` */
202
165
  onBlur: _propTypes.default.func,
203
-
204
166
  /** Called with signature `({ name: string, value: string }, event)` */
205
167
  onChange: _propTypes.default.func,
206
-
207
168
  /** Called with signature `({ name: string, value: string }, event)` */
208
169
  onFocus: _propTypes.default.func,
209
-
210
170
  /** Called with signature `({ name: string, value: string }, event)` */
211
171
  onKeyDown: _propTypes.default.func
212
172
  };
@@ -4,16 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.WithValue = exports.ValueTextOverflow = exports.StatusWarning = exports.StatusValid = exports.StatusLoading = exports.StatusError = exports.ReadOnly = exports.RTLErrorPlaceholder = exports.PlaceholderNoValue = exports.NumberMaxMinStep = exports.NoPlaceholderNoValue = exports.Focus = exports.Disabled = exports.Dense = exports.Default = 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
+ const description = `
12
+ An input allows a user to enter data, usually text.
13
+
14
+ Inputs are used wherever a user needs to input standard text information. Inputs are often used as part of forms. An input can also be used to capture information outside of a form, perhaps as a 'Filter' or 'Search' field.
13
15
 
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ To use a label and validation text, consider the \`InputField\` component.
15
17
 
16
- const description = "\nAn input allows a user to enter data, usually text.\n\nInputs are used wherever a user needs to input standard text information. Inputs are often used as part of forms. An input can also be used to capture information outside of a form, perhaps as a 'Filter' or 'Search' field.\n\nTo use a label and validation text, consider the `InputField` component.\n\nRead more about Inputs and InputFields at [Design System: Inputs](https://github.com/dhis2/design-system/blob/master/atoms/inputfield.md).\n\n```js\nimport { Input } from '@dhis/ui'\n```\n";
18
+ Read more about Inputs and InputFields at [Design System: Inputs](https://github.com/dhis2/design-system/blob/master/atoms/inputfield.md).
19
+
20
+ \`\`\`js
21
+ import { Input } from '@dhis/ui'
22
+ \`\`\`
23
+ `;
17
24
  const inputTypeArgType = {
18
25
  table: {
19
26
  type: {
@@ -25,16 +32,14 @@ const inputTypeArgType = {
25
32
  options: ['text', 'number', 'password', 'email', 'url', 'tel', 'date', 'datetime', 'datetime-local', 'month', 'week', 'time', 'search']
26
33
  }
27
34
  };
28
-
29
35
  const logger = _ref => {
30
36
  let {
31
37
  name,
32
38
  value
33
39
  } = _ref;
34
- return console.log("Name: ".concat(name, ", value: ").concat(value));
40
+ return console.log(`Name: ${name}, value: ${value}`);
35
41
  };
36
-
37
- var _default = {
42
+ var _default = exports.default = {
38
43
  title: 'Input',
39
44
  component: _index.Input,
40
45
  parameters: {
@@ -49,113 +54,98 @@ var _default = {
49
54
  onChange: logger
50
55
  },
51
56
  argTypes: {
52
- type: { ...inputTypeArgType
57
+ type: {
58
+ ...inputTypeArgType
53
59
  },
54
- valid: { ..._uiConstants.sharedPropTypes.statusArgType
60
+ valid: {
61
+ ..._uiConstants.sharedPropTypes.statusArgType
55
62
  },
56
- warning: { ..._uiConstants.sharedPropTypes.statusArgType
63
+ warning: {
64
+ ..._uiConstants.sharedPropTypes.statusArgType
57
65
  },
58
- error: { ..._uiConstants.sharedPropTypes.statusArgType
66
+ error: {
67
+ ..._uiConstants.sharedPropTypes.statusArgType
59
68
  }
60
69
  }
61
70
  };
62
- exports.default = _default;
63
-
64
71
  const Template = args => /*#__PURE__*/_react.default.createElement(_index.Input, args);
65
-
66
- const Default = Template.bind({});
67
- exports.Default = Default;
68
- const NoPlaceholderNoValue = Template.bind({});
69
- exports.NoPlaceholderNoValue = NoPlaceholderNoValue;
72
+ const Default = exports.Default = Template.bind({});
73
+ const NoPlaceholderNoValue = exports.NoPlaceholderNoValue = Template.bind({});
70
74
  NoPlaceholderNoValue.storyName = 'No placeholder, no value';
71
- const PlaceholderNoValue = Template.bind({});
72
- exports.PlaceholderNoValue = PlaceholderNoValue;
75
+ const PlaceholderNoValue = exports.PlaceholderNoValue = Template.bind({});
73
76
  PlaceholderNoValue.args = {
74
77
  placeholder: 'Hold the place'
75
78
  };
76
79
  PlaceholderNoValue.storyName = 'Placeholder, no value';
77
- const WithValue = Template.bind({});
78
- exports.WithValue = WithValue;
80
+ const WithValue = exports.WithValue = Template.bind({});
79
81
  WithValue.args = {
80
82
  value: 'This is set through the value prop, which means the component is controlled.'
81
83
  };
82
- const NumberMaxMinStep = Template.bind({});
83
- exports.NumberMaxMinStep = NumberMaxMinStep;
84
+ const NumberMaxMinStep = exports.NumberMaxMinStep = Template.bind({});
84
85
  NumberMaxMinStep.args = {
85
86
  type: 'number',
86
87
  max: '3',
87
88
  min: '0',
88
89
  step: '0.5'
89
90
  };
90
- const Focus = Template.bind({});
91
- exports.Focus = Focus;
91
+ const Focus = exports.Focus = Template.bind({});
92
92
  Focus.args = {
93
93
  initialFocus: true
94
- }; // Disabled initial focus stories on docs page
95
-
94
+ };
95
+ // Disabled initial focus stories on docs page
96
96
  Focus.parameters = {
97
97
  docs: {
98
98
  disable: true
99
99
  }
100
100
  };
101
- const StatusValid = Template.bind({});
102
- exports.StatusValid = StatusValid;
101
+ const StatusValid = exports.StatusValid = Template.bind({});
103
102
  StatusValid.args = {
104
103
  valid: true,
105
104
  value: 'This value is valid'
106
105
  };
107
106
  StatusValid.storyName = 'Status: Valid';
108
- const StatusWarning = Template.bind({});
109
- exports.StatusWarning = StatusWarning;
107
+ const StatusWarning = exports.StatusWarning = Template.bind({});
110
108
  StatusWarning.args = {
111
109
  warning: true,
112
110
  value: 'This value produces a warning'
113
111
  };
114
112
  StatusWarning.storyName = 'Status: Warning';
115
- const StatusError = Template.bind({});
116
- exports.StatusError = StatusError;
113
+ const StatusError = exports.StatusError = Template.bind({});
117
114
  StatusError.args = {
118
115
  error: true,
119
116
  value: 'This value produces an error'
120
117
  };
121
118
  StatusError.storyName = 'Status: Error';
122
- const StatusLoading = Template.bind({});
123
- exports.StatusLoading = StatusLoading;
119
+ const StatusLoading = exports.StatusLoading = Template.bind({});
124
120
  StatusLoading.args = {
125
121
  loading: true,
126
122
  value: 'This value produces a loading state'
127
123
  };
128
124
  StatusLoading.storyName = 'Status: Loading';
129
- const Disabled = Template.bind({});
130
- exports.Disabled = Disabled;
125
+ const Disabled = exports.Disabled = Template.bind({});
131
126
  Disabled.args = {
132
127
  disabled: true,
133
128
  value: 'This field is disabled'
134
129
  };
135
- const ReadOnly = Template.bind({});
136
- exports.ReadOnly = ReadOnly;
130
+ const ReadOnly = exports.ReadOnly = Template.bind({});
137
131
  ReadOnly.args = {
138
132
  readOnly: true,
139
133
  value: 'This field is read-only'
140
134
  };
141
- const Dense = Template.bind({});
142
- exports.Dense = Dense;
135
+ const Dense = exports.Dense = Template.bind({});
143
136
  Dense.args = {
144
137
  dense: true,
145
138
  value: 'This field is dense'
146
139
  };
147
- const ValueTextOverflow = Template.bind({});
148
- exports.ValueTextOverflow = ValueTextOverflow;
140
+ const ValueTextOverflow = exports.ValueTextOverflow = Template.bind({});
149
141
  ValueTextOverflow.args = {
150
142
  value: "This value is too long in order to show on a single line of the input field. It should stay on one line, not in an extra line and which wouldn't look like a standard input",
151
143
  dense: true,
152
144
  warning: true
153
145
  };
154
-
155
146
  const RTLErrorPlaceholder = args => /*#__PURE__*/_react.default.createElement("div", {
156
147
  dir: "rtl"
157
148
  }, /*#__PURE__*/_react.default.createElement(_index.Input, args));
158
-
159
149
  exports.RTLErrorPlaceholder = RTLErrorPlaceholder;
160
150
  RTLErrorPlaceholder.args = {
161
151
  error: true,
@@ -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 _inputField = require("../input-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('<Input>', () => {
12
8
  it('should call the onKeyDown callback when provided', () => {
13
9
  const onKeyDown = jest.fn();
@@ -17,9 +13,7 @@ describe('<Input>', () => {
17
13
  value: "bar",
18
14
  onKeyDown: onKeyDown
19
15
  }));
20
-
21
16
  _react.fireEvent.keyDown(_react.screen.getByRole('textbox'), {});
22
-
23
17
  expect(onKeyDown).toHaveBeenCalledWith({
24
18
  name: 'foo',
25
19
  value: 'bar'
@@ -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 InputField with label and a required flag is rendered', () => {
6
5
  cy.visitStory('InputField', 'With label and required');
7
6
  });
@@ -15,5 +15,4 @@ Object.defineProperty(exports, "InputFieldProps", {
15
15
  return _inputField.InputFieldProps;
16
16
  }
17
17
  });
18
-
19
18
  var _inputField = require("./input-field.js");
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.WithLabelAndRequired = 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: 'InputField'
12
+ };
13
+ const WithLabelAndRequired = () => /*#__PURE__*/_react.default.createElement(_index.InputField, {
14
+ label: "Default label",
15
+ name: "Default",
16
+ required: true
17
+ });
18
+ exports.WithLabelAndRequired = WithLabelAndRequired;