@pisell/date-picker 1.0.115 → 3.0.2

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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ButtonProps } from 'antd';
2
3
  import { Dayjs } from 'dayjs';
3
4
  import './index.less';
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { DesktopDateRangePickerProps } from './DesktopDateRangePicker.types';
3
+ declare type DesktopDateRangePickerComponent = (<TDate>(props: DesktopDateRangePickerProps<TDate> & React.RefAttributes<HTMLDivElement>) => JSX.Element) & {
4
+ propTypes?: any;
5
+ };
6
+ declare const DesktopDateRangePicker: DesktopDateRangePickerComponent;
7
+ export { DesktopDateRangePicker };
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { MobileDateRangePickerProps } from './MobileDateRangePicker.types';
3
+ declare type MobileDateRangePickerComponent = (<TDate>(props: MobileDateRangePickerProps<TDate> & React.RefAttributes<HTMLDivElement>) => JSX.Element) & {
4
+ propTypes?: any;
5
+ };
6
+ declare const MobileDateRangePicker: MobileDateRangePickerComponent;
7
+ export { MobileDateRangePicker };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ButtonProps } from "antd";
2
3
  import { Dayjs } from "dayjs";
3
4
  import "./index.less";
@@ -147,7 +147,7 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
147
147
  };
148
148
  var handleOk = function handleOk() {
149
149
  var val = getVal();
150
- if (isArr(val) && val.some(function (item) {
150
+ if (val.some(function (item) {
151
151
  return !item;
152
152
  })) {
153
153
  return;
@@ -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: "end" | "start";
8
+ dateName: "start" | "end";
9
9
  value: string;
10
10
  format: string;
11
11
  maxLength: number | null;
package/es/utils/index.js CHANGED
@@ -82,7 +82,7 @@ export var getShortcutValue = function getShortcutValue(value, preset) {
82
82
  var _preset$find;
83
83
  return ((_preset$find = preset.find(function (item) {
84
84
  return item.value === value || item.label === value;
85
- })) === null || _preset$find === void 0 ? void 0 : _preset$find.getValue()) || [null, null];
85
+ })) === null || _preset$find === void 0 ? void 0 : _preset$find.getValue()) || [];
86
86
  };
87
87
 
88
88
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ButtonProps } from 'antd';
2
3
  import { Dayjs } from 'dayjs';
3
4
  import './index.less';
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { DesktopDateRangePickerProps } from './DesktopDateRangePicker.types';
3
+ declare type DesktopDateRangePickerComponent = (<TDate>(props: DesktopDateRangePickerProps<TDate> & React.RefAttributes<HTMLDivElement>) => JSX.Element) & {
4
+ propTypes?: any;
5
+ };
6
+ declare const DesktopDateRangePicker: DesktopDateRangePickerComponent;
7
+ export { DesktopDateRangePicker };
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { MobileDateRangePickerProps } from './MobileDateRangePicker.types';
3
+ declare type MobileDateRangePickerComponent = (<TDate>(props: MobileDateRangePickerProps<TDate> & React.RefAttributes<HTMLDivElement>) => JSX.Element) & {
4
+ propTypes?: any;
5
+ };
6
+ declare const MobileDateRangePicker: MobileDateRangePickerComponent;
7
+ export { MobileDateRangePicker };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ButtonProps } from "antd";
2
3
  import { Dayjs } from "dayjs";
3
4
  import "./index.less";
@@ -148,7 +148,7 @@ var PisellDateRangePicker = (props) => {
148
148
  };
