@pisell/date-picker 1.0.89 → 1.0.91

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.
Files changed (47) hide show
  1. package/es/ActionBar/index.d.ts +18 -0
  2. package/es/CustomCalendarHeader/index.d.ts +2 -0
  3. package/es/Dialog/index.d.ts +2 -0
  4. package/es/Drawer/index.d.ts +11 -0
  5. package/es/PisellDateRangePicker/LocaleContext.d.ts +2 -0
  6. package/es/PisellDateRangePicker/index.js +9 -1
  7. package/es/Shortcuts/index.d.ts +15 -0
  8. package/es/Toolbar/index.js +28 -6
  9. package/es/browserSelect/index.d.ts +15 -0
  10. package/es/constants.d.ts +58 -0
  11. package/es/hooks/useDocumentVisibility.d.ts +2 -0
  12. package/es/hooks/useNextDay.d.ts +2 -0
  13. package/es/hooks/useUpdateEffect.d.ts +2 -0
  14. package/es/icon/ChevronLeft.d.ts +5 -0
  15. package/es/icon/ChevronLeftDouble.d.ts +5 -0
  16. package/es/icon/ChevronRight.d.ts +5 -0
  17. package/es/icon/ChevronRightDouble.d.ts +5 -0
  18. package/es/icon/CloseCircle.d.ts +5 -0
  19. package/es/locales/en-US.d.ts +26 -0
  20. package/es/locales/index.d.ts +2 -0
  21. package/es/locales/zh-CN.d.ts +26 -0
  22. package/es/locales/zh-TW.d.ts +26 -0
  23. package/es/utils/index.d.ts +42 -0
  24. package/lib/ActionBar/index.d.ts +18 -0
  25. package/lib/CustomCalendarHeader/index.d.ts +2 -0
  26. package/lib/Dialog/index.d.ts +2 -0
  27. package/lib/Drawer/index.d.ts +11 -0
  28. package/lib/PisellDateRangePicker/LocaleContext.d.ts +2 -0
  29. package/lib/PisellDateRangePicker/index.js +7 -1
  30. package/lib/Shortcuts/index.d.ts +15 -0
  31. package/lib/Toolbar/index.js +25 -3
  32. package/lib/browserSelect/index.d.ts +15 -0
  33. package/lib/constants.d.ts +58 -0
  34. package/lib/hooks/useDocumentVisibility.d.ts +2 -0
  35. package/lib/hooks/useNextDay.d.ts +2 -0
  36. package/lib/hooks/useUpdateEffect.d.ts +2 -0
  37. package/lib/icon/ChevronLeft.d.ts +5 -0
  38. package/lib/icon/ChevronLeftDouble.d.ts +5 -0
  39. package/lib/icon/ChevronRight.d.ts +5 -0
  40. package/lib/icon/ChevronRightDouble.d.ts +5 -0
  41. package/lib/icon/CloseCircle.d.ts +5 -0
  42. package/lib/locales/en-US.d.ts +26 -0
  43. package/lib/locales/index.d.ts +2 -0
  44. package/lib/locales/zh-CN.d.ts +26 -0
  45. package/lib/locales/zh-TW.d.ts +26 -0
  46. package/lib/utils/index.d.ts +42 -0
  47. package/package.json +2 -2
@@ -0,0 +1,18 @@
1
+ import { ButtonProps } from "antd";
2
+ import { Dayjs } from "dayjs";
3
+ import "./index.less";
4
+ interface ActionBarProps {
5
+ ownerState: any;
6
+ onCancel: () => void;
7
+ onChange: (val: any[], type?: "time") => void;
8
+ onOk: () => void;
9
+ value: any[];
10
+ showTime?: boolean | {
11
+ defaultValue: Dayjs;
12
+ [key: string]: any;
13
+ }[];
14
+ okButtonProps?: ButtonProps;
15
+ cancelButtonProps?: ButtonProps;
16
+ }
17
+ declare const ActionBar: (props: ActionBarProps) => JSX.Element;
18
+ export default ActionBar;
@@ -0,0 +1,2 @@
1
+ declare const CustomCalendarHeader: (props: any) => JSX.Element;
2
+ export default CustomCalendarHeader;
@@ -0,0 +1,2 @@
1
+ declare const Dialog: (props: any) => JSX.Element;
2
+ export default Dialog;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import "./index.less";
3
+ interface DrawerProps {
4
+ open: boolean;
5
+ className?: string;
6
+ height?: number;
7
+ children: React.ReactNode;
8
+ onClose: () => void;
9
+ }
10
+ declare const Drawer: (props: DrawerProps) => JSX.Element | null;
11
+ export default Drawer;
@@ -0,0 +1,2 @@
1
+ export declare const LocaleContext: any;
2
+ export declare const LocaleProvider: any;
@@ -141,6 +141,12 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
141
141
  setCurrentShortcut(lastConfirmShortcut.current);
142
142
  };
