@unbxd-ui/unbxd-react-components 0.2.145 → 0.2.146
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/README.md +17 -1
- package/components/Accordian/Accordian.js +1 -2
- package/components/Accordian/Accordian.stories.js +140 -117
- package/components/Button/Button.stories.js +167 -61
- package/components/Button/DropdownButton.js +1 -2
- package/components/Button/index.js +1 -2
- package/components/DataLoader/DataLoader.js +1 -2
- package/components/DataLoader/DataLoader.stories.js +239 -53
- package/components/Form/Checkbox.js +5 -4
- package/components/Form/DragDropFileUploader.js +1 -2
- package/components/Form/Dropdown.js +1 -2
- package/components/Form/FileUploader.js +1 -2
- package/components/Form/Form.js +1 -2
- package/components/Form/Input.js +1 -2
- package/components/Form/RadioList.js +1 -2
- package/components/Form/RangeSlider.js +1 -2
- package/components/Form/SearchableDropdown.js +563 -0
- package/components/Form/ServerPaginatedDDList.js +17 -11
- package/components/Form/Textarea.js +1 -2
- package/components/Form/Toggle.js +1 -2
- package/components/Form/formCore.css +1 -1
- package/components/Form/formTheme.css +1 -1
- package/components/Form/index.js +7 -0
- package/components/Form/stories/Checkbox.stories.js +138 -39
- package/components/Form/stories/Dropdown.stories.js +322 -91
- package/components/Form/stories/FileUploader.stories.js +177 -18
- package/components/Form/stories/Input.stories.js +115 -0
- package/components/Form/stories/RangeSlider.stories.js +161 -63
- package/components/Form/stories/SearchableDropdown.stories.js +189 -0
- package/components/Form/stories/ServerPaginatedDropdown.stories.js +365 -0
- package/components/Form/stories/Textarea.stories.js +112 -33
- package/components/Form/stories/Toggle.stories.js +192 -13
- package/components/Form/variables.css +0 -0
- package/components/InlineModal/InlineModal.js +1 -2
- package/components/InlineModal/InlineModal.stories.js +239 -45
- package/components/InlineModal/index.js +1 -2
- package/components/InlineModal/inlineModalCore.css +1 -1
- package/components/List/List.stories.js +238 -0
- package/components/Modal/Modal.js +1 -2
- package/components/Modal/Modal.stories.js +256 -37
- package/components/Modal/modalCore.css +1 -1
- package/components/NotificationComponent/NotificationComponent.js +1 -2
- package/components/NotificationComponent/NotificationComponent.stories.js +170 -18
- package/components/PageLoader/PageLoader.js +84 -0
- package/components/PageLoader/PageLoader.stories.js +276 -0
- package/components/PageLoader/index.js +9 -0
- package/components/PageLoader/pageLoaderCore.css +1 -0
- package/components/ProgressBar/ProgressBar.css +0 -0
- package/components/ProgressBar/ProgressBar.stories.js +202 -9
- package/components/ProgressBar/progressBarCore.css +1 -1
- package/components/Table/BaseTable.js +84 -354
- package/components/Table/Table.js +6 -359
- package/components/Table/Table.stories.js +2109 -150
- package/components/Table/TableChild.js +383 -0
- package/components/Table/TableConstants.js +15 -0
- package/components/Table/hooks/usePrevious.js +14 -0
- package/components/Table/index.js +13 -0
- package/components/Table/tableCore.css +1 -1
- package/components/TableOld/BaseTable.js +373 -0
- package/components/TableOld/PaginationComponent.js +86 -0
- package/components/TableOld/TableOld.js +367 -0
- package/components/TableOld/index.js +15 -0
- package/components/TabsComponent/TabsComponent.js +1 -2
- package/components/TabsComponent/TabsComponent.stories.js +290 -52
- package/components/ToastNotification/ToastNotificationWrapper.js +212 -0
- package/components/ToastNotification/ToastNotificationWrapper.stories.js +554 -0
- package/components/ToastNotification/index.js +40 -0
- package/components/ToastNotification/toastNotificationCore.css +1 -0
- package/components/Tooltip/Tooltip.js +221 -83
- package/components/Tooltip/Tooltip.stories.js +379 -14
- package/components/Tooltip/tooltipCore.css +1 -1
- package/components/Tooltip/tooltipTheme.css +1 -1
- package/components/core.css +2 -3
- package/components/core.scss +17 -0
- package/components/index.js +58 -2
- package/components/theme.css +2 -3
- package/core/dataLoader.js +5 -2
- package/index.js +54 -0
- package/package.json +31 -20
- package/components/Button/DropdownButton.stories.js +0 -49
- package/components/Form/stories/DragDropFileUploader.stories.js +0 -25
- package/components/Form/stories/FormDefault.stories.js +0 -115
- package/components/Form/stories/RadioList.stories.js +0 -53
- package/components/Form/stories/TextInput.stories.js +0 -76
- package/components/Form/stories/form.stories.js +0 -233
- package/components/List/list.stories.js +0 -35
- package/core/dataLoader.stories.js +0 -119
|
@@ -9,130 +9,268 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _excluded = ["TooltipActivator", "activatorAction", "direction", "children", "className"];
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
-
function
|
|
13
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
13
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
15
16
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
16
17
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
18
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
18
19
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
19
20
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
20
21
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
21
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
22
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
23
22
|
/* eslint-disable react/prop-types */
|
|
24
23
|
var DefaultTooltipActivator = function DefaultTooltipActivator() {
|
|
25
24
|
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, "i");
|
|
26
25
|
};
|
|
27
|
-
|
|
26
|
+
|
|
27
|
+
// Dynamic positioning hook
|
|
28
|
+
var useTooltipPosition = function useTooltipPosition(activatorRef, tooltipRef) {
|
|
29
|
+
var preferredDirection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'top';
|
|
30
|
+
var isOpen = arguments.length > 3 ? arguments[3] : undefined;
|
|
31
|
+
var _useState = (0, _react.useState)({
|
|
32
|
+
direction: preferredDirection,
|
|
33
|
+
tooltipStyle: {},
|
|
34
|
+
arrowStyle: {}
|
|
35
|
+
}),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
position = _useState2[0],
|
|
38
|
+
setPosition = _useState2[1];
|
|
39
|
+
var calculatePosition = (0, _react.useCallback)(function () {
|
|
40
|
+
if (!activatorRef.current || !tooltipRef.current || !isOpen) return;
|
|
41
|
+
var activator = activatorRef.current.getBoundingClientRect();
|
|
42
|
+
var tooltip = tooltipRef.current.getBoundingClientRect();
|
|
43
|
+
var viewport = {
|
|
44
|
+
width: window.innerWidth,
|
|
45
|
+
height: window.innerHeight
|
|
46
|
+
};
|
|
47
|
+
var spacing = 12; // Increased from 8 to 12 to prevent overlap
|
|
48
|
+
var arrowSize = 8; // Size of the pointer triangle
|
|
49
|
+
|
|
50
|
+
// Calculate available space in each direction
|
|
51
|
+
var spaces = {
|
|
52
|
+
top: activator.top,
|
|
53
|
+
bottom: viewport.height - activator.bottom,
|
|
54
|
+
left: activator.left,
|
|
55
|
+
right: viewport.width - activator.right
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Determine best direction based on available space
|
|
59
|
+
var direction = preferredDirection;
|
|
60
|
+
var requiredSpace = {
|
|
61
|
+
top: tooltip.height + spacing + arrowSize,
|
|
62
|
+
bottom: tooltip.height + spacing + arrowSize,
|
|
63
|
+
left: tooltip.width + spacing + arrowSize,
|
|
64
|
+
right: tooltip.width + spacing + arrowSize
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Check if preferred direction has enough space, otherwise find best alternative
|
|
68
|
+
if (spaces[direction] < requiredSpace[direction]) {
|
|
69
|
+
var alternatives = Object.keys(spaces).filter(function (dir) {
|
|
70
|
+
return spaces[dir] >= requiredSpace[dir];
|
|
71
|
+
}).sort(function (a, b) {
|
|
72
|
+
return spaces[b] - spaces[a];
|
|
73
|
+
});
|
|
74
|
+
direction = alternatives[0] || preferredDirection; // Fallback to preferred if no space
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Calculate tooltip position relative to the activator
|
|
78
|
+
var tooltipStyle = {
|
|
79
|
+
position: 'absolute'
|
|
80
|
+
};
|
|
81
|
+
var arrowStyle = {
|
|
82
|
+
position: 'absolute'
|
|
83
|
+
};
|
|
84
|
+
switch (direction) {
|
|
85
|
+
case 'top':
|
|
86
|
+
tooltipStyle.bottom = "".concat(activator.height + spacing, "px"); // Changed to use activator height + spacing
|
|
87
|
+
tooltipStyle.left = "50%";
|
|
88
|
+
tooltipStyle.transform = 'translateX(-50%)';
|
|
89
|
+
arrowStyle.top = '100%';
|
|
90
|
+
arrowStyle.left = '50%';
|
|
91
|
+
arrowStyle.transform = 'translateX(-50%)';
|
|
92
|
+
break;
|
|
93
|
+
case 'bottom':
|
|
94
|
+
tooltipStyle.top = "".concat(activator.height + spacing, "px"); // Changed to use activator height + spacing
|
|
95
|
+
tooltipStyle.left = "50%";
|
|
96
|
+
tooltipStyle.transform = 'translateX(-50%)';
|
|
97
|
+
arrowStyle.bottom = '100%';
|
|
98
|
+
arrowStyle.left = '50%';
|
|
99
|
+
arrowStyle.transform = 'translateX(-50%)';
|
|
100
|
+
break;
|
|
101
|
+
case 'left':
|
|
102
|
+
tooltipStyle.right = "".concat(activator.width + spacing, "px"); // Changed to use activator width + spacing
|
|
103
|
+
tooltipStyle.top = "50%";
|
|
104
|
+
tooltipStyle.transform = 'translateY(-50%)';
|
|
105
|
+
arrowStyle.left = '100%';
|
|
106
|
+
arrowStyle.top = '50%';
|
|
107
|
+
arrowStyle.transform = 'translateY(-50%)';
|
|
108
|
+
break;
|
|
109
|
+
case 'right':
|
|
110
|
+
tooltipStyle.left = "".concat(activator.width + spacing, "px"); // Changed to use activator width + spacing
|
|
111
|
+
tooltipStyle.top = "50%";
|
|
112
|
+
tooltipStyle.transform = 'translateY(-50%)';
|
|
113
|
+
arrowStyle.right = '100%';
|
|
114
|
+
arrowStyle.top = '50%';
|
|
115
|
+
arrowStyle.transform = 'translateY(-50%)';
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Handle viewport boundary collisions for horizontal directions
|
|
120
|
+
if (direction === 'top' || direction === 'bottom') {
|
|
121
|
+
var tooltipCenter = activator.left + activator.width / 2;
|
|
122
|
+
var tooltipHalfWidth = tooltip.width / 2;
|
|
123
|
+
if (tooltipCenter - tooltipHalfWidth < 0) {
|
|
124
|
+
// Too far left
|
|
125
|
+
tooltipStyle.left = "".concat(-activator.left, "px");
|
|
126
|
+
tooltipStyle.transform = 'none';
|
|
127
|
+
arrowStyle.left = "".concat(activator.width / 2, "px");
|
|
128
|
+
} else if (tooltipCenter + tooltipHalfWidth > viewport.width) {
|
|
129
|
+
// Too far right
|
|
130
|
+
tooltipStyle.right = "".concat(activator.left + activator.width - viewport.width, "px");
|
|
131
|
+
tooltipStyle.left = 'auto';
|
|
132
|
+
tooltipStyle.transform = 'none';
|
|
133
|
+
arrowStyle.right = "".concat(activator.width / 2, "px");
|
|
134
|
+
arrowStyle.left = 'auto';
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
setPosition({
|
|
138
|
+
direction: direction,
|
|
139
|
+
tooltipStyle: tooltipStyle,
|
|
140
|
+
arrowStyle: arrowStyle
|
|
141
|
+
});
|
|
142
|
+
}, [preferredDirection, isOpen]);
|
|
143
|
+
(0, _react.useEffect)(function () {
|
|
144
|
+
if (isOpen && activatorRef.current && tooltipRef.current) {
|
|
145
|
+
// Small delay to ensure tooltip is rendered
|
|
146
|
+
var timer = setTimeout(calculatePosition, 10);
|
|
147
|
+
return function () {
|
|
148
|
+
return clearTimeout(timer);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}, [calculatePosition, isOpen]);
|
|
152
|
+
(0, _react.useEffect)(function () {
|
|
153
|
+
if (isOpen) {
|
|
154
|
+
var handleResize = function handleResize() {
|
|
155
|
+
return calculatePosition();
|
|
156
|
+
};
|
|
157
|
+
window.addEventListener('resize', handleResize);
|
|
158
|
+
return function () {
|
|
159
|
+
return window.removeEventListener('resize', handleResize);
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}, [calculatePosition, isOpen]);
|
|
163
|
+
return position;
|
|
164
|
+
};
|
|
165
|
+
var Tooltip = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
28
166
|
var TooltipActivator = props.TooltipActivator,
|
|
29
167
|
activatorAction = props.activatorAction,
|
|
30
|
-
direction = props.direction,
|
|
168
|
+
_props$direction = props.direction,
|
|
169
|
+
preferredDirection = _props$direction === void 0 ? 'top' : _props$direction,
|
|
31
170
|
children = props.children,
|
|
32
|
-
className = props.className,
|
|
171
|
+
_props$className = props.className,
|
|
172
|
+
className = _props$className === void 0 ? "" : _props$className,
|
|
33
173
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
34
|
-
var _useState = (0, _react.useState)(""),
|
|
35
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
-
actionClassName = _useState2[0],
|
|
37
|
-
setActionClassName = _useState2[1];
|
|
38
174
|
var _useState3 = (0, _react.useState)(false),
|
|
39
175
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
176
|
isOpen = _useState4[0],
|
|
41
177
|
setIsOpen = _useState4[1];
|
|
42
|
-
var
|
|
178
|
+
var _useState5 = (0, _react.useState)(""),
|
|
179
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
180
|
+
actionClassName = _useState6[0],
|
|
181
|
+
setActionClassName = _useState6[1];
|
|
182
|
+
var activatorRef = (0, _react.useRef)(null);
|
|
43
183
|
var tooltipRef = (0, _react.useRef)(null);
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
break;
|
|
52
|
-
case "top":
|
|
53
|
-
dirClassName = "RCB-tooltip-top";
|
|
54
|
-
break;
|
|
55
|
-
default:
|
|
56
|
-
dirClassName = "RCB-tooltip-right";
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
184
|
+
var containerRef = (0, _react.useRef)(null);
|
|
185
|
+
|
|
186
|
+
// Use the dynamic positioning hook
|
|
187
|
+
var _useTooltipPosition = useTooltipPosition(activatorRef, tooltipRef, preferredDirection, isOpen),
|
|
188
|
+
direction = _useTooltipPosition.direction,
|
|
189
|
+
tooltipStyle = _useTooltipPosition.tooltipStyle,
|
|
190
|
+
arrowStyle = _useTooltipPosition.arrowStyle;
|
|
59
191
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
60
192
|
return {
|
|
61
193
|
hideToolTip: function hideToolTip() {
|
|
62
|
-
setIsOpen(false);
|
|
194
|
+
return setIsOpen(false);
|
|
63
195
|
}
|
|
64
196
|
};
|
|
65
197
|
});
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
198
|
+
var showToolTip = function showToolTip(e) {
|
|
199
|
+
if (activatorAction === 'click') {
|
|
200
|
+
e.stopPropagation();
|
|
201
|
+
setIsOpen(!isOpen);
|
|
202
|
+
setActionClassName("RCB-tooltip-click");
|
|
203
|
+
} else {
|
|
204
|
+
setIsOpen(true);
|
|
205
|
+
setActionClassName("RCB-tooltip-hover");
|
|
206
|
+
}
|
|
74
207
|
};
|
|
75
208
|
var hideToolTip = function hideToolTip() {
|
|
76
209
|
setIsOpen(false);
|
|
77
210
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (inlineModalNode.contains(eventTarget)) {
|
|
87
|
-
isWithinModal = true;
|
|
88
|
-
} else {
|
|
89
|
-
for (var i = 0; i < eventPathNodes.length; i++) {
|
|
90
|
-
var node = eventPathNodes[i];
|
|
91
|
-
if (node !== window && inlineModalNode.contains(node)) {
|
|
92
|
-
isWithinModal = true;
|
|
93
|
-
break;
|
|
211
|
+
|
|
212
|
+
// Handle outside click for click-activated tooltips
|
|
213
|
+
(0, _react.useEffect)(function () {
|
|
214
|
+
if (activatorAction === 'click' && isOpen) {
|
|
215
|
+
var handleOutsideClick = function handleOutsideClick(e) {
|
|
216
|
+
// Check if click is outside the container (includes both activator and tooltip)
|
|
217
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
218
|
+
setIsOpen(false);
|
|
94
219
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// Add event listener with a small delay to avoid immediate closure
|
|
223
|
+
var timer = setTimeout(function () {
|
|
224
|
+
document.addEventListener('click', handleOutsideClick);
|
|
225
|
+
}, 10);
|
|
226
|
+
return function () {
|
|
227
|
+
clearTimeout(timer);
|
|
228
|
+
document.removeEventListener('click', handleOutsideClick);
|
|
229
|
+
};
|
|
100
230
|
}
|
|
101
|
-
};
|
|
102
|
-
(0, _react.useEffect)(function () {
|
|
103
|
-
/* add when mounted */
|
|
104
|
-
document.addEventListener("click", onBodyClick);
|
|
231
|
+
}, [activatorAction, isOpen]);
|
|
105
232
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
}, []);
|
|
111
|
-
var eventProps = activatorAction === "click" ? {
|
|
112
|
-
onClick: showToolTipClick
|
|
113
|
-
} : {
|
|
114
|
-
onMouseEnter: showToolTipHover,
|
|
233
|
+
// For hover tooltips, handle mouse events on the container
|
|
234
|
+
var containerEventProps = activatorAction === 'hover' ? {
|
|
235
|
+
onMouseEnter: showToolTip,
|
|
115
236
|
onMouseLeave: hideToolTip
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
237
|
+
} : {};
|
|
238
|
+
|
|
239
|
+
// For click tooltips, handle events on the activator
|
|
240
|
+
var activatorEventProps = activatorAction === 'click' ? {
|
|
241
|
+
onClick: showToolTip
|
|
242
|
+
} : {};
|
|
243
|
+
return /*#__PURE__*/_react["default"].createElement("div", _extends({
|
|
244
|
+
className: "RCB-tooltip ".concat(className, " ").concat(isOpen ? ' RCB-tooltip-open' : ''),
|
|
245
|
+
ref: containerRef
|
|
246
|
+
}, containerEventProps), /*#__PURE__*/_react["default"].createElement("div", _extends({
|
|
121
247
|
className: "RCB-tooltip-btn"
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
248
|
+
}, activatorEventProps, {
|
|
249
|
+
ref: activatorRef
|
|
250
|
+
}), /*#__PURE__*/_react["default"].createElement(TooltipActivator, restProps)), isOpen && /*#__PURE__*/_react["default"].createElement("div", {
|
|
251
|
+
className: "RCB-tooltip-body RCB-tooltip-".concat(direction, " ").concat(actionClassName),
|
|
252
|
+
ref: tooltipRef,
|
|
253
|
+
style: tooltipStyle
|
|
254
|
+
}, children, /*#__PURE__*/_react["default"].createElement("div", {
|
|
255
|
+
className: "RCB-tooltip-arrow RCB-tooltip-arrow-".concat(direction),
|
|
256
|
+
style: arrowStyle
|
|
257
|
+
})));
|
|
258
|
+
});
|
|
128
259
|
Tooltip.propTypes = {
|
|
260
|
+
/** Custom component to act as the tooltip activator */
|
|
129
261
|
TooltipActivator: _propTypes["default"].func,
|
|
262
|
+
/** Action that triggers the tooltip - either click or hover */
|
|
130
263
|
activatorAction: _propTypes["default"].oneOf(["click", "hover"]),
|
|
131
|
-
direction
|
|
264
|
+
/** Preferred direction for tooltip placement. Will auto-adjust based on available space */
|
|
265
|
+
direction: _propTypes["default"].oneOf(["right", "bottom", "left", "top"]),
|
|
266
|
+
/** Tooltip content */
|
|
267
|
+
children: _propTypes["default"].node,
|
|
268
|
+
/** Additional CSS classes */
|
|
269
|
+
className: _propTypes["default"].string
|
|
132
270
|
};
|
|
133
271
|
Tooltip.defaultProps = {
|
|
134
272
|
TooltipActivator: DefaultTooltipActivator,
|
|
135
273
|
activatorAction: "hover",
|
|
136
|
-
direction: "
|
|
274
|
+
direction: "top"
|
|
137
275
|
};
|
|
138
276
|
var _default = exports["default"] = Tooltip;
|