@pisell/date-picker 1.0.68 → 1.0.70
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.d.ts +2 -0
- package/es/PisellDateRangePicker/index.js +24 -3
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +8 -0
- package/lib/PisellDateRangePicker/index.d.ts +2 -0
- package/lib/PisellDateRangePicker/index.js +19 -2
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +14 -2
- package/package.json +1 -1
|
@@ -72,6 +72,8 @@ export interface PisellDateRangePickerProps {
|
|
|
72
72
|
disablePortal?: boolean;
|
|
73
73
|
/** 弹窗放置位置 */
|
|
74
74
|
placement?: PopperPlacementType;
|
|
75
|
+
/** 输入框只读 */
|
|
76
|
+
inputReadOnly: boolean;
|
|
75
77
|
}
|
|
76
78
|
declare const PisellDateRangePicker: (props: PisellDateRangePickerProps) => JSX.Element;
|
|
77
79
|
export default PisellDateRangePicker;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
1
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -17,6 +23,7 @@ import 'dayjs/locale/zh-cn';
|
|
|
17
23
|
import 'dayjs/locale/en';
|
|
18
24
|
import 'dayjs/locale/zh-tw';
|
|
19
25
|
import "./index.less";
|
|
26
|
+
import { isMobile } from "../utils";
|
|
20
27
|
var transDayjsArr = function transDayjsArr(dayjsArr, defaultValue) {
|
|
21
28
|
var _newArr;
|
|
22
29
|
var newArr = dayjsArr || defaultValue || [null, null];
|
|
@@ -62,7 +69,8 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
62
69
|
allowClear = props.allowClear,
|
|
63
70
|
disablePortal = props.disablePortal,
|
|
64
71
|
_props$placement = props.placement,
|
|
65
|
-
placement = _props$placement === void 0 ? "auto" : _props$placement
|
|
72
|
+
placement = _props$placement === void 0 ? "auto" : _props$placement,
|
|
73
|
+
inputReadOnly = props.inputReadOnly;
|
|
66
74
|
var _useState = useState(propsOpen !== null && propsOpen !== void 0 ? propsOpen : false),
|
|
67
75
|
_useState2 = _slicedToArray(_useState, 2),
|
|
68
76
|
open = _useState2[0],
|
|
@@ -95,6 +103,7 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
95
103
|
propsOnChange === null || propsOnChange === void 0 ? void 0 : propsOnChange(_value);
|
|
96
104
|
};
|
|
97
105
|
var _presets = useMemo(function () {
|
|
106
|
+
if (isMobile()) return [];
|
|
98
107
|
return presets.map(function (item) {
|
|
99
108
|
var getValue = function getValue() {
|
|
100
109
|
if (typeof item.getValue === "function") {
|
|
@@ -153,6 +162,15 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
153
162
|
});
|
|
154
163
|
}
|
|
155
164
|
}, [suffixIcon, allowClear, _value]);
|
|
165
|
+
var readOnlyProps = useMemo(function () {
|
|
166
|
+
if (inputReadOnly) {
|
|
167
|
+
return {
|
|
168
|
+
readOnly: true,
|
|
169
|
+
selectedSections: null
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return {};
|
|
173
|
+
}, [inputReadOnly]);
|
|
156
174
|
return /*#__PURE__*/React.createElement("span", {
|
|
157
175
|
className: classNames(className, "pisell-date-range-picker", {
|
|
158
176
|
"pisell-date-range-picker-no-border": !bordered
|
|
@@ -201,7 +219,7 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
201
219
|
okButtonProps: okButtonProps,
|
|
202
220
|
cancelButtonProps: cancelButtonProps
|
|
203
221
|
},
|
|
204
|
-
field: {
|
|
222
|
+
field: _objectSpread({
|
|
205
223
|
value: _value,
|
|
206
224
|
size: "small",
|
|
207
225
|
fullWidth: true,
|
|
@@ -210,12 +228,15 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
|
|
|
210
228
|
InputProps: {
|
|
211
229
|
endAdornment: endAdornment
|
|
212
230
|
}
|
|
213
|
-
},
|
|
231
|
+
}, readOnlyProps),
|
|
214
232
|
popper: {
|
|
215
233
|
className: popupClassName,
|
|
216
234
|
disablePortal: disablePortal,
|
|
217
235
|
placement: placement
|
|
218
236
|
},
|
|
237
|
+
dialog: {
|
|
238
|
+
disablePortal: disablePortal
|
|
239
|
+
},
|
|
219
240
|
mobilePaper: {
|
|
220
241
|
className: popupClassName
|
|
221
242
|
}
|
package/es/utils/index.d.ts
CHANGED
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
|
};
|
|
@@ -72,6 +72,8 @@ export interface PisellDateRangePickerProps {
|
|
|
72
72
|
disablePortal?: boolean;
|
|
73
73
|
/** 弹窗放置位置 */
|
|
74
74
|
placement?: PopperPlacementType;
|
|
75
|
+
/** 输入框只读 */
|
|
76
|
+
inputReadOnly: boolean;
|
|
75
77
|
}
|
|
76
78
|
declare const PisellDateRangePicker: (props: PisellDateRangePickerProps) => JSX.Element;
|
|
77
79
|
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) {
|
|
@@ -84,7 +85,8 @@ var PisellDateRangePicker = (props) => {
|
|
|
84
85
|
style,
|
|
85
86
|
allowClear,
|
|
86
87
|
disablePortal,
|
|
87
|
-
placement = "auto"
|
|
88
|
+
placement = "auto",
|
|
89
|
+
inputReadOnly
|
|
88
90
|
} = props;
|
|
89
91
|
const [open, setOpen] = (0, import_react.useState)(propsOpen ?? false);
|
|
90
92
|
(0, import_react.useEffect)(() => {
|
|
@@ -112,6 +114,8 @@ var PisellDateRangePicker = (props) => {
|
|
|
112
114
|
propsOnChange == null ? void 0 : propsOnChange(_value);
|
|
113
115
|
};
|
|
114
116
|
const _presets = (0, import_react.useMemo)(() => {
|
|
117
|
+
if ((0, import_utils2.isMobile)())
|
|
118
|
+
return [];
|
|
115
119
|
return presets.map((item) => {
|
|
116
120
|
const getValue = () => {
|
|
117
121
|
if (typeof item.getValue === "function") {
|
|
@@ -170,6 +174,15 @@ var PisellDateRangePicker = (props) => {
|
|
|
170
174
|
);
|
|
171
175
|
}
|
|
172
176
|
}, [suffixIcon, allowClear, _value]);
|
|
177
|
+
const readOnlyProps = (0, import_react.useMemo)(() => {
|
|
178
|
+
if (inputReadOnly) {
|
|
179
|
+
return {
|
|
180
|
+
readOnly: true,
|
|
181
|
+
selectedSections: null
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return {};
|
|
185
|
+
}, [inputReadOnly]);
|
|
173
186
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
174
187
|
"span",
|
|
175
188
|
{
|
|
@@ -226,13 +239,17 @@ var PisellDateRangePicker = (props) => {
|
|
|
226
239
|
// hiddenLabel: true,
|
|
227
240
|
InputProps: {
|
|
228
241
|
endAdornment
|
|
229
|
-
}
|
|
242
|
+
},
|
|
243
|
+
...readOnlyProps
|
|
230
244
|
},
|
|
231
245
|
popper: {
|
|
232
246
|
className: popupClassName,
|
|
233
247
|
disablePortal,
|
|
234
248
|
placement
|
|
235
249
|
},
|
|
250
|
+
dialog: {
|
|
251
|
+
disablePortal
|
|
252
|
+
},
|
|
236
253
|
mobilePaper: {
|
|
237
254
|
className: popupClassName
|
|
238
255
|
}
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -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
|
});
|