@jobber/components 6.111.7 → 6.112.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(): {
1
+ export declare function useFocusOnSelectedDate(portalContainerId?: string): {
2
2
  ref: import("react").RefObject<HTMLDivElement | null>;
3
- focusOnSelectedDate: () => void;
3
+ focusOnSelectedDate: () => boolean;
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-","header":"Epg-Ub8Dn9A-","month":"Wx3NP8La95k-","spinning":"o0JLwNATy-M-"};
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-"};
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() {
12694
+ function useFocusOnSelectedDate(portalContainerId) {
12695
12695
  const ref = React.useRef(null);
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();
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;
12702
12706
  }
12703
- }
12707
+ return false;
12708
+ }, [portalContainerId]);
12704
12709
  return { ref, focusOnSelectedDate };
12705
12710
  }
12706
12711
 
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;
12712
+ function getDatePickerClassNames(inline, open, fullWidth) {
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,44 +12724,58 @@ function DatePicker({ onChange, onMonthChange, onOpenChange, activator, inline,
12724
12724
  const datePickerClassNames = classnames(styles.datePicker, {
12725
12725
  [styles.inline]: inline,
12726
12726
  });
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: [
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: [
12734
12767
  dateFormat,
12735
12768
  "P",
12736
12769
  "PP",
12737
12770
  "PPP",
12738
12771
  "MMM dd yyyy",
12739
12772
  "MMMM dd yyyy",
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
- }
12773
+ ], highlightDates: highlightDates, onMonthChange: onMonthChange, calendarStartDay: effectiveFirstDayOfWeek, popperPlacement: "bottom-start" }, (renderInsidePortal && { portalId: uniquePortalId }))),
12774
+ renderInsidePortal && React.createElement(DatePickerPortal, { portalId: uniquePortalId })));
12761
12775
  }
12762
- function useEscapeKeyToCloseDatePicker(open, ref) {
12776
+ function useEscapeKeyToCloseDatePicker(open, ref, focusOnSelectedDate, isPortalled) {
12763
12777
  const pickerRef = React.useRef(null);
12764
- const escFunction = (event) => {
12778
+ const handleKeyDown = (event) => {
12765
12779
  var _a;
12766
12780
  if (event.key === "Escape" && open) {
12767
12781
  // Close the picker ourselves and prevent propagation so that ESC presses with the picker open
@@ -12769,18 +12783,38 @@ function useEscapeKeyToCloseDatePicker(open, ref) {
12769
12783
  (_a = pickerRef.current) === null || _a === void 0 ? void 0 : _a.setOpen(false);
12770
12784
  event.stopPropagation();
12771
12785
  }
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
+ }
12772
12795
  };
12773
12796
  React.useEffect(() => {
12774
12797
  var _a;
12775
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener("keydown", escFunction);
12798
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener("keydown", handleKeyDown);
12776
12799
  return () => {
12777
12800
  var _a;
12778
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", escFunction);
12801
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", handleKeyDown);
12779
12802
  };
12780
- }, [open, ref, pickerRef]);
12803
+ }, [open, ref, pickerRef, isPortalled]);
12781
12804
  return {
12782
12805
  pickerRef,
12783
12806
  };
12784
12807
  }
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
+ }
12785
12819
 
12786
12820
  exports.DatePicker = DatePicker;
@@ -1,7 +1,7 @@
1
- import React__default, { cloneElement, Component, createRef, useRef, useCallback, useEffect, createElement, forwardRef, isValidElement, useState } from 'react';
1
+ import React__default, { cloneElement, Component, createRef, useRef, useCallback, useEffect, createElement, forwardRef, isValidElement, useState, useId } 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 } 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, j as useFloatingNodeId, i as useFloatingParentNodeId, k as FloatingTree, m as FloatingNode, F as FloatingPortal } 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-","header":"Epg-Ub8Dn9A-","month":"Wx3NP8La95k-","spinning":"o0JLwNATy-M-"};
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-"};
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() {
12692
+ function useFocusOnSelectedDate(portalContainerId) {
12693
12693
  const ref = useRef(null);
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();
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;
12700
12704
  }
12701
- }
12705
+ return false;
12706
+ }, [portalContainerId]);
12702
12707
  return { ref, focusOnSelectedDate };
12703
12708
  }
12704
12709
 
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;
12710
+ function getDatePickerClassNames(inline, open, fullWidth) {
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,44 +12722,58 @@ function DatePicker({ onChange, onMonthChange, onOpenChange, activator, inline,
12722
12722
  const datePickerClassNames = classnames(styles.datePicker, {
12723
12723
  [styles.inline]: inline,
12724
12724
  });
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: [
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: [
12732
12765
  dateFormat,
12733
12766
  "P",
12734
12767
  "PP",
12735
12768
  "PPP",
12736
12769
  "MMM dd yyyy",
12737
12770
  "MMMM dd yyyy",
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
- }
12771
+ ], highlightDates: highlightDates, onMonthChange: onMonthChange, calendarStartDay: effectiveFirstDayOfWeek, popperPlacement: "bottom-start" }, (renderInsidePortal && { portalId: uniquePortalId }))),
12772
+ renderInsidePortal && React__default.createElement(DatePickerPortal, { portalId: uniquePortalId })));
12759
12773
  }
