@cypress-design/react-tooltip 0.0.2 → 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 +21 -0
- package/Tooltip.rootstory.tsx +24 -0
- package/Tooltip.tsx +109 -43
- package/dist/Tooltip.d.ts +22 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/index.es.js +54 -25
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +54 -25
- 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, rest = __rest(_a, ["placement", "color", "className", "children", "popper"]);
|
|
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,14 +30359,26 @@ 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,
|
|
30377
|
+
enabled: !disabled
|
|
30378
|
+
}),
|
|
30379
|
+
useFocus(context, {
|
|
30380
|
+
enabled: !disabled
|
|
30368
30381
|
}),
|
|
30369
|
-
useFocus(context),
|
|
30370
30382
|
useRole(context, { role: 'tooltip' }),
|
|
30371
30383
|
useDismiss(context),
|
|
30372
30384
|
]), getReferenceProps = _h.getReferenceProps, getFloatingProps = _h.getFloatingProps;
|
|
@@ -30385,9 +30397,28 @@ var Tooltip = function (_a) {
|
|
|
30385
30397
|
arrowXRule = placementSide === 'left' ? 'right' : 'left';
|
|
30386
30398
|
arrowYRule = 'top';
|
|
30387
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();
|
|
30388
30419
|
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
30389
30420
|
React__namespace.createElement("div", __assign({}, getReferenceProps(), { ref: reference, className: className }, rest), children),
|
|
30390
|
-
React__namespace.createElement(FloatingPortal, null, open && (React__namespace.createElement("div", __assign({}, getFloatingProps({
|
|
30421
|
+
React__namespace.createElement(FloatingPortal, null, open && !disabled && (React__namespace.createElement("div", __assign({}, getFloatingProps({
|
|
30391
30422
|
ref: floating,
|
|
30392
30423
|
style: {
|
|
30393
30424
|
position: strategy,
|
|
@@ -30396,28 +30427,26 @@ var Tooltip = function (_a) {
|
|
|
30396
30427
|
padding: '16px'
|
|
30397
30428
|
}
|
|
30398
30429
|
})),
|
|
30399
|
-
React__namespace.createElement("
|
|
30400
|
-
|
|
30401
|
-
|
|
30402
|
-
]), style: (_b = {
|
|
30403
|
-
transform: "rotate(".concat(arrowRotate, "deg)"),
|
|
30404
|
-
filter: placementSide === 'bottom' || color === 'dark'
|
|
30405
|
-
? undefined
|
|
30406
|
-
: 'drop-shadow(0 1px 1px rgba(225, 227, 237, .8))'
|
|
30407
|
-
},
|
|
30408
|
-
_b[arrowXRule] = "".concat(arrowX !== null && arrowX !== void 0 ? arrowX : -6, "px"),
|
|
30409
|
-
_b[arrowYRule] = "".concat(arrowY !== null && arrowY !== void 0 ? arrowY : -6, "px"),
|
|
30410
|
-
_b), fill: "none" },
|
|
30411
|
-
React__namespace.createElement("rect", { x: "0", y: "0", width: "48", height: "4", strokeWidth: "0" }),
|
|
30412
|
-
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" })),
|
|
30413
|
-
React__namespace.createElement("div", { className: clsx__default["default"]('rounded shadow border p-8px text-16px leading-24px min-w-160px text-center', [
|
|
30414
|
-
color === 'dark' &&
|
|
30415
|
-
'bg-gray-900 shadow-gray-800 border-gray-800',
|
|
30416
|
-
color === 'light' &&
|
|
30417
|
-
'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,
|
|
30418
30433
|
(!x || !y) && 'invisible',
|
|
30419
|
-
]) },
|
|
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)))))));
|
|
30420
30447
|
};
|
|
30421
30448
|
|
|
30422
30449
|
module.exports = Tooltip;
|
|
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"> */
|
|
30451
|
+
|
|
30423
30452
|
//# sourceMappingURL=index.umd.js.map
|