@trackunit/react-date-and-time-components 0.0.191 → 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 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: true }, { last: 30, unit: "days", includeExtraDay: true }, { last: numberOfDays, unit: "days", includeExtraDay: true });
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: true }, { last: 30, unit: "days", includeExtraDay: true }, { last: numberOfDays, unit: "days", includeExtraDay: true });
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, add } = reactDateAndTimeHooks.useDateAndTime();
223
+ const { nowDate, startOf, endOf, subtract } = reactDateAndTimeHooks.useDateAndTime();
225
224
  const handleClick = react.useCallback(() => {
226
- const from = subtract(endOf(nowDate, "day"), option.last, option.unit);
225
+ const from = subtract(startOf(nowDate, "day"), option.includeExtraDay ? option.last : option.last - 1, option.unit);
227
226
  onClick({
228
- from: option.includeExtraDay ? from : add(from, 1, "days"),
227
+ from,
229
228
  to: endOf(nowDate, "day"),
230
229
  });
231
- }, [subtract, endOf, nowDate, option.last, option.unit, option.includeExtraDay, onClick, add]);
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: true }, { last: 30, unit: "days", includeExtraDay: true }, { last: numberOfDays, unit: "days", includeExtraDay: true });
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: true }, { last: 30, unit: "days", includeExtraDay: true }, { last: numberOfDays, unit: "days", includeExtraDay: true });
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, add } = useDateAndTime();
221
+ const { nowDate, startOf, endOf, subtract } = useDateAndTime();
223
222
  const handleClick = useCallback(() => {
224
- const from = subtract(endOf(nowDate, "day"), option.last, option.unit);
223
+ const from = subtract(startOf(nowDate, "day"), option.includeExtraDay ? option.last : option.last - 1, option.unit);
225
224
  onClick({
226
- from: option.includeExtraDay ? from : add(from, 1, "days"),
225
+ from,
227
226
  to: endOf(nowDate, "day"),
228
227
  });
229
- }, [subtract, endOf, nowDate, option.last, option.unit, option.includeExtraDay, onClick, add]);
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":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-date-and-time-components",
3
- "version": "0.0.191",
3
+ "version": "0.0.193",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {