@pisell/date-picker 1.0.80 → 1.0.82
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/PisellDateRangePicker/index.js +5 -4
- package/es/Toolbar/index.d.ts +1 -1
- package/es/Toolbar/index.js +18 -18
- package/es/constants.d.ts +14 -14
- package/es/constants.js +27 -27
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/internals/utils/date-fields-utils.d.ts +1 -1
- package/es/utils/index.d.ts +2 -2
- package/es/utils/index.js +4 -4
- package/lib/PisellDateRangePicker/index.js +4 -4
- package/lib/Toolbar/index.d.ts +1 -1
- package/lib/Toolbar/index.js +21 -7
- package/lib/constants.d.ts +14 -14
- package/lib/constants.js +52 -13
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -0
- package/lib/internals/utils/date-fields-utils.d.ts +1 -1
- package/lib/utils/index.d.ts +2 -2
- package/lib/utils/index.js +4 -4
- package/package.json +1 -1
|
@@ -72,7 +72,8 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
72
72
|
okButtonProps = props.okButtonProps,
|
|
73
73
|
cancelButtonProps = props.cancelButtonProps,
|
|
74
74
|
onDateChange = props.onDateChange,
|
|
75
|
-
|
|
75
|
+
_props$desktopModeMed = props.desktopModeMediaQuery,
|
|
76
|
+
desktopModeMediaQuery = _props$desktopModeMed === void 0 ? '(min-width: 625px)' : _props$desktopModeMed,
|
|
76
77
|
style = props.style,
|
|
77
78
|
allowClear = props.allowClear,
|
|
78
79
|
disablePortal = props.disablePortal,
|
|
@@ -97,7 +98,7 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
97
98
|
isBoolean(propsOpen) && setOpen(propsOpen);
|
|
98
99
|
}, [propsOpen]);
|
|
99
100
|
var _presets = useMemo(function () {
|
|
100
|
-
return formatPresets(presets || defaultPresets);
|
|
101
|
+
return formatPresets(presets || defaultPresets, locale);
|
|
101
102
|
}, [presets]);
|
|
102
103
|
var _useState5 = useState(function () {
|
|
103
104
|
return transDayjsArr(propsValue, defaultValue, _presets);
|
|
@@ -224,9 +225,9 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
224
225
|
var obj = {
|
|
225
226
|
endAdornment: endAdornment
|
|
226
227
|
};
|
|
227
|
-
if (_value !== null && _value !== void 0 && (_value$every = _value.every) !== null && _value$every !== void 0 && _value$every.call(_value, Boolean) && getPresetLabel(currentShortcut, _presets)) {
|
|
228
|
+
if (_value !== null && _value !== void 0 && (_value$every = _value.every) !== null && _value$every !== void 0 && _value$every.call(_value, Boolean) && getPresetLabel(currentShortcut, _presets, locale)) {
|
|
228
229
|
obj = _objectSpread(_objectSpread({}, obj), {}, {
|
|
229
|
-
value: getPresetLabel(currentShortcut, _presets)
|
|
230
|
+
value: getPresetLabel(currentShortcut, _presets, locale)
|
|
230
231
|
});
|
|
231
232
|
}
|
|
232
233
|
return obj;
|
package/es/Toolbar/index.d.ts
CHANGED
package/es/Toolbar/index.js
CHANGED
|
@@ -8,11 +8,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
8
8
|
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; }
|
|
9
9
|
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; } }
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
-
import React, { useMemo, useState, useEffect } from
|
|
12
|
-
import { Input } from
|
|
13
|
-
import dayjs from
|
|
11
|
+
import React, { useMemo, useState, useEffect } from 'react';
|
|
12
|
+
import { Input } from 'antd';
|
|
13
|
+
import dayjs from 'dayjs';
|
|
14
14
|
import BrowserSelect from "../browserSelect";
|
|
15
|
-
import { getText } from "../locales";
|
|
15
|
+
import { getText, pLocaleMap } from "../locales";
|
|
16
16
|
import "./index.less";
|
|
17
17
|
var isValidDate = function isValidDate(dateString, format) {
|
|
18
18
|
var date = dayjs(dateString, format, true);
|
|
@@ -26,12 +26,12 @@ var Toolbar = function Toolbar(props) {
|
|
|
26
26
|
onChange = props.onChange,
|
|
27
27
|
currentShortcut = props.currentShortcut,
|
|
28
28
|
setCurrentShortcut = props.setCurrentShortcut;
|
|
29
|
-
var format = locale ===
|
|
30
|
-
var _useState = useState(
|
|
29
|
+
var format = locale === 'en' || locale === 'en-US' ? 'DD/MM/YYYY' : 'YYYY/MM/DD';
|
|
30
|
+
var _useState = useState(''),
|
|
31
31
|
_useState2 = _slicedToArray(_useState, 2),
|
|
32
32
|
startStr = _useState2[0],
|
|
33
33
|
setStartStr = _useState2[1];
|
|
34
|
-
var _useState3 = useState(
|
|
34
|
+
var _useState3 = useState(''),
|
|
35
35
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
36
|
endStr = _useState4[0],
|
|
37
37
|
setEndStr = _useState4[1];
|
|
@@ -39,12 +39,12 @@ var Toolbar = function Toolbar(props) {
|
|
|
39
39
|
if (value !== null && value !== void 0 && value[0]) {
|
|
40
40
|
setStartStr(value[0].format(format));
|
|
41
41
|
} else {
|
|
42
|
-
setStartStr(
|
|
42
|
+
setStartStr('');
|
|
43
43
|
}
|
|
44
44
|
if (value !== null && value !== void 0 && value[1]) {
|
|
45
45
|
setEndStr(value[1].format(format));
|
|
46
46
|
} else {
|
|
47
|
-
setEndStr(
|
|
47
|
+
setEndStr('');
|
|
48
48
|
}
|
|
49
49
|
}, [value]);
|
|
50
50
|
var handleStartChange = function handleStartChange(e) {
|
|
@@ -55,7 +55,7 @@ var Toolbar = function Toolbar(props) {
|
|
|
55
55
|
var valDate = dayjs(val, format);
|
|
56
56
|
var newValue = _toConsumableArray(value);
|
|
57
57
|
var start = newValue[0] || dayjs();
|
|
58
|
-
newValue[0] = (start === null || start === void 0 ? void 0 : (_start$set = start.set(
|
|
58
|
+
newValue[0] = (start === null || start === void 0 ? void 0 : (_start$set = start.set('year', (valDate === null || valDate === void 0 ? void 0 : valDate.get('year')) || 0)) === null || _start$set === void 0 ? void 0 : (_start$set$set = _start$set.set('month', (valDate === null || valDate === void 0 ? void 0 : valDate.get('month')) || 0)) === null || _start$set$set === void 0 ? void 0 : _start$set$set.set('date', (valDate === null || valDate === void 0 ? void 0 : valDate.get('date')) || 0)) || null;
|
|
59
59
|
onChange(newValue);
|
|
60
60
|
}
|
|
61
61
|
};
|
|
@@ -67,7 +67,7 @@ var Toolbar = function Toolbar(props) {
|
|
|
67
67
|
var valDate = dayjs(val, format);
|
|
68
68
|
var newValue = _toConsumableArray(value);
|
|
69
69
|
var end = newValue[1] || dayjs();
|
|
70
|
-
newValue[1] = (end === null || end === void 0 ? void 0 : (_end$set = end.set(
|
|
70
|
+
newValue[1] = (end === null || end === void 0 ? void 0 : (_end$set = end.set('year', (valDate === null || valDate === void 0 ? void 0 : valDate.get('year')) || 0)) === null || _end$set === void 0 ? void 0 : (_end$set$set = _end$set.set('month', (valDate === null || valDate === void 0 ? void 0 : valDate.get('month')) || 0)) === null || _end$set$set === void 0 ? void 0 : _end$set$set.set('date', (valDate === null || valDate === void 0 ? void 0 : valDate.get('date')) || 0)) || null;
|
|
71
71
|
onChange(newValue);
|
|
72
72
|
}
|
|
73
73
|
};
|
|
@@ -83,8 +83,8 @@ var Toolbar = function Toolbar(props) {
|
|
|
83
83
|
var customPresetItems = useMemo(function () {
|
|
84
84
|
if (!currentShortcut) {
|
|
85
85
|
return presetItems.concat([{
|
|
86
|
-
label: getText(
|
|
87
|
-
value: getText(
|
|
86
|
+
label: getText('toolbar-date-range-shortcut-custom', pLocaleMap[locale]),
|
|
87
|
+
value: getText('toolbar-date-range-shortcut-custom', pLocaleMap[locale])
|
|
88
88
|
}]);
|
|
89
89
|
}
|
|
90
90
|
return presetItems;
|
|
@@ -93,26 +93,26 @@ var Toolbar = function Toolbar(props) {
|
|
|
93
93
|
className: "date-picker-toolbar"
|
|
94
94
|
}, /*#__PURE__*/React.createElement("div", {
|
|
95
95
|
className: "date-picker-content-top"
|
|
96
|
-
}, /*#__PURE__*/React.createElement("span", null, getText(
|
|
96
|
+
}, /*#__PURE__*/React.createElement("span", null, getText('toolbar-date-range-shortcut-date-range', pLocaleMap[locale])), /*#__PURE__*/React.createElement(BrowserSelect
|
|
97
97
|
// @ts-ignore
|
|
98
98
|
, {
|
|
99
|
-
value: currentShortcut || getText(
|
|
99
|
+
value: currentShortcut || getText('toolbar-date-range-shortcut-custom', pLocaleMap[locale]),
|
|
100
100
|
className: "date-picker-toolbar-select",
|
|
101
101
|
options: customPresetItems,
|
|
102
|
-
size:
|
|
102
|
+
size: 'large',
|
|
103
103
|
onChange: handleSelectChange
|
|
104
104
|
})), /*#__PURE__*/React.createElement("div", {
|
|
105
105
|
className: "date-picker-content-bottom"
|
|
106
106
|
}, /*#__PURE__*/React.createElement("div", {
|
|
107
107
|
className: "date-picker-toolbar-start-wrap"
|
|
108
|
-
}, /*#__PURE__*/React.createElement("span", null, getText(
|
|
108
|
+
}, /*#__PURE__*/React.createElement("span", null, getText('toolbar-date-range-shortcut-starting', pLocaleMap[locale])), /*#__PURE__*/React.createElement(Input, {
|
|
109
109
|
size: "large",
|
|
110
110
|
value: startStr,
|
|
111
111
|
onChange: handleStartChange,
|
|
112
112
|
placeholder: dayjs().format(format)
|
|
113
113
|
})), /*#__PURE__*/React.createElement("div", {
|
|
114
114
|
className: "date-picker-toolbar-end-wrap"
|
|
115
|
-
}, /*#__PURE__*/React.createElement("span", null, getText(
|
|
115
|
+
}, /*#__PURE__*/React.createElement("span", null, getText('toolbar-date-range-shortcut-ending', pLocaleMap[locale])), /*#__PURE__*/React.createElement(Input, {
|
|
116
116
|
size: "large",
|
|
117
117
|
value: endStr,
|
|
118
118
|
onChange: handleEndChange,
|
package/es/constants.d.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
import { PresetType } from
|
|
2
|
+
import { PresetType } from './Shortcuts';
|
|
3
3
|
export declare const presetValueArr: string[];
|
|
4
4
|
export declare const presetDetailMap: {
|
|
5
5
|
today: {
|
|
6
6
|
getValue: () => dayjs.Dayjs[];
|
|
7
|
-
label: () => any;
|
|
7
|
+
label: (locale?: string) => any;
|
|
8
8
|
};
|
|
9
9
|
yesterday: {
|
|
10
10
|
getValue: () => dayjs.Dayjs[];
|
|
11
|
-
label: () => any;
|
|
11
|
+
label: (locale?: string) => any;
|
|
12
12
|
};
|
|
13
13
|
last_3_days: {
|
|
14
14
|
getValue: () => dayjs.Dayjs[];
|
|
15
|
-
label: () => any;
|
|
15
|
+
label: (locale?: string) => any;
|
|
16
16
|
};
|
|
17
17
|
last_7_days: {
|
|
18
18
|
getValue: () => dayjs.Dayjs[];
|
|
19
|
-
label: () => any;
|
|
19
|
+
label: (locale?: string) => any;
|
|
20
20
|
};
|
|
21
21
|
last_30_days: {
|
|
22
22
|
getValue: () => dayjs.Dayjs[];
|
|
23
|
-
label: () => any;
|
|
23
|
+
label: (locale?: string) => any;
|
|
24
24
|
};
|
|
25
25
|
last_90_days: {
|
|
26
26
|
getValue: () => dayjs.Dayjs[];
|
|
27
|
-
label: () => any;
|
|
27
|
+
label: (locale?: string) => any;
|
|
28
28
|
};
|
|
29
29
|
last_180_days: {
|
|
30
30
|
getValue: () => dayjs.Dayjs[];
|
|
31
|
-
label: () => any;
|
|
31
|
+
label: (locale?: string) => any;
|
|
32
32
|
};
|
|
33
33
|
tomorrow: {
|
|
34
34
|
getValue: () => dayjs.Dayjs[];
|
|
35
|
-
label: () => any;
|
|
35
|
+
label: (locale?: string) => any;
|
|
36
36
|
};
|
|
37
37
|
next_3_days: {
|
|
38
38
|
getValue: () => dayjs.Dayjs[];
|
|
39
|
-
label: () => any;
|
|
39
|
+
label: (locale?: string) => any;
|
|
40
40
|
};
|
|
41
41
|
next_7_days: {
|
|
42
42
|
getValue: () => dayjs.Dayjs[];
|
|
43
|
-
label: () => any;
|
|
43
|
+
label: (locale?: string) => any;
|
|
44
44
|
};
|
|
45
45
|
next_30_days: {
|
|
46
46
|
getValue: () => dayjs.Dayjs[];
|
|
47
|
-
label: () => any;
|
|
47
|
+
label: (locale?: string) => any;
|
|
48
48
|
};
|
|
49
49
|
next_90_days: {
|
|
50
50
|
getValue: () => dayjs.Dayjs[];
|
|
51
|
-
label: () => any;
|
|
51
|
+
label: (locale?: string) => any;
|
|
52
52
|
};
|
|
53
53
|
next_180_days: {
|
|
54
54
|
getValue: () => dayjs.Dayjs[];
|
|
55
|
-
label: () => any;
|
|
55
|
+
label: (locale?: string) => any;
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
export declare const defaultPresets: PresetType[];
|
package/es/constants.js
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
import { getText } from "./locales";
|
|
2
|
+
import { getText, pLocaleMap } from "./locales";
|
|
3
3
|
export var presetValueArr = ['today', 'yesterday', 'last_3_days', 'last_7_days', 'last_30_days', 'last_90_days', 'last_180_days', 'tomorrow', 'next_3_days', 'next_7_days', 'next_30_days', 'next_90_days', 'next_180_days'];
|
|
4
4
|
export var presetDetailMap = {
|
|
5
5
|
today: {
|
|
6
6
|
getValue: function getValue() {
|
|
7
7
|
return [dayjs().startOf('day'), dayjs().endOf('day')];
|
|
8
8
|
},
|
|
9
|
-
label: function label() {
|
|
10
|
-
return getText('toolbar-date-range-shortcut-today');
|
|
9
|
+
label: function label(locale) {
|
|
10
|
+
return getText('toolbar-date-range-shortcut-today', locale && pLocaleMap[locale]);
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
yesterday: {
|
|
14
14
|
getValue: function getValue() {
|
|
15
15
|
return [dayjs().add(-1, 'd').startOf('day'), dayjs().add(-1, 'd').endOf('day')];
|
|
16
16
|
},
|
|
17
|
-
label: function label() {
|
|
18
|
-
return getText('toolbar-date-range-shortcut-yesterday');
|
|
17
|
+
label: function label(locale) {
|
|
18
|
+
return getText('toolbar-date-range-shortcut-yesterday', locale && pLocaleMap[locale]);
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
last_3_days: {
|
|
22
22
|
getValue: function getValue() {
|
|
23
23
|
return [dayjs().add(-3, 'd').startOf('day'), dayjs().add(-1, 'd').endOf('day')];
|
|
24
24
|
},
|
|
25
|
-
label: function label() {
|
|
26
|
-
return getText('toolbar-date-range-shortcut-last-3-days');
|
|
25
|
+
label: function label(locale) {
|
|
26
|
+
return getText('toolbar-date-range-shortcut-last-3-days', locale && pLocaleMap[locale]);
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
last_7_days: {
|
|
30
30
|
getValue: function getValue() {
|
|
31
31
|
return [dayjs().add(-7, 'd').startOf('day'), dayjs().add(-1, 'd').endOf('day')];
|
|
32
32
|
},
|
|
33
|
-
label: function label() {
|
|
34
|
-
return getText('toolbar-date-range-shortcut-last-7-days');
|
|
33
|
+
label: function label(locale) {
|
|
34
|
+
return getText('toolbar-date-range-shortcut-last-7-days', locale && pLocaleMap[locale]);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
last_30_days: {
|
|
38
38
|
getValue: function getValue() {
|
|
39
39
|
return [dayjs().add(-30, 'd').startOf('day'), dayjs().add(-1, 'd').endOf('day')];
|
|
40
40
|
},
|
|
41
|
-
label: function label() {
|
|
42
|
-
return getText('toolbar-date-range-shortcut-last-30-days');
|
|
41
|
+
label: function label(locale) {
|
|
42
|
+
return getText('toolbar-date-range-shortcut-last-30-days', locale && pLocaleMap[locale]);
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
last_90_days: {
|
|
46
46
|
getValue: function getValue() {
|
|
47
47
|
return [dayjs().add(-90, 'd').startOf('day'), dayjs().add(-1, 'd').endOf('day')];
|
|
48
48
|
},
|
|
49
|
-
label: function label() {
|
|
50
|
-
return getText('toolbar-date-range-shortcut-last-90-days');
|
|
49
|
+
label: function label(locale) {
|
|
50
|
+
return getText('toolbar-date-range-shortcut-last-90-days', locale && pLocaleMap[locale]);
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
last_180_days: {
|
|
54
54
|
getValue: function getValue() {
|
|
55
55
|
return [dayjs().add(-180, 'd').startOf('day'), dayjs().add(-1, 'd').endOf('day')];
|
|
56
56
|
},
|
|
57
|
-
label: function label() {
|
|
58
|
-
return getText('toolbar-date-range-shortcut-last-180-days');
|
|
57
|
+
label: function label(locale) {
|
|
58
|
+
return getText('toolbar-date-range-shortcut-last-180-days', locale && pLocaleMap[locale]);
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
tomorrow: {
|
|
62
62
|
getValue: function getValue() {
|
|
63
63
|
return [dayjs().add(1, 'd').startOf('day'), dayjs().add(1, 'd').endOf('day')];
|
|
64
64
|
},
|
|
65
|
-
label: function label() {
|
|
66
|
-
return getText('toolbar-date-range-shortcut-tomorrow');
|
|
65
|
+
label: function label(locale) {
|
|
66
|
+
return getText('toolbar-date-range-shortcut-tomorrow', locale && pLocaleMap[locale]);
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
next_3_days: {
|
|
70
70
|
getValue: function getValue() {
|
|
71
71
|
return [dayjs().add(1, 'd').startOf('day'), dayjs().add(3, 'd').endOf('day')];
|
|
72
72
|
},
|
|
73
|
-
label: function label() {
|
|
74
|
-
return getText('toolbar-date-range-shortcut-next-3-days');
|
|
73
|
+
label: function label(locale) {
|
|
74
|
+
return getText('toolbar-date-range-shortcut-next-3-days', locale && pLocaleMap[locale]);
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
next_7_days: {
|
|
78
78
|
getValue: function getValue() {
|
|
79
79
|
return [dayjs().add(1, 'd').startOf('day'), dayjs().add(7, 'd').endOf('day')];
|
|
80
80
|
},
|
|
81
|
-
label: function label() {
|
|
82
|
-
return getText('toolbar-date-range-shortcut-next-7-days');
|
|
81
|
+
label: function label(locale) {
|
|
82
|
+
return getText('toolbar-date-range-shortcut-next-7-days', locale && pLocaleMap[locale]);
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
next_30_days: {
|
|
86
86
|
getValue: function getValue() {
|
|
87
87
|
return [dayjs().add(1, 'd').startOf('day'), dayjs().add(30, 'd').endOf('day')];
|
|
88
88
|
},
|
|
89
|
-
label: function label() {
|
|
90
|
-
return getText('toolbar-date-range-shortcut-next-30-days');
|
|
89
|
+
label: function label(locale) {
|
|
90
|
+
return getText('toolbar-date-range-shortcut-next-30-days', locale && pLocaleMap[locale]);
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
next_90_days: {
|
|
94
94
|
getValue: function getValue() {
|
|
95
95
|
return [dayjs().add(1, 'd').startOf('day'), dayjs().add(90, 'd').endOf('day')];
|
|
96
96
|
},
|
|
97
|
-
label: function label() {
|
|
98
|
-
return getText('toolbar-date-range-shortcut-next-90-days');
|
|
97
|
+
label: function label(locale) {
|
|
98
|
+
return getText('toolbar-date-range-shortcut-next-90-days', locale && pLocaleMap[locale]);
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
next_180_days: {
|
|
102
102
|
getValue: function getValue() {
|
|
103
103
|
return [dayjs().add(1, 'd').startOf('day'), dayjs().add(180, 'd').endOf('day')];
|
|
104
104
|
},
|
|
105
|
-
label: function label() {
|
|
106
|
-
return getText('toolbar-date-range-shortcut-next-180-days');
|
|
105
|
+
label: function label(locale) {
|
|
106
|
+
return getText('toolbar-date-range-shortcut-next-180-days', locale && pLocaleMap[locale]);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
};
|
package/es/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConfigProvider } from 'antd';
|
|
1
2
|
import PisellDateRangePicker from "./PisellDateRangePicker";
|
|
2
3
|
import { LocaleContext, LocaleProvider } from "./PisellDateRangePicker/LocaleContext";
|
|
3
4
|
export * from "@mui/x-date-pickers";
|
|
@@ -18,6 +19,6 @@ export * from "./dateRangeViewRenderers";
|
|
|
18
19
|
export type { DateRange, RangePosition } from "./internals/models/range";
|
|
19
20
|
export type { UseDateRangeFieldProps } from "./internals/models/dateRange";
|
|
20
21
|
export { PisellDateRangePicker as RangePicker };
|
|
21
|
-
export { LocaleContext, LocaleProvider };
|
|
22
|
+
export { LocaleContext, LocaleProvider, ConfigProvider };
|
|
22
23
|
export { getDatePickerValueByShortcut, formatPresets, getShortcutValue, getPresetLabel, getDatePickerValue, } from "./utils/index";
|
|
23
24
|
export * from "./models";
|
package/es/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConfigProvider } from 'antd';
|
|
1
2
|
import PisellDateRangePicker from "./PisellDateRangePicker";
|
|
2
3
|
import { LocaleContext, LocaleProvider } from "./PisellDateRangePicker/LocaleContext";
|
|
3
4
|
export * from "@mui/x-date-pickers";
|
|
@@ -23,6 +24,6 @@ export * from "./StaticDateRangePicker";
|
|
|
23
24
|
// View renderers
|
|
24
25
|
export * from "./dateRangeViewRenderers";
|
|
25
26
|
export { PisellDateRangePicker as RangePicker };
|
|
26
|
-
export { LocaleContext, LocaleProvider };
|
|
27
|
+
export { LocaleContext, LocaleProvider, ConfigProvider };
|
|
27
28
|
export { getDatePickerValueByShortcut, formatPresets, getShortcutValue, getPresetLabel, getDatePickerValue } from "./utils/index";
|
|
28
29
|
export * from "./models";
|
|
@@ -5,7 +5,7 @@ export declare const splitDateRangeSections: (sections: RangeFieldSection[]) =>
|
|
|
5
5
|
};
|
|
6
6
|
export declare const removeLastSeparator: (dateSections: RangeFieldSection[]) => (RangeFieldSection | {
|
|
7
7
|
separator: null;
|
|
8
|
-
dateName: "
|
|
8
|
+
dateName: "start" | "end";
|
|
9
9
|
value: string;
|
|
10
10
|
format: string;
|
|
11
11
|
maxLength: number | null;
|
package/es/utils/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const isMobile: () => boolean;
|
|
|
7
7
|
* 格式化预设
|
|
8
8
|
* @param presets
|
|
9
9
|
*/
|
|
10
|
-
export declare const formatPresets: (presets: PresetType[]) => ({
|
|
10
|
+
export declare const formatPresets: (presets: PresetType[], locale?: string) => ({
|
|
11
11
|
label: any;
|
|
12
12
|
getValue: (() => Dayjs[]) | (() => [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days");
|
|
13
13
|
value: [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days";
|
|
@@ -21,7 +21,7 @@ export declare const formatPresets: (presets: PresetType[]) => ({
|
|
|
21
21
|
* @param currentShortcut
|
|
22
22
|
* @param presets
|
|
23
23
|
*/
|
|
24
|
-
export declare const getPresetLabel: (currentShortcut: string | null, presets: any[]) => any;
|
|
24
|
+
export declare const getPresetLabel: (currentShortcut: string | null, presets: any[], locale: string) => any;
|
|
25
25
|
/**
|
|
26
26
|
* 获取预设的value
|
|
27
27
|
* @param value
|
package/es/utils/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export var isMobile = function isMobile() {
|
|
|
23
23
|
* 格式化预设
|
|
24
24
|
* @param presets
|
|
25
25
|
*/
|
|
26
|
-
export var formatPresets = function formatPresets(presets) {
|
|
26
|
+
export var formatPresets = function formatPresets(presets, locale) {
|
|
27
27
|
return presets.map(function (item) {
|
|
28
28
|
// value包含在预设当中时
|
|
29
29
|
if (isString(item.value)) {
|
|
@@ -39,7 +39,7 @@ export var formatPresets = function formatPresets(presets) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
42
|
-
label: item.label || (presetDetailMap === null || presetDetailMap === void 0 ? void 0 : (_presetDetailMap$item = presetDetailMap[item.value]) === null || _presetDetailMap$item === void 0 ? void 0 : (_presetDetailMap$item2 = _presetDetailMap$item.label) === null || _presetDetailMap$item2 === void 0 ? void 0 : _presetDetailMap$item2.call(_presetDetailMap$item)),
|
|
42
|
+
label: item.label || (presetDetailMap === null || presetDetailMap === void 0 ? void 0 : (_presetDetailMap$item = presetDetailMap[item.value]) === null || _presetDetailMap$item === void 0 ? void 0 : (_presetDetailMap$item2 = _presetDetailMap$item.label) === null || _presetDetailMap$item2 === void 0 ? void 0 : _presetDetailMap$item2.call(_presetDetailMap$item, locale)),
|
|
43
43
|
getValue: _getValue
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -61,9 +61,9 @@ export var formatPresets = function formatPresets(presets) {
|
|
|
61
61
|
* @param currentShortcut
|
|
62
62
|
* @param presets
|
|
63
63
|
*/
|
|
64
|
-
export var getPresetLabel = function getPresetLabel(currentShortcut, presets) {
|
|
64
|
+
export var getPresetLabel = function getPresetLabel(currentShortcut, presets, locale) {
|
|
65
65
|
var _ref, _ref$label;
|
|
66
|
-
var label = presetDetailMap === null || presetDetailMap === void 0 ? void 0 : (_ref = presetDetailMap[currentShortcut]) === null || _ref === void 0 ? void 0 : (_ref$label = _ref.label) === null || _ref$label === void 0 ? void 0 : _ref$label.call(_ref);
|
|
66
|
+
var label = presetDetailMap === null || presetDetailMap === void 0 ? void 0 : (_ref = presetDetailMap[currentShortcut]) === null || _ref === void 0 ? void 0 : (_ref$label = _ref.label) === null || _ref$label === void 0 ? void 0 : _ref$label.call(_ref, locale);
|
|
67
67
|
if (label) {
|
|
68
68
|
return label;
|
|
69
69
|
}
|
|
@@ -90,7 +90,7 @@ var PisellDateRangePicker = (props) => {
|
|
|
90
90
|
okButtonProps,
|
|
91
91
|
cancelButtonProps,
|
|
92
92
|
onDateChange,
|
|
93
|
-
desktopModeMediaQuery,
|
|
93
|
+
desktopModeMediaQuery = "(min-width: 625px)",
|
|
94
94
|
style,
|
|
95
95
|
allowClear,
|
|
96
96
|
disablePortal,
|
|
@@ -106,7 +106,7 @@ var PisellDateRangePicker = (props) => {
|
|
|
106
106
|
(0, import_utils.isBoolean)(propsOpen) && setOpen(propsOpen);
|
|
107
107
|
}, [propsOpen]);
|
|
108
108
|
const _presets = (0, import_react.useMemo)(() => {
|
|
109
|
-
return (0, import_utils2.formatPresets)(presets || import_constants.defaultPresets);
|
|
109
|
+
return (0, import_utils2.formatPresets)(presets || import_constants.defaultPresets, locale);
|
|
110
110
|
}, [presets]);
|
|
111
111
|
const [_value, setValue] = (0, import_react.useState)(
|
|
112
112
|
() => transDayjsArr(propsValue, defaultValue, _presets)
|
|
@@ -230,10 +230,10 @@ var PisellDateRangePicker = (props) => {
|
|
|
230
230
|
let obj = {
|
|
231
231
|
endAdornment
|
|
232
232
|
};
|
|
233
|
-
if (((_a = _value == null ? void 0 : _value.every) == null ? void 0 : _a.call(_value, Boolean)) && (0, import_utils2.getPresetLabel)(currentShortcut, _presets)) {
|
|
233
|
+
if (((_a = _value == null ? void 0 : _value.every) == null ? void 0 : _a.call(_value, Boolean)) && (0, import_utils2.getPresetLabel)(currentShortcut, _presets, locale)) {
|
|
234
234
|
obj = {
|
|
235
235
|
...obj,
|
|
236
|
-
value: (0, import_utils2.getPresetLabel)(currentShortcut, _presets)
|
|
236
|
+
value: (0, import_utils2.getPresetLabel)(currentShortcut, _presets, locale)
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
239
|
return obj;
|
package/lib/Toolbar/index.d.ts
CHANGED
package/lib/Toolbar/index.js
CHANGED
|
@@ -92,7 +92,9 @@ var Toolbar = (props) => {
|
|
|
92
92
|
};
|
|
93
93
|
const handleSelectChange = (e) => {
|
|
94
94
|
const val = e.target.value;
|
|
95
|
-
const detail = presetItems.find(
|
|
95
|
+
const detail = presetItems.find(
|
|
96
|
+
(item) => item.value === val || item.label === val
|
|
97
|
+
);
|
|
96
98
|
if (!detail)
|
|
97
99
|
return;
|
|
98
100
|
const dateVal = detail.getValue();
|
|
@@ -102,23 +104,35 @@ var Toolbar = (props) => {
|
|
|
102
104
|
if (!currentShortcut) {
|
|
103
105
|
return presetItems.concat([
|
|
104
106
|
{
|
|
105
|
-
label: (0, import_locales.getText)(
|
|
106
|
-
|
|
107
|
+
label: (0, import_locales.getText)(
|
|
108
|
+
"toolbar-date-range-shortcut-custom",
|
|
109
|
+
import_locales.pLocaleMap[locale]
|
|
110
|
+
),
|
|
111
|
+
value: (0, import_locales.getText)(
|
|
112
|
+
"toolbar-date-range-shortcut-custom",
|
|
113
|
+
import_locales.pLocaleMap[locale]
|
|
114
|
+
)
|
|
107
115
|
}
|
|
108
116
|
]);
|
|
109
117
|
}
|
|
110
118
|
return presetItems;
|
|
111
119
|
}, [presetItems, currentShortcut]);
|
|
112
|
-
return /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-toolbar" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-content-top" }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_locales.getText)(
|
|
120
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-toolbar" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-content-top" }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_locales.getText)(
|
|
121
|
+
"toolbar-date-range-shortcut-date-range",
|
|
122
|
+
import_locales.pLocaleMap[locale]
|
|
123
|
+
)), /* @__PURE__ */ import_react.default.createElement(
|
|
113
124
|
import_browserSelect.default,
|
|
114
125
|
{
|
|
115
|
-
value: currentShortcut || (0, import_locales.getText)("toolbar-date-range-shortcut-custom"),
|
|
126
|
+
value: currentShortcut || (0, import_locales.getText)("toolbar-date-range-shortcut-custom", import_locales.pLocaleMap[locale]),
|
|
116
127
|
className: "date-picker-toolbar-select",
|
|
117
128
|
options: customPresetItems,
|
|
118
129
|
size: "large",
|
|
119
130
|
onChange: handleSelectChange
|
|
120
131
|
}
|
|
121
|
-
)), /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-content-bottom" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-toolbar-start-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_locales.getText)(
|
|
132
|
+
)), /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-content-bottom" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-toolbar-start-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_locales.getText)(
|
|
133
|
+
"toolbar-date-range-shortcut-starting",
|
|
134
|
+
import_locales.pLocaleMap[locale]
|
|
135
|
+
)), /* @__PURE__ */ import_react.default.createElement(
|
|
122
136
|
import_antd.Input,
|
|
123
137
|
{
|
|
124
138
|
size: "large",
|
|
@@ -126,7 +140,7 @@ var Toolbar = (props) => {
|
|
|
126
140
|
onChange: handleStartChange,
|
|
127
141
|
placeholder: (0, import_dayjs.default)().format(format)
|
|
128
142
|
}
|
|
129
|
-
)), /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-toolbar-end-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_locales.getText)("toolbar-date-range-shortcut-ending")), /* @__PURE__ */ import_react.default.createElement(
|
|
143
|
+
)), /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-toolbar-end-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_locales.getText)("toolbar-date-range-shortcut-ending", import_locales.pLocaleMap[locale])), /* @__PURE__ */ import_react.default.createElement(
|
|
130
144
|
import_antd.Input,
|
|
131
145
|
{
|
|
132
146
|
size: "large",
|
package/lib/constants.d.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
import { PresetType } from
|
|
2
|
+
import { PresetType } from './Shortcuts';
|
|
3
3
|
export declare const presetValueArr: string[];
|
|
4
4
|
export declare const presetDetailMap: {
|
|
5
5
|
today: {
|
|
6
6
|
getValue: () => dayjs.Dayjs[];
|
|
7
|
-
label: () => any;
|
|
7
|
+
label: (locale?: string) => any;
|
|
8
8
|
};
|
|
9
9
|
yesterday: {
|
|
10
10
|
getValue: () => dayjs.Dayjs[];
|
|
11
|
-
label: () => any;
|
|
11
|
+
label: (locale?: string) => any;
|
|
12
12
|
};
|
|
13
13
|
last_3_days: {
|
|
14
14
|
getValue: () => dayjs.Dayjs[];
|
|
15
|
-
label: () => any;
|
|
15
|
+
label: (locale?: string) => any;
|
|
16
16
|
};
|
|
17
17
|
last_7_days: {
|
|
18
18
|
getValue: () => dayjs.Dayjs[];
|
|
19
|
-
label: () => any;
|
|
19
|
+
label: (locale?: string) => any;
|
|
20
20
|
};
|
|
21
21
|
last_30_days: {
|
|
22
22
|
getValue: () => dayjs.Dayjs[];
|
|
23
|
-
label: () => any;
|
|
23
|
+
label: (locale?: string) => any;
|
|
24
24
|
};
|
|
25
25
|
last_90_days: {
|
|
26
26
|
getValue: () => dayjs.Dayjs[];
|
|
27
|
-
label: () => any;
|
|
27
|
+
label: (locale?: string) => any;
|
|
28
28
|
};
|
|
29
29
|
last_180_days: {
|
|
30
30
|
getValue: () => dayjs.Dayjs[];
|
|
31
|
-
label: () => any;
|
|
31
|
+
label: (locale?: string) => any;
|
|
32
32
|
};
|
|
33
33
|
tomorrow: {
|
|
34
34
|
getValue: () => dayjs.Dayjs[];
|
|
35
|
-
label: () => any;
|
|
35
|
+
label: (locale?: string) => any;
|
|
36
36
|
};
|
|
37
37
|
next_3_days: {
|
|
38
38
|
getValue: () => dayjs.Dayjs[];
|
|
39
|
-
label: () => any;
|
|
39
|
+
label: (locale?: string) => any;
|
|
40
40
|
};
|
|
41
41
|
next_7_days: {
|
|
42
42
|
getValue: () => dayjs.Dayjs[];
|
|
43
|
-
label: () => any;
|
|
43
|
+
label: (locale?: string) => any;
|
|
44
44
|
};
|
|
45
45
|
next_30_days: {
|
|
46
46
|
getValue: () => dayjs.Dayjs[];
|
|
47
|
-
label: () => any;
|
|
47
|
+
label: (locale?: string) => any;
|
|
48
48
|
};
|
|
49
49
|
next_90_days: {
|
|
50
50
|
getValue: () => dayjs.Dayjs[];
|
|
51
|
-
label: () => any;
|
|
51
|
+
label: (locale?: string) => any;
|
|
52
52
|
};
|
|
53
53
|
next_180_days: {
|
|
54
54
|
getValue: () => dayjs.Dayjs[];
|
|
55
|
-
label: () => any;
|
|
55
|
+
label: (locale?: string) => any;
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
export declare const defaultPresets: PresetType[];
|
package/lib/constants.js
CHANGED
|
@@ -54,91 +54,130 @@ var presetValueArr = [
|
|
|
54
54
|
var presetDetailMap = {
|
|
55
55
|
today: {
|
|
56
56
|
getValue: () => [(0, import_dayjs.default)().startOf("day"), (0, import_dayjs.default)().endOf("day")],
|
|
57
|
-
label: () => (0, import_locales.getText)(
|
|
57
|
+
label: (locale) => (0, import_locales.getText)(
|
|
58
|
+
"toolbar-date-range-shortcut-today",
|
|
59
|
+
locale && import_locales.pLocaleMap[locale]
|
|
60
|
+
)
|
|
58
61
|
},
|
|
59
62
|
yesterday: {
|
|
60
63
|
getValue: () => [
|
|
61
64
|
(0, import_dayjs.default)().add(-1, "d").startOf("day"),
|
|
62
65
|
(0, import_dayjs.default)().add(-1, "d").endOf("day")
|
|
63
66
|
],
|
|
64
|
-
label: () => (0, import_locales.getText)(
|
|
67
|
+
label: (locale) => (0, import_locales.getText)(
|
|
68
|
+
"toolbar-date-range-shortcut-yesterday",
|
|
69
|
+
locale && import_locales.pLocaleMap[locale]
|
|
70
|
+
)
|
|
65
71
|
},
|
|
66
72
|
last_3_days: {
|
|
67
73
|
getValue: () => [
|
|
68
74
|
(0, import_dayjs.default)().add(-3, "d").startOf("day"),
|
|
69
75
|
(0, import_dayjs.default)().add(-1, "d").endOf("day")
|
|
70
76
|
],
|
|
71
|
-
label: () => (0, import_locales.getText)(
|
|
77
|
+
label: (locale) => (0, import_locales.getText)(
|
|
78
|
+
"toolbar-date-range-shortcut-last-3-days",
|
|
79
|
+
locale && import_locales.pLocaleMap[locale]
|
|
80
|
+
)
|
|
72
81
|
},
|
|
73
82
|
last_7_days: {
|
|
74
83
|
getValue: () => [
|
|
75
84
|
(0, import_dayjs.default)().add(-7, "d").startOf("day"),
|
|
76
85
|
(0, import_dayjs.default)().add(-1, "d").endOf("day")
|
|
77
86
|
],
|
|
78
|
-
label: () => (0, import_locales.getText)(
|
|
87
|
+
label: (locale) => (0, import_locales.getText)(
|
|
88
|
+
"toolbar-date-range-shortcut-last-7-days",
|
|
89
|
+
locale && import_locales.pLocaleMap[locale]
|
|
90
|
+
)
|
|
79
91
|
},
|
|
80
92
|
last_30_days: {
|
|
81
93
|
getValue: () => [
|
|
82
94
|
(0, import_dayjs.default)().add(-30, "d").startOf("day"),
|
|
83
95
|
(0, import_dayjs.default)().add(-1, "d").endOf("day")
|
|
84
96
|
],
|
|
85
|
-
label: () => (0, import_locales.getText)(
|
|
97
|
+
label: (locale) => (0, import_locales.getText)(
|
|
98
|
+
"toolbar-date-range-shortcut-last-30-days",
|
|
99
|
+
locale && import_locales.pLocaleMap[locale]
|
|
100
|
+
)
|
|
86
101
|
},
|
|
87
102
|
last_90_days: {
|
|
88
103
|
getValue: () => [
|
|
89
104
|
(0, import_dayjs.default)().add(-90, "d").startOf("day"),
|
|
90
105
|
(0, import_dayjs.default)().add(-1, "d").endOf("day")
|
|
91
106
|
],
|
|
92
|
-
label: () => (0, import_locales.getText)(
|
|
107
|
+
label: (locale) => (0, import_locales.getText)(
|
|
108
|
+
"toolbar-date-range-shortcut-last-90-days",
|
|
109
|
+
locale && import_locales.pLocaleMap[locale]
|
|
110
|
+
)
|
|
93
111
|
},
|
|
94
112
|
last_180_days: {
|
|
95
113
|
getValue: () => [
|
|
96
114
|
(0, import_dayjs.default)().add(-180, "d").startOf("day"),
|
|
97
115
|
(0, import_dayjs.default)().add(-1, "d").endOf("day")
|
|
98
116
|
],
|
|
99
|
-
label: () => (0, import_locales.getText)(
|
|
117
|
+
label: (locale) => (0, import_locales.getText)(
|
|
118
|
+
"toolbar-date-range-shortcut-last-180-days",
|
|
119
|
+
locale && import_locales.pLocaleMap[locale]
|
|
120
|
+
)
|
|
100
121
|
},
|
|
101
122
|
tomorrow: {
|
|
102
123
|
getValue: () => [
|
|
103
124
|
(0, import_dayjs.default)().add(1, "d").startOf("day"),
|
|
104
125
|
(0, import_dayjs.default)().add(1, "d").endOf("day")
|
|
105
126
|
],
|
|
106
|
-
label: () => (0, import_locales.getText)(
|
|
127
|
+
label: (locale) => (0, import_locales.getText)(
|
|
128
|
+
"toolbar-date-range-shortcut-tomorrow",
|
|
129
|
+
locale && import_locales.pLocaleMap[locale]
|
|
130
|
+
)
|
|
107
131
|
},
|
|
108
132
|
next_3_days: {
|
|
109
133
|
getValue: () => [
|
|
110
134
|
(0, import_dayjs.default)().add(1, "d").startOf("day"),
|
|
111
135
|
(0, import_dayjs.default)().add(3, "d").endOf("day")
|
|
112
136
|
],
|
|
113
|
-
label: () => (0, import_locales.getText)(
|
|
137
|
+
label: (locale) => (0, import_locales.getText)(
|
|
138
|
+
"toolbar-date-range-shortcut-next-3-days",
|
|
139
|
+
locale && import_locales.pLocaleMap[locale]
|
|
140
|
+
)
|
|
114
141
|
},
|
|
115
142
|
next_7_days: {
|
|
116
143
|
getValue: () => [
|
|
117
144
|
(0, import_dayjs.default)().add(1, "d").startOf("day"),
|
|
118
145
|
(0, import_dayjs.default)().add(7, "d").endOf("day")
|
|
119
146
|
],
|
|
120
|
-
label: () => (0, import_locales.getText)(
|
|
147
|
+
label: (locale) => (0, import_locales.getText)(
|
|
148
|
+
"toolbar-date-range-shortcut-next-7-days",
|
|
149
|
+
locale && import_locales.pLocaleMap[locale]
|
|
150
|
+
)
|
|
121
151
|
},
|
|
122
152
|
next_30_days: {
|
|
123
153
|
getValue: () => [
|
|
124
154
|
(0, import_dayjs.default)().add(1, "d").startOf("day"),
|
|
125
155
|
(0, import_dayjs.default)().add(30, "d").endOf("day")
|
|
126
156
|
],
|
|
127
|
-
label: () => (0, import_locales.getText)(
|
|
157
|
+
label: (locale) => (0, import_locales.getText)(
|
|
158
|
+
"toolbar-date-range-shortcut-next-30-days",
|
|
159
|
+
locale && import_locales.pLocaleMap[locale]
|
|
160
|
+
)
|
|
128
161
|
},
|
|
129
162
|
next_90_days: {
|
|
130
163
|
getValue: () => [
|
|
131
164
|
(0, import_dayjs.default)().add(1, "d").startOf("day"),
|
|
132
165
|
(0, import_dayjs.default)().add(90, "d").endOf("day")
|
|
133
166
|
],
|
|
134
|
-
label: () => (0, import_locales.getText)(
|
|
167
|
+
label: (locale) => (0, import_locales.getText)(
|
|
168
|
+
"toolbar-date-range-shortcut-next-90-days",
|
|
169
|
+
locale && import_locales.pLocaleMap[locale]
|
|
170
|
+
)
|
|
135
171
|
},
|
|
136
172
|
next_180_days: {
|
|
137
173
|
getValue: () => [
|
|
138
174
|
(0, import_dayjs.default)().add(1, "d").startOf("day"),
|
|
139
175
|
(0, import_dayjs.default)().add(180, "d").endOf("day")
|
|
140
176
|
],
|
|
141
|
-
label: () => (0, import_locales.getText)(
|
|
177
|
+
label: (locale) => (0, import_locales.getText)(
|
|
178
|
+
"toolbar-date-range-shortcut-next-180-days",
|
|
179
|
+
locale && import_locales.pLocaleMap[locale]
|
|
180
|
+
)
|
|
142
181
|
}
|
|
143
182
|
};
|
|
144
183
|
var defaultPresets = [
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConfigProvider } from 'antd';
|
|
1
2
|
import PisellDateRangePicker from "./PisellDateRangePicker";
|
|
2
3
|
import { LocaleContext, LocaleProvider } from "./PisellDateRangePicker/LocaleContext";
|
|
3
4
|
export * from "@mui/x-date-pickers";
|
|
@@ -18,6 +19,6 @@ export * from "./dateRangeViewRenderers";
|
|
|
18
19
|
export type { DateRange, RangePosition } from "./internals/models/range";
|
|
19
20
|
export type { UseDateRangeFieldProps } from "./internals/models/dateRange";
|
|
20
21
|
export { PisellDateRangePicker as RangePicker };
|
|
21
|
-
export { LocaleContext, LocaleProvider };
|
|
22
|
+
export { LocaleContext, LocaleProvider, ConfigProvider };
|
|
22
23
|
export { getDatePickerValueByShortcut, formatPresets, getShortcutValue, getPresetLabel, getDatePickerValue, } from "./utils/index";
|
|
23
24
|
export * from "./models";
|
package/lib/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
ConfigProvider: () => import_antd.ConfigProvider,
|
|
33
34
|
LocaleContext: () => import_LocaleContext.LocaleContext,
|
|
34
35
|
LocaleProvider: () => import_LocaleContext.LocaleProvider,
|
|
35
36
|
RangePicker: () => import_PisellDateRangePicker.default,
|
|
@@ -40,6 +41,7 @@ __export(src_exports, {
|
|
|
40
41
|
getShortcutValue: () => import_utils.getShortcutValue
|
|
41
42
|
});
|
|
42
43
|
module.exports = __toCommonJS(src_exports);
|
|
44
|
+
var import_antd = require("antd");
|
|
43
45
|
var import_PisellDateRangePicker = __toESM(require("./PisellDateRangePicker"));
|
|
44
46
|
var import_LocaleContext = require("./PisellDateRangePicker/LocaleContext");
|
|
45
47
|
__reExport(src_exports, require("@mui/x-date-pickers"), module.exports);
|
|
@@ -60,6 +62,7 @@ var import_utils = require("./utils/index");
|
|
|
60
62
|
__reExport(src_exports, require("./models"), module.exports);
|
|
61
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
62
64
|
0 && (module.exports = {
|
|
65
|
+
ConfigProvider,
|
|
63
66
|
LocaleContext,
|
|
64
67
|
LocaleProvider,
|
|
65
68
|
RangePicker,
|
|
@@ -5,7 +5,7 @@ export declare const splitDateRangeSections: (sections: RangeFieldSection[]) =>
|
|
|
5
5
|
};
|
|
6
6
|
export declare const removeLastSeparator: (dateSections: RangeFieldSection[]) => (RangeFieldSection | {
|
|
7
7
|
separator: null;
|
|
8
|
-
dateName: "
|
|
8
|
+
dateName: "start" | "end";
|
|
9
9
|
value: string;
|
|
10
10
|
format: string;
|
|
11
11
|
maxLength: number | null;
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const isMobile: () => boolean;
|
|
|
7
7
|
* 格式化预设
|
|
8
8
|
* @param presets
|
|
9
9
|
*/
|
|
10
|
-
export declare const formatPresets: (presets: PresetType[]) => ({
|
|
10
|
+
export declare const formatPresets: (presets: PresetType[], locale?: string) => ({
|
|
11
11
|
label: any;
|
|
12
12
|
getValue: (() => Dayjs[]) | (() => [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days");
|
|
13
13
|
value: [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days";
|
|
@@ -21,7 +21,7 @@ export declare const formatPresets: (presets: PresetType[]) => ({
|
|
|
21
21
|
* @param currentShortcut
|
|
22
22
|
* @param presets
|
|
23
23
|
*/
|
|
24
|
-
export declare const getPresetLabel: (currentShortcut: string | null, presets: any[]) => any;
|
|
24
|
+
export declare const getPresetLabel: (currentShortcut: string | null, presets: any[], locale: string) => any;
|
|
25
25
|
/**
|
|
26
26
|
* 获取预设的value
|
|
27
27
|
* @param value
|
package/lib/utils/index.js
CHANGED
|
@@ -42,7 +42,7 @@ var isMobile = () => {
|
|
|
42
42
|
}
|
|
43
43
|
return (0, import_utils.isMobile)();
|
|
44
44
|
};
|
|
45
|
-
var formatPresets = (presets) => {
|
|
45
|
+
var formatPresets = (presets, locale) => {
|
|
46
46
|
return presets.map((item) => {
|
|
47
47
|
var _a, _b, _c;
|
|
48
48
|
if ((0, import_utils.isString)(item.value)) {
|
|
@@ -56,7 +56,7 @@ var formatPresets = (presets) => {
|
|
|
56
56
|
}
|
|
57
57
|
return {
|
|
58
58
|
...item,
|
|
59
|
-
label: item.label || ((_c = (_b = (_a = import_constants.presetDetailMap) == null ? void 0 : _a[item.value]) == null ? void 0 : _b.label) == null ? void 0 : _c.call(_b)),
|
|
59
|
+
label: item.label || ((_c = (_b = (_a = import_constants.presetDetailMap) == null ? void 0 : _a[item.value]) == null ? void 0 : _b.label) == null ? void 0 : _c.call(_b, locale)),
|
|
60
60
|
getValue: getValue2
|
|
61
61
|
};
|
|
62
62
|
}
|
|
@@ -72,9 +72,9 @@ var formatPresets = (presets) => {
|
|
|
72
72
|
};
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
|
-
var getPresetLabel = (currentShortcut, presets) => {
|
|
75
|
+
var getPresetLabel = (currentShortcut, presets, locale) => {
|
|
76
76
|
var _a, _b, _c;
|
|
77
|
-
const label = (_c = (_b = (_a = import_constants.presetDetailMap) == null ? void 0 : _a[currentShortcut]) == null ? void 0 : _b.label) == null ? void 0 : _c.call(_b);
|
|
77
|
+
const label = (_c = (_b = (_a = import_constants.presetDetailMap) == null ? void 0 : _a[currentShortcut]) == null ? void 0 : _b.label) == null ? void 0 : _c.call(_b, locale);
|
|
78
78
|
if (label) {
|
|
79
79
|
return label;
|
|
80
80
|
}
|