glints-aries 4.0.140 → 4.0.141
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/es/Display/Tooltip/Tooltip.d.ts +11 -6
- package/es/Display/Tooltip/Tooltip.js +5 -2
- package/es/Display/Tooltip/Tooltip.stories.d.ts +1 -0
- package/es/Display/Tooltip/Tooltip.stories.js +17 -3
- package/lib/Display/Tooltip/Tooltip.d.ts +11 -6
- package/lib/Display/Tooltip/Tooltip.js +5 -2
- package/lib/Display/Tooltip/Tooltip.stories.d.ts +1 -0
- package/lib/Display/Tooltip/Tooltip.stories.js +18 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTMLAttributes, FC } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, FC } from 'react';
|
|
2
2
|
export declare const Tooltip: FC<Props>;
|
|
3
3
|
export interface Classes {
|
|
4
4
|
container?: string;
|
|
@@ -6,12 +6,17 @@ export interface Classes {
|
|
|
6
6
|
message?: string;
|
|
7
7
|
}
|
|
8
8
|
export declare type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
9
|
-
|
|
10
|
-
/** This is an object with three keys: <code>container</code>,
|
|
11
|
-
* <code>content</code> and <code>message</code>. Use them to attach
|
|
12
|
-
* additional classes to the respective elements. */
|
|
9
|
+
interface BaseProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
13
10
|
classes?: Classes;
|
|
14
|
-
text: string;
|
|
15
11
|
position?: Position;
|
|
16
12
|
}
|
|
13
|
+
export interface StringTooltip extends BaseProps {
|
|
14
|
+
text: string;
|
|
15
|
+
textAsString?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface HtmlTooltip extends BaseProps {
|
|
18
|
+
text: React.ReactNode;
|
|
19
|
+
textAsString: string;
|
|
20
|
+
}
|
|
21
|
+
export declare type Props = StringTooltip | HtmlTooltip;
|
|
17
22
|
export default Tooltip;
|
|
@@ -8,9 +8,10 @@ export var Tooltip = function Tooltip(_ref) {
|
|
|
8
8
|
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
9
9
|
children = _ref.children,
|
|
10
10
|
text = _ref.text,
|
|
11
|
+
textAsString = _ref.textAsString,
|
|
11
12
|
_ref$position = _ref.position,
|
|
12
13
|
position = _ref$position === void 0 ? 'top' : _ref$position,
|
|
13
|
-
defaultProps = _objectWithoutPropertiesLoose(_ref, ["classes", "children", "text", "position"]);
|
|
14
|
+
defaultProps = _objectWithoutPropertiesLoose(_ref, ["classes", "children", "text", "textAsString", "position"]);
|
|
14
15
|
|
|
15
16
|
var contentRef = useRef(null);
|
|
16
17
|
|
|
@@ -42,11 +43,12 @@ export var Tooltip = function Tooltip(_ref) {
|
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
|
|
46
|
+
var arialLabel = typeof text === 'string' ? text : textAsString;
|
|
45
47
|
return /*#__PURE__*/React.createElement(TooltipContainer, _extends({
|
|
46
48
|
className: classNames('aries-tooltip', classes.container),
|
|
47
49
|
role: "tooltip",
|
|
48
50
|
"aria-hidden": isShow ? 'false' : 'true',
|
|
49
|
-
"aria-label":
|
|
51
|
+
"aria-label": arialLabel // The tooltip does not close on iOS devices because of this issue https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event#Safari_Mobile
|
|
50
52
|
// Adding onTouchStart and onTouchEnd as a workaround
|
|
51
53
|
// On mobile, it shows the tooltip on touch and hides the tooltip when the touch is released
|
|
52
54
|
,
|
|
@@ -57,6 +59,7 @@ export var Tooltip = function Tooltip(_ref) {
|
|
|
57
59
|
ref: contentRef,
|
|
58
60
|
className: classNames('aries-tooltip-content', classes.content),
|
|
59
61
|
text: text,
|
|
62
|
+
textAsString: textAsString,
|
|
60
63
|
position: position
|
|
61
64
|
}, /*#__PURE__*/React.createElement(TooltipMessage, {
|
|
62
65
|
className: classNames('aries-tooltip-message', classes.message)
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
}]
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var StringTooltipTemplate = function StringTooltipTemplate(_ref) {
|
|
22
22
|
var text = _ref.text,
|
|
23
23
|
args = _objectWithoutPropertiesLoose(_ref, ["text"]);
|
|
24
24
|
|
|
@@ -27,12 +27,26 @@ var Template = function Template(_ref) {
|
|
|
27
27
|
}), /*#__PURE__*/React.createElement(Tag, null, "Glints Aries"));
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
var HtmlTooltipTemplate = function HtmlTooltipTemplate(_ref2) {
|
|
31
|
+
var text = _ref2.text,
|
|
32
|
+
args = _objectWithoutPropertiesLoose(_ref2, ["text"]);
|
|
33
|
+
|
|
34
|
+
return /*#__PURE__*/React.createElement(Tooltip, _extends({}, args, {
|
|
35
|
+
text: text || defaultText
|
|
36
|
+
}), /*#__PURE__*/React.createElement(Tag, null, "Glints Aries"));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export var Interactive = StringTooltipTemplate.bind({});
|
|
31
40
|
Interactive.args = {
|
|
32
41
|
text: defaultText,
|
|
33
42
|
position: 'top'
|
|
34
43
|
};
|
|
35
|
-
export var DifferentPosition =
|
|
44
|
+
export var DifferentPosition = StringTooltipTemplate.bind({});
|
|
36
45
|
DifferentPosition.args = {
|
|
37
46
|
position: 'left'
|
|
47
|
+
};
|
|
48
|
+
export var WithHtmlContent = HtmlTooltipTemplate.bind({});
|
|
49
|
+
WithHtmlContent.args = {
|
|
50
|
+
text: /*#__PURE__*/React.createElement("b", null, "Hello World"),
|
|
51
|
+
textAsString: 'Hello World'
|
|
38
52
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTMLAttributes, FC } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, FC } from 'react';
|
|
2
2
|
export declare const Tooltip: FC<Props>;
|
|
3
3
|
export interface Classes {
|
|
4
4
|
container?: string;
|
|
@@ -6,12 +6,17 @@ export interface Classes {
|
|
|
6
6
|
message?: string;
|
|
7
7
|
}
|
|
8
8
|
export declare type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
9
|
-
|
|
10
|
-
/** This is an object with three keys: <code>container</code>,
|
|
11
|
-
* <code>content</code> and <code>message</code>. Use them to attach
|
|
12
|
-
* additional classes to the respective elements. */
|
|
9
|
+
interface BaseProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
13
10
|
classes?: Classes;
|
|
14
|
-
text: string;
|
|
15
11
|
position?: Position;
|
|
16
12
|
}
|
|
13
|
+
export interface StringTooltip extends BaseProps {
|
|
14
|
+
text: string;
|
|
15
|
+
textAsString?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface HtmlTooltip extends BaseProps {
|
|
18
|
+
text: React.ReactNode;
|
|
19
|
+
textAsString: string;
|
|
20
|
+
}
|
|
21
|
+
export declare type Props = StringTooltip | HtmlTooltip;
|
|
17
22
|
export default Tooltip;
|
|
@@ -22,9 +22,10 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
22
22
|
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
23
23
|
children = _ref.children,
|
|
24
24
|
text = _ref.text,
|
|
25
|
+
textAsString = _ref.textAsString,
|
|
25
26
|
_ref$position = _ref.position,
|
|
26
27
|
position = _ref$position === void 0 ? 'top' : _ref$position,
|
|
27
|
-
defaultProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, ["classes", "children", "text", "position"]);
|
|
28
|
+
defaultProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, ["classes", "children", "text", "textAsString", "position"]);
|
|
28
29
|
var contentRef = (0, _react.useRef)(null);
|
|
29
30
|
|
|
30
31
|
var _useState = (0, _react.useState)(false),
|
|
@@ -55,11 +56,12 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
58
|
|
|
59
|
+
var arialLabel = typeof text === 'string' ? text : textAsString;
|
|
58
60
|
return /*#__PURE__*/_react["default"].createElement(_TooltipStyle.TooltipContainer, (0, _extends2["default"])({
|
|
59
61
|
className: (0, _classnames["default"])('aries-tooltip', classes.container),
|
|
60
62
|
role: "tooltip",
|
|
61
63
|
"aria-hidden": isShow ? 'false' : 'true',
|
|
62
|
-
"aria-label":
|
|
64
|
+
"aria-label": arialLabel // The tooltip does not close on iOS devices because of this issue https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event#Safari_Mobile
|
|
63
65
|
// Adding onTouchStart and onTouchEnd as a workaround
|
|
64
66
|
// On mobile, it shows the tooltip on touch and hides the tooltip when the touch is released
|
|
65
67
|
,
|
|
@@ -70,6 +72,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
70
72
|
ref: contentRef,
|
|
71
73
|
className: (0, _classnames["default"])('aries-tooltip-content', classes.content),
|
|
72
74
|
text: text,
|
|
75
|
+
textAsString: textAsString,
|
|
73
76
|
position: position
|
|
74
77
|
}, /*#__PURE__*/_react["default"].createElement(_TooltipStyle.TooltipMessage, {
|
|
75
78
|
className: (0, _classnames["default"])('aries-tooltip-message', classes.message)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports.DifferentPosition = exports.Interactive = exports["default"] = void 0;
|
|
6
|
+
exports.WithHtmlContent = exports.DifferentPosition = exports.Interactive = exports["default"] = void 0;
|
|
7
7
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
|
|
@@ -33,7 +33,7 @@ var _default = {
|
|
|
33
33
|
};
|
|
34
34
|
exports["default"] = _default;
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var StringTooltipTemplate = function StringTooltipTemplate(_ref) {
|
|
37
37
|
var text = _ref.text,
|
|
38
38
|
args = (0, _objectWithoutPropertiesLoose2["default"])(_ref, ["text"]);
|
|
39
39
|
return /*#__PURE__*/_react["default"].createElement(_Tooltip.Tooltip, (0, _extends2["default"])({}, args, {
|
|
@@ -41,14 +41,28 @@ var Template = function Template(_ref) {
|
|
|
41
41
|
}), /*#__PURE__*/_react["default"].createElement(_BasicTag["default"], null, "Glints Aries"));
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
var
|
|
44
|
+
var HtmlTooltipTemplate = function HtmlTooltipTemplate(_ref2) {
|
|
45
|
+
var text = _ref2.text,
|
|
46
|
+
args = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, ["text"]);
|
|
47
|
+
return /*#__PURE__*/_react["default"].createElement(_Tooltip.Tooltip, (0, _extends2["default"])({}, args, {
|
|
48
|
+
text: text || defaultText
|
|
49
|
+
}), /*#__PURE__*/_react["default"].createElement(_BasicTag["default"], null, "Glints Aries"));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var Interactive = StringTooltipTemplate.bind({});
|
|
45
53
|
exports.Interactive = Interactive;
|
|
46
54
|
Interactive.args = {
|
|
47
55
|
text: defaultText,
|
|
48
56
|
position: 'top'
|
|
49
57
|
};
|
|
50
|
-
var DifferentPosition =
|
|
58
|
+
var DifferentPosition = StringTooltipTemplate.bind({});
|
|
51
59
|
exports.DifferentPosition = DifferentPosition;
|
|
52
60
|
DifferentPosition.args = {
|
|
53
61
|
position: 'left'
|
|
62
|
+
};
|
|
63
|
+
var WithHtmlContent = HtmlTooltipTemplate.bind({});
|
|
64
|
+
exports.WithHtmlContent = WithHtmlContent;
|
|
65
|
+
WithHtmlContent.args = {
|
|
66
|
+
text: /*#__PURE__*/_react["default"].createElement("b", null, "Hello World"),
|
|
67
|
+
textAsString: 'Hello World'
|
|
54
68
|
};
|