@cypress-design/react-tooltip 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/Tooltip.rootstory.tsx +20 -0
- package/Tooltip.tsx +78 -39
- package/dist/Tooltip.d.ts +8 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/index.es.js +48 -24
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +48 -24
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -30341,7 +30341,7 @@ var ROTATE_MAP = {
|
|
|
30341
30341
|
};
|
|
30342
30342
|
var Tooltip = function (_a) {
|
|
30343
30343
|
var _b;
|
|
30344
|
-
var placement = _a.placement, _c = _a.color, color = _c === void 0 ? 'light' : _c, className = _a.className, children = _a.children, popper = _a.popper, disabled = _a.disabled, rest = __rest(_a, ["placement", "color", "className", "children", "popper", "disabled"]);
|
|
30344
|
+
var placement = _a.placement, _c = _a.color, color = _c === void 0 ? 'light' : _c, className = _a.className, children = _a.children, popper = _a.popper, disabled = _a.disabled, interactive = _a.interactive, forcePlacement = _a.forcePlacement, rest = __rest(_a, ["placement", "color", "className", "children", "popper", "disabled", "interactive", "forcePlacement"]);
|
|
30345
30345
|
var arrowRef = React__namespace.useRef(null);
|
|
30346
30346
|
var _d = React__namespace.useState(false), open = _d[0], setOpen = _d[1];
|
|
30347
30347
|
var container = React__namespace.useState(function () {
|
|
@@ -30359,12 +30359,21 @@ var Tooltip = function (_a) {
|
|
|
30359
30359
|
placement: placement,
|
|
30360
30360
|
open: open,
|
|
30361
30361
|
onOpenChange: setOpen,
|
|
30362
|
-
middleware: [
|
|
30362
|
+
middleware: [
|
|
30363
|
+
forcePlacement
|
|
30364
|
+
? {
|
|
30365
|
+
name: 'no-flip',
|
|
30366
|
+
fn: function (obj) { return obj; }
|
|
30367
|
+
}
|
|
30368
|
+
: flip(),
|
|
30369
|
+
offset(0),
|
|
30370
|
+
arrow({ element: arrowRef, padding: 24 }),
|
|
30371
|
+
],
|
|
30363
30372
|
whileElementsMounted: autoUpdate
|
|
30364
30373
|
}), x = _e.x, y = _e.y, reference = _e.reference, floating = _e.floating, strategy = _e.strategy, calculatedPlacement = _e.placement, context = _e.context, _f = _e.middlewareData.arrow, _g = _f === void 0 ? {} : _f, arrowX = _g.x, arrowY = _g.y;
|
|
30365
30374
|
var _h = useInteractions([
|
|
30366
30375
|
useHover(context, {
|
|
30367
|
-
handleClose: safePolygon(),
|
|
30376
|
+
handleClose: interactive ? safePolygon() : undefined,
|
|
30368
30377
|
enabled: !disabled
|
|
30369
30378
|
}),
|
|
30370
30379
|
useFocus(context, {
|
|
@@ -30388,6 +30397,25 @@ var Tooltip = function (_a) {
|
|
|
30388
30397
|
arrowXRule = placementSide === 'left' ? 'right' : 'left';
|
|
30389
30398
|
arrowYRule = 'top';
|
|
30390
30399
|
}
|
|
30400
|
+
var getColors = function () {
|
|
30401
|
+
switch (color) {
|
|
30402
|
+
case 'light':
|
|
30403
|
+
return {
|
|
30404
|
+
svg: 'stroke-gray-100 fill-white',
|
|
30405
|
+
block: 'text-gray-900 border-gray-100 shadow-gray-100',
|
|
30406
|
+
background: 'bg-white'
|
|
30407
|
+
};
|
|
30408
|
+
case 'dark':
|
|
30409
|
+
return {
|
|
30410
|
+
svg: 'stroke-gray-800 fill-gray-900',
|
|
30411
|
+
block: 'text-white shadow-gray-800 border-gray-800',
|
|
30412
|
+
background: 'bg-gray-900'
|
|
30413
|
+
};
|
|
30414
|
+
default:
|
|
30415
|
+
return {};
|
|
30416
|
+
}
|
|
30417
|
+
};
|
|
30418
|
+
var colors = getColors();
|
|
30391
30419
|
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
30392
30420
|
React__namespace.createElement("div", __assign({}, getReferenceProps(), { ref: reference, className: className }, rest), children),
|
|
30393
30421
|
React__namespace.createElement(FloatingPortal, null, open && !disabled && (React__namespace.createElement("div", __assign({}, getFloatingProps({
|
|
@@ -30399,30 +30427,26 @@ var Tooltip = function (_a) {
|
|
|
30399
30427
|
padding: '16px'
|
|
30400
30428
|
}
|
|
30401
30429
|
})),
|
|
30402
|
-
React__namespace.createElement("
|
|
30403
|
-
|
|
30404
|
-
|
|
30405
|
-
]), style: (_b = {
|
|
30406
|
-
transform: "rotate(" + arrowRotate + "deg)",
|
|
30407
|
-
filter: placementSide === 'bottom' || color === 'dark'
|
|
30408
|
-
? undefined
|
|
30409
|
-
: 'drop-shadow(0 1px 1px rgba(225, 227, 237, .8))'
|
|
30410
|
-
},
|
|
30411
|
-
_b[arrowXRule] = (arrowX !== null && arrowX !== void 0 ? arrowX : -6) + "px",
|
|
30412
|
-
_b[arrowYRule] = (arrowY !== null && arrowY !== void 0 ? arrowY : -6) + "px",
|
|
30413
|
-
_b), fill: "none" },
|
|
30414
|
-
React__namespace.createElement("rect", { x: "0", y: "0", width: "48", height: "4", strokeWidth: "0" }),
|
|
30415
|
-
React__namespace.createElement("path", { d: "M 0 3 C 12 3 18 18 24 18 C 30 18 36 3 48 3", "stroke-width": "2" })),
|
|
30416
|
-
React__namespace.createElement("div", { className: clsx__default["default"]('rounded shadow border p-8px text-16px leading-24px min-w-160px text-center', [
|
|
30417
|
-
color === 'dark' &&
|
|
30418
|
-
'bg-gray-900 shadow-gray-800 border-gray-800',
|
|
30419
|
-
color === 'light' &&
|
|
30420
|
-
'bg-white shadow-gray-100 border-gray-100',
|
|
30430
|
+
React__namespace.createElement("div", { className: clsx__default["default"]('rounded shadow border', [
|
|
30431
|
+
colors.background,
|
|
30432
|
+
colors.block,
|
|
30421
30433
|
(!x || !y) && 'invisible',
|
|
30422
|
-
]) },
|
|
30434
|
+
]) },
|
|
30435
|
+
React__namespace.createElement("svg", { ref: arrowRef, viewBox: "0 0 48 48", width: "24", height: "24", className: clsx__default["default"]('absolute z-10', colors.svg), style: (_b = {
|
|
30436
|
+
transform: "rotate(" + arrowRotate + "deg)",
|
|
30437
|
+
filter: placementSide === 'bottom' || color === 'dark'
|
|
30438
|
+
? undefined
|
|
30439
|
+
: 'drop-shadow(0 1px 1px rgba(225, 227, 237, .8))'
|
|
30440
|
+
},
|
|
30441
|
+
_b[arrowXRule] = (arrowX !== null && arrowX !== void 0 ? arrowX : -6) + "px",
|
|
30442
|
+
_b[arrowYRule] = (arrowY !== null && arrowY !== void 0 ? arrowY : -6) + "px",
|
|
30443
|
+
_b), fill: "none" },
|
|
30444
|
+
React__namespace.createElement("rect", { x: "0", y: "0", width: "48", height: "4", strokeWidth: "0" }),
|
|
30445
|
+
React__namespace.createElement("path", { d: "M 0 3 C 12 3 18 18 24 18 C 30 18 36 3 48 3", strokeWidth: "2" })),
|
|
30446
|
+
React__namespace.createElement("div", { className: clsx__default["default"]('rounded text-16px leading-24px min-w-160px text-center p-8px relative z-20', colors.background) }, popper)))))));
|
|
30423
30447
|
};
|
|
30424
30448
|
|
|
30425
30449
|
module.exports = Tooltip;
|
|
30426
|
-
/* <windicss-keep class="container
|
|
30450
|
+
/* <windicss-keep class="container stroke-gray-100 fill-white text-gray-900 border-gray-100 shadow-gray-100 bg-white stroke-gray-800 fill-gray-900 text-white shadow-gray-800 border-gray-800 bg-gray-900 rounded shadow border invisible absolute z-10 text-16px leading-24px min-w-160px text-center p-8px relative z-20"> */
|
|
30427
30451
|
|
|
30428
30452
|
//# sourceMappingURL=index.umd.js.map
|