@pisell/date-picker 1.0.67 → 1.0.69

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,6 +1,7 @@
1
1
  import { Dayjs } from "dayjs";
2
2
  import React from "react";
3
3
  import { ButtonProps } from "antd";
4
+ import { PopperPlacementType } from "@mui/base/Popper/Popper.types";
4
5
  import { PresetType } from "../Shortcuts";
5
6
  import 'dayjs/locale/zh-cn';
6
7
  import 'dayjs/locale/en';
@@ -69,6 +70,8 @@ export interface PisellDateRangePickerProps {
69
70
  allowClear?: boolean;
70
71
  /** true 将弹窗当前DOM层次结构下 false 追加到body */
71
72
  disablePortal?: boolean;
73
+ /** 弹窗放置位置 */
74
+ placement?: PopperPlacementType;
72
75
  }
73
76
  declare const PisellDateRangePicker: (props: PisellDateRangePickerProps) => JSX.Element;
74
77
  export default PisellDateRangePicker;
@@ -17,6 +17,7 @@ import 'dayjs/locale/zh-cn';
17
17
  import 'dayjs/locale/en';
18
18
  import 'dayjs/locale/zh-tw';
19
19
  import "./index.less";
20
+ import { isMobile } from "../utils";
20
21
  var transDayjsArr = function transDayjsArr(dayjsArr, defaultValue) {
21
22
  var _newArr;
22
23
  var newArr = dayjsArr || defaultValue || [null, null];
@@ -60,7 +61,9 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
60
61
  desktopModeMediaQuery = props.desktopModeMediaQuery,
61
62
  style = props.style,
62
63
  allowClear = props.allowClear,
63
- disablePortal = props.disablePortal;
64
+ disablePortal = props.disablePortal,
65
+ _props$placement = props.placement,
66
+ placement = _props$placement === void 0 ? "auto" : _props$placement;
64
67
  var _useState = useState(propsOpen !== null && propsOpen !== void 0 ? propsOpen : false),
65
68
  _useState2 = _slicedToArray(_useState, 2),
66
69
  open = _useState2[0],
@@ -93,6 +96,7 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
93
96
  propsOnChange === null || propsOnChange === void 0 ? void 0 : propsOnChange(_value);
94
97
  };
95
98
  var _presets = useMemo(function () {
99
+ if (isMobile()) return [];
96
100
  return presets.map(function (item) {
97
101
  var getValue = function getValue() {
98
102
  if (typeof item.getValue === "function") {
@@ -118,7 +122,7 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
118
122
  return item || null;
119
123
  });
120
124
  }
121
- if (clearEndOnSelection && _value.filter(Boolean).length === 2) {
125
+ if (clearEndOnSelection && type !== "set" && _value.filter(Boolean).length === 2) {
122
126
  newVal = [newVal[0], null];
123
127
  }
124
128
  onDateChange === null || onDateChange === void 0 ? void 0 : onDateChange(newVal);
@@ -212,7 +216,10 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
212
216
  popper: {
213
217
  className: popupClassName,
214
218
  disablePortal: disablePortal,
215
- placement: "auto"
219
+ placement: placement
220
+ },
221
+ dialog: {
222
+ disablePortal: disablePortal
216
223
  },
217
224
  mobilePaper: {
218
225
  className: popupClassName
@@ -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;
@@ -1 +1,3 @@
1
1
  export declare const getCurrentLocale: () => string;
2
+ export declare const isBrowser: boolean;
3
+ export declare const isMobile: () => boolean;
package/es/utils/index.js CHANGED
@@ -1,5 +1,13 @@
1
+ import { isMobile as isMobileUtils } from "@pisell/utils";
1
2
  export var getCurrentLocale = function getCurrentLocale() {
2
3
  var locale = localStorage.getItem('umi_locale') || 'en-US';
3
4
  //@ts-ignore
4
5
  return locale;
6
+ };
7
+ export var isBrowser = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
8
+ export var isMobile = function isMobile() {
9
+ if (isBrowser) {
10
+ return window.innerWidth <= 768 || isMobileUtils();
11
+ }
12
+ return isMobileUtils();
5
13
  };
@@ -1,6 +1,7 @@
1
1
  import { Dayjs } from "dayjs";
2
2
  import React from "react";
3
3
  import { ButtonProps } from "antd";
4
+ import { PopperPlacementType } from "@mui/base/Popper/Popper.types";
4
5
  import { PresetType } from "../Shortcuts";
5
6
  import 'dayjs/locale/zh-cn';
6
7
  import 'dayjs/locale/en';
@@ -69,6 +70,8 @@ export interface PisellDateRangePickerProps {
69
70
  allowClear?: boolean;
70
71
  /** true 将弹窗当前DOM层次结构下 false 追加到body */
71
72
  disablePortal?: boolean;
73
+ /** 弹窗放置位置 */
74
+ placement?: PopperPlacementType;
72
75
  }
73
76
  declare const PisellDateRangePicker: (props: PisellDateRangePickerProps) => JSX.Element;
74
77
  export default PisellDateRangePicker;
@@ -45,6 +45,7 @@ var import_zh_cn = require("dayjs/locale/zh-cn");
45
45
  var import_en = require("dayjs/locale/en");
46
46
  var import_zh_tw = require("dayjs/locale/zh-tw");
47
47
  var import_index = require("./index.less");
48
+ var import_utils2 = require("../utils");
48
49
  var transDayjsArr = (dayjsArr, defaultValue) => {
49
50
  let newArr = dayjsArr || defaultValue || [null, null];
50
51
  if ((dayjsArr == null ? void 0 : dayjsArr.length) === 0) {
@@ -83,7 +84,8 @@ var PisellDateRangePicker = (props) => {
83
84
  desktopModeMediaQuery,
84
85
  style,
85
86
  allowClear,
86
- disablePortal
87
+ disablePortal,
88
+ placement = "auto"
87
89
  } = props;
88
90
  const [open, setOpen] = (0, import_react.useState)(propsOpen ?? false);
89
91
  (0, import_react.useEffect)(() => {
@@ -111,6 +113,8 @@ var PisellDateRangePicker = (props) => {
111
113
  propsOnChange == null ? void 0 : propsOnChange(_value);
112
114
  };
113
115
  const _presets = (0, import_react.useMemo)(() => {
116
+ if ((0, import_utils2.isMobile)())
117
+ return [];
114
118
  return presets.map((item) => {
115
119
  const getValue = () => {
116
120
  if (typeof item.getValue === "function") {
@@ -135,7 +139,7 @@ var PisellDateRangePicker = (props) => {
135
139
  return item || null;
136
140
  });
137
141
  }
138
- if (clearEndOnSelection && _value.filter(Boolean).length === 2) {
142
+ if (clearEndOnSelection && type !== "set" && _value.filter(Boolean).length === 2) {
139
143
  newVal = [newVal[0], null];
140
144
  }
141
145
  onDateChange == null ? void 0 : onDateChange(newVal);
@@ -230,7 +234,10 @@ var PisellDateRangePicker = (props) => {
230
234
  popper: {
231
235
  className: popupClassName,
232
236
  disablePortal,
233
- placement: "auto"
237
+ placement
238
+ },
239
+ dialog: {
240
+ disablePortal
234
241
  },
235
242
  mobilePaper: {
236
243
  className: popupClassName
@@ -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;
@@ -1 +1,3 @@
1
1
  export declare const getCurrentLocale: () => string;
2
+ export declare const isBrowser: boolean;
3
+ export declare const isMobile: () => boolean;
@@ -19,14 +19,26 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/utils/index.ts
20
20
  var utils_exports = {};
21
21
  __export(utils_exports, {
22
- getCurrentLocale: () => getCurrentLocale
22
+ getCurrentLocale: () => getCurrentLocale,
23
+ isBrowser: () => isBrowser,
24
+ isMobile: () => isMobile
23
25
  });
24
26
  module.exports = __toCommonJS(utils_exports);
27
+ var import_utils = require("@pisell/utils");
25
28
  var getCurrentLocale = () => {
26
29
  let locale = localStorage.getItem("umi_locale") || "en-US";
27
30
  return locale;
28
31
  };
32
+ var isBrowser = !!(typeof window !== "undefined" && window.document && window.document.createElement);
33
+ var isMobile = () => {
34
+ if (isBrowser) {
35
+ return window.innerWidth <= 768 || (0, import_utils.isMobile)();
36
+ }
37
+ return (0, import_utils.isMobile)();
38
+ };
29
39
  // Annotate the CommonJS export names for ESM import in node:
30
40
  0 && (module.exports = {
31
- getCurrentLocale
41
+ getCurrentLocale,
42
+ isBrowser,
43
+ isMobile
32
44
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/date-picker",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
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.21"
29
+ "@pisell/utils": "1.0.23"
30
30
  },
31
31
  "files": [
32
32
  "es",