12760
- function useEscapeKeyToCloseDatePicker(open, ref) {
12774
+ function useEscapeKeyToCloseDatePicker(open, ref, focusOnSelectedDate, isPortalled) {
12761
12775
  const pickerRef = useRef(null);
12762
- const escFunction = (event) => {
12776
+ const handleKeyDown = (event) => {
12763
12777
  var _a;
12764
12778
  if (event.key === "Escape" && open) {
12765
12779
  // Close the picker ourselves and prevent propagation so that ESC presses with the picker open
@@ -12767,18 +12781,38 @@ function useEscapeKeyToCloseDatePicker(open, ref) {
12767
12781
  (_a = pickerRef.current) === null || _a === void 0 ? void 0 : _a.setOpen(false);
12768
12782
  event.stopPropagation();
12769
12783
  }
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
+ }
12770
12793
  };
12771
12794
  useEffect(() => {
12772
12795
  var _a;
12773
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener("keydown", escFunction);
12796
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener("keydown", handleKeyDown);
12774
12797
  return () => {
12775
12798
  var _a;
12776
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", escFunction);
12799
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", handleKeyDown);
12777
12800
  };
12778
- }, [open, ref, pickerRef]);
12801
+ }, [open, ref, pickerRef, isPortalled]);
12779
12802
  return {
12780
12803
  pickerRef,
12781
12804
  };
12782
12805
  }
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
+ }
12783
12817
 
12784
12818
  export { DatePicker as D };
@@ -168,7 +168,7 @@ export interface MenuItemIconComposableProps extends IconProps {
168
168
  export interface MenuContentComposableProps extends UnsafeProps {
169
169
  readonly children: ReactNode;
170
170
  }
171
- export interface MenuTriggerComposableProps {
171
+ export interface MenuTriggerComposableProps extends UnsafeProps {
172
172
  /**
173
173
  * Accessible name for the trigger.
174
174
  */
package/dist/Menu-cjs.js CHANGED
@@ -295,9 +295,10 @@ function getDerivedAnimation(open, animation) {
295
295
  // so the Popover can be removed from the DOM once exit completes.
296
296
  return animation === "unmounted" ? "unmounted" : "hidden";
297
297
  }
298
- const MenuTriggerComposable = React.forwardRef(function MenuTriggerComposable({ ariaLabel, children }, ref) {
298
+ const MenuTriggerComposable = React.forwardRef(function MenuTriggerComposable({ ariaLabel, children, UNSAFE_style, UNSAFE_className }, ref) {
299
+ const className = classnames(styles.triggerWrapper, UNSAFE_className);
299
300
  return (React.createElement($3b117e43dc0ca95d$export$27c701ed9e449e99, { "aria-label": ariaLabel },
300
- React.createElement("div", { role: "button", className: styles.triggerWrapper, ref: ref }, children)));
301
+ React.createElement("div", { role: "button", className: className, ref: ref, style: UNSAFE_style }, children)));
301
302
  });
302
303
  function MenuContentComposable({ children, UNSAFE_style, UNSAFE_className, }) {
303
304
  const { state: animation, setState } = useMenuAnimation();
package/dist/Menu-es.js CHANGED
@@ -293,9 +293,10 @@ function getDerivedAnimation(open, animation) {
293
293
  // so the Popover can be removed from the DOM once exit completes.
294
294
  return animation === "unmounted" ? "unmounted" : "hidden";
295
295
  }
296
- const MenuTriggerComposable = React__default.forwardRef(function MenuTriggerComposable({ ariaLabel, children }, ref) {
296
+ const MenuTriggerComposable = React__default.forwardRef(function MenuTriggerComposable({ ariaLabel, children, UNSAFE_style, UNSAFE_className }, ref) {
297
+ const className = classnames(styles.triggerWrapper, UNSAFE_className);
297
298
  return (React__default.createElement($3b117e43dc0ca95d$export$27c701ed9e449e99, { "aria-label": ariaLabel },
298
- React__default.createElement("div", { role: "button", className: styles.triggerWrapper, ref: ref }, children)));
299
+ React__default.createElement("div", { role: "button", className: className, ref: ref, style: UNSAFE_style }, children)));
299
300
  });
300
301
  function MenuContentComposable({ children, UNSAFE_style, UNSAFE_className, }) {
301
302
  const { state: animation, setState } = useMenuAnimation();
package/dist/styles.css CHANGED
@@ -7383,9 +7383,12 @@ h2.react-datepicker__current-month {
7383
7383
  width: 100%;
7384
7384
  max-width: 100%;
7385
7385
  }
7386
- .OmFI-Bfdzgw- .react-datepicker-popper {
7387
- z-index: 6;
7388
- z-index: var(--elevation-datepicker);
7386
+ .LDxKi0E-1rg- {
7387
+ position: fixed;
7388
+ top: 0;
7389
+ left: 0;
7390
+ z-index: 1001;
7391
+ z-index: var(--elevation-modal);
7389
7392
  }
7390
7393
  .Ma55F5Y-XhE- .react-datepicker__header {
7391
7394
  padding: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.111.7",
3
+ "version": "6.112.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": "cca677d99a6152517fe9f4c265af04a219113966"
541
+ "gitHead": "6a70e6fdb7ebd0925285306df14b17ba21d78679"
542
542
  }