@jobber/components 6.114.1 → 6.114.6

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.
@@ -10,7 +10,6 @@ interface FloatingMenuProps<Value extends OptionLike> {
10
10
  readonly className: string;
11
11
  readonly floatingStyles: React.CSSProperties;
12
12
  readonly transitionStyles: React.CSSProperties;
13
- readonly menuWidth?: number;
14
13
  readonly menuStyle?: React.CSSProperties;
15
14
  readonly renderable: Array<RenderItem<Value>>;
16
15
  readonly persistentsHeaders: Array<MenuHeader<Record<string, unknown>>>;
@@ -57,5 +56,5 @@ interface FloatingMenuProps<Value extends OptionLike> {
57
56
  };
58
57
  };
59
58
  }
60
- export declare function FloatingMenu<Value extends OptionLike>({ context, getFloatingProps, refs, listboxId, className, floatingStyles, transitionStyles, menuWidth, menuStyle, renderable, persistentsHeaders, persistentsFooters, activeIndex, headerInteractiveCount, middleNavigableCount, getItemProps, listRef, onSelection, onAction, onInteractionPointerDown, getOptionLabel, isOptionSelected, loading, showEmptyStateMessage, emptyStateMessage, customRenderLoading, customRenderOption, customRenderSection, customRenderAction, customRenderHeader, customRenderFooter, slotOverrides, }: FloatingMenuProps<Value>): React.JSX.Element;
59
+ export declare function FloatingMenu<Value extends OptionLike>({ context, getFloatingProps, refs, listboxId, className, floatingStyles, transitionStyles, menuStyle, renderable, persistentsHeaders, persistentsFooters, activeIndex, headerInteractiveCount, middleNavigableCount, getItemProps, listRef, onSelection, onAction, onInteractionPointerDown, getOptionLabel, isOptionSelected, loading, showEmptyStateMessage, emptyStateMessage, customRenderLoading, customRenderOption, customRenderSection, customRenderAction, customRenderHeader, customRenderFooter, slotOverrides, }: FloatingMenuProps<Value>): React.JSX.Element;
61
60
  export {};
@@ -133,6 +133,11 @@ function invokeActiveItemOnEnter(event, activeIndex, renderable, onSelect, onAct
133
133
 
134
134
  const MENU_OFFSET = design.tokens["space-small"];
135
135
  const AUTOCOMPLETE_MAX_HEIGHT = 300;
136
+ function useStableSetReference(refs) {
137
+ const latestRefs = React.useRef(refs);
138
+ latestRefs.current = refs;
139
+ return React.useCallback((el) => latestRefs.current.setReference(el), []);
140
+ }
136
141
  function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuOpen, onMenuClose, selectedIndex, readOnly = false, disabled = false, outsidePressExcludeSelector, }) {
137
142
  const [open, setOpen] = React.useState(false);
138
143
  const [activeIndex, setActiveIndex] = React.useState(null);
@@ -157,12 +162,13 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
157
162
  floatingUi_react.offset(MENU_OFFSET),
158
163
  floatingUi_react.flip({ fallbackPlacements: ["top"] }),
159
164
  floatingUi_react.size({
160
- apply({ availableHeight, elements }) {
165
+ apply({ availableHeight, rects, elements }) {
161
166
  const maxHeight$1 = maxHeight.calculateMaxHeight(availableHeight, {
162
167
  maxHeight: AUTOCOMPLETE_MAX_HEIGHT,
163
168
  });
164
169
  Object.assign(elements.floating.style, {
165
170
  maxHeight: `${maxHeight$1}px`,
171
+ width: `${rects.reference.width}px`,
166
172
  });
167
173
  },
168
174
  }),
@@ -214,7 +220,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
214
220
  return prev >= navigableCount ? navigableCount - 1 : prev;
215
221
  });
216
222
  }, [navigableCount, setActiveIndex, listRef]);
