@paygreen/pgui 2.14.1 → 2.14.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 +34 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/InputDayPicker/index.d.ts +4 -1
- package/dist/cjs/types/components/InputRangePicker/index.d.ts +5 -3
- package/dist/esm/index.js +34 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/InputDayPicker/index.d.ts +4 -1
- package/dist/esm/types/components/InputRangePicker/index.d.ts +5 -3
- package/dist/index.d.ts +9 -4
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -7931,8 +7931,11 @@ function MdCalendarToday (props) {
|
|
|
7931
7931
|
dayjs.extend(customParseFormat);
|
|
7932
7932
|
dayjs.extend(utc);
|
|
7933
7933
|
var InputDayPicker = function (_a) {
|
|
7934
|
-
var value = _a.value, onChange = _a.onChange, placeholder = _a.placeholder, name = _a.name, isDisabled = _a.isDisabled, withTime = _a.withTime, _b = _a.locale, locale = _b === void 0 ? 'en' : _b, minDate = _a.minDate, maxDate = _a.maxDate, _c = _a.variant, variant = _c === void 0 ? 'filled' : _c, inputProps = _a.inputProps, dayPickerProps = _a.dayPickerProps;
|
|
7935
|
-
var
|
|
7934
|
+
var value = _a.value, onChange = _a.onChange, placeholder = _a.placeholder, name = _a.name, isDisabled = _a.isDisabled, withTime = _a.withTime, _b = _a.locale, locale = _b === void 0 ? 'en' : _b, minDate = _a.minDate, maxDate = _a.maxDate, _c = _a.variant, variant = _c === void 0 ? 'filled' : _c, inputProps = _a.inputProps, dayPickerProps = _a.dayPickerProps, isOpenProp = _a.isOpen, onOpenProp = _a.onOpen, onCloseProp = _a.onClose;
|
|
7935
|
+
var disclosure = react.useDisclosure();
|
|
7936
|
+
var isOpen = isOpenProp || disclosure.isOpen;
|
|
7937
|
+
var onOpen = onOpenProp || disclosure.onOpen;
|
|
7938
|
+
var onClose = onCloseProp || disclosure.onClose;
|
|
7936
7939
|
var inputLeftElementColor = react.useColorModeValue('gray.400', 'gray.600');
|
|
7937
7940
|
var inputLeftElementDisabledColor = react.useColorModeValue('gray.600', 'gray.400');
|
|
7938
7941
|
var dialogSheetBg = react.useColorModeValue('gray.50', 'gray.800');
|
|
@@ -7943,18 +7946,20 @@ var InputDayPicker = function (_a) {
|
|
|
7943
7946
|
: withTime
|
|
7944
7947
|
? 'MM/DD/YYYY HH:mm'
|
|
7945
7948
|
: 'MM/DD/YYYY';
|
|
7946
|
-
var
|
|
7949
|
+
var _d = React.useState(value ? dayjs(value).format(defaultDateFormat) : ''), dateValue = _d[0], setDateValue = _d[1];
|
|
7947
7950
|
// Update the input value when the value prop changes
|
|
7948
7951
|
React.useEffect(function () {
|
|
7949
|
-
setDateValue(value ? dayjs(value).format(defaultDateFormat) : '');
|
|
7952
|
+
setDateValue(dayjs(value).isValid() ? dayjs(value).format(defaultDateFormat) : '');
|
|
7950
7953
|
}, [value]);
|
|
7951
7954
|
// Add new state variables for hours and minutes
|
|
7952
|
-
var
|
|
7953
|
-
var
|
|
7955
|
+
var _e = React.useState('00'), hours = _e[0], setHours = _e[1];
|
|
7956
|
+
var _f = React.useState('00'), minutes = _f[0], setMinutes = _f[1];
|
|
7954
7957
|
// Update the input value when the value prop changes
|
|
7955
7958
|
var handleInputChange = function (date) {
|
|
7956
|
-
if (!date)
|
|
7959
|
+
if (!date) {
|
|
7957
7960
|
setDateValue('');
|
|
7961
|
+
onChange(null);
|
|
7962
|
+
}
|
|
7958
7963
|
var dateInput = dayjs(date, defaultDateFormat, true);
|
|
7959
7964
|
if (dateInput.isValid()) {
|
|
7960
7965
|
if (isOpen)
|
|
@@ -7965,9 +7970,6 @@ var InputDayPicker = function (_a) {
|
|
|
7965
7970
|
setMinutes(parseInt(dateInput.format('mm'), 10).toString());
|
|
7966
7971
|
onChange(dateInput.toDate());
|
|
7967
7972
|
}
|
|
7968
|
-
else {
|
|
7969
|
-
onChange(null);
|
|
7970
|
-
}
|
|
7971
7973
|
};
|
|
7972
7974
|
// Update the input value when the value prop changes
|
|
7973
7975
|
var handleDateSelection = function (date) {
|
|
@@ -19050,13 +19052,30 @@ var InputPhone = function (_a) {
|
|
|
19050
19052
|
|
|
19051
19053
|
var InputRangePicker = function (_a) {
|
|
19052
19054
|
var _b;
|
|
19053
|
-
var value = _a.value, onChange = _a.onChange, placeholder = _a.placeholder, name = _a.name, isDisabled = _a.isDisabled, withTime = _a.withTime, _c = _a.locale, locale = _c === void 0 ? 'en' : _c,
|
|
19055
|
+
var value = _a.value, onChange = _a.onChange, placeholder = _a.placeholder, name = _a.name, isDisabled = _a.isDisabled, withTime = _a.withTime, _c = _a.locale, locale = _c === void 0 ? 'en' : _c, minStartDate = _a.minStartDate, maxStartDate = _a.maxStartDate, minEndDate = _a.minEndDate, maxEndDate = _a.maxEndDate, _d = _a.variant, variant = _d === void 0 ? 'filled' : _d, _e = _a.breakpoint, breakpoint = _e === void 0 ? 'md' : _e, inputProps = _a.inputProps, dayPickerProps = _a.dayPickerProps;
|
|
19054
19056
|
var _f = React.useState((value === null || value === void 0 ? void 0 : value.from) || null), fromValue = _f[0], setFromValue = _f[1];
|
|
19055
19057
|
var _g = React.useState((value === null || value === void 0 ? void 0 : value.to) || null), toValue = _g[0], setToValue = _g[1];
|
|
19058
|
+
var _h = react.useDisclosure(), isOpenFrom = _h.isOpen, onOpenFrom = _h.onOpen, onCloseFrom = _h.onClose;
|
|
19059
|
+
var _j = react.useDisclosure(), isOpenTo = _j.isOpen, onOpenTo = _j.onOpen, onCloseTo = _j.onClose;
|
|
19060
|
+
// close the other date picker when one is opened
|
|
19056
19061
|
React.useEffect(function () {
|
|
19057
|
-
|
|
19062
|
+
if (isOpenFrom) {
|
|
19063
|
+
onCloseTo();
|
|
19064
|
+
}
|
|
19065
|
+
}, [isOpenFrom]);
|
|
19066
|
+
React.useEffect(function () {
|
|
19067
|
+
if (isOpenTo) {
|
|
19068
|
+
onCloseFrom();
|
|
19069
|
+
}
|
|
19070
|
+
}, [isOpenTo]);
|
|
19071
|
+
// Update the parent state when the local state changes
|
|
19072
|
+
React.useEffect(function () {
|
|
19073
|
+
var newValue = { from: fromValue, to: toValue };
|
|
19074
|
+
if (JSON.stringify(newValue) !== JSON.stringify(value)) {
|
|
19075
|
+
onChange(newValue);
|
|
19076
|
+
}
|
|
19058
19077
|
}, [fromValue, toValue]);
|
|
19059
|
-
// Update the state when the value changes
|
|
19078
|
+
// Update the state when the props value changes
|
|
19060
19079
|
React.useEffect(function () {
|
|
19061
19080
|
setFromValue((value === null || value === void 0 ? void 0 : value.from) || null);
|
|
19062
19081
|
setToValue((value === null || value === void 0 ? void 0 : value.to) || null);
|
|
@@ -19067,8 +19086,8 @@ var InputRangePicker = function (_a) {
|
|
|
19067
19086
|
_b[breakpoint] = 'row',
|
|
19068
19087
|
_b));
|
|
19069
19088
|
return (React__default["default"].createElement(react.Flex, { flexDirection: flexDirection, gap: 2 },
|
|
19070
|
-
React__default["default"].createElement(InputDayPicker, { value: fromValue, onChange: setFromValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate:
|
|
19071
|
-
React__default["default"].createElement(InputDayPicker, { value: toValue, onChange: setToValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate:
|
|
19089
|
+
React__default["default"].createElement(InputDayPicker, { value: fromValue, onChange: setFromValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate: minStartDate, maxDate: maxStartDate, variant: variant, inputProps: inputProps, dayPickerProps: dayPickerProps, onClose: onCloseFrom, onOpen: onOpenFrom, isOpen: isOpenFrom }),
|
|
19090
|
+
React__default["default"].createElement(InputDayPicker, { value: toValue, onChange: setToValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate: minEndDate, maxDate: maxEndDate, variant: variant, inputProps: inputProps, dayPickerProps: dayPickerProps, onClose: onCloseTo, onOpen: onOpenTo, isOpen: isOpenTo })));
|
|
19072
19091
|
};
|
|
19073
19092
|
|
|
19074
19093
|
var ModalResponsive = function (_a) {
|