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
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
|
|
@@ -27,167 +27,107 @@ var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/e
|
|
|
27
27
|
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
29
|
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
|
-
|
|
34
|
-
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); } }
|
|
35
|
-
|
|
36
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
37
|
-
|
|
38
|
-
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); }
|
|
39
|
-
|
|
40
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
41
|
-
|
|
42
|
-
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); }; }
|
|
43
|
-
|
|
44
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
45
|
-
|
|
46
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
47
|
-
|
|
48
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
|
-
|
|
50
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
51
|
-
|
|
52
|
-
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; }
|
|
53
|
-
|
|
54
|
-
let Toast = /*#__PURE__*/function (_React$Component) {
|
|
55
|
-
_inherits(Toast, _React$Component);
|
|
56
|
-
|
|
57
|
-
var _super = _createSuper(Toast);
|
|
58
|
-
|
|
59
|
-
function Toast(props) {
|
|
60
|
-
var _this;
|
|
30
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
61
31
|
|
|
62
|
-
|
|
32
|
+
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; }
|
|
63
33
|
|
|
64
|
-
|
|
34
|
+
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); }
|
|
65
35
|
|
|
66
|
-
|
|
67
|
-
|
|
36
|
+
const Toast = ({
|
|
37
|
+
as = "warning",
|
|
38
|
+
children,
|
|
39
|
+
className,
|
|
40
|
+
id,
|
|
41
|
+
isCenter = true,
|
|
42
|
+
maxWidth,
|
|
43
|
+
onDismiss,
|
|
44
|
+
open = true,
|
|
45
|
+
targetPortalId,
|
|
46
|
+
timeout,
|
|
47
|
+
variant,
|
|
48
|
+
...restProps
|
|
49
|
+
}) => {
|
|
50
|
+
const toastRef = (0, _react.useRef)();
|
|
51
|
+
const timer = (0, _react.useRef)();
|
|
52
|
+
const componentClasses = (0, _react.useMemo)(() => {
|
|
53
|
+
return (0, _classnames.default)(className);
|
|
54
|
+
}, [className]);
|
|
55
|
+
const dismissToast = (0, _react.useCallback)(ev => {
|
|
56
|
+
const isTopmost = _modalManager.default.isTopmost(toastRef.current);
|
|
57
|
+
|
|
58
|
+
if (onDismiss && _events.default.isEscKey(ev) && isTopmost) {
|
|
59
|
+
ev.stopImmediatePropagation();
|
|
60
|
+
onDismiss(ev);
|
|
61
|
+
}
|
|
62
|
+
}, [onDismiss]);
|
|
63
|
+
(0, _react.useEffect)(() => {
|
|
64
|
+
const currentElement = toastRef.current;
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
ev.stopImmediatePropagation();
|
|
66
|
+
_modalManager.default.addModal(currentElement);
|
|
71
67
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
document.addEventListener("keyup", dismissToast);
|
|
69
|
+
return () => {
|
|
70
|
+
_modalManager.default.removeModal(currentElement);
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
document.removeEventListener("keyup", dismissToast);
|
|
73
|
+
};
|
|
74
|
+
}, [dismissToast]);
|
|
75
|
+
(0, _react.useEffect)(() => {
|
|
76
|
+
clearTimeout(timer.current);
|
|
80
77
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
get:
|
|
84
|
-
/** Classes to be applied to the component. */
|
|
85
|
-
function () {
|
|
86
|
-
return (0, _classnames.default)(this.props.className);
|
|
78
|
+
if (!timeout || !open || !onDismiss) {
|
|
79
|
+
return;
|
|
87
80
|
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "componentDidMount",
|
|
90
|
-
value: function componentDidMount() {
|
|
91
|
-
_modalManager.default.addModal(this.toastRef.current);
|
|
92
81
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
82
|
+
timer.current = setTimeout(() => onDismiss(), timeout);
|
|
83
|
+
}, [onDismiss, open, timeout]);
|
|
84
|
+
|
|
85
|
+
function renderCloseIcon() {
|
|
86
|
+
if (!onDismiss) return null;
|
|
87
|
+
return /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
88
|
+
"data-element": "close",
|
|
89
|
+
onAction: onDismiss
|
|
90
|
+
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
91
|
+
type: "close"
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
99
94
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
95
|
+
function renderToastContent() {
|
|
96
|
+
if (!open) return null;
|
|
97
|
+
const toastProps = {
|
|
98
|
+
isCenter,
|
|
99
|
+
variant: variant || as,
|
|
100
|
+
id,
|
|
101
|
+
maxWidth
|
|
102
|
+
};
|
|
103
|
+
return /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
|
|
104
|
+
enter: true,
|
|
105
|
+
classNames: "toast",
|
|
106
|
+
timeout: {
|
|
107
|
+
appear: 1600,
|
|
108
|
+
enter: 1500,
|
|
109
|
+
exit: 500
|
|
114
110
|
}
|
|
111
|
+
}, /*#__PURE__*/_react.default.createElement(_toast.ToastStyle, _extends({
|
|
112
|
+
className: componentClasses
|
|
113
|
+
}, (0, _tags.default)(restProps["data-component"] || "toast", restProps), toastProps), /*#__PURE__*/_react.default.createElement(_toast.TypeIcon, {
|
|
114
|
+
variant: toastProps.variant
|
|
115
|
+
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
116
|
+
type: toastProps.variant
|
|
117
|
+
})), /*#__PURE__*/_react.default.createElement(_toast.ToastContentStyle, {
|
|
118
|
+
variant: toastProps.variant,
|
|
119
|
+
isDismiss: onDismiss
|
|
120
|
+
}, children), renderCloseIcon()));
|
|
121
|
+
}
|
|
115
122
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (!onDismiss) return null;
|
|
125
|
-
return /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
126
|
-
"data-element": "close",
|
|
127
|
-
onAction: onDismiss
|
|
128
|
-
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
129
|
-
type: "close"
|
|
130
|
-
}));
|
|
131
|
-
}
|
|
132
|
-
/** Content rendered for the toast. */
|
|
133
|
-
|
|
134
|
-
}, {
|
|
135
|
-
key: "toastContent",
|
|
136
|
-
value: function toastContent() {
|
|
137
|
-
if (!this.props.open) return null;
|
|
138
|
-
const {
|
|
139
|
-
isCenter,
|
|
140
|
-
variant,
|
|
141
|
-
id,
|
|
142
|
-
as,
|
|
143
|
-
onDismiss,
|
|
144
|
-
children,
|
|
145
|
-
maxWidth
|
|
146
|
-
} = this.props;
|
|
147
|
-
const toastProps = {
|
|
148
|
-
isCenter,
|
|
149
|
-
variant: variant || as,
|
|
150
|
-
id,
|
|
151
|
-
maxWidth
|
|
152
|
-
};
|
|
153
|
-
return /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
|
|
154
|
-
enter: true,
|
|
155
|
-
classNames: "toast",
|
|
156
|
-
timeout: {
|
|
157
|
-
appear: 1600,
|
|
158
|
-
enter: 1500,
|
|
159
|
-
exit: 500
|
|
160
|
-
}
|
|
161
|
-
}, /*#__PURE__*/_react.default.createElement(_toast.ToastStyle, _extends({
|
|
162
|
-
className: this.componentClasses
|
|
163
|
-
}, (0, _tags.default)(this.props["data-component"] || "toast", this.props), toastProps), /*#__PURE__*/_react.default.createElement(_toast.TypeIcon, {
|
|
164
|
-
variant: toastProps.variant
|
|
165
|
-
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
166
|
-
type: toastProps.variant
|
|
167
|
-
})), /*#__PURE__*/_react.default.createElement(_toast.ToastContentStyle, {
|
|
168
|
-
variant: toastProps.variant,
|
|
169
|
-
isDismiss: onDismiss
|
|
170
|
-
}, children), this.closeIcon()));
|
|
171
|
-
}
|
|
172
|
-
}, {
|
|
173
|
-
key: "render",
|
|
174
|
-
value: function render() {
|
|
175
|
-
const {
|
|
176
|
-
targetPortalId,
|
|
177
|
-
isCenter
|
|
178
|
-
} = this.props;
|
|
179
|
-
return /*#__PURE__*/_react.default.createElement(_toast.StyledPortal, {
|
|
180
|
-
id: targetPortalId,
|
|
181
|
-
isCenter: isCenter
|
|
182
|
-
}, /*#__PURE__*/_react.default.createElement(_toast.ToastWrapper, {
|
|
183
|
-
isCenter: isCenter,
|
|
184
|
-
ref: this.toastRef
|
|
185
|
-
}, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.TransitionGroup, null, this.toastContent())));
|
|
186
|
-
}
|
|
187
|
-
}]);
|
|
188
|
-
|
|
189
|
-
return Toast;
|
|
190
|
-
}(_react.default.Component);
|
|
123
|
+
return /*#__PURE__*/_react.default.createElement(_toast.StyledPortal, {
|
|
124
|
+
id: targetPortalId,
|
|
125
|
+
isCenter: isCenter
|
|
126
|
+
}, /*#__PURE__*/_react.default.createElement(_toast.ToastWrapper, {
|
|
127
|
+
isCenter: isCenter,
|
|
128
|
+
ref: toastRef
|
|
129
|
+
}, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.TransitionGroup, null, renderToastContent())));
|
|
130
|
+
};
|
|
191
131
|
|
|
192
132
|
Toast.propTypes = {
|
|
193
133
|
/** Customizes the appearance in the DLS theme */
|
|
@@ -226,11 +166,5 @@ Toast.propTypes = {
|
|
|
226
166
|
/** Maximum toast width */
|
|
227
167
|
maxWidth: _propTypes.default.string
|
|
228
168
|
};
|
|
229
|
-
Toast.defaultProps = {
|
|
230
|
-
as: "warning",
|
|
231
|
-
onDismiss: null,
|
|
232
|
-
open: true,
|
|
233
|
-
isCenter: true
|
|
234
|
-
};
|
|
235
169
|
var _default = Toast;
|
|
236
170
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "98.0.1",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"engines": {
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
"babel": "cross-env NODE_ENV=production babel ./src --config-file ./babel.config.js --out-dir ./lib --ignore '**/*/__spec__.js','**/*.spec.js','**/__definition__.js' --quiet",
|
|
32
32
|
"clean-lib": "rimraf ./lib",
|
|
33
33
|
"copy-files": "cpy \"**/\" \"!**/(*.js|*.md|*.mdx|*.stories.*|*.snap)\" ../lib/ --cwd=src --parents",
|
|
34
|
-
"commit": "git-cz"
|
|
35
|
-
"chromatic": "chromatic"
|
|
34
|
+
"commit": "git-cz"
|
|
36
35
|
},
|
|
37
36
|
"repository": {
|
|
38
37
|
"type": "git",
|
|
@@ -89,6 +88,7 @@
|
|
|
89
88
|
"babel-jest": "^26.6.3",
|
|
90
89
|
"browserslist": "^4.16.6",
|
|
91
90
|
"chalk": "^4.1.1",
|
|
91
|
+
"chromatic": "^6.0.5",
|
|
92
92
|
"commitizen": "^4.2.4",
|
|
93
93
|
"conventional-changelog-conventionalcommits": "^4.5.0",
|
|
94
94
|
"core-js": "^3.1.4",
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
"cypress": "^8.3.1",
|
|
98
98
|
"cypress-axe": "^0.13.0",
|
|
99
99
|
"cypress-cucumber-preprocessor": "^4.2.0",
|
|
100
|
+
"cypress-each": "^1.5.0",
|
|
100
101
|
"cypress-plugin-tab": "^1.0.5",
|
|
101
102
|
"cypress-real-events": "^1.5.1",
|
|
102
103
|
"cypress-storybook": "^0.5.1",
|
|
@@ -119,6 +120,7 @@
|
|
|
119
120
|
"events": "~1.1.1",
|
|
120
121
|
"husky": "^4.3.6",
|
|
121
122
|
"jest": "^26.6.3",
|
|
123
|
+
"jest-canvas-mock": "^2.3.1",
|
|
122
124
|
"jest-styled-components": "^6.3.1",
|
|
123
125
|
"lint-staged": "^10.5.3",
|
|
124
126
|
"mockdate": "^2.0.2",
|
|
@@ -137,7 +139,7 @@
|
|
|
137
139
|
"dependencies": {
|
|
138
140
|
"@octokit/rest": "^18.12.0",
|
|
139
141
|
"@popperjs/core": "^2.9.0",
|
|
140
|
-
"@sage/design-tokens": "^1.
|
|
142
|
+
"@sage/design-tokens": "^1.80.0",
|
|
141
143
|
"@styled-system/prop-types": "^5.1.5",
|
|
142
144
|
"@tippyjs/react": "^4.2.5",
|
|
143
145
|
"classnames": "~2.2.6",
|