@jobber/components 6.105.0 → 6.105.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Autocomplete/Autocomplete.types.d.ts +2 -0
- package/dist/Autocomplete/components/MenuList.d.ts +2 -1
- package/dist/Autocomplete/components/PersistentRegion.d.ts +2 -1
- package/dist/Autocomplete/hooks/useAutocompleteListNav.d.ts +2 -1
- package/dist/Autocomplete/index.cjs +86 -32
- package/dist/Autocomplete/index.mjs +87 -33
- package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +13 -0
- package/dist/Autocomplete/useAutocomplete.d.ts +1 -0
- package/dist/Autocomplete/utils/interactionUtils.d.ts +14 -0
- package/dist/DatePicker/DatePicker.d.ts +5 -1
- package/dist/DatePicker-cjs.js +3 -1
- package/dist/DatePicker-es.js +4 -2
- package/dist/InputDate/index.cjs +29 -3
- package/dist/InputDate/index.mjs +29 -3
- package/dist/floating-ui.react-cjs.js +115 -0
- package/dist/floating-ui.react-es.js +115 -1
- package/dist/styles.css +3 -0
- package/package.json +2 -2
|
@@ -379,6 +379,8 @@ interface AutocompleteRebuiltBaseProps<Value extends OptionLike, Multiple extend
|
|
|
379
379
|
}) => MenuAction<ActionExtra>[]);
|
|
380
380
|
/**
|
|
381
381
|
* Whether the menu should open when the input gains focus.
|
|
382
|
+
* Note: Clicking on the input will always open the menu.
|
|
383
|
+
* openOnFocus only determines the behavior of focus events such as tabs or programmatic focus.
|
|
382
384
|
*
|
|
383
385
|
* @default true
|
|
384
386
|
*/
|
|
@@ -14,6 +14,7 @@ interface MenuListProps<T extends OptionLike> {
|
|
|
14
14
|
readonly getOptionLabel: (option: T) => string;
|
|
15
15
|
readonly onSelect: (option: T) => void;
|
|
16
16
|
readonly onAction: (action: ActionConfig) => void;
|
|
17
|
+
readonly onInteractionPointerDown: (e: React.PointerEvent) => void;
|
|
17
18
|
readonly isOptionSelected: (option: T) => boolean;
|
|
18
19
|
readonly slotOverrides?: {
|
|
19
20
|
option?: {
|
|
@@ -30,7 +31,7 @@ interface MenuListProps<T extends OptionLike> {
|
|
|
30
31
|
};
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
|
-
export declare function MenuList<T extends OptionLike>({ items, activeIndex, indexOffset, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, isOptionSelected, slotOverrides, }: MenuListProps<T>): React.JSX.Element;
|
|
34
|
+
export declare function MenuList<T extends OptionLike>({ items, activeIndex, indexOffset, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, onInteractionPointerDown, isOptionSelected, slotOverrides, }: MenuListProps<T>): React.JSX.Element;
|
|
34
35
|
export declare function DefaultActionContent({ textContent, }: {
|
|
35
36
|
readonly textContent: string;
|
|
36
37
|
}): React.JSX.Element;
|
|
@@ -13,6 +13,7 @@ interface PersistentRegionProps<T extends OptionLike> {
|
|
|
13
13
|
readonly className?: string;
|
|
14
14
|
readonly style?: React.CSSProperties;
|
|
15
15
|
readonly onAction: (action: ActionConfig) => void;
|
|
16
|
+
readonly onInteractionPointerDown: (e: React.PointerEvent) => void;
|
|
16
17
|
}
|
|
17
|
-
export declare function PersistentRegion<T extends OptionLike>({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, }: PersistentRegionProps<T>): React.JSX.Element | null;
|
|
18
|
+
export declare function PersistentRegion<T extends OptionLike>({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, onInteractionPointerDown, }: PersistentRegionProps<T>): React.JSX.Element | null;
|
|
18
19
|
export {};
|
|
@@ -18,5 +18,6 @@ export interface UseAutocompleteListNavProps {
|
|
|
18
18
|
shouldResetActiveIndexOnClose?: () => boolean;
|
|
19
19
|
onMenuClose?: (reason?: string) => void;
|
|
20
20
|
selectedIndex?: number | null;
|
|
21
|
+
readOnly?: boolean;
|
|
21
22
|
}
|
|
22
|
-
export declare function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, }: UseAutocompleteListNavProps): UseAutocompleteListNavReturn;
|
|
23
|
+
export declare function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, readOnly, }: UseAutocompleteListNavProps): UseAutocompleteListNavReturn;
|
|
@@ -129,7 +129,7 @@ function invokeActiveItemOnEnter(event, activeIndex, renderable, onSelect, onAct
|
|
|
129
129
|
|
|
130
130
|
const MENU_OFFSET = design.tokens["space-small"];
|
|
131
131
|
const AUTOCOMPLETE_MAX_HEIGHT$1 = 300;
|
|
132
|
-
function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, }) {
|
|
132
|
+
function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, readOnly = false, }) {
|
|
133
133
|
const [open, setOpen] = React.useState(false);
|
|
134
134
|
const [activeIndex, setActiveIndex] = React.useState(null);
|
|
135
135
|
const listRef = React.useRef([]);
|
|
@@ -161,6 +161,10 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
|
|
|
161
161
|
}),
|
|
162
162
|
],
|
|
163
163
|
});
|
|
164
|
+
const click = floatingUi_react.useClick(context, {
|
|
165
|
+
enabled: !readOnly,
|
|
166
|
+
toggle: false, // Only open, never close on click
|
|
167
|
+
});
|
|
164
168
|
const listNav = floatingUi_react.useListNavigation(context, {
|
|
165
169
|
listRef,
|
|
166
170
|
activeIndex,
|
|
@@ -182,7 +186,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
|
|
|
182
186
|
escapeKey: true,
|
|
183
187
|
outsidePressEvent: "click",
|
|
184
188
|
});
|
|
185
|
-
const { getReferenceProps, getFloatingProps, getItemProps } = floatingUi_react.useInteractions([listNav, dismiss]);
|
|
189
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = floatingUi_react.useInteractions([click, listNav, dismiss]);
|
|
186
190
|
React.useEffect(() => {
|
|
187
191
|
listRef.current.length = navigableCount;
|
|
188
192
|
setActiveIndex(prev => {
|
|
@@ -209,11 +213,34 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
|
|
|
209
213
|
};
|
|
210
214
|
}
|
|
211
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Handler that prevents default pointer behavior.
|
|
218
|
+
* Used to prevent blur/focus issues when clicking on non-interactive menu elements.
|
|
219
|
+
*/
|
|
220
|
+
function preventDefaultPointerDown(e) {
|
|
221
|
+
e.preventDefault();
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Creates a handler for pointer down events on interactive menu items (options/actions).
|
|
225
|
+
* Prevents default to avoid blur and sets flag for focus management.
|
|
226
|
+
*
|
|
227
|
+
* @param isHandlingMenuInteractionRef - Ref to track if a menu interaction is in progress
|
|
228
|
+
* @returns A pointer down event handler
|
|
229
|
+
*/
|
|
230
|
+
function createInteractionPointerDownHandler(isHandlingMenuInteractionRef) {
|
|
231
|
+
return (e) => {
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
// Set flag to prevent blur/focus handlers from interfering
|
|
234
|
+
isHandlingMenuInteractionRef.current = true;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
212
238
|
// Keeping this hook cohesive improves readability by centralizing related
|
|
213
239
|
// interactions and state transitions.
|
|
214
240
|
// eslint-disable-next-line max-statements
|
|
215
241
|
function useAutocomplete(props) {
|
|
216
242
|
const { menu, emptyActions, getOptionLabel: getOptionLabelProp, isOptionEqualToValue, inputValue, onInputChange, value, onChange, multiple, openOnFocus = true, readOnly = false, debounce: debounceMs = 300, } = props;
|
|
243
|
+
const isHandlingMenuInteractionRef = React.useRef(false);
|
|
217
244
|
// TODO: Clean up the types in these refs by enhancing the type system in useCallbackRef
|
|
218
245
|
const getOptionLabelPropRef = jobberHooks.useCallbackRef((opt) => getOptionLabelProp === null || getOptionLabelProp === void 0 ? void 0 : getOptionLabelProp(opt));
|
|
219
246
|
const getOptionLabel = React.useCallback((opt) => {
|
|
@@ -256,7 +283,8 @@ function useAutocomplete(props) {
|
|
|
256
283
|
const [debouncedInputValue, setDebouncedInputValue] = React.useState(inputValue);
|
|
257
284
|
const debouncedSetter = jobberHooks.useDebounce(setDebouncedInputValue, debounceMs);
|
|
258
285
|
React.useEffect(() => {
|
|
259
|
-
|
|
286
|
+
// Skip debounce when clearing input for immediate feedback, preventing flickering of last selected item
|
|
287
|
+
if (debounceMs === 0 || inputValue === "") {
|
|
260
288
|
setDebouncedInputValue(inputValue);
|
|
261
289
|
return;
|
|
262
290
|
}
|
|
@@ -346,6 +374,7 @@ function useAutocomplete(props) {
|
|
|
346
374
|
navigableCount: totalNavigableCount,
|
|
347
375
|
shouldResetActiveIndexOnClose: () => !hasSelection,
|
|
348
376
|
selectedIndex,
|
|
377
|
+
readOnly,
|
|
349
378
|
onMenuClose: () => {
|
|
350
379
|
if (props.allowFreeForm !== true) {
|
|
351
380
|
const hasText = inputValue.trim().length > 0;
|
|
@@ -357,7 +386,6 @@ function useAutocomplete(props) {
|
|
|
357
386
|
}
|
|
358
387
|
},
|
|
359
388
|
});
|
|
360
|
-
const [inputFocused, setInputFocused] = React.useState(false);
|
|
361
389
|
// Handles activeIndex reset and, in single-select mode only, clearing selection when input is empty
|
|
362
390
|
React.useEffect(() => {
|
|
363
391
|
const hasText = inputValue.trim().length > 0;
|
|
@@ -453,13 +481,24 @@ function useAutocomplete(props) {
|
|
|
453
481
|
selectOption(option);
|
|
454
482
|
// Might not always want to close on selection. Multi for example.
|
|
455
483
|
setOpen(false);
|
|
484
|
+
if (refs.domReference.current instanceof HTMLElement) {
|
|
485
|
+
refs.domReference.current.focus();
|
|
486
|
+
}
|
|
456
487
|
}, [selectOption, setOpen]);
|
|
457
488
|
const onAction = React.useCallback((action) => {
|
|
458
489
|
action.run();
|
|
459
490
|
setActiveIndex(null);
|
|
460
491
|
if (action.closeOnRun !== false)
|
|
461
492
|
setOpen(false);
|
|
493
|
+
if (refs.domReference.current instanceof HTMLElement) {
|
|
494
|
+
refs.domReference.current.focus();
|
|
495
|
+
}
|
|
462
496
|
}, [setOpen, setActiveIndex]);
|
|
497
|
+
/**
|
|
498
|
+
* Handler for mousedown on interactive menu items (options/actions)
|
|
499
|
+
* Prevents default to avoid blur and sets flag for focus management
|
|
500
|
+
*/
|
|
501
|
+
const onInteractionPointerDown = React.useMemo(() => createInteractionPointerDownHandler(isHandlingMenuInteractionRef), []);
|
|
463
502
|
function commitFromInputText(inputText) {
|
|
464
503
|
var _a;
|
|
465
504
|
if (inputText.length === 0)
|
|
@@ -501,14 +540,20 @@ function useAutocomplete(props) {
|
|
|
501
540
|
]);
|
|
502
541
|
const onInputFocus = React.useCallback((event) => {
|
|
503
542
|
var _a;
|
|
504
|
-
|
|
505
|
-
if (!readOnly && openOnFocus)
|
|
543
|
+
if (!readOnly && openOnFocus && !isHandlingMenuInteractionRef.current) {
|
|
506
544
|
setOpen(true);
|
|
507
|
-
|
|
545
|
+
}
|
|
546
|
+
// Only call user's onFocus for genuine focus events, not programmatic restorations
|
|
547
|
+
if (!isHandlingMenuInteractionRef.current) {
|
|
548
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
549
|
+
}
|
|
550
|
+
isHandlingMenuInteractionRef.current = false;
|
|
508
551
|
}, [props.onFocus, readOnly, openOnFocus, setOpen]);
|
|
509
552
|
const onInputBlur = React.useCallback((event) => {
|
|
510
553
|
var _a, _b;
|
|
511
|
-
|
|
554
|
+
if (isHandlingMenuInteractionRef.current) {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
512
557
|
if (readOnly) {
|
|
513
558
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
514
559
|
return;
|
|
@@ -614,11 +659,11 @@ function useAutocomplete(props) {
|
|
|
614
659
|
setActiveIndex(null);
|
|
615
660
|
}
|
|
616
661
|
// Important: update open state before propagating the change so that downstream effects
|
|
617
|
-
// don
|
|
662
|
+
// don't see an intermediate state where inputValue changed but open was stale
|
|
618
663
|
if (!readOnly) {
|
|
619
664
|
const hasText = val.trim().length > 0;
|
|
620
665
|
const mustSelectFromOptions = hasText && !props.allowFreeForm;
|
|
621
|
-
const keepOpenOnEmpty = openOnFocus
|
|
666
|
+
const keepOpenOnEmpty = openOnFocus;
|
|
622
667
|
setOpen(mustSelectFromOptions || keepOpenOnEmpty);
|
|
623
668
|
}
|
|
624
669
|
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(val);
|
|
@@ -629,7 +674,6 @@ function useAutocomplete(props) {
|
|
|
629
674
|
readOnly,
|
|
630
675
|
props.allowFreeForm,
|
|
631
676
|
openOnFocus,
|
|
632
|
-
inputFocused,
|
|
633
677
|
setOpen,
|
|
634
678
|
]);
|
|
635
679
|
return {
|
|
@@ -658,6 +702,7 @@ function useAutocomplete(props) {
|
|
|
658
702
|
// actions
|
|
659
703
|
onSelection,
|
|
660
704
|
onAction,
|
|
705
|
+
onInteractionPointerDown,
|
|
661
706
|
// input handlers
|
|
662
707
|
onInputChangeFromUser,
|
|
663
708
|
onInputBlur,
|
|
@@ -668,7 +713,7 @@ function useAutocomplete(props) {
|
|
|
668
713
|
};
|
|
669
714
|
}
|
|
670
715
|
|
|
671
|
-
function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, isOptionSelected, slotOverrides, }) {
|
|
716
|
+
function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, onInteractionPointerDown, isOptionSelected, slotOverrides, }) {
|
|
672
717
|
let navigableIndex = -1;
|
|
673
718
|
function renderItemNode(item) {
|
|
674
719
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -692,6 +737,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
|
|
|
692
737
|
customRenderOption,
|
|
693
738
|
getOptionLabel,
|
|
694
739
|
onSelect,
|
|
740
|
+
onInteractionPointerDown,
|
|
695
741
|
indexOffset,
|
|
696
742
|
optionClassName: (_c = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _c === void 0 ? void 0 : _c.className,
|
|
697
743
|
optionStyle: (_d = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _d === void 0 ? void 0 : _d.style,
|
|
@@ -708,6 +754,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
|
|
|
708
754
|
listboxId,
|
|
709
755
|
customRenderAction,
|
|
710
756
|
onAction,
|
|
757
|
+
onInteractionPointerDown,
|
|
711
758
|
indexOffset,
|
|
712
759
|
actionClassName: (_e = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _e === void 0 ? void 0 : _e.className,
|
|
713
760
|
actionStyle: (_f = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _f === void 0 ? void 0 : _f.style,
|
|
@@ -721,12 +768,12 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
|
|
|
721
768
|
function handleSectionRendering({ customRenderSection, section, sectionClassName, sectionStyle, }) {
|
|
722
769
|
var _a;
|
|
723
770
|
const headerContent = customRenderSection ? (customRenderSection(section)) : (React.createElement(DefaultSectionContent, { section: section }));
|
|
724
|
-
return (React.createElement("div", { key: `section-${String((_a = section.key) !== null && _a !== void 0 ? _a : section.label)}`, role: "presentation", tabIndex: -1, "data-testid": "ATL-AutocompleteRebuilt-Section", className: classnames(styles$1.section, styles$1.stickyTop, sectionClassName), style: sectionStyle }, headerContent));
|
|
771
|
+
return (React.createElement("div", { key: `section-${String((_a = section.key) !== null && _a !== void 0 ? _a : section.label)}`, role: "presentation", tabIndex: -1, "data-testid": "ATL-AutocompleteRebuilt-Section", className: classnames(styles$1.section, styles$1.stickyTop, sectionClassName), style: sectionStyle, onPointerDown: preventDefaultPointerDown }, headerContent));
|
|
725
772
|
}
|
|
726
773
|
function DefaultSectionContent({ section, }) {
|
|
727
774
|
return React.createElement(Heading.Heading, { level: 5 }, section.label);
|
|
728
775
|
}
|
|
729
|
-
function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, indexOffset = 0, optionClassName, optionStyle, }) {
|
|
776
|
+
function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, onInteractionPointerDown, indexOffset = 0, optionClassName, optionStyle, }) {
|
|
730
777
|
var _a;
|
|
731
778
|
const nextNavigableIndex = navigableIndex + 1;
|
|
732
779
|
const isActive = activeIndex === nextNavigableIndex;
|
|
@@ -740,6 +787,7 @@ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemPro
|
|
|
740
787
|
listRef.current[idx] = node;
|
|
741
788
|
},
|
|
742
789
|
onClick: () => onSelect(option),
|
|
790
|
+
onPointerDown: onInteractionPointerDown,
|
|
743
791
|
className: classnames(styles$1.option, isActive && styles$1.optionActive, optionClassName),
|
|
744
792
|
style: optionStyle,
|
|
745
793
|
}), { role: "option", tabIndex: -1, "aria-selected": isSelected ? true : false, id: `${listboxId}-item-${nextNavigableIndex + indexOffset}`, "data-index": nextNavigableIndex + indexOffset, "data-active": isActive ? true : undefined }), optionContent)),
|
|
@@ -751,7 +799,7 @@ function DefaultOptionContent({ isSelected, text, }) {
|
|
|
751
799
|
React.createElement("div", { className: styles$1.icon }, isSelected && React.createElement(Icon.Icon, { name: "checkmark", size: "small" })),
|
|
752
800
|
React.createElement(Text.Text, null, text)));
|
|
753
801
|
}
|
|
754
|
-
function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, indexOffset = 0, actionClassName, actionStyle, origin, }) {
|
|
802
|
+
function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, onInteractionPointerDown, indexOffset = 0, actionClassName, actionStyle, origin, }) {
|
|
755
803
|
var _a;
|
|
756
804
|
const nextNavigableIndex = navigableIndex + 1;
|
|
757
805
|
const isActive = activeIndex === nextNavigableIndex;
|
|
@@ -769,6 +817,7 @@ function handleActionRendering({ action, activeIndex, navigableIndex, getItemPro
|
|
|
769
817
|
closeOnRun: action.shouldClose,
|
|
770
818
|
});
|
|
771
819
|
},
|
|
820
|
+
onPointerDown: onInteractionPointerDown,
|
|
772
821
|
className: classnames(styles$1.action, isActive && styles$1.actionActive, actionClassName),
|
|
773
822
|
style: actionStyle,
|
|
774
823
|
});
|
|
@@ -786,7 +835,7 @@ function DefaultActionContent({ textContent, }) {
|
|
|
786
835
|
} }, textContent));
|
|
787
836
|
}
|
|
788
837
|
|
|
789
|
-
function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, }) {
|
|
838
|
+
function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, onInteractionPointerDown, }) {
|
|
790
839
|
if (!items || items.length === 0)
|
|
791
840
|
return null;
|
|
792
841
|
let navigableIndex = -1;
|
|
@@ -801,13 +850,14 @@ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemPr
|
|
|
801
850
|
customRenderFooter,
|
|
802
851
|
listRef,
|
|
803
852
|
onAction,
|
|
853
|
+
onInteractionPointerDown,
|
|
804
854
|
navigableIndex,
|
|
805
855
|
});
|
|
806
856
|
navigableIndex = result.nextNavigableIndex;
|
|
807
857
|
return result.node;
|
|
808
858
|
})));
|
|
809
859
|
}
|
|
810
|
-
function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
|
|
860
|
+
function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionPointerDown, navigableIndex, }) {
|
|
811
861
|
const interactive = Boolean(persistent.onClick);
|
|
812
862
|
if (!interactive) {
|
|
813
863
|
const node = handleTextPersistentRendering({
|
|
@@ -828,6 +878,7 @@ function handlePersistentRendering({ persistent, position, activeIndex, indexOff
|
|
|
828
878
|
customRenderFooter,
|
|
829
879
|
listRef,
|
|
830
880
|
onAction,
|
|
881
|
+
onInteractionPointerDown,
|
|
831
882
|
navigableIndex,
|
|
832
883
|
});
|
|
833
884
|
}
|
|
@@ -843,9 +894,9 @@ function handleTextPersistentRendering({ persistent, position, customRenderHeade
|
|
|
843
894
|
else {
|
|
844
895
|
content = React.createElement(DefaultTextPersistentContent, { persistent: persistent });
|
|
845
896
|
}
|
|
846
|
-
return (React.createElement("div", { key: `persistent-${position}-${String((_a = persistent.key) !== null && _a !== void 0 ? _a : persistent.label)}`, role: "presentation", tabIndex: -1, className: styles$1.textPersistent }, content));
|
|
897
|
+
return (React.createElement("div", { key: `persistent-${position}-${String((_a = persistent.key) !== null && _a !== void 0 ? _a : persistent.label)}`, role: "presentation", tabIndex: -1, className: styles$1.textPersistent, onPointerDown: preventDefaultPointerDown }, content));
|
|
847
898
|
}
|
|
848
|
-
function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
|
|
899
|
+
function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionPointerDown, navigableIndex, }) {
|
|
849
900
|
var _a;
|
|
850
901
|
const nextNavigableIndex = navigableIndex + 1;
|
|
851
902
|
const isActive = activeIndex === indexOffset + nextNavigableIndex;
|
|
@@ -872,13 +923,16 @@ function handleActionPersistentRendering({ persistent, position, activeIndex, in
|
|
|
872
923
|
if (persistNode)
|
|
873
924
|
listRef.current[idx] = persistNode;
|
|
874
925
|
},
|
|
875
|
-
onClick: () =>
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
926
|
+
onClick: () => {
|
|
927
|
+
onAction({
|
|
928
|
+
run: () => {
|
|
929
|
+
var _a;
|
|
930
|
+
(_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
|
|
931
|
+
},
|
|
932
|
+
closeOnRun: persistent.shouldClose,
|
|
933
|
+
});
|
|
934
|
+
},
|
|
935
|
+
onPointerDown: onInteractionPointerDown,
|
|
882
936
|
className: classnames(styles$1.action, isActive && styles$1.actionActive),
|
|
883
937
|
}), { role: "button", tabIndex: -1 }), content)),
|
|
884
938
|
nextNavigableIndex,
|
|
@@ -893,7 +947,7 @@ const AutocompleteRebuilt = React.forwardRef(AutocompleteRebuiltInternal);
|
|
|
893
947
|
function AutocompleteRebuiltInternal(props, forwardedRef) {
|
|
894
948
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
895
949
|
const { inputValue, placeholder, disabled, error, invalid, description, size: sizeProp, loading = false, } = props;
|
|
896
|
-
const { renderable, optionCount, persistentsHeaders, persistentsFooters, headerInteractiveCount, middleNavigableCount, getOptionLabel, isOptionSelected, refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps, activeIndex, open, listRef, onSelection, onAction, onInputChangeFromUser, onInputBlur, onInputFocus, onInputKeyDown, setReferenceElement, } = useAutocomplete(props);
|
|
950
|
+
const { renderable, optionCount, persistentsHeaders, persistentsFooters, headerInteractiveCount, middleNavigableCount, getOptionLabel, isOptionSelected, refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps, activeIndex, open, listRef, onSelection, onAction, onInteractionPointerDown, onInputChangeFromUser, onInputBlur, onInputFocus, onInputKeyDown, setReferenceElement, } = useAutocomplete(props);
|
|
897
951
|
const listboxId = React.useId();
|
|
898
952
|
// Provides mount/unmount-aware transition styles for the floating element
|
|
899
953
|
const { isMounted, styles: transitionStyles } = floatingUi_react.useTransitionStyles(context, {
|
|
@@ -953,10 +1007,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
|
|
|
953
1007
|
? { width: menuWidth, maxWidth: menuWidth }
|
|
954
1008
|
: {})),
|
|
955
1009
|
})),
|
|
956
|
-
React.createElement(PersistentRegion, { items: persistentsHeaders, position: "header", activeIndex: activeIndex, indexOffset: 0, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, className: classnames(styles$1.persistentHeader, (_c = props.UNSAFE_className) === null || _c === void 0 ? void 0 : _c.header), style: (_d = props.UNSAFE_styles) === null || _d === void 0 ? void 0 : _d.header }),
|
|
1010
|
+
React.createElement(PersistentRegion, { items: persistentsHeaders, position: "header", activeIndex: activeIndex, indexOffset: 0, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, className: classnames(styles$1.persistentHeader, (_c = props.UNSAFE_className) === null || _c === void 0 ? void 0 : _c.header), style: (_d = props.UNSAFE_styles) === null || _d === void 0 ? void 0 : _d.header }),
|
|
957
1011
|
React.createElement("div", { className: styles$1.scrollRegion }, loading ? ((_e = props.customRenderLoading) !== null && _e !== void 0 ? _e : React.createElement(LoadingContent, null)) : (React.createElement(React.Fragment, null,
|
|
958
1012
|
showEmptyStateMessage && (React.createElement(EmptyStateMessage, { emptyState: props.emptyStateMessage })),
|
|
959
|
-
renderable.length > 0 && (React.createElement(MenuList, { items: renderable, activeIndex: activeIndexForMiddle, indexOffset: headerInteractiveCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderOption: props.customRenderOption, customRenderSection: props.customRenderSection, customRenderAction: props.customRenderAction, getOptionLabel: getOptionLabel, onSelect: onSelection, onAction: onAction, isOptionSelected: isOptionSelected, slotOverrides: {
|
|
1013
|
+
renderable.length > 0 && (React.createElement(MenuList, { items: renderable, activeIndex: activeIndexForMiddle, indexOffset: headerInteractiveCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderOption: props.customRenderOption, customRenderSection: props.customRenderSection, customRenderAction: props.customRenderAction, getOptionLabel: getOptionLabel, onSelect: onSelection, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, isOptionSelected: isOptionSelected, slotOverrides: {
|
|
960
1014
|
option: {
|
|
961
1015
|
className: (_f = props.UNSAFE_className) === null || _f === void 0 ? void 0 : _f.option,
|
|
962
1016
|
style: (_g = props.UNSAFE_styles) === null || _g === void 0 ? void 0 : _g.option,
|
|
@@ -970,10 +1024,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
|
|
|
970
1024
|
style: (_l = props.UNSAFE_styles) === null || _l === void 0 ? void 0 : _l.section,
|
|
971
1025
|
},
|
|
972
1026
|
} }))))),
|
|
973
|
-
React.createElement(PersistentRegion, { items: persistentsFooters, position: "footer", activeIndex: activeIndex, indexOffset: headerInteractiveCount + middleNavigableCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, className: classnames(styles$1.persistentFooter, (_m = props.UNSAFE_className) === null || _m === void 0 ? void 0 : _m.footer), style: (_o = props.UNSAFE_styles) === null || _o === void 0 ? void 0 : _o.footer })))))));
|
|
1027
|
+
React.createElement(PersistentRegion, { items: persistentsFooters, position: "footer", activeIndex: activeIndex, indexOffset: headerInteractiveCount + middleNavigableCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, className: classnames(styles$1.persistentFooter, (_m = props.UNSAFE_className) === null || _m === void 0 ? void 0 : _m.footer), style: (_o = props.UNSAFE_styles) === null || _o === void 0 ? void 0 : _o.footer })))))));
|
|
974
1028
|
}
|
|
975
1029
|
function LoadingContent() {
|
|
976
|
-
return (React.createElement("div", { className: styles$1.loadingList },
|
|
1030
|
+
return (React.createElement("div", { className: styles$1.loadingList, onPointerDown: preventDefaultPointerDown },
|
|
977
1031
|
React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" }),
|
|
978
1032
|
React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" }),
|
|
979
1033
|
React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" })));
|
|
@@ -981,7 +1035,7 @@ function LoadingContent() {
|
|
|
981
1035
|
function EmptyStateMessage({ emptyState, }) {
|
|
982
1036
|
const emptyStateDefault = "No options";
|
|
983
1037
|
const emptyStateContent = emptyState !== null && emptyState !== void 0 ? emptyState : emptyStateDefault;
|
|
984
|
-
return React.createElement("div", { className: styles$1.emptyStateMessage }, emptyStateContent);
|
|
1038
|
+
return (React.createElement("div", { className: styles$1.emptyStateMessage, onPointerDown: preventDefaultPointerDown }, emptyStateContent));
|
|
985
1039
|
}
|
|
986
1040
|
|
|
987
1041
|
var styles = {"autocomplete":"_7mObJiwfPh4-","options":"dL5JShAJlKM-","heading":"PWZL-94hH7k-","visible":"_2RzcnTdaPyc-","option":"y9zhi8Wr8QA-","active":"_3Xg49dtL1Q8-","separator":"LIeh390F3W8-","icon":"K2phy6IC3TY-","text":"a6-LbUm5WnY-","label":"tQNbuxcE9nU-","details":"qacStG9-XbE-","spinning":"P9cQDL4MZ-s-"};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default, { useState, useRef, useEffect, useCallback, useMemo, forwardRef } from 'react';
|
|
2
|
-
import { u as useFloating, b as autoUpdate, o as offset, f as flip, c as size, e as useListNavigation, d as useDismiss, g as useInteractions,
|
|
2
|
+
import { u as useFloating, b as autoUpdate, o as offset, f as flip, c as size, r as useClick, e as useListNavigation, d as useDismiss, g as useInteractions, t as useTransitionStyles, F as FloatingPortal, p as FloatingFocusManager } from '../floating-ui.react-es.js';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { tokens } from '@jobber/design';
|
|
5
5
|
import { useCallbackRef, useDebounce, useSafeLayoutEffect, useIsMounted, useOnKeyDown } from '@jobber/hooks';
|
|
@@ -127,7 +127,7 @@ function invokeActiveItemOnEnter(event, activeIndex, renderable, onSelect, onAct
|
|
|
127
127
|
|
|
128
128
|
const MENU_OFFSET = tokens["space-small"];
|
|
129
129
|
const AUTOCOMPLETE_MAX_HEIGHT$1 = 300;
|
|
130
|
-
function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, }) {
|
|
130
|
+
function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, readOnly = false, }) {
|
|
131
131
|
const [open, setOpen] = useState(false);
|
|
132
132
|
const [activeIndex, setActiveIndex] = useState(null);
|
|
133
133
|
const listRef = useRef([]);
|
|
@@ -159,6 +159,10 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
|
|
|
159
159
|
}),
|
|
160
160
|
],
|
|
161
161
|
});
|
|
162
|
+
const click = useClick(context, {
|
|
163
|
+
enabled: !readOnly,
|
|
164
|
+
toggle: false, // Only open, never close on click
|
|
165
|
+
});
|
|
162
166
|
const listNav = useListNavigation(context, {
|
|
163
167
|
listRef,
|
|
164
168
|
activeIndex,
|
|
@@ -180,7 +184,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
|
|
|
180
184
|
escapeKey: true,
|
|
181
185
|
outsidePressEvent: "click",
|
|
182
186
|
});
|
|
183
|
-
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([listNav, dismiss]);
|
|
187
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([click, listNav, dismiss]);
|
|
184
188
|
useEffect(() => {
|
|
185
189
|
listRef.current.length = navigableCount;
|
|
186
190
|
setActiveIndex(prev => {
|
|
@@ -207,11 +211,34 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
|
|
|
207
211
|
};
|
|
208
212
|
}
|
|
209
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Handler that prevents default pointer behavior.
|
|
216
|
+
* Used to prevent blur/focus issues when clicking on non-interactive menu elements.
|
|
217
|
+
*/
|
|
218
|
+
function preventDefaultPointerDown(e) {
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Creates a handler for pointer down events on interactive menu items (options/actions).
|
|
223
|
+
* Prevents default to avoid blur and sets flag for focus management.
|
|
224
|
+
*
|
|
225
|
+
* @param isHandlingMenuInteractionRef - Ref to track if a menu interaction is in progress
|
|
226
|
+
* @returns A pointer down event handler
|
|
227
|
+
*/
|
|
228
|
+
function createInteractionPointerDownHandler(isHandlingMenuInteractionRef) {
|
|
229
|
+
return (e) => {
|
|
230
|
+
e.preventDefault();
|
|
231
|
+
// Set flag to prevent blur/focus handlers from interfering
|
|
232
|
+
isHandlingMenuInteractionRef.current = true;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
210
236
|
// Keeping this hook cohesive improves readability by centralizing related
|
|
211
237
|
// interactions and state transitions.
|
|
212
238
|
// eslint-disable-next-line max-statements
|
|
213
239
|
function useAutocomplete(props) {
|
|
214
240
|
const { menu, emptyActions, getOptionLabel: getOptionLabelProp, isOptionEqualToValue, inputValue, onInputChange, value, onChange, multiple, openOnFocus = true, readOnly = false, debounce: debounceMs = 300, } = props;
|
|
241
|
+
const isHandlingMenuInteractionRef = useRef(false);
|
|
215
242
|
// TODO: Clean up the types in these refs by enhancing the type system in useCallbackRef
|
|
216
243
|
const getOptionLabelPropRef = useCallbackRef((opt) => getOptionLabelProp === null || getOptionLabelProp === void 0 ? void 0 : getOptionLabelProp(opt));
|
|
217
244
|
const getOptionLabel = useCallback((opt) => {
|
|
@@ -254,7 +281,8 @@ function useAutocomplete(props) {
|
|
|
254
281
|
const [debouncedInputValue, setDebouncedInputValue] = useState(inputValue);
|
|
255
282
|
const debouncedSetter = useDebounce(setDebouncedInputValue, debounceMs);
|
|
256
283
|
useEffect(() => {
|
|
257
|
-
|
|
284
|
+
// Skip debounce when clearing input for immediate feedback, preventing flickering of last selected item
|
|
285
|
+
if (debounceMs === 0 || inputValue === "") {
|
|
258
286
|
setDebouncedInputValue(inputValue);
|
|
259
287
|
return;
|
|
260
288
|
}
|
|
@@ -344,6 +372,7 @@ function useAutocomplete(props) {
|
|
|
344
372
|
navigableCount: totalNavigableCount,
|
|
345
373
|
shouldResetActiveIndexOnClose: () => !hasSelection,
|
|
346
374
|
selectedIndex,
|
|
375
|
+
readOnly,
|
|
347
376
|
onMenuClose: () => {
|
|
348
377
|
if (props.allowFreeForm !== true) {
|
|
349
378
|
const hasText = inputValue.trim().length > 0;
|
|
@@ -355,7 +384,6 @@ function useAutocomplete(props) {
|
|
|
355
384
|
}
|
|
356
385
|
},
|
|
357
386
|
});
|
|
358
|
-
const [inputFocused, setInputFocused] = useState(false);
|
|
359
387
|
// Handles activeIndex reset and, in single-select mode only, clearing selection when input is empty
|
|
360
388
|
useEffect(() => {
|
|
361
389
|
const hasText = inputValue.trim().length > 0;
|
|
@@ -451,13 +479,24 @@ function useAutocomplete(props) {
|
|
|
451
479
|
selectOption(option);
|
|
452
480
|
// Might not always want to close on selection. Multi for example.
|
|
453
481
|
setOpen(false);
|
|
482
|
+
if (refs.domReference.current instanceof HTMLElement) {
|
|
483
|
+
refs.domReference.current.focus();
|
|
484
|
+
}
|
|
454
485
|
}, [selectOption, setOpen]);
|
|
455
486
|
const onAction = useCallback((action) => {
|
|
456
487
|
action.run();
|
|
457
488
|
setActiveIndex(null);
|
|
458
489
|
if (action.closeOnRun !== false)
|
|
459
490
|
setOpen(false);
|
|
491
|
+
if (refs.domReference.current instanceof HTMLElement) {
|
|
492
|
+
refs.domReference.current.focus();
|
|
493
|
+
}
|
|
460
494
|
}, [setOpen, setActiveIndex]);
|
|
495
|
+
/**
|
|
496
|
+
* Handler for mousedown on interactive menu items (options/actions)
|
|
497
|
+
* Prevents default to avoid blur and sets flag for focus management
|
|
498
|
+
*/
|
|
499
|
+
const onInteractionPointerDown = useMemo(() => createInteractionPointerDownHandler(isHandlingMenuInteractionRef), []);
|
|
461
500
|
function commitFromInputText(inputText) {
|
|
462
501
|
var _a;
|
|
463
502
|
if (inputText.length === 0)
|
|
@@ -499,14 +538,20 @@ function useAutocomplete(props) {
|
|
|
499
538
|
]);
|
|
500
539
|
const onInputFocus = useCallback((event) => {
|
|
501
540
|
var _a;
|
|
502
|
-
|
|
503
|
-
if (!readOnly && openOnFocus)
|
|
541
|
+
if (!readOnly && openOnFocus && !isHandlingMenuInteractionRef.current) {
|
|
504
542
|
setOpen(true);
|
|
505
|
-
|
|
543
|
+
}
|
|
544
|
+
// Only call user's onFocus for genuine focus events, not programmatic restorations
|
|
545
|
+
if (!isHandlingMenuInteractionRef.current) {
|
|
546
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
547
|
+
}
|
|
548
|
+
isHandlingMenuInteractionRef.current = false;
|
|
506
549
|
}, [props.onFocus, readOnly, openOnFocus, setOpen]);
|
|
507
550
|
const onInputBlur = useCallback((event) => {
|
|
508
551
|
var _a, _b;
|
|
509
|
-
|
|
552
|
+
if (isHandlingMenuInteractionRef.current) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
510
555
|
if (readOnly) {
|
|
511
556
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
512
557
|
return;
|
|
@@ -612,11 +657,11 @@ function useAutocomplete(props) {
|
|
|
612
657
|
setActiveIndex(null);
|
|
613
658
|
}
|
|
614
659
|
// Important: update open state before propagating the change so that downstream effects
|
|
615
|
-
// don
|
|
660
|
+
// don't see an intermediate state where inputValue changed but open was stale
|
|
616
661
|
if (!readOnly) {
|
|
617
662
|
const hasText = val.trim().length > 0;
|
|
618
663
|
const mustSelectFromOptions = hasText && !props.allowFreeForm;
|
|
619
|
-
const keepOpenOnEmpty = openOnFocus
|
|
664
|
+
const keepOpenOnEmpty = openOnFocus;
|
|
620
665
|
setOpen(mustSelectFromOptions || keepOpenOnEmpty);
|
|
621
666
|
}
|
|
622
667
|
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(val);
|
|
@@ -627,7 +672,6 @@ function useAutocomplete(props) {
|
|
|
627
672
|
readOnly,
|
|
628
673
|
props.allowFreeForm,
|
|
629
674
|
openOnFocus,
|
|
630
|
-
inputFocused,
|
|
631
675
|
setOpen,
|
|
632
676
|
]);
|
|
633
677
|
return {
|
|
@@ -656,6 +700,7 @@ function useAutocomplete(props) {
|
|
|
656
700
|
// actions
|
|
657
701
|
onSelection,
|
|
658
702
|
onAction,
|
|
703
|
+
onInteractionPointerDown,
|
|
659
704
|
// input handlers
|
|
660
705
|
onInputChangeFromUser,
|
|
661
706
|
onInputBlur,
|
|
@@ -666,7 +711,7 @@ function useAutocomplete(props) {
|
|
|
666
711
|
};
|
|
667
712
|
}
|
|
668
713
|
|
|
669
|
-
function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, isOptionSelected, slotOverrides, }) {
|
|
714
|
+
function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, onInteractionPointerDown, isOptionSelected, slotOverrides, }) {
|
|
670
715
|
let navigableIndex = -1;
|
|
671
716
|
function renderItemNode(item) {
|
|
672
717
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -690,6 +735,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
|
|
|
690
735
|
customRenderOption,
|
|
691
736
|
getOptionLabel,
|
|
692
737
|
onSelect,
|
|
738
|
+
onInteractionPointerDown,
|
|
693
739
|
indexOffset,
|
|
694
740
|
optionClassName: (_c = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _c === void 0 ? void 0 : _c.className,
|
|
695
741
|
optionStyle: (_d = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _d === void 0 ? void 0 : _d.style,
|
|
@@ -706,6 +752,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
|
|
|
706
752
|
listboxId,
|
|
707
753
|
customRenderAction,
|
|
708
754
|
onAction,
|
|
755
|
+
onInteractionPointerDown,
|
|
709
756
|
indexOffset,
|
|
710
757
|
actionClassName: (_e = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _e === void 0 ? void 0 : _e.className,
|
|
711
758
|
actionStyle: (_f = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _f === void 0 ? void 0 : _f.style,
|
|
@@ -719,12 +766,12 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
|
|
|
719
766
|
function handleSectionRendering({ customRenderSection, section, sectionClassName, sectionStyle, }) {
|
|
720
767
|
var _a;
|
|
721
768
|
const headerContent = customRenderSection ? (customRenderSection(section)) : (React__default.createElement(DefaultSectionContent, { section: section }));
|
|
722
|
-
return (React__default.createElement("div", { key: `section-${String((_a = section.key) !== null && _a !== void 0 ? _a : section.label)}`, role: "presentation", tabIndex: -1, "data-testid": "ATL-AutocompleteRebuilt-Section", className: classnames(styles$1.section, styles$1.stickyTop, sectionClassName), style: sectionStyle }, headerContent));
|
|
769
|
+
return (React__default.createElement("div", { key: `section-${String((_a = section.key) !== null && _a !== void 0 ? _a : section.label)}`, role: "presentation", tabIndex: -1, "data-testid": "ATL-AutocompleteRebuilt-Section", className: classnames(styles$1.section, styles$1.stickyTop, sectionClassName), style: sectionStyle, onPointerDown: preventDefaultPointerDown }, headerContent));
|
|
723
770
|
}
|
|
724
771
|
function DefaultSectionContent({ section, }) {
|
|
725
772
|
return React__default.createElement(Heading, { level: 5 }, section.label);
|
|
726
773
|
}
|
|
727
|
-
function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, indexOffset = 0, optionClassName, optionStyle, }) {
|
|
774
|
+
function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, onInteractionPointerDown, indexOffset = 0, optionClassName, optionStyle, }) {
|
|
728
775
|
var _a;
|
|
729
776
|
const nextNavigableIndex = navigableIndex + 1;
|
|
730
777
|
const isActive = activeIndex === nextNavigableIndex;
|
|
@@ -738,6 +785,7 @@ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemPro
|
|
|
738
785
|
listRef.current[idx] = node;
|
|
739
786
|
},
|
|
740
787
|
onClick: () => onSelect(option),
|
|
788
|
+
onPointerDown: onInteractionPointerDown,
|
|
741
789
|
className: classnames(styles$1.option, isActive && styles$1.optionActive, optionClassName),
|
|
742
790
|
style: optionStyle,
|
|
743
791
|
}), { role: "option", tabIndex: -1, "aria-selected": isSelected ? true : false, id: `${listboxId}-item-${nextNavigableIndex + indexOffset}`, "data-index": nextNavigableIndex + indexOffset, "data-active": isActive ? true : undefined }), optionContent)),
|
|
@@ -749,7 +797,7 @@ function DefaultOptionContent({ isSelected, text, }) {
|
|
|
749
797
|
React__default.createElement("div", { className: styles$1.icon }, isSelected && React__default.createElement(Icon, { name: "checkmark", size: "small" })),
|
|
750
798
|
React__default.createElement(Text, null, text)));
|
|
751
799
|
}
|
|
752
|
-
function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, indexOffset = 0, actionClassName, actionStyle, origin, }) {
|
|
800
|
+
function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, onInteractionPointerDown, indexOffset = 0, actionClassName, actionStyle, origin, }) {
|
|
753
801
|
var _a;
|
|
754
802
|
const nextNavigableIndex = navigableIndex + 1;
|
|
755
803
|
const isActive = activeIndex === nextNavigableIndex;
|
|
@@ -767,6 +815,7 @@ function handleActionRendering({ action, activeIndex, navigableIndex, getItemPro
|
|
|
767
815
|
closeOnRun: action.shouldClose,
|
|
768
816
|
});
|
|
769
817
|
},
|
|
818
|
+
onPointerDown: onInteractionPointerDown,
|
|
770
819
|
className: classnames(styles$1.action, isActive && styles$1.actionActive, actionClassName),
|
|
771
820
|
style: actionStyle,
|
|
772
821
|
});
|
|
@@ -784,7 +833,7 @@ function DefaultActionContent({ textContent, }) {
|
|
|
784
833
|
} }, textContent));
|
|
785
834
|
}
|
|
786
835
|
|
|
787
|
-
function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, }) {
|
|
836
|
+
function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, onInteractionPointerDown, }) {
|
|
788
837
|
if (!items || items.length === 0)
|
|
789
838
|
return null;
|
|
790
839
|
let navigableIndex = -1;
|
|
@@ -799,13 +848,14 @@ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemPr
|
|
|
799
848
|
customRenderFooter,
|
|
800
849
|
listRef,
|
|
801
850
|
onAction,
|
|
851
|
+
onInteractionPointerDown,
|
|
802
852
|
navigableIndex,
|
|
803
853
|
});
|
|
804
854
|
navigableIndex = result.nextNavigableIndex;
|
|
805
855
|
return result.node;
|
|
806
856
|
})));
|
|
807
857
|
}
|
|
808
|
-
function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
|
|
858
|
+
function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionPointerDown, navigableIndex, }) {
|
|
809
859
|
const interactive = Boolean(persistent.onClick);
|
|
810
860
|
if (!interactive) {
|
|
811
861
|
const node = handleTextPersistentRendering({
|
|
@@ -826,6 +876,7 @@ function handlePersistentRendering({ persistent, position, activeIndex, indexOff
|
|
|
826
876
|
customRenderFooter,
|
|
827
877
|
listRef,
|
|
828
878
|
onAction,
|
|
879
|
+
onInteractionPointerDown,
|
|
829
880
|
navigableIndex,
|
|
830
881
|
});
|
|
831
882
|
}
|
|
@@ -841,9 +892,9 @@ function handleTextPersistentRendering({ persistent, position, customRenderHeade
|
|
|
841
892
|
else {
|
|
842
893
|
content = React__default.createElement(DefaultTextPersistentContent, { persistent: persistent });
|
|
843
894
|
}
|
|
844
|
-
return (React__default.createElement("div", { key: `persistent-${position}-${String((_a = persistent.key) !== null && _a !== void 0 ? _a : persistent.label)}`, role: "presentation", tabIndex: -1, className: styles$1.textPersistent }, content));
|
|
895
|
+
return (React__default.createElement("div", { key: `persistent-${position}-${String((_a = persistent.key) !== null && _a !== void 0 ? _a : persistent.label)}`, role: "presentation", tabIndex: -1, className: styles$1.textPersistent, onPointerDown: preventDefaultPointerDown }, content));
|
|
845
896
|
}
|
|
846
|
-
function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
|
|
897
|
+
function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionPointerDown, navigableIndex, }) {
|
|
847
898
|
var _a;
|
|
848
899
|
const nextNavigableIndex = navigableIndex + 1;
|
|
849
900
|
const isActive = activeIndex === indexOffset + nextNavigableIndex;
|
|
@@ -870,13 +921,16 @@ function handleActionPersistentRendering({ persistent, position, activeIndex, in
|
|
|
870
921
|
if (persistNode)
|
|
871
922
|
listRef.current[idx] = persistNode;
|
|
872
923
|
},
|
|
873
|
-
onClick: () =>
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
924
|
+
onClick: () => {
|
|
925
|
+
onAction({
|
|
926
|
+
run: () => {
|
|
927
|
+
var _a;
|
|
928
|
+
(_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
|
|
929
|
+
},
|
|
930
|
+
closeOnRun: persistent.shouldClose,
|
|
931
|
+
});
|
|
932
|
+
},
|
|
933
|
+
onPointerDown: onInteractionPointerDown,
|
|
880
934
|
className: classnames(styles$1.action, isActive && styles$1.actionActive),
|
|
881
935
|
}), { role: "button", tabIndex: -1 }), content)),
|
|
882
936
|
nextNavigableIndex,
|
|
@@ -891,7 +945,7 @@ const AutocompleteRebuilt = forwardRef(AutocompleteRebuiltInternal);
|
|
|
891
945
|
function AutocompleteRebuiltInternal(props, forwardedRef) {
|
|
892
946
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
893
947
|
const { inputValue, placeholder, disabled, error, invalid, description, size: sizeProp, loading = false, } = props;
|
|
894
|
-
const { renderable, optionCount, persistentsHeaders, persistentsFooters, headerInteractiveCount, middleNavigableCount, getOptionLabel, isOptionSelected, refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps, activeIndex, open, listRef, onSelection, onAction, onInputChangeFromUser, onInputBlur, onInputFocus, onInputKeyDown, setReferenceElement, } = useAutocomplete(props);
|
|
948
|
+
const { renderable, optionCount, persistentsHeaders, persistentsFooters, headerInteractiveCount, middleNavigableCount, getOptionLabel, isOptionSelected, refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps, activeIndex, open, listRef, onSelection, onAction, onInteractionPointerDown, onInputChangeFromUser, onInputBlur, onInputFocus, onInputKeyDown, setReferenceElement, } = useAutocomplete(props);
|
|
895
949
|
const listboxId = React__default.useId();
|
|
896
950
|
// Provides mount/unmount-aware transition styles for the floating element
|
|
897
951
|
const { isMounted, styles: transitionStyles } = useTransitionStyles(context, {
|
|
@@ -951,10 +1005,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
|
|
|
951
1005
|
? { width: menuWidth, maxWidth: menuWidth }
|
|
952
1006
|
: {})),
|
|
953
1007
|
})),
|
|
954
|
-
React__default.createElement(PersistentRegion, { items: persistentsHeaders, position: "header", activeIndex: activeIndex, indexOffset: 0, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, className: classnames(styles$1.persistentHeader, (_c = props.UNSAFE_className) === null || _c === void 0 ? void 0 : _c.header), style: (_d = props.UNSAFE_styles) === null || _d === void 0 ? void 0 : _d.header }),
|
|
1008
|
+
React__default.createElement(PersistentRegion, { items: persistentsHeaders, position: "header", activeIndex: activeIndex, indexOffset: 0, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, className: classnames(styles$1.persistentHeader, (_c = props.UNSAFE_className) === null || _c === void 0 ? void 0 : _c.header), style: (_d = props.UNSAFE_styles) === null || _d === void 0 ? void 0 : _d.header }),
|
|
955
1009
|
React__default.createElement("div", { className: styles$1.scrollRegion }, loading ? ((_e = props.customRenderLoading) !== null && _e !== void 0 ? _e : React__default.createElement(LoadingContent, null)) : (React__default.createElement(React__default.Fragment, null,
|
|
956
1010
|
showEmptyStateMessage && (React__default.createElement(EmptyStateMessage, { emptyState: props.emptyStateMessage })),
|
|
957
|
-
renderable.length > 0 && (React__default.createElement(MenuList, { items: renderable, activeIndex: activeIndexForMiddle, indexOffset: headerInteractiveCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderOption: props.customRenderOption, customRenderSection: props.customRenderSection, customRenderAction: props.customRenderAction, getOptionLabel: getOptionLabel, onSelect: onSelection, onAction: onAction, isOptionSelected: isOptionSelected, slotOverrides: {
|
|
1011
|
+
renderable.length > 0 && (React__default.createElement(MenuList, { items: renderable, activeIndex: activeIndexForMiddle, indexOffset: headerInteractiveCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderOption: props.customRenderOption, customRenderSection: props.customRenderSection, customRenderAction: props.customRenderAction, getOptionLabel: getOptionLabel, onSelect: onSelection, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, isOptionSelected: isOptionSelected, slotOverrides: {
|
|
958
1012
|
option: {
|
|
959
1013
|
className: (_f = props.UNSAFE_className) === null || _f === void 0 ? void 0 : _f.option,
|
|
960
1014
|
style: (_g = props.UNSAFE_styles) === null || _g === void 0 ? void 0 : _g.option,
|
|
@@ -968,10 +1022,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
|
|
|
968
1022
|
style: (_l = props.UNSAFE_styles) === null || _l === void 0 ? void 0 : _l.section,
|
|
969
1023
|
},
|
|
970
1024
|
} }))))),
|
|
971
|
-
React__default.createElement(PersistentRegion, { items: persistentsFooters, position: "footer", activeIndex: activeIndex, indexOffset: headerInteractiveCount + middleNavigableCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, className: classnames(styles$1.persistentFooter, (_m = props.UNSAFE_className) === null || _m === void 0 ? void 0 : _m.footer), style: (_o = props.UNSAFE_styles) === null || _o === void 0 ? void 0 : _o.footer })))))));
|
|
1025
|
+
React__default.createElement(PersistentRegion, { items: persistentsFooters, position: "footer", activeIndex: activeIndex, indexOffset: headerInteractiveCount + middleNavigableCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, onInteractionPointerDown: onInteractionPointerDown, className: classnames(styles$1.persistentFooter, (_m = props.UNSAFE_className) === null || _m === void 0 ? void 0 : _m.footer), style: (_o = props.UNSAFE_styles) === null || _o === void 0 ? void 0 : _o.footer })))))));
|
|
972
1026
|
}
|
|
973
1027
|
function LoadingContent() {
|
|
974
|
-
return (React__default.createElement("div", { className: styles$1.loadingList },
|
|
1028
|
+
return (React__default.createElement("div", { className: styles$1.loadingList, onPointerDown: preventDefaultPointerDown },
|
|
975
1029
|
React__default.createElement(Glimmer, { shape: "rectangle", size: "base" }),
|
|
976
1030
|
React__default.createElement(Glimmer, { shape: "rectangle", size: "base" }),
|
|
977
1031
|
React__default.createElement(Glimmer, { shape: "rectangle", size: "base" })));
|
|
@@ -979,7 +1033,7 @@ function LoadingContent() {
|
|
|
979
1033
|
function EmptyStateMessage({ emptyState, }) {
|
|
980
1034
|
const emptyStateDefault = "No options";
|
|
981
1035
|
const emptyStateContent = emptyState !== null && emptyState !== void 0 ? emptyState : emptyStateDefault;
|
|
982
|
-
return React__default.createElement("div", { className: styles$1.emptyStateMessage }, emptyStateContent);
|
|
1036
|
+
return (React__default.createElement("div", { className: styles$1.emptyStateMessage, onPointerDown: preventDefaultPointerDown }, emptyStateContent));
|
|
983
1037
|
}
|
|
984
1038
|
|
|
985
1039
|
var styles = {"autocomplete":"_7mObJiwfPh4-","options":"dL5JShAJlKM-","heading":"PWZL-94hH7k-","visible":"_2RzcnTdaPyc-","option":"y9zhi8Wr8QA-","active":"_3Xg49dtL1Q8-","separator":"LIeh390F3W8-","icon":"K2phy6IC3TY-","text":"a6-LbUm5WnY-","label":"tQNbuxcE9nU-","details":"qacStG9-XbE-","spinning":"P9cQDL4MZ-s-"};
|
|
@@ -36,3 +36,16 @@ export declare function FreeFormWrapper({ initialValue, initialInputValue, onCha
|
|
|
36
36
|
readonly inputEqualsOption?: (input: string, option: OptionLike) => boolean;
|
|
37
37
|
readonly debounce?: number;
|
|
38
38
|
}): React.JSX.Element;
|
|
39
|
+
/**
|
|
40
|
+
* Wrapper for testing focus and blur behavior with tabbable siblings
|
|
41
|
+
* Includes tabbable elements before and after the autocomplete
|
|
42
|
+
* so tests can use tab navigation to focus without clicking
|
|
43
|
+
*/
|
|
44
|
+
export declare function FocusableSiblingsWrapper<T extends OptionLike>({ onFocus, onChange, onInputChange, menu, readOnly, openOnFocus, }: {
|
|
45
|
+
readonly onChange?: (v: T | undefined) => void;
|
|
46
|
+
readonly onInputChange?: (v: string) => void;
|
|
47
|
+
readonly menu?: MenuItem<T>[];
|
|
48
|
+
readonly readOnly?: boolean;
|
|
49
|
+
readonly onFocus?: () => void;
|
|
50
|
+
readonly openOnFocus?: boolean;
|
|
51
|
+
}): React.JSX.Element;
|
|
@@ -58,6 +58,7 @@ export declare function useAutocomplete<Value extends OptionLike, Multiple exten
|
|
|
58
58
|
listRef: React.RefObject<(HTMLElement | null)[]>;
|
|
59
59
|
onSelection: (option: Value) => void;
|
|
60
60
|
onAction: (action: ActionConfig) => void;
|
|
61
|
+
onInteractionPointerDown: (e: React.PointerEvent) => void;
|
|
61
62
|
onInputChangeFromUser: (val: string) => void;
|
|
62
63
|
onInputBlur: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
63
64
|
onInputFocus: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Handler that prevents default pointer behavior.
|
|
4
|
+
* Used to prevent blur/focus issues when clicking on non-interactive menu elements.
|
|
5
|
+
*/
|
|
6
|
+
export declare function preventDefaultPointerDown(e: React.PointerEvent): void;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a handler for pointer down events on interactive menu items (options/actions).
|
|
9
|
+
* Prevents default to avoid blur and sets flag for focus management.
|
|
10
|
+
*
|
|
11
|
+
* @param isHandlingMenuInteractionRef - Ref to track if a menu interaction is in progress
|
|
12
|
+
* @returns A pointer down event handler
|
|
13
|
+
*/
|
|
14
|
+
export declare function createInteractionPointerDownHandler(isHandlingMenuInteractionRef: React.RefObject<boolean>): (e: React.PointerEvent) => void;
|
|
@@ -40,6 +40,10 @@ interface BaseDatePickerProps {
|
|
|
40
40
|
* Change handler when the selected month changes
|
|
41
41
|
*/
|
|
42
42
|
onMonthChange?(val: Date): void;
|
|
43
|
+
/**
|
|
44
|
+
* Callback when the calendar open state changes
|
|
45
|
+
*/
|
|
46
|
+
onOpenChange?(open: boolean): void;
|
|
43
47
|
}
|
|
44
48
|
interface DatePickerModalProps extends BaseDatePickerProps {
|
|
45
49
|
/**
|
|
@@ -66,5 +70,5 @@ interface DatePickerInlineProps extends BaseDatePickerProps {
|
|
|
66
70
|
readonly inline?: boolean;
|
|
67
71
|
}
|
|
68
72
|
type DatePickerProps = XOR<DatePickerModalProps, DatePickerInlineProps>;
|
|
69
|
-
export declare function DatePicker({ onChange, onMonthChange, activator, inline, selected, readonly, disabled, fullWidth, smartAutofocus, maxDate, minDate, highlightDates, firstDayOfWeek, }: DatePickerProps): React.JSX.Element;
|
|
73
|
+
export declare function DatePicker({ onChange, onMonthChange, onOpenChange, activator, inline, selected, readonly, disabled, fullWidth, smartAutofocus, maxDate, minDate, highlightDates, firstDayOfWeek, }: DatePickerProps): React.JSX.Element;
|
|
70
74
|
export {};
|
package/dist/DatePicker-cjs.js
CHANGED
|
@@ -12705,7 +12705,7 @@ function useFocusOnSelectedDate() {
|
|
|
12705
12705
|
}
|
|
12706
12706
|
|
|
12707
12707
|
/*eslint max-statements: ["error", 14]*/
|
|
12708
|
-
function DatePicker({ onChange, onMonthChange, activator, inline, selected, readonly = false, disabled = false, fullWidth = false, smartAutofocus = true, maxDate, minDate, highlightDates, firstDayOfWeek, }) {
|
|
12708
|
+
function DatePicker({ onChange, onMonthChange, onOpenChange, activator, inline, selected, readonly = false, disabled = false, fullWidth = false, smartAutofocus = true, maxDate, minDate, highlightDates, firstDayOfWeek, }) {
|
|
12709
12709
|
const { ref, focusOnSelectedDate } = useFocusOnSelectedDate();
|
|
12710
12710
|
const [open, setOpen] = React.useState(false);
|
|
12711
12711
|
const { dateFormat, firstDayOfWeek: contextFirstDayOfWeek } = AtlantisContext.useAtlantisContext();
|
|
@@ -12752,9 +12752,11 @@ function DatePicker({ onChange, onMonthChange, activator, inline, selected, read
|
|
|
12752
12752
|
}
|
|
12753
12753
|
function handleCalendarOpen() {
|
|
12754
12754
|
setOpen(true);
|
|
12755
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
|
|
12755
12756
|
}
|
|
12756
12757
|
function handleCalendarClose() {
|
|
12757
12758
|
setOpen(false);
|
|
12759
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
|
|
12758
12760
|
}
|
|
12759
12761
|
}
|
|
12760
12762
|
function useEscapeKeyToCloseDatePicker(open, ref) {
|
package/dist/DatePicker-es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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,
|
|
4
|
+
import { u as useFloating, b as autoUpdate, f as flip, o as offset, a as arrow, v 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';
|
|
@@ -12703,7 +12703,7 @@ function useFocusOnSelectedDate() {
|
|
|
12703
12703
|
}
|
|
12704
12704
|
|
|
12705
12705
|
/*eslint max-statements: ["error", 14]*/
|
|
12706
|
-
function DatePicker({ onChange, onMonthChange, activator, inline, selected, readonly = false, disabled = false, fullWidth = false, smartAutofocus = true, maxDate, minDate, highlightDates, firstDayOfWeek, }) {
|
|
12706
|
+
function DatePicker({ onChange, onMonthChange, onOpenChange, activator, inline, selected, readonly = false, disabled = false, fullWidth = false, smartAutofocus = true, maxDate, minDate, highlightDates, firstDayOfWeek, }) {
|
|
12707
12707
|
const { ref, focusOnSelectedDate } = useFocusOnSelectedDate();
|
|
12708
12708
|
const [open, setOpen] = useState(false);
|
|
12709
12709
|
const { dateFormat, firstDayOfWeek: contextFirstDayOfWeek } = useAtlantisContext();
|
|
@@ -12750,9 +12750,11 @@ function DatePicker({ onChange, onMonthChange, activator, inline, selected, read
|
|
|
12750
12750
|
}
|
|
12751
12751
|
function handleCalendarOpen() {
|
|
12752
12752
|
setOpen(true);
|
|
12753
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
|
|
12753
12754
|
}
|
|
12754
12755
|
function handleCalendarClose() {
|
|
12755
12756
|
setOpen(false);
|
|
12757
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
|
|
12756
12758
|
}
|
|
12757
12759
|
}
|
|
12758
12760
|
function useEscapeKeyToCloseDatePicker(open, ref) {
|
package/dist/InputDate/index.cjs
CHANGED
|
@@ -103,21 +103,47 @@ function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
|
103
103
|
|
|
104
104
|
const InputDateRebuilt = React.forwardRef((props, forwardedRef) => {
|
|
105
105
|
const { onChange } = props;
|
|
106
|
+
const isCalendarOpenRef = React.useRef(false);
|
|
107
|
+
const inputFocusedRef = React.useRef(false);
|
|
108
|
+
const compositeFocusedRef = React.useRef(false);
|
|
109
|
+
const lastBlurEventRef = React.useRef(null);
|
|
106
110
|
return (React.createElement(DatePicker.DatePicker, { selected: props.value, onChange: newValue => {
|
|
107
111
|
onChange(newValue);
|
|
108
|
-
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator
|
|
112
|
+
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator, onOpenChange: open => {
|
|
113
|
+
var _a;
|
|
114
|
+
isCalendarOpenRef.current = open;
|
|
115
|
+
// When calendar closes, fire onBlur if input is also not focused
|
|
116
|
+
if (!open &&
|
|
117
|
+
!inputFocusedRef.current &&
|
|
118
|
+
compositeFocusedRef.current &&
|
|
119
|
+
lastBlurEventRef.current) {
|
|
120
|
+
compositeFocusedRef.current = false;
|
|
121
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, lastBlurEventRef.current);
|
|
122
|
+
}
|
|
123
|
+
} }));
|
|
109
124
|
function InputDateActivator(activatorProps) {
|
|
110
125
|
const { onClick, value } = activatorProps;
|
|
111
126
|
const { handleChange, handleFocus, handleBlur, isFocused } = useInputDateActivatorActions({
|
|
112
127
|
onChange: activatorProps.onChange,
|
|
113
128
|
onFocus: event => {
|
|
114
129
|
var _a, _b;
|
|
115
|
-
|
|
130
|
+
inputFocusedRef.current = true;
|
|
131
|
+
// Fire parent's onFocus only when the composite component first receives focus
|
|
132
|
+
if (!compositeFocusedRef.current) {
|
|
133
|
+
compositeFocusedRef.current = true;
|
|
134
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
135
|
+
}
|
|
116
136
|
(_b = activatorProps.onFocus) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
117
137
|
},
|
|
118
138
|
onBlur: event => {
|
|
119
139
|
var _a, _b;
|
|
120
|
-
|
|
140
|
+
inputFocusedRef.current = false;
|
|
141
|
+
lastBlurEventRef.current = event;
|
|
142
|
+
// Only fire parent's onBlur if calendar is also closed
|
|
143
|
+
if (!isCalendarOpenRef.current && compositeFocusedRef.current) {
|
|
144
|
+
compositeFocusedRef.current = false;
|
|
145
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
146
|
+
}
|
|
121
147
|
(_b = activatorProps.onBlur) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
122
148
|
},
|
|
123
149
|
});
|
package/dist/InputDate/index.mjs
CHANGED
|
@@ -101,21 +101,47 @@ function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
|
101
101
|
|
|
102
102
|
const InputDateRebuilt = forwardRef((props, forwardedRef) => {
|
|
103
103
|
const { onChange } = props;
|
|
104
|
+
const isCalendarOpenRef = useRef(false);
|
|
105
|
+
const inputFocusedRef = useRef(false);
|
|
106
|
+
const compositeFocusedRef = useRef(false);
|
|
107
|
+
const lastBlurEventRef = useRef(null);
|
|
104
108
|
return (React__default.createElement(DatePicker, { selected: props.value, onChange: newValue => {
|
|
105
109
|
onChange(newValue);
|
|
106
|
-
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator
|
|
110
|
+
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator, onOpenChange: open => {
|
|
111
|
+
var _a;
|
|
112
|
+
isCalendarOpenRef.current = open;
|
|
113
|
+
// When calendar closes, fire onBlur if input is also not focused
|
|
114
|
+
if (!open &&
|
|
115
|
+
!inputFocusedRef.current &&
|
|
116
|
+
compositeFocusedRef.current &&
|
|
117
|
+
lastBlurEventRef.current) {
|
|
118
|
+
compositeFocusedRef.current = false;
|
|
119
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, lastBlurEventRef.current);
|
|
120
|
+
}
|
|
121
|
+
} }));
|
|
107
122
|
function InputDateActivator(activatorProps) {
|
|
108
123
|
const { onClick, value } = activatorProps;
|
|
109
124
|
const { handleChange, handleFocus, handleBlur, isFocused } = useInputDateActivatorActions({
|
|
110
125
|
onChange: activatorProps.onChange,
|
|
111
126
|
onFocus: event => {
|
|
112
127
|
var _a, _b;
|
|
113
|
-
|
|
128
|
+
inputFocusedRef.current = true;
|
|
129
|
+
// Fire parent's onFocus only when the composite component first receives focus
|
|
130
|
+
if (!compositeFocusedRef.current) {
|
|
131
|
+
compositeFocusedRef.current = true;
|
|
132
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
133
|
+
}
|
|
114
134
|
(_b = activatorProps.onFocus) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
115
135
|
},
|
|
116
136
|
onBlur: event => {
|
|
117
137
|
var _a, _b;
|
|
118
|
-
|
|
138
|
+
inputFocusedRef.current = false;
|
|
139
|
+
lastBlurEventRef.current = event;
|
|
140
|
+
// Only fire parent's onBlur if calendar is also closed
|
|
141
|
+
if (!isCalendarOpenRef.current && compositeFocusedRef.current) {
|
|
142
|
+
compositeFocusedRef.current = false;
|
|
143
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
144
|
+
}
|
|
119
145
|
(_b = activatorProps.onBlur) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
120
146
|
},
|
|
121
147
|
});
|
|
@@ -1065,6 +1065,12 @@ function isVirtualPointerEvent(event) {
|
|
|
1065
1065
|
// iOS VoiceOver returns 0.333• for width/height.
|
|
1066
1066
|
event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'touch';
|
|
1067
1067
|
}
|
|
1068
|
+
function isMouseLikePointerType(pointerType, strict) {
|
|
1069
|
+
// On some Linux machines with Chromium, mouse inputs return a `pointerType`
|
|
1070
|
+
// of "pen": https://github.com/floating-ui/floating-ui/issues/2015
|
|
1071
|
+
const values = ['mouse', 'pen'];
|
|
1072
|
+
return values.includes(pointerType);
|
|
1073
|
+
}
|
|
1068
1074
|
|
|
1069
1075
|
var isClient$1 = typeof document !== 'undefined';
|
|
1070
1076
|
|
|
@@ -4562,6 +4568,114 @@ const FloatingOverlay = /*#__PURE__*/React__namespace.forwardRef(function Floati
|
|
|
4562
4568
|
});
|
|
4563
4569
|
});
|
|
4564
4570
|
|
|
4571
|
+
function isButtonTarget(event) {
|
|
4572
|
+
return isHTMLElement(event.target) && event.target.tagName === 'BUTTON';
|
|
4573
|
+
}
|
|
4574
|
+
function isAnchorTarget(event) {
|
|
4575
|
+
return isHTMLElement(event.target) && event.target.tagName === 'A';
|
|
4576
|
+
}
|
|
4577
|
+
function isSpaceIgnored(element) {
|
|
4578
|
+
return isTypeableElement(element);
|
|
4579
|
+
}
|
|
4580
|
+
/**
|
|
4581
|
+
* Opens or closes the floating element when clicking the reference element.
|
|
4582
|
+
* @see https://floating-ui.com/docs/useClick
|
|
4583
|
+
*/
|
|
4584
|
+
function useClick(context, props) {
|
|
4585
|
+
if (props === void 0) {
|
|
4586
|
+
props = {};
|
|
4587
|
+
}
|
|
4588
|
+
const {
|
|
4589
|
+
open,
|
|
4590
|
+
onOpenChange,
|
|
4591
|
+
dataRef,
|
|
4592
|
+
elements: {
|
|
4593
|
+
domReference
|
|
4594
|
+
}
|
|
4595
|
+
} = context;
|
|
4596
|
+
const {
|
|
4597
|
+
enabled = true,
|
|
4598
|
+
event: eventOption = 'click',
|
|
4599
|
+
toggle = true,
|
|
4600
|
+
ignoreMouse = false,
|
|
4601
|
+
keyboardHandlers = true,
|
|
4602
|
+
stickIfOpen = true
|
|
4603
|
+
} = props;
|
|
4604
|
+
const pointerTypeRef = React__namespace.useRef();
|
|
4605
|
+
const didKeyDownRef = React__namespace.useRef(false);
|
|
4606
|
+
const reference = React__namespace.useMemo(() => ({
|
|
4607
|
+
onPointerDown(event) {
|
|
4608
|
+
pointerTypeRef.current = event.pointerType;
|
|
4609
|
+
},
|
|
4610
|
+
onMouseDown(event) {
|
|
4611
|
+
const pointerType = pointerTypeRef.current;
|
|
4612
|
+
|
|
4613
|
+
// Ignore all buttons except for the "main" button.
|
|
4614
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
4615
|
+
if (event.button !== 0) return;
|
|
4616
|
+
if (eventOption === 'click') return;
|
|
4617
|
+
if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
|
|
4618
|
+
if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === 'mousedown' : true)) {
|
|
4619
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
4620
|
+
} else {
|
|
4621
|
+
// Prevent stealing focus from the floating element
|
|
4622
|
+
event.preventDefault();
|
|
4623
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
4624
|
+
}
|
|
4625
|
+
},
|
|
4626
|
+
onClick(event) {
|
|
4627
|
+
const pointerType = pointerTypeRef.current;
|
|
4628
|
+
if (eventOption === 'mousedown' && pointerTypeRef.current) {
|
|
4629
|
+
pointerTypeRef.current = undefined;
|
|
4630
|
+
return;
|
|
4631
|
+
}
|
|
4632
|
+
if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
|
|
4633
|
+
if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === 'click' : true)) {
|
|
4634
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
4635
|
+
} else {
|
|
4636
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
4637
|
+
}
|
|
4638
|
+
},
|
|
4639
|
+
onKeyDown(event) {
|
|
4640
|
+
pointerTypeRef.current = undefined;
|
|
4641
|
+
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {
|
|
4642
|
+
return;
|
|
4643
|
+
}
|
|
4644
|
+
if (event.key === ' ' && !isSpaceIgnored(domReference)) {
|
|
4645
|
+
// Prevent scrolling
|
|
4646
|
+
event.preventDefault();
|
|
4647
|
+
didKeyDownRef.current = true;
|
|
4648
|
+
}
|
|
4649
|
+
if (isAnchorTarget(event)) {
|
|
4650
|
+
return;
|
|
4651
|
+
}
|
|
4652
|
+
if (event.key === 'Enter') {
|
|
4653
|
+
if (open && toggle) {
|
|
4654
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
4655
|
+
} else {
|
|
4656
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
4657
|
+
}
|
|
4658
|
+
}
|
|
4659
|
+
},
|
|
4660
|
+
onKeyUp(event) {
|
|
4661
|
+
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {
|
|
4662
|
+
return;
|
|
4663
|
+
}
|
|
4664
|
+
if (event.key === ' ' && didKeyDownRef.current) {
|
|
4665
|
+
didKeyDownRef.current = false;
|
|
4666
|
+
if (open && toggle) {
|
|
4667
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
4668
|
+
} else {
|
|
4669
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
4670
|
+
}
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
4673
|
+
}), [dataRef, domReference, eventOption, ignoreMouse, keyboardHandlers, onOpenChange, open, stickIfOpen, toggle]);
|
|
4674
|
+
return React__namespace.useMemo(() => enabled ? {
|
|
4675
|
+
reference
|
|
4676
|
+
} : {}, [enabled, reference]);
|
|
4677
|
+
}
|
|
4678
|
+
|
|
4565
4679
|
const bubbleHandlerKeys = {
|
|
4566
4680
|
pointerdown: 'onPointerDown',
|
|
4567
4681
|
mousedown: 'onMouseDown',
|
|
@@ -5943,6 +6057,7 @@ exports.limitShift = limitShift;
|
|
|
5943
6057
|
exports.offset = offset;
|
|
5944
6058
|
exports.shift = shift;
|
|
5945
6059
|
exports.size = size;
|
|
6060
|
+
exports.useClick = useClick;
|
|
5946
6061
|
exports.useDismiss = useDismiss;
|
|
5947
6062
|
exports.useFloating = useFloating;
|
|
5948
6063
|
exports.useFloatingNodeId = useFloatingNodeId;
|
|
@@ -1044,6 +1044,12 @@ function isVirtualPointerEvent(event) {
|
|
|
1044
1044
|
// iOS VoiceOver returns 0.333• for width/height.
|
|
1045
1045
|
event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'touch';
|
|
1046
1046
|
}
|
|
1047
|
+
function isMouseLikePointerType(pointerType, strict) {
|
|
1048
|
+
// On some Linux machines with Chromium, mouse inputs return a `pointerType`
|
|
1049
|
+
// of "pen": https://github.com/floating-ui/floating-ui/issues/2015
|
|
1050
|
+
const values = ['mouse', 'pen'];
|
|
1051
|
+
return values.includes(pointerType);
|
|
1052
|
+
}
|
|
1047
1053
|
|
|
1048
1054
|
var isClient$1 = typeof document !== 'undefined';
|
|
1049
1055
|
|
|
@@ -4541,6 +4547,114 @@ const FloatingOverlay = /*#__PURE__*/React.forwardRef(function FloatingOverlay(p
|
|
|
4541
4547
|
});
|
|
4542
4548
|
});
|
|
4543
4549
|
|
|
4550
|
+
function isButtonTarget(event) {
|
|
4551
|
+
return isHTMLElement(event.target) && event.target.tagName === 'BUTTON';
|
|
4552
|
+
}
|
|
4553
|
+
function isAnchorTarget(event) {
|
|
4554
|
+
return isHTMLElement(event.target) && event.target.tagName === 'A';
|
|
4555
|
+
}
|
|
4556
|
+
function isSpaceIgnored(element) {
|
|
4557
|
+
return isTypeableElement(element);
|
|
4558
|
+
}
|
|
4559
|
+
/**
|
|
4560
|
+
* Opens or closes the floating element when clicking the reference element.
|
|
4561
|
+
* @see https://floating-ui.com/docs/useClick
|
|
4562
|
+
*/
|
|
4563
|
+
function useClick(context, props) {
|
|
4564
|
+
if (props === void 0) {
|
|
4565
|
+
props = {};
|
|
4566
|
+
}
|
|
4567
|
+
const {
|
|
4568
|
+
open,
|
|
4569
|
+
onOpenChange,
|
|
4570
|
+
dataRef,
|
|
4571
|
+
elements: {
|
|
4572
|
+
domReference
|
|
4573
|
+
}
|
|
4574
|
+
} = context;
|
|
4575
|
+
const {
|
|
4576
|
+
enabled = true,
|
|
4577
|
+
event: eventOption = 'click',
|
|
4578
|
+
toggle = true,
|
|
4579
|
+
ignoreMouse = false,
|
|
4580
|
+
keyboardHandlers = true,
|
|
4581
|
+
stickIfOpen = true
|
|
4582
|
+
} = props;
|
|
4583
|
+
const pointerTypeRef = React.useRef();
|
|
4584
|
+
const didKeyDownRef = React.useRef(false);
|
|
4585
|
+
const reference = React.useMemo(() => ({
|
|
4586
|
+
onPointerDown(event) {
|
|
4587
|
+
pointerTypeRef.current = event.pointerType;
|
|
4588
|
+
},
|
|
4589
|
+
onMouseDown(event) {
|
|
4590
|
+
const pointerType = pointerTypeRef.current;
|
|
4591
|
+
|
|
4592
|
+
// Ignore all buttons except for the "main" button.
|
|
4593
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
4594
|
+
if (event.button !== 0) return;
|
|
4595
|
+
if (eventOption === 'click') return;
|
|
4596
|
+
if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
|
|
4597
|
+
if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === 'mousedown' : true)) {
|
|
4598
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
4599
|
+
} else {
|
|
4600
|
+
// Prevent stealing focus from the floating element
|
|
4601
|
+
event.preventDefault();
|
|
4602
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
4603
|
+
}
|
|
4604
|
+
},
|
|
4605
|
+
onClick(event) {
|
|
4606
|
+
const pointerType = pointerTypeRef.current;
|
|
4607
|
+
if (eventOption === 'mousedown' && pointerTypeRef.current) {
|
|
4608
|
+
pointerTypeRef.current = undefined;
|
|
4609
|
+
return;
|
|
4610
|
+
}
|
|
4611
|
+
if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
|
|
4612
|
+
if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === 'click' : true)) {
|
|
4613
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
4614
|
+
} else {
|
|
4615
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
4616
|
+
}
|
|
4617
|
+
},
|
|
4618
|
+
onKeyDown(event) {
|
|
4619
|
+
pointerTypeRef.current = undefined;
|
|
4620
|
+
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {
|
|
4621
|
+
return;
|
|
4622
|
+
}
|
|
4623
|
+
if (event.key === ' ' && !isSpaceIgnored(domReference)) {
|
|
4624
|
+
// Prevent scrolling
|
|
4625
|
+
event.preventDefault();
|
|
4626
|
+
didKeyDownRef.current = true;
|
|
4627
|
+
}
|
|
4628
|
+
if (isAnchorTarget(event)) {
|
|
4629
|
+
return;
|
|
4630
|
+
}
|
|
4631
|
+
if (event.key === 'Enter') {
|
|
4632
|
+
if (open && toggle) {
|
|
4633
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
4634
|
+
} else {
|
|
4635
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4638
|
+
},
|
|
4639
|
+
onKeyUp(event) {
|
|
4640
|
+
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {
|
|
4641
|
+
return;
|
|
4642
|
+
}
|
|
4643
|
+
if (event.key === ' ' && didKeyDownRef.current) {
|
|
4644
|
+
didKeyDownRef.current = false;
|
|
4645
|
+
if (open && toggle) {
|
|
4646
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
4647
|
+
} else {
|
|
4648
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
}
|
|
4652
|
+
}), [dataRef, domReference, eventOption, ignoreMouse, keyboardHandlers, onOpenChange, open, stickIfOpen, toggle]);
|
|
4653
|
+
return React.useMemo(() => enabled ? {
|
|
4654
|
+
reference
|
|
4655
|
+
} : {}, [enabled, reference]);
|
|
4656
|
+
}
|
|
4657
|
+
|
|
4544
4658
|
const bubbleHandlerKeys = {
|
|
4545
4659
|
pointerdown: 'onPointerDown',
|
|
4546
4660
|
mousedown: 'onMouseDown',
|
|
@@ -5908,4 +6022,4 @@ function useTransitionStyles(context, props) {
|
|
|
5908
6022
|
};
|
|
5909
6023
|
}
|
|
5910
6024
|
|
|
5911
|
-
export { FloatingPortal as F, arrow as a, autoUpdate as b, size as c, useDismiss as d, useListNavigation as e, flip as f, useInteractions as g, useFloatingParentNodeId as h, useFloatingNodeId as i, FloatingTree as j, FloatingNode as k, limitShift as l, autoPlacement as m, useRole as n, offset as o, FloatingFocusManager as p, FloatingOverlay as q,
|
|
6025
|
+
export { FloatingPortal as F, arrow as a, autoUpdate as b, size as c, useDismiss as d, useListNavigation as e, flip as f, useInteractions as g, useFloatingParentNodeId as h, useFloatingNodeId as i, FloatingTree as j, FloatingNode as k, limitShift as l, autoPlacement as m, useRole as n, offset as o, FloatingFocusManager as p, FloatingOverlay as q, useClick as r, shift as s, useTransitionStyles as t, useFloating as u, FloatingArrow as v };
|
package/dist/styles.css
CHANGED
|
@@ -99,11 +99,13 @@
|
|
|
99
99
|
padding: var(--space-small) 0 var(--space-smaller) var(--space-small);
|
|
100
100
|
border-bottom: 1px solid hsl(200, 13%, 87%);
|
|
101
101
|
border-bottom: var(--border-base) solid var(--color-border);
|
|
102
|
+
cursor: default;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
.Twgjn26oldE- {
|
|
105
106
|
padding: 8px 16px;
|
|
106
107
|
padding: var(--space-small) var(--space-base);
|
|
108
|
+
cursor: default;
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
.mc1-CEwZtHE- {
|
|
@@ -132,6 +134,7 @@
|
|
|
132
134
|
.vxk57ZhP8GU- {
|
|
133
135
|
padding: 8px 0 4px 8px;
|
|
134
136
|
padding: var(--space-small) 0 var(--space-smaller) var(--space-small);
|
|
137
|
+
cursor: default;
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
.j4h-0Mxa5gk- {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "6.105.
|
|
3
|
+
"version": "6.105.2",
|
|
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": "
|
|
541
|
+
"gitHead": "a4b58acea68d4e33629e47aba6f812c2c1259d96"
|
|
542
542
|
}
|