@paygreen/pgui 2.8.1 → 2.8.2
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.
- package/dist/cjs/index.js +49 -44
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/InputDayPicker/index.d.ts +1 -1
- package/dist/esm/index.js +49 -44
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/InputDayPicker/index.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -62366,43 +62366,12 @@ dayjs.extend(customParseFormat);
|
|
|
62366
62366
|
dayjs.extend(utc);
|
|
62367
62367
|
dayjs.extend(isoWeek);
|
|
62368
62368
|
var InputRangePicker = function (_a) {
|
|
62369
|
-
var
|
|
62370
|
-
var _e =
|
|
62371
|
-
var
|
|
62372
|
-
var
|
|
62373
|
-
var
|
|
62374
|
-
|
|
62375
|
-
if (!withTime) {
|
|
62376
|
-
var formatedMin = minDate
|
|
62377
|
-
? dayjs(dayjs(minDate).startOf('day').toISOString()).toDate()
|
|
62378
|
-
: null;
|
|
62379
|
-
var formatedMax = maxDate
|
|
62380
|
-
? dayjs(dayjs(maxDate).endOf('day').toISOString()).toDate()
|
|
62381
|
-
: null;
|
|
62382
|
-
setFormatedMinDate(formatedMin);
|
|
62383
|
-
setFormatedMaxDate(formatedMax);
|
|
62384
|
-
}
|
|
62385
|
-
}, [withTime]);
|
|
62386
|
-
React.useEffect(function () {
|
|
62387
|
-
onChange({
|
|
62388
|
-
from: fromValue ? dayjs(fromValue).toDate() : null,
|
|
62389
|
-
to: toValue ? dayjs(toValue).toDate() : null
|
|
62390
|
-
});
|
|
62391
|
-
}, [fromValue, toValue]);
|
|
62392
|
-
React.useEffect(function () {
|
|
62393
|
-
if (!withTime) {
|
|
62394
|
-
if (value === null || value === void 0 ? void 0 : value.from) {
|
|
62395
|
-
if (dayjs(value.from).diff(dayjs(formatedMinDate).utcOffset(0, true)) < 0) {
|
|
62396
|
-
setFromValue(dayjs(formatedMinDate).utcOffset(0, true).toISOString());
|
|
62397
|
-
}
|
|
62398
|
-
}
|
|
62399
|
-
if (value === null || value === void 0 ? void 0 : value.to) {
|
|
62400
|
-
if (dayjs(value.to).diff(dayjs(formatedMaxDate).utcOffset(0, true)) > 0) {
|
|
62401
|
-
setToValue(dayjs(formatedMaxDate).utcOffset(0, true).toISOString());
|
|
62402
|
-
}
|
|
62403
|
-
}
|
|
62404
|
-
}
|
|
62405
|
-
}, [withTime, fromValue, toValue]);
|
|
62369
|
+
var _b, _c;
|
|
62370
|
+
var fromLabel = _a.fromLabel, toLabel = _a.toLabel, value = _a.value, onChange = _a.onChange, _d = _a.minDate, minDate = _d === void 0 ? null : _d, _e = _a.maxDate, maxDate = _e === void 0 ? null : _e, _f = _a.withTime, withTime = _f === void 0 ? false : _f, _g = _a.format, format = _g === void 0 ? 'DD/MM/YYYY' : _g, _h = _a.variant, variant = _h === void 0 ? 'unstyled' : _h, props = __rest$2(_a, ["fromLabel", "toLabel", "value", "onChange", "minDate", "maxDate", "withTime", "format", "variant"]);
|
|
62371
|
+
var _j = React.useState(minDate), formatedMinDate = _j[0], setFormatedMinDate = _j[1];
|
|
62372
|
+
var _k = React.useState(maxDate), formatedMaxDate = _k[0], setFormatedMaxDate = _k[1];
|
|
62373
|
+
var fromValue = ((_b = value === null || value === void 0 ? void 0 : value.from) === null || _b === void 0 ? void 0 : _b.toISOString()) || undefined;
|
|
62374
|
+
var toValue = ((_c = value === null || value === void 0 ? void 0 : value.to) === null || _c === void 0 ? void 0 : _c.toISOString()) || undefined;
|
|
62406
62375
|
var fromFunc = function (_a) {
|
|
62407
62376
|
var date = _a.date;
|
|
62408
62377
|
if (toValue) {
|
|
@@ -62457,17 +62426,53 @@ var InputRangePicker = function (_a) {
|
|
|
62457
62426
|
return 'after-max-date';
|
|
62458
62427
|
}
|
|
62459
62428
|
};
|
|
62460
|
-
|
|
62429
|
+
var handleChange = function (from, to) {
|
|
62430
|
+
if (withTime) {
|
|
62431
|
+
return onChange({
|
|
62432
|
+
from: from ? dayjs(from).toDate() : null,
|
|
62433
|
+
to: to ? dayjs(to).toDate() : null
|
|
62434
|
+
});
|
|
62435
|
+
}
|
|
62436
|
+
return onChange({
|
|
62437
|
+
from: from ? dayjs(from).startOf('day').toDate() : null,
|
|
62438
|
+
to: to ? dayjs(to).startOf('day').toDate() : null
|
|
62439
|
+
});
|
|
62440
|
+
};
|
|
62441
|
+
React.useEffect(function () {
|
|
62442
|
+
if (!withTime) {
|
|
62443
|
+
var formatedMin = minDate
|
|
62444
|
+
? dayjs(dayjs(minDate).startOf('day').toISOString()).toDate()
|
|
62445
|
+
: null;
|
|
62446
|
+
var formatedMax = maxDate
|
|
62447
|
+
? dayjs(dayjs(maxDate).endOf('day').toISOString()).toDate()
|
|
62448
|
+
: null;
|
|
62449
|
+
setFormatedMinDate(formatedMin);
|
|
62450
|
+
setFormatedMaxDate(formatedMax);
|
|
62451
|
+
if (fromValue) {
|
|
62452
|
+
if (formatedMin &&
|
|
62453
|
+
dayjs(fromValue).diff(dayjs(formatedMin).utcOffset(0, true)) < 0) {
|
|
62454
|
+
fromValue = dayjs(formatedMin).utcOffset(0, true).toISOString();
|
|
62455
|
+
}
|
|
62456
|
+
}
|
|
62457
|
+
if (toValue) {
|
|
62458
|
+
if (formatedMax &&
|
|
62459
|
+
dayjs(toValue).diff(dayjs(formatedMax).utcOffset(0, true)) > 0) {
|
|
62460
|
+
toValue = dayjs(formatedMax).utcOffset(0, true).toISOString();
|
|
62461
|
+
}
|
|
62462
|
+
}
|
|
62463
|
+
}
|
|
62464
|
+
}, [withTime]);
|
|
62465
|
+
return (React__default["default"].createElement(react.Wrap, { flexWrap: "wrap", w: "full", maxW: "full" },
|
|
62461
62466
|
React__default["default"].createElement(react.WrapItem, { flex: "1", alignItems: "center", minW: "fit-content" },
|
|
62462
62467
|
React__default["default"].createElement(react.Text, { mr: 2, wordBreak: "normal" }, fromLabel),
|
|
62463
|
-
React__default["default"].createElement(InputDayPicker, { name: "from", onChange: function (e) {
|
|
62464
|
-
|
|
62465
|
-
}, value: fromValue, format: format, minDate: formatedMinDate, maxDate: (value === null || value === void 0 ? void 0 : value.to) || maxDate, calendarFunc: fromFunc, withTime: withTime, variant: variant, minW: "11.5rem", w: "full" })),
|
|
62468
|
+
React__default["default"].createElement(InputDayPicker, __assign$2({ name: "from", onChange: function (e) {
|
|
62469
|
+
handleChange(e, toValue);
|
|
62470
|
+
}, value: fromValue, format: withTime ? "".concat(format, " HH:mm") : format, minDate: formatedMinDate, maxDate: (value === null || value === void 0 ? void 0 : value.to) || maxDate, calendarFunc: fromFunc, withTime: withTime, variant: variant, minW: "11.5rem", w: "full" }, props))),
|
|
62466
62471
|
React__default["default"].createElement(react.WrapItem, { flex: "1", alignItems: "center", minW: "fit-content" },
|
|
62467
62472
|
React__default["default"].createElement(react.Text, { mr: 2, wordBreak: "normal" }, toLabel),
|
|
62468
|
-
React__default["default"].createElement(InputDayPicker, { name: "to", onChange: function (e) {
|
|
62469
|
-
|
|
62470
|
-
}, value: toValue, format: format, minDate: (value === null || value === void 0 ? void 0 : value.from) || formatedMinDate, maxDate: formatedMaxDate, calendarFunc: toFunc, withTime: withTime, variant: variant, minW: "11.5rem", w: "full" }))));
|
|
62473
|
+
React__default["default"].createElement(InputDayPicker, __assign$2({ name: "to", onChange: function (e) {
|
|
62474
|
+
handleChange(fromValue, e);
|
|
62475
|
+
}, value: toValue, format: withTime ? "".concat(format, " HH:mm") : format, minDate: (value === null || value === void 0 ? void 0 : value.from) || formatedMinDate, maxDate: formatedMaxDate, calendarFunc: toFunc, withTime: withTime, variant: variant, minW: "11.5rem", w: "full" }, props)))));
|
|
62471
62476
|
};
|
|
62472
62477
|
|
|
62473
62478
|
var ModalResponsive = function (_a) {
|