@pedidopago/ui 1.3.0 → 1.3.3
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/dist/components/Alert/alert.test.js +8 -8
- package/dist/components/Alert/index.d.ts +2 -2
- package/dist/components/Alert/index.d.ts.map +1 -1
- package/dist/components/Alert/index.js +7 -26
- package/dist/components/Alert/styles.d.ts +0 -12
- package/dist/components/Alert/styles.d.ts.map +1 -1
- package/dist/components/Alert/styles.js +4 -22
- package/dist/components/Alert/types.d.ts +5 -22
- package/dist/components/Alert/types.d.ts.map +1 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +11 -2
- package/dist/components/Button/styles.js +1 -1
- package/dist/components/Button/types.d.ts +1 -0
- package/dist/components/Button/types.d.ts.map +1 -1
- package/dist/components/DateInput/DateInput-example.d.ts +2 -2
- package/dist/components/DateInput/DateInput-example.d.ts.map +1 -1
- package/dist/components/DateInput/DateInput-example.js +10 -15
- package/dist/components/DateInput/dateInput.test.js +4 -4
- package/dist/components/DateInput/index.d.ts +2 -2
- package/dist/components/DateInput/index.d.ts.map +1 -1
- package/dist/components/DateInput/index.js +65 -136
- package/dist/components/DateInput/styles.d.ts +7 -29
- package/dist/components/DateInput/styles.d.ts.map +1 -1
- package/dist/components/DateInput/styles.js +15 -19
- package/dist/components/DateInput/types.d.ts +7 -14
- package/dist/components/DateInput/types.d.ts.map +1 -1
- package/dist/components/DatePicker/datepicker.test.js +8 -8
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +4 -8
- package/dist/components/DatePicker/types.d.ts +3 -4
- package/dist/components/DatePicker/types.d.ts.map +1 -1
- package/dist/components/Input/index.js +14 -15
- package/dist/components/Input/styles.d.ts +1 -0
- package/dist/components/Input/styles.d.ts.map +1 -1
- package/dist/components/Input/styles.js +39 -34
- package/dist/components/Label/index.d.ts +2 -2
- package/dist/components/Label/index.d.ts.map +1 -1
- package/dist/components/Label/index.js +12 -23
- package/dist/components/Label/label.test.d.ts +2 -0
- package/dist/components/Label/label.test.d.ts.map +1 -0
- package/dist/components/Label/label.test.js +105 -0
- package/dist/components/Label/styles.js +1 -1
- package/dist/components/Label/types.d.ts +5 -6
- package/dist/components/Label/types.d.ts.map +1 -1
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/Modal/styles.d.ts.map +1 -1
- package/dist/components/Modal/styles.js +3 -3
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +21 -15
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js +13 -3
- package/dist/components/Table/styles.d.ts.map +1 -1
- package/dist/components/Table/styles.js +5 -8
- package/dist/components/Toast/components/Toast.d.ts.map +1 -1
- package/dist/components/Toast/components/Toast.js +6 -7
- package/dist/components/Toast/contexts/ToastProvider.d.ts.map +1 -1
- package/dist/components/Toast/contexts/ToastProvider.js +3 -1
- package/dist/components/Toast/toast.test.js +10 -10
- package/dist/components/Toast/types.d.ts +8 -15
- package/dist/components/Toast/types.d.ts.map +1 -1
- package/dist/components/Tooltip/components/TooltipLabel.d.ts +4 -0
- package/dist/components/Tooltip/components/TooltipLabel.d.ts.map +1 -0
- package/dist/components/Tooltip/components/TooltipLabel.js +59 -0
- package/dist/components/Tooltip/index.d.ts +2 -2
- package/dist/components/Tooltip/index.d.ts.map +1 -1
- package/dist/components/Tooltip/index.js +91 -74
- package/dist/components/Tooltip/styles.d.ts +6 -14
- package/dist/components/Tooltip/styles.d.ts.map +1 -1
- package/dist/components/Tooltip/styles.js +9 -31
- package/dist/components/Tooltip/types.d.ts +17 -19
- package/dist/components/Tooltip/types.d.ts.map +1 -1
- package/dist/components/Typography/styles.d.ts +2 -2
- package/package.json +1 -1
|
@@ -23,12 +23,12 @@ var Toast = function Toast(_ref) {
|
|
|
23
23
|
var type = _ref.type,
|
|
24
24
|
close = _ref.close,
|
|
25
25
|
duration = _ref.duration,
|
|
26
|
-
|
|
26
|
+
content = _ref.content,
|
|
27
|
+
icon = _ref.icon,
|
|
27
28
|
id = _ref.toastId,
|
|
28
|
-
buttonTitle = _ref.buttonTitle,
|
|
29
|
-
onButtonClick = _ref.onButtonClick,
|
|
30
29
|
title = _ref.title,
|
|
31
|
-
position = _ref.position
|
|
30
|
+
_ref$position = _ref.position,
|
|
31
|
+
position = _ref$position === void 0 ? 'top-right' : _ref$position;
|
|
32
32
|
(0, _react.useEffect)(function () {
|
|
33
33
|
var timer = setTimeout(function () {
|
|
34
34
|
close(id);
|
|
@@ -73,12 +73,11 @@ var Toast = function Toast(_ref) {
|
|
|
73
73
|
className: "pp-toast-".concat(position),
|
|
74
74
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.StyledToastComponent, {
|
|
75
75
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
76
|
-
|
|
76
|
+
content: content,
|
|
77
77
|
title: title,
|
|
78
|
+
icon: icon,
|
|
78
79
|
variant: "closable",
|
|
79
80
|
type: type,
|
|
80
|
-
buttonTitle: buttonTitle,
|
|
81
|
-
onButtonClick: onButtonClick,
|
|
82
81
|
onClose: handleCloseButtonClick
|
|
83
82
|
})
|
|
84
83
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/Toast/contexts/ToastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,EAAE,EAAyB,MAAM,OAAO,CAAC;AAGjE,OAAO,EAA4B,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAExE,eAAO,MAAM,YAAY,6CAA0C,CAAC;AAEpE,QAAA,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/Toast/contexts/ToastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,EAAE,EAAyB,MAAM,OAAO,CAAC;AAGjE,OAAO,EAA4B,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAExE,eAAO,MAAM,YAAY,6CAA0C,CAAC;AAEpE,QAAA,MAAM,aAAa,EAAE,EAmCpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -53,9 +53,11 @@ var ToastProvider = function ToastProvider(_ref) {
|
|
|
53
53
|
var addToast = function addToast(options) {
|
|
54
54
|
var toastOptions = {
|
|
55
55
|
config: _objectSpread(_objectSpread({}, options), {}, {
|
|
56
|
+
icon: options.icon || 'info',
|
|
56
57
|
duration: options.duration || 5000,
|
|
57
58
|
type: options.type || 'default',
|
|
58
|
-
position: options.position || 'bottom'
|
|
59
|
+
position: options.position || 'bottom',
|
|
60
|
+
onClose: options.onClose || undefined
|
|
59
61
|
}),
|
|
60
62
|
id: Math.random().toString(36).substring(2, 9)
|
|
61
63
|
};
|
|
@@ -28,7 +28,7 @@ describe('Toast', function () {
|
|
|
28
28
|
it('should it render the toast on the screen', function () {
|
|
29
29
|
var container = setup({
|
|
30
30
|
title: 'Toast Title',
|
|
31
|
-
|
|
31
|
+
content: 'Toast Message',
|
|
32
32
|
type: 'success'
|
|
33
33
|
});
|
|
34
34
|
container.getByText('Show toast').click();
|
|
@@ -37,7 +37,7 @@ describe('Toast', function () {
|
|
|
37
37
|
it('should it render the toast on position top of the screen', function () {
|
|
38
38
|
var container = setup({
|
|
39
39
|
title: 'Toast Title',
|
|
40
|
-
|
|
40
|
+
content: 'Toast Message',
|
|
41
41
|
type: 'success',
|
|
42
42
|
position: 'top'
|
|
43
43
|
});
|
|
@@ -47,7 +47,7 @@ describe('Toast', function () {
|
|
|
47
47
|
it('should it render the toast on position top-left of the screen', function () {
|
|
48
48
|
var container = setup({
|
|
49
49
|
title: 'Toast Title',
|
|
50
|
-
|
|
50
|
+
content: 'Toast Message',
|
|
51
51
|
type: 'success',
|
|
52
52
|
position: 'top-left'
|
|
53
53
|
});
|
|
@@ -57,7 +57,7 @@ describe('Toast', function () {
|
|
|
57
57
|
it('should it render the toast on position top-right of the screen', function () {
|
|
58
58
|
var container = setup({
|
|
59
59
|
title: 'Toast Title',
|
|
60
|
-
|
|
60
|
+
content: 'Toast Message',
|
|
61
61
|
type: 'success',
|
|
62
62
|
position: 'top-right'
|
|
63
63
|
});
|
|
@@ -67,7 +67,7 @@ describe('Toast', function () {
|
|
|
67
67
|
it('should it render the toast on position bottom of the screen', function () {
|
|
68
68
|
var container = setup({
|
|
69
69
|
title: 'Toast Title',
|
|
70
|
-
|
|
70
|
+
content: 'Toast Message',
|
|
71
71
|
type: 'success',
|
|
72
72
|
position: 'bottom'
|
|
73
73
|
});
|
|
@@ -77,7 +77,7 @@ describe('Toast', function () {
|
|
|
77
77
|
it('should it render the toast on position bottom-left of the screen', function () {
|
|
78
78
|
var container = setup({
|
|
79
79
|
title: 'Toast Title',
|
|
80
|
-
|
|
80
|
+
content: 'Toast Message',
|
|
81
81
|
type: 'success',
|
|
82
82
|
position: 'bottom-left'
|
|
83
83
|
});
|
|
@@ -87,7 +87,7 @@ describe('Toast', function () {
|
|
|
87
87
|
it('should it render the toast on position bottom-right of the screen', function () {
|
|
88
88
|
var container = setup({
|
|
89
89
|
title: 'Toast Title',
|
|
90
|
-
|
|
90
|
+
content: 'Toast Message',
|
|
91
91
|
type: 'success',
|
|
92
92
|
position: 'bottom-right'
|
|
93
93
|
});
|
|
@@ -99,7 +99,7 @@ describe('Toast', function () {
|
|
|
99
99
|
|
|
100
100
|
var container = setup({
|
|
101
101
|
title: 'Toast Title',
|
|
102
|
-
|
|
102
|
+
content: 'Toast Message',
|
|
103
103
|
type: 'success'
|
|
104
104
|
});
|
|
105
105
|
container.getByText('Show toast').click();
|
|
@@ -114,7 +114,7 @@ describe('Toast', function () {
|
|
|
114
114
|
var onClose = jest.fn();
|
|
115
115
|
var container = setup({
|
|
116
116
|
title: 'Toast Title',
|
|
117
|
-
|
|
117
|
+
content: 'Toast Message',
|
|
118
118
|
type: 'success',
|
|
119
119
|
onClose: onClose
|
|
120
120
|
});
|
|
@@ -128,7 +128,7 @@ describe('Toast', function () {
|
|
|
128
128
|
var onClose = jest.fn();
|
|
129
129
|
var container = setup({
|
|
130
130
|
title: 'Toast Title',
|
|
131
|
-
|
|
131
|
+
content: 'Toast Message',
|
|
132
132
|
type: 'success',
|
|
133
133
|
onClose: onClose
|
|
134
134
|
});
|
|
@@ -1,28 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { IconName } from '../Icon/types';
|
|
1
3
|
export declare type IToastConfig = {
|
|
2
4
|
title: string;
|
|
3
|
-
|
|
5
|
+
content: ReactNode;
|
|
4
6
|
position?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right';
|
|
5
7
|
type?: 'default' | 'success' | 'warning' | 'error' | 'critical';
|
|
6
|
-
buttonTitle?: string;
|
|
7
|
-
onButtonClick?: () => void;
|
|
8
8
|
duration?: number;
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export declare type IToastConfigOnList = {
|
|
12
|
-
title: string;
|
|
13
|
-
message: string;
|
|
14
|
-
position: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right';
|
|
15
|
-
type: 'default' | 'success' | 'warning' | 'error' | 'critical';
|
|
16
|
-
buttonTitle?: string;
|
|
17
|
-
onButtonClick?: () => void;
|
|
18
|
-
duration: number;
|
|
9
|
+
icon?: IconName;
|
|
19
10
|
onClose?: (id: string) => void;
|
|
20
11
|
};
|
|
21
12
|
export declare type IToastList = {
|
|
22
13
|
id: string;
|
|
23
|
-
config:
|
|
14
|
+
config: Required<Omit<IToastConfig, 'onClose'>> & {
|
|
15
|
+
onClose?: (id: string) => void;
|
|
16
|
+
};
|
|
24
17
|
};
|
|
25
|
-
export declare type Toast =
|
|
18
|
+
export declare type Toast = IToastConfig & {
|
|
26
19
|
toastId: string;
|
|
27
20
|
close: (id: string) => void;
|
|
28
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Toast/types.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Toast/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,oBAAY,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,aAAa,GAAG,cAAc,CAAC;IACxF,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,GAAG;QAChD,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,oBAAY,KAAK,GAAG,YAAY,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B,GAAG,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IACrC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TooltipLabel.d.ts","sourceRoot":"","sources":["../../../../src/components/Tooltip/components/TooltipLabel.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,wBAAgB,YAAY,CAAC,EAC3B,gBAAgB,EAChB,uBAAuB,EACvB,iBAAuB,EACvB,GAAG,IAAI,EACR,EAAE,iBAAiB,eAgCnB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TooltipLabel = TooltipLabel;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _styles = require("../styles");
|
|
11
|
+
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
|
|
14
|
+
var _excluded = ["tooltipPositions", "handleRepositionTooltip", "animationDuration"];
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
|
|
20
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
|
|
22
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
23
|
+
|
|
24
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
25
|
+
|
|
26
|
+
function TooltipLabel(_ref) {
|
|
27
|
+
var tooltipPositions = _ref.tooltipPositions,
|
|
28
|
+
handleRepositionTooltip = _ref.handleRepositionTooltip,
|
|
29
|
+
_ref$animationDuratio = _ref.animationDuration,
|
|
30
|
+
animationDuration = _ref$animationDuratio === void 0 ? 0.2 : _ref$animationDuratio,
|
|
31
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
|
|
33
|
+
var labelRef = (0, _react.useRef)(null);
|
|
34
|
+
var animations = {
|
|
35
|
+
enter: {
|
|
36
|
+
opacity: 1
|
|
37
|
+
},
|
|
38
|
+
exit: {
|
|
39
|
+
opacity: 0
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
(0, _react.useEffect)(function () {
|
|
43
|
+
if (labelRef.current) {
|
|
44
|
+
handleRepositionTooltip(labelRef.current);
|
|
45
|
+
}
|
|
46
|
+
}, []);
|
|
47
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.StyledTooltipLabel, _objectSpread(_objectSpread({
|
|
48
|
+
ref: labelRef,
|
|
49
|
+
initial: animations.exit,
|
|
50
|
+
animate: animations.enter,
|
|
51
|
+
exit: animations.exit,
|
|
52
|
+
transition: {
|
|
53
|
+
duration: animationDuration
|
|
54
|
+
},
|
|
55
|
+
style: tooltipPositions
|
|
56
|
+
}, rest), {}, {
|
|
57
|
+
children: rest.label
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAoB,MAAM,OAAO,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,QAAA,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAuF7B,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -5,13 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _framerMotion = require("framer-motion");
|
|
9
|
+
|
|
8
10
|
var _react = require("react");
|
|
9
11
|
|
|
12
|
+
var _TooltipLabel = require("./components/TooltipLabel");
|
|
13
|
+
|
|
10
14
|
var _styles = require("./styles");
|
|
11
15
|
|
|
12
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
17
|
|
|
14
|
-
var _excluded = ["position", "
|
|
18
|
+
var _excluded = ["position", "offset"];
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
+
|
|
24
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
25
|
|
|
16
26
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
27
|
|
|
@@ -31,94 +41,101 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
31
41
|
|
|
32
42
|
var Tooltip = function Tooltip(_ref) {
|
|
33
43
|
var _ref$position = _ref.position,
|
|
34
|
-
position = _ref$position === void 0 ? '
|
|
35
|
-
_ref$
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
labelColor = _ref.labelColor,
|
|
39
|
-
_ref$animationDuratio = _ref.animationDuration,
|
|
40
|
-
animationDuration = _ref$animationDuratio === void 0 ? 0.2 : _ref$animationDuratio,
|
|
41
|
-
backgroundColor = _ref.backgroundColor,
|
|
42
|
-
width = _ref.width,
|
|
43
|
-
children = _ref.children,
|
|
44
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
44
|
+
position = _ref$position === void 0 ? 'bottom' : _ref$position,
|
|
45
|
+
_ref$offset = _ref.offset,
|
|
46
|
+
offset = _ref$offset === void 0 ? 10 : _ref$offset,
|
|
47
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
45
48
|
|
|
46
49
|
var _useState = (0, _react.useState)(false),
|
|
47
50
|
_useState2 = _slicedToArray(_useState, 2),
|
|
48
51
|
showTooltip = _useState2[0],
|
|
49
52
|
setShowTooltip = _useState2[1];
|
|
50
53
|
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
54
|
+
var _useState3 = (0, _react.useState)({
|
|
55
|
+
top: 0,
|
|
56
|
+
left: 0,
|
|
57
|
+
transform: ''
|
|
58
|
+
}),
|
|
59
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
60
|
+
tooltipPositions = _useState4[0],
|
|
61
|
+
setTooltipPositions = _useState4[1];
|
|
62
|
+
|
|
63
|
+
var tooltipContentRef = (0, _react.useRef)(null);
|
|
64
|
+
|
|
65
|
+
function refreshTooltipPosition(newPosition) {
|
|
66
|
+
if (tooltipContentRef.current) {
|
|
67
|
+
var tooltipContentRect = tooltipContentRef.current.getBoundingClientRect();
|
|
68
|
+
|
|
69
|
+
switch (newPosition) {
|
|
70
|
+
case 'top':
|
|
71
|
+
setTooltipPositions({
|
|
72
|
+
top: tooltipContentRect.top - tooltipContentRect.height - offset,
|
|
73
|
+
left: tooltipContentRect.left + tooltipContentRect.width / 2,
|
|
74
|
+
transform: 'translate(-50%, -50%)'
|
|
75
|
+
});
|
|
76
|
+
break;
|
|
77
|
+
|
|
78
|
+
case 'bottom':
|
|
79
|
+
setTooltipPositions({
|
|
80
|
+
top: tooltipContentRect.top + tooltipContentRect.height + offset,
|
|
81
|
+
left: tooltipContentRect.left + tooltipContentRect.width / 2,
|
|
82
|
+
transform: 'translateX(-50%)'
|
|
83
|
+
});
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case 'left':
|
|
87
|
+
setTooltipPositions({
|
|
88
|
+
top: tooltipContentRect.top + tooltipContentRect.height / 2,
|
|
89
|
+
left: tooltipContentRect.left - offset,
|
|
90
|
+
transform: 'translate(-100%, -50%)'
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
case 'right':
|
|
95
|
+
setTooltipPositions({
|
|
96
|
+
top: tooltipContentRect.top + tooltipContentRect.height / 2,
|
|
97
|
+
left: tooltipContentRect.left + tooltipContentRect.width + offset,
|
|
98
|
+
transform: 'translateY(-50%)'
|
|
99
|
+
});
|
|
100
|
+
break;
|
|
76
101
|
}
|
|
77
102
|
}
|
|
78
103
|
}
|
|
79
104
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
105
|
+
function handleRepositionTooltip(element) {
|
|
106
|
+
var elementRect = element.getBoundingClientRect();
|
|
107
|
+
var top = elementRect.top,
|
|
108
|
+
left = elementRect.left,
|
|
109
|
+
width = elementRect.width,
|
|
110
|
+
height = elementRect.height;
|
|
111
|
+
|
|
112
|
+
if (left < 0) {
|
|
113
|
+
refreshTooltipPosition('right');
|
|
114
|
+
} else if (left + width > window.innerWidth) {
|
|
115
|
+
refreshTooltipPosition('left');
|
|
116
|
+
} else if (top < 0) {
|
|
117
|
+
refreshTooltipPosition('bottom');
|
|
118
|
+
} else if (top + height > window.innerHeight) {
|
|
119
|
+
refreshTooltipPosition('top');
|
|
83
120
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
124
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.TooltipWrapper, {
|
|
125
|
+
ref: tooltipContentRef,
|
|
89
126
|
onMouseEnter: function onMouseEnter() {
|
|
90
|
-
|
|
127
|
+
refreshTooltipPosition(position);
|
|
128
|
+
setShowTooltip(true);
|
|
91
129
|
},
|
|
92
130
|
onMouseLeave: function onMouseLeave() {
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
"data-testid": "tooltip-target",
|
|
96
|
-
ref: componentDiv,
|
|
97
|
-
children: children
|
|
98
|
-
}), showTooltip && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.MotionDiv, {
|
|
99
|
-
initial: {
|
|
100
|
-
opacity: 0
|
|
101
|
-
},
|
|
102
|
-
animate: {
|
|
103
|
-
opacity: 1
|
|
104
|
-
},
|
|
105
|
-
exit: {
|
|
106
|
-
opacity: 0
|
|
107
|
-
},
|
|
108
|
-
transition: {
|
|
109
|
-
duration: animationDuration
|
|
131
|
+
setShowTooltip(false);
|
|
110
132
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
maxWidth: maxWidth,
|
|
118
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.TooltipWrapper, {
|
|
119
|
-
labelColor: labelColor,
|
|
120
|
-
children: label
|
|
121
|
-
})
|
|
133
|
+
children: props.children
|
|
134
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_framerMotion.AnimatePresence, {
|
|
135
|
+
children: showTooltip && /*#__PURE__*/(0, _jsxRuntime.jsx)(_TooltipLabel.TooltipLabel, _objectSpread({
|
|
136
|
+
tooltipPositions: tooltipPositions,
|
|
137
|
+
handleRepositionTooltip: handleRepositionTooltip
|
|
138
|
+
}, props))
|
|
122
139
|
})]
|
|
123
140
|
});
|
|
124
141
|
};
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare const
|
|
4
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
5
|
-
as?: import("react").ElementType<any> | undefined;
|
|
6
|
-
} & IStyleProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
7
|
-
export declare const TooltipTarget: import("@emotion/styled").StyledComponent<{
|
|
8
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
9
|
-
as?: import("react").ElementType<any> | undefined;
|
|
10
|
-
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
11
|
-
export declare const MotionDiv: import("@emotion/styled").StyledComponent<{
|
|
2
|
+
import { TooltipProps } from './types';
|
|
3
|
+
export declare const StyledTooltipLabel: import("@emotion/styled").StyledComponent<{
|
|
12
4
|
slot?: string | undefined;
|
|
13
5
|
title?: string | undefined;
|
|
14
6
|
color?: string | undefined;
|
|
15
7
|
translate?: "no" | "yes" | undefined;
|
|
8
|
+
id?: string | undefined;
|
|
16
9
|
hidden?: boolean | undefined;
|
|
17
10
|
className?: string | undefined;
|
|
18
|
-
id?: string | undefined;
|
|
19
11
|
lang?: string | undefined;
|
|
20
12
|
role?: import("react").AriaRole | undefined;
|
|
21
13
|
tabIndex?: number | undefined;
|
|
22
14
|
"aria-activedescendant"?: string | undefined;
|
|
23
15
|
"aria-atomic"?: (boolean | "false" | "true") | undefined;
|
|
24
|
-
"aria-autocomplete"?: "none" | "
|
|
16
|
+
"aria-autocomplete"?: "none" | "list" | "inline" | "both" | undefined;
|
|
25
17
|
"aria-busy"?: (boolean | "false" | "true") | undefined;
|
|
26
18
|
"aria-checked"?: boolean | "mixed" | "false" | "true" | undefined;
|
|
27
19
|
"aria-colcount"?: number | undefined;
|
|
@@ -262,9 +254,9 @@ export declare const MotionDiv: import("@emotion/styled").StyledComponent<{
|
|
|
262
254
|
is?: string | undefined;
|
|
263
255
|
} & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLDivElement> & {
|
|
264
256
|
theme?: import("@emotion/react").Theme | undefined;
|
|
265
|
-
} &
|
|
257
|
+
} & TooltipProps, {}, {}>;
|
|
266
258
|
export declare const TooltipWrapper: import("@emotion/styled").StyledComponent<{
|
|
267
259
|
theme?: import("@emotion/react").Theme | undefined;
|
|
268
260
|
as?: import("react").ElementType<any> | undefined;
|
|
269
|
-
}
|
|
261
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
270
262
|
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/styles.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/styles.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAiB7B,CAAC;AAEH,eAAO,MAAM,cAAc;;;yGAG1B,CAAC"}
|
|
@@ -3,49 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TooltipWrapper = exports.
|
|
6
|
+
exports.TooltipWrapper = exports.StyledTooltipLabel = void 0;
|
|
7
7
|
|
|
8
8
|
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
9
9
|
|
|
10
|
-
var _util = require("./util");
|
|
11
|
-
|
|
12
10
|
var _framerMotion = require("framer-motion");
|
|
13
11
|
|
|
14
|
-
var
|
|
12
|
+
var _getColorValue = require("../../utils/getColorValue");
|
|
15
13
|
|
|
16
|
-
var _templateObject
|
|
14
|
+
var _templateObject;
|
|
17
15
|
|
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
17
|
|
|
20
18
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
21
19
|
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
return
|
|
20
|
+
var StyledTooltipLabel = (0, _styled.default)(_framerMotion.motion.div)(function (props) {
|
|
21
|
+
var parsedBgColor = (0, _getColorValue.getColorValue)(props.bgColor || 'neutral.black', props.theme);
|
|
22
|
+
var parsedLabelColor = (0, _getColorValue.getColorValue)(props.labelColor || 'neutral.white', props.theme);
|
|
23
|
+
return "\n font-family: inherit;\n font-size: ".concat(props.theme.fontSizes.xxs, ";\n font-weight: 400;\n max-width: ", "".concat(props.maxWidth || 260, "px"), ";\n border-radius: 8px;\n padding: 12px;\n color: ").concat(parsedLabelColor, ";\n background-color: ").concat(parsedBgColor, ";\n position: fixed;\n pointer-events: none;\n z-index: ").concat(props.theme.zIndex.level48, ";\n ");
|
|
26
24
|
});
|
|
25
|
+
exports.StyledTooltipLabel = StyledTooltipLabel;
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var TooltipTarget = _styled.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral([""]))); // MOTION.DIV class= TooltipArea
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
exports.TooltipTarget = TooltipTarget;
|
|
34
|
-
var MotionDiv = (0, _styled.default)(_framerMotion.motion.div)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", "\n"])), function (_ref2) {
|
|
35
|
-
var _ref2$position = _ref2.position,
|
|
36
|
-
position = _ref2$position === void 0 ? 'right' : _ref2$position,
|
|
37
|
-
backgroundColor = _ref2.backgroundColor,
|
|
38
|
-
width = _ref2.width,
|
|
39
|
-
maxWidth = _ref2.maxWidth,
|
|
40
|
-
theme = _ref2.theme;
|
|
41
|
-
return (0, _react.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n position: absolute;\n background-color: ", ";\n justify-content: inherit;\n align-items: inherit;\n width: ", ";\n max-width: ", ";\n border-radius: ", ";\n ", ";\n "])), backgroundColor || (theme.colorMode === 'dark' ? theme.colors.neutral.white : theme.colors.neutral.neutral5), width, maxWidth, theme.borderRadius.default, (0, _util.TooltipAreaPositionController)(position));
|
|
42
|
-
});
|
|
43
|
-
exports.MotionDiv = MotionDiv;
|
|
44
|
-
|
|
45
|
-
var TooltipWrapper = _styled.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n height: inherit;\n overflow: hidden;\n\n color: ", ";\n padding: 10px;\n"])), function (_ref3) {
|
|
46
|
-
var labelColor = _ref3.labelColor,
|
|
47
|
-
theme = _ref3.theme;
|
|
48
|
-
return labelColor || (theme.colorMode === 'dark' ? theme.colors.neutral.black : theme.colors.neutral.white);
|
|
49
|
-
});
|
|
27
|
+
var TooltipWrapper = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: fit-content;\n height: fit-content;\n"])));
|
|
50
28
|
|
|
51
29
|
exports.TooltipWrapper = TooltipWrapper;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare type positionType = 'top
|
|
4
|
-
export declare type
|
|
5
|
-
width?: string;
|
|
6
|
-
maxWidth?: string;
|
|
2
|
+
import { GlobalColorsProps } from '../../shared/theme';
|
|
3
|
+
export declare type positionType = 'top' | 'right' | 'bottom' | 'left';
|
|
4
|
+
export declare type TooltipProps = {
|
|
7
5
|
position?: positionType;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare type IInputProps = {
|
|
15
|
-
width?: string;
|
|
16
|
-
maxWidth?: string;
|
|
17
|
-
position?: positionType;
|
|
18
|
-
backgroundColor?: string;
|
|
19
|
-
label?: ReactNode;
|
|
20
|
-
labelColor?: string;
|
|
21
|
-
children?: ReactNode;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
labelColor?: GlobalColorsProps | (string & {});
|
|
9
|
+
bgColor?: GlobalColorsProps | (string & {});
|
|
10
|
+
maxWidth?: number;
|
|
11
|
+
offset?: number;
|
|
22
12
|
animationDuration?: number;
|
|
23
13
|
};
|
|
14
|
+
export declare type TooltipLabelProps = TooltipProps & {
|
|
15
|
+
tooltipPositions: {
|
|
16
|
+
top: number;
|
|
17
|
+
left: number;
|
|
18
|
+
transform: string;
|
|
19
|
+
};
|
|
20
|
+
handleRepositionTooltip: (element: HTMLDivElement) => void;
|
|
21
|
+
};
|
|
24
22
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,oBAAY,YAAY,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE/D,oBAAY,YAAY,GAAG;IACzB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,iBAAiB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,iBAAiB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,oBAAY,iBAAiB,GAAG,YAAY,GAAG;IAC7C,gBAAgB,EAAE;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,uBAAuB,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;CAC5D,CAAC"}
|