carbon-react 105.1.2 → 106.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/esm/__internal__/tooltip-provider/index.d.ts +19 -24
- package/esm/__internal__/tooltip-provider/index.js +1 -11
- package/esm/__internal__/utils/helpers/browser/index.d.ts +15 -1
- package/esm/__internal__/utils/helpers/browser/index.js +33 -1
- package/esm/__internal__/utils/helpers/browser-type-check/index.d.ts +7 -1
- package/esm/__internal__/utils/helpers/browser-type-check/index.js +8 -1
- package/esm/__internal__/utils/helpers/events/composedPath.d.ts +1 -1
- package/esm/__internal__/utils/helpers/events/events.d.ts +132 -31
- package/esm/__internal__/utils/helpers/events/events.js +10 -125
- package/esm/__internal__/utils/helpers/guid/index.d.ts +5 -0
- package/esm/__internal__/utils/helpers/guid/{guid.js → index.js} +0 -2
- package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +4 -2
- package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +2 -1
- package/esm/__internal__/utils/helpers/tags/tags.d.ts +10 -6
- package/esm/__internal__/utils/helpers/tags/tags.js +2 -6
- package/esm/__internal__/utils/helpers/useUniqueId/index.d.ts +2 -0
- package/esm/__internal__/utils/helpers/useUniqueId/index.js +7 -0
- package/esm/__internal__/utils/logger/index.d.ts +5 -1
- package/esm/__internal__/utils/logger/index.js +25 -1
- package/esm/components/app-wrapper/app-wrapper.component.d.ts +4 -0
- package/esm/components/app-wrapper/app-wrapper.component.js +5 -3
- package/esm/components/badge/badge.style.d.ts +4 -2
- package/esm/components/button/button-types.style.d.ts +1 -2
- package/esm/components/button/button-types.style.js +3 -1
- package/esm/components/button/button.component.d.ts +67 -36
- package/esm/components/button/button.component.js +3314 -165
- package/esm/components/button/button.config.d.ts +4 -3
- package/esm/components/button/button.style.d.ts +6 -8
- package/esm/components/button/button.style.js +51 -95
- package/esm/components/button/index.d.ts +2 -2
- package/esm/components/confirm/confirm.component.js +1 -1
- package/esm/components/dialog/dialog.component.js +1 -1
- package/esm/components/dialog-full-screen/dialog-full-screen.component.js +1 -1
- package/esm/components/duelling-picklist/picklist-group/picklist-group.style.d.ts +1 -2
- package/esm/components/duelling-picklist/picklist-item/picklist-item.style.d.ts +1 -2
- package/esm/components/fieldset/fieldset.component.d.ts +6 -1
- package/esm/components/fieldset/fieldset.component.js +14 -15
- package/esm/components/heading/heading.component.d.ts +5 -0
- package/esm/components/icon/index.d.ts +1 -0
- package/esm/components/multi-action-button/multi-action-button.component.d.ts +3 -1
- package/esm/components/multi-action-button/multi-action-button.component.js +7 -5
- package/esm/components/multi-action-button/multi-action-button.d.ts +4 -2
- package/esm/components/multi-step-wizard/multi-step-wizard.d.ts +22 -0
- package/esm/components/multi-step-wizard/step/step.d.ts +6 -0
- package/esm/components/multi-step-wizard/step/step.style.d.ts +4 -2
- package/esm/components/portrait/portrait-initials.component.js +1 -1
- package/esm/components/radio-button/radio-button-svg.component.js +29 -16
- package/esm/components/scrollable-list/scrollable-list.component.d.ts +8 -0
- package/esm/components/select/select-list/select-list.component.js +1 -1
- package/esm/components/select/select-textbox/select-textbox.component.js +1 -1
- package/esm/components/split-button/split-button-toggle.style.d.ts +2 -6
- package/esm/components/split-button/split-button.component.d.ts +3 -1
- package/esm/components/split-button/split-button.component.js +7 -4
- package/esm/components/split-button/split-button.d.ts +5 -2
- package/esm/components/tabs/__internal__/tab-title/tab-title.style.js +3 -5
- package/esm/components/textbox/textbox.component.d.ts +1 -2
- package/esm/components/textbox/textbox.component.js +7 -6
- package/esm/components/tooltip/index.d.ts +2 -1
- package/esm/components/tooltip/tooltip-pointer.style.d.ts +10 -1
- package/esm/components/tooltip/tooltip-pointer.style.js +5 -12
- package/esm/components/tooltip/tooltip.component.d.ts +33 -2
- package/esm/components/tooltip/tooltip.component.js +255 -110
- package/esm/components/tooltip/tooltip.config.d.ts +2 -1
- package/esm/components/tooltip/tooltip.style.d.ts +7 -2
- package/esm/components/tooltip/tooltip.style.js +7 -21
- package/esm/components/typography/typography.component.d.ts +1 -1
- package/esm/locales/en-gb.d.ts +3 -5
- package/esm/locales/en-gb.js +5 -4
- package/esm/locales/index.d.ts +1 -1
- package/esm/locales/index.js +2 -0
- package/esm/locales/locale.d.ts +99 -105
- package/esm/locales/locale.js +1 -0
- package/esm/locales/pl-pl.d.ts +3 -5
- package/esm/locales/pl-pl.js +5 -4
- package/esm/style/{fonts → assets}/carbon-icons-webfont.woff +0 -0
- package/esm/style/fonts.css +30 -0
- package/esm/style/global-style.js +1 -1
- package/esm/style/themes/base/base-theme.config.d.ts +17 -8
- package/esm/style/themes/sage/index.d.ts +17 -8
- package/lib/__internal__/tooltip-provider/index.d.ts +19 -24
- package/lib/__internal__/tooltip-provider/index.js +2 -13
- package/lib/__internal__/utils/helpers/browser/index.d.ts +15 -1
- package/lib/__internal__/utils/helpers/browser/index.js +33 -8
- package/lib/__internal__/utils/helpers/browser-type-check/index.d.ts +7 -1
- package/lib/__internal__/utils/helpers/browser-type-check/index.js +10 -21
- package/lib/__internal__/utils/helpers/events/composedPath.d.ts +1 -1
- package/lib/__internal__/utils/helpers/events/events.d.ts +132 -31
- package/lib/__internal__/utils/helpers/events/events.js +10 -125
- package/lib/__internal__/utils/helpers/guid/index.d.ts +5 -0
- package/lib/__internal__/utils/helpers/guid/{guid.js → index.js} +0 -2
- package/lib/__internal__/utils/helpers/guid/package.json +5 -2
- package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +4 -2
- package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +2 -1
- package/lib/__internal__/utils/helpers/tags/tags.d.ts +10 -6
- package/lib/__internal__/utils/helpers/tags/tags.js +2 -6
- package/lib/__internal__/utils/helpers/useUniqueId/index.d.ts +2 -0
- package/lib/__internal__/utils/helpers/useUniqueId/index.js +20 -0
- package/lib/__internal__/utils/helpers/useUniqueId/package.json +6 -0
- package/lib/__internal__/utils/logger/index.d.ts +5 -1
- package/lib/__internal__/utils/logger/index.js +26 -8
- package/lib/components/app-wrapper/app-wrapper.component.d.ts +4 -0
- package/lib/components/app-wrapper/app-wrapper.component.js +5 -4
- package/lib/components/badge/badge.style.d.ts +4 -2
- package/lib/components/button/button-types.style.d.ts +1 -2
- package/lib/components/button/button-types.style.js +0 -1
- package/lib/components/button/button.component.d.ts +67 -36
- package/lib/components/button/button.component.js +3381 -172
- package/lib/components/button/button.config.d.ts +4 -3
- package/lib/components/button/button.style.d.ts +6 -8
- package/lib/components/button/button.style.js +52 -101
- package/lib/components/button/index.d.ts +2 -2
- package/lib/components/confirm/confirm.component.js +1 -1
- package/lib/components/dialog/dialog.component.js +1 -1
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +1 -1
- package/lib/components/duelling-picklist/picklist-group/picklist-group.style.d.ts +1 -2
- package/lib/components/duelling-picklist/picklist-item/picklist-item.style.d.ts +1 -2
- package/lib/components/fieldset/fieldset.component.d.ts +6 -1
- package/lib/components/fieldset/fieldset.component.js +14 -16
- package/lib/components/heading/heading.component.d.ts +5 -0
- package/lib/components/icon/index.d.ts +1 -0
- package/lib/components/multi-action-button/multi-action-button.component.d.ts +3 -1
- package/lib/components/multi-action-button/multi-action-button.component.js +6 -4
- package/lib/components/multi-action-button/multi-action-button.d.ts +4 -2
- package/lib/components/multi-step-wizard/multi-step-wizard.d.ts +22 -0
- package/lib/components/multi-step-wizard/step/step.d.ts +6 -0
- package/lib/components/multi-step-wizard/step/step.style.d.ts +4 -2
- package/lib/components/portrait/portrait-initials.component.js +1 -1
- package/lib/components/radio-button/radio-button-svg.component.js +38 -20
- package/lib/components/scrollable-list/scrollable-list.component.d.ts +8 -0
- package/lib/components/select/select-list/select-list.component.js +1 -1
- package/lib/components/select/select-textbox/select-textbox.component.js +1 -1
- package/lib/components/split-button/split-button-toggle.style.d.ts +2 -6
- package/lib/components/split-button/split-button.component.d.ts +3 -1
- package/lib/components/split-button/split-button.component.js +6 -3
- package/lib/components/split-button/split-button.d.ts +5 -2
- package/lib/components/tabs/__internal__/tab-title/tab-title.style.js +3 -5
- package/lib/components/textbox/textbox.component.d.ts +1 -2
- package/lib/components/textbox/textbox.component.js +7 -8
- package/lib/components/tooltip/index.d.ts +2 -1
- package/lib/components/tooltip/tooltip-pointer.style.d.ts +10 -1
- package/lib/components/tooltip/tooltip-pointer.style.js +7 -15
- package/lib/components/tooltip/tooltip.component.d.ts +33 -2
- package/lib/components/tooltip/tooltip.component.js +221 -130
- package/lib/components/tooltip/tooltip.config.d.ts +2 -1
- package/lib/components/tooltip/tooltip.style.d.ts +7 -2
- package/lib/components/tooltip/tooltip.style.js +7 -22
- package/lib/components/typography/typography.component.d.ts +1 -1
- package/lib/locales/en-gb.d.ts +3 -5
- package/lib/locales/en-gb.js +2 -1
- package/lib/locales/index.d.ts +1 -1
- package/lib/locales/index.js +23 -0
- package/lib/locales/locale.d.ts +99 -105
- package/lib/locales/locale.js +5 -0
- package/lib/{__internal__/utils/ether → locales}/package.json +1 -1
- package/lib/locales/pl-pl.d.ts +3 -5
- package/lib/locales/pl-pl.js +2 -1
- package/lib/style/{fonts → assets}/carbon-icons-webfont.woff +0 -0
- package/lib/style/fonts.css +30 -0
- package/lib/style/global-style.js +1 -1
- package/lib/style/themes/base/base-theme.config.d.ts +17 -8
- package/lib/style/themes/sage/index.d.ts +17 -8
- package/package.json +10 -5
- package/esm/__internal__/utils/ether/ether.d.ts +0 -19
- package/esm/__internal__/utils/ether/ether.js +0 -29
- package/esm/__internal__/utils/ether/index.d.ts +0 -1
- package/esm/__internal__/utils/ether/index.js +0 -1
- package/esm/__internal__/utils/helpers/browser/browser.d.ts +0 -17
- package/esm/__internal__/utils/helpers/browser/browser.js +0 -198
- package/esm/__internal__/utils/helpers/browser-type-check/browser-type-check.d.ts +0 -7
- package/esm/__internal__/utils/helpers/browser-type-check/browser-type-check.js +0 -14
- package/esm/__internal__/utils/helpers/guid/__spec__.d.ts +0 -1
- package/esm/__internal__/utils/helpers/guid/__spec__.js +0 -10
- package/esm/__internal__/utils/helpers/guid/guid.d.ts +0 -2
- package/esm/__internal__/utils/helpers/guid/package.json +0 -3
- package/esm/__internal__/utils/helpers/immutable/__spec__.d.ts +0 -1
- package/esm/__internal__/utils/helpers/immutable/__spec__.js +0 -117
- package/esm/__internal__/utils/helpers/immutable/immutable.d.ts +0 -4
- package/esm/__internal__/utils/helpers/immutable/immutable.js +0 -36
- package/esm/__internal__/utils/helpers/immutable/package.json +0 -4
- package/esm/__internal__/utils/helpers/with-unique-id-props/index.d.ts +0 -1
- package/esm/__internal__/utils/helpers/with-unique-id-props/index.js +0 -1
- package/esm/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.d.ts +0 -7
- package/esm/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.js +0 -82
- package/esm/__internal__/utils/logger/logger.d.ts +0 -9
- package/esm/__internal__/utils/logger/logger.js +0 -71
- package/esm/components/button/button.d.ts +0 -85
- package/esm/components/tooltip/tooltip.d.ts +0 -40
- package/lib/__internal__/utils/ether/ether.d.ts +0 -19
- package/lib/__internal__/utils/ether/ether.js +0 -33
- package/lib/__internal__/utils/ether/index.d.ts +0 -1
- package/lib/__internal__/utils/ether/index.js +0 -18
- package/lib/__internal__/utils/helpers/browser/browser.d.ts +0 -17
- package/lib/__internal__/utils/helpers/browser/browser.js +0 -213
- package/lib/__internal__/utils/helpers/browser-type-check/browser-type-check.d.ts +0 -7
- package/lib/__internal__/utils/helpers/browser-type-check/browser-type-check.js +0 -26
- package/lib/__internal__/utils/helpers/guid/__spec__.d.ts +0 -1
- package/lib/__internal__/utils/helpers/guid/__spec__.js +0 -15
- package/lib/__internal__/utils/helpers/guid/guid.d.ts +0 -2
- package/lib/__internal__/utils/helpers/immutable/__spec__.d.ts +0 -1
- package/lib/__internal__/utils/helpers/immutable/__spec__.js +0 -135
- package/lib/__internal__/utils/helpers/immutable/immutable.d.ts +0 -4
- package/lib/__internal__/utils/helpers/immutable/immutable.js +0 -46
- package/lib/__internal__/utils/helpers/immutable/package.json +0 -4
- package/lib/__internal__/utils/helpers/with-unique-id-props/index.d.ts +0 -1
- package/lib/__internal__/utils/helpers/with-unique-id-props/index.js +0 -15
- package/lib/__internal__/utils/helpers/with-unique-id-props/package.json +0 -6
- package/lib/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.d.ts +0 -7
- package/lib/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.js +0 -96
- package/lib/__internal__/utils/logger/logger.d.ts +0 -9
- package/lib/__internal__/utils/logger/logger.js +0 -78
- package/lib/components/button/button.d.ts +0 -85
- package/lib/components/tooltip/tooltip.d.ts +0 -40
|
@@ -12,7 +12,7 @@ import StyledSplitButtonChildrenContainer from "./split-button-children.style";
|
|
|
12
12
|
import Events from "../../__internal__/utils/helpers/events";
|
|
13
13
|
import guid from "../../__internal__/utils/helpers/guid";
|
|
14
14
|
import Popover from "../../__internal__/popover";
|
|
15
|
-
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
15
|
+
import { filterStyledSystemMarginProps, filterOutStyledSystemSpacingProps } from "../../style/utils";
|
|
16
16
|
import { baseTheme } from "../../style/themes";
|
|
17
17
|
import { defaultFocusableSelectors } from "../../__internal__/focus-trap/focus-trap-utils";
|
|
18
18
|
import Logger from "../../__internal__/utils/logger";
|
|
@@ -32,6 +32,8 @@ const SplitButton = ({
|
|
|
32
32
|
size = "medium",
|
|
33
33
|
subtext,
|
|
34
34
|
text,
|
|
35
|
+
"data-element": dataElement,
|
|
36
|
+
"data-role": dataRole,
|
|
35
37
|
...rest
|
|
36
38
|
}) => {
|
|
37
39
|
if (!deprecatedWarnTriggered && as) {
|
|
@@ -114,7 +116,8 @@ const SplitButton = ({
|
|
|
114
116
|
iconType,
|
|
115
117
|
onClick,
|
|
116
118
|
size,
|
|
117
|
-
subtext
|
|
119
|
+
subtext,
|
|
120
|
+
...filterOutStyledSystemSpacingProps(rest)
|
|
118
121
|
};
|
|
119
122
|
}
|
|
120
123
|
|
|
@@ -142,8 +145,8 @@ const SplitButton = ({
|
|
|
142
145
|
function componentTags() {
|
|
143
146
|
return {
|
|
144
147
|
"data-component": "split-button",
|
|
145
|
-
"data-element":
|
|
146
|
-
"data-role":
|
|
148
|
+
"data-element": dataElement,
|
|
149
|
+
"data-role": dataRole
|
|
147
150
|
};
|
|
148
151
|
}
|
|
149
152
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
2
3
|
|
|
3
|
-
export interface SplitButtonProps
|
|
4
|
+
export interface SplitButtonProps
|
|
5
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
6
|
+
MarginProps {
|
|
4
7
|
/** Set align of the rendered content */
|
|
5
8
|
align?: "left" | "right";
|
|
6
9
|
/** Button type: "primary" | "secondary" for legacy theme */
|
|
@@ -23,6 +26,6 @@ export interface SplitButtonProps {
|
|
|
23
26
|
text: string;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
declare
|
|
29
|
+
declare function SplitButton(props: SplitButtonProps): JSX.Element;
|
|
27
30
|
|
|
28
31
|
export default SplitButton;
|
|
@@ -356,18 +356,16 @@ const StyledTabTitle = styled.button`
|
|
|
356
356
|
|
|
357
357
|
${alternateStyling && css`
|
|
358
358
|
&:focus {
|
|
359
|
-
background-color: var(--
|
|
359
|
+
background-color: var(--colorsActionMinor200);
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
&:hover {
|
|
363
|
-
background-color: ${isTabSelected ? "var(--
|
|
363
|
+
background-color: ${isTabSelected ? "var(--colorsActionMinor200)" : "var(--colorsActionMinor250)"};
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
${isTabSelected && css`
|
|
367
|
-
background-color: var(--
|
|
367
|
+
background-color: var(--colorsActionMinor200);
|
|
368
368
|
`}
|
|
369
|
-
|
|
370
|
-
${isInSidebar && `padding-bottom: 1px;`}
|
|
371
369
|
`}
|
|
372
370
|
`}
|
|
373
371
|
`;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { Textbox as OriginalTextbox };
|
|
2
|
-
|
|
3
|
-
export default _default;
|
|
2
|
+
export default Textbox;
|
|
4
3
|
declare function Textbox({ align, autoFocus, children, disabled, inputIcon, leftChildren, labelId: externalLabelId, label, labelAlign, labelHelp, labelInline, labelSpacing, id, formattedValue, fieldHelp, error, warning, info, name, reverse, size, value, readOnly, placeholder, inputRef, onBlur, onClick, onFocus, onChange, onMouseDown, onChangeDeferred, deferTimeout, isOptional, iconOnClick, iconOnMouseDown, iconTabIndex, validationOnLabel, labelWidth, inputWidth, prefix, adaptiveLabelBreakpoint, required, positionedChildren, tooltipPosition, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, enforceCharacterLimit, characterLimit, warnOverLimit, helpAriaLabel, ...props }: {
|
|
5
4
|
[x: string]: any;
|
|
6
5
|
align: any;
|
|
@@ -7,7 +7,7 @@ import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
|
7
7
|
import { Input, InputPresentation } from "../../__internal__/input";
|
|
8
8
|
import InputIconToggle from "../../__internal__/input-icon-toggle";
|
|
9
9
|
import FormField from "../../__internal__/form-field";
|
|
10
|
-
import
|
|
10
|
+
import useUniqueId from "../../__internal__/utils/helpers/useUniqueId";
|
|
11
11
|
import { InputBehaviour } from "../../__internal__/input-behaviour";
|
|
12
12
|
import StyledPrefix from "./__internal__/prefix.style";
|
|
13
13
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
@@ -83,13 +83,14 @@ const Textbox = ({
|
|
|
83
83
|
|
|
84
84
|
const computeLabelPropValues = prop => validationRedesignOptIn ? undefined : prop;
|
|
85
85
|
|
|
86
|
+
const [uniqueId, uniqueName] = useUniqueId(id, name);
|
|
86
87
|
const {
|
|
87
88
|
labelId: internalLabelId,
|
|
88
89
|
validationIconId,
|
|
89
90
|
fieldHelpId,
|
|
90
91
|
ariaDescribedBy
|
|
91
92
|
} = useInputAccessibility({
|
|
92
|
-
id,
|
|
93
|
+
id: uniqueId,
|
|
93
94
|
error,
|
|
94
95
|
warning,
|
|
95
96
|
info,
|
|
@@ -115,7 +116,7 @@ const Textbox = ({
|
|
|
115
116
|
labelInline: computeLabelPropValues(labelInline),
|
|
116
117
|
labelSpacing: labelSpacing,
|
|
117
118
|
labelWidth: computeLabelPropValues(labelWidth),
|
|
118
|
-
id:
|
|
119
|
+
id: uniqueId,
|
|
119
120
|
reverse: computeLabelPropValues(reverse),
|
|
120
121
|
isOptional: isOptional,
|
|
121
122
|
useValidationIcon: computeLabelPropValues(validationOnLabel),
|
|
@@ -155,9 +156,9 @@ const Textbox = ({
|
|
|
155
156
|
autoFocus: autoFocus,
|
|
156
157
|
deferTimeout: deferTimeout,
|
|
157
158
|
disabled: disabled,
|
|
158
|
-
id:
|
|
159
|
+
id: uniqueId,
|
|
159
160
|
inputRef: inputRef,
|
|
160
|
-
name:
|
|
161
|
+
name: uniqueName,
|
|
161
162
|
onBlur: onBlur,
|
|
162
163
|
onChange: onChange,
|
|
163
164
|
onChangeDeferred: onChangeDeferred,
|
|
@@ -379,4 +380,4 @@ Textbox.defaultProps = {
|
|
|
379
380
|
validationOnLabel: false
|
|
380
381
|
};
|
|
381
382
|
export { Textbox as OriginalTextbox };
|
|
382
|
-
export default
|
|
383
|
+
export default Textbox;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./tooltip";
|
|
1
|
+
export { default } from "./tooltip.component";
|
|
2
|
+
export type { TooltipProps } from "./tooltip.component";
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
import { Placement } from "tippy.js";
|
|
2
|
+
interface StyledTooltipPointer {
|
|
3
|
+
/** Sets position of the tooltip */
|
|
4
|
+
position?: Placement;
|
|
5
|
+
/** Defines the message type */
|
|
6
|
+
type?: string;
|
|
7
|
+
/** Override background color of the Tooltip, provide any color from palette or any valid css color value. */
|
|
8
|
+
bgColor?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const StyledTooltipPointer: import("styled-components").StyledComponent<"div", any, StyledTooltipPointer, never>;
|
|
1
11
|
export default StyledTooltipPointer;
|
|
2
|
-
declare const StyledTooltipPointer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import styled, { css } from "styled-components";
|
|
3
2
|
import baseTheme from "../../style/themes/base";
|
|
4
3
|
import { toColor } from "../../style/utils/color";
|
|
5
4
|
|
|
6
|
-
const pointerColor = (
|
|
5
|
+
const pointerColor = (theme, bgColor, type) => {
|
|
7
6
|
if (bgColor) return toColor(theme, bgColor);
|
|
8
7
|
return type === "error" ? "var(--colorsSemanticNegative500)" : "var(--colorsSemanticNeutral500)";
|
|
9
8
|
};
|
|
@@ -22,7 +21,7 @@ const StyledTooltipPointer = styled.div`
|
|
|
22
21
|
${position === "top" && css`
|
|
23
22
|
border-left: 8px solid transparent;
|
|
24
23
|
border-right: 8px solid transparent;
|
|
25
|
-
border-top: 8px solid ${pointerColor(
|
|
24
|
+
border-top: 8px solid ${pointerColor(theme, bgColor, type)};
|
|
26
25
|
bottom: calc(-1 * var(--spacing100));
|
|
27
26
|
@-moz-document url-prefix() {
|
|
28
27
|
bottom: -7px;
|
|
@@ -32,7 +31,7 @@ const StyledTooltipPointer = styled.div`
|
|
|
32
31
|
${position === "bottom" && css`
|
|
33
32
|
border-left: 8px solid transparent;
|
|
34
33
|
border-right: 8px solid transparent;
|
|
35
|
-
border-bottom: 8px solid ${pointerColor(
|
|
34
|
+
border-bottom: 8px solid ${pointerColor(theme, bgColor, type)};
|
|
36
35
|
top: calc(-1 * var(--spacing100));
|
|
37
36
|
@-moz-document url-prefix() {
|
|
38
37
|
top: -7px;
|
|
@@ -42,7 +41,7 @@ const StyledTooltipPointer = styled.div`
|
|
|
42
41
|
${position === "right" && css`
|
|
43
42
|
border-top: 8px solid transparent;
|
|
44
43
|
border-bottom: 8px solid transparent;
|
|
45
|
-
border-right: 8px solid ${pointerColor(
|
|
44
|
+
border-right: 8px solid ${pointerColor(theme, bgColor, type)};
|
|
46
45
|
left: calc(-1 * var(--spacing100));
|
|
47
46
|
@-moz-document url-prefix() {
|
|
48
47
|
left: -7px;
|
|
@@ -52,7 +51,7 @@ const StyledTooltipPointer = styled.div`
|
|
|
52
51
|
${position === "left" && css`
|
|
53
52
|
border-top: 8px solid transparent;
|
|
54
53
|
border-bottom: 8px solid transparent;
|
|
55
|
-
border-left: 8px solid ${pointerColor(
|
|
54
|
+
border-left: 8px solid ${pointerColor(theme, bgColor, type)};
|
|
56
55
|
right: calc(-1 * var(--spacing100));
|
|
57
56
|
@-moz-document url-prefix() {
|
|
58
57
|
right: -7px;
|
|
@@ -64,10 +63,4 @@ StyledTooltipPointer.defaultProps = {
|
|
|
64
63
|
theme: baseTheme,
|
|
65
64
|
position: "top"
|
|
66
65
|
};
|
|
67
|
-
StyledTooltipPointer.propTypes = {
|
|
68
|
-
position: PropTypes.oneOf(["bottom", "left", "right", "top"]),
|
|
69
|
-
theme: PropTypes.object,
|
|
70
|
-
type: PropTypes.string,
|
|
71
|
-
bgColor: PropTypes.string
|
|
72
|
-
};
|
|
73
66
|
export default StyledTooltipPointer;
|
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
export default Tooltip;
|
|
2
|
-
declare const Tooltip: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
3
1
|
import React from "react";
|
|
2
|
+
import { TooltipPositions } from "./tooltip.config";
|
|
3
|
+
export declare type InputSizes = "small" | "medium" | "large";
|
|
4
|
+
export interface TooltipProps {
|
|
5
|
+
/** The message to be displayed within the tooltip */
|
|
6
|
+
message: React.ReactNode;
|
|
7
|
+
/** The id attribute to use for the tooltip */
|
|
8
|
+
id?: string;
|
|
9
|
+
/** Whether to to show the Tooltip */
|
|
10
|
+
isVisible?: boolean;
|
|
11
|
+
/** Sets position of the tooltip */
|
|
12
|
+
position?: TooltipPositions;
|
|
13
|
+
/** Defines the message type */
|
|
14
|
+
type?: string;
|
|
15
|
+
/** Children elements */
|
|
16
|
+
children: React.ReactElement;
|
|
17
|
+
/** Defines the size of the tooltip content */
|
|
18
|
+
size?: "medium" | "large";
|
|
19
|
+
/** Override background color of the Tooltip, provide any color from palette or any valid css color value. */
|
|
20
|
+
bgColor?: string;
|
|
21
|
+
/** Override font color of the Tooltip, provide any color from palette or any valid css color value. */
|
|
22
|
+
fontColor?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Overrides the default flip behaviour of the Tooltip,
|
|
25
|
+
* must be an array containing some or all of ["top", "bottom", "left", "right"]
|
|
26
|
+
* (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements)
|
|
27
|
+
*/
|
|
28
|
+
flipOverrides?: TooltipPositions[];
|
|
29
|
+
target?: Element;
|
|
30
|
+
isPartOfInput?: boolean;
|
|
31
|
+
inputSize?: InputSizes;
|
|
32
|
+
}
|
|
33
|
+
export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement | null>>;
|
|
34
|
+
export default Tooltip;
|
|
@@ -1,134 +1,279 @@
|
|
|
1
|
-
function _extends() {
|
|
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
|
+
}
|
|
2
17
|
|
|
3
|
-
import React
|
|
18
|
+
import React from "react";
|
|
4
19
|
import PropTypes from "prop-types";
|
|
5
20
|
import Tippy from "@tippyjs/react/headless";
|
|
6
21
|
import { sticky } from "tippy.js";
|
|
22
|
+
import invariant from "invariant";
|
|
7
23
|
import StyledTooltip from "./tooltip.style";
|
|
8
24
|
import StyledPointer from "./tooltip-pointer.style";
|
|
25
|
+
import { TOOLTIP_POSITIONS } from "./tooltip.config";
|
|
9
26
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
10
27
|
import CarbonScopedTokensProvider from "../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component";
|
|
11
28
|
const TOOLTIP_DELAY = 100;
|
|
12
29
|
const tippyPlugins = [sticky];
|
|
13
|
-
const Tooltip = /*#__PURE__*/React.forwardRef(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
const Tooltip = /*#__PURE__*/ React.forwardRef(
|
|
31
|
+
(
|
|
32
|
+
{
|
|
33
|
+
children,
|
|
34
|
+
isVisible,
|
|
35
|
+
position = "top",
|
|
36
|
+
message,
|
|
37
|
+
type,
|
|
38
|
+
size = "medium",
|
|
39
|
+
isPartOfInput,
|
|
40
|
+
inputSize,
|
|
41
|
+
id,
|
|
42
|
+
bgColor,
|
|
43
|
+
fontColor,
|
|
44
|
+
flipOverrides,
|
|
45
|
+
target,
|
|
46
|
+
...rest
|
|
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
|
+
);
|
|
30
60
|
|
|
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
|
-
|
|
61
|
+
const tooltip = (attrs, content) => {
|
|
62
|
+
const currentPosition = attrs["data-placement"] || position;
|
|
63
|
+
return /*#__PURE__*/ React.createElement(
|
|
64
|
+
CarbonScopedTokensProvider,
|
|
65
|
+
null,
|
|
66
|
+
/*#__PURE__*/ React.createElement(
|
|
67
|
+
StyledTooltip,
|
|
68
|
+
_extends(
|
|
69
|
+
{
|
|
70
|
+
"data-element": "tooltip",
|
|
71
|
+
role: "tooltip",
|
|
72
|
+
tabIndex: -1,
|
|
73
|
+
type: type,
|
|
74
|
+
size: size,
|
|
75
|
+
id: id,
|
|
76
|
+
},
|
|
77
|
+
tagComponent("tooltip", rest),
|
|
78
|
+
{
|
|
79
|
+
isPartOfInput: isPartOfInput,
|
|
80
|
+
inputSize: inputSize,
|
|
81
|
+
},
|
|
82
|
+
attrs,
|
|
83
|
+
{
|
|
84
|
+
position: currentPosition,
|
|
85
|
+
ref: ref,
|
|
86
|
+
bgColor: bgColor,
|
|
87
|
+
fontColor: fontColor,
|
|
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
|
+
};
|
|
58
110
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
111
|
+
return /*#__PURE__*/ React.createElement(
|
|
112
|
+
Tippy,
|
|
113
|
+
_extends(
|
|
114
|
+
{
|
|
115
|
+
placement: position,
|
|
116
|
+
delay: TOOLTIP_DELAY,
|
|
117
|
+
},
|
|
118
|
+
isVisible !== undefined && {
|
|
119
|
+
visible: isVisible,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
plugins: tippyPlugins,
|
|
123
|
+
sticky: true,
|
|
124
|
+
render: (attrs) => tooltip(attrs, message),
|
|
125
|
+
reference: target,
|
|
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
|
+
},
|
|
79
146
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
Tooltip.propTypes = {
|
|
86
|
-
/** The message to be displayed within the tooltip */
|
|
87
|
-
message: PropTypes.node.isRequired,
|
|
147
|
+
),
|
|
148
|
+
children
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
);
|
|
88
152
|
|
|
89
|
-
|
|
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
|
+
*/
|
|
90
177
|
id: PropTypes.string,
|
|
91
|
-
|
|
92
|
-
|
|
178
|
+
inputSize: PropTypes.oneOf(["large", "medium", "small"]),
|
|
179
|
+
isPartOfInput: PropTypes.bool,
|
|
180
|
+
/**
|
|
181
|
+
* Whether to to show the Tooltip
|
|
182
|
+
*/
|
|
93
183
|
isVisible: PropTypes.bool,
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
+
);
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
/**
|
|
210
|
+
* Defines the message type
|
|
211
|
+
*/
|
|
99
212
|
type: PropTypes.string,
|
|
213
|
+
};
|
|
100
214
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
size: PropTypes.oneOf(["medium", "large"]),
|
|
106
|
-
// Reference element, tooltip will be positioned in relation to this element
|
|
107
|
-
target: PropTypes.instanceOf(Element),
|
|
108
|
-
|
|
109
|
-
/** Override background color of the Tooltip, provide design token, any color from palette or any valid css color value. */
|
|
215
|
+
Tooltip.propTypes = {
|
|
216
|
+
/**
|
|
217
|
+
* Override background color of the Tooltip, provide any color from palette or any valid css color value.
|
|
218
|
+
*/
|
|
110
219
|
bgColor: PropTypes.string,
|
|
111
|
-
|
|
112
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Children elements
|
|
222
|
+
*/
|
|
223
|
+
children: PropTypes.element.isRequired,
|
|
224
|
+
/**
|
|
225
|
+
* Overrides the default flip behaviour of the Tooltip,
|
|
226
|
+
* must be an array containing some or all of ["top", "bottom", "left", "right"]
|
|
227
|
+
* (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements)
|
|
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
|
+
*/
|
|
113
235
|
fontColor: PropTypes.string,
|
|
114
|
-
|
|
115
|
-
|
|
236
|
+
/**
|
|
237
|
+
* The id attribute to use for the tooltip
|
|
238
|
+
*/
|
|
239
|
+
id: PropTypes.string,
|
|
240
|
+
inputSize: PropTypes.oneOf(["large", "medium", "small"]),
|
|
116
241
|
isPartOfInput: PropTypes.bool,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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) {
|
|
260
|
+
if (props[propName] == null) {
|
|
127
261
|
return null;
|
|
262
|
+
} else if (
|
|
263
|
+
typeof props[propName] !== "object" ||
|
|
264
|
+
props[propName].nodeType !== 1
|
|
265
|
+
) {
|
|
266
|
+
return new Error(
|
|
267
|
+
"Expected prop '" + propName + "' to be of type Element"
|
|
268
|
+
);
|
|
128
269
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
270
|
+
},
|
|
271
|
+
/**
|
|
272
|
+
* Defines the message type
|
|
273
|
+
*/
|
|
274
|
+
type: PropTypes.string,
|
|
133
275
|
};
|
|
134
|
-
|
|
276
|
+
|
|
277
|
+
export { Tooltip };
|
|
278
|
+
Tooltip.displayName = "Tooltip";
|
|
279
|
+
export default Tooltip;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export const TOOLTIP_POSITIONS: string[];
|
|
1
|
+
export declare const TOOLTIP_POSITIONS: string[];
|
|
2
|
+
export declare type TooltipPositions = "top" | "bottom" | "left" | "right";
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Placement } from "tippy.js";
|
|
2
|
+
import { TooltipProps } from "./tooltip.component";
|
|
3
|
+
interface StyledTooltipProps extends Omit<TooltipProps, "children" | "message" | "position"> {
|
|
4
|
+
position: Placement;
|
|
5
|
+
}
|
|
6
|
+
declare const StyledTooltip: import("styled-components").StyledComponent<"div", any, StyledTooltipProps, never>;
|
|
7
|
+
export default StyledTooltip;
|