@dhis2-ui/input 10.0.0-alpha.6 → 10.0.0-alpha.8

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.
@@ -13,7 +13,7 @@ describe('<Input>', () => {
13
13
  max: '10',
14
14
  step: '0.5'
15
15
  };
16
- const wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react2.default.createElement(_input.Input, _extends({
16
+ const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react2.default.createElement(_input.Input, _extends({
17
17
  type: "number"
18
18
  }, testProps)));
19
19
  const inputEl = wrapper.find('input');
@@ -21,7 +21,7 @@ describe('<Input>', () => {
21
21
  });
22
22
  it('should call the onKeyDown callback when provided', () => {
23
23
  const onKeyDown = jest.fn();
24
- (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_input.Input, {
24
+ (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_input.Input, {
25
25
  name: "foo",
26
26
  value: "bar",
27
27
  onKeyDown: onKeyDown
@@ -9,4 +9,11 @@ Object.defineProperty(exports, "Input", {
9
9
  return _input.Input;
10
10
  }
11
11
  });
12
- var _input = require("./input.js");
12
+ Object.defineProperty(exports, "inputTypes", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _inputTypes.inputTypes;
16
+ }
17
+ });
18
+ var _input = require("./input.js");
19
+ var _inputTypes = require("./inputTypes.js");
@@ -6,18 +6,20 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Input = void 0;
7
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
8
8
  var _uiConstants = require("@dhis2/ui-constants");
9
+ var _uiIcons = require("@dhis2/ui-icons");
9
10
  var _statusIcon = require("@dhis2-ui/status-icon");
10
11
  var _classnames = _interopRequireDefault(require("classnames"));
11
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
13
  var _react = _interopRequireWildcard(require("react"));
14
+ var _inputTypes = require("./inputTypes.js");
13
15
  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
16
  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
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
18
  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
19
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
18
20
  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;}`];
20
- styles.__hash = "31445346";
21
+ const styles = [`.input.jsx-4253951613{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;gap:${_uiConstants.spacers.dp8};}`, `input.jsx-4253951613{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-4253951613{max-height:32px;padding:7px 8px;}", `input.jsx-4253951613:focus{outline:none;box-shadow:inset 0 0 0 2px ${_uiConstants.theme.focus};border-color:${_uiConstants.theme.focus};}`, `input.jsx-4253951613::-webkit-input-placeholder{color:${_uiConstants.colors.grey600};opacity:1;}`, `input.jsx-4253951613::-moz-placeholder{color:${_uiConstants.colors.grey600};opacity:1;}`, `input.jsx-4253951613:-ms-input-placeholder{color:${_uiConstants.colors.grey600};opacity:1;}`, `input.jsx-4253951613::placeholder{color:${_uiConstants.colors.grey600};opacity:1;}`, "input[type='date'].jsx-4253951613::-webkit-inner-spin-button,input[type='date'].jsx-4253951613::-webkit-calendar-picker-indicator,input[type='time'].jsx-4253951613::-webkit-inner-spin-button,input[type='time'].jsx-4253951613::-webkit-calendar-picker-indicator,input[type='datetime-local'].jsx-4253951613::-webkit-inner-spin-button,input[type='datetime-local'].jsx-4253951613::-webkit-calendar-picker-indicator{height:14px;padding-top:1px;padding-bottom:1px;}", "input[type='date'].jsx-4253951613::-webkit-datetime-edit-fields-wrapper,input[type='datetime-local'].jsx-4253951613::-webkit-datetime-edit-fields-wrapper,input[type='time'].jsx-4253951613::-webkit-datetime-edit-fields-wrapper{padding:0;}", `input.warning.jsx-4253951613{border-color:${_uiConstants.theme.warning};}`, `input.error.jsx-4253951613{border-color:${_uiConstants.theme.error};}`, `input.read-only.jsx-4253951613{background-color:${_uiConstants.colors.grey050};border-color:${_uiConstants.colors.grey300};box-shadow:none;cursor:text;}`, `input.disabled.jsx-4253951613{background-color:${_uiConstants.colors.grey100};border-color:${_uiConstants.colors.grey500};color:${_uiConstants.theme.disabled};cursor:not-allowed;}`];
22
+ styles.__hash = "4253951613";
21
23
  class Input extends _react.Component {
22
24
  constructor() {
23
25
  super(...arguments);
@@ -42,6 +44,14 @@ class Input extends _react.Component {
42
44
  this.props.onKeyDown(this.createHandlerPayload(e), e);
43
45
  }
44
46
  });
47
+ _defineProperty(this, "handleClear", () => {
48
+ if (this.props.onChange) {
49
+ this.props.onChange({
50
+ value: '',
51
+ name: this.props.name
52
+ });
53
+ }
54
+ });
45
55
  }
46
56
  componentDidMount() {
47
57
  if (this.props.initialFocus) {
@@ -58,7 +68,7 @@ class Input extends _react.Component {
58
68
  const {
59
69
  role,
60
70
  className,
61
- type,
71
+ type = 'text',
62
72
  dense,
63
73
  disabled,
64
74
  readOnly,
@@ -74,12 +84,21 @@ class Input extends _react.Component {
74
84
  min,
75
85
  step,
76
86
  autoComplete,
77
- dataTest
87
+ dataTest = 'dhis2-uicore-input',
88
+ clearable,
89
+ prefixIcon,
90
+ width
78
91
  } = this.props;
79
92
  return /*#__PURE__*/_react.default.createElement("div", {
80
93
  "data-test": dataTest,
81
- className: "jsx-3353877153 " + `jsx-${styles.__hash}` + " " + ((0, _classnames.default)('input', className) || "")
82
- }, /*#__PURE__*/_react.default.createElement("input", {
94
+ className: `jsx-${styles.__hash}` + " " + _style.default.dynamic([["3324859945", [width ? width : `100%`, _uiConstants.colors.grey600, _uiConstants.colors.grey500]]]) + " " + ((0, _classnames.default)('input', className, {
95
+ 'input-prefix-icon': prefixIcon
96
+ }, {
97
+ 'input-clearable': clearable
98
+ }) || "")
99
+ }, prefixIcon && /*#__PURE__*/_react.default.createElement("span", {
100
+ className: `jsx-${styles.__hash}` + " " + _style.default.dynamic([["3324859945", [width ? width : `100%`, _uiConstants.colors.grey600, _uiConstants.colors.grey500]]]) + " " + "prefix"
101
+ }, prefixIcon), /*#__PURE__*/_react.default.createElement("input", {
83
102
  role: role,
84
103
  id: name,
85
104
  name: name,
@@ -98,7 +117,7 @@ class Input extends _react.Component {
98
117
  onBlur: this.handleBlur,
99
118
  onChange: this.handleChange,
100
119
  onKeyDown: this.handleKeyDown,
101
- className: "jsx-3353877153 " + `jsx-${styles.__hash}` + " " + ((0, _classnames.default)({
120
+ className: `jsx-${styles.__hash}` + " " + _style.default.dynamic([["3324859945", [width ? width : `100%`, _uiConstants.colors.grey600, _uiConstants.colors.grey500]]]) + " " + ((0, _classnames.default)({
102
121
  dense,
103
122
  disabled,
104
123
  error,
@@ -106,7 +125,13 @@ class Input extends _react.Component {
106
125
  warning,
107
126
  'read-only': readOnly
108
127
  }) || "")
109
- }), /*#__PURE__*/_react.default.createElement(_statusIcon.StatusIcon, {
128
+ }), clearable && value !== null && value !== void 0 && value.length ? /*#__PURE__*/_react.default.createElement("button", {
129
+ type: "button",
130
+ onClick: this.handleClear,
131
+ className: `jsx-${styles.__hash}` + " " + _style.default.dynamic([["3324859945", [width ? width : `100%`, _uiConstants.colors.grey600, _uiConstants.colors.grey500]]]) + " " + "clear-button"
132
+ }, /*#__PURE__*/_react.default.createElement(_uiIcons.IconCross16, {
133
+ color: _uiConstants.colors.white
134
+ })) : null, /*#__PURE__*/_react.default.createElement(_statusIcon.StatusIcon, {
110
135
  error: error,
111
136
  valid: valid,
112
137
  loading: loading,
@@ -114,19 +139,22 @@ class Input extends _react.Component {
114
139
  }), /*#__PURE__*/_react.default.createElement(_style.default, {
115
140
  id: styles.__hash
116
141
  }, styles), /*#__PURE__*/_react.default.createElement(_style.default, {
117
- id: "3353877153"
118
- }, ["input.jsx-3353877153{width:100%;}"]));
142
+ id: "3324859945",
143
+ dynamic: [width ? width : `100%`, _uiConstants.colors.grey600, _uiConstants.colors.grey500]
144
+ }, [`.input.__jsx-style-dynamic-selector{width:${width ? width : `100%`};}`, "input.__jsx-style-dynamic-selector{width:100%;}", ".input-prefix-icon.__jsx-style-dynamic-selector input.__jsx-style-dynamic-selector{padding-inline-start:30px;}", ".input-clearable.__jsx-style-dynamic-selector input.__jsx-style-dynamic-selector{padding-inline-end:30px;}", `.prefix.__jsx-style-dynamic-selector{position:absolute;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;pointer-events:none;left:10px;padding:0;color:${_uiConstants.colors.grey600};}`, `.clear-button.__jsx-style-dynamic-selector{position:absolute;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;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;border:none;cursor:pointer;height:16px;width:16px;border-radius:50%;right:10px;background:${_uiConstants.colors.grey500};padding:1px;}`]));
119
145
  }
120
146
  }
121
147
  exports.Input = Input;
122
- Input.defaultProps = {
148
+ _defineProperty(Input, "defaultProps", {
123
149
  type: 'text',
124
150
  dataTest: 'dhis2-uicore-input'
125
- };
151
+ });
126
152
  Input.propTypes = {
127
153
  /** The [native `autocomplete` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete) */
128
154
  autoComplete: _propTypes.default.string,
129
155
  className: _propTypes.default.string,
156
+ /** Makes the input field clearable */
157
+ clearable: _propTypes.default.bool,
130
158
  dataTest: _propTypes.default.string,
131
159
  /** Makes the input smaller */
132
160
  dense: _propTypes.default.bool,
@@ -146,6 +174,8 @@ Input.propTypes = {
146
174
  name: _propTypes.default.string,
147
175
  /** Placeholder text for the input */
148
176
  placeholder: _propTypes.default.string,
177
+ /** Add prefix icon */
178
+ prefixIcon: _propTypes.default.element,
149
179
  /** Makes the input read-only */
150
180
  readOnly: _propTypes.default.bool,
151
181
  /** Sets a role attribute on the input */
@@ -154,13 +184,15 @@ Input.propTypes = {
154
184
  step: _propTypes.default.string,
155
185
  tabIndex: _propTypes.default.string,
156
186
  /** The native input `type` attribute */
157
- type: _propTypes.default.oneOf(['text', 'number', 'password', 'email', 'url', 'tel', 'date', 'datetime', 'datetime-local', 'month', 'week', 'time', 'search']),
187
+ type: _propTypes.default.oneOf(_inputTypes.inputTypes),
158
188
  /** Applies 'valid' appearance for validation feedback. Mutually exclusive with `error` and `warning` props */
159
189
  valid: _uiConstants.sharedPropTypes.statusPropType,
160
190
  /** Value in the input. Can be used to control the component (recommended). Passed to event handler callbacks in object */
161
191
  value: _propTypes.default.string,
162
192
  /** Applies 'warning' appearance for validation feedback. Mutually exclusive with `valid` and `error` props */
163
193
  warning: _uiConstants.sharedPropTypes.statusPropType,
194
+ /** Defines the width of the input. Can be any valid CSS measurement */
195
+ width: _propTypes.default.string,
164
196
  /** Called with signature `({ name: string, value: string }, event)` */
165
197
  onBlur: _propTypes.default.func,
166
198
  /** Called with signature `({ name: string, value: string }, event)` */
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.inputTypes = void 0;
7
+ const inputTypes = exports.inputTypes = ['text', 'number', 'password', 'email', 'url', 'tel', 'date', 'datetime', 'datetime-local', 'month', 'week', 'time', 'search'];
@@ -7,7 +7,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
7
7
  describe('<Input>', () => {
8
8
  it('should call the onKeyDown callback when provided', () => {
9
9
  const onKeyDown = jest.fn();
10
- (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_inputField.InputField, {
10
+ (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_inputField.InputField, {
11
11
  label: "label",
12
12
  name: "foo",
13
13
  value: "bar",
@@ -11,6 +11,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _react = _interopRequireDefault(require("react"));
12
12
  var _index = require("../input/index.js");
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ 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; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
+ 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); }
14
17
  class InputField extends _react.default.Component {
15
18
  render() {
16
19
  const {
@@ -41,7 +44,9 @@ class InputField extends _react.default.Component {
41
44
  validationText,
42
45
  inputWidth,
43
46
  autoComplete,
44
- dataTest
47
+ clearable,
48
+ prefixIcon,
49
+ dataTest = 'dhis2-uiwidgets-inputfield'
45
50
  } = this.props;
46
51
  return /*#__PURE__*/_react.default.createElement(_field.Field, {
47
52
  className: className,
@@ -79,18 +84,23 @@ class InputField extends _react.default.Component {
79
84
  tabIndex: tabIndex,
80
85
  initialFocus: initialFocus,
81
86
  readOnly: readOnly,
82
- autoComplete: autoComplete
87
+ autoComplete: autoComplete,
88
+ clearable: clearable,
89
+ prefixIcon: prefixIcon,
90
+ width: inputWidth
83
91
  })));
84
92
  }
85
93
  }
86
94
  exports.InputField = InputField;
87
- InputField.defaultProps = {
95
+ _defineProperty(InputField, "defaultProps", {
88
96
  dataTest: 'dhis2-uiwidgets-inputfield'
89
- };
97
+ });
90
98
  const InputFieldProps = exports.InputFieldProps = {
91
99
  /** The [native `autocomplete` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete) */
92
100
  autoComplete: _propTypes.default.string,
93
101
  className: _propTypes.default.string,
102
+ /** Makes the input field clearable */
103
+ clearable: _propTypes.default.bool,
94
104
  dataTest: _propTypes.default.string,
95
105
  /** Makes the input smaller */
96
106
  dense: _propTypes.default.bool,
@@ -116,6 +126,8 @@ const InputFieldProps = exports.InputFieldProps = {
116
126
  name: _propTypes.default.string,
117
127
  /** Placeholder text for the input */
118
128
  placeholder: _propTypes.default.string,
129
+ /** Add prefix icon */
130
+ prefixIcon: _propTypes.default.element,
119
131
  /** Makes the input read-only */
120
132
  readOnly: _propTypes.default.bool,
121
133
  /** Indicates this input is required */
@@ -124,7 +136,7 @@ const InputFieldProps = exports.InputFieldProps = {
124
136
  step: _propTypes.default.string,
125
137
  tabIndex: _propTypes.default.string,
126
138
  /** Type of input */
127
- type: _index.Input.propTypes.type,
139
+ type: _propTypes.default.oneOf(_index.inputTypes),
128
140
  /** Applies 'valid' appearance for validation feedback. Mutually exclusive with `error` and `warning` props */
129
141
  valid: _uiConstants.sharedPropTypes.statusPropType,
130
142
  /** Text below input for validation feedback. Receives styles depending on validation status */
@@ -3,11 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
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;
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.InputWithPrefixIcon = exports.InputWidth = exports.Focus = exports.Disabled = exports.Dense = exports.Default = exports.ClearableInput = void 0;
7
7
  var _uiConstants = require("@dhis2/ui-constants");
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _uiIcons = require("@dhis2/ui-icons");
9
+ var _react = _interopRequireWildcard(require("react"));
9
10
  var _index = require("./index.js");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ 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); }
12
+ 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; }
11
13
  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
14
  const subtitle = 'Allows a user to enter data, usually text';
13
15
  const description = `
@@ -165,4 +167,30 @@ ValueTextOverflow.args = {
165
167
  const Required = exports.Required = Template.bind({});
166
168
  Required.args = {
167
169
  required: true
168
- };
170
+ };
171
+ const InputWithPrefixIcon = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.InputField, _extends({}, args, {
172
+ name: "prefix-icon-input",
173
+ label: "Search",
174
+ placeholder: 'Search',
175
+ prefixIcon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconSearch16, null)
176
+ })), /*#__PURE__*/_react.default.createElement(_index.InputField, _extends({}, args, {
177
+ name: "prefix-icon-input",
178
+ label: "Location",
179
+ placeholder: 'Enter Location',
180
+ prefixIcon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconLocation16, null),
181
+ inputWidth: '200px'
182
+ })));
183
+ exports.InputWithPrefixIcon = InputWithPrefixIcon;
184
+ const ClearableInput = args => {
185
+ const [value, setValue] = (0, _react.useState)('value');
186
+ return /*#__PURE__*/_react.default.createElement(_index.InputField, _extends({}, args, {
187
+ name: "clearable-input",
188
+ label: "This field can be cleared",
189
+ placeholder: '',
190
+ onChange: e => setValue(e.value),
191
+ clearable: true,
192
+ clearText: () => setValue(''),
193
+ value: value
194
+ }));
195
+ };
196
+ exports.ClearableInput = ClearableInput;
@@ -10,7 +10,7 @@ describe('<Input>', () => {
10
10
  max: '10',
11
11
  step: '0.5'
12
12
  };
13
- const wrapper = shallow( /*#__PURE__*/React.createElement(Input, _extends({
13
+ const wrapper = shallow(/*#__PURE__*/React.createElement(Input, _extends({
14
14
  type: "number"
15
15
  }, testProps)));
16
16
  const inputEl = wrapper.find('input');
@@ -18,7 +18,7 @@ describe('<Input>', () => {
18
18
  });
19
19
  it('should call the onKeyDown callback when provided', () => {
20
20
  const onKeyDown = jest.fn();
21
- render( /*#__PURE__*/React.createElement(Input, {
21
+ render(/*#__PURE__*/React.createElement(Input, {
22
22
  name: "foo",
23
23
  value: "bar",
24
24
  onKeyDown: onKeyDown
@@ -1 +1,2 @@
1
- export { Input } from './input.js';
1
+ export { Input } from './input.js';
2
+ export { inputTypes } from './inputTypes.js';
@@ -3,12 +3,14 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
3
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
4
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); }
5
5
  import { theme, colors, spacers, sharedPropTypes } from '@dhis2/ui-constants';
6
+ import { IconCross16 } from '@dhis2/ui-icons';
6
7
  import { StatusIcon } from '@dhis2-ui/status-icon';
7
8
  import cx from 'classnames';
8
9
  import PropTypes from 'prop-types';
9
10
  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:${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
- styles.__hash = "31445346";
11
+ import { inputTypes } from './inputTypes.js';
12
+ const styles = [`.input.jsx-4253951613{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;gap:${spacers.dp8};}`, `input.jsx-4253951613{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-4253951613{max-height:32px;padding:7px 8px;}", `input.jsx-4253951613:focus{outline:none;box-shadow:inset 0 0 0 2px ${theme.focus};border-color:${theme.focus};}`, `input.jsx-4253951613::-webkit-input-placeholder{color:${colors.grey600};opacity:1;}`, `input.jsx-4253951613::-moz-placeholder{color:${colors.grey600};opacity:1;}`, `input.jsx-4253951613:-ms-input-placeholder{color:${colors.grey600};opacity:1;}`, `input.jsx-4253951613::placeholder{color:${colors.grey600};opacity:1;}`, "input[type='date'].jsx-4253951613::-webkit-inner-spin-button,input[type='date'].jsx-4253951613::-webkit-calendar-picker-indicator,input[type='time'].jsx-4253951613::-webkit-inner-spin-button,input[type='time'].jsx-4253951613::-webkit-calendar-picker-indicator,input[type='datetime-local'].jsx-4253951613::-webkit-inner-spin-button,input[type='datetime-local'].jsx-4253951613::-webkit-calendar-picker-indicator{height:14px;padding-top:1px;padding-bottom:1px;}", "input[type='date'].jsx-4253951613::-webkit-datetime-edit-fields-wrapper,input[type='datetime-local'].jsx-4253951613::-webkit-datetime-edit-fields-wrapper,input[type='time'].jsx-4253951613::-webkit-datetime-edit-fields-wrapper{padding:0;}", `input.warning.jsx-4253951613{border-color:${theme.warning};}`, `input.error.jsx-4253951613{border-color:${theme.error};}`, `input.read-only.jsx-4253951613{background-color:${colors.grey050};border-color:${colors.grey300};box-shadow:none;cursor:text;}`, `input.disabled.jsx-4253951613{background-color:${colors.grey100};border-color:${colors.grey500};color:${theme.disabled};cursor:not-allowed;}`];
13
+ styles.__hash = "4253951613";
12
14
  export class Input extends Component {
13
15
  constructor() {
14
16
  super(...arguments);
@@ -33,6 +35,14 @@ export class Input extends Component {
33
35
  this.props.onKeyDown(this.createHandlerPayload(e), e);
34
36
  }
35
37
  });
38
+ _defineProperty(this, "handleClear", () => {
39
+ if (this.props.onChange) {
40
+ this.props.onChange({
41
+ value: '',
42
+ name: this.props.name
43
+ });
44
+ }
45
+ });
36
46
  }
37
47
  componentDidMount() {
38
48
  if (this.props.initialFocus) {
@@ -49,7 +59,7 @@ export class Input extends Component {
49
59
  const {
50
60
  role,
51
61
  className,
52
- type,
62
+ type = 'text',
53
63
  dense,
54
64
  disabled,
55
65
  readOnly,
@@ -65,12 +75,21 @@ export class Input extends Component {
65
75
  min,
66
76
  step,
67
77
  autoComplete,
68
- dataTest
78
+ dataTest = 'dhis2-uicore-input',
79
+ clearable,
80
+ prefixIcon,
81
+ width
69
82
  } = this.props;
70
83
  return /*#__PURE__*/React.createElement("div", {
71
84
  "data-test": dataTest,
72
- className: "jsx-3353877153 " + `jsx-${styles.__hash}` + " " + (cx('input', className) || "")
73
- }, /*#__PURE__*/React.createElement("input", {
85
+ className: `jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([["3324859945", [width ? width : `100%`, colors.grey600, colors.grey500]]]) + " " + (cx('input', className, {
86
+ 'input-prefix-icon': prefixIcon
87
+ }, {
88
+ 'input-clearable': clearable
89
+ }) || "")
90
+ }, prefixIcon && /*#__PURE__*/React.createElement("span", {
91
+ className: `jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([["3324859945", [width ? width : `100%`, colors.grey600, colors.grey500]]]) + " " + "prefix"
92
+ }, prefixIcon), /*#__PURE__*/React.createElement("input", {
74
93
  role: role,
75
94
  id: name,
76
95
  name: name,
@@ -89,7 +108,7 @@ export class Input extends Component {
89
108
  onBlur: this.handleBlur,
90
109
  onChange: this.handleChange,
91
110
  onKeyDown: this.handleKeyDown,
92
- className: "jsx-3353877153 " + `jsx-${styles.__hash}` + " " + (cx({
111
+ className: `jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([["3324859945", [width ? width : `100%`, colors.grey600, colors.grey500]]]) + " " + (cx({
93
112
  dense,
94
113
  disabled,
95
114
  error,
@@ -97,7 +116,13 @@ export class Input extends Component {
97
116
  warning,
98
117
  'read-only': readOnly
99
118
  }) || "")
100
- }), /*#__PURE__*/React.createElement(StatusIcon, {
119
+ }), clearable && value !== null && value !== void 0 && value.length ? /*#__PURE__*/React.createElement("button", {
120
+ type: "button",
121
+ onClick: this.handleClear,
122
+ className: `jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([["3324859945", [width ? width : `100%`, colors.grey600, colors.grey500]]]) + " " + "clear-button"
123
+ }, /*#__PURE__*/React.createElement(IconCross16, {
124
+ color: colors.white
125
+ })) : null, /*#__PURE__*/React.createElement(StatusIcon, {
101
126
  error: error,
102
127
  valid: valid,
103
128
  loading: loading,
@@ -105,18 +130,21 @@ export class Input extends Component {
105
130
  }), /*#__PURE__*/React.createElement(_JSXStyle, {
106
131
  id: styles.__hash
107
132
  }, styles), /*#__PURE__*/React.createElement(_JSXStyle, {
108
- id: "3353877153"
109
- }, ["input.jsx-3353877153{width:100%;}"]));
133
+ id: "3324859945",
134
+ dynamic: [width ? width : `100%`, colors.grey600, colors.grey500]
135
+ }, [`.input.__jsx-style-dynamic-selector{width:${width ? width : `100%`};}`, "input.__jsx-style-dynamic-selector{width:100%;}", ".input-prefix-icon.__jsx-style-dynamic-selector input.__jsx-style-dynamic-selector{padding-inline-start:30px;}", ".input-clearable.__jsx-style-dynamic-selector input.__jsx-style-dynamic-selector{padding-inline-end:30px;}", `.prefix.__jsx-style-dynamic-selector{position:absolute;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;pointer-events:none;left:10px;padding:0;color:${colors.grey600};}`, `.clear-button.__jsx-style-dynamic-selector{position:absolute;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;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;border:none;cursor:pointer;height:16px;width:16px;border-radius:50%;right:10px;background:${colors.grey500};padding:1px;}`]));
110
136
  }
111
137
  }
112
- Input.defaultProps = {
138
+ _defineProperty(Input, "defaultProps", {
113
139
  type: 'text',
114
140
  dataTest: 'dhis2-uicore-input'
115
- };
141
+ });
116
142
  Input.propTypes = {
117
143
  /** The [native `autocomplete` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete) */
118
144
  autoComplete: PropTypes.string,
119
145
  className: PropTypes.string,
146
+ /** Makes the input field clearable */
147
+ clearable: PropTypes.bool,
120
148
  dataTest: PropTypes.string,
121
149
  /** Makes the input smaller */
122
150
  dense: PropTypes.bool,
@@ -136,6 +164,8 @@ Input.propTypes = {
136
164
  name: PropTypes.string,
137
165
  /** Placeholder text for the input */
138
166
  placeholder: PropTypes.string,
167
+ /** Add prefix icon */
168
+ prefixIcon: PropTypes.element,
139
169
  /** Makes the input read-only */
140
170
  readOnly: PropTypes.bool,
141
171
  /** Sets a role attribute on the input */
@@ -144,13 +174,15 @@ Input.propTypes = {
144
174
  step: PropTypes.string,
145
175
  tabIndex: PropTypes.string,
146
176
  /** The native input `type` attribute */
147
- type: PropTypes.oneOf(['text', 'number', 'password', 'email', 'url', 'tel', 'date', 'datetime', 'datetime-local', 'month', 'week', 'time', 'search']),
177
+ type: PropTypes.oneOf(inputTypes),
148
178
  /** Applies 'valid' appearance for validation feedback. Mutually exclusive with `error` and `warning` props */
149
179
  valid: sharedPropTypes.statusPropType,
150
180
  /** Value in the input. Can be used to control the component (recommended). Passed to event handler callbacks in object */
151
181
  value: PropTypes.string,
152
182
  /** Applies 'warning' appearance for validation feedback. Mutually exclusive with `valid` and `error` props */
153
183
  warning: sharedPropTypes.statusPropType,
184
+ /** Defines the width of the input. Can be any valid CSS measurement */
185
+ width: PropTypes.string,
154
186
  /** Called with signature `({ name: string, value: string }, event)` */
155
187
  onBlur: PropTypes.func,
156
188
  /** Called with signature `({ name: string, value: string }, event)` */
@@ -0,0 +1 @@
1
+ export const inputTypes = ['text', 'number', 'password', 'email', 'url', 'tel', 'date', 'datetime', 'datetime-local', 'month', 'week', 'time', 'search'];
@@ -4,7 +4,7 @@ import { InputField } from '../input-field.js';
4
4
  describe('<Input>', () => {
5
5
  it('should call the onKeyDown callback when provided', () => {
6
6
  const onKeyDown = jest.fn();
7
- render( /*#__PURE__*/React.createElement(InputField, {
7
+ render(/*#__PURE__*/React.createElement(InputField, {
8
8
  label: "label",
9
9
  name: "foo",
10
10
  value: "bar",
@@ -1,9 +1,12 @@
1
+ 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; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
+ 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); }
1
4
  import { sharedPropTypes } from '@dhis2/ui-constants';
2
5
  import { Box } from '@dhis2-ui/box';
3
6
  import { Field } from '@dhis2-ui/field';
4
7
  import PropTypes from 'prop-types';
5
8
  import React from 'react';
6
- import { Input } from '../input/index.js';
9
+ import { Input, inputTypes } from '../input/index.js';
7
10
  class InputField extends React.Component {
8
11
  render() {
9
12
  const {
@@ -34,7 +37,9 @@ class InputField extends React.Component {
34
37
  validationText,
35
38
  inputWidth,
36
39
  autoComplete,
37
- dataTest
40
+ clearable,
41
+ prefixIcon,
42
+ dataTest = 'dhis2-uiwidgets-inputfield'
38
43
  } = this.props;
39
44
  return /*#__PURE__*/React.createElement(Field, {
40
45
  className: className,
@@ -72,17 +77,22 @@ class InputField extends React.Component {
72
77
  tabIndex: tabIndex,
73
78
  initialFocus: initialFocus,
74
79
  readOnly: readOnly,
75
- autoComplete: autoComplete
80
+ autoComplete: autoComplete,
81
+ clearable: clearable,
82
+ prefixIcon: prefixIcon,
83
+ width: inputWidth
76
84
  })));
77
85
  }
78
86
  }
79
- InputField.defaultProps = {
87
+ _defineProperty(InputField, "defaultProps", {
80
88
  dataTest: 'dhis2-uiwidgets-inputfield'
81
- };
89
+ });
82
90
  const InputFieldProps = {
83
91
  /** The [native `autocomplete` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete) */
84
92
  autoComplete: PropTypes.string,
85
93
  className: PropTypes.string,
94
+ /** Makes the input field clearable */
95
+ clearable: PropTypes.bool,
86
96
  dataTest: PropTypes.string,
87
97
  /** Makes the input smaller */
88
98
  dense: PropTypes.bool,
@@ -108,6 +118,8 @@ const InputFieldProps = {
108
118
  name: PropTypes.string,
109
119
  /** Placeholder text for the input */
110
120
  placeholder: PropTypes.string,
121
+ /** Add prefix icon */
122
+ prefixIcon: PropTypes.element,
111
123
  /** Makes the input read-only */
112
124
  readOnly: PropTypes.bool,
113
125
  /** Indicates this input is required */
@@ -116,7 +128,7 @@ const InputFieldProps = {
116
128
  step: PropTypes.string,
117
129
  tabIndex: PropTypes.string,
118
130
  /** Type of input */
119
- type: Input.propTypes.type,
131
+ type: PropTypes.oneOf(inputTypes),
120
132
  /** Applies 'valid' appearance for validation feedback. Mutually exclusive with `error` and `warning` props */
121
133
  valid: sharedPropTypes.statusPropType,
122
134
  /** Text below input for validation feedback. Receives styles depending on validation status */
@@ -1,6 +1,7 @@
1
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); }
2
2
  import { sharedPropTypes } from '@dhis2/ui-constants';
3
- import React from 'react';
3
+ import { IconLocation16, IconSearch16 } from '@dhis2/ui-icons';
4
+ import React, { useState } from 'react';
4
5
  import { InputField } from './index.js';
5
6
  const subtitle = 'Allows a user to enter data, usually text';
6
7
  const description = `
@@ -157,4 +158,28 @@ ValueTextOverflow.args = {
157
158
  export const Required = Template.bind({});
158
159
  Required.args = {
159
160
  required: true
161
+ };
162
+ export const InputWithPrefixIcon = args => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputField, _extends({}, args, {
163
+ name: "prefix-icon-input",
164
+ label: "Search",
165
+ placeholder: 'Search',
166
+ prefixIcon: /*#__PURE__*/React.createElement(IconSearch16, null)
167
+ })), /*#__PURE__*/React.createElement(InputField, _extends({}, args, {
168
+ name: "prefix-icon-input",
169
+ label: "Location",
170
+ placeholder: 'Enter Location',
171
+ prefixIcon: /*#__PURE__*/React.createElement(IconLocation16, null),
172
+ inputWidth: '200px'
173
+ })));
174
+ export const ClearableInput = args => {
175
+ const [value, setValue] = useState('value');
176
+ return /*#__PURE__*/React.createElement(InputField, _extends({}, args, {
177
+ name: "clearable-input",
178
+ label: "This field can be cleared",
179
+ placeholder: '',
180
+ onChange: e => setValue(e.value),
181
+ clearable: true,
182
+ clearText: () => setValue(''),
183
+ value: value
184
+ }));
160
185
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/input",
3
- "version": "10.0.0-alpha.6",
3
+ "version": "10.0.0-alpha.8",
4
4
  "description": "UI Input",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,19 +27,19 @@
27
27
  "test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
28
28
  },
29
29
  "peerDependencies": {
30
- "react": "^16.13",
31
- "react-dom": "^16.13",
30
+ "react": "^16.13 || ^18",
31
+ "react-dom": "^16.13 || ^18",
32
32
  "styled-jsx": "^4"
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2-ui/box": "10.0.0-alpha.6",
37
- "@dhis2-ui/field": "10.0.0-alpha.6",
38
- "@dhis2-ui/input": "10.0.0-alpha.6",
39
- "@dhis2-ui/loader": "10.0.0-alpha.6",
40
- "@dhis2-ui/status-icon": "10.0.0-alpha.6",
41
- "@dhis2/ui-constants": "10.0.0-alpha.6",
42
- "@dhis2/ui-icons": "10.0.0-alpha.6",
36
+ "@dhis2-ui/box": "10.0.0-alpha.8",
37
+ "@dhis2-ui/field": "10.0.0-alpha.8",
38
+ "@dhis2-ui/input": "10.0.0-alpha.8",
39
+ "@dhis2-ui/loader": "10.0.0-alpha.8",
40
+ "@dhis2-ui/status-icon": "10.0.0-alpha.8",
41
+ "@dhis2/ui-constants": "10.0.0-alpha.8",
42
+ "@dhis2/ui-icons": "10.0.0-alpha.8",
43
43
  "classnames": "^2.3.1",
44
44
  "prop-types": "^15.7.2"
45
45
  },
@@ -48,8 +48,8 @@
48
48
  "types"
49
49
  ],
50
50
  "devDependencies": {
51
- "react": "16.13",
52
- "react-dom": "16.13",
51
+ "react": "^18.3.1",
52
+ "react-dom": "^18.3.1",
53
53
  "styled-jsx": "^4.0.1"
54
54
  },
55
55
  "types": "types"
package/types/index.d.ts CHANGED
@@ -41,6 +41,10 @@ export interface InputProps {
41
41
  */
42
42
  autoComplete?: string
43
43
  className?: string
44
+ /**
45
+ * Makes the input clearable
46
+ */
47
+ clearable?: boolean
44
48
  dataTest?: string
45
49
  /**
46
50
  * Makes the input smaller
@@ -78,6 +82,10 @@ export interface InputProps {
78
82
  * Placeholder text for the input
79
83
  */
80
84
  placeholder?: string
85
+ /**
86
+ * Add prefix icon
87
+ */
88
+ prefixIcon?: Element
81
89
  /**
82
90
  * Makes the input read-only
83
91
  */
@@ -135,6 +143,10 @@ export interface InputFieldProps {
135
143
  */
136
144
  autoComplete?: string
137
145
  className?: string
146
+ /**
147
+ * Makes the input field clearable
148
+ */
149
+ clearable?: boolean
138
150
  dataTest?: string
139
151
  /**
140
152
  * Makes the input smaller
@@ -184,6 +196,10 @@ export interface InputFieldProps {
184
196
  * Placeholder text for the input
185
197
  */
186
198
  placeholder?: string
199
+ /**
200
+ * Add prefix icon to input
201
+ */
202
+ prefixIcon?: Element
187
203
  /**
188
204
  * Makes the input read-only
189
205
  */