@trackunit/react-date-and-time-components 0.0.190 → 0.0.193
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/index.cjs.js +6 -7
- package/index.esm.js +6 -7
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -177,7 +177,6 @@ const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, dataTestId,
|
|
|
177
177
|
}
|
|
178
178
|
}, [selectedDays]);
|
|
179
179
|
const handleOnRangeSelect = react.useCallback((range) => {
|
|
180
|
-
// store the range
|
|
181
180
|
if (range && range.from) {
|
|
182
181
|
if (range.to === undefined) {
|
|
183
182
|
setNewRange({ from: range.from, to: range.from });
|
|
@@ -212,23 +211,23 @@ const calcQuickOptions = (numberOfDays) => {
|
|
|
212
211
|
quickOptions.push({ last: 1, unit: "days" }, { last: numberOfDays, unit: "days", includeExtraDay: true });
|
|
213
212
|
}
|
|
214
213
|
else if (numberOfDays >= 35 && numberOfDays < 185) {
|
|
215
|
-
quickOptions.push({ last: 1, unit: "days" }, { last: 7, unit: "days", includeExtraDay:
|
|
214
|
+
quickOptions.push({ last: 1, unit: "days" }, { last: 7, unit: "days", includeExtraDay: false }, { last: 30, unit: "days", includeExtraDay: false }, { last: numberOfDays, unit: "days", includeExtraDay: false });
|
|
216
215
|
}
|
|
217
216
|
else if (numberOfDays >= 185) {
|
|
218
|
-
quickOptions.push({ last: 1, unit: "days" }, { last: 14, unit: "days", includeExtraDay:
|
|
217
|
+
quickOptions.push({ last: 1, unit: "days" }, { last: 14, unit: "days", includeExtraDay: false }, { last: 30, unit: "days", includeExtraDay: false }, { last: numberOfDays, unit: "days", includeExtraDay: false });
|
|
219
218
|
}
|
|
220
219
|
return quickOptions;
|
|
221
220
|
};
|
|
222
221
|
const QuickOptionButton = ({ option, onClick, timezone }) => {
|
|
223
222
|
const [t] = useTranslation();
|
|
224
|
-
const { nowDate, endOf, subtract
|
|
223
|
+
const { nowDate, startOf, endOf, subtract } = reactDateAndTimeHooks.useDateAndTime();
|
|
225
224
|
const handleClick = react.useCallback(() => {
|
|
226
|
-
const from = subtract(
|
|
225
|
+
const from = subtract(startOf(nowDate, "day"), option.includeExtraDay ? option.last : option.last - 1, option.unit);
|
|
227
226
|
onClick({
|
|
228
|
-
from
|
|
227
|
+
from,
|
|
229
228
|
to: endOf(nowDate, "day"),
|
|
230
229
|
});
|
|
231
|
-
}, [subtract, endOf, nowDate, option.last, option.unit, option.includeExtraDay, onClick
|
|
230
|
+
}, [subtract, startOf, endOf, nowDate, option.last, option.unit, option.includeExtraDay, onClick]);
|
|
232
231
|
const translatedUnits = (unit) => {
|
|
233
232
|
switch (unit) {
|
|
234
233
|
case "hours":
|
package/index.esm.js
CHANGED
|
@@ -175,7 +175,6 @@ const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, dataTestId,
|
|
|
175
175
|
}
|
|
176
176
|
}, [selectedDays]);
|
|
177
177
|
const handleOnRangeSelect = useCallback((range) => {
|
|
178
|
-
// store the range
|
|
179
178
|
if (range && range.from) {
|
|
180
179
|
if (range.to === undefined) {
|
|
181
180
|
setNewRange({ from: range.from, to: range.from });
|
|
@@ -210,23 +209,23 @@ const calcQuickOptions = (numberOfDays) => {
|
|
|
210
209
|
quickOptions.push({ last: 1, unit: "days" }, { last: numberOfDays, unit: "days", includeExtraDay: true });
|
|
211
210
|
}
|
|
212
211
|
else if (numberOfDays >= 35 && numberOfDays < 185) {
|
|
213
|
-
quickOptions.push({ last: 1, unit: "days" }, { last: 7, unit: "days", includeExtraDay:
|
|
212
|
+
quickOptions.push({ last: 1, unit: "days" }, { last: 7, unit: "days", includeExtraDay: false }, { last: 30, unit: "days", includeExtraDay: false }, { last: numberOfDays, unit: "days", includeExtraDay: false });
|
|
214
213
|
}
|
|
215
214
|
else if (numberOfDays >= 185) {
|
|
216
|
-
quickOptions.push({ last: 1, unit: "days" }, { last: 14, unit: "days", includeExtraDay:
|
|
215
|
+
quickOptions.push({ last: 1, unit: "days" }, { last: 14, unit: "days", includeExtraDay: false }, { last: 30, unit: "days", includeExtraDay: false }, { last: numberOfDays, unit: "days", includeExtraDay: false });
|
|
217
216
|
}
|
|
218
217
|
return quickOptions;
|
|
219
218
|
};
|
|
220
219
|
const QuickOptionButton = ({ option, onClick, timezone }) => {
|
|
221
220
|
const [t] = useTranslation();
|
|
222
|
-
const { nowDate, endOf, subtract
|
|
221
|
+
const { nowDate, startOf, endOf, subtract } = useDateAndTime();
|
|
223
222
|
const handleClick = useCallback(() => {
|
|
224
|
-
const from = subtract(
|
|
223
|
+
const from = subtract(startOf(nowDate, "day"), option.includeExtraDay ? option.last : option.last - 1, option.unit);
|
|
225
224
|
onClick({
|
|
226
|
-
from
|
|
225
|
+
from,
|
|
227
226
|
to: endOf(nowDate, "day"),
|
|
228
227
|
});
|
|
229
|
-
}, [subtract, endOf, nowDate, option.last, option.unit, option.includeExtraDay, onClick
|
|
228
|
+
}, [subtract, startOf, endOf, nowDate, option.last, option.unit, option.includeExtraDay, onClick]);
|
|
230
229
|
const translatedUnits = (unit) => {
|
|
231
230
|
switch (unit) {
|
|
232
231
|
case "hours":
|