bhd-components 0.8.0 → 0.9.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 +1 -1
- package/dist/{2f338078.esm.es5.production.js → 256789e0.esm.es5.production.js} +10 -10
- package/dist/{de88944c.esm.es5.development.js → f8c2008a.esm.es5.development.js} +18 -9
- package/dist/index.esm.es5.development.css +2237 -1003
- package/dist/index.esm.es5.development.js +519 -250
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/es2017/bhdDatePicker/index.d.ts +17 -0
- package/es2017/bhdDatePicker/index.js +360 -0
- package/es2017/bhdDatePicker/index.module.less +851 -0
- package/es2017/customerService/historyFun.js +1 -1
- package/es2017/customerService/index.js +21 -106
- package/es2017/customerService/index.module.less +2 -1
- package/es2017/customerService/index2.module.less +1 -0
- package/es2017/customerService/screenshotTool.js +9 -12
- package/es2017/index.d.ts +1 -0
- package/es2017/index.js +1 -0
- package/esm/bhdDatePicker/index.d.ts +17 -0
- package/esm/bhdDatePicker/index.js +367 -0
- package/esm/bhdDatePicker/index.module.less +851 -0
- package/esm/customerService/historyFun.js +1 -1
- package/esm/customerService/index.js +27 -113
- package/esm/customerService/index.module.less +2 -1
- package/esm/customerService/index2.module.less +1 -0
- package/esm/customerService/screenshotTool.js +8 -11
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
|
|
4
4
|
import React, { useEffect, useState, useRef } from "react";
|
|
5
5
|
import styles from "./index.module.less";
|
|
6
|
-
import "highlight.js/styles/github.css";
|
|
7
6
|
//import "highlight.js/styles/default.css";
|
|
7
|
+
import "highlight.js/styles/github.css";
|
|
8
8
|
import { Input } from "antd";
|
|
9
9
|
import { CustomClose, CustomExpand, CustomAiIcon } from "../icons/index";
|
|
10
10
|
import { SearchOutlined } from "@ant-design/icons";
|
|
@@ -4,6 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runt
|
|
|
4
4
|
import React, { useEffect, useState, useRef } from "react";
|
|
5
5
|
import { Modal, Drawer, Input, Tooltip } from "antd";
|
|
6
6
|
import ViewImage from "../viewImage";
|
|
7
|
+
// import html2canvas from "html2canvas";
|
|
7
8
|
import cssStyle from "./index.module.less";
|
|
8
9
|
import cssStyleOnline from "./index2.module.less";
|
|
9
10
|
let styles = cssStyle;
|
|
@@ -19,6 +20,7 @@ import TeacherList from "./teacherList";
|
|
|
19
20
|
import { parseDate } from "../utils/Date";
|
|
20
21
|
import { Remarkable } from "remarkable";
|
|
21
22
|
import hljs from "highlight.js";
|
|
23
|
+
//import "highlight.js/styles/default.css";
|
|
22
24
|
import "highlight.js/styles/github.css";
|
|
23
25
|
import { render } from "react-dom";
|
|
24
26
|
import Provider from "../provider";
|
|
@@ -105,117 +107,33 @@ const CustomerService = (props)=>{
|
|
|
105
107
|
initShowType
|
|
106
108
|
]);
|
|
107
109
|
useEffect(()=>{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
//|| showScreenshot
|
|
111
|
+
if (showType == 5 || showScreenshot) {
|
|
110
112
|
try {
|
|
111
113
|
newShowType.current = true;
|
|
112
114
|
setImgBese64('');
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
cropBoxInfo: {
|
|
123
|
-
x: 0,
|
|
124
|
-
y: 0,
|
|
125
|
-
w: window.innerWidth,
|
|
126
|
-
h: window.innerHeight
|
|
127
|
-
},
|
|
128
|
-
wrcReplyTime: 20,
|
|
129
|
-
wrcWindowMode: true,
|
|
130
|
-
hiddenScrollBar: {
|
|
131
|
-
state: true
|
|
132
|
-
},
|
|
133
|
-
completeCallback: ({ base64 })=>{
|
|
134
|
-
// console.log(
|
|
135
|
-
// "截图组件加载完毕调用此方法来完成框选区域的截图",
|
|
136
|
-
// base64
|
|
137
|
-
// );
|
|
138
|
-
setImgBese64(base64);
|
|
139
|
-
},
|
|
140
|
-
triggerCallback: ()=>{
|
|
141
|
-
// 截图组件加载完毕调用此方法来完成框选区域的截图
|
|
142
|
-
plugin.completeScreenshot();
|
|
143
|
-
},
|
|
144
|
-
cancelCallback: (err)=>{
|
|
145
|
-
if (err.code === -1) {
|
|
146
|
-
console.log(err);
|
|
147
|
-
newShowType.current = false;
|
|
148
|
-
if (saveShowType != -1) {
|
|
149
|
-
setShowType(saveShowType);
|
|
150
|
-
} else {
|
|
151
|
-
setShowType(1);
|
|
152
|
-
}
|
|
153
|
-
setShowScreenshot(false);
|
|
154
|
-
onCancel();
|
|
155
|
-
}
|
|
115
|
+
// let dom = document.getElementById(screenshotAreaId);
|
|
116
|
+
html2canvas(screenshotAreaId, {
|
|
117
|
+
useCORS: true,
|
|
118
|
+
// allowTaint: true, // 污染处理
|
|
119
|
+
scale: 1,
|
|
120
|
+
// logging:true,
|
|
121
|
+
ignoreElements: (element)=>{
|
|
122
|
+
if (element.compareDocumentPosition(screenshotAreaId) === 2) return true;
|
|
123
|
+
return false;
|
|
156
124
|
}
|
|
125
|
+
}).then(function(canvas) {
|
|
126
|
+
// document.body.appendChild(canvas);
|
|
127
|
+
console.log(canvas, 99999);
|
|
128
|
+
// var base64URL = canvas.toDataURL('image/jpeg')
|
|
129
|
+
let base64URL = canvas.toDataURL("image/jpg", 1.0);
|
|
130
|
+
console.log(base64URL);
|
|
131
|
+
setImgBese64(base64URL);
|
|
157
132
|
});
|
|
158
|
-
// modernScreenshot
|
|
159
|
-
// .domToPng(document.querySelector("body"))
|
|
160
|
-
// .then((dataUrl:any) => {
|
|
161
|
-
// console.log(dataUrl);
|
|
162
|
-
// setImgBese64(dataUrl);
|
|
163
|
-
// });
|
|
164
|
-
// domtoimage
|
|
165
|
-
// .toPng(document.body)
|
|
166
|
-
// .then(function (dataUrl:any) {
|
|
167
|
-
// setImgBese64(dataUrl);
|
|
168
|
-
// })
|
|
169
|
-
// .catch(function (error:any) {
|
|
170
|
-
// console.error("oops, something went wrong!", error);
|
|
171
|
-
// });
|
|
172
|
-
// //排除
|
|
173
|
-
// new screenShotPlugin({
|
|
174
|
-
// enableWebRtc: true,
|
|
175
|
-
// canvasWidth:window.innerWidth,
|
|
176
|
-
// canvasHeight:window.innerHeight,
|
|
177
|
-
// level:9999999,
|
|
178
|
-
// completeCallback: function (info:any) {
|
|
179
|
-
// console.log(info);
|
|
180
|
-
// setImgBese64(info.base64);
|
|
181
|
-
// },
|
|
182
|
-
// closeCallback: function () {
|
|
183
|
-
// },
|
|
184
|
-
// });
|
|
185
|
-
// html2canvas(document.body,{//__docusaurus
|
|
186
|
-
// useCORS: true, // 支持跨域图片截图
|
|
187
|
-
// allowTaint: true, // 污染处理
|
|
188
|
-
// scale: 1 ,// 图片比例
|
|
189
|
-
// logging:false,
|
|
190
|
-
// // foreignObjectRendering:true,
|
|
191
|
-
// ignoreElements:(element: { compareDocumentPosition: (arg0: string) => number; })=>{
|
|
192
|
-
// if(element.compareDocumentPosition(screenshotAreaId)===2)return true
|
|
193
|
-
// return false
|
|
194
|
-
// },
|
|
195
|
-
// windowWidth:window.innerWidth,
|
|
196
|
-
// windowHeight:window.innerHeight
|
|
197
|
-
// })
|
|
198
|
-
// .then(function (canvas:any) {
|
|
199
|
-
// // document.body.appendChild(canvas);
|
|
200
|
-
// // console.log(canvas,99999);
|
|
201
|
-
// // var base64URL = canvas.toDataURL('image/jpeg')
|
|
202
|
-
// let base64URL = canvas.toDataURL("image/jpg", 1.0)
|
|
203
|
-
// // console.log(base64URL);
|
|
204
|
-
// setImgBese64(base64URL);
|
|
205
|
-
// // svgNodesToRemove.forEach(item=>{
|
|
206
|
-
// // item.remove()
|
|
207
|
-
// // })
|
|
208
|
-
// });
|
|
209
133
|
} catch (error) {
|
|
210
134
|
console.log(error);
|
|
211
135
|
}
|
|
212
136
|
}
|
|
213
|
-
//|| showScreenshot
|
|
214
|
-
if (showType == 5 || showScreenshot) {
|
|
215
|
-
console.log('bbbbbbbbbbbbbb');
|
|
216
|
-
handlerHtml2canvas();
|
|
217
|
-
// window.addEventListener('resize',handlerHtml2canvas)
|
|
218
|
-
}
|
|
219
137
|
if (showType != 1 && !firstLoad && pageCount > 0) {
|
|
220
138
|
setFirstLoad(true);
|
|
221
139
|
scrollToBottom();
|
|
@@ -275,7 +193,7 @@ const CustomerService = (props)=>{
|
|
|
275
193
|
if (content) {
|
|
276
194
|
content.removeEventListener("scroll", handleScroll);
|
|
277
195
|
}
|
|
278
|
-
|
|
196
|
+
// window.removeEventListener('resize',handlerHtml2canvas)
|
|
279
197
|
};
|
|
280
198
|
}, [
|
|
281
199
|
historyMessageList,
|
|
@@ -3470,9 +3388,6 @@ const CustomerService = (props)=>{
|
|
|
3470
3388
|
}),
|
|
3471
3389
|
(showType == 4 || showType == 5) && /*#__PURE__*/ _jsxs("div", {
|
|
3472
3390
|
className: `${styles.ChatWindow_Drawer}`,
|
|
3473
|
-
style: {
|
|
3474
|
-
display: `${!showScreenshot ? "none" : "flex"}`
|
|
3475
|
-
},
|
|
3476
3391
|
id: "",
|
|
3477
3392
|
children: [
|
|
3478
3393
|
/*#__PURE__*/ _jsx("div", {
|
|
@@ -10,8 +10,6 @@ const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
10
10
|
const [crop, setCrop] = useState();
|
|
11
11
|
const [completedCrop, setCompletedCrop] = useState();
|
|
12
12
|
const [aspect, setAspect] = useState(16 / 9);
|
|
13
|
-
const [devicePixelRatio, setDevicePixelRatio] = useState(window.devicePixelRatio);
|
|
14
|
-
const [isFirst, setIsFirst] = useState(true);
|
|
15
13
|
const [btnPosition, setBtnPosition] = useState({
|
|
16
14
|
top: 0,
|
|
17
15
|
left: 0
|
|
@@ -37,17 +35,17 @@ const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
37
35
|
}
|
|
38
36
|
function saveImage() {
|
|
39
37
|
// 创建一个新的canvas元素
|
|
40
|
-
var canvas = document.createElement(
|
|
41
|
-
var context = canvas.getContext(
|
|
38
|
+
var canvas = document.createElement('canvas');
|
|
39
|
+
var context = canvas.getContext('2d');
|
|
42
40
|
// 加载要操作的图片
|
|
43
41
|
var image = new Image();
|
|
44
42
|
image.src = imgBese64; // 将'your_image_url'替换为你自己的图片URL
|
|
45
43
|
// 等待图片加载完成后再进行操作
|
|
46
44
|
image.onload = function() {
|
|
47
|
-
var x =
|
|
48
|
-
var y =
|
|
49
|
-
var width =
|
|
50
|
-
var height =
|
|
45
|
+
var x = completedCrop.x; // 起始点x坐标
|
|
46
|
+
var y = completedCrop.y; // 起始点y坐标
|
|
47
|
+
var width = completedCrop.width; // 需要裁剪的区域宽度
|
|
48
|
+
var height = completedCrop.height; // 需要裁剪的区域高度
|
|
51
49
|
// 设置canvas大小与裁剪区域相同
|
|
52
50
|
canvas.width = width;
|
|
53
51
|
canvas.height = height;
|
|
@@ -68,7 +66,7 @@ const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
68
66
|
let y = e.y;
|
|
69
67
|
let h = e.height;
|
|
70
68
|
let w = e.width;
|
|
71
|
-
let top = y + h +
|
|
69
|
+
let top = y + h + 8;
|
|
72
70
|
let left = x + w - 88;
|
|
73
71
|
if (top + 42 > window.innerHeight) {
|
|
74
72
|
top = top - 50;
|
|
@@ -78,7 +76,6 @@ const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
78
76
|
left
|
|
79
77
|
});
|
|
80
78
|
setShowBtn(true);
|
|
81
|
-
setIsFirst(false);
|
|
82
79
|
};
|
|
83
80
|
return /*#__PURE__*/ _jsxs("div", {
|
|
84
81
|
className: styles.screenshot_Modal,
|
|
@@ -122,8 +119,8 @@ const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
122
119
|
onClick: cancelScreenshot,
|
|
123
120
|
children: /*#__PURE__*/ _jsx(CloseOutlined, {
|
|
124
121
|
style: {
|
|
125
|
-
position:
|
|
126
|
-
top:
|
|
122
|
+
position: 'relative',
|
|
123
|
+
top: '1px'
|
|
127
124
|
}
|
|
128
125
|
})
|
|
129
126
|
}),
|
package/es2017/index.d.ts
CHANGED
|
@@ -80,3 +80,4 @@ export { default as BhdTipModal } from "./bhdTipModal";
|
|
|
80
80
|
export { default as BhdSelect } from "./bhdSelect";
|
|
81
81
|
export { default as BhdAppLayout } from "./bhdAppLayout";
|
|
82
82
|
export { default as CustomerService } from "./customerService";
|
|
83
|
+
export { default as BhdDatePicker } from "./bhdDatePicker";
|
package/es2017/index.js
CHANGED
|
@@ -85,3 +85,4 @@ export { default as BhdTipModal } from "./bhdTipModal/index"; //提示框
|
|
|
85
85
|
export { default as BhdSelect } from "./bhdSelect/index"; //封装 bhdSelect
|
|
86
86
|
export { default as BhdAppLayout } from "./bhdAppLayout/index"; //封装 BhdAppLayout
|
|
87
87
|
export { default as CustomerService } from "./customerService/index"; //封装 智能客服
|
|
88
|
+
export { default as BhdDatePicker } from "./bhdDatePicker/index"; //封装 日历组件
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Dayjs } from "dayjs";
|
|
3
|
+
export interface BhdDateExtraPicker {
|
|
4
|
+
date: Dayjs;
|
|
5
|
+
text: string;
|
|
6
|
+
status: "selectable" | "noselectable" | "selected";
|
|
7
|
+
}
|
|
8
|
+
interface BhdDatePickerProps {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
kind: "single" | "range" | "extra";
|
|
11
|
+
useType?: string;
|
|
12
|
+
label?: React.ReactNode;
|
|
13
|
+
extraItems?: BhdDateExtraPicker[];
|
|
14
|
+
extraReadonly?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare const BhdDatePicker: (props: BhdDatePickerProps) => React.JSX.Element;
|
|
17
|
+
export default BhdDatePicker;
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
|
+
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { useState, useRef } from "react";
|
|
7
|
+
import styles from "./index.module.less";
|
|
8
|
+
import { Button, DatePicker } from "antd";
|
|
9
|
+
import { CustomArrow, CalendarOutlined } from "../icons/index";
|
|
10
|
+
import dayjs from "dayjs";
|
|
11
|
+
var RangePicker = DatePicker.RangePicker;
|
|
12
|
+
var BhdDatePicker = function(props) {
|
|
13
|
+
var _props_kind = props.kind, kind = _props_kind === void 0 ? "single" : _props_kind, _props_value = props.value, value = _props_value === void 0 ? props.kind === "range" ? [] : "" : _props_value, extraItems = props.extraItems, _props_extraReadonly = props.extraReadonly, extraReadonly = _props_extraReadonly === void 0 ? false : _props_extraReadonly, picker = props.picker, _props_useType = props.useType, useType = _props_useType === void 0 ? "" : _props_useType, _props_label = props.label, label = _props_label === void 0 ? "" : _props_label, className = props.className, popupClassName = props.popupClassName, showTime = props.showTime, _props_showNow = props.showNow, showNow = _props_showNow === void 0 ? true : _props_showNow, onClick = props.onClick, onBlur = props.onBlur, onChange = props.onChange, onOk = props.onOk, _props_presets = props.presets, presets = _props_presets === void 0 ? [] : _props_presets;
|
|
14
|
+
var bhdDatePickerRef = useRef(null);
|
|
15
|
+
var _useState = _sliced_to_array(useState(false), 2), open = _useState[0], setOpen = _useState[1];
|
|
16
|
+
var _useState1 = _sliced_to_array(useState(value), 2), selectedDate = _useState1[0], setSelectedDate = _useState1[1];
|
|
17
|
+
var _useState2 = _sliced_to_array(useState(null), 2), selectedDateString = _useState2[0], setSelectedDateString = _useState2[1];
|
|
18
|
+
var selectedDateRef = useRef(value);
|
|
19
|
+
var selectedDateStringRef = useRef(null);
|
|
20
|
+
var _useState3 = _sliced_to_array(useState(value), 2), selectedRangeDate = _useState3[0], setSelectedRangeDate = _useState3[1];
|
|
21
|
+
var _useState4 = _sliced_to_array(useState([]), 2), selectedRangeDateString = _useState4[0], setSelectedRangeDateString = _useState4[1];
|
|
22
|
+
var getConfig = function() {
|
|
23
|
+
var config = _object_spread({}, props);
|
|
24
|
+
delete config.cellRender;
|
|
25
|
+
delete config.className;
|
|
26
|
+
delete config.prevIcon;
|
|
27
|
+
delete config.nextIcon;
|
|
28
|
+
delete config.superPrevIcon;
|
|
29
|
+
delete config.superNextIcon;
|
|
30
|
+
delete config.open;
|
|
31
|
+
delete config.onOpenChange;
|
|
32
|
+
delete config.renderExtraFooter;
|
|
33
|
+
delete config.useType;
|
|
34
|
+
delete config.showNow;
|
|
35
|
+
delete config.onClick;
|
|
36
|
+
delete config.onBlur;
|
|
37
|
+
delete config.onOk;
|
|
38
|
+
delete config.onChange;
|
|
39
|
+
delete config.presets;
|
|
40
|
+
if (kind === "single" || kind === "extra") {
|
|
41
|
+
delete config.value;
|
|
42
|
+
}
|
|
43
|
+
if (kind === "extra" && picker !== "date") {
|
|
44
|
+
delete config.extraItems;
|
|
45
|
+
}
|
|
46
|
+
if (kind === "extra") {
|
|
47
|
+
delete config.disabledDate;
|
|
48
|
+
}
|
|
49
|
+
return config;
|
|
50
|
+
};
|
|
51
|
+
//单元格渲染
|
|
52
|
+
var cellRender = function(current, info) {
|
|
53
|
+
if (info.type !== "date") {
|
|
54
|
+
return info.originNode;
|
|
55
|
+
}
|
|
56
|
+
if (typeof current === "number" || typeof current === "string") {
|
|
57
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
58
|
+
className: "bhd-picker-cell-inner",
|
|
59
|
+
children: current
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
var extraItem = null;
|
|
63
|
+
if (kind === "extra") {
|
|
64
|
+
extraItem = extraItems === null || extraItems === void 0 ? void 0 : extraItems.find(function(item) {
|
|
65
|
+
return item.date.format("YYYYMMDD") === current.format("YYYYMMDD");
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
69
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
70
|
+
className: "bhd-picker-cell-inner",
|
|
71
|
+
children: [
|
|
72
|
+
current.format("DD"),
|
|
73
|
+
kind === "extra" && extraItem && /*#__PURE__*/ _jsx("div", {
|
|
74
|
+
className: "extraText ".concat(extraItem.status),
|
|
75
|
+
children: extraItem.text
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
//日期禁用
|
|
82
|
+
var disabledDate = function(current) {
|
|
83
|
+
if (extraReadonly) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
// 不能选择的是没有日程安排的
|
|
87
|
+
var extraItem = null;
|
|
88
|
+
if (kind === "extra") {
|
|
89
|
+
extraItem = extraItems === null || extraItems === void 0 ? void 0 : extraItems.find(function(item) {
|
|
90
|
+
return item.date.format("YYYYMMDD") === current.format("YYYYMMDD");
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return !extraItem || current && extraItem.status === "noselectable";
|
|
94
|
+
};
|
|
95
|
+
// 渲染底部扩展内容
|
|
96
|
+
var renderExtraFooter = function(mode) {
|
|
97
|
+
return !showTime ? /*#__PURE__*/ _jsxs("ul", {
|
|
98
|
+
className: "bhd-picker-ranges",
|
|
99
|
+
children: [
|
|
100
|
+
renderPresets(),
|
|
101
|
+
showNow && (kind === "single" || kind === "extra" && extraItems.filter(function(item) {
|
|
102
|
+
return item.status !== "noselectable" && item.date.format("YYYY-MM-DD") === dayjs().format("YYYY-MM-DD");
|
|
103
|
+
}).length > 0) && mode === "date" && /*#__PURE__*/ _jsx("li", {
|
|
104
|
+
className: "bhd-picker-now",
|
|
105
|
+
children: /*#__PURE__*/ _jsx("a", {
|
|
106
|
+
className: "bhd-picker-now-btn",
|
|
107
|
+
onClick: todayClick,
|
|
108
|
+
children: showTime ? "此刻" : "今天"
|
|
109
|
+
})
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ _jsx("li", {
|
|
112
|
+
className: "bhd-picker-ok",
|
|
113
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
114
|
+
type: "primary",
|
|
115
|
+
disabled: kind === "range" ? !((selectedRangeDate === null || selectedRangeDate === void 0 ? void 0 : selectedRangeDate[0]) && (selectedRangeDate === null || selectedRangeDate === void 0 ? void 0 : selectedRangeDate[1])) : !(selectedDate && selectedDateString),
|
|
116
|
+
onClick: okClick,
|
|
117
|
+
children: "确定"
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}) : /*#__PURE__*/ _jsx("ul", {
|
|
122
|
+
className: "bhd-picker-ranges",
|
|
123
|
+
children: renderPresets()
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
// 渲染预设
|
|
127
|
+
var renderPresets = function() {
|
|
128
|
+
return /*#__PURE__*/ _jsx("li", {
|
|
129
|
+
className: "bhd-picker-presets",
|
|
130
|
+
children: presets.map(function(item) {
|
|
131
|
+
return /*#__PURE__*/ _jsx("a", {
|
|
132
|
+
className: "bhd-picker-preset-btn",
|
|
133
|
+
onClick: function() {
|
|
134
|
+
presetClick(item.value);
|
|
135
|
+
},
|
|
136
|
+
children: item.label
|
|
137
|
+
});
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
// 日期选择确认
|
|
142
|
+
var okClick = function() {
|
|
143
|
+
if (kind === "range") {
|
|
144
|
+
if (selectedRangeDate && selectedRangeDateString) {
|
|
145
|
+
onChange && onChange(selectedRangeDate, selectedRangeDateString);
|
|
146
|
+
setOpen(false);
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
if (selectedDate && selectedDateString) {
|
|
150
|
+
onChange && onChange(selectedDate, selectedDateString);
|
|
151
|
+
setOpen(false);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
var todayClick = function() {
|
|
156
|
+
var today = dayjs();
|
|
157
|
+
var todayString = today.format(showTime ? "YYYY-MM-DD hh:mm:ss" : "YYYY-MM-DD");
|
|
158
|
+
setSelectedDate(today);
|
|
159
|
+
setSelectedDateString(todayString);
|
|
160
|
+
onChange && onChange(today, todayString);
|
|
161
|
+
setOpen(false);
|
|
162
|
+
};
|
|
163
|
+
//预设点击
|
|
164
|
+
var presetClick = function(value) {
|
|
165
|
+
var todayString = value.format(showTime ? "YYYY-MM-DD hh:mm:ss" : "YYYY-MM-DD");
|
|
166
|
+
setSelectedDate(value);
|
|
167
|
+
setSelectedDateString(todayString);
|
|
168
|
+
onChange && onChange(value, todayString);
|
|
169
|
+
setOpen(false);
|
|
170
|
+
};
|
|
171
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
172
|
+
className: "".concat(styles.bhdDatePicker),
|
|
173
|
+
ref: bhdDatePickerRef,
|
|
174
|
+
children: [
|
|
175
|
+
kind === "single" && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
176
|
+
children: [
|
|
177
|
+
useType === "table" && /*#__PURE__*/ _jsxs("span", {
|
|
178
|
+
className: styles.pickerLabel,
|
|
179
|
+
onClick: function() {
|
|
180
|
+
setOpen(true);
|
|
181
|
+
},
|
|
182
|
+
children: [
|
|
183
|
+
label,
|
|
184
|
+
/*#__PURE__*/ _jsx(CalendarOutlined, {})
|
|
185
|
+
]
|
|
186
|
+
}),
|
|
187
|
+
/*#__PURE__*/ _jsx(DatePicker, _object_spread_props(_object_spread({}, getConfig()), {
|
|
188
|
+
className: "".concat(className, " ").concat(useType === "table" ? "hide" : ""),
|
|
189
|
+
popupClassName: "".concat(styles.bhdDatePickerPopup, " ").concat(styles.singlePicker, " ").concat(popupClassName || ""),
|
|
190
|
+
cellRender: cellRender,
|
|
191
|
+
prevIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
192
|
+
style: {
|
|
193
|
+
transform: "rotate(90deg)"
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
nextIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
197
|
+
style: {
|
|
198
|
+
transform: "rotate(-90deg)"
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
superPrevIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
202
|
+
style: {
|
|
203
|
+
transform: "rotate(90deg)"
|
|
204
|
+
}
|
|
205
|
+
}),
|
|
206
|
+
superNextIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
207
|
+
style: {
|
|
208
|
+
transform: "rotate(-90deg)"
|
|
209
|
+
}
|
|
210
|
+
}),
|
|
211
|
+
open: open,
|
|
212
|
+
showNow: showTime ? showNow : false,
|
|
213
|
+
value: selectedDate,
|
|
214
|
+
onChange: function(date, dateString) {
|
|
215
|
+
setSelectedDate(function(prevState) {
|
|
216
|
+
selectedDateRef.current = date;
|
|
217
|
+
return selectedDateRef.current;
|
|
218
|
+
});
|
|
219
|
+
setSelectedDateString(function(prevState) {
|
|
220
|
+
selectedDateStringRef.current = dateString;
|
|
221
|
+
return selectedDateStringRef.current;
|
|
222
|
+
});
|
|
223
|
+
console.log({
|
|
224
|
+
selectedDate: selectedDateRef.current,
|
|
225
|
+
selectedDateString: selectedDateStringRef.current
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
onOk: function() {
|
|
229
|
+
if (showTime) {
|
|
230
|
+
setTimeout(function() {
|
|
231
|
+
console.log({
|
|
232
|
+
selectedDate: selectedDateRef.current,
|
|
233
|
+
selectedDateString: selectedDateStringRef.current
|
|
234
|
+
});
|
|
235
|
+
onChange && onChange(selectedDateRef.current, selectedDateStringRef.current);
|
|
236
|
+
setOpen(false);
|
|
237
|
+
}, 0);
|
|
238
|
+
}
|
|
239
|
+
onOk && onOk();
|
|
240
|
+
},
|
|
241
|
+
onClick: function() {
|
|
242
|
+
setOpen(true);
|
|
243
|
+
onClick && onClick();
|
|
244
|
+
},
|
|
245
|
+
onBlur: function() {
|
|
246
|
+
okClick();
|
|
247
|
+
setOpen(false);
|
|
248
|
+
onBlur && onBlur();
|
|
249
|
+
},
|
|
250
|
+
renderExtraFooter: renderExtraFooter
|
|
251
|
+
}))
|
|
252
|
+
]
|
|
253
|
+
}),
|
|
254
|
+
kind === "range" && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
255
|
+
children: [
|
|
256
|
+
useType === "table" && /*#__PURE__*/ _jsxs("span", {
|
|
257
|
+
className: styles.pickerLabel,
|
|
258
|
+
onClick: function() {
|
|
259
|
+
setOpen(true);
|
|
260
|
+
},
|
|
261
|
+
children: [
|
|
262
|
+
label,
|
|
263
|
+
/*#__PURE__*/ _jsx(CalendarOutlined, {})
|
|
264
|
+
]
|
|
265
|
+
}),
|
|
266
|
+
/*#__PURE__*/ _jsx(RangePicker, _object_spread_props(_object_spread({}, getConfig()), {
|
|
267
|
+
className: "".concat(className, " ").concat(useType === "table" ? "hide" : ""),
|
|
268
|
+
popupClassName: "".concat(styles.bhdDatePickerPopup, " ").concat(styles.rangePicker, " ").concat(popupClassName || ""),
|
|
269
|
+
cellRender: cellRender,
|
|
270
|
+
prevIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
271
|
+
style: {
|
|
272
|
+
transform: "rotate(90deg)"
|
|
273
|
+
}
|
|
274
|
+
}),
|
|
275
|
+
nextIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
276
|
+
style: {
|
|
277
|
+
transform: "rotate(-90deg)"
|
|
278
|
+
}
|
|
279
|
+
}),
|
|
280
|
+
superPrevIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
281
|
+
style: {
|
|
282
|
+
transform: "rotate(90deg)"
|
|
283
|
+
}
|
|
284
|
+
}),
|
|
285
|
+
superNextIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
286
|
+
style: {
|
|
287
|
+
transform: "rotate(-90deg)"
|
|
288
|
+
}
|
|
289
|
+
}),
|
|
290
|
+
open: open,
|
|
291
|
+
showNow: false,
|
|
292
|
+
value: selectedRangeDate,
|
|
293
|
+
onClick: function() {
|
|
294
|
+
setOpen(true);
|
|
295
|
+
onClick && onClick();
|
|
296
|
+
},
|
|
297
|
+
onCalendarChange: function(dates, dateStrings, info) {
|
|
298
|
+
setSelectedRangeDate(dates);
|
|
299
|
+
setSelectedRangeDateString(dateStrings);
|
|
300
|
+
},
|
|
301
|
+
onBlur: function() {
|
|
302
|
+
if ((selectedRangeDate === null || selectedRangeDate === void 0 ? void 0 : selectedRangeDate[0]) && (selectedRangeDate === null || selectedRangeDate === void 0 ? void 0 : selectedRangeDate[1])) {
|
|
303
|
+
okClick();
|
|
304
|
+
setOpen(false);
|
|
305
|
+
} else if (!(selectedRangeDate === null || selectedRangeDate === void 0 ? void 0 : selectedRangeDate[0]) && !(selectedRangeDate === null || selectedRangeDate === void 0 ? void 0 : selectedRangeDate[1])) {
|
|
306
|
+
setOpen(false);
|
|
307
|
+
}
|
|
308
|
+
onBlur && onBlur();
|
|
309
|
+
},
|
|
310
|
+
renderExtraFooter: renderExtraFooter
|
|
311
|
+
}))
|
|
312
|
+
]
|
|
313
|
+
}),
|
|
314
|
+
kind === "extra" && /*#__PURE__*/ _jsx(DatePicker, _object_spread_props(_object_spread({}, getConfig()), {
|
|
315
|
+
className: "".concat(className, " ").concat(useType === "table" ? "hide" : ""),
|
|
316
|
+
popupClassName: "".concat(styles.bhdDatePickerPopup, " ").concat(styles.extraPicker, " ").concat(extraReadonly ? styles.readonly : "", " ").concat(popupClassName || ""),
|
|
317
|
+
cellRender: cellRender,
|
|
318
|
+
prevIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
319
|
+
style: {
|
|
320
|
+
transform: "rotate(90deg)"
|
|
321
|
+
}
|
|
322
|
+
}),
|
|
323
|
+
nextIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
324
|
+
style: {
|
|
325
|
+
transform: "rotate(-90deg)"
|
|
326
|
+
}
|
|
327
|
+
}),
|
|
328
|
+
superPrevIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
329
|
+
style: {
|
|
330
|
+
transform: "rotate(90deg)"
|
|
331
|
+
}
|
|
332
|
+
}),
|
|
333
|
+
superNextIcon: /*#__PURE__*/ _jsx(CustomArrow, {
|
|
334
|
+
style: {
|
|
335
|
+
transform: "rotate(-90deg)"
|
|
336
|
+
}
|
|
337
|
+
}),
|
|
338
|
+
disabledDate: disabledDate,
|
|
339
|
+
allowClear: !extraReadonly,
|
|
340
|
+
open: open,
|
|
341
|
+
showNow: false,
|
|
342
|
+
value: selectedDate,
|
|
343
|
+
onChange: function(date, dateString) {
|
|
344
|
+
setSelectedDate(date);
|
|
345
|
+
setSelectedDateString(dateString);
|
|
346
|
+
},
|
|
347
|
+
onClick: function() {
|
|
348
|
+
setOpen(true);
|
|
349
|
+
onClick && onClick();
|
|
350
|
+
},
|
|
351
|
+
onBlur: function() {
|
|
352
|
+
if (!extraReadonly) {
|
|
353
|
+
okClick();
|
|
354
|
+
}
|
|
355
|
+
setOpen(false);
|
|
356
|
+
onBlur && onBlur();
|
|
357
|
+
},
|
|
358
|
+
panelRender: function(panelNode) {
|
|
359
|
+
console.log(panelNode);
|
|
360
|
+
return panelNode;
|
|
361
|
+
},
|
|
362
|
+
renderExtraFooter: extraReadonly ? null : renderExtraFooter
|
|
363
|
+
}))
|
|
364
|
+
]
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
export default BhdDatePicker;
|