@pisell/date-picker 1.0.9 → 1.0.11

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,9 +1,14 @@
1
+ import { Dayjs } from "dayjs";
1
2
  import "./index.less";
2
3
  interface ActionBarProps {
3
4
  ownerState: any;
4
5
  onCancel: () => void;
6
+ onChange: (val: any[], type?: "time") => void;
5
7
  onOk: () => void;
6
- showTime?: boolean;
8
+ showTime?: boolean | {
9
+ defaultValue: [Dayjs, Dayjs];
10
+ [key: string]: any;
11
+ };
7
12
  }
8
13
  declare const ActionBar: (props: ActionBarProps) => JSX.Element;
9
14
  export default ActionBar;
@@ -1,12 +1,22 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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); }
7
+ 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); }
1
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
9
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
10
  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); }
4
11
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
12
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
13
  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; }
7
- import React from "react";
14
+ import React, { useMemo } from "react";
8
15
  import classNames from "classnames";
9
16
  import { Button, Space, TimePicker } from "antd";
17
+ import { isMobile } from "@pisell/utils";
18
+ import dayjs from "dayjs";
19
+ import { getText } from "../locales";
10
20
  import "./index.less";
11
21
  var ActionBar = function ActionBar(props) {
12
22
  var ownerState = props.ownerState,
@@ -20,38 +30,73 @@ var ActionBar = function ActionBar(props) {
20
30
  items = _ref.items;
21
31
  var hasShortcuts = !!items.length;
22
32
  var handleStartChange = function handleStartChange(val) {
33
+ var _start$set, _start$set$set;
23
34
  var newValue = _toConsumableArray(value);
24
- newValue[0] = newValue[0].set("hour", val.get("hour")).set("minute", val.get("minute")).set("second", val.get("second"));
35
+ var start = newValue[0] || dayjs();
36
+ newValue[0] = (start === null || start === void 0 ? void 0 : (_start$set = start.set("hour", val.get("hour"))) === null || _start$set === void 0 ? void 0 : (_start$set$set = _start$set.set("minute", val.get("minute"))) === null || _start$set$set === void 0 ? void 0 : _start$set$set.set("second", val.get("second"))) || null;
25
37
  onChange(newValue, "time");
26
38
  };
27
39
  var handleEndChange = function handleEndChange(val) {
40
+ var _end$set, _end$set$set;
28
41
  var newValue = _toConsumableArray(value);
29
- newValue[1] = newValue[1].set("hour", val.get("hour")).set("minute", val.get("minute")).set("second", val.get("second"));
42
+ var end = newValue[1] || dayjs();
43
+ newValue[1] = (end === null || end === void 0 ? void 0 : (_end$set = end.set("hour", val.get("hour"))) === null || _end$set === void 0 ? void 0 : (_end$set$set = _end$set.set("minute", val.get("minute"))) === null || _end$set$set === void 0 ? void 0 : _end$set$set.set("second", val.get("second"))) || null;
30
44
  onChange(newValue, "time");
31
45
  };
46
+ var spaceStyle = useMemo(function () {
47
+ return isMobile() ? {
48
+ display: "flex",
49
+ justifyContent: "end",
50
+ marginBottom: 12
51
+ } : {
52
+ display: "flex"
53
+ };
54
+ }, []);
55
+ var startTimeProps = useMemo(function () {
56
+ if (_typeof(showTime) === "object") {
57
+ return showTime[0];
58
+ }
59
+ return {};
60
+ }, [showTime]);
61
+ var endTimeProps = useMemo(function () {
62
+ if (_typeof(showTime) === "object") {
63
+ return showTime[1];
64
+ }
65
+ return {};
66
+ }, [showTime]);
32
67
  return /*#__PURE__*/React.createElement("div", {
33
68
  className: classNames(props.className, "date-picker-action-bar")
34
69
  }, hasShortcuts && /*#__PURE__*/React.createElement("div", {
35
70
  className: "date-picker-action-bar-left"
36
71
  }), /*#__PURE__*/React.createElement("div", {
37
- className: "date-picker-action-bar-right"
72
+ className: "date-picker-action-bar-right",
73
+ style: isMobile() ? {
74
+ display: "block"
75
+ } : {}
38
76
  }, /*#__PURE__*/React.createElement(Space, {
39
- split: "-"
40
- }, showTime ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TimePicker, {
41
- placeholder: "start time",
77
+ split: "-",
78
+ style: _objectSpread({}, spaceStyle)
79
+ }, showTime ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TimePicker, _extends({
80
+ placeholder: getText("action-bar-start.time")
81
+ }, startTimeProps, {
42
82
  value: value[0],
43
83
  popupClassName: "date-picker-action-bar-time-picker-popup",
44
84
  onChange: handleStartChange
45
- }), /*#__PURE__*/React.createElement(TimePicker, {
46
- placeholder: "end time",
85
+ })), /*#__PURE__*/React.createElement(TimePicker, _extends({
86
+ placeholder: getText("action-bar-end.time")
87
+ }, endTimeProps, {
47
88
  value: value[1],
48
89
  popupClassName: "date-picker-action-bar-time-picker-popup",
49
90
  onChange: handleEndChange
50
- })) : /*#__PURE__*/React.createElement("div", null)), /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
91
+ }))) : /*#__PURE__*/React.createElement("div", null)), /*#__PURE__*/React.createElement(Space, {
92
+ style: _objectSpread(_objectSpread({}, spaceStyle), {}, {
93
+ margin: 0
94
+ })
95
+ }, /*#__PURE__*/React.createElement(Button, {
51
96
  onClick: onCancel
52
- }, "Cancel"), /*#__PURE__*/React.createElement(Button, {
97
+ }, getText("action-bar-cancel")), /*#__PURE__*/React.createElement(Button, {
53
98
  type: "primary",
54
99
  onClick: onOk
55
- }, "Apply"))));
100
+ }, getText("action-bar-apply")))));
56
101
  };