143
143
  var handleOk = function handleOk() {
144
+ var val = getVal();
145
+ if (val.some(function (item) {
146
+ return !item;
147
+ })) {
148
+ return;
149
+ }
144
150
  setOpen(false);
145
151
  onClose === null || onClose === void 0 ? void 0 : onClose();
146
152
  propsOnChange === null || propsOnChange === void 0 ? void 0 : propsOnChange(getVal());
@@ -310,7 +316,9 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
310
316
  locale: locale,
311
317
  onChange: handleChange,
312
318
  currentShortcut: currentShortcut,
313
- setCurrentShortcut: setCurrentShortcut
319
+ setCurrentShortcut: setCurrentShortcut,
320
+ disabledDate: disabledDate,
321
+ value: _value
314
322
  },
315
323
  layout: {
316
324
  orientation: "portrait"
@@ -0,0 +1,15 @@
1
+ import "./index.less";
2
+ import { Dayjs } from "dayjs";
3
+ export declare type PresetType = {
4
+ label?: string;
5
+ getValue?: () => [Dayjs, Dayjs];
6
+ 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";
7
+ key?: string;
8
+ };
9
+ interface ShortcutsProps {
10
+ items: PresetType[];
11
+ onChange: (day: [Dayjs, Dayjs], changeImportance?: "accept" | "set") => void;
12
+ changeImportance?: "accept" | "set";
13
+ }
14
+ declare const Shortcuts: (props: ShortcutsProps) => JSX.Element | null;
15
+ export default Shortcuts;
@@ -8,7 +8,7 @@ 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 'react';
11
+ import React, { useMemo, useState, useEffect, useRef } from 'react';
12
12
  import { Input } from 'antd';
13
13
  import dayjs from 'dayjs';
14
14
  import BrowserSelect from "../browserSelect";
@@ -25,7 +25,8 @@ var Toolbar = function Toolbar(props) {
25
25
  locale = props.locale,
26
26
  onChange = props.onChange,
27
27
  currentShortcut = props.currentShortcut,
28
- setCurrentShortcut = props.setCurrentShortcut;
28
+ setCurrentShortcut = props.setCurrentShortcut,
29
+ disabledDate = props.disabledDate;
29
30
  var format = locale === 'en' || locale === 'en-US' ? 'DD/MM/YYYY' : 'YYYY/MM/DD';
30
31
  var _useState = useState(''),
31
32
  _useState2 = _slicedToArray(_useState, 2),
@@ -43,6 +44,8 @@ var Toolbar = function Toolbar(props) {
43
44
  _useState8 = _slicedToArray(_useState7, 2),
44
45
  endError = _useState8[0],
45
46
  setEndError = _useState8[1];
47
+ var valueRef = useRef(value);
48
+ valueRef.current = value;
46
49
  useEffect(function () {
47
50
  if (value !== null && value !== void 0 && value[0]) {
48
51
  setStartStr(value[0].format(format));
@@ -57,10 +60,22 @@ var Toolbar = function Toolbar(props) {
57
60
  setEndStr('');
58
61
  }
59
62
  }, [value]);
63
+ var checkDateDisabled = function checkDateDisabled(position) {
64
+ var val = valueRef.current;
65
+ if (position === 'start' && val[0] && disabledDate !== null && disabledDate !== void 0 && disabledDate(val[1], position, val)) {
66
+ setStartError(true);
67
+ onChange([null, val[1]], 'write');
68
+ }
69
+ if (position === 'end' && val[1] && disabledDate !== null && disabledDate !== void 0 && disabledDate(val[1], position, val)) {
70
+ setEndError(true);
71
+ onChange([val[0], null], 'write');
72
+ }
73
+ };
60
74
  var handleStartChange = function handleStartChange(e) {
61
75
  var val = e.target.value;
62
76
  setStartStr(val);
63
- if (isValidDate(val, format) && (value[1] ? dayjs(val, format) <= value[1] : true)) {
77
+ var objValue = dayjs(val, format);
78
+ if (isValidDate(val, format) && (value[1] ? objValue <= value[1] : true) && !(disabledDate !== null && disabledDate !== void 0 && disabledDate(objValue, 'start', value))) {
64
79
  var _start$set, _start$set$set;
65
80
  setStartError(false);
66
81
  var valDate = dayjs(val, format);
@@ -71,11 +86,15 @@ var Toolbar = function Toolbar(props) {
71
86
  } else {
72
87
  setStartError(true);
73
88
  }
89
+ setTimeout(function () {
90
+ checkDateDisabled('end');
91
+ }, 200);
74
92
  };
75
93
  var handleEndChange = function handleEndChange(e) {
76
94
  var val = e.target.value;
77
95
  setEndStr(val);
78
- if (isValidDate(val, format) && (value[0] ? dayjs(val, format) >= value[0] : true)) {
96
+ var objValue = dayjs(val, format);
97
+ if (isValidDate(val, format) && (value[0] ? objValue >= value[0] : true) && !(disabledDate !== null && disabledDate !== void 0 && disabledDate(objValue, 'end', value))) {
79
98
  var _end$set, _end$set$set;
80
99
  setEndError(false);
81
100
  var valDate = dayjs(val, format);
@@ -86,6 +105,9 @@ var Toolbar = function Toolbar(props) {
86
105
  } else {
87
106
  setEndError(true);
88
107
  }
108
+ setTimeout(function () {
109
+ checkDateDisabled('start');
110
+ }, 200);
89
111
  };
90
112
  var handleSelectChange = function handleSelectChange(e) {
91
113
  var val = e.target.value;
@@ -122,7 +144,7 @@ var Toolbar = function Toolbar(props) {
122
144
  }, /*#__PURE__*/React.createElement("div", {
123
145
  className: "date-picker-toolbar-start-wrap"
124
146
  }, /*#__PURE__*/React.createElement("span", null, getText('toolbar-date-range-shortcut-starting', pLocaleMap[locale])), /*#__PURE__*/React.createElement(Input, {
125
- status: startError ? "error" : "",
147
+ status: startError ? 'error' : '',
126
148
  size: "large",
127
149
  value: startStr,
128
150
  onChange: handleStartChange,
@@ -132,7 +154,7 @@ var Toolbar = function Toolbar(props) {
132
154
  }, getText('toolbar-date-range-invalid-start-date', pLocaleMap[locale]))), /*#__PURE__*/React.createElement("div", {
133
155
  className: "date-picker-toolbar-end-wrap"
134
156
  }, /*#__PURE__*/React.createElement("span", null, getText('toolbar-date-range-shortcut-ending', pLocaleMap[locale])), /*#__PURE__*/React.createElement(Input, {
135
- status: endError ? "error" : "",
157
+ status: endError ? 'error' : '',
136
158
  size: "large",
137
159
  value: endStr,
138
160
  onChange: handleEndChange,
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import "./index.less";
3
+ interface BrowserSelectProps extends React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement> {
4
+ options: any[];
5
+ }
6
+ /**
7
+ * @title: 系统级别的下拉框
8
+ * @description:
9
+ * @param {BrowserSelectProps} props
10
+ * @return {*}
11
+ * @Author: zhiwei.Wang
12
+ * @Date: 2024-01-30 16:43
13
+ */
14
+ declare const BrowserSelect: (props: BrowserSelectProps) => JSX.Element;
15
+ export default BrowserSelect;
@@ -0,0 +1,58 @@
1
+ import dayjs from 'dayjs';
2
+ import { PresetType } from './Shortcuts';
3
+ export declare const presetValueArr: string[];
4
+ export declare const presetDetailMap: {
5
+ today: {
6
+ getValue: () => dayjs.Dayjs[];
7
+ label: (locale?: string) => any;
8
+ };
9
+ yesterday: {
10
+ getValue: () => dayjs.Dayjs[];
11
+ label: (locale?: string) => any;
12
+ };
13
+ last_3_days: {
14
+ getValue: () => dayjs.Dayjs[];
15
+ label: (locale?: string) => any;
16
+ };
17
+ last_7_days: {
18
+ getValue: () => dayjs.Dayjs[];
19
+ label: (locale?: string) => any;
20
+ };
21
+ last_30_days: {
22
+ getValue: () => dayjs.Dayjs[];
23
+ label: (locale?: string) => any;
24
+ };
25
+ last_90_days: {
26
+ getValue: () => dayjs.Dayjs[];
27
+ label: (locale?: string) => any;
28
+ };
29
+ last_180_days: {
30
+ getValue: () => dayjs.Dayjs[];
31
+ label: (locale?: string) => any;
32
+ };
33
+ tomorrow: {
34
+ getValue: () => dayjs.Dayjs[];
35
+ label: (locale?: string) => any;
36
+ };
37
+ next_3_days: {
38
+ getValue: () => dayjs.Dayjs[];
39
+ label: (locale?: string) => any;
40
+ };
41
+ next_7_days: {
42
+ getValue: () => dayjs.Dayjs[];
43
+ label: (locale?: string) => any;
44
+ };
45
+ next_30_days: {
46
+ getValue: () => dayjs.Dayjs[];
47
+ label: (locale?: string) => any;
48
+ };
49
+ next_90_days: {
50
+ getValue: () => dayjs.Dayjs[];
51
+ label: (locale?: string) => any;
52
+ };
53
+ next_180_days: {
54
+ getValue: () => dayjs.Dayjs[];
55
+ label: (locale?: string) => any;
56
+ };
57
+ };
58
+ export declare const defaultPresets: PresetType[];
@@ -0,0 +1,2 @@
1
+ declare const useDocumentVisibility: () => any;
2
+ export default useDocumentVisibility;
@@ -0,0 +1,2 @@
1
+ declare const useNextDay: (fn: Function) => void;
2
+ export default useNextDay;
@@ -0,0 +1,2 @@
1
+ declare const useUpdateEffect: (fn: Function, deps: any[]) => void;
2
+ export default useUpdateEffect;
@@ -0,0 +1,5 @@
1
+ declare const ChevronLeft: (props: {
2
+ className?: string | undefined;
3
+ onClick?: any;
4
+ }) => JSX.Element;
5
+ export default ChevronLeft;
@@ -0,0 +1,5 @@
1
+ declare const ChevronLeftDouble: (props: {
2
+ className?: string | undefined;
3
+ onClick?: any;
4
+ }) => JSX.Element;
5
+ export default ChevronLeftDouble;
@@ -0,0 +1,5 @@
1
+ declare const ChevronRight: (props: {
2
+ className?: string | undefined;
3
+ onClick?: any;
4
+ }) => JSX.Element;
5
+ export default ChevronRight;
@@ -0,0 +1,5 @@
1
+ declare const ChevronRightDouble: (props: {
2
+ className?: string | undefined;
3
+ onClick?: any;
4
+ }) => JSX.Element;
5
+ export default ChevronRightDouble;
@@ -0,0 +1,5 @@
1
+ declare const CloseCircle: (props: {
2
+ className: string;
3
+ onClick: any;
4
+ }) => JSX.Element;
5
+ export default CloseCircle;
@@ -0,0 +1,26 @@
1
+ declare const _default: {
2
+ 'action-bar-cancel': string;
3
+ 'action-bar-apply': string;
4
+ 'action-bar-start.time': string;
5
+ 'action-bar-end.time': string;
6
+ 'toolbar-date-range-shortcut-custom': string;
7
+ "toolbar-date-range-shortcut-date-range": string;
8
+ "toolbar-date-range-shortcut-starting": string;
9
+ "toolbar-date-range-shortcut-ending": string;
10
+ "toolbar-date-range-shortcut-today": string;
11
+ "toolbar-date-range-shortcut-yesterday": string;
12
+ "toolbar-date-range-shortcut-tomorrow": string;
13
+ "toolbar-date-range-shortcut-last-3-days": string;
14
+ "toolbar-date-range-shortcut-last-7-days": string;
15
+ "toolbar-date-range-shortcut-last-30-days": string;
16
+ "toolbar-date-range-shortcut-last-90-days": string;
17
+ "toolbar-date-range-shortcut-last-180-days": string;
18
+ "toolbar-date-range-shortcut-next-3-days": string;
19
+ "toolbar-date-range-shortcut-next-7-days": string;
20
+ "toolbar-date-range-shortcut-next-30-days": string;
21
+ "toolbar-date-range-shortcut-next-90-days": string;
22
+ "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
25
+ };
26
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export declare const pLocaleMap: Record<string, any>;
2
+ export declare const getText: (id: string, pLocale?: string) => any;
@@ -0,0 +1,26 @@
1
+ declare const _default: {
2
+ "action-bar-cancel": string;
3
+ "action-bar-apply": string;
4
+ "action-bar-start.time": string;
5
+ "action-bar-end.time": string;
6
+ "toolbar-date-range-shortcut-date-range": string;
7
+ "toolbar-date-range-shortcut-starting": string;
8
+ "toolbar-date-range-shortcut-ending": string;
9
+ "toolbar-date-range-shortcut-custom": string;
10
+ "toolbar-date-range-shortcut-today": string;
11
+ "toolbar-date-range-shortcut-yesterday": string;
12
+ "toolbar-date-range-shortcut-tomorrow": string;
13
+ "toolbar-date-range-shortcut-last-3-days": string;
14
+ "toolbar-date-range-shortcut-last-7-days": string;
15
+ "toolbar-date-range-shortcut-last-30-days": string;
16
+ "toolbar-date-range-shortcut-last-90-days": string;
17
+ "toolbar-date-range-shortcut-last-180-days": string;
18
+ "toolbar-date-range-shortcut-next-3-days": string;
19
+ "toolbar-date-range-shortcut-next-7-days": string;
20
+ "toolbar-date-range-shortcut-next-30-days": string;
21
+ "toolbar-date-range-shortcut-next-90-days": string;
22
+ "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
25
+ };
26
+ export default _default;
@@ -0,0 +1,26 @@
1
+ declare const _default: {
2
+ 'action-bar-cancel': string;
3
+ 'action-bar-apply': string;
4
+ 'action-bar-start.time': string;
5
+ 'action-bar-end.time': string;
6
+ 'toolbar-date-range-shortcut-custom': string;
7
+ "toolbar-date-range-shortcut-date-range": string;
8
+ "toolbar-date-range-shortcut-starting": string;
9
+ "toolbar-date-range-shortcut-ending": string;
10
+ "toolbar-date-range-shortcut-today": string;
11
+ "toolbar-date-range-shortcut-yesterday": string;
12
+ "toolbar-date-range-shortcut-tomorrow": string;
13
+ "toolbar-date-range-shortcut-last-3-days": string;
14
+ "toolbar-date-range-shortcut-last-7-days": string;
15
+ "toolbar-date-range-shortcut-last-30-days": string;
16
+ "toolbar-date-range-shortcut-last-90-days": string;
17
+ "toolbar-date-range-shortcut-last-180-days": string;
18
+ "toolbar-date-range-shortcut-next-3-days": string;
19
+ "toolbar-date-range-shortcut-next-7-days": string;
20
+ "toolbar-date-range-shortcut-next-30-days": string;
21
+ "toolbar-date-range-shortcut-next-90-days": string;
22
+ "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
25
+ };
26
+ export default _default;
@@ -0,0 +1,42 @@
1
+ import { PresetType } from "../Shortcuts";
2
+ import { Dayjs } from "dayjs";
3
+ export declare const getCurrentLocale: () => string;
4
+ export declare const isBrowser: boolean;
5
+ export declare const isMobile: () => boolean;
6
+ /**
7
+ * 格式化预设
8
+ * @param presets
9
+ */
10
+ export declare const formatPresets: (presets: PresetType[], locale?: string) => ({
11
+ label: any;
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
+ 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";
14
+ key?: string | undefined;
15
+ } | {
16
+ label: string | undefined;
17
+ getValue: () => [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";
18
+ })[];
19
+ /**
20
+ * 获取预设的label
21
+ * @param currentShortcut
22
+ * @param presets
23
+ */
24
+ export declare const getPresetLabel: (currentShortcut: string | null, presets: any[], locale: string) => any;
25
+ /**
26
+ * 获取预设的value
27
+ * @param value
28
+ * @param preset
29
+ */
30
+ export declare const getShortcutValue: (value: string, preset: any[]) => any;
31
+ /**
32
+ * 通过快捷字符串获取对应的value值
33
+ * @param value
34
+ * @param preset
35
+ */
36
+ export declare const getDatePickerValueByShortcut: (value: string, preset?: any[]) => any;
37
+ /**
38
+ * 获取datePicker 时间值 [dayjs,dayjs]
39
+ * @param value
40
+ * @param preset
41
+ */
42
+ export declare const getDatePickerValue: (value: string | Dayjs[], preset?: any[]) => any;
@@ -0,0 +1,18 @@
1
+ import { ButtonProps } from "antd";
2
+ import { Dayjs } from "dayjs";
3
+ import "./index.less";
4
+ interface ActionBarProps {
5
+ ownerState: any;
6
+ onCancel: () => void;
7
+ onChange: (val: any[], type?: "time") => void;
8
+ onOk: () => void;
9
+ value: any[];
10
+ showTime?: boolean | {
11
+ defaultValue: Dayjs;
12
+ [key: string]: any;
13
+ }[];
14
+ okButtonProps?: ButtonProps;
15
+ cancelButtonProps?: ButtonProps;
16
+ }
17
+ declare const ActionBar: (props: ActionBarProps) => JSX.Element;
18
+ export default ActionBar;
@@ -0,0 +1,2 @@
1
+ declare const CustomCalendarHeader: (props: any) => JSX.Element;
2
+ export default CustomCalendarHeader;
@@ -0,0 +1,2 @@
1
+ declare const Dialog: (props: any) => JSX.Element;
2
+ export default Dialog;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import "./index.less";
3
+ interface DrawerProps {
4
+ open: boolean;
5
+ className?: string;
6
+ height?: number;
7
+ children: React.ReactNode;
8
+ onClose: () => void;
9
+ }
10
+ declare const Drawer: (props: DrawerProps) => JSX.Element | null;
11
+ export default Drawer;
@@ -0,0 +1,2 @@
1
+ export declare const LocaleContext: any;
2
+ export declare const LocaleProvider: any;
@@ -144,6 +144,10 @@ var PisellDateRangePicker = (props) => {
144
144
  setCurrentShortcut(lastConfirmShortcut.current);
145
145
  };
146
146
  const handleOk = () => {
147
+ const val = getVal();
148
+ if (val.some((item) => !item)) {
149
+ return;
150
+ }
147
151
  setOpen(false);
148
152
  onClose == null ? void 0 : onClose();
149
153
  propsOnChange == null ? void 0 : propsOnChange(getVal());
@@ -305,7 +309,9 @@ var PisellDateRangePicker = (props) => {
305
309
  locale,
306
310
  onChange: handleChange,
307
311
  currentShortcut,
308
- setCurrentShortcut
312
+ setCurrentShortcut,
313
+ disabledDate,
314
+ value: _value
309
315
  },
310
316
  layout: {
311
317
  orientation: "portrait"
@@ -0,0 +1,15 @@
1
+ import "./index.less";
2
+ import { Dayjs } from "dayjs";
3
+ export declare type PresetType = {
4
+ label?: string;
5
+ getValue?: () => [Dayjs, Dayjs];
6
+ 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";
7
+ key?: string;
8
+ };
9
+ interface ShortcutsProps {
10
+ items: PresetType[];
11
+ onChange: (day: [Dayjs, Dayjs], changeImportance?: "accept" | "set") => void;
12
+ changeImportance?: "accept" | "set";
13
+ }
14
+ declare const Shortcuts: (props: ShortcutsProps) => JSX.Element | null;
15
+ export default Shortcuts;
@@ -49,13 +49,16 @@ var Toolbar = (props) => {
49
49
  locale,
50
50
  onChange,
51
51
  currentShortcut,
52
- setCurrentShortcut
52
+ setCurrentShortcut,
53
+ disabledDate
53
54
  } = props;
54
55
  const format = locale === "en" || locale === "en-US" ? "DD/MM/YYYY" : "YYYY/MM/DD";
55
56
  const [startStr, setStartStr] = (0, import_react.useState)("");
56
57
  const [endStr, setEndStr] = (0, import_react.useState)("");
57
58
  const [startError, setStartError] = (0, import_react.useState)(false);
58
59
  const [endError, setEndError] = (0, import_react.useState)(false);
60
+ const valueRef = (0, import_react.useRef)(value);
61
+ valueRef.current = value;
59
62
  (0, import_react.useEffect)(() => {
60
63
  if (value == null ? void 0 : value[0]) {
61
64
  setStartStr(value[0].format(format));
@@ -70,11 +73,23 @@ var Toolbar = (props) => {
70
73
  setEndStr("");
71
74
  }
72
75
  }, [value]);
76
+ const checkDateDisabled = (position) => {
77
+ const val = valueRef.current;
78
+ if (position === "start" && val[0] && (disabledDate == null ? void 0 : disabledDate(val[1], position, val))) {
79
+ setStartError(true);
80
+ onChange([null, val[1]], "write");
81
+ }
82
+ if (position === "end" && val[1] && (disabledDate == null ? void 0 : disabledDate(val[1], position, val))) {
83
+ setEndError(true);
84
+ onChange([val[0], null], "write");
85
+ }
86
+ };
73
87
  const handleStartChange = (e) => {
74
88
  var _a, _b;
75
89
  const val = e.target.value;
76
90
  setStartStr(val);
77
- if (isValidDate(val, format) && (value[1] ? (0, import_dayjs.default)(val, format) <= value[1] : true)) {
91
+ const objValue = (0, import_dayjs.default)(val, format);
92
+ if (isValidDate(val, format) && (value[1] ? objValue <= value[1] : true) && !(disabledDate == null ? void 0 : disabledDate(objValue, "start", value))) {
78
93
  setStartError(false);
79
94
  const valDate = (0, import_dayjs.default)(val, format);
80
95
  const newValue = [...value];
@@ -84,12 +99,16 @@ var Toolbar = (props) => {
84
99
  } else {
85
100
  setStartError(true);
86
101
  }
102
+ setTimeout(() => {
103
+ checkDateDisabled("end");
104
+ }, 200);
87
105
  };
88
106
  const handleEndChange = (e) => {
89
107
  var _a, _b;
90
108
  const val = e.target.value;
91
109
  setEndStr(val);
92
- if (isValidDate(val, format) && (value[0] ? (0, import_dayjs.default)(val, format) >= value[0] : true)) {
110
+ const objValue = (0, import_dayjs.default)(val, format);
111
+ if (isValidDate(val, format) && (value[0] ? objValue >= value[0] : true) && !(disabledDate == null ? void 0 : disabledDate(objValue, "end", value))) {
93
112
  setEndError(false);
94
113
  const valDate = (0, import_dayjs.default)(val, format);
95
114
  const newValue = [...value];
@@ -99,6 +118,9 @@ var Toolbar = (props) => {
99
118
  } else {
100
119
  setEndError(true);
101
120
  }
121
+ setTimeout(() => {
122
+ checkDateDisabled("start");
123
+ }, 200);
102
124
  };
103
125
  const handleSelectChange = (e) => {
104
126
  const val = e.target.value;
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import "./index.less";
3
+ interface BrowserSelectProps extends React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement> {
4
+ options: any[];
5
+ }
6
+ /**
7
+ * @title: 系统级别的下拉框
8
+ * @description:
9
+ * @param {BrowserSelectProps} props
10
+ * @return {*}
11
+ * @Author: zhiwei.Wang
12
+ * @Date: 2024-01-30 16:43
13
+ */
14
+ declare const BrowserSelect: (props: BrowserSelectProps) => JSX.Element;
15
+ export default BrowserSelect;
@@ -0,0 +1,58 @@
1
+ import dayjs from 'dayjs';
2
+ import { PresetType } from './Shortcuts';
3
+ export declare const presetValueArr: string[];
4
+ export declare const presetDetailMap: {
5
+ today: {
6
+ getValue: () => dayjs.Dayjs[];
7
+ label: (locale?: string) => any;
8
+ };
9
+ yesterday: {
10
+ getValue: () => dayjs.Dayjs[];
11
+ label: (locale?: string) => any;
12
+ };
13
+ last_3_days: {
14
+ getValue: () => dayjs.Dayjs[];
15
+ label: (locale?: string) => any;
16
+ };
17
+ last_7_days: {
18
+ getValue: () => dayjs.Dayjs[];
19
+ label: (locale?: string) => any;
20
+ };
21
+ last_30_days: {
22
+ getValue: () => dayjs.Dayjs[];
23
+ label: (locale?: string) => any;
24
+ };
25
+ last_90_days: {
26
+ getValue: () => dayjs.Dayjs[];
27
+ label: (locale?: string) => any;
28
+ };
29
+ last_180_days: {
30
+ getValue: () => dayjs.Dayjs[];
31
+ label: (locale?: string) => any;
32
+ };
33
+ tomorrow: {
34
+ getValue: () => dayjs.Dayjs[];
35
+ label: (locale?: string) => any;
36
+ };
37
+ next_3_days: {
38
+ getValue: () => dayjs.Dayjs[];
39
+ label: (locale?: string) => any;
40
+ };
41
+ next_7_days: {
42
+ getValue: () => dayjs.Dayjs[];
43
+ label: (locale?: string) => any;
44
+ };
45
+ next_30_days: {
46
+ getValue: () => dayjs.Dayjs[];
47
+ label: (locale?: string) => any;
48
+ };
49
+ next_90_days: {
50
+ getValue: () => dayjs.Dayjs[];
51
+ label: (locale?: string) => any;
52
+ };
53
+ next_180_days: {
54
+ getValue: () => dayjs.Dayjs[];
55
+ label: (locale?: string) => any;
56
+ };
57
+ };
58
+ export declare const defaultPresets: PresetType[];
@@ -0,0 +1,2 @@
1
+ declare const useDocumentVisibility: () => any;
2
+ export default useDocumentVisibility;
@@ -0,0 +1,2 @@
1
+ declare const useNextDay: (fn: Function) => void;
2
+ export default useNextDay;
@@ -0,0 +1,2 @@
1
+ declare const useUpdateEffect: (fn: Function, deps: any[]) => void;
2
+ export default useUpdateEffect;
@@ -0,0 +1,5 @@
1
+ declare const ChevronLeft: (props: {
2
+ className?: string | undefined;
3
+ onClick?: any;
4
+ }) => JSX.Element;
5
+ export default ChevronLeft;
@@ -0,0 +1,5 @@
1
+ declare const ChevronLeftDouble: (props: {
2
+ className?: string | undefined;
3
+ onClick?: any;
4
+ }) => JSX.Element;
5
+ export default ChevronLeftDouble;
@@ -0,0 +1,5 @@
1
+ declare const ChevronRight: (props: {
2
+ className?: string | undefined;
3
+ onClick?: any;
4
+ }) => JSX.Element;
5
+ export default ChevronRight;
@@ -0,0 +1,5 @@
1
+ declare const ChevronRightDouble: (props: {
2
+ className?: string | undefined;
3
+ onClick?: any;
4
+ }) => JSX.Element;
5
+ export default ChevronRightDouble;
@@ -0,0 +1,5 @@
1
+ declare const CloseCircle: (props: {
2
+ className: string;
3
+ onClick: any;
4
+ }) => JSX.Element;
5
+ export default CloseCircle;
@@ -0,0 +1,26 @@
1
+ declare const _default: {
2
+ 'action-bar-cancel': string;
3
+ 'action-bar-apply': string;
4
+ 'action-bar-start.time': string;
5
+ 'action-bar-end.time': string;
6
+ 'toolbar-date-range-shortcut-custom': string;
7
+ "toolbar-date-range-shortcut-date-range": string;
8
+ "toolbar-date-range-shortcut-starting": string;
9
+ "toolbar-date-range-shortcut-ending": string;
10
+ "toolbar-date-range-shortcut-today": string;
11
+ "toolbar-date-range-shortcut-yesterday": string;
12
+ "toolbar-date-range-shortcut-tomorrow": string;
13
+ "toolbar-date-range-shortcut-last-3-days": string;
14
+ "toolbar-date-range-shortcut-last-7-days": string;
15
+ "toolbar-date-range-shortcut-last-30-days": string;
16
+ "toolbar-date-range-shortcut-last-90-days": string;
17
+ "toolbar-date-range-shortcut-last-180-days": string;
18
+ "toolbar-date-range-shortcut-next-3-days": string;
19
+ "toolbar-date-range-shortcut-next-7-days": string;
20
+ "toolbar-date-range-shortcut-next-30-days": string;
21
+ "toolbar-date-range-shortcut-next-90-days": string;
22
+ "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
25
+ };
26
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export declare const pLocaleMap: Record<string, any>;
2
+ export declare const getText: (id: string, pLocale?: string) => any;
@@ -0,0 +1,26 @@
1
+ declare const _default: {
2
+ "action-bar-cancel": string;
3
+ "action-bar-apply": string;
4
+ "action-bar-start.time": string;
5
+ "action-bar-end.time": string;
6
+ "toolbar-date-range-shortcut-date-range": string;
7
+ "toolbar-date-range-shortcut-starting": string;
8
+ "toolbar-date-range-shortcut-ending": string;
9
+ "toolbar-date-range-shortcut-custom": string;
10
+ "toolbar-date-range-shortcut-today": string;
11
+ "toolbar-date-range-shortcut-yesterday": string;
12
+ "toolbar-date-range-shortcut-tomorrow": string;
13
+ "toolbar-date-range-shortcut-last-3-days": string;
14
+ "toolbar-date-range-shortcut-last-7-days": string;
15
+ "toolbar-date-range-shortcut-last-30-days": string;
16
+ "toolbar-date-range-shortcut-last-90-days": string;
17
+ "toolbar-date-range-shortcut-last-180-days": string;
18
+ "toolbar-date-range-shortcut-next-3-days": string;
19
+ "toolbar-date-range-shortcut-next-7-days": string;
20
+ "toolbar-date-range-shortcut-next-30-days": string;
21
+ "toolbar-date-range-shortcut-next-90-days": string;
22
+ "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
25
+ };
26
+ export default _default;
@@ -0,0 +1,26 @@
1
+ declare const _default: {
2
+ 'action-bar-cancel': string;
3
+ 'action-bar-apply': string;
4
+ 'action-bar-start.time': string;
5
+ 'action-bar-end.time': string;
6
+ 'toolbar-date-range-shortcut-custom': string;
7
+ "toolbar-date-range-shortcut-date-range": string;
8
+ "toolbar-date-range-shortcut-starting": string;
9
+ "toolbar-date-range-shortcut-ending": string;
10
+ "toolbar-date-range-shortcut-today": string;
11
+ "toolbar-date-range-shortcut-yesterday": string;
12
+ "toolbar-date-range-shortcut-tomorrow": string;
13
+ "toolbar-date-range-shortcut-last-3-days": string;
14
+ "toolbar-date-range-shortcut-last-7-days": string;
15
+ "toolbar-date-range-shortcut-last-30-days": string;
16
+ "toolbar-date-range-shortcut-last-90-days": string;
17
+ "toolbar-date-range-shortcut-last-180-days": string;
18
+ "toolbar-date-range-shortcut-next-3-days": string;
19
+ "toolbar-date-range-shortcut-next-7-days": string;
20
+ "toolbar-date-range-shortcut-next-30-days": string;
21
+ "toolbar-date-range-shortcut-next-90-days": string;
22
+ "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
25
+ };
26
+ export default _default;
@@ -0,0 +1,42 @@
1
+ import { PresetType } from "../Shortcuts";
2
+ import { Dayjs } from "dayjs";
3
+ export declare const getCurrentLocale: () => string;
4
+ export declare const isBrowser: boolean;
5
+ export declare const isMobile: () => boolean;
6
+ /**
7
+ * 格式化预设
8
+ * @param presets
9
+ */
10
+ export declare const formatPresets: (presets: PresetType[], locale?: string) => ({
11
+ label: any;
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
+ 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";
14
+ key?: string | undefined;
15
+ } | {
16
+ label: string | undefined;
17
+ getValue: () => [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";
18
+ })[];
19
+ /**
20
+ * 获取预设的label
21
+ * @param currentShortcut
22
+ * @param presets
23
+ */
24
+ export declare const getPresetLabel: (currentShortcut: string | null, presets: any[], locale: string) => any;
25
+ /**
26
+ * 获取预设的value
27
+ * @param value
28
+ * @param preset
29
+ */
30
+ export declare const getShortcutValue: (value: string, preset: any[]) => any;
31
+ /**
32
+ * 通过快捷字符串获取对应的value值
33
+ * @param value
34
+ * @param preset
35
+ */
36
+ export declare const getDatePickerValueByShortcut: (value: string, preset?: any[]) => any;
37
+ /**
38
+ * 获取datePicker 时间值 [dayjs,dayjs]
39
+ * @param value
40
+ * @param preset
41
+ */
42
+ export declare const getDatePickerValue: (value: string | Dayjs[], preset?: any[]) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/date-picker",
3
- "version": "1.0.89",
3
+ "version": "1.0.91",
4
4
  "sideEffects": [
5
5
  "*.less"
6
6
  ],
@@ -26,7 +26,7 @@
26
26
  "antd": "^5.5.0",
27
27
  "react": "^18.0.0",
28
28
  "react-dom": "^18.0.0",
29
- "@pisell/utils": "1.0.28"
29
+ "@pisell/utils": "1.0.27"
30
30
  },
31
31
  "files": [
32
32
  "es",