@geotab/zenith 3.17.1-beta.3 → 3.18.0-beta.0

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.
Files changed (68) hide show
  1. package/README.md +8 -0
  2. package/dist/chart/pieChart/pieLegendPlugin.js +3 -0
  3. package/dist/chart/pieChart/renderPieLegend.js +6 -4
  4. package/dist/chart/plugins/legend/legendFocus.d.ts +2 -0
  5. package/dist/chart/plugins/legend/legendFocus.js +20 -0
  6. package/dist/chart/plugins/legend/legendPlugin.js +3 -0
  7. package/dist/chart/plugins/legend/renderLegend.js +9 -5
  8. package/dist/commonHelpers/hooks/useFormFieldValues/useFormFieldValues.d.ts +2 -1
  9. package/dist/commonHelpers/hooks/useFormFieldValues/useFormFieldValues.js +1 -0
  10. package/dist/commonHelpers/hooks/useMergedRef.d.ts +6 -0
  11. package/dist/commonHelpers/hooks/useMergedRef.js +37 -0
  12. package/dist/commonStyles/typography/typography.less +9 -0
  13. package/dist/dateInputInner/dateInputInnerReducer.d.ts +1 -0
  14. package/dist/dateInputInner/dateInputInnerReducer.js +18 -0
  15. package/dist/dateInputRaw/types.d.ts +1 -0
  16. package/dist/dateInputRaw/types.js +18 -0
  17. package/dist/datePickerCommon/hooks/useDateRangeRaw/useDateRangeRawCore.d.ts +7 -1
  18. package/dist/datePickerCommon/hooks/useDateRangeRaw/useDateRangeRawCore.js +5 -5
  19. package/dist/dateRangeRaw/types.d.ts +1 -0
  20. package/dist/dateRangeRaw/types.js +18 -0
  21. package/dist/dateRangeRaw/utils/areMapsEqual.d.ts +1 -0
  22. package/dist/dateRangeRaw/utils/areMapsEqual.js +18 -0
  23. package/dist/dateRangeRawNew/hooks/useDateRangeNewParts.d.ts +7 -1
  24. package/dist/dateRangeRawNew/hooks/useDateRangeNewParts.js +24 -15
  25. package/dist/dateRangeRawNew/hooks/useDateRangeRawNew.js +2 -2
  26. package/dist/dateRangeRawNew/hooks/useRangeEntry.js +31 -4
  27. package/dist/index.css +123 -0
  28. package/dist/miniTabs/miniTabs.d.ts +2 -1
  29. package/dist/miniTabs/miniTabs.js +2 -2
  30. package/dist/miniTabs/miniTabsItem.js +1 -1
  31. package/dist/stepperRaw/stepperRaw.js +5 -2
  32. package/dist/textInputRaw/textInputRaw.js +4 -2
  33. package/dist/textareaRaw/textareaRaw.js +4 -2
  34. package/dist/utils/dateInputUtils/useTodayButton.d.ts +1 -0
  35. package/dist/utils/dateInputUtils/useTodayButton.js +18 -0
  36. package/esm/chart/pieChart/pieLegendPlugin.js +3 -0
  37. package/esm/chart/pieChart/renderPieLegend.js +6 -4
  38. package/esm/chart/plugins/legend/legendFocus.d.ts +2 -0
  39. package/esm/chart/plugins/legend/legendFocus.js +15 -0
  40. package/esm/chart/plugins/legend/legendPlugin.js +3 -0
  41. package/esm/chart/plugins/legend/renderLegend.js +9 -5
  42. package/esm/commonHelpers/hooks/useFormFieldValues/useFormFieldValues.d.ts +2 -1
  43. package/esm/commonHelpers/hooks/useFormFieldValues/useFormFieldValues.js +1 -0
  44. package/esm/commonHelpers/hooks/useMergedRef.d.ts +6 -0
  45. package/esm/commonHelpers/hooks/useMergedRef.js +33 -0
  46. package/esm/dateInputInner/dateInputInnerReducer.d.ts +1 -0
  47. package/esm/dateInputInner/dateInputInnerReducer.js +2 -0
  48. package/esm/dateInputRaw/types.d.ts +1 -0
  49. package/esm/dateInputRaw/types.js +2 -0
  50. package/esm/datePickerCommon/hooks/useDateRangeRaw/useDateRangeRawCore.d.ts +7 -1
  51. package/esm/datePickerCommon/hooks/useDateRangeRaw/useDateRangeRawCore.js +5 -5
  52. package/esm/dateRangeRaw/types.d.ts +1 -0
  53. package/esm/dateRangeRaw/types.js +2 -0
  54. package/esm/dateRangeRaw/utils/areMapsEqual.d.ts +1 -0
  55. package/esm/dateRangeRaw/utils/areMapsEqual.js +2 -0
  56. package/esm/dateRangeRawNew/hooks/useDateRangeNewParts.d.ts +7 -1
  57. package/esm/dateRangeRawNew/hooks/useDateRangeNewParts.js +24 -15
  58. package/esm/dateRangeRawNew/hooks/useDateRangeRawNew.js +2 -2
  59. package/esm/dateRangeRawNew/hooks/useRangeEntry.js +31 -4
  60. package/esm/miniTabs/miniTabs.d.ts +2 -1
  61. package/esm/miniTabs/miniTabs.js +2 -2
  62. package/esm/miniTabs/miniTabsItem.js +1 -1
  63. package/esm/stepperRaw/stepperRaw.js +5 -2
  64. package/esm/textInputRaw/textInputRaw.js +4 -2
  65. package/esm/textareaRaw/textareaRaw.js +4 -2
  66. package/esm/utils/dateInputUtils/useTodayButton.d.ts +1 -0
  67. package/esm/utils/dateInputUtils/useTodayButton.js +2 -0
  68. package/package.json +8 -1