57
102
  export default ActionBar;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Dayjs } from "dayjs";
2
3
  import { PresetType } from "../Shortcuts";
3
4
  import "./index.less";
@@ -9,6 +10,7 @@ export interface PisellDateRangePickerProps {
9
10
  className?: string;
10
11
  showTime?: boolean | {
11
12
  defaultValue: [Dayjs, Dayjs];
13
+ [key: string]: any;
12
14
  };
13
15
  placeholder?: string;
14
16
  disableDate?: (day: Dayjs) => boolean;
@@ -75,7 +75,7 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
75
75
  }, [presets]);
76
76
  var handleChange = function handleChange(val, type) {
77
77
  var newVal = val;
78
- if (_typeof(showTime) === "object" && showTime !== null && showTime !== void 0 && showTime.defaultValue && type !== 'time') {
78
+ if (_typeof(showTime) === "object" && showTime !== null && showTime !== void 0 && showTime.defaultValue && type !== "time") {
79
79
  newVal = newVal.map(function (item, index) {
80
80
  var _showTime$defaultValu, _showTime$defaultValu2, _showTime$defaultValu3, _showTime$defaultValu4, _showTime$defaultValu5, _showTime$defaultValu6;
81
81
  return (item === null || item === void 0 ? void 0 : item.set("hour", showTime === null || showTime === void 0 ? void 0 : (_showTime$defaultValu = showTime.defaultValue) === null || _showTime$defaultValu === void 0 ? void 0 : (_showTime$defaultValu2 = _showTime$defaultValu[index]) === null || _showTime$defaultValu2 === void 0 ? void 0 : _showTime$defaultValu2.get("hour")).set("minute", showTime === null || showTime === void 0 ? void 0 : (_showTime$defaultValu3 = showTime.defaultValue) === null || _showTime$defaultValu3 === void 0 ? void 0 : (_showTime$defaultValu4 = _showTime$defaultValu3[index]) === null || _showTime$defaultValu4 === void 0 ? void 0 : _showTime$defaultValu4.get("minute")).set("second", showTime === null || showTime === void 0 ? void 0 : (_showTime$defaultValu5 = showTime.defaultValue) === null || _showTime$defaultValu5 === void 0 ? void 0 : (_showTime$defaultValu6 = _showTime$defaultValu5[index]) === null || _showTime$defaultValu6 === void 0 ? void 0 : _showTime$defaultValu6.get("second"))) || null;
@@ -114,7 +114,8 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
114
114
  onChange: handleChange
115
115
  },
116
116
  field: {
117
- size: "small"
117
+ size: "small",
118
+ fullWidth: true
118
119
  }
119
120
  }
120
121
  });
@@ -1,5 +1,5 @@
1
1
  .pisell-date-range-picker {
2
- width: 350px;
2
+ //width: 350px;
3
3
  //.MuiInputBase-input {
4
4
  // padding: 10px;
5
5
  //}
@@ -7,8 +7,8 @@ export declare type PresetType = {
7
7
  };
8
8
  interface ShortcutsProps {
9
9
  items: PresetType[];
10
- onChange: (day: [Dayjs, Dayjs], changeImportance?: 'accept' | 'set') => void;
11
- changeImportance?: 'accept' | 'set';
10
+ onChange: (day: [Dayjs, Dayjs], changeImportance?: "accept" | "set") => void;
11
+ changeImportance?: "accept" | "set";
12
12
  }
13
13
  declare const Shortcuts: (props: ShortcutsProps) => JSX.Element | null;
14
14
  export default Shortcuts;
@@ -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: "start" | "end";
8
+ dateName: "end" | "start";
9
9
  value: string;
10
10
  format: string;
11
11
  maxLength: number | null;
@@ -0,0 +1,7 @@
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
+ };
7
+ export default _default;
@@ -0,0 +1,6 @@
1
+ export default {
2
+ 'action-bar-cancel': 'Cancel',
3
+ 'action-bar-apply': 'Apply',
4
+ 'action-bar-start.time': 'Start time',
5
+ 'action-bar-end.time': 'End time'
6
+ };
@@ -0,0 +1 @@
1
+ export declare const getText: (id: string) => any;
@@ -0,0 +1,22 @@
1
+ import zhCN from "./zh-CN";
2
+ import enUS from "./en-US";
3
+ import zhTW from "./zh-TW";
4
+ import { getCurrentLocale } from "../utils";
5
+ var langMap = {
6
+ "zh-CN": zhCN,
7
+ "en-US": enUS,
8
+ "zh-TW": zhTW
9
+ };
10
+ export var getText = function getText(id) {
11
+ console.log('id', id);
12
+ if (!id) {
13
+ return;
14
+ }
15
+ var locale = getCurrentLocale();
16
+ if (!locale) {
17
+ localStorage.setItem("umi_locale", "en-US");
18
+ locale = "en-US";
19
+ }
20
+ //@ts-ignore
21
+ return langMap[locale][id] || id;
22
+ };
@@ -0,0 +1,7 @@
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
+ };
7
+ export default _default;
@@ -0,0 +1,6 @@
1
+ export default {
2
+ 'action-bar-cancel': '取消',
3
+ 'action-bar-apply': '确定',
4
+ 'action-bar-start.time': '开始时间',
5
+ 'action-bar-end.time': '结束时间'
6
+ };
@@ -0,0 +1,7 @@
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
+ };
7
+ export default _default;
@@ -0,0 +1,6 @@
1
+ export default {
2
+ 'action-bar-cancel': '取消',
3
+ 'action-bar-apply': '確定',
4
+ 'action-bar-start.time': '開始時間',
5
+ 'action-bar-end.time': '結束時間'
6
+ };
@@ -0,0 +1 @@
1
+ export declare const getCurrentLocale: () => string;
@@ -0,0 +1,6 @@
1
+ export var getCurrentLocale = function getCurrentLocale() {
2
+ var locale = 'en-US';
3
+ locale = localStorage.getItem('umi_locale');
4
+ //@ts-ignore
5
+ return locale;
6
+ };
@@ -1,9 +1,14 @@
1
+ import { Dayjs } from "dayjs";
1
2
  import "./index.less";
