carbon-react 96.0.0 → 98.0.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.
- package/lib/components/multi-action-button/multi-action-button.component.js +2 -2
- package/lib/components/multi-action-button/multi-action-button.config.js +1 -1
- package/lib/components/multi-action-button/multi-action-button.d.ts +4 -1
- package/lib/components/portrait/portrait-gravatar.component.js +30 -76
- package/lib/components/portrait/portrait-initials.component.js +63 -135
- package/lib/components/portrait/portrait.component.js +80 -138
- package/lib/components/search/search.component.js +1 -0
- package/lib/components/textarea/textarea-test.stories.js +153 -0
- package/lib/components/textarea/textarea.component.js +144 -215
- package/lib/components/textarea/textarea.d.ts +1 -1
- package/lib/components/toast/toast.component.js +90 -156
- package/package.json +6 -4
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Default = exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _specialCharacters = _interopRequireWildcard(require("../../../.storybook/utils/argTypes/specialCharacters"));
|
|
11
|
+
|
|
12
|
+
var _ = _interopRequireDefault(require("."));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
var _default = {
|
|
23
|
+
component: _.default,
|
|
24
|
+
title: "Textarea/Test",
|
|
25
|
+
parameters: {
|
|
26
|
+
info: {
|
|
27
|
+
disable: true
|
|
28
|
+
},
|
|
29
|
+
chromatic: {
|
|
30
|
+
disable: true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
argTypes: {
|
|
34
|
+
labelAlign: {
|
|
35
|
+
options: ["left", "right"],
|
|
36
|
+
control: {
|
|
37
|
+
type: "select"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
cols: {
|
|
41
|
+
control: {
|
|
42
|
+
min: 0,
|
|
43
|
+
max: 100,
|
|
44
|
+
step: 1,
|
|
45
|
+
type: "range"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
rows: {
|
|
49
|
+
control: {
|
|
50
|
+
min: 0,
|
|
51
|
+
max: 100,
|
|
52
|
+
step: 1,
|
|
53
|
+
type: "range"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
inputWidth: {
|
|
57
|
+
control: {
|
|
58
|
+
min: 0,
|
|
59
|
+
max: 100,
|
|
60
|
+
step: 1,
|
|
61
|
+
type: "range"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
labelWidth: {
|
|
65
|
+
control: {
|
|
66
|
+
min: 0,
|
|
67
|
+
max: 100,
|
|
68
|
+
step: 1,
|
|
69
|
+
type: "range"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
adaptiveLabelBreakpoint: {
|
|
73
|
+
control: {
|
|
74
|
+
type: "number"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
placeholderSpecialCharacters: _specialCharacters.default,
|
|
78
|
+
labelSpecialCharacters: _specialCharacters.default,
|
|
79
|
+
labelHelpSpecialCharacters: _specialCharacters.default,
|
|
80
|
+
characterLimitSpecialCharacters: {
|
|
81
|
+
options: [..._specialCharacters.default.options, ..._specialCharacters.number.options],
|
|
82
|
+
mapping: { ..._specialCharacters.default.mapping,
|
|
83
|
+
..._specialCharacters.number.mapping
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
fieldHelpSpecialCharacters: _specialCharacters.default
|
|
87
|
+
},
|
|
88
|
+
args: {
|
|
89
|
+
expandable: false,
|
|
90
|
+
cols: 0,
|
|
91
|
+
rows: 0,
|
|
92
|
+
disabled: false,
|
|
93
|
+
autoFocus: false,
|
|
94
|
+
readOnly: false,
|
|
95
|
+
placeholder: "",
|
|
96
|
+
fieldHelp: "",
|
|
97
|
+
characterLimit: "",
|
|
98
|
+
inputWidth: 100,
|
|
99
|
+
warnOverLimit: false,
|
|
100
|
+
enforceCharacterLimit: true,
|
|
101
|
+
label: "",
|
|
102
|
+
labelHelp: "",
|
|
103
|
+
labelInline: false,
|
|
104
|
+
labelWidth: 30,
|
|
105
|
+
labelAlign: undefined,
|
|
106
|
+
adaptiveLabelBreakpoint: undefined,
|
|
107
|
+
required: false,
|
|
108
|
+
placeholderSpecialCharacters: undefined,
|
|
109
|
+
labelSpecialCharacters: undefined,
|
|
110
|
+
labelHelpSpecialCharacters: undefined,
|
|
111
|
+
characterLimitSpecialCharacters: undefined,
|
|
112
|
+
fieldHelpSpecialCharacters: undefined
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
exports.default = _default;
|
|
116
|
+
|
|
117
|
+
const Default = ({
|
|
118
|
+
placeholder,
|
|
119
|
+
placeholderSpecialCharacters,
|
|
120
|
+
label,
|
|
121
|
+
labelSpecialCharacters,
|
|
122
|
+
labelHelp,
|
|
123
|
+
labelHelpSpecialCharacters,
|
|
124
|
+
characterLimit,
|
|
125
|
+
characterLimitSpecialCharacters,
|
|
126
|
+
fieldHelp,
|
|
127
|
+
fieldHelpSpecialCharacters,
|
|
128
|
+
...args
|
|
129
|
+
}) => {
|
|
130
|
+
const [state, setState] = (0, _react.useState)("");
|
|
131
|
+
|
|
132
|
+
const handleChange = ({
|
|
133
|
+
target: {
|
|
134
|
+
value
|
|
135
|
+
}
|
|
136
|
+
}) => {
|
|
137
|
+
setState(value);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return /*#__PURE__*/_react.default.createElement(_.default, _extends({}, args, {
|
|
141
|
+
name: "textarea",
|
|
142
|
+
onChange: handleChange,
|
|
143
|
+
value: state,
|
|
144
|
+
placeholder: placeholder || placeholderSpecialCharacters,
|
|
145
|
+
label: label || labelSpecialCharacters,
|
|
146
|
+
labelHelp: labelHelp || labelHelpSpecialCharacters,
|
|
147
|
+
helpAriaLabel: labelHelp || labelHelpSpecialCharacters,
|
|
148
|
+
characterLimit: characterLimit || characterLimitSpecialCharacters,
|
|
149
|
+
fieldHelp: fieldHelp || fieldHelpSpecialCharacters
|
|
150
|
+
}));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
exports.Default = Default;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.OriginalTextarea = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
@@ -35,229 +35,167 @@ var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
|
35
35
|
|
|
36
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
37
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
41
|
-
|
|
42
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
43
|
-
|
|
44
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
45
|
-
|
|
46
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
47
|
-
|
|
48
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
49
|
-
|
|
50
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
51
|
-
|
|
52
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
53
|
-
|
|
54
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
38
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
55
39
|
|
|
56
|
-
function
|
|
40
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
57
41
|
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
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; }
|
|
42
|
+
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); }
|
|
61
43
|
|
|
62
44
|
const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
|
|
63
45
|
|
|
64
46
|
const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
|
|
65
47
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
48
|
+
const Textarea = ({
|
|
49
|
+
autoFocus,
|
|
50
|
+
fieldHelp,
|
|
51
|
+
label,
|
|
52
|
+
size,
|
|
53
|
+
children,
|
|
54
|
+
characterLimit,
|
|
55
|
+
enforceCharacterLimit = true,
|
|
56
|
+
warnOverLimit = false,
|
|
57
|
+
onChange,
|
|
58
|
+
disabled = false,
|
|
59
|
+
labelInline,
|
|
60
|
+
labelAlign,
|
|
61
|
+
labelHelp,
|
|
62
|
+
labelSpacing,
|
|
63
|
+
inputIcon,
|
|
64
|
+
id: idProp,
|
|
65
|
+
error,
|
|
66
|
+
warning,
|
|
67
|
+
info,
|
|
68
|
+
name,
|
|
69
|
+
readOnly = false,
|
|
70
|
+
placeholder,
|
|
71
|
+
expandable = false,
|
|
72
|
+
rows,
|
|
73
|
+
cols,
|
|
74
|
+
validationOnLabel = false,
|
|
75
|
+
adaptiveLabelBreakpoint,
|
|
76
|
+
inputWidth,
|
|
77
|
+
labelWidth = 30,
|
|
78
|
+
tooltipPosition,
|
|
79
|
+
value,
|
|
80
|
+
"data-component": dataComponent,
|
|
81
|
+
"data-element": dataElement,
|
|
82
|
+
"data-role": dataRole,
|
|
83
|
+
helpAriaLabel,
|
|
84
|
+
...props
|
|
85
|
+
}) => {
|
|
86
|
+
const locale = (0, _react.useContext)(_i18nContext.default);
|
|
87
|
+
const {
|
|
88
|
+
current: id
|
|
89
|
+
} = (0, _react.useRef)(idProp || (0, _guid.default)());
|
|
90
|
+
const inputRef = (0, _react.useRef)();
|
|
91
|
+
const minHeight = (0, _react.useRef)(0);
|
|
92
|
+
|
|
93
|
+
const expandTextarea = () => {
|
|
94
|
+
const textarea = inputRef.current;
|
|
95
|
+
|
|
96
|
+
if (textarea.scrollHeight > minHeight.current) {
|
|
97
|
+
// Reset height to zero - IE specific
|
|
98
|
+
textarea.style.height = "0px"; // Set the height so all content is shown
|
|
99
|
+
|
|
100
|
+
textarea.style.height = `${Math.max(textarea.scrollHeight, minHeight.current)}px`;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
94
103
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
_createClass(Textarea, [{
|
|
99
|
-
key: "componentDidMount",
|
|
100
|
-
value:
|
|
101
|
-
/**
|
|
102
|
-
* A lifecycle method that is called after initial render.
|
|
103
|
-
* Allows access to refs and DOM to set expandable variables
|
|
104
|
-
*/
|
|
105
|
-
function componentDidMount() {
|
|
106
|
-
if (this.props.expandable) {
|
|
107
|
-
window.addEventListener("resize", this.expandTextarea); // Set the min height to the initially rendered height.
|
|
108
|
-
// Without minHeight expandable textareas will only have
|
|
109
|
-
// one line when no content is present.
|
|
110
|
-
|
|
111
|
-
this.minHeight = this._input.current.clientHeight;
|
|
112
|
-
this.expandTextarea();
|
|
113
|
-
}
|
|
104
|
+
(0, _react.useEffect)(() => {
|
|
105
|
+
if (expandable) {
|
|
106
|
+
expandTextarea();
|
|
114
107
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
108
|
+
});
|
|
109
|
+
(0, _react.useEffect)(() => {
|
|
110
|
+
if (expandable) {
|
|
111
|
+
window.addEventListener("resize", expandTextarea);
|
|
112
|
+
minHeight.current = inputRef.current.clientHeight;
|
|
121
113
|
}
|
|
122
|
-
}, {
|
|
123
|
-
key: "componentDidUpdate",
|
|
124
|
-
value: function componentDidUpdate() {
|
|
125
|
-
const {
|
|
126
|
-
expandable
|
|
127
|
-
} = this.props;
|
|
128
114
|
|
|
115
|
+
return () => {
|
|
129
116
|
if (expandable) {
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}, {
|
|
134
|
-
key: "overLimit",
|
|
135
|
-
get: function () {
|
|
136
|
-
const value = this.props.value || "";
|
|
137
|
-
return value.length > parseInt(this.props.characterLimit, 10);
|
|
138
|
-
}
|
|
139
|
-
}, {
|
|
140
|
-
key: "characterCount",
|
|
141
|
-
get: function () {
|
|
142
|
-
const value = this.props.value || "";
|
|
143
|
-
const {
|
|
144
|
-
characterLimit,
|
|
145
|
-
warnOverLimit
|
|
146
|
-
} = this.props;
|
|
147
|
-
|
|
148
|
-
if (!characterLimit) {
|
|
149
|
-
return null;
|
|
117
|
+
window.removeEventListener("resize", expandTextarea);
|
|
150
118
|
}
|
|
119
|
+
};
|
|
120
|
+
}, [expandable]);
|
|
151
121
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}, {
|
|
160
|
-
key: "render",
|
|
161
|
-
value: function render() {
|
|
162
|
-
const {
|
|
163
|
-
autoFocus,
|
|
164
|
-
fieldHelp,
|
|
165
|
-
label,
|
|
166
|
-
size,
|
|
167
|
-
children,
|
|
168
|
-
characterLimit,
|
|
169
|
-
enforceCharacterLimit,
|
|
170
|
-
onChange,
|
|
171
|
-
disabled,
|
|
172
|
-
labelInline,
|
|
173
|
-
labelAlign,
|
|
174
|
-
labelHelp,
|
|
175
|
-
labelSpacing,
|
|
176
|
-
inputIcon,
|
|
177
|
-
error,
|
|
178
|
-
warning,
|
|
179
|
-
info,
|
|
180
|
-
name,
|
|
181
|
-
readOnly,
|
|
182
|
-
placeholder,
|
|
183
|
-
rows,
|
|
184
|
-
cols,
|
|
185
|
-
validationOnLabel,
|
|
186
|
-
adaptiveLabelBreakpoint,
|
|
187
|
-
inputWidth,
|
|
188
|
-
labelWidth,
|
|
189
|
-
tooltipPosition,
|
|
190
|
-
"data-component": dataComponent,
|
|
191
|
-
"data-element": dataElement,
|
|
192
|
-
"data-role": dataRole,
|
|
193
|
-
helpAriaLabel,
|
|
194
|
-
...props
|
|
195
|
-
} = this.props;
|
|
196
|
-
return /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
197
|
-
helpAriaLabel: helpAriaLabel,
|
|
198
|
-
tooltipPosition: tooltipPosition
|
|
199
|
-
}, /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputBehaviour, null, /*#__PURE__*/_react.default.createElement(_textarea.default, _extends({
|
|
200
|
-
labelInline: labelInline,
|
|
201
|
-
"data-component": dataComponent,
|
|
202
|
-
"data-role": dataRole,
|
|
203
|
-
"data-element": dataElement
|
|
204
|
-
}, (0, _utils.filterStyledSystemMarginProps)(props)), /*#__PURE__*/_react.default.createElement(_formField.default, {
|
|
205
|
-
fieldHelp: fieldHelp,
|
|
206
|
-
error: error,
|
|
207
|
-
warning: warning,
|
|
208
|
-
info: info,
|
|
209
|
-
label: label,
|
|
210
|
-
disabled: disabled,
|
|
211
|
-
id: this.id,
|
|
212
|
-
labelInline: labelInline,
|
|
213
|
-
labelAlign: labelAlign,
|
|
214
|
-
labelWidth: labelWidth,
|
|
215
|
-
labelHelp: labelHelp,
|
|
216
|
-
labelSpacing: labelSpacing,
|
|
217
|
-
isRequired: props.required,
|
|
218
|
-
useValidationIcon: validationOnLabel,
|
|
219
|
-
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint
|
|
220
|
-
}, /*#__PURE__*/_react.default.createElement(_input.InputPresentation, {
|
|
221
|
-
size: size,
|
|
222
|
-
disabled: disabled,
|
|
223
|
-
readOnly: readOnly,
|
|
224
|
-
inputWidth: typeof inputWidth === "number" ? inputWidth : 100 - labelWidth,
|
|
225
|
-
error: error,
|
|
226
|
-
warning: warning,
|
|
227
|
-
info: info
|
|
228
|
-
}, /*#__PURE__*/_react.default.createElement(_input2.default, _extends({
|
|
229
|
-
autoFocus: autoFocus,
|
|
230
|
-
name: name,
|
|
231
|
-
"aria-invalid": !!error,
|
|
232
|
-
ref: this._input,
|
|
233
|
-
maxLength: enforceCharacterLimit && characterLimit ? characterLimit : undefined,
|
|
234
|
-
onChange: onChange,
|
|
235
|
-
disabled: disabled,
|
|
236
|
-
readOnly: readOnly,
|
|
237
|
-
labelInline: labelInline,
|
|
238
|
-
placeholder: disabled ? "" : placeholder,
|
|
239
|
-
rows: rows,
|
|
240
|
-
cols: cols,
|
|
241
|
-
id: this.id,
|
|
242
|
-
as: "textarea"
|
|
243
|
-
}, props)), children, /*#__PURE__*/_react.default.createElement(_inputIconToggle.default, {
|
|
244
|
-
disabled: disabled,
|
|
245
|
-
readOnly: readOnly,
|
|
246
|
-
inputIcon: inputIcon,
|
|
247
|
-
size: size,
|
|
248
|
-
error: error,
|
|
249
|
-
warning: warning,
|
|
250
|
-
info: info,
|
|
251
|
-
useValidationIcon: !validationOnLabel
|
|
252
|
-
}))), this.characterCount)));
|
|
122
|
+
const isOverLimit = () => {
|
|
123
|
+
return (value || "").length > parseInt(characterLimit, 10);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const characterCount = () => {
|
|
127
|
+
if (!characterLimit) {
|
|
128
|
+
return null;
|
|
253
129
|
}
|
|
254
|
-
}]);
|
|
255
130
|
|
|
256
|
-
|
|
257
|
-
|
|
131
|
+
return /*#__PURE__*/_react.default.createElement(_characterCount.default, {
|
|
132
|
+
isOverLimit: isOverLimit() && warnOverLimit,
|
|
133
|
+
value: getFormatNumber((value || "").length, locale.locale()),
|
|
134
|
+
limit: getFormatNumber(characterLimit, locale.locale()),
|
|
135
|
+
"data-element": "character-limit"
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
140
|
+
tooltipPosition: tooltipPosition,
|
|
141
|
+
helpAriaLabel: helpAriaLabel
|
|
142
|
+
}, /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputBehaviour, null, /*#__PURE__*/_react.default.createElement(_textarea.default, _extends({
|
|
143
|
+
labelInline: labelInline,
|
|
144
|
+
"data-component": dataComponent,
|
|
145
|
+
"data-role": dataRole,
|
|
146
|
+
"data-element": dataElement
|
|
147
|
+
}, (0, _utils.filterStyledSystemMarginProps)(props)), /*#__PURE__*/_react.default.createElement(_formField.default, {
|
|
148
|
+
fieldHelp: fieldHelp,
|
|
149
|
+
error: error,
|
|
150
|
+
warning: warning,
|
|
151
|
+
info: info,
|
|
152
|
+
label: label,
|
|
153
|
+
disabled: disabled,
|
|
154
|
+
id: id,
|
|
155
|
+
labelInline: labelInline,
|
|
156
|
+
labelAlign: labelAlign,
|
|
157
|
+
labelWidth: labelWidth,
|
|
158
|
+
labelHelp: labelHelp,
|
|
159
|
+
labelSpacing: labelSpacing,
|
|
160
|
+
isRequired: props.required,
|
|
161
|
+
useValidationIcon: validationOnLabel,
|
|
162
|
+
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint
|
|
163
|
+
}, /*#__PURE__*/_react.default.createElement(_input.InputPresentation, {
|
|
164
|
+
size: size,
|
|
165
|
+
disabled: disabled,
|
|
166
|
+
readOnly: readOnly,
|
|
167
|
+
inputWidth: typeof inputWidth === "number" ? inputWidth : 100 - labelWidth,
|
|
168
|
+
error: error,
|
|
169
|
+
warning: warning,
|
|
170
|
+
info: info
|
|
171
|
+
}, /*#__PURE__*/_react.default.createElement(_input2.default, _extends({
|
|
172
|
+
autoFocus: autoFocus,
|
|
173
|
+
name: name,
|
|
174
|
+
"aria-invalid": !!error,
|
|
175
|
+
ref: inputRef,
|
|
176
|
+
maxLength: enforceCharacterLimit && characterLimit ? characterLimit : undefined,
|
|
177
|
+
onChange: onChange,
|
|
178
|
+
disabled: disabled,
|
|
179
|
+
readOnly: readOnly,
|
|
180
|
+
labelInline: labelInline,
|
|
181
|
+
placeholder: disabled ? "" : placeholder,
|
|
182
|
+
rows: rows,
|
|
183
|
+
cols: cols,
|
|
184
|
+
id: id,
|
|
185
|
+
as: "textarea"
|
|
186
|
+
}, props)), children, /*#__PURE__*/_react.default.createElement(_inputIconToggle.default, {
|
|
187
|
+
disabled: disabled,
|
|
188
|
+
readOnly: readOnly,
|
|
189
|
+
inputIcon: inputIcon,
|
|
190
|
+
size: size,
|
|
191
|
+
error: error,
|
|
192
|
+
warning: warning,
|
|
193
|
+
info: info,
|
|
194
|
+
useValidationIcon: !validationOnLabel
|
|
195
|
+
}))), characterCount())));
|
|
196
|
+
};
|
|
258
197
|
|
|
259
198
|
exports.OriginalTextarea = Textarea;
|
|
260
|
-
Textarea.contextType = _i18nContext.default;
|
|
261
199
|
Textarea.propTypes = { ...marginPropTypes,
|
|
262
200
|
|
|
263
201
|
/** Automatically focus the input on component mount */
|
|
@@ -381,14 +319,5 @@ Textarea.propTypes = { ...marginPropTypes,
|
|
|
381
319
|
/** Aria label for rendered help component */
|
|
382
320
|
helpAriaLabel: _propTypes.default.string
|
|
383
321
|
};
|
|
384
|
-
Textarea.defaultProps = {
|
|
385
|
-
labelWidth: 30,
|
|
386
|
-
disabled: false,
|
|
387
|
-
expandable: false,
|
|
388
|
-
enforceCharacterLimit: true,
|
|
389
|
-
readOnly: false,
|
|
390
|
-
warnOverLimit: false,
|
|
391
|
-
validationOnLabel: false
|
|
392
|
-
};
|
|
393
322
|
var _default = Textarea;
|
|
394
323
|
exports.default = _default;
|
|
@@ -74,7 +74,7 @@ export interface TextareaProps
|
|
|
74
74
|
helpAriaLabel?: string;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
declare
|
|
77
|
+
declare function Textarea(props: TextareaProps): JSX.Element;
|
|
78
78
|
|
|
79
79
|
export { Textarea as OriginalTextarea };
|
|
80
80
|
export default Textarea;
|