@actview/floating-ui 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/FloatingDelayGroup.d.ts +3 -3
- package/dist/components/FloatingPortal.d.ts +1 -1
- package/dist/components/FloatingTree.d.ts +1 -0
- package/dist/floating-ui.actview.esm.js +106 -89
- package/dist/floating-ui.actview.mjs +106 -89
- package/dist/floating-ui.actview.umd.js +106 -89
- package/dist/floating-ui.actview.umd.min.js +1 -1
- package/package.json +3 -3
|
@@ -803,15 +803,20 @@
|
|
|
803
803
|
});
|
|
804
804
|
return newMap;
|
|
805
805
|
});
|
|
806
|
-
|
|
806
|
+
|
|
807
|
+
// store-as-is 载体:身份稳定的 getter 对象(provide 只在 Provider setup 执行
|
|
808
|
+
// 一次,computed 重建的新对象会冻结快照——map 变化时 use() 仍拿到首帧对象)。
|
|
809
|
+
const contextValue = {
|
|
807
810
|
register,
|
|
808
811
|
unregister,
|
|
809
|
-
map
|
|
812
|
+
get map() {
|
|
813
|
+
return map.value;
|
|
814
|
+
},
|
|
810
815
|
elementsRef,
|
|
811
816
|
labelsRef
|
|
812
|
-
}
|
|
817
|
+
};
|
|
813
818
|
return () => jsx(FloatingListContext.Provider, {
|
|
814
|
-
"value": contextValue
|
|
819
|
+
"value": contextValue,
|
|
815
820
|
"children": props.children
|
|
816
821
|
}, undefined);
|
|
817
822
|
});
|
|
@@ -838,15 +843,15 @@
|
|
|
838
843
|
// (register 幂等,Set 去重)并立即用重算后的 map 同步 index,保证
|
|
839
844
|
// 挂载后首个事件处理器读到正确的 index。
|
|
840
845
|
if (node) {
|
|
841
|
-
listContext.
|
|
842
|
-
const index = listContext.
|
|
846
|
+
listContext.register(node);
|
|
847
|
+
const index = listContext.map.get(node);
|
|
843
848
|
if (index != null) {
|
|
844
849
|
indexRef.value = index;
|
|
845
|
-
listContext.
|
|
846
|
-
if (listContext.
|
|
850
|
+
listContext.elementsRef.value[index] = node;
|
|
851
|
+
if (listContext.labelsRef) {
|
|
847
852
|
var _node$textContent;
|
|
848
853
|
const isLabelDefined = label !== undefined;
|
|
849
|
-
listContext.
|
|
854
|
+
listContext.labelsRef.value[index] = isLabelDefined ? label : (_node$textContent = node == null ? void 0 : node.textContent) != null ? _node$textContent : null;
|
|
850
855
|
}
|
|
851
856
|
}
|
|
852
857
|
}
|
|
@@ -859,13 +864,13 @@
|
|
|
859
864
|
core.watch(() => componentRef.value, () => {
|
|
860
865
|
const node = componentRef.value;
|
|
861
866
|
if (node) {
|
|
862
|
-
listContext.
|
|
867
|
+
listContext.register(node);
|
|
863
868
|
registeredNode = node;
|
|
864
869
|
}
|
|
865
870
|
});
|
|
866
871
|
core.onUnmounted(() => {
|
|
867
872
|
if (registeredNode) {
|
|
868
|
-
listContext.
|
|
873
|
+
listContext.unregister(registeredNode);
|
|
869
874
|
}
|
|
870
875
|
});
|
|
871
876
|
|
|
@@ -873,16 +878,16 @@
|
|
|
873
878
|
// React 版靠「ref 回调依赖 index state、依赖变化时 React 重新调用 ref(null)+ref(node)」
|
|
874
879
|
// 写入 elementsRef;actview 的 ref 回调是固定函数不会重建,这里在 index 就绪后
|
|
875
880
|
// 主动同步 elementsRef / labelsRef。
|
|
876
|
-
core.watch(() => listContext.
|
|
881
|
+
core.watch(() => listContext.map, () => {
|
|
877
882
|
const node = componentRef.value;
|
|
878
|
-
const index = node ? listContext.
|
|
883
|
+
const index = node ? listContext.map.get(node) : null;
|
|
879
884
|
if (index != null) {
|
|
880
885
|
indexRef.value = index;
|
|
881
|
-
listContext.
|
|
882
|
-
if (listContext.
|
|
886
|
+
listContext.elementsRef.value[index] = node;
|
|
887
|
+
if (listContext.labelsRef) {
|
|
883
888
|
var _node$textContent2;
|
|
884
889
|
const isLabelDefined = label !== undefined;
|
|
885
|
-
listContext.
|
|
890
|
+
listContext.labelsRef.value[index] = isLabelDefined ? label : (_node$textContent2 = node == null ? void 0 : node.textContent) != null ? _node$textContent2 : null;
|
|
886
891
|
}
|
|
887
892
|
}
|
|
888
893
|
});
|
|
@@ -966,10 +971,16 @@
|
|
|
966
971
|
}
|
|
967
972
|
};
|
|
968
973
|
const elementsRef = core.ref([]);
|
|
969
|
-
|
|
970
|
-
|
|
974
|
+
|
|
975
|
+
// store-as-is 载体:身份稳定的 getter 对象(provide 只在 Provider setup 执行
|
|
976
|
+
// 一次,computed 重建的新对象会冻结快照——activeIndex 变化时 use() 仍拿到
|
|
977
|
+
// 首帧对象)。
|
|
978
|
+
const contextValue = {
|
|
979
|
+
get activeIndex() {
|
|
980
|
+
return activeIndex.value;
|
|
981
|
+
},
|
|
971
982
|
onNavigate
|
|
972
|
-
}
|
|
983
|
+
};
|
|
973
984
|
return () => {
|
|
974
985
|
const {
|
|
975
986
|
render,
|
|
@@ -1076,7 +1087,7 @@
|
|
|
1076
1087
|
}
|
|
1077
1088
|
};
|
|
1078
1089
|
return jsx(CompositeContext.Provider, {
|
|
1079
|
-
"value": contextValue
|
|
1090
|
+
"value": contextValue,
|
|
1080
1091
|
"children": jsx(FloatingList, {
|
|
1081
1092
|
"elementsRef": core.rawRef(elementsRef),
|
|
1082
1093
|
"children": renderJsx(render, computedProps)
|
|
@@ -1094,7 +1105,7 @@
|
|
|
1094
1105
|
index
|
|
1095
1106
|
} = useListItem();
|
|
1096
1107
|
const mergedRef = useMergeRefs([itemRef, props.ref, renderElementRef()]);
|
|
1097
|
-
const isActive = core.computed(() => compositeContext.
|
|
1108
|
+
const isActive = core.computed(() => compositeContext.activeIndex === index.value);
|
|
1098
1109
|
function renderElementRef() {
|
|
1099
1110
|
const r = props.render;
|
|
1100
1111
|
return r && typeof r !== 'function' ? r.props.ref : undefined;
|
|
@@ -1114,7 +1125,7 @@
|
|
|
1114
1125
|
onFocus(e) {
|
|
1115
1126
|
domProps.onFocus == null || domProps.onFocus(e);
|
|
1116
1127
|
renderElementProps.onFocus == null || renderElementProps.onFocus(e);
|
|
1117
|
-
compositeContext.
|
|
1128
|
+
compositeContext.onNavigate(index.value);
|
|
1118
1129
|
}
|
|
1119
1130
|
};
|
|
1120
1131
|
return renderJsx(render, computedProps);
|
|
@@ -1349,16 +1360,17 @@
|
|
|
1349
1360
|
/**
|
|
1350
1361
|
* Returns the parent node id for nested floating elements, if available.
|
|
1351
1362
|
* Returns `null` for top-level floating elements.
|
|
1363
|
+
* (store-as-is:use() 原样返回 payload——直读字段,不再 `.value`。)
|
|
1352
1364
|
*/
|
|
1353
1365
|
const useFloatingParentNodeId = () => {
|
|
1354
1366
|
var _FloatingNodeContext$;
|
|
1355
|
-
return ((_FloatingNodeContext$ = FloatingNodeContext.use()
|
|
1367
|
+
return ((_FloatingNodeContext$ = FloatingNodeContext.use()) == null ? void 0 : _FloatingNodeContext$.id) || null;
|
|
1356
1368
|
};
|
|
1357
1369
|
|
|
1358
1370
|
/**
|
|
1359
1371
|
* Returns the nearest floating tree context, if available.
|
|
1360
1372
|
*/
|
|
1361
|
-
const useFloatingTree = () => FloatingTreeContext.use()
|
|
1373
|
+
const useFloatingTree = () => FloatingTreeContext.use();
|
|
1362
1374
|
|
|
1363
1375
|
/**
|
|
1364
1376
|
* Registers a node into the `FloatingTree`, returning its id.
|
|
@@ -1368,10 +1380,7 @@
|
|
|
1368
1380
|
const id = useId();
|
|
1369
1381
|
const tree = useFloatingTree();
|
|
1370
1382
|
const nodeContext = FloatingNodeContext.use();
|
|
1371
|
-
const parentId = core.computed(() =>
|
|
1372
|
-
var _nodeContext$value;
|
|
1373
|
-
return customParentId || ((_nodeContext$value = nodeContext.value) == null ? void 0 : _nodeContext$value.id) || null;
|
|
1374
|
-
});
|
|
1383
|
+
const parentId = core.computed(() => customParentId || (nodeContext == null ? void 0 : nodeContext.id) || null);
|
|
1375
1384
|
let added = false;
|
|
1376
1385
|
let node = null;
|
|
1377
1386
|
// immediate:id 由 useId 同步生成(不再变化),非 immediate 的 watch 不会触发;
|
|
@@ -1402,10 +1411,7 @@
|
|
|
1402
1411
|
*/
|
|
1403
1412
|
const FloatingNode = core.defineComponent(function (props) {
|
|
1404
1413
|
const nodeContext = FloatingNodeContext.use();
|
|
1405
|
-
const parentId = core.computed(() =>
|
|
1406
|
-
var _nodeContext$value2;
|
|
1407
|
-
return ((_nodeContext$value2 = nodeContext.value) == null ? void 0 : _nodeContext$value2.id) || null;
|
|
1408
|
-
});
|
|
1414
|
+
const parentId = core.computed(() => (nodeContext == null ? void 0 : nodeContext.id) || null);
|
|
1409
1415
|
return () => jsx(FloatingNodeContext.Provider, {
|
|
1410
1416
|
"value": {
|
|
1411
1417
|
id: props.id,
|
|
@@ -1858,6 +1864,7 @@
|
|
|
1858
1864
|
/**
|
|
1859
1865
|
* @deprecated
|
|
1860
1866
|
* Use the return value of `useDelayGroup()` instead.
|
|
1867
|
+
* (store-as-is:use() 原样返回 payload——直读字段,不再 `.value`。)
|
|
1861
1868
|
*/
|
|
1862
1869
|
const useDelayGroupContext = () => FloatingDelayGroupContext.use();
|
|
1863
1870
|
/**
|
|
@@ -1910,13 +1917,30 @@
|
|
|
1910
1917
|
initialCurrentIdRef.value = null;
|
|
1911
1918
|
}
|
|
1912
1919
|
});
|
|
1913
|
-
|
|
1914
|
-
|
|
1920
|
+
|
|
1921
|
+
// store-as-is 载体:身份稳定的 getter 对象(provide 只在 Provider setup 执行
|
|
1922
|
+
// 一次,computed 重建的新对象会冻结快照——state 变化时 use() 仍拿到首帧对象)。
|
|
1923
|
+
const contextValue = {
|
|
1924
|
+
get delay() {
|
|
1925
|
+
return state.value.delay;
|
|
1926
|
+
},
|
|
1927
|
+
get initialDelay() {
|
|
1928
|
+
return state.value.initialDelay;
|
|
1929
|
+
},
|
|
1930
|
+
get currentId() {
|
|
1931
|
+
return state.value.currentId;
|
|
1932
|
+
},
|
|
1933
|
+
get timeoutMs() {
|
|
1934
|
+
return state.value.timeoutMs;
|
|
1935
|
+
},
|
|
1936
|
+
get isInstantPhase() {
|
|
1937
|
+
return state.value.isInstantPhase;
|
|
1938
|
+
},
|
|
1915
1939
|
setState,
|
|
1916
1940
|
setCurrentId
|
|
1917
|
-
}
|
|
1941
|
+
};
|
|
1918
1942
|
return () => jsx(FloatingDelayGroupContext.Provider, {
|
|
1919
|
-
"value": contextValue
|
|
1943
|
+
"value": contextValue,
|
|
1920
1944
|
"children": children
|
|
1921
1945
|
}, undefined);
|
|
1922
1946
|
});
|
|
@@ -1942,12 +1966,12 @@
|
|
|
1942
1966
|
const groupContext = useDelayGroupContext();
|
|
1943
1967
|
|
|
1944
1968
|
// React 版 effect [enabled, id, onOpenChange, setState, currentId, initialDelay]
|
|
1945
|
-
core.watch(() => [enabled, id.value, groupContext.
|
|
1969
|
+
core.watch(() => [enabled, id.value, groupContext.currentId, groupContext.initialDelay], () => {
|
|
1946
1970
|
const {
|
|
1947
1971
|
currentId,
|
|
1948
1972
|
initialDelay,
|
|
1949
1973
|
setState
|
|
1950
|
-
} = groupContext
|
|
1974
|
+
} = groupContext;
|
|
1951
1975
|
if (!enabled) return;
|
|
1952
1976
|
if (!currentId) return;
|
|
1953
1977
|
setState({
|
|
@@ -1963,11 +1987,11 @@
|
|
|
1963
1987
|
|
|
1964
1988
|
// React 版 effect [enabled, open, setState, currentId, id, onOpenChange,
|
|
1965
1989
|
// initialDelay, timeoutMs]
|
|
1966
|
-
core.watch(() => [enabled, open.value, groupContext.
|
|
1990
|
+
core.watch(() => [enabled, open.value, groupContext.currentId, groupContext.initialDelay, groupContext.timeoutMs], () => {
|
|
1967
1991
|
function unset() {
|
|
1968
1992
|
onOpenChange(false);
|
|
1969
|
-
groupContext.
|
|
1970
|
-
delay: groupContext.
|
|
1993
|
+
groupContext.setState({
|
|
1994
|
+
delay: groupContext.initialDelay,
|
|
1971
1995
|
currentId: null
|
|
1972
1996
|
});
|
|
1973
1997
|
}
|
|
@@ -1976,7 +2000,7 @@
|
|
|
1976
2000
|
timeoutMs,
|
|
1977
2001
|
setState,
|
|
1978
2002
|
initialDelay
|
|
1979
|
-
} = groupContext
|
|
2003
|
+
} = groupContext;
|
|
1980
2004
|
if (!enabled) return;
|
|
1981
2005
|
if (!currentId) return;
|
|
1982
2006
|
if (!open.value && currentId === id.value) {
|
|
@@ -1994,8 +2018,8 @@
|
|
|
1994
2018
|
// React 版 effect [enabled, open, setCurrentId, id]
|
|
1995
2019
|
core.watch(() => [enabled, open.value, id.value], () => {
|
|
1996
2020
|
if (!enabled) return;
|
|
1997
|
-
if (groupContext.
|
|
1998
|
-
groupContext.
|
|
2021
|
+
if (groupContext.setCurrentId === NOOP || !open.value) return;
|
|
2022
|
+
groupContext.setCurrentId(id.value);
|
|
1999
2023
|
});
|
|
2000
2024
|
return groupContext;
|
|
2001
2025
|
}
|
|
@@ -2040,7 +2064,10 @@
|
|
|
2040
2064
|
const currentIdRef = core.ref(null);
|
|
2041
2065
|
const currentContextRef = core.ref(null);
|
|
2042
2066
|
const timeoutIdRef = core.ref(-1);
|
|
2043
|
-
|
|
2067
|
+
|
|
2068
|
+
// store-as-is 载体:身份稳定的对象(字段全是 ref 容器,字段引用不变、
|
|
2069
|
+
// 消费方读 `.value` 实时;computed 重建的新对象会冻结快照)。
|
|
2070
|
+
const contextValue = {
|
|
2044
2071
|
hasProvider: true,
|
|
2045
2072
|
delayRef,
|
|
2046
2073
|
initialDelayRef,
|
|
@@ -2048,9 +2075,9 @@
|
|
|
2048
2075
|
timeoutMs,
|
|
2049
2076
|
currentContextRef,
|
|
2050
2077
|
timeoutIdRef
|
|
2051
|
-
}
|
|
2078
|
+
};
|
|
2052
2079
|
return () => jsx(NextFloatingDelayGroupContext.Provider, {
|
|
2053
|
-
"value": contextValue
|
|
2080
|
+
"value": contextValue,
|
|
2054
2081
|
"children": children
|
|
2055
2082
|
}, undefined);
|
|
2056
2083
|
});
|
|
@@ -2080,7 +2107,7 @@
|
|
|
2080
2107
|
currentContextRef,
|
|
2081
2108
|
hasProvider,
|
|
2082
2109
|
timeoutIdRef
|
|
2083
|
-
} = groupContext
|
|
2110
|
+
} = groupContext;
|
|
2084
2111
|
const isInstantPhase = core.ref(false);
|
|
2085
2112
|
|
|
2086
2113
|
// React 版 effect [enabled, open, floatingId, ...]:unset / timeout
|
|
@@ -2405,11 +2432,7 @@
|
|
|
2405
2432
|
// React 版两个创建 effect(id 分支 + root 分支)。
|
|
2406
2433
|
// immediate:uniqueId 由 useId 同步生成(不再变化),非 immediate 的 watch
|
|
2407
2434
|
// 不会触发(依赖不变),portalNode 将永不创建。
|
|
2408
|
-
core.watch(() => {
|
|
2409
|
-
var _portalContext$value;
|
|
2410
|
-
return [id, uniqueId.value, core.toValue(root), (_portalContext$value = portalContext.value) == null ? void 0 : _portalContext$value.portalNode];
|
|
2411
|
-
}, () => {
|
|
2412
|
-
var _portalContext$value2;
|
|
2435
|
+
core.watch(() => [id, uniqueId.value, core.toValue(root), portalContext == null ? void 0 : portalContext.portalNode], () => {
|
|
2413
2436
|
// Wait for the uniqueId to be generated before creating the portal node
|
|
2414
2437
|
// (mirroring React <18 `useFloatingId` semantics).
|
|
2415
2438
|
// https://github.com/floating-ui/floating-ui/issues/2778
|
|
@@ -2431,7 +2454,7 @@
|
|
|
2431
2454
|
// `root` 分支:root / 父 portal 节点 / body
|
|
2432
2455
|
const rootValue = core.toValue(root);
|
|
2433
2456
|
if (rootValue === null) return;
|
|
2434
|
-
let container = rootValue || (
|
|
2457
|
+
let container = rootValue || (portalContext == null ? void 0 : portalContext.portalNode);
|
|
2435
2458
|
container = container || document.body;
|
|
2436
2459
|
let idWrapper = null;
|
|
2437
2460
|
if (id) {
|
|
@@ -2534,17 +2557,19 @@
|
|
|
2534
2557
|
core.onUnmounted(() => {
|
|
2535
2558
|
cleanupFocusListeners == null || cleanupFocusListeners();
|
|
2536
2559
|
});
|
|
2537
|
-
const contextValue =
|
|
2560
|
+
const contextValue = {
|
|
2538
2561
|
preserveTabOrder,
|
|
2539
2562
|
beforeOutsideRef,
|
|
2540
2563
|
afterOutsideRef,
|
|
2541
2564
|
beforeInsideRef,
|
|
2542
2565
|
afterInsideRef,
|
|
2543
|
-
portalNode
|
|
2566
|
+
get portalNode() {
|
|
2567
|
+
return portalNode.value;
|
|
2568
|
+
},
|
|
2544
2569
|
setFocusManagerState
|
|
2545
|
-
}
|
|
2570
|
+
};
|
|
2546
2571
|
return () => jsx(PortalContext.Provider, {
|
|
2547
|
-
"value": contextValue
|
|
2572
|
+
"value": contextValue,
|
|
2548
2573
|
"children": [shouldRenderGuards.value && portalNode.value && jsx(FocusGuard, {
|
|
2549
2574
|
"data-type": "outside",
|
|
2550
2575
|
"ref": beforeOutsideRef,
|
|
@@ -2822,7 +2847,7 @@
|
|
|
2822
2847
|
// disabled/open 变化会触发多次 watch 重跑,若为周期局部变量,后续周期的
|
|
2823
2848
|
// cleanup 会读到 ''(丢失 Escape 的 'keyboard'),returnFocus 函数参数错。
|
|
2824
2849
|
const closeTypeRef = core.ref('');
|
|
2825
|
-
const isInsidePortal = core.computed(() => portalContext
|
|
2850
|
+
const isInsidePortal = core.computed(() => portalContext != null);
|
|
2826
2851
|
const floatingFocusElement = core.computed(() => getFloatingFocusElement(floating.value));
|
|
2827
2852
|
const getTabbableContent = function (container) {
|
|
2828
2853
|
if (container === void 0) {
|
|
@@ -2906,7 +2931,7 @@
|
|
|
2906
2931
|
// 依赖含 disabled:keepMounted 场景初始 disabled=true 时跳过注册,
|
|
2907
2932
|
// 打开(disabled=false)后需重新注册 focusout 监听。
|
|
2908
2933
|
let cleanupFocusOut;
|
|
2909
|
-
core.watch([domReference, floating, portalContext, disabled], () => {
|
|
2934
|
+
core.watch(() => [domReference.value, floating.value, portalContext == null ? void 0 : portalContext.portalNode, disabled.value], () => {
|
|
2910
2935
|
cleanupFocusOut == null || cleanupFocusOut();
|
|
2911
2936
|
cleanupFocusOut = undefined;
|
|
2912
2937
|
if (disabled.value) return;
|
|
@@ -2924,9 +2949,9 @@
|
|
|
2924
2949
|
const currentTarget = event.currentTarget;
|
|
2925
2950
|
const target = getTarget(event);
|
|
2926
2951
|
queueMicrotask(() => {
|
|
2927
|
-
var _portalContext$
|
|
2952
|
+
var _portalContext$portal;
|
|
2928
2953
|
const nodeId = getNodeId();
|
|
2929
|
-
const movedToUnrelatedNode = !(contains(domReference.value, relatedTarget) || contains(floating.value, relatedTarget) || contains(relatedTarget, floating.value) || contains((_portalContext$
|
|
2954
|
+
const movedToUnrelatedNode = !(contains(domReference.value, relatedTarget) || contains(floating.value, relatedTarget) || contains(relatedTarget, floating.value) || contains((_portalContext$portal = portalContext == null ? void 0 : portalContext.portalNode) != null ? _portalContext$portal : null, relatedTarget) || relatedTarget != null && relatedTarget.hasAttribute(createAttribute('focus-guard')) || tree && (getNodeChildren(tree.nodesRef.value, nodeId).find(node => {
|
|
2930
2955
|
var _node$context, _node$context2;
|
|
2931
2956
|
return contains((_node$context = node.context) == null ? void 0 : _node$context.elements.floating.value, relatedTarget) || contains((_node$context2 = node.context) == null ? void 0 : _node$context2.elements.domReference.value, relatedTarget);
|
|
2932
2957
|
}) || getNodeAncestors(tree.nodesRef.value, nodeId).find(node => {
|
|
@@ -2979,7 +3004,7 @@
|
|
|
2979
3004
|
}
|
|
2980
3005
|
});
|
|
2981
3006
|
}
|
|
2982
|
-
const shouldHandleBlurCapture = Boolean(!tree && portalContext
|
|
3007
|
+
const shouldHandleBlurCapture = Boolean(!tree && portalContext);
|
|
2983
3008
|
function markInsideReactTree() {
|
|
2984
3009
|
clearTimeoutIfSet(blurTimeoutRef);
|
|
2985
3010
|
dataRef.value.insideReactTree = true;
|
|
@@ -3009,32 +3034,26 @@
|
|
|
3009
3034
|
});
|
|
3010
3035
|
const beforeGuardRef = core.ref(null);
|
|
3011
3036
|
const afterGuardRef = core.ref(null);
|
|
3012
|
-
const mergedBeforeGuardRef = useLiteMergeRefs([beforeGuardRef, () =>
|
|
3013
|
-
|
|
3014
|
-
return (_portalContext$value2 = portalContext.value) == null ? void 0 : _portalContext$value2.beforeInsideRef;
|
|
3015
|
-
}]);
|
|
3016
|
-
const mergedAfterGuardRef = useLiteMergeRefs([afterGuardRef, () => {
|
|
3017
|
-
var _portalContext$value3;
|
|
3018
|
-
return (_portalContext$value3 = portalContext.value) == null ? void 0 : _portalContext$value3.afterInsideRef;
|
|
3019
|
-
}]);
|
|
3037
|
+
const mergedBeforeGuardRef = useLiteMergeRefs([beforeGuardRef, () => portalContext == null ? void 0 : portalContext.beforeInsideRef]);
|
|
3038
|
+
const mergedAfterGuardRef = useLiteMergeRefs([afterGuardRef, () => portalContext == null ? void 0 : portalContext.afterInsideRef]);
|
|
3020
3039
|
|
|
3021
3040
|
// React 版 effect:markOthers(inert / aria-hidden)
|
|
3022
3041
|
let cleanupMarkOthers;
|
|
3023
|
-
core.watch([domReference, floating, portalContext], () => {
|
|
3024
|
-
var _portalContext$
|
|
3042
|
+
core.watch(() => [domReference.value, floating.value, portalContext == null ? void 0 : portalContext.portalNode], () => {
|
|
3043
|
+
var _portalContext$portal2, _ancestors$find;
|
|
3025
3044
|
cleanupMarkOthers == null || cleanupMarkOthers();
|
|
3026
3045
|
cleanupMarkOthers = undefined;
|
|
3027
3046
|
if (disabled.value) return;
|
|
3028
3047
|
if (!floating.value) return;
|
|
3029
3048
|
|
|
3030
3049
|
// Don't hide portals nested within the parent portal.
|
|
3031
|
-
const portalNodes = Array.from((
|
|
3050
|
+
const portalNodes = Array.from((portalContext == null || (_portalContext$portal2 = portalContext.portalNode) == null ? void 0 : _portalContext$portal2.querySelectorAll("[" + createAttribute('portal') + "]")) || []);
|
|
3032
3051
|
const ancestors = tree ? getNodeAncestors(tree.nodesRef.value, getNodeId()) : [];
|
|
3033
3052
|
const rootAncestorComboboxDomReference = (_ancestors$find = ancestors.find(node => {
|
|
3034
3053
|
var _node$context6;
|
|
3035
3054
|
return isTypeableCombobox(((_node$context6 = node.context) == null ? void 0 : _node$context6.elements.domReference.value) || null);
|
|
3036
3055
|
})) == null || (_ancestors$find = _ancestors$find.context) == null ? void 0 : _ancestors$find.elements.domReference.value;
|
|
3037
|
-
const insideElements = [floating.value, rootAncestorComboboxDomReference, ...portalNodes, ...getInsideElements(), startDismissButtonRef.value, endDismissButtonRef.value, beforeGuardRef.value, afterGuardRef.value,
|
|
3056
|
+
const insideElements = [floating.value, rootAncestorComboboxDomReference, ...portalNodes, ...getInsideElements(), startDismissButtonRef.value, endDismissButtonRef.value, beforeGuardRef.value, afterGuardRef.value, portalContext == null ? void 0 : portalContext.beforeOutsideRef.value, portalContext == null ? void 0 : portalContext.afterOutsideRef.value, orderRef.value.includes('reference') || isUntrappedTypeableCombobox.value ? domReference.value : null].filter(x => x != null);
|
|
3038
3057
|
cleanupMarkOthers = modal.value || isUntrappedTypeableCombobox.value ? markOthers(insideElements, !useInert.value, useInert.value) : markOthers(insideElements);
|
|
3039
3058
|
});
|
|
3040
3059
|
|
|
@@ -3217,9 +3236,9 @@
|
|
|
3217
3236
|
// React 版 `useModernLayoutEffect`:同步 context & modal 到 FloatingPortal
|
|
3218
3237
|
// 注意:open 在 FFM 挂载前已为 true,watch 无 immediate 时首次不触发,
|
|
3219
3238
|
// FloatingPortal 的 focusManagerState 保持 null(owner/guard 不渲染)。
|
|
3220
|
-
core.watch([portalContext, open, domReference], () => {
|
|
3239
|
+
core.watch(() => [portalContext == null ? void 0 : portalContext.portalNode, open.value, domReference.value], () => {
|
|
3221
3240
|
if (disabled.value) return;
|
|
3222
|
-
const currentPortal = portalContext
|
|
3241
|
+
const currentPortal = portalContext;
|
|
3223
3242
|
if (!currentPortal) return;
|
|
3224
3243
|
currentPortal.setFocusManagerState({
|
|
3225
3244
|
modal: modal.value,
|
|
@@ -3269,19 +3288,18 @@
|
|
|
3269
3288
|
"data-type": "inside",
|
|
3270
3289
|
"ref": mergedBeforeGuardRef,
|
|
3271
3290
|
"onFocus": event => {
|
|
3272
|
-
var _portalContext$value7;
|
|
3273
3291
|
if (modal.value) {
|
|
3274
3292
|
const els = getTabbableElements();
|
|
3275
3293
|
enqueueFocus(order.value[0] === 'reference' ? els[0] : els[els.length - 1]);
|
|
3276
|
-
} else if (
|
|
3277
|
-
var _portalContext$
|
|
3294
|
+
} else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) {
|
|
3295
|
+
var _portalContext$portal3;
|
|
3278
3296
|
preventReturnFocusRef.value = false;
|
|
3279
|
-
if (isOutsideEvent(event, (_portalContext$
|
|
3297
|
+
if (isOutsideEvent(event, (_portalContext$portal3 = portalContext.portalNode) != null ? _portalContext$portal3 : undefined)) {
|
|
3280
3298
|
const nextTabbable = getNextTabbable(domReference.value);
|
|
3281
3299
|
nextTabbable == null || nextTabbable.focus();
|
|
3282
3300
|
} else {
|
|
3283
|
-
var _portalContext$
|
|
3284
|
-
(_portalContext$
|
|
3301
|
+
var _portalContext$before;
|
|
3302
|
+
(_portalContext$before = portalContext.beforeOutsideRef.value) == null || _portalContext$before.focus();
|
|
3285
3303
|
}
|
|
3286
3304
|
}
|
|
3287
3305
|
}
|
|
@@ -3289,20 +3307,19 @@
|
|
|
3289
3307
|
"data-type": "inside",
|
|
3290
3308
|
"ref": mergedAfterGuardRef,
|
|
3291
3309
|
"onFocus": event => {
|
|
3292
|
-
var _portalContext$value8;
|
|
3293
3310
|
if (modal.value) {
|
|
3294
3311
|
enqueueFocus(getTabbableElements()[0]);
|
|
3295
|
-
} else if (
|
|
3296
|
-
var _portalContext$
|
|
3312
|
+
} else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) {
|
|
3313
|
+
var _portalContext$portal4;
|
|
3297
3314
|
if (closeOnFocusOut.value) {
|
|
3298
3315
|
preventReturnFocusRef.value = true;
|
|
3299
3316
|
}
|
|
3300
|
-
if (isOutsideEvent(event, (_portalContext$
|
|
3317
|
+
if (isOutsideEvent(event, (_portalContext$portal4 = portalContext.portalNode) != null ? _portalContext$portal4 : undefined)) {
|
|
3301
3318
|
const prevTabbable = getPreviousTabbable(domReference.value);
|
|
3302
3319
|
prevTabbable == null || prevTabbable.focus();
|
|
3303
3320
|
} else {
|
|
3304
|
-
var _portalContext$
|
|
3305
|
-
(_portalContext$
|
|
3321
|
+
var _portalContext$afterO;
|
|
3322
|
+
(_portalContext$afterO = portalContext.afterOutsideRef.value) == null || _portalContext$afterO.focus();
|
|
3306
3323
|
}
|
|
3307
3324
|
}
|
|
3308
3325
|
}
|