217
- const setReferenceElement = React.useCallback((el) => refs.setReference(el), [refs]);
223
+ const setReferenceElement = useStableSetReference(refs);
218
224
  return {
219
225
  refs,
220
226
  floatingStyles,
@@ -1088,7 +1094,7 @@ function DefaultTextPersistentContent({ persistent, }) {
1088
1094
  return React.createElement("div", { className: styles$1.textPersistent }, persistent.label);
1089
1095
  }
1090
1096
 
1091
- function FloatingMenu({ context, getFloatingProps, refs, listboxId, className, floatingStyles, transitionStyles, menuWidth, menuStyle, renderable, persistentsHeaders, persistentsFooters, activeIndex, headerInteractiveCount, middleNavigableCount, getItemProps, listRef, onSelection, onAction, onInteractionPointerDown, getOptionLabel, isOptionSelected, loading, showEmptyStateMessage, emptyStateMessage, customRenderLoading, customRenderOption, customRenderSection, customRenderAction, customRenderHeader, customRenderFooter, slotOverrides, }) {
1097
+ function FloatingMenu({ context, getFloatingProps, refs, listboxId, className, floatingStyles, transitionStyles, menuStyle, renderable, persistentsHeaders, persistentsFooters, activeIndex, headerInteractiveCount, middleNavigableCount, getItemProps, listRef, onSelection, onAction, onInteractionPointerDown, getOptionLabel, isOptionSelected, loading, showEmptyStateMessage, emptyStateMessage, customRenderLoading, customRenderOption, customRenderSection, customRenderAction, customRenderHeader, customRenderFooter, slotOverrides, }) {
1092
1098
  var _a, _b, _c, _d;
1093
1099
  const activeIndexForMiddle = activeIndex != null ? activeIndex - headerInteractiveCount : null;
1094
1100
  return (React.createElement(floatingUi_react.FloatingPortal, null,
@@ -1101,7 +1107,7 @@ function FloatingMenu({ context, getFloatingProps, refs, listboxId, className, f
1101
1107
  id: listboxId,
1102
1108
  role: "listbox",
1103
1109
  className,
1104
- style: Object.assign(Object.assign(Object.assign(Object.assign({}, floatingStyles), transitionStyles), menuStyle), (menuWidth ? { width: menuWidth, maxWidth: menuWidth } : {})),
1110
+ style: Object.assign(Object.assign(Object.assign({}, floatingStyles), transitionStyles), menuStyle),
1105
1111
  })),
1106
1112
  React.createElement(PersistentRegion, { items: persistentsHeaders, position: "header", activeIndex: activeIndex, indexOffset: 0, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: customRenderHeader, customRenderFooter: customRenderFooter, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, className: classnames(styles$1.persistentHeader, (_a = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.header) === null || _a === void 0 ? void 0 : _a.className), style: (_b = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.header) === null || _b === void 0 ? void 0 : _b.style }),
1107
1113
  React.createElement("div", { className: styles$1.scrollRegion }, loading ? (customRenderLoading !== null && customRenderLoading !== void 0 ? customRenderLoading : React.createElement(LoadingContent, null)) : (React.createElement(React.Fragment, null,
@@ -1140,7 +1146,6 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
1140
1146
  close: { opacity: 0 },
1141
1147
  duration: { open: design.tokens["timing-base"], close: design.tokens["timing-base"] },
1142
1148
  });
1143
- const [menuWidth, setMenuWidth] = React.useState(undefined);
1144
1149
  const [positionRefEl, setPositionRefEl] = React.useState(null);
1145
1150
  const inputId = React.useId();
1146
1151
  const descriptionId = `descriptionUUID--${inputId}`;
@@ -1187,18 +1192,17 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
1187
1192
  }
1188
1193
  const multiContainer = node.closest("[data-testid='ATL-AutocompleteRebuilt-multiSelectContainer']");
1189
1194
  if (multiContainer) {
1190
- setMenuWidth(multiContainer.clientWidth);
1191
1195
  setPositionRefEl(multiContainer);
1192
1196
  }
1193
1197
  }, [setReferenceElement, props.multiple]);
1194
1198
  const referenceInputRef = React.useCallback((node) => {
1195
1199
  setReferenceElement(node);
1196
1200
  if (!props.multiple) {
1197
- // Workaround to get the width of the visual InputText element, which is not the same as
1198
- // the literal input reference element.
1201
+ // Workaround to get the visual InputText element, which is not the same
1202
+ // as the literal input reference element when props like suffix/prefix
1203
+ // are present. Used to set the position reference for the floating menu.
1199
1204
  const visualInputTextElement = node === null || node === void 0 ? void 0 : node.closest("[data-testid='Form-Field-Wrapper']");
1200
1205
  if (visualInputTextElement) {
1201
- setMenuWidth(visualInputTextElement.clientWidth);
1202
1206
  setPositionRefEl(visualInputTextElement);
1203
1207
  }
1204
1208
  }
@@ -1215,7 +1219,7 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
1215
1219
  }, [positionRefEl, refs]);
1216
1220
  const menuClassName = classnames(styles$1.list, (_b = props.UNSAFE_className) === null || _b === void 0 ? void 0 : _b.menu);
1217
1221
  const showEmptyStateMessage = optionCount === 0 && props.emptyStateMessage !== false;
1218
- const floatingMenu = isMounted && !props.readOnly && !disabled && (React.createElement(FloatingMenu, { context: context, getFloatingProps: getFloatingProps, refs: refs, listboxId: listboxId, className: menuClassName, floatingStyles: floatingStyles, transitionStyles: transitionStyles, menuWidth: menuWidth, menuStyle: (_c = props.UNSAFE_styles) === null || _c === void 0 ? void 0 : _c.menu, renderable: renderable, persistentsHeaders: persistentsHeaders, persistentsFooters: persistentsFooters, activeIndex: activeIndex, headerInteractiveCount: headerInteractiveCount, middleNavigableCount: middleNavigableCount, getItemProps: getItemProps, listRef: listRef, onSelection: onSelection, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, getOptionLabel: getOptionLabel, isOptionSelected: isOptionSelected, loading: loading, showEmptyStateMessage: showEmptyStateMessage, emptyStateMessage: props.emptyStateMessage, customRenderLoading: props.customRenderLoading, customRenderOption: props.customRenderOption, customRenderSection: props.customRenderSection, customRenderAction: props.customRenderAction, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, slotOverrides: {
1222
+ const floatingMenu = isMounted && !props.readOnly && !disabled && (React.createElement(FloatingMenu, { context: context, getFloatingProps: getFloatingProps, refs: refs, listboxId: listboxId, className: menuClassName, floatingStyles: floatingStyles, transitionStyles: transitionStyles, menuStyle: (_c = props.UNSAFE_styles) === null || _c === void 0 ? void 0 : _c.menu, renderable: renderable, persistentsHeaders: persistentsHeaders, persistentsFooters: persistentsFooters, activeIndex: activeIndex, headerInteractiveCount: headerInteractiveCount, middleNavigableCount: middleNavigableCount, getItemProps: getItemProps, listRef: listRef, onSelection: onSelection, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, getOptionLabel: getOptionLabel, isOptionSelected: isOptionSelected, loading: loading, showEmptyStateMessage: showEmptyStateMessage, emptyStateMessage: props.emptyStateMessage, customRenderLoading: props.customRenderLoading, customRenderOption: props.customRenderOption, customRenderSection: props.customRenderSection, customRenderAction: props.customRenderAction, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, slotOverrides: {
1219
1223
  option: {
1220
1224
  className: (_d = props.UNSAFE_className) === null || _d === void 0 ? void 0 : _d.option,
1221
1225
  style: (_e = props.UNSAFE_styles) === null || _e === void 0 ? void 0 : _e.option,
@@ -131,6 +131,11 @@ function invokeActiveItemOnEnter(event, activeIndex, renderable, onSelect, onAct
131
131
 
132
132
  const MENU_OFFSET = tokens["space-small"];
133
133
  const AUTOCOMPLETE_MAX_HEIGHT = 300;
134
+ function useStableSetReference(refs) {
135
+ const latestRefs = useRef(refs);
136
+ latestRefs.current = refs;
137
+ return useCallback((el) => latestRefs.current.setReference(el), []);
138
+ }
134
139
  function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuOpen, onMenuClose, selectedIndex, readOnly = false, disabled = false, outsidePressExcludeSelector, }) {
135
140
  const [open, setOpen] = useState(false);
136
141
  const [activeIndex, setActiveIndex] = useState(null);
@@ -155,12 +160,13 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
155
160
  offset(MENU_OFFSET),
156
161
  flip({ fallbackPlacements: ["top"] }),
157
162
  size({
158
- apply({ availableHeight, elements }) {
163
+ apply({ availableHeight, rects, elements }) {
159
164
  const maxHeight = calculateMaxHeight(availableHeight, {
160
165
  maxHeight: AUTOCOMPLETE_MAX_HEIGHT,
161
166
  });
162
167
  Object.assign(elements.floating.style, {
163
168
  maxHeight: `${maxHeight}px`,
169
+ width: `${rects.reference.width}px`,
164
170
  });
165
171
  },
166
172
  }),
@@ -212,7 +218,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
212
218
  return prev >= navigableCount ? navigableCount - 1 : prev;
213
219
  });
214
220
  }, [navigableCount, setActiveIndex, listRef]);
215
- const setReferenceElement = useCallback((el) => refs.setReference(el), [refs]);
221
+ const setReferenceElement = useStableSetReference(refs);
216
222
  return {
217
223
  refs,
218
224
  floatingStyles,
@@ -1086,7 +1092,7 @@ function DefaultTextPersistentContent({ persistent, }) {
1086
1092
  return React__default.createElement("div", { className: styles$1.textPersistent }, persistent.label);
1087
1093
  }
1088
1094
 
1089
- function FloatingMenu({ context, getFloatingProps, refs, listboxId, className, floatingStyles, transitionStyles, menuWidth, menuStyle, renderable, persistentsHeaders, persistentsFooters, activeIndex, headerInteractiveCount, middleNavigableCount, getItemProps, listRef, onSelection, onAction, onInteractionPointerDown, getOptionLabel, isOptionSelected, loading, showEmptyStateMessage, emptyStateMessage, customRenderLoading, customRenderOption, customRenderSection, customRenderAction, customRenderHeader, customRenderFooter, slotOverrides, }) {
1095
+ function FloatingMenu({ context, getFloatingProps, refs, listboxId, className, floatingStyles, transitionStyles, menuStyle, renderable, persistentsHeaders, persistentsFooters, activeIndex, headerInteractiveCount, middleNavigableCount, getItemProps, listRef, onSelection, onAction, onInteractionPointerDown, getOptionLabel, isOptionSelected, loading, showEmptyStateMessage, emptyStateMessage, customRenderLoading, customRenderOption, customRenderSection, customRenderAction, customRenderHeader, customRenderFooter, slotOverrides, }) {
1090
1096
  var _a, _b, _c, _d;
1091
1097
  const activeIndexForMiddle = activeIndex != null ? activeIndex - headerInteractiveCount : null;
1092
1098
  return (React__default.createElement(FloatingPortal, null,
@@ -1099,7 +1105,7 @@ function FloatingMenu({ context, getFloatingProps, refs, listboxId, className, f
1099
1105
  id: listboxId,
1100
1106
  role: "listbox",
1101
1107
  className,
1102
- style: Object.assign(Object.assign(Object.assign(Object.assign({}, floatingStyles), transitionStyles), menuStyle), (menuWidth ? { width: menuWidth, maxWidth: menuWidth } : {})),
1108
+ style: Object.assign(Object.assign(Object.assign({}, floatingStyles), transitionStyles), menuStyle),
1103
1109
  })),
1104
1110
  React__default.createElement(PersistentRegion, { items: persistentsHeaders, position: "header", activeIndex: activeIndex, indexOffset: 0, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: customRenderHeader, customRenderFooter: customRenderFooter, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, className: classnames(styles$1.persistentHeader, (_a = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.header) === null || _a === void 0 ? void 0 : _a.className), style: (_b = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.header) === null || _b === void 0 ? void 0 : _b.style }),
1105
1111
  React__default.createElement("div", { className: styles$1.scrollRegion }, loading ? (customRenderLoading !== null && customRenderLoading !== void 0 ? customRenderLoading : React__default.createElement(LoadingContent, null)) : (React__default.createElement(React__default.Fragment, null,
@@ -1138,7 +1144,6 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
1138
1144
  close: { opacity: 0 },
1139
1145
  duration: { open: tokens["timing-base"], close: tokens["timing-base"] },
1140
1146
  });
1141
- const [menuWidth, setMenuWidth] = React__default.useState(undefined);
1142
1147
  const [positionRefEl, setPositionRefEl] = React__default.useState(null);
1143
1148
  const inputId = React__default.useId();
1144
1149
  const descriptionId = `descriptionUUID--${inputId}`;
@@ -1185,18 +1190,17 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
1185
1190
  }
1186
1191
  const multiContainer = node.closest("[data-testid='ATL-AutocompleteRebuilt-multiSelectContainer']");
1187
1192
  if (multiContainer) {
1188
- setMenuWidth(multiContainer.clientWidth);
1189
1193
  setPositionRefEl(multiContainer);
1190
1194
  }
1191
1195
  }, [setReferenceElement, props.multiple]);
1192
1196
  const referenceInputRef = useCallback((node) => {
1193
1197
  setReferenceElement(node);
1194
1198
  if (!props.multiple) {
1195
- // Workaround to get the width of the visual InputText element, which is not the same as
1196
- // the literal input reference element.
1199
+ // Workaround to get the visual InputText element, which is not the same
1200
+ // as the literal input reference element when props like suffix/prefix
1201
+ // are present. Used to set the position reference for the floating menu.
1197
1202
  const visualInputTextElement = node === null || node === void 0 ? void 0 : node.closest("[data-testid='Form-Field-Wrapper']");
1198
1203
  if (visualInputTextElement) {
1199
- setMenuWidth(visualInputTextElement.clientWidth);
1200
1204
  setPositionRefEl(visualInputTextElement);
1201
1205
  }
1202
1206
  }
@@ -1213,7 +1217,7 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
1213
1217
  }, [positionRefEl, refs]);
1214
1218
  const menuClassName = classnames(styles$1.list, (_b = props.UNSAFE_className) === null || _b === void 0 ? void 0 : _b.menu);
1215
1219
  const showEmptyStateMessage = optionCount === 0 && props.emptyStateMessage !== false;
1216
- const floatingMenu = isMounted && !props.readOnly && !disabled && (React__default.createElement(FloatingMenu, { context: context, getFloatingProps: getFloatingProps, refs: refs, listboxId: listboxId, className: menuClassName, floatingStyles: floatingStyles, transitionStyles: transitionStyles, menuWidth: menuWidth, menuStyle: (_c = props.UNSAFE_styles) === null || _c === void 0 ? void 0 : _c.menu, renderable: renderable, persistentsHeaders: persistentsHeaders, persistentsFooters: persistentsFooters, activeIndex: activeIndex, headerInteractiveCount: headerInteractiveCount, middleNavigableCount: middleNavigableCount, getItemProps: getItemProps, listRef: listRef, onSelection: onSelection, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, getOptionLabel: getOptionLabel, isOptionSelected: isOptionSelected, loading: loading, showEmptyStateMessage: showEmptyStateMessage, emptyStateMessage: props.emptyStateMessage, customRenderLoading: props.customRenderLoading, customRenderOption: props.customRenderOption, customRenderSection: props.customRenderSection, customRenderAction: props.customRenderAction, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, slotOverrides: {
1220
+ const floatingMenu = isMounted && !props.readOnly && !disabled && (React__default.createElement(FloatingMenu, { context: context, getFloatingProps: getFloatingProps, refs: refs, listboxId: listboxId, className: menuClassName, floatingStyles: floatingStyles, transitionStyles: transitionStyles, menuStyle: (_c = props.UNSAFE_styles) === null || _c === void 0 ? void 0 : _c.menu, renderable: renderable, persistentsHeaders: persistentsHeaders, persistentsFooters: persistentsFooters, activeIndex: activeIndex, headerInteractiveCount: headerInteractiveCount, middleNavigableCount: middleNavigableCount, getItemProps: getItemProps, listRef: listRef, onSelection: onSelection, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, getOptionLabel: getOptionLabel, isOptionSelected: isOptionSelected, loading: loading, showEmptyStateMessage: showEmptyStateMessage, emptyStateMessage: props.emptyStateMessage, customRenderLoading: props.customRenderLoading, customRenderOption: props.customRenderOption, customRenderSection: props.customRenderSection, customRenderAction: props.customRenderAction, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, slotOverrides: {
1217
1221
  option: {
1218
1222
  className: (_d = props.UNSAFE_className) === null || _d === void 0 ? void 0 : _d.option,
1219
1223
  style: (_e = props.UNSAFE_styles) === null || _e === void 0 ? void 0 : _e.option,
@@ -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 };
@@ -240,11 +240,12 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
240
240
  const descriptionVisible = props.description && !props.inline;
241
241
  const isInvalid = Boolean(props.error || props.invalid);
242
242
  const dataAttrs = filterDataAttributes.filterDataAttributes(props);
243
+ const mergedRef = React.useMemo(() => FormField.mergeRefs([inputRef, inputTextRef]), []);
243
244
  // Shared props for both TextArea and TextInput
244
245
  const commonInputProps = Object.assign({ id,
245
246
  name, className: FormField.formFieldStyles.input, value: props.value, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, maxLength: props.maxLength, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
246
247
  ? descriptionIdentifier
247
- : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onClick: handleClick, ref: FormField.mergeRefs([inputRef, inputTextRef]) }, dataAttrs);
248
+ : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onClick: handleClick, ref: mergedRef }, dataAttrs);
248
249
  return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, name: name, wrapperRef: wrapperRef, error: (_a = props.error) !== null && _a !== void 0 ? _a : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: props.multiline ? "textarea" : "text", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, readonly: props.readOnly, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
249
250
  React.createElement(React.Fragment, null,
250
251
  props.multiline ? (React.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
@@ -1,6 +1,6 @@
1
- import React__default, { forwardRef, useRef, useImperativeHandle, useId } from 'react';
1
+ import React__default, { forwardRef, useRef, useImperativeHandle, useMemo, useId } from 'react';
2
2
  import { useSafeLayoutEffect } from '@jobber/hooks';
3
- import { k as FormField, b as useAtlantisFormFieldName, l as formFieldStyles, n as mergeRefs, f as FormFieldWrapper, m as FormFieldPostFix } from '../FormField-es.js';
3
+ import { k as FormField, b as useAtlantisFormFieldName, n as mergeRefs, l as formFieldStyles, f as FormFieldWrapper, m as FormFieldPostFix } from '../FormField-es.js';
4
4
  import 'classnames';
5
5
  import '../tslib.es6-es.js';
6
6
  import 'react-hook-form';
@@ -238,11 +238,12 @@ const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRef) {
238
238
  const descriptionVisible = props.description && !props.inline;
239
239
  const isInvalid = Boolean(props.error || props.invalid);
240
240
  const dataAttrs = filterDataAttributes(props);
241
+ const mergedRef = useMemo(() => mergeRefs([inputRef, inputTextRef]), []);
241
242
  // Shared props for both TextArea and TextInput
242
243
  const commonInputProps = Object.assign({ id,
243
244
  name, className: formFieldStyles.input, value: props.value, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, maxLength: props.maxLength, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
244
245
  ? descriptionIdentifier
245
- : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onClick: handleClick, ref: mergeRefs([inputRef, inputTextRef]) }, dataAttrs);
246
+ : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onClick: handleClick, ref: mergedRef }, dataAttrs);
246
247
  return (React__default.createElement(FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, name: name, wrapperRef: wrapperRef, error: (_a = props.error) !== null && _a !== void 0 ? _a : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: props.multiline ? "textarea" : "text", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, readonly: props.readOnly, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
247
248
  React__default.createElement(React__default.Fragment, null,
248
249
  props.multiline ? (React__default.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React__default.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
package/dist/styles.css CHANGED
@@ -1097,8 +1097,6 @@
1097
1097
  display: -ms-flexbox;
1098
1098
  display: flex;
1099
1099
  height: var(--field--height);
1100
- -ms-flex-align: center;
1101
- align-items: center;
1102
1100
  -ms-flex: 1;
1103
1101
  flex: 1;
1104
1102
  }
@@ -1899,6 +1897,8 @@ a._7BLGtYNuJOU-.zgRx3ehZ2z8-:hover {
1899
1897
  justify-content: center;
1900
1898
  -ms-flex-align: center;
1901
1899
  align-items: center;
1900
+ -webkit-transform: translateY(50%);
1901
+ transform: translateY(50%);
1902
1902
  }
1903
1903
 
1904
1904
  .YmRTd-KeXv4-:focus {
@@ -7518,9 +7518,12 @@ h2.react-datepicker__current-month {
7518
7518
  width: 100%;
7519
7519
  max-width: 100%;
7520
7520
  }
7521
- .OmFI-Bfdzgw- .react-datepicker-popper {
7522
- z-index: 6;
7523
- z-index: var(--elevation-datepicker);
7521
+ .LDxKi0E-1rg- {
7522
+ position: fixed;
7523
+ top: 0;
7524
+ left: 0;
7525
+ z-index: 1001;
7526
+ z-index: var(--elevation-modal);
7524
7527
  }
7525
7528
  .Ma55F5Y-XhE- .react-datepicker__header {
7526
7529
  padding: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.114.1",
3
+ "version": "6.114.6",
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": "8e79d0138c20e8e2b0eb8839296cd85cb9c8e403"
541
+ "gitHead": "f3ee342f23c2e0c2d5d5876934efcbbec7c27c5e"
542
542
  }