carbon-react 106.2.2 → 106.3.2
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/progress-tracker/progress-tracker.component.d.ts +4 -1
- package/esm/components/progress-tracker/progress-tracker.component.js +25 -2
- package/esm/components/progress-tracker/progress-tracker.config.d.ts +0 -1
- package/esm/components/progress-tracker/progress-tracker.config.js +1 -1
- package/esm/components/progress-tracker/progress-tracker.d.ts +5 -3
- package/esm/components/progress-tracker/progress-tracker.style.js +9 -7
- package/esm/components/radio-button/radio-button-svg.component.js +16 -29
- 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/progress-tracker/progress-tracker.component.d.ts +4 -1
- package/lib/components/progress-tracker/progress-tracker.component.js +30 -2
- package/lib/components/progress-tracker/progress-tracker.config.d.ts +0 -1
- package/lib/components/progress-tracker/progress-tracker.config.js +3 -3
- package/lib/components/progress-tracker/progress-tracker.d.ts +5 -3
- package/lib/components/progress-tracker/progress-tracker.style.js +8 -6
- package/lib/components/radio-button/radio-button-svg.component.js +20 -38
- 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,5 +1,5 @@
|
|
|
1
1
|
export default ProgressTracker;
|
|
2
|
-
declare function ProgressTracker({ "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, "aria-valuenow": ariaValueNow, "aria-valuemin": ariaValueMin, "aria-valuemax": ariaValueMax, "aria-valuetext": ariaValueText, size, progress, showDefaultLabels, currentProgressLabel, maxProgressLabel, orientation, direction, labelsPosition, ...rest }: {
|
|
2
|
+
declare function ProgressTracker({ "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, "aria-valuenow": ariaValueNow, "aria-valuemin": ariaValueMin, "aria-valuemax": ariaValueMax, "aria-valuetext": ariaValueText, size, length, progress, showDefaultLabels, currentProgressLabel, maxProgressLabel, orientation, direction, labelsPosition, ...rest }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
"aria-label"?: string | undefined;
|
|
5
5
|
"aria-describedby": any;
|
|
@@ -8,6 +8,7 @@ declare function ProgressTracker({ "aria-label": ariaLabel, "aria-describedby":
|
|
|
8
8
|
"aria-valuemax": any;
|
|
9
9
|
"aria-valuetext": any;
|
|
10
10
|
size?: string | undefined;
|
|
11
|
+
length?: string | undefined;
|
|
11
12
|
progress?: number | undefined;
|
|
12
13
|
showDefaultLabels?: boolean | undefined;
|
|
13
14
|
currentProgressLabel: any;
|
|
@@ -34,6 +35,8 @@ declare namespace ProgressTracker {
|
|
|
34
35
|
"aria-valuetext": PropTypes.Requireable<string>;
|
|
35
36
|
/** Size of the progress bar. */
|
|
36
37
|
size: PropTypes.Requireable<string>;
|
|
38
|
+
/** Length of the progress bar, any valid css string. */
|
|
39
|
+
length: PropTypes.Requireable<string>;
|
|
37
40
|
/** Current progress (percentage). */
|
|
38
41
|
progress: PropTypes.Requireable<number>;
|
|
39
42
|
/** Flag to control whether the default value labels (as percentages) should be rendered. */
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
6
|
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
7
7
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
8
8
|
import { StyledProgressBar, InnerBar, StyledValuesLabel, StyledProgressTracker, StyledValue } from "./progress-tracker.style";
|
|
9
|
+
import useResizeObserver from "../../hooks/__internal__/useResizeObserver";
|
|
9
10
|
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
10
11
|
|
|
11
12
|
const ProgressTracker = ({
|
|
@@ -16,6 +17,7 @@ const ProgressTracker = ({
|
|
|
16
17
|
"aria-valuemax": ariaValueMax,
|
|
17
18
|
"aria-valuetext": ariaValueText,
|
|
18
19
|
size = "medium",
|
|
20
|
+
length = "256px",
|
|
19
21
|
progress = 0,
|
|
20
22
|
showDefaultLabels = false,
|
|
21
23
|
currentProgressLabel,
|
|
@@ -25,8 +27,23 @@ const ProgressTracker = ({
|
|
|
25
27
|
labelsPosition,
|
|
26
28
|
...rest
|
|
27
29
|
}) => {
|
|
30
|
+
const barRef = useRef();
|
|
31
|
+
const [barLength, setBarLength] = useState(0);
|
|
28
32
|
const isVertical = orientation === "vertical";
|
|
29
33
|
const prefixLabels = !isVertical && labelsPosition !== "bottom" || isVertical && labelsPosition === "left";
|
|
34
|
+
const updateBarLength = useCallback(() => {
|
|
35
|
+
if (orientation === "horizontal") {
|
|
36
|
+
setBarLength(`${barRef.current.offsetWidth}px`);
|
|
37
|
+
} else {
|
|
38
|
+
setBarLength(`${barRef.current.offsetHeight}px`);
|
|
39
|
+
}
|
|
40
|
+
}, [barRef, orientation]);
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
updateBarLength();
|
|
43
|
+
}, [barRef, orientation, updateBarLength]);
|
|
44
|
+
useResizeObserver(barRef, () => {
|
|
45
|
+
updateBarLength();
|
|
46
|
+
});
|
|
30
47
|
|
|
31
48
|
const renderValueLabels = () => {
|
|
32
49
|
if (!showDefaultLabels && !currentProgressLabel && !maxProgressLabel) {
|
|
@@ -53,6 +70,7 @@ const ProgressTracker = ({
|
|
|
53
70
|
|
|
54
71
|
return /*#__PURE__*/React.createElement(StyledProgressTracker, _extends({
|
|
55
72
|
size: size,
|
|
73
|
+
length: length,
|
|
56
74
|
isVertical: isVertical
|
|
57
75
|
}, rest, tagComponent("progress-bar", rest), {
|
|
58
76
|
role: "progressbar",
|
|
@@ -65,10 +83,12 @@ const ProgressTracker = ({
|
|
|
65
83
|
}), prefixLabels && renderValueLabels(), /*#__PURE__*/React.createElement(StyledProgressBar, {
|
|
66
84
|
direction: isVertical ? direction : undefined,
|
|
67
85
|
isVertical: isVertical,
|
|
68
|
-
size: size
|
|
86
|
+
size: size,
|
|
87
|
+
ref: barRef
|
|
69
88
|
}, /*#__PURE__*/React.createElement(InnerBar, {
|
|
70
89
|
isVertical: isVertical,
|
|
71
90
|
size: size,
|
|
91
|
+
length: barLength,
|
|
72
92
|
progress: progress
|
|
73
93
|
})), !prefixLabels && renderValueLabels());
|
|
74
94
|
};
|
|
@@ -98,6 +118,9 @@ ProgressTracker.propTypes = { ...marginPropTypes,
|
|
|
98
118
|
/** Size of the progress bar. */
|
|
99
119
|
size: PropTypes.oneOf(["small", "medium", "large"]),
|
|
100
120
|
|
|
121
|
+
/** Length of the progress bar, any valid css string. */
|
|
122
|
+
length: PropTypes.string,
|
|
123
|
+
|
|
101
124
|
/** Current progress (percentage). */
|
|
102
125
|
progress: PropTypes.number,
|
|
103
126
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
2
|
export const PROGRESS_TRACKER_SIZES = ["small", "medium", "large"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarginProps } from "styled-system";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface ProgressTrackerProps extends MarginProps {
|
|
4
4
|
/** Specifies an aria-label to the component */
|
|
5
5
|
"aria-label"?: string;
|
|
6
6
|
/** Specifies the aria-describedby for the component */
|
|
@@ -16,6 +16,8 @@ export interface ProgressBarProps extends MarginProps {
|
|
|
16
16
|
"aria-valuetext"?: string;
|
|
17
17
|
/** Size of the progressBar. */
|
|
18
18
|
size?: "small" | "medium" | "large";
|
|
19
|
+
/** Length of the progress bar, any valid css string. */
|
|
20
|
+
length?: string;
|
|
19
21
|
/** Current progress (percentage). */
|
|
20
22
|
progress?: number;
|
|
21
23
|
/** Flag to control whether the default value labels (as percentages) should be rendered. */
|
|
@@ -35,6 +37,6 @@ export interface ProgressBarProps extends MarginProps {
|
|
|
35
37
|
labelsPosition?: "top" | "bottom" | "left" | "right";
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
declare function
|
|
40
|
+
declare function ProgressTracker(props: ProgressTrackerProps): JSX.Element;
|
|
39
41
|
|
|
40
|
-
export default
|
|
42
|
+
export default ProgressTracker;
|
|
@@ -2,20 +2,21 @@ import styled, { css } from "styled-components";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { margin } from "styled-system";
|
|
4
4
|
import baseTheme from "../../style/themes/base";
|
|
5
|
-
import {
|
|
5
|
+
import { PROGRESS_TRACKER_SIZES } from "./progress-tracker.config";
|
|
6
6
|
const StyledProgressTracker = styled.div`
|
|
7
7
|
${margin}
|
|
8
8
|
text-align: center;
|
|
9
9
|
white-space: nowrap;
|
|
10
10
|
|
|
11
11
|
${({
|
|
12
|
-
isVertical
|
|
12
|
+
isVertical,
|
|
13
|
+
length
|
|
13
14
|
}) => css`
|
|
14
15
|
${!isVertical && `
|
|
15
|
-
width: ${
|
|
16
|
+
width: ${length};
|
|
16
17
|
`}
|
|
17
18
|
${isVertical && `
|
|
18
|
-
height: ${
|
|
19
|
+
height: ${length};
|
|
19
20
|
display: flex;
|
|
20
21
|
`}
|
|
21
22
|
`}
|
|
@@ -94,19 +95,20 @@ const InnerBar = styled.span`
|
|
|
94
95
|
${({
|
|
95
96
|
isVertical,
|
|
96
97
|
progress,
|
|
97
|
-
size
|
|
98
|
+
size,
|
|
99
|
+
length
|
|
98
100
|
}) => css`
|
|
99
101
|
position: absolute;
|
|
100
102
|
left: 0;
|
|
101
103
|
background-color: ${getInnerBarColour(progress)};
|
|
102
104
|
|
|
103
105
|
${!isVertical && css`
|
|
104
|
-
width: calc(${
|
|
106
|
+
width: calc(${length} * ${progress / 100});
|
|
105
107
|
min-width: 2px;
|
|
106
108
|
height: ${getHeight(size)};
|
|
107
109
|
`}
|
|
108
110
|
${isVertical && css`
|
|
109
|
-
height: calc(${
|
|
111
|
+
height: calc(${length} * ${progress / 100});
|
|
110
112
|
min-height: 2px;
|
|
111
113
|
width: ${getHeight(size)};
|
|
112
114
|
`}
|
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import StyledCheckableInputSvgWrapper from "../../__internal__/checkable-input/checkable-input-svg-wrapper.style";
|
|
4
3
|
|
|
5
4
|
const RadioButtonSvg = () => {
|
|
6
|
-
return /*#__PURE__*/ React.createElement(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
fillRule: "evenodd",
|
|
22
|
-
},
|
|
23
|
-
/*#__PURE__*/ React.createElement("circle", {
|
|
24
|
-
className: "radio-button-check",
|
|
25
|
-
fill: "#FFFFFF",
|
|
26
|
-
cx: "7.5",
|
|
27
|
-
cy: "7.5",
|
|
28
|
-
r: "5",
|
|
29
|
-
})
|
|
30
|
-
)
|
|
31
|
-
)
|
|
32
|
-
);
|
|
5
|
+
return /*#__PURE__*/React.createElement(StyledCheckableInputSvgWrapper, null, /*#__PURE__*/React.createElement("svg", {
|
|
6
|
+
focusable: "false",
|
|
7
|
+
viewBox: "0 0 15 15"
|
|
8
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
9
|
+
stroke: "none",
|
|
10
|
+
strokeWidth: "1",
|
|
11
|
+
fill: "none",
|
|
12
|
+
fillRule: "evenodd"
|
|
13
|
+
}, /*#__PURE__*/React.createElement("circle", {
|
|
14
|
+
className: "radio-button-check",
|
|
15
|
+
fill: "#FFFFFF",
|
|
16
|
+
cx: "7.5",
|
|
17
|
+
cy: "7.5",
|
|
18
|
+
r: "5"
|
|
19
|
+
}))));
|
|
33
20
|
};
|
|
34
21
|
|
|
35
|
-
export default /*#__PURE__*/
|
|
22
|
+
export default /*#__PURE__*/React.memo(RadioButtonSvg, () => true);
|
|
@@ -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,19 +1,4 @@
|
|
|
1
|
-
function _extends() {
|
|
2
|
-
_extends =
|
|
3
|
-
Object.assign ||
|
|
4
|
-
function (target) {
|
|
5
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
6
|
-
var source = arguments[i];
|
|
7
|
-
for (var key in source) {
|
|
8
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
9
|
-
target[key] = source[key];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return target;
|
|
14
|
-
};
|
|
15
|
-
return _extends.apply(this, arguments);
|
|
16
|
-
}
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
2
|
|
|
18
3
|
import React from "react";
|
|
19
4
|
import PropTypes from "prop-types";
|
|
@@ -27,253 +12,99 @@ import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
|
27
12
|
import CarbonScopedTokensProvider from "../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component";
|
|
28
13
|
const TOOLTIP_DELAY = 100;
|
|
29
14
|
const tippyPlugins = [sticky];
|
|
30
|
-
const Tooltip = /*#__PURE__*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
ref
|
|
49
|
-
) => {
|
|
50
|
-
const isFlipOverridesValid =
|
|
51
|
-
!flipOverrides ||
|
|
52
|
-
(Array.isArray(flipOverrides) &&
|
|
53
|
-
flipOverrides.every((placement) =>
|
|
54
|
-
TOOLTIP_POSITIONS.includes(placement)
|
|
55
|
-
));
|
|
56
|
-
invariant(
|
|
57
|
-
isFlipOverridesValid,
|
|
58
|
-
`The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`
|
|
59
|
-
);
|
|
15
|
+
const Tooltip = /*#__PURE__*/React.forwardRef(({
|
|
16
|
+
children,
|
|
17
|
+
isVisible,
|
|
18
|
+
position = "top",
|
|
19
|
+
message,
|
|
20
|
+
type,
|
|
21
|
+
size = "medium",
|
|
22
|
+
isPartOfInput,
|
|
23
|
+
inputSize,
|
|
24
|
+
id,
|
|
25
|
+
bgColor,
|
|
26
|
+
fontColor,
|
|
27
|
+
flipOverrides,
|
|
28
|
+
target,
|
|
29
|
+
...rest
|
|
30
|
+
}, ref) => {
|
|
31
|
+
const isFlipOverridesValid = !flipOverrides || Array.isArray(flipOverrides) && flipOverrides.every(placement => TOOLTIP_POSITIONS.includes(placement));
|
|
32
|
+
invariant(isFlipOverridesValid, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`);
|
|
60
33
|
|
|
61
|
-
|
|
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
|
-
}
|
|
89
|
-
),
|
|
90
|
-
/*#__PURE__*/ React.createElement(
|
|
91
|
-
StyledPointer,
|
|
92
|
-
_extends(
|
|
93
|
-
{
|
|
94
|
-
key: "pointer",
|
|
95
|
-
type: type,
|
|
96
|
-
},
|
|
97
|
-
attrs,
|
|
98
|
-
{
|
|
99
|
-
position: currentPosition,
|
|
100
|
-
"data-popper-arrow": "",
|
|
101
|
-
"data-element": "tooltip-pointer",
|
|
102
|
-
bgColor: bgColor,
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
),
|
|
106
|
-
content
|
|
107
|
-
)
|
|
108
|
-
);
|
|
109
|
-
};
|
|
34
|
+
const tooltip = (attrs, content) => {
|
|
35
|
+
const currentPosition = attrs["data-placement"] || position;
|
|
36
|
+
return /*#__PURE__*/React.createElement(CarbonScopedTokensProvider, null, /*#__PURE__*/React.createElement(StyledTooltip, _extends({
|
|
37
|
+
"data-element": "tooltip",
|
|
38
|
+
role: "tooltip",
|
|
39
|
+
tabIndex: -1,
|
|
40
|
+
type: type,
|
|
41
|
+
size: size,
|
|
42
|
+
id: id
|
|
43
|
+
}, tagComponent("tooltip", rest), {
|
|
44
|
+
isPartOfInput: isPartOfInput,
|
|
45
|
+
inputSize: inputSize
|
|
46
|
+
}, attrs, {
|
|
47
|
+
position: currentPosition,
|
|
48
|
+
ref: ref,
|
|
49
|
+
bgColor: bgColor,
|
|
50
|
+
fontColor: fontColor
|
|
51
|
+
}), /*#__PURE__*/React.createElement(StyledPointer, _extends({
|
|
52
|
+
key: "pointer",
|
|
53
|
+
type: type
|
|
54
|
+
}, attrs, {
|
|
55
|
+
position: currentPosition,
|
|
56
|
+
"data-popper-arrow": "",
|
|
57
|
+
"data-element": "tooltip-pointer",
|
|
58
|
+
bgColor: bgColor
|
|
59
|
+
})), content));
|
|
60
|
+
};
|
|
110
61
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
popperOptions: {
|
|
127
|
-
modifiers: [
|
|
128
|
-
...(flipOverrides
|
|
129
|
-
? [
|
|
130
|
-
{
|
|
131
|
-
name: "flip",
|
|
132
|
-
options: {
|
|
133
|
-
fallbackPlacements: flipOverrides,
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
]
|
|
137
|
-
: []),
|
|
138
|
-
{
|
|
139
|
-
name: "computeStyles",
|
|
140
|
-
options: {
|
|
141
|
-
gpuAcceleration: false,
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
],
|
|
145
|
-
},
|
|
62
|
+
return /*#__PURE__*/React.createElement(Tippy, _extends({
|
|
63
|
+
placement: position,
|
|
64
|
+
delay: TOOLTIP_DELAY
|
|
65
|
+
}, isVisible !== undefined && {
|
|
66
|
+
visible: isVisible
|
|
67
|
+
}, {
|
|
68
|
+
plugins: tippyPlugins,
|
|
69
|
+
sticky: true,
|
|
70
|
+
render: attrs => tooltip(attrs, message),
|
|
71
|
+
reference: target,
|
|
72
|
+
popperOptions: {
|
|
73
|
+
modifiers: [...(flipOverrides ? [{
|
|
74
|
+
name: "flip",
|
|
75
|
+
options: {
|
|
76
|
+
fallbackPlacements: flipOverrides
|
|
146
77
|
}
|
|
147
|
-
),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
Tooltip.propTypes = {
|
|
154
|
-
/**
|
|
155
|
-
* Override background color of the Tooltip, provide any color from palette or any valid css color value.
|
|
156
|
-
*/
|
|
157
|
-
bgColor: PropTypes.string,
|
|
158
|
-
/**
|
|
159
|
-
* Children elements
|
|
160
|
-
*/
|
|
161
|
-
children: PropTypes.element.isRequired,
|
|
162
|
-
/**
|
|
163
|
-
* Overrides the default flip behaviour of the Tooltip,
|
|
164
|
-
* must be an array containing some or all of ["top", "bottom", "left", "right"]
|
|
165
|
-
* (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements)
|
|
166
|
-
*/
|
|
167
|
-
flipOverrides: PropTypes.arrayOf(
|
|
168
|
-
PropTypes.oneOf(["bottom", "left", "right", "top"])
|
|
169
|
-
),
|
|
170
|
-
/**
|
|
171
|
-
* Override font color of the Tooltip, provide any color from palette or any valid css color value.
|
|
172
|
-
*/
|
|
173
|
-
fontColor: PropTypes.string,
|
|
174
|
-
/**
|
|
175
|
-
* The id attribute to use for the tooltip
|
|
176
|
-
*/
|
|
177
|
-
id: PropTypes.string,
|
|
178
|
-
inputSize: PropTypes.oneOf(["large", "medium", "small"]),
|
|
179
|
-
isPartOfInput: PropTypes.bool,
|
|
180
|
-
/**
|
|
181
|
-
* Whether to to show the Tooltip
|
|
182
|
-
*/
|
|
183
|
-
isVisible: PropTypes.bool,
|
|
184
|
-
key: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
185
|
-
/**
|
|
186
|
-
* The message to be displayed within the tooltip
|
|
187
|
-
*/
|
|
188
|
-
message: PropTypes.node,
|
|
189
|
-
/**
|
|
190
|
-
* Sets position of the tooltip
|
|
191
|
-
*/
|
|
192
|
-
position: PropTypes.oneOf(["bottom", "left", "right", "top"]),
|
|
193
|
-
/**
|
|
194
|
-
* Defines the size of the tooltip content
|
|
195
|
-
*/
|
|
196
|
-
size: PropTypes.oneOf(["large", "medium"]),
|
|
197
|
-
target: function (props, propName) {
|
|
198
|
-
if (props[propName] == null) {
|
|
199
|
-
return null;
|
|
200
|
-
} else if (
|
|
201
|
-
typeof props[propName] !== "object" ||
|
|
202
|
-
props[propName].nodeType !== 1
|
|
203
|
-
) {
|
|
204
|
-
return new Error(
|
|
205
|
-
"Expected prop '" + propName + "' to be of type Element"
|
|
206
|
-
);
|
|
78
|
+
}] : []), {
|
|
79
|
+
name: "computeStyles",
|
|
80
|
+
options: {
|
|
81
|
+
gpuAcceleration: false
|
|
82
|
+
}
|
|
83
|
+
}]
|
|
207
84
|
}
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
* Defines the message type
|
|
211
|
-
*/
|
|
212
|
-
type: PropTypes.string,
|
|
213
|
-
};
|
|
214
|
-
|
|
85
|
+
}), children);
|
|
86
|
+
});
|
|
215
87
|
Tooltip.propTypes = {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
*/
|
|
229
|
-
flipOverrides: PropTypes.arrayOf(
|
|
230
|
-
PropTypes.oneOf(["bottom", "left", "right", "top"])
|
|
231
|
-
),
|
|
232
|
-
/**
|
|
233
|
-
* Override font color of the Tooltip, provide any color from palette or any valid css color value.
|
|
234
|
-
*/
|
|
235
|
-
fontColor: PropTypes.string,
|
|
236
|
-
/**
|
|
237
|
-
* The id attribute to use for the tooltip
|
|
238
|
-
*/
|
|
239
|
-
id: PropTypes.string,
|
|
240
|
-
inputSize: PropTypes.oneOf(["large", "medium", "small"]),
|
|
241
|
-
isPartOfInput: PropTypes.bool,
|
|
242
|
-
/**
|
|
243
|
-
* Whether to to show the Tooltip
|
|
244
|
-
*/
|
|
245
|
-
isVisible: PropTypes.bool,
|
|
246
|
-
key: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
247
|
-
/**
|
|
248
|
-
* The message to be displayed within the tooltip
|
|
249
|
-
*/
|
|
250
|
-
message: PropTypes.node,
|
|
251
|
-
/**
|
|
252
|
-
* Sets position of the tooltip
|
|
253
|
-
*/
|
|
254
|
-
position: PropTypes.oneOf(["bottom", "left", "right", "top"]),
|
|
255
|
-
/**
|
|
256
|
-
* Defines the size of the tooltip content
|
|
257
|
-
*/
|
|
258
|
-
size: PropTypes.oneOf(["large", "medium"]),
|
|
259
|
-
target: function (props, propName) {
|
|
88
|
+
"bgColor": PropTypes.string,
|
|
89
|
+
"children": PropTypes.element.isRequired,
|
|
90
|
+
"flipOverrides": PropTypes.arrayOf(PropTypes.oneOf(["bottom", "left", "right", "top"])),
|
|
91
|
+
"fontColor": PropTypes.string,
|
|
92
|
+
"id": PropTypes.string,
|
|
93
|
+
"inputSize": PropTypes.oneOf(["large", "medium", "small"]),
|
|
94
|
+
"isPartOfInput": PropTypes.bool,
|
|
95
|
+
"isVisible": PropTypes.bool,
|
|
96
|
+
"message": PropTypes.node,
|
|
97
|
+
"position": PropTypes.oneOf(["bottom", "left", "right", "top"]),
|
|
98
|
+
"size": PropTypes.oneOf(["large", "medium"]),
|
|
99
|
+
"target": function (props, propName) {
|
|
260
100
|
if (props[propName] == null) {
|
|
261
101
|
return null;
|
|
262
|
-
} else if (
|
|
263
|
-
|
|
264
|
-
props[propName].nodeType !== 1
|
|
265
|
-
) {
|
|
266
|
-
return new Error(
|
|
267
|
-
"Expected prop '" + propName + "' to be of type Element"
|
|
268
|
-
);
|
|
102
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
103
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
269
104
|
}
|
|
270
105
|
},
|
|
271
|
-
|
|
272
|
-
* Defines the message type
|
|
273
|
-
*/
|
|
274
|
-
type: PropTypes.string,
|
|
106
|
+
"type": PropTypes.string
|
|
275
107
|
};
|
|
276
|
-
|
|
277
108
|
export { Tooltip };
|
|
278
109
|
Tooltip.displayName = "Tooltip";
|
|
279
|
-
export default Tooltip;
|
|
110
|
+
export default Tooltip;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SpaceProps } from "styled-system";
|
|
3
3
|
declare type TintRange = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 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 | 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 | 94 | 95 | 96 | 97 | 98 | 99 | 100;
|
|
4
|
-
export interface
|
|
4
|
+
export interface VerticalDividerProps extends SpaceProps {
|
|
5
5
|
h?: number | string;
|
|
6
6
|
height?: number | string;
|
|
7
7
|
displayInline?: boolean;
|
|
8
8
|
/** the supported rage is 1-100 */
|
|
9
9
|
tint?: TintRange;
|
|
10
10
|
}
|
|
11
|
-
declare const VerticalDivider: ({ h, height, displayInline, tint, ...props }:
|
|
11
|
+
declare const VerticalDivider: ({ h, height, displayInline, tint, ...props }: VerticalDividerProps) => JSX.Element;
|
|
12
12
|
export default VerticalDivider;
|