blixify-ui-web 0.2.9 → 0.2.10

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.
@@ -1,20 +1,10 @@
1
- import React, { Component, ReactElement } from "react";
1
+ import React, { ReactElement } from "react";
2
2
  import "../../../index.css";
3
3
  interface Props {
4
- content: string | ReactElement;
4
+ content: ReactElement;
5
5
  icon: ReactElement;
6
- type: "top" | "right" | "left";
7
- infoTextColor?: string;
8
- infoCardClassName?: string;
9
- infoCardBackgroundColor?: string;
10
- }
11
- interface State {
12
- open: boolean;
13
- }
14
- export declare class InfoWindow extends Component<Props> {
15
- state: State;
16
- renderLayout: () => React.JSX.Element;
17
- render(): React.JSX.Element;
6
+ type: "left" | "right";
18
7
  }
8
+ export declare const InfoWindow: (props: Props) => React.JSX.Element;
19
9
  export {};
20
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/advanced/infoWindow/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,oBAAoB,CAAC;AAE5B,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,UAAU,KAAK;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAED,qBAAa,UAAW,SAAQ,SAAS,CAAC,KAAK,CAAC;IAC9C,KAAK,EAAE,KAAK,CAEV;IAEF,YAAY,0BAqDV;IAEF,MAAM;CAmBP"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/advanced/infoWindow/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,YAAY,EAA+B,MAAM,OAAO,CAAC;AAEzE,OAAO,oBAAoB,CAAC;AAE5B,UAAU,KAAK;IACb,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,UAAU,UAAW,KAAK,sBAoDtC,CAAC"}
@@ -1,19 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
3
  if (k2 === undefined) k2 = k;
