@unbxd-ui/unbxd-react-components 0.2.221 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/components/Accordian/Accordian.js +14 -11
- package/components/Accordian/Accordian.stories.js +141 -118
- package/components/Accordian/index.js +1 -1
- package/components/Button/Button.js +8 -6
- package/components/Button/Button.stories.js +181 -62
- package/components/Button/DropdownButton.js +5 -6
- package/components/Button/buttonTheme.css +1 -1
- package/components/Button/index.js +2 -3
- package/components/DataLoader/DataLoader.js +6 -7
- package/components/DataLoader/DataLoader.stories.js +244 -58
- package/components/DataLoader/index.js +1 -1
- package/components/Form/Checkbox.js +12 -11
- package/components/Form/DragDropFileUploader.js +6 -7
- package/components/Form/Dropdown.js +14 -12
- package/components/Form/FileUploader.js +3 -4
- package/components/Form/Form.js +6 -7
- package/components/Form/FormElementWrapper.js +1 -1
- package/components/Form/Input.js +24 -15
- package/components/Form/RadioList.js +8 -9
- package/components/Form/RangeSlider.js +12 -13
- package/components/Form/SearchableDropdown.js +563 -0
- package/components/Form/ServerPaginatedDDList.js +53 -44
- package/components/Form/Textarea.js +26 -10
- package/components/Form/Toggle.js +6 -7
- package/components/Form/formCore.css +1 -1
- package/components/Form/formTheme.css +1 -1
- package/components/Form/index.js +8 -1
- package/components/Form/stories/Checkbox.stories.js +139 -40
- package/components/Form/stories/Dropdown.stories.js +323 -92
- package/components/Form/stories/FileUploader.stories.js +178 -19
- package/components/Form/stories/Input.stories.js +115 -0
- package/components/Form/stories/RangeSlider.stories.js +162 -64
- 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 +113 -34
- package/components/Form/stories/Toggle.stories.js +193 -14
- package/components/Form/variables.css +0 -0
- package/components/InlineModal/InlineModal.js +119 -21
- package/components/InlineModal/InlineModal.stories.js +239 -45
- package/components/InlineModal/index.js +1 -2
- package/components/InlineModal/inlineModalCore.css +1 -1
- package/components/Link/Link.js +139 -0
- package/components/Link/Link.stories.js +489 -0
- package/components/Link/index.js +28 -0
- package/components/Link/linkCore.css +1 -0
- package/components/Link/linkTheme.css +1 -0
- package/components/List/List.js +11 -8
- package/components/List/List.stories.js +238 -0
- package/components/List/index.js +1 -1
- package/components/Modal/Modal.js +67 -20
- package/components/Modal/Modal.stories.js +257 -38
- package/components/Modal/index.js +1 -1
- package/components/Modal/modalCore.css +1 -1
- package/components/NoDataPlaceholder/NoDataPlaceholder.js +41 -0
- package/components/NoDataPlaceholder/NoDataPlaceholder.stories.js +42 -0
- package/components/NoDataPlaceholder/index.js +9 -0
- package/components/NoDataPlaceholder/noDataPlaceholderCore.css +1 -0
- package/components/NotificationComponent/NotificationComponent.js +20 -10
- package/components/NotificationComponent/NotificationComponent.stories.js +171 -19
- package/components/NotificationComponent/index.js +1 -1
- package/components/NotificationComponent/notificationTheme.css +1 -1
- 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.js +1 -1
- package/components/ProgressBar/ProgressBar.stories.js +203 -10
- package/components/ProgressBar/index.js +1 -1
- package/components/ProgressBar/progressBarCore.css +1 -1
- package/components/Table/BaseTable.js +86 -342
- package/components/Table/PaginationComponent.js +4 -4
- package/components/Table/Table.js +7 -326
- package/components/Table/Table.stories.js +2117 -158
- 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 +14 -1
- 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 +6 -7
- package/components/TabsComponent/TabsComponent.stories.js +291 -53
- package/components/TabsComponent/index.js +1 -1
- 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 +231 -56
- package/components/Tooltip/Tooltip.stories.js +380 -15
- package/components/Tooltip/index.js +1 -1
- package/components/Tooltip/tooltipCore.css +1 -1
- package/components/Tooltip/tooltipTheme.css +1 -1
- package/components/common/NoDataDropdown.js +50 -0
- package/components/common/common.css +1 -0
- package/components/core.css +2 -3
- package/components/core.scss +21 -1
- package/components/index.js +91 -3
- package/components/theme.css +2 -3
- package/components/theme.scss +2 -1
- package/core/Validators.js +1 -1
- package/core/customHooks.js +4 -4
- package/core/dataLoader.js +58 -17
- package/core/index.js +1 -1
- package/core/utils.js +15 -4
- package/index.js +54 -0
- package/package.json +41 -28
- 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
|
@@ -8,94 +8,269 @@ exports["default"] = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _excluded = ["TooltipActivator", "activatorAction", "direction", "children", "className"];
|
|
11
|
-
function _interopRequireDefault(
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
function
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
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); }
|
|
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; }
|
|
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
|
-
function _unsupportedIterableToArray(
|
|
18
|
-
function _arrayLikeToArray(
|
|
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; } }
|
|
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
|
-
function _arrayWithHoles(
|
|
21
|
-
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; }
|
|
22
|
-
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; }
|
|
21
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
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
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
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);
|
|
183
|
+
var tooltipRef = (0, _react.useRef)(null);
|
|
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;
|
|
57
191
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
58
192
|
return {
|
|
59
193
|
hideToolTip: function hideToolTip() {
|
|
60
|
-
setIsOpen(false);
|
|
194
|
+
return setIsOpen(false);
|
|
61
195
|
}
|
|
62
196
|
};
|
|
63
197
|
});
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
+
}
|
|
72
207
|
};
|
|
73
208
|
var hideToolTip = function hideToolTip() {
|
|
74
209
|
setIsOpen(false);
|
|
75
210
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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);
|
|
219
|
+
}
|
|
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
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}, [activatorAction, isOpen]);
|
|
232
|
+
|
|
233
|
+
// For hover tooltips, handle mouse events on the container
|
|
234
|
+
var containerEventProps = activatorAction === 'hover' ? {
|
|
235
|
+
onMouseEnter: showToolTip,
|
|
80
236
|
onMouseLeave: hideToolTip
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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({
|
|
85
247
|
className: "RCB-tooltip-btn"
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
|
|
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
|
+
});
|
|
91
259
|
Tooltip.propTypes = {
|
|
260
|
+
/** Custom component to act as the tooltip activator */
|
|
92
261
|
TooltipActivator: _propTypes["default"].func,
|
|
262
|
+
/** Action that triggers the tooltip - either click or hover */
|
|
93
263
|
activatorAction: _propTypes["default"].oneOf(["click", "hover"]),
|
|
94
|
-
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
|
|
95
270
|
};
|
|
96
271
|
Tooltip.defaultProps = {
|
|
97
272
|
TooltipActivator: DefaultTooltipActivator,
|
|
98
273
|
activatorAction: "hover",
|
|
99
|
-
direction: "
|
|
274
|
+
direction: "top"
|
|
100
275
|
};
|
|
101
276
|
var _default = exports["default"] = Tooltip;
|