2
3
  interface ActionBarProps {
3
4
  ownerState: any;
4
5
  onCancel: () => void;
6
+ onChange: (val: any[], type?: "time") => void;
5
7
  onOk: () => void;
6
- showTime?: boolean;
8
+ showTime?: boolean | {
9
+ defaultValue: [Dayjs, Dayjs];
10
+ [key: string]: any;
11
+ };
7
12
  }
8
13
  declare const ActionBar: (props: ActionBarProps) => JSX.Element;
9
14
  export default ActionBar;
@@ -35,6 +35,9 @@ module.exports = __toCommonJS(ActionBar_exports);
35
35
  var import_react = __toESM(require("react"));
36
36
  var import_classnames = __toESM(require("classnames"));
37
37
  var import_antd = require("antd");
38
+ var import_utils = require("@pisell/utils");
39
+ var import_dayjs = __toESM(require("dayjs"));
40
+ var import_locales = require("../locales");
38
41
  var import_index = require("./index.less");
39
42
  var ActionBar = (props) => {
40
43
  const { ownerState, onCancel, onOk, onChange, showTime } = props;
@@ -42,31 +45,66 @@ var ActionBar = (props) => {
42
45
  const { items } = (slotProps == null ? void 0 : slotProps.shortcuts) || {};
43
46
  const hasShortcuts = !!items.length;
44
47
  const handleStartChange = (val) => {
48
+ var _a, _b;
45
49
  const newValue = [...value];
46
- newValue[0] = newValue[0].set("hour", val.get("hour")).set("minute", val.get("minute")).set("second", val.get("second"));
50
+ const start = newValue[0] || (0, import_dayjs.default)();
51
+ newValue[0] = ((_b = (_a = start == null ? void 0 : start.set("hour", val.get("hour"))) == null ? void 0 : _a.set("minute", val.get("minute"))) == null ? void 0 : _b.set("second", val.get("second"))) || null;
47
52
  onChange(newValue, "time");
48
53
  };
49
54
  const handleEndChange = (val) => {
55
+ var _a, _b;
50
56
  const newValue = [...value];
51
- newValue[1] = newValue[1].set("hour", val.get("hour")).set("minute", val.get("minute")).set("second", val.get("second"));
57
+ const end = newValue[1] || (0, import_dayjs.default)();
58
+ newValue[1] = ((_b = (_a = end == null ? void 0 : end.set("hour", val.get("hour"))) == null ? void 0 : _a.set("minute", val.get("minute"))) == null ? void 0 : _b.set("second", val.get("second"))) || null;
52
59
  onChange(newValue, "time");
53
60
  };
54
- return /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_classnames.default)(props.className, "date-picker-action-bar") }, hasShortcuts && /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-action-bar-left" }), /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-action-bar-right" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { split: "-" }, showTime ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
55
- import_antd.TimePicker,
56
- {
57
- placeholder: "start time",
58
- value: value[0],
59
- popupClassName: "date-picker-action-bar-time-picker-popup",
60
- onChange: handleStartChange
61
+ const spaceStyle = (0, import_react.useMemo)(() => {
62
+ return (0, import_utils.isMobile)() ? {
63
+ display: "flex",
64
+ justifyContent: "end",
65
+ marginBottom: 12
66
+ } : {
67
+ display: "flex"
68
+ };
69
+ }, []);
70
+ const startTimeProps = (0, import_react.useMemo)(() => {
71
+ if (typeof showTime === "object") {
72
+ return showTime[0];
61
73
  }
62
- ), /* @__PURE__ */ import_react.default.createElement(
63
- import_antd.TimePicker,
64
- {
65
- placeholder: "end time",
66
- value: value[1],
67
- popupClassName: "date-picker-action-bar-time-picker-popup",
68
- onChange: handleEndChange
74
+ return {};
75
+ }, [showTime]);
76
+ const endTimeProps = (0, import_react.useMemo)(() => {
77
+ if (typeof showTime === "object") {
78
+ return showTime[1];
69
79
  }
70
- )) : /* @__PURE__ */ import_react.default.createElement("div", null)), /* @__PURE__ */ import_react.default.createElement(import_antd.Space, null, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: onCancel }, "Cancel"), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { type: "primary", onClick: onOk }, "Apply"))));
80
+ return {};
81
+ }, [showTime]);
82
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_classnames.default)(props.className, "date-picker-action-bar") }, hasShortcuts && /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-action-bar-left" }), /* @__PURE__ */ import_react.default.createElement(
83
+ "div",
84
+ {
85
+ className: "date-picker-action-bar-right",
86
+ style: (0, import_utils.isMobile)() ? { display: "block" } : {}
87
+ },
88
+ /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { split: "-", style: { ...spaceStyle } }, showTime ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
89
+ import_antd.TimePicker,
90
+ {
91
+ placeholder: (0, import_locales.getText)("action-bar-start.time"),
92
+ ...startTimeProps,
93
+ value: value[0],
94
+ popupClassName: "date-picker-action-bar-time-picker-popup",
95
+ onChange: handleStartChange
96
+ }
97
+ ), /* @__PURE__ */ import_react.default.createElement(
98
+ import_antd.TimePicker,
99
+ {
100
+ placeholder: (0, import_locales.getText)("action-bar-end.time"),
101
+ ...endTimeProps,
102
+ value: value[1],
103
+ popupClassName: "date-picker-action-bar-time-picker-popup",
104
+ onChange: handleEndChange
105
+ }
106
+ )) : /* @__PURE__ */ import_react.default.createElement("div", null)),
107
+ /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { style: { ...spaceStyle, margin: 0 } }, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: onCancel }, (0, import_locales.getText)("action-bar-cancel")), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { type: "primary", onClick: onOk }, (0, import_locales.getText)("action-bar-apply")))
108
+ ));
71
109
  };
