@platox/pivot-table 0.0.34 → 0.0.36
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.js +14 -5
- package/es/dashboard-workbench/components/add-module-btn/index.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.d.ts +3 -3
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js +73 -82
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.d.ts +1 -5
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js +13 -22
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/CombinationChartOptionPicker.d.ts +18 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/CombinationChartOptionPicker.js +103 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/CombinationChartOptionPicker.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/GroupFieldConfigPicker.d.ts +14 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/GroupFieldConfigPicker.js +79 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/GroupFieldConfigPicker.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/index.module.less.js +11 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/index.module.less.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/config.d.ts +14 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/config.js +153 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/config.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.d.ts +1 -19
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js +132 -101
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.d.ts +0 -6
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js +2 -4
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.d.ts +1 -8
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js +13 -22
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.module.less.js +7 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.module.less.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/interface.d.ts +62 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/interface.js +31 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/interface.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.d.ts +3 -3
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js +2 -2
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js +16 -11
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.d.ts +1 -7
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js +13 -22
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/config.d.ts +30 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/config.js +132 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/config.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.d.ts +4 -12
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js +6 -200
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/interface.d.ts +14 -0
- package/es/dashboard-workbench/components/global-filter-condition/ConditionRowItem.d.ts +9 -0
- package/es/dashboard-workbench/components/global-filter-condition/ConditionRowItem.js +90 -0
- package/es/dashboard-workbench/components/global-filter-condition/ConditionRowItem.js.map +1 -0
- package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.d.ts +15 -0
- package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.js +218 -0
- package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.js.map +1 -0
- package/es/dashboard-workbench/components/global-filter-condition/FieldPicker.d.ts +13 -0
- package/es/dashboard-workbench/components/global-filter-condition/FieldPicker.js +56 -0
- package/es/dashboard-workbench/components/global-filter-condition/FieldPicker.js.map +1 -0
- package/es/dashboard-workbench/components/global-filter-condition/index.d.ts +13 -0
- package/es/dashboard-workbench/components/global-filter-condition/index.js +311 -0
- package/es/dashboard-workbench/components/global-filter-condition/index.js.map +1 -0
- package/es/dashboard-workbench/components/global-filter-condition/index.module.less.js +8 -0
- package/es/dashboard-workbench/components/global-filter-condition/index.module.less.js.map +1 -0
- package/es/dashboard-workbench/components/global-filter-condition/interface.d.ts +9 -0
- package/es/dashboard-workbench/components/global-filter-condition/useContext.d.ts +13 -0
- package/es/dashboard-workbench/components/global-filter-condition/useContext.js +10 -0
- package/es/dashboard-workbench/components/global-filter-condition/useContext.js.map +1 -0
- package/es/dashboard-workbench/components/global-filter-condition/util.d.ts +1 -0
- package/es/dashboard-workbench/components/global-filter-condition/util.js +7 -0
- package/es/dashboard-workbench/components/global-filter-condition/util.js.map +1 -0
- package/es/dashboard-workbench/components/modal-editor-header/index.d.ts +12 -0
- package/es/dashboard-workbench/components/modal-editor-header/index.js +59 -0
- package/es/dashboard-workbench/components/modal-editor-header/index.js.map +1 -0
- package/es/dashboard-workbench/components/modal-editor-header/index.module.less.js +9 -0
- package/es/dashboard-workbench/components/modal-editor-header/index.module.less.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/index.js +38 -26
- package/es/dashboard-workbench/components/module-content/calendar-module/index.js.map +1 -1
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.d.ts +7 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.js +10 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.d.ts +22 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.js +29 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/chart-module/Empty.d.ts +5 -0
- package/es/dashboard-workbench/components/module-content/chart-module/Empty.js +30 -0
- package/es/dashboard-workbench/components/module-content/chart-module/Empty.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js +1 -1
- package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js.map +1 -1
- package/es/dashboard-workbench/components/module-content/chart-module/index.d.ts +3 -4
- package/es/dashboard-workbench/components/module-content/chart-module/index.js +263 -160
- package/es/dashboard-workbench/components/module-content/chart-module/index.js.map +1 -1
- package/es/dashboard-workbench/components/module-content/chart-module/utils.d.ts +100 -2
- package/es/dashboard-workbench/components/module-content/chart-module/utils.js +66 -13
- package/es/dashboard-workbench/components/module-content/chart-module/utils.js.map +1 -1
- package/es/dashboard-workbench/components/module-content/index.js +3 -3
- package/es/dashboard-workbench/components/module-content/index.js.map +1 -1
- package/es/dashboard-workbench/components/module-content/statistics-module/index.d.ts +1 -1
- package/es/dashboard-workbench/components/module-content/statistics-module/index.js +17 -7
- package/es/dashboard-workbench/components/module-content/statistics-module/index.js.map +1 -1
- package/es/dashboard-workbench/components/module-content/text-module/editor/index.js +5 -5
- package/es/dashboard-workbench/components/module-content/text-module/editor/index.js.map +1 -1
- package/es/dashboard-workbench/components/module-content/utils.d.ts +2 -15
- package/es/dashboard-workbench/components/module-content/utils.js.map +1 -1
- package/es/dashboard-workbench/components/module-header/index.d.ts +1 -1
- package/es/dashboard-workbench/components/module-header/index.js +3 -3
- package/es/dashboard-workbench/components/module-header/index.js.map +1 -1
- package/es/dashboard-workbench/context.d.ts +21 -9
- package/es/dashboard-workbench/context.js +2 -9
- package/es/dashboard-workbench/context.js.map +1 -1
- package/es/dashboard-workbench/icon/icon-chart-combination.d.ts +3 -0
- package/es/dashboard-workbench/icon/icon-chart-combination.js +36 -0
- package/es/dashboard-workbench/icon/icon-chart-combination.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-empty.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-empty.js +139 -0
- package/es/dashboard-workbench/icon/icon-empty.js.map +1 -0
- package/es/dashboard-workbench/index.d.ts +2 -2
- package/es/dashboard-workbench/index.js +92 -83
- package/es/dashboard-workbench/index.js.map +1 -1
- package/es/dashboard-workbench/lang/en-US.d.ts +38 -0
- package/es/dashboard-workbench/lang/en-US.js +32 -4
- package/es/dashboard-workbench/lang/en-US.js.map +1 -1
- package/es/dashboard-workbench/lang/index.js +2 -2
- package/es/dashboard-workbench/lang/index.js.map +1 -1
- package/es/dashboard-workbench/lang/zh-CN.d.ts +38 -0
- package/es/dashboard-workbench/lang/zh-CN.js +31 -3
- package/es/dashboard-workbench/lang/zh-CN.js.map +1 -1
- package/es/dashboard-workbench/types.d.ts +18 -5
- package/es/dashboard-workbench/utils/index.d.ts +6 -4
- package/es/dashboard-workbench/utils/index.js +24 -3
- package/es/dashboard-workbench/utils/index.js.map +1 -1
- package/es/style.css +1 -1
- package/package.json +28 -20
- package/umd/pivot-table.umd.cjs +74 -74
- package/umd/style.css +1 -1
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useMemo, useEffect } from "react";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { Popover, Button, Select } from "antd";
|
|
5
|
+
import { FilterOutlined, PlusOutlined } from "@ant-design/icons";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
import { useMemoizedFn } from "ahooks";
|
|
8
|
+
import { cloneDeep, isEqual } from "lodash-es";
|
|
9
|
+
import { useAppContext } from "../../context.js";
|
|
10
|
+
import { useConditionTypeOptions } from "../add-module-modal/components/condition-modal/config.js";
|
|
11
|
+
import { ConditionRowItem } from "./ConditionRowItem.js";
|
|
12
|
+
import styles from "./index.module.less.js";
|
|
13
|
+
import { Context, useContext } from "./useContext.js";
|
|
14
|
+
import { getMergeId } from "./util.js";
|
|
15
|
+
const componentName = "global-filter-condition";
|
|
16
|
+
const Empty = [];
|
|
17
|
+
const GlobalFilterCondition = (props) => {
|
|
18
|
+
const { className, style } = props;
|
|
19
|
+
const { t } = useTranslation();
|
|
20
|
+
const { globalFilterCondition, setGlobalFilterCondition } = useAppContext();
|
|
21
|
+
const [open, setOpen] = useState(false);
|
|
22
|
+
const { globalData } = useAppContext();
|
|
23
|
+
const { fieldPickerDataSource, flattenFieldMap } = useMemo(() => {
|
|
24
|
+
let flattenFieldMap2 = /* @__PURE__ */ new Map();
|
|
25
|
+
let fieldPickerDataSource2 = ((globalData == null ? void 0 : globalData.sourceData) || []).map((item) => {
|
|
26
|
+
let children = ((item == null ? void 0 : item.fields) || []).map((v) => {
|
|
27
|
+
let mergeId = getMergeId(item == null ? void 0 : item.value, v == null ? void 0 : v.value);
|
|
28
|
+
flattenFieldMap2.set(mergeId, {
|
|
29
|
+
field: v,
|
|
30
|
+
source: item,
|
|
31
|
+
mergeId
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
key: mergeId,
|
|
35
|
+
label: v == null ? void 0 : v.label,
|
|
36
|
+
// 没有props 可以传到submenu里面 写在这里写死
|
|
37
|
+
style: {
|
|
38
|
+
minWidth: "160px"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
key: item == null ? void 0 : item.value,
|
|
44
|
+
label: item == null ? void 0 : item.label,
|
|
45
|
+
children
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
fieldPickerDataSource: fieldPickerDataSource2,
|
|
50
|
+
flattenFieldMap: flattenFieldMap2
|
|
51
|
+
};
|
|
52
|
+
}, [globalData == null ? void 0 : globalData.sourceData]);
|
|
53
|
+
return /* @__PURE__ */ jsx(
|
|
54
|
+
Context.Provider,
|
|
55
|
+
{
|
|
56
|
+
value: {
|
|
57
|
+
fieldPickerDataSource,
|
|
58
|
+
flattenFieldMap
|
|
59
|
+
},
|
|
60
|
+
children: /* @__PURE__ */ jsx("div", { className: clsx(styles[`${componentName}`], className), style, children: /* @__PURE__ */ jsx(
|
|
61
|
+
Popover,
|
|
62
|
+
{
|
|
63
|
+
content: /* @__PURE__ */ jsx(
|
|
64
|
+
PopoverContent,
|
|
65
|
+
{
|
|
66
|
+
defaultValue: globalFilterCondition,
|
|
67
|
+
onClose: (isOk, data) => {
|
|
68
|
+
if (isOk) {
|
|
69
|
+
setGlobalFilterCondition(data);
|
|
70
|
+
}
|
|
71
|
+
setOpen(false);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
destroyTooltipOnHide: true,
|
|
76
|
+
placement: "bottomRight",
|
|
77
|
+
trigger: "click",
|
|
78
|
+
open,
|
|
79
|
+
onOpenChange: setOpen,
|
|
80
|
+
children: /* @__PURE__ */ jsxs(Button, { children: [
|
|
81
|
+
/* @__PURE__ */ jsx(FilterOutlined, {}),
|
|
82
|
+
t("filter"),
|
|
83
|
+
((globalFilterCondition == null ? void 0 : globalFilterCondition.length) ?? 0) > 0 ? `(${globalFilterCondition == null ? void 0 : globalFilterCondition.length})` : ""
|
|
84
|
+
] })
|
|
85
|
+
}
|
|
86
|
+
) })
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
GlobalFilterCondition.displayName = "GlobalFilterCondition";
|
|
91
|
+
const PopoverContent = (props) => {
|
|
92
|
+
const { defaultValue } = props;
|
|
93
|
+
const { t } = useTranslation();
|
|
94
|
+
const fieldPickerDataSource = useContext().fieldPickerDataSource;
|
|
95
|
+
const conditionTypeOptions = useConditionTypeOptions();
|
|
96
|
+
const [value = Empty, setValue] = useState([]);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (defaultValue) {
|
|
99
|
+
setValue(cloneDeep(defaultValue));
|
|
100
|
+
}
|
|
101
|
+
}, [defaultValue]);
|
|
102
|
+
const [emptyBlockList, setEmptyBlockList] = useState([]);
|
|
103
|
+
const handleEmptyBlockListChange = (newItem) => {
|
|
104
|
+
if (newItem == null ? void 0 : newItem.field) {
|
|
105
|
+
setValue((prev) => {
|
|
106
|
+
let ret = [...prev];
|
|
107
|
+
let match = ret.find((item) => item.dataSourceId === newItem.dataSourceId);
|
|
108
|
+
if (match) {
|
|
109
|
+
match.conditionList.push(newItem);
|
|
110
|
+
return [...ret];
|
|
111
|
+
} else {
|
|
112
|
+
let newConditionBlockWrapper = {
|
|
113
|
+
dataSourceId: newItem.dataSourceId,
|
|
114
|
+
conditionType: "all",
|
|
115
|
+
conditionList: [newItem]
|
|
116
|
+
};
|
|
117
|
+
return [...ret, newConditionBlockWrapper];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const handleAddEmptyBlock = () => {
|
|
123
|
+
setEmptyBlockList([...emptyBlockList, {}]);
|
|
124
|
+
};
|
|
125
|
+
const hasChange = useMemo(() => {
|
|
126
|
+
return !isEqual(value, defaultValue);
|
|
127
|
+
}, [value, defaultValue]);
|
|
128
|
+
const handleSubmit = useMemoizedFn(() => {
|
|
129
|
+
var _a;
|
|
130
|
+
(_a = props == null ? void 0 : props.onClose) == null ? void 0 : _a.call(props, true, value);
|
|
131
|
+
});
|
|
132
|
+
return /* @__PURE__ */ jsxs("div", { className: clsx(styles[`${componentName}__popover`]), children: [
|
|
133
|
+
/* @__PURE__ */ jsx(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
style: {
|
|
137
|
+
marginBottom: "10px"
|
|
138
|
+
},
|
|
139
|
+
children: t("setFilterCondition")
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
value.map((item, index) => {
|
|
143
|
+
var _a;
|
|
144
|
+
let conditionList = item == null ? void 0 : item.conditionList;
|
|
145
|
+
let dataSourceName = (_a = fieldPickerDataSource == null ? void 0 : fieldPickerDataSource.find((v) => v.key === (item == null ? void 0 : item.dataSourceId))) == null ? void 0 : _a.label;
|
|
146
|
+
return /* @__PURE__ */ jsxs("div", { className: clsx(styles[`${componentName}__block`]), children: [
|
|
147
|
+
/* @__PURE__ */ jsxs(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
style: {
|
|
151
|
+
marginBottom: "10px",
|
|
152
|
+
display: "flex",
|
|
153
|
+
justifyContent: "space-between"
|
|
154
|
+
},
|
|
155
|
+
children: [
|
|
156
|
+
/* @__PURE__ */ jsx("div", { children: dataSourceName }),
|
|
157
|
+
/* @__PURE__ */ jsxs(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
style: {
|
|
161
|
+
display: "flex",
|
|
162
|
+
alignItems: "center",
|
|
163
|
+
gap: "5px"
|
|
164
|
+
},
|
|
165
|
+
children: [
|
|
166
|
+
t("conformTo"),
|
|
167
|
+
/* @__PURE__ */ jsx(
|
|
168
|
+
Select,
|
|
169
|
+
{
|
|
170
|
+
style: { width: "80px" },
|
|
171
|
+
options: conditionTypeOptions,
|
|
172
|
+
value: item == null ? void 0 : item.conditionType,
|
|
173
|
+
onChange: (v) => {
|
|
174
|
+
setValue((prev) => {
|
|
175
|
+
let ret = [...prev];
|
|
176
|
+
ret[index].conditionType = v;
|
|
177
|
+
return ret;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
t("addCondition")
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
style: {
|
|
193
|
+
display: "flex",
|
|
194
|
+
flexDirection: "column",
|
|
195
|
+
gap: "10px"
|
|
196
|
+
},
|
|
197
|
+
children: conditionList.map((v, conditionIndex) => {
|
|
198
|
+
return /* @__PURE__ */ jsx(
|
|
199
|
+
ConditionRowItem,
|
|
200
|
+
{
|
|
201
|
+
value: v,
|
|
202
|
+
onChange: (newValue) => {
|
|
203
|
+
setValue((prev) => {
|
|
204
|
+
let ret = [...prev];
|
|
205
|
+
let prevItem = ret[index].conditionList[conditionIndex];
|
|
206
|
+
if ((prevItem == null ? void 0 : prevItem.dataSourceId) !== (newValue == null ? void 0 : newValue.dataSourceId)) {
|
|
207
|
+
ret[index].conditionList.splice(conditionIndex, 1);
|
|
208
|
+
if (ret[index].conditionList.length === 0) {
|
|
209
|
+
ret.splice(index, 1);
|
|
210
|
+
}
|
|
211
|
+
let newItem = newValue;
|
|
212
|
+
let match = ret.find((item2) => item2.dataSourceId === newItem.dataSourceId);
|
|
213
|
+
if (match) {
|
|
214
|
+
match.conditionList.push(newItem);
|
|
215
|
+
return [...ret];
|
|
216
|
+
} else {
|
|
217
|
+
let newConditionBlockWrapper = {
|
|
218
|
+
dataSourceId: newItem.dataSourceId,
|
|
219
|
+
conditionType: "all",
|
|
220
|
+
conditionList: [newItem]
|
|
221
|
+
};
|
|
222
|
+
return [...ret, newConditionBlockWrapper];
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
ret[index].conditionList[conditionIndex] = {
|
|
226
|
+
...prevItem,
|
|
227
|
+
...newValue
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return ret;
|
|
231
|
+
});
|
|
232
|
+
},
|
|
233
|
+
onDelete: () => {
|
|
234
|
+
setValue((prev) => {
|
|
235
|
+
let ret = [...prev];
|
|
236
|
+
ret[index].conditionList.splice(conditionIndex, 1);
|
|
237
|
+
if (ret[index].conditionList.length === 0) {
|
|
238
|
+
ret.splice(index, 1);
|
|
239
|
+
}
|
|
240
|
+
return ret;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
conditionIndex
|
|
245
|
+
);
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
] }, item == null ? void 0 : item.dataSourceId);
|
|
250
|
+
}),
|
|
251
|
+
emptyBlockList.map((item, index) => {
|
|
252
|
+
return /* @__PURE__ */ jsx("div", { className: clsx(styles[`${componentName}__block`]), children: /* @__PURE__ */ jsx(
|
|
253
|
+
ConditionRowItem,
|
|
254
|
+
{
|
|
255
|
+
value: item,
|
|
256
|
+
onChange: (newValue) => {
|
|
257
|
+
handleEmptyBlockListChange(newValue);
|
|
258
|
+
},
|
|
259
|
+
onDelete: () => {
|
|
260
|
+
setEmptyBlockList((prev) => {
|
|
261
|
+
let ret = [...prev];
|
|
262
|
+
ret.splice(index, 1);
|
|
263
|
+
return ret;
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
) }, index);
|
|
268
|
+
}),
|
|
269
|
+
/* @__PURE__ */ jsx(
|
|
270
|
+
Button,
|
|
271
|
+
{
|
|
272
|
+
type: "dashed",
|
|
273
|
+
block: true,
|
|
274
|
+
style: {
|
|
275
|
+
marginBottom: "10px"
|
|
276
|
+
},
|
|
277
|
+
icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
|
|
278
|
+
onClick: () => {
|
|
279
|
+
handleAddEmptyBlock();
|
|
280
|
+
},
|
|
281
|
+
children: t("addCondition")
|
|
282
|
+
}
|
|
283
|
+
),
|
|
284
|
+
/* @__PURE__ */ jsx(
|
|
285
|
+
"div",
|
|
286
|
+
{
|
|
287
|
+
style: {
|
|
288
|
+
display: "flex",
|
|
289
|
+
justifyContent: "flex-end"
|
|
290
|
+
},
|
|
291
|
+
children: /* @__PURE__ */ jsx(
|
|
292
|
+
Button,
|
|
293
|
+
{
|
|
294
|
+
type: "primary",
|
|
295
|
+
disabled: !hasChange,
|
|
296
|
+
onClick: () => {
|
|
297
|
+
handleSubmit();
|
|
298
|
+
},
|
|
299
|
+
children: t("confirm")
|
|
300
|
+
}
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
] });
|
|
305
|
+
};
|
|
306
|
+
export {
|
|
307
|
+
GlobalFilterCondition,
|
|
308
|
+
PopoverContent,
|
|
309
|
+
GlobalFilterCondition as default
|
|
310
|
+
};
|
|
311
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/dashboard-workbench/components/global-filter-condition/index.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react'\nimport clsx from 'clsx'\nimport { Button, MenuProps, Popover, Select, Space } from 'antd'\nimport { FilterOutlined, PlusOutlined } from '@ant-design/icons'\nimport { useTranslation } from 'react-i18next'\nimport { useControllableValue, useMemoizedFn } from 'ahooks'\nimport { cloneDeep, groupBy, isEqual } from 'lodash-es'\nimport { useAppContext } from '@platox/pivot-table/context'\nimport { useConditionTypeOptions } from '../add-module-modal/components/condition-modal/config'\nimport ConditionRowItem from './ConditionRowItem'\nimport { FieldPickerDataSourceItem } from './FieldPicker'\nimport styles from './index.module.less'\nimport { ConditionBlockWrapper, ConditionListItemWrapper } from './interface'\nimport { Context, ContextProps, useContext } from './useContext'\nimport { getMergeId } from './util'\n\nconst componentName = 'global-filter-condition'\n\nconst Empty: unknown[] = []\n\n/* ============================== split =============================== */\n\nexport interface GlobalFilterConditionProps {\n className?: string\n style?: React.CSSProperties\n}\nexport const GlobalFilterCondition: React.FC<GlobalFilterConditionProps> = props => {\n const { className, style } = props\n\n const { t } = useTranslation()\n\n const { globalFilterCondition, setGlobalFilterCondition } = useAppContext()\n\n const [open, setOpen] = useState<boolean>(false)\n\n /* ============================== 整理数据 =============================== */\n const { globalData } = useAppContext()\n const { fieldPickerDataSource, flattenFieldMap } = useMemo(() => {\n let flattenFieldMap: ContextProps['flattenFieldMap'] = new Map()\n\n let fieldPickerDataSource = (globalData?.sourceData || []).map(item => {\n let children = (item?.fields || []).map(v => {\n let mergeId = getMergeId(item?.value, v?.value)\n\n // 记录mergeId对应的field和source\n flattenFieldMap.set(mergeId, {\n field: v,\n source: item,\n mergeId: mergeId,\n })\n\n return {\n key: mergeId,\n label: v?.label,\n // 没有props 可以传到submenu里面 写在这里写死\n style: {\n minWidth: '160px',\n },\n }\n })\n\n return {\n key: item?.value,\n label: item?.label,\n children,\n }\n })\n\n return {\n fieldPickerDataSource: fieldPickerDataSource as unknown as FieldPickerDataSourceItem[],\n flattenFieldMap,\n }\n }, [globalData?.sourceData])\n\n return (\n <Context.Provider\n value={{\n fieldPickerDataSource: fieldPickerDataSource,\n flattenFieldMap: flattenFieldMap,\n }}\n >\n <div className={clsx(styles[`${componentName}`], className)} style={style}>\n <Popover\n content={\n <PopoverContent\n defaultValue={globalFilterCondition}\n onClose={(isOk, data) => {\n if (isOk) {\n setGlobalFilterCondition(data!)\n }\n setOpen(false)\n }}\n />\n }\n destroyTooltipOnHide\n placement=\"bottomRight\"\n trigger=\"click\"\n open={open}\n onOpenChange={setOpen}\n >\n <Button>\n <FilterOutlined />\n {t('filter')}\n {(globalFilterCondition?.length ?? 0) > 0 ? `(${globalFilterCondition?.length})` : ''}\n </Button>\n </Popover>\n </div>\n </Context.Provider>\n )\n}\n\nGlobalFilterCondition.displayName = 'GlobalFilterCondition'\n\nexport default GlobalFilterCondition\n\n/* ============================== split =============================== */\n\nexport type PopoverContentProps = {\n defaultValue?: ConditionBlockWrapper[]\n onClose?: (isOk: boolean, data?: ConditionBlockWrapper[]) => void\n}\n\nexport const PopoverContent = (props: PopoverContentProps) => {\n const { defaultValue } = props\n\n const { t } = useTranslation()\n const fieldPickerDataSource = useContext().fieldPickerDataSource\n const conditionTypeOptions = useConditionTypeOptions()\n\n /* ============================== split =============================== */\n const [value = Empty as ConditionBlockWrapper[], setValue] = useState<ConditionBlockWrapper[]>([])\n\n useEffect(() => {\n if (defaultValue) {\n setValue(cloneDeep(defaultValue))\n }\n }, [defaultValue])\n\n /* ============================== 这是empty =============================== */\n const [emptyBlockList, setEmptyBlockList] = useState<ConditionListItemWrapper[]>([])\n\n const handleEmptyBlockListChange = (newItem: ConditionListItemWrapper) => {\n if (newItem?.field) {\n setValue(prev => {\n let ret = [...prev]\n let match = ret.find(item => item.dataSourceId === newItem.dataSourceId)\n if (match) {\n match.conditionList.push(newItem)\n return [...ret]\n } else {\n // 创建一个\n let newConditionBlockWrapper = {\n dataSourceId: newItem.dataSourceId,\n conditionType: 'all',\n conditionList: [newItem],\n } as ConditionBlockWrapper\n return [...ret, newConditionBlockWrapper]\n }\n })\n }\n }\n\n const handleAddEmptyBlock = () => {\n setEmptyBlockList([...emptyBlockList, {}])\n }\n\n /* ============================== split =============================== */\n const hasChange = useMemo(() => {\n return !isEqual(value, defaultValue)\n }, [value, defaultValue])\n\n const handleSubmit = useMemoizedFn(() => {\n props?.onClose?.(true, value)\n })\n\n return (\n <div className={clsx(styles[`${componentName}__popover`])}>\n <div\n style={{\n marginBottom: '10px',\n }}\n >\n {t('setFilterCondition')}\n </div>\n\n {value.map((item, index) => {\n let conditionList = item?.conditionList\n let dataSourceName = fieldPickerDataSource?.find(v => v.key === item?.dataSourceId)?.label\n\n return (\n <div className={clsx(styles[`${componentName}__block`])} key={item?.dataSourceId}>\n <div\n style={{\n marginBottom: '10px',\n display: 'flex',\n justifyContent: 'space-between',\n }}\n >\n <div>{dataSourceName}</div>\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n gap: '5px',\n }}\n >\n {t('conformTo')}\n <Select\n style={{ width: '80px' }}\n options={conditionTypeOptions}\n value={item?.conditionType}\n onChange={v => {\n setValue(prev => {\n let ret = [...prev]\n ret[index].conditionType = v\n return ret\n })\n }}\n />\n {t('addCondition')}\n </div>\n </div>\n <div\n style={{\n display: 'flex',\n flexDirection: 'column',\n gap: '10px',\n }}\n >\n {conditionList.map((v, conditionIndex) => {\n return (\n <ConditionRowItem\n key={conditionIndex}\n value={v}\n onChange={newValue => {\n setValue(prev => {\n let ret = [...prev]\n let prevItem = ret[index].conditionList[conditionIndex]\n if (prevItem?.dataSourceId !== newValue?.dataSourceId) {\n // 数据源变化了 删除原来的\n ret[index].conditionList.splice(conditionIndex, 1)\n if (ret[index].conditionList.length === 0) {\n ret.splice(index, 1)\n }\n // 添加到新的数据源添\n let newItem = newValue\n let match = ret.find(item => item.dataSourceId === newItem.dataSourceId)\n if (match) {\n match.conditionList.push(newItem)\n return [...ret]\n } else {\n let newConditionBlockWrapper = {\n dataSourceId: newItem.dataSourceId,\n conditionType: 'all',\n conditionList: [newItem],\n } as ConditionBlockWrapper\n return [...ret, newConditionBlockWrapper]\n }\n } else {\n ret[index].conditionList[conditionIndex] = {\n ...prevItem,\n ...newValue,\n }\n }\n\n return ret\n })\n }}\n onDelete={() => {\n setValue(prev => {\n let ret = [...prev]\n ret[index].conditionList.splice(conditionIndex, 1)\n\n if (ret[index].conditionList.length === 0) {\n ret.splice(index, 1)\n }\n return ret\n })\n }}\n />\n )\n })}\n </div>\n </div>\n )\n })}\n\n {emptyBlockList.map((item, index) => {\n return (\n <div className={clsx(styles[`${componentName}__block`])} key={index}>\n <ConditionRowItem\n value={item}\n onChange={newValue => {\n handleEmptyBlockListChange(newValue)\n }}\n onDelete={() => {\n setEmptyBlockList(prev => {\n let ret = [...prev]\n ret.splice(index, 1)\n return ret\n })\n }}\n />\n </div>\n )\n })}\n\n <Button\n type=\"dashed\"\n block\n style={{\n marginBottom: '10px',\n }}\n icon={<PlusOutlined />}\n onClick={() => {\n handleAddEmptyBlock()\n }}\n >\n {t('addCondition')}\n </Button>\n\n <div\n style={{\n display: 'flex',\n justifyContent: 'flex-end',\n }}\n >\n <Button\n type=\"primary\"\n disabled={!hasChange}\n onClick={() => {\n handleSubmit()\n }}\n >\n {t('confirm')}\n </Button>\n </div>\n </div>\n )\n}\n"],"names":["flattenFieldMap","fieldPickerDataSource","item"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,gBAAgB;AAEtB,MAAM,QAAmB,CAAC;AAQnB,MAAM,wBAA8D,CAAS,UAAA;AAC5E,QAAA,EAAE,WAAW,MAAA,IAAU;AAEvB,QAAA,EAAE,EAAE,IAAI,eAAe;AAE7B,QAAM,EAAE,uBAAuB,yBAAyB,IAAI,cAAc;AAE1E,QAAM,CAAC,MAAM,OAAO,IAAI,SAAkB,KAAK;AAGzC,QAAA,EAAE,WAAW,IAAI,cAAc;AACrC,QAAM,EAAE,uBAAuB,gBAAgB,IAAI,QAAQ,MAAM;AAC3DA,QAAAA,uCAAuD,IAAI;AAE/D,QAAIC,2BAAyB,yCAAY,eAAc,CAAA,GAAI,IAAI,CAAQ,SAAA;AACrE,UAAI,aAAY,6BAAM,WAAU,CAAA,GAAI,IAAI,CAAK,MAAA;AAC3C,YAAI,UAAU,WAAW,6BAAM,OAAO,uBAAG,KAAK;AAG9CD,yBAAgB,IAAI,SAAS;AAAA,UAC3B,OAAO;AAAA,UACP,QAAQ;AAAA,UACR;AAAA,QAAA,CACD;AAEM,eAAA;AAAA,UACL,KAAK;AAAA,UACL,OAAO,uBAAG;AAAA;AAAA,UAEV,OAAO;AAAA,YACL,UAAU;AAAA,UAAA;AAAA,QAEd;AAAA,MAAA,CACD;AAEM,aAAA;AAAA,QACL,KAAK,6BAAM;AAAA,QACX,OAAO,6BAAM;AAAA,QACb;AAAA,MACF;AAAA,IAA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U,CAAY,aAAA;AACpB,uCAA2B,QAAQ;AAAA,UACrC;AAAA,UACA,UAAU,MAAM;AACd,8BAAkB,CAAQ,SAAA;AACpB,kBAAA,MAAM,CAAC,GAAG,IAAI;AACd,kBAAA,OAAO,OAAO,CAAC;AACZ,qBAAA;AAAA,YAAA,CACR;AAAA,UAAA;AAAA,QACH;AAAA,WAZ0D,KAc9D;AAAA,IAAA,CAEH;AAAA,IAED;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAK;AAAA,QACL,OAAO;AAAA,UACL,cAAc;AAAA,QAChB;AAAA,QACA,0BAAO,cAAa,EAAA;AAAA,QACpB,SAAS,MAAM;AACO,8BAAA;AAAA,QACtB;AAAA,QAEC,YAAE,cAAc;AAAA,MAAA;AAAA,IACnB;AAAA,IAEA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO;AAAA,UACL,SAAS;AAAA,UACT,gBAAgB;AAAA,QAClB;AAAA,QAEA,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,UAAU,CAAC;AAAA,YACX,SAAS,MAAM;AACA,2BAAA;AAAA,YACf;AAAA,YAEC,YAAE,SAAS;AAAA,UAAA;AAAA,QAAA;AAAA,MACd;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const styles = {
|
|
2
|
+
"global-filter-condition__popover": "_global-filter-condition__popover_7daxk_1",
|
|
3
|
+
"global-filter-condition__block": "_global-filter-condition__block_7daxk_4"
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
styles as default
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=index.module.less.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.module.less.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConditionListItem } from '../add-module-modal/components/condition-modal/interface';
|
|
2
|
+
export type ConditionListItemWrapper = Partial<ConditionListItem> & {
|
|
3
|
+
dataSourceId?: string;
|
|
4
|
+
};
|
|
5
|
+
export interface ConditionBlockWrapper {
|
|
6
|
+
conditionList: ConditionListItemWrapper[];
|
|
7
|
+
conditionType: 'all' | 'any';
|
|
8
|
+
dataSourceId: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FieldItem, SourceDataItem } from '../../types';
|
|
2
|
+
import { FieldPickerDataSourceItem } from './FieldPicker';
|
|
3
|
+
export type ContextProps = {
|
|
4
|
+
fieldPickerDataSource: FieldPickerDataSourceItem[];
|
|
5
|
+
flattenFieldMap: Map<string, //mergeId
|
|
6
|
+
{
|
|
7
|
+
field: FieldItem;
|
|
8
|
+
source: SourceDataItem;
|
|
9
|
+
mergeId: string;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
export declare const Context: import('react').Context<Partial<ContextProps>>;
|
|
13
|
+
export declare const useContext: () => Partial<ContextProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContext.js","sources":["../../../../packages/dashboard-workbench/components/global-filter-condition/useContext.tsx"],"sourcesContent":["import { useContext as _useContext, createContext } from 'react'\nimport { FieldItem, SourceDataItem } from '../../types'\nimport { FieldPickerDataSourceItem } from './FieldPicker'\n\nexport type ContextProps = {\n fieldPickerDataSource: FieldPickerDataSourceItem[]\n\n //方便后续查找\n flattenFieldMap: Map<\n string, //mergeId\n {\n field: FieldItem\n source: SourceDataItem\n mergeId: string\n }\n >\n}\n\nexport const Context = createContext<Partial<ContextProps>>({})\n\nexport const useContext = () => {\n return _useContext(Context)\n}\n"],"names":["_useContext"],"mappings":";AAkBa,MAAA,UAAU,cAAqC,CAAE,CAAA;AAEvD,MAAM,aAAa,MAAM;AAC9B,SAAOA,aAAY,OAAO;AAC5B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getMergeId: (dataSourceId: string, field: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../../packages/dashboard-workbench/components/global-filter-condition/util.ts"],"sourcesContent":["export const getMergeId = (dataSourceId: string, field: string) => {\n return `${dataSourceId}-${field}`\n}\n"],"names":[],"mappings":"AAAa,MAAA,aAAa,CAAC,cAAsB,UAAkB;AAC1D,SAAA,GAAG,YAAY,IAAI,KAAK;AACjC;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export type EditorHeaderProps = {
|
|
3
|
+
style?: CSSProperties;
|
|
4
|
+
className?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
onChange?: (value: string) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const EditorHeader: {
|
|
9
|
+
(props: EditorHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
12
|
+
export default EditorHeader;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, useEffect } from "react";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { Input, Button } from "antd";
|
|
5
|
+
import { EditOutlined } from "@ant-design/icons";
|
|
6
|
+
import { useControllableValue } from "ahooks";
|
|
7
|
+
import styles from "./index.module.less.js";
|
|
8
|
+
const componentName = "editor-header";
|
|
9
|
+
const EditorHeader = (props) => {
|
|
10
|
+
const { style, className } = props;
|
|
11
|
+
const [value, setValue] = useControllableValue(props);
|
|
12
|
+
const inputRef = useRef(null);
|
|
13
|
+
const [isEdit, setIsEdit] = useState(false);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (isEdit) {
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
var _a;
|
|
18
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
19
|
+
}, 16);
|
|
20
|
+
}
|
|
21
|
+
}, [isEdit]);
|
|
22
|
+
return /* @__PURE__ */ jsx("div", { className: clsx(styles[`${componentName}`], className), style, children: isEdit ? /* @__PURE__ */ jsx(
|
|
23
|
+
Input,
|
|
24
|
+
{
|
|
25
|
+
className: clsx(styles[`${componentName}__input`]),
|
|
26
|
+
ref: inputRef,
|
|
27
|
+
value,
|
|
28
|
+
onChange: (e) => {
|
|
29
|
+
setValue(e.target.value.trim());
|
|
30
|
+
},
|
|
31
|
+
onBlur: () => {
|
|
32
|
+
setIsEdit(false);
|
|
33
|
+
},
|
|
34
|
+
onKeyDown: (e) => {
|
|
35
|
+
if (e.key == "Enter") {
|
|
36
|
+
setIsEdit(false);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
41
|
+
/* @__PURE__ */ jsx("span", { children: value }),
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
Button,
|
|
44
|
+
{
|
|
45
|
+
className: clsx(styles[`${componentName}__edit`]),
|
|
46
|
+
onClick: () => setIsEdit(true),
|
|
47
|
+
type: "text",
|
|
48
|
+
size: "small",
|
|
49
|
+
children: /* @__PURE__ */ jsx(EditOutlined, {})
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
] }) });
|
|
53
|
+
};
|
|
54
|
+
EditorHeader.displayName = "EditorHeader";
|
|
55
|
+
export {
|
|
56
|
+
EditorHeader,
|
|
57
|
+
EditorHeader as default
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/dashboard-workbench/components/modal-editor-header/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type CSSProperties } from 'react'\nimport clsx from 'clsx'\nimport { Button, Input, InputRef } from 'antd'\nimport { EditOutlined } from '@ant-design/icons'\nimport { useControllableValue } from 'ahooks'\nimport styles from './index.module.less'\n\nconst componentName = 'editor-header'\n\nexport type EditorHeaderProps = {\n style?: CSSProperties\n className?: string\n\n value?: string\n onChange?: (value: string) => void\n}\n\nexport const EditorHeader = (props: EditorHeaderProps) => {\n const { style, className } = props\n\n /* ============================== split =============================== */\n const [value, setValue] = useControllableValue(props)\n\n const inputRef = useRef<InputRef>(null)\n const [isEdit, setIsEdit] = useState<boolean>(false)\n useEffect(() => {\n if (isEdit) {\n setTimeout(() => {\n inputRef.current?.focus()\n }, 16)\n }\n }, [isEdit])\n\n return (\n <div className={clsx(styles[`${componentName}`], className)} style={style}>\n {isEdit ? (\n <Input\n className={clsx(styles[`${componentName}__input`])}\n ref={inputRef}\n value={value}\n onChange={e => {\n setValue(e.target.value.trim())\n }}\n onBlur={() => {\n setIsEdit(false)\n }}\n onKeyDown={e => {\n if (e.key == 'Enter') {\n setIsEdit(false)\n }\n }}\n />\n ) : (\n <>\n <span>{value}</span>\n <Button\n className={clsx(styles[`${componentName}__edit`])}\n onClick={() => setIsEdit(true)}\n type=\"text\"\n size=\"small\"\n >\n <EditOutlined />\n </Button>\n </>\n )}\n </div>\n )\n}\n\nEditorHeader.displayName = 'EditorHeader'\n\nexport default EditorHeader\n"],"names":[],"mappings":";;;;;;;AAOA,MAAM,gBAAgB;AAUT,MAAA,eAAe,CAAC,UAA6B;AAClD,QAAA,EAAE,OAAO,UAAA,IAAc;AAG7B,QAAM,CAAC,OAAO,QAAQ,IAAI,qBAAqB,KAAK;AAE9C,QAAA,WAAW,OAAiB,IAAI;AACtC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAkB,KAAK;AACnD,YAAU,MAAM;AACd,QAAI,QAAQ;AACV,iBAAW,MAAM;;AACf,uBAAS,YAAT,mBAAkB;AAAA,SACjB,EAAE;AAAA,IAAA;AAAA,EACP,GACC,CAAC,MAAM,CAAC;AAEX,SACG,oBAAA,OAAA,EAAI,WAAW,KAAK,OAAO,GAAG,aAAa,EAAE,GAAG,SAAS,GAAG,OAC1D,UACC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,KAAK,OAAO,GAAG,aAAa,SAAS,CAAC;AAAA,MACjD,KAAK;AAAA,MACL;AAAA,MACA,UAAU,CAAK,MAAA;AACb,iBAAS,EAAE,OAAO,MAAM,KAAA,CAAM;AAAA,MAChC;AAAA,MACA,QAAQ,MAAM;AACZ,kBAAU,KAAK;AAAA,MACjB;AAAA,MACA,WAAW,CAAK,MAAA;AACV,YAAA,EAAE,OAAO,SAAS;AACpB,oBAAU,KAAK;AAAA,QAAA;AAAA,MACjB;AAAA,IACF;AAAA,EAAA,IAIA,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAA,oBAAC,UAAM,UAAM,MAAA,CAAA;AAAA,IACb;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAW,KAAK,OAAO,GAAG,aAAa,QAAQ,CAAC;AAAA,QAChD,SAAS,MAAM,UAAU,IAAI;AAAA,QAC7B,MAAK;AAAA,QACL,MAAK;AAAA,QAEL,8BAAC,cAAa,CAAA,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAChB,EAAA,CACF,EAEJ,CAAA;AAEJ;AAEA,aAAa,cAAc;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const styles = {
|
|
2
|
+
"editor-header": "_editor-header_198q1_1",
|
|
3
|
+
"editor-header__edit": "_editor-header__edit_198q1_13",
|
|
4
|
+
"editor-header__input": "_editor-header__input_198q1_24"
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
styles as default
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.module.less.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.module.less.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState,
|
|
3
|
-
import
|
|
2
|
+
import React, { useState, useMemo, useEffect, useRef } from "react";
|
|
3
|
+
import { message, Spin, Modal, Descriptions } from "antd";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
4
5
|
import dayGridPlugin from "@fullcalendar/daygrid";
|
|
6
|
+
import FullCalendar from "@fullcalendar/react";
|
|
7
|
+
import { useMemoizedFn, useSize } from "ahooks";
|
|
5
8
|
import dayjs from "dayjs";
|
|
6
9
|
import isBetween from "dayjs/plugin/isBetween";
|
|
7
10
|
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
11
|
import { getTransformValue } from "../../../utils/index.js";
|
|
12
|
-
import {
|
|
12
|
+
import { mapConditionsToPostgrest } from "../utils.js";
|
|
13
|
+
import MINIMAL_RAW_EN_LOCALE from "./locales/en.js";
|
|
14
|
+
import l77 from "./locales/zh.js";
|
|
13
15
|
dayjs.extend(isBetween);
|
|
14
|
-
const CalendarModule = ({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
width,
|
|
18
|
-
height
|
|
19
|
-
}) => {
|
|
20
|
-
const { t } = useTranslation();
|
|
21
|
-
const { globalData } = useAppContext();
|
|
16
|
+
const CalendarModule = ({ moduleDataApi, customData }) => {
|
|
17
|
+
const { t, i18n } = useTranslation();
|
|
18
|
+
const { globalData, globalFilterCondition } = useAppContext();
|
|
22
19
|
const [startMonthIntervals, setStartMonthIntervals] = useState(["", ""]);
|
|
23
20
|
const handleDatesSet = (dateInfo) => {
|
|
24
21
|
const currentDate = dayjs(dateInfo.view.currentStart);
|
|
@@ -26,10 +23,16 @@ const CalendarModule = ({
|
|
|
26
23
|
const lastDay = currentDate.endOf("month").format("YYYY-MM-DD");
|
|
27
24
|
setStartMonthIntervals([firstDay, lastDay]);
|
|
28
25
|
};
|
|
26
|
+
let matchGlobalFilterCondition = useMemo(() => {
|
|
27
|
+
let matchGlobalFilterCondition2 = globalFilterCondition == null ? void 0 : globalFilterCondition.find(
|
|
28
|
+
(item) => (item == null ? void 0 : item.dataSourceId) === (customData == null ? void 0 : customData.dataSourceId)
|
|
29
|
+
);
|
|
30
|
+
return matchGlobalFilterCondition2;
|
|
31
|
+
}, [globalFilterCondition, customData == null ? void 0 : customData.dataSourceId]);
|
|
29
32
|
const [isloading, setIsloading] = useState(false);
|
|
30
33
|
const [chartData, setChartData] = useState();
|
|
31
34
|
const fetchChartData = useMemoizedFn(async () => {
|
|
32
|
-
var _a, _b;
|
|
35
|
+
var _a, _b, _c;
|
|
33
36
|
setChartData([]);
|
|
34
37
|
if (customData) {
|
|
35
38
|
setIsloading(true);
|
|
@@ -39,16 +42,19 @@ const CalendarModule = ({
|
|
|
39
42
|
const conditionData = customData.conditionData;
|
|
40
43
|
const FMDay = startMonthIntervals.length > 0 ? startMonthIntervals[0] : firstDayOfMonth;
|
|
41
44
|
const LMDay = startMonthIntervals.length > 0 ? startMonthIntervals[1] : lastDayOfMonth;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
queryString
|
|
45
|
+
let isConditionTimestampExist = ((conditionData == null ? void 0 : conditionData.conditionList) ?? []).some((item) => item.type == "timestamp") || ((matchGlobalFilterCondition == null ? void 0 : matchGlobalFilterCondition.conditionList) ?? []).some((item) => item.type == "timestamp");
|
|
46
|
+
if (!isConditionTimestampExist) {
|
|
47
|
+
queryString = `&added_on=gt.${FMDay}&added_on=lt.${LMDay}`;
|
|
48
|
+
}
|
|
49
|
+
if ((conditionData == null ? void 0 : conditionData.conditionList) && ((_a = conditionData == null ? void 0 : conditionData.conditionList) == null ? void 0 : _a.length) > 0) {
|
|
50
|
+
(_b = conditionData == null ? void 0 : conditionData.conditionList) == null ? void 0 : _b.some((item) => item.type == "timestamp");
|
|
51
|
+
queryString += `&${mapConditionsToPostgrest(conditionData)}`;
|
|
52
|
+
}
|
|
53
|
+
if ((((_c = matchGlobalFilterCondition == null ? void 0 : matchGlobalFilterCondition.conditionList) == null ? void 0 : _c.length) ?? 0) > 0) {
|
|
54
|
+
queryString += `&${mapConditionsToPostgrest(matchGlobalFilterCondition)}`;
|
|
55
|
+
}
|
|
56
|
+
if (queryString.startsWith("&")) {
|
|
57
|
+
queryString = queryString.substring(1);
|
|
52
58
|
}
|
|
53
59
|
if (customData == null ? void 0 : customData.dataSourceId) {
|
|
54
60
|
moduleDataApi == null ? void 0 : moduleDataApi({
|
|
@@ -70,7 +76,12 @@ const CalendarModule = ({
|
|
|
70
76
|
if (customData) {
|
|
71
77
|
fetchChartData();
|
|
72
78
|
}
|
|
73
|
-
}, [
|
|
79
|
+
}, [
|
|
80
|
+
customData == null ? void 0 : customData.dataSourceId,
|
|
81
|
+
customData == null ? void 0 : customData.conditionData,
|
|
82
|
+
startMonthIntervals,
|
|
83
|
+
matchGlobalFilterCondition
|
|
84
|
+
]);
|
|
74
85
|
const fieldOptions = useMemo(() => {
|
|
75
86
|
var _a, _b;
|
|
76
87
|
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;
|
|
@@ -162,6 +173,7 @@ const CalendarModule = ({
|
|
|
162
173
|
/* @__PURE__ */ jsx(
|
|
163
174
|
FullCalendar,
|
|
164
175
|
{
|
|
176
|
+
locale: i18n.language === "zh-CN" ? l77 : MINIMAL_RAW_EN_LOCALE,
|
|
165
177
|
ref: calendarRef,
|
|
166
178
|
plugins: [dayGridPlugin],
|
|
167
179
|
headerToolbar: {
|