@jobber/components 6.114.0 → 6.114.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.
@@ -1,4 +1,4 @@
1
- export declare function useFocusOnSelectedDate(portalContainerId?: string): {
1
+ export declare function useFocusOnSelectedDate(): {
2
2
  ref: import("react").RefObject<HTMLDivElement | null>;
3
- focusOnSelectedDate: () => boolean;
3
+ focusOnSelectedDate: () => void;
4
4
  };
@@ -12652,7 +12652,7 @@ var DatePicker$1 = /** @class */ (function (_super) {
12652
12652
  var PRESELECT_CHANGE_VIA_INPUT = "input";
12653
12653
  var PRESELECT_CHANGE_VIA_NAVIGATE = "navigate";
12654
12654
 
12655
- var styles = {"datePickerWrapper":"OmFI-Bfdzgw-","fullWidth":"HWDFy10kcYA-","datePicker":"Ma55F5Y-XhE-","inline":"_58kEbTu-IAA-","portalContainer":"LDxKi0E-1rg-","header":"Epg-Ub8Dn9A-","month":"Wx3NP8La95k-","spinning":"o0JLwNATy-M-"};
12655
+ var styles = {"datePickerWrapper":"OmFI-Bfdzgw-","fullWidth":"HWDFy10kcYA-","datePicker":"Ma55F5Y-XhE-","inline":"_58kEbTu-IAA-","header":"Epg-Ub8Dn9A-","month":"Wx3NP8La95k-","spinning":"o0JLwNATy-M-"};
12656
12656
 
12657
12657
  function DatePickerCustomHeader({ monthDate, decreaseMonth, increaseMonth, prevMonthButtonDisabled, nextMonthButtonDisabled, }) {
12658
12658
  return (React.createElement("div", { className: styles.header },
@@ -12691,25 +12691,25 @@ function InternalActivator(props, ref) {
12691
12691
  }
12692
12692
  }
12693
12693
 
12694
- function useFocusOnSelectedDate(portalContainerId) {
12694
+ function useFocusOnSelectedDate() {
12695
12695
  const ref = React.useRef(null);
12696
- // Moves focus to the selected/pre-selected day in the calendar ([tabindex="0"]).
12697
- const focusOnSelectedDate = React.useCallback(() => {
12698
- const portalElement = portalContainerId
12699
- ? document.getElementById(portalContainerId)
12700
- : null;
12701
- const searchRoot = portalElement !== null && portalElement !== void 0 ? portalElement : ref.current;
12702
- const day = searchRoot === null || searchRoot === void 0 ? void 0 : searchRoot.querySelector('[tabindex="0"]');
12703
- if (day instanceof HTMLElement) {
12704
- day.focus();
12705
- return true;
12696
+ function focusOnSelectedDate() {
12697
+ var _a;
12698
+ const selectedDateClass = ".react-datepicker__day--selected";
12699
+ const selectedDate = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.querySelector(selectedDateClass);
12700
+ if (selectedDate instanceof HTMLDivElement) {
12701
+ selectedDate.focus();
12706
12702
  }
12707
- return false;
12708
- }, [portalContainerId]);
12703
+ }
12709
12704
  return { ref, focusOnSelectedDate };
12710
12705
  }
12711
12706
 
12712
- function getDatePickerClassNames(inline, open, fullWidth) {
12707
+ /*eslint max-statements: ["error", 14]*/
12708
+ function DatePicker({ onChange, onMonthChange, onOpenChange, activator, inline, selected, readonly = false, disabled = false, fullWidth = false, smartAutofocus = true, maxDate, minDate, highlightDates, firstDayOfWeek, }) {
12709
+ const { ref, focusOnSelectedDate } = useFocusOnSelectedDate();
12710
+ const [open, setOpen] = React.useState(false);
12711
+ const { dateFormat, firstDayOfWeek: contextFirstDayOfWeek } = AtlantisContext.useAtlantisContext();
12712
+ const effectiveFirstDayOfWeek = firstDayOfWeek !== null && firstDayOfWeek !== void 0 ? firstDayOfWeek : contextFirstDayOfWeek;
12713
12713
  const wrapperClassName = classnames(styles.datePickerWrapper, {
12714
12714
  // react-datepicker uses this class name to not close the date picker when
12715
12715
  // the activator is clicked
@@ -12724,58 +12724,44 @@ function getDatePickerClassNames(inline, open, fullWidth) {
12724
12724
  const datePickerClassNames = classnames(styles.datePicker, {
12725
12725
  [styles.inline]: inline,
12726
12726
  });
12727
- return { wrapperClassName, datePickerClassNames };
12728
- }
12729
- function useDatePickerHandlers(onChange, setOpen, onOpenChange, smartAutofocus, focusOnSelectedDate) {
12730
- const handleChange = React.useCallback((value) => {
12731
- onChange(value);
12732
- }, [onChange]);
12733
- const handleCalendarOpen = React.useCallback(() => {
12734
- setOpen(true);
12735
- onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
12736
- if (smartAutofocus) {
12737
- // The portal DOM may not be painted yet, so defer to the next frame
12738
- requestAnimationFrame(() => {
12739
- focusOnSelectedDate === null || focusOnSelectedDate === void 0 ? void 0 : focusOnSelectedDate();
12740
- });
12741
- }
12742
- }, [setOpen, onOpenChange, smartAutofocus, focusOnSelectedDate]);
12743
- const handleCalendarClose = React.useCallback(() => {
12744
- setOpen(false);
12745
- onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
12746
- }, [setOpen, onOpenChange]);
12747
- return { handleChange, handleCalendarOpen, handleCalendarClose };
12748
- }
12749
- function DatePicker({ onChange, onMonthChange, onOpenChange, activator, inline, selected, readonly = false, disabled = false, fullWidth = false, smartAutofocus = true, maxDate, minDate, highlightDates, firstDayOfWeek, }) {
12750
- const [open, setOpen] = React.useState(false);
12751
- const { dateFormat, firstDayOfWeek: contextFirstDayOfWeek } = AtlantisContext.useAtlantisContext();
12752
- const effectiveFirstDayOfWeek = firstDayOfWeek !== null && firstDayOfWeek !== void 0 ? firstDayOfWeek : contextFirstDayOfWeek;
12753
- const renderInsidePortal = !inline;
12754
- const uniquePortalId = React.useId();
12755
- const { ref, focusOnSelectedDate } = useFocusOnSelectedDate(uniquePortalId);
12756
- const { wrapperClassName, datePickerClassNames } = getDatePickerClassNames(inline !== null && inline !== void 0 ? inline : false, open, fullWidth !== null && fullWidth !== void 0 ? fullWidth : false);
12757
- const { pickerRef } = useEscapeKeyToCloseDatePicker(open, ref, focusOnSelectedDate, renderInsidePortal);
12758
- const { handleChange, handleCalendarOpen, handleCalendarClose } = useDatePickerHandlers(onChange, setOpen, onOpenChange, smartAutofocus !== null && smartAutofocus !== void 0 ? smartAutofocus : true, focusOnSelectedDate);
12759
- jobberHooks.useRefocusOnActivator(smartAutofocus ? open : false);
12760
- return (React.createElement("div", { className: wrapperClassName, ref: ref, "data-elevation": "elevated", onKeyDown: event => {
12761
- // Stop Escape from bubbling to parent floating elements (e.g. Modal).
12762
- if (event.key === "Escape" && open) {
12763
- event.stopPropagation();
12764
- }
12765
- } },
12766
- React.createElement(DatePicker$1, Object.assign({ ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React.createElement(DatePickerActivator, { activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
12727
+ const { pickerRef } = useEscapeKeyToCloseDatePicker(open, ref);
12728
+ if (smartAutofocus) {
12729
+ jobberHooks.useRefocusOnActivator(open);
12730
+ React.useEffect(focusOnSelectedDate, [open]);
12731
+ }
12732
+ return (React.createElement("div", { className: wrapperClassName, ref: ref, "data-elevation": "elevated" },
12733
+ React.createElement(DatePicker$1, { ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React.createElement(DatePickerActivator, { activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
12767
12734
  dateFormat,
12768
12735
  "P",
12769
12736
  "PP",
12770
12737
  "PPP",
12771
12738
  "MMM dd yyyy",
12772
12739
  "MMMM dd yyyy",
12773
- ], highlightDates: highlightDates, onMonthChange: onMonthChange, calendarStartDay: effectiveFirstDayOfWeek, popperPlacement: "bottom-start" }, (renderInsidePortal && { portalId: uniquePortalId }))),
12774
- renderInsidePortal && React.createElement(DatePickerPortal, { portalId: uniquePortalId })));
12740
+ ], highlightDates: highlightDates, onMonthChange: onMonthChange, calendarStartDay: effectiveFirstDayOfWeek, popperPlacement: "bottom-start" })));
12741
+ /**
12742
+ * The onChange callback on ReactDatePicker returns a Date and an Event, but
12743
+ * the onChange in our interface only provides the Date. Simplifying the code
12744
+ * by removing this function and passing it directly to the underlying
12745
+ * component breaks tests both here and downstream (i.e. the pattern
12746
+ * `expect(onChange).toHaveBeenCalledWith(date)` is commonly used and would
12747
+ * fail).
12748
+ */
12749
+ function handleChange(value) {
12750
+ // TODO: Ticket created to update all DatePicker and InputDate usages to accept Date | null
12751
+ onChange(value);
12752
+ }
12753
+ function handleCalendarOpen() {
12754
+ setOpen(true);
12755
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
12756
+ }
12757
+ function handleCalendarClose() {
12758
+ setOpen(false);
12759
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
12760
+ }
12775
12761
  }
12776
- function useEscapeKeyToCloseDatePicker(open, ref, focusOnSelectedDate, isPortalled) {
12762
+ function useEscapeKeyToCloseDatePicker(open, ref) {
12777
12763
  const pickerRef = React.useRef(null);
12778
- const handleKeyDown = (event) => {
12764
+ const escFunction = (event) => {
12779
12765
  var _a;
12780
12766
  if (event.key === "Escape" && open) {
12781
12767
  // Close the picker ourselves and prevent propagation so that ESC presses with the picker open
@@ -12783,38 +12769,18 @@ function useEscapeKeyToCloseDatePicker(open, ref, focusOnSelectedDate, isPortall
12783
12769
  (_a = pickerRef.current) === null || _a === void 0 ? void 0 : _a.setOpen(false);
12784
12770
  event.stopPropagation();
12785
12771
  }
12786
- if (event.key === "Tab" && open && isPortalled) {
12787
- // When portalled, Tab from the activator doesn't reach the calendar.
12788
- // Intercept Tab to move focus there (mainly when smartAutofocus is false
12789
- // and focus stayed in the input).
12790
- const focused = focusOnSelectedDate();
12791
- if (focused) {
12792
- event.preventDefault();
12793
- }
12794
- }
12795
12772
  };
12796
12773
  React.useEffect(() => {
12797
12774
  var _a;
12798
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener("keydown", handleKeyDown);
12775
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener("keydown", escFunction);
12799
12776
  return () => {
12800
12777
  var _a;
12801
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", handleKeyDown);
12778
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", escFunction);
12802
12779
  };
12803
- }, [open, ref, pickerRef, isPortalled]);
12780
+ }, [open, ref, pickerRef]);
12804
12781
  return {
12805
12782
  pickerRef,
12806
12783
  };
12807
12784
  }
12808
- function DatePickerPortal({ portalId }) {
12809
- const nodeId = floatingUi_react.useFloatingNodeId();
12810
- const parentNodeId = floatingUi_react.useFloatingParentNodeId();
12811
- const portalDiv = React.createElement("div", { id: portalId, className: styles.portalContainer });
12812
- if (parentNodeId) {
12813
- return (React.createElement(floatingUi_react.FloatingTree, null,
12814
- React.createElement(floatingUi_react.FloatingNode, { id: nodeId },
12815
- React.createElement(floatingUi_react.FloatingPortal, null, portalDiv))));
12816
- }
12817
- return React.createElement(floatingUi_react.FloatingPortal, null, portalDiv);
12818
- }
12819
12785
 
12820
12786
  exports.DatePicker = DatePicker;
@@ -1,7 +1,7 @@
1
- import React__default, { cloneElement, Component, createRef, useRef, useCallback, useEffect, createElement, forwardRef, isValidElement, useState, useId } from 'react';
1
+ import React__default, { cloneElement, Component, createRef, useRef, useCallback, useEffect, createElement, forwardRef, isValidElement, useState } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { c as clsx } from './clsx-es.js';
4
- import { u as useFloating, b as autoUpdate, f as flip, o as offset, a as arrow, w as FloatingArrow, j as useFloatingNodeId, i as useFloatingParentNodeId, k as FloatingTree, m as FloatingNode, F as FloatingPortal } from './floating-ui.react-es.js';
4
+ import { u as useFloating, b as autoUpdate, f as flip, o as offset, a as arrow, w as FloatingArrow } from './floating-ui.react-es.js';
5
5
  import ReactDOM__default from 'react-dom';
6
6
  import { useRefocusOnActivator } from '@jobber/hooks';
7
7
  import { T as Typography } from './Typography-es.js';
@@ -12650,7 +12650,7 @@ var DatePicker$1 = /** @class */ (function (_super) {
12650
12650
  var PRESELECT_CHANGE_VIA_INPUT = "input";
12651
12651
  var PRESELECT_CHANGE_VIA_NAVIGATE = "navigate";
12652
12652
 
12653
- var styles = {"datePickerWrapper":"OmFI-Bfdzgw-","fullWidth":"HWDFy10kcYA-","datePicker":"Ma55F5Y-XhE-","inline":"_58kEbTu-IAA-","portalContainer":"LDxKi0E-1rg-","header":"Epg-Ub8Dn9A-","month":"Wx3NP8La95k-","spinning":"o0JLwNATy-M-"};
12653
+ var styles = {"datePickerWrapper":"OmFI-Bfdzgw-","fullWidth":"HWDFy10kcYA-","datePicker":"Ma55F5Y-XhE-","inline":"_58kEbTu-IAA-","header":"Epg-Ub8Dn9A-","month":"Wx3NP8La95k-","spinning":"o0JLwNATy-M-"};
12654
12654
 
12655
12655
  function DatePickerCustomHeader({ monthDate, decreaseMonth, increaseMonth, prevMonthButtonDisabled, nextMonthButtonDisabled, }) {
12656
12656
  return (React__default.createElement("div", { className: styles.header },
@@ -12689,25 +12689,25 @@ function InternalActivator(props, ref) {
12689
12689
  }
12690
12690
  }
12691
12691
 
12692
- function useFocusOnSelectedDate(portalContainerId) {
12692
+ function useFocusOnSelectedDate() {
12693
12693
  const ref = useRef(null);
12694
- // Moves focus to the selected/pre-selected day in the calendar ([tabindex="0"]).
12695
- const focusOnSelectedDate = useCallback(() => {
12696
- const portalElement = portalContainerId
12697
- ? document.getElementById(portalContainerId)
12698
- : null;
12699
- const searchRoot = portalElement !== null && portalElement !== void 0 ? portalElement : ref.current;
12700
- const day = searchRoot === null || searchRoot === void 0 ? void 0 : searchRoot.querySelector('[tabindex="0"]');
12701
- if (day instanceof HTMLElement) {
12702
- day.focus();
12703
- return true;
12694
+ function focusOnSelectedDate() {
12695
+ var _a;
12696
+ const selectedDateClass = ".react-datepicker__day--selected";
12697
+ const selectedDate = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.querySelector(selectedDateClass);
12698
+ if (selectedDate instanceof HTMLDivElement) {
12699
+ selectedDate.focus();
12704
12700
  }
12705
- return false;
12706
- }, [portalContainerId]);
12701
+ }
12707
12702
  return { ref, focusOnSelectedDate };
12708
12703
  }
12709
12704
 
12710
- function getDatePickerClassNames(inline, open, fullWidth) {
12705
+ /*eslint max-statements: ["error", 14]*/
12706
+ function DatePicker({ onChange, onMonthChange, onOpenChange, activator, inline, selected, readonly = false, disabled = false, fullWidth = false, smartAutofocus = true, maxDate, minDate, highlightDates, firstDayOfWeek, }) {
12707
+ const { ref, focusOnSelectedDate } = useFocusOnSelectedDate();
12708
+ const [open, setOpen] = useState(false);
12709
+ const { dateFormat, firstDayOfWeek: contextFirstDayOfWeek } = useAtlantisContext();
12710
+ const effectiveFirstDayOfWeek = firstDayOfWeek !== null && firstDayOfWeek !== void 0 ? firstDayOfWeek : contextFirstDayOfWeek;
12711
12711
  const wrapperClassName = classnames(styles.datePickerWrapper, {
12712
12712
  // react-datepicker uses this class name to not close the date picker when
12713
12713
  // the activator is clicked
@@ -12722,58 +12722,44 @@ function getDatePickerClassNames(inline, open, fullWidth) {
12722
12722
  const datePickerClassNames = classnames(styles.datePicker, {
12723
12723
  [styles.inline]: inline,
12724
12724
  });
12725
- return { wrapperClassName, datePickerClassNames };
12726
- }
12727
- function useDatePickerHandlers(onChange, setOpen, onOpenChange, smartAutofocus, focusOnSelectedDate) {
12728
- const handleChange = useCallback((value) => {
12729
- onChange(value);
12730
- }, [onChange]);
12731
- const handleCalendarOpen = useCallback(() => {
12732
- setOpen(true);
12733
- onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
12734
- if (smartAutofocus) {
12735
- // The portal DOM may not be painted yet, so defer to the next frame
12736
- requestAnimationFrame(() => {
12737
- focusOnSelectedDate === null || focusOnSelectedDate === void 0 ? void 0 : focusOnSelectedDate();
12738
- });
12739
- }
12740
- }, [setOpen, onOpenChange, smartAutofocus, focusOnSelectedDate]);
12741
- const handleCalendarClose = useCallback(() => {
12742
- setOpen(false);
12743
- onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
12744
- }, [setOpen, onOpenChange]);
12745
- return { handleChange, handleCalendarOpen, handleCalendarClose };
12746
- }
12747
- function DatePicker({ onChange, onMonthChange, onOpenChange, activator, inline, selected, readonly = false, disabled = false, fullWidth = false, smartAutofocus = true, maxDate, minDate, highlightDates, firstDayOfWeek, }) {
12748
- const [open, setOpen] = useState(false);
12749
- const { dateFormat, firstDayOfWeek: contextFirstDayOfWeek } = useAtlantisContext();
12750
- const effectiveFirstDayOfWeek = firstDayOfWeek !== null && firstDayOfWeek !== void 0 ? firstDayOfWeek : contextFirstDayOfWeek;
12751
- const renderInsidePortal = !inline;
12752
- const uniquePortalId = useId();
12753
- const { ref, focusOnSelectedDate } = useFocusOnSelectedDate(uniquePortalId);
12754
- const { wrapperClassName, datePickerClassNames } = getDatePickerClassNames(inline !== null && inline !== void 0 ? inline : false, open, fullWidth !== null && fullWidth !== void 0 ? fullWidth : false);
12755
- const { pickerRef } = useEscapeKeyToCloseDatePicker(open, ref, focusOnSelectedDate, renderInsidePortal);
12756
- const { handleChange, handleCalendarOpen, handleCalendarClose } = useDatePickerHandlers(onChange, setOpen, onOpenChange, smartAutofocus !== null && smartAutofocus !== void 0 ? smartAutofocus : true, focusOnSelectedDate);
12757
- useRefocusOnActivator(smartAutofocus ? open : false);
12758
- return (React__default.createElement("div", { className: wrapperClassName, ref: ref, "data-elevation": "elevated", onKeyDown: event => {
12759
- // Stop Escape from bubbling to parent floating elements (e.g. Modal).
12760
- if (event.key === "Escape" && open) {
12761
- event.stopPropagation();
12762
- }
12763
- } },
12764
- React__default.createElement(DatePicker$1, Object.assign({ ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React__default.createElement(DatePickerActivator, { activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React__default.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
12725
+ const { pickerRef } = useEscapeKeyToCloseDatePicker(open, ref);
12726
+ if (smartAutofocus) {
12727
+ useRefocusOnActivator(open);
12728
+ useEffect(focusOnSelectedDate, [open]);
12729
+ }
12730
+ return (React__default.createElement("div", { className: wrapperClassName, ref: ref, "data-elevation": "elevated" },
12731
+ React__default.createElement(DatePicker$1, { ref: pickerRef, calendarClassName: datePickerClassNames, showPopperArrow: false, selected: selected, inline: inline, disabled: disabled, readOnly: readonly, onChange: handleChange, maxDate: maxDate, preventOpenOnFocus: true, minDate: minDate, useWeekdaysShort: true, customInput: React__default.createElement(DatePickerActivator, { activator: activator, fullWidth: fullWidth }), renderCustomHeader: props => React__default.createElement(DatePickerCustomHeader, Object.assign({}, props)), onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose, dateFormat: [
12765
12732
  dateFormat,
12766
12733
  "P",
12767
12734
  "PP",
12768
12735
  "PPP",
12769
12736
  "MMM dd yyyy",
12770
12737
  "MMMM dd yyyy",
12771
- ], highlightDates: highlightDates, onMonthChange: onMonthChange, calendarStartDay: effectiveFirstDayOfWeek, popperPlacement: "bottom-start" }, (renderInsidePortal && { portalId: uniquePortalId }))),
12772
- renderInsidePortal && React__default.createElement(DatePickerPortal, { portalId: uniquePortalId })));
12738
+ ], highlightDates: highlightDates, onMonthChange: onMonthChange, calendarStartDay: effectiveFirstDayOfWeek, popperPlacement: "bottom-start" })));
12739
+ /**
12740
+ * The onChange callback on ReactDatePicker returns a Date and an Event, but
12741
+ * the onChange in our interface only provides the Date. Simplifying the code
12742
+ * by removing this function and passing it directly to the underlying
12743
+ * component breaks tests both here and downstream (i.e. the pattern
12744
+ * `expect(onChange).toHaveBeenCalledWith(date)` is commonly used and would
12745
+ * fail).
12746
+ */
12747
+ function handleChange(value) {
12748
+ // TODO: Ticket created to update all DatePicker and InputDate usages to accept Date | null
12749
+ onChange(value);
12750
+ }
12751
+ function handleCalendarOpen() {
12752
+ setOpen(true);
12753
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
12754
+ }
12755
+ function handleCalendarClose() {
12756
+ setOpen(false);
12757
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
12758
+ }
12773
12759
  }
12774
- function useEscapeKeyToCloseDatePicker(open, ref, focusOnSelectedDate, isPortalled) {
12760
+ function useEscapeKeyToCloseDatePicker(open, ref) {
12775
12761
  const pickerRef = useRef(null);
12776
- const handleKeyDown = (event) => {
12762
+ const escFunction = (event) => {
12777
12763
  var _a;
12778
12764
  if (event.key === "Escape" && open) {
12779
12765
  // Close the picker ourselves and prevent propagation so that ESC presses with the picker open
@@ -12781,38 +12767,18 @@ function useEscapeKeyToCloseDatePicker(open, ref, focusOnSelectedDate, isPortall
12781
12767
  (_a = pickerRef.current) === null || _a === void 0 ? void 0 : _a.setOpen(false);
12782
12768
  event.stopPropagation();
12783
12769
  }
12784
- if (event.key === "Tab" && open && isPortalled) {
12785
- // When portalled, Tab from the activator doesn't reach the calendar.
12786
- // Intercept Tab to move focus there (mainly when smartAutofocus is false
12787
- // and focus stayed in the input).
12788
- const focused = focusOnSelectedDate();
12789
- if (focused) {
12790
- event.preventDefault();
12791
- }
12792
- }
12793
12770
  };
12794
12771
  useEffect(() => {
12795
12772
  var _a;
12796
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener("keydown", handleKeyDown);
12773
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener("keydown", escFunction);
12797
12774
  return () => {
12798
12775
  var _a;
12799
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", handleKeyDown);
12776
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", escFunction);
12800
12777
  };
12801
- }, [open, ref, pickerRef, isPortalled]);
12778
+ }, [open, ref, pickerRef]);
12802
12779
  return {
12803
12780
  pickerRef,
12804
12781
  };
12805
12782
  }
12806
- function DatePickerPortal({ portalId }) {
12807
- const nodeId = useFloatingNodeId();
12808
- const parentNodeId = useFloatingParentNodeId();
12809
- const portalDiv = React__default.createElement("div", { id: portalId, className: styles.portalContainer });
12810
- if (parentNodeId) {
12811
- return (React__default.createElement(FloatingTree, null,
12812
- React__default.createElement(FloatingNode, { id: nodeId },
12813
- React__default.createElement(FloatingPortal, null, portalDiv))));
12814
- }
12815
- return React__default.createElement(FloatingPortal, null, portalDiv);
12816
- }
12817
12783
 
12818
12784
  export { DatePicker as D };
package/dist/styles.css CHANGED
@@ -7518,12 +7518,9 @@ h2.react-datepicker__current-month {
7518
7518
  width: 100%;
7519
7519
  max-width: 100%;
7520
7520
  }
7521
- .LDxKi0E-1rg- {
7522
- position: fixed;
7523
- top: 0;
7524
- left: 0;
7525
- z-index: 1001;
7526
- z-index: var(--elevation-modal);
7521
+ .OmFI-Bfdzgw- .react-datepicker-popper {
7522
+ z-index: 6;
7523
+ z-index: var(--elevation-datepicker);
7527
7524
  }
7528
7525
  .Ma55F5Y-XhE- .react-datepicker__header {
7529
7526
  padding: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.114.0",
3
+ "version": "6.114.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -538,5 +538,5 @@
538
538
  "> 1%",
539
539
  "IE 10"
540
540
  ],
541
- "gitHead": "fa776129b22e49b376813fafbbfdfe3d48ea88e4"
541
+ "gitHead": "8e79d0138c20e8e2b0eb8839296cd85cb9c8e403"
542
542
  }