@pisell/date-picker 1.0.85 → 1.0.87

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.
@@ -153,6 +153,14 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
153
153
  } else {
154
154
  setCurrentShortcut(null);
155
155
  }
156
+ if (!clearEndOnSelection && type !== "shortcuts" && type !== "write") {
157
+ if (rangePosition === 'start') {
158
+ newVal = [newVal[0], newVal[0]];
159
+ }
160
+ if (!newVal[1]) {
161
+ newVal = [newVal[0], newVal[0]];
162
+ }
163
+ }
156
164
  if (isArr(showTime) && type !== "time") {
157
165
  newVal = newVal.map(function (item, index) {
158
166
  var _showTime$index;
@@ -163,14 +171,6 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
163
171
  return item || null;
164
172
  });
165
173
  }
166
- if (!clearEndOnSelection && type !== "shortcuts") {
167
- if (rangePosition === 'start') {
168
- newVal = [newVal[0], newVal[0]];
169
- }
170
- if (!newVal[1]) {
171
- newVal = [newVal[0], newVal[0]];
172
- }
173
- }
174
174
  if (clearEndOnSelection && type !== "set" && _value.filter(Boolean).length === 2) {
175
175
  newVal = [newVal[0], null];
176
176
  }
@@ -209,7 +209,7 @@ var PisellDateRangePicker = function PisellDateRangePicker(props) {
209
209
  if (inputReadOnly) {
210
210
  return {
211
211
  readOnly: true,
212
- selectedSections: null
212
+ selectedSections: 0
213
213
  };
214
214
  }
215
215
  return {};
@@ -60,14 +60,14 @@ var Toolbar = function Toolbar(props) {
60
60
  var handleStartChange = function handleStartChange(e) {
61
61
  var val = e.target.value;
62
62
  setStartStr(val);
63
- if (isValidDate(val, format)) {
63
+ if (isValidDate(val, format) && (value[1] ? dayjs(val, format) <= value[1] : true)) {
64
64
  var _start$set, _start$set$set;
65
65
  setStartError(false);
66
66
  var valDate = dayjs(val, format);
67
67
  var newValue = _toConsumableArray(value);
68
68
  var start = newValue[0] || dayjs();
69
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;
70
- onChange(newValue);
70
+ onChange(newValue, 'write');
71
71
  } else {
72
72
  setStartError(true);
73
73
  }
@@ -75,14 +75,14 @@ var Toolbar = function Toolbar(props) {
75
75
  var handleEndChange = function handleEndChange(e) {
76
76
  var val = e.target.value;
77
77
  setEndStr(val);
78
- if (isValidDate(val, format)) {
78
+ if (isValidDate(val, format) && (value[0] ? dayjs(val, format) >= value[0] : true)) {
79
79
  var _end$set, _end$set$set;
80
80
  setEndError(false);
81
81
  var valDate = dayjs(val, format);
82
82
  var newValue = _toConsumableArray(value);
83
83
  var end = newValue[1] || dayjs();
84
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;
85
- onChange(newValue);
85
+ onChange(newValue, 'write');
86
86
  } else {
87
87
  setEndError(true);
88
88
  }
@@ -156,6 +156,14 @@ var PisellDateRangePicker = (props) => {
156
156
  } else {
157
157
  setCurrentShortcut(null);
158
158
  }
159
+ if (!clearEndOnSelection && type !== "shortcuts" && type !== "write") {
160
+ if (rangePosition === "start") {
161
+ newVal = [newVal[0], newVal[0]];
162
+ }
163
+ if (!newVal[1]) {
164
+ newVal = [newVal[0], newVal[0]];
165
+ }
166
+ }
159
167
  if ((0, import_utils.isArr)(showTime) && type !== "time") {
160
168
  newVal = newVal.map((item, index) => {
161
169
  var _a, _b, _c, _d, _e, _f, _g;
@@ -165,14 +173,6 @@ var PisellDateRangePicker = (props) => {
165
173
  return item || null;
166
174
  });
167
175
  }
168
- if (!clearEndOnSelection && type !== "shortcuts") {
169
- if (rangePosition === "start") {
170
- newVal = [newVal[0], newVal[0]];
171
- }
172
- if (!newVal[1]) {
173
- newVal = [newVal[0], newVal[0]];
174
- }
175
- }
176
176
  if (clearEndOnSelection && type !== "set" && _value.filter(Boolean).length === 2) {
177
177
  newVal = [newVal[0], null];
178
178
  }
@@ -212,7 +212,7 @@ var PisellDateRangePicker = (props) => {
212
212
  if (inputReadOnly) {
213
213
  return {
214
214
  readOnly: true,
215
- selectedSections: null
215
+ selectedSections: 0
216
216
  };
217
217
  }
218
218
  return {};
@@ -74,13 +74,13 @@ var Toolbar = (props) => {
74
74
  var _a, _b;
75
75
  const val = e.target.value;
76
76
  setStartStr(val);
77
- if (isValidDate(val, format)) {
77
+ if (isValidDate(val, format) && (value[1] ? (0, import_dayjs.default)(val, format) <= value[1] : true)) {
78
78
  setStartError(false);
79
79
  const valDate = (0, import_dayjs.default)(val, format);
80
80
  const newValue = [...value];
81
81
  const start = newValue[0] || (0, import_dayjs.default)();
82
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;
83
- onChange(newValue);
83
+ onChange(newValue, "write");
84
84
  } else {
85
85
  setStartError(true);
86
86
  }
@@ -89,13 +89,13 @@ var Toolbar = (props) => {
89
89
  var _a, _b;
90
90
  const val = e.target.value;
91
91
  setEndStr(val);
92
- if (isValidDate(val, format)) {
92
+ if (isValidDate(val, format) && (value[0] ? (0, import_dayjs.default)(val, format) >= value[0] : true)) {
93
93
  setEndError(false);
94
94
  const valDate = (0, import_dayjs.default)(val, format);
95
95
  const newValue = [...value];
96
96
  const end = newValue[1] || (0, import_dayjs.default)();
97
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;
98
- onChange(newValue);
98
+ onChange(newValue, "write");
99
99
  } else {
100
100
  setEndError(true);
101
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/date-picker",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "sideEffects": [
5
5
  "*.less"
6
6
  ],
@@ -26,7 +26,7 @@
26
26
  "antd": "^5.5.0",
27
27
  "react": "^18.0.0",
28
28
  "react-dom": "^18.0.0",
29
- "@pisell/utils": "1.0.27"
29
+ "@pisell/utils": "1.0.25"
30
30
  },
31
31
  "files": [
32
32
  "es",