72
110
  var ActionBar_default = ActionBar;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Dayjs } from "dayjs";
2
3
  import { PresetType } from "../Shortcuts";
3
4
  import "./index.less";
@@ -9,6 +10,7 @@ export interface PisellDateRangePickerProps {
9
10
  className?: string;
10
11
  showTime?: boolean | {
11
12
  defaultValue: [Dayjs, Dayjs];
13
+ [key: string]: any;
12
14
  };
13
15
  placeholder?: string;
14
16
  disableDate?: (day: Dayjs) => boolean;
@@ -135,7 +135,8 @@ var PisellDateRangePicker = (props) => {
135
135
  onChange: handleChange
136
136
  },
137
137
  field: {
138
- size: "small"
138
+ size: "small",
139
+ fullWidth: true
139
140
  }
140
141
  }
141
142
  }
@@ -1,5 +1,5 @@
1
1
  .pisell-date-range-picker {
2
- width: 350px;
2
+ //width: 350px;
3
3
  //.MuiInputBase-input {
4
4
  // padding: 10px;
5
5
  //}
@@ -7,8 +7,8 @@ export declare type PresetType = {
7
7
  };
8
8
  interface ShortcutsProps {
9
9
  items: PresetType[];
10
- onChange: (day: [Dayjs, Dayjs], changeImportance?: 'accept' | 'set') => void;
11
- changeImportance?: 'accept' | 'set';
10
+ onChange: (day: [Dayjs, Dayjs], changeImportance?: "accept" | "set") => void;
11
+ changeImportance?: "accept" | "set";
12
12
  }
13
13
  declare const Shortcuts: (props: ShortcutsProps) => JSX.Element | null;
14
14
  export default Shortcuts;
@@ -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: "start" | "end";
8
+ dateName: "end" | "start";
9
9
  value: string;
10
10
  format: string;
11
11
  maxLength: number | null;
@@ -0,0 +1,7 @@
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
+ };
7
+ export default _default;
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/locales/en-US.ts
20
+ var en_US_exports = {};
21
+ __export(en_US_exports, {
22
+ default: () => en_US_default
23
+ });
24
+ module.exports = __toCommonJS(en_US_exports);
25
+ var en_US_default = {
26
+ "action-bar-cancel": "Cancel",
27
+ "action-bar-apply": "Apply",
28
+ "action-bar-start.time": "Start time",
29
+ "action-bar-end.time": "End time"
30
+ };
@@ -0,0 +1 @@
1
+ export declare const getText: (id: string) => any;
@@ -0,0 +1,59 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/locales/index.ts
30
+ var locales_exports = {};
31
+ __export(locales_exports, {
32
+ getText: () => getText
33
+ });
34
+ module.exports = __toCommonJS(locales_exports);
35
+ var import_zh_CN = __toESM(require("./zh-CN"));
36
+ var import_en_US = __toESM(require("./en-US"));
37
+ var import_zh_TW = __toESM(require("./zh-TW"));
38
+ var import_utils = require("../utils");
39
+ var langMap = {
40
+ "zh-CN": import_zh_CN.default,
41
+ "en-US": import_en_US.default,
42
+ "zh-TW": import_zh_TW.default
43
+ };
44
+ var getText = (id) => {
45
+ console.log("id", id);
46
+ if (!id) {
47
+ return;
48
+ }
49
+ let locale = (0, import_utils.getCurrentLocale)();
50
+ if (!locale) {
51
+ localStorage.setItem("umi_locale", "en-US");
52
+ locale = "en-US";
53
+ }
54
+ return langMap[locale][id] || id;
55
+ };
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ getText
59
+ });
@@ -0,0 +1,7 @@
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
+ };
7
+ export default _default;
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/locales/zh-CN.ts
20
+ var zh_CN_exports = {};
21
+ __export(zh_CN_exports, {
22
+ default: () => zh_CN_default
23
+ });
24
+ module.exports = __toCommonJS(zh_CN_exports);
25
+ var zh_CN_default = {
26
+ "action-bar-cancel": "取消",
27
+ "action-bar-apply": "确定",
28
+ "action-bar-start.time": "开始时间",
29
+ "action-bar-end.time": "结束时间"
30
+ };
@@ -0,0 +1,7 @@
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
+ };
7
+ export default _default;
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/locales/zh-TW.ts
20
+ var zh_TW_exports = {};
21
+ __export(zh_TW_exports, {
22
+ default: () => zh_TW_default
23
+ });
24
+ module.exports = __toCommonJS(zh_TW_exports);
25
+ var zh_TW_default = {
26
+ "action-bar-cancel": "取消",
27
+ "action-bar-apply": "確定",
28
+ "action-bar-start.time": "開始時間",
29
+ "action-bar-end.time": "結束時間"
30
+ };
@@ -0,0 +1 @@
1
+ export declare const getCurrentLocale: () => string;
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/utils/index.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ getCurrentLocale: () => getCurrentLocale
23
+ });
24
+ module.exports = __toCommonJS(utils_exports);
25
+ var getCurrentLocale = () => {
26
+ let locale = "en-US";
27
+ locale = localStorage.getItem("umi_locale");
28
+ return locale;
29
+ };
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ getCurrentLocale
33
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/date-picker",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "sideEffects": [
5
5
  "*.less"
6
6
  ],
@@ -13,6 +13,7 @@
13
13
  "dayjs": "^1.11.9"
14
14
  },
15
15
  "dependencies": {
16
+ "@pisell/utils": "workspaces*",
16
17
  "@mui/x-date-pickers": "6.10.1",
17
18
  "@emotion/react": "^11.11.1",
18
19
  "@emotion/styled": "^11.11.0",