@platox/pivot-table 0.0.32 → 0.0.34
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/es/dashboard-workbench/components/add-module-btn/index.d.ts +11 -0
- package/es/dashboard-workbench/components/add-module-btn/index.js +97 -0
- package/es/dashboard-workbench/components/add-module-btn/index.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.d.ts +20 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js +178 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.d.ts +17 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js +91 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.d.ts +27 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js +328 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.d.ts +15 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js +58 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.d.ts +20 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js +123 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.d.ts +20 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js +180 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.d.ts +13 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js +119 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.d.ts +19 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js +120 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.d.ts +12 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.js +44 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.d.ts +21 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js +510 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/utils.d.ts +25 -0
- package/es/dashboard-workbench/components/add-module-modal/components/select-color/index.d.ts +12 -0
- package/es/dashboard-workbench/components/add-module-modal/components/select-color/index.js +45 -0
- package/es/dashboard-workbench/components/add-module-modal/components/select-color/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/index.d.ts +14 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/index.js +231 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.d.ts +8 -0
- package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js +62 -0
- package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/chart-module/index.d.ts +14 -0
- package/es/dashboard-workbench/components/module-content/chart-module/index.js +384 -0
- package/es/dashboard-workbench/components/module-content/chart-module/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/chart-module/utils.d.ts +9 -0
- package/es/dashboard-workbench/components/module-content/chart-module/utils.js +200 -0
- package/es/dashboard-workbench/components/module-content/chart-module/utils.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/index.d.ts +31 -0
- package/es/dashboard-workbench/components/module-content/index.js +81 -0
- package/es/dashboard-workbench/components/module-content/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/index.d.ts +15 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/index.js +305 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/utils.d.ts +4 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/utils.js +41 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/utils.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/index.d.ts +7 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/index.js +224 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/useDebounce.d.ts +2 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/useDebounce.js +24 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/useDebounce.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/text-module/index.d.ts +7 -0
- package/es/dashboard-workbench/components/module-content/text-module/index.js +11 -0
- package/es/dashboard-workbench/components/module-content/text-module/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/utils.d.ts +15 -0
- package/es/dashboard-workbench/components/module-content/utils.js +113 -0
- package/es/dashboard-workbench/components/module-content/utils.js.map +1 -0
- package/es/dashboard-workbench/components/module-header/index.d.ts +12 -0
- package/es/dashboard-workbench/components/module-header/index.js +115 -0
- package/es/dashboard-workbench/components/module-header/index.js.map +1 -0
- package/es/dashboard-workbench/context.d.ts +16 -0
- package/es/dashboard-workbench/context.js +21 -0
- package/es/dashboard-workbench/context.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-bar-percentage.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-bar-percentage.js +17 -0
- package/es/dashboard-workbench/icon/icon-bar-percentage.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-bar-pile.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-bar-pile.js +17 -0
- package/es/dashboard-workbench/icon/icon-bar-pile.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-bar.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-bar.js +13 -0
- package/es/dashboard-workbench/icon/icon-bar.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-calendar.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-calendar.js +40 -0
- package/es/dashboard-workbench/icon/icon-calendar.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-drag.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-drag.js +25 -0
- package/es/dashboard-workbench/icon/icon-drag.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-editor.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-editor.js +40 -0
- package/es/dashboard-workbench/icon/icon-editor.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-line-smooth.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-line-smooth.js +28 -0
- package/es/dashboard-workbench/icon/icon-line-smooth.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-line.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-line.js +28 -0
- package/es/dashboard-workbench/icon/icon-line.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-move.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-move.js +25 -0
- package/es/dashboard-workbench/icon/icon-move.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-pie-circular.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-pie-circular.js +30 -0
- package/es/dashboard-workbench/icon/icon-pie-circular.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-pie.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-pie.js +24 -0
- package/es/dashboard-workbench/icon/icon-pie.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-statistics.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-statistics.js +37 -0
- package/es/dashboard-workbench/icon/icon-statistics.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-percentage.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-percentage.js +105 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-percentage.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-pile.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-pile.js +105 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-pile.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-strip-bar.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-strip-bar.js +57 -0
- package/es/dashboard-workbench/icon/icon-strip-bar.js.map +1 -0
- package/es/dashboard-workbench/index.d.ts +33 -0
- package/es/dashboard-workbench/index.js +435 -0
- package/es/dashboard-workbench/index.js.map +1 -0
- package/es/dashboard-workbench/lang/en-US.d.ts +146 -0
- package/es/dashboard-workbench/lang/en-US.js +157 -0
- package/es/dashboard-workbench/lang/en-US.js.map +1 -0
- package/es/dashboard-workbench/lang/index.d.ts +2 -0
- package/es/dashboard-workbench/lang/index.js +25 -0
- package/es/dashboard-workbench/lang/index.js.map +1 -0
- package/es/dashboard-workbench/lang/zh-CN.d.ts +146 -0
- package/es/dashboard-workbench/lang/zh-CN.js +157 -0
- package/es/dashboard-workbench/lang/zh-CN.js.map +1 -0
- package/es/dashboard-workbench/types.d.ts +22 -0
- package/es/dashboard-workbench/utils/index.d.ts +9 -0
- package/es/dashboard-workbench/utils/index.js +30 -0
- package/es/dashboard-workbench/utils/index.js.map +1 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +5 -0
- package/es/index.js.map +1 -0
- package/es/style.css +1 -0
- package/package.json +27 -24
- package/umd/pivot-table.umd.cjs +178 -0
- package/umd/style.css +1 -0
- package/index.d.ts +0 -98
- package/lib/index.js +0 -52233
- package/lib/index.umd.cjs +0 -178
- package/lib/style.css +0 -1
package/es/dashboard-workbench/components/add-module-modal/components/select-color/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../packages/dashboard-workbench/components/add-module-modal/components/select-color/index.tsx"],"sourcesContent":["import { CheckOutlined } from '@ant-design/icons'\nimport './index.less'\nimport { useEffect, useState } from 'react'\n\nexport type StatisticsCustomeStylesTypes = {\n color?: string\n unit?: string\n precision?: number\n desc: string\n}\n\ninterface CustomeStylesProps {\n value?: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange?: ((values: any) => void) | undefined\n}\nconst CustomeStyles: React.FC<CustomeStylesProps> = ({ value, onChange }) => {\n const [color, setColor] = useState<string | undefined>()\n const colors = [\n '#373c43',\n '#3370ff',\n '#4954e6',\n '#34c724',\n '#14c0ff',\n '#ffc60a',\n '#f80',\n '#f76964',\n ]\n\n useEffect(() => {\n setColor(value)\n }, [value])\n\n return (\n <div className=\"pane-item-body item-body-column\">\n <div className=\"panel-single-color-selector\">\n {colors.map((item, idx) => (\n <div\n key={idx}\n className=\"panel-single-color-selector-color-item\"\n onClick={() => {\n setColor(item)\n onChange?.(item)\n }}\n >\n <div\n className=\"panel-single-color-selector-color-item-background\"\n style={{ background: item }}\n ></div>\n {color === item ? (\n <span className=\"panel-icon\">\n <CheckOutlined />\n </span>\n ) : null}\n </div>\n ))}\n </div>\n </div>\n )\n}\nexport default CustomeStyles\n"],"names":[],"mappings":";;;;AAgBA,MAAM,gBAA8C,CAAC,EAAE,OAAO,eAAe;AAC3E,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA6B;AACvD,QAAM,SAAS;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,YAAU,MAAM;AACd,aAAS,KAAK;AAAA,EAAA,GACb,CAAC,KAAK,CAAC;AAEV,SACG,oBAAA,OAAA,EAAI,WAAU,mCACb,UAAC,oBAAA,OAAA,EAAI,WAAU,+BACZ,UAAO,OAAA,IAAI,CAAC,MAAM,QACjB;AAAA,IAAC;AAAA,IAAA;AAAA,MAEC,WAAU;AAAA,MACV,SAAS,MAAM;AACb,iBAAS,IAAI;AACb,6CAAW;AAAA,MACb;AAAA,MAEA,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,OAAO,EAAE,YAAY,KAAK;AAAA,UAAA;AAAA,QAC3B;AAAA,QACA,UAAU,OACR,oBAAA,QAAA,EAAK,WAAU,cACd,UAAA,oBAAC,eAAc,CAAA,CAAA,EACjB,CAAA,IACE;AAAA,MAAA;AAAA,IAAA;AAAA,IAfC;AAAA,EAAA,CAiBR,GACH,EACF,CAAA;AAEJ;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ModuleDataApi } from '../../../types';
|
|
3
|
+
import { CalendarCustomeDataTypes } from '../../add-module-modal/add-calendar-modal/custome-data';
|
|
4
|
+
interface CalendarModuleProps {
|
|
5
|
+
customData?: CalendarCustomeDataTypes;
|
|
6
|
+
onChange?: (val: unknown) => void;
|
|
7
|
+
moduleDataApi?: ModuleDataApi;
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
rowWidth?: number;
|
|
11
|
+
rowHeight?: number;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: React.NamedExoticComponent<CalendarModuleProps>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState, useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import FullCalendar from "@fullcalendar/react";
|
|
4
|
+
import dayGridPlugin from "@fullcalendar/daygrid";
|
|
5
|
+
import dayjs from "dayjs";
|
|
6
|
+
import isBetween from "dayjs/plugin/isBetween";
|
|
7
|
+
import { useAppContext } from "../../../context.js";
|
|
8
|
+
import { useTranslation } from "react-i18next";
|
|
9
|
+
import { mapConditionsToPostgrest } from "../utils.js";
|
|
10
|
+
import { message, Spin, Modal, Descriptions } from "antd";
|
|
11
|
+
import { getTransformValue } from "../../../utils/index.js";
|
|
12
|
+
import { useMemoizedFn, useSize } from "ahooks";
|
|
13
|
+
dayjs.extend(isBetween);
|
|
14
|
+
const CalendarModule = ({
|
|
15
|
+
moduleDataApi,
|
|
16
|
+
customData,
|
|
17
|
+
width,
|
|
18
|
+
height
|
|
19
|
+
}) => {
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const { globalData } = useAppContext();
|
|
22
|
+
const [startMonthIntervals, setStartMonthIntervals] = useState(["", ""]);
|
|
23
|
+
const handleDatesSet = (dateInfo) => {
|
|
24
|
+
const currentDate = dayjs(dateInfo.view.currentStart);
|
|
25
|
+
const firstDay = currentDate.startOf("month").format("YYYY-MM-DD");
|
|
26
|
+
const lastDay = currentDate.endOf("month").format("YYYY-MM-DD");
|
|
27
|
+
setStartMonthIntervals([firstDay, lastDay]);
|
|
28
|
+
};
|
|
29
|
+
const [isloading, setIsloading] = useState(false);
|
|
30
|
+
const [chartData, setChartData] = useState();
|
|
31
|
+
const fetchChartData = useMemoizedFn(async () => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
setChartData([]);
|
|
34
|
+
if (customData) {
|
|
35
|
+
setIsloading(true);
|
|
36
|
+
let queryString = "";
|
|
37
|
+
const firstDayOfMonth = dayjs().startOf("month").format("YYYY-MM-DD");
|
|
38
|
+
const lastDayOfMonth = dayjs().endOf("month").format("YYYY-MM-DD");
|
|
39
|
+
const conditionData = customData.conditionData;
|
|
40
|
+
const FMDay = startMonthIntervals.length > 0 ? startMonthIntervals[0] : firstDayOfMonth;
|
|
41
|
+
const LMDay = startMonthIntervals.length > 0 ? startMonthIntervals[1] : lastDayOfMonth;
|
|
42
|
+
if (conditionData) {
|
|
43
|
+
if ((_b = (_a = conditionData == null ? void 0 : conditionData.conditionList) == null ? void 0 : _a.map((item) => item.type)) == null ? void 0 : _b.includes("timestamp")) {
|
|
44
|
+
queryString += `${mapConditionsToPostgrest(conditionData)}`;
|
|
45
|
+
} else {
|
|
46
|
+
queryString += `added_on=gt.${FMDay}&added_on=lt.${LMDay}&${mapConditionsToPostgrest(
|
|
47
|
+
conditionData
|
|
48
|
+
)}`;
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
queryString = `added_on=gt.${FMDay}&added_on=lt.${LMDay}`;
|
|
52
|
+
}
|
|
53
|
+
if (customData == null ? void 0 : customData.dataSourceId) {
|
|
54
|
+
moduleDataApi == null ? void 0 : moduleDataApi({
|
|
55
|
+
id: customData == null ? void 0 : customData.dataSourceId,
|
|
56
|
+
query: queryString
|
|
57
|
+
}).then((res) => {
|
|
58
|
+
if (!res.success) {
|
|
59
|
+
message.error(res.message);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
setChartData(res.data);
|
|
63
|
+
}).finally(() => {
|
|
64
|
+
setIsloading(false);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (customData) {
|
|
71
|
+
fetchChartData();
|
|
72
|
+
}
|
|
73
|
+
}, [customData == null ? void 0 : customData.dataSourceId, customData == null ? void 0 : customData.conditionData, startMonthIntervals]);
|
|
74
|
+
const fieldOptions = useMemo(() => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
return (_b = (_a = globalData == null ? void 0 : globalData.sourceData) == null ? void 0 : _a.find((item) => item.value === (customData == null ? void 0 : customData.dataSourceId))) == null ? void 0 : _b.fields;
|
|
77
|
+
}, [globalData, customData]);
|
|
78
|
+
const events = useMemo(() => {
|
|
79
|
+
const calendarEvents = chartData == null ? void 0 : chartData.map((item) => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
const title = getTransformValue({
|
|
82
|
+
fieldOptions,
|
|
83
|
+
val: (customData == null ? void 0 : customData.titleField) ? item == null ? void 0 : item[customData.titleField] : "",
|
|
84
|
+
field: customData == null ? void 0 : customData.titleField,
|
|
85
|
+
fieldMap: globalData == null ? void 0 : globalData.fieldMap
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
title: title ?? t("unnamedRecord"),
|
|
89
|
+
start: (customData == null ? void 0 : customData.startDateField) && item[customData == null ? void 0 : customData.startDateField] ? (_a = dayjs(item[customData == null ? void 0 : customData.startDateField])) == null ? void 0 : _a.toISOString() : "",
|
|
90
|
+
end: (customData == null ? void 0 : customData.endDateField) && item[customData == null ? void 0 : customData.endDateField] ? (_b = dayjs(item[customData == null ? void 0 : customData.endDateField])) == null ? void 0 : _b.toISOString() : void 0,
|
|
91
|
+
allDay: true,
|
|
92
|
+
...item,
|
|
93
|
+
originalData: item
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
return calendarEvents;
|
|
97
|
+
}, [chartData, customData, fieldOptions]);
|
|
98
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
99
|
+
const [currData, setCurrData] = useState();
|
|
100
|
+
const currTitle = getTransformValue({
|
|
101
|
+
fieldOptions,
|
|
102
|
+
val: (customData == null ? void 0 : customData.titleField) ? currData == null ? void 0 : currData[customData.titleField] : "",
|
|
103
|
+
field: customData == null ? void 0 : customData.titleField,
|
|
104
|
+
fieldMap: globalData == null ? void 0 : globalData.fieldMap
|
|
105
|
+
});
|
|
106
|
+
const handleEventClick = useMemoizedFn((info) => {
|
|
107
|
+
var _a;
|
|
108
|
+
const event = info.event;
|
|
109
|
+
setIsModalOpen(true);
|
|
110
|
+
setCurrData((_a = event.extendedProps) == null ? void 0 : _a.originalData);
|
|
111
|
+
});
|
|
112
|
+
const boxRef = useRef();
|
|
113
|
+
const calendarRef = useRef(null);
|
|
114
|
+
const size = useSize(boxRef);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
var _a, _b;
|
|
118
|
+
(_b = (_a = calendarRef.current) == null ? void 0 : _a.getApi()) == null ? void 0 : _b.updateSize();
|
|
119
|
+
}, 16);
|
|
120
|
+
}, [size]);
|
|
121
|
+
return /* @__PURE__ */ jsx(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
ref: boxRef,
|
|
125
|
+
style: {
|
|
126
|
+
height: "100%",
|
|
127
|
+
width: "100%",
|
|
128
|
+
boxSizing: "border-box",
|
|
129
|
+
padding: "12px"
|
|
130
|
+
},
|
|
131
|
+
children: /* @__PURE__ */ jsxs(
|
|
132
|
+
"div",
|
|
133
|
+
{
|
|
134
|
+
className: "full-calendar-app",
|
|
135
|
+
style: {
|
|
136
|
+
height: "100%",
|
|
137
|
+
width: "100%",
|
|
138
|
+
overflowY: "auto",
|
|
139
|
+
position: "relative"
|
|
140
|
+
},
|
|
141
|
+
children: [
|
|
142
|
+
isloading ? /* @__PURE__ */ jsx(
|
|
143
|
+
Spin,
|
|
144
|
+
{
|
|
145
|
+
style: {
|
|
146
|
+
width: "100%",
|
|
147
|
+
height: "100%",
|
|
148
|
+
display: "flex",
|
|
149
|
+
justifyContent: "center",
|
|
150
|
+
alignItems: "center",
|
|
151
|
+
position: "absolute",
|
|
152
|
+
background: "rgba(255,255,255,0.6)",
|
|
153
|
+
top: 0,
|
|
154
|
+
left: 0,
|
|
155
|
+
right: 0,
|
|
156
|
+
bottom: 0,
|
|
157
|
+
zIndex: 1e3
|
|
158
|
+
},
|
|
159
|
+
spinning: isloading
|
|
160
|
+
}
|
|
161
|
+
) : null,
|
|
162
|
+
/* @__PURE__ */ jsx(
|
|
163
|
+
FullCalendar,
|
|
164
|
+
{
|
|
165
|
+
ref: calendarRef,
|
|
166
|
+
plugins: [dayGridPlugin],
|
|
167
|
+
headerToolbar: {
|
|
168
|
+
left: "title,today,prev,next",
|
|
169
|
+
center: "",
|
|
170
|
+
right: ""
|
|
171
|
+
},
|
|
172
|
+
initialView: "dayGridMonth",
|
|
173
|
+
height: "auto",
|
|
174
|
+
contentHeight: "auto",
|
|
175
|
+
editable: true,
|
|
176
|
+
selectable: true,
|
|
177
|
+
selectMirror: true,
|
|
178
|
+
fixedWeekCount: false,
|
|
179
|
+
datesSet: handleDatesSet,
|
|
180
|
+
timeZone: "UTC",
|
|
181
|
+
events,
|
|
182
|
+
eventContent: (eventInfo) => {
|
|
183
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("i", { children: eventInfo.event.title }) });
|
|
184
|
+
},
|
|
185
|
+
eventClick: handleEventClick
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
/* @__PURE__ */ jsx(
|
|
189
|
+
Modal,
|
|
190
|
+
{
|
|
191
|
+
title: currTitle ?? t("unnamedRecord"),
|
|
192
|
+
open: isModalOpen,
|
|
193
|
+
onOk: () => {
|
|
194
|
+
setIsModalOpen(false);
|
|
195
|
+
},
|
|
196
|
+
onCancel: () => {
|
|
197
|
+
setIsModalOpen(false);
|
|
198
|
+
},
|
|
199
|
+
destroyOnClose: true,
|
|
200
|
+
footer: (_, { OkBtn }) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(OkBtn, {}) }),
|
|
201
|
+
children: ((fieldOptions == null ? void 0 : fieldOptions.length) ?? 0) > 0 ? /* @__PURE__ */ jsx(
|
|
202
|
+
Descriptions,
|
|
203
|
+
{
|
|
204
|
+
className: "reset-descriptions",
|
|
205
|
+
layout: "vertical",
|
|
206
|
+
column: 2,
|
|
207
|
+
items: fieldOptions == null ? void 0 : fieldOptions.map((field, fieldKey) => ({
|
|
208
|
+
key: fieldKey,
|
|
209
|
+
label: field.label,
|
|
210
|
+
children: getTransformValue({
|
|
211
|
+
fieldOptions,
|
|
212
|
+
val: currData == null ? void 0 : currData[field.value],
|
|
213
|
+
field: field.value,
|
|
214
|
+
fieldMap: globalData == null ? void 0 : globalData.fieldMap
|
|
215
|
+
})
|
|
216
|
+
}))
|
|
217
|
+
}
|
|
218
|
+
) : null
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
};
|
|
227
|
+
const CalendarModule$1 = React.memo(CalendarModule);
|
|
228
|
+
export {
|
|
229
|
+
CalendarModule$1 as default
|
|
230
|
+
};
|
|
231
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/module-content/calendar-module/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport FullCalendar from '@fullcalendar/react'\nimport dayGridPlugin from '@fullcalendar/daygrid'\nimport dayjs from 'dayjs'\nimport isBetween from 'dayjs/plugin/isBetween'\nimport { EventContentArg, EventSourceInput } from '@fullcalendar/core'\nimport { ModuleDataApi, SourceDataFieldsTypes } from '../../../types'\nimport { CalendarCustomeDataTypes } from '../../add-module-modal/add-calendar-modal/custome-data'\nimport { useAppContext } from '../../../context'\nimport { useTranslation } from 'react-i18next'\nimport { mapConditionsToPostgrest } from '../utils'\nimport { Descriptions, message, Modal, Spin } from 'antd'\nimport { getTransformValue } from '../../../utils'\nimport { useMemoizedFn, useSize } from 'ahooks'\n\ndayjs.extend(isBetween)\n\ninterface CalendarModuleProps {\n customData?: CalendarCustomeDataTypes\n onChange?: (val: unknown) => void\n moduleDataApi?: ModuleDataApi\n width?: number\n height?: number\n rowWidth?: number\n rowHeight?: number\n}\n\nconst CalendarModule: React.FC<CalendarModuleProps> = ({\n moduleDataApi,\n customData,\n width,\n height,\n}) => {\n const { t } = useTranslation()\n const { globalData } = useAppContext()\n\n /* ============================== split =============================== */\n const [startMonthIntervals, setStartMonthIntervals] = useState<[string, string]>(['', ''])\n const handleDatesSet = (dateInfo: any) => {\n const currentDate = dayjs(dateInfo.view.currentStart)\n const firstDay = currentDate.startOf('month').format('YYYY-MM-DD')\n const lastDay = currentDate.endOf('month').format('YYYY-MM-DD')\n setStartMonthIntervals([firstDay, lastDay])\n }\n /* ============================== split =============================== */\n const [isloading, setIsloading] = useState(false)\n const [chartData, setChartData] = useState<any>()\n const fetchChartData = useMemoizedFn(async () => {\n setChartData([])\n if (customData) {\n setIsloading(true)\n let queryString = ''\n const firstDayOfMonth = dayjs().startOf('month').format('YYYY-MM-DD')\n const lastDayOfMonth = dayjs().endOf('month').format('YYYY-MM-DD')\n const conditionData = customData.conditionData\n const FMDay = startMonthIntervals.length > 0 ? startMonthIntervals[0] : firstDayOfMonth\n const LMDay = startMonthIntervals.length > 0 ? startMonthIntervals[1] : lastDayOfMonth\n\n if (conditionData) {\n if (conditionData?.conditionList?.map(item => item.type)?.includes('timestamp')) {\n queryString += `${mapConditionsToPostgrest(conditionData)}`\n } else {\n queryString += `added_on=gt.${FMDay}&added_on=lt.${LMDay}&${mapConditionsToPostgrest(\n conditionData\n )}`\n }\n } else {\n queryString = `added_on=gt.${FMDay}&added_on=lt.${LMDay}`\n }\n\n if (customData?.dataSourceId) {\n moduleDataApi?.({\n id: customData?.dataSourceId,\n query: queryString,\n })\n .then((res: any) => {\n if (!res.success) {\n message.error(res.message)\n return\n }\n setChartData(res.data)\n })\n .finally(() => {\n setIsloading(false)\n })\n }\n }\n })\n useEffect(() => {\n if (customData) {\n fetchChartData()\n }\n }, [customData?.dataSourceId, customData?.conditionData, startMonthIntervals])\n\n /* ============================== split =============================== */\n const fieldOptions = useMemo(() => {\n return globalData?.sourceData?.find(item => item.value === customData?.dataSourceId)?.fields\n }, [globalData, customData])\n\n const events = useMemo(() => {\n const calendarEvents = chartData?.map((item: any) => {\n const title = getTransformValue({\n fieldOptions,\n val: customData?.titleField ? item?.[customData.titleField] : '',\n field: customData?.titleField,\n fieldMap: globalData?.fieldMap,\n })\n return {\n title: title ?? t('unnamedRecord'),\n start:\n customData?.startDateField && item[customData?.startDateField]\n ? dayjs(item[customData?.startDateField])?.toISOString()\n : '',\n end:\n customData?.endDateField && item[customData?.endDateField]\n ? dayjs(item[customData?.endDateField])?.toISOString()\n : undefined,\n allDay: true,\n ...item,\n originalData: item,\n }\n })\n return calendarEvents\n }, [chartData, customData, fieldOptions])\n\n /* ============================== split =============================== */\n const [isModalOpen, setIsModalOpen] = useState(false)\n const [currData, setCurrData] = useState()\n const currTitle = getTransformValue({\n fieldOptions,\n val: customData?.titleField ? currData?.[customData.titleField] : '',\n field: customData?.titleField,\n fieldMap: globalData?.fieldMap,\n })\n\n const handleEventClick = useMemoizedFn((info: any) => {\n const event = info.event\n setIsModalOpen(true)\n\n setCurrData(event.extendedProps?.originalData)\n })\n\n /* ============================== split =============================== */\n const boxRef = useRef<any>()\n const calendarRef = useRef<any>(null)\n const size = useSize(boxRef)\n useEffect(() => {\n setTimeout(() => {\n calendarRef.current?.getApi()?.updateSize()\n }, 16) //不是一个div 会有延迟\n }, [size])\n\n /* ============================== split =============================== */\n\n return (\n <div\n ref={boxRef}\n style={{\n height: '100%',\n width: '100%',\n boxSizing: 'border-box',\n padding: '12px',\n }}\n >\n <div\n className=\"full-calendar-app\"\n style={{\n height: '100%',\n width: '100%',\n overflowY: 'auto',\n position: 'relative',\n }}\n >\n {isloading ? (\n <Spin\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n position: 'absolute',\n background: 'rgba(255,255,255,0.6)',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n zIndex: 1000,\n }}\n spinning={isloading}\n />\n ) : null}\n\n <FullCalendar\n ref={calendarRef} // 设置 FullCalendar 引用\n plugins={[dayGridPlugin]}\n headerToolbar={{\n left: 'title,today,prev,next',\n center: '',\n right: '',\n }}\n initialView=\"dayGridMonth\"\n height=\"auto\" // 自适应高度\n contentHeight=\"auto\" // 自动调整内容高度\n // dayMaxEvents={4} // 如果一天的事件太多则显示更多按钮\n editable={true}\n selectable={true}\n selectMirror={true}\n fixedWeekCount={false}\n datesSet={handleDatesSet}\n timeZone=\"UTC\"\n events={events} // 将筛选后的事件传递给 FullCalendar\n eventContent={(eventInfo: EventContentArg) => {\n return (\n <>\n <i>{eventInfo.event.title}</i>\n </>\n )\n }} // 自定义事件内容渲染\n eventClick={handleEventClick} // 事件点击时调用\n ></FullCalendar>\n <Modal\n title={currTitle ?? t('unnamedRecord')}\n open={isModalOpen}\n onOk={() => {\n setIsModalOpen(false)\n }}\n onCancel={() => {\n setIsModalOpen(false)\n }}\n destroyOnClose\n footer={(_, { OkBtn }) => (\n <>\n <OkBtn />\n </>\n )}\n >\n {(fieldOptions?.length ?? 0) > 0 ? (\n <Descriptions\n className=\"reset-descriptions\"\n layout=\"vertical\"\n column={2}\n items={fieldOptions?.map((field: any, fieldKey) => ({\n key: fieldKey,\n label: field.label,\n children: getTransformValue({\n fieldOptions,\n val: currData?.[field.value],\n field: field.value,\n fieldMap: globalData?.fieldMap,\n }),\n }))}\n />\n ) : null}\n </Modal>\n </div>\n </div>\n )\n}\n\nexport default React.memo(CalendarModule)\n"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,MAAM,OAAO,SAAS;AAYtB,MAAM,iBAAgD,CAAC;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,EAAE,IAAI,eAAe;AACvB,QAAA,EAAE,WAAW,IAAI,cAAc;AAG/B,QAAA,CAAC,qBAAqB,sBAAsB,IAAI,SAA2B,CAAC,IAAI,EAAE,CAAC;AACnF,QAAA,iBAAiB,CAAC,aAAkB;AACxC,UAAM,cAAc,MAAM,SAAS,KAAK,YAAY;AACpD,UAAM,WAAW,YAAY,QAAQ,OAAO,EAAE,OAAO,YAAY;AACjE,UAAM,UAAU,YAAY,MAAM,OAAO,EAAE,OAAO,YAAY;AACvC,2BAAA,CAAC,UAAU,OAAO,CAAC;AAAA,EAC5C;AAEA,QAAM,CAAC,W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AAC,oBAAA,KAAA,EAAG,UAAU,UAAA,MAAM,OAAM,EAC5B,CAAA;AAAA,gBAEJ;AAAA,gBACA,YAAY;AAAA,cAAA;AAAA,YACb;AAAA,YACD;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,OAAO,aAAa,EAAE,eAAe;AAAA,gBACrC,MAAM;AAAA,gBACN,MAAM,MAAM;AACV,iCAAe,KAAK;AAAA,gBACtB;AAAA,gBACA,UAAU,MAAM;AACd,iCAAe,KAAK;AAAA,gBACtB;AAAA,gBACA,gBAAc;AAAA,gBACd,QAAQ,CAAC,GAAG,EAAE,MACZ,MAAA,oBAAA,UAAA,EACE,UAAC,oBAAA,OAAA,CAAA,CAAM,EACT,CAAA;AAAA,gBAGA,YAAA,6CAAc,WAAU,KAAK,IAC7B;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,WAAU;AAAA,oBACV,QAAO;AAAA,oBACP,QAAQ;AAAA,oBACR,OAAO,6CAAc,IAAI,CAAC,OAAY,cAAc;AAAA,sBAClD,KAAK;AAAA,sBACL,OAAO,MAAM;AAAA,sBACb,UAAU,kBAAkB;AAAA,wBAC1B;AAAA,wBACA,KAAK,qCAAW,MAAM;AAAA,wBACtB,OAAO,MAAM;AAAA,wBACb,UAAU,yCAAY;AAAA,sBACvB,CAAA;AAAA,oBAAA;AAAA,kBACD;AAAA,gBAAA,IAEF;AAAA,cAAA;AAAA,YAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ;AAEA,MAAA,mBAAe,MAAM,KAAK,cAAc;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { useRef, useEffect, useImperativeHandle } from "react";
|
|
3
|
+
import * as echarts from "echarts/core";
|
|
4
|
+
import { BarChart, LineChart, PieChart } from "echarts/charts";
|
|
5
|
+
import { GraphicComponent, LegendComponent, TitleComponent, TooltipComponent, GridComponent, DatasetComponent, TransformComponent } from "echarts/components";
|
|
6
|
+
import { LabelLayout, UniversalTransition } from "echarts/features";
|
|
7
|
+
import { CanvasRenderer } from "echarts/renderers";
|
|
8
|
+
echarts.use([
|
|
9
|
+
GraphicComponent,
|
|
10
|
+
LegendComponent,
|
|
11
|
+
TitleComponent,
|
|
12
|
+
TooltipComponent,
|
|
13
|
+
GridComponent,
|
|
14
|
+
DatasetComponent,
|
|
15
|
+
TransformComponent,
|
|
16
|
+
BarChart,
|
|
17
|
+
LineChart,
|
|
18
|
+
PieChart,
|
|
19
|
+
LabelLayout,
|
|
20
|
+
UniversalTransition,
|
|
21
|
+
CanvasRenderer
|
|
22
|
+
]);
|
|
23
|
+
const Chart = React.memo(({ options, echartRef }) => {
|
|
24
|
+
const chartRef = useRef(null);
|
|
25
|
+
const chartInstanceRef = useRef(null);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (chartRef.current) {
|
|
28
|
+
chartInstanceRef.current = echarts.init(chartRef.current);
|
|
29
|
+
window.__chartInstanceRef = chartInstanceRef;
|
|
30
|
+
}
|
|
31
|
+
return () => {
|
|
32
|
+
if (chartInstanceRef.current) {
|
|
33
|
+
chartInstanceRef.current.dispose();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (chartInstanceRef.current) {
|
|
39
|
+
chartInstanceRef.current.clear();
|
|
40
|
+
if (options && Object.keys(options).length > 0) {
|
|
41
|
+
chartInstanceRef.current.setOption({ ...options });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, [options]);
|
|
45
|
+
useImperativeHandle(echartRef, () => ({
|
|
46
|
+
resize: () => {
|
|
47
|
+
if (chartInstanceRef.current) {
|
|
48
|
+
chartInstanceRef.current.resize();
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
getWidth: () => {
|
|
52
|
+
if (chartInstanceRef.current) {
|
|
53
|
+
chartInstanceRef.current.getWidth();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
return /* @__PURE__ */ jsx("div", { ref: chartRef, style: { width: "100%", height: "100%" } });
|
|
58
|
+
});
|
|
59
|
+
export {
|
|
60
|
+
Chart as default
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../packages/dashboard-workbench/components/module-content/chart-module/base-chart/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useImperativeHandle, useRef } from 'react'\nimport * as echarts from 'echarts/core'\nimport { BarChart, LineChart, PieChart } from 'echarts/charts'\nimport {\n GraphicComponent,\n TitleComponent,\n TooltipComponent,\n GridComponent,\n DatasetComponent,\n TransformComponent,\n LegendComponent,\n} from 'echarts/components'\n\nimport { LabelLayout, UniversalTransition } from 'echarts/features'\nimport { CanvasRenderer } from 'echarts/renderers'\nimport { EChartsOption } from 'echarts'\n\necharts.use([\n GraphicComponent,\n LegendComponent,\n TitleComponent,\n TooltipComponent,\n GridComponent,\n DatasetComponent,\n TransformComponent,\n BarChart,\n LineChart,\n PieChart,\n LabelLayout,\n UniversalTransition,\n CanvasRenderer,\n])\n\ninterface ChartProps {\n options?: EChartsOption\n echartRef?: any\n}\n\nconst Chart: React.FC<ChartProps> = React.memo(({ options, echartRef }) => {\n const chartRef = useRef<HTMLDivElement>(null)\n const chartInstanceRef = useRef<echarts.ECharts | null>(null)\n\n useEffect(() => {\n if (chartRef.current) {\n chartInstanceRef.current = echarts.init(chartRef.current)\n //@ts-ignore\n window.__chartInstanceRef = chartInstanceRef\n // chartInstanceRef.current = echarts.init(chartRef.current, 'light223')\n }\n return () => {\n if (chartInstanceRef.current) {\n chartInstanceRef.current.dispose()\n }\n }\n }, [])\n\n useEffect(() => {\n if (chartInstanceRef.current) {\n chartInstanceRef.current.clear()\n if (options && Object.keys(options).length > 0) {\n chartInstanceRef.current.setOption({ ...options })\n }\n }\n }, [options])\n\n useImperativeHandle(echartRef, () => ({\n resize: () => {\n if (chartInstanceRef.current) {\n chartInstanceRef.current.resize()\n }\n },\n getWidth: () => {\n if (chartInstanceRef.current) {\n chartInstanceRef.current.getWidth()\n }\n },\n }))\n\n return <div ref={chartRef} style={{ width: '100%', height: '100%' }} />\n})\n\nexport default Chart\n"],"names":[],"mappings":";;;;;;;AAkBA,QAAQ,IAAI;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAOD,MAAM,QAA8B,MAAM,KAAK,CAAC,EAAE,SAAS,gBAAgB;AACnE,QAAA,WAAW,OAAuB,IAAI;AACtC,QAAA,mBAAmB,OAA+B,IAAI;AAE5D,YAAU,MAAM;AACd,QAAI,SAAS,SAAS;AACpB,uBAAiB,UAAU,QAAQ,KAAK,SAAS,OAAO;AAExD,aAAO,qBAAqB;AAAA,IAAA;AAG9B,WAAO,MAAM;AACX,UAAI,iBAAiB,SAAS;AAC5B,yBAAiB,QAAQ,QAAQ;AAAA,MAAA;AAAA,IAErC;AAAA,EACF,GAAG,EAAE;AAEL,YAAU,MAAM;AACd,QAAI,iBAAiB,SAAS;AAC5B,uBAAiB,QAAQ,MAAM;AAC/B,UAAI,WAAW,OAAO,KAAK,OAAO,EAAE,SAAS,GAAG;AAC9C,yBAAiB,QAAQ,UAAU,EAAE,GAAG,SAAS;AAAA,MAAA;AAAA,IACnD;AAAA,EACF,GACC,CAAC,OAAO,CAAC;AAEZ,sBAAoB,WAAW,OAAO;AAAA,IACpC,QAAQ,MAAM;AACZ,UAAI,iBAAiB,SAAS;AAC5B,yBAAiB,QAAQ,OAAO;AAAA,MAAA;AAAA,IAEpC;AAAA,IACA,UAAU,MAAM;AACd,UAAI,iBAAiB,SAAS;AAC5B,yBAAiB,QAAQ,SAAS;AAAA,MAAA;AAAA,IACpC;AAAA,EACF,EACA;AAEK,SAAA,oBAAC,OAAI,EAAA,KAAK,UAAU,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAU,EAAA,CAAA;AACvE,CAAC;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModuleDataApi } from '../../../types';
|
|
2
|
+
import { ChartCustomeDataTypes } from '../../add-module-modal/add-chart-modal/custome-data';
|
|
3
|
+
import { ChartCustomeStylesTypes } from '../../add-module-modal/add-chart-modal/custome-styles';
|
|
4
|
+
import { default as React } from 'react';
|
|
5
|
+
interface ChartModuleProps {
|
|
6
|
+
customData?: ChartCustomeDataTypes;
|
|
7
|
+
customeStyle?: ChartCustomeStylesTypes;
|
|
8
|
+
onChange?: (val: unknown) => void;
|
|
9
|
+
moduleDataApi?: ModuleDataApi;
|
|
10
|
+
width?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: React.NamedExoticComponent<ChartModuleProps>;
|
|
14
|
+
export default _default;
|