@quickbi/bi-open-menu-sdk 1.0.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # 说明
2
+
3
+ 基于 react 框架的自定义菜单 sdk
package/cjs/index.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ // Generated by dts-bundle v0.7.3
2
+ // Dependencies for this module:
3
+ // ../../../../../../../../../../@quickbi/bi-open
4
+ // ../../../../../../../../../../@quickbi/bi-open-react-sdk
5
+ // ../../../../../../../../../../react
6
+
7
+ declare module '@quickbi/bi-open-menu-sdk' {
8
+ export { I18n, formatNumberWithConfig, formatNumber, LATEST_VERSION, revisal, OLDEST_VERSION, getRevisalRange, } from '@quickbi/bi-open';
9
+ export type { Interfaces } from '@quickbi/bi-open';
10
+ export { createBIComponent } from '@quickbi/bi-open-react-sdk';
11
+ export { IconDefault, IconLoading, IconWrapper, MenuItem, CUSTOM_MENU_TOOLTIP_EVENT } from '@quickbi/bi-open-menu-sdk/components';
12
+ }
13
+
14
+ declare module '@quickbi/bi-open-menu-sdk/components' {
15
+ /**
16
+ * @flie 自定义菜单默认模板
17
+ */
18
+ import * as React from 'react';
19
+ export const CUSTOM_MENU_TOOLTIP_EVENT = "CUSTOM_MENU_TOOLTIP_EVENT";
20
+ export type IconComponent<P = React.HTMLAttributes<HTMLElement>> = React.FC<P>;
21
+ export const IconWrapper: IconComponent;
22
+ /** 菜单默认图标 */
23
+ export const IconDefault: IconComponent;
24
+ /** 菜单 loading 图标 */
25
+ export const IconLoading: IconComponent;
26
+ /**
27
+ * 默认自定义菜单
28
+ * @param param0
29
+ * @returns
30
+ */
31
+ export const MenuItem: React.FC<{
32
+ /** root element className */
33
+ className?: string;
34
+ /** root element style */
35
+ style?: React.StyleHTMLAttributes<HTMLDivElement>['style'];
36
+ /** 菜单标题 */
37
+ title?: string | React.ReactNode;
38
+ /** 菜单禁用 */
39
+ disabled?: boolean;
40
+ /** PC端鼠标 hover 提示 */
41
+ hoverTip?: string;
42
+ /** 是否加载中 */
43
+ loading?: boolean;
44
+ /** 点击事件 */
45
+ onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
46
+ /** 是否展示标题 */
47
+ showTitle?: boolean;
48
+ /** 是否展示图标 */
49
+ showIcon?: boolean;
50
+ }>;
51
+ }
52
+
package/cjs/index.js ADDED
@@ -0,0 +1,220 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/basic/bi-open/packages/bi-open-menu-sdk/src/index.ts
30
+ var src_exports = {};
31
+ __export(src_exports, {
32
+ CUSTOM_MENU_TOOLTIP_EVENT: () => CUSTOM_MENU_TOOLTIP_EVENT,
33
+ I18n: () => import_bi_open.I18n,
34
+ IconDefault: () => IconDefault,
35
+ IconLoading: () => IconLoading,
36
+ IconWrapper: () => IconWrapper,
37
+ LATEST_VERSION: () => import_bi_open.LATEST_VERSION,
38
+ MenuItem: () => MenuItem,
39
+ OLDEST_VERSION: () => import_bi_open.OLDEST_VERSION,
40
+ createBIComponent: () => import_bi_open_react_sdk.createBIComponent,
41
+ formatNumber: () => import_bi_open.formatNumber,
42
+ formatNumberWithConfig: () => import_bi_open.formatNumberWithConfig,
43
+ getRevisalRange: () => import_bi_open.getRevisalRange,
44
+ revisal: () => import_bi_open.revisal
45
+ });
46
+ module.exports = __toCommonJS(src_exports);
47
+ var import_bi_open = require("@quickbi/bi-open");
48
+ var import_bi_open_react_sdk = require("@quickbi/bi-open-react-sdk");
49
+
50
+ // src/basic/bi-open/packages/bi-open-menu-sdk/src/components.tsx
51
+ var React = __toESM(require("react"));
52
+ function _array_like_to_array(arr, len) {
53
+ if (len == null || len > arr.length) len = arr.length;
54
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
55
+ return arr2;
56
+ }
57
+ function _array_with_holes(arr) {
58
+ if (Array.isArray(arr)) return arr;
59
+ }
60
+ function _iterable_to_array_limit(arr, i) {
61
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
62
+ if (_i == null) return;
63
+ var _arr = [];
64
+ var _n = true;
65
+ var _d = false;
66
+ var _s, _e;
67
+ try {
68
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
69
+ _arr.push(_s.value);
70
+ if (i && _arr.length === i) break;
71
+ }
72
+ } catch (err) {
73
+ _d = true;
74
+ _e = err;
75
+ } finally {
76
+ try {
77
+ if (!_n && _i["return"] != null) _i["return"]();
78
+ } finally {
79
+ if (_d) throw _e;
80
+ }
81
+ }
82
+ return _arr;
83
+ }
84
+ function _non_iterable_rest() {
85
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
86
+ }
87
+ function _sliced_to_array(arr, i) {
88
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
89
+ }
90
+ function _unsupported_iterable_to_array(o, minLen) {
91
+ if (!o) return;
92
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
93
+ var n = Object.prototype.toString.call(o).slice(8, -1);
94
+ if (n === "Object" && o.constructor) n = o.constructor.name;
95
+ if (n === "Map" || n === "Set") return Array.from(n);
96
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
97
+ }
98
+ var CUSTOM_MENU_TOOLTIP_EVENT = "CUSTOM_MENU_TOOLTIP_EVENT";
99
+ var IconWrapper = function(props) {
100
+ return /* @__PURE__ */ React.createElement("i", props, /* @__PURE__ */ React.createElement("svg", {
101
+ viewBox: "0 0 1024 1024",
102
+ "aria-hidden": "true",
103
+ width: "1em",
104
+ height: "1em",
105
+ fill: "currentColor"
106
+ }, props.children));
107
+ };
108
+ var IconDefault = function(props) {
109
+ return /* @__PURE__ */ React.createElement(IconWrapper, props, /* @__PURE__ */ React.createElement("path", {
110
+ d: "M838.193105 907.620131V1023.99744H582.193745a23.193542 23.193542 0 0 1-23.295942-23.295942v-23.449541c0-82.380594-47.206282-139.468451-139.98045-139.468451-91.85257 0-139.673251 57.599856-139.673251 139.468451v23.449541a23.244742 23.244742 0 0 1-23.295942 23.244742H116.377309L0.0512 1023.99744v-116.428509l0.511999-139.673251a23.244742 23.244742 0 0 1 23.244742-23.142342h46.489483c64.10224 0 116.07011-60.262249 116.07011-139.622051 0-80.0766-51.660671-139.673251-116.07011-139.673251H23.654341a23.244742 23.244742 0 0 1-23.295942-23.244742V302.591244c0-23.80794-0.1024-62.617443-0.307199-116.37731h232.703418v-0.204799C232.754618 80.1278 299.314452 0 418.968553 0c116.735708 0 186.930733 82.278194 186.930732 186.009135v0.1536h116.530909c15.564761 0 54.374264 0 116.377309-0.1536v232.857018h22.630344c91.647771 0 162.610793 81.868595 162.610793 186.213934 0 103.730941-71.167822 186.162735-162.610793 186.162735h-23.244742v116.377309z"
111
+ }));
112
+ };
113
+ var IconLoading = function(props) {
114
+ return /* @__PURE__ */ React.createElement(IconWrapper, props, /* @__PURE__ */ React.createElement("path", {
115
+ d: "M960 447.008q-11.008-152.992-120-261.504t-260.992-120.512q-16-0.992-27.488 9.504t-11.488 26.496q0 14.016 9.504 24.512t23.488 11.488q55.008 4 107.008 26.016 60.992 26.016 108.992 73.504t74.016 109.504q22.016 51.008 26.016 106.016 0.992 14.016 11.488 23.488t24.512 9.504q15.008 0 26.016-11.008 11.008-12 8.992-27.008z"
116
+ }));
117
+ };
118
+ function getComponentInfoByDom(elem) {
119
+ if (!elem || elem.nodeName.toUpperCase() === "BODY") {
120
+ return {
121
+ componentType: "",
122
+ name: ""
123
+ };
124
+ }
125
+ if (typeof elem.hasAttribute === "function" && elem.hasAttribute("data-custom-component-root")) {
126
+ return {
127
+ componentType: elem.getAttribute("data-custom-component-type"),
128
+ name: elem.getAttribute("data-custom-component-name")
129
+ };
130
+ }
131
+ return getComponentInfoByDom(elem.parentNode);
132
+ }
133
+ var MenuItem = function(param) {
134
+ var className = param.className, style = param.style, title = param.title, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, _param_loading = param.loading, loading = _param_loading === void 0 ? false : _param_loading, hoverTip = param.hoverTip, onClick = param.onClick, _param_showTitle = param.showTitle, showTitle = _param_showTitle === void 0 ? true : _param_showTitle, _param_showIcon = param.showIcon, showIcon = _param_showIcon === void 0 ? true : _param_showIcon;
135
+ var _React_useState = _sliced_to_array(React.useState(""), 2), icon = _React_useState[0], setIcon = _React_useState[1];
136
+ var _React_useState1 = _sliced_to_array(React.useState(""), 2), originTitle = _React_useState1[0], setOriginTitle = _React_useState1[1];
137
+ var ref = React.useRef();
138
+ React.useEffect(function() {
139
+ if (ref.current) {
140
+ var doc = ref.current.getRootNode();
141
+ var iconElem = doc.querySelector("#custom-component-icon");
142
+ var _getComponentInfoByDom = getComponentInfoByDom(ref.current), componentType = _getComponentInfoByDom.componentType, name = _getComponentInfoByDom.name;
143
+ setOriginTitle(name);
144
+ if (iconElem && iconElem.textContent.indexOf(".icon-".concat(componentType)) >= 0) {
145
+ setIcon("icon-".concat(componentType));
146
+ }
147
+ }
148
+ }, []);
149
+ var setTip = React.useCallback(function(visible) {
150
+ if (ref.current) {
151
+ var container = ref.current.closest("[data-custom-component-root]");
152
+ if (hoverTip && typeof hoverTip === "string" && container) {
153
+ container.dispatchEvent(new CustomEvent(CUSTOM_MENU_TOOLTIP_EVENT, {
154
+ detail: {
155
+ title: hoverTip,
156
+ visible
157
+ }
158
+ }));
159
+ }
160
+ }
161
+ }, [
162
+ hoverTip
163
+ ]);
164
+ var iconContent = /* @__PURE__ */ React.createElement(IconDefault, {
165
+ className: "default-icon"
166
+ });
167
+ if (icon) {
168
+ iconContent = /* @__PURE__ */ React.createElement("i", {
169
+ className: "upload-icon ".concat(icon)
170
+ });
171
+ }
172
+ if (loading) {
173
+ iconContent = /* @__PURE__ */ React.createElement(IconLoading, {
174
+ className: "default-icon animate-cricle"
175
+ });
176
+ }
177
+ var handleClick = React.useCallback(function(e) {
178
+ if (typeof onClick === "function" && !disabled) {
179
+ onClick(e);
180
+ e.stopPropagation();
181
+ }
182
+ }, [
183
+ disabled,
184
+ onClick
185
+ ]);
186
+ var handleMouseEnter = React.useCallback(function(e) {
187
+ setTip(true);
188
+ }, [
189
+ setTip
190
+ ]);
191
+ var handleMouseLeave = React.useCallback(function(e) {
192
+ setTip(false);
193
+ }, [
194
+ setTip
195
+ ]);
196
+ var viewTitle = React.useMemo(function() {
197
+ var propsTitle = typeof title === "string" ? title : void 0;
198
+ var _ref;
199
+ return (_ref = propsTitle !== null && propsTitle !== void 0 ? propsTitle : originTitle) !== null && _ref !== void 0 ? _ref : "";
200
+ }, [
201
+ originTitle,
202
+ title
203
+ ]);
204
+ if (!showTitle && !showIcon) {
205
+ return null;
206
+ }
207
+ return /* @__PURE__ */ React.createElement("div", {
208
+ ref,
209
+ className: "custom-card-menu ".concat(disabled ? "disabled" : "", " ").concat(className || ""),
210
+ style,
211
+ onClick: handleClick,
212
+ title: viewTitle,
213
+ onMouseOver: handleMouseEnter,
214
+ onMouseLeave: handleMouseLeave
215
+ }, showIcon ? /* @__PURE__ */ React.createElement("div", {
216
+ className: "custom-card-menu-icon"
217
+ }, iconContent) : null, showTitle ? /* @__PURE__ */ React.createElement("div", {
218
+ className: "custom-card-menu-text"
219
+ }, viewTitle) : null);
220
+ };
package/esm/index.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ // Generated by dts-bundle v0.7.3
2
+ // Dependencies for this module:
3
+ // ../../../../../../../../../../@quickbi/bi-open
4
+ // ../../../../../../../../../../@quickbi/bi-open-react-sdk
5
+ // ../../../../../../../../../../react
6
+
7
+ declare module '@quickbi/bi-open-menu-sdk' {
8
+ export { I18n, formatNumberWithConfig, formatNumber, LATEST_VERSION, revisal, OLDEST_VERSION, getRevisalRange, } from '@quickbi/bi-open';
9
+ export type { Interfaces } from '@quickbi/bi-open';
10
+ export { createBIComponent } from '@quickbi/bi-open-react-sdk';
11
+ export { IconDefault, IconLoading, IconWrapper, MenuItem, CUSTOM_MENU_TOOLTIP_EVENT } from '@quickbi/bi-open-menu-sdk/components';
12
+ }
13
+
14
+ declare module '@quickbi/bi-open-menu-sdk/components' {
15
+ /**
16
+ * @flie 自定义菜单默认模板
17
+ */
18
+ import * as React from 'react';
19
+ export const CUSTOM_MENU_TOOLTIP_EVENT = "CUSTOM_MENU_TOOLTIP_EVENT";
20
+ export type IconComponent<P = React.HTMLAttributes<HTMLElement>> = React.FC<P>;
21
+ export const IconWrapper: IconComponent;
22
+ /** 菜单默认图标 */
23
+ export const IconDefault: IconComponent;
24
+ /** 菜单 loading 图标 */
25
+ export const IconLoading: IconComponent;
26
+ /**
27
+ * 默认自定义菜单
28
+ * @param param0
29
+ * @returns
30
+ */
31
+ export const MenuItem: React.FC<{
32
+ /** root element className */
33
+ className?: string;
34
+ /** root element style */
35
+ style?: React.StyleHTMLAttributes<HTMLDivElement>['style'];
36
+ /** 菜单标题 */
37
+ title?: string | React.ReactNode;
38
+ /** 菜单禁用 */
39
+ disabled?: boolean;
40
+ /** PC端鼠标 hover 提示 */
41
+ hoverTip?: string;
42
+ /** 是否加载中 */
43
+ loading?: boolean;
44
+ /** 点击事件 */
45
+ onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
46
+ /** 是否展示标题 */
47
+ showTitle?: boolean;
48
+ /** 是否展示图标 */
49
+ showIcon?: boolean;
50
+ }>;
51
+ }
52
+
package/esm/index.mjs ADDED
@@ -0,0 +1,190 @@
1
+ // src/basic/bi-open/packages/bi-open-menu-sdk/src/index.ts
2
+ import { I18n, formatNumberWithConfig, formatNumber, LATEST_VERSION, revisal, OLDEST_VERSION, getRevisalRange } from "@quickbi/bi-open";
3
+ import { createBIComponent } from "@quickbi/bi-open-react-sdk";
4
+
5
+ // src/basic/bi-open/packages/bi-open-menu-sdk/src/components.tsx
6
+ import * as React from "react";
7
+ function _array_like_to_array(arr, len) {
8
+ if (len == null || len > arr.length) len = arr.length;
9
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
10
+ return arr2;
11
+ }
12
+ function _array_with_holes(arr) {
13
+ if (Array.isArray(arr)) return arr;
14
+ }
15
+ function _iterable_to_array_limit(arr, i) {
16
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
17
+ if (_i == null) return;
18
+ var _arr = [];
19
+ var _n = true;
20
+ var _d = false;
21
+ var _s, _e;
22
+ try {
23
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
24
+ _arr.push(_s.value);
25
+ if (i && _arr.length === i) break;
26
+ }
27
+ } catch (err) {
28
+ _d = true;
29
+ _e = err;
30
+ } finally {
31
+ try {
32
+ if (!_n && _i["return"] != null) _i["return"]();
33
+ } finally {
34
+ if (_d) throw _e;
35
+ }
36
+ }
37
+ return _arr;
38
+ }
39
+ function _non_iterable_rest() {
40
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41
+ }
42
+ function _sliced_to_array(arr, i) {
43
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
44
+ }
45
+ function _unsupported_iterable_to_array(o, minLen) {
46
+ if (!o) return;
47
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
48
+ var n = Object.prototype.toString.call(o).slice(8, -1);
49
+ if (n === "Object" && o.constructor) n = o.constructor.name;
50
+ if (n === "Map" || n === "Set") return Array.from(n);
51
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
52
+ }
53
+ var CUSTOM_MENU_TOOLTIP_EVENT = "CUSTOM_MENU_TOOLTIP_EVENT";
54
+ var IconWrapper = function(props) {
55
+ return /* @__PURE__ */ React.createElement("i", props, /* @__PURE__ */ React.createElement("svg", {
56
+ viewBox: "0 0 1024 1024",
57
+ "aria-hidden": "true",
58
+ width: "1em",
59
+ height: "1em",
60
+ fill: "currentColor"
61
+ }, props.children));
62
+ };
63
+ var IconDefault = function(props) {
64
+ return /* @__PURE__ */ React.createElement(IconWrapper, props, /* @__PURE__ */ React.createElement("path", {
65
+ d: "M838.193105 907.620131V1023.99744H582.193745a23.193542 23.193542 0 0 1-23.295942-23.295942v-23.449541c0-82.380594-47.206282-139.468451-139.98045-139.468451-91.85257 0-139.673251 57.599856-139.673251 139.468451v23.449541a23.244742 23.244742 0 0 1-23.295942 23.244742H116.377309L0.0512 1023.99744v-116.428509l0.511999-139.673251a23.244742 23.244742 0 0 1 23.244742-23.142342h46.489483c64.10224 0 116.07011-60.262249 116.07011-139.622051 0-80.0766-51.660671-139.673251-116.07011-139.673251H23.654341a23.244742 23.244742 0 0 1-23.295942-23.244742V302.591244c0-23.80794-0.1024-62.617443-0.307199-116.37731h232.703418v-0.204799C232.754618 80.1278 299.314452 0 418.968553 0c116.735708 0 186.930733 82.278194 186.930732 186.009135v0.1536h116.530909c15.564761 0 54.374264 0 116.377309-0.1536v232.857018h22.630344c91.647771 0 162.610793 81.868595 162.610793 186.213934 0 103.730941-71.167822 186.162735-162.610793 186.162735h-23.244742v116.377309z"
66
+ }));
67
+ };
68
+ var IconLoading = function(props) {
69
+ return /* @__PURE__ */ React.createElement(IconWrapper, props, /* @__PURE__ */ React.createElement("path", {
70
+ d: "M960 447.008q-11.008-152.992-120-261.504t-260.992-120.512q-16-0.992-27.488 9.504t-11.488 26.496q0 14.016 9.504 24.512t23.488 11.488q55.008 4 107.008 26.016 60.992 26.016 108.992 73.504t74.016 109.504q22.016 51.008 26.016 106.016 0.992 14.016 11.488 23.488t24.512 9.504q15.008 0 26.016-11.008 11.008-12 8.992-27.008z"
71
+ }));
72
+ };
73
+ function getComponentInfoByDom(elem) {
74
+ if (!elem || elem.nodeName.toUpperCase() === "BODY") {
75
+ return {
76
+ componentType: "",
77
+ name: ""
78
+ };
79
+ }
80
+ if (typeof elem.hasAttribute === "function" && elem.hasAttribute("data-custom-component-root")) {
81
+ return {
82
+ componentType: elem.getAttribute("data-custom-component-type"),
83
+ name: elem.getAttribute("data-custom-component-name")
84
+ };
85
+ }
86
+ return getComponentInfoByDom(elem.parentNode);
87
+ }
88
+ var MenuItem = function(param) {
89
+ var className = param.className, style = param.style, title = param.title, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, _param_loading = param.loading, loading = _param_loading === void 0 ? false : _param_loading, hoverTip = param.hoverTip, onClick = param.onClick, _param_showTitle = param.showTitle, showTitle = _param_showTitle === void 0 ? true : _param_showTitle, _param_showIcon = param.showIcon, showIcon = _param_showIcon === void 0 ? true : _param_showIcon;
90
+ var _React_useState = _sliced_to_array(React.useState(""), 2), icon = _React_useState[0], setIcon = _React_useState[1];
91
+ var _React_useState1 = _sliced_to_array(React.useState(""), 2), originTitle = _React_useState1[0], setOriginTitle = _React_useState1[1];
92
+ var ref = React.useRef();
93
+ React.useEffect(function() {
94
+ if (ref.current) {
95
+ var doc = ref.current.getRootNode();
96
+ var iconElem = doc.querySelector("#custom-component-icon");
97
+ var _getComponentInfoByDom = getComponentInfoByDom(ref.current), componentType = _getComponentInfoByDom.componentType, name = _getComponentInfoByDom.name;
98
+ setOriginTitle(name);
99
+ if (iconElem && iconElem.textContent.indexOf(".icon-".concat(componentType)) >= 0) {
100
+ setIcon("icon-".concat(componentType));
101
+ }
102
+ }
103
+ }, []);
104
+ var setTip = React.useCallback(function(visible) {
105
+ if (ref.current) {
106
+ var container = ref.current.closest("[data-custom-component-root]");
107
+ if (hoverTip && typeof hoverTip === "string" && container) {
108
+ container.dispatchEvent(new CustomEvent(CUSTOM_MENU_TOOLTIP_EVENT, {
109
+ detail: {
110
+ title: hoverTip,
111
+ visible
112
+ }
113
+ }));
114
+ }
115
+ }
116
+ }, [
117
+ hoverTip
118
+ ]);
119
+ var iconContent = /* @__PURE__ */ React.createElement(IconDefault, {
120
+ className: "default-icon"
121
+ });
122
+ if (icon) {
123
+ iconContent = /* @__PURE__ */ React.createElement("i", {
124
+ className: "upload-icon ".concat(icon)
125
+ });
126
+ }
127
+ if (loading) {
128
+ iconContent = /* @__PURE__ */ React.createElement(IconLoading, {
129
+ className: "default-icon animate-cricle"
130
+ });
131
+ }
132
+ var handleClick = React.useCallback(function(e) {
133
+ if (typeof onClick === "function" && !disabled) {
134
+ onClick(e);
135
+ e.stopPropagation();
136
+ }
137
+ }, [
138
+ disabled,
139
+ onClick
140
+ ]);
141
+ var handleMouseEnter = React.useCallback(function(e) {
142
+ setTip(true);
143
+ }, [
144
+ setTip
145
+ ]);
146
+ var handleMouseLeave = React.useCallback(function(e) {
147
+ setTip(false);
148
+ }, [
149
+ setTip
150
+ ]);
151
+ var viewTitle = React.useMemo(function() {
152
+ var propsTitle = typeof title === "string" ? title : void 0;
153
+ var _ref;
154
+ return (_ref = propsTitle !== null && propsTitle !== void 0 ? propsTitle : originTitle) !== null && _ref !== void 0 ? _ref : "";
155
+ }, [
156
+ originTitle,
157
+ title
158
+ ]);
159
+ if (!showTitle && !showIcon) {
160
+ return null;
161
+ }
162
+ return /* @__PURE__ */ React.createElement("div", {
163
+ ref,
164
+ className: "custom-card-menu ".concat(disabled ? "disabled" : "", " ").concat(className || ""),
165
+ style,
166
+ onClick: handleClick,
167
+ title: viewTitle,
168
+ onMouseOver: handleMouseEnter,
169
+ onMouseLeave: handleMouseLeave
170
+ }, showIcon ? /* @__PURE__ */ React.createElement("div", {
171
+ className: "custom-card-menu-icon"
172
+ }, iconContent) : null, showTitle ? /* @__PURE__ */ React.createElement("div", {
173
+ className: "custom-card-menu-text"
174
+ }, viewTitle) : null);
175
+ };
176
+ export {
177
+ CUSTOM_MENU_TOOLTIP_EVENT,
178
+ I18n,
179
+ IconDefault,
180
+ IconLoading,
181
+ IconWrapper,
182
+ LATEST_VERSION,
183
+ MenuItem,
184
+ OLDEST_VERSION,
185
+ createBIComponent,
186
+ formatNumber,
187
+ formatNumberWithConfig,
188
+ getRevisalRange,
189
+ revisal
190
+ };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@quickbi/bi-open-menu-sdk",
3
+ "version": "1.0.0",
4
+ "main": "./cjs/index.js",
5
+ "dependencies": {
6
+ "@quickbi/bi-open": "4.0.0",
7
+ "@quickbi/bi-open-react-sdk": "3.0.0"
8
+ },
9
+ "publishConfig": {
10
+ "registry": "https://registry.npmjs.org",
11
+ "access": "public"
12
+ },
13
+ "sideEffects": false,
14
+ "files": [
15
+ "esm",
16
+ "cjs",
17
+ "README.md"
18
+ ],
19
+ "author": "Quick BI team",
20
+ "peerDependencies": {
21
+ "react": ">=16.14.0"
22
+ },
23
+ "module": "./esm/index.mjs",
24
+ "browser": "./esm/index.mjs",
25
+ "exports": {
26
+ ".": {
27
+ "import": "./esm/index.mjs",
28
+ "require": "./cjs/index.js",
29
+ "default": "./esm/index.mjs",
30
+ "types": "./esm/index.d.ts"
31
+ },
32
+ "./*.css": {
33
+ "import": "./esm/*.css",
34
+ "require": "./cjs/*.css",
35
+ "default": "./esm/*.css"
36
+ }
37
+ },
38
+ "revisalInfo": {
39
+ "version": "4.1"
40
+ }
41
+ }