carbon-react 105.1.0 → 105.2.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__/tooltip-provider/index.d.ts +19 -24
- package/esm/__internal__/tooltip-provider/index.js +0 -10
- package/esm/__spec_helper__/mock-match-media.d.ts +3 -1
- package/esm/components/app-wrapper/app-wrapper.component.d.ts +4 -0
- 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/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/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +10 -3
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +2 -0
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js +9 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +0 -1
- 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/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/option/index.d.ts +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/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/hooks/__internal__/useCharacterCount/index.d.ts +1 -2
- package/esm/hooks/__internal__/useCharacterCount/index.js +1 -18
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +3 -0
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +24 -0
- package/esm/hooks/__internal__/useInputAccessibility/index.d.ts +1 -24
- package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +11 -11
- package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.js +1 -3
- package/esm/hooks/__internal__/useIsAboveBreakpoint/index.d.ts +1 -1
- package/esm/hooks/__internal__/useIsAboveBreakpoint/index.js +1 -6
- package/esm/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.d.ts +1 -0
- package/esm/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js +6 -0
- package/esm/hooks/__internal__/useLocale/index.d.ts +1 -1
- package/esm/hooks/__internal__/useLocale/index.js +1 -5
- package/esm/hooks/__internal__/useLocale/useLocale.d.ts +1 -0
- package/esm/hooks/__internal__/useLocale/useLocale.js +5 -0
- package/esm/hooks/__internal__/useResizeObserver/index.d.ts +1 -10
- package/esm/hooks/__internal__/useResizeObserver/index.js +1 -23
- package/esm/hooks/__internal__/useResizeObserver/useResizeObserver.d.ts +8 -0
- package/esm/hooks/__internal__/useResizeObserver/useResizeObserver.js +29 -0
- package/esm/hooks/__internal__/useScrollBlock/index.d.ts +1 -4
- package/esm/hooks/__internal__/useScrollBlock/scroll-block-manager.d.ts +23 -9
- package/esm/hooks/__internal__/useScrollBlock/scroll-block-manager.js +24 -12
- package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.d.ts +2 -2
- package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.js +3 -5
- package/esm/hooks/useMediaQuery/index.d.ts +1 -1
- package/esm/hooks/useMediaQuery/index.js +1 -19
- package/esm/hooks/useMediaQuery/useMediaQuery.d.ts +1 -0
- package/esm/hooks/useMediaQuery/useMediaQuery.js +19 -0
- 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/lib/__internal__/tooltip-provider/index.d.ts +19 -24
- package/lib/__internal__/tooltip-provider/index.js +1 -12
- package/lib/__spec_helper__/mock-match-media.d.ts +3 -1
- package/lib/components/app-wrapper/app-wrapper.component.d.ts +4 -0
- 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/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/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +10 -3
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +2 -0
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js +22 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +0 -1
- 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/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/option/index.d.ts +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/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/components/vertical-divider/vertical-divider.component.js +3 -0
- package/lib/hooks/__internal__/useCharacterCount/index.d.ts +1 -2
- package/lib/hooks/__internal__/useCharacterCount/index.js +8 -27
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +3 -0
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +40 -0
- package/lib/hooks/__internal__/useInputAccessibility/index.d.ts +1 -24
- package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +11 -11
- package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.js +1 -3
- package/lib/hooks/__internal__/useIsAboveBreakpoint/index.d.ts +1 -1
- package/lib/hooks/__internal__/useIsAboveBreakpoint/index.js +8 -9
- package/lib/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.d.ts +1 -0
- package/lib/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js +16 -0
- package/lib/hooks/__internal__/useLocale/index.d.ts +1 -1
- package/lib/hooks/__internal__/useLocale/index.js +8 -9
- package/lib/hooks/__internal__/useLocale/useLocale.d.ts +1 -0
- package/lib/hooks/__internal__/useLocale/useLocale.js +16 -0
- package/lib/hooks/__internal__/useResizeObserver/index.d.ts +1 -10
- package/lib/hooks/__internal__/useResizeObserver/index.js +8 -24
- package/lib/hooks/__internal__/useResizeObserver/useResizeObserver.d.ts +8 -0
- package/lib/hooks/__internal__/useResizeObserver/useResizeObserver.js +37 -0
- package/lib/hooks/__internal__/useScrollBlock/index.d.ts +1 -4
- package/lib/hooks/__internal__/useScrollBlock/scroll-block-manager.d.ts +23 -9
- package/lib/hooks/__internal__/useScrollBlock/scroll-block-manager.js +24 -12
- package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.d.ts +2 -2
- package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.js +3 -5
- package/lib/hooks/useMediaQuery/index.d.ts +1 -1
- package/lib/hooks/useMediaQuery/index.js +8 -25
- package/lib/hooks/useMediaQuery/useMediaQuery.d.ts +1 -0
- package/lib/hooks/useMediaQuery/useMediaQuery.js +32 -0
- 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/locales/package.json +6 -0
- package/lib/locales/pl-pl.d.ts +3 -5
- package/lib/locales/pl-pl.js +2 -1
- package/package.json +11 -6
- package/esm/components/button/button.d.ts +0 -85
- package/esm/components/tooltip/tooltip.d.ts +0 -40
- package/lib/components/button/button.d.ts +0 -85
- package/lib/components/tooltip/tooltip.d.ts +0 -40
|
@@ -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>;
|
|
@@ -5,21 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
11
9
|
|
|
12
10
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
13
11
|
|
|
14
12
|
var _color = require("../../style/utils/color");
|
|
15
13
|
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
16
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
17
17
|
|
|
18
18
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const pointerColor = (type, theme, bgColor) => {
|
|
20
|
+
const pointerColor = (theme, bgColor, type) => {
|
|
23
21
|
if (bgColor) return (0, _color.toColor)(theme, bgColor);
|
|
24
22
|
return type === "error" ? "var(--colorsSemanticNegative500)" : "var(--colorsSemanticNeutral500)";
|
|
25
23
|
};
|
|
@@ -38,7 +36,7 @@ const StyledTooltipPointer = _styledComponents.default.div`
|
|
|
38
36
|
${position === "top" && (0, _styledComponents.css)`
|
|
39
37
|
border-left: 8px solid transparent;
|
|
40
38
|
border-right: 8px solid transparent;
|
|
41
|
-
border-top: 8px solid ${pointerColor(
|
|
39
|
+
border-top: 8px solid ${pointerColor(theme, bgColor, type)};
|
|
42
40
|
bottom: calc(-1 * var(--spacing100));
|
|
43
41
|
@-moz-document url-prefix() {
|
|
44
42
|
bottom: -7px;
|
|
@@ -48,7 +46,7 @@ const StyledTooltipPointer = _styledComponents.default.div`
|
|
|
48
46
|
${position === "bottom" && (0, _styledComponents.css)`
|
|
49
47
|
border-left: 8px solid transparent;
|
|
50
48
|
border-right: 8px solid transparent;
|
|
51
|
-
border-bottom: 8px solid ${pointerColor(
|
|
49
|
+
border-bottom: 8px solid ${pointerColor(theme, bgColor, type)};
|
|
52
50
|
top: calc(-1 * var(--spacing100));
|
|
53
51
|
@-moz-document url-prefix() {
|
|
54
52
|
top: -7px;
|
|
@@ -58,7 +56,7 @@ const StyledTooltipPointer = _styledComponents.default.div`
|
|
|
58
56
|
${position === "right" && (0, _styledComponents.css)`
|
|
59
57
|
border-top: 8px solid transparent;
|
|
60
58
|
border-bottom: 8px solid transparent;
|
|
61
|
-
border-right: 8px solid ${pointerColor(
|
|
59
|
+
border-right: 8px solid ${pointerColor(theme, bgColor, type)};
|
|
62
60
|
left: calc(-1 * var(--spacing100));
|
|
63
61
|
@-moz-document url-prefix() {
|
|
64
62
|
left: -7px;
|
|
@@ -68,7 +66,7 @@ const StyledTooltipPointer = _styledComponents.default.div`
|
|
|
68
66
|
${position === "left" && (0, _styledComponents.css)`
|
|
69
67
|
border-top: 8px solid transparent;
|
|
70
68
|
border-bottom: 8px solid transparent;
|
|
71
|
-
border-left: 8px solid ${pointerColor(
|
|
69
|
+
border-left: 8px solid ${pointerColor(theme, bgColor, type)};
|
|
72
70
|
right: calc(-1 * var(--spacing100));
|
|
73
71
|
@-moz-document url-prefix() {
|
|
74
72
|
right: -7px;
|
|
@@ -80,11 +78,5 @@ StyledTooltipPointer.defaultProps = {
|
|
|
80
78
|
theme: _base.default,
|
|
81
79
|
position: "top"
|
|
82
80
|
};
|
|
83
|
-
StyledTooltipPointer.propTypes = {
|
|
84
|
-
position: _propTypes.default.oneOf(["bottom", "left", "right", "top"]),
|
|
85
|
-
theme: _propTypes.default.object,
|
|
86
|
-
type: _propTypes.default.string,
|
|
87
|
-
bgColor: _propTypes.default.string
|
|
88
|
-
};
|
|
89
81
|
var _default = StyledTooltipPointer;
|
|
90
82
|
exports.default = _default;
|
|
@@ -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,158 +1,249 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
4
|
+
value: true,
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
exports.default = exports.Tooltip = void 0;
|
|
9
8
|
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
12
|
var _headless = _interopRequireDefault(require("@tippyjs/react/headless"));
|
|
13
13
|
|
|
14
14
|
var _tippy = require("tippy.js");
|
|
15
15
|
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
var _tooltipPointer = _interopRequireDefault(require("./tooltip-pointer.style"));
|
|
19
|
-
|
|
20
|
-
var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
|
|
21
|
-
|
|
22
|
-
var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
|
+
var _tooltip = _interopRequireDefault(require("./tooltip.style"));
|
|
29
19
|
|
|
30
|
-
|
|
20
|
+
var _tooltipPointer = _interopRequireDefault(
|
|
21
|
+
require("./tooltip-pointer.style")
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
var _tooltip2 = require("./tooltip.config");
|
|
25
|
+
|
|
26
|
+
var _tags = _interopRequireDefault(
|
|
27
|
+
require("../../__internal__/utils/helpers/tags/tags")
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
var _carbonScopedTokensProvider = _interopRequireDefault(
|
|
31
|
+
require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component")
|
|
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
|
+
}
|
|
31
54
|
|
|
32
55
|
const TOOLTIP_DELAY = 100;
|
|
33
56
|
const tippyPlugins = [_tippy.sticky];
|
|
34
57
|
|
|
35
|
-
const Tooltip = /*#__PURE__*/_react.default.forwardRef(
|
|
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
|
-
|
|
58
|
+
const Tooltip = /*#__PURE__*/ _react.default.forwardRef(
|
|
59
|
+
(
|
|
60
|
+
{
|
|
61
|
+
children,
|
|
62
|
+
isVisible,
|
|
63
|
+
position = "top",
|
|
64
|
+
message,
|
|
65
|
+
type,
|
|
66
|
+
size = "medium",
|
|
67
|
+
isPartOfInput,
|
|
68
|
+
inputSize,
|
|
69
|
+
id,
|
|
70
|
+
bgColor,
|
|
71
|
+
fontColor,
|
|
72
|
+
flipOverrides,
|
|
73
|
+
target,
|
|
74
|
+
...rest
|
|
75
|
+
},
|
|
76
|
+
ref
|
|
77
|
+
) => {
|
|
78
|
+
const isFlipOverridesValid =
|
|
79
|
+
!flipOverrides ||
|
|
80
|
+
(Array.isArray(flipOverrides) &&
|
|
81
|
+
flipOverrides.every((placement) =>
|
|
82
|
+
_tooltip2.TOOLTIP_POSITIONS.includes(placement)
|
|
83
|
+
));
|
|
84
|
+
(0, _invariant.default)(
|
|
85
|
+
isFlipOverridesValid,
|
|
86
|
+
`The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const tooltip = (attrs, content) => {
|
|
90
|
+
const currentPosition = attrs["data-placement"] || position;
|
|
91
|
+
return /*#__PURE__*/ _react.default.createElement(
|
|
92
|
+
_carbonScopedTokensProvider.default,
|
|
93
|
+
null,
|
|
94
|
+
/*#__PURE__*/ _react.default.createElement(
|
|
95
|
+
_tooltip.default,
|
|
96
|
+
_extends(
|
|
97
|
+
{
|
|
98
|
+
"data-element": "tooltip",
|
|
99
|
+
role: "tooltip",
|
|
100
|
+
tabIndex: -1,
|
|
101
|
+
type: type,
|
|
102
|
+
size: size,
|
|
103
|
+
id: id,
|
|
104
|
+
},
|
|
105
|
+
(0, _tags.default)("tooltip", rest),
|
|
106
|
+
{
|
|
107
|
+
isPartOfInput: isPartOfInput,
|
|
108
|
+
inputSize: inputSize,
|
|
109
|
+
},
|
|
110
|
+
attrs,
|
|
111
|
+
{
|
|
112
|
+
position: currentPosition,
|
|
113
|
+
ref: ref,
|
|
114
|
+
bgColor: bgColor,
|
|
115
|
+
fontColor: fontColor,
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/*#__PURE__*/ _react.default.createElement(
|
|
119
|
+
_tooltipPointer.default,
|
|
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
|
+
},
|
|
101
174
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
175
|
+
),
|
|
176
|
+
children
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
);
|
|
106
180
|
|
|
107
|
-
const placements = ["top", "bottom", "left", "right"];
|
|
108
181
|
Tooltip.propTypes = {
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
/** The id attribute to use for the tooltip */
|
|
113
|
-
id: _propTypes.default.string,
|
|
114
|
-
|
|
115
|
-
/** Whether to to show the Tooltip */
|
|
116
|
-
isVisible: _propTypes.default.bool,
|
|
117
|
-
|
|
118
|
-
/** Sets position of the tooltip */
|
|
119
|
-
position: _propTypes.default.oneOf(placements),
|
|
120
|
-
|
|
121
|
-
/** Defines the message type */
|
|
122
|
-
type: _propTypes.default.string,
|
|
123
|
-
|
|
124
|
-
/** Children elements */
|
|
125
|
-
children: _propTypes.default.node.isRequired,
|
|
126
|
-
|
|
127
|
-
/** Defines the size of the tooltip content */
|
|
128
|
-
size: _propTypes.default.oneOf(["medium", "large"]),
|
|
129
|
-
// Reference element, tooltip will be positioned in relation to this element
|
|
130
|
-
target: _propTypes.default.instanceOf(Element),
|
|
131
|
-
|
|
132
|
-
/** Override background color of the Tooltip, provide design token, any color from palette or any valid css color value. */
|
|
182
|
+
/**
|
|
183
|
+
* Override background color of the Tooltip, provide any color from palette or any valid css color value.
|
|
184
|
+
*/
|
|
133
185
|
bgColor: _propTypes.default.string,
|
|
134
|
-
|
|
135
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Children elements
|
|
188
|
+
*/
|
|
189
|
+
children: _propTypes.default.element.isRequired,
|
|
190
|
+
/**
|
|
191
|
+
* Overrides the default flip behaviour of the Tooltip,
|
|
192
|
+
* must be an array containing some or all of ["top", "bottom", "left", "right"]
|
|
193
|
+
* (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements)
|
|
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
|
+
*/
|
|
136
201
|
fontColor: _propTypes.default.string,
|
|
137
|
-
|
|
138
|
-
|
|
202
|
+
/**
|
|
203
|
+
* The id attribute to use for the tooltip
|
|
204
|
+
*/
|
|
205
|
+
id: _propTypes.default.string,
|
|
206
|
+
inputSize: _propTypes.default.oneOf(["large", "medium", "small"]),
|
|
139
207
|
isPartOfInput: _propTypes.default.bool,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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) {
|
|
229
|
+
if (props[propName] == null) {
|
|
150
230
|
return null;
|
|
231
|
+
} else if (
|
|
232
|
+
typeof props[propName] !== "object" ||
|
|
233
|
+
props[propName].nodeType !== 1
|
|
234
|
+
) {
|
|
235
|
+
return new Error(
|
|
236
|
+
"Expected prop '" + propName + "' to be of type Element"
|
|
237
|
+
);
|
|
151
238
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
239
|
+
},
|
|
240
|
+
/**
|
|
241
|
+
* Defines the message type
|
|
242
|
+
*/
|
|
243
|
+
type: _propTypes.default.string,
|
|
156
244
|
};
|
|
245
|
+
|
|
246
|
+
exports.Tooltip = Tooltip;
|
|
247
|
+
Tooltip.displayName = "Tooltip";
|
|
157
248
|
var _default = Tooltip;
|
|
158
|
-
exports.default = _default;
|
|
249
|
+
exports.default = _default;
|
|
@@ -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;
|
|
@@ -7,8 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
13
11
|
|
|
14
12
|
var _color = require("../../style/utils/color");
|
|
@@ -29,7 +27,7 @@ const fadeIn = (0, _styledComponents.keyframes)`
|
|
|
29
27
|
}
|
|
30
28
|
`;
|
|
31
29
|
|
|
32
|
-
const tooltipColor = (
|
|
30
|
+
const tooltipColor = (theme, bgColor, type) => {
|
|
33
31
|
if (bgColor) return (0, _color.toColor)(theme, bgColor);
|
|
34
32
|
return type === "error" ? "var(--colorsSemanticNegative500)" : "var(--colorsSemanticNeutral500)";
|
|
35
33
|
};
|
|
@@ -68,14 +66,14 @@ const tooltipOffset = (position, inputSize, isPartOfInput) => {
|
|
|
68
66
|
}
|
|
69
67
|
};
|
|
70
68
|
|
|
71
|
-
const
|
|
69
|
+
const StyledTooltip = _styledComponents.default.div`
|
|
72
70
|
${({
|
|
73
71
|
position,
|
|
74
72
|
size,
|
|
75
73
|
theme,
|
|
76
74
|
type,
|
|
77
75
|
isPartOfInput,
|
|
78
|
-
inputSize,
|
|
76
|
+
inputSize = "medium",
|
|
79
77
|
bgColor,
|
|
80
78
|
fontColor
|
|
81
79
|
}) => (0, _styledComponents.css)`
|
|
@@ -94,25 +92,12 @@ const StyledTooltipWrapper = _styledComponents.default.div`
|
|
|
94
92
|
font-size: ${size === "medium" ? "14px" : "16px"};
|
|
95
93
|
line-height: 1.5rem;
|
|
96
94
|
font-weight: 400;
|
|
97
|
-
background-color: ${tooltipColor(
|
|
95
|
+
background-color: ${tooltipColor(theme, bgColor, type)};
|
|
98
96
|
${tooltipOffset(position, inputSize, isPartOfInput)};
|
|
99
97
|
`}
|
|
100
98
|
`;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
size: _propTypes.default.oneOf(["medium", "large"]),
|
|
104
|
-
theme: _propTypes.default.object,
|
|
105
|
-
type: _propTypes.default.string,
|
|
106
|
-
isPartOfInput: _propTypes.default.bool,
|
|
107
|
-
inputSize: _propTypes.default.oneOf(["small", "medium", "large"]),
|
|
108
|
-
bgColor: _propTypes.default.string,
|
|
109
|
-
fontColor: _propTypes.default.string
|
|
110
|
-
};
|
|
111
|
-
StyledTooltipWrapper.defaultProps = {
|
|
112
|
-
theme: _base.default,
|
|
113
|
-
size: "medium",
|
|
114
|
-
inputSize: "medium",
|
|
115
|
-
position: "top"
|
|
99
|
+
StyledTooltip.defaultProps = {
|
|
100
|
+
theme: _base.default
|
|
116
101
|
};
|
|
117
|
-
var _default =
|
|
102
|
+
var _default = StyledTooltip;
|
|
118
103
|
exports.default = _default;
|
|
@@ -12,4 +12,4 @@ declare const Typography: import("styled-components").StyledComponent<"span", an
|
|
|
12
12
|
color: any;
|
|
13
13
|
bg: any;
|
|
14
14
|
backgroundColor: any;
|
|
15
|
-
}, "as" | "
|
|
15
|
+
}, "as" | "textDecoration" | "size" | "lineHeight" | "textTransform" | "weight" | "defaultMargin">;
|
|
@@ -12,6 +12,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
12
12
|
var _menu = require("../menu/menu.component");
|
|
13
13
|
|
|
14
14
|
var _verticalDivider = require("./vertical-divider.style");
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
function _getRequireWildcardCache() {
|
|
17
20
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export default useCharacterCount;
|
|
2
|
-
declare function useCharacterCount(value: any, characterLimit: any, warnOverLimit?: boolean, enforceCharacterLimit?: boolean): any[];
|
|
1
|
+
export { default } from "./useCharacterCount";
|
|
@@ -3,32 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _useLocale = _interopRequireDefault(require("../useLocale"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useCharacterCount.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
const l = (0, _useLocale.default)();
|
|
24
|
-
const isOverLimit = (0, _react.useMemo)(() => value && value.length > parseInt(characterLimit, 10), [value, characterLimit]);
|
|
25
|
-
return [enforceCharacterLimit && characterLimit ? characterLimit : undefined, characterLimit ? /*#__PURE__*/_react.default.createElement(_characterCount.default, {
|
|
26
|
-
isOverLimit: isOverLimit && warnOverLimit,
|
|
27
|
-
value: getFormatNumber(value.length, l.locale()),
|
|
28
|
-
limit: getFormatNumber(characterLimit, l.locale()),
|
|
29
|
-
"data-element": "character-limit"
|
|
30
|
-
}) : null];
|
|
31
|
-
};
|
|
13
|
+
var _useCharacterCount = _interopRequireDefault(require("./useCharacterCount"));
|
|
32
14
|
|
|
33
|
-
|
|
34
|
-
exports.default = _default;
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|