@pisell/date-picker 1.0.75 → 1.0.76

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 (75) hide show
  1. package/es/ActionBar/index.js +19 -28
  2. package/es/ActionBar/index.less +2 -1
  3. package/es/CustomCalendarHeader/index.js +53 -0
  4. package/es/Dialog/index.js +22 -0
  5. package/es/Drawer/index.js +35 -0
  6. package/es/Drawer/index.less +40 -0
  7. package/es/PisellDateRangePicker/LocaleContext.d.ts +2 -0
  8. package/es/PisellDateRangePicker/index.js +109 -39
  9. package/es/PisellDateRangePicker/index.less +56 -0
  10. package/es/Toolbar/index.js +122 -0
  11. package/es/Toolbar/index.less +32 -0
  12. package/es/browserSelect/chevron-down.png +0 -0
  13. package/es/browserSelect/index.js +36 -0
  14. package/es/browserSelect/index.less +18 -0
  15. package/es/constants.js +109 -0
  16. package/es/hooks/useDocumentVisibility.js +27 -0
  17. package/es/hooks/useNextDay.js +15 -0
  18. package/es/hooks/useUpdateEffect.js +11 -0
  19. package/es/icon/ChevronLeft.js +23 -0
  20. package/es/icon/ChevronLeftDouble.js +23 -0
  21. package/es/icon/ChevronRight.js +23 -0
  22. package/es/icon/ChevronRightDouble.js +23 -0
  23. package/es/index.js +1 -0
  24. package/es/internals/utils/date-fields-utils.d.ts +1 -1
  25. package/es/locales/en-US.js +18 -1
  26. package/es/locales/index.d.ts +2 -0
  27. package/es/locales/zh-CN.js +21 -4
  28. package/es/locales/zh-TW.js +18 -1
  29. package/es/utils/index.js +86 -3
  30. package/lib/ActionBar/index.js +30 -25
  31. package/lib/ActionBar/index.less +2 -1
  32. package/lib/CustomCalendarHeader/index.js +58 -0
  33. package/lib/Dialog/index.js +52 -0
  34. package/lib/Drawer/index.js +62 -0
  35. package/lib/Drawer/index.less +40 -0
  36. package/lib/PisellDateRangePicker/LocaleContext.d.ts +2 -0
  37. package/lib/PisellDateRangePicker/index.js +86 -32
  38. package/lib/PisellDateRangePicker/index.less +56 -0
  39. package/lib/Toolbar/index.js +139 -0
  40. package/lib/Toolbar/index.less +32 -0
  41. package/lib/browserSelect/chevron-down.png +0 -0
  42. package/lib/browserSelect/index.js +59 -0
  43. package/lib/browserSelect/index.less +18 -0
  44. package/lib/constants.js +147 -0
  45. package/lib/hooks/useDocumentVisibility.js +40 -0
  46. package/lib/hooks/useNextDay.js +49 -0
  47. package/lib/hooks/useUpdateEffect.js +35 -0
  48. package/lib/icon/ChevronLeft.js +60 -0
  49. package/lib/icon/ChevronLeftDouble.js +60 -0
  50. package/lib/icon/ChevronRight.js +60 -0
  51. package/lib/icon/ChevronRightDouble.js +60 -0
  52. package/lib/{PisellDateRangePicker → icon}/CloseCircle.js +1 -1
  53. package/lib/index.js +10 -1
  54. package/lib/internals/utils/date-fields-utils.d.ts +1 -1
  55. package/lib/locales/en-US.js +18 -1
  56. package/lib/locales/index.d.ts +2 -0
  57. package/lib/locales/zh-CN.js +18 -1
  58. package/lib/locales/zh-TW.js +18 -1
  59. package/lib/utils/index.js +58 -0
  60. package/package.json +1 -1
  61. package/es/ActionBar/index.d.ts +0 -18
  62. package/es/PisellDateRangePicker/CloseCircle.d.ts +0 -5
  63. package/es/Shortcuts/index.d.ts +0 -14
  64. package/es/locales/en-US.d.ts +0 -7
  65. package/es/locales/zh-CN.d.ts +0 -7
  66. package/es/locales/zh-TW.d.ts +0 -7
  67. package/es/utils/index.d.ts +0 -3
  68. package/lib/ActionBar/index.d.ts +0 -18
  69. package/lib/PisellDateRangePicker/CloseCircle.d.ts +0 -5
  70. package/lib/Shortcuts/index.d.ts +0 -14
  71. package/lib/locales/en-US.d.ts +0 -7
  72. package/lib/locales/zh-CN.d.ts +0 -7
  73. package/lib/locales/zh-TW.d.ts +0 -7
  74. package/lib/utils/index.d.ts +0 -3
  75. /package/es/{PisellDateRangePicker → icon}/CloseCircle.js +0 -0
@@ -0,0 +1,60 @@
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/icon/ChevronLeftDouble.tsx
30
+ var ChevronLeftDouble_exports = {};
31
+ __export(ChevronLeftDouble_exports, {
32
+ default: () => ChevronLeftDouble_default
33
+ });
34
+ module.exports = __toCommonJS(ChevronLeftDouble_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var ChevronLeftDouble = (props) => {
37
+ const { className, onClick } = props;
38
+ return /* @__PURE__ */ import_react.default.createElement("span", { className, onClick }, /* @__PURE__ */ import_react.default.createElement(
39
+ "svg",
40
+ {
41
+ className: "icon",
42
+ viewBox: "0 0 1024 1024",
43
+ version: "1.1",
44
+ xmlns: "http://www.w3.org/2000/svg",
45
+ "p-id": "35105",
46
+ width: "1em",
47
+ height: "1em"
48
+ },
49
+ /* @__PURE__ */ import_react.default.createElement(
50
+ "path",
51
+ {
52
+ "fill-rule": "evenodd",
53
+ "clip-rule": "evenodd",
54
+ d: "M11.7071 6.29289C12.0976 6.68342 12.0976 7.31658 11.7071 7.70711L7.41421 12L11.7071 16.2929C12.0976 16.6834 12.0976 17.3166 11.7071 17.7071C11.3166 18.0976 10.6834 18.0976 10.2929 17.7071L5.29289 12.7071C4.90237 12.3166 4.90237 11.6834 5.29289 11.2929L10.2929 6.29289C10.6834 5.90237 11.3166 5.90237 11.7071 6.29289ZM18.7071 6.29289C19.0976 6.68342 19.0976 7.31658 18.7071 7.70711L14.4142 12L18.7071 16.2929C19.0976 16.6834 19.0976 17.3166 18.7071 17.7071C18.3166 18.0976 17.6834 18.0976 17.2929 17.7071L12.2929 12.7071C11.9024 12.3166 11.9024 11.6834 12.2929 11.2929L17.2929 6.29289C17.6834 5.90237 18.3166 5.90237 18.7071 6.29289Z",
55
+ fill: "currentColor"
56
+ }
57
+ )
58
+ ));
59
+ };
60
+ var ChevronLeftDouble_default = ChevronLeftDouble;
@@ -0,0 +1,60 @@
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/icon/ChevronRight.tsx
30
+ var ChevronRight_exports = {};
31
+ __export(ChevronRight_exports, {
32
+ default: () => ChevronRight_default
33
+ });
34
+ module.exports = __toCommonJS(ChevronRight_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var ChevronRight = (props) => {
37
+ const { className, onClick } = props;
38
+ return /* @__PURE__ */ import_react.default.createElement("span", { className, onClick }, /* @__PURE__ */ import_react.default.createElement(
39
+ "svg",
40
+ {
41
+ className: "icon",
42
+ viewBox: "0 0 1024 1024",
43
+ version: "1.1",
44
+ xmlns: "http://www.w3.org/2000/svg",
45
+ "p-id": "35105",
46
+ width: "1em",
47
+ height: "1em"
48
+ },
49
+ /* @__PURE__ */ import_react.default.createElement(
50
+ "path",
51
+ {
52
+ "fill-rule": "evenodd",
53
+ "clip-rule": "evenodd",
54
+ d: "M8.29289 5.29289C8.68342 4.90237 9.31658 4.90237 9.70711 5.29289L15.7071 11.2929C16.0976 11.6834 16.0976 12.3166 15.7071 12.7071L9.70711 18.7071C9.31658 19.0976 8.68342 19.0976 8.29289 18.7071C7.90237 18.3166 7.90237 17.6834 8.29289 17.2929L13.5858 12L8.29289 6.70711C7.90237 6.31658 7.90237 5.68342 8.29289 5.29289Z",
55
+ fill: "currentColor"
56
+ }
57
+ )
58
+ ));
59
+ };
60
+ var ChevronRight_default = ChevronRight;
@@ -0,0 +1,60 @@
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/icon/ChevronRightDouble.tsx
30
+ var ChevronRightDouble_exports = {};
31
+ __export(ChevronRightDouble_exports, {
32
+ default: () => ChevronRightDouble_default
33
+ });
34
+ module.exports = __toCommonJS(ChevronRightDouble_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var ChevronRightDouble = (props) => {
37
+ const { className, onClick } = props;
38
+ return /* @__PURE__ */ import_react.default.createElement("span", { className, onClick }, /* @__PURE__ */ import_react.default.createElement(
39
+ "svg",
40
+ {
41
+ className: "icon",
42
+ viewBox: "0 0 1024 1024",
43
+ version: "1.1",
44
+ xmlns: "http://www.w3.org/2000/svg",
45
+ "p-id": "35105",
46
+ width: "1em",
47
+ height: "1em"
48
+ },
49
+ /* @__PURE__ */ import_react.default.createElement(
50
+ "path",
51
+ {
52
+ "fill-rule": "evenodd",
53
+ "clip-rule": "evenodd",
54
+ d: "M5.29289 6.29289C5.68342 5.90237 6.31658 5.90237 6.70711 6.29289L11.7071 11.2929C12.0976 11.6834 12.0976 12.3166 11.7071 12.7071L6.70711 17.7071C6.31658 18.0976 5.68342 18.0976 5.29289 17.7071C4.90237 17.3166 4.90237 16.6834 5.29289 16.2929L9.58579 12L5.29289 7.70711C4.90237 7.31658 4.90237 6.68342 5.29289 6.29289ZM12.2929 6.29289C12.6834 5.90237 13.3166 5.90237 13.7071 6.29289L18.7071 11.2929C19.0976 11.6834 19.0976 12.3166 18.7071 12.7071L13.7071 17.7071C13.3166 18.0976 12.6834 18.0976 12.2929 17.7071C11.9024 17.3166 11.9024 16.6834 12.2929 16.2929L16.5858 12L12.2929 7.70711C11.9024 7.31658 11.9024 6.68342 12.2929 6.29289Z",
55
+ fill: "currentColor"
56
+ }
57
+ )
58
+ ));
59
+ };
60
+ var ChevronRightDouble_default = ChevronRightDouble;
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // src/PisellDateRangePicker/CloseCircle.tsx
29
+ // src/icon/CloseCircle.tsx
30
30
  var CloseCircle_exports = {};
31
31
  __export(CloseCircle_exports, {
32
32
  default: () => CloseCircle_default
package/lib/index.js CHANGED
@@ -32,7 +32,11 @@ var src_exports = {};
32
32
  __export(src_exports, {
33
33
  LocaleContext: () => import_LocaleContext.LocaleContext,
34
34
  LocaleProvider: () => import_LocaleContext.LocaleProvider,
35
- RangePicker: () => import_PisellDateRangePicker.default
35
+ RangePicker: () => import_PisellDateRangePicker.default,
36
+ formatPresets: () => import_utils.formatPresets,
37
+ getDatePickerValueByShortcut: () => import_utils.getDatePickerValueByShortcut,
38
+ getPresetLabel: () => import_utils.getPresetLabel,
39
+ getShortcutValue: () => import_utils.getShortcutValue
36
40
  });
37
41
  module.exports = __toCommonJS(src_exports);
38
42
  var import_PisellDateRangePicker = __toESM(require("./PisellDateRangePicker"));
@@ -51,12 +55,17 @@ __reExport(src_exports, require("./DesktopDateRangePicker"), module.exports);
51
55
  __reExport(src_exports, require("./MobileDateRangePicker"), module.exports);
52
56
  __reExport(src_exports, require("./StaticDateRangePicker"), module.exports);
53
57
  __reExport(src_exports, require("./dateRangeViewRenderers"), module.exports);
58
+ var import_utils = require("./utils/index");
54
59
  __reExport(src_exports, require("./models"), module.exports);
55
60
  // Annotate the CommonJS export names for ESM import in node:
56
61
  0 && (module.exports = {
57
62
  LocaleContext,
58
63
  LocaleProvider,
59
64
  RangePicker,
65
+ formatPresets,
66
+ getDatePickerValueByShortcut,
67
+ getPresetLabel,
68
+ getShortcutValue,
60
69
  ...require("@mui/x-date-pickers"),
61
70
  ...require("@mui/material/styles"),
62
71
  ...require("./DateRangePickerDay"),
@@ -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;
@@ -26,5 +26,22 @@ var en_US_default = {
26
26
  "action-bar-cancel": "Cancel",
27
27
  "action-bar-apply": "Apply",
28
28
  "action-bar-start.time": "Start time",
29
- "action-bar-end.time": "End time"
29
+ "action-bar-end.time": "End time",
30
+ "toolbar-date-range-shortcut-custom": "Custom",
31
+ "toolbar-date-range-shortcut-date-range": "Date range",
32
+ "toolbar-date-range-shortcut-starting": "Starting",
33
+ "toolbar-date-range-shortcut-ending": "Ending",
34
+ "toolbar-date-range-shortcut-today": "Today",
35
+ "toolbar-date-range-shortcut-yesterday": "Yesterday",
36
+ "toolbar-date-range-shortcut-tomorrow": "Tomorrow",
37
+ "toolbar-date-range-shortcut-last-3-days": "Last 3 days",
38
+ "toolbar-date-range-shortcut-last-7-days": "Last 7 days",
39
+ "toolbar-date-range-shortcut-last-30-days": "Last 30 days",
40
+ "toolbar-date-range-shortcut-last-90-days": "Last 90 days",
41
+ "toolbar-date-range-shortcut-last-180-days": "Last 180 days",
42
+ "toolbar-date-range-shortcut-next-3-days": "Next 3 days",
43
+ "toolbar-date-range-shortcut-next-7-days": "Next 7 days",
44
+ "toolbar-date-range-shortcut-next-30-days": "Next 30 days",
45
+ "toolbar-date-range-shortcut-next-90-days": "Next 90 days",
46
+ "toolbar-date-range-shortcut-next-180-days": "Next 180 days"
30
47
  };
@@ -0,0 +1,2 @@
1
+ export declare const pLocaleMap: Record<string, any>;
2
+ export declare const getText: (id: string, pLocale?: string) => any;
@@ -26,5 +26,22 @@ var zh_CN_default = {
26
26
  "action-bar-cancel": "取消",
27
27
  "action-bar-apply": "确定",
28
28
  "action-bar-start.time": "开始时间",
29
- "action-bar-end.time": "结束时间"
29
+ "action-bar-end.time": "结束时间",
30
+ "toolbar-date-range-shortcut-date-range": "日期范围",
31
+ "toolbar-date-range-shortcut-starting": "开始",
32
+ "toolbar-date-range-shortcut-ending": "结束",
33
+ "toolbar-date-range-shortcut-custom": "自定义",
34
+ "toolbar-date-range-shortcut-today": "今天",
35
+ "toolbar-date-range-shortcut-yesterday": "昨天",
36
+ "toolbar-date-range-shortcut-tomorrow": "明天",
37
+ "toolbar-date-range-shortcut-last-3-days": "过去3天",
38
+ "toolbar-date-range-shortcut-last-7-days": "过去7天",
39
+ "toolbar-date-range-shortcut-last-30-days": "过去30天",
40
+ "toolbar-date-range-shortcut-last-90-days": "过去90天",
41
+ "toolbar-date-range-shortcut-last-180-days": "过去180天",
42
+ "toolbar-date-range-shortcut-next-3-days": "未来3天",
43
+ "toolbar-date-range-shortcut-next-7-days": "未来7天",
44
+ "toolbar-date-range-shortcut-next-30-days": "未来30天",
45
+ "toolbar-date-range-shortcut-next-90-days": "未来90天",
46
+ "toolbar-date-range-shortcut-next-180-days": "未来180天"
30
47
  };
@@ -26,5 +26,22 @@ var zh_TW_default = {
26
26
  "action-bar-cancel": "取消",
27
27
  "action-bar-apply": "確定",
28
28
  "action-bar-start.time": "開始時間",
29
- "action-bar-end.time": "結束時間"
29
+ "action-bar-end.time": "結束時間",
30
+ "toolbar-date-range-shortcut-custom": "自定義",
31
+ "toolbar-date-range-shortcut-date-range": "日期範圍",
32
+ "toolbar-date-range-shortcut-starting": "開始",
33
+ "toolbar-date-range-shortcut-ending": "結束",
34
+ "toolbar-date-range-shortcut-today": "今天",
35
+ "toolbar-date-range-shortcut-yesterday": "昨天",
36
+ "toolbar-date-range-shortcut-tomorrow": "明天",
37
+ "toolbar-date-range-shortcut-last-3-days": "過去3天",
38
+ "toolbar-date-range-shortcut-last-7-days": "過去7天",
39
+ "toolbar-date-range-shortcut-last-30-days": "過去30天",
40
+ "toolbar-date-range-shortcut-last-90-days": "過去90天",
41
+ "toolbar-date-range-shortcut-last-180-days": "過去180天",
42
+ "toolbar-date-range-shortcut-next-3-days": "未來3天",
43
+ "toolbar-date-range-shortcut-next-7-days": "未來7天",
44
+ "toolbar-date-range-shortcut-next-30-days": "未來30天",
45
+ "toolbar-date-range-shortcut-next-90-days": "未來90天",
46
+ "toolbar-date-range-shortcut-next-180-days": "未來180天"
30
47
  };
@@ -19,12 +19,17 @@ 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
+ formatPresets: () => formatPresets,
22
23
  getCurrentLocale: () => getCurrentLocale,
24
+ getDatePickerValueByShortcut: () => getDatePickerValueByShortcut,
25
+ getPresetLabel: () => getPresetLabel,
26
+ getShortcutValue: () => getShortcutValue,
23
27
  isBrowser: () => isBrowser,
24
28
  isMobile: () => isMobile
25
29
  });
26
30
  module.exports = __toCommonJS(utils_exports);
27
31
  var import_utils = require("@pisell/utils");
32
+ var import_constants = require("../constants");
28
33
  var getCurrentLocale = () => {
29
34
  let locale = localStorage.getItem("umi_locale") || "en-US";
30
35
  return locale;
@@ -36,9 +41,62 @@ var isMobile = () => {
36
41
  }
37
42
  return (0, import_utils.isMobile)();
38
43
  };
44
+ var formatPresets = (presets) => {
45
+ return presets.map((item) => {
46
+ var _a, _b, _c;
47
+ if ((0, import_utils.isString)(item.value)) {
48
+ let getValue2;
49
+ if ((0, import_utils.isFunction)(item.getValue)) {
50
+ getValue2 = item.getValue;
51
+ } else if (import_constants.presetValueArr.includes(item.value)) {
52
+ getValue2 = import_constants.presetDetailMap[item.value].getValue;
53
+ } else {
54
+ getValue2 = () => item.value;
55
+ }
56
+ return {
57
+ ...item,
58
+ label: item.label || ((_c = (_b = (_a = import_constants.presetDetailMap) == null ? void 0 : _a[item.value]) == null ? void 0 : _b.label) == null ? void 0 : _c.call(_b)),
59
+ getValue: getValue2
60
+ };
61
+ }
62
+ const getValue = () => {
63
+ if ((0, import_utils.isFunction)(item.getValue)) {
64
+ return item.getValue();
65
+ }
66
+ return item == null ? void 0 : item.value;
67
+ };
68
+ return {
69
+ label: item.label,
70
+ getValue
71
+ };
72
+ });
73
+ };
74
+ var getPresetLabel = (currentShortcut, presets) => {
75
+ var _a, _b, _c;
76
+ const label = (_c = (_b = (_a = import_constants.presetDetailMap) == null ? void 0 : _a[currentShortcut]) == null ? void 0 : _b.label) == null ? void 0 : _c.call(_b);
77
+ if (label) {
78
+ return label;
79
+ }
80
+ const detail = presets.find(
81
+ (item) => item.label === currentShortcut || item.value === currentShortcut
82
+ );
83
+ return detail == null ? void 0 : detail.label;
84
+ };
85
+ var getShortcutValue = (value, preset) => {
86
+ var _a;
87
+ return (_a = preset.find((item) => item.value === value || item.label === value)) == null ? void 0 : _a.getValue();
88
+ };
89
+ var getDatePickerValueByShortcut = (value, preset) => {
90
+ const p = formatPresets(preset);
91
+ return getShortcutValue(value, p);
92
+ };
39
93
  // Annotate the CommonJS export names for ESM import in node:
40
94
  0 && (module.exports = {
95
+ formatPresets,
41
96
  getCurrentLocale,
97
+ getDatePickerValueByShortcut,
98
+ getPresetLabel,
99
+ getShortcutValue,
42
100
  isBrowser,
43
101
  isMobile
44
102
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/date-picker",
3
- "version": "1.0.75",
3
+ "version": "1.0.76",
4
4
  "sideEffects": [
5
5
  "*.less"
6
6
  ],
@@ -1,18 +0,0 @@
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;
@@ -1,5 +0,0 @@
1
- declare const CloseCircle: (props: {
2
- className: string;
3
- onClick: any;
4
- }) => JSX.Element;
5
- export default CloseCircle;
@@ -1,14 +0,0 @@
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];
7
- };
8
- interface ShortcutsProps {
9
- items: PresetType[];
10
- onChange: (day: [Dayjs, Dayjs], changeImportance?: "accept" | "set") => void;
11
- changeImportance?: "accept" | "set";
12
- }
13
- declare const Shortcuts: (props: ShortcutsProps) => JSX.Element | null;
14
- export default Shortcuts;
@@ -1,7 +0,0 @@
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;
@@ -1,7 +0,0 @@
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;
@@ -1,7 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- export declare const getCurrentLocale: () => string;
2
- export declare const isBrowser: boolean;
3
- export declare const isMobile: () => boolean;
@@ -1,18 +0,0 @@
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;
@@ -1,5 +0,0 @@
1
- declare const CloseCircle: (props: {
2
- className: string;
3
- onClick: any;
4
- }) => JSX.Element;
5
- export default CloseCircle;
@@ -1,14 +0,0 @@
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];
7
- };
8
- interface ShortcutsProps {
9
- items: PresetType[];
10
- onChange: (day: [Dayjs, Dayjs], changeImportance?: "accept" | "set") => void;
11
- changeImportance?: "accept" | "set";
12
- }
13
- declare const Shortcuts: (props: ShortcutsProps) => JSX.Element | null;
14
- export default Shortcuts;
@@ -1,7 +0,0 @@
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;
@@ -1,7 +0,0 @@
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;
@@ -1,7 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- export declare const getCurrentLocale: () => string;
2
- export declare const isBrowser: boolean;
3
- export declare const isMobile: () => boolean;