@tamagui/floating 3.0.6 → 3.0.8
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/cjs/Floating.native.cjs +2 -2
- package/dist/cjs/Floating.native.js +2 -2
- package/dist/cjs/Floating.native.js.map +1 -1
- package/dist/cjs/interactions/PopupTriggerMap.native.cjs +2 -6
- package/dist/cjs/interactions/PopupTriggerMap.native.js +2 -6
- package/dist/cjs/interactions/PopupTriggerMap.native.js.map +1 -1
- package/dist/cjs/interactions/safePolygon.native.cjs +2 -2
- package/dist/cjs/interactions/safePolygon.native.js +2 -2
- package/dist/cjs/interactions/safePolygon.native.js.map +1 -1
- package/dist/cjs/interactions/useDelayGroup.native.cjs +6 -6
- package/dist/cjs/interactions/useDelayGroup.native.js +6 -6
- package/dist/cjs/interactions/useDelayGroup.native.js.map +1 -1
- package/dist/cjs/interactions/useListNavigation.native.cjs +2 -2
- package/dist/cjs/interactions/useListNavigation.native.js +2 -2
- package/dist/cjs/interactions/useListNavigation.native.js.map +1 -1
- package/dist/cjs/interactions/useRole.native.cjs +1 -1
- package/dist/cjs/interactions/useRole.native.js +1 -1
- package/dist/cjs/interactions/useRole.native.js.map +1 -1
- package/dist/cjs/interactions/useTypeahead.native.cjs +3 -3
- package/dist/cjs/interactions/useTypeahead.native.js +3 -3
- package/dist/cjs/interactions/useTypeahead.native.js.map +1 -1
- package/dist/cjs/interactions/utils.native.cjs +2 -2
- package/dist/cjs/interactions/utils.native.js +2 -2
- package/dist/cjs/interactions/utils.native.js.map +1 -1
- package/dist/cjs/middleware/inner.native.cjs +5 -5
- package/dist/cjs/middleware/inner.native.js +5 -5
- package/dist/cjs/middleware/inner.native.js.map +1 -1
- package/dist/cjs/useFloating.native.cjs +1 -1
- package/dist/cjs/useFloating.native.js +1 -1
- package/dist/cjs/useFloating.native.js.map +1 -1
- package/dist/esm/Floating.native.js +2 -2
- package/dist/esm/Floating.native.js.map +1 -1
- package/dist/esm/interactions/PopupTriggerMap.native.js +2 -6
- package/dist/esm/interactions/PopupTriggerMap.native.js.map +1 -1
- package/dist/esm/interactions/safePolygon.native.js +2 -2
- package/dist/esm/interactions/safePolygon.native.js.map +1 -1
- package/dist/esm/interactions/useDelayGroup.native.js +6 -6
- package/dist/esm/interactions/useDelayGroup.native.js.map +1 -1
- package/dist/esm/interactions/useListNavigation.native.js +2 -2
- package/dist/esm/interactions/useListNavigation.native.js.map +1 -1
- package/dist/esm/interactions/useRole.native.js +1 -1
- package/dist/esm/interactions/useRole.native.js.map +1 -1
- package/dist/esm/interactions/useTypeahead.native.js +3 -3
- package/dist/esm/interactions/useTypeahead.native.js.map +1 -1
- package/dist/esm/interactions/utils.native.js +2 -2
- package/dist/esm/interactions/utils.native.js.map +1 -1
- package/dist/esm/middleware/inner.native.js +5 -5
- package/dist/esm/middleware/inner.native.js.map +1 -1
- package/dist/esm/useFloating.native.js +1 -1
- package/dist/esm/useFloating.native.js.map +1 -1
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
var DelayGroupContext = React.createContext({
|
|
4
4
|
currentId: null,
|
|
5
|
-
setCurrentId: function() {},
|
|
5
|
+
setCurrentId: function setCurrentId() {},
|
|
6
6
|
delay: 0,
|
|
7
7
|
timeoutMs: 0,
|
|
8
8
|
initialDelay: 0
|
|
@@ -14,7 +14,7 @@ function FloatingDelayGroup(param) {
|
|
|
14
14
|
var { children, delay, timeoutMs = 0 } = param;
|
|
15
15
|
var [currentId, setCurrentIdRaw] = React.useState(null);
|
|
16
16
|
var timeoutRef = React.useRef(void 0);
|
|
17
|
-
var
|
|
17
|
+
var setCurrentId2 = React.useCallback(function(id) {
|
|
18
18
|
clearTimeout(timeoutRef.current);
|
|
19
19
|
if (id == null && timeoutMs > 0) {
|
|
20
20
|
timeoutRef.current = setTimeout(function() {
|
|
@@ -32,14 +32,14 @@ function FloatingDelayGroup(param) {
|
|
|
32
32
|
var value = React.useMemo(function() {
|
|
33
33
|
return {
|
|
34
34
|
currentId,
|
|
35
|
-
setCurrentId,
|
|
35
|
+
setCurrentId: setCurrentId2,
|
|
36
36
|
delay,
|
|
37
37
|
timeoutMs,
|
|
38
38
|
initialDelay: delay
|
|
39
39
|
};
|
|
40
40
|
}, [
|
|
41
41
|
currentId,
|
|
42
|
-
|
|
42
|
+
setCurrentId2,
|
|
43
43
|
delay,
|
|
44
44
|
timeoutMs
|
|
45
45
|
]);
|
|
@@ -78,9 +78,9 @@ function useDelayGroup(context) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
function getClose(delay) {
|
|
81
|
+
var _ref;
|
|
81
82
|
if (typeof delay === "number") return delay;
|
|
82
|
-
|
|
83
|
-
return (_delay_close = delay === null || delay === void 0 ? void 0 : delay.close) !== null && _delay_close !== void 0 ? _delay_close : 0;
|
|
83
|
+
return (_ref = delay === null || delay === void 0 ? void 0 : delay.close) !== null && _ref !== void 0 ? _ref : 0;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
export { FloatingDelayGroup, useDelayGroup, useDelayGroupContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDelayGroup.native.js","names":[],"sources":["esm/interactions/useDelayGroup.native.js"],"sourcesContent":["import * as React from \"react\";\nvar DelayGroupContext = React.createContext({\n currentId: null,\n setCurrentId: function() {\n },\n delay: 0,\n timeoutMs: 0,\n initialDelay: 0\n});\nfunction useDelayGroupContext() {\n return React.useContext(DelayGroupContext);\n}\nfunction FloatingDelayGroup(param) {\n var { children, delay, timeoutMs = 0 } = param;\n var [currentId, setCurrentIdRaw] = React.useState(null);\n var timeoutRef = React.useRef(void 0);\n var
|
|
1
|
+
{"version":3,"file":"useDelayGroup.native.js","names":[],"sources":["esm/interactions/useDelayGroup.native.js"],"sourcesContent":["import * as React from \"react\";\nvar DelayGroupContext = React.createContext({\n currentId: null,\n setCurrentId: function setCurrentId() {\n },\n delay: 0,\n timeoutMs: 0,\n initialDelay: 0\n});\nfunction useDelayGroupContext() {\n return React.useContext(DelayGroupContext);\n}\nfunction FloatingDelayGroup(param) {\n var { children, delay, timeoutMs = 0 } = param;\n var [currentId, setCurrentIdRaw] = React.useState(null);\n var timeoutRef = React.useRef(void 0);\n var setCurrentId2 = React.useCallback(function(id) {\n clearTimeout(timeoutRef.current);\n if (id == null && timeoutMs > 0) {\n timeoutRef.current = setTimeout(function() {\n setCurrentIdRaw(null);\n }, timeoutMs);\n } else {\n setCurrentIdRaw(id);\n }\n }, [\n timeoutMs\n ]);\n React.useEffect(function() {\n return function() {\n return clearTimeout(timeoutRef.current);\n };\n }, []);\n var value = React.useMemo(function() {\n return {\n currentId,\n setCurrentId: setCurrentId2,\n delay,\n timeoutMs,\n initialDelay: delay\n };\n }, [\n currentId,\n setCurrentId2,\n delay,\n timeoutMs\n ]);\n return React.createElement(DelayGroupContext.Provider, {\n value\n }, children);\n}\nfunction useDelayGroup(context) {\n var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n var { id } = options;\n var groupContext = React.useContext(DelayGroupContext);\n React.useEffect(function() {\n if (!context.open && groupContext.currentId === id) {\n groupContext.setCurrentId(null);\n }\n }, [\n context.open,\n id\n ]);\n React.useEffect(function() {\n if (groupContext.currentId != null && groupContext.currentId !== id && context.open) {\n context.onOpenChange(false);\n }\n }, [\n groupContext.currentId,\n id,\n context.open\n ]);\n if (groupContext.currentId != null) {\n return {\n delay: {\n open: 1,\n close: getClose(groupContext.initialDelay)\n },\n currentId: groupContext.currentId\n };\n }\n return {\n delay: groupContext.initialDelay,\n currentId: groupContext.currentId\n };\n}\nfunction getClose(delay) {\n var _ref;\n if (typeof delay === \"number\") return delay;\n return (_ref = delay === null || delay === void 0 ? void 0 : delay.close) !== null && _ref !== void 0 ? _ref : 0;\n}\nexport {\n FloatingDelayGroup,\n useDelayGroup,\n useDelayGroupContext\n};\n//# sourceMappingURL=useDelayGroup.js.map\n"],"mappings":";;;AACA,IAAI,oBAAo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MAAM,QAAQ,MAAM;GACnF,QAAQ,aAAa,KAAK;EAC5B;CACF,GAAG;EACD,aAAa;EACb;EACA,QAAQ;CACV,CAAC;CACD,IAAI,aAAa,aAAa,MAAM;EAClC,OAAO;GACL,OAAO;IACL,MAAM;IACN,OAAO,SAAS,aAAa,YAAY;GAC3C;GACA,WAAW,aAAa;EAC1B;CACF;CACA,OAAO;EACL,OAAO,aAAa;EACpB,WAAW,aAAa;CAC1B;AACF;AACA,SAAS,SAAS,OAAO;CACvB,IAAI;CACJ,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,QAAQ,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,WAAW,QAAQ,SAAS,KAAK,IAAI,OAAO;AACjH"}
|
|
@@ -129,7 +129,7 @@ function useListNavigation(context, props) {
|
|
|
129
129
|
}
|
|
130
130
|
if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {
|
|
131
131
|
var runs = 0;
|
|
132
|
-
var waitForListPopulated = function() {
|
|
132
|
+
var waitForListPopulated = function waitForListPopulated1() {
|
|
133
133
|
if (listRef.current[0] == null) {
|
|
134
134
|
if (runs < 2) {
|
|
135
135
|
var scheduler = runs ? requestAnimationFrame : queueMicrotask;
|
|
@@ -370,7 +370,7 @@ function useListNavigation(context, props) {
|
|
|
370
370
|
forceSyncFocusRef.current = true;
|
|
371
371
|
syncCurrentTarget(currentTarget);
|
|
372
372
|
},
|
|
373
|
-
onClick: function(param) {
|
|
373
|
+
onClick: function onClick(param) {
|
|
374
374
|
var { currentTarget } = param;
|
|
375
375
|
return currentTarget.focus({ preventScroll: true });
|
|
376
376
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useListNavigation.native.js","names":[],"sources":["esm/interactions/useListNavigation.native.js"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { useEvent } from \"@tamagui/use-event\";\nimport { activeElement, enqueueFocus, findNonDisabledListIndex, getMinListIndex, getMaxListIndex, isHTMLElement, isIndexOutOfListBounds, isTypeableCombobox, isVirtualClick, isVirtualPointerEvent, stopEvent } from \"./utils\";\nvar ARROW_UP = \"ArrowUp\";\nvar ARROW_DOWN = \"ArrowDown\";\nvar ARROW_LEFT = \"ArrowLeft\";\nvar ARROW_RIGHT = \"ArrowRight\";\nfunction doSwitch(orientation, vertical, horizontal) {\n switch (orientation) {\n case \"vertical\":\n return vertical;\n case \"horizontal\":\n return horizontal;\n default:\n return vertical || horizontal;\n }\n}\nfunction isMainOrientationKey(key, orientation) {\n var vertical = key === ARROW_UP || key === ARROW_DOWN;\n var horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isMainOrientationToEndKey(key, orientation, rtl) {\n var vertical = key === ARROW_DOWN;\n var horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal) || key === \"Enter\" || key === \" \" || key === \"\";\n}\nfunction isCrossOrientationOpenKey(key, orientation, rtl) {\n var vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n var horizontal = key === ARROW_DOWN;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isCrossOrientationCloseKey(key, orientation, rtl) {\n var vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;\n var horizontal = key === ARROW_UP;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction useListNavigation(context, props) {\n var { open, onOpenChange, elements } = context;\n var { listRef, activeIndex, onNavigate: unstable_onNavigate = function() {\n }, enabled = true, selectedIndex = null, allowEscape = false, loop = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = \"auto\", focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices = void 0, orientation = \"vertical\", scrollItemIntoView = true } = props;\n var typeableComboboxReference = isTypeableCombobox(elements.domReference);\n var focusItemOnOpenRef = useRef(focusItemOnOpen);\n var indexRef = useRef(selectedIndex !== null && selectedIndex !== void 0 ? selectedIndex : -1);\n var keyRef = useRef(null);\n var isPointerModalityRef = useRef(true);\n var previousMountedRef = useRef(!!elements.floating);\n var previousOpenRef = useRef(open);\n var forceSyncFocusRef = useRef(false);\n var forceScrollIntoViewRef = useRef(false);\n var disabledIndicesRef = useRef(disabledIndices);\n disabledIndicesRef.current = disabledIndices;\n var latestOpenRef = useRef(open);\n latestOpenRef.current = open;\n var scrollItemIntoViewRef = useRef(scrollItemIntoView);\n scrollItemIntoViewRef.current = scrollItemIntoView;\n var selectedIndexRef = useRef(selectedIndex);\n selectedIndexRef.current = selectedIndex;\n var stableOnNavigate = useEvent(unstable_onNavigate);\n var [activeId, setActiveId] = useState();\n var onNavigate = useEvent(function() {\n stableOnNavigate(indexRef.current === -1 ? null : indexRef.current);\n });\n var previousOnNavigateRef = useRef(onNavigate);\n var focusItem = useEvent(function() {\n function runFocus(item2) {\n if (virtual) {\n setActiveId(item2.id);\n } else {\n enqueueFocus(item2, {\n sync: forceSyncFocusRef.current,\n preventScroll: true\n });\n }\n }\n var initialItem = listRef.current[indexRef.current];\n var forceScrollIntoView = forceScrollIntoViewRef.current;\n if (initialItem) {\n runFocus(initialItem);\n }\n var scheduler = forceSyncFocusRef.current ? function(v) {\n return v();\n } : requestAnimationFrame;\n scheduler(function() {\n var waitedItem = listRef.current[indexRef.current] || initialItem;\n if (!waitedItem) return;\n if (!initialItem) {\n runFocus(waitedItem);\n }\n var scrollIntoViewOptions = scrollItemIntoViewRef.current;\n var shouldScrollIntoView = scrollIntoViewOptions && waitedItem && (forceScrollIntoView || !isPointerModalityRef.current);\n if (shouldScrollIntoView) {\n var _waitedItem_scrollIntoView;\n (_waitedItem_scrollIntoView = waitedItem.scrollIntoView) === null || _waitedItem_scrollIntoView === void 0 ? void 0 : _waitedItem_scrollIntoView.call(waitedItem, typeof scrollIntoViewOptions === \"boolean\" ? {\n block: \"nearest\",\n inline: \"nearest\"\n } : scrollIntoViewOptions);\n }\n });\n });\n useLayoutEffect(function() {\n if (!enabled) return;\n if (open && elements.floating) {\n if (focusItemOnOpenRef.current && selectedIndex != null) {\n forceScrollIntoViewRef.current = true;\n indexRef.current = selectedIndex;\n onNavigate();\n }\n } else if (previousMountedRef.current) {\n indexRef.current = -1;\n previousOnNavigateRef.current();\n }\n }, [\n enabled,\n open,\n elements.floating,\n selectedIndex,\n onNavigate\n ]);\n useLayoutEffect(function() {\n if (!enabled) return;\n if (!open) return;\n if (!elements.floating) return;\n if (activeIndex == null) {\n forceSyncFocusRef.current = false;\n if (selectedIndexRef.current != null) {\n return;\n }\n if (previousMountedRef.current) {\n indexRef.current = -1;\n focusItem();\n }\n if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {\n var runs = 0;\n var waitForListPopulated = function() {\n if (listRef.current[0] == null) {\n if (runs < 2) {\n var scheduler = runs ? requestAnimationFrame : queueMicrotask;\n scheduler(waitForListPopulated);\n }\n runs++;\n } else {\n indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? getMinListIndex(listRef, disabledIndicesRef.current) : getMaxListIndex(listRef, disabledIndicesRef.current);\n keyRef.current = null;\n onNavigate();\n }\n };\n waitForListPopulated();\n }\n } else if (!isIndexOutOfListBounds(listRef, activeIndex)) {\n indexRef.current = activeIndex;\n focusItem();\n forceScrollIntoViewRef.current = false;\n }\n }, [\n enabled,\n open,\n elements.floating,\n activeIndex,\n selectedIndexRef,\n nested,\n listRef,\n orientation,\n rtl,\n onNavigate,\n focusItem,\n disabledIndicesRef\n ]);\n useLayoutEffect(function() {\n previousOnNavigateRef.current = onNavigate;\n previousOpenRef.current = open;\n previousMountedRef.current = !!elements.floating;\n });\n useLayoutEffect(function() {\n if (!open) {\n keyRef.current = null;\n focusItemOnOpenRef.current = focusItemOnOpen;\n }\n }, [\n open,\n focusItemOnOpen\n ]);\n var hasActiveIndex = activeIndex != null;\n var commonOnKeyDown = useEvent(function(event) {\n isPointerModalityRef.current = false;\n forceSyncFocusRef.current = true;\n if (event.which === 229) {\n return;\n }\n if (!latestOpenRef.current && event.currentTarget === elements.floating) {\n return;\n }\n if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl)) {\n stopEvent(event);\n onOpenChange(false, event.nativeEvent, \"list-navigation\");\n if (isHTMLElement(elements.domReference)) {\n elements.domReference.focus();\n }\n return;\n }\n var currentIndex = indexRef.current;\n var minIndex = getMinListIndex(listRef, disabledIndices);\n var maxIndex = getMaxListIndex(listRef, disabledIndices);\n if (!typeableComboboxReference) {\n if (event.key === \"Home\") {\n stopEvent(event);\n indexRef.current = minIndex;\n onNavigate();\n }\n if (event.key === \"End\") {\n stopEvent(event);\n indexRef.current = maxIndex;\n onNavigate();\n }\n }\n if (isMainOrientationKey(event.key, orientation)) {\n stopEvent(event);\n if (open && !virtual && activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {\n indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;\n onNavigate();\n return;\n }\n if (isMainOrientationToEndKey(event.key, orientation, rtl)) {\n if (loop) {\n indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n });\n } else {\n indexRef.current = Math.min(maxIndex, findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n }));\n }\n } else {\n if (loop) {\n indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n });\n } else {\n indexRef.current = Math.max(minIndex, findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n }));\n }\n }\n if (isIndexOutOfListBounds(listRef, indexRef.current)) {\n indexRef.current = -1;\n }\n onNavigate();\n }\n });\n var ariaActiveDescendantProp = useMemo(function() {\n return virtual && open && hasActiveIndex && {\n \"aria-activedescendant\": activeId\n };\n }, [\n virtual,\n open,\n hasActiveIndex,\n activeId\n ]);\n var floating = useMemo(function() {\n return {\n \"aria-orientation\": orientation === \"both\" ? void 0 : orientation,\n ...!typeableComboboxReference ? ariaActiveDescendantProp : {},\n onKeyDown: commonOnKeyDown,\n onPointerMove() {\n isPointerModalityRef.current = true;\n }\n };\n }, [\n ariaActiveDescendantProp,\n commonOnKeyDown,\n orientation,\n typeableComboboxReference\n ]);\n var reference = useMemo(function() {\n function checkVirtualMouse(event) {\n if (focusItemOnOpen === \"auto\" && isVirtualClick(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n function checkVirtualPointer(event) {\n focusItemOnOpenRef.current = focusItemOnOpen;\n if (focusItemOnOpen === \"auto\" && isVirtualPointerEvent(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n return {\n ...ariaActiveDescendantProp,\n onKeyDown(event) {\n isPointerModalityRef.current = false;\n var isArrowKey = event.key.startsWith(\"Arrow\");\n var isCrossOpenKey = isCrossOrientationOpenKey(event.key, orientation, rtl);\n var isMainKey = isMainOrientationKey(event.key, orientation);\n var isNavigationKey = (nested ? isCrossOpenKey : isMainKey) || event.key === \"Enter\" || event.key.trim() === \"\";\n if (virtual && open) {\n return commonOnKeyDown(event);\n }\n if (!open && !openOnArrowKeyDown && isArrowKey) {\n return;\n }\n if (isNavigationKey) {\n keyRef.current = event.key;\n }\n if (nested) {\n if (isCrossOpenKey) {\n stopEvent(event);\n if (open) {\n indexRef.current = getMinListIndex(listRef, disabledIndicesRef.current);\n onNavigate();\n } else {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n }\n }\n return;\n }\n if (isMainKey) {\n if (selectedIndex != null) {\n indexRef.current = selectedIndex;\n }\n stopEvent(event);\n if (!open && openOnArrowKeyDown) {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n } else {\n commonOnKeyDown(event);\n }\n if (open) {\n onNavigate();\n }\n }\n },\n onFocus() {\n if (open && !virtual) {\n indexRef.current = -1;\n onNavigate();\n }\n },\n onPointerDown: checkVirtualPointer,\n onPointerEnter: checkVirtualPointer,\n onMouseDown: checkVirtualMouse,\n onClick: checkVirtualMouse\n };\n }, [\n ariaActiveDescendantProp,\n commonOnKeyDown,\n disabledIndicesRef,\n focusItemOnOpen,\n listRef,\n nested,\n onNavigate,\n onOpenChange,\n open,\n openOnArrowKeyDown,\n orientation,\n rtl,\n selectedIndex,\n virtual\n ]);\n var floatingRef = useRef(elements.floating);\n floatingRef.current = elements.floating;\n var item = useMemo(function() {\n function syncCurrentTarget(currentTarget) {\n if (!latestOpenRef.current) return;\n var index = listRef.current.indexOf(currentTarget);\n if (index !== -1 && indexRef.current !== index) {\n indexRef.current = index;\n onNavigate();\n }\n }\n var itemProps = {\n onFocus(param) {\n var { currentTarget } = param;\n forceSyncFocusRef.current = true;\n syncCurrentTarget(currentTarget);\n },\n onClick: function(param) {\n var { currentTarget } = param;\n return currentTarget.focus({\n preventScroll: true\n });\n },\n // safari\n onMouseMove(param) {\n var { currentTarget } = param;\n forceSyncFocusRef.current = true;\n forceScrollIntoViewRef.current = false;\n if (focusItemOnHover) {\n syncCurrentTarget(currentTarget);\n }\n },\n onPointerLeave(param) {\n var { pointerType } = param;\n if (!isPointerModalityRef.current || pointerType === \"touch\") {\n return;\n }\n forceSyncFocusRef.current = true;\n if (!focusItemOnHover) {\n return;\n }\n indexRef.current = -1;\n onNavigate();\n if (!virtual) {\n var _floatingRef_current;\n (_floatingRef_current = floatingRef.current) === null || _floatingRef_current === void 0 ? void 0 : _floatingRef_current.focus({\n preventScroll: true\n });\n }\n }\n };\n return itemProps;\n }, [\n latestOpenRef,\n focusItemOnHover,\n listRef,\n onNavigate,\n virtual\n ]);\n return useMemo(function() {\n return enabled ? {\n reference,\n floating,\n item\n } : {};\n }, [\n enabled,\n reference,\n floating,\n item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GACF;EACF;EACA,OAAO;CACT,GAAG;EACD;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OAAO,QAAQ,WAAW;EACxB,OAAO,UAAU;GACf;GACA;GACA;EACF,IAAI,CAAC;CACP,GAAG;EACD;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"useListNavigation.native.js","names":[],"sources":["esm/interactions/useListNavigation.native.js"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { useEvent } from \"@tamagui/use-event\";\nimport { activeElement, enqueueFocus, findNonDisabledListIndex, getMinListIndex, getMaxListIndex, isHTMLElement, isIndexOutOfListBounds, isTypeableCombobox, isVirtualClick, isVirtualPointerEvent, stopEvent } from \"./utils\";\nvar ARROW_UP = \"ArrowUp\";\nvar ARROW_DOWN = \"ArrowDown\";\nvar ARROW_LEFT = \"ArrowLeft\";\nvar ARROW_RIGHT = \"ArrowRight\";\nfunction doSwitch(orientation, vertical, horizontal) {\n switch (orientation) {\n case \"vertical\":\n return vertical;\n case \"horizontal\":\n return horizontal;\n default:\n return vertical || horizontal;\n }\n}\nfunction isMainOrientationKey(key, orientation) {\n var vertical = key === ARROW_UP || key === ARROW_DOWN;\n var horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isMainOrientationToEndKey(key, orientation, rtl) {\n var vertical = key === ARROW_DOWN;\n var horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal) || key === \"Enter\" || key === \" \" || key === \"\";\n}\nfunction isCrossOrientationOpenKey(key, orientation, rtl) {\n var vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n var horizontal = key === ARROW_DOWN;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isCrossOrientationCloseKey(key, orientation, rtl) {\n var vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;\n var horizontal = key === ARROW_UP;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction useListNavigation(context, props) {\n var { open, onOpenChange, elements } = context;\n var { listRef, activeIndex, onNavigate: unstable_onNavigate = function() {\n }, enabled = true, selectedIndex = null, allowEscape = false, loop = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = \"auto\", focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices = void 0, orientation = \"vertical\", scrollItemIntoView = true } = props;\n var typeableComboboxReference = isTypeableCombobox(elements.domReference);\n var focusItemOnOpenRef = useRef(focusItemOnOpen);\n var indexRef = useRef(selectedIndex !== null && selectedIndex !== void 0 ? selectedIndex : -1);\n var keyRef = useRef(null);\n var isPointerModalityRef = useRef(true);\n var previousMountedRef = useRef(!!elements.floating);\n var previousOpenRef = useRef(open);\n var forceSyncFocusRef = useRef(false);\n var forceScrollIntoViewRef = useRef(false);\n var disabledIndicesRef = useRef(disabledIndices);\n disabledIndicesRef.current = disabledIndices;\n var latestOpenRef = useRef(open);\n latestOpenRef.current = open;\n var scrollItemIntoViewRef = useRef(scrollItemIntoView);\n scrollItemIntoViewRef.current = scrollItemIntoView;\n var selectedIndexRef = useRef(selectedIndex);\n selectedIndexRef.current = selectedIndex;\n var stableOnNavigate = useEvent(unstable_onNavigate);\n var [activeId, setActiveId] = useState();\n var onNavigate = useEvent(function() {\n stableOnNavigate(indexRef.current === -1 ? null : indexRef.current);\n });\n var previousOnNavigateRef = useRef(onNavigate);\n var focusItem = useEvent(function() {\n function runFocus(item2) {\n if (virtual) {\n setActiveId(item2.id);\n } else {\n enqueueFocus(item2, {\n sync: forceSyncFocusRef.current,\n preventScroll: true\n });\n }\n }\n var initialItem = listRef.current[indexRef.current];\n var forceScrollIntoView = forceScrollIntoViewRef.current;\n if (initialItem) {\n runFocus(initialItem);\n }\n var scheduler = forceSyncFocusRef.current ? function(v) {\n return v();\n } : requestAnimationFrame;\n scheduler(function() {\n var waitedItem = listRef.current[indexRef.current] || initialItem;\n if (!waitedItem) return;\n if (!initialItem) {\n runFocus(waitedItem);\n }\n var scrollIntoViewOptions = scrollItemIntoViewRef.current;\n var shouldScrollIntoView = scrollIntoViewOptions && waitedItem && (forceScrollIntoView || !isPointerModalityRef.current);\n if (shouldScrollIntoView) {\n var _waitedItem_scrollIntoView;\n (_waitedItem_scrollIntoView = waitedItem.scrollIntoView) === null || _waitedItem_scrollIntoView === void 0 ? void 0 : _waitedItem_scrollIntoView.call(waitedItem, typeof scrollIntoViewOptions === \"boolean\" ? {\n block: \"nearest\",\n inline: \"nearest\"\n } : scrollIntoViewOptions);\n }\n });\n });\n useLayoutEffect(function() {\n if (!enabled) return;\n if (open && elements.floating) {\n if (focusItemOnOpenRef.current && selectedIndex != null) {\n forceScrollIntoViewRef.current = true;\n indexRef.current = selectedIndex;\n onNavigate();\n }\n } else if (previousMountedRef.current) {\n indexRef.current = -1;\n previousOnNavigateRef.current();\n }\n }, [\n enabled,\n open,\n elements.floating,\n selectedIndex,\n onNavigate\n ]);\n useLayoutEffect(function() {\n if (!enabled) return;\n if (!open) return;\n if (!elements.floating) return;\n if (activeIndex == null) {\n forceSyncFocusRef.current = false;\n if (selectedIndexRef.current != null) {\n return;\n }\n if (previousMountedRef.current) {\n indexRef.current = -1;\n focusItem();\n }\n if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {\n var runs = 0;\n var waitForListPopulated = function waitForListPopulated1() {\n if (listRef.current[0] == null) {\n if (runs < 2) {\n var scheduler = runs ? requestAnimationFrame : queueMicrotask;\n scheduler(waitForListPopulated);\n }\n runs++;\n } else {\n indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? getMinListIndex(listRef, disabledIndicesRef.current) : getMaxListIndex(listRef, disabledIndicesRef.current);\n keyRef.current = null;\n onNavigate();\n }\n };\n waitForListPopulated();\n }\n } else if (!isIndexOutOfListBounds(listRef, activeIndex)) {\n indexRef.current = activeIndex;\n focusItem();\n forceScrollIntoViewRef.current = false;\n }\n }, [\n enabled,\n open,\n elements.floating,\n activeIndex,\n selectedIndexRef,\n nested,\n listRef,\n orientation,\n rtl,\n onNavigate,\n focusItem,\n disabledIndicesRef\n ]);\n useLayoutEffect(function() {\n previousOnNavigateRef.current = onNavigate;\n previousOpenRef.current = open;\n previousMountedRef.current = !!elements.floating;\n });\n useLayoutEffect(function() {\n if (!open) {\n keyRef.current = null;\n focusItemOnOpenRef.current = focusItemOnOpen;\n }\n }, [\n open,\n focusItemOnOpen\n ]);\n var hasActiveIndex = activeIndex != null;\n var commonOnKeyDown = useEvent(function(event) {\n isPointerModalityRef.current = false;\n forceSyncFocusRef.current = true;\n if (event.which === 229) {\n return;\n }\n if (!latestOpenRef.current && event.currentTarget === elements.floating) {\n return;\n }\n if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl)) {\n stopEvent(event);\n onOpenChange(false, event.nativeEvent, \"list-navigation\");\n if (isHTMLElement(elements.domReference)) {\n elements.domReference.focus();\n }\n return;\n }\n var currentIndex = indexRef.current;\n var minIndex = getMinListIndex(listRef, disabledIndices);\n var maxIndex = getMaxListIndex(listRef, disabledIndices);\n if (!typeableComboboxReference) {\n if (event.key === \"Home\") {\n stopEvent(event);\n indexRef.current = minIndex;\n onNavigate();\n }\n if (event.key === \"End\") {\n stopEvent(event);\n indexRef.current = maxIndex;\n onNavigate();\n }\n }\n if (isMainOrientationKey(event.key, orientation)) {\n stopEvent(event);\n if (open && !virtual && activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {\n indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;\n onNavigate();\n return;\n }\n if (isMainOrientationToEndKey(event.key, orientation, rtl)) {\n if (loop) {\n indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n });\n } else {\n indexRef.current = Math.min(maxIndex, findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n }));\n }\n } else {\n if (loop) {\n indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n });\n } else {\n indexRef.current = Math.max(minIndex, findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n }));\n }\n }\n if (isIndexOutOfListBounds(listRef, indexRef.current)) {\n indexRef.current = -1;\n }\n onNavigate();\n }\n });\n var ariaActiveDescendantProp = useMemo(function() {\n return virtual && open && hasActiveIndex && {\n \"aria-activedescendant\": activeId\n };\n }, [\n virtual,\n open,\n hasActiveIndex,\n activeId\n ]);\n var floating = useMemo(function() {\n return {\n \"aria-orientation\": orientation === \"both\" ? void 0 : orientation,\n ...!typeableComboboxReference ? ariaActiveDescendantProp : {},\n onKeyDown: commonOnKeyDown,\n onPointerMove() {\n isPointerModalityRef.current = true;\n }\n };\n }, [\n ariaActiveDescendantProp,\n commonOnKeyDown,\n orientation,\n typeableComboboxReference\n ]);\n var reference = useMemo(function() {\n function checkVirtualMouse(event) {\n if (focusItemOnOpen === \"auto\" && isVirtualClick(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n function checkVirtualPointer(event) {\n focusItemOnOpenRef.current = focusItemOnOpen;\n if (focusItemOnOpen === \"auto\" && isVirtualPointerEvent(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n return {\n ...ariaActiveDescendantProp,\n onKeyDown(event) {\n isPointerModalityRef.current = false;\n var isArrowKey = event.key.startsWith(\"Arrow\");\n var isCrossOpenKey = isCrossOrientationOpenKey(event.key, orientation, rtl);\n var isMainKey = isMainOrientationKey(event.key, orientation);\n var isNavigationKey = (nested ? isCrossOpenKey : isMainKey) || event.key === \"Enter\" || event.key.trim() === \"\";\n if (virtual && open) {\n return commonOnKeyDown(event);\n }\n if (!open && !openOnArrowKeyDown && isArrowKey) {\n return;\n }\n if (isNavigationKey) {\n keyRef.current = event.key;\n }\n if (nested) {\n if (isCrossOpenKey) {\n stopEvent(event);\n if (open) {\n indexRef.current = getMinListIndex(listRef, disabledIndicesRef.current);\n onNavigate();\n } else {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n }\n }\n return;\n }\n if (isMainKey) {\n if (selectedIndex != null) {\n indexRef.current = selectedIndex;\n }\n stopEvent(event);\n if (!open && openOnArrowKeyDown) {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n } else {\n commonOnKeyDown(event);\n }\n if (open) {\n onNavigate();\n }\n }\n },\n onFocus() {\n if (open && !virtual) {\n indexRef.current = -1;\n onNavigate();\n }\n },\n onPointerDown: checkVirtualPointer,\n onPointerEnter: checkVirtualPointer,\n onMouseDown: checkVirtualMouse,\n onClick: checkVirtualMouse\n };\n }, [\n ariaActiveDescendantProp,\n commonOnKeyDown,\n disabledIndicesRef,\n focusItemOnOpen,\n listRef,\n nested,\n onNavigate,\n onOpenChange,\n open,\n openOnArrowKeyDown,\n orientation,\n rtl,\n selectedIndex,\n virtual\n ]);\n var floatingRef = useRef(elements.floating);\n floatingRef.current = elements.floating;\n var item = useMemo(function() {\n function syncCurrentTarget(currentTarget) {\n if (!latestOpenRef.current) return;\n var index = listRef.current.indexOf(currentTarget);\n if (index !== -1 && indexRef.current !== index) {\n indexRef.current = index;\n onNavigate();\n }\n }\n var itemProps = {\n onFocus(param) {\n var { currentTarget } = param;\n forceSyncFocusRef.current = true;\n syncCurrentTarget(currentTarget);\n },\n onClick: function onClick(param) {\n var { currentTarget } = param;\n return currentTarget.focus({\n preventScroll: true\n });\n },\n // safari\n onMouseMove(param) {\n var { currentTarget } = param;\n forceSyncFocusRef.current = true;\n forceScrollIntoViewRef.current = false;\n if (focusItemOnHover) {\n syncCurrentTarget(currentTarget);\n }\n },\n onPointerLeave(param) {\n var { pointerType } = param;\n if (!isPointerModalityRef.current || pointerType === \"touch\") {\n return;\n }\n forceSyncFocusRef.current = true;\n if (!focusItemOnHover) {\n return;\n }\n indexRef.current = -1;\n onNavigate();\n if (!virtual) {\n var _floatingRef_current;\n (_floatingRef_current = floatingRef.current) === null || _floatingRef_current === void 0 ? void 0 : _floatingRef_current.focus({\n preventScroll: true\n });\n }\n }\n };\n return itemProps;\n }, [\n latestOpenRef,\n focusItemOnHover,\n listRef,\n onNavigate,\n virtual\n ]);\n return useMemo(function() {\n return enabled ? {\n reference,\n floating,\n item\n } : {};\n }, [\n enabled,\n reference,\n floating,\n item\n ]);\n}\nexport {\n useListNavigation\n};\n//# sourceMappingURL=useListNavigation.js.map\n"],"mappings":";;;;;AAGA,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,cAAc;AAClB,SAAS,SAAS,aAAa,UAAU,YAAY;CACnD,QAAQ,aAAR;EACE,KAAK,YACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,SACE,OAAO,YAAY;CACvB;AACF;AACA,SAAS,qBAAqB,KAAK,aAAa;CAC9C,IAAI,WAAW,QAAQ,YAAY,QAAQ;CAC3C,IAAI,aAAa,QAAQ,cAAc,QAAQ;CAC/C,OAAO,SAAS,aAAa,UAAU,UAAU;AACnD;AACA,SAAS,0BAA0B,KAAK,aAAa,KAAK;CACxD,IAAI,WAAW,QAAQ;CACvB,IAAI,aAAa,MAAM,QAAQ,aAAa,QAAQ;CACpD,OAAO,SAAS,aAAa,UAAU,UAAU,KAAK,QAAQ,WAAW,QAAQ,OAAO,QAAQ;AAClG;AACA,SAAS,0BAA0B,KAAK,aAAa,KAAK;CACxD,IAAI,WAAW,MAAM,QAAQ,aAAa,QAAQ;CAClD,IAAI,aAAa,QAAQ;CACzB,OAAO,SAAS,aAAa,UAAU,UAAU;AACnD;AACA,SAAS,2BAA2B,KAAK,aAAa,KAAK;CACzD,IAAI,WAAW,MAAM,QAAQ,cAAc,QAAQ;CACnD,IAAI,aAAa,QAAQ;CACzB,OAAO,SAAS,aAA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C;GACF;GACA,eAAe,OAAO;IACpB,IAAI,EAAE,gBAAgB;IACtB,IAAI,CAAC,qBAAqB,WAAW,gBAAgB,SAAS;KAC5D;IACF;IACA,kBAAkB,UAAU;IAC5B,IAAI,CAAC,kBAAkB;KACrB;IACF;IACA,SAAS,UAAU,CAAC;IACpB,WAAW;IACX,IAAI,CAAC,SAAS;KACZ,IAAI;KACJ,CAAC,uBAAuB,YAAY,aAAa,QAAQ,yBAAyB,KAAK,IAAI,KAAK,IAAI,qBAAqB,MAAM,EAC7H,eAAe,KACjB,CAAC;IACH;GACF;EACF;EACA,OAAO;CACT,GAAG;EACD;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OAAO,QAAQ,WAAW;EACxB,OAAO,UAAU;GACf;GACA;GACA;EACF,IAAI,CAAC;CACP,GAAG;EACD;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -8,6 +8,7 @@ var componentRoleToAriaRoleMap = /* @__PURE__ */ new Map([
|
|
|
8
8
|
var idCounter = 0;
|
|
9
9
|
function useRole(context) {
|
|
10
10
|
var props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
11
|
+
var _componentRoleToAriaRoleMap_get;
|
|
11
12
|
var _elements_domReference;
|
|
12
13
|
var { open, elements } = context;
|
|
13
14
|
var { enabled = true, role = "dialog" } = props;
|
|
@@ -20,7 +21,6 @@ function useRole(context) {
|
|
|
20
21
|
var _elements_floating;
|
|
21
22
|
return ((_elements_floating = elements.floating) === null || _elements_floating === void 0 ? void 0 : _elements_floating.id) || defaultFloatingId;
|
|
22
23
|
}, [elements.floating, defaultFloatingId]);
|
|
23
|
-
var _componentRoleToAriaRoleMap_get;
|
|
24
24
|
var ariaRole = (_componentRoleToAriaRoleMap_get = componentRoleToAriaRoleMap.get(role)) !== null && _componentRoleToAriaRoleMap_get !== void 0 ? _componentRoleToAriaRoleMap_get : role;
|
|
25
25
|
var reference = React.useMemo(function() {
|
|
26
26
|
if (ariaRole === "tooltip" || role === "label") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRole.native.js","names":[],"sources":["esm/interactions/useRole.native.js"],"sourcesContent":["import * as React from \"react\";\nvar componentRoleToAriaRoleMap = /* @__PURE__ */ new Map([\n [\n \"select\",\n \"listbox\"\n ],\n [\n \"combobox\",\n \"listbox\"\n ],\n [\n \"label\",\n false\n ]\n]);\nvar idCounter = 0;\nfunction useRole(context) {\n var props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n var _elements_domReference;\n var { open, elements } = context;\n var { enabled = true, role = \"dialog\" } = props;\n var defaultReferenceId = React.useId();\n var referenceId = ((_elements_domReference = elements.domReference) === null || _elements_domReference === void 0 ? void 0 : _elements_domReference.id) || defaultReferenceId;\n var defaultFloatingId = React.useMemo(function() {\n return `floating-${idCounter++}`;\n }, []);\n var floatingId = React.useMemo(function() {\n var _elements_floating;\n return ((_elements_floating = elements.floating) === null || _elements_floating === void 0 ? void 0 : _elements_floating.id) || defaultFloatingId;\n }, [\n elements.floating,\n defaultFloatingId\n ]);\n var
|
|
1
|
+
{"version":3,"file":"useRole.native.js","names":[],"sources":["esm/interactions/useRole.native.js"],"sourcesContent":["import * as React from \"react\";\nvar componentRoleToAriaRoleMap = /* @__PURE__ */ new Map([\n [\n \"select\",\n \"listbox\"\n ],\n [\n \"combobox\",\n \"listbox\"\n ],\n [\n \"label\",\n false\n ]\n]);\nvar idCounter = 0;\nfunction useRole(context) {\n var props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n var _componentRoleToAriaRoleMap_get;\n var _elements_domReference;\n var { open, elements } = context;\n var { enabled = true, role = \"dialog\" } = props;\n var defaultReferenceId = React.useId();\n var referenceId = ((_elements_domReference = elements.domReference) === null || _elements_domReference === void 0 ? void 0 : _elements_domReference.id) || defaultReferenceId;\n var defaultFloatingId = React.useMemo(function() {\n return `floating-${idCounter++}`;\n }, []);\n var floatingId = React.useMemo(function() {\n var _elements_floating;\n return ((_elements_floating = elements.floating) === null || _elements_floating === void 0 ? void 0 : _elements_floating.id) || defaultFloatingId;\n }, [\n elements.floating,\n defaultFloatingId\n ]);\n var ariaRole = (_componentRoleToAriaRoleMap_get = componentRoleToAriaRoleMap.get(role)) !== null && _componentRoleToAriaRoleMap_get !== void 0 ? _componentRoleToAriaRoleMap_get : role;\n var reference = React.useMemo(function() {\n if (ariaRole === \"tooltip\" || role === \"label\") {\n return {\n [`aria-${role === \"label\" ? \"labelledby\" : \"describedby\"}`]: open ? floatingId : void 0\n };\n }\n return {\n \"aria-expanded\": open ? \"true\" : \"false\",\n \"aria-haspopup\": ariaRole === \"alertdialog\" ? \"dialog\" : ariaRole,\n \"aria-controls\": open ? floatingId : void 0,\n ...ariaRole === \"listbox\" && {\n role: \"combobox\"\n },\n ...ariaRole === \"menu\" && {\n id: referenceId\n },\n ...role === \"select\" && {\n \"aria-autocomplete\": \"none\"\n },\n ...role === \"combobox\" && {\n \"aria-autocomplete\": \"list\"\n }\n };\n }, [\n ariaRole,\n floatingId,\n open,\n referenceId,\n role\n ]);\n var floating = React.useMemo(function() {\n var floatingProps = {\n id: floatingId,\n ...ariaRole && {\n role: ariaRole\n }\n };\n if (ariaRole === \"tooltip\" || role === \"label\") {\n return floatingProps;\n }\n return {\n ...floatingProps,\n ...ariaRole === \"menu\" && {\n \"aria-labelledby\": referenceId\n }\n };\n }, [\n ariaRole,\n floatingId,\n referenceId,\n role\n ]);\n var item = React.useCallback(function(param) {\n var { active, selected } = param;\n var commonProps = {\n role: \"option\",\n ...active && {\n id: `${floatingId}-fui-option`\n }\n };\n switch (role) {\n case \"select\":\n case \"combobox\":\n return {\n ...commonProps,\n \"aria-selected\": selected\n };\n }\n return {};\n }, [\n floatingId,\n role\n ]);\n return React.useMemo(function() {\n return enabled ? {\n reference,\n floating,\n item\n } : {};\n }, [\n enabled,\n reference,\n floating,\n item\n ]);\n}\nexport {\n useRole\n};\n//# sourceMappingURL=useRole.js.map\n"],"mappings":";;;AACA,IAAI,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ACD;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,IAAI,WAAW,MAAM,QAAQ,WAAW;EACtC,IAAI,gBAAgB;GAClB,IAAI;GACJ,GAAG,YAAY,EACb,MAAM,SACR;EACF;EACA,IAAI,aAAa,aAAa,SAAS,SAAS;GAC9C,OAAO;EACT;EACA,OAAO;GACL,GAAG;GACH,GAAG,aAAa,UAAU,EACxB,mBAAmB,YACrB;EACF;CACF,GAAG;EACD;EACA;EACA;EACA;CACF,CAAC;CACD,IAAI,OAAO,MAAM,YAAY,SAAS,OAAO;EAC3C,IAAI,EAAE,QAAQ,aAAa;EAC3B,IAAI,cAAc;GAChB,MAAM;GACN,GAAG,UAAU,EACX,IAAI,GAAG,WAAW,aACpB;EACF;EACA,QAAQ,MAAR;GACE,KAAK;GACL,KAAK,YACH,OAAO;IACL,GAAG;IACH,iBAAiB;GACnB;EACJ;EACA,OAAO,CAAC;CACV,GAAG,CACD,YACA,IACF,CAAC;CACD,OAAO,MAAM,QAAQ,WAAW;EAC9B,OAAO,UAAU;GACf;GACA;GACA;EACF,IAAI,CAAC;CACP,GAAG;EACD;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -3,11 +3,11 @@ import { useEvent } from "@tamagui/use-event";
|
|
|
3
3
|
import { clearTimeoutIfSet, stopEvent } from "./utils.native.js";
|
|
4
4
|
|
|
5
5
|
function useTypeahead(context, props) {
|
|
6
|
+
var _ref;
|
|
6
7
|
var { open, dataRef } = context;
|
|
7
8
|
var { listRef, activeIndex, onMatch: unstable_onMatch, onTypingChange: unstable_onTypingChange, enabled = true, findMatch = null, resetMs = 750, ignoreKeys = [], selectedIndex = null } = props;
|
|
8
9
|
var timeoutIdRef = useRef(-1);
|
|
9
10
|
var stringRef = useRef("");
|
|
10
|
-
var _ref;
|
|
11
11
|
var prevIndexRef = useRef((_ref = selectedIndex !== null && selectedIndex !== void 0 ? selectedIndex : activeIndex) !== null && _ref !== void 0 ? _ref : -1);
|
|
12
12
|
var matchIndexRef = useRef(null);
|
|
13
13
|
var onMatch = useEvent(unstable_onMatch || function() {});
|
|
@@ -33,7 +33,7 @@ function useTypeahead(context, props) {
|
|
|
33
33
|
selectedIndex,
|
|
34
34
|
activeIndex
|
|
35
35
|
]);
|
|
36
|
-
var setTypingChange = function(value) {
|
|
36
|
+
var setTypingChange = function setTypingChange2(value) {
|
|
37
37
|
if (value) {
|
|
38
38
|
if (!dataRef.current.typing) {
|
|
39
39
|
dataRef.current.typing = value;
|
|
@@ -46,7 +46,7 @@ function useTypeahead(context, props) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
var onKeyDown = function(event) {
|
|
49
|
+
var onKeyDown = function onKeyDown2(event) {
|
|
50
50
|
function getMatchingIndex(list, orderedList, string) {
|
|
51
51
|
var str = findMatchRef.current ? findMatchRef.current(orderedList, string) : orderedList.find(function(text) {
|
|
52
52
|
return (text === null || text === void 0 ? void 0 : text.toLocaleLowerCase().indexOf(string.toLocaleLowerCase())) === 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTypeahead.native.js","names":[],"sources":["esm/interactions/useTypeahead.native.js"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef } from \"react\";\nimport { useEvent } from \"@tamagui/use-event\";\nimport { clearTimeoutIfSet, stopEvent } from \"./utils\";\nfunction useTypeahead(context, props) {\n var { open, dataRef } = context;\n var { listRef, activeIndex, onMatch: unstable_onMatch, onTypingChange: unstable_onTypingChange, enabled = true, findMatch = null, resetMs = 750, ignoreKeys = [], selectedIndex = null } = props;\n var timeoutIdRef = useRef(-1);\n var stringRef = useRef(\"\");\n var
|
|
1
|
+
{"version":3,"file":"useTypeahead.native.js","names":[],"sources":["esm/interactions/useTypeahead.native.js"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef } from \"react\";\nimport { useEvent } from \"@tamagui/use-event\";\nimport { clearTimeoutIfSet, stopEvent } from \"./utils\";\nfunction useTypeahead(context, props) {\n var _ref;\n var { open, dataRef } = context;\n var { listRef, activeIndex, onMatch: unstable_onMatch, onTypingChange: unstable_onTypingChange, enabled = true, findMatch = null, resetMs = 750, ignoreKeys = [], selectedIndex = null } = props;\n var timeoutIdRef = useRef(-1);\n var stringRef = useRef(\"\");\n var prevIndexRef = useRef((_ref = selectedIndex !== null && selectedIndex !== void 0 ? selectedIndex : activeIndex) !== null && _ref !== void 0 ? _ref : -1);\n var matchIndexRef = useRef(null);\n var onMatch = useEvent(unstable_onMatch || function() {\n });\n var onTypingChange = useEvent(unstable_onTypingChange || function() {\n });\n var findMatchRef = useRef(findMatch);\n findMatchRef.current = findMatch;\n var ignoreKeysRef = useRef(ignoreKeys);\n ignoreKeysRef.current = ignoreKeys;\n useLayoutEffect(function() {\n if (open) {\n clearTimeoutIfSet(timeoutIdRef);\n matchIndexRef.current = null;\n stringRef.current = \"\";\n }\n }, [\n open\n ]);\n useLayoutEffect(function() {\n if (open && stringRef.current === \"\") {\n var _ref2;\n prevIndexRef.current = (_ref2 = selectedIndex !== null && selectedIndex !== void 0 ? selectedIndex : activeIndex) !== null && _ref2 !== void 0 ? _ref2 : -1;\n }\n }, [\n open,\n selectedIndex,\n activeIndex\n ]);\n var setTypingChange = function setTypingChange2(value) {\n if (value) {\n if (!dataRef.current.typing) {\n dataRef.current.typing = value;\n onTypingChange(value);\n }\n } else {\n if (dataRef.current.typing) {\n dataRef.current.typing = value;\n onTypingChange(value);\n }\n }\n };\n var onKeyDown = function onKeyDown2(event) {\n function getMatchingIndex(list, orderedList, string) {\n var str = findMatchRef.current ? findMatchRef.current(orderedList, string) : orderedList.find(function(text) {\n return (text === null || text === void 0 ? void 0 : text.toLocaleLowerCase().indexOf(string.toLocaleLowerCase())) === 0;\n });\n return str ? list.indexOf(str) : -1;\n }\n var listContent = listRef.current;\n if (stringRef.current.length > 0 && stringRef.current[0] !== \" \") {\n if (getMatchingIndex(listContent, listContent, stringRef.current) === -1) {\n setTypingChange(false);\n } else if (event.key === \" \") {\n stopEvent(event);\n }\n }\n if (listContent == null || ignoreKeysRef.current.includes(event.key) || // character key\n event.key.length !== 1 || // modifier key\n event.ctrlKey || event.metaKey || event.altKey) {\n return;\n }\n if (open && event.key !== \" \") {\n stopEvent(event);\n setTypingChange(true);\n }\n var allowRapidSuccessionOfFirstLetter = listContent.every(function(text) {\n var _text_, _text_1;\n return text ? ((_text_ = text[0]) === null || _text_ === void 0 ? void 0 : _text_.toLocaleLowerCase()) !== ((_text_1 = text[1]) === null || _text_1 === void 0 ? void 0 : _text_1.toLocaleLowerCase()) : true;\n });\n if (allowRapidSuccessionOfFirstLetter && stringRef.current === event.key) {\n stringRef.current = \"\";\n prevIndexRef.current = matchIndexRef.current;\n }\n stringRef.current += event.key;\n clearTimeoutIfSet(timeoutIdRef);\n timeoutIdRef.current = window.setTimeout(function() {\n stringRef.current = \"\";\n prevIndexRef.current = matchIndexRef.current;\n setTypingChange(false);\n }, resetMs);\n var prevIndex = prevIndexRef.current;\n var index = getMatchingIndex(listContent, [\n ...listContent.slice((prevIndex || 0) + 1),\n ...listContent.slice(0, (prevIndex || 0) + 1)\n ], stringRef.current);\n if (index !== -1) {\n onMatch(index);\n matchIndexRef.current = index;\n } else if (event.key !== \" \") {\n stringRef.current = \"\";\n setTypingChange(false);\n }\n };\n var reference = useMemo(function() {\n return {\n onKeyDown\n };\n }, [\n open,\n enabled\n ]);\n var floating = useMemo(function() {\n return {\n onKeyDown,\n onKeyUp(event) {\n if (event.key === \" \") {\n setTypingChange(false);\n }\n }\n };\n }, [\n open,\n enabled\n ]);\n return useMemo(function() {\n return enabled ? {\n reference,\n floating\n } : {};\n }, [\n enabled,\n reference,\n floating\n ]);\n}\nexport {\n useTypeahead\n};\n//# sourceMappingURL=useTypeahead.js.map\n"],"mappings":";;;;;AAGA,SAAS,aAAa,SAAS,OAAO;CACpC,IAAI;CACJ,IAAI,EAAE,MAAM,YAAY;CACxB,IAAI,EAAE,SAAS,aAAa,SAAS,kBAAkB,gBAAgB,yBAAyB,U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a,CACxC,GAAG,YAAY,OAAO,aAAa,KAAK,CAAC,GACzC,GAAG,YAAY,MAAM,IAAI,aAAa,KAAK,CAAC,CAC9C,GAAG,UAAU,OAAO;EACpB,IAAI,UAAU,CAAC,GAAG;GAChB,QAAQ,KAAK;GACb,cAAc,UAAU;EAC1B,OAAO,IAAI,MAAM,QAAQ,KAAK;GAC5B,UAAU,UAAU;GACpB,gBAAgB,KAAK;EACvB;CACF;CACA,IAAI,YAAY,QAAQ,WAAW;EACjC,OAAO,EACL,UACF;CACF,GAAG,CACD,MACA,OACF,CAAC;CACD,IAAI,WAAW,QAAQ,WAAW;EAChC,OAAO;GACL;GACA,QAAQ,OAAO;IACb,IAAI,MAAM,QAAQ,KAAK;KACrB,gBAAgB,KAAK;IACvB;GACF;EACF;CACF,GAAG,CACD,MACA,OACF,CAAC;CACD,OAAO,QAAQ,WAAW;EACxB,OAAO,UAAU;GACf;GACA;EACF,IAAI,CAAC;CACP,GAAG;EACD;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -74,7 +74,7 @@ function matchesFocusVisible(element) {
|
|
|
74
74
|
if (!element || isJSDOM()) return true;
|
|
75
75
|
try {
|
|
76
76
|
return element.matches(":focus-visible");
|
|
77
|
-
} catch (
|
|
77
|
+
} catch (unused) {
|
|
78
78
|
return true;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -115,7 +115,7 @@ function enqueueFocus(el) {
|
|
|
115
115
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
116
116
|
var { preventScroll = false, cancelPrevious = true, sync = false } = options;
|
|
117
117
|
cancelPrevious && cancelAnimationFrame(rafId);
|
|
118
|
-
var exec = function() {
|
|
118
|
+
var exec = function exec2() {
|
|
119
119
|
return el === null || el === void 0 ? void 0 : el.focus({ preventScroll });
|
|
120
120
|
};
|
|
121
121
|
if (sync) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.native.js","names":[],"sources":["esm/interactions/utils.native.js"],"sourcesContent":["function getDocument(node) {\n return (node === null || node === void 0 ? void 0 : node.ownerDocument) || document;\n}\nfunction contains(parent, child) {\n var _child_getRootNode;\n if (!parent || !child) return false;\n var rootNode = (_child_getRootNode = child.getRootNode) === null || _child_getRootNode === void 0 ? void 0 : _child_getRootNode.call(child);\n if (parent.contains(child)) return true;\n if (rootNode && isShadowRoot(rootNode)) {\n var next = child;\n while (next) {\n if (parent === next) return true;\n next = next.parentNode || next.host;\n }\n }\n return false;\n}\nfunction isShadowRoot(node) {\n return node instanceof ShadowRoot;\n}\nfunction getTarget(event) {\n if (\"composedPath\" in event) {\n return event.composedPath()[0];\n }\n return event.target;\n}\nfunction activeElement(doc) {\n var _el_shadowRoot;\n var el = doc.activeElement;\n while ((el === null || el === void 0 ? void 0 : (_el_shadowRoot = el.shadowRoot) === null || _el_shadowRoot === void 0 ? void 0 : _el_shadowRoot.activeElement) != null) {\n el = el.shadowRoot.activeElement;\n }\n return el;\n}\nfunction isHTMLElement(value) {\n return value instanceof HTMLElement;\n}\nfunction isElement(value) {\n return value instanceof Element;\n}\nvar TYPEABLE_SELECTOR = \"input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])\";\nfunction isTypeableElement(element) {\n return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);\n}\nfunction isTypeableCombobox(element) {\n if (!element) return false;\n return element.getAttribute(\"role\") === \"combobox\" && isTypeableElement(element);\n}\nfunction getPlatform() {\n var uaData = navigator.userAgentData;\n if (uaData === null || uaData === void 0 ? void 0 : uaData.platform) return uaData.platform;\n return navigator.platform;\n}\nfunction getUserAgent() {\n var uaData = navigator.userAgentData;\n if (uaData && Array.isArray(uaData.brands)) {\n return uaData.brands.map(function(param) {\n var { brand, version } = param;\n return `${brand}/${version}`;\n }).join(\" \");\n }\n return navigator.userAgent;\n}\nfunction isSafari() {\n return /apple/i.test(navigator.vendor);\n}\nfunction isMac() {\n return getPlatform().toLowerCase().startsWith(\"mac\") && !navigator.maxTouchPoints;\n}\nfunction isJSDOM() {\n return getUserAgent().includes(\"jsdom/\");\n}\nfunction matchesFocusVisible(element) {\n if (!element || isJSDOM()) return true;\n try {\n return element.matches(\":focus-visible\");\n } catch (
|
|
1
|
+
{"version":3,"file":"utils.native.js","names":[],"sources":["esm/interactions/utils.native.js"],"sourcesContent":["function getDocument(node) {\n return (node === null || node === void 0 ? void 0 : node.ownerDocument) || document;\n}\nfunction contains(parent, child) {\n var _child_getRootNode;\n if (!parent || !child) return false;\n var rootNode = (_child_getRootNode = child.getRootNode) === null || _child_getRootNode === void 0 ? void 0 : _child_getRootNode.call(child);\n if (parent.contains(child)) return true;\n if (rootNode && isShadowRoot(rootNode)) {\n var next = child;\n while (next) {\n if (parent === next) return true;\n next = next.parentNode || next.host;\n }\n }\n return false;\n}\nfunction isShadowRoot(node) {\n return node instanceof ShadowRoot;\n}\nfunction getTarget(event) {\n if (\"composedPath\" in event) {\n return event.composedPath()[0];\n }\n return event.target;\n}\nfunction activeElement(doc) {\n var _el_shadowRoot;\n var el = doc.activeElement;\n while ((el === null || el === void 0 ? void 0 : (_el_shadowRoot = el.shadowRoot) === null || _el_shadowRoot === void 0 ? void 0 : _el_shadowRoot.activeElement) != null) {\n el = el.shadowRoot.activeElement;\n }\n return el;\n}\nfunction isHTMLElement(value) {\n return value instanceof HTMLElement;\n}\nfunction isElement(value) {\n return value instanceof Element;\n}\nvar TYPEABLE_SELECTOR = \"input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])\";\nfunction isTypeableElement(element) {\n return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);\n}\nfunction isTypeableCombobox(element) {\n if (!element) return false;\n return element.getAttribute(\"role\") === \"combobox\" && isTypeableElement(element);\n}\nfunction getPlatform() {\n var uaData = navigator.userAgentData;\n if (uaData === null || uaData === void 0 ? void 0 : uaData.platform) return uaData.platform;\n return navigator.platform;\n}\nfunction getUserAgent() {\n var uaData = navigator.userAgentData;\n if (uaData && Array.isArray(uaData.brands)) {\n return uaData.brands.map(function(param) {\n var { brand, version } = param;\n return `${brand}/${version}`;\n }).join(\" \");\n }\n return navigator.userAgent;\n}\nfunction isSafari() {\n return /apple/i.test(navigator.vendor);\n}\nfunction isMac() {\n return getPlatform().toLowerCase().startsWith(\"mac\") && !navigator.maxTouchPoints;\n}\nfunction isJSDOM() {\n return getUserAgent().includes(\"jsdom/\");\n}\nfunction matchesFocusVisible(element) {\n if (!element || isJSDOM()) return true;\n try {\n return element.matches(\":focus-visible\");\n } catch (unused) {\n return true;\n }\n}\nfunction isMouseLikePointerType(pointerType, strict) {\n var values = [\n \"mouse\",\n \"pen\"\n ];\n if (!strict) {\n values.push(\"\", void 0);\n }\n return values.includes(pointerType);\n}\nfunction clearTimeoutIfSet(timeoutRef) {\n if (timeoutRef.current !== -1) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = -1;\n }\n}\nfunction stopEvent(event) {\n event.preventDefault();\n event.stopPropagation();\n}\nfunction isVirtualClick(event) {\n if (event.mozInputSource === 0 && event.isTrusted) return true;\n if (isAndroid() && event.pointerType) {\n return event.type === \"click\" && event.buttons === 1;\n }\n return event.detail === 0 && !event.pointerType;\n}\nfunction isVirtualPointerEvent(event) {\n if (isJSDOM()) return false;\n return !isAndroid() && event.width === 0 && event.height === 0 || isAndroid() && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === \"mouse\" || event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === \"touch\";\n}\nfunction isAndroid() {\n var re = /android/i;\n return re.test(getPlatform()) || re.test(getUserAgent());\n}\nvar rafId = 0;\nfunction enqueueFocus(el) {\n var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n var { preventScroll = false, cancelPrevious = true, sync = false } = options;\n cancelPrevious && cancelAnimationFrame(rafId);\n var exec = function exec2() {\n return el === null || el === void 0 ? void 0 : el.focus({\n preventScroll\n });\n };\n if (sync) {\n exec();\n } else {\n rafId = requestAnimationFrame(exec);\n }\n}\nfunction isListIndexDisabled(listRef, index, disabledIndices) {\n if (typeof disabledIndices === \"function\") return disabledIndices(index);\n if (disabledIndices) return disabledIndices.includes(index);\n var element = listRef.current[index];\n return element == null || element.hasAttribute(\"disabled\") || element.getAttribute(\"aria-disabled\") === \"true\";\n}\nfunction findNonDisabledListIndex(listRef) {\n var { startingIndex = -1, decrement = false, disabledIndices, amount = 1 } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n var index = startingIndex;\n do {\n index += decrement ? -amount : amount;\n } while (index >= 0 && index <= listRef.current.length - 1 && isListIndexDisabled(listRef, index, disabledIndices));\n return index;\n}\nfunction getMinListIndex(listRef, disabledIndices) {\n return findNonDisabledListIndex(listRef, {\n disabledIndices\n });\n}\nfunction getMaxListIndex(listRef, disabledIndices) {\n return findNonDisabledListIndex(listRef, {\n decrement: true,\n startingIndex: listRef.current.length,\n disabledIndices\n });\n}\nfunction isIndexOutOfListBounds(listRef, index) {\n return index < 0 || index >= listRef.current.length;\n}\nexport {\n activeElement,\n clearTimeoutIfSet,\n contains,\n enqueueFocus,\n findNonDisabledListIndex,\n getDocument,\n getMaxListIndex,\n getMinListIndex,\n getTarget,\n isElement,\n isHTMLElement,\n isIndexOutOfListBounds,\n isListIndexDisabled,\n isMac,\n isMouseLikePointerType,\n isSafari,\n isTypeableCombobox,\n isTypeableElement,\n isVirtualClick,\n isVirtualPointerEvent,\n matchesFocusVisible,\n stopEvent\n};\n//# sourceMappingURL=utils.js.map\n"],"mappings":";AAAA,SAAS,YAAY,MAAM;CACzB,QAAQ,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,IAAI,KAAK,kBAAkB;AAC7E;AACA,SAAS,SAAS,QAAQ,OAAO;CAC/B,IAAI;CACJ,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO;CAC9B,IAAI,YAAY,qBAAqB,MAAM,iBAAiB,QAAQ,uBAAuB,KAAK,IAAI,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OAAO,eAAe;CACjH,OAAO;AACT;AACA,SAAS,gBAAgB,SAAS,iBAAiB;CACjD,OAAO,yBAAyB,SAAS,EACvC,gBACF,CAAC;AACH;AACA,SAAS,gBAAgB,SAAS,iBAAiB;CACjD,OAAO,yBAAyB,SAAS;EACvC,WAAW;EACX,eAAe,QAAQ,QAAQ;EAC/B;CACF,CAAC;AACH;AACA,SAAS,uBAAuB,SAAS,OAAO;CAC9C,OAAO,QAAQ,KAAK,SAAS,QAAQ,QAAQ;AAC/C"}
|
|
@@ -13,11 +13,12 @@ function getArgsWithCustomFloatingHeight(state, height) {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
var inner = function(props) {
|
|
16
|
+
var inner = function inner2(props) {
|
|
17
17
|
return {
|
|
18
18
|
name: "inner",
|
|
19
19
|
options: props,
|
|
20
20
|
async fn(state) {
|
|
21
|
+
var _ref;
|
|
21
22
|
var _listRef_current, _listRef_current1;
|
|
22
23
|
var { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef, padding = 0 } = props;
|
|
23
24
|
var { rects, elements: { floating } } = state;
|
|
@@ -47,16 +48,15 @@ var inner = function(props) {
|
|
|
47
48
|
return v;
|
|
48
49
|
} : Math.round;
|
|
49
50
|
var fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);
|
|
50
|
-
var
|
|
51
|
-
var minimumHeight = item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0);
|
|
51
|
+
var minimumHeight = item.offsetHeight * Math.min(minItemsVisible, (_ref = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _ref !== void 0 ? _ref : 0);
|
|
52
52
|
var maxHeight = rounder(Math.max(0, Math.min(fullHeight, fullHeight - overflow.top - overflow.bottom, Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom)))));
|
|
53
53
|
var nextY = Math.min(nextArgs.y + diffY, nextArgs.y + fullHeight - overflow.bottom - maxHeight);
|
|
54
54
|
scrollEl.style.maxHeight = `${maxHeight}px`;
|
|
55
55
|
scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y);
|
|
56
56
|
if (onFallbackChange) {
|
|
57
|
+
var _ref1;
|
|
57
58
|
var _listRef_current2;
|
|
58
|
-
var
|
|
59
|
-
var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length1 = (_listRef_current2 = listRef.current) === null || _listRef_current2 === void 0 ? void 0 : _listRef_current2.length) !== null && _listRef_current_length1 !== void 0 ? _listRef_current_length1 : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
|
|
59
|
+
var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_ref1 = (_listRef_current2 = listRef.current) === null || _listRef_current2 === void 0 ? void 0 : _listRef_current2.length) !== null && _ref1 !== void 0 ? _ref1 : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
|
|
60
60
|
ReactDOM.flushSync(function() {
|
|
61
61
|
return onFallbackChange(shouldFallback);
|
|
62
62
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inner.native.js","names":[],"sources":["esm/middleware/inner.native.js"],"sourcesContent":["import * as ReactDOM from \"react-dom\";\nimport { detectOverflow, offset } from \"@floating-ui/react-dom\";\nfunction getArgsWithCustomFloatingHeight(state, height) {\n return {\n ...state,\n rects: {\n ...state.rects,\n floating: {\n ...state.rects.floating,\n height\n }\n }\n };\n}\nvar inner = function(props) {\n return {\n name: \"inner\",\n options: props,\n async fn(state) {\n var _listRef_current, _listRef_current1;\n var { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef, padding = 0 } = props;\n var { rects, elements: { floating } } = state;\n var item = (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current[index !== null && index !== void 0 ? index : 0];\n var scrollEl = (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) || floating;\n var clientTop = floating.clientTop || scrollEl.clientTop;\n var floatingIsBordered = floating.clientTop !== 0;\n var scrollElIsBordered = scrollEl.clientTop !== 0;\n var floatingIsScrollEl = floating === scrollEl;\n if (!item || index == null) {\n onFallbackChange === null || onFallbackChange === void 0 ? void 0 : onFallbackChange(true);\n return {};\n }\n var nextArgs = {\n ...state,\n ...await offset(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state)\n };\n var detectOverflowOptions = {\n padding\n };\n var overflow = await detectOverflow(getArgsWithCustomFloatingHeight(nextArgs, scrollEl.scrollHeight + clientTop + floating.clientTop), detectOverflowOptions);\n var refOverflow = await detectOverflow(nextArgs, {\n ...detectOverflowOptions,\n elementContext: \"reference\"\n });\n var diffY = Math.max(0, overflow.top);\n var isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;\n var rounder = isScrollable ? function(v) {\n return v;\n } : Math.round;\n var fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);\n var
|
|
1
|
+
{"version":3,"file":"inner.native.js","names":[],"sources":["esm/middleware/inner.native.js"],"sourcesContent":["import * as ReactDOM from \"react-dom\";\nimport { detectOverflow, offset } from \"@floating-ui/react-dom\";\nfunction getArgsWithCustomFloatingHeight(state, height) {\n return {\n ...state,\n rects: {\n ...state.rects,\n floating: {\n ...state.rects.floating,\n height\n }\n }\n };\n}\nvar inner = function inner2(props) {\n return {\n name: \"inner\",\n options: props,\n async fn(state) {\n var _ref;\n var _listRef_current, _listRef_current1;\n var { listRef, overflowRef, onFallbackChange, offset: innerOffset = 0, index = 0, minItemsVisible = 4, referenceOverflowThreshold = 0, scrollRef, padding = 0 } = props;\n var { rects, elements: { floating } } = state;\n var item = (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current[index !== null && index !== void 0 ? index : 0];\n var scrollEl = (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) || floating;\n var clientTop = floating.clientTop || scrollEl.clientTop;\n var floatingIsBordered = floating.clientTop !== 0;\n var scrollElIsBordered = scrollEl.clientTop !== 0;\n var floatingIsScrollEl = floating === scrollEl;\n if (!item || index == null) {\n onFallbackChange === null || onFallbackChange === void 0 ? void 0 : onFallbackChange(true);\n return {};\n }\n var nextArgs = {\n ...state,\n ...await offset(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state)\n };\n var detectOverflowOptions = {\n padding\n };\n var overflow = await detectOverflow(getArgsWithCustomFloatingHeight(nextArgs, scrollEl.scrollHeight + clientTop + floating.clientTop), detectOverflowOptions);\n var refOverflow = await detectOverflow(nextArgs, {\n ...detectOverflowOptions,\n elementContext: \"reference\"\n });\n var diffY = Math.max(0, overflow.top);\n var isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;\n var rounder = isScrollable ? function(v) {\n return v;\n } : Math.round;\n var fullHeight = scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0);\n var minimumHeight = item.offsetHeight * Math.min(minItemsVisible, (_ref = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _ref !== void 0 ? _ref : 0);\n var maxHeight = rounder(Math.max(0, Math.min(fullHeight, fullHeight - overflow.top - overflow.bottom, Math.max(minimumHeight, fullHeight - diffY - Math.max(0, overflow.bottom)))));\n var nextY = Math.min(nextArgs.y + diffY, nextArgs.y + fullHeight - overflow.bottom - maxHeight);\n scrollEl.style.maxHeight = `${maxHeight}px`;\n scrollEl.scrollTop = Math.max(0, nextY - nextArgs.y);\n if (onFallbackChange) {\n var _ref1;\n var _listRef_current2;\n var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_ref1 = (_listRef_current2 = listRef.current) === null || _listRef_current2 === void 0 ? void 0 : _listRef_current2.length) !== null && _ref1 !== void 0 ? _ref1 : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;\n ReactDOM.flushSync(function() {\n return onFallbackChange(shouldFallback);\n });\n }\n if (overflowRef) {\n ;\n overflowRef.current = await detectOverflow(getArgsWithCustomFloatingHeight({\n ...nextArgs,\n y: nextY\n }, scrollEl.offsetHeight + clientTop + floating.clientTop), detectOverflowOptions);\n }\n return {\n y: nextY\n };\n }\n };\n};\nexport {\n inner\n};\n//# sourceMappingURL=inner.js.map\n"],"mappings":";;;;AAEA,SAAS,gCAAgC,OAAO,QAAQ;CACtD,OAAO;EACL,GAAG;EACH,OAAO;GACL,GAAG,MAAM;GACT,UAAU;IACR,GAAG,MAAM,MAAM;IACf;GACF;EACF;CACF;AACF;AACA,IAAI,QAAQ,SAAS,OAAO,OAAO;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,MAAM,GAAG,OAAO;GACd,IAAI;GACJ,IAAI,kBAAkB;GACtB,IAAI,EAAE,SAAS,aAAa,kBAAkB,QAAQ,cAAc,GAAG,QAAQ,GAAG,kBAAkB,GAAG,6BAA6B,GAAG,WAAW,UAAU,MAAM;GAClK,IAAI,EAAE,OAAO,UAAU,EAAE,eAAe;GACxC,IAAI,QAAQ,mBAAmB,QAAQ,aAAa,QAAQ,qBAAqB,KAAK,IAAI,KAAK,IAAI,iBAAiB,UAAU,QAAQ,UAAU,KAAK,IAAI,QAAQ;GACjK,IAAI,YAAY,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU,YAAY;GAC5F,IAAI,YAAY,SAAS,aAAa,SAAS;G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AC9F,SAAS,MAAM,YAAY,GAAG,UAAU;GACxC,SAAS,YAAY,KAAK,IAAI,GAAG,QAAQ,SAAS,CAAC;GACnD,IAAI,kBAAkB;IACpB,IAAI;IACJ,IAAI;IACJ,IAAI,iBAAiB,SAAS,eAAe,KAAK,eAAe,KAAK,IAAI,kBAAkB,SAAS,oBAAoB,QAAQ,aAAa,QAAQ,sBAAsB,KAAK,IAAI,KAAK,IAAI,kBAAkB,YAAY,QAAQ,UAAU,KAAK,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,OAAO,CAAC,8BAA8B,YAAY,UAAU,CAAC;IAClV,SAAS,UAAU,WAAW;KAC5B,OAAO,iBAAiB,cAAc;IACxC,CAAC;GACH;GACA,IAAI,aAAa;IACf;IACA,YAAY,UAAU,MAAM,eAAe,gCAAgC;KACzE,GAAG;KACH,GAAG;IACL,GAAG,SAAS,eAAe,YAAY,SAAS,SAAS,GAAG,qBAAqB;GACnF;GACA,OAAO,EACL,GAAG,MACL;EACF;CACF;AACF"}
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import * as Floating from "./Floating.native.js";
|
|
3
3
|
|
|
4
4
|
var FloatingOverrideContext = /* @__PURE__ */ React.createContext(null);
|
|
5
|
-
var useFloating = function(props) {
|
|
5
|
+
var useFloating = function useFloating2(props) {
|
|
6
6
|
"use no memo";
|
|
7
7
|
var _this;
|
|
8
8
|
var context = React.useContext(FloatingOverrideContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFloating.native.js","names":[],"sources":["esm/useFloating.native.js"],"sourcesContent":["import React from \"react\";\nimport * as Floating from \"./Floating\";\nvar FloatingOverrideContext = /* @__PURE__ */ React.createContext(null);\nvar useFloating = function(props) {\n \"use no memo\";\n var _this;\n var context = React.useContext(FloatingOverrideContext);\n return (_this = context || Floating.useFloating) === null || _this === void 0 ? void 0 : _this({\n ...props,\n middleware: [\n // @ts-ignore\n ...props.middleware,\n {\n name: `rounded`,\n fn(param) {\n var { x, y } = param;\n return {\n x: Math.round(x),\n y: Math.round(y)\n };\n }\n }\n ]\n });\n};\nexport {\n FloatingOverrideContext,\n useFloating\n};\n//# sourceMappingURL=useFloating.js.map\n"],"mappings":";;;;AAEA,IAAI,0BAA0C,sBAAM,cAAc,IAAI;AACtE,IAAI,cAAc,SAAS,OAAO;
|
|
1
|
+
{"version":3,"file":"useFloating.native.js","names":[],"sources":["esm/useFloating.native.js"],"sourcesContent":["import React from \"react\";\nimport * as Floating from \"./Floating\";\nvar FloatingOverrideContext = /* @__PURE__ */ React.createContext(null);\nvar useFloating = function useFloating2(props) {\n \"use no memo\";\n var _this;\n var context = React.useContext(FloatingOverrideContext);\n return (_this = context || Floating.useFloating) === null || _this === void 0 ? void 0 : _this({\n ...props,\n middleware: [\n // @ts-ignore\n ...props.middleware,\n {\n name: `rounded`,\n fn(param) {\n var { x, y } = param;\n return {\n x: Math.round(x),\n y: Math.round(y)\n };\n }\n }\n ]\n });\n};\nexport {\n FloatingOverrideContext,\n useFloating\n};\n//# sourceMappingURL=useFloating.js.map\n"],"mappings":";;;;AAEA,IAAI,0BAA0C,sBAAM,cAAc,IAAI;AACtE,IAAI,cAAc,SAAS,aAAa,OAAO;CAC7C;CACA,IAAI;CACJ,IAAI,UAAU,MAAM,WAAW,uBAAuB;CACtD,QAAQ,QAAQ,WAAW,SAAS,iBAAiB,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EAC7F,GAAG;EACH,YAAY,CAEV,GAAG,MAAM,YACT;GACE,MAAM;GACN,GAAG,OAAO;IACR,IAAI,EAAE,GAAG,MAAM;IACf,OAAO;KACL,GAAG,KAAK,MAAM,CAAC;KACf,GAAG,KAAK,MAAM,CAAC;IACjB;GACF;EACF,CACF;CACF,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/floating",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@floating-ui/react-dom": "^2.1.6",
|
|
39
39
|
"@floating-ui/react-native": "^0.10.7",
|
|
40
|
-
"@tamagui/use-event": "3.0.
|
|
40
|
+
"@tamagui/use-event": "3.0.8"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@tamagui/build": "3.0.
|
|
43
|
+
"@tamagui/build": "3.0.8",
|
|
44
44
|
"react": "19.2.3",
|
|
45
45
|
"react-native": "0.87.1"
|
|
46
46
|
},
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"url": "git+https://github.com/tamagui/tamagui.git",
|
|
54
54
|
"directory": "code/core/floating"
|
|
55
55
|
},
|
|
56
|
-
"releaseSourceCommit": "
|
|
56
|
+
"releaseSourceCommit": "b723356193510591d9ad15877b8937e8e6a31910"
|
|
57
57
|
}
|