@widergy/energy-ui 3.6.0 → 3.6.1
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.6.1](https://github.com/widergy/energy-ui/compare/v3.6.0...v3.6.1) (2024-04-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fix date picker to only past month ([8aa6ded](https://github.com/widergy/energy-ui/commit/8aa6dedacfe75d33079621b4934435a1b86f848f))
|
|
7
|
+
|
|
1
8
|
# [3.6.0](https://github.com/widergy/energy-ui/compare/v3.5.5...v3.6.0) (2024-04-15)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -54,7 +54,7 @@ class CustomUtils extends _dayjs.default {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
const UTDatePicker = _ref => {
|
|
57
|
-
var _field$configuration;
|
|
57
|
+
var _field$configuration, _field$configuration2;
|
|
58
58
|
let {
|
|
59
59
|
classes: themeClasses,
|
|
60
60
|
classNames,
|
|
@@ -79,6 +79,12 @@ const UTDatePicker = _ref => {
|
|
|
79
79
|
} = _ref;
|
|
80
80
|
const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(themeClasses, classNames), [classNames]);
|
|
81
81
|
const configMask = (field === null || field === void 0 || (_field$configuration = field.configuration) === null || _field$configuration === void 0 ? void 0 : _field$configuration.date_mask) || _constants.OUTPUT_LABEL_MASK;
|
|
82
|
+
const onlyPastMonth = (field === null || field === void 0 || (_field$configuration2 = field.configuration) === null || _field$configuration2 === void 0 ? void 0 : _field$configuration2.only_past_month) || false;
|
|
83
|
+
const pastMonthDates = (0, _utils.getPastMonthDates)(onlyPastMonth);
|
|
84
|
+
const {
|
|
85
|
+
minDate,
|
|
86
|
+
maxDate
|
|
87
|
+
} = pastMonthDates;
|
|
82
88
|
const [pickedDate, setPickedDate] = (0, _react.useState)(null);
|
|
83
89
|
const [internalError, setInternalError] = (0, _react.useState)(null);
|
|
84
90
|
const handleChange = date => {
|
|
@@ -147,7 +153,9 @@ const UTDatePicker = _ref => {
|
|
|
147
153
|
PopoverProps: {
|
|
148
154
|
...(iconAnchor ? (0, _constants.iconAnchorProps)(operenerIconReference) : {}),
|
|
149
155
|
...popoverProps
|
|
150
|
-
}
|
|
156
|
+
},
|
|
157
|
+
minDate: minDate,
|
|
158
|
+
maxDate: maxDate
|
|
151
159
|
}, pickerProps))));
|
|
152
160
|
};
|
|
153
161
|
UTDatePicker.propTypes = {
|
|
@@ -3,10 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isSelected = exports.dateMatchesFormat = void 0;
|
|
6
|
+
exports.isSelected = exports.getPastMonthDates = exports.dateMatchesFormat = void 0;
|
|
7
7
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
9
|
const isSelected = (date, selectedDate) => selectedDate && date.isSame(selectedDate, 'day');
|
|
10
10
|
exports.isSelected = isSelected;
|
|
11
11
|
const dateMatchesFormat = (date, targetFormat) => (0, _dayjs.default)(date, targetFormat).format(targetFormat) === date;
|
|
12
|
-
exports.dateMatchesFormat = dateMatchesFormat;
|
|
12
|
+
exports.dateMatchesFormat = dateMatchesFormat;
|
|
13
|
+
const getPastMonthDates = function () {
|
|
14
|
+
let onlyPastMonth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
15
|
+
if (!onlyPastMonth) return {};
|
|
16
|
+
const date = new Date();
|
|
17
|
+
const currentYear = date.getFullYear();
|
|
18
|
+
const currentMonth = date.getMonth();
|
|
19
|
+
return {
|
|
20
|
+
minDate: new Date(currentYear, currentMonth - 1, 1),
|
|
21
|
+
maxDate: new Date(currentYear, currentMonth, 0)
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.getPastMonthDates = getPastMonthDates;
|