19
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -37,57 +22,55 @@ var __importStar = (this && this.__importStar) || function (mod) {
37
22
  __setModuleDefault(result, mod);
38
23
  return result;
39
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
40
28
  Object.defineProperty(exports, "__esModule", { value: true });
41
29
  exports.InfoWindow = void 0;
42
30
  var react_1 = __importStar(require("react"));
31
+ var react_dom_1 = __importDefault(require("react-dom"));
43
32
  require("../../../index.css");
44
- var InfoWindow = /** @class */ (function (_super) {
45
- __extends(InfoWindow, _super);
46
- function InfoWindow() {
47
- var _this = _super !== null && _super.apply(this, arguments) || this;
48
- _this.state = {
49
- open: false,
33
+ var InfoWindow = function (props) {
34
+ var iconRef = (0, react_1.useRef)(null);
35
+ var _a = (0, react_1.useState)(false), isVisible = _a[0], setIsVisible = _a[1];
36
+ var _b = (0, react_1.useState)({ top: 0, left: 0 }), position = _b[0], setPosition = _b[1];
37
+ (0, react_1.useEffect)(function () {
38
+ var iconElement = iconRef.current;
39
+ var handleMouseEnter = function (event) {
40
+ var clientX = event.clientX, clientY = event.clientY;
41
+ setPosition({ top: clientY, left: clientX });
42
+ setIsVisible(true);
50
43
  };
51
- _this.renderLayout = function () {
52
- var defaultClassName = "absolute bottom-0 items-center ".concat(_this.props.infoCardClassName && _this.props.infoCardClassName, " ").concat(_this.state.open && " animate-fadeIn ");
53
- var layoutClassName = "";
54
- var arrowClasses = "w-3 h-3 ".concat(_this.props.infoCardBackgroundColor
55
- ? _this.props.infoCardBackgroundColor
56
- : "bg-gray-200", " transform rotate-45 ");
57
- var arrowPosition = "";
58
- switch (_this.props.type) {
59
- case "top":
60
- layoutClassName = "".concat(defaultClassName, " mb-7 flex flex-col");
61
- arrowPosition = "-mt-1.5";
62
- break;
63
- case "left":
64
- layoutClassName = "".concat(defaultClassName, " top-0 right-7 flex flex-row ");
65
- arrowPosition = "-ml-1.5";
66
- break;
67
- default:
68
- layoutClassName = "".concat(defaultClassName, " top-0 ml-7 flex flex-row ");
69
- arrowPosition = "-mr-1.5";
70
- }
71
- return (react_1.default.createElement("div", { className: layoutClassName },
72
- _this.props.type === "right" && (react_1.default.createElement("div", { className: "".concat(arrowClasses, " ").concat(arrowPosition) })),
73
- react_1.default.createElement("div", { className: "w-full p-4 ".concat(_this.props.infoCardBackgroundColor
74
- ? _this.props.infoCardBackgroundColor
75
- : "bg-gray-200", " rounded z-10") },
76
- react_1.default.createElement("p", { className: _this.props.infoTextColor
77
- ? _this.props.infoTextColor
78
- : "text-gray-500" }, _this.props.content && _this.props.content)),
79
- _this.props.type !== "right" && (react_1.default.createElement("div", { className: "".concat(arrowClasses, " ").concat(arrowPosition) }))));
44
+ var handleMouseLeave = function () {
45
+ setIsVisible(false);
80
46
  };
81
- return _this;
82
- }
83
- InfoWindow.prototype.render = function () {
84
- var _this = this;
85
- return (react_1.default.createElement("div", { className: "flex" },
86
- react_1.default.createElement("div", { className: "relative flex ".concat(this.props.type === "top" ? "justify-center" : "", " ") },
87
- react_1.default.createElement("div", { onMouseOver: function () { return _this.setState({ open: true }); }, onMouseLeave: function () { return _this.setState({ open: false }); } }, this.props.icon && this.props.icon),
88
- this.state.open && this.renderLayout())));
89
- };
90
- return InfoWindow;
91
- }(react_1.Component));
47
+ iconElement === null || iconElement === void 0 ? void 0 : iconElement.addEventListener("mouseenter", handleMouseEnter);
48
+ iconElement === null || iconElement === void 0 ? void 0 : iconElement.addEventListener("mouseleave", handleMouseLeave);
49
+ return function () {
50
+ iconElement === null || iconElement === void 0 ? void 0 : iconElement.removeEventListener("mouseenter", handleMouseEnter);
51
+ iconElement === null || iconElement === void 0 ? void 0 : iconElement.removeEventListener("mouseleave", handleMouseLeave);
52
+ };
53
+ }, [isVisible]);
54
+ (0, react_1.useEffect)(function () {
55
+ if (isVisible) {
56
+ var popoutElement_1 = document.createElement("div");
57
+ popoutElement_1.className =
58
+ "absolute z-50 " +
59
+ (props.type === "left" ? "transform -translate-x-full" : "");
60
+ popoutElement_1.style.position = "absolute";
61
+ popoutElement_1.style.top = "".concat(position.top, "px");
62
+ popoutElement_1.style.left = "".concat(position.left, "px");
63
+ document.body.appendChild(popoutElement_1);
64
+ react_dom_1.default.render(props.content, popoutElement_1);
65
+ return function () {
66
+ document.body.removeChild(popoutElement_1);
67
+ react_dom_1.default.unmountComponentAtNode(popoutElement_1);
68
+ };
69
+ }
70
+ return function () { };
71
+ }, [isVisible, props.content, props.type, position.top, position.left]);
72
+ var refIcon = react_1.default.cloneElement(props.icon, { ref: iconRef });
73
+ return react_1.default.createElement("div", null, refIcon);
74
+ };
92
75
  exports.InfoWindow = InfoWindow;
93
76
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/advanced/infoWindow/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuD;AACvD,8BAA4B;AAe5B;IAAgC,8BAAgB;IAAhD;QAAA,qEA+EC;QA9EC,WAAK,GAAU;YACb,IAAI,EAAE,KAAK;SACZ,CAAC;QAEF,kBAAY,GAAG;YACb,IAAI,gBAAgB,GAAG,yCACrB,KAAI,CAAC,KAAK,CAAC,iBAAiB,IAAI,KAAI,CAAC,KAAK,CAAC,iBAAiB,cAC1D,KAAI,CAAC,KAAK,CAAC,IAAI,IAAI,kBAAkB,CAAE,CAAC;YAC5C,IAAI,eAAe,GAAG,EAAE,CAAC;YACzB,IAAI,YAAY,GAAG,kBACjB,KAAI,CAAC,KAAK,CAAC,uBAAuB;gBAChC,CAAC,CAAC,KAAI,CAAC,KAAK,CAAC,uBAAuB;gBACpC,CAAC,CAAC,aAAa,0BACI,CAAC;YACxB,IAAI,aAAa,GAAG,EAAE,CAAC;YAEvB,QAAQ,KAAI,CAAC,KAAK,CAAC,IAAI,EAAE;gBACvB,KAAK,KAAK;oBACR,eAAe,GAAG,UAAG,gBAAgB,wBAAqB,CAAC;oBAC3D,aAAa,GAAG,SAAS,CAAC;oBAC1B,MAAM;gBACR,KAAK,MAAM;oBACT,eAAe,GAAG,UAAG,gBAAgB,kCAA+B,CAAC;oBACrE,aAAa,GAAG,SAAS,CAAC;oBAC1B,MAAM;gBACR;oBACE,eAAe,GAAG,UAAG,gBAAgB,+BAA4B,CAAC;oBAClE,aAAa,GAAG,SAAS,CAAC;aAC7B;YAED,OAAO,CACL,uCAAK,SAAS,EAAE,eAAe;gBAC5B,KAAI,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,CAC9B,uCAAK,SAAS,EAAE,UAAG,Y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