@pisell/date-picker 1.0.74 → 1.0.76
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/ActionBar/index.js +19 -28
- package/es/ActionBar/index.less +2 -1
- package/es/CustomCalendarHeader/index.js +53 -0
- package/es/Dialog/index.js +22 -0
- package/es/Drawer/index.js +35 -0
- package/es/Drawer/index.less +40 -0
- package/es/PisellDateRangePicker/LocaleContext.d.ts +2 -0
- package/es/PisellDateRangePicker/index.js +109 -39
- package/es/PisellDateRangePicker/index.less +56 -0
- package/es/Toolbar/index.js +122 -0
- package/es/Toolbar/index.less +32 -0
- package/es/browserSelect/chevron-down.png +0 -0
- package/es/browserSelect/index.js +36 -0
- package/es/browserSelect/index.less +18 -0
- package/es/constants.js +109 -0
- package/es/hooks/useDocumentVisibility.js +27 -0
- package/es/hooks/useNextDay.js +15 -0
- package/es/hooks/useUpdateEffect.js +11 -0
- package/es/icon/ChevronLeft.js +23 -0
- package/es/icon/ChevronLeftDouble.js +23 -0
- package/es/icon/ChevronRight.js +23 -0
- package/es/icon/ChevronRightDouble.js +23 -0
- package/es/index.js +1 -0
- package/es/internals/utils/date-fields-utils.d.ts +1 -1
- package/es/locales/en-US.js +18 -1
- package/es/locales/index.d.ts +2 -0
- package/es/locales/zh-CN.js +21 -4
- package/es/locales/zh-TW.js +18 -1
- package/es/utils/index.js +86 -3
- package/lib/ActionBar/index.js +30 -25
- package/lib/ActionBar/index.less +2 -1
- package/lib/CustomCalendarHeader/index.js +58 -0
- package/lib/Dialog/index.js +52 -0
- package/lib/Drawer/index.js +62 -0
- package/lib/Drawer/index.less +40 -0
- package/lib/PisellDateRangePicker/LocaleContext.d.ts +2 -0
- package/lib/PisellDateRangePicker/index.js +86 -32
- package/lib/PisellDateRangePicker/index.less +56 -0
- package/lib/Toolbar/index.js +139 -0
- package/lib/Toolbar/index.less +32 -0
- package/lib/browserSelect/chevron-down.png +0 -0
- package/lib/browserSelect/index.js +59 -0
- package/lib/browserSelect/index.less +18 -0
- package/lib/constants.js +147 -0
- package/lib/hooks/useDocumentVisibility.js +40 -0
- package/lib/hooks/useNextDay.js +49 -0
- package/lib/hooks/useUpdateEffect.js +35 -0
- package/lib/icon/ChevronLeft.js +60 -0
- package/lib/icon/ChevronLeftDouble.js +60 -0
- package/lib/icon/ChevronRight.js +60 -0
- package/lib/icon/ChevronRightDouble.js +60 -0
- package/lib/{PisellDateRangePicker → icon}/CloseCircle.js +1 -1
- package/lib/index.js +10 -1
- package/lib/internals/utils/date-fields-utils.d.ts +1 -1
- package/lib/locales/en-US.js +18 -1
- package/lib/locales/index.d.ts +2 -0
- package/lib/locales/zh-CN.js +18 -1
- package/lib/locales/zh-TW.js +18 -1
- package/lib/utils/index.js +58 -0
- package/package.json +2 -2
- package/es/ActionBar/index.d.ts +0 -18
- package/es/PisellDateRangePicker/CloseCircle.d.ts +0 -5
- package/es/Shortcuts/index.d.ts +0 -14
- package/es/locales/en-US.d.ts +0 -7
- package/es/locales/zh-CN.d.ts +0 -7
- package/es/locales/zh-TW.d.ts +0 -7
- package/es/utils/index.d.ts +0 -3
- package/lib/ActionBar/index.d.ts +0 -18
- package/lib/PisellDateRangePicker/CloseCircle.d.ts +0 -5
- package/lib/Shortcuts/index.d.ts +0 -14
- package/lib/locales/en-US.d.ts +0 -7
- package/lib/locales/zh-CN.d.ts +0 -7
- package/lib/locales/zh-TW.d.ts +0 -7
- package/lib/utils/index.d.ts +0 -3
- /package/es/{PisellDateRangePicker → icon}/CloseCircle.js +0 -0
package/es/ActionBar/index.js
CHANGED
|
@@ -13,7 +13,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
13
13
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
14
|
import React, { useMemo, useContext } from "react";
|
|
15
15
|
import classNames from "classnames";
|
|
16
|
-
import { Button
|
|
16
|
+
import { Button } from "antd";
|
|
17
17
|
import { MuiPickersAdapterContext } from "@mui/x-date-pickers";
|
|
18
18
|
import { isArr, isMobile } from "@pisell/utils";
|
|
19
19
|
import dayjs from "dayjs";
|
|
@@ -52,6 +52,15 @@ var ActionBar = function ActionBar(props) {
|
|
|
52
52
|
onChange(newValue, "time");
|
|
53
53
|
};
|
|
54
54
|
var spaceStyle = useMemo(function () {
|
|
55
|
+
return isMobile() ? {
|
|
56
|
+
display: "flex",
|
|
57
|
+
justifyContent: "end",
|
|
58
|
+
gap: 16
|
|
59
|
+
} : {
|
|
60
|
+
display: "flex"
|
|
61
|
+
};
|
|
62
|
+
}, []);
|
|
63
|
+
var buttonStyle = useMemo(function () {
|
|
55
64
|
return isMobile() ? {
|
|
56
65
|
display: "flex",
|
|
57
66
|
justifyContent: "end",
|
|
@@ -74,40 +83,22 @@ var ActionBar = function ActionBar(props) {
|
|
|
74
83
|
}, [showTime]);
|
|
75
84
|
return /*#__PURE__*/React.createElement("div", {
|
|
76
85
|
className: classNames(props.className, "date-picker-action-bar")
|
|
77
|
-
},
|
|
78
|
-
className: "date-picker-action-bar-left"
|
|
79
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
80
87
|
className: "date-picker-action-bar-right",
|
|
81
|
-
style: isMobile() ? {
|
|
82
|
-
display: "block"
|
|
83
|
-
} : {}
|
|
84
|
-
}, /*#__PURE__*/React.createElement(Space, {
|
|
85
|
-
split: "-",
|
|
86
|
-
style: _objectSpread({}, spaceStyle)
|
|
87
|
-
}, showTime ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TimePicker, _extends({
|
|
88
|
-
placeholder: getText("action-bar-start.time", pLocaleMap[locale])
|
|
89
|
-
}, startTimeProps, {
|
|
90
|
-
value: value[0],
|
|
91
|
-
popupClassName: "date-picker-action-bar-time-picker-popup",
|
|
92
|
-
onChange: handleStartChange,
|
|
93
|
-
inputReadOnly: true
|
|
94
|
-
})), /*#__PURE__*/React.createElement(TimePicker, _extends({
|
|
95
|
-
placeholder: getText("action-bar-end.time", pLocaleMap[locale])
|
|
96
|
-
}, endTimeProps, {
|
|
97
|
-
value: value[1],
|
|
98
|
-
popupClassName: "date-picker-action-bar-time-picker-popup",
|
|
99
|
-
onChange: handleEndChange,
|
|
100
|
-
inputReadOnly: true
|
|
101
|
-
}))) : /*#__PURE__*/React.createElement("div", null)), /*#__PURE__*/React.createElement(Space, {
|
|
102
88
|
style: _objectSpread(_objectSpread({}, spaceStyle), {}, {
|
|
103
89
|
margin: 0
|
|
104
90
|
})
|
|
105
|
-
}, /*#__PURE__*/React.createElement(Button, _extends({
|
|
91
|
+
}, /*#__PURE__*/React.createElement(Button, _extends({
|
|
92
|
+
block: isMobile(),
|
|
93
|
+
size: "large"
|
|
94
|
+
}, cancelButtonProps || {}, {
|
|
106
95
|
onClick: onCancel
|
|
107
96
|
}), getText("action-bar-cancel", pLocaleMap[locale])), /*#__PURE__*/React.createElement(Button, _extends({
|
|
108
|
-
type: "primary"
|
|
97
|
+
type: "primary",
|
|
98
|
+
size: "large",
|
|
99
|
+
block: isMobile()
|
|
109
100
|
}, okButtonProps || {}, {
|
|
110
101
|
onClick: onOk
|
|
111
|
-
}), getText("action-bar-apply", pLocaleMap[locale]))))
|
|
102
|
+
}), getText("action-bar-apply", pLocaleMap[locale]))));
|
|
112
103
|
};
|
|
113
104
|
export default ActionBar;
|
package/es/ActionBar/index.less
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Stack from '@mui/material/Stack';
|
|
3
|
+
import IconButton from '@mui/material/IconButton';
|
|
4
|
+
import Typography from '@mui/material/Typography';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
|
+
import ChevronLeft from "../icon/ChevronLeft";
|
|
7
|
+
import ChevronLeftDouble from "../icon/ChevronLeftDouble";
|
|
8
|
+
import ChevronRight from "../icon/ChevronRight";
|
|
9
|
+
import ChevronRightDouble from "../icon/ChevronRightDouble";
|
|
10
|
+
var CustomCalendarHeaderRoot = styled('div')({
|
|
11
|
+
display: 'flex',
|
|
12
|
+
justifyContent: 'space-between',
|
|
13
|
+
padding: '8px 16px',
|
|
14
|
+
alignItems: 'center'
|
|
15
|
+
});
|
|
16
|
+
var CustomCalendarHeader = function CustomCalendarHeader(props) {
|
|
17
|
+
var currentMonth = props.currentMonth,
|
|
18
|
+
onMonthChange = props.onMonthChange;
|
|
19
|
+
var selectNextMonth = function selectNextMonth() {
|
|
20
|
+
return onMonthChange(currentMonth.add(1, 'month'), 'left');
|
|
21
|
+
};
|
|
22
|
+
var selectNextYear = function selectNextYear() {
|
|
23
|
+
return onMonthChange(currentMonth.add(1, 'year'), 'left');
|
|
24
|
+
};
|
|
25
|
+
var selectPreviousMonth = function selectPreviousMonth() {
|
|
26
|
+
return onMonthChange(currentMonth.subtract(1, 'month'), 'right');
|
|
27
|
+
};
|
|
28
|
+
var selectPreviousYear = function selectPreviousYear() {
|
|
29
|
+
return onMonthChange(currentMonth.subtract(1, 'year'), 'right');
|
|
30
|
+
};
|
|
31
|
+
return /*#__PURE__*/React.createElement(CustomCalendarHeaderRoot, null, /*#__PURE__*/React.createElement(Stack, {
|
|
32
|
+
spacing: 1,
|
|
33
|
+
direction: "row"
|
|
34
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
35
|
+
onClick: selectPreviousYear,
|
|
36
|
+
title: "Previous year"
|
|
37
|
+
}, /*#__PURE__*/React.createElement(ChevronLeftDouble, null)), /*#__PURE__*/React.createElement(IconButton, {
|
|
38
|
+
onClick: selectPreviousMonth,
|
|
39
|
+
title: "Previous month"
|
|
40
|
+
}, /*#__PURE__*/React.createElement(ChevronLeft, null))), /*#__PURE__*/React.createElement(Typography, {
|
|
41
|
+
variant: "body2"
|
|
42
|
+
}, currentMonth.format('MMMM YYYY')), /*#__PURE__*/React.createElement(Stack, {
|
|
43
|
+
spacing: 1,
|
|
44
|
+
direction: "row"
|
|
45
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
46
|
+
onClick: selectNextMonth,
|
|
47
|
+
title: "Next month"
|
|
48
|
+
}, /*#__PURE__*/React.createElement(ChevronRight, null)), /*#__PURE__*/React.createElement(IconButton, {
|
|
49
|
+
onClick: selectNextYear,
|
|
50
|
+
title: "Next year"
|
|
51
|
+
}, /*#__PURE__*/React.createElement(ChevronRightDouble, null))));
|
|
52
|
+
};
|
|
53
|
+
export default CustomCalendarHeader;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
// import Drawer from "../Drawer";
|
|
3
|
+
|
|
4
|
+
import Drawer from "@mui/material/Drawer";
|
|
5
|
+
var Dialog = function Dialog(props) {
|
|
6
|
+
var open = props.open,
|
|
7
|
+
onClose = props.onClose,
|
|
8
|
+
children = props.children;
|
|
9
|
+
|
|
10
|
+
// return <MuiDialog open={open}>
|
|
11
|
+
// {children}
|
|
12
|
+
// </MuiDialog>
|
|
13
|
+
return /*#__PURE__*/React.createElement(Drawer, {
|
|
14
|
+
anchor: "bottom",
|
|
15
|
+
open: open,
|
|
16
|
+
onClose: onClose,
|
|
17
|
+
height: 650,
|
|
18
|
+
autoFocus: true,
|
|
19
|
+
className: window.innerWidth > 800 ? 'date-picker-paid-drawer' : 'date-picker-custom-drawer'
|
|
20
|
+
}, children);
|
|
21
|
+
};
|
|
22
|
+
export default Dialog;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import "./index.less";
|
|
4
|
+
var Drawer = function Drawer(props) {
|
|
5
|
+
var open = props.open,
|
|
6
|
+
className = props.className,
|
|
7
|
+
onClose = props.onClose,
|
|
8
|
+
children = props.children,
|
|
9
|
+
_props$height = props.height,
|
|
10
|
+
height = _props$height === void 0 ? 375 : _props$height;
|
|
11
|
+
|
|
12
|
+
// return ReactDOM.createPortal(
|
|
13
|
+
// drawerElement,
|
|
14
|
+
// document.body
|
|
15
|
+
// );
|
|
16
|
+
|
|
17
|
+
if (!open) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, open && /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: "date-picker-drawer-overlay",
|
|
22
|
+
onClick: onClose
|
|
23
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
className: classNames("date-picker-drawer", className, {
|
|
25
|
+
open: open
|
|
26
|
+
}),
|
|
27
|
+
onClick: function onClick() {}
|
|
28
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: "date-picker-drawer-content",
|
|
30
|
+
style: {
|
|
31
|
+
height: height
|
|
32
|
+
}
|
|
33
|
+
}, children)));
|
|
34
|
+
};
|
|
35
|
+
export default Drawer;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
.date-picker-drawer {
|
|
2
|
+
position: fixed;
|
|
3
|
+
bottom: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
background-color: white;
|
|
7
|
+
box-shadow: 0px -2px 10px rgba(0, 0, 0, 0.1);
|
|
8
|
+
transform: translateY(100%);
|
|
9
|
+
transition: transform 0.3s ease-out;
|
|
10
|
+
z-index: 1000;
|
|
11
|
+
border-radius: 8px 8px 0 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.date-picker-drawer-content {
|
|
15
|
+
//transform: translateY(100%);
|
|
16
|
+
//transition: transform 0.3s ease-out;
|
|
17
|
+
//position: absolute;
|
|
18
|
+
//padding: 20px;
|
|
19
|
+
//bottom: 0;
|
|
20
|
+
//width: 100vw;
|
|
21
|
+
//background-color: #fff;
|
|
22
|
+
//z-index: 1000;
|
|
23
|
+
//box-shadow: 0px -2px 10px rgba(0, 0, 0, 0.1);
|
|
24
|
+
//border-radius: 8px 8px 0px 0px;
|
|
25
|
+
//height: 650px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.date-picker-drawer.open {
|
|
29
|
+
transform: translateY(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.date-picker-drawer-overlay {
|
|
33
|
+
position: fixed;
|
|
34
|
+
top: 0;
|
|
35
|
+
left: 0;
|
|
36
|
+
width: 100%;
|
|
37
|
+
height: 100%;
|
|
38
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
39
|
+
z-index: 999;
|
|
40
|
+
}
|
|
@@ -10,24 +10,30 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
11
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import React, { useState, useEffect, useMemo, useContext } from "react";
|
|
13
|
+
import React, { useState, useEffect, useMemo, useContext, useRef } from "react";
|
|
14
14
|
import { DateRangePicker } from "../DateRangePicker";
|
|
15
15
|
import ActionBar from "../ActionBar";
|
|
16
16
|
import Shortcuts from "../Shortcuts";
|
|
17
17
|
import { SingleInputDateRangeField } from "../SingleInputDateRangeField";
|
|
18
18
|
import classNames from "classnames";
|
|
19
|
-
import { isArr, isBoolean } from "@pisell/utils";
|
|
19
|
+
import { isArr, isBoolean, isString } from "@pisell/utils";
|
|
20
20
|
import useCssVariables from "./useCssVariables";
|
|
21
|
-
import CloseCircle from "
|
|
21
|
+
import CloseCircle from "../icon/CloseCircle";
|
|
22
22
|
import "dayjs/locale/zh-cn";
|
|
23
23
|
import "dayjs/locale/en";
|
|
24
24
|
import "dayjs/locale/zh-tw";
|
|
25
25
|
import "./index.less";
|
|
26
|
-
import { getCurrentLocale,
|
|
26
|
+
import { formatPresets, getCurrentLocale, getPresetLabel, getShortcutValue } from "../utils";
|
|
27
27
|
import { LocaleContext } from "./LocaleContext";
|
|
28
28
|
import { pLocaleMap } from "../locales";
|
|
29
|
-
|
|
29
|
+
import Dialog from "../Dialog";
|
|
30
|
+
import Toolbar from "../Toolbar";
|
|
31
|
+
import useNextDay from "../hooks/useNextDay";
|
|
32
|
+
var transDayjsArr = function transDayjsArr(dayjsArr, defaultValue, _presets) {
|
|
30
33
|
var _newArr;
|
|
34
|
+
if (isString(dayjsArr)) {
|
|
35
|
+
return getShortcutValue(dayjsArr, _presets);
|
|
36
|
+
}
|
|
31
37
|
var newArr = dayjsArr || defaultValue || [null, null];
|
|
32
38
|
if ((dayjsArr === null || dayjsArr === void 0 ? void 0 : dayjsArr.length) === 0) {
|
|
33
39
|
newArr = defaultValue || [null, null];
|
|
@@ -72,25 +78,52 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
72
78
|
disablePortal = props.disablePortal,
|
|
73
79
|
_props$placement = props.placement,
|
|
74
80
|
placement = _props$placement === void 0 ? "auto" : _props$placement,
|
|
75
|
-
inputReadOnly = props.inputReadOnly
|
|
81
|
+
_props$inputReadOnly = props.inputReadOnly,
|
|
82
|
+
inputReadOnly = _props$inputReadOnly === void 0 ? true : _props$inputReadOnly,
|
|
83
|
+
_props$returnShortcut = props.returnShortcutString,
|
|
84
|
+
returnShortcutString = _props$returnShortcut === void 0 ? false : _props$returnShortcut;
|
|
76
85
|
var _useState = useState(propsOpen !== null && propsOpen !== void 0 ? propsOpen : false),
|
|
77
86
|
_useState2 = _slicedToArray(_useState, 2),
|
|
78
87
|
open = _useState2[0],
|
|
79
88
|
setOpen = _useState2[1];
|
|
80
89
|
var _ref = useContext(LocaleContext) || {},
|
|
81
90
|
locale = _ref.locale;
|
|
91
|
+
var _useState3 = useState(""),
|
|
92
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
93
|
+
currentShortcut = _useState4[0],
|
|
94
|
+
setCurrentShortcut = _useState4[1];
|
|
95
|
+
var lastConfirmShortcut = useRef(isString(propsValue) ? propsValue : null);
|
|
82
96
|
useEffect(function () {
|
|
83
97
|
isBoolean(propsOpen) && setOpen(propsOpen);
|
|
84
98
|
}, [propsOpen]);
|
|
85
|
-
var
|
|
86
|
-
|
|
99
|
+
var _presets = useMemo(function () {
|
|
100
|
+
return formatPresets(presets);
|
|
101
|
+
}, [presets]);
|
|
102
|
+
var _useState5 = useState(function () {
|
|
103
|
+
return transDayjsArr(propsValue, defaultValue, _presets);
|
|
87
104
|
}),
|
|
88
|
-
|
|
89
|
-
_value =
|
|
90
|
-
setValue =
|
|
105
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
106
|
+
_value = _useState6[0],
|
|
107
|
+
setValue = _useState6[1];
|
|
91
108
|
useEffect(function () {
|
|
92
|
-
setValue(transDayjsArr(propsValue, defaultValue));
|
|
109
|
+
setValue(transDayjsArr(propsValue, defaultValue, _presets));
|
|
110
|
+
if (isString(propsValue)) {
|
|
111
|
+
setCurrentShortcut(propsValue);
|
|
112
|
+
}
|
|
93
113
|
}, [propsValue]);
|
|
114
|
+
var getVal = function getVal() {
|
|
115
|
+
var val = _value;
|
|
116
|
+
if (returnShortcutString) {
|
|
117
|
+
val = currentShortcut;
|
|
118
|
+
} else if (currentShortcut) {
|
|
119
|
+
val = getShortcutValue(currentShortcut, _presets);
|
|
120
|
+
}
|
|
121
|
+
return val;
|
|
122
|
+
};
|
|
123
|
+
useNextDay(function () {
|
|
124
|
+
setValue(getVal());
|
|
125
|
+
setTimeout(handleOk);
|
|
126
|
+
});
|
|
94
127
|
var handleOpen = function handleOpen() {
|
|
95
128
|
setOpen(true);
|
|
96
129
|
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
@@ -98,31 +131,24 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
98
131
|
var handleClose = function handleClose() {
|
|
99
132
|
setOpen(false);
|
|
100
133
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
101
|
-
|
|
102
|
-
|
|
134
|
+
var v = transDayjsArr(propsValue, defaultValue, _presets);
|
|
135
|
+
onDateChange === null || onDateChange === void 0 ? void 0 : onDateChange(v);
|
|
136
|
+
setValue(v);
|
|
137
|
+
setCurrentShortcut(lastConfirmShortcut.current);
|
|
103
138
|
};
|
|
104
139
|
var handleOk = function handleOk() {
|
|
105
140
|
setOpen(false);
|
|
106
141
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
107
|
-
propsOnChange === null || propsOnChange === void 0 ? void 0 : propsOnChange(
|
|
142
|
+
propsOnChange === null || propsOnChange === void 0 ? void 0 : propsOnChange(getVal());
|
|
143
|
+
lastConfirmShortcut.current = currentShortcut;
|
|
108
144
|
};
|
|
109
|
-
var
|
|
110
|
-
if (isMobile()) return [];
|
|
111
|
-
return presets.map(function (item) {
|
|
112
|
-
var getValue = function getValue() {
|
|
113
|
-
if (typeof item.getValue === "function") {
|
|
114
|
-
return item.getValue();
|
|
115
|
-
}
|
|
116
|
-
return item === null || item === void 0 ? void 0 : item.value;
|
|
117
|
-
};
|
|
118
|
-
return {
|
|
119
|
-
label: item.label,
|
|
120
|
-
getValue: getValue
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
}, [presets]);
|
|
124
|
-
var handleChange = function handleChange(val, type) {
|
|
145
|
+
var handleChange = function handleChange(val, type, shortcutValue) {
|
|
125
146
|
var newVal = val;
|
|
147
|
+
if (isString(shortcutValue) && type === "shortcuts") {
|
|
148
|
+
setCurrentShortcut(shortcutValue);
|
|
149
|
+
} else {
|
|
150
|
+
setCurrentShortcut(null);
|
|
151
|
+
}
|
|
126
152
|
if (isArr(showTime) && type !== "time") {
|
|
127
153
|
newVal = newVal.map(function (item, index) {
|
|
128
154
|
var _showTime$index;
|
|
@@ -133,16 +159,22 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
133
159
|
return item || null;
|
|
134
160
|
});
|
|
135
161
|
}
|
|
162
|
+
if (!clearEndOnSelection) {
|
|
163
|
+
if (newVal[0] && !newVal[1]) {
|
|
164
|
+
newVal[1] = newVal[0];
|
|
165
|
+
} else if (newVal[1] && !newVal[0]) {
|
|
166
|
+
newVal[0] = newVal[1];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
136
169
|
if (clearEndOnSelection && type !== "set" && _value.filter(Boolean).length === 2) {
|
|
137
170
|
newVal = [newVal[0], null];
|
|
138
171
|
}
|
|
139
172
|
onDateChange === null || onDateChange === void 0 ? void 0 : onDateChange(newVal);
|
|
140
173
|
setValue(newVal);
|
|
141
174
|
};
|
|
142
|
-
var hasPreset = (_presets === null || _presets === void 0 ? void 0 : _presets.length) > 0;
|
|
143
175
|
useCssVariables({
|
|
144
176
|
variables: {
|
|
145
|
-
"--pisell-date-range-picker-popup-width": "".concat(
|
|
177
|
+
"--pisell-date-range-picker-popup-width": "".concat(popupWidth, "px")
|
|
146
178
|
},
|
|
147
179
|
dom: document.body
|
|
148
180
|
});
|
|
@@ -152,6 +184,8 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
152
184
|
setOpen(false);
|
|
153
185
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
154
186
|
propsOnChange === null || propsOnChange === void 0 ? void 0 : propsOnChange([null, null]);
|
|
187
|
+
setCurrentShortcut(null);
|
|
188
|
+
lastConfirmShortcut.current = null;
|
|
155
189
|
};
|
|
156
190
|
var endAdornment = useMemo(function () {
|
|
157
191
|
if (!allowClear) {
|
|
@@ -185,6 +219,17 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
185
219
|
}
|
|
186
220
|
return localeValue === "en" || localeValue === "en-US" ? "DD/MM/YYYY" : "YYYY/MM/DD";
|
|
187
221
|
}, [propsFormat, locale]);
|
|
222
|
+
var inputPropsObj = useMemo(function () {
|
|
223
|
+
var obj = {
|
|
224
|
+
endAdornment: endAdornment
|
|
225
|
+
};
|
|
226
|
+
if (_value.every(Boolean) && getPresetLabel(currentShortcut, _presets)) {
|
|
227
|
+
obj = _objectSpread(_objectSpread({}, obj), {}, {
|
|
228
|
+
value: getPresetLabel(currentShortcut, _presets)
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return obj;
|
|
232
|
+
}, [_value, endAdornment, returnShortcutString, currentShortcut]);
|
|
188
233
|
return /*#__PURE__*/React.createElement("span", {
|
|
189
234
|
className: classNames(className, "pisell-date-range-picker", {
|
|
190
235
|
"pisell-date-range-picker-no-border": !bordered
|
|
@@ -208,7 +253,18 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
208
253
|
onClose: handleClose,
|
|
209
254
|
onChange: handleChange,
|
|
210
255
|
onOpen: handleOpen,
|
|
211
|
-
open: open
|
|
256
|
+
open: open
|
|
257
|
+
// onRangePositionChange={(rp) => {
|
|
258
|
+
// console.log(rp, "rangePosition");
|
|
259
|
+
// // if (_value.every(item => !Boolean(item))) {
|
|
260
|
+
// // return
|
|
261
|
+
// // } else {
|
|
262
|
+
// setRangePosition(rp)
|
|
263
|
+
// // }
|
|
264
|
+
// }}
|
|
265
|
+
// // defaultRangePosition="start"
|
|
266
|
+
// rangePosition={_value.every((item) => Boolean(item)) ? "start" : undefined}
|
|
267
|
+
,
|
|
212
268
|
defaultCalendarMonth: defaultCalendarMonth,
|
|
213
269
|
shouldDisableDate: function shouldDisableDate(current, position) {
|
|
214
270
|
return disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(current, position, _value);
|
|
@@ -216,14 +272,18 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
216
272
|
slots: {
|
|
217
273
|
actionBar: ActionBar,
|
|
218
274
|
shortcuts: Shortcuts,
|
|
219
|
-
field: SingleInputDateRangeField
|
|
275
|
+
field: SingleInputDateRangeField,
|
|
276
|
+
dialog: Dialog,
|
|
277
|
+
// calendarHeader: CustomCalendarHeader,
|
|
278
|
+
// calendarHeader: <div>12312</div> ,
|
|
279
|
+
toolbar: Toolbar
|
|
220
280
|
},
|
|
221
281
|
dayOfWeekFormatter: function dayOfWeekFormatter(day) {
|
|
222
282
|
return day;
|
|
223
283
|
},
|
|
224
284
|
slotProps: {
|
|
225
285
|
shortcuts: {
|
|
226
|
-
items:
|
|
286
|
+
items: [],
|
|
227
287
|
changeImportance: "set",
|
|
228
288
|
onChange: handleChange
|
|
229
289
|
},
|
|
@@ -236,15 +296,25 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
236
296
|
okButtonProps: okButtonProps,
|
|
237
297
|
cancelButtonProps: cancelButtonProps
|
|
238
298
|
},
|
|
299
|
+
toolbar: {
|
|
300
|
+
hidden: false,
|
|
301
|
+
presetItems: _presets,
|
|
302
|
+
format: format,
|
|
303
|
+
locale: locale,
|
|
304
|
+
onChange: handleChange,
|
|
305
|
+
currentShortcut: currentShortcut,
|
|
306
|
+
setCurrentShortcut: setCurrentShortcut
|
|
307
|
+
},
|
|
308
|
+
layout: {
|
|
309
|
+
orientation: "portrait"
|
|
310
|
+
},
|
|
239
311
|
field: _objectSpread({
|
|
240
312
|
value: _value,
|
|
241
313
|
size: "small",
|
|
242
314
|
fullWidth: true,
|
|
243
315
|
// variant: "standard",
|
|
244
316
|
// hiddenLabel: true,
|
|
245
|
-
InputProps:
|
|
246
|
-
endAdornment: endAdornment
|
|
247
|
-
}
|
|
317
|
+
InputProps: inputPropsObj
|
|
248
318
|
}, readOnlyProps),
|
|
249
319
|
popper: {
|
|
250
320
|
className: popupClassName,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
//.MuiInputBase-input {
|
|
6
6
|
// padding: 10px;
|
|
7
7
|
//}
|
|
8
|
+
|
|
8
9
|
label {
|
|
9
10
|
font-size: 14px;
|
|
10
11
|
}
|
|
@@ -42,11 +43,13 @@
|
|
|
42
43
|
.MuiPickersPopper-root {
|
|
43
44
|
.MuiPickersLayout-root {
|
|
44
45
|
width: var(--pisell-date-range-picker-popup-width, 625px);
|
|
46
|
+
display: block;
|
|
45
47
|
.MuiDateRangeCalendar-root {
|
|
46
48
|
width: 100%;
|
|
47
49
|
flex: 1;
|
|
48
50
|
.MuiDateRangeCalendar-monthContainer {
|
|
49
51
|
width: 50%;
|
|
52
|
+
border: none;
|
|
50
53
|
.MuiDayCalendar-header {
|
|
51
54
|
padding: 0 20px;
|
|
52
55
|
.MuiDayCalendar-weekDayLabel {
|
|
@@ -95,3 +98,56 @@
|
|
|
95
98
|
grid-column: 1 !important;
|
|
96
99
|
grid-row: 1/3 !important;
|
|
97
100
|
}
|
|
101
|
+
|
|
102
|
+
.date-picker-paid-drawer {
|
|
103
|
+
.MuiPickersLayout-root {
|
|
104
|
+
display: block;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.date-picker-custom-drawer {
|
|
109
|
+
.MuiPickersCalendarHeader-root {
|
|
110
|
+
padding-left: 35px;
|
|
111
|
+
padding-right: 22px;
|
|
112
|
+
}
|
|
113
|
+
.MuiPickersLayout-root {
|
|
114
|
+
display: block;
|
|
115
|
+
}
|
|
116
|
+
.MuiPickersLayout-toolbar {
|
|
117
|
+
display: none;
|
|
118
|
+
}
|
|
119
|
+
.MuiDayCalendar-header {
|
|
120
|
+
padding: 0 20px;
|
|
121
|
+
.MuiDayCalendar-weekDayLabel {
|
|
122
|
+
flex: 1;
|
|
123
|
+
max-width: 46px;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
.MuiDayCalendar-slideTransition {
|
|
127
|
+
height: 315px;
|
|
128
|
+
.MuiDayCalendar-monthContainer {
|
|
129
|
+
padding: 0 20px;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
.MuiDateRangeCalendar-monthContainer {
|
|
133
|
+
width: 100%;
|
|
134
|
+
.MuiDateRangePickerDay-root {
|
|
135
|
+
flex: 1;
|
|
136
|
+
max-width: 50px;
|
|
137
|
+
max-height: 50px;
|
|
138
|
+
.MuiDateRangePickerDay-day {
|
|
139
|
+
width: 100%;
|
|
140
|
+
height: auto;
|
|
141
|
+
&::before {
|
|
142
|
+
content: "";
|
|
143
|
+
display: block;
|
|
144
|
+
padding-top: 100%;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
.MuiDrawer-paperAnchorBottom {
|
|
150
|
+
border-top-left-radius: 8px;
|
|
151
|
+
border-top-right-radius: 8px;
|
|
152
|
+
}
|
|
153
|
+
}
|