@pisell/date-picker 1.0.75 → 1.0.77

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 (101) hide show
  1. package/es/ActionBar/index.js +19 -28
  2. package/es/ActionBar/index.less +2 -1
  3. package/es/CustomCalendarHeader/index.d.ts +2 -0
  4. package/es/CustomCalendarHeader/index.js +53 -0
  5. package/es/Dialog/index.d.ts +2 -0
  6. package/es/Dialog/index.js +22 -0
  7. package/es/Drawer/index.d.ts +11 -0
  8. package/es/Drawer/index.js +35 -0
  9. package/es/Drawer/index.less +40 -0
  10. package/es/PisellDateRangePicker/LocaleContext.d.ts +2 -0
  11. package/es/PisellDateRangePicker/index.d.ts +81 -0
  12. package/es/PisellDateRangePicker/index.js +112 -41
  13. package/es/PisellDateRangePicker/index.less +56 -0
  14. package/es/Shortcuts/index.d.ts +4 -3
  15. package/es/Toolbar/index.d.ts +3 -0
  16. package/es/Toolbar/index.js +122 -0
  17. package/es/Toolbar/index.less +32 -0
  18. package/es/browserSelect/chevron-down.png +0 -0
  19. package/es/browserSelect/index.d.ts +15 -0
  20. package/es/browserSelect/index.js +36 -0
  21. package/es/browserSelect/index.less +18 -0
  22. package/es/constants.d.ts +58 -0
  23. package/es/constants.js +128 -0
  24. package/es/hooks/useDocumentVisibility.d.ts +2 -0
  25. package/es/hooks/useDocumentVisibility.js +27 -0
  26. package/es/hooks/useNextDay.d.ts +2 -0
  27. package/es/hooks/useNextDay.js +15 -0
  28. package/es/hooks/useUpdateEffect.d.ts +2 -0
  29. package/es/hooks/useUpdateEffect.js +11 -0
  30. package/es/icon/ChevronLeft.d.ts +5 -0
  31. package/es/icon/ChevronLeft.js +23 -0
  32. package/es/icon/ChevronLeftDouble.d.ts +5 -0
  33. package/es/icon/ChevronLeftDouble.js +23 -0
  34. package/es/icon/ChevronRight.d.ts +5 -0
  35. package/es/icon/ChevronRight.js +23 -0
  36. package/es/icon/ChevronRightDouble.d.ts +5 -0
  37. package/es/icon/ChevronRightDouble.js +23 -0
  38. package/es/index.d.ts +23 -0
  39. package/es/index.js +1 -0
  40. package/es/locales/en-US.d.ts +17 -0
  41. package/es/locales/en-US.js +18 -1
  42. package/es/locales/index.d.ts +2 -0
  43. package/es/locales/zh-CN.d.ts +21 -4
  44. package/es/locales/zh-CN.js +21 -4
  45. package/es/locales/zh-TW.d.ts +17 -0
  46. package/es/locales/zh-TW.js +18 -1
  47. package/es/utils/index.d.ts +32 -0
  48. package/es/utils/index.js +86 -3
  49. package/lib/ActionBar/index.js +30 -25
  50. package/lib/ActionBar/index.less +2 -1
  51. package/lib/CustomCalendarHeader/index.d.ts +2 -0
  52. package/lib/CustomCalendarHeader/index.js +58 -0
  53. package/lib/Dialog/index.d.ts +2 -0
  54. package/lib/Dialog/index.js +52 -0
  55. package/lib/Drawer/index.d.ts +11 -0
  56. package/lib/Drawer/index.js +62 -0
  57. package/lib/Drawer/index.less +40 -0
  58. package/lib/PisellDateRangePicker/LocaleContext.d.ts +2 -0
  59. package/lib/PisellDateRangePicker/index.d.ts +81 -0
  60. package/lib/PisellDateRangePicker/index.js +89 -33
  61. package/lib/PisellDateRangePicker/index.less +56 -0
  62. package/lib/Shortcuts/index.d.ts +4 -3
  63. package/lib/Toolbar/index.d.ts +3 -0
  64. package/lib/Toolbar/index.js +139 -0
  65. package/lib/Toolbar/index.less +32 -0
  66. package/lib/browserSelect/chevron-down.png +0 -0
  67. package/lib/browserSelect/index.d.ts +15 -0
  68. package/lib/browserSelect/index.js +59 -0
  69. package/lib/browserSelect/index.less +18 -0
  70. package/lib/constants.d.ts +58 -0
  71. package/lib/constants.js +178 -0
  72. package/lib/hooks/useDocumentVisibility.d.ts +2 -0
  73. package/lib/hooks/useDocumentVisibility.js +40 -0
  74. package/lib/hooks/useNextDay.d.ts +2 -0
  75. package/lib/hooks/useNextDay.js +49 -0
  76. package/lib/hooks/useUpdateEffect.d.ts +2 -0
  77. package/lib/hooks/useUpdateEffect.js +35 -0
  78. package/lib/icon/ChevronLeft.d.ts +5 -0
  79. package/lib/icon/ChevronLeft.js +60 -0
  80. package/lib/icon/ChevronLeftDouble.d.ts +5 -0
  81. package/lib/icon/ChevronLeftDouble.js +60 -0
  82. package/lib/icon/ChevronRight.d.ts +5 -0
  83. package/lib/icon/ChevronRight.js +60 -0
  84. package/lib/icon/ChevronRightDouble.d.ts +5 -0
  85. package/lib/icon/ChevronRightDouble.js +60 -0
  86. package/lib/{PisellDateRangePicker → icon}/CloseCircle.js +1 -1
  87. package/lib/index.d.ts +23 -0
  88. package/lib/index.js +10 -1
  89. package/lib/locales/en-US.d.ts +17 -0
  90. package/lib/locales/en-US.js +18 -1
  91. package/lib/locales/index.d.ts +2 -0
  92. package/lib/locales/zh-CN.d.ts +21 -4
  93. package/lib/locales/zh-CN.js +18 -1
  94. package/lib/locales/zh-TW.d.ts +17 -0
  95. package/lib/locales/zh-TW.js +18 -1
  96. package/lib/utils/index.d.ts +32 -0
  97. package/lib/utils/index.js +58 -0
  98. package/package.json +1 -1
  99. /package/es/{PisellDateRangePicker → icon}/CloseCircle.d.ts +0 -0
  100. /package/es/{PisellDateRangePicker → icon}/CloseCircle.js +0 -0
  101. /package/lib/{PisellDateRangePicker → icon}/CloseCircle.d.ts +0 -0
@@ -0,0 +1,62 @@
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/Drawer/index.tsx
30
+ var Drawer_exports = {};
31
+ __export(Drawer_exports, {
32
+ default: () => Drawer_default
33
+ });
34
+ module.exports = __toCommonJS(Drawer_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_classnames = __toESM(require("classnames"));
37
+ var import_index = require("./index.less");
38
+ var Drawer = (props) => {
39
+ const { open, className, onClose, children, height = 375 } = props;
40
+ if (!open) {
41
+ return null;
42
+ }
43
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, open && /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-drawer-overlay", onClick: onClose }), /* @__PURE__ */ import_react.default.createElement(
44
+ "div",
45
+ {
46
+ className: (0, import_classnames.default)("date-picker-drawer", className, {
47
+ open
48
+ }),
49
+ onClick: () => {
50
+ }
51
+ },
52
+ /* @__PURE__ */ import_react.default.createElement(
53
+ "div",
54
+ {
55
+ className: "date-picker-drawer-content",
56
+ style: { height }
57
+ },
58
+ children
59
+ )
60
+ ));
61
+ };
62
+ var Drawer_default = Drawer;
@@ -0,0 +1,40 @@
1
+ .date-picker-drawer {
2
+ position: fixed;
3
+ bottom: 0;
4
+ left: 0;
5
+ width: 100%;
6
+ background-color: white;
7
+ box-shadow: 0px -2px 10px rgba(0, 0, 0, 0.1);
8
+ transform: translateY(100%);
9
+ transition: transform 0.3s ease-out;
10
+ z-index: 1000;
11
+ border-radius: 8px 8px 0 0;
12
+ }
13
+
14
+ .date-picker-drawer-content {
15
+ //transform: translateY(100%);
16
+ //transition: transform 0.3s ease-out;
17
+ //position: absolute;
18
+ //padding: 20px;
19
+ //bottom: 0;
20
+ //width: 100vw;
21
+ //background-color: #fff;
22
+ //z-index: 1000;
23
+ //box-shadow: 0px -2px 10px rgba(0, 0, 0, 0.1);
24
+ //border-radius: 8px 8px 0px 0px;
25
+ //height: 650px;
26
+ }
27
+
28
+ .date-picker-drawer.open {
29
+ transform: translateY(0);
30
+ }
31
+
32
+ .date-picker-drawer-overlay {
33
+ position: fixed;
34
+ top: 0;
35
+ left: 0;
36
+ width: 100%;
37
+ height: 100%;
38
+ background-color: rgba(0, 0, 0, 0.5);
39
+ z-index: 999;
40
+ }
@@ -0,0 +1,2 @@
1
+ export declare const LocaleContext: any;
2
+ export declare const LocaleProvider: any;
@@ -0,0 +1,81 @@
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
+ }
80
+ declare const PisellDateRangePicker: (props: PisellDateRangePickerProps) => JSX.Element;
81
+ export default PisellDateRangePicker;
@@ -40,7 +40,7 @@ var import_SingleInputDateRangeField = require("../SingleInputDateRangeField");
40
40
  var import_classnames = __toESM(require("classnames"));
41
41
  var import_utils = require("@pisell/utils");
42
42
  var import_useCssVariables = __toESM(require("./useCssVariables"));
43
- var import_CloseCircle = __toESM(require("./CloseCircle"));
43
+ var import_CloseCircle = __toESM(require("../icon/CloseCircle"));
44
44
  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");
@@ -48,7 +48,14 @@ var import_index = require("./index.less");
48
48
  var import_utils2 = require("../utils");
49
49
  var import_LocaleContext = require("./LocaleContext");
50
50
  var import_locales = require("../locales");
51
- var transDayjsArr = (dayjsArr, defaultValue) => {
51
+ var import_Dialog = __toESM(require("../Dialog"));
52
+ var import_Toolbar = __toESM(require("../Toolbar"));
53
+ var import_useNextDay = __toESM(require("../hooks/useNextDay"));
54
+ var import_constants = require("../constants");
55
+ var transDayjsArr = (dayjsArr, defaultValue, _presets) => {
56
+ if ((0, import_utils.isString)(dayjsArr)) {
57
+ return (0, import_utils2.getShortcutValue)(dayjsArr, _presets);
58
+ }
52
59
  let newArr = dayjsArr || defaultValue || [null, null];
53
60
  if ((dayjsArr == null ? void 0 : dayjsArr.length) === 0) {
54
61
  newArr = defaultValue || [null, null];
@@ -61,7 +68,7 @@ var PisellDateRangePicker = (props) => {
61
68
  const {
62
69
  onChange: propsOnChange,
63
70
  value: propsValue,
64
- presets = [],
71
+ presets,
65
72
  className,
66
73
  showTime,
67
74
  placeholder,
@@ -88,19 +95,41 @@ var PisellDateRangePicker = (props) => {
88
95
  allowClear,
89
96
  disablePortal,
90
97
  placement = "auto",
91
- inputReadOnly
98
+ inputReadOnly = true,
99
+ returnShortcutString = false
92
100
  } = props;
93
101
  const [open, setOpen] = (0, import_react.useState)(propsOpen ?? false);
94
102
  const { locale } = (0, import_react.useContext)(import_LocaleContext.LocaleContext) || {};
103
+ const [currentShortcut, setCurrentShortcut] = (0, import_react.useState)("");
104
+ const lastConfirmShortcut = (0, import_react.useRef)((0, import_utils.isString)(propsValue) ? propsValue : null);
95
105
  (0, import_react.useEffect)(() => {
96
106
  (0, import_utils.isBoolean)(propsOpen) && setOpen(propsOpen);
97
107
  }, [propsOpen]);
108
+ const _presets = (0, import_react.useMemo)(() => {
109
+ return (0, import_utils2.formatPresets)(presets || import_constants.defaultPresets);
110
+ }, [presets]);
98
111
  const [_value, setValue] = (0, import_react.useState)(
99
- () => transDayjsArr(propsValue, defaultValue)
112
+ () => transDayjsArr(propsValue, defaultValue, _presets)
100
113
  );
101
114
  (0, import_react.useEffect)(() => {
102
- setValue(transDayjsArr(propsValue, defaultValue));
115
+ setValue(transDayjsArr(propsValue, defaultValue, _presets));
116
+ if ((0, import_utils.isString)(propsValue)) {
117
+ setCurrentShortcut(propsValue);
118
+ }
103
119
  }, [propsValue]);
120
+ const getVal = () => {
121
+ let val = _value;
122
+ if (returnShortcutString) {
123
+ val = currentShortcut;
124
+ } else if (currentShortcut) {
125
+ val = (0, import_utils2.getShortcutValue)(currentShortcut, _presets);
126
+ }
127
+ return val;
128
+ };
129
+ (0, import_useNextDay.default)(() => {
130
+ setValue(getVal());
131
+ setTimeout(handleOk);
132
+ });
104
133
  const handleOpen = () => {
105
134
  setOpen(true);
106
135
  onOpen == null ? void 0 : onOpen();
@@ -108,32 +137,24 @@ var PisellDateRangePicker = (props) => {
108
137
  const handleClose = () => {
109
138
  setOpen(false);
110
139
  onClose == null ? void 0 : onClose();
111
- onDateChange == null ? void 0 : onDateChange(transDayjsArr(propsValue, defaultValue));
112
- setValue(transDayjsArr(propsValue, defaultValue));
140
+ const v = transDayjsArr(propsValue, defaultValue, _presets);
141
+ onDateChange == null ? void 0 : onDateChange(v);
142
+ setValue(v);
143
+ setCurrentShortcut(lastConfirmShortcut.current);
113
144
  };
114
145
  const handleOk = () => {
115
146
  setOpen(false);
116
147
  onClose == null ? void 0 : onClose();
117
- propsOnChange == null ? void 0 : propsOnChange(_value);
148
+ propsOnChange == null ? void 0 : propsOnChange(getVal());
149
+ lastConfirmShortcut.current = currentShortcut;
118
150
  };
119
- const _presets = (0, import_react.useMemo)(() => {
120
- if ((0, import_utils2.isMobile)())
121
- return [];
122
- return presets.map((item) => {
123
- const getValue = () => {
124
- if (typeof item.getValue === "function") {
125
- return item.getValue();
126
- }
127
- return item == null ? void 0 : item.value;
128
- };
129
- return {
130
- label: item.label,
131
- getValue
132
- };
133
- });
134
- }, [presets]);
135
- const handleChange = (val, type) => {
151
+ const handleChange = (val, type, shortcutValue) => {
136
152
  let newVal = val;
153
+ if ((0, import_utils.isString)(shortcutValue) && type === "shortcuts") {
154
+ setCurrentShortcut(shortcutValue);
155
+ } else {
156
+ setCurrentShortcut(null);
157
+ }
137
158
  if ((0, import_utils.isArr)(showTime) && type !== "time") {
138
159
  newVal = newVal.map((item, index) => {
139
160
  var _a, _b, _c, _d, _e, _f, _g;
@@ -143,16 +164,22 @@ var PisellDateRangePicker = (props) => {
143
164
  return item || null;
144
165
  });
145
166
  }
167
+ if (!clearEndOnSelection) {
168
+ if (newVal[0] && !newVal[1]) {
169
+ newVal[1] = newVal[0];
170
+ } else if (newVal[1] && !newVal[0]) {
171
+ newVal[0] = newVal[1];
172
+ }
173
+ }
146
174
  if (clearEndOnSelection && type !== "set" && _value.filter(Boolean).length === 2) {
147
175
  newVal = [newVal[0], null];
148
176
  }
149
177
  onDateChange == null ? void 0 : onDateChange(newVal);
150
178
  setValue(newVal);
151
179
  };
152
- const hasPreset = (_presets == null ? void 0 : _presets.length) > 0;
153
180
  (0, import_useCssVariables.default)({
154
181
  variables: {
155
- "--pisell-date-range-picker-popup-width": `${hasPreset ? popupWidth + 192 : popupWidth}px`
182
+ "--pisell-date-range-picker-popup-width": `${popupWidth}px`
156
183
  },
157
184
  dom: document.body
158
185
  });
@@ -162,6 +189,8 @@ var PisellDateRangePicker = (props) => {
162
189
  setOpen(false);
163
190
  onClose == null ? void 0 : onClose();
164
191
  propsOnChange == null ? void 0 : propsOnChange([null, null]);
192
+ setCurrentShortcut(null);
193
+ lastConfirmShortcut.current = null;
165
194
  };
166
195
  const endAdornment = (0, import_react.useMemo)(() => {
167
196
  if (!allowClear) {
@@ -196,6 +225,19 @@ var PisellDateRangePicker = (props) => {
196
225
  }
197
226
  return localeValue === "en" || localeValue === "en-US" ? "DD/MM/YYYY" : "YYYY/MM/DD";
198
227
  }, [propsFormat, locale]);
228
+ const inputPropsObj = (0, import_react.useMemo)(() => {
229
+ var _a;
230
+ let obj = {
231
+ endAdornment
232
+ };
233
+ if (((_a = _value == null ? void 0 : _value.every) == null ? void 0 : _a.call(_value, Boolean)) && (0, import_utils2.getPresetLabel)(currentShortcut, _presets)) {
234
+ obj = {
235
+ ...obj,
236
+ value: (0, import_utils2.getPresetLabel)(currentShortcut, _presets)
237
+ };
238
+ }
239
+ return obj;
240
+ }, [_value, endAdornment, returnShortcutString, currentShortcut]);
199
241
  return /* @__PURE__ */ import_react.default.createElement(
200
242
  "span",
201
243
  {
@@ -225,14 +267,18 @@ var PisellDateRangePicker = (props) => {
225
267
  slots: {
226
268
  actionBar: import_ActionBar.default,
227
269
  shortcuts: import_Shortcuts.default,
228
- field: import_SingleInputDateRangeField.SingleInputDateRangeField
270
+ field: import_SingleInputDateRangeField.SingleInputDateRangeField,
271
+ dialog: import_Dialog.default,
272
+ // calendarHeader: CustomCalendarHeader,
273
+ // calendarHeader: <div>12312</div> ,
274
+ toolbar: import_Toolbar.default
229
275
  },
230
276
  dayOfWeekFormatter: (day) => {
231
277
  return day;
232
278
  },
233
279
  slotProps: {
234
280
  shortcuts: {
235
- items: _presets,
281
+ items: [],
236
282
  changeImportance: "set",
237
283
  onChange: handleChange
238
284
  },
@@ -245,15 +291,25 @@ var PisellDateRangePicker = (props) => {
245
291
  okButtonProps,
246
292
  cancelButtonProps
247
293
  },
294
+ toolbar: {
295
+ hidden: false,
296
+ presetItems: _presets,
297
+ format,
298
+ locale,
299
+ onChange: handleChange,
300
+ currentShortcut,
301
+ setCurrentShortcut
302
+ },
303
+ layout: {
304
+ orientation: "portrait"
305
+ },
248
306
  field: {
249
307
  value: _value,
250
308
  size: "small",
251
309
  fullWidth: true,
252
310
  // variant: "standard",
253
311
  // hiddenLabel: true,
254
- InputProps: {
255
- endAdornment
256
- },
312
+ InputProps: inputPropsObj,
257
313
  ...readOnlyProps
258
314
  },
259
315
  popper: {
@@ -5,6 +5,7 @@
5
5
  //.MuiInputBase-input {
6
6
  // padding: 10px;
7
7
  //}
8
+
8
9
  label {
9
10
  font-size: 14px;
10
11
  }
@@ -42,11 +43,13 @@
42
43
  .MuiPickersPopper-root {
43
44
  .MuiPickersLayout-root {
44
45
  width: var(--pisell-date-range-picker-popup-width, 625px);
46
+ display: block;
45
47
  .MuiDateRangeCalendar-root {
46
48
  width: 100%;
47
49
  flex: 1;
48
50
  .MuiDateRangeCalendar-monthContainer {
49
51
  width: 50%;
52
+ border: none;
50
53
  .MuiDayCalendar-header {
51
54
  padding: 0 20px;
52
55
  .MuiDayCalendar-weekDayLabel {
@@ -95,3 +98,56 @@
95
98
  grid-column: 1 !important;
96
99
  grid-row: 1/3 !important;
97
100
  }
101
+
102
+ .date-picker-paid-drawer {
103
+ .MuiPickersLayout-root {
104
+ display: block;
105
+ }
106
+ }
107
+
108
+ .date-picker-custom-drawer {
109
+ .MuiPickersCalendarHeader-root {
110
+ padding-left: 35px;
111
+ padding-right: 22px;
112
+ }
113
+ .MuiPickersLayout-root {
114
+ display: block;
115
+ }
116
+ .MuiPickersLayout-toolbar {
117
+ display: none;
118
+ }
119
+ .MuiDayCalendar-header {
120
+ padding: 0 20px;
121
+ .MuiDayCalendar-weekDayLabel {
122
+ flex: 1;
123
+ max-width: 46px;
124
+ }
125
+ }
126
+ .MuiDayCalendar-slideTransition {
127
+ height: 315px;
128
+ .MuiDayCalendar-monthContainer {
129
+ padding: 0 20px;
130
+ }
131
+ }
132
+ .MuiDateRangeCalendar-monthContainer {
133
+ width: 100%;
134
+ .MuiDateRangePickerDay-root {
135
+ flex: 1;
136
+ max-width: 50px;
137
+ max-height: 50px;
138
+ .MuiDateRangePickerDay-day {
139
+ width: 100%;
140
+ height: auto;
141
+ &::before {
142
+ content: "";
143
+ display: block;
144
+ padding-top: 100%;
145
+ }
146
+ }
147
+ }
148
+ }
149
+ .MuiDrawer-paperAnchorBottom {
150
+ border-top-left-radius: 8px;
151
+ border-top-right-radius: 8px;
152
+ }
153
+ }
@@ -1,9 +1,10 @@
1
1
  import "./index.less";
2
2
  import { Dayjs } from "dayjs";
3
3
  export declare type PresetType = {
4
- label: string;
5
- getValue: () => [Dayjs, Dayjs];
6
- value: [Dayjs, Dayjs];
4
+ label?: string;
5
+ getValue?: () => [Dayjs, Dayjs];
6
+ value: [Dayjs, Dayjs] | "today" | "yesterday" | "last_3_days" | "last_7_days" | "last_30_days" | "last_90_days" | "last_180_days" | "tomorrow" | "next_3_days" | "next_7_days" | "next_30_days" | "next_90_days" | "next_180_days";
7
+ key?: string;
7
8
  };
8
9
  interface ShortcutsProps {
9
10
  items: PresetType[];
@@ -0,0 +1,3 @@
1
+ import "./index.less";
2
+ declare const Toolbar: (props: any) => JSX.Element;
3
+ export default Toolbar;
@@ -0,0 +1,139 @@
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/Toolbar/index.tsx
30
+ var Toolbar_exports = {};
31
+ __export(Toolbar_exports, {
32
+ default: () => Toolbar_default
33
+ });
34
+ module.exports = __toCommonJS(Toolbar_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_antd = require("antd");
37
+ var import_dayjs = __toESM(require("dayjs"));
38
+ var import_browserSelect = __toESM(require("../browserSelect"));
39
+ var import_locales = require("../locales");
40
+ var import_index = require("./index.less");
41
+ var isValidDate = (dateString, format) => {
42
+ const date = (0, import_dayjs.default)(dateString, format, true);
43
+ return date.isValid();
44
+ };
45
+ var Toolbar = (props) => {
46
+ const {
47
+ presetItems,
48
+ value = [],
49
+ locale,
50
+ onChange,
51
+ currentShortcut,
52
+ setCurrentShortcut
53
+ } = props;
54
+ const format = locale === "en" || locale === "en-US" ? "DD/MM/YYYY" : "YYYY/MM/DD";
55
+ const [startStr, setStartStr] = (0, import_react.useState)("");
56
+ const [endStr, setEndStr] = (0, import_react.useState)("");
57
+ (0, import_react.useEffect)(() => {
58
+ if (value == null ? void 0 : value[0]) {
59
+ setStartStr(value[0].format(format));
60
+ } else {
61
+ setStartStr("");
62
+ }
63
+ if (value == null ? void 0 : value[1]) {
64
+ setEndStr(value[1].format(format));
65
+ } else {
66
+ setEndStr("");
67
+ }
68
+ }, [value]);
69
+ const handleStartChange = (e) => {
70
+ var _a, _b;
71
+ const val = e.target.value;
72
+ setStartStr(val);
73
+ if (isValidDate(val, format)) {
74
+ const valDate = (0, import_dayjs.default)(val, format);
75
+ const newValue = [...value];
76
+ const start = newValue[0] || (0, import_dayjs.default)();
77
+ newValue[0] = ((_b = (_a = start == null ? void 0 : start.set("year", (valDate == null ? void 0 : valDate.get("year")) || 0)) == null ? void 0 : _a.set("month", (valDate == null ? void 0 : valDate.get("month")) || 0)) == null ? void 0 : _b.set("date", (valDate == null ? void 0 : valDate.get("date")) || 0)) || null;
78
+ onChange(newValue);
79
+ }
80
+ };
81
+ const handleEndChange = (e) => {
82
+ var _a, _b;
83
+ const val = e.target.value;
84
+ setEndStr(val);
85
+ if (isValidDate(val, format)) {
86
+ const valDate = (0, import_dayjs.default)(val, format);
87
+ const newValue = [...value];
88
+ const end = newValue[1] || (0, import_dayjs.default)();
89
+ newValue[1] = ((_b = (_a = end == null ? void 0 : end.set("year", (valDate == null ? void 0 : valDate.get("year")) || 0)) == null ? void 0 : _a.set("month", (valDate == null ? void 0 : valDate.get("month")) || 0)) == null ? void 0 : _b.set("date", (valDate == null ? void 0 : valDate.get("date")) || 0)) || null;
90
+ onChange(newValue);
91
+ }
92
+ };
93
+ const handleSelectChange = (e) => {
94
+ const val = e.target.value;
95
+ const detail = presetItems.find((item) => item.value === val || item.label === val);
96
+ if (!detail)
97
+ return;
98
+ const dateVal = detail.getValue();
99
+ onChange(dateVal, "shortcuts", val);
100
+ };
101
+ const customPresetItems = (0, import_react.useMemo)(() => {
102
+ if (!currentShortcut) {
103
+ return presetItems.concat([
104
+ {
105
+ label: (0, import_locales.getText)("toolbar-date-range-shortcut-custom"),
106
+ value: (0, import_locales.getText)("toolbar-date-range-shortcut-custom")
107
+ }
108
+ ]);
109
+ }
110
+ return presetItems;
111
+ }, [presetItems]);
112
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-toolbar" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-content-top" }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_locales.getText)("toolbar-date-range-shortcut-date-range")), /* @__PURE__ */ import_react.default.createElement(
113
+ import_browserSelect.default,
114
+ {
115
+ value: currentShortcut || (0, import_locales.getText)("toolbar-date-range-shortcut-custom"),
116
+ className: "date-picker-toolbar-select",
117
+ options: customPresetItems,
118
+ size: "large",
119
+ onChange: handleSelectChange
120
+ }
121
+ )), /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-content-bottom" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-toolbar-start-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_locales.getText)("toolbar-date-range-shortcut-starting")), /* @__PURE__ */ import_react.default.createElement(
122
+ import_antd.Input,
123
+ {
124
+ size: "large",
125
+ value: startStr,
126
+ onChange: handleStartChange,
127
+ placeholder: (0, import_dayjs.default)().format(format)
128
+ }
129
+ )), /* @__PURE__ */ import_react.default.createElement("div", { className: "date-picker-toolbar-end-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_locales.getText)("toolbar-date-range-shortcut-ending")), /* @__PURE__ */ import_react.default.createElement(
130
+ import_antd.Input,
131
+ {
132
+ size: "large",
133
+ value: endStr,
134
+ onChange: handleEndChange,
135
+ placeholder: (0, import_dayjs.default)().format(format)
136
+ }
137
+ ))));
138
+ };
139
+ var Toolbar_default = Toolbar;
@@ -0,0 +1,32 @@
1
+ .date-picker-toolbar {
2
+ padding: 20px 20px 0;
3
+ color: var(--Gray-700, #344054);
4
+ font-size: 14px;
5
+ font-style: normal;
6
+ font-weight: 600;
7
+ line-height: 20px; /* 142.857% */
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: 12px;
11
+ .date-picker-content-top {
12
+ display: flex;
13
+ flex-direction: column;
14
+ gap: 8px;
15
+ }
16
+ .date-picker-content-bottom {
17
+ display: flex;
18
+ gap: 16px;
19
+ }
20
+ .date-picker-toolbar-start-wrap {
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: 8px;
24
+ flex: 1;
25
+ }
26
+ .date-picker-toolbar-end-wrap {
27
+ display: flex;
28
+ flex-direction: column;
29
+ gap: 8px;
30
+ flex: 1;
31
+ }
32
+ }