149
149
  const handleOk = () => {
150
150
  const val = getVal();
151
- if ((0, import_utils.isArr)(val) && val.some((item) => !item)) {
151
+ if (val.some((item) => !item)) {
152
152
  return;
153
153
  }
154
154
  setOpen(false);
@@ -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: "end" | "start";
8
+ dateName: "start" | "end";
9
9
  value: string;
10
10
  format: string;
11
11
  maxLength: number | null;
@@ -85,7 +85,7 @@ var getPresetLabel = (currentShortcut, presets, locale) => {
85
85
  };
86
86
  var getShortcutValue = (value, preset) => {
87
87
  var _a;
88
- return ((_a = preset.find((item) => item.value === value || item.label === value)) == null ? void 0 : _a.getValue()) || [null, null];
88
+ return ((_a = preset.find((item) => item.value === value || item.label === value)) == null ? void 0 : _a.getValue()) || [];
89
89
  };
90
90
  var getDatePickerValueByShortcut = (value, preset) => {
91
91
  const p = formatPresets(preset || import_constants.defaultPresets);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/date-picker",
3
- "version": "1.0.115",
3
+ "version": "3.0.2",
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.43"
29
+ "@pisell/utils": "1.0.42"
30
30
  },
31
31
  "files": [
32
32
  "es",
@@ -1,83 +0,0 @@
1
- import { Dayjs } from 'dayjs';
2
- import React from 'react';
3
- import { ButtonProps } from 'antd';
4
- import { PopperPlacementType } from '@mui/base/Popper/Popper.types';
5
- import { PresetType } from '../Shortcuts';
6
- import 'dayjs/locale/zh-cn';
7
- import 'dayjs/locale/en';
8
- import 'dayjs/locale/zh-tw';
9
- import './index.less';
10
- export interface PisellDateRangePickerProps {
11
- /** 再次选择日期时是否清除结束时间 */
12
- clearEndOnSelection?: boolean;
13
- /** 日期选择确认回调 */
14
- onChange?: (day: (Dayjs | null)[] | string) => void;
15
- /** 日期改变回调 此处只为了组件外拿到当前日期项进行状态操作 通常情况下只使用onChange来拿value */
16
- onDateChange?: (day: (Dayjs | null)[]) => void;
17
- /** 日期选择值 */
18
- value?: Dayjs[] | string;
19
- /** 日期选择默认值 */
20
- defaultValue?: Dayjs[];
21
- /** 快捷选择项 */
22
- presets?: PresetType[];
23
- /** 类名 */
24
- className?: string;
25
- /** 是否显示时间选择 这里参数为antd TimePickerProps */
26
- showTime?: boolean | {
27
- defaultValue: Dayjs;
28
- [key: string]: any;
29
- }[];
30
- /** 占位符 */
31
- placeholder?: string;
32
- /** 是否禁用日期 */
33
- disabledDate?: (day: Dayjs, position: 'start' | 'end', value: Dayjs[]) => boolean;
34
- /** 日期格式 */
35
- format?: string;
36
- /** 后缀图标 */
37
- suffixIcon?: React.ReactNode;
38
- /** 是否显示边框 */
39
- bordered?: boolean;
40
- /** 是否打开日期选择 */
41
- open?: boolean;
42
- /** 关闭回调 */
43
- onClose?: () => void;
44
- /** 打开回调 */
45
- onOpen?: () => void;
46
- /** 弹窗宽度 */
47
- popupWidth?: number;
48
- /** 最小日期 */
49
- minDate?: Dayjs;
50
- /** 最大日期 */
51
- maxDate?: Dayjs;
52
- /** 月份切换事件 */
53
- onMonthChange?: (value: Dayjs) => void;
54
- /** 额外的弹出日历 className */
55
- popupClassName?: string;
56
- /** 默认显示月份 */
57
- defaultCalendarMonth?: Dayjs;
58
- /** ok 按钮 props */
59
- okButtonProps?: ButtonProps;
60
- /** cancel 按钮 props */
61
- cancelButtonProps?: ButtonProps;
62
- /**
63
- * CSS media query when `Mobile` mode will be changed to `Desktop`.
64
- * @default '@media (pointer: fine)'
65
- * @example '@media (min-width: 720px)' or theme.breakpoints.up("sm")
66
- */
67
- desktopModeMediaQuery?: string;
68
- style?: React.CSSProperties;
69
- /** 是否展示清除按钮 */
70
- allowClear?: boolean;
71
- /** true 将弹窗当前DOM层次结构下 false 追加到body */
72
- disablePortal?: boolean;
73
- /** 弹窗放置位置 */
74
- placement?: PopperPlacementType;
75
- /** 输入框只读 */
76
- inputReadOnly: boolean;
77
- /** 使用快捷筛选时返回快捷字符串 */
78
- returnShortcutString?: boolean;
79
- isHideCustomSelect?: boolean;
80
- endDateDays?: number;
81
- }
82
- declare const PisellDateRangePicker: (props: PisellDateRangePickerProps) => JSX.Element;
83
- export default PisellDateRangePicker;
@@ -1,3 +0,0 @@
1
- import './index.less';
2
- declare const Toolbar: (props: any) => JSX.Element | null;
3
- export default Toolbar;
@@ -1,83 +0,0 @@
1
- import { Dayjs } from 'dayjs';
2
- import React from 'react';
3
- import { ButtonProps } from 'antd';
4
- import { PopperPlacementType } from '@mui/base/Popper/Popper.types';
5
- import { PresetType } from '../Shortcuts';
6
- import 'dayjs/locale/zh-cn';
7
- import 'dayjs/locale/en';
8
- import 'dayjs/locale/zh-tw';
9
- import './index.less';
10
- export interface PisellDateRangePickerProps {
11
- /** 再次选择日期时是否清除结束时间 */
12
- clearEndOnSelection?: boolean;
13
- /** 日期选择确认回调 */
14
- onChange?: (day: (Dayjs | null)[] | string) => void;
15
- /** 日期改变回调 此处只为了组件外拿到当前日期项进行状态操作 通常情况下只使用onChange来拿value */
16
- onDateChange?: (day: (Dayjs | null)[]) => void;
17
- /** 日期选择值 */
18
- value?: Dayjs[] | string;
19
- /** 日期选择默认值 */
20
- defaultValue?: Dayjs[];
21
- /** 快捷选择项 */
22
- presets?: PresetType[];
23
- /** 类名 */
24
- className?: string;
25
- /** 是否显示时间选择 这里参数为antd TimePickerProps */
26
- showTime?: boolean | {
27
- defaultValue: Dayjs;
28
- [key: string]: any;
29
- }[];
30
- /** 占位符 */
31
- placeholder?: string;
32
- /** 是否禁用日期 */
33
- disabledDate?: (day: Dayjs, position: 'start' | 'end', value: Dayjs[]) => boolean;
34
- /** 日期格式 */
35
- format?: string;
36
- /** 后缀图标 */
37
- suffixIcon?: React.ReactNode;
38
- /** 是否显示边框 */
39
- bordered?: boolean;
40
- /** 是否打开日期选择 */
41
- open?: boolean;
42
- /** 关闭回调 */
43
- onClose?: () => void;
44
- /** 打开回调 */
45
- onOpen?: () => void;
46
- /** 弹窗宽度 */
47
- popupWidth?: number;
48
- /** 最小日期 */
49
- minDate?: Dayjs;
50
- /** 最大日期 */
51
- maxDate?: Dayjs;
52
- /** 月份切换事件 */
53
- onMonthChange?: (value: Dayjs) => void;
54
- /** 额外的弹出日历 className */
55
- popupClassName?: string;
56
- /** 默认显示月份 */
57
- defaultCalendarMonth?: Dayjs;
58
- /** ok 按钮 props */
59
- okButtonProps?: ButtonProps;
60
- /** cancel 按钮 props */
61
- cancelButtonProps?: ButtonProps;
62
- /**
63
- * CSS media query when `Mobile` mode will be changed to `Desktop`.
64
- * @default '@media (pointer: fine)'
65
- * @example '@media (min-width: 720px)' or theme.breakpoints.up("sm")
66
- */
67
- desktopModeMediaQuery?: string;
68
- style?: React.CSSProperties;
69
- /** 是否展示清除按钮 */
70
- allowClear?: boolean;
71
- /** true 将弹窗当前DOM层次结构下 false 追加到body */
72
- disablePortal?: boolean;
73
- /** 弹窗放置位置 */
74
- placement?: PopperPlacementType;
75
- /** 输入框只读 */
76
- inputReadOnly: boolean;
77
- /** 使用快捷筛选时返回快捷字符串 */
78
- returnShortcutString?: boolean;
79
- isHideCustomSelect?: boolean;
80
- endDateDays?: number;
81
- }
82
- declare const PisellDateRangePicker: (props: PisellDateRangePickerProps) => JSX.Element;
83
- export default PisellDateRangePicker;
@@ -1,3 +0,0 @@
1
- import './index.less';
2
- declare const Toolbar: (props: any) => JSX.Element | null;
3
- export default Toolbar;