@dhis2-ui/text-area 9.11.0 → 9.11.1-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/build/cjs/index.js +0 -2
  2. package/build/cjs/text-area/__tests__/text-area.test.js +1 -7
  3. package/build/cjs/text-area/features/accepts_initial_focus/index.js +1 -2
  4. package/build/cjs/text-area/features/can_be_blurred/index.js +1 -2
  5. package/build/cjs/text-area/features/can_be_changed/index.js +1 -2
  6. package/build/cjs/text-area/features/can_be_disabled/index.js +0 -1
  7. package/build/cjs/text-area/features/can_be_focused/index.js +1 -2
  8. package/build/cjs/text-area/features/common/index.js +0 -1
  9. package/build/cjs/text-area/index.js +0 -1
  10. package/build/cjs/text-area/text-area.e2e.stories.js +41 -0
  11. package/build/cjs/text-area/text-area.js +10 -61
  12. package/build/cjs/text-area/{text-area.stories.js → text-area.prod.stories.js} +31 -52
  13. package/build/cjs/text-area/text-area.styles.js +1 -4
  14. package/build/cjs/text-area-field/__tests__/text-area-field.test.js +1 -7
  15. package/build/cjs/text-area-field/features/can_be_required/index.js +0 -1
  16. package/build/cjs/text-area-field/index.js +0 -1
  17. package/build/cjs/text-area-field/text-area-field.e2e.stories.js +18 -0
  18. package/build/cjs/text-area-field/text-area-field.js +3 -34
  19. package/build/cjs/text-area-field/{text-area-field.stories.js → text-area-field.prod.stories.js} +35 -56
  20. package/build/es/text-area/features/accepts_initial_focus/index.js +1 -1
  21. package/build/es/text-area/features/can_be_blurred/index.js +1 -1
  22. package/build/es/text-area/features/can_be_changed/index.js +1 -1
  23. package/build/es/text-area/features/can_be_focused/index.js +1 -1
  24. package/build/es/text-area/{text-area.stories.e2e.js → text-area.e2e.stories.js} +13 -7
  25. package/build/es/text-area/text-area.js +7 -47
  26. package/build/es/text-area/{text-area.stories.js → text-area.prod.stories.js} +19 -14
  27. package/build/es/text-area/text-area.styles.js +1 -1
  28. package/build/es/text-area-field/text-area-field.e2e.stories.js +10 -0
  29. package/build/es/text-area-field/text-area-field.js +2 -26
  30. package/build/es/text-area-field/{text-area-field.stories.js → text-area-field.prod.stories.js} +18 -10
  31. package/package.json +10 -10
  32. package/build/cjs/text-area/text-area.stories.e2e.js +0 -30
  33. package/build/cjs/text-area-field/text-area-field.stories.e2e.js +0 -15
  34. package/build/es/text-area-field/text-area-field.stories.e2e.js +0 -8
@@ -1,37 +1,41 @@
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 { TextArea } from './index.js';
6
- const description = "\nA textarea allows multiple lines of text input. Use a textarea wherever a user needs to input a lot of information. Do not use a textarea if a short, single line of content is expected.\n\nOptions for textarea inputs are:\n\n- Rows: the height of the input, defined by the number of rows of text\n- Resizable: whether the textarea can be resized by the user or not. Can be set for both width and height.\n- Autoheight: if enabled, the texarea will grow in height to adapt to the content.\n\n```js\nimport { TextArea } from '@dhis2/ui'\n```\n";
5
+ const description = `
6
+ A textarea allows multiple lines of text input. Use a textarea wherever a user needs to input a lot of information. Do not use a textarea if a short, single line of content is expected.
7
+
8
+ Options for textarea inputs are:
9
+
10
+ - Rows: the height of the input, defined by the number of rows of text
11
+ - Resizable: whether the textarea can be resized by the user or not. Can be set for both width and height.
12
+ - Autoheight: if enabled, the texarea will grow in height to adapt to the content.
7
13
 
14
+ \`\`\`js
15
+ import { TextArea } from '@dhis2/ui'
16
+ \`\`\`
17
+ `;
8
18
  window.onChange = (payload, event) => {
9
19
  console.log('onChange payload', payload);
10
20
  console.log('onChange event', event);
11
21
  };
12
-
13
22
  window.onFocus = (payload, event) => {
14
23
  console.log('onFocus payload', payload);
15
24
  console.log('onFocus event', event);
16
25
  };
17
-
18
26
  window.onBlur = (payload, event) => {
19
27
  console.log('onBlur payload', payload);
20
28
  console.log('onBlur event', event);
21
29
  };
22
-
23
30
  const onChange = function () {
24
31
  return window.onChange(...arguments);
25
32
  };
26
-
27
33
  const onFocus = function () {
28
34
  return window.onFocus(...arguments);
29
35
  };
30
-
31
36
  const onBlur = function () {
32
37
  return window.onBlur(...arguments);
33
38
  };
34
-
35
39
  export default {
36
40
  title: 'Text Area',
37
41
  component: TextArea,
@@ -43,11 +47,14 @@ export default {
43
47
  }
44
48
  },
45
49
  argTypes: {
46
- valid: { ...sharedPropTypes.statusArgType
50
+ valid: {
51
+ ...sharedPropTypes.statusArgType
47
52
  },
48
- error: { ...sharedPropTypes.statusArgType
53
+ error: {
54
+ ...sharedPropTypes.statusArgType
49
55
  },
50
- warning: { ...sharedPropTypes.statusArgType
56
+ warning: {
57
+ ...sharedPropTypes.statusArgType
51
58
  }
52
59
  },
53
60
  args: {
@@ -57,9 +64,7 @@ export default {
57
64
  onBlur
58
65
  }
59
66
  };
60
-
61
67
  const Template = args => /*#__PURE__*/React.createElement(TextArea, args);
62
-
63
68
  export const Default = Template.bind({});
64
69
  export const PlaceholderNoValue = Template.bind({});
65
70
  PlaceholderNoValue.args = {
@@ -1,3 +1,3 @@
1
1
  import { colors, theme, spacers } from '@dhis2/ui-constants';
2
- export const styles = [".textarea.jsx-1284170182{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(spacers.dp8, ";}"), "textarea.jsx-1284170182{box-sizing:border-box;padding:8px 12px;color:".concat(colors.grey900, ";background-color:white;border:1px solid ").concat(colors.grey500, ";border-radius:3px;box-shadow:inset 0 0 1px 0 rgba(48,54,60,0.1);outline:0;font-size:14px;line-height:17px;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;}"), "textarea.dense.jsx-1284170182{padding:6px 8px;}", "textarea.jsx-1284170182:focus{outline:none;box-shadow:inset 0 0 0 2px ".concat(theme.focus, ";border-color:").concat(theme.focus, ";}"), "textarea.valid.jsx-1284170182{border-color:".concat(theme.valid, ";}"), "textarea.warning.jsx-1284170182{border-color:".concat(theme.warning, ";}"), "textarea.error.jsx-1284170182{border-color:".concat(theme.error, ";}"), "textarea.read-only.jsx-1284170182{background-color:".concat(colors.grey100, ";border-color:").concat(colors.grey500, ";cursor:text;}"), "textarea.disabled.jsx-1284170182{background-color:".concat(colors.grey100, ";border-color:").concat(colors.grey500, ";color:").concat(theme.disabled, ";cursor:not-allowed;}")];
2
+ export const styles = [`.textarea.jsx-1284170182{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${spacers.dp8};}`, `textarea.jsx-1284170182{box-sizing:border-box;padding:8px 12px;color:${colors.grey900};background-color:white;border:1px solid ${colors.grey500};border-radius:3px;box-shadow:inset 0 0 1px 0 rgba(48,54,60,0.1);outline:0;font-size:14px;line-height:17px;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;}`, "textarea.dense.jsx-1284170182{padding:6px 8px;}", `textarea.jsx-1284170182:focus{outline:none;box-shadow:inset 0 0 0 2px ${theme.focus};border-color:${theme.focus};}`, `textarea.valid.jsx-1284170182{border-color:${theme.valid};}`, `textarea.warning.jsx-1284170182{border-color:${theme.warning};}`, `textarea.error.jsx-1284170182{border-color:${theme.error};}`, `textarea.read-only.jsx-1284170182{background-color:${colors.grey100};border-color:${colors.grey500};cursor:text;}`, `textarea.disabled.jsx-1284170182{background-color:${colors.grey100};border-color:${colors.grey500};color:${theme.disabled};cursor:not-allowed;}`];
3
3
  styles.__hash = "1284170182";
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { TextAreaField } from './index.js';
3
+ export default {
4
+ title: 'TextAreaField'
5
+ };
6
+ export const WithLabelAndRequired = () => /*#__PURE__*/React.createElement(TextAreaField, {
7
+ name: "textarea",
8
+ label: "I am required and have an asterisk",
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
- import { sharedPropTypes } from '@dhis2/ui-constants';
4
4
  import PropTypes from 'prop-types';
5
5
  import React from 'react';
6
- import { TextArea } from '../index.js';
7
-
6
+ import { TextArea } from '../text-area/index.js';
8
7
  const TextAreaField = _ref => {
9
8
  let {
10
9
  className,
@@ -71,7 +70,6 @@ const TextAreaField = _ref => {
71
70
  rows: rows
72
71
  })));
73
72
  };
74
-
75
73
  TextAreaField.defaultProps = {
76
74
  rows: 4,
77
75
  resize: 'vertical',
@@ -82,71 +80,49 @@ TextAreaField.propTypes = {
82
80
  autoGrow: PropTypes.bool,
83
81
  className: PropTypes.string,
84
82
  dataTest: PropTypes.string,
85
-
86
83
  /** Compact mode */
87
84
  dense: PropTypes.bool,
88
-
89
85
  /** Disables the textarea and makes in non-interactive */
90
86
  disabled: PropTypes.bool,
91
-
92
87
  /** Applies 'error' styles for validation feedback. Mutually exclusive with `valid` and `warning` props */
93
88
  error: sharedPropTypes.statusPropType,
94
-
95
89
  /** Adds useful help text below the textarea */
96
90
  helpText: PropTypes.string,
97
-
98
91
  /** Grabs initial focus on the page */
99
92
  initialFocus: PropTypes.bool,
100
-
101
93
  /** Sets the width of the textarea. Minimum 220px. Any valid CSS measurement can be used */
102
94
  inputWidth: PropTypes.string,
103
-
104
95
  /** Labels the textarea */
105
96
  label: PropTypes.string,
106
-
107
97
  /** Adds a loading spinner */
108
98
  loading: PropTypes.bool,
109
-
110
99
  /** Name associated with the text area. Passed in object argument to event handlers. */
111
100
  name: PropTypes.string,
112
-
113
101
  /** Placeholder text for an empty textarea */
114
102
  placeholder: PropTypes.string,
115
-
116
103
  /** Makes the textarea read-only */
117
104
  readOnly: PropTypes.bool,
118
-
119
105
  /** Adds an asterisk to the label to indicate this field is required */
120
106
  required: PropTypes.bool,
121
-
122
107
  /** [Resize property](https://developer.mozilla.org/en-US/docs/Web/CSS/resize) for the textarea element */
123
108
  resize: PropTypes.oneOf(['none', 'both', 'horizontal', 'vertical']),
124
-
125
109
  /** Initial height of the textarea, in lines of text */
126
110
  rows: PropTypes.number,
127
111
  tabIndex: PropTypes.string,
128
-
129
112
  /** Applies 'valid' styles for validation feedback. Mutually exclusive with `warning` and `error` props */
130
113
  valid: sharedPropTypes.statusPropType,
131
-
132
114
  /** Validation text below the textarea to provide validation feedback. Changes appearance depending on validation status */
133
115
  validationText: PropTypes.string,
134
-
135
116
  /** Value in the textarea. Can be used to control component (recommended). Passed in object argument to event handlers. */
136
117
  value: PropTypes.string,
137
-
138
118
  /** Applies 'warning' styles for validation feedback. Mutually exclusive with `valid` and `error` props */
139
119
  warning: sharedPropTypes.statusPropType,
140
-
141
120
  /** Called with signature ({ name: string, value: string }, event) */
142
121
  onBlur: PropTypes.func,
143
-
144
122
  /** Called with signature ({ name: string, value: string }, event) */
145
123
  onChange: PropTypes.func,
146
-
147
124
  /** Called with signature ({ name: string, value: string }, event) */
148
125
  onFocus: PropTypes.func,
149
-
150
126
  /** Called with signature ({ name: string, value: string }, event) */
151
127
  onKeyDown: PropTypes.func
152
128
  };
@@ -1,9 +1,16 @@
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 { TextAreaField } from './index.js';
6
- const description = "\n`TextAreaField` wraps a `TextArea` component with a label, help text, validation text, and other functions.\n\nSee the regular TextArea for usage information and options.\n\n```js\nimport { TextAreaField } from '@dhis2/ui'\n```\n";
5
+ const description = `
6
+ \`TextAreaField\` wraps a \`TextArea\` component with a label, help text, validation text, and other functions.
7
+
8
+ See the regular TextArea for usage information and options.
9
+
10
+ \`\`\`js
11
+ import { TextAreaField } from '@dhis2/ui'
12
+ \`\`\`
13
+ `;
7
14
  export default {
8
15
  title: 'Text Area Field',
9
16
  component: TextAreaField,
@@ -20,17 +27,18 @@ export default {
20
27
  name: 'textareaName'
21
28
  },
22
29
  argTypes: {
23
- valid: { ...sharedPropTypes.statusArgType
30
+ valid: {
31
+ ...sharedPropTypes.statusArgType
24
32
  },
25
- warning: { ...sharedPropTypes.statusArgType
33
+ warning: {
34
+ ...sharedPropTypes.statusArgType
26
35
  },
27
- error: { ...sharedPropTypes.statusArgType
36
+ error: {
37
+ ...sharedPropTypes.statusArgType
28
38
  }
29
39
  }
30
40
  };
31
-
32
41
  const Template = args => /*#__PURE__*/React.createElement(TextAreaField, args);
33
-
34
42
  export const NoPlaceholderNoValue = Template.bind({});
35
43
  NoPlaceholderNoValue.storyName = 'No placeholder, no value';
36
44
  export const PlaceholderNoValue = Template.bind({});
@@ -50,8 +58,8 @@ WithValue.args = {
50
58
  export const Focus = Template.bind({});
51
59
  Focus.args = {
52
60
  initialFocus: true
53
- }; // Disable stories that manipulate focus on docs page
54
-
61
+ };
62
+ // Disable stories that manipulate focus on docs page
55
63
  Focus.parameters = {
56
64
  docs: {
57
65
  disable: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/text-area",
3
- "version": "9.11.0",
3
+ "version": "9.11.1-beta.10",
4
4
  "description": "UI TextArea",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,23 +22,23 @@
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.11.0",
37
- "@dhis2-ui/field": "9.11.0",
38
- "@dhis2-ui/loader": "9.11.0",
39
- "@dhis2-ui/status-icon": "9.11.0",
40
- "@dhis2/ui-constants": "9.11.0",
41
- "@dhis2/ui-icons": "9.11.0",
36
+ "@dhis2-ui/box": "9.11.1-beta.10",
37
+ "@dhis2-ui/field": "9.11.1-beta.10",
38
+ "@dhis2-ui/loader": "9.11.1-beta.10",
39
+ "@dhis2-ui/status-icon": "9.11.1-beta.10",
40
+ "@dhis2/ui-constants": "9.11.1-beta.10",
41
+ "@dhis2/ui-icons": "9.11.1-beta.10",
42
42
  "classnames": "^2.3.1",
43
43
  "prop-types": "^15.7.2"
44
44
  },
@@ -1,30 +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)('TextArea', module).add('With onChange', () => /*#__PURE__*/_react2.default.createElement(_index.TextArea, {
15
- onChange: window.onChange,
16
- name: "textarea"
17
- })).add('With initialFocus and onBlur', () => /*#__PURE__*/_react2.default.createElement(_index.TextArea, {
18
- initialFocus: true,
19
- name: "textarea",
20
- onBlur: window.onBlur
21
- })).add('With onFocus', () => /*#__PURE__*/_react2.default.createElement(_index.TextArea, {
22
- name: "textarea",
23
- onFocus: window.onFocus
24
- })).add('With initialFocus', () => /*#__PURE__*/_react2.default.createElement(_index.TextArea, {
25
- name: "textarea",
26
- initialFocus: true
27
- })).add('With disabled', () => /*#__PURE__*/_react2.default.createElement(_index.TextArea, {
28
- name: "textarea",
29
- disabled: true
30
- }));
@@ -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)('TextAreaField', module).add('With label and required', () => /*#__PURE__*/_react2.default.createElement(_index.TextAreaField, {
12
- name: "textarea",
13
- label: "I am required and have an asterisk",
14
- required: true
15
- }));
@@ -1,8 +0,0 @@
1
- import { storiesOf } from '@storybook/react';
2
- import React from 'react';
3
- import { TextAreaField } from './index.js';
4
- storiesOf('TextAreaField', module).add('With label and required', () => /*#__PURE__*/React.createElement(TextAreaField, {
5
- name: "textarea",
6
- label: "I am required and have an asterisk",
7
- required: true
8
- }));