@astryx-vue/core 0.39.0 → 0.40.0
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/AlertDialog/index.js +1 -1
- package/dist/{AlertDialog-DnylRSpj.js → AlertDialog-McG6w72O.js} +4 -4
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/Banner/index.d.ts +1 -1
- package/dist/Banner/index.js +1 -1
- package/dist/{Banner-CqIYLEcx.js → Banner-CmWBciT7.js} +1 -1
- package/dist/BottomSheet/index.d.ts +1 -1
- package/dist/BottomSheet/index.js +2 -2
- package/dist/BottomSheet-BOEmV4QT.js +527 -0
- package/dist/{BottomSheet-D37eNqz5.js → BottomSheet-BkBRbF1_.js} +1379 -192
- package/dist/Breadcrumbs/index.js +1 -1
- package/dist/{Breadcrumbs-BEzCPnoe.js → Breadcrumbs-D7dac2Vx.js} +1 -1
- package/dist/Button/index.d.ts +1 -1
- package/dist/Button/index.js +1 -1
- package/dist/{Button-DGIfLwqj.js → Button-pAwKXPpg.js} +1 -1
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/ButtonGroup/index.js +1 -1
- package/dist/{ButtonGroup-CaQ7bir4.js → ButtonGroup-CuxHcLGQ.js} +2 -2
- package/dist/Calendar/index.d.ts +1 -1
- package/dist/Carousel/index.d.ts +1 -1
- package/dist/Carousel/index.js +1 -1
- package/dist/{Carousel-DmeW51vC.js → Carousel-CS2e2A7m.js} +1 -1
- package/dist/Chat/index.d.ts +1 -1
- package/dist/Chat/index.js +1 -1
- package/dist/{Chat-whrqE8Zj.js → Chat-BpZRcgDp.js} +1 -1
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxInput/index.js +1 -1
- package/dist/{CheckboxInput-CHO4Jz0m.js → CheckboxInput-DhacWPUS.js} +2 -2
- package/dist/CheckboxList/index.d.ts +1 -1
- package/dist/CheckboxList/index.js +1 -1
- package/dist/{CheckboxListItem-C4dmrC_w.js → CheckboxListItem-D7PdrL6R.js} +3 -3
- package/dist/ClickableCard/index.d.ts +1 -1
- package/dist/Code/index.js +2 -2
- package/dist/{Code-D80SHrJx.js → Code-CpOHgCdF.js} +1 -1
- package/dist/{CodeBlock-vhMVY90M.js → CodeBlock-CkGp6dGF.js} +1 -1
- package/dist/CommandPalette/index.js +1 -1
- package/dist/{CommandPalette-C-iXk7EB.js → CommandPalette-DiM8MlSa.js} +1 -1
- package/dist/ComplexSelector/index.d.ts +1 -1
- package/dist/ComplexSelector/index.js +1 -1
- package/dist/{ComplexSelector-BsdtBmd0.js → ComplexSelector-BmXhD8Oe.js} +2 -2
- package/dist/ContextMenu/index.d.ts +1 -1
- package/dist/ContextMenu/index.js +1 -1
- package/dist/{ContextMenu-GZkN9lf1.js → ContextMenu-DcqcObzD.js} +1 -1
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-Cb6eLrbU.js → DateInput-C3KNWKD5.js} +4 -4
- package/dist/DateRangeInput/index.d.ts +1 -1
- package/dist/DateRangeInput/index.js +1 -1
- package/dist/{DateRangeInput-BUFeQYJ6.js → DateRangeInput-C7qeaG20.js} +3 -3
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.js +1 -1
- package/dist/{DateTimeInput-r-MOwLs4.js → DateTimeInput-L0EZbgPe.js} +5 -5
- package/dist/Dialog/index.js +3 -3
- package/dist/{Dialog-BP2KWnEi.js → Dialog-DLg0POKn.js} +1 -1
- package/dist/{Dialog-BUl1lqE6.js → Dialog-iVqfWx9T.js} +1 -1
- package/dist/{DialogHeader-CPhEYbZ1.js → DialogHeader-B0B8oATV.js} +1 -1
- package/dist/Divider/index.d.ts +1 -1
- package/dist/Drawer/index.d.ts +1 -1
- package/dist/Drawer/index.js +1 -1
- package/dist/{Drawer-C0ntt2L9.js → Drawer-C0x5HNmD.js} +2 -2
- package/dist/DropdownMenu/index.js +1 -1
- package/dist/{DropdownMenu-CSWLdtI4.js → DropdownMenu-pqhotFvD.js} +2 -2
- package/dist/Field/index.js +3 -3
- package/dist/{Field-BYAHZ4s7.js → Field-D3W-qMmn.js} +1 -1
- package/dist/{FieldInfoTip-6IHEEEJL.js → FieldInfoTip-K-cUaCBk.js} +1 -1
- package/dist/{FieldLabel-CHaeZROf.js → FieldLabel-CIe1tEyM.js} +1 -1
- package/dist/FileInput/index.js +1 -1
- package/dist/{FileInput-DD3DvIT0.js → FileInput-Crb5znnx.js} +3 -3
- package/dist/Heading/index.d.ts +1 -1
- package/dist/HoverCard/index.d.ts +1 -1
- package/dist/IconButton/index.js +1 -1
- package/dist/{IconButton-CzU-cz_H.js → IconButton-Cug4YcFk.js} +1 -1
- package/dist/InfoTip/index.d.ts +1 -1
- package/dist/InfoTip/index.js +1 -1
- package/dist/{InfoTip-Ckhg715K.js → InfoTip-Cu4a1mi4.js} +1 -1
- package/dist/{InputClearButton-Btjd5Lnk.js → InputClearButton-CgUhJflI.js} +1 -1
- package/dist/InputGroup/index.js +1 -1
- package/dist/{InputGroup-C388xPHC.js → InputGroup-BRsu7Tbv.js} +1 -1
- package/dist/Lightbox/index.js +1 -1
- package/dist/{Lightbox-CQhmsbhy.js → Lightbox-_RBPOxDZ.js} +1 -1
- package/dist/Link/index.d.ts +1 -1
- package/dist/List/index.d.ts +1 -1
- package/dist/List/index.js +1 -1
- package/dist/{ListItem-BEc2EF1u.js → ListItem-DZwU5RrZ.js} +1 -1
- package/dist/Markdown/index.d.ts +1 -1
- package/dist/Markdown/index.js +1 -1
- package/dist/{Markdown-BkL2wt7F.js → Markdown-CiLkzTFi.js} +1 -1
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-pvuN9vfu.js → MoreMenu-BWuzaT3K.js} +2 -2
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-sD97taHQ.js → MultiSelector-geUPBvlE.js} +3 -3
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/NumberInput/index.js +1 -1
- package/dist/{NumberInput-B3Y_NOui.js → NumberInput--sai94t9.js} +3 -3
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-BJKFuELz.js → Pagination-C10gbfyv.js} +2 -2
- package/dist/{PickerWheel-J5F_ecWb.js → PickerWheel-CpAyp6NS.js} +4 -3
- package/dist/Popover/index.js +1 -1
- package/dist/{Popover-CVZnqsUy.js → Popover-C6_p8KAA.js} +2 -2
- package/dist/PowerSearch/index.d.ts +1 -1
- package/dist/PowerSearch/index.js +1 -1
- package/dist/{PowerSearch-BHTHVINR.js → PowerSearch-D47zbO7s.js} +18 -18
- package/dist/Radio/index.d.ts +1 -1
- package/dist/Radio/index.js +1 -1
- package/dist/{RadioGroup-CvMj98z_.js → RadioGroup-C1VXRBSf.js} +2 -2
- package/dist/RadioList/index.d.ts +1 -1
- package/dist/RadioList/index.js +1 -1
- package/dist/{RadioListItem-CptY2wdB.js → RadioListItem-DrAwYoOz.js} +1 -1
- package/dist/ScrollableArea/index.d.ts +1 -1
- package/dist/SegmentedControl/index.js +1 -1
- package/dist/{SegmentedControl-DMxIY7uq.js → SegmentedControl-D9atngIc.js} +1 -1
- package/dist/SelectableCard/index.d.ts +1 -1
- package/dist/Selector/index.d.ts +1 -1
- package/dist/Selector/index.js +1 -1
- package/dist/{Selector-DhKtSP71.js → Selector-DFTryuh1.js} +2 -2
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +1 -1
- package/dist/{SideNav-DOXNxEIp.js → SideNav-Bjk5ACqf.js} +1 -1
- package/dist/Slider/index.js +1 -1
- package/dist/{Slider-D5GYcH4S.js → Slider-rOwQQK6G.js} +1 -1
- package/dist/Stack/index.d.ts +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-DDHf_9iJ.js → Switch-BBfZ6XqA.js} +2 -2
- package/dist/Table/index.d.ts +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/{Table-B49mlc0R.js → Table-D0yjxm9X.js} +9 -9
- package/dist/Text/index.d.ts +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-BSB5WIpK.js → TextArea-Cr00OL0D.js} +4 -4
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/TextInput/index.js +1 -1
- package/dist/{TextInput-Ck-6Mtbt.js → TextInput-CVfvRHOa.js} +4 -4
- package/dist/Thumbnail/index.js +1 -1
- package/dist/{Thumbnail-Tg50Msul.js → Thumbnail-CJPZ299u.js} +1 -1
- package/dist/{TimeField-CLD_j1tX.js → TimeField-Csp1-lRo.js} +3 -3
- package/dist/TimeInput/index.d.ts +1 -1
- package/dist/TimeInput/index.js +1 -1
- package/dist/{TimeInput-DuijuQMd.js → TimeInput-B4JLpJ2N.js} +2 -2
- package/dist/Timer/index.d.ts +1 -1
- package/dist/Timestamp/index.d.ts +1 -1
- package/dist/Timestamp/index.js +1 -1
- package/dist/{Timestamp-D8fyTuhk.js → Timestamp-BmH-CQ8p.js} +1 -1
- package/dist/Toast/index.js +1 -1
- package/dist/{Toast-51l_F_YA.js → Toast-Cuc1o3ph.js} +3 -5
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/ToggleButton/index.js +1 -1
- package/dist/{ToggleButton-_fEU63Nz.js → ToggleButton-BsAi9ln1.js} +3 -3
- package/dist/Token/index.d.ts +1 -1
- package/dist/Tokenizer/index.d.ts +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-wWybLovw.js → Tokenizer-CXCnZtY3.js} +257 -175
- package/dist/Toolbar/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/TopNav/index.d.ts +1 -1
- package/dist/Typeahead/index.js +1 -1
- package/dist/{Typeahead-DtNM4311.js → Typeahead-Csob3tst.js} +2 -2
- package/dist/composables/index.js +2 -2
- package/dist/{composables-D5840uKi.js → composables-DqaKLASV.js} +1 -1
- package/dist/{index-X4S7_dmq.d.ts → index-BA8exXNP.d.ts} +1 -1
- package/dist/{index-BgT6mH3U.d.ts → index-BB9acgK8.d.ts} +1 -1
- package/dist/{index-EyFu5eSZ.d.ts → index-BFPb14Xj.d.ts} +6 -6
- package/dist/{index-CEdoNcHF.d.ts → index-BfOs5BQj.d.ts} +2 -2
- package/dist/{index-DofC9Rll.d.ts → index-BtqvPjAf.d.ts} +1 -1
- package/dist/{index-waTkqxTz.d.ts → index-C89cIh4E.d.ts} +1 -1
- package/dist/{index-rdwI-mcm.d.ts → index-CtYlR9Cu.d.ts} +1 -1
- package/dist/{index--kbwaSXW.d.ts → index-CuW4AQ7M.d.ts} +1 -1
- package/dist/{index-C8wfe0Mr.d.ts → index-D05JGsT3.d.ts} +1 -1
- package/dist/{index-ZXDolNI1.d.ts → index-DN2b-w3H.d.ts} +50 -50
- package/dist/{index-DYabo8TI.d.ts → index-DPhQZXYw.d.ts} +1 -1
- package/dist/{index-J83fLEyo.d.ts → index-DgNCHxvu.d.ts} +2 -2
- package/dist/{index-DVX2jlTQ.d.ts → index-Ds4dOCSy.d.ts} +7 -4
- package/dist/{index-DXGoFpRN.d.ts → index-LvZ3vP29.d.ts} +1 -1
- package/dist/{index-Bk2SsmEu.d.ts → index-YP5WRwXH.d.ts} +3 -3
- package/dist/index.d.ts +16 -16
- package/dist/index.js +59 -59
- package/dist/{lazyBottomSheet-DUPKYGf1.js → lazyBottomSheet-0H4ih8Oh.js} +1 -1
- package/dist/{modalOutlet-BwR9AAlm.js → modalOutlet-C2nqIYUt.js} +7 -6
- package/dist/{useActionGroupTracking-DB5xIxPW.js → useActionGroupTracking-SVkaaOzz.js} +1 -1
- package/dist/{useInputStatusIcon-DJfhmCiH.js → useInputStatusIcon-CRG-be-K.js} +1 -1
- package/dist/{useTouchHitArea-DvKV21NY.js → useTouchHitArea-BdpeksgK.js} +225 -43
- package/package.json +1 -1
- package/styles/bottom-sheet.css +61 -19
- package/styles/date-input.css +76 -0
- package/styles/tokenizer.css +88 -0
- package/dist/BottomSheet-6W3izQzr.js +0 -203
- package/dist/{index-5FGt4HsB.d.ts → index-BqhgeAT4.d.ts} +1 -1
|
@@ -12,19 +12,17 @@ import { s as springs } from "./springs-B5hVbZta.js";
|
|
|
12
12
|
import { t as VelocityTracker } from "./VelocityTracker-CWqXCLNe.js";
|
|
13
13
|
import { t as resolveSnapPoint } from "./resolveSnapPoint-D1yU-Z-K.js";
|
|
14
14
|
import { t as focusForLastInput } from "./focusReturn-BeSRm0xD.js";
|
|
15
|
-
import { t as useFocusTrap } from "./useFocusTrap-Bj9GskLh.js";
|
|
16
15
|
import { t as rubberBand } from "./rubberBand-C-2erWWl.js";
|
|
17
|
-
import { t as useRestoreFocus } from "./useRestoreFocus-m3rsqE4d.js";
|
|
18
16
|
import { t as attachScrollKeyboardDelegation } from "./scrollKeyboardDelegation-DZ4t5PvC.js";
|
|
19
17
|
import { t as useScrollLock } from "./scrollLock-CoVg9lLU.js";
|
|
20
18
|
import { n as restoreLayerFocus, r as trackLayerFocus, t as isLayerFocusStranded } from "./layerFocusReturn-uixUCSc8.js";
|
|
21
|
-
import { t as
|
|
19
|
+
import { i as removeModalOutlet, r as notifyTopLayerEntry, t as addModalOutlet } from "./modalOutlet-C2nqIYUt.js";
|
|
22
20
|
import { o as provideLayoutContainer } from "./context-D-Hwh-Jf.js";
|
|
23
21
|
import { t as useScrollbars } from "./useScrollbars-Ch0xqJWO.js";
|
|
24
22
|
import { t as useMobileKeyboard } from "./useMobileKeyboard-Cibxl8ZC.js";
|
|
25
23
|
import { t as waitForTransition } from "./sheetTransition-BEm1GCv1.js";
|
|
26
24
|
import { t as bottomSheetEscapeKey } from "./escape-DzSxSmez.js";
|
|
27
|
-
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, getCurrentInstance, inject, mergeModels, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, onScopeDispose, onUpdated, openBlock, provide, ref, renderSlot, shallowRef, toValue, unref, useAttrs, useModel, useTemplateRef, watch, withCtx } from "vue";
|
|
25
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, getCurrentInstance, inject, mergeModels, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, onScopeDispose, onUpdated, openBlock, provide, ref, renderSlot, shallowRef, toValue, unref, useAttrs, useModel, useTemplateRef, watch, withCtx } from "vue";
|
|
28
26
|
import "../styles/bottom-sheet.css";
|
|
29
27
|
//#region \0rolldown/runtime.js
|
|
30
28
|
var __defProp = Object.defineProperty;
|
|
@@ -132,6 +130,19 @@ function holdKeptInside(layer, until) {
|
|
|
132
130
|
return release;
|
|
133
131
|
}
|
|
134
132
|
//#endregion
|
|
133
|
+
//#region src/BottomSheet/panelState.ts
|
|
134
|
+
/** 某个状态下面板正在走的动作;静止就是 `null`。 */
|
|
135
|
+
function motionForPanelState(state, retainedMotion) {
|
|
136
|
+
if (state === "open") return "entering";
|
|
137
|
+
if (state === "exiting") return "exiting";
|
|
138
|
+
if (state === "retained") return retainedMotion === "covered" ? null : retainedMotion;
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
/** 公开的动作事件只有进场和退场。 */
|
|
142
|
+
function isPublicMotion(motion) {
|
|
143
|
+
return motion === "entering" || motion === "exiting";
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
135
146
|
//#region src/BottomSheet/sheetDragExit.ts
|
|
136
147
|
/** How many more frames a drag's close looks for its scrim's fade to adopt. */
|
|
137
148
|
const MAX_SCRIM_FADE_ADOPT_FRAMES = 3;
|
|
@@ -1200,26 +1211,29 @@ function useSheetReserve(isPresented, isSized) {
|
|
|
1200
1211
|
}
|
|
1201
1212
|
//#endregion
|
|
1202
1213
|
//#region src/BottomSheet/BottomSheetPanel.vue
|
|
1203
|
-
const _hoisted_1$
|
|
1214
|
+
const _hoisted_1$2 = [
|
|
1204
1215
|
"data-state",
|
|
1216
|
+
"data-motion",
|
|
1205
1217
|
"data-height",
|
|
1206
1218
|
"data-dragging",
|
|
1207
1219
|
"data-reconciling",
|
|
1208
1220
|
"data-exit"
|
|
1209
1221
|
];
|
|
1210
|
-
const _hoisted_2$
|
|
1222
|
+
const _hoisted_2$2 = [
|
|
1211
1223
|
"data-keyboard",
|
|
1212
1224
|
"tabindex",
|
|
1213
1225
|
"role",
|
|
1214
1226
|
"aria-label"
|
|
1215
1227
|
];
|
|
1216
|
-
const _hoisted_3$
|
|
1228
|
+
const _hoisted_3$2 = ["data-padding"];
|
|
1217
1229
|
const MOBILE_KEYBOARD_BOTTOM_CLEARANCE = 48;
|
|
1218
|
-
const _sfc_main$
|
|
1230
|
+
const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
1219
1231
|
name: "AstryxBottomSheetPanel",
|
|
1220
1232
|
__name: "BottomSheetPanel",
|
|
1221
1233
|
props: {
|
|
1222
1234
|
state: {},
|
|
1235
|
+
retainedMotion: { default: "covered" },
|
|
1236
|
+
alignmentOffset: { default: 0 },
|
|
1223
1237
|
label: {},
|
|
1224
1238
|
height: { default: "capped" },
|
|
1225
1239
|
padding: { default: void 0 },
|
|
@@ -1257,6 +1271,9 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
1257
1271
|
const content = useTemplateRef("content");
|
|
1258
1272
|
useScrollbars(body);
|
|
1259
1273
|
const isInteractive = computed(() => props.state === "open");
|
|
1274
|
+
const isRetained = computed(() => props.state === "retained");
|
|
1275
|
+
const motion = computed(() => motionForPanelState(props.state, props.retainedMotion));
|
|
1276
|
+
const retainedOffset = computed(() => isRetained.value && !defaultPrefersReducedMotion() ? props.alignmentOffset : 0);
|
|
1260
1277
|
const attrs = useAttrs();
|
|
1261
1278
|
const reserve = useSheetReserve(computed(() => props.state !== "hidden"), () => isSizedByCaller(attrs));
|
|
1262
1279
|
const heightKind = computed(() => {
|
|
@@ -1312,6 +1329,11 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
1312
1329
|
if (isInteractive.value) {
|
|
1313
1330
|
style.transform = gestures.panelTransform.value;
|
|
1314
1331
|
style.height = gestures.panelHeight.value;
|
|
1332
|
+
} else if (isRetained.value) {
|
|
1333
|
+
style.height = gestures.panelHeight.value;
|
|
1334
|
+
const offset = retainedOffset.value;
|
|
1335
|
+
if (offset > 0) style.transform = [gestures.panelTransform.value, `translateY(${offset}px)`].filter(Boolean).join(" ");
|
|
1336
|
+
else style.transform = gestures.panelTransform.value;
|
|
1315
1337
|
} else if (props.state === "exiting") {
|
|
1316
1338
|
style.height = gestures.panelHeight.value;
|
|
1317
1339
|
if (holdsDragClose.value) style.transform = gestures.panelTransform.value ?? "translateY(0px)";
|
|
@@ -1326,13 +1348,18 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
1326
1348
|
let cancelMotionWait = null;
|
|
1327
1349
|
/** The element a swipe's close moved on the animator, until the sheet is hidden. */
|
|
1328
1350
|
let dragExitElement = null;
|
|
1329
|
-
function waitForMotion(motion) {
|
|
1351
|
+
function waitForMotion(motion, isReactivated) {
|
|
1330
1352
|
cancelMotionWait?.();
|
|
1331
1353
|
emit("motionStart", motion);
|
|
1332
1354
|
const complete = () => {
|
|
1333
1355
|
cancelMotionWait = null;
|
|
1334
1356
|
emit("motionComplete", motion);
|
|
1335
1357
|
};
|
|
1358
|
+
if (motion === "entering" && isReactivated) {
|
|
1359
|
+
cancelMotionWait = null;
|
|
1360
|
+
complete();
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1336
1363
|
const element = panel.value;
|
|
1337
1364
|
const exit = playedDragExit.value;
|
|
1338
1365
|
if (motion === "exiting" && exit != null && element != null) {
|
|
@@ -1343,17 +1370,17 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
1343
1370
|
});
|
|
1344
1371
|
return;
|
|
1345
1372
|
}
|
|
1346
|
-
const property = motion === "exiting" && isCrossFade.value ? "opacity" : "transform";
|
|
1373
|
+
const property = motion === "fading" || motion === "exiting" && isCrossFade.value ? "opacity" : "transform";
|
|
1347
1374
|
cancelMotionWait = waitForTransition(element, property, complete);
|
|
1348
1375
|
}
|
|
1349
|
-
watch(() => props.state, (state) => {
|
|
1350
|
-
if (
|
|
1351
|
-
|
|
1376
|
+
watch(() => [motion.value, props.state], ([next, state], [previous, previousState]) => {
|
|
1377
|
+
if (next != null) {
|
|
1378
|
+
if (next !== previous) waitForMotion(next, previousState === "retained");
|
|
1352
1379
|
return;
|
|
1353
1380
|
}
|
|
1354
1381
|
cancelMotionWait?.();
|
|
1355
1382
|
cancelMotionWait = null;
|
|
1356
|
-
if (dragExitElement != null) {
|
|
1383
|
+
if (state === "hidden" && dragExitElement != null) {
|
|
1357
1384
|
resetDragExit(dragExitElement);
|
|
1358
1385
|
dragExitElement = null;
|
|
1359
1386
|
}
|
|
@@ -1379,6 +1406,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
1379
1406
|
ref: panel,
|
|
1380
1407
|
class: "astryx-bottom-sheet astryx-layer",
|
|
1381
1408
|
"data-state": __props.state,
|
|
1409
|
+
"data-motion": isRetained.value ? __props.retainedMotion : void 0,
|
|
1382
1410
|
"data-height": heightKind.value,
|
|
1383
1411
|
"data-dragging": unref(gestures).isDragging.value || void 0,
|
|
1384
1412
|
"data-reconciling": unref(gestures).isReconciling.value || void 0,
|
|
@@ -1404,7 +1432,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
1404
1432
|
ref: content,
|
|
1405
1433
|
class: "astryx-bottom-sheet__content",
|
|
1406
1434
|
"data-padding": __props.padding
|
|
1407
|
-
}, [renderSlot(_ctx.$slots, "default")], 8, _hoisted_3$
|
|
1435
|
+
}, [renderSlot(_ctx.$slots, "default")], 8, _hoisted_3$2)], 44, _hoisted_2$2)], 12, _hoisted_1$2);
|
|
1408
1436
|
};
|
|
1409
1437
|
}
|
|
1410
1438
|
});
|
|
@@ -1426,24 +1454,1260 @@ function focusFirstEligibleAutofocus(panel) {
|
|
|
1426
1454
|
return false;
|
|
1427
1455
|
}
|
|
1428
1456
|
/**
|
|
1429
|
-
*
|
|
1457
|
+
* 把焦点送进面板。
|
|
1430
1458
|
*
|
|
1431
|
-
*
|
|
1432
|
-
*
|
|
1433
|
-
*
|
|
1459
|
+
* 被盖住的面板(对话框 inert 或对读屏隐藏)不接焦点:人还留在最上面那张里。
|
|
1460
|
+
* `reveal`(上面那张关了露出这一张),以及 `replace` 时焦点已经在里面某个控件上,焦点都不动。
|
|
1461
|
+
* `open` 和 `replace` 时原生对话框已经按自己的规矩聚焦过(Chromium 落在面板上,Firefox 落在第一个控件上),
|
|
1462
|
+
* 那不是使用者的选择:只要有可聚焦的 `data-autofocus` 元素,它就盖过原生的落点。没有的话,
|
|
1463
|
+
* `open` 保留原生落点,焦点不在里面且这一层是模态的才落到面板上;`replace` 落到进场的面板上。
|
|
1464
|
+
* `reveal` 由面板自己接住焦点,焦点环只在上一次是键盘时才画。
|
|
1434
1465
|
*/
|
|
1435
|
-
function
|
|
1466
|
+
function focusSheetPanel(panel, reason, isModal) {
|
|
1436
1467
|
if (panel == null) return;
|
|
1468
|
+
const host = panel.closest("dialog");
|
|
1469
|
+
if (host != null && (host.hasAttribute("inert") || host.getAttribute("aria-hidden") === "true")) return;
|
|
1437
1470
|
const active = panel.ownerDocument.activeElement;
|
|
1438
|
-
const isInsidePanel = active != null && panel.contains(active) && active.closest("dialog") ===
|
|
1439
|
-
if (isInsidePanel &&
|
|
1440
|
-
if (
|
|
1441
|
-
|
|
1471
|
+
const isInsidePanel = active != null && panel.contains(active) && active.closest("dialog") === host;
|
|
1472
|
+
if (isInsidePanel && (reason === "reveal" || reason === "replace" && active !== panel)) return;
|
|
1473
|
+
if (reason === "reveal") {
|
|
1474
|
+
focusForLastInput(panel, { preventScroll: true });
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
if (isInsidePanel && active.hasAttribute("data-autofocus") || focusFirstEligibleAutofocus(panel)) return;
|
|
1478
|
+
if (!isInsidePanel && (isModal || reason === "replace")) panel.focus({ preventScroll: true });
|
|
1479
|
+
}
|
|
1480
|
+
//#endregion
|
|
1481
|
+
//#region src/BottomSheet/sheetHostContext.ts
|
|
1482
|
+
const bottomSheetHostKey = Symbol("astryx-bottom-sheet-host");
|
|
1483
|
+
//#endregion
|
|
1484
|
+
//#region src/BottomSheet/stack/stackState.ts
|
|
1485
|
+
const BOTTOM_SHEET_STACK_DEFAULT_VIEW = Object.freeze({
|
|
1486
|
+
isStacked: false,
|
|
1487
|
+
isTop: false,
|
|
1488
|
+
isCovered: false,
|
|
1489
|
+
depth: 0,
|
|
1490
|
+
ownsScrim: false,
|
|
1491
|
+
isScrimHandoff: false,
|
|
1492
|
+
isBlocked: false,
|
|
1493
|
+
isScrimTakenOver: false,
|
|
1494
|
+
replacedMotion: null,
|
|
1495
|
+
alignmentOffset: 0,
|
|
1496
|
+
isReplacing: false
|
|
1497
|
+
});
|
|
1498
|
+
const STACK_PROTOCOL_VERSION = 1;
|
|
1499
|
+
const STACK_STATE_KEY = Symbol.for(`astryx-vue.bottomSheetStack.v${STACK_PROTOCOL_VERSION}`);
|
|
1500
|
+
function createStackState() {
|
|
1501
|
+
return {
|
|
1502
|
+
shape: STACK_PROTOCOL_VERSION,
|
|
1503
|
+
entries: [],
|
|
1504
|
+
shownOrder: /* @__PURE__ */ new WeakMap(),
|
|
1505
|
+
listenedDocuments: /* @__PURE__ */ new WeakMap(),
|
|
1506
|
+
batchOpened: [],
|
|
1507
|
+
batchClosed: [],
|
|
1508
|
+
batchActor: null,
|
|
1509
|
+
lastPress: /* @__PURE__ */ new WeakMap(),
|
|
1510
|
+
pendingDrops: [],
|
|
1511
|
+
pendingReplaceFocus: null,
|
|
1512
|
+
batchPair: null,
|
|
1513
|
+
closingTogether: /* @__PURE__ */ new Map(),
|
|
1514
|
+
rankByKey: /* @__PURE__ */ new WeakMap(),
|
|
1515
|
+
currentBatch: 0,
|
|
1516
|
+
nextSeq: 0,
|
|
1517
|
+
isBatchDirty: false,
|
|
1518
|
+
isSealScheduled: false,
|
|
1519
|
+
focusToKeep: /* @__PURE__ */ new WeakMap()
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
function readSharedState() {
|
|
1523
|
+
const holder = globalThis;
|
|
1524
|
+
const shared = holder[STACK_STATE_KEY];
|
|
1525
|
+
if (shared?.shape === STACK_PROTOCOL_VERSION) return shared;
|
|
1526
|
+
const created = createStackState();
|
|
1527
|
+
holder[STACK_STATE_KEY] = created;
|
|
1528
|
+
return created;
|
|
1529
|
+
}
|
|
1530
|
+
const state = readSharedState();
|
|
1531
|
+
function findEntry(key) {
|
|
1532
|
+
return state.entries.find((entry) => entry.key === key);
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* 一次 Vue 更新算一批。宿主都在 post 回调里调登记表,同一次刷新里的调用在同一批;
|
|
1536
|
+
* 刷新结束后的微任务封批,之后的调用就是下一批了。
|
|
1537
|
+
*/
|
|
1538
|
+
function scheduleSeal(seal) {
|
|
1539
|
+
if (state.isSealScheduled) return;
|
|
1540
|
+
state.isSealScheduled = true;
|
|
1541
|
+
queueMicrotask(() => {
|
|
1542
|
+
state.isSealScheduled = false;
|
|
1543
|
+
seal();
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
function compareRank(a, b) {
|
|
1547
|
+
if (a.rank.batch !== b.rank.batch) return a.rank.batch - b.rank.batch;
|
|
1548
|
+
const aEl = a.getTreeAnchor?.() ?? a.getElement();
|
|
1549
|
+
const bEl = b.getTreeAnchor?.() ?? b.getElement();
|
|
1550
|
+
if (aEl != null && bEl != null && aEl !== bEl) {
|
|
1551
|
+
const position = aEl.compareDocumentPosition(bEl);
|
|
1552
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
|
|
1553
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;
|
|
1554
|
+
}
|
|
1555
|
+
return a.rank.seq - b.rank.seq;
|
|
1556
|
+
}
|
|
1557
|
+
/** 一组(document + 是否模态)的面板,从下到上。 */
|
|
1558
|
+
function sortedEntries(doc, isModal) {
|
|
1559
|
+
return state.entries.filter((entry) => entry.doc === doc && entry.isModal === isModal).sort(compareRank);
|
|
1560
|
+
}
|
|
1561
|
+
function groupOf(entry) {
|
|
1562
|
+
return sortedEntries(entry.doc, entry.isModal);
|
|
1563
|
+
}
|
|
1564
|
+
function getShownOrder(doc, isModal) {
|
|
1565
|
+
const orders = state.shownOrder.get(doc);
|
|
1566
|
+
if (orders == null) return [];
|
|
1567
|
+
return isModal ? orders.modal : orders.nonModal;
|
|
1568
|
+
}
|
|
1569
|
+
function setShownOrder(doc, isModal, order) {
|
|
1570
|
+
const orders = state.shownOrder.get(doc) ?? {
|
|
1571
|
+
modal: [],
|
|
1572
|
+
nonModal: []
|
|
1573
|
+
};
|
|
1574
|
+
if (isModal) orders.modal = order;
|
|
1575
|
+
else orders.nonModal = order;
|
|
1576
|
+
state.shownOrder.set(doc, orders);
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* 记下每个 document 最近一次按压:pointerdown、click(指针、键盘激活、代码触发都会有)、keydown。
|
|
1580
|
+
* 捕获阶段监听,每个 document 一套,随第一张登记的面板装上,最后一张离开时拆掉。
|
|
1581
|
+
*/
|
|
1582
|
+
function listenForPresses(doc) {
|
|
1583
|
+
if (state.listenedDocuments.has(doc)) return;
|
|
1584
|
+
const record = (event) => {
|
|
1585
|
+
if (event.target instanceof Element) state.lastPress.set(doc, {
|
|
1586
|
+
target: new WeakRef(event.target),
|
|
1587
|
+
at: Date.now()
|
|
1588
|
+
});
|
|
1589
|
+
};
|
|
1590
|
+
doc.addEventListener("pointerdown", record, true);
|
|
1591
|
+
doc.addEventListener("click", record, true);
|
|
1592
|
+
doc.addEventListener("keydown", record, true);
|
|
1593
|
+
state.listenedDocuments.set(doc, () => {
|
|
1594
|
+
doc.removeEventListener("pointerdown", record, true);
|
|
1595
|
+
doc.removeEventListener("click", record, true);
|
|
1596
|
+
doc.removeEventListener("keydown", record, true);
|
|
1597
|
+
state.lastPress.delete(doc);
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
function stopListeningForPresses(doc) {
|
|
1601
|
+
if (state.entries.some((entry) => entry.doc === doc)) return;
|
|
1602
|
+
const remove = state.listenedDocuments.get(doc);
|
|
1603
|
+
if (remove != null) {
|
|
1604
|
+
state.listenedDocuments.delete(doc);
|
|
1605
|
+
remove();
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* 按压只在新鲜时算数:按钮的处理函数在同一个任务里几毫秒后就翻转面板。
|
|
1610
|
+
* 晚到的翻转(保存完成后才换步骤)不算那次按压干的,改看焦点。
|
|
1611
|
+
* 按压落在的面板已经关了或被替换了,这次按压也作废。
|
|
1612
|
+
*/
|
|
1613
|
+
const PRESS_ACTOR_WINDOW_MS = 1e3;
|
|
1614
|
+
function isPressSpent(target, flipping) {
|
|
1615
|
+
const owning = state.entries.find((entry) => {
|
|
1616
|
+
const element = entry.getElement();
|
|
1617
|
+
return entry.doc === flipping.doc && element != null && element.contains(target);
|
|
1618
|
+
});
|
|
1619
|
+
if (owning == null || owning === flipping) return false;
|
|
1620
|
+
return !owning.isOpen || owning.replace != null;
|
|
1621
|
+
}
|
|
1622
|
+
function actorFor(doc, flipping) {
|
|
1623
|
+
const press = state.lastPress.get(doc);
|
|
1624
|
+
const target = press?.target.deref();
|
|
1625
|
+
if (press != null && target != null && target.isConnected && Date.now() - press.at <= PRESS_ACTOR_WINDOW_MS && !isPressSpent(target, flipping)) return target;
|
|
1626
|
+
return doc.activeElement;
|
|
1627
|
+
}
|
|
1628
|
+
/** 记一次本批的翻转;是本批第一次时顺便记下是谁动的手。 */
|
|
1629
|
+
function recordFlip(entry, flip) {
|
|
1630
|
+
if (state.batchOpened.length === 0 && state.batchClosed.length === 0) state.batchActor = actorFor(entry.doc, entry);
|
|
1631
|
+
(flip === "opened" ? state.batchOpened : state.batchClosed).push(entry);
|
|
1632
|
+
}
|
|
1633
|
+
//#endregion
|
|
1634
|
+
//#region src/BottomSheet/stack/sheetHost.ts
|
|
1635
|
+
/**
|
|
1636
|
+
* 面板宿主对话框的原生呈现、收起和遮罩写入。叠放登记表和切换器共用。
|
|
1637
|
+
*/
|
|
1638
|
+
/** 对话框现在是否被浏览器呈现着:模态打开、`show()` 打开或者作为手动 popover 打开。 */
|
|
1639
|
+
function isSheetHostPresented(dialog) {
|
|
1640
|
+
if (dialog == null) return false;
|
|
1641
|
+
if (dialog.open) return true;
|
|
1642
|
+
try {
|
|
1643
|
+
return dialog.matches(":popover-open");
|
|
1644
|
+
} catch {
|
|
1645
|
+
return false;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* 以模态呈现切换器某一步的对话框,而且不留「关闭时要还焦点」的记录。
|
|
1650
|
+
*
|
|
1651
|
+
* `showModal()` 会记下当时有焦点的元素,`close()` 时把焦点送回去,哪怕焦点那时已在别的对话框里。
|
|
1652
|
+
* 对一步来说那个元素是推动流程的按钮(继续、返回)或者流程的打开者,而这个对话框要在人进到下一步
|
|
1653
|
+
* 之后才关:送回去会把焦点从当前面板上拽走。所以先让焦点离开,什么都不记;进场的那一步自己聚焦,
|
|
1654
|
+
* 流程结束时切换器自己把焦点还给打开者。
|
|
1655
|
+
*/
|
|
1656
|
+
function presentStepModally(dialog) {
|
|
1657
|
+
const doc = dialog.ownerDocument;
|
|
1658
|
+
const focused = doc.activeElement;
|
|
1659
|
+
if (focused instanceof HTMLElement && focused !== doc.body) {
|
|
1660
|
+
const focusedDialog = focused.closest("dialog");
|
|
1661
|
+
if (focusedDialog != null && focusedDialog !== dialog && !focusedDialog.contains(dialog) && !dialog.contains(focusedDialog) && isSheetHostPresented(focusedDialog)) state.focusToKeep.set(doc, focused);
|
|
1662
|
+
focused.blur();
|
|
1663
|
+
}
|
|
1664
|
+
dialog.showModal();
|
|
1665
|
+
}
|
|
1666
|
+
/** 呈现一个遮罩必须一开始就透明、并且保持透明的对话框:先钉住 0s 过渡写好透明度,样式生效后再放开。 */
|
|
1667
|
+
function presentWithClearScrim(dialog) {
|
|
1668
|
+
dialog.style.setProperty("--_sheet-scrim-duration", "0s");
|
|
1669
|
+
dialog.style.setProperty("--_sheet-scrim-opacity", "0");
|
|
1670
|
+
presentStepModally(dialog);
|
|
1671
|
+
if (typeof getComputedStyle === "function") getComputedStyle(dialog, "::backdrop").opacity;
|
|
1672
|
+
dialog.style.removeProperty("--_sheet-scrim-duration");
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* 写对话框的遮罩透明度。对话框开着时改透明度就是换了遮罩的主人,要完全不带过渡:
|
|
1676
|
+
* 哪怕 `0.01s` 也会先画一帧旧值,看起来就是闪一下或者两层叠暗。`0s` 钉两帧(第一帧画出新值,
|
|
1677
|
+
* 第二帧确认已经上屏)再还给样式表的时长。宿主卸载时用 `cancelScrimWrite` 取消。
|
|
1678
|
+
*/
|
|
1679
|
+
function writeScrimOpacity(dialog, opacity, pending) {
|
|
1680
|
+
if (dialog == null) return;
|
|
1681
|
+
if (!dialog.open || dialog.style.getPropertyValue("--_sheet-scrim-opacity") === opacity) {
|
|
1682
|
+
dialog.style.setProperty("--_sheet-scrim-opacity", opacity);
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
dialog.style.setProperty("--_sheet-scrim-duration", "0s");
|
|
1686
|
+
dialog.style.setProperty("--_sheet-scrim-opacity", opacity);
|
|
1687
|
+
cancelScrimWrite(pending);
|
|
1688
|
+
if (typeof requestAnimationFrame !== "function") {
|
|
1689
|
+
dialog.style.removeProperty("--_sheet-scrim-duration");
|
|
1690
|
+
return;
|
|
1691
|
+
}
|
|
1692
|
+
pending.frame = requestAnimationFrame(() => {
|
|
1693
|
+
pending.frame = requestAnimationFrame(() => {
|
|
1694
|
+
pending.frame = null;
|
|
1695
|
+
dialog.style.removeProperty("--_sheet-scrim-duration");
|
|
1696
|
+
});
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
function cancelScrimWrite(pending) {
|
|
1700
|
+
if (pending.frame != null) {
|
|
1701
|
+
cancelAnimationFrame(pending.frame);
|
|
1702
|
+
pending.frame = null;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
/** 离开原生宿主。 */
|
|
1706
|
+
function hideSheetHost(dialog) {
|
|
1707
|
+
if (dialog.open) dialog.close();
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* 关掉对话框但不让浏览器挪焦点。`close()` 会把焦点还给 `showModal()` 时有焦点的元素;
|
|
1711
|
+
* 上面还有别的面板开着时,那会把焦点从人正在用的面板里拽走。焦点原地不动,接下来去哪由调用方决定。
|
|
1712
|
+
*/
|
|
1713
|
+
function closeDialogKeepingFocus(dialog) {
|
|
1714
|
+
if (dialog == null || !isSheetHostPresented(dialog)) return;
|
|
1715
|
+
const doc = dialog.ownerDocument;
|
|
1716
|
+
const activeElement = doc.activeElement;
|
|
1717
|
+
hideSheetHost(dialog);
|
|
1718
|
+
if (doc.activeElement !== activeElement && activeElement instanceof HTMLElement && activeElement.isConnected) activeElement.focus({ preventScroll: true });
|
|
1719
|
+
}
|
|
1720
|
+
/** 像关闭时浏览器自己还焦点那样还给 `target`,不滚页面;焦点环跟着上一次的输入走。 */
|
|
1721
|
+
function returnFocusTo(target) {
|
|
1722
|
+
if (target != null && target.isConnected) focusForLastInput(target, { preventScroll: true });
|
|
1723
|
+
}
|
|
1724
|
+
//#endregion
|
|
1725
|
+
//#region src/BottomSheet/stack/stackPresentation.ts
|
|
1726
|
+
/**
|
|
1727
|
+
* 宿主按叠放视图写到对话框上的东西:`data-sheet-stack` 属性、后退的类名、遮罩透明度。
|
|
1728
|
+
* 独立面板和切换器的每一步共用。
|
|
1729
|
+
*/
|
|
1730
|
+
/** 宿主的 `data-sheet-stack` 值:只在叠放时才有。 */
|
|
1731
|
+
function stackStateAttribute(view, isOpen) {
|
|
1732
|
+
if (!view.isStacked) return void 0;
|
|
1733
|
+
if (!isOpen) return view.replacedMotion != null ? "replaced" : "exiting";
|
|
1734
|
+
return view.isTop ? "top" : "covered";
|
|
1735
|
+
}
|
|
1736
|
+
/** 叠放后退用的类名:叠放期间一直挂着过渡,回来时也有动画。 */
|
|
1737
|
+
function stackRecedeClasses(view) {
|
|
1738
|
+
return {
|
|
1739
|
+
"astryx-bottom-sheet-stack-motion": view.isStacked,
|
|
1740
|
+
"astryx-bottom-sheet-stack-receded-1": view.depth === 1,
|
|
1741
|
+
"astryx-bottom-sheet-stack-receded-2": view.depth >= 2
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
/** 打开的模态面板的遮罩透明度:一叠只有一层可见的遮罩。 */
|
|
1745
|
+
function scrimOpacityForView(view) {
|
|
1746
|
+
return view.isStacked && !view.ownsScrim ? "0" : "1";
|
|
1747
|
+
}
|
|
1748
|
+
/**
|
|
1749
|
+
* 把手指拖动关闭时遮罩跟着走的淡出写到对话框上,`fade` 为 `null` 时清掉。`written` 记着自己写的时长,
|
|
1750
|
+
* 清的时候只清自己那份:叠放交接写的 `0s` 要留着。
|
|
1751
|
+
*/
|
|
1752
|
+
function writeScrimFade(dialog, fade, written) {
|
|
1753
|
+
if (dialog == null) return;
|
|
1754
|
+
const current = dialog.style.getPropertyValue("--_sheet-scrim-duration");
|
|
1755
|
+
if (fade == null) {
|
|
1756
|
+
if (written.current != null && current === written.current) {
|
|
1757
|
+
dialog.style.removeProperty("--_sheet-scrim-duration");
|
|
1758
|
+
dialog.style.removeProperty("--_sheet-scrim-easing");
|
|
1759
|
+
}
|
|
1760
|
+
written.current = null;
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
if (current === "0s") return;
|
|
1764
|
+
written.current = `${fade.durationMs}ms`;
|
|
1765
|
+
dialog.style.setProperty("--_sheet-scrim-duration", written.current);
|
|
1766
|
+
dialog.style.setProperty("--_sheet-scrim-easing", fade.easing);
|
|
1442
1767
|
}
|
|
1443
1768
|
//#endregion
|
|
1444
1769
|
//#region src/BottomSheet/switcher.ts
|
|
1445
1770
|
const bottomSheetSwitcherKey = Symbol("astryx-bottom-sheet-switcher");
|
|
1446
1771
|
//#endregion
|
|
1772
|
+
//#region src/BottomSheet/BottomSheetStep.vue
|
|
1773
|
+
const _hoisted_1$1 = [
|
|
1774
|
+
"data-settled",
|
|
1775
|
+
"aria-label",
|
|
1776
|
+
"aria-modal",
|
|
1777
|
+
"aria-hidden",
|
|
1778
|
+
"inert",
|
|
1779
|
+
"data-sheet-stack",
|
|
1780
|
+
"data-sheet-stack-depth",
|
|
1781
|
+
"role"
|
|
1782
|
+
];
|
|
1783
|
+
const _hoisted_2$1 = [
|
|
1784
|
+
"hidden",
|
|
1785
|
+
"aria-hidden",
|
|
1786
|
+
"inert"
|
|
1787
|
+
];
|
|
1788
|
+
const _hoisted_3$1 = {
|
|
1789
|
+
key: 0,
|
|
1790
|
+
class: "astryx-bottom-sheet__edge-tint",
|
|
1791
|
+
"aria-hidden": "true"
|
|
1792
|
+
};
|
|
1793
|
+
const _hoisted_4$1 = {
|
|
1794
|
+
ref: "layerHost",
|
|
1795
|
+
class: "astryx-bottom-sheet__layer-host"
|
|
1796
|
+
};
|
|
1797
|
+
/** 切换器里的一步:自己有一个原生 dialog,什么时候呈现、什么时候关由切换器决定。 */
|
|
1798
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
1799
|
+
name: "AstryxBottomSheetStep",
|
|
1800
|
+
inheritAttrs: false,
|
|
1801
|
+
__name: "BottomSheetStep",
|
|
1802
|
+
props: {
|
|
1803
|
+
switcher: {},
|
|
1804
|
+
sheetId: {},
|
|
1805
|
+
label: {},
|
|
1806
|
+
height: {},
|
|
1807
|
+
padding: {},
|
|
1808
|
+
snapPoints: {},
|
|
1809
|
+
purpose: {}
|
|
1810
|
+
},
|
|
1811
|
+
emits: [
|
|
1812
|
+
"snap",
|
|
1813
|
+
"motionStart",
|
|
1814
|
+
"motionComplete"
|
|
1815
|
+
],
|
|
1816
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1817
|
+
const props = __props;
|
|
1818
|
+
const emit = __emit;
|
|
1819
|
+
const attrs = useAttrs();
|
|
1820
|
+
const dialog = useTemplateRef("dialog");
|
|
1821
|
+
const panel = useTemplateRef("panel");
|
|
1822
|
+
provideNestedLayerMountTarget(useTemplateRef("layerHost"));
|
|
1823
|
+
const switcher = props.switcher;
|
|
1824
|
+
const phase = computed(() => switcher.phaseOf(props.sheetId));
|
|
1825
|
+
const isInteractive = computed(() => phase.value === "active" || phase.value === "entering");
|
|
1826
|
+
const isInactive = computed(() => phase.value === "covered" || phase.value === "aligning" || phase.value === "fading" || phase.value === "exiting");
|
|
1827
|
+
const isPresented = computed(() => phase.value !== "hidden");
|
|
1828
|
+
const ownsScrim = computed(() => switcher.isScrimOwner(props.sheetId));
|
|
1829
|
+
const isHost = computed(() => switcher.isHost(props.sheetId));
|
|
1830
|
+
const isSettled = computed(() => isPresented.value && switcher.settledId.value === props.sheetId);
|
|
1831
|
+
const isBlocked = computed(() => isInactive.value || switcher.hasScrim() && switcher.stackView.value.isBlocked);
|
|
1832
|
+
const panelState = computed(() => {
|
|
1833
|
+
if (isInteractive.value) return "open";
|
|
1834
|
+
if (phase.value === "exiting") return "exiting";
|
|
1835
|
+
return isInactive.value ? "retained" : "hidden";
|
|
1836
|
+
});
|
|
1837
|
+
const retainedMotion = computed(() => phase.value === "aligning" || phase.value === "fading" ? phase.value : "covered");
|
|
1838
|
+
provide(bottomSheetSwitcherKey, null);
|
|
1839
|
+
provide(bottomSheetHostKey, { isOpen: isInteractive });
|
|
1840
|
+
provide(bottomSheetEscapeKey, () => true);
|
|
1841
|
+
function register(id) {
|
|
1842
|
+
switcher.register(id, {
|
|
1843
|
+
getDialog: () => dialog.value ?? null,
|
|
1844
|
+
getPanel: () => panel.value?.element ?? null,
|
|
1845
|
+
purpose: () => props.purpose
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
register(props.sheetId);
|
|
1849
|
+
watch(() => props.sheetId, (id, previous) => {
|
|
1850
|
+
switcher.unregister(previous);
|
|
1851
|
+
register(id);
|
|
1852
|
+
});
|
|
1853
|
+
/**
|
|
1854
|
+
* 切换器把这一步留在屏幕上时呈现它自己的对话框,藏起来之后关掉。带遮罩的流程以模态呈现:进场的对话框
|
|
1855
|
+
* 压在被留下的那个上面,被留下的那个等面板淡出后才关。回到一个还在淡出、仍开在更新对话框下面的步骤时,
|
|
1856
|
+
* 重新呈现让它回到最上面:文档被最上面的模态对话框挡住,压在下面的不管切换器怎么说都是 inert。
|
|
1857
|
+
*/
|
|
1858
|
+
let dialogMode = null;
|
|
1859
|
+
function syncDialog() {
|
|
1860
|
+
const element = dialog.value;
|
|
1861
|
+
if (element == null) return;
|
|
1862
|
+
if (!isPresented.value) {
|
|
1863
|
+
if (element.open) element.close();
|
|
1864
|
+
dialogMode = null;
|
|
1865
|
+
switcher.afterStepSync(props.sheetId);
|
|
1866
|
+
return;
|
|
1867
|
+
}
|
|
1868
|
+
const hasScrim = switcher.hasScrim();
|
|
1869
|
+
const nextMode = hasScrim ? "modal" : "non-modal";
|
|
1870
|
+
if (element.open && dialogMode == null && hasScrim) dialogMode = nextMode;
|
|
1871
|
+
if (element.open && dialogMode !== nextMode) element.close();
|
|
1872
|
+
if (element.open && hasScrim && isInteractive.value && switcher.isCoveredInTopLayer(props.sheetId)) element.close();
|
|
1873
|
+
if (!element.open) {
|
|
1874
|
+
switcher.beforePresent(props.sheetId);
|
|
1875
|
+
if (!hasScrim) element.show();
|
|
1876
|
+
else if (ownsScrim.value) presentStepModally(element);
|
|
1877
|
+
else presentWithClearScrim(element);
|
|
1878
|
+
}
|
|
1879
|
+
dialogMode = nextMode;
|
|
1880
|
+
switcher.afterStepSync(props.sheetId);
|
|
1881
|
+
}
|
|
1882
|
+
watch([
|
|
1883
|
+
isPresented,
|
|
1884
|
+
isInteractive,
|
|
1885
|
+
ownsScrim,
|
|
1886
|
+
() => switcher.hasScrim()
|
|
1887
|
+
], syncDialog, { flush: "post" });
|
|
1888
|
+
let hasFocused = false;
|
|
1889
|
+
function syncFocus(interactive, wasInteractive) {
|
|
1890
|
+
if (interactive) {
|
|
1891
|
+
if (!hasFocused || !wasInteractive) focusSheetPanel(panel.value?.element ?? null, "open", switcher.hasScrim());
|
|
1892
|
+
hasFocused = true;
|
|
1893
|
+
} else if (phase.value === "hidden") hasFocused = false;
|
|
1894
|
+
}
|
|
1895
|
+
watch(isInteractive, (interactive, wasInteractive) => syncFocus(interactive, wasInteractive), { flush: "post" });
|
|
1896
|
+
onMounted(() => {
|
|
1897
|
+
syncDialog();
|
|
1898
|
+
syncFocus(isInteractive.value, false);
|
|
1899
|
+
});
|
|
1900
|
+
onBeforeUnmount(() => {
|
|
1901
|
+
if (dialog.value?.open) dialog.value.close();
|
|
1902
|
+
switcher.unregister(props.sheetId);
|
|
1903
|
+
});
|
|
1904
|
+
/** 切换器的 attrs 落到每一步的对话框上;标识一个元素的 `id`、`data-testid` 只在宿主那步上。 */
|
|
1905
|
+
const dialogAttrs = computed(() => isHost.value ? {
|
|
1906
|
+
...switcher.stepAttrs(),
|
|
1907
|
+
...switcher.hostAttrs()
|
|
1908
|
+
} : switcher.stepAttrs());
|
|
1909
|
+
const dialogLabel = computed(() => {
|
|
1910
|
+
const shared = dialogAttrs.value;
|
|
1911
|
+
return shared["aria-label"] ?? (shared["aria-labelledby"] == null ? props.label : void 0);
|
|
1912
|
+
});
|
|
1913
|
+
const dialogRole = computed(() => props.purpose === "required" ? "alertdialog" : dialogAttrs.value.role);
|
|
1914
|
+
function panelAttrs() {
|
|
1915
|
+
const { "aria-label": _label, "aria-labelledby": _labelledBy, ...rest } = attrs;
|
|
1916
|
+
return rest;
|
|
1917
|
+
}
|
|
1918
|
+
const scrimFade = { current: null };
|
|
1919
|
+
function onScrimFade(fade) {
|
|
1920
|
+
writeScrimFade(dialog.value ?? null, fade, scrimFade);
|
|
1921
|
+
}
|
|
1922
|
+
function onDismiss() {
|
|
1923
|
+
if (props.purpose === "info") switcher.requestClose(props.sheetId);
|
|
1924
|
+
}
|
|
1925
|
+
function onMotionStart(motion) {
|
|
1926
|
+
if (isPublicMotion(motion)) emit("motionStart", motion);
|
|
1927
|
+
switcher.onMotionStart(props.sheetId, motion);
|
|
1928
|
+
}
|
|
1929
|
+
function onMotionComplete(motion) {
|
|
1930
|
+
if (isPublicMotion(motion)) emit("motionComplete", motion);
|
|
1931
|
+
switcher.onMotionComplete(props.sheetId, motion);
|
|
1932
|
+
}
|
|
1933
|
+
__expose({ element: computed(() => panel.value?.element ?? null) });
|
|
1934
|
+
return (_ctx, _cache) => {
|
|
1935
|
+
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 点在 dialog 自身上等于点遮罩;键盘走原生 cancel 和下面的 keydown。 "), createElementVNode("dialog", mergeProps({
|
|
1936
|
+
ref_key: "dialog",
|
|
1937
|
+
ref: dialog
|
|
1938
|
+
}, dialogAttrs.value, {
|
|
1939
|
+
class: ["astryx-bottom-sheet-dialog astryx-bottom-sheet-switcher", {
|
|
1940
|
+
"astryx-bottom-sheet-dialog--scrim": unref(switcher).hasScrim(),
|
|
1941
|
+
"astryx-bottom-sheet-dialog--closing": unref(switcher).hasScrim() && ownsScrim.value && unref(switcher).isFlowClosing.value,
|
|
1942
|
+
"astryx-bottom-sheet-switcher--non-modal": !unref(switcher).hasScrim(),
|
|
1943
|
+
"astryx-bottom-sheet-switcher--non-modal-top": !unref(switcher).hasScrim() && isInteractive.value
|
|
1944
|
+
}],
|
|
1945
|
+
"data-settled": isSettled.value || void 0,
|
|
1946
|
+
"aria-label": dialogLabel.value,
|
|
1947
|
+
"aria-modal": unref(switcher).hasScrim() && isInteractive.value ? "true" : void 0,
|
|
1948
|
+
"aria-hidden": isBlocked.value ? "true" : void 0,
|
|
1949
|
+
inert: isBlocked.value || void 0,
|
|
1950
|
+
"data-sheet-stack": unref(switcher).hasScrim() && isPresented.value ? unref(stackStateAttribute)(unref(switcher).stackView.value, unref(switcher).activeId.value != null) : void 0,
|
|
1951
|
+
"data-sheet-stack-depth": unref(switcher).hasScrim() && isPresented.value && unref(switcher).stackView.value.depth > 0 ? unref(switcher).stackView.value.depth : void 0,
|
|
1952
|
+
role: dialogRole.value,
|
|
1953
|
+
onCancel: _cache[2] || (_cache[2] = (...args) => unref(switcher).onCancel && unref(switcher).onCancel(...args)),
|
|
1954
|
+
onClick: _cache[3] || (_cache[3] = (...args) => unref(switcher).onClick && unref(switcher).onClick(...args)),
|
|
1955
|
+
onKeydown: _cache[4] || (_cache[4] = (...args) => unref(switcher).onKeydown && unref(switcher).onKeydown(...args))
|
|
1956
|
+
}), [
|
|
1957
|
+
createElementVNode("div", {
|
|
1958
|
+
class: normalizeClass(["astryx-bottom-sheet__positioner", [unref(switcher).hasScrim() ? unref(stackRecedeClasses)(unref(switcher).stackView.value) : void 0, { "astryx-bottom-sheet__positioner--top": isInteractive.value }]]),
|
|
1959
|
+
hidden: !isPresented.value || void 0,
|
|
1960
|
+
"aria-hidden": isBlocked.value ? "true" : void 0,
|
|
1961
|
+
inert: isBlocked.value || void 0
|
|
1962
|
+
}, [createVNode(_sfc_main$2, mergeProps({
|
|
1963
|
+
ref_key: "panel",
|
|
1964
|
+
ref: panel
|
|
1965
|
+
}, panelAttrs(), {
|
|
1966
|
+
state: panelState.value,
|
|
1967
|
+
"retained-motion": retainedMotion.value,
|
|
1968
|
+
"alignment-offset": unref(switcher).alignmentOffsetOf(__props.sheetId),
|
|
1969
|
+
label: __props.label,
|
|
1970
|
+
height: __props.height,
|
|
1971
|
+
padding: __props.padding,
|
|
1972
|
+
"snap-points": __props.snapPoints,
|
|
1973
|
+
"is-swipe-dismiss-allowed": __props.purpose === "info",
|
|
1974
|
+
"is-page-scroll-locked": unref(switcher).hasScrim(),
|
|
1975
|
+
onDismiss,
|
|
1976
|
+
onScrimOpacity: _cache[0] || (_cache[0] = ($event) => unref(switcher).onScrimOpacity(__props.sheetId, $event)),
|
|
1977
|
+
onScrimFade,
|
|
1978
|
+
onSnap: _cache[1] || (_cache[1] = ($event) => emit("snap", $event)),
|
|
1979
|
+
onMotionStart,
|
|
1980
|
+
onMotionComplete
|
|
1981
|
+
}), {
|
|
1982
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
1983
|
+
_: 3
|
|
1984
|
+
}, 16, [
|
|
1985
|
+
"state",
|
|
1986
|
+
"retained-motion",
|
|
1987
|
+
"alignment-offset",
|
|
1988
|
+
"label",
|
|
1989
|
+
"height",
|
|
1990
|
+
"padding",
|
|
1991
|
+
"snap-points",
|
|
1992
|
+
"is-swipe-dismiss-allowed",
|
|
1993
|
+
"is-page-scroll-locked"
|
|
1994
|
+
])], 10, _hoisted_2$1),
|
|
1995
|
+
isPresented.value ? (openBlock(), createElementBlock("div", _hoisted_3$1)) : createCommentVNode("v-if", true),
|
|
1996
|
+
createElementVNode("div", _hoisted_4$1, null, 512)
|
|
1997
|
+
], 16, _hoisted_1$1)], 2112);
|
|
1998
|
+
};
|
|
1999
|
+
}
|
|
2000
|
+
});
|
|
2001
|
+
//#endregion
|
|
2002
|
+
//#region src/BottomSheet/stack/useModalOutletWhile.ts
|
|
2003
|
+
/**
|
|
2004
|
+
* 条件成立期间把对话框登记成全局浮层(toast)的挂载点。条件跟着叠放走:只有最上面那层是挂载点,
|
|
2005
|
+
* 上面那张关掉后下面露出来的那张重新登记,排到清单最后。
|
|
2006
|
+
*
|
|
2007
|
+
* 不靠对话框的 `close` 事件撤销:叠放为了保顺序会关了再重新呈现,那次 `close` 事件晚到,会把刚登记的撤掉。
|
|
2008
|
+
*/
|
|
2009
|
+
function useModalOutletWhile(getDialog, isOn) {
|
|
2010
|
+
let current = null;
|
|
2011
|
+
function sync() {
|
|
2012
|
+
const next = isOn() ? getDialog() : null;
|
|
2013
|
+
if (next === current) return;
|
|
2014
|
+
if (current != null) removeModalOutlet(current);
|
|
2015
|
+
current = next;
|
|
2016
|
+
if (next != null) addModalOutlet(next);
|
|
2017
|
+
}
|
|
2018
|
+
watch(() => [isOn(), getDialog()], sync, { flush: "post" });
|
|
2019
|
+
onBeforeUnmount(() => {
|
|
2020
|
+
if (current != null) removeModalOutlet(current);
|
|
2021
|
+
current = null;
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
//#endregion
|
|
2025
|
+
//#region src/BottomSheet/stack/stackReplace.ts
|
|
2026
|
+
/**
|
|
2027
|
+
* 替换交接:同一次更新里一张关、一张开,而且是人从关掉的那张里动手换到下一张。
|
|
2028
|
+
*/
|
|
2029
|
+
const ALIGNMENT_THRESHOLD_PX = 1;
|
|
2030
|
+
/**
|
|
2031
|
+
* 把本批的一关一开配成替换。条件逐条对应「人从这一张换到下一张」:
|
|
2032
|
+
*
|
|
2033
|
+
* - 这次更新里正好关了一张、开了一张;
|
|
2034
|
+
* - 两张都是独立面板,属于同一组(同一 document,同是模态或同是非模态);
|
|
2035
|
+
* - 把新开的那张放一边,关掉的那张原来在最上面:被盖住的面板关掉、同时开一张,是下面出栈上面入栈;
|
|
2036
|
+
* - 两个对话框互不包含:内容里的面板跟着外面那张一起关,不是替换它;
|
|
2037
|
+
* - 动作来自关掉的那张:人最后按下的控件(没有新近按压就看这次更新第一次翻转时焦点在哪)
|
|
2038
|
+
* 在它的对话框里,或者哪里都不在(控件跟着那一步走了)。从外面的控件同时关一张开一张,
|
|
2039
|
+
* 是两个不相干的主人在同一次更新里各做各的,两张面板保留各自的打开者和进退动效。
|
|
2040
|
+
*
|
|
2041
|
+
* 配成后新开的那张接过关掉那张的打开者:它自己的打开者在要离开的那张里,流程是从关掉那张的起点开始的。
|
|
2042
|
+
*/
|
|
2043
|
+
function detectReplace() {
|
|
2044
|
+
if (state.batchOpened.length !== 1 || state.batchClosed.length !== 1) {
|
|
2045
|
+
undoBatchPair();
|
|
2046
|
+
return;
|
|
2047
|
+
}
|
|
2048
|
+
const [replacer] = state.batchOpened;
|
|
2049
|
+
const [replaced] = state.batchClosed;
|
|
2050
|
+
if (state.batchPair != null && state.batchPair.replaced === replaced) return;
|
|
2051
|
+
if (replaced === replacer || replaced.replaceable == null || replacer.replaceable == null || replaced.doc !== replacer.doc || replaced.isModal !== replacer.isModal || replaced.replace?.replacer === replacer || !replacer.isOpen || replaced.isOpen) return;
|
|
2052
|
+
const replacedElement = replaced.getElement();
|
|
2053
|
+
const replacerElement = replacer.getElement();
|
|
2054
|
+
if (replacedElement == null || replacerElement == null || replacedElement.contains(replacerElement) || replacerElement.contains(replacedElement)) return;
|
|
2055
|
+
if (!!groupOf(replaced).some((other) => other !== replacer && other !== replaced && other.isOpen && compareRank(other, replaced) > 0)) return;
|
|
2056
|
+
const actor = state.batchActor;
|
|
2057
|
+
if (actor != null && actor !== replaced.doc.body && !replacedElement.contains(actor)) return;
|
|
2058
|
+
if (replaced.replacing != null && replaced.replacing !== replacer) finishReplace(replaced.replacing);
|
|
2059
|
+
if (replaced.replace != null) replaced.replace.replacer.replacing = null;
|
|
2060
|
+
if (replacer.replace != null) replacer.replace = null;
|
|
2061
|
+
replaced.replace = {
|
|
2062
|
+
replacer,
|
|
2063
|
+
motion: "covered",
|
|
2064
|
+
alignmentOffset: 0,
|
|
2065
|
+
isAlignmentComplete: false,
|
|
2066
|
+
isEnteringComplete: false
|
|
2067
|
+
};
|
|
2068
|
+
replacer.replacing = replaced;
|
|
2069
|
+
state.batchPair = {
|
|
2070
|
+
replaced,
|
|
2071
|
+
replacer,
|
|
2072
|
+
replacerOpener: replacer.replaceable.getOpener()
|
|
2073
|
+
};
|
|
2074
|
+
state.lastPress.delete(replacer.doc);
|
|
2075
|
+
replacer.replaceable.setOpener(replaced.replaceable.getOpener());
|
|
2076
|
+
state.pendingReplaceFocus = replacer;
|
|
2077
|
+
}
|
|
2078
|
+
/** 撤销本批配成的一对:被替换的那张恢复成普通的关闭,替换者恢复自己的打开者,也不再欠焦点。 */
|
|
2079
|
+
function undoBatchPair() {
|
|
2080
|
+
const pair = state.batchPair;
|
|
2081
|
+
if (pair == null) return;
|
|
2082
|
+
state.batchPair = null;
|
|
2083
|
+
const { replaced, replacer, replacerOpener } = pair;
|
|
2084
|
+
if (replaced.replace?.replacer === replacer) replaced.replace = null;
|
|
2085
|
+
if (replacer.replacing === replaced) replacer.replacing = null;
|
|
2086
|
+
replacer.replaceable?.setOpener(replacerOpener);
|
|
2087
|
+
if (state.pendingReplaceFocus === replacer) state.pendingReplaceFocus = null;
|
|
2088
|
+
}
|
|
2089
|
+
/** 人从被替换的那一步换到进场的那一步,焦点也跟过去;对话框呈现之后才做。 */
|
|
2090
|
+
function focusPendingReplacer() {
|
|
2091
|
+
const replacer = state.pendingReplaceFocus;
|
|
2092
|
+
if (replacer == null) return;
|
|
2093
|
+
const element = replacer.getElement();
|
|
2094
|
+
if (element == null || !isSheetHostPresented(element)) return;
|
|
2095
|
+
state.pendingReplaceFocus = null;
|
|
2096
|
+
replacer.focus("replace");
|
|
2097
|
+
}
|
|
2098
|
+
/** 结束替换:被替换的面板藏起、对话框关掉;下一次算视图时遮罩交给替换它的那张。焦点不动。 */
|
|
2099
|
+
function finishReplace(replaced) {
|
|
2100
|
+
const replace = replaced.replace;
|
|
2101
|
+
if (replace == null) return;
|
|
2102
|
+
const { replacer } = replace;
|
|
2103
|
+
replaced.replace = null;
|
|
2104
|
+
if (replacer.replacing === replaced) replacer.replacing = null;
|
|
2105
|
+
replaced.hide();
|
|
2106
|
+
replaced.replaceable?.finish();
|
|
2107
|
+
}
|
|
2108
|
+
/** 丢掉本批里替换者自己关掉了、又没被本批哪次替换接回去的被替换面板。 */
|
|
2109
|
+
function flushPendingDrops() {
|
|
2110
|
+
if (state.pendingDrops.length === 0) return;
|
|
2111
|
+
const drops = state.pendingDrops;
|
|
2112
|
+
state.pendingDrops = [];
|
|
2113
|
+
for (const replaced of drops) {
|
|
2114
|
+
const replacer = replaced.replace?.replacer;
|
|
2115
|
+
if (replacer != null && !replacer.isOpen) finishReplace(replaced);
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
/**
|
|
2119
|
+
* 面板静止时的视口顶边:它的盒子去掉还在走的位移(进场的面板正从视口下面升上来)。
|
|
2120
|
+
* 从面板自己身上量,不看外面那层:独立面板的面板直接在铺满视口的对话框里,外层的顶边不是面板停的地方。
|
|
2121
|
+
*/
|
|
2122
|
+
function restingTopOfPanel(panel) {
|
|
2123
|
+
const top = panel.getBoundingClientRect().top;
|
|
2124
|
+
const view = panel.ownerDocument.defaultView;
|
|
2125
|
+
if (view == null || typeof view.DOMMatrixReadOnly !== "function") return top;
|
|
2126
|
+
const { transform } = view.getComputedStyle(panel);
|
|
2127
|
+
if (transform === "" || transform === "none") return top;
|
|
2128
|
+
try {
|
|
2129
|
+
return top - new view.DOMMatrixReadOnly(transform).m42;
|
|
2130
|
+
} catch {
|
|
2131
|
+
return top;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
/** 被替换的面板(静止)要向下移多少,才能和进场面板最终停下的顶边对齐。 */
|
|
2135
|
+
function alignmentOffsetForPanels(entering, retained) {
|
|
2136
|
+
if (entering == null || retained == null) return 0;
|
|
2137
|
+
return Math.max(0, restingTopOfPanel(entering) - retained.getBoundingClientRect().top);
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* 面板动作的开始和结束。替换期间由它推进交接:进场的面板开始升起时,比它高的被替换面板开始
|
|
2141
|
+
* 向下对齐;两边都走完后被替换的面板淡出;淡出结束替换就完了。返回要不要重新算视图。
|
|
2142
|
+
*/
|
|
2143
|
+
function applyMotionReport(entry, event, motion) {
|
|
2144
|
+
if (motion === "entering") {
|
|
2145
|
+
const replaced = entry.replacing;
|
|
2146
|
+
const replace = replaced?.replace ?? null;
|
|
2147
|
+
if (replaced == null || replace == null || replace.replacer !== entry) return false;
|
|
2148
|
+
if (event === "start") {
|
|
2149
|
+
if (replace.motion !== "covered") return false;
|
|
2150
|
+
const offset = alignmentOffsetForPanels(entry.replaceable?.getPanel() ?? null, replaced.replaceable?.getPanel() ?? null);
|
|
2151
|
+
if (offset > ALIGNMENT_THRESHOLD_PX) {
|
|
2152
|
+
replace.motion = "aligning";
|
|
2153
|
+
replace.alignmentOffset = offset;
|
|
2154
|
+
replace.isAlignmentComplete = false;
|
|
2155
|
+
}
|
|
2156
|
+
if (entry.isEnteringInPlace) {
|
|
2157
|
+
entry.isEnteringInPlace = false;
|
|
2158
|
+
replace.isEnteringComplete = true;
|
|
2159
|
+
if (replace.motion !== "aligning") replace.motion = "fading";
|
|
2160
|
+
} else if (replace.motion === "covered") return false;
|
|
2161
|
+
} else {
|
|
2162
|
+
replace.isEnteringComplete = true;
|
|
2163
|
+
if (replace.motion === "aligning" && !replace.isAlignmentComplete) return false;
|
|
2164
|
+
replace.motion = "fading";
|
|
2165
|
+
}
|
|
2166
|
+
return true;
|
|
2167
|
+
}
|
|
2168
|
+
const replace = entry.replace;
|
|
2169
|
+
if (replace == null || event !== "complete") return false;
|
|
2170
|
+
if (motion === "aligning" && replace.motion === "aligning") {
|
|
2171
|
+
if (replace.isEnteringComplete) replace.motion = "fading";
|
|
2172
|
+
else replace.isAlignmentComplete = true;
|
|
2173
|
+
return true;
|
|
2174
|
+
}
|
|
2175
|
+
if (motion === "fading" && replace.motion === "fading") {
|
|
2176
|
+
finishReplace(entry);
|
|
2177
|
+
return true;
|
|
2178
|
+
}
|
|
2179
|
+
return false;
|
|
2180
|
+
}
|
|
2181
|
+
//#endregion
|
|
2182
|
+
//#region src/BottomSheet/stack/stackViews.ts
|
|
2183
|
+
function isSameView(a, b) {
|
|
2184
|
+
return Object.keys(a).every((key) => a[key] === b[key]);
|
|
2185
|
+
}
|
|
2186
|
+
function viewFor(entry, order, index, owner, top) {
|
|
2187
|
+
let depth = 0;
|
|
2188
|
+
for (let above = index + 1; above < order.length; above += 1) if (order[above].isOpen && order[above] !== entry.replace?.replacer) depth += 1;
|
|
2189
|
+
const isCovered = entry.isOpen && depth > 0;
|
|
2190
|
+
const element = entry.getElement();
|
|
2191
|
+
const containsPresented = element != null && order.some((other) => {
|
|
2192
|
+
const otherElement = other.getElement();
|
|
2193
|
+
return other !== entry && otherElement != null && element.contains(otherElement);
|
|
2194
|
+
});
|
|
2195
|
+
const ownsScrim = entry === owner;
|
|
2196
|
+
return {
|
|
2197
|
+
isStacked: order.length > 1,
|
|
2198
|
+
isTop: entry === top,
|
|
2199
|
+
isCovered,
|
|
2200
|
+
depth,
|
|
2201
|
+
ownsScrim,
|
|
2202
|
+
isScrimHandoff: ownsScrim && entry.isOpen && order.slice(0, index).some((below) => !below.isOpen),
|
|
2203
|
+
isBlocked: isCovered && !containsPresented,
|
|
2204
|
+
isScrimTakenOver: !entry.isOpen && owner != null && owner !== entry,
|
|
2205
|
+
replacedMotion: entry.replace?.motion ?? null,
|
|
2206
|
+
alignmentOffset: entry.replace?.alignmentOffset ?? 0,
|
|
2207
|
+
isReplacing: entry.replacing != null
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
/** 算出一组面板各自的视图,变了的才通知宿主。 */
|
|
2211
|
+
function computeViews(order, isModal) {
|
|
2212
|
+
const openEntries = order.filter((entry) => entry.isOpen);
|
|
2213
|
+
const top = openEntries[openEntries.length - 1] ?? null;
|
|
2214
|
+
const owner = order.find((entry) => entry.isOpen || entry.replace != null) ?? null;
|
|
2215
|
+
const changed = [];
|
|
2216
|
+
order.forEach((entry, index) => {
|
|
2217
|
+
const view = isModal ? viewFor(entry, order, index, owner, top) : {
|
|
2218
|
+
...BOTTOM_SHEET_STACK_DEFAULT_VIEW,
|
|
2219
|
+
replacedMotion: entry.replace?.motion ?? null,
|
|
2220
|
+
alignmentOffset: entry.replace?.alignmentOffset ?? 0,
|
|
2221
|
+
isReplacing: entry.replacing != null
|
|
2222
|
+
};
|
|
2223
|
+
if (!isSameView(entry.view, view)) {
|
|
2224
|
+
entry.view = view;
|
|
2225
|
+
changed.push(entry);
|
|
2226
|
+
}
|
|
2227
|
+
});
|
|
2228
|
+
for (const entry of changed) entry.onView(entry.view);
|
|
2229
|
+
}
|
|
2230
|
+
/** 重新呈现时要保住焦点的元素:活动元素在一张马上要重新呈现的打开面板里。 */
|
|
2231
|
+
function activeElementToKeep(doc, reshown) {
|
|
2232
|
+
const remembered = state.focusToKeep.get(doc);
|
|
2233
|
+
state.focusToKeep.delete(doc);
|
|
2234
|
+
const current = doc.activeElement;
|
|
2235
|
+
const active = remembered != null && remembered.isConnected ? remembered : current instanceof HTMLElement && current !== doc.body ? current : null;
|
|
2236
|
+
if (active == null) return null;
|
|
2237
|
+
for (const entry of reshown) {
|
|
2238
|
+
const element = entry.getElement();
|
|
2239
|
+
if (entry.isOpen && element != null && element.contains(active)) return active;
|
|
2240
|
+
}
|
|
2241
|
+
return null;
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* 让顶层的顺序和名次一致。顶层只能往末尾追加,对话框要往上挪只能先关再重新呈现:
|
|
2245
|
+
* 已呈现顺序里按次序包含的、想要顺序的最长前缀原样保留,之后的都从上往下关掉,再按顺序重新呈现。
|
|
2246
|
+
* 有东西呈现了,焦点就进最上面那张打开的面板;人原本就在某张只是为了保位置而重新呈现的面板里时,
|
|
2247
|
+
* 焦点落回他原来所在的元素。
|
|
2248
|
+
*/
|
|
2249
|
+
function reconcileTopLayer(doc, isModal, order) {
|
|
2250
|
+
const shownOrder = getShownOrder(doc, isModal);
|
|
2251
|
+
const presentable = order.filter((entry) => {
|
|
2252
|
+
const element = entry.getElement();
|
|
2253
|
+
return element != null && element.isConnected;
|
|
2254
|
+
});
|
|
2255
|
+
let kept = 0;
|
|
2256
|
+
let cursor = 0;
|
|
2257
|
+
while (kept < presentable.length) {
|
|
2258
|
+
const next = shownOrder.indexOf(presentable[kept], cursor);
|
|
2259
|
+
if (next === -1) break;
|
|
2260
|
+
cursor = next + 1;
|
|
2261
|
+
kept += 1;
|
|
2262
|
+
}
|
|
2263
|
+
const keptEntries = new Set(presentable.slice(0, kept));
|
|
2264
|
+
const reshown = presentable.slice(kept);
|
|
2265
|
+
const keptActive = activeElementToKeep(doc, reshown);
|
|
2266
|
+
for (let index = shownOrder.length - 1; index >= 0; index -= 1) if (!keptEntries.has(shownOrder[index])) shownOrder[index].hide();
|
|
2267
|
+
for (const entry of reshown) {
|
|
2268
|
+
const delegate = keptActive != null && entry.getElement()?.contains(keptActive) ? keptActive : null;
|
|
2269
|
+
const hadAutofocus = delegate?.hasAttribute("autofocus") ?? false;
|
|
2270
|
+
if (delegate != null && !hadAutofocus) delegate.setAttribute("autofocus", "");
|
|
2271
|
+
entry.show();
|
|
2272
|
+
if (delegate != null && !hadAutofocus) delegate.removeAttribute("autofocus");
|
|
2273
|
+
}
|
|
2274
|
+
setShownOrder(doc, isModal, presentable);
|
|
2275
|
+
if (reshown.length === 0) return;
|
|
2276
|
+
if (reshown.some((entry) => shownOrder.includes(entry))) notifyTopLayerEntry();
|
|
2277
|
+
if (keptActive != null && keptActive.isConnected) {
|
|
2278
|
+
if (doc.activeElement !== keptActive) keptActive.focus({ preventScroll: true });
|
|
2279
|
+
return;
|
|
2280
|
+
}
|
|
2281
|
+
const openEntries = presentable.filter((entry) => entry.isOpen);
|
|
2282
|
+
openEntries[openEntries.length - 1]?.focus("open");
|
|
2283
|
+
}
|
|
2284
|
+
//#endregion
|
|
2285
|
+
//#region src/BottomSheet/stack/bottomSheetStack.ts
|
|
2286
|
+
function takeRank() {
|
|
2287
|
+
state.isBatchDirty = true;
|
|
2288
|
+
scheduleSeal(sealBottomSheetBatch);
|
|
2289
|
+
return {
|
|
2290
|
+
batch: state.currentBatch,
|
|
2291
|
+
seq: state.nextSeq++
|
|
2292
|
+
};
|
|
2293
|
+
}
|
|
2294
|
+
/** 结束当前这一批。之后的登记就是另一个打开顺序了。 */
|
|
2295
|
+
function sealBottomSheetBatch() {
|
|
2296
|
+
flushPendingDrops();
|
|
2297
|
+
sealClosingGroups();
|
|
2298
|
+
if (state.isBatchDirty) {
|
|
2299
|
+
state.currentBatch += 1;
|
|
2300
|
+
state.isBatchDirty = false;
|
|
2301
|
+
}
|
|
2302
|
+
state.batchOpened = [];
|
|
2303
|
+
state.batchClosed = [];
|
|
2304
|
+
state.batchActor = null;
|
|
2305
|
+
state.batchPair = null;
|
|
2306
|
+
}
|
|
2307
|
+
/**
|
|
2308
|
+
* 同一叠里两张以上模态面板在同一次更新里一起关、这叠里没有剩下打开的、也没有新开的:「全部关闭」。
|
|
2309
|
+
* 每张自己还焦点都还不成:打开者要么在一起关的对话框里,要么在仍被别的模态挡着的页面上。
|
|
2310
|
+
* 这一组在最后一个对话框离开顶层后,按最底下那张的归还目标还一次焦点。
|
|
2311
|
+
*/
|
|
2312
|
+
function sealClosingGroups() {
|
|
2313
|
+
if (state.batchOpened.length > 0) return;
|
|
2314
|
+
const closingModal = state.batchClosed.filter((entry) => entry.isModal && entry.replace == null && entry.replacing == null);
|
|
2315
|
+
if (closingModal.length < 2) return;
|
|
2316
|
+
const byDoc = /* @__PURE__ */ new Map();
|
|
2317
|
+
for (const entry of closingModal) byDoc.set(entry.doc, [...byDoc.get(entry.doc) ?? [], entry]);
|
|
2318
|
+
for (const [doc, closing] of byDoc) {
|
|
2319
|
+
if (closing.length < 2) continue;
|
|
2320
|
+
const stack = sortedEntries(doc, true);
|
|
2321
|
+
if (stack.some((entry) => entry.isOpen)) continue;
|
|
2322
|
+
const members = stack.filter((entry) => closing.includes(entry));
|
|
2323
|
+
const group = {
|
|
2324
|
+
members,
|
|
2325
|
+
pending: new Set(members),
|
|
2326
|
+
returnTarget: members[0].getReturnTarget?.() ?? null
|
|
2327
|
+
};
|
|
2328
|
+
for (const entry of members) state.closingTogether.set(entry, group);
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
/** `key` 是否作为「全部关闭」的一员在关:它的宿主离开顶层时不自己还焦点。 */
|
|
2332
|
+
function isClosingTogether(key) {
|
|
2333
|
+
const entry = findEntry(key);
|
|
2334
|
+
return entry != null && state.closingTogether.has(entry);
|
|
2335
|
+
}
|
|
2336
|
+
function leaveClosingGroup(entry, group) {
|
|
2337
|
+
state.closingTogether.delete(entry);
|
|
2338
|
+
group.pending.delete(entry);
|
|
2339
|
+
if (group.pending.size > 0 || group.reported) return;
|
|
2340
|
+
group.reported = true;
|
|
2341
|
+
returnFocusTo(group.returnTarget);
|
|
2342
|
+
}
|
|
2343
|
+
/** 「全部关闭」的一员离开了顶层;最后一个离开时焦点回到这一组的归还目标。 */
|
|
2344
|
+
function reportClosedTogether(key) {
|
|
2345
|
+
const entry = findEntry(key);
|
|
2346
|
+
const group = entry == null ? void 0 : state.closingTogether.get(entry);
|
|
2347
|
+
if (entry != null && group != null) leaveClosingGroup(entry, group);
|
|
2348
|
+
}
|
|
2349
|
+
function update(doc, isModal) {
|
|
2350
|
+
detectReplace();
|
|
2351
|
+
if (state.batchOpened.length > 0 && state.batchClosed.length > 0) flushPendingDrops();
|
|
2352
|
+
const order = sortedEntries(doc, isModal);
|
|
2353
|
+
computeViews(order, isModal);
|
|
2354
|
+
reconcileTopLayer(doc, isModal, order);
|
|
2355
|
+
state.focusToKeep.delete(doc);
|
|
2356
|
+
focusPendingReplacer();
|
|
2357
|
+
}
|
|
2358
|
+
function rankFor(key, isOpen) {
|
|
2359
|
+
const remembered = state.rankByKey.get(key);
|
|
2360
|
+
if (remembered != null && !remembered.isClosed && (remembered.detachedBatch == null || remembered.detachedBatch === state.currentBatch)) {
|
|
2361
|
+
remembered.detachedBatch = null;
|
|
2362
|
+
return {
|
|
2363
|
+
batch: remembered.batch,
|
|
2364
|
+
seq: remembered.seq
|
|
2365
|
+
};
|
|
2366
|
+
}
|
|
2367
|
+
const rank = takeRank();
|
|
2368
|
+
state.rankByKey.set(key, {
|
|
2369
|
+
...rank,
|
|
2370
|
+
isClosed: !isOpen,
|
|
2371
|
+
detachedBatch: null
|
|
2372
|
+
});
|
|
2373
|
+
return rank;
|
|
2374
|
+
}
|
|
2375
|
+
/**
|
|
2376
|
+
* 面板呈现期间加入叠放,返回离开的函数。`isOpen` 是受控的打开状态;呈现着但 `isOpen` 为假的
|
|
2377
|
+
* 面板正在滑出,保留位置但不算一层。
|
|
2378
|
+
*/
|
|
2379
|
+
function registerBottomSheet(registration, isOpen, isModal = true) {
|
|
2380
|
+
const { key } = registration;
|
|
2381
|
+
const rank = rankFor(key, isOpen);
|
|
2382
|
+
const doc = registration.getElement()?.ownerDocument ?? document;
|
|
2383
|
+
listenForPresses(doc);
|
|
2384
|
+
const entry = {
|
|
2385
|
+
...registration,
|
|
2386
|
+
rank,
|
|
2387
|
+
isOpen,
|
|
2388
|
+
doc,
|
|
2389
|
+
isModal,
|
|
2390
|
+
view: BOTTOM_SHEET_STACK_DEFAULT_VIEW,
|
|
2391
|
+
replace: null,
|
|
2392
|
+
replacing: null,
|
|
2393
|
+
isEnteringInPlace: false
|
|
2394
|
+
};
|
|
2395
|
+
state.entries.push(entry);
|
|
2396
|
+
if (isOpen && rank.batch === state.currentBatch && state.isBatchDirty) recordFlip(entry, "opened");
|
|
2397
|
+
update(doc, isModal);
|
|
2398
|
+
return () => leave(entry);
|
|
2399
|
+
}
|
|
2400
|
+
function leave(entry) {
|
|
2401
|
+
const index = state.entries.indexOf(entry);
|
|
2402
|
+
if (index === -1) return;
|
|
2403
|
+
state.entries.splice(index, 1);
|
|
2404
|
+
stopListeningForPresses(entry.doc);
|
|
2405
|
+
setShownOrder(entry.doc, entry.isModal, getShownOrder(entry.doc, entry.isModal).filter((shown) => shown !== entry));
|
|
2406
|
+
state.batchOpened = state.batchOpened.filter((other) => other !== entry);
|
|
2407
|
+
state.batchClosed = state.batchClosed.filter((other) => other !== entry);
|
|
2408
|
+
state.pendingDrops = state.pendingDrops.filter((other) => other !== entry);
|
|
2409
|
+
if (state.pendingReplaceFocus === entry) state.pendingReplaceFocus = null;
|
|
2410
|
+
if (state.batchPair?.replaced === entry || state.batchPair?.replacer === entry) state.batchPair = null;
|
|
2411
|
+
const closingGroup = state.closingTogether.get(entry);
|
|
2412
|
+
if (entry.replace != null) {
|
|
2413
|
+
entry.replace.replacer.replacing = null;
|
|
2414
|
+
entry.replace = null;
|
|
2415
|
+
}
|
|
2416
|
+
if (entry.replacing != null) {
|
|
2417
|
+
entry.replacing.replace = null;
|
|
2418
|
+
entry.replacing = null;
|
|
2419
|
+
}
|
|
2420
|
+
entry.hide();
|
|
2421
|
+
if (closingGroup != null) leaveClosingGroup(entry, closingGroup);
|
|
2422
|
+
const current = state.rankByKey.get(entry.key);
|
|
2423
|
+
if (current != null) {
|
|
2424
|
+
current.detachedBatch = state.currentBatch;
|
|
2425
|
+
state.isBatchDirty = true;
|
|
2426
|
+
scheduleSeal(sealBottomSheetBatch);
|
|
2427
|
+
}
|
|
2428
|
+
entry.view = BOTTOM_SHEET_STACK_DEFAULT_VIEW;
|
|
2429
|
+
entry.onView(entry.view);
|
|
2430
|
+
update(entry.doc, entry.isModal);
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* 这一层换了实现它的对话框:切换器交接到一个自带对话框的步骤,宿主在同一次更新里把它呈现到了顶层最上面。
|
|
2434
|
+
* 这一层保留名次;登记表把新对话框记为最近呈现的,再把该在它上面的面板放回上面。
|
|
2435
|
+
*/
|
|
2436
|
+
function notifyBottomSheetHostChanged(key) {
|
|
2437
|
+
const entry = findEntry(key);
|
|
2438
|
+
if (entry == null || !entry.isModal) return;
|
|
2439
|
+
const element = entry.getElement();
|
|
2440
|
+
if (element == null || !element.open) return;
|
|
2441
|
+
const shown = getShownOrder(entry.doc, true).filter((shownEntry) => shownEntry !== entry);
|
|
2442
|
+
shown.push(entry);
|
|
2443
|
+
setShownOrder(entry.doc, true, shown);
|
|
2444
|
+
update(entry.doc, true);
|
|
2445
|
+
}
|
|
2446
|
+
/** 报告已登记面板的受控打开状态。关闭时滑出期间保留位置;重新打开拿新名次,回到最上面。 */
|
|
2447
|
+
function setBottomSheetOpen(key, isOpen) {
|
|
2448
|
+
const entry = findEntry(key);
|
|
2449
|
+
if (entry == null || entry.isOpen === isOpen) return;
|
|
2450
|
+
entry.isOpen = isOpen;
|
|
2451
|
+
if (isOpen) {
|
|
2452
|
+
const group = state.closingTogether.get(entry);
|
|
2453
|
+
if (group != null) {
|
|
2454
|
+
state.closingTogether.delete(entry);
|
|
2455
|
+
group.pending.delete(entry);
|
|
2456
|
+
}
|
|
2457
|
+
entry.rank = takeRank();
|
|
2458
|
+
state.rankByKey.set(key, {
|
|
2459
|
+
...entry.rank,
|
|
2460
|
+
isClosed: false,
|
|
2461
|
+
detachedBatch: null
|
|
2462
|
+
});
|
|
2463
|
+
recordFlip(entry, "opened");
|
|
2464
|
+
if (entry.replace != null) {
|
|
2465
|
+
entry.replace.replacer.replacing = null;
|
|
2466
|
+
entry.replace = null;
|
|
2467
|
+
entry.isEnteringInPlace = true;
|
|
2468
|
+
}
|
|
2469
|
+
} else {
|
|
2470
|
+
const remembered = state.rankByKey.get(key);
|
|
2471
|
+
if (remembered != null) remembered.isClosed = true;
|
|
2472
|
+
state.isBatchDirty = true;
|
|
2473
|
+
scheduleSeal(sealBottomSheetBatch);
|
|
2474
|
+
recordFlip(entry, "closed");
|
|
2475
|
+
entry.isEnteringInPlace = false;
|
|
2476
|
+
if (entry.replacing != null) state.pendingDrops.push(entry.replacing);
|
|
2477
|
+
}
|
|
2478
|
+
update(entry.doc, entry.isModal);
|
|
2479
|
+
}
|
|
2480
|
+
/** 面板的动作开始和结束都报到这里;替换期间由它推进交接。 */
|
|
2481
|
+
function reportBottomSheetMotion(key, event, motion) {
|
|
2482
|
+
const entry = findEntry(key);
|
|
2483
|
+
if (entry != null && applyMotionReport(entry, event, motion)) update(entry.doc, entry.isModal);
|
|
2484
|
+
}
|
|
2485
|
+
/** `key` 正下方那张打开的面板:它的对话框和把焦点送进去的办法。下面没有打开的就是 `null`。 */
|
|
2486
|
+
function getBottomSheetBeneath(key) {
|
|
2487
|
+
const own = findEntry(key);
|
|
2488
|
+
if (own == null) return null;
|
|
2489
|
+
const order = groupOf(own);
|
|
2490
|
+
for (let below = order.indexOf(own) - 1; below >= 0; below -= 1) {
|
|
2491
|
+
const entry = order[below];
|
|
2492
|
+
const element = entry.getElement();
|
|
2493
|
+
if (entry.isOpen && element != null) return {
|
|
2494
|
+
element,
|
|
2495
|
+
focus: () => entry.focus("reveal")
|
|
2496
|
+
};
|
|
2497
|
+
}
|
|
2498
|
+
return null;
|
|
2499
|
+
}
|
|
2500
|
+
//#endregion
|
|
2501
|
+
//#region src/BottomSheet/stack/useStandaloneSheetStack.ts
|
|
2502
|
+
/**
|
|
2503
|
+
* 独立面板加入叠放登记表的那一整套:呈现期间登记、报告开关、接收视图、遮罩写入、
|
|
2504
|
+
* 替换交接、退场结束时的焦点去向,以及打开着被卸载时把困住的焦点送出去。
|
|
2505
|
+
*/
|
|
2506
|
+
function useStandaloneSheetStack(options) {
|
|
2507
|
+
const key = {};
|
|
2508
|
+
const isPresented = ref(options.isOpen.value);
|
|
2509
|
+
const shouldPresent = computed(() => options.isOpen.value || isPresented.value);
|
|
2510
|
+
const view = shallowRef(BOTTOM_SHEET_STACK_DEFAULT_VIEW);
|
|
2511
|
+
const isCloseSettled = ref(false);
|
|
2512
|
+
const isModalShown = ref(false);
|
|
2513
|
+
const isReplaced = computed(() => !options.isOpen.value && isPresented.value && view.value.replacedMotion != null);
|
|
2514
|
+
let trigger = null;
|
|
2515
|
+
let hadFocusAtClose = false;
|
|
2516
|
+
let leaveStack = null;
|
|
2517
|
+
let registeredScrim = options.hasScrim();
|
|
2518
|
+
let focusRecord = null;
|
|
2519
|
+
const scrimWrite = { frame: null };
|
|
2520
|
+
const scrimFadeWritten = { current: null };
|
|
2521
|
+
function writeScrim(opacity) {
|
|
2522
|
+
writeScrimOpacity(options.getDialog(), opacity, scrimWrite);
|
|
2523
|
+
}
|
|
2524
|
+
function show() {
|
|
2525
|
+
const dialog = options.getDialog();
|
|
2526
|
+
if (dialog == null || isSheetHostPresented(dialog)) return;
|
|
2527
|
+
trigger ??= dialog.ownerDocument.activeElement;
|
|
2528
|
+
focusRecord?.stop();
|
|
2529
|
+
focusRecord = trackLayerFocus({
|
|
2530
|
+
getLayer: options.getDialog,
|
|
2531
|
+
opener: trigger
|
|
2532
|
+
});
|
|
2533
|
+
if (!options.hasScrim()) {
|
|
2534
|
+
dialog.show();
|
|
2535
|
+
return;
|
|
2536
|
+
}
|
|
2537
|
+
dialog.style.setProperty("--_sheet-scrim-opacity", scrimOpacityForView(view.value));
|
|
2538
|
+
dialog.showModal();
|
|
2539
|
+
isModalShown.value = true;
|
|
2540
|
+
}
|
|
2541
|
+
function register() {
|
|
2542
|
+
registeredScrim = options.hasScrim();
|
|
2543
|
+
leaveStack = registerBottomSheet({
|
|
2544
|
+
key,
|
|
2545
|
+
getElement: options.getDialog,
|
|
2546
|
+
show,
|
|
2547
|
+
hide: () => closeDialogKeepingFocus(options.getDialog()),
|
|
2548
|
+
focus: (reason) => focusSheetPanel(options.getPanel(), reason, options.hasScrim()),
|
|
2549
|
+
getReturnTarget: () => options.getFinalFocus() ?? trigger,
|
|
2550
|
+
onView: (next) => {
|
|
2551
|
+
view.value = next;
|
|
2552
|
+
if (options.isOpen.value || next.replacedMotion != null) writeScrim(scrimOpacityForView(next));
|
|
2553
|
+
else if (next.isScrimTakenOver) writeScrim("0");
|
|
2554
|
+
},
|
|
2555
|
+
replaceable: {
|
|
2556
|
+
getPanel: options.getPanel,
|
|
2557
|
+
getOpener: () => trigger,
|
|
2558
|
+
setOpener: (opener) => {
|
|
2559
|
+
trigger = opener;
|
|
2560
|
+
},
|
|
2561
|
+
finish: () => {
|
|
2562
|
+
trigger = null;
|
|
2563
|
+
stopFocusRecord();
|
|
2564
|
+
isPresented.value = false;
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
}, options.isOpen.value, registeredScrim);
|
|
2568
|
+
}
|
|
2569
|
+
function leave() {
|
|
2570
|
+
const stop = leaveStack;
|
|
2571
|
+
leaveStack = null;
|
|
2572
|
+
stop?.();
|
|
2573
|
+
}
|
|
2574
|
+
function stopFocusRecord() {
|
|
2575
|
+
focusRecord?.stop();
|
|
2576
|
+
focusRecord = null;
|
|
2577
|
+
}
|
|
2578
|
+
function sync() {
|
|
2579
|
+
if (!options.isEnabled()) return;
|
|
2580
|
+
const open = options.isOpen.value;
|
|
2581
|
+
if (!open) {
|
|
2582
|
+
const dialog = options.getDialog();
|
|
2583
|
+
hadFocusAtClose = dialog != null && dialog.contains(dialog.ownerDocument.activeElement);
|
|
2584
|
+
}
|
|
2585
|
+
if (shouldPresent.value && leaveStack != null && registeredScrim !== options.hasScrim()) leave();
|
|
2586
|
+
if (shouldPresent.value) {
|
|
2587
|
+
if (leaveStack == null) register();
|
|
2588
|
+
else setBottomSheetOpen(key, open);
|
|
2589
|
+
} else if (leaveStack != null) leave();
|
|
2590
|
+
if (!open) isCloseSettled.value = true;
|
|
2591
|
+
}
|
|
2592
|
+
watch(options.isOpen, (open) => {
|
|
2593
|
+
isCloseSettled.value = false;
|
|
2594
|
+
if (open) isPresented.value = true;
|
|
2595
|
+
}, { flush: "sync" });
|
|
2596
|
+
watch([
|
|
2597
|
+
shouldPresent,
|
|
2598
|
+
options.isOpen,
|
|
2599
|
+
options.hasScrim
|
|
2600
|
+
], sync, { flush: "post" });
|
|
2601
|
+
onMounted(sync);
|
|
2602
|
+
watch([
|
|
2603
|
+
options.isOpen,
|
|
2604
|
+
isPresented,
|
|
2605
|
+
isReplaced
|
|
2606
|
+
], () => {
|
|
2607
|
+
const dialog = options.getDialog();
|
|
2608
|
+
if (dialog == null || !options.hasScrim() || !options.isEnabled()) return;
|
|
2609
|
+
if (options.isOpen.value || isReplaced.value) dialog.style.setProperty("--_sheet-scrim-opacity", scrimOpacityForView(view.value));
|
|
2610
|
+
else if (isPresented.value) dialog.style.setProperty("--_sheet-scrim-opacity", "0");
|
|
2611
|
+
}, { flush: "post" });
|
|
2612
|
+
/** 拖动时遮罩跟手变淡;叠在遮罩主人上面的面板遮罩是透明的,拖动不能把它露出来。 */
|
|
2613
|
+
function onScrimOpacity(opacity) {
|
|
2614
|
+
if (view.value.isStacked && !view.value.ownsScrim) return;
|
|
2615
|
+
options.getDialog()?.style.setProperty("--_sheet-scrim-opacity", String(opacity));
|
|
2616
|
+
}
|
|
2617
|
+
function onScrimFade(fade) {
|
|
2618
|
+
if (view.value.isStacked && !view.value.ownsScrim) return;
|
|
2619
|
+
writeScrimFade(options.getDialog(), fade, scrimFadeWritten);
|
|
2620
|
+
}
|
|
2621
|
+
let entering = "idle";
|
|
2622
|
+
let isEnteringReported = false;
|
|
2623
|
+
function reportEnteringIfReplacing() {
|
|
2624
|
+
if (isEnteringReported || entering === "idle" || !view.value.isReplacing) return;
|
|
2625
|
+
isEnteringReported = true;
|
|
2626
|
+
reportBottomSheetMotion(key, "start", "entering");
|
|
2627
|
+
if (entering === "done") reportBottomSheetMotion(key, "complete", "entering");
|
|
2628
|
+
}
|
|
2629
|
+
watch(() => view.value.isReplacing, reportEnteringIfReplacing, { flush: "post" });
|
|
2630
|
+
function onMotionStart(motion) {
|
|
2631
|
+
if (motion !== "entering") {
|
|
2632
|
+
reportBottomSheetMotion(key, "start", motion);
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
entering = "running";
|
|
2636
|
+
isEnteringReported = false;
|
|
2637
|
+
reportEnteringIfReplacing();
|
|
2638
|
+
}
|
|
2639
|
+
function onMotionComplete(motion) {
|
|
2640
|
+
if (motion === "entering") {
|
|
2641
|
+
entering = "done";
|
|
2642
|
+
if (isEnteringReported) reportBottomSheetMotion(key, "complete", "entering");
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
if (motion === "exiting") entering = "idle";
|
|
2646
|
+
reportBottomSheetMotion(key, "complete", motion);
|
|
2647
|
+
if (motion === "exiting" && !options.isOpen.value) finishExit();
|
|
2648
|
+
}
|
|
2649
|
+
function settleClosed() {
|
|
2650
|
+
isPresented.value = false;
|
|
2651
|
+
trigger = null;
|
|
2652
|
+
stopFocusRecord();
|
|
2653
|
+
}
|
|
2654
|
+
function finishExit() {
|
|
2655
|
+
const dialog = options.getDialog();
|
|
2656
|
+
const hasScrim = options.hasScrim();
|
|
2657
|
+
if (hasScrim && view.value.depth > 0) {
|
|
2658
|
+
closeDialogKeepingFocus(dialog);
|
|
2659
|
+
settleClosed();
|
|
2660
|
+
return;
|
|
2661
|
+
}
|
|
2662
|
+
if (hasScrim && isClosingTogether(key)) {
|
|
2663
|
+
closeDialogKeepingFocus(dialog);
|
|
2664
|
+
settleClosed();
|
|
2665
|
+
reportClosedTogether(key);
|
|
2666
|
+
return;
|
|
2667
|
+
}
|
|
2668
|
+
const revealed = hasScrim ? getBottomSheetBeneath(key) : null;
|
|
2669
|
+
const returnTarget = options.getFinalFocus() ?? (hasScrim || hadFocusAtClose ? trigger : null);
|
|
2670
|
+
if (dialog != null) hideSheetHost(dialog);
|
|
2671
|
+
settleClosed();
|
|
2672
|
+
if (revealed != null && (returnTarget == null || !revealed.element.contains(returnTarget))) revealed.focus();
|
|
2673
|
+
else returnFocusTo(returnTarget);
|
|
2674
|
+
}
|
|
2675
|
+
onBeforeUnmount(() => {
|
|
2676
|
+
cancelScrimWrite(scrimWrite);
|
|
2677
|
+
const record = focusRecord;
|
|
2678
|
+
focusRecord = null;
|
|
2679
|
+
const dialog = options.getDialog();
|
|
2680
|
+
if (record != null && leaveStack != null && isSheetHostPresented(dialog)) {
|
|
2681
|
+
const wasStranded = isLayerFocusStranded(record, dialog);
|
|
2682
|
+
const returnTarget = options.getFinalFocus() ?? trigger;
|
|
2683
|
+
const revealed = options.hasScrim() ? getBottomSheetBeneath(key) : null;
|
|
2684
|
+
queueMicrotask(() => {
|
|
2685
|
+
if (wasStranded) {
|
|
2686
|
+
if (revealed != null && revealed.element.isConnected && (returnTarget == null || !revealed.element.contains(returnTarget))) revealed.focus();
|
|
2687
|
+
else if (revealed == null || revealed.element.isConnected) restoreLayerFocus(record, {
|
|
2688
|
+
layer: null,
|
|
2689
|
+
name: "BottomSheet"
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
2692
|
+
record.stop();
|
|
2693
|
+
});
|
|
2694
|
+
} else record?.stop();
|
|
2695
|
+
leave();
|
|
2696
|
+
});
|
|
2697
|
+
return {
|
|
2698
|
+
view,
|
|
2699
|
+
isPresented,
|
|
2700
|
+
shouldPresent,
|
|
2701
|
+
isCloseSettled,
|
|
2702
|
+
isModalShown,
|
|
2703
|
+
isReplaced,
|
|
2704
|
+
onScrimOpacity,
|
|
2705
|
+
onScrimFade,
|
|
2706
|
+
onMotionStart,
|
|
2707
|
+
onMotionComplete
|
|
2708
|
+
};
|
|
2709
|
+
}
|
|
2710
|
+
//#endregion
|
|
1447
2711
|
//#region src/BottomSheet/useSheetLayerDismiss.ts
|
|
1448
2712
|
/**
|
|
1449
2713
|
* 把底部面板登记进全页关闭栈。
|
|
@@ -1479,24 +2743,27 @@ function useSheetLayerDismiss(options) {
|
|
|
1479
2743
|
//#endregion
|
|
1480
2744
|
//#region src/BottomSheet/BottomSheet.vue
|
|
1481
2745
|
var BottomSheet_exports = /* @__PURE__ */ __exportAll({ default: () => _sfc_main });
|
|
1482
|
-
const _hoisted_1 =
|
|
1483
|
-
const _hoisted_2 = {
|
|
2746
|
+
const _hoisted_1 = {
|
|
1484
2747
|
key: 1,
|
|
1485
2748
|
class: "astryx-bottom-sheet-inline"
|
|
1486
2749
|
};
|
|
1487
|
-
const
|
|
2750
|
+
const _hoisted_2 = {
|
|
1488
2751
|
key: 0,
|
|
1489
2752
|
class: "astryx-bottom-sheet__positioner astryx-bottom-sheet__positioner--inline"
|
|
1490
2753
|
};
|
|
1491
|
-
const
|
|
2754
|
+
const _hoisted_3 = [
|
|
1492
2755
|
"data-settled",
|
|
2756
|
+
"data-sheet-stack",
|
|
2757
|
+
"data-sheet-stack-depth",
|
|
1493
2758
|
"aria-label",
|
|
1494
2759
|
"aria-labelledby",
|
|
1495
2760
|
"aria-modal",
|
|
2761
|
+
"aria-hidden",
|
|
2762
|
+
"inert",
|
|
1496
2763
|
"role"
|
|
1497
2764
|
];
|
|
1498
|
-
const
|
|
1499
|
-
const
|
|
2765
|
+
const _hoisted_4 = { class: "astryx-bottom-sheet__positioner" };
|
|
2766
|
+
const _hoisted_5 = {
|
|
1500
2767
|
ref: "layerHost",
|
|
1501
2768
|
class: "astryx-bottom-sheet__layer-host"
|
|
1502
2769
|
};
|
|
@@ -1540,49 +2807,44 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1540
2807
|
const emit = __emit;
|
|
1541
2808
|
const isOpen = useModel(__props, "isOpen");
|
|
1542
2809
|
const switcher = inject(bottomSheetSwitcherKey, null);
|
|
2810
|
+
const host = inject(bottomSheetHostKey, null);
|
|
1543
2811
|
const isEscapeAllowed = inject(bottomSheetEscapeKey, () => true);
|
|
1544
2812
|
provide(bottomSheetEscapeKey, () => true);
|
|
1545
2813
|
const hosted = computed(() => switcher != null && props.sheetId != null);
|
|
1546
|
-
const
|
|
1547
|
-
|
|
1548
|
-
return switcher.retainedId.value === props.sheetId && switcher.activeId.value !== props.sheetId;
|
|
1549
|
-
});
|
|
1550
|
-
const open = computed(() => {
|
|
1551
|
-
if (!hosted.value || props.sheetId == null) return isOpen.value;
|
|
1552
|
-
return switcher?.activeId.value === props.sheetId || switcher?.retainedId.value === props.sheetId;
|
|
1553
|
-
});
|
|
2814
|
+
const effectiveOpen = computed(() => !hosted.value && isOpen.value && (host?.isOpen.value ?? true));
|
|
2815
|
+
provide(bottomSheetHostKey, { isOpen: effectiveOpen });
|
|
1554
2816
|
const attrs = useAttrs();
|
|
1555
2817
|
const dialog = useTemplateRef("dialog");
|
|
1556
2818
|
provideNestedLayerMountTarget(useTemplateRef("layerHost"));
|
|
1557
2819
|
const panel = useTemplateRef("panel");
|
|
1558
|
-
const
|
|
1559
|
-
const
|
|
1560
|
-
const isModalShown = ref(false);
|
|
2820
|
+
const step = useTemplateRef("step");
|
|
2821
|
+
const isMounted = ref(false);
|
|
1561
2822
|
const isSettled = ref(getCurrentInstance()?.vnode.el != null && isOpen.value && !hosted.value && !props.isInline);
|
|
2823
|
+
function panelElement() {
|
|
2824
|
+
if (hosted.value) return step.value?.element ?? null;
|
|
2825
|
+
return panel.value?.element ?? null;
|
|
2826
|
+
}
|
|
2827
|
+
const stack = useStandaloneSheetStack({
|
|
2828
|
+
isOpen: effectiveOpen,
|
|
2829
|
+
hasScrim: () => props.hasScrim,
|
|
2830
|
+
isEnabled: () => !hosted.value && !props.isInline && typeof document !== "undefined",
|
|
2831
|
+
getDialog: () => dialog.value ?? null,
|
|
2832
|
+
getPanel: panelElement,
|
|
2833
|
+
getFinalFocus: () => toValue(props.finalFocusRef) ?? null
|
|
2834
|
+
});
|
|
2835
|
+
const view = stack.view;
|
|
1562
2836
|
const panelState = computed(() => {
|
|
1563
|
-
if (
|
|
1564
|
-
if (
|
|
1565
|
-
if (
|
|
1566
|
-
|
|
2837
|
+
if (props.isInline) return isOpen.value ? "open" : "hidden";
|
|
2838
|
+
if (effectiveOpen.value) return "open";
|
|
2839
|
+
if (stack.isReplaced.value) return "retained";
|
|
2840
|
+
if (stack.isPresented.value) return stack.isCloseSettled.value ? "exiting" : "open";
|
|
2841
|
+
return "hidden";
|
|
1567
2842
|
});
|
|
1568
2843
|
const isDismissible = computed(() => props.purpose === "info");
|
|
1569
|
-
const
|
|
1570
|
-
const
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
"--_sheet-scrim-opacity": isClosing.value ? "0" : String(scrimOpacity.value),
|
|
1574
|
-
"--_sheet-scrim-duration": scrimFade.value == null ? void 0 : `${scrimFade.value.durationMs}ms`,
|
|
1575
|
-
"--_sheet-scrim-easing": scrimFade.value?.easing
|
|
1576
|
-
}));
|
|
1577
|
-
useFocusTrap({
|
|
1578
|
-
container: computed(() => panelElement()),
|
|
1579
|
-
isEnabled: computed(() => !hosted.value && isOpen.value && props.hasScrim)
|
|
1580
|
-
});
|
|
1581
|
-
useRestoreFocus({
|
|
1582
|
-
isEnabled: computed(() => !props.isInline && !hosted.value),
|
|
1583
|
-
shouldRestore: isOpen,
|
|
1584
|
-
preventScroll: true
|
|
1585
|
-
});
|
|
2844
|
+
const isExiting = computed(() => !hosted.value && !props.isInline && !effectiveOpen.value && stack.isPresented.value);
|
|
2845
|
+
const isInert = computed(() => isExiting.value && stack.isReplaced.value || view.value.isBlocked);
|
|
2846
|
+
useScrollLock(computed(() => isMounted.value && !hosted.value && !props.isInline && props.hasScrim && stack.shouldPresent.value));
|
|
2847
|
+
useModalOutletWhile(() => dialog.value ?? null, () => effectiveOpen.value && props.hasScrim && (view.value.isTop || !view.value.isStacked));
|
|
1586
2848
|
/** The dialog carries the accessible name; the panel keeps every other attribute. */
|
|
1587
2849
|
const dialogLabel = computed(() => {
|
|
1588
2850
|
if (attrs["aria-labelledby"] != null) return void 0;
|
|
@@ -1593,78 +2855,26 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1593
2855
|
const { "aria-label": _label, "aria-labelledby": _labelledBy, ...rest } = attrs;
|
|
1594
2856
|
return rest;
|
|
1595
2857
|
}
|
|
1596
|
-
const isScrollLocked = ref(false);
|
|
1597
|
-
useScrollLock(isScrollLocked);
|
|
1598
|
-
function lockScroll() {
|
|
1599
|
-
if (typeof document === "undefined") return;
|
|
1600
|
-
isScrollLocked.value = true;
|
|
1601
|
-
}
|
|
1602
|
-
function unlockScroll() {
|
|
1603
|
-
if (typeof document === "undefined") return;
|
|
1604
|
-
isScrollLocked.value = false;
|
|
1605
|
-
}
|
|
1606
|
-
function panelElement() {
|
|
1607
|
-
return panel.value?.element ?? null;
|
|
1608
|
-
}
|
|
1609
|
-
function focusPanel() {
|
|
1610
|
-
if (typeof document === "undefined") return;
|
|
1611
|
-
focusSheetOnOpen(panelElement(), props.hasScrim);
|
|
1612
|
-
}
|
|
1613
|
-
let focusRecord = null;
|
|
1614
|
-
const modalOutlet = createModalOutletHandle();
|
|
1615
|
-
function openSheet() {
|
|
1616
|
-
if (props.isInline || typeof document === "undefined") return;
|
|
1617
|
-
const dialogElement = dialog.value;
|
|
1618
|
-
if (!dialogElement) return;
|
|
1619
|
-
isPresented.value = true;
|
|
1620
|
-
if (!dialogElement.open) {
|
|
1621
|
-
focusRecord?.stop();
|
|
1622
|
-
focusRecord = trackLayerFocus({ getLayer: () => dialog.value });
|
|
1623
|
-
if (props.hasScrim) {
|
|
1624
|
-
dialogElement.showModal();
|
|
1625
|
-
isModalShown.value = true;
|
|
1626
|
-
if (!hosted.value) modalOutlet.attach(dialogElement);
|
|
1627
|
-
} else dialogElement.show();
|
|
1628
|
-
}
|
|
1629
|
-
if (props.hasScrim) lockScroll();
|
|
1630
|
-
focusPanel();
|
|
1631
|
-
}
|
|
1632
|
-
function closeSheet() {
|
|
1633
|
-
modalOutlet.detach();
|
|
1634
|
-
dialog.value?.close();
|
|
1635
|
-
unlockScroll();
|
|
1636
|
-
isPresented.value = false;
|
|
1637
|
-
isModalShown.value = false;
|
|
1638
|
-
focusRecord?.stop();
|
|
1639
|
-
focusRecord = null;
|
|
1640
|
-
const target = toValue(props.finalFocusRef);
|
|
1641
|
-
if (target?.isConnected) focusForLastInput(target, { preventScroll: true });
|
|
1642
|
-
}
|
|
1643
2858
|
const layer = useSheetLayerDismiss({
|
|
1644
|
-
isActive: computed(() => !hosted.value && !props.isInline &&
|
|
2859
|
+
isActive: computed(() => !hosted.value && !props.isInline && stack.shouldPresent.value),
|
|
1645
2860
|
escape: computed(() => {
|
|
1646
|
-
if (!
|
|
2861
|
+
if (!effectiveOpen.value || props.purpose === "required" || !isEscapeAllowed()) return "block";
|
|
1647
2862
|
if (!props.hasScrim) return "ignore";
|
|
1648
2863
|
return "close";
|
|
1649
2864
|
}),
|
|
1650
2865
|
getContainer: () => dialog.value ?? null,
|
|
1651
|
-
isPresent: () => dialog.value
|
|
2866
|
+
isPresent: () => isSheetHostPresented(dialog.value) && !view.value.isCovered && view.value.replacedMotion == null,
|
|
1652
2867
|
onDismiss: () => {
|
|
1653
|
-
if (!
|
|
2868
|
+
if (!effectiveOpen.value || props.purpose === "required") return;
|
|
1654
2869
|
requestClose();
|
|
1655
2870
|
}
|
|
1656
2871
|
});
|
|
1657
2872
|
function requestClose() {
|
|
1658
|
-
if (hosted.value && props.sheetId != null) {
|
|
1659
|
-
if (switcher?.activeId.value === props.sheetId) switcher.setActive(null);
|
|
1660
|
-
emit("openChange", false);
|
|
1661
|
-
return;
|
|
1662
|
-
}
|
|
1663
2873
|
isOpen.value = false;
|
|
1664
2874
|
emit("openChange", false);
|
|
1665
2875
|
}
|
|
1666
2876
|
function dismissOnEscape() {
|
|
1667
|
-
if (props.purpose === "required" || !isEscapeAllowed()) return;
|
|
2877
|
+
if (!effectiveOpen.value || props.purpose === "required" || !isEscapeAllowed()) return;
|
|
1668
2878
|
requestClose();
|
|
1669
2879
|
}
|
|
1670
2880
|
function onKeydown(event) {
|
|
@@ -1681,61 +2891,33 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1681
2891
|
}
|
|
1682
2892
|
function onDialogClick(event) {
|
|
1683
2893
|
if (event.target !== event.currentTarget) return;
|
|
1684
|
-
if (props.hasScrim && isDismissible.value) requestClose();
|
|
2894
|
+
if (props.hasScrim && isDismissible.value && effectiveOpen.value) requestClose();
|
|
2895
|
+
}
|
|
2896
|
+
function onPanelMotionStart(motion) {
|
|
2897
|
+
if (isPublicMotion(motion)) emit("motionStart", motion);
|
|
2898
|
+
stack.onMotionStart(motion);
|
|
1685
2899
|
}
|
|
1686
2900
|
function onPanelMotionComplete(motion) {
|
|
1687
|
-
emit("motionComplete", motion);
|
|
1688
|
-
|
|
2901
|
+
if (isPublicMotion(motion)) emit("motionComplete", motion);
|
|
2902
|
+
stack.onMotionComplete(motion);
|
|
1689
2903
|
}
|
|
1690
2904
|
watch(isOpen, (value) => {
|
|
1691
|
-
if (
|
|
1692
|
-
openSheet();
|
|
1693
|
-
}, { flush: "post" });
|
|
1694
|
-
watch(isOpen, (value) => {
|
|
1695
|
-
if (value) {
|
|
1696
|
-
scrimOpacity.value = 1;
|
|
1697
|
-
return;
|
|
1698
|
-
}
|
|
1699
|
-
isSettled.value = false;
|
|
1700
|
-
isModalShown.value = false;
|
|
2905
|
+
if (!value) isSettled.value = false;
|
|
1701
2906
|
});
|
|
1702
|
-
const
|
|
2907
|
+
const isExitHeld = computed(() => isExiting.value && !stack.isReplaced.value && stack.isCloseSettled.value);
|
|
1703
2908
|
let releaseExitHold = null;
|
|
1704
|
-
watch(
|
|
2909
|
+
watch(isExitHeld, (held) => {
|
|
1705
2910
|
releaseExitHold?.();
|
|
1706
2911
|
releaseExitHold = null;
|
|
1707
2912
|
const element = dialog.value;
|
|
1708
|
-
if (
|
|
2913
|
+
if (held && element != null) releaseExitHold = holdKeptInside(element, new Promise(() => {}));
|
|
1709
2914
|
}, { flush: "post" });
|
|
1710
2915
|
onMounted(() => {
|
|
1711
|
-
|
|
1712
|
-
switcher?.register(props.sheetId, {
|
|
1713
|
-
getElement: () => panelElement(),
|
|
1714
|
-
label: () => props.label,
|
|
1715
|
-
purpose: () => props.purpose
|
|
1716
|
-
});
|
|
1717
|
-
return;
|
|
1718
|
-
}
|
|
1719
|
-
if (isOpen.value) openSheet();
|
|
2916
|
+
isMounted.value = true;
|
|
1720
2917
|
});
|
|
1721
2918
|
onBeforeUnmount(() => {
|
|
1722
|
-
const record = focusRecord;
|
|
1723
|
-
focusRecord = null;
|
|
1724
|
-
if (record != null) {
|
|
1725
|
-
const wasStranded = isLayerFocusStranded(record, dialog.value);
|
|
1726
|
-
queueMicrotask(() => {
|
|
1727
|
-
if (wasStranded) restoreLayerFocus(record, {
|
|
1728
|
-
layer: null,
|
|
1729
|
-
name: "BottomSheet"
|
|
1730
|
-
});
|
|
1731
|
-
record.stop();
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1734
2919
|
releaseExitHold?.();
|
|
1735
2920
|
releaseExitHold = null;
|
|
1736
|
-
modalOutlet.detach();
|
|
1737
|
-
if (props.sheetId != null) switcher?.unregister(props.sheetId);
|
|
1738
|
-
unlockScroll();
|
|
1739
2921
|
});
|
|
1740
2922
|
__expose({
|
|
1741
2923
|
element: computed(() => panelElement()),
|
|
@@ -1743,23 +2925,18 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1743
2925
|
blur: () => panelElement()?.blur()
|
|
1744
2926
|
});
|
|
1745
2927
|
return (_ctx, _cache) => {
|
|
1746
|
-
return hosted.value
|
|
2928
|
+
return hosted.value && unref(switcher) != null && __props.sheetId != null ? (openBlock(), createBlock(_sfc_main$1, mergeProps({
|
|
1747
2929
|
key: 0,
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
ref: panel
|
|
1754
|
-
}, panelAttrs(), {
|
|
1755
|
-
state: panelState.value,
|
|
2930
|
+
ref_key: "step",
|
|
2931
|
+
ref: step
|
|
2932
|
+
}, unref(attrs), {
|
|
2933
|
+
switcher: unref(switcher),
|
|
2934
|
+
"sheet-id": __props.sheetId,
|
|
1756
2935
|
label: __props.label,
|
|
1757
2936
|
height: __props.height,
|
|
1758
2937
|
padding: __props.padding,
|
|
1759
2938
|
"snap-points": __props.snapPoints,
|
|
1760
|
-
|
|
1761
|
-
"is-page-scroll-locked": __props.hasScrim,
|
|
1762
|
-
onDismiss: requestClose,
|
|
2939
|
+
purpose: __props.purpose,
|
|
1763
2940
|
onSnap: _cache[0] || (_cache[0] = ($event) => emit("snap", $event)),
|
|
1764
2941
|
onMotionStart: _cache[1] || (_cache[1] = ($event) => emit("motionStart", $event)),
|
|
1765
2942
|
onMotionComplete: _cache[2] || (_cache[2] = ($event) => emit("motionComplete", $event))
|
|
@@ -1767,14 +2944,14 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1767
2944
|
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
1768
2945
|
_: 3
|
|
1769
2946
|
}, 16, [
|
|
1770
|
-
"
|
|
2947
|
+
"switcher",
|
|
2948
|
+
"sheet-id",
|
|
1771
2949
|
"label",
|
|
1772
2950
|
"height",
|
|
1773
2951
|
"padding",
|
|
1774
2952
|
"snap-points",
|
|
1775
|
-
"
|
|
1776
|
-
|
|
1777
|
-
])], 14, _hoisted_1)) : createCommentVNode("v-if", true)], 64)) : __props.isInline ? (openBlock(), createElementBlock("div", _hoisted_2, [isOpen.value ? (openBlock(), createElementBlock("div", _hoisted_3, [createVNode(_sfc_main$1, mergeProps({
|
|
2953
|
+
"purpose"
|
|
2954
|
+
])) : __props.isInline ? (openBlock(), createElementBlock("div", _hoisted_1, [isOpen.value ? (openBlock(), createElementBlock("div", _hoisted_2, [createVNode(_sfc_main$2, mergeProps({
|
|
1778
2955
|
ref_key: "panel",
|
|
1779
2956
|
ref: panel
|
|
1780
2957
|
}, panelAttrs(), {
|
|
@@ -1797,57 +2974,67 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1797
2974
|
])])) : createCommentVNode("v-if", true)])) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 点在 dialog 自身上等于点遮罩;键盘走原生 cancel 和下面的 keydown。 "), createElementVNode("dialog", {
|
|
1798
2975
|
ref_key: "dialog",
|
|
1799
2976
|
ref: dialog,
|
|
1800
|
-
class: normalizeClass(["astryx-bottom-sheet-dialog", {
|
|
2977
|
+
class: normalizeClass(["astryx-bottom-sheet-dialog", [unref(stackRecedeClasses)(unref(view)), {
|
|
1801
2978
|
"astryx-bottom-sheet-dialog--scrim": __props.hasScrim,
|
|
1802
|
-
"astryx-bottom-sheet-dialog--closing":
|
|
1803
|
-
|
|
2979
|
+
"astryx-bottom-sheet-dialog--closing": isExiting.value,
|
|
2980
|
+
"astryx-bottom-sheet-dialog--replacing": !__props.hasScrim && unref(view).isReplacing
|
|
2981
|
+
}]]),
|
|
1804
2982
|
"data-settled": isSettled.value || void 0,
|
|
2983
|
+
"data-sheet-stack": __props.hasScrim ? unref(stackStateAttribute)(unref(view), effectiveOpen.value) : void 0,
|
|
2984
|
+
"data-sheet-stack-depth": __props.hasScrim && unref(view).depth > 0 ? unref(view).depth : void 0,
|
|
1805
2985
|
"aria-label": dialogLabel.value,
|
|
1806
2986
|
"aria-labelledby": labelledBy.value,
|
|
1807
|
-
"aria-modal": __props.hasScrim && isModalShown.value ? "true" : void 0,
|
|
2987
|
+
"aria-modal": __props.hasScrim && effectiveOpen.value && unref(stack).isModalShown.value ? "true" : void 0,
|
|
2988
|
+
"aria-hidden": isInert.value ? "true" : void 0,
|
|
2989
|
+
inert: isInert.value || void 0,
|
|
1808
2990
|
role: __props.purpose === "required" ? "alertdialog" : void 0,
|
|
1809
|
-
style: normalizeStyle(dialogStyle.value),
|
|
1810
2991
|
onCancel,
|
|
1811
2992
|
onClick: onDialogClick,
|
|
1812
2993
|
onKeydown
|
|
1813
2994
|
}, [
|
|
1814
|
-
createElementVNode("div",
|
|
2995
|
+
createElementVNode("div", _hoisted_4, [createVNode(_sfc_main$2, mergeProps({
|
|
1815
2996
|
ref_key: "panel",
|
|
1816
2997
|
ref: panel
|
|
1817
2998
|
}, panelAttrs(), {
|
|
1818
2999
|
state: panelState.value,
|
|
3000
|
+
"retained-motion": unref(view).replacedMotion ?? "covered",
|
|
3001
|
+
"alignment-offset": unref(view).alignmentOffset,
|
|
1819
3002
|
label: __props.label,
|
|
1820
3003
|
height: __props.height,
|
|
1821
3004
|
padding: __props.padding,
|
|
1822
3005
|
"snap-points": __props.snapPoints,
|
|
1823
|
-
"is-swipe-dismiss-allowed":
|
|
1824
|
-
"is-page-scroll-locked":
|
|
3006
|
+
"is-swipe-dismiss-allowed": __props.purpose === "info",
|
|
3007
|
+
"is-page-scroll-locked": __props.hasScrim && unref(stack).shouldPresent.value,
|
|
1825
3008
|
onDismiss: requestClose,
|
|
1826
|
-
onScrimOpacity:
|
|
1827
|
-
onScrimFade:
|
|
1828
|
-
onSnap: _cache[
|
|
1829
|
-
onMotionStart:
|
|
3009
|
+
onScrimOpacity: unref(stack).onScrimOpacity,
|
|
3010
|
+
onScrimFade: unref(stack).onScrimFade,
|
|
3011
|
+
onSnap: _cache[4] || (_cache[4] = ($event) => emit("snap", $event)),
|
|
3012
|
+
onMotionStart: onPanelMotionStart,
|
|
1830
3013
|
onMotionComplete: onPanelMotionComplete
|
|
1831
3014
|
}), {
|
|
1832
3015
|
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
1833
3016
|
_: 3
|
|
1834
3017
|
}, 16, [
|
|
1835
3018
|
"state",
|
|
3019
|
+
"retained-motion",
|
|
3020
|
+
"alignment-offset",
|
|
1836
3021
|
"label",
|
|
1837
3022
|
"height",
|
|
1838
3023
|
"padding",
|
|
1839
3024
|
"snap-points",
|
|
1840
3025
|
"is-swipe-dismiss-allowed",
|
|
1841
|
-
"is-page-scroll-locked"
|
|
3026
|
+
"is-page-scroll-locked",
|
|
3027
|
+
"onScrimOpacity",
|
|
3028
|
+
"onScrimFade"
|
|
1842
3029
|
])]),
|
|
1843
|
-
_cache[
|
|
3030
|
+
_cache[5] || (_cache[5] = createElementVNode("div", {
|
|
1844
3031
|
class: "astryx-bottom-sheet__edge-tint",
|
|
1845
3032
|
"aria-hidden": "true"
|
|
1846
3033
|
}, null, -1)),
|
|
1847
|
-
createElementVNode("div",
|
|
1848
|
-
],
|
|
3034
|
+
createElementVNode("div", _hoisted_5, null, 512)
|
|
3035
|
+
], 42, _hoisted_3)], 2112));
|
|
1849
3036
|
};
|
|
1850
3037
|
}
|
|
1851
3038
|
});
|
|
1852
3039
|
//#endregion
|
|
1853
|
-
export {
|
|
3040
|
+
export { writeScrimOpacity as _, isClosingTogether as a, focusSheetPanel as b, reportClosedTogether as c, bottomSheetSwitcherKey as d, cancelScrimWrite as f, returnFocusTo as g, presentWithClearScrim as h, getBottomSheetBeneath as i, setBottomSheetOpen as l, presentStepModally as m, _sfc_main as n, notifyBottomSheetHostChanged as o, closeDialogKeepingFocus as p, useSheetLayerDismiss as r, registerBottomSheet as s, BottomSheet_exports as t, useModalOutletWhile as u, BOTTOM_SHEET_STACK_DEFAULT_VIEW as v, bottomSheetHostKey as y };
|