@dhis2-ui/input 9.10.3 → 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
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { InputField } from './index.js';
3
+ export default {
4
+ title: 'InputField'
5
+ };
6
+ export const WithLabelAndRequired = () => /*#__PURE__*/React.createElement(InputField, {
7
+ label: "Default label",
8
+ name: "Default",
9
+ required: true
10
+ });
@@ -1,10 +1,9 @@
1
+ import { sharedPropTypes } from '@dhis2/ui-constants';
1
2
  import { Box } from '@dhis2-ui/box';
2
3
  import { Field } from '@dhis2-ui/field';
3
4
  import { Input } from '@dhis2-ui/input';
4
- import { sharedPropTypes } from '@dhis2/ui-constants';
5
5
  import PropTypes from 'prop-types';
6
6
  import React from 'react';
7
-
8
7
  class InputField extends React.Component {
9
8
  render() {
10
9
  const {
@@ -76,9 +75,7 @@ class InputField extends React.Component {
76
75
  autoComplete: autoComplete
77
76
  })));
78
77
  }
79
-
80
78
  }
81
-
82
79
  InputField.defaultProps = {
83
80
  dataTest: 'dhis2-uiwidgets-inputfield'
84
81
  };
@@ -87,77 +84,53 @@ const InputFieldProps = {
87
84
  autoComplete: PropTypes.string,
88
85
  className: PropTypes.string,
89
86
  dataTest: PropTypes.string,
90
-
91
87
  /** Makes the input smaller */
92
88
  dense: PropTypes.bool,
93
-
94
89
  /** Disables the input */
95
90
  disabled: PropTypes.bool,
96
-
97
91
  /** Applies 'error' appearance for validation feedback. Mutually exclusive with `valid` and `warning` props */
98
92
  error: sharedPropTypes.statusPropType,
99
-
100
93
  /** Guiding text for how to use this input */
101
94
  helpText: PropTypes.string,
102
-
103
95
  /** The input grabs initial focus on the page */
104
96
  initialFocus: PropTypes.bool,
105
-
106
97
  /** Defines the width of the input. Can be any valid CSS measurement */
107
98
  inputWidth: PropTypes.string,
108
-
109
99
  /** Label text for the input */
110
100
  label: PropTypes.string,
111
-
112
101
  /** Adds a loading indicator beside the input */
113
102
  loading: PropTypes.bool,
114
-
115
103
  /** The [native `max` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max), for use when `type` is `'number'` */
116
104
  max: PropTypes.string,
117
-
118
105
  /** The [native `min` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min), for use when `type` is `'number'` */
119
106
  min: PropTypes.string,
120
-
121
107
  /** Name associated with the input. Passed to event handler callbacks in object */
122
108
  name: PropTypes.string,
123
-
124
109
  /** Placeholder text for the input */
125
110
  placeholder: PropTypes.string,
126
-
127
111
  /** Makes the input read-only */
128
112
  readOnly: PropTypes.bool,
129
-
130
113
  /** Indicates this input is required */
131
114
  required: PropTypes.bool,
132
-
133
115
  /** The [native `step` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step), for use when `type` is `'number'` */
134
116
  step: PropTypes.string,
135
117
  tabIndex: PropTypes.string,
136
-
137
118
  /** Type of input */
138
119
  type: Input.propTypes.type,
139
-
140
120
  /** Applies 'valid' appearance for validation feedback. Mutually exclusive with `error` and `warning` props */
141
121
  valid: sharedPropTypes.statusPropType,
142
-
143
122
  /** Text below input for validation feedback. Receives styles depending on validation status */
144
123
  validationText: PropTypes.string,
145
-
146
124
  /** Value in the input. Can be used to control the component (recommended). Passed to event handler callbacks in object */
147
125
  value: PropTypes.string,
148
-
149
126
  /** Applies 'warning' appearance for validation feedback. Mutually exclusive with `valid` and `error` props */
150
127
  warning: sharedPropTypes.statusPropType,
151
-
152
128
  /** Called with signature `({ name: string, value: string }, event)` */
153
129
  onBlur: PropTypes.func,
154
-
155
130
  /** Called with signature `({ name: string, value: string }, event)` */
156
131
  onChange: PropTypes.func,
157
-
158
132
  /** Called with signature `({ name: string, value: string }, event)` */
159
133
  onFocus: PropTypes.func,
160
-
161
134
  /** Called with signature `({ name: string, value: string }, event)` */
162
135
  onKeyDown: PropTypes.func
163
136
  };
@@ -1,19 +1,26 @@
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 { sharedPropTypes } from '@dhis2/ui-constants';
4
3
  import React from 'react';
5
4
  import { InputField } from './index.js';
6
5
  const subtitle = 'Allows a user to enter data, usually text';
7
- 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";
6
+ const description = `
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
+ InputField wraps an Input component with a label, help text, validation text, and some other features.
10
+
11
+ 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).
8
12
 
13
+ \`\`\`js
14
+ import { InputField } from '@dhis2/ui'
15
+ \`\`\`
16
+ `;
9
17
  const logger = _ref => {
10
18
  let {
11
19
  name,
12
20
  value
13
21
  } = _ref;
14
- return console.log("Name: ".concat(name, ", value: ").concat(value));
22
+ return console.log(`Name: ${name}, value: ${value}`);
15
23
  };
16
-
17
24
  const inputTypeArgType = {
18
25
  table: {
19
26
  type: {
@@ -43,19 +50,21 @@ export default {
43
50
  onChange: logger
44
51
  },
45
52
  argTypes: {
46
- type: { ...inputTypeArgType
53
+ type: {
54
+ ...inputTypeArgType
47
55
  },
48
- valid: { ...sharedPropTypes.statusArgType
56
+ valid: {
57
+ ...sharedPropTypes.statusArgType
49
58
  },
50
- warning: { ...sharedPropTypes.statusArgType
59
+ warning: {
60
+ ...sharedPropTypes.statusArgType
51
61
  },
52
- error: { ...sharedPropTypes.statusArgType
62
+ error: {
63
+ ...sharedPropTypes.statusArgType
53
64
  }
54
65
  }
55
66
  };
56
-
57
67
  const Template = args => /*#__PURE__*/React.createElement(InputField, args);
58
-
59
68
  export const Default = Template.bind({});
60
69
  export const NoPlaceholderNoValue = Template.bind({});
61
70
  NoPlaceholderNoValue.storyName = 'No placeholder, no value';
@@ -65,7 +74,8 @@ PlaceholderNoValue.args = {
65
74
  };
66
75
  PlaceholderNoValue.storyName = 'Placeholder, no value';
67
76
  export const WithHelpText = Template.bind({});
68
- WithHelpText.args = { ...PlaceholderNoValue.args,
77
+ WithHelpText.args = {
78
+ ...PlaceholderNoValue.args,
69
79
  helpText: 'With some helping text to guide the user along'
70
80
  };
71
81
  export const WithValue = Template.bind({});
@@ -75,8 +85,8 @@ WithValue.args = {
75
85
  export const Focus = Template.bind({});
76
86
  Focus.args = {
77
87
  initialFocus: true
78
- }; // Disabled initial focus stories on docs page
79
-
88
+ };
89
+ // Disabled initial focus stories on docs page
80
90
  Focus.parameters = {
81
91
  docs: {
82
92
  disable: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/input",
3
- "version": "9.10.3",
3
+ "version": "9.11.1-beta.1",
4
4
  "description": "UI Input",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,24 +22,24 @@
22
22
  "access": "public"
23
23
  },
24
24
  "scripts": {
25
- "start": "start-storybook -c ../../storybook/config --port 5000",
25
+ "start": "storybook dev -c ../../storybook/config --port 5000",
26
26
  "build": "d2-app-scripts build",
27
27
  "test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
28
28
  },
29
29
  "peerDependencies": {
30
- "react": "^16.8",
31
- "react-dom": "^16.8",
30
+ "react": "^16.13",
31
+ "react-dom": "^16.13",
32
32
  "styled-jsx": "^4"
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2-ui/box": "9.10.3",
37
- "@dhis2-ui/field": "9.10.3",
38
- "@dhis2-ui/input": "9.10.3",
39
- "@dhis2-ui/loader": "9.10.3",
40
- "@dhis2-ui/status-icon": "9.10.3",
41
- "@dhis2/ui-constants": "9.10.3",
42
- "@dhis2/ui-icons": "9.10.3",
36
+ "@dhis2-ui/box": "9.11.1-beta.1",
37
+ "@dhis2-ui/field": "9.11.1-beta.1",
38
+ "@dhis2-ui/input": "9.11.1-beta.1",
39
+ "@dhis2-ui/loader": "9.11.1-beta.1",
40
+ "@dhis2-ui/status-icon": "9.11.1-beta.1",
41
+ "@dhis2/ui-constants": "9.11.1-beta.1",
42
+ "@dhis2/ui-icons": "9.11.1-beta.1",
43
43
  "classnames": "^2.3.1",
44
44
  "prop-types": "^15.7.2"
45
45
  },
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- var _react = require("@storybook/react");
4
-
5
- var _react2 = _interopRequireDefault(require("react"));
6
-
7
- var _index = require("./index.js");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- window.onChange = window.Cypress && window.Cypress.cy.stub();
12
- window.onBlur = window.Cypress && window.Cypress.cy.stub();
13
- window.onFocus = window.Cypress && window.Cypress.cy.stub();
14
- (0, _react.storiesOf)('Input', module).add('With onChange', () => /*#__PURE__*/_react2.default.createElement(_index.Input, {
15
- label: "Default label",
16
- name: "Default",
17
- value: "",
18
- onChange: window.onChange
19
- })).add('With initialFocus and onBlur', () => /*#__PURE__*/_react2.default.createElement(_index.Input, {
20
- label: "Default label",
21
- name: "Default",
22
- value: "",
23
- initialFocus: true,
24
- onBlur: window.onBlur
25
- })).add('With onFocus', () => /*#__PURE__*/_react2.default.createElement(_index.Input, {
26
- label: "Default label",
27
- name: "Default",
28
- value: "",
29
- onFocus: window.onFocus
30
- })).add('With initialFocus', () => /*#__PURE__*/_react2.default.createElement(_index.Input, {
31
- label: "Default label",
32
- name: "Default",
33
- value: "",
34
- initialFocus: true
35
- })).add('With disabled', () => /*#__PURE__*/_react2.default.createElement(_index.Input, {
36
- label: "Default label",
37
- name: "Default",
38
- value: "",
39
- disabled: true
40
- }));
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- var _react = require("@storybook/react");
4
-
5
- var _react2 = _interopRequireDefault(require("react"));
6
-
7
- var _index = require("./index.js");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- (0, _react.storiesOf)('InputField', module).add('With label and required', () => /*#__PURE__*/_react2.default.createElement(_index.InputField, {
12
- label: "Default label",
13
- name: "Default",
14
- required: true
15
- }));
@@ -1,8 +0,0 @@
1
- import { storiesOf } from '@storybook/react';
2
- import React from 'react';
3
- import { InputField } from './index.js';
4
- storiesOf('InputField', module).add('With label and required', () => /*#__PURE__*/React.createElement(InputField, {
5
- label: "Default label",
6
- name: "Default",
7
- required: true
8
- }));