package/README.md CHANGED
@@ -47,6 +47,14 @@ Zenith library provides components defined in Zenith Design System. It includes
47
47
 
48
48
  ## Change log
49
49
 
50
+ ### 3.18.0
51
+
52
+ - Add opt-in `fill` prop to `MiniTabs` so the tabs fill the available width
53
+ - Make chart legend items keyboard accessible
54
+ - Add `stepper` support to `Filters.DateRange` as a single pill around the chip; make the `Filters` side panel date range full width
55
+ - Add `data-xxxl` typography style (`zen-data-xxxl`)
56
+ - Focus the first invalid field when a React Hook Form submit fails in `TextInput`, `Textarea` and `Stepper` (including the `Raw` variants)
57
+
50
58
  ### 3.17.1
51
59
 
52
60
  - Preserve filter names and show applied selection counts.
@@ -4,6 +4,7 @@ exports.pieLegendPlugin = void 0;
4
4
  const zen_1 = require("../../utils/zen");
5
5
  const getPieLegendItems_1 = require("./getPieLegendItems");
6
6
  const renderPieLegend_1 = require("./renderPieLegend");
7
+ const legendFocus_1 = require("../plugins/legend/legendFocus");
7
8
  const pieLegendPlugin = (containerId, options, isDrive, rawData, isHidden, toggleHidden) => ({
8
9
  id: "zenithPieLegend",
9
10
  isDrive,
@@ -37,9 +38,11 @@ const pieLegendPlugin = (containerId, options, isDrive, rawData, isHidden, toggl
37
38
  barWidth: hidden ? 0 : total > 0 ? (rawValues[item.index] / total) * 100 : 0
38
39
  }));
39
40
  });
41
+ const focusedIndex = (0, legendFocus_1.getFocusedLegendIndex)(container);
40
42
  container.innerHTML = "";
41
43
  container.classList.remove("zen-legend--hidden");
42
44
  (0, renderPieLegend_1.renderPieLegend)(container, isDrive, items, options);
45
+ (0, legendFocus_1.restoreLegendFocus)(container, focusedIndex);
43
46
  }
44
47
  });
45
48
  exports.pieLegendPlugin = pieLegendPlugin;
@@ -19,8 +19,7 @@ const renderPieLegend = (element, isDrive, items, options) => {
19
19
  <div class="zen-pie-legend__item-bar" data-bar-width="${(_a = item.barWidth) !== null && _a !== void 0 ? _a : 0}"></div>
20
20
  </div>`
21
21
  : "";
22
- return `<li class="zen-pie-legend__item" data-index="${item.index}">
23
- <span class="zen-pie-legend__item-color"></span>
22
+ const content = `<span class="zen-pie-legend__item-color"></span>
24
23
  <div class="zen-pie-legend__item-content">
25
24
  <div class="zen-pie-legend__item-row">
26
25
  <p class="${labelClass}">${(0, escapeHtml_1.htmlEscape)(item.text)}</p>
@@ -28,8 +27,11 @@ const renderPieLegend = (element, isDrive, items, options) => {
28
27
  ${percentageHtml}
29
28
  </div>
30
29
  ${barHtml}
31
- </div>
32
- </li>`;
30
+ </div>`;
31
+ const control = item.onClick
32
+ ? `<button type="button" class="zen-pie-legend__button" aria-pressed="${!item.hidden}">${content}</button>`
33
+ : `<span class="zen-pie-legend__button">${content}</span>`;
34
+ return `<li class="zen-pie-legend__item" data-index="${item.index}">${control}</li>`;
33
35
  })
34
36
  .join("");
35
37
  element.innerHTML = `<ul class="${classes}">${listItems}</ul>`;
@@ -0,0 +1,2 @@
1
+ export declare const getFocusedLegendIndex: (container: HTMLElement) => string | undefined;
2
+ export declare const restoreLegendFocus: (container: HTMLElement, index: string | undefined) => void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.restoreLegendFocus = exports.getFocusedLegendIndex = void 0;
4
+ const getFocusedLegendIndex = (container) => {
5
+ var _a, _b;
6
+ const active = container.ownerDocument.activeElement;
7
+ if (!active || !container.contains(active)) {
8
+ return undefined;
9
+ }
10
+ return (_b = (_a = active.closest("[data-index]")) === null || _a === void 0 ? void 0 : _a.getAttribute("data-index")) !== null && _b !== void 0 ? _b : undefined;
11
+ };
12
+ exports.getFocusedLegendIndex = getFocusedLegendIndex;
13
+ const restoreLegendFocus = (container, index) => {
14
+ var _a;
15
+ if (index === undefined) {
16
+ return;
17
+ }
18
+ (_a = container.querySelector(`[data-index="${index}"] button`)) === null || _a === void 0 ? void 0 : _a.focus();
19
+ };
20
+ exports.restoreLegendFocus = restoreLegendFocus;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.legendPlugin = exports.LEGEND_PLUGIN_ID = void 0;
4
4
  const renderLegend_1 = require("./renderLegend");
5
+ const legendFocus_1 = require("./legendFocus");
5
6
  const getLineLegendItems_1 = require("../../lineChart/getLineLegendItems");
6
7
  const getBarLegendItems_1 = require("../../barChart/getBarLegendItems");
7
8
  const getPieLegendItems_1 = require("../../pieChart/getPieLegendItems");
@@ -20,6 +21,7 @@ const legendPlugin = (containerId, options, isDrive, isHidden, toggleHidden) =>
20
21
  container.classList.add("zen-legend--hidden");
21
22
  return;
22
23
  }
24
+ const focusedIndex = (0, legendFocus_1.getFocusedLegendIndex)(container);
23
25
  container.innerHTML = "";
24
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
27
  const chartType = chart.config.type;
@@ -46,6 +48,7 @@ const legendPlugin = (containerId, options, isDrive, isHidden, toggleHidden) =>
46
48
  }
47
49
  container.classList.remove("zen-legend--hidden");
48
50
  (0, renderLegend_1.renderLegend)(container, this.isDrive, items);
51
+ (0, legendFocus_1.restoreLegendFocus)(container, focusedIndex);
49
52
  }
50
53
  });
51
54
  exports.legendPlugin = legendPlugin;
@@ -6,13 +6,17 @@ const escapeHtml_1 = require("../../../utils/escapeHtml");
6
6
  const renderLegend = (element, isDrive, items) => {
7
7
  const classes = (0, classNames_1.classNames)(["zen-legend", isDrive ? "zen-legend--drive" : ""]);
8
8
  const listItems = items
9
- .map((item, index) => `<li class="zen-legend__item" data-index="${index}">
10
- <span class="zen-legend__item-color" style="background-color: ${item.color};"></span>
9
+ .map((item, index) => {
10
+ const content = `<span class="zen-legend__item-color" style="background-color: ${item.color};"></span>
11
11
  <p class="${(0, classNames_1.classNames)(["zen-legend__item-label", item.hidden ? "zen-legend__item-label--hidden" : ""])}">${(0, escapeHtml_1.htmlEscape)(item.text)}</p>
12
12
  ${item.value !== undefined
13
- ? `<p class="${(0, classNames_1.classNames)(["zen-legend__item-value", item.hidden ? "zen-legend__item-value--hidden" : ""])}">${(0, escapeHtml_1.htmlEscape)(item.value)}</p>`
14
- : ""}
15
- </li>`)
13
+ ? `<p class="${(0, classNames_1.classNames)(["zen-legend__item-value", item.hidden ? "zen-legend__item-value--hidden" : ""])}">${(0, escapeHtml_1.htmlEscape)(item.value)}</p>`
14
+ : ""}`;
15
+ const control = item.onClick
16
+ ? `<button type="button" class="zen-legend__button" aria-pressed="${!item.hidden}">${content}</button>`
17
+ : `<span class="zen-legend__button">${content}</span>`;
18
+ return `<li class="zen-legend__item" data-index="${index}">${control}</li>`;
19
+ })
16
20
  .join("");
17
21
  element.innerHTML = `<ul class='${classes}'>${listItems}</ul>`;
18
22
  const itemElements = element.querySelectorAll(".zen-legend__item");
@@ -1,4 +1,4 @@
1
- import { RegisterOptions, UseControllerProps } from "react-hook-form";
1
+ import { RefCallBack, RegisterOptions, UseControllerProps } from "react-hook-form";
2
2
  interface IRegisterOptions extends Partial<Pick<RegisterOptions, "required" | "min" | "max" | "maxLength" | "minLength" | "value" | "onChange" | "onBlur" | "disabled">> {
3
3
  }
4
4
  export interface IRulesProps extends IRegisterOptions {
@@ -8,6 +8,7 @@ export interface IRulesProps extends IRegisterOptions {
8
8
  interface IUseFormFieldValues extends IRegisterOptions {
9
9
  name?: string;
10
10
  pattern?: string;
11
+ ref?: RefCallBack;
11
12
  }
12
13
  export declare const useFormFieldValues: (controller?: UseControllerProps, props?: IRulesProps) => IUseFormFieldValues;
13
14
  export {};
@@ -40,6 +40,7 @@ const useFormFieldValues = (controller, props) => {
40
40
  value: field.value,
41
41
  onChange: field.onChange,
42
42
  onBlur: field.onBlur,
43
+ ref: field.ref,
43
44
  disabled: controller === null || controller === void 0 ? void 0 : controller.disabled,
44
45
  name: field.name,
45
46
  required: (0, getRuleValue_1.getRuleValue)((_a = controller === null || controller === void 0 ? void 0 : controller.rules) === null || _a === void 0 ? void 0 : _a.required),
@@ -0,0 +1,6 @@
1
+ import { Ref } from "react";
2
+ /**
3
+ * Merges two refs (e.g. the consumer ref and the one provided by React Hook Form).
4
+ * Without the second ref the first one is returned unchanged, so callers without a controller behave exactly as before.
5
+ */
6
+ export declare const useMergedRef: <T>(refA?: Ref<T>, refB?: Ref<T>) => Ref<T> | undefined;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMergedRef = void 0;
4
+ const react_1 = require("react");
5
+ const assignRef = (ref, node) => {
6
+ if (typeof ref === "function") {
7
+ return ref(node);
8
+ }
9
+ if (ref) {
10
+ ref.current = node;
11
+ }
12
+ return undefined;
13
+ };
14
+ const detachRef = (ref, cleanup) => {
15
+ if (typeof cleanup === "function") {
16
+ cleanup();
17
+ }
18
+ else {
19
+ assignRef(ref, null);
20
+ }
21
+ };
22
+ /**
23
+ * Merges two refs (e.g. the consumer ref and the one provided by React Hook Form).
24
+ * Without the second ref the first one is returned unchanged, so callers without a controller behave exactly as before.
25
+ */
26
+ const useMergedRef = (refA, refB) => {
27
+ const merged = (0, react_1.useCallback)((node) => {
28
+ const cleanupA = assignRef(refA, node);
29
+ const cleanupB = assignRef(refB, node);
30
+ return () => {
31
+ detachRef(refA, cleanupA);
32
+ detachRef(refB, cleanupB);
33
+ };
34
+ }, [refA, refB]);
35
+ return refB ? merged : refA;
36
+ };
37
+ exports.useMergedRef = useMergedRef;
@@ -78,6 +78,11 @@
78
78
  @heading-06-letter-spacing: 0;
79
79
  @heading-06-text-transformI: uppercase;
80
80
 
81
+ //data-xxxl
82
+ @data-xxxl-font-size: 42;
83
+ @data-xxxl-line-height: 52;
84
+ @data-xxxl-letter-spacing: 0;
85
+
81
86
  //data-01
82
87
  //data-xxl
83
88
  @data-01-font-size: 32;
@@ -338,6 +343,10 @@
338
343
  }
339
344
 
340
345
  // Data
346
+ .zen-data-xxxl {
347
+ .zen-font(@main-font-family, @data-xxxl-font-size, @data-xxxl-line-height, @data-xxxl-letter-spacing);
348
+ }
349
+
341
350
  .zen-data-xxl {
342
351
  .zen-font(@main-font-family, @data-01-font-size, @data-01-line-height);
343
352
  }
@@ -0,0 +1 @@
1
+ export * from "../datePickerCommon/hooks/useDateInputInner/dateInputInnerReducer";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Kept so that deep imports of the old path keep working; the module moved to datePickerCommon in 3.17.1.
18
+ __exportStar(require("../datePickerCommon/hooks/useDateInputInner/dateInputInnerReducer"), exports);
@@ -0,0 +1 @@
1
+ export * from "../datePickerCommon/types/dateInputRaw";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Kept so that deep imports of the old path keep working; the module moved to datePickerCommon in 3.17.1.
18
+ __exportStar(require("../datePickerCommon/types/dateInputRaw"), exports);
@@ -60,7 +60,13 @@ export declare const useDateRangeRawCore: (props: TWithDefaultOptions<TDateRange
60
60
  datesValidation: (val: any) => boolean;
61
61
  isDatesValid: import("react").RefObject<boolean>;
62
62
  previousStepOption: import("react").RefObject<string>;
63
- handleDateRangeSelection: (newVal: string) => void;
63
+ handleDateRangeSelection: (newVal: string, transformRange?: (range: {
64
+ from: Date;
65
+ to: Date;
66
+ }) => {
67
+ from: Date;
68
+ to: Date;
69
+ }) => void;
64
70
  handleApplyClick: () => void;
65
71
  handleCancelClick: () => void;
66
72
  handleClearClick: () => void;
@@ -219,12 +219,12 @@ const useDateRangeRawCore = (props, behavior) => {
219
219
  }, [isOpen, isStaleCustomDraft, prevSelection]);
220
220
  const handleDateRangeSelection = (0, react_1.useCallback)(
221
221
  // eslint-disable-next-line complexity
222
- newVal => {
223
- var _a, _b;
222
+ (newVal, transformRange) => {
223
+ var _a, _b, _c;
224
224
  const selection = options.find(option => option.id === newVal);
225
225
  newVal === customCalendarId_1.CUSTOM_CALENDAR_ID && setShowMobileCalendar(true);
226
226
  if (selection && newVal !== customCalendarId_1.CUSTOM_CALENDAR_ID && selection.getRange) {
227
- const range = selection.getRange();
227
+ const range = (_a = transformRange === null || transformRange === void 0 ? void 0 : transformRange(selection.getRange())) !== null && _a !== void 0 ? _a : selection.getRange();
228
228
  const normalizedDates = (0, normalizeDates_1.normalizeDates)(range.from.toISOString(), range.to.toISOString(), disableFutureDates, disablePastDates, disableDatesBefore, disableDatesAfter);
229
229
  const newRange = newVal === customCalendarId_1.CUSTOM_CALENDAR_ID ? {
230
230
  from: new Date(normalizedDates.from),
@@ -242,8 +242,8 @@ const useDateRangeRawCore = (props, behavior) => {
242
242
  }, newRange)));
243
243
  previousStepOption.current = "";
244
244
  } else {
245
- const startDateForNormalize = ((_a = selection === null || selection === void 0 ? void 0 : selection.getRange) === null || _a === void 0 ? void 0 : _a.call(selection)) && (selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.label) !== newVal ? selection.getRange().from : value === null || value === void 0 ? void 0 : value.from;
246
- const endDateForNormalize = ((_b = selection === null || selection === void 0 ? void 0 : selection.getRange) === null || _b === void 0 ? void 0 : _b.call(selection)) && (selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.label) !== newVal ? selection.getRange().to : value === null || value === void 0 ? void 0 : value.to;
245
+ const startDateForNormalize = ((_b = selection === null || selection === void 0 ? void 0 : selection.getRange) === null || _b === void 0 ? void 0 : _b.call(selection)) && (selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.label) !== newVal ? selection.getRange().from : value === null || value === void 0 ? void 0 : value.from;
246
+ const endDateForNormalize = ((_c = selection === null || selection === void 0 ? void 0 : selection.getRange) === null || _c === void 0 ? void 0 : _c.call(selection)) && (selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.label) !== newVal ? selection.getRange().to : value === null || value === void 0 ? void 0 : value.to;
247
247
  if (!datesValidation(startDateForNormalize === undefined && endDateForNormalize === undefined ? undefined : {
248
248
  from: startDateForNormalize,
249
249
  to: endDateForNormalize
@@ -0,0 +1 @@
1
+ export * from "../datePickerCommon/types/dateRangeRaw";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Kept so that deep imports of the old path keep working; the module moved to datePickerCommon in 3.17.1.
18
+ __exportStar(require("../datePickerCommon/types/dateRangeRaw"), exports);
@@ -0,0 +1 @@
1
+ export * from "../../datePickerCommon/utils/areMapsEqual";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Kept so that deep imports of the old path keep working; the module moved to datePickerCommon in 3.17.1.
18
+ __exportStar(require("../../datePickerCommon/utils/areMapsEqual"), exports);
@@ -12,7 +12,13 @@ interface IUseDateRangeNewParts {
12
12
  setShowMobileCalendar: (isVisible: boolean) => void;
13
13
  /** What was last applied; closing without Apply goes back to it. */
14
14
  prevSelection: IDateRangeValue | undefined;
15
- selectOption: (optionId: string) => void;
15
+ selectOption: (optionId: string, transformRange?: (range: {
16
+ from: Date;
17
+ to: Date;
18
+ }) => {
19
+ from: Date;
20
+ to: Date;
21
+ }) => void;
16
22
  segmentedTriggerRef: RefObject<HTMLElement | null>;
17
23
  hasApplyButton: boolean;
18
24
  defaultValue?: IDateRangeValue;
@@ -68,28 +68,37 @@ const useDateRangeNewParts = ({ isOpen, setIsOpen, isMobile, customDate, setCust
68
68
  const { rebaseToDay } = rangeEntry;
69
69
  const handleOptionSelect = (0, react_1.useCallback)((optionId) => {
70
70
  const before = customDate;
71
- selectOption(optionId);
72
- if (!timeSelect || optionId === customCalendarId_1.CUSTOM_CALENDAR_ID || !before.from || !before.to)
71
+ if (!timeSelect || optionId === customCalendarId_1.CUSTOM_CALENDAR_ID || !before.from || !before.to) {
72
+ selectOption(optionId);
73
73
  return;
74
+ }
74
75
  const { from: timeFrom, to: timeTo } = before;
75
76
  const keepTime = (range) => ({
76
- from: range.from ? rebaseToDay(range.from, timeFrom, false) : range.from,
77
- to: range.to ? rebaseToDay(range.to, timeTo, true) : range.to
77
+ from: new Date(rebaseToDay(range.from.toISOString(), timeFrom, false)),
78
+ to: new Date(rebaseToDay(range.to.toISOString(), timeTo, true))
78
79
  });
79
80
  // Kept times that leave no range (13:00 to 13:00 on a single-day preset, or an end before the start) would make a
80
81
  // range a form cannot take, so the preset keeps its own whole day then.
81
- const isEmpty = (range) => (0, rangeOrder_1.isEndBeforeStart)(range.from, range.to) || (!!range.from && range.from === range.to);
82
- setCustomDate(current => {
83
- const kept = keepTime(current);
84
- return isEmpty(kept) ? current : kept;
82
+ const isEmpty = (range) => (0, rangeOrder_1.isEndBeforeStart)(range.from.toISOString(), range.to.toISOString()) || range.from.getTime() === range.to.getTime();
83
+ selectOption(optionId, range => {
84
+ const kept = keepTime(range);
85
+ return isEmpty(kept) ? range : kept;
85
86
  });
86
- setSelectedRange(current => {
87
- if (!current)
88
- return current;
89
- const kept = keepTime({ from: current.from.toISOString(), to: current.to.toISOString() });
90
- return isEmpty(kept) ? current : Object.assign(Object.assign({}, current), { from: new Date(kept.from), to: new Date(kept.to) });
91
- });
92
- }, [customDate, rebaseToDay, selectOption, setCustomDate, setSelectedRange, timeSelect]);
87
+ if (hasApplyButton) {
88
+ setCustomDate(current => {
89
+ if (!current.from || !current.to)
90
+ return current;
91
+ const kept = keepTime({ from: new Date(current.from), to: new Date(current.to) });
92
+ return isEmpty(kept) ? current : { from: kept.from.toISOString(), to: kept.to.toISOString() };
93
+ });
94
+ setSelectedRange(current => {
95
+ if (!current)
96
+ return current;
97
+ const kept = keepTime(current);
98
+ return isEmpty(kept) ? current : Object.assign(Object.assign({}, current), { from: kept.from, to: kept.to });
99
+ });
100
+ }
101
+ }, [customDate, hasApplyButton, rebaseToDay, selectOption, setCustomDate, setSelectedRange, timeSelect]);
93
102
  // The new picker only compares the dates: the pills are not a selection of their own, any draft is a custom range.
94
103
  const isDraftUnchanged = (0, react_1.useMemo)(() => customDate.from === ((0, getRangeOption_1.isDateValid)(value === null || value === void 0 ? void 0 : value.from) ? value.from.toISOString() : undefined) &&
95
104
  customDate.to === ((0, getRangeOption_1.isDateValid)(value === null || value === void 0 ? void 0 : value.to) ? value.to.toISOString() : undefined), [customDate.from, customDate.to, value === null || value === void 0 ? void 0 : value.from, value === null || value === void 0 ? void 0 : value.to]);
@@ -305,12 +305,12 @@ const useDateRangeRawNew = props => {
305
305
  // Opened with no value, the draft starts on the default, or on today; Clear puts it back there rather than to nothing.
306
306
  const handleClear = (0, react_1.useCallback)(() => {
307
307
  handleClearClick();
308
- if (!hasApplyButton || defaultValue || value) return;
308
+ if (!hasApplyButton || defaultValue) return;
309
309
  const fallback = getFallbackRange();
310
310
  if (!fallback) return;
311
311
  setSelectedRange(fallback.labeled);
312
312
  setCustomDate(fallback.draft);
313
- }, [defaultValue, getFallbackRange, handleClearClick, hasApplyButton, setCustomDate, setSelectedRange, value]);
313
+ }, [defaultValue, getFallbackRange, handleClearClick, hasApplyButton, setCustomDate, setSelectedRange]);
314
314
  // The chip's X has no popup to press Apply in. With an Apply button the core only resets the draft, so the X reports the reset itself:
315
315
  // the default, or nothing when the value may be unset. Without one the core already does. The footer's Clear stays staged.
316
316
  const {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useRangeEntry = void 0;
4
4
  const react_1 = require("react");
5
+ const dateUtils_1 = require("../../calendar/dateUtils");
5
6
  const customCalendarId_1 = require("../../datePickerCommon/utils/customCalendarId");
6
7
  const toEditableFormat_1 = require("../../datePickerNew/components/dateSegmentInput/utils/toEditableFormat");
7
8
  const toEditableTimeFormat_1 = require("../../datePickerNew/components/dateSegmentInput/utils/toEditableTimeFormat");
@@ -62,13 +63,39 @@ const useRangeEntry = ({ customDate, setCustomDate, setSelectedRange, isOpen, lo
62
63
  }, [customDate, lockEndDate, lockStartDate, markCustom, raiseAdjustment, rebaseToDay, setCustomDate, toLocalDateTime, toReverseOffsetDateTime]);
63
64
  // A range edited by hand, dates typed or a time picked, is put in order and a locked end is kept; the banner says when an end moved.
64
65
  const commitEdited = (0, react_1.useCallback)((next) => {
66
+ var _a, _b;
65
67
  const { range: ordered, adjusted } = (0, rangeOrder_1.resolveRangeOrder)(customDate, (0, pinLockedEnds_1.pinLockedEnds)(next, lockStartDate, lockEndDate), rebaseToDay);
66
68
  const locked = (0, applyRangeLocks_1.applyRangeLocks)(customDate, ordered, lockStartDate, lockEndDate);
67
- setCustomDate(locked);
68
- markCustom(locked);
69
+ const start = locked.from ? new Date(locked.from) : undefined;
70
+ const end = locked.to ? new Date(locked.to) : undefined;
71
+ const crossesDisabledPeriod = start &&
72
+ end &&
73
+ (0, dateUtils_1.isDifferentPeriod)(toReverseOffsetDateTime(start), toReverseOffsetDateTime(end), disableFutureDates, disablePastDates, disableDatesBefore, disableDatesAfter);
74
+ const startChanged = locked.from !== customDate.from;
75
+ const validRange = crossesDisabledPeriod
76
+ ? startChanged && !lockStartDate
77
+ ? (0, dateUtils_1.getValidDatesForEnd)(toReverseOffsetDateTime, end, start, disableFutureDates, disablePastDates, disableDatesBefore, disableDatesAfter)
78
+ : (0, dateUtils_1.getValidDatesForStart)(toReverseOffsetDateTime, start, end, disableFutureDates, disablePastDates, disableDatesBefore, disableDatesAfter)
79
+ : undefined;
80
+ const committed = validRange ? { from: (_a = validRange.start) === null || _a === void 0 ? void 0 : _a.toISOString(), to: (_b = validRange.end) === null || _b === void 0 ? void 0 : _b.toISOString() } : locked;
81
+ setCustomDate(committed);
82
+ markCustom(committed);
69
83
  // The banner says an end moved, so it is raised only for an edit that was kept.
70
- raiseAdjustment(locked === customDate ? undefined : adjusted, locked);
71
- }, [customDate, lockEndDate, lockStartDate, markCustom, raiseAdjustment, rebaseToDay, setCustomDate]);
84
+ raiseAdjustment(committed === customDate ? undefined : adjusted, committed);
85
+ }, [
86
+ customDate,
87
+ disableDatesAfter,
88
+ disableDatesBefore,
89
+ disableFutureDates,
90
+ disablePastDates,
91
+ lockEndDate,
92
+ lockStartDate,
93
+ markCustom,
94
+ raiseAdjustment,
95
+ rebaseToDay,
96
+ setCustomDate,
97
+ toReverseOffsetDateTime
98
+ ]);
72
99
  // A time picked for one end (mobile). Unlike picking a day, the typed time replaces the end's own.
73
100
  const handleTimeSelect = (0, react_1.useCallback)((field, timeText) => {
74
101
  const current = customDate[field];