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

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
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.InputFieldProps = exports.InputField = void 0;
7
-
7
+ var _uiConstants = require("@dhis2/ui-constants");
8
8
  var _box = require("@dhis2-ui/box");
9
-
10
9
  var _field = require("@dhis2-ui/field");
11
-
12
10
  var _input = require("@dhis2-ui/input");
13
-
14
- var _uiConstants = require("@dhis2/ui-constants");
15
-
16
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
17
-
18
12
  var _react = _interopRequireDefault(require("react"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
14
  class InputField extends _react.default.Component {
23
15
  render() {
24
16
  const {
@@ -90,91 +82,64 @@ class InputField extends _react.default.Component {
90
82
  autoComplete: autoComplete
91
83
  })));
92
84
  }
93
-
94
85
  }
95
-
96
86
  exports.InputField = InputField;
97
87
  InputField.defaultProps = {
98
88
  dataTest: 'dhis2-uiwidgets-inputfield'
99
89
  };
100
- const InputFieldProps = {
90
+ const InputFieldProps = exports.InputFieldProps = {
101
91
  /** The [native `autocomplete` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete) */
102
92
  autoComplete: _propTypes.default.string,
103
93
  className: _propTypes.default.string,
104
94
  dataTest: _propTypes.default.string,
105
-
106
95
  /** Makes the input smaller */
107
96
  dense: _propTypes.default.bool,
108
-
109
97
  /** Disables the input */
110
98
  disabled: _propTypes.default.bool,
111
-
112
99
  /** Applies 'error' appearance for validation feedback. Mutually exclusive with `valid` and `warning` props */
113
100
  error: _uiConstants.sharedPropTypes.statusPropType,
114
-
115
101
  /** Guiding text for how to use this input */
116
102
  helpText: _propTypes.default.string,
117
-
118
103
  /** The input grabs initial focus on the page */
119
104
  initialFocus: _propTypes.default.bool,
120
-
121
105
  /** Defines the width of the input. Can be any valid CSS measurement */
122
106
  inputWidth: _propTypes.default.string,
123
-
124
107
  /** Label text for the input */
125
108
  label: _propTypes.default.string,
126
-
127
109
  /** Adds a loading indicator beside the input */
128
110
  loading: _propTypes.default.bool,
129
-
130
111
  /** The [native `max` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max), for use when `type` is `'number'` */
131
112
  max: _propTypes.default.string,
132
-
133
113
  /** The [native `min` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min), for use when `type` is `'number'` */
134
114
  min: _propTypes.default.string,
135
-
136
115
  /** Name associated with the input. Passed to event handler callbacks in object */
137
116
  name: _propTypes.default.string,
138
-
139
117
  /** Placeholder text for the input */
140
118
  placeholder: _propTypes.default.string,
141
-
142
119
  /** Makes the input read-only */
143
120
  readOnly: _propTypes.default.bool,
144
-
145
121
  /** Indicates this input is required */
146
122
  required: _propTypes.default.bool,
147
-
148
123
  /** The [native `step` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step), for use when `type` is `'number'` */
149
124
  step: _propTypes.default.string,
150
125
  tabIndex: _propTypes.default.string,
151
-
152
126
  /** Type of input */
153
127
  type: _input.Input.propTypes.type,
154
-
155
128
  /** Applies 'valid' appearance for validation feedback. Mutually exclusive with `error` and `warning` props */
156
129
  valid: _uiConstants.sharedPropTypes.statusPropType,
157
-
158
130
  /** Text below input for validation feedback. Receives styles depending on validation status */
159
131
  validationText: _propTypes.default.string,
160
-
161
132
  /** Value in the input. Can be used to control the component (recommended). Passed to event handler callbacks in object */
162
133
  value: _propTypes.default.string,
163
-
164
134
  /** Applies 'warning' appearance for validation feedback. Mutually exclusive with `valid` and `error` props */
165
135
  warning: _uiConstants.sharedPropTypes.statusPropType,
166
-
167
136
  /** Called with signature `({ name: string, value: string }, event)` */
168
137
  onBlur: _propTypes.default.func,
169
-
170
138
  /** Called with signature `({ name: string, value: string }, event)` */
171
139
  onChange: _propTypes.default.func,
172
-
173
140
  /** Called with signature `({ name: string, value: string }, event)` */
174
141
  onFocus: _propTypes.default.func,
175
-
176
142
  /** Called with signature `({ name: string, value: string }, event)` */
177
143
  onKeyDown: _propTypes.default.func
178
144
  };
179
- exports.InputFieldProps = InputFieldProps;
180
145
  InputField.propTypes = InputFieldProps;
@@ -4,28 +4,30 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.WithValue = exports.WithHelpText = exports.ValueTextOverflow = exports.StatusWarning = exports.StatusValid = exports.StatusLoading = exports.StatusError = exports.Required = exports.ReadOnly = exports.PlaceholderNoValue = exports.NoPlaceholderNoValue = exports.LabelTextOverflow = exports.InputWidth = 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
+ 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 = 'Allows a user to enter data, usually text';
13
+ const description = `
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 }; }
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
+ InputField wraps an Input component with a label, help text, validation text, and some other features.
17
17
 
18
- const subtitle = 'Allows a user to enter data, usually text';
19
- const description = "\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\nInputField wraps an Input component with a label, help text, validation text, and some other features.\n\nPlease see more about options and features of inputs at [Design System: Input Field](https://github.com/dhis2/design-system/blob/master/atoms/inputfield.md#input).\n\n```js\nimport { InputField } from '@dhis2/ui'\n```\n";
18
+ Please see more about options and features of inputs at [Design System: Input Field](https://github.com/dhis2/design-system/blob/master/atoms/inputfield.md#input).
20
19
 
20
+ \`\`\`js
21
+ import { InputField } from '@dhis2/ui'
22
+ \`\`\`
23
+ `;
21
24
  const logger = _ref => {
22
25
  let {
23
26
  name,
24
27
  value
25
28
  } = _ref;
26
- return console.log("Name: ".concat(name, ", value: ").concat(value));
29
+ return console.log(`Name: ${name}, value: ${value}`);
27
30
  };
28
-
29
31
  const inputTypeArgType = {
30
32
  table: {
31
33
  type: {
@@ -37,7 +39,7 @@ const inputTypeArgType = {
37
39
  options: ['text', 'number', 'password', 'email', 'url', 'tel', 'date', 'datetime', 'datetime-local', 'month', 'week', 'time', 'search']
38
40
  }
39
41
  };
40
- var _default = {
42
+ var _default = exports.default = {
41
43
  title: 'Input Field',
42
44
  component: _index.InputField,
43
45
  parameters: {
@@ -55,68 +57,61 @@ var _default = {
55
57
  onChange: logger
56
58
  },
57
59
  argTypes: {
58
- type: { ...inputTypeArgType
60
+ type: {
61
+ ...inputTypeArgType
59
62
  },
60
- valid: { ..._uiConstants.sharedPropTypes.statusArgType
63
+ valid: {
64
+ ..._uiConstants.sharedPropTypes.statusArgType
61
65
  },
62
- warning: { ..._uiConstants.sharedPropTypes.statusArgType
66
+ warning: {
67
+ ..._uiConstants.sharedPropTypes.statusArgType
63
68
  },
64
- error: { ..._uiConstants.sharedPropTypes.statusArgType
69
+ error: {
70
+ ..._uiConstants.sharedPropTypes.statusArgType
65
71
  }
66
72
  }
67
73
  };
68
- exports.default = _default;
69
-
70
74
  const Template = args => /*#__PURE__*/_react.default.createElement(_index.InputField, args);
71
-
72
- const Default = Template.bind({});
73
- exports.Default = Default;
74
- const NoPlaceholderNoValue = Template.bind({});
75
- exports.NoPlaceholderNoValue = NoPlaceholderNoValue;
75
+ const Default = exports.Default = Template.bind({});
76
+ const NoPlaceholderNoValue = exports.NoPlaceholderNoValue = Template.bind({});
76
77
  NoPlaceholderNoValue.storyName = 'No placeholder, no value';
77
- const PlaceholderNoValue = Template.bind({});
78
- exports.PlaceholderNoValue = PlaceholderNoValue;
78
+ const PlaceholderNoValue = exports.PlaceholderNoValue = Template.bind({});
79
79
  PlaceholderNoValue.args = {
80
80
  placeholder: 'Hold the place'
81
81
  };
82
82
  PlaceholderNoValue.storyName = 'Placeholder, no value';
83
- const WithHelpText = Template.bind({});
84
- exports.WithHelpText = WithHelpText;
85
- WithHelpText.args = { ...PlaceholderNoValue.args,
83
+ const WithHelpText = exports.WithHelpText = Template.bind({});
84
+ WithHelpText.args = {
85
+ ...PlaceholderNoValue.args,
86
86
  helpText: 'With some helping text to guide the user along'
87
87
  };
88
- const WithValue = Template.bind({});
89
- exports.WithValue = WithValue;
88
+ const WithValue = exports.WithValue = Template.bind({});
90
89
  WithValue.args = {
91
90
  value: 'This is set through the value prop, which means the component is controlled.'
92
91
  };
93
- const Focus = Template.bind({});
94
- exports.Focus = Focus;
92
+ const Focus = exports.Focus = Template.bind({});
95
93
  Focus.args = {
96
94
  initialFocus: true
97
- }; // Disabled initial focus stories on docs page
98
-
95
+ };
96
+ // Disabled initial focus stories on docs page
99
97
  Focus.parameters = {
100
98
  docs: {
101
99
  disable: true
102
100
  }
103
101
  };
104
- const StatusValid = Template.bind({});
105
- exports.StatusValid = StatusValid;
102
+ const StatusValid = exports.StatusValid = Template.bind({});
106
103
  StatusValid.args = {
107
104
  valid: true,
108
105
  value: 'This value is valid'
109
106
  };
110
107
  StatusValid.storyName = 'Status: Valid';
111
- const StatusWarning = Template.bind({});
112
- exports.StatusWarning = StatusWarning;
108
+ const StatusWarning = exports.StatusWarning = Template.bind({});
113
109
  StatusWarning.args = {
114
110
  warning: true,
115
111
  value: 'This value produces a warning'
116
112
  };
117
113
  StatusWarning.storyName = 'Status: Warning';
118
- const StatusError = Template.bind({});
119
- exports.StatusError = StatusError;
114
+ const StatusError = exports.StatusError = Template.bind({});
120
115
  StatusError.args = {
121
116
  error: true,
122
117
  value: 'This value produces an error',
@@ -124,32 +119,27 @@ StatusError.args = {
124
119
  validationText: 'This validation text describes the error, if a message is supplied.'
125
120
  };
126
121
  StatusError.storyName = 'Status: Error';
127
- const StatusLoading = Template.bind({});
128
- exports.StatusLoading = StatusLoading;
122
+ const StatusLoading = exports.StatusLoading = Template.bind({});
129
123
  StatusLoading.args = {
130
124
  loading: true,
131
125
  value: 'This value produces a loading state'
132
126
  };
133
127
  StatusLoading.storyName = 'Status: Loading';
134
- const Disabled = Template.bind({});
135
- exports.Disabled = Disabled;
128
+ const Disabled = exports.Disabled = Template.bind({});
136
129
  Disabled.args = {
137
130
  disabled: true,
138
131
  value: 'This field is disabled'
139
132
  };
140
- const ReadOnly = Template.bind({});
141
- exports.ReadOnly = ReadOnly;
133
+ const ReadOnly = exports.ReadOnly = Template.bind({});
142
134
  ReadOnly.args = {
143
135
  readOnly: true,
144
136
  value: 'This field is read-only'
145
137
  };
146
- const Dense = Template.bind({});
147
- exports.Dense = Dense;
138
+ const Dense = exports.Dense = Template.bind({});
148
139
  Dense.args = {
149
140
  dense: true,
150
141
  value: 'This field is dense'
151
142
  };
152
-
153
143
  const InputWidth = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.InputField, _extends({}, args, {
154
144
  name: "input1",
155
145
  label: "My textarea has a width of 100px",
@@ -159,24 +149,20 @@ const InputWidth = args => /*#__PURE__*/_react.default.createElement(_react.defa
159
149
  label: "My textarea has a width of 220px",
160
150
  inputWidth: "220px"
161
151
  })));
162
-
163
152
  exports.InputWidth = InputWidth;
164
- const LabelTextOverflow = Template.bind({});
165
- exports.LabelTextOverflow = LabelTextOverflow;
153
+ const LabelTextOverflow = exports.LabelTextOverflow = Template.bind({});
166
154
  LabelTextOverflow.args = {
167
155
  dense: true,
168
156
  warning: true,
169
157
  label: "This label is too long to show on a single line of the input field's label. We just let it flow to the next line so the user can still read it. However, we should always aim to keep it shorter than this!"
170
158
  };
171
- const ValueTextOverflow = Template.bind({});
172
- exports.ValueTextOverflow = ValueTextOverflow;
159
+ const ValueTextOverflow = exports.ValueTextOverflow = Template.bind({});
173
160
  ValueTextOverflow.args = {
174
161
  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",
175
162
  dense: true,
176
163
  warning: true
177
164
  };
178
- const Required = Template.bind({});
179
- exports.Required = Required;
165
+ const Required = exports.Required = Template.bind({});
180
166
  Required.args = {
181
167
  required: true
182
168
  };
@@ -1,5 +1,4 @@
1
- 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); }
2
-
1
+ 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); }
3
2
  import { render, fireEvent, screen } from '@testing-library/react';
4
3
  import { shallow } from 'enzyme';
5
4
  import React from 'react';
@@ -1,6 +1,6 @@
1
1
  import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
2
2
  Given('a Input with initialFocus is rendered', () => {
3
- cy.visitStory('Input', 'With initialFocus');
3
+ cy.visitStory('Input', 'With initial focus');
4
4
  });
5
5
  Then('the Input is focused', () => {
6
6
  cy.focused().parent('[data-test="dhis2-uicore-input"]').should('exist');
@@ -1,6 +1,6 @@
1
1
  import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
2
2
  Given('an Input with initialFocus and onBlur handler is rendered', () => {
3
- cy.visitStory('Input', 'With initialFocus and onBlur');
3
+ cy.visitStory('Input', 'With initial focus and on blur');
4
4
  });
5
5
  When('the Input is blurred', () => {
6
6
  cy.get('[data-test="dhis2-uicore-input"] input').blur();
@@ -1,6 +1,6 @@
1
1
  import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
2
2
  Given('a Input with onChange handler is rendered', () => {
3
- cy.visitStory('Input', 'With onChange');
3
+ cy.visitStory('Input', 'With on change');
4
4
  });
5
5
  When('the Input is filled with a character', () => {
6
6
  cy.get('[data-test="dhis2-uicore-input"]').click().type('a');
@@ -1,6 +1,6 @@
1
1
  import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
2
2
  Given('a Input with onFocus handler is rendered', () => {
3
- cy.visitStory('Input', 'With onFocus');
3
+ cy.visitStory('Input', 'With on focus');
4
4
  });
5
5
  When('the Input is focused', () => {
6
6
  cy.get('[data-test="dhis2-uicore-input"] input').focus();
@@ -1,33 +1,39 @@
1
- import { storiesOf } from '@storybook/react';
2
1
  import React from 'react';
3
2
  import { Input } from './index.js';
4
3
  window.onChange = window.Cypress && window.Cypress.cy.stub();
5
4
  window.onBlur = window.Cypress && window.Cypress.cy.stub();
6
5
  window.onFocus = window.Cypress && window.Cypress.cy.stub();
7
- storiesOf('Input', module).add('With onChange', () => /*#__PURE__*/React.createElement(Input, {
6
+ export default {
7
+ title: 'Input'
8
+ };
9
+ export const WithOnChange = () => /*#__PURE__*/React.createElement(Input, {
8
10
  label: "Default label",
9
11
  name: "Default",
10
12
  value: "",
11
13
  onChange: window.onChange
12
- })).add('With initialFocus and onBlur', () => /*#__PURE__*/React.createElement(Input, {
14
+ });
15
+ export const WithInitialFocusAndOnBlur = () => /*#__PURE__*/React.createElement(Input, {
13
16
  label: "Default label",
14
17
  name: "Default",
15
18
  value: "",
16
19
  initialFocus: true,
17
20
  onBlur: window.onBlur
18
- })).add('With onFocus', () => /*#__PURE__*/React.createElement(Input, {
21
+ });
22
+ export const WithOnFocus = () => /*#__PURE__*/React.createElement(Input, {
19
23
  label: "Default label",
20
24
  name: "Default",
21
25
  value: "",
22
26
  onFocus: window.onFocus
23
- })).add('With initialFocus', () => /*#__PURE__*/React.createElement(Input, {
27
+ });
28
+ export const WithInitialFocus = () => /*#__PURE__*/React.createElement(Input, {
24
29
  label: "Default label",
25
30
  name: "Default",
26
31
  value: "",
27
32
  initialFocus: true
28
- })).add('With disabled', () => /*#__PURE__*/React.createElement(Input, {
33
+ });
34
+ export const WithDisabled = () => /*#__PURE__*/React.createElement(Input, {
29
35
  label: "Default label",
30
36
  name: "Default",
31
37
  value: "",
32
38
  disabled: true
33
- }));
39
+ });
@@ -1,58 +1,50 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
-
3
- 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; }
4
-
5
- import { StatusIcon } from '@dhis2-ui/status-icon';
2
+ 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; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
4
+ 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); }
6
5
  import { theme, colors, spacers, sharedPropTypes } from '@dhis2/ui-constants';
6
+ import { StatusIcon } from '@dhis2-ui/status-icon';
7
7
  import cx from 'classnames';
8
8
  import PropTypes from 'prop-types';
9
9
  import React, { Component } from 'react';
10
- 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(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(colors.grey900, ";background-color:white;padding:11px 12px;max-height:40px;outline:0;border:1px solid ").concat(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(theme.focus, ";border-color:").concat(theme.focus, ";}"), "input.jsx-31445346::-webkit-input-placeholder{color:".concat(colors.grey600, ";opacity:1;}"), "input.jsx-31445346::-moz-placeholder{color:".concat(colors.grey600, ";opacity:1;}"), "input.jsx-31445346:-ms-input-placeholder{color:".concat(colors.grey600, ";opacity:1;}"), "input.jsx-31445346::placeholder{color:".concat(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(theme.warning, ";}"), "input.error.jsx-31445346{border-color:".concat(theme.error, ";}"), "input.read-only.jsx-31445346{background-color:".concat(colors.grey050, ";border-color:").concat(colors.grey300, ";box-shadow:none;cursor:text;}"), "input.disabled.jsx-31445346{background-color:".concat(colors.grey100, ";border-color:").concat(colors.grey500, ";color:").concat(theme.disabled, ";cursor:not-allowed;}")];
10
+ 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:${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:${colors.grey900};background-color:white;padding:11px 12px;max-height:40px;outline:0;border:1px solid ${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 ${theme.focus};border-color:${theme.focus};}`, `input.jsx-31445346::-webkit-input-placeholder{color:${colors.grey600};opacity:1;}`, `input.jsx-31445346::-moz-placeholder{color:${colors.grey600};opacity:1;}`, `input.jsx-31445346:-ms-input-placeholder{color:${colors.grey600};opacity:1;}`, `input.jsx-31445346::placeholder{color:${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:${theme.warning};}`, `input.error.jsx-31445346{border-color:${theme.error};}`, `input.read-only.jsx-31445346{background-color:${colors.grey050};border-color:${colors.grey300};box-shadow:none;cursor:text;}`, `input.disabled.jsx-31445346{background-color:${colors.grey100};border-color:${colors.grey500};color:${theme.disabled};cursor:not-allowed;}`];
11
11
  styles.__hash = "31445346";
12
12
  export class Input extends Component {
13
13
  constructor() {
14
14
  super(...arguments);
15
-
16
15
  _defineProperty(this, "inputRef", /*#__PURE__*/React.createRef());
17
-
18
16
  _defineProperty(this, "handleChange", e => {
19
17
  if (this.props.onChange) {
20
18
  this.props.onChange(this.createHandlerPayload(e), e);
21
19
  }
22
20
  });
23
-
24
21
  _defineProperty(this, "handleBlur", e => {
25
22
  if (this.props.onBlur) {
26
23
  this.props.onBlur(this.createHandlerPayload(e), e);
27
24
  }
28
25
  });
29
-
30
26
  _defineProperty(this, "handleFocus", e => {
31
27
  if (this.props.onFocus) {
32
28
  this.props.onFocus(this.createHandlerPayload(e), e);
33
29
  }
34
30
  });
35
-
36
31
  _defineProperty(this, "handleKeyDown", e => {
37
32
  if (this.props.onKeyDown) {
38
33
  this.props.onKeyDown(this.createHandlerPayload(e), e);
39
34
  }
40
35
  });
41
36
  }
42
-
43
37
  componentDidMount() {
44
38
  if (this.props.initialFocus) {
45
39
  this.inputRef.current.focus();
46
40
  }
47
41
  }
48
-
49
42
  createHandlerPayload(e) {
50
43
  return {
51
44
  value: e.target.value,
52
45
  name: this.props.name
53
46
  };
54
47
  }
55
-
56
48
  render() {
57
49
  const {
58
50
  role,
@@ -77,7 +69,7 @@ export class Input extends Component {
77
69
  } = this.props;
78
70
  return /*#__PURE__*/React.createElement("div", {
79
71
  "data-test": dataTest,
80
- className: "jsx-3353877153 " + "jsx-".concat(styles.__hash) + " " + (cx('input', className) || "")
72
+ className: "jsx-3353877153 " + `jsx-${styles.__hash}` + " " + (cx('input', className) || "")
81
73
  }, /*#__PURE__*/React.createElement("input", {
82
74
  role: role,
83
75
  id: name,
@@ -97,7 +89,7 @@ export class Input extends Component {
97
89
  onBlur: this.handleBlur,
98
90
  onChange: this.handleChange,
99
91
  onKeyDown: this.handleKeyDown,
100
- className: "jsx-3353877153 " + "jsx-".concat(styles.__hash) + " " + (cx({
92
+ className: "jsx-3353877153 " + `jsx-${styles.__hash}` + " " + (cx({
101
93
  dense,
102
94
  disabled,
103
95
  error,
@@ -116,7 +108,6 @@ export class Input extends Component {
116
108
  id: "3353877153"
117
109
  }, ["input.jsx-3353877153{width:100%;}"]));
118
110
  }
119
-
120
111
  }
121
112
  Input.defaultProps = {
122
113
  type: 'text',
@@ -127,65 +118,45 @@ Input.propTypes = {
127
118
  autoComplete: PropTypes.string,
128
119
  className: PropTypes.string,
129
120
  dataTest: PropTypes.string,
130
-
131
121
  /** Makes the input smaller */
132
122
  dense: PropTypes.bool,
133
-
134
123
  /** Disables the input */
135
124
  disabled: PropTypes.bool,
136
-
137
125
  /** Applies 'error' appearance for validation feedback. Mutually exclusive with `valid` and `warning` props */
138
126
  error: sharedPropTypes.statusPropType,
139
-
140
127
  /** The input grabs initial focus on the page */
141
128
  initialFocus: PropTypes.bool,
142
-
143
129
  /** Adds a loading indicator beside the input */
144
130
  loading: PropTypes.bool,
145
-
146
131
  /** The [native `max` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max), for use when `type` is `'number'` */
147
132
  max: PropTypes.string,
148
-
149
133
  /** The [native `min` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min), for use when `type` is `'number'` */
150
134
  min: PropTypes.string,
151
-
152
135
  /** Name associated with the input. Passed to event handler callbacks in object */
153
136
  name: PropTypes.string,
154
-
155
137
  /** Placeholder text for the input */
156
138
  placeholder: PropTypes.string,
157
-
158
139
  /** Makes the input read-only */
159
140
  readOnly: PropTypes.bool,
160
-
161
141
  /** Sets a role attribute on the input */
162
142
  role: PropTypes.string,
163
-
164
143
  /** The [native `step` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step), for use when `type` is `'number'` */
165
144
  step: PropTypes.string,
166
145
  tabIndex: PropTypes.string,
167
-
168
146
  /** The native input `type` attribute */
169
147
  type: PropTypes.oneOf(['text', 'number', 'password', 'email', 'url', 'tel', 'date', 'datetime', 'datetime-local', 'month', 'week', 'time', 'search']),
170
-
171
148
  /** Applies 'valid' appearance for validation feedback. Mutually exclusive with `error` and `warning` props */
172
149
  valid: sharedPropTypes.statusPropType,
173
-
174
150
  /** Value in the input. Can be used to control the component (recommended). Passed to event handler callbacks in object */
175
151
  value: PropTypes.string,
176
-
177
152
  /** Applies 'warning' appearance for validation feedback. Mutually exclusive with `valid` and `error` props */
178
153
  warning: sharedPropTypes.statusPropType,
179
-
180
154
  /** Called with signature `({ name: string, value: string }, event)` */
181
155
  onBlur: PropTypes.func,
182
-
183
156
  /** Called with signature `({ name: string, value: string }, event)` */
184
157
  onChange: PropTypes.func,
185
-
186
158
  /** Called with signature `({ name: string, value: string }, event)` */
187
159
  onFocus: PropTypes.func,
188
-
189
160
  /** Called with signature `({ name: string, value: string }, event)` */
190
161
  onKeyDown: PropTypes.func
191
162
  };
@@ -1,7 +1,19 @@
1
1
  import { sharedPropTypes } from '@dhis2/ui-constants';
2
2
  import React from 'react';
3
3
  import { Input } from './index.js';
4
- 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";
4
+ const description = `
5
+ An input allows a user to enter data, usually text.
6
+
7
+ 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.
8
+
9
+ To use a label and validation text, consider the \`InputField\` component.
10
+
11
+ Read more about Inputs and InputFields at [Design System: Inputs](https://github.com/dhis2/design-system/blob/master/atoms/inputfield.md).
12
+
13
+ \`\`\`js
14
+ import { Input } from '@dhis/ui'
15
+ \`\`\`
16
+ `;
5
17
  const inputTypeArgType = {
6
18
  table: {
7
19
  type: {
@@ -13,15 +25,13 @@ const inputTypeArgType = {
13
25
  options: ['text', 'number', 'password', 'email', 'url', 'tel', 'date', 'datetime', 'datetime-local', 'month', 'week', 'time', 'search']
14
26
  }
15
27
  };
16
-
17
28
  const logger = _ref => {
18
29
  let {
19
30
  name,
20
31
  value
21
32
  } = _ref;
22
- return console.log("Name: ".concat(name, ", value: ").concat(value));
33
+ return console.log(`Name: ${name}, value: ${value}`);
23
34
  };
24
-
25
35
  export default {
26
36
  title: 'Input',
27
37
  component: Input,
@@ -37,19 +47,21 @@ export default {
37
47
  onChange: logger
38
48
  },
39
49
  argTypes: {
40
- type: { ...inputTypeArgType
50
+ type: {
51
+ ...inputTypeArgType
41
52
  },
42
- valid: { ...sharedPropTypes.statusArgType
53
+ valid: {
54
+ ...sharedPropTypes.statusArgType
43
55
  },
44
- warning: { ...sharedPropTypes.statusArgType
56
+ warning: {
57
+ ...sharedPropTypes.statusArgType
45
58
  },
46
- error: { ...sharedPropTypes.statusArgType
59
+ error: {
60
+ ...sharedPropTypes.statusArgType
47
61
  }
48
62
  }
49
63
  };
50
-
51
64
  const Template = args => /*#__PURE__*/React.createElement(Input, args);
52
-
53
65
  export const Default = Template.bind({});
54
66
  export const NoPlaceholderNoValue = Template.bind({});
55
67
  NoPlaceholderNoValue.storyName = 'No placeholder, no value';
@@ -72,8 +84,8 @@ NumberMaxMinStep.args = {
72
84
  export const Focus = Template.bind({});
73
85
  Focus.args = {
74
86
  initialFocus: true
75
- }; // Disabled initial focus stories on docs page
76
-
87
+ };
88
+ // Disabled initial focus stories on docs page
77
89
  Focus.parameters = {
78
90
  docs: {
79
91
  disable: true