@pisell/date-picker 1.0.83 → 1.0.84

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.
@@ -92,6 +92,9 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
92
92
  _useState4 = _slicedToArray(_useState3, 2),
93
93
  currentShortcut = _useState4[0],
94
94
  setCurrentShortcut = _useState4[1];
95
+
96
+ // const [rangePosition, setRangePosition] = useState('start');
97
+
95
98
  var lastConfirmShortcut = useRef(isString(propsValue) ? propsValue : null);
96
99
  useEffect(function () {
97
100
  isBoolean(propsOpen) && setOpen(propsOpen);
@@ -243,7 +246,12 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
243
246
  // defaultValue={defaultValue}
244
247
  // key={`${_value?.[0]?.valueOf()}-${_value?.[1]?.valueOf()}`}
245
248
  , {
246
- desktopModeMediaQuery: desktopModeMediaQuery,
249
+ desktopModeMediaQuery: desktopModeMediaQuery
250
+ // onSelectedSectionsChange={(val) => {
251
+ // console.log(val,'valval');
252
+ // }}
253
+ // selectedSections={null}
254
+ ,
247
255
  onMonthChange: onMonthChange,
248
256
  minDate: minDate,
249
257
  maxDate: maxDate,
@@ -263,8 +271,8 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
263
271
  // setRangePosition(rp)
264
272
  // // }
265
273
  // }}
266
- // // defaultRangePosition="start"
267
- // rangePosition={_value.every((item) => Boolean(item)) ? "start" : undefined}
274
+ // defaultRangePosition="start"
275
+ // rangePosition={rangePosition}
268
276
  ,
269
277
  defaultCalendarMonth: defaultCalendarMonth,
270
278
  shouldDisableDate: function shouldDisableDate(current, position) {
@@ -320,7 +328,26 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
320
328
  popper: {
321
329
  className: popupClassName,
322
330
  disablePortal: disablePortal,
323
- placement: placement
331
+ placement: placement,
332
+ modifiers: [{
333
+ name: 'flip',
334
+ enabled: true,
335
+ options: {
336
+ altBoundary: true,
337
+ rootBoundary: 'viewport',
338
+ padding: 8
339
+ }
340
+ }, {
341
+ name: 'preventOverflow',
342
+ enabled: true,
343
+ options: {
344
+ altAxis: true,
345
+ altBoundary: true,
346
+ tether: true,
347
+ rootBoundary: 'viewport',
348
+ padding: 8
349
+ }
350
+ }]
324
351
  },
325
352
  dialog: {
326
353
  disablePortal: disablePortal
@@ -60,6 +60,7 @@
60
60
  }
61
61
  .MuiPickersSlideTransition-root {
62
62
  min-width: 200px;
63
+ min-height: 235px;
63
64
  //min-height: auto;
64
65
  &::before {
65
66
  content: "";
@@ -35,14 +35,24 @@ var Toolbar = function Toolbar(props) {
35
35
  _useState4 = _slicedToArray(_useState3, 2),
36
36
  endStr = _useState4[0],
37
37
  setEndStr = _useState4[1];
38
+ var _useState5 = useState(false),
39
+ _useState6 = _slicedToArray(_useState5, 2),
40
+ startError = _useState6[0],
41
+ setStartError = _useState6[1];
42
+ var _useState7 = useState(false),
43
+ _useState8 = _slicedToArray(_useState7, 2),
44
+ endError = _useState8[0],
45
+ setEndError = _useState8[1];
38
46
  useEffect(function () {
39
47
  if (value !== null && value !== void 0 && value[0]) {
40
48
  setStartStr(value[0].format(format));
49
+ setStartError(false);
41
50
  } else {
42
51
  setStartStr('');
43
52
  }
44
53
  if (value !== null && value !== void 0 && value[1]) {
45
54
  setEndStr(value[1].format(format));
55
+ setEndError(false);
46
56
  } else {
47
57
  setEndStr('');
48
58
  }
@@ -52,11 +62,14 @@ var Toolbar = function Toolbar(props) {
52
62
  setStartStr(val);
53
63
  if (isValidDate(val, format)) {
54
64
  var _start$set, _start$set$set;
65
+ setStartError(false);
55
66
  var valDate = dayjs(val, format);
56
67
  var newValue = _toConsumableArray(value);
57
68
  var start = newValue[0] || dayjs();
58
69
  newValue[0] = (start === null || start === void 0 ? void 0 : (_start$set = start.set('year', (valDate === null || valDate === void 0 ? void 0 : valDate.get('year')) || 0)) === null || _start$set === void 0 ? void 0 : (_start$set$set = _start$set.set('month', (valDate === null || valDate === void 0 ? void 0 : valDate.get('month')) || 0)) === null || _start$set$set === void 0 ? void 0 : _start$set$set.set('date', (valDate === null || valDate === void 0 ? void 0 : valDate.get('date')) || 0)) || null;
59
70
  onChange(newValue);
71
+ } else {
72
+ setStartError(true);
60
73
  }
61
74
  };
62
75
  var handleEndChange = function handleEndChange(e) {
@@ -64,11 +77,14 @@ var Toolbar = function Toolbar(props) {
64
77
  setEndStr(val);
65
78
  if (isValidDate(val, format)) {
66
79
  var _end$set, _end$set$set;
80
+ setEndError(false);
67
81
  var valDate = dayjs(val, format);
68
82
  var newValue = _toConsumableArray(value);
69
83
  var end = newValue[1] || dayjs();
70
84
  newValue[1] = (end === null || end === void 0 ? void 0 : (_end$set = end.set('year', (valDate === null || valDate === void 0 ? void 0 : valDate.get('year')) || 0)) === null || _end$set === void 0 ? void 0 : (_end$set$set = _end$set.set('month', (valDate === null || valDate === void 0 ? void 0 : valDate.get('month')) || 0)) === null || _end$set$set === void 0 ? void 0 : _end$set$set.set('date', (valDate === null || valDate === void 0 ? void 0 : valDate.get('date')) || 0)) || null;
71
85
  onChange(newValue);
86
+ } else {
87
+ setEndError(true);
72
88
  }
73
89
  };
74
90
  var handleSelectChange = function handleSelectChange(e) {
@@ -106,17 +122,23 @@ var Toolbar = function Toolbar(props) {
106
122
  }, /*#__PURE__*/React.createElement("div", {
107
123
  className: "date-picker-toolbar-start-wrap"
108
124
  }, /*#__PURE__*/React.createElement("span", null, getText('toolbar-date-range-shortcut-starting', pLocaleMap[locale])), /*#__PURE__*/React.createElement(Input, {
125
+ status: startError ? "error" : "",
109
126
  size: "large",
110
127
  value: startStr,
111
128
  onChange: handleStartChange,
112
129
  placeholder: dayjs().format(format)
113
- })), /*#__PURE__*/React.createElement("div", {
130
+ }), startError && /*#__PURE__*/React.createElement("span", {
131
+ className: "date-picker-error"
132
+ }, getText('toolbar-date-range-invalid-start-date', pLocaleMap[locale]))), /*#__PURE__*/React.createElement("div", {
114
133
  className: "date-picker-toolbar-end-wrap"
115
134
  }, /*#__PURE__*/React.createElement("span", null, getText('toolbar-date-range-shortcut-ending', pLocaleMap[locale])), /*#__PURE__*/React.createElement(Input, {
135
+ status: endError ? "error" : "",
116
136
  size: "large",
117
137
  value: endStr,
118
138
  onChange: handleEndChange,
119
139
  placeholder: dayjs().format(format)
120
- }))));
140
+ }), endError && /*#__PURE__*/React.createElement("span", {
141
+ className: "date-picker-error"
142
+ }, getText('toolbar-date-range-invalid-end-date', pLocaleMap[locale])))));
121
143
  };
122
144
  export default Toolbar;
@@ -29,4 +29,7 @@
29
29
  gap: 8px;
30
30
  flex: 1;
31
31
  }
32
+ .date-picker-error {
33
+ color: #d4163a;
34
+ }
32
35
  }
@@ -5,7 +5,7 @@ export declare const splitDateRangeSections: (sections: RangeFieldSection[]) =>
5
5
  };
6
6
  export declare const removeLastSeparator: (dateSections: RangeFieldSection[]) => (RangeFieldSection | {
7
7
  separator: null;
8
- dateName: "end" | "start";
8
+ dateName: "start" | "end";
9
9
  value: string;
10
10
  format: string;
11
11
  maxLength: number | null;
@@ -20,5 +20,7 @@ declare const _default: {
20
20
  "toolbar-date-range-shortcut-next-30-days": string;
21
21
  "toolbar-date-range-shortcut-next-90-days": string;
22
22
  "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
23
25
  };
24
26
  export default _default;
@@ -19,5 +19,7 @@ export default {
19
19
  "toolbar-date-range-shortcut-next-7-days": "Next 7 days",
20
20
  "toolbar-date-range-shortcut-next-30-days": "Next 30 days",
21
21
  "toolbar-date-range-shortcut-next-90-days": "Next 90 days",
22
- "toolbar-date-range-shortcut-next-180-days": "Next 180 days"
22
+ "toolbar-date-range-shortcut-next-180-days": "Next 180 days",
23
+ "toolbar-date-range-invalid-start-date": "Invalid start date",
24
+ "toolbar-date-range-invalid-end-date": "Invalid end date"
23
25
  };
@@ -20,5 +20,7 @@ declare const _default: {
20
20
  "toolbar-date-range-shortcut-next-30-days": string;
21
21
  "toolbar-date-range-shortcut-next-90-days": string;
22
22
  "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
23
25
  };
24
26
  export default _default;
@@ -19,5 +19,7 @@ export default {
19
19
  "toolbar-date-range-shortcut-next-7-days": "未来7天",
20
20
  "toolbar-date-range-shortcut-next-30-days": "未来30天",
21
21
  "toolbar-date-range-shortcut-next-90-days": "未来90天",
22
- "toolbar-date-range-shortcut-next-180-days": "未来180天"
22
+ "toolbar-date-range-shortcut-next-180-days": "未来180天",
23
+ "toolbar-date-range-invalid-start-date": "开始日期无效",
24
+ "toolbar-date-range-invalid-end-date": "结束日期无效"
23
25
  };
@@ -20,5 +20,7 @@ declare const _default: {
20
20
  "toolbar-date-range-shortcut-next-30-days": string;
21
21
  "toolbar-date-range-shortcut-next-90-days": string;
22
22
  "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
23
25
  };
24
26
  export default _default;
@@ -19,5 +19,7 @@ export default {
19
19
  "toolbar-date-range-shortcut-next-7-days": "未來7天",
20
20
  "toolbar-date-range-shortcut-next-30-days": "未來30天",
21
21
  "toolbar-date-range-shortcut-next-90-days": "未來90天",
22
- "toolbar-date-range-shortcut-next-180-days": "未來180天"
22
+ "toolbar-date-range-shortcut-next-180-days": "未來180天",
23
+ "toolbar-date-range-invalid-start-date": "開始日期無效",
24
+ "toolbar-date-range-invalid-end-date": "結束日期無效"
23
25
  };
@@ -315,7 +315,29 @@ var PisellDateRangePicker = (props) => {
315
315
  popper: {
316
316
  className: popupClassName,
317
317
  disablePortal,
318
- placement
318
+ placement,
319
+ modifiers: [
320
+ {
321
+ name: "flip",
322
+ enabled: true,
323
+ options: {
324
+ altBoundary: true,
325
+ rootBoundary: "viewport",
326
+ padding: 8
327
+ }
328
+ },
329
+ {
330
+ name: "preventOverflow",
331
+ enabled: true,
332
+ options: {
333
+ altAxis: true,
334
+ altBoundary: true,
335
+ tether: true,
336
+ rootBoundary: "viewport",
337
+ padding: 8
338
+ }
339
+ }
340
+ ]
319
341
  },
320
342
  dialog: {
321
343
  disablePortal
@@ -60,6 +60,7 @@
60
60
  }
61
61
  .MuiPickersSlideTransition-root {
62
62
  min-width: 200px;
63
+ min-height: 235px;
63
64
  //min-height: auto;
64
65
  &::before {
65
66
  content: "";
@@ -54,14 +54,18 @@ var Toolbar = (props) => {
54
54
  const format = locale === "en" || locale === "en-US" ? "DD/MM/YYYY" : "YYYY/MM/DD";
55
55
  const [startStr, setStartStr] = (0, import_react.useState)("");
56
56
  const [endStr, setEndStr] = (0, import_react.useState)("");
57
+ const [startError, setStartError] = (0, import_react.useState)(false);
58
+ const [endError, setEndError] = (0, import_react.useState)(false);
57
59
  (0, import_react.useEffect)(() => {
58
60
  if (value == null ? void 0 : value[0]) {
59
61
  setStartStr(value[0].format(format));
62
+ setStartError(false);
60
63
  } else {
61
64
  setStartStr("");
62
65
  }
63
66
  if (value == null ? void 0 : value[1]) {
64
67
  setEndStr(value[1].format(format));
68
+ setEndError(false);
65
69
  } else {
66
70
  setEndStr("");
67
71
  }
@@ -71,11 +75,14 @@ var Toolbar = (props) => {
71
75
  const val = e.target.value;
72
76
  setStartStr(val);
73
77
  if (isValidDate(val, format)) {
78
+ setStartError(false);
74
79
  const valDate = (0, import_dayjs.default)(val, format);
75
80
  const newValue = [...value];
76
81
  const start = newValue[0] || (0, import_dayjs.default)();
77
82
  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
83
  onChange(newValue);
84
+ } else {
85
+ setStartError(true);
79
86
  }
80
87
  };
81
88
  const handleEndChange = (e) => {
@@ -83,11 +90,14 @@ var Toolbar = (props) => {
83
90
  const val = e.target.value;
84
91
  setEndStr(val);
85
92
  if (isValidDate(val, format)) {
93
+ setEndError(false);
86
94
  const valDate = (0, import_dayjs.default)(val, format);
87
95
  const newValue = [...value];
88
96
  const end = newValue[1] || (0, import_dayjs.default)();
89
97
  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
98
  onChange(newValue);
99
+ } else {
100
+ setEndError(true);
91
101
  }
92
102
  };
93
103
  const handleSelectChange = (e) => {
@@ -135,19 +145,27 @@ var Toolbar = (props) => {
135
145
  )), /* @__PURE__ */ import_react.default.createElement(
136
146
  import_antd.Input,
137
147
  {
148
+ status: startError ? "error" : "",
138
149
  size: "large",
139
150
  value: startStr,
140
151
  onChange: handleStartChange,
141
152
  placeholder: (0, import_dayjs.default)().format(format)
142
153
  }
143
- )), /* @__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", import_locales.pLocaleMap[locale])), /* @__PURE__ */ import_react.default.createElement(
154
+ ), startError && /* @__PURE__ */ import_react.default.createElement("span", { className: "date-picker-error" }, (0, import_locales.getText)(
155
+ "toolbar-date-range-invalid-start-date",
156
+ import_locales.pLocaleMap[locale]
157
+ ))), /* @__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", import_locales.pLocaleMap[locale])), /* @__PURE__ */ import_react.default.createElement(
144
158
  import_antd.Input,
145
159
  {
160
+ status: endError ? "error" : "",
146
161
  size: "large",
147
162
  value: endStr,
148
163
  onChange: handleEndChange,
149
164
  placeholder: (0, import_dayjs.default)().format(format)
150
165
  }
151
- ))));
166
+ ), endError && /* @__PURE__ */ import_react.default.createElement("span", { className: "date-picker-error" }, (0, import_locales.getText)(
167
+ "toolbar-date-range-invalid-end-date",
168
+ import_locales.pLocaleMap[locale]
169
+ )))));
152
170
  };
153
171
  var Toolbar_default = Toolbar;
@@ -29,4 +29,7 @@
29
29
  gap: 8px;
30
30
  flex: 1;
31
31
  }
32
+ .date-picker-error {
33
+ color: #d4163a;
34
+ }
32
35
  }
@@ -5,7 +5,7 @@ export declare const splitDateRangeSections: (sections: RangeFieldSection[]) =>
5
5
  };
6
6
  export declare const removeLastSeparator: (dateSections: RangeFieldSection[]) => (RangeFieldSection | {
7
7
  separator: null;
8
- dateName: "end" | "start";
8
+ dateName: "start" | "end";
9
9
  value: string;
10
10
  format: string;
11
11
  maxLength: number | null;
@@ -20,5 +20,7 @@ declare const _default: {
20
20
  "toolbar-date-range-shortcut-next-30-days": string;
21
21
  "toolbar-date-range-shortcut-next-90-days": string;
22
22
  "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
23
25
  };
24
26
  export default _default;
@@ -43,5 +43,7 @@ var en_US_default = {
43
43
  "toolbar-date-range-shortcut-next-7-days": "Next 7 days",
44
44
  "toolbar-date-range-shortcut-next-30-days": "Next 30 days",
45
45
  "toolbar-date-range-shortcut-next-90-days": "Next 90 days",
46
- "toolbar-date-range-shortcut-next-180-days": "Next 180 days"
46
+ "toolbar-date-range-shortcut-next-180-days": "Next 180 days",
47
+ "toolbar-date-range-invalid-start-date": "Invalid start date",
48
+ "toolbar-date-range-invalid-end-date": "Invalid end date"
47
49
  };
@@ -20,5 +20,7 @@ declare const _default: {
20
20
  "toolbar-date-range-shortcut-next-30-days": string;
21
21
  "toolbar-date-range-shortcut-next-90-days": string;
22
22
  "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
23
25
  };
24
26
  export default _default;
@@ -43,5 +43,7 @@ var zh_CN_default = {
43
43
  "toolbar-date-range-shortcut-next-7-days": "未来7天",
44
44
  "toolbar-date-range-shortcut-next-30-days": "未来30天",
45
45
  "toolbar-date-range-shortcut-next-90-days": "未来90天",
46
- "toolbar-date-range-shortcut-next-180-days": "未来180天"
46
+ "toolbar-date-range-shortcut-next-180-days": "未来180天",
47
+ "toolbar-date-range-invalid-start-date": "开始日期无效",
48
+ "toolbar-date-range-invalid-end-date": "结束日期无效"
47
49
  };
@@ -20,5 +20,7 @@ declare const _default: {
20
20
  "toolbar-date-range-shortcut-next-30-days": string;
21
21
  "toolbar-date-range-shortcut-next-90-days": string;
22
22
  "toolbar-date-range-shortcut-next-180-days": string;
23
+ "toolbar-date-range-invalid-start-date": string;
24
+ "toolbar-date-range-invalid-end-date": string;
23
25
  };
24
26
  export default _default;
@@ -43,5 +43,7 @@ var zh_TW_default = {
43
43
  "toolbar-date-range-shortcut-next-7-days": "未來7天",
44
44
  "toolbar-date-range-shortcut-next-30-days": "未來30天",
45
45
  "toolbar-date-range-shortcut-next-90-days": "未來90天",
46
- "toolbar-date-range-shortcut-next-180-days": "未來180天"
46
+ "toolbar-date-range-shortcut-next-180-days": "未來180天",
47
+ "toolbar-date-range-invalid-start-date": "開始日期無效",
48
+ "toolbar-date-range-invalid-end-date": "結束日期無效"
47
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/date-picker",
3
- "version": "1.0.83",
3
+ "version": "1.0.84",
4
4
  "sideEffects": [
5
5
  "*.less"
6
6
  ],