carbon-react 106.3.0 → 106.4.0
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/esm/__internal__/input/input-presentation.component.js +13 -0
- package/esm/__internal__/input/input.component.js +294 -0
- package/esm/__internal__/input-behaviour/input-behaviour.component.js +4 -0
- package/esm/__internal__/input-behaviour/input-group-behaviour.component.js +5 -0
- package/esm/__internal__/validation-message/validation-message.component.js +5 -0
- package/esm/__internal__/validations/validation-icon.component.js +41 -1
- package/esm/components/alert/alert.component.js +38 -252
- package/esm/components/alert/index.d.ts +1 -0
- package/esm/components/badge/badge.component.js +20 -60
- package/esm/components/button/button.component.js +760 -3310
- package/esm/components/carbon-provider/carbon-provider.component.js +48 -106
- package/esm/components/date/__internal__/utils.js +1 -1
- package/esm/components/date/date.component.js +3 -1
- package/esm/components/heading/heading.style.d.ts +2 -2
- package/esm/components/hr/hr.component.js +171 -1305
- package/esm/components/hr/index.d.ts +1 -0
- package/esm/components/inline-inputs/inline-inputs.component.js +35 -90
- package/esm/components/link/index.d.ts +1 -0
- package/esm/components/link/link.component.js +123 -1228
- package/esm/components/navigation-bar/index.d.ts +1 -0
- package/esm/components/navigation-bar/navigation-bar.component.js +1018 -10761
- package/esm/components/pager/pager.style.d.ts +1 -1
- package/esm/components/pod/pod.style.d.ts +1 -1
- package/esm/components/radio-button/radio-button-svg.component.js +16 -29
- package/esm/components/select/filterable-select/filterable-select.component.js +1 -4
- package/esm/components/select/multi-select/multi-select.component.js +1 -4
- package/esm/components/select/select-list/select-list.component.js +1 -4
- package/esm/components/select/simple-select/simple-select.component.js +1 -4
- package/esm/components/select/utils/get-next-index-by-key.d.ts +1 -0
- package/esm/components/select/utils/get-next-index-by-key.js +50 -18
- package/esm/components/select/utils/is-navigation-key.d.ts +1 -0
- package/esm/components/select/utils/is-navigation-key.js +4 -0
- package/esm/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +1 -1
- package/esm/components/tooltip/tooltip.component.js +85 -254
- package/esm/components/vertical-divider/index.d.ts +1 -0
- package/esm/components/vertical-divider/vertical-divider.component.d.ts +2 -2
- package/esm/components/vertical-divider/vertical-divider.component.js +328 -1406
- package/esm/components/vertical-divider/vertical-divider.style.d.ts +3 -3
- package/lib/__internal__/input/input-presentation.component.js +16 -0
- package/lib/__internal__/input/input.component.js +295 -0
- package/lib/__internal__/input-behaviour/input-behaviour.component.js +6 -1
- package/lib/__internal__/input-behaviour/input-group-behaviour.component.js +7 -1
- package/lib/__internal__/validation-message/validation-message.component.js +6 -0
- package/lib/__internal__/validations/validation-icon.component.js +39 -0
- package/lib/components/alert/alert.component.js +42 -143
- package/lib/components/alert/index.d.ts +1 -0
- package/lib/components/badge/badge.component.js +24 -50
- package/lib/components/button/button.component.js +768 -3378
- package/lib/components/carbon-provider/carbon-provider.component.js +54 -110
- package/lib/components/date/__internal__/utils.js +1 -1
- package/lib/components/date/date.component.js +3 -1
- package/lib/components/heading/heading.style.d.ts +2 -2
- package/lib/components/hr/hr.component.js +175 -676
- package/lib/components/hr/index.d.ts +1 -0
- package/lib/components/inline-inputs/inline-inputs.component.js +43 -137
- package/lib/components/link/index.d.ts +1 -0
- package/lib/components/link/link.component.js +142 -746
- package/lib/components/navigation-bar/index.d.ts +1 -0
- package/lib/components/navigation-bar/navigation-bar.component.js +1022 -5426
- package/lib/components/pager/pager.style.d.ts +1 -1
- package/lib/components/pod/pod.style.d.ts +1 -1
- package/lib/components/radio-button/radio-button-svg.component.js +20 -38
- package/lib/components/select/filterable-select/filterable-select.component.js +3 -5
- package/lib/components/select/multi-select/multi-select.component.js +3 -5
- package/lib/components/select/select-list/select-list.component.js +3 -5
- package/lib/components/select/simple-select/simple-select.component.js +3 -5
- package/lib/components/select/utils/get-next-index-by-key.d.ts +1 -0
- package/lib/components/select/utils/get-next-index-by-key.js +52 -18
- package/lib/components/select/utils/is-navigation-key.d.ts +1 -0
- package/lib/components/select/utils/is-navigation-key.js +11 -0
- package/lib/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +1 -1
- package/lib/components/tooltip/tooltip.component.js +98 -215
- package/lib/components/vertical-divider/index.d.ts +1 -0
- package/lib/components/vertical-divider/vertical-divider.component.d.ts +2 -2
- package/lib/components/vertical-divider/vertical-divider.component.js +334 -1457
- package/lib/components/vertical-divider/vertical-divider.style.d.ts +3 -3
- package/package.json +4 -3
|
@@ -3,7 +3,7 @@ export const StyledPagerSizeOptions: import("styled-components").StyledComponent
|
|
|
3
3
|
export const StyledPagerSizeOptionsInner: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
4
|
export const StyledPagerNavigation: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
5
|
export const StyledPagerNavInner: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
-
export const StyledPagerLinkStyles: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../link
|
|
6
|
+
export const StyledPagerLinkStyles: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../link").LinkProps & import("react").RefAttributes<HTMLLinkElement | HTMLButtonElement>>, any, {}, never>;
|
|
7
7
|
export const StyledPagerNoSelect: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
8
8
|
export const StyledPagerSummary: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
9
|
export const StyledSelectContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const StyledBlock: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
2
|
export const StyledContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
-
export const StyledEditAction: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../link
|
|
3
|
+
export const StyledEditAction: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../link").LinkProps & import("react").RefAttributes<HTMLLinkElement | HTMLButtonElement>>, any, {}, never>;
|
|
4
4
|
export const StyledActionsContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
5
|
export const StyledDeleteButton: import("styled-components").StyledComponent<typeof IconButton, any, {}, never>;
|
|
6
6
|
export const StyledUndoButton: import("styled-components").StyledComponent<typeof IconButton, any, {}, never>;
|
|
@@ -1,52 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
exports.default = void 0;
|
|
8
7
|
|
|
9
8
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
9
|
|
|
12
|
-
var _checkableInputSvgWrapper = _interopRequireDefault(
|
|
13
|
-
require("../../__internal__/checkable-input/checkable-input-svg-wrapper.style")
|
|
14
|
-
);
|
|
10
|
+
var _checkableInputSvgWrapper = _interopRequireDefault(require("../../__internal__/checkable-input/checkable-input-svg-wrapper.style"));
|
|
15
11
|
|
|
16
|
-
function _interopRequireDefault(obj) {
|
|
17
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
18
|
-
}
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
13
|
|
|
20
14
|
const RadioButtonSvg = () => {
|
|
21
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
fillRule: "evenodd",
|
|
37
|
-
},
|
|
38
|
-
/*#__PURE__*/ _react.default.createElement("circle", {
|
|
39
|
-
className: "radio-button-check",
|
|
40
|
-
fill: "#FFFFFF",
|
|
41
|
-
cx: "7.5",
|
|
42
|
-
cy: "7.5",
|
|
43
|
-
r: "5",
|
|
44
|
-
})
|
|
45
|
-
)
|
|
46
|
-
)
|
|
47
|
-
);
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement(_checkableInputSvgWrapper.default, null, /*#__PURE__*/_react.default.createElement("svg", {
|
|
16
|
+
focusable: "false",
|
|
17
|
+
viewBox: "0 0 15 15"
|
|
18
|
+
}, /*#__PURE__*/_react.default.createElement("g", {
|
|
19
|
+
stroke: "none",
|
|
20
|
+
strokeWidth: "1",
|
|
21
|
+
fill: "none",
|
|
22
|
+
fillRule: "evenodd"
|
|
23
|
+
}, /*#__PURE__*/_react.default.createElement("circle", {
|
|
24
|
+
className: "radio-button-check",
|
|
25
|
+
fill: "#FFFFFF",
|
|
26
|
+
cx: "7.5",
|
|
27
|
+
cy: "7.5",
|
|
28
|
+
r: "5"
|
|
29
|
+
}))));
|
|
48
30
|
};
|
|
49
31
|
|
|
50
|
-
var _default = /*#__PURE__*/
|
|
32
|
+
var _default = /*#__PURE__*/_react.default.memo(RadioButtonSvg, () => true);
|
|
51
33
|
|
|
52
|
-
exports.default = _default;
|
|
34
|
+
exports.default = _default;
|
|
@@ -25,6 +25,8 @@ var _selectList = _interopRequireDefault(require("../select-list/select-list.com
|
|
|
25
25
|
|
|
26
26
|
var _isExpectedOption = _interopRequireDefault(require("../utils/is-expected-option"));
|
|
27
27
|
|
|
28
|
+
var _isNavigationKey = _interopRequireDefault(require("../utils/is-navigation-key"));
|
|
29
|
+
|
|
28
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
31
|
|
|
30
32
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -171,7 +173,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
171
173
|
return;
|
|
172
174
|
}
|
|
173
175
|
|
|
174
|
-
if (!event.defaultPrevented &&
|
|
176
|
+
if (!event.defaultPrevented && (0, _isNavigationKey.default)(key)) {
|
|
175
177
|
event.preventDefault();
|
|
176
178
|
setOpen(true);
|
|
177
179
|
}
|
|
@@ -410,10 +412,6 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
410
412
|
};
|
|
411
413
|
}
|
|
412
414
|
|
|
413
|
-
function isNavigationKey(key) {
|
|
414
|
-
return key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End";
|
|
415
|
-
}
|
|
416
|
-
|
|
417
415
|
const selectList = /*#__PURE__*/_react.default.createElement(FilterableSelectList, {
|
|
418
416
|
ref: listboxRef,
|
|
419
417
|
id: selectListId.current,
|
|
@@ -29,6 +29,8 @@ var _isExpectedOption = _interopRequireDefault(require("../utils/is-expected-opt
|
|
|
29
29
|
|
|
30
30
|
var _isExpectedValue = _interopRequireDefault(require("../utils/is-expected-value"));
|
|
31
31
|
|
|
32
|
+
var _isNavigationKey = _interopRequireDefault(require("../utils/is-navigation-key"));
|
|
33
|
+
|
|
32
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
35
|
|
|
34
36
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -155,7 +157,7 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
155
157
|
return;
|
|
156
158
|
}
|
|
157
159
|
|
|
158
|
-
if (!event.defaultPrevented &&
|
|
160
|
+
if (!event.defaultPrevented && (0, _isNavigationKey.default)(key)) {
|
|
159
161
|
event.preventDefault();
|
|
160
162
|
setOpen();
|
|
161
163
|
}
|
|
@@ -428,10 +430,6 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
428
430
|
};
|
|
429
431
|
}
|
|
430
432
|
|
|
431
|
-
function isNavigationKey(key) {
|
|
432
|
-
return key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End";
|
|
433
|
-
}
|
|
434
|
-
|
|
435
433
|
const selectList = /*#__PURE__*/_react.default.createElement(FilterableSelectList, {
|
|
436
434
|
ref: listboxRef,
|
|
437
435
|
"aria-multiselectable": true,
|
|
@@ -23,6 +23,8 @@ var _getNextChildByText = _interopRequireDefault(require("../utils/get-next-chil
|
|
|
23
23
|
|
|
24
24
|
var _getNextIndexByKey = _interopRequireDefault(require("../utils/get-next-index-by-key"));
|
|
25
25
|
|
|
26
|
+
var _isNavigationKey = _interopRequireDefault(require("../utils/is-navigation-key"));
|
|
27
|
+
|
|
26
28
|
var _listActionButton = _interopRequireDefault(require("../list-action-button/list-action-button.component"));
|
|
27
29
|
|
|
28
30
|
var _selectListContainer = _interopRequireDefault(require("./select-list-container.style"));
|
|
@@ -221,7 +223,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
221
223
|
value,
|
|
222
224
|
selectionType: "enterKey"
|
|
223
225
|
});
|
|
224
|
-
} else if (
|
|
226
|
+
} else if ((0, _isNavigationKey.default)(key)) {
|
|
225
227
|
focusOnAnchor();
|
|
226
228
|
highlightNextItem(key);
|
|
227
229
|
}
|
|
@@ -305,10 +307,6 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
305
307
|
enabled: flipEnabled
|
|
306
308
|
}], [flipEnabled]);
|
|
307
309
|
|
|
308
|
-
function isNavigationKey(keyEvent) {
|
|
309
|
-
return keyEvent === "ArrowDown" || keyEvent === "ArrowUp" || keyEvent === "Home" || keyEvent === "End";
|
|
310
|
-
}
|
|
311
|
-
|
|
312
310
|
const loader = () => /*#__PURE__*/_react.default.createElement(_selectList.StyledSelectLoaderContainer, {
|
|
313
311
|
key: "loader",
|
|
314
312
|
as: multiColumn ? "div" : "li"
|
|
@@ -27,6 +27,8 @@ var _getNextChildByText = _interopRequireDefault(require("../utils/get-next-chil
|
|
|
27
27
|
|
|
28
28
|
var _isExpectedOption = _interopRequireDefault(require("../utils/is-expected-option"));
|
|
29
29
|
|
|
30
|
+
var _isNavigationKey = _interopRequireDefault(require("../utils/is-navigation-key"));
|
|
31
|
+
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
33
|
|
|
32
34
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -145,7 +147,7 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
145
147
|
return;
|
|
146
148
|
}
|
|
147
149
|
|
|
148
|
-
if (key === "Enter" || key === " " ||
|
|
150
|
+
if (key === "Enter" || key === " " || (0, _isNavigationKey.default)(key)) {
|
|
149
151
|
event.preventDefault();
|
|
150
152
|
setOpenState(isAlreadyOpen => {
|
|
151
153
|
if (!isAlreadyOpen && onOpen) {
|
|
@@ -309,10 +311,6 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
309
311
|
setOpenState(false);
|
|
310
312
|
}
|
|
311
313
|
|
|
312
|
-
function isNavigationKey(key) {
|
|
313
|
-
return key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End";
|
|
314
|
-
}
|
|
315
|
-
|
|
316
314
|
function assignInput(input) {
|
|
317
315
|
setTextboxRef(input.current);
|
|
318
316
|
|
|
@@ -4,31 +4,65 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getNextIndexByKey;
|
|
7
|
+
exports.PAGE_SIZE = void 0;
|
|
8
|
+
const PAGE_SIZE = 4;
|
|
9
|
+
exports.PAGE_SIZE = PAGE_SIZE;
|
|
7
10
|
|
|
8
11
|
function getNextIndexByKey(key, currentIndex, lastIndex, isLoading) {
|
|
9
12
|
const isNoOptionSelected = currentIndex === -1;
|
|
10
13
|
let newIndex = currentIndex;
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} else if (key === "End") {
|
|
15
|
-
newIndex = lastIndex;
|
|
16
|
-
} else if (key === "ArrowDown") {
|
|
17
|
-
if (isLoading && currentIndex === lastIndex) {
|
|
18
|
-
return lastIndex;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (currentIndex === lastIndex || isNoOptionSelected) {
|
|
15
|
+
switch (key) {
|
|
16
|
+
case "Home":
|
|
22
17
|
newIndex = 0;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} else if (key === "ArrowUp") {
|
|
27
|
-
if (currentIndex === 0 || isNoOptionSelected) {
|
|
18
|
+
break;
|
|
19
|
+
|
|
20
|
+
case "End":
|
|
28
21
|
newIndex = lastIndex;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
break;
|
|
23
|
+
|
|
24
|
+
case "ArrowDown":
|
|
25
|
+
if (isLoading && currentIndex === lastIndex) {
|
|
26
|
+
return lastIndex;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (currentIndex === lastIndex || isNoOptionSelected) {
|
|
30
|
+
newIndex = 0;
|
|
31
|
+
} else {
|
|
32
|
+
newIndex = currentIndex + 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
break;
|
|
36
|
+
|
|
37
|
+
case "ArrowUp":
|
|
38
|
+
if (currentIndex === 0 || isNoOptionSelected) {
|
|
39
|
+
newIndex = lastIndex;
|
|
40
|
+
} else {
|
|
41
|
+
newIndex = currentIndex - 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
break;
|
|
45
|
+
|
|
46
|
+
case "PageDown":
|
|
47
|
+
if (isNoOptionSelected) {
|
|
48
|
+
newIndex = Math.min(PAGE_SIZE - 1, lastIndex);
|
|
49
|
+
} else {
|
|
50
|
+
newIndex = Math.min(currentIndex + PAGE_SIZE, lastIndex);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
break;
|
|
54
|
+
|
|
55
|
+
case "PageUp":
|
|
56
|
+
if (isNoOptionSelected) {
|
|
57
|
+
newIndex = Math.max(lastIndex + 1 - PAGE_SIZE, 0);
|
|
58
|
+
} else {
|
|
59
|
+
newIndex = Math.max(currentIndex - PAGE_SIZE, 0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
default:
|
|
65
|
+
break;
|
|
32
66
|
}
|
|
33
67
|
|
|
34
68
|
return newIndex;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isNavigationKey(key: any): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = isNavigationKey;
|
|
7
|
+
|
|
8
|
+
function isNavigationKey(key) {
|
|
9
|
+
const navigationKeys = ["ArrowDown", "ArrowUp", "Home", "End", "PageUp", "PageDown"];
|
|
10
|
+
return navigationKeys.includes(key);
|
|
11
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export default StyledEditorLink;
|
|
2
|
-
declare const StyledEditorLink: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../../link
|
|
2
|
+
declare const StyledEditorLink: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../../link").LinkProps & import("react").RefAttributes<HTMLLinkElement | HTMLButtonElement>>, any, {}, never>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
exports.default = exports.Tooltip = void 0;
|
|
8
7
|
|
|
9
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
12
|
var _headless = _interopRequireDefault(require("@tippyjs/react/headless"));
|
|
@@ -17,233 +17,116 @@ var _invariant = _interopRequireDefault(require("invariant"));
|
|
|
17
17
|
|
|
18
18
|
var _tooltip = _interopRequireDefault(require("./tooltip.style"));
|
|
19
19
|
|
|
20
|
-
var _tooltipPointer = _interopRequireDefault(
|
|
21
|
-
require("./tooltip-pointer.style")
|
|
22
|
-
);
|
|
20
|
+
var _tooltipPointer = _interopRequireDefault(require("./tooltip-pointer.style"));
|
|
23
21
|
|
|
24
22
|
var _tooltip2 = require("./tooltip.config");
|
|
25
23
|
|
|
26
|
-
var _tags = _interopRequireDefault(
|
|
27
|
-
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
function _interopRequireDefault(obj) {
|
|
35
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function _extends() {
|
|
39
|
-
_extends =
|
|
40
|
-
Object.assign ||
|
|
41
|
-
function (target) {
|
|
42
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
43
|
-
var source = arguments[i];
|
|
44
|
-
for (var key in source) {
|
|
45
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
46
|
-
target[key] = source[key];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return target;
|
|
51
|
-
};
|
|
52
|
-
return _extends.apply(this, arguments);
|
|
53
|
-
}
|
|
24
|
+
var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
|
|
25
|
+
|
|
26
|
+
var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
|
|
27
|
+
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
|
|
30
|
+
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); }
|
|
54
31
|
|
|
55
32
|
const TOOLTIP_DELAY = 100;
|
|
56
33
|
const tippyPlugins = [_tippy.sticky];
|
|
57
34
|
|
|
58
|
-
const Tooltip = /*#__PURE__*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
) => {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
_extends(
|
|
121
|
-
{
|
|
122
|
-
key: "pointer",
|
|
123
|
-
type: type,
|
|
124
|
-
},
|
|
125
|
-
attrs,
|
|
126
|
-
{
|
|
127
|
-
position: currentPosition,
|
|
128
|
-
"data-popper-arrow": "",
|
|
129
|
-
"data-element": "tooltip-pointer",
|
|
130
|
-
bgColor: bgColor,
|
|
131
|
-
}
|
|
132
|
-
)
|
|
133
|
-
),
|
|
134
|
-
content
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
140
|
-
_headless.default,
|
|
141
|
-
_extends(
|
|
142
|
-
{
|
|
143
|
-
placement: position,
|
|
144
|
-
delay: TOOLTIP_DELAY,
|
|
145
|
-
},
|
|
146
|
-
isVisible !== undefined && {
|
|
147
|
-
visible: isVisible,
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
plugins: tippyPlugins,
|
|
151
|
-
sticky: true,
|
|
152
|
-
render: (attrs) => tooltip(attrs, message),
|
|
153
|
-
reference: target,
|
|
154
|
-
popperOptions: {
|
|
155
|
-
modifiers: [
|
|
156
|
-
...(flipOverrides
|
|
157
|
-
? [
|
|
158
|
-
{
|
|
159
|
-
name: "flip",
|
|
160
|
-
options: {
|
|
161
|
-
fallbackPlacements: flipOverrides,
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
]
|
|
165
|
-
: []),
|
|
166
|
-
{
|
|
167
|
-
name: "computeStyles",
|
|
168
|
-
options: {
|
|
169
|
-
gpuAcceleration: false,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
},
|
|
35
|
+
const Tooltip = /*#__PURE__*/_react.default.forwardRef(({
|
|
36
|
+
children,
|
|
37
|
+
isVisible,
|
|
38
|
+
position = "top",
|
|
39
|
+
message,
|
|
40
|
+
type,
|
|
41
|
+
size = "medium",
|
|
42
|
+
isPartOfInput,
|
|
43
|
+
inputSize,
|
|
44
|
+
id,
|
|
45
|
+
bgColor,
|
|
46
|
+
fontColor,
|
|
47
|
+
flipOverrides,
|
|
48
|
+
target,
|
|
49
|
+
...rest
|
|
50
|
+
}, ref) => {
|
|
51
|
+
const isFlipOverridesValid = !flipOverrides || Array.isArray(flipOverrides) && flipOverrides.every(placement => _tooltip2.TOOLTIP_POSITIONS.includes(placement));
|
|
52
|
+
(0, _invariant.default)(isFlipOverridesValid, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`);
|
|
53
|
+
|
|
54
|
+
const tooltip = (attrs, content) => {
|
|
55
|
+
const currentPosition = attrs["data-placement"] || position;
|
|
56
|
+
return /*#__PURE__*/_react.default.createElement(_carbonScopedTokensProvider.default, null, /*#__PURE__*/_react.default.createElement(_tooltip.default, _extends({
|
|
57
|
+
"data-element": "tooltip",
|
|
58
|
+
role: "tooltip",
|
|
59
|
+
tabIndex: -1,
|
|
60
|
+
type: type,
|
|
61
|
+
size: size,
|
|
62
|
+
id: id
|
|
63
|
+
}, (0, _tags.default)("tooltip", rest), {
|
|
64
|
+
isPartOfInput: isPartOfInput,
|
|
65
|
+
inputSize: inputSize
|
|
66
|
+
}, attrs, {
|
|
67
|
+
position: currentPosition,
|
|
68
|
+
ref: ref,
|
|
69
|
+
bgColor: bgColor,
|
|
70
|
+
fontColor: fontColor
|
|
71
|
+
}), /*#__PURE__*/_react.default.createElement(_tooltipPointer.default, _extends({
|
|
72
|
+
key: "pointer",
|
|
73
|
+
type: type
|
|
74
|
+
}, attrs, {
|
|
75
|
+
position: currentPosition,
|
|
76
|
+
"data-popper-arrow": "",
|
|
77
|
+
"data-element": "tooltip-pointer",
|
|
78
|
+
bgColor: bgColor
|
|
79
|
+
})), content));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return /*#__PURE__*/_react.default.createElement(_headless.default, _extends({
|
|
83
|
+
placement: position,
|
|
84
|
+
delay: TOOLTIP_DELAY
|
|
85
|
+
}, isVisible !== undefined && {
|
|
86
|
+
visible: isVisible
|
|
87
|
+
}, {
|
|
88
|
+
plugins: tippyPlugins,
|
|
89
|
+
sticky: true,
|
|
90
|
+
render: attrs => tooltip(attrs, message),
|
|
91
|
+
reference: target,
|
|
92
|
+
popperOptions: {
|
|
93
|
+
modifiers: [...(flipOverrides ? [{
|
|
94
|
+
name: "flip",
|
|
95
|
+
options: {
|
|
96
|
+
fallbackPlacements: flipOverrides
|
|
174
97
|
}
|
|
175
|
-
),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
98
|
+
}] : []), {
|
|
99
|
+
name: "computeStyles",
|
|
100
|
+
options: {
|
|
101
|
+
gpuAcceleration: false
|
|
102
|
+
}
|
|
103
|
+
}]
|
|
104
|
+
}
|
|
105
|
+
}), children);
|
|
106
|
+
});
|
|
180
107
|
|
|
108
|
+
exports.Tooltip = Tooltip;
|
|
181
109
|
Tooltip.propTypes = {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
*/
|
|
195
|
-
flipOverrides: _propTypes.default.arrayOf(
|
|
196
|
-
_propTypes.default.oneOf(["bottom", "left", "right", "top"])
|
|
197
|
-
),
|
|
198
|
-
/**
|
|
199
|
-
* Override font color of the Tooltip, provide any color from palette or any valid css color value.
|
|
200
|
-
*/
|
|
201
|
-
fontColor: _propTypes.default.string,
|
|
202
|
-
/**
|
|
203
|
-
* The id attribute to use for the tooltip
|
|
204
|
-
*/
|
|
205
|
-
id: _propTypes.default.string,
|
|
206
|
-
inputSize: _propTypes.default.oneOf(["large", "medium", "small"]),
|
|
207
|
-
isPartOfInput: _propTypes.default.bool,
|
|
208
|
-
/**
|
|
209
|
-
* Whether to to show the Tooltip
|
|
210
|
-
*/
|
|
211
|
-
isVisible: _propTypes.default.bool,
|
|
212
|
-
key: _propTypes.default.oneOfType([
|
|
213
|
-
_propTypes.default.number,
|
|
214
|
-
_propTypes.default.string,
|
|
215
|
-
]),
|
|
216
|
-
/**
|
|
217
|
-
* The message to be displayed within the tooltip
|
|
218
|
-
*/
|
|
219
|
-
message: _propTypes.default.node,
|
|
220
|
-
/**
|
|
221
|
-
* Sets position of the tooltip
|
|
222
|
-
*/
|
|
223
|
-
position: _propTypes.default.oneOf(["bottom", "left", "right", "top"]),
|
|
224
|
-
/**
|
|
225
|
-
* Defines the size of the tooltip content
|
|
226
|
-
*/
|
|
227
|
-
size: _propTypes.default.oneOf(["large", "medium"]),
|
|
228
|
-
target: function (props, propName) {
|
|
110
|
+
"bgColor": _propTypes.default.string,
|
|
111
|
+
"children": _propTypes.default.element.isRequired,
|
|
112
|
+
"flipOverrides": _propTypes.default.arrayOf(_propTypes.default.oneOf(["bottom", "left", "right", "top"])),
|
|
113
|
+
"fontColor": _propTypes.default.string,
|
|
114
|
+
"id": _propTypes.default.string,
|
|
115
|
+
"inputSize": _propTypes.default.oneOf(["large", "medium", "small"]),
|
|
116
|
+
"isPartOfInput": _propTypes.default.bool,
|
|
117
|
+
"isVisible": _propTypes.default.bool,
|
|
118
|
+
"message": _propTypes.default.node,
|
|
119
|
+
"position": _propTypes.default.oneOf(["bottom", "left", "right", "top"]),
|
|
120
|
+
"size": _propTypes.default.oneOf(["large", "medium"]),
|
|
121
|
+
"target": function (props, propName) {
|
|
229
122
|
if (props[propName] == null) {
|
|
230
123
|
return null;
|
|
231
|
-
} else if (
|
|
232
|
-
|
|
233
|
-
props[propName].nodeType !== 1
|
|
234
|
-
) {
|
|
235
|
-
return new Error(
|
|
236
|
-
"Expected prop '" + propName + "' to be of type Element"
|
|
237
|
-
);
|
|
124
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
125
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
238
126
|
}
|
|
239
127
|
},
|
|
240
|
-
|
|
241
|
-
* Defines the message type
|
|
242
|
-
*/
|
|
243
|
-
type: _propTypes.default.string,
|
|
128
|
+
"type": _propTypes.default.string
|
|
244
129
|
};
|
|
245
|
-
|
|
246
|
-
exports.Tooltip = Tooltip;
|
|
247
130
|
Tooltip.displayName = "Tooltip";
|
|
248
131
|
var _default = Tooltip;
|
|
249
|
-
exports.default = _default;
|
|
132
|
+
exports.default = _default;
|