@atlaskit/textarea 4.5.4 → 4.5.5
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/CHANGELOG.md +6 -0
- package/dist/cjs/component-tokens.js +0 -2
- package/dist/cjs/index.js +0 -3
- package/dist/cjs/styles.js +11 -31
- package/dist/cjs/text-area.js +34 -60
- package/dist/cjs/theme.js +2 -9
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/styles.js +7 -16
- package/dist/es2019/text-area.js +6 -14
- package/dist/es2019/theme.js +1 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/styles.js +11 -23
- package/dist/esm/text-area.js +34 -47
- package/dist/esm/theme.js +2 -3
- package/dist/esm/version.json +1 -1
- package/package.json +2 -2
- package/report.api.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transparent = exports.textColor = exports.subtleBorderColorHover = exports.placeholderTextColor = exports.invalidBorderColor = exports.disabledTextColor = exports.disabledBorder = exports.disabledBackground = exports.defaultBorderColorFocus = exports.defaultBorderColor = exports.defaultBackgroundColorHover = exports.defaultBackgroundColorFocus = exports.defaultBackgroundColor = void 0;
|
|
7
|
-
|
|
8
7
|
var _colors = require("@atlaskit/theme/colors");
|
|
9
|
-
|
|
10
8
|
var disabledBackground = {
|
|
11
9
|
light: "var(--ds-background-disabled, ".concat(_colors.N20, ")"),
|
|
12
10
|
dark: "var(--ds-background-disabled, ".concat(_colors.DN20, ")")
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -23,7 +22,5 @@ Object.defineProperty(exports, "themeTokens", {
|
|
|
23
22
|
return _theme.themeTokens;
|
|
24
23
|
}
|
|
25
24
|
});
|
|
26
|
-
|
|
27
25
|
var _textArea = _interopRequireDefault(require("./text-area"));
|
|
28
|
-
|
|
29
26
|
var _theme = require("./theme");
|
package/dist/cjs/styles.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.themeStyles = exports.getBaseStyles = exports.borderWidth = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _react = require("@emotion/react");
|
|
13
|
-
|
|
14
10
|
var _constants = require("@atlaskit/theme/constants");
|
|
15
|
-
|
|
16
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
|
|
20
13
|
var grid = (0, _constants.gridSize)();
|
|
21
14
|
var borderRadius = 3;
|
|
22
15
|
var lineHeightBase = grid * 2.5;
|
|
@@ -28,25 +21,23 @@ var transitionDuration = '0.2s';
|
|
|
28
21
|
var fontSize = (0, _constants.fontSize)();
|
|
29
22
|
var fontFamily = (0, _constants.fontFamily)();
|
|
30
23
|
var codeFontFamily = (0, _constants.codeFontFamily)();
|
|
31
|
-
var borderWidth = 2;
|
|
32
|
-
// but we want full control so need to override them in all cases
|
|
24
|
+
var borderWidth = 2;
|
|
33
25
|
|
|
26
|
+
// Safari puts on some difficult to remove styles, mainly for disabled inputs
|
|
27
|
+
// but we want full control so need to override them in all cases
|
|
34
28
|
exports.borderWidth = borderWidth;
|
|
35
29
|
var overrideSafariDisabledStyles = {
|
|
36
30
|
WebkitTextFillColor: 'unset',
|
|
37
31
|
WebkitOpacity: '1'
|
|
38
32
|
};
|
|
39
|
-
|
|
40
33
|
var borderBoxMinHeight = function borderBoxMinHeight(minimumRows, borderHeight) {
|
|
41
34
|
var contentHeight = lineHeightBase * minimumRows;
|
|
42
35
|
return contentHeight + verticalPadding * 2 + borderHeight * 2;
|
|
43
36
|
};
|
|
44
|
-
|
|
45
37
|
var borderBoxMinHeightCompact = function borderBoxMinHeightCompact(minimumRows, borderHeight) {
|
|
46
38
|
var contentHeightCompact = lineHeightCompact * minimumRows;
|
|
47
39
|
return contentHeightCompact + compactVerticalPadding * 2 + borderHeight * 2;
|
|
48
40
|
};
|
|
49
|
-
|
|
50
41
|
var bgAndBorderColorStyles = function bgAndBorderColorStyles(props, appearance) {
|
|
51
42
|
return (0, _react.css)(_objectSpread({
|
|
52
43
|
'&:focus': {
|
|
@@ -78,7 +69,6 @@ var bgAndBorderColorStyles = function bgAndBorderColorStyles(props, appearance)
|
|
|
78
69
|
}
|
|
79
70
|
} : {}));
|
|
80
71
|
};
|
|
81
|
-
|
|
82
72
|
var placeholderStyle = function placeholderStyle(placeholderTextColor) {
|
|
83
73
|
return (0, _react.css)({
|
|
84
74
|
'&::placeholder': {
|
|
@@ -86,7 +76,6 @@ var placeholderStyle = function placeholderStyle(placeholderTextColor) {
|
|
|
86
76
|
}
|
|
87
77
|
});
|
|
88
78
|
};
|
|
89
|
-
|
|
90
79
|
var hoverBackgroundAndBorderStyles = function hoverBackgroundAndBorderStyles(props) {
|
|
91
80
|
return (0, _react.css)({
|
|
92
81
|
'&:hover:not(:read-only):not(:focus)': {
|
|
@@ -102,37 +91,31 @@ var hoverBackgroundAndBorderStyles = function hoverBackgroundAndBorderStyles(pro
|
|
|
102
91
|
}
|
|
103
92
|
});
|
|
104
93
|
};
|
|
105
|
-
|
|
106
94
|
var resizeStyle = function resizeStyle(resize) {
|
|
107
95
|
if (resize === 'horizontal' || resize === 'vertical') {
|
|
108
96
|
return (0, _react.css)({
|
|
109
97
|
resize: resize
|
|
110
98
|
});
|
|
111
99
|
}
|
|
112
|
-
|
|
113
100
|
if (resize === 'auto') {
|
|
114
101
|
return (0, _react.css)({
|
|
115
102
|
resize: 'both'
|
|
116
103
|
});
|
|
117
104
|
}
|
|
118
|
-
|
|
119
105
|
return (0, _react.css)({
|
|
120
106
|
resize: 'none'
|
|
121
107
|
});
|
|
122
108
|
};
|
|
123
|
-
|
|
124
109
|
var borderStyle = function borderStyle(appearance) {
|
|
125
110
|
return (0, _react.css)({
|
|
126
111
|
borderStyle: appearance === 'none' ? 'none' : 'solid'
|
|
127
112
|
});
|
|
128
113
|
};
|
|
129
|
-
|
|
130
114
|
var fontFamilyStyle = function fontFamilyStyle(isMonospaced) {
|
|
131
115
|
return (0, _react.css)({
|
|
132
116
|
fontFamily: isMonospaced ? codeFontFamily : fontFamily
|
|
133
117
|
});
|
|
134
118
|
};
|
|
135
|
-
|
|
136
119
|
var borderPaddingAndHeightStyles = function borderPaddingAndHeightStyles() {
|
|
137
120
|
var minimumRows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
138
121
|
var horizontalPaddingWithoutBorderWidth = horizontalPadding - borderWidth;
|
|
@@ -151,7 +134,6 @@ var borderPaddingAndHeightStyles = function borderPaddingAndHeightStyles() {
|
|
|
151
134
|
}
|
|
152
135
|
});
|
|
153
136
|
};
|
|
154
|
-
|
|
155
137
|
var staticStyles = (0, _react.css)({
|
|
156
138
|
display: 'block',
|
|
157
139
|
boxSizing: 'border-box',
|
|
@@ -178,24 +160,23 @@ var staticStyles = (0, _react.css)({
|
|
|
178
160
|
boxShadow: 'none'
|
|
179
161
|
}
|
|
180
162
|
});
|
|
181
|
-
|
|
182
163
|
var getBaseStyles = function getBaseStyles(_ref) {
|
|
183
164
|
var minimumRows = _ref.minimumRows,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return (
|
|
165
|
+
resize = _ref.resize,
|
|
166
|
+
appearance = _ref.appearance,
|
|
167
|
+
isMonospaced = _ref.isMonospaced,
|
|
168
|
+
maxHeight = _ref.maxHeight;
|
|
169
|
+
return (
|
|
170
|
+
// eslint-disable-next-line @repo/internal/styles/no-exported-styles
|
|
189
171
|
(0, _react.css)([staticStyles, borderPaddingAndHeightStyles(minimumRows), resizeStyle(resize), borderStyle(appearance), fontFamilyStyle(isMonospaced), {
|
|
190
172
|
maxHeight: maxHeight
|
|
191
173
|
}])
|
|
192
174
|
);
|
|
193
175
|
};
|
|
194
|
-
|
|
195
176
|
exports.getBaseStyles = getBaseStyles;
|
|
196
|
-
|
|
197
177
|
var themeStyles = function themeStyles(props, appearance) {
|
|
198
|
-
return (
|
|
178
|
+
return (
|
|
179
|
+
// eslint-disable-next-line @repo/internal/styles/no-exported-styles
|
|
199
180
|
(0, _react.css)([bgAndBorderColorStyles(props, appearance), hoverBackgroundAndBorderStyles(props), placeholderStyle(props.placeholderTextColor), {
|
|
200
181
|
color: props.textColor,
|
|
201
182
|
'&:disabled': {
|
|
@@ -204,5 +185,4 @@ var themeStyles = function themeStyles(props, appearance) {
|
|
|
204
185
|
}])
|
|
205
186
|
);
|
|
206
187
|
};
|
|
207
|
-
|
|
208
188
|
exports.themeStyles = themeStyles;
|
package/dist/cjs/text-area.js
CHANGED
|
@@ -1,52 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = void 0;
|
|
11
|
-
|
|
12
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
15
|
-
|
|
16
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
|
|
18
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
19
|
-
|
|
20
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
|
-
|
|
22
14
|
var _react2 = require("@emotion/react");
|
|
23
|
-
|
|
24
15
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
25
|
-
|
|
26
16
|
var _components = require("@atlaskit/theme/components");
|
|
27
|
-
|
|
28
17
|
var _styles = require("./styles");
|
|
29
|
-
|
|
30
18
|
var _theme = require("./theme");
|
|
31
|
-
|
|
32
19
|
var _excluded = ["resize", "appearance", "isCompact", "isRequired", "isReadOnly", "isDisabled", "isInvalid", "isMonospaced", "minimumRows", "theme", "testId", "maxHeight", "onBlur", "onFocus", "onChange", "tokens", "value"];
|
|
33
|
-
|
|
34
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
-
|
|
36
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
37
|
-
|
|
38
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
39
|
-
|
|
40
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
|
-
|
|
42
24
|
var packageName = "@atlaskit/textarea";
|
|
43
|
-
var packageVersion = "4.5.
|
|
25
|
+
var packageVersion = "4.5.5";
|
|
44
26
|
var analyticsParams = {
|
|
45
27
|
componentName: 'textArea',
|
|
46
28
|
packageName: packageName,
|
|
47
29
|
packageVersion: packageVersion
|
|
48
30
|
};
|
|
49
|
-
|
|
50
31
|
var setSmartHeight = function setSmartHeight(el) {
|
|
51
32
|
// Always reset height to auto before calculating new height
|
|
52
33
|
el.style.height = 'auto';
|
|
@@ -55,40 +36,38 @@ var setSmartHeight = function setSmartHeight(el) {
|
|
|
55
36
|
var borderBoxHeight = paddingBoxHeight + borderHeight * 2;
|
|
56
37
|
el.style.height = "".concat(borderBoxHeight, "px");
|
|
57
38
|
};
|
|
58
|
-
|
|
59
39
|
var TextAreaWithTokens = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
60
40
|
var ourRef = (0, _react.useRef)(null);
|
|
61
41
|
var _props$resize = props.resize,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
42
|
+
resize = _props$resize === void 0 ? 'smart' : _props$resize,
|
|
43
|
+
_props$appearance = props.appearance,
|
|
44
|
+
appearance = _props$appearance === void 0 ? 'standard' : _props$appearance,
|
|
45
|
+
_props$isCompact = props.isCompact,
|
|
46
|
+
isCompact = _props$isCompact === void 0 ? false : _props$isCompact,
|
|
47
|
+
_props$isRequired = props.isRequired,
|
|
48
|
+
isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
|
|
49
|
+
_props$isReadOnly = props.isReadOnly,
|
|
50
|
+
isReadOnly = _props$isReadOnly === void 0 ? false : _props$isReadOnly,
|
|
51
|
+
_props$isDisabled = props.isDisabled,
|
|
52
|
+
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
53
|
+
_props$isInvalid = props.isInvalid,
|
|
54
|
+
isInvalid = _props$isInvalid === void 0 ? false : _props$isInvalid,
|
|
55
|
+
_props$isMonospaced = props.isMonospaced,
|
|
56
|
+
isMonospaced = _props$isMonospaced === void 0 ? false : _props$isMonospaced,
|
|
57
|
+
_props$minimumRows = props.minimumRows,
|
|
58
|
+
minimumRows = _props$minimumRows === void 0 ? 2 : _props$minimumRows,
|
|
59
|
+
theme = props.theme,
|
|
60
|
+
testId = props.testId,
|
|
61
|
+
_props$maxHeight = props.maxHeight,
|
|
62
|
+
maxHeight = _props$maxHeight === void 0 ? '50vh' : _props$maxHeight,
|
|
63
|
+
onBlur = props.onBlur,
|
|
64
|
+
onFocus = props.onFocus,
|
|
65
|
+
onChange = props.onChange,
|
|
66
|
+
tokens = props.tokens,
|
|
67
|
+
value = props.value,
|
|
68
|
+
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
89
69
|
(0, _react.useEffect)(function () {
|
|
90
70
|
var el = ourRef.current;
|
|
91
|
-
|
|
92
71
|
if (resize === 'smart' && el) {
|
|
93
72
|
setSmartHeight(el);
|
|
94
73
|
}
|
|
@@ -105,27 +84,21 @@ var TextAreaWithTokens = /*#__PURE__*/(0, _react.forwardRef)(function (props, re
|
|
|
105
84
|
},
|
|
106
85
|
action: 'focused'
|
|
107
86
|
}, analyticsParams));
|
|
108
|
-
|
|
109
87
|
var getTextAreaRef = function getTextAreaRef(elementRef) {
|
|
110
88
|
ourRef.current = elementRef;
|
|
111
|
-
|
|
112
89
|
if (ref && (0, _typeof2.default)(ref) === 'object') {
|
|
113
90
|
// @ts-ignore
|
|
114
91
|
ref.current = elementRef;
|
|
115
92
|
}
|
|
116
|
-
|
|
117
93
|
if (ref && typeof ref === 'function') {
|
|
118
94
|
ref(elementRef);
|
|
119
95
|
}
|
|
120
96
|
};
|
|
121
|
-
|
|
122
97
|
var handleOnChange = (0, _react.useCallback)(function (e) {
|
|
123
98
|
var el = ourRef.current;
|
|
124
|
-
|
|
125
99
|
if (resize === 'smart' && el) {
|
|
126
100
|
setSmartHeight(el);
|
|
127
101
|
}
|
|
128
|
-
|
|
129
102
|
onChange && onChange(e);
|
|
130
103
|
}, [onChange, resize]);
|
|
131
104
|
var controlProps = {
|
|
@@ -142,7 +115,8 @@ var TextAreaWithTokens = /*#__PURE__*/(0, _react.forwardRef)(function (props, re
|
|
|
142
115
|
maxHeight: maxHeight
|
|
143
116
|
});
|
|
144
117
|
}, [minimumRows, resize, appearance, isMonospaced, maxHeight]);
|
|
145
|
-
var textAreaStyles = (0, _react2.css)([baseStyles,
|
|
118
|
+
var textAreaStyles = (0, _react2.css)([baseStyles,
|
|
119
|
+
// not memoizing themeStyles as `tokens` is an unstable reference
|
|
146
120
|
(0, _styles.themeStyles)(tokens, appearance)]);
|
|
147
121
|
return (0, _react2.jsx)("textarea", (0, _extends2.default)({}, controlProps, {
|
|
148
122
|
value: value,
|
|
@@ -153,13 +127,15 @@ var TextAreaWithTokens = /*#__PURE__*/(0, _react.forwardRef)(function (props, re
|
|
|
153
127
|
onChange: handleOnChange,
|
|
154
128
|
onBlur: onBlurWithAnalytics,
|
|
155
129
|
onFocus: onFocusWithAnalytics,
|
|
156
|
-
rows: minimumRows
|
|
130
|
+
rows: minimumRows
|
|
131
|
+
// TODO refactor to follow emotion styling rules
|
|
157
132
|
// see: https://product-fabric.atlassian.net/browse/DSP-6060
|
|
158
133
|
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
159
134
|
,
|
|
160
135
|
css: textAreaStyles
|
|
161
136
|
}, rest));
|
|
162
137
|
});
|
|
138
|
+
|
|
163
139
|
/**
|
|
164
140
|
* __Text area__
|
|
165
141
|
*
|
|
@@ -169,11 +145,9 @@ var TextAreaWithTokens = /*#__PURE__*/(0, _react.forwardRef)(function (props, re
|
|
|
169
145
|
* - [Code](https://atlassian.design/components/textarea/code)
|
|
170
146
|
* - [Usage](https://atlassian.design/components/textarea/usage)
|
|
171
147
|
*/
|
|
172
|
-
|
|
173
148
|
var TextArea = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function TextArea(props, ref) {
|
|
174
149
|
var _useGlobalTheme = (0, _components.useGlobalTheme)(),
|
|
175
|
-
|
|
176
|
-
|
|
150
|
+
mode = _useGlobalTheme.mode;
|
|
177
151
|
return (0, _react2.jsx)(_theme.Theme.Provider, {
|
|
178
152
|
value: props.theme
|
|
179
153
|
}, (0, _react2.jsx)(_theme.Theme.Consumer, {
|
package/dist/cjs/theme.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.themeTokens = exports.Theme = void 0;
|
|
9
|
-
|
|
10
8
|
var _components = require("@atlaskit/theme/components");
|
|
11
|
-
|
|
12
9
|
var componentTokens = _interopRequireWildcard(require("./component-tokens"));
|
|
13
|
-
|
|
14
10
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
|
|
16
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
17
|
-
|
|
18
12
|
var disabledRules = {
|
|
19
13
|
light: {
|
|
20
14
|
backgroundColor: componentTokens.disabledBackground.light,
|
|
@@ -79,7 +73,6 @@ var borderColorHover = {
|
|
|
79
73
|
subtle: componentTokens.subtleBorderColorHover,
|
|
80
74
|
none: componentTokens.transparent
|
|
81
75
|
};
|
|
82
|
-
|
|
83
76
|
/**
|
|
84
77
|
* @deprecated
|
|
85
78
|
* Component-level theming is deprecated in the design system.
|
|
@@ -96,16 +89,16 @@ var themeTokens = {
|
|
|
96
89
|
textColor: componentTokens.textColor,
|
|
97
90
|
placeholderTextColor: componentTokens.placeholderTextColor
|
|
98
91
|
};
|
|
92
|
+
|
|
99
93
|
/**
|
|
100
94
|
* @deprecated
|
|
101
95
|
* Component-level theming is deprecated in the design system.
|
|
102
96
|
* Components should respect the global theme.
|
|
103
97
|
*/
|
|
104
|
-
|
|
105
98
|
exports.themeTokens = themeTokens;
|
|
106
99
|
var Theme = (0, _components.createTheme)(function (_ref) {
|
|
107
100
|
var appearance = _ref.appearance,
|
|
108
|
-
|
|
101
|
+
mode = _ref.mode;
|
|
109
102
|
return {
|
|
110
103
|
borderColor: borderColor[appearance][mode],
|
|
111
104
|
borderColorFocus: borderColorFocus[appearance][mode],
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/styles.js
CHANGED
|
@@ -12,24 +12,22 @@ const transitionDuration = '0.2s';
|
|
|
12
12
|
const fontSize = getFontSize();
|
|
13
13
|
const fontFamily = getFontFamily();
|
|
14
14
|
const codeFontFamily = getCodeFontFamily();
|
|
15
|
-
export const borderWidth = 2;
|
|
16
|
-
// but we want full control so need to override them in all cases
|
|
15
|
+
export const borderWidth = 2;
|
|
17
16
|
|
|
17
|
+
// Safari puts on some difficult to remove styles, mainly for disabled inputs
|
|
18
|
+
// but we want full control so need to override them in all cases
|
|
18
19
|
const overrideSafariDisabledStyles = {
|
|
19
20
|
WebkitTextFillColor: 'unset',
|
|
20
21
|
WebkitOpacity: '1'
|
|
21
22
|
};
|
|
22
|
-
|
|
23
23
|
const borderBoxMinHeight = (minimumRows, borderHeight) => {
|
|
24
24
|
const contentHeight = lineHeightBase * minimumRows;
|
|
25
25
|
return contentHeight + verticalPadding * 2 + borderHeight * 2;
|
|
26
26
|
};
|
|
27
|
-
|
|
28
27
|
const borderBoxMinHeightCompact = (minimumRows, borderHeight) => {
|
|
29
28
|
const contentHeightCompact = lineHeightCompact * minimumRows;
|
|
30
29
|
return contentHeightCompact + compactVerticalPadding * 2 + borderHeight * 2;
|
|
31
30
|
};
|
|
32
|
-
|
|
33
31
|
const bgAndBorderColorStyles = (props, appearance) => css({
|
|
34
32
|
'&:focus': {
|
|
35
33
|
backgroundColor: props.backgroundColorFocus,
|
|
@@ -62,13 +60,11 @@ const bgAndBorderColorStyles = (props, appearance) => css({
|
|
|
62
60
|
}
|
|
63
61
|
} : {})
|
|
64
62
|
});
|
|
65
|
-
|
|
66
63
|
const placeholderStyle = placeholderTextColor => css({
|
|
67
64
|
'&::placeholder': {
|
|
68
65
|
color: placeholderTextColor
|
|
69
66
|
}
|
|
70
67
|
});
|
|
71
|
-
|
|
72
68
|
const hoverBackgroundAndBorderStyles = props => css({
|
|
73
69
|
'&:hover:not(:read-only):not(:focus)': {
|
|
74
70
|
backgroundColor: props.backgroundColorHover,
|
|
@@ -82,33 +78,27 @@ const hoverBackgroundAndBorderStyles = props => css({
|
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
80
|
});
|
|
85
|
-
|
|
86
81
|
const resizeStyle = resize => {
|
|
87
82
|
if (resize === 'horizontal' || resize === 'vertical') {
|
|
88
83
|
return css({
|
|
89
84
|
resize
|
|
90
85
|
});
|
|
91
86
|
}
|
|
92
|
-
|
|
93
87
|
if (resize === 'auto') {
|
|
94
88
|
return css({
|
|
95
89
|
resize: 'both'
|
|
96
90
|
});
|
|
97
91
|
}
|
|
98
|
-
|
|
99
92
|
return css({
|
|
100
93
|
resize: 'none'
|
|
101
94
|
});
|
|
102
95
|
};
|
|
103
|
-
|
|
104
96
|
const borderStyle = appearance => css({
|
|
105
97
|
borderStyle: appearance === 'none' ? 'none' : 'solid'
|
|
106
98
|
});
|
|
107
|
-
|
|
108
99
|
const fontFamilyStyle = isMonospaced => css({
|
|
109
100
|
fontFamily: isMonospaced ? codeFontFamily : fontFamily
|
|
110
101
|
});
|
|
111
|
-
|
|
112
102
|
const borderPaddingAndHeightStyles = (minimumRows = 1) => {
|
|
113
103
|
const horizontalPaddingWithoutBorderWidth = horizontalPadding - borderWidth;
|
|
114
104
|
const borderHeight = borderWidth;
|
|
@@ -126,7 +116,6 @@ const borderPaddingAndHeightStyles = (minimumRows = 1) => {
|
|
|
126
116
|
}
|
|
127
117
|
});
|
|
128
118
|
};
|
|
129
|
-
|
|
130
119
|
const staticStyles = css({
|
|
131
120
|
display: 'block',
|
|
132
121
|
boxSizing: 'border-box',
|
|
@@ -161,11 +150,13 @@ export const getBaseStyles = ({
|
|
|
161
150
|
appearance,
|
|
162
151
|
isMonospaced,
|
|
163
152
|
maxHeight
|
|
164
|
-
}) =>
|
|
153
|
+
}) =>
|
|
154
|
+
// eslint-disable-next-line @repo/internal/styles/no-exported-styles
|
|
165
155
|
css([staticStyles, borderPaddingAndHeightStyles(minimumRows), resizeStyle(resize), borderStyle(appearance), fontFamilyStyle(isMonospaced), {
|
|
166
156
|
maxHeight
|
|
167
157
|
}]);
|
|
168
|
-
export const themeStyles = (props, appearance) =>
|
|
158
|
+
export const themeStyles = (props, appearance) =>
|
|
159
|
+
// eslint-disable-next-line @repo/internal/styles/no-exported-styles
|
|
169
160
|
css([bgAndBorderColorStyles(props, appearance), hoverBackgroundAndBorderStyles(props), placeholderStyle(props.placeholderTextColor), {
|
|
170
161
|
color: props.textColor,
|
|
171
162
|
'&:disabled': {
|
package/dist/es2019/text-area.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import React, { forwardRef, memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
5
4
|
import { css, jsx } from '@emotion/react';
|
|
@@ -8,13 +7,12 @@ import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
|
8
7
|
import { borderWidth, getBaseStyles, themeStyles } from './styles';
|
|
9
8
|
import { Theme } from './theme';
|
|
10
9
|
const packageName = "@atlaskit/textarea";
|
|
11
|
-
const packageVersion = "4.5.
|
|
10
|
+
const packageVersion = "4.5.5";
|
|
12
11
|
const analyticsParams = {
|
|
13
12
|
componentName: 'textArea',
|
|
14
13
|
packageName,
|
|
15
14
|
packageVersion
|
|
16
15
|
};
|
|
17
|
-
|
|
18
16
|
const setSmartHeight = el => {
|
|
19
17
|
// Always reset height to auto before calculating new height
|
|
20
18
|
el.style.height = 'auto';
|
|
@@ -23,7 +21,6 @@ const setSmartHeight = el => {
|
|
|
23
21
|
const borderBoxHeight = paddingBoxHeight + borderHeight * 2;
|
|
24
22
|
el.style.height = `${borderBoxHeight}px`;
|
|
25
23
|
};
|
|
26
|
-
|
|
27
24
|
const TextAreaWithTokens = /*#__PURE__*/forwardRef((props, ref) => {
|
|
28
25
|
const ourRef = useRef(null);
|
|
29
26
|
const {
|
|
@@ -48,7 +45,6 @@ const TextAreaWithTokens = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
48
45
|
} = props;
|
|
49
46
|
useEffect(() => {
|
|
50
47
|
const el = ourRef.current;
|
|
51
|
-
|
|
52
48
|
if (resize === 'smart' && el) {
|
|
53
49
|
setSmartHeight(el);
|
|
54
50
|
}
|
|
@@ -67,27 +63,21 @@ const TextAreaWithTokens = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
67
63
|
action: 'focused',
|
|
68
64
|
...analyticsParams
|
|
69
65
|
});
|
|
70
|
-
|
|
71
66
|
const getTextAreaRef = elementRef => {
|
|
72
67
|
ourRef.current = elementRef;
|
|
73
|
-
|
|
74
68
|
if (ref && typeof ref === 'object') {
|
|
75
69
|
// @ts-ignore
|
|
76
70
|
ref.current = elementRef;
|
|
77
71
|
}
|
|
78
|
-
|
|
79
72
|
if (ref && typeof ref === 'function') {
|
|
80
73
|
ref(elementRef);
|
|
81
74
|
}
|
|
82
75
|
};
|
|
83
|
-
|
|
84
76
|
const handleOnChange = useCallback(e => {
|
|
85
77
|
const el = ourRef.current;
|
|
86
|
-
|
|
87
78
|
if (resize === 'smart' && el) {
|
|
88
79
|
setSmartHeight(el);
|
|
89
80
|
}
|
|
90
|
-
|
|
91
81
|
onChange && onChange(e);
|
|
92
82
|
}, [onChange, resize]);
|
|
93
83
|
const controlProps = {
|
|
@@ -102,7 +92,8 @@ const TextAreaWithTokens = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
102
92
|
isMonospaced,
|
|
103
93
|
maxHeight
|
|
104
94
|
}), [minimumRows, resize, appearance, isMonospaced, maxHeight]);
|
|
105
|
-
const textAreaStyles = css([baseStyles,
|
|
95
|
+
const textAreaStyles = css([baseStyles,
|
|
96
|
+
// not memoizing themeStyles as `tokens` is an unstable reference
|
|
106
97
|
themeStyles(tokens, appearance)]);
|
|
107
98
|
return jsx("textarea", _extends({}, controlProps, {
|
|
108
99
|
value: value,
|
|
@@ -113,13 +104,15 @@ const TextAreaWithTokens = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
113
104
|
onChange: handleOnChange,
|
|
114
105
|
onBlur: onBlurWithAnalytics,
|
|
115
106
|
onFocus: onFocusWithAnalytics,
|
|
116
|
-
rows: minimumRows
|
|
107
|
+
rows: minimumRows
|
|
108
|
+
// TODO refactor to follow emotion styling rules
|
|
117
109
|
// see: https://product-fabric.atlassian.net/browse/DSP-6060
|
|
118
110
|
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
119
111
|
,
|
|
120
112
|
css: textAreaStyles
|
|
121
113
|
}, rest));
|
|
122
114
|
});
|
|
115
|
+
|
|
123
116
|
/**
|
|
124
117
|
* __Text area__
|
|
125
118
|
*
|
|
@@ -129,7 +122,6 @@ const TextAreaWithTokens = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
129
122
|
* - [Code](https://atlassian.design/components/textarea/code)
|
|
130
123
|
* - [Usage](https://atlassian.design/components/textarea/usage)
|
|
131
124
|
*/
|
|
132
|
-
|
|
133
125
|
const TextArea = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function TextArea(props, ref) {
|
|
134
126
|
const {
|
|
135
127
|
mode
|
package/dist/es2019/theme.js
CHANGED
|
@@ -64,7 +64,6 @@ const borderColorHover = {
|
|
|
64
64
|
subtle: componentTokens.subtleBorderColorHover,
|
|
65
65
|
none: componentTokens.transparent
|
|
66
66
|
};
|
|
67
|
-
|
|
68
67
|
/**
|
|
69
68
|
* @deprecated
|
|
70
69
|
* Component-level theming is deprecated in the design system.
|
|
@@ -81,12 +80,12 @@ export const themeTokens = {
|
|
|
81
80
|
textColor: componentTokens.textColor,
|
|
82
81
|
placeholderTextColor: componentTokens.placeholderTextColor
|
|
83
82
|
};
|
|
83
|
+
|
|
84
84
|
/**
|
|
85
85
|
* @deprecated
|
|
86
86
|
* Component-level theming is deprecated in the design system.
|
|
87
87
|
* Components should respect the global theme.
|
|
88
88
|
*/
|
|
89
|
-
|
|
90
89
|
export const Theme = createTheme(({
|
|
91
90
|
appearance,
|
|
92
91
|
mode
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/styles.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
/** @jsx jsx */
|
|
8
5
|
import { css } from '@emotion/react';
|
|
9
6
|
import { codeFontFamily as getCodeFontFamily, fontFamily as getFontFamily, fontSize as getFontSize, gridSize } from '@atlaskit/theme/constants';
|
|
@@ -18,24 +15,22 @@ var transitionDuration = '0.2s';
|
|
|
18
15
|
var fontSize = getFontSize();
|
|
19
16
|
var fontFamily = getFontFamily();
|
|
20
17
|
var codeFontFamily = getCodeFontFamily();
|
|
21
|
-
export var borderWidth = 2;
|
|
22
|
-
// but we want full control so need to override them in all cases
|
|
18
|
+
export var borderWidth = 2;
|
|
23
19
|
|
|
20
|
+
// Safari puts on some difficult to remove styles, mainly for disabled inputs
|
|
21
|
+
// but we want full control so need to override them in all cases
|
|
24
22
|
var overrideSafariDisabledStyles = {
|
|
25
23
|
WebkitTextFillColor: 'unset',
|
|
26
24
|
WebkitOpacity: '1'
|
|
27
25
|
};
|
|
28
|
-
|
|
29
26
|
var borderBoxMinHeight = function borderBoxMinHeight(minimumRows, borderHeight) {
|
|
30
27
|
var contentHeight = lineHeightBase * minimumRows;
|
|
31
28
|
return contentHeight + verticalPadding * 2 + borderHeight * 2;
|
|
32
29
|
};
|
|
33
|
-
|
|
34
30
|
var borderBoxMinHeightCompact = function borderBoxMinHeightCompact(minimumRows, borderHeight) {
|
|
35
31
|
var contentHeightCompact = lineHeightCompact * minimumRows;
|
|
36
32
|
return contentHeightCompact + compactVerticalPadding * 2 + borderHeight * 2;
|
|
37
33
|
};
|
|
38
|
-
|
|
39
34
|
var bgAndBorderColorStyles = function bgAndBorderColorStyles(props, appearance) {
|
|
40
35
|
return css(_objectSpread({
|
|
41
36
|
'&:focus': {
|
|
@@ -67,7 +62,6 @@ var bgAndBorderColorStyles = function bgAndBorderColorStyles(props, appearance)
|
|
|
67
62
|
}
|
|
68
63
|
} : {}));
|
|
69
64
|
};
|
|
70
|
-
|
|
71
65
|
var placeholderStyle = function placeholderStyle(placeholderTextColor) {
|
|
72
66
|
return css({
|
|
73
67
|
'&::placeholder': {
|
|
@@ -75,7 +69,6 @@ var placeholderStyle = function placeholderStyle(placeholderTextColor) {
|
|
|
75
69
|
}
|
|
76
70
|
});
|
|
77
71
|
};
|
|
78
|
-
|
|
79
72
|
var hoverBackgroundAndBorderStyles = function hoverBackgroundAndBorderStyles(props) {
|
|
80
73
|
return css({
|
|
81
74
|
'&:hover:not(:read-only):not(:focus)': {
|
|
@@ -91,37 +84,31 @@ var hoverBackgroundAndBorderStyles = function hoverBackgroundAndBorderStyles(pro
|
|
|
91
84
|
}
|
|
92
85
|
});
|
|
93
86
|
};
|
|
94
|
-
|
|
95
87
|
var resizeStyle = function resizeStyle(resize) {
|
|
96
88
|
if (resize === 'horizontal' || resize === 'vertical') {
|
|
97
89
|
return css({
|
|
98
90
|
resize: resize
|
|
99
91
|
});
|
|
100
92
|
}
|
|
101
|
-
|
|
102
93
|
if (resize === 'auto') {
|
|
103
94
|
return css({
|
|
104
95
|
resize: 'both'
|
|
105
96
|
});
|
|
106
97
|
}
|
|
107
|
-
|
|
108
98
|
return css({
|
|
109
99
|
resize: 'none'
|
|
110
100
|
});
|
|
111
101
|
};
|
|
112
|
-
|
|
113
102
|
var borderStyle = function borderStyle(appearance) {
|
|
114
103
|
return css({
|
|
115
104
|
borderStyle: appearance === 'none' ? 'none' : 'solid'
|
|
116
105
|
});
|
|
117
106
|
};
|
|
118
|
-
|
|
119
107
|
var fontFamilyStyle = function fontFamilyStyle(isMonospaced) {
|
|
120
108
|
return css({
|
|
121
109
|
fontFamily: isMonospaced ? codeFontFamily : fontFamily
|
|
122
110
|
});
|
|
123
111
|
};
|
|
124
|
-
|
|
125
112
|
var borderPaddingAndHeightStyles = function borderPaddingAndHeightStyles() {
|
|
126
113
|
var minimumRows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
127
114
|
var horizontalPaddingWithoutBorderWidth = horizontalPadding - borderWidth;
|
|
@@ -140,7 +127,6 @@ var borderPaddingAndHeightStyles = function borderPaddingAndHeightStyles() {
|
|
|
140
127
|
}
|
|
141
128
|
});
|
|
142
129
|
};
|
|
143
|
-
|
|
144
130
|
var staticStyles = css({
|
|
145
131
|
display: 'block',
|
|
146
132
|
boxSizing: 'border-box',
|
|
@@ -169,18 +155,20 @@ var staticStyles = css({
|
|
|
169
155
|
});
|
|
170
156
|
export var getBaseStyles = function getBaseStyles(_ref) {
|
|
171
157
|
var minimumRows = _ref.minimumRows,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return (
|
|
158
|
+
resize = _ref.resize,
|
|
159
|
+
appearance = _ref.appearance,
|
|
160
|
+
isMonospaced = _ref.isMonospaced,
|
|
161
|
+
maxHeight = _ref.maxHeight;
|
|
162
|
+
return (
|
|
163
|
+
// eslint-disable-next-line @repo/internal/styles/no-exported-styles
|
|
177
164
|
css([staticStyles, borderPaddingAndHeightStyles(minimumRows), resizeStyle(resize), borderStyle(appearance), fontFamilyStyle(isMonospaced), {
|
|
178
165
|
maxHeight: maxHeight
|
|
179
166
|
}])
|
|
180
167
|
);
|
|
181
168
|
};
|
|
182
169
|
export var themeStyles = function themeStyles(props, appearance) {
|
|
183
|
-
return (
|
|
170
|
+
return (
|
|
171
|
+
// eslint-disable-next-line @repo/internal/styles/no-exported-styles
|
|
184
172
|
css([bgAndBorderColorStyles(props, appearance), hoverBackgroundAndBorderStyles(props), placeholderStyle(props.placeholderTextColor), {
|
|
185
173
|
color: props.textColor,
|
|
186
174
|
'&:disabled': {
|
package/dist/esm/text-area.js
CHANGED
|
@@ -3,11 +3,8 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
5
|
var _excluded = ["resize", "appearance", "isCompact", "isRequired", "isReadOnly", "isDisabled", "isInvalid", "isMonospaced", "minimumRows", "theme", "testId", "maxHeight", "onBlur", "onFocus", "onChange", "tokens", "value"];
|
|
6
|
-
|
|
7
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
|
|
11
8
|
/** @jsx jsx */
|
|
12
9
|
import React, { forwardRef, memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
13
10
|
import { css, jsx } from '@emotion/react';
|
|
@@ -16,13 +13,12 @@ import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
|
16
13
|
import { borderWidth, getBaseStyles, themeStyles } from './styles';
|
|
17
14
|
import { Theme } from './theme';
|
|
18
15
|
var packageName = "@atlaskit/textarea";
|
|
19
|
-
var packageVersion = "4.5.
|
|
16
|
+
var packageVersion = "4.5.5";
|
|
20
17
|
var analyticsParams = {
|
|
21
18
|
componentName: 'textArea',
|
|
22
19
|
packageName: packageName,
|
|
23
20
|
packageVersion: packageVersion
|
|
24
21
|
};
|
|
25
|
-
|
|
26
22
|
var setSmartHeight = function setSmartHeight(el) {
|
|
27
23
|
// Always reset height to auto before calculating new height
|
|
28
24
|
el.style.height = 'auto';
|
|
@@ -31,42 +27,38 @@ var setSmartHeight = function setSmartHeight(el) {
|
|
|
31
27
|
var borderBoxHeight = paddingBoxHeight + borderHeight * 2;
|
|
32
28
|
el.style.height = "".concat(borderBoxHeight, "px");
|
|
33
29
|
};
|
|
34
|
-
|
|
35
30
|
var TextAreaWithTokens = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
36
31
|
var ourRef = useRef(null);
|
|
37
|
-
|
|
38
32
|
var _props$resize = props.resize,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
33
|
+
resize = _props$resize === void 0 ? 'smart' : _props$resize,
|
|
34
|
+
_props$appearance = props.appearance,
|
|
35
|
+
appearance = _props$appearance === void 0 ? 'standard' : _props$appearance,
|
|
36
|
+
_props$isCompact = props.isCompact,
|
|
37
|
+
isCompact = _props$isCompact === void 0 ? false : _props$isCompact,
|
|
38
|
+
_props$isRequired = props.isRequired,
|
|
39
|
+
isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
|
|
40
|
+
_props$isReadOnly = props.isReadOnly,
|
|
41
|
+
isReadOnly = _props$isReadOnly === void 0 ? false : _props$isReadOnly,
|
|
42
|
+
_props$isDisabled = props.isDisabled,
|
|
43
|
+
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
44
|
+
_props$isInvalid = props.isInvalid,
|
|
45
|
+
isInvalid = _props$isInvalid === void 0 ? false : _props$isInvalid,
|
|
46
|
+
_props$isMonospaced = props.isMonospaced,
|
|
47
|
+
isMonospaced = _props$isMonospaced === void 0 ? false : _props$isMonospaced,
|
|
48
|
+
_props$minimumRows = props.minimumRows,
|
|
49
|
+
minimumRows = _props$minimumRows === void 0 ? 2 : _props$minimumRows,
|
|
50
|
+
theme = props.theme,
|
|
51
|
+
testId = props.testId,
|
|
52
|
+
_props$maxHeight = props.maxHeight,
|
|
53
|
+
maxHeight = _props$maxHeight === void 0 ? '50vh' : _props$maxHeight,
|
|
54
|
+
onBlur = props.onBlur,
|
|
55
|
+
onFocus = props.onFocus,
|
|
56
|
+
onChange = props.onChange,
|
|
57
|
+
tokens = props.tokens,
|
|
58
|
+
value = props.value,
|
|
59
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
67
60
|
useEffect(function () {
|
|
68
61
|
var el = ourRef.current;
|
|
69
|
-
|
|
70
62
|
if (resize === 'smart' && el) {
|
|
71
63
|
setSmartHeight(el);
|
|
72
64
|
}
|
|
@@ -83,27 +75,21 @@ var TextAreaWithTokens = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
83
75
|
},
|
|
84
76
|
action: 'focused'
|
|
85
77
|
}, analyticsParams));
|
|
86
|
-
|
|
87
78
|
var getTextAreaRef = function getTextAreaRef(elementRef) {
|
|
88
79
|
ourRef.current = elementRef;
|
|
89
|
-
|
|
90
80
|
if (ref && _typeof(ref) === 'object') {
|
|
91
81
|
// @ts-ignore
|
|
92
82
|
ref.current = elementRef;
|
|
93
83
|
}
|
|
94
|
-
|
|
95
84
|
if (ref && typeof ref === 'function') {
|
|
96
85
|
ref(elementRef);
|
|
97
86
|
}
|
|
98
87
|
};
|
|
99
|
-
|
|
100
88
|
var handleOnChange = useCallback(function (e) {
|
|
101
89
|
var el = ourRef.current;
|
|
102
|
-
|
|
103
90
|
if (resize === 'smart' && el) {
|
|
104
91
|
setSmartHeight(el);
|
|
105
92
|
}
|
|
106
|
-
|
|
107
93
|
onChange && onChange(e);
|
|
108
94
|
}, [onChange, resize]);
|
|
109
95
|
var controlProps = {
|
|
@@ -120,7 +106,8 @@ var TextAreaWithTokens = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
120
106
|
maxHeight: maxHeight
|
|
121
107
|
});
|
|
122
108
|
}, [minimumRows, resize, appearance, isMonospaced, maxHeight]);
|
|
123
|
-
var textAreaStyles = css([baseStyles,
|
|
109
|
+
var textAreaStyles = css([baseStyles,
|
|
110
|
+
// not memoizing themeStyles as `tokens` is an unstable reference
|
|
124
111
|
themeStyles(tokens, appearance)]);
|
|
125
112
|
return jsx("textarea", _extends({}, controlProps, {
|
|
126
113
|
value: value,
|
|
@@ -131,13 +118,15 @@ var TextAreaWithTokens = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
131
118
|
onChange: handleOnChange,
|
|
132
119
|
onBlur: onBlurWithAnalytics,
|
|
133
120
|
onFocus: onFocusWithAnalytics,
|
|
134
|
-
rows: minimumRows
|
|
121
|
+
rows: minimumRows
|
|
122
|
+
// TODO refactor to follow emotion styling rules
|
|
135
123
|
// see: https://product-fabric.atlassian.net/browse/DSP-6060
|
|
136
124
|
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
137
125
|
,
|
|
138
126
|
css: textAreaStyles
|
|
139
127
|
}, rest));
|
|
140
128
|
});
|
|
129
|
+
|
|
141
130
|
/**
|
|
142
131
|
* __Text area__
|
|
143
132
|
*
|
|
@@ -147,11 +136,9 @@ var TextAreaWithTokens = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
147
136
|
* - [Code](https://atlassian.design/components/textarea/code)
|
|
148
137
|
* - [Usage](https://atlassian.design/components/textarea/usage)
|
|
149
138
|
*/
|
|
150
|
-
|
|
151
139
|
var TextArea = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function TextArea(props, ref) {
|
|
152
140
|
var _useGlobalTheme = useGlobalTheme(),
|
|
153
|
-
|
|
154
|
-
|
|
141
|
+
mode = _useGlobalTheme.mode;
|
|
155
142
|
return jsx(Theme.Provider, {
|
|
156
143
|
value: props.theme
|
|
157
144
|
}, jsx(Theme.Consumer, {
|
package/dist/esm/theme.js
CHANGED
|
@@ -64,7 +64,6 @@ var borderColorHover = {
|
|
|
64
64
|
subtle: componentTokens.subtleBorderColorHover,
|
|
65
65
|
none: componentTokens.transparent
|
|
66
66
|
};
|
|
67
|
-
|
|
68
67
|
/**
|
|
69
68
|
* @deprecated
|
|
70
69
|
* Component-level theming is deprecated in the design system.
|
|
@@ -81,15 +80,15 @@ export var themeTokens = {
|
|
|
81
80
|
textColor: componentTokens.textColor,
|
|
82
81
|
placeholderTextColor: componentTokens.placeholderTextColor
|
|
83
82
|
};
|
|
83
|
+
|
|
84
84
|
/**
|
|
85
85
|
* @deprecated
|
|
86
86
|
* Component-level theming is deprecated in the design system.
|
|
87
87
|
* Components should respect the global theme.
|
|
88
88
|
*/
|
|
89
|
-
|
|
90
89
|
export var Theme = createTheme(function (_ref) {
|
|
91
90
|
var appearance = _ref.appearance,
|
|
92
|
-
|
|
91
|
+
mode = _ref.mode;
|
|
93
92
|
return {
|
|
94
93
|
borderColor: borderColor[appearance][mode],
|
|
95
94
|
borderColorFocus: borderColorFocus[appearance][mode],
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/textarea",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.5",
|
|
4
4
|
"description": "A text area lets users enter long form text which spans over multiple lines.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/analytics-next": "^8.0.0",
|
|
36
36
|
"@atlaskit/theme": "^12.2.0",
|
|
37
|
-
"@atlaskit/tokens": "^0.
|
|
37
|
+
"@atlaskit/tokens": "^1.0.0",
|
|
38
38
|
"@babel/runtime": "^7.0.0",
|
|
39
39
|
"@emotion/react": "^11.7.1"
|
|
40
40
|
},
|
package/report.api.md
CHANGED