@astryx-vue/core 0.41.0 → 0.42.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-DxrO48Kg.js → AlertDialog-Cld8wc2u.js} +3 -3
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/AvatarGroup/index.js +1 -1
- package/dist/{AvatarGroup-BZ5iG7M-.js → AvatarGroup-CU1zqtTi.js} +1 -1
- package/dist/Banner/index.d.ts +1 -1
- package/dist/Banner/index.js +1 -1
- package/dist/{Banner-0YtnbBU6.js → Banner-5KOS4fe8.js} +1 -1
- package/dist/BottomSheet/index.d.ts +1 -1
- package/dist/Breadcrumbs/index.d.ts +2 -2
- package/dist/Breadcrumbs/index.js +2 -2
- package/dist/{Breadcrumbs-9KMHiyXr.js → Breadcrumbs-Bcrk04nL.js} +1 -1
- package/dist/Button/index.js +1 -1
- package/dist/{Button-ClyetTf6.js → Button-tVILPfaj.js} +2 -2
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/ButtonGroup/index.js +1 -1
- package/dist/{ButtonGroup-tk0H2O8q.js → ButtonGroup-D7p8oEry.js} +2 -2
- package/dist/Calendar/index.d.ts +1 -1
- package/dist/Calendar/index.js +2 -2
- package/dist/{Calendar-CfhOlgQJ.js → Calendar-Brz2iDeZ.js} +1 -1
- package/dist/{Calendar-DbAQvHgy.js → Calendar-C1E1ZiaS.js} +1 -1
- package/dist/Carousel/index.d.ts +1 -1
- package/dist/Carousel/index.js +1 -1
- package/dist/{Carousel-utfvjW5p.js → Carousel-DlHeba5J.js} +1 -1
- package/dist/Chat/index.d.ts +1 -1
- package/dist/Chat/index.js +1 -1
- package/dist/{Chat-DL583Xle.js → Chat-B0jgkmWf.js} +1 -1
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxInput/index.js +1 -1
- package/dist/{CheckboxInput-BQH87pfn.js → CheckboxInput-BhKf3JOh.js} +4 -4
- package/dist/CheckboxList/index.d.ts +1 -1
- package/dist/CheckboxList/index.js +1 -1
- package/dist/{CheckboxListItem-CZ1B81gI.js → CheckboxListItem-DFCDLwLP.js} +4 -4
- package/dist/ClickableCard/index.d.ts +1 -1
- package/dist/ClickableCard/index.js +1 -1
- package/dist/{ClickableCard-CdByvXDr.js → ClickableCard-DyBa2X4I.js} +1 -1
- package/dist/Code/index.js +2 -2
- package/dist/{Code-KvqZ1ZES.js → Code-BtJV5J-h.js} +1 -1
- package/dist/{CodeBlock-e2rlXQWO.js → CodeBlock-D1i3lEK3.js} +1 -1
- package/dist/Collapsible/index.d.ts +1 -1
- package/dist/Collapsible/index.js +1 -1
- package/dist/{Collapsible-CTc7irlw.js → Collapsible-CXbcOn80.js} +1 -1
- package/dist/CommandPalette/index.d.ts +1 -1
- package/dist/CommandPalette/index.js +1 -1
- package/dist/{CommandPalette-PBYSDIpx.js → CommandPalette-DyjB9xE_.js} +1 -1
- package/dist/ComplexSelector/index.js +1 -1
- package/dist/{ComplexSelector-CPg5jcdL.js → ComplexSelector-MRuOupEd.js} +2 -2
- package/dist/ContextMenu/index.d.ts +2 -2
- package/dist/ContextMenu/index.js +2 -2
- package/dist/{ContextMenu-DcZEviKv.js → ContextMenu-JZUal7pu.js} +1 -1
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-C4qtEFDW.js → DateInput-B76O2ceL.js} +579 -78
- package/dist/DateRangeInput/index.d.ts +1 -1
- package/dist/DateRangeInput/index.js +1 -1
- package/dist/{DateRangeInput-CGqCQAlT.js → DateRangeInput-B8ZWK6sm.js} +4 -4
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.js +1 -1
- package/dist/{DateTimeInput-CAirxttc.js → DateTimeInput-DOaPB2D4.js} +4 -4
- package/dist/Dialog/index.js +1 -1
- package/dist/{DialogHeader-BS8mjD8z.js → DialogHeader-B4cnOihd.js} +1 -1
- package/dist/Drawer/index.d.ts +1 -1
- package/dist/Drawer/index.js +1 -1
- package/dist/{Drawer-Cq1Y_1iJ.js → Drawer-dk9etcN3.js} +1 -1
- package/dist/DropdownMenu/index.d.ts +2 -2
- package/dist/DropdownMenu/index.js +2 -2
- package/dist/{DropdownMenu-CSn1OQ2D.js → DropdownMenu-Dqkyvelz.js} +3 -3
- package/dist/{DropdownMenuRadioItem.vue-BFCbIBfb.d.ts → DropdownMenuRadioItem.vue-BrcSzOfA.d.ts} +1 -1
- package/dist/Field/index.js +3 -3
- package/dist/{Field-BzGwGqwa.js → Field-B_GThk2X.js} +1 -1
- package/dist/{FieldInfoTip-DqsdZxo0.js → FieldInfoTip-jhm02XZs.js} +1 -1
- package/dist/{FieldLabel-DdMLaCP_.js → FieldLabel-C0XDwWCd.js} +1 -1
- package/dist/FileInput/index.js +1 -1
- package/dist/{FileInput-B_BXknEU.js → FileInput-CbXrw3RO.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-kj1M_L7a.js → IconButton-CU1kvO7X.js} +1 -1
- package/dist/InfoTip/index.d.ts +1 -1
- package/dist/InfoTip/index.js +1 -1
- package/dist/{InfoTip-DJIb8b29.js → InfoTip-BwxUx7Hk.js} +1 -1
- package/dist/{InputClearButton-wd0VoZja.js → InputClearButton-CN8J7JOl.js} +1 -1
- package/dist/InputGroup/index.js +1 -1
- package/dist/{InputGroup-DGiF9Xaz.js → InputGroup-Ca-SOzyp.js} +1 -1
- package/dist/InternationalizationProvider/index.d.ts +1 -1
- package/dist/InternationalizationProvider/index.js +2 -1
- package/dist/{InternationalizationProvider-BkJ8Z7ox.js → InternationalizationProvider-Ddr5L4mQ.js} +5 -61
- package/dist/Item-B6nYjAw3.js +1476 -0
- package/dist/Lightbox/index.js +1 -1
- package/dist/{Lightbox-Fu6RCX0k.js → Lightbox-DCI-S6Ln.js} +1 -1
- package/dist/Link/index.d.ts +1 -1
- package/dist/Link/index.js +1 -1
- package/dist/{Link-zPVCNAM6.js → Link-B5CJso43.js} +1 -1
- package/dist/List/index.d.ts +4 -3
- package/dist/List/index.js +5 -4
- package/dist/List-DuWNjAKk.js +69 -0
- package/dist/{ListItem-CrFLvZ6o.js → ListItem-BxQt4Emy.js} +9 -4
- package/dist/Markdown/index.d.ts +1 -1
- package/dist/Markdown/index.js +1 -1
- package/dist/{Markdown-BiXz75mz.js → Markdown-BFV7g8oa.js} +118 -59
- package/dist/MetadataList/index.d.ts +1 -1
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-RbFK2t0J.js → MoreMenu-DOVbdDmP.js} +2 -2
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-CaL3UDIc.js → MultiSelector-BLESAk-K.js} +3 -3
- package/dist/NavItem/index.js +1 -1
- package/dist/{NavItem-D_1ecPv_.js → NavItem-BR639emm.js} +1 -1
- package/dist/NavMenu/index.js +1 -1
- package/dist/{NavMenuItem-DqBCA1VP.js → NavMenuItem-C9e62bSc.js} +1 -1
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/NumberInput/index.js +1 -1
- package/dist/{NumberInput-0lTA5weY.js → NumberInput-C7cRBlQm.js} +3 -3
- package/dist/Outline/index.js +1 -1
- package/dist/{Outline-BoxN40Bd.js → Outline-BcZMmO9Y.js} +1 -1
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/OverflowList/index.js +1 -1
- package/dist/{OverflowList-7oui4oT5.js → OverflowList-cjl0AaEP.js} +1 -1
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-BrkX0lga.js → Pagination-BnA277o8.js} +2 -2
- package/dist/Popover/index.d.ts +1 -1
- package/dist/Popover/index.js +1 -1
- package/dist/{Popover-BZ4VWDtv.js → Popover-DfO-mkcm.js} +1 -1
- package/dist/PowerSearch/index.d.ts +1 -1
- package/dist/PowerSearch/index.js +1 -1
- package/dist/{PowerSearch-BEDWm7aj.js → PowerSearch-CvBTNf6L.js} +20 -20
- package/dist/Radio/index.d.ts +1 -1
- package/dist/Radio/index.js +1 -1
- package/dist/{RadioGroup-CrRm7H51.js → RadioGroup-CVOlUPbf.js} +4 -4
- package/dist/RadioList/index.d.ts +1 -1
- package/dist/RadioList/index.js +1 -1
- package/dist/{RadioListItem-iPD3y2Eo.js → RadioListItem-5y613Xrt.js} +1 -1
- package/dist/Resizable/index.d.ts +1 -1
- package/dist/ScrollableArea/index.d.ts +1 -1
- package/dist/SegmentedControl/index.js +1 -1
- package/dist/{SegmentedControl-D8A_jaFC.js → SegmentedControl-B6BQlTfN.js} +3 -3
- package/dist/SelectableCard/index.d.ts +1 -1
- package/dist/SelectableCard/index.js +1 -1
- package/dist/{SelectableCard-DIruuGBa.js → SelectableCard-C2hl7HBW.js} +1 -1
- package/dist/Selector/index.d.ts +1 -1
- package/dist/Selector/index.js +1 -1
- package/dist/{Selector-CFdM10Uc.js → Selector-Dw_0e0zY.js} +1 -1
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +1 -1
- package/dist/{SideNav-Cl1H-baW.js → SideNav-dsff7R2R.js} +2 -2
- package/dist/Slider/index.js +1 -1
- package/dist/{Slider-Bd3wpFo7.js → Slider-CN5NOM10.js} +3 -3
- package/dist/Stack/index.d.ts +1 -1
- package/dist/Stepper/index.d.ts +1 -1
- package/dist/Stepper/index.js +1 -1
- package/dist/{Stepper-CZU_Zvi5.js → Stepper-BYZasZK7.js} +1 -1
- package/dist/Swipe/index.d.ts +3 -0
- package/dist/Swipe/index.js +2 -0
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-BpkKyz98.js → Switch-DHr3_O1r.js} +4 -4
- package/dist/TabList/index.d.ts +1 -1
- package/dist/TabList/index.js +1 -1
- package/dist/{TabList-DZ2i0QIt.js → TabList-O34fxJlZ.js} +1 -1
- package/dist/Table/index.d.ts +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/{Table-kq_-RxXg.js → Table-sTJtTqmi.js} +11 -11
- 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-D5aDDlgr.js → TextArea-TO_A1D_W.js} +4 -4
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/TextInput/index.js +1 -1
- package/dist/{TextInput-CVRWRtoL.js → TextInput-jIBboBDS.js} +4 -4
- package/dist/Thumbnail/index.js +1 -1
- package/dist/{Thumbnail-zFN5p6dk.js → Thumbnail-CRltyNsq.js} +2 -2
- package/dist/{TimeField-B49DgkyR.js → TimeField-BG409_10.js} +1 -1
- package/dist/TimeInput/index.d.ts +1 -1
- package/dist/TimeInput/index.js +1 -1
- package/dist/{TimeInput-BoFij92p.js → TimeInput-CQzBs55U.js} +2 -2
- package/dist/Timestamp/index.d.ts +1 -1
- package/dist/Timestamp/index.js +1 -1
- package/dist/{Timestamp-DunFvQYG.js → Timestamp-s4Nksy5i.js} +1 -1
- package/dist/Toast/index.js +1 -1
- package/dist/{Toast-BnIq3gzw.js → Toast-DcKB9QHW.js} +1 -1
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/ToggleButton/index.js +1 -1
- package/dist/{ToggleButton-CLgj6yLQ.js → ToggleButton-DZgHhJd7.js} +3 -3
- package/dist/Token/index.d.ts +1 -1
- package/dist/Token/index.js +1 -1
- package/dist/{Token-BPjnWrHl.js → Token-B6mV8hyk.js} +1 -1
- package/dist/Tokenizer/index.d.ts +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-CMv-Bi0y.js → Tokenizer-BvCiuyhk.js} +5 -5
- 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/TopNav/index.js +1 -1
- package/dist/{TopNav-DUkn4CMv.js → TopNav-xKD14HTR.js} +2 -2
- package/dist/TreeList/index.js +1 -1
- package/dist/{TreeList-o5MrA7rz.js → TreeList-BOr0GpJC.js} +1 -1
- package/dist/Typeahead/index.js +1 -1
- package/dist/{Typeahead-DXlsxjkQ.js → Typeahead-C18-lx2P.js} +3 -3
- package/dist/{accessibleName-9UI6HUaA.js → accessibleName-Chl0zwq_.js} +1 -1
- package/dist/{boxHold-DfsWCZLh.js → boxHold-BCbXt9_d.js} +1 -1
- package/dist/composables/index.js +4 -3
- package/dist/{composables-Dzpv7G2Z.js → composables-CKAzgdPD.js} +3 -473
- package/dist/context-BNCjTOCB.js +60 -0
- package/dist/createSwipe-DXObfkyb.js +77 -0
- package/dist/{index-CqvIpZ-t.d.ts → index-3vt1Ew4A.d.ts} +1 -1
- package/dist/{index-DQ5vPsr8.d.ts → index-B9LwZ19y.d.ts} +5 -5
- package/dist/{index-BgT6mH3U.d.ts → index-BB9acgK8.d.ts} +1 -1
- package/dist/{index-BIcmTipH.d.ts → index-BItxjc3w.d.ts} +1 -1
- package/dist/{index-C1e8LNx2.d.ts → index-BjqoHLMq.d.ts} +1 -1
- package/dist/{index-DofC9Rll.d.ts → index-BtqvPjAf.d.ts} +1 -1
- package/dist/{index-DLPSlnXP.d.ts → index-C2dLjYoW.d.ts} +1 -1
- package/dist/{index-waTkqxTz.d.ts → index-C89cIh4E.d.ts} +1 -1
- package/dist/{index-Bwh8O-v8.d.ts → index-CZ29Xu_E.d.ts} +1 -1
- package/dist/{index-rdwI-mcm.d.ts → index-CtYlR9Cu.d.ts} +1 -1
- package/dist/{index-DYabo8TI.d.ts → index-DPhQZXYw.d.ts} +1 -1
- package/dist/index-DPsvfn2V.d.ts +25 -0
- package/dist/{index-DCH2D3wa.d.ts → index-Dn6iAyK4.d.ts} +4 -4
- package/dist/{index-m-fFGq2e.d.ts → index-Ds4dOCSy.d.ts} +1 -1
- package/dist/{index-B7-c8UTz.d.ts → index-J83fLEyo.d.ts} +3 -3
- package/dist/{index-COqeB2ug.d.ts → index-Nln6FiRr.d.ts} +1 -1
- package/dist/{index-4_uuTfaY.d.ts → index-VWHtgjGh.d.ts} +1 -1
- package/dist/{index-DrbxKOhR.d.ts → index-lNjYxF1K.d.ts} +41 -40
- package/dist/{index-Cm36VS1A.d.ts → index-mK1ICsVg.d.ts} +2 -2
- package/dist/{index-a6o69uPN.d.ts → index-tdOyqA_U.d.ts} +2 -2
- package/dist/{index-NOXYEdOI.d.ts → index-utZGF4GR.d.ts} +1 -1
- package/dist/{index-BylgDU_m.d.ts → index-v27zktLu.d.ts} +49 -5
- package/dist/{index-ql9ApSTF.d.ts → index-yQc-te9a.d.ts} +2 -2
- package/dist/index.d.ts +29 -27
- package/dist/index.js +83 -80
- package/dist/itemSlots-Dl7Ipj5I.js +539 -0
- package/dist/{loadCatalog-S2AgQN51.d.ts → loadCatalog-DfwwR4ox.d.ts} +2 -0
- package/dist/{loadCatalog-baFZaTpj.js → loadCatalog-Dvlsgn71.js} +6 -0
- package/dist/locale/index.d.ts +2 -2
- package/dist/locale/index.js +2 -2
- package/dist/{locale-BIyfn-cf.js → locale-BgXR3tSm.js} +1 -1
- package/dist/{pressSlot-5Bp-B175.js → pressSlot-31XyOhUS.js} +20 -2
- package/dist/swipeHost-B2OlVVZt.d.ts +73 -0
- package/dist/{types-D9mwL8sz.d.ts → types-wKC-Ws-M.d.ts} +29 -10
- package/dist/{useActionGroupTracking-Cujjrmt3.js → useActionGroupTracking-CioHSqgG.js} +2 -2
- package/dist/{useCalendarGrid-0WvxbeFC.js → useCalendarGrid-BpBA8UZa.js} +1 -1
- package/dist/{useInputStatusIcon-2sRn-Nbf.js → useInputStatusIcon-D0xNp9jO.js} +1 -1
- package/dist/{usePressFeedback-Ber7MRiI.js → usePressFeedback-D4oohqP5.js} +1 -1
- package/dist/{useTouchHitArea-B6g7fhfF.js → useTouchHitArea-rwyNMxFb.js} +1 -1
- package/package.json +5 -1
- package/styles/date-input.css +36 -0
- package/styles/list-reorder.css +6 -3
- package/styles/list.css +125 -69
- package/styles/markdown.css +17 -0
- package/dist/Item-DC1v56yE.js +0 -723
- package/dist/itemSlots-BxUu7hje.js +0 -54
- package/dist/{index-BqhgeAT4.d.ts → index-J6YRJ7Ul.d.ts} +1 -1
|
@@ -0,0 +1,1476 @@
|
|
|
1
|
+
import { a as subscribeInput } from "./inputStream-DmPkJ1aU.js";
|
|
2
|
+
import { f as toSpring } from "./roles-D6hLs7Rg.js";
|
|
3
|
+
import { c as solveSpring } from "./linearEasing-CDsqxyiS.js";
|
|
4
|
+
import { a as isInLayerSurface, o as isLayerSurface } from "./useClickableContainer-Dtjg-nkm.js";
|
|
5
|
+
import { h as setPressHeld } from "./pressSlot-31XyOhUS.js";
|
|
6
|
+
import { t as usePressFeedback } from "./usePressFeedback-D4oohqP5.js";
|
|
7
|
+
import { n as readLayerScoped } from "./scopedProvide-C-Df7c15.js";
|
|
8
|
+
import { n as isSafeUrl } from "./safeUrl-CsvfcZ9m.js";
|
|
9
|
+
import { n as useLinkComponent } from "./context-C_peZbXf.js";
|
|
10
|
+
import { n as useDevWarning } from "./useDevWarning-B2fsk2B-.js";
|
|
11
|
+
import { t as resolveMotion } from "./resolveMotion-BHR1cz0Q.js";
|
|
12
|
+
import { i as getGestureHost } from "./geometry-ae8bOxQ5.js";
|
|
13
|
+
import { n as lockSelection } from "./selectionLock-BM8XEZQD.js";
|
|
14
|
+
import { t as isCoarsePointer } from "./coarsePointer-BWNSUIY8.js";
|
|
15
|
+
import { t as isRtlElement } from "./isRtlElement-NHuH48AA.js";
|
|
16
|
+
import { a as itemDescriptionContextKey, d as DEFAULT_FLICK_THRESHOLD, i as useItemSlotsFromWrapper, o as itemListRowKey, u as createSnapDrag } from "./itemSlots-Dl7Ipj5I.js";
|
|
17
|
+
import { t as resolveSnapPoint } from "./resolveSnapPoint-C7GZY6jT.js";
|
|
18
|
+
import { t as useInteractiveRole } from "./useInteractiveRole-Cn0Nd5GX.js";
|
|
19
|
+
import { n as reducedMotionFade } from "./reducedMotion-BcstlXZU.js";
|
|
20
|
+
import { t as useFocusAcrossSwap } from "./focusAcrossSwap-Casww_IY.js";
|
|
21
|
+
import { n as disabledInteractionProps } from "./disabledInteraction-Bqoyhoss.js";
|
|
22
|
+
import { t as TapGestureRecognizer } from "./TapGestureRecognizer-DCiP88h8.js";
|
|
23
|
+
import { t as useGestureRecognizer } from "./useGestureRecognizer-CtfxP4uw.js";
|
|
24
|
+
import { n as createSwipeHost, r as swipeHostOf } from "./createSwipe-DXObfkyb.js";
|
|
25
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, h, mergeProps, normalizeClass, normalizeStyle, onScopeDispose, openBlock, provide, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toRaw, toValue, unref, useAttrs, useId, useSlots, useTemplateRef, watch, watchEffect, withCtx, withModifiers } from "vue";
|
|
26
|
+
import "../styles/list.css";
|
|
27
|
+
//#region src/motion/uikit/swipeActions.ts
|
|
28
|
+
/**
|
|
29
|
+
* @file swipeActions.ts
|
|
30
|
+
* @input Nothing; data only
|
|
31
|
+
* @output Exports `swipeActions`: the swipe-action row's gesture thresholds,
|
|
32
|
+
* the web's claim and UIKit's swipe. Also its tracking and settle springs,
|
|
33
|
+
* and the speed and position that pick where a release lands
|
|
34
|
+
* @position The swipe-actions domain of the UIKit constants table
|
|
35
|
+
* (motion/uikit): `UIContextualAction` / `UISwipeActionsConfiguration` rows
|
|
36
|
+
* of a table or collection list
|
|
37
|
+
*
|
|
38
|
+
* Measured on a UIKit host app (plain `UITableView`, 402 pt rows, two
|
|
39
|
+
* trailing actions, iOS 26.2). Lengths are in pt (CSS px), springs in the
|
|
40
|
+
* vocabulary UIKit was read in (`toSpring` normalizes).
|
|
41
|
+
*
|
|
42
|
+
* Every leaf carries one or more `@source`; GUESS values also carry the
|
|
43
|
+
* `@measure` task that will confirm or replace them. uikit.test.ts enforces
|
|
44
|
+
* both.
|
|
45
|
+
*
|
|
46
|
+
* Reduce Motion is not a value here. UIKit keeps both springs under it. In the
|
|
47
|
+
* lab (iOS 26.2 simulator, iPhone 17 Pro, Reduce Motion on), tracking and
|
|
48
|
+
* release use the same animators. They are `UISpringTimingParameters(mass: 2,
|
|
49
|
+
* stiffness: 200, damping: 100)`, and the full swipe still performs. Astryx's
|
|
50
|
+
* Reduce Motion rules govern instead: what a release starts cross-fades, and a
|
|
51
|
+
* core component keeps no motion under it.
|
|
52
|
+
*/
|
|
53
|
+
const swipeActions = {
|
|
54
|
+
/**
|
|
55
|
+
* Sideways travel at which the row claims the touch from the browser, NOT a
|
|
56
|
+
* UIKit value. On the web a scrolling ancestor takes the touch at about 10
|
|
57
|
+
* px, unless the page cancels `touchmove` before that. So the row claims at 8
|
|
58
|
+
* px. From there a finger's row is at the finger's travel since touch-down.
|
|
59
|
+
* Before it, the touch moves neither the row nor the page.
|
|
60
|
+
* @source measured: Mobile Safari, iOS 26.2 simulator, iPhone 17 Pro, the
|
|
61
|
+
* touch stream against WebKit's scroll commit on a scrollable element
|
|
62
|
+
* (the last cancelable `touchmove` at 10 px; cancelling every `touchmove`
|
|
63
|
+
* from 8 px keeps the page still for the whole gesture), Oct 23 2026
|
|
64
|
+
*/
|
|
65
|
+
claim: 8,
|
|
66
|
+
/**
|
|
67
|
+
* UIKit's finger travel before its swipe begins. A finger's row follows
|
|
68
|
+
* from `claim`. This value sets where UIKit's measure of the swipe counts
|
|
69
|
+
* from, and the confirm point is judged on that measure.
|
|
70
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
71
|
+
* iPhone 17 Pro, `_UISwipeActionPanGestureRecognizer` `_hysteresis` ivar
|
|
72
|
+
* read (25) and a 1 pt step drag: began at exactly 25 pt of travel with
|
|
73
|
+
* a translation of 0, Oct 23 2026
|
|
74
|
+
*/
|
|
75
|
+
hysteresis: 25,
|
|
76
|
+
/**
|
|
77
|
+
* UIKit's tracking spring. A held row stays under the finger, one for one,
|
|
78
|
+
* with no spring. A confirmed row runs ahead to the confirmation offset on
|
|
79
|
+
* this spring, and a trackpad's confirm or back-out springs the row on it.
|
|
80
|
+
* In UIKit, each tracking update starts it toward the finger. Overdamped
|
|
81
|
+
* on paper; Core Animation renders it critically damped (allowsOverdamping
|
|
82
|
+
* off), ω₀ = 10 rad/s, which `toSpring` mirrors.
|
|
83
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
84
|
+
* iPhone 17 Pro, `UIViewPropertyAnimator` with
|
|
85
|
+
* `UISpringTimingParameters(mass: 2, stiffness: 200, damping: 100)`
|
|
86
|
+
* read on every tracking update, seeded with the presentation velocity,
|
|
87
|
+
* settlingDuration 0.9235 s, Oct 23 2026
|
|
88
|
+
*/
|
|
89
|
+
tracking: {
|
|
90
|
+
mass: 2,
|
|
91
|
+
stiffness: 200,
|
|
92
|
+
damping: 100
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* The settle after the finger lifts, to open, to closed or out. It is the
|
|
96
|
+
* same spring, seeded with the row's presentation velocity (the tracking
|
|
97
|
+
* spring's), not with the finger's.
|
|
98
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
99
|
+
* iPhone 17 Pro, the release animator read: mass 2, stiffness 200,
|
|
100
|
+
* damping 100, rendered critically damped; a 1000 pt/s closing flick
|
|
101
|
+
* seeded it with the presentation velocity (initialVelocity 2.88), not
|
|
102
|
+
* the finger's, Oct 23 2026
|
|
103
|
+
*/
|
|
104
|
+
settle: {
|
|
105
|
+
mass: 2,
|
|
106
|
+
stiffness: 200,
|
|
107
|
+
damping: 100
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* Where a slow release lands (one slower than `releaseVelocity`): past
|
|
111
|
+
* this fraction of the open width the row opens, short of it the row
|
|
112
|
+
* closes.
|
|
113
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
114
|
+
* iPhone 17 Pro, releases at rest: 0.32 × the 156.67 pt open width
|
|
115
|
+
* closed and 0.56 opened (batch 10a), Oct 23 2026
|
|
116
|
+
* @source GUESS — the fraction inside the measured 0.32 to 0.56 bracket
|
|
117
|
+
* @measure M-SA01
|
|
118
|
+
*/
|
|
119
|
+
openFraction: .5,
|
|
120
|
+
/**
|
|
121
|
+
* A release this fast goes the way it moves, from anywhere short of the
|
|
122
|
+
* commit point. It opens the row when it opens, and closes it when it closes.
|
|
123
|
+
* A flick therefore never fires an action. The speed is the release velocity
|
|
124
|
+
* of a dragged surface: the pan's velocity as the finger lifts. It is 0 once
|
|
125
|
+
* the finger has stayed still before lifting. There UIKit's pan, which never
|
|
126
|
+
* decays, still reports its last moving speed. The measurements below are
|
|
127
|
+
* UIKit's pan velocities.
|
|
128
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
129
|
+
* iPhone 17 Pro, the swipe pan's velocity read at its end: released past
|
|
130
|
+
* half the open width while closing at 19.9, 21.2, 35.7 and 40.7 pt/s
|
|
131
|
+
* the row opened, and at 56.1, 56.5, 68.5, 105, 200 and 308 pt/s it
|
|
132
|
+
* closed (batch 38d); of 51 releases every one at 283 pt/s or more went
|
|
133
|
+
* its way (batch 10a), Oct 23 2026
|
|
134
|
+
* @source GUESS — the speed inside the measured 40.7 to 56.1 pt/s bracket
|
|
135
|
+
* @measure M-SA05
|
|
136
|
+
*/
|
|
137
|
+
releaseVelocity: 48,
|
|
138
|
+
/**
|
|
139
|
+
* Where the full swipe confirms. On confirming, the row's offset snaps to
|
|
140
|
+
* this far short of the row's far edge. It is UIKit's
|
|
141
|
+
* `confirmationThreshold`: the table width less this inset, whatever the
|
|
142
|
+
* action count.
|
|
143
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
144
|
+
* iPhone 17 Pro, `UISwipeActionPullView.confirmationThreshold` read:
|
|
145
|
+
* −373 at 402 pt and −346 at 375 pt, with one, two and three actions
|
|
146
|
+
* (batch 10b); on confirming the row jumped from −326 to −376.6 ahead of
|
|
147
|
+
* the finger (batch 38), Oct 23 2026
|
|
148
|
+
*/
|
|
149
|
+
confirmInset: 29,
|
|
150
|
+
/**
|
|
151
|
+
* How far the finger must drag from the open width toward the confirmation
|
|
152
|
+
* offset for the full swipe to confirm. The confirmation offset is the row
|
|
153
|
+
* width less `confirmInset`. Judged on the finger's travel, not the row's:
|
|
154
|
+
* past the confirm point the row runs ahead of the finger.
|
|
155
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
156
|
+
* iPhone 17 Pro, 402 pt rows: with a 204.67 pt open width a release
|
|
157
|
+
* performed from 335 pt of swipe and not from 315, at every velocity
|
|
158
|
+
* tried, and backing out from 345 to 315 left the row unconfirmed
|
|
159
|
+
* (batch 38); with a 156.67 pt open width it performed from 315 and not
|
|
160
|
+
* from 275 (batch 10b): 0.655 to 0.732 of the way, Oct 23 2026
|
|
161
|
+
* @source GUESS — the fraction inside the measured 0.655 to 0.732 bracket
|
|
162
|
+
* @measure M-SA02
|
|
163
|
+
*/
|
|
164
|
+
confirmFraction: .69,
|
|
165
|
+
/**
|
|
166
|
+
* How far past the row's edge the row travels when an action fires and
|
|
167
|
+
* the row goes out.
|
|
168
|
+
* @source GUESS — the distance Astryx used before the UIKit lab
|
|
169
|
+
* @measure M-SA04
|
|
170
|
+
*/
|
|
171
|
+
slideOutOvershoot: 24
|
|
172
|
+
};
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/Swipe/swipeRelease.ts
|
|
175
|
+
/**
|
|
176
|
+
* @file swipeRelease.ts
|
|
177
|
+
* @input UIKit 的横滑常量表(motion/uikit/swipeActions.ts)
|
|
178
|
+
* @output 横滑的纯规则:松手落在哪(resolveRelease)、确认点(confirmPoint、confirmedOffset)、
|
|
179
|
+
* 一侧的几何和停靠点、确认进度(confirmOf),以及状态类型和面板读的 CSS 自定义属性名
|
|
180
|
+
* @position 横滑模块的纯函数层,不碰 DOM。swipeDragModel.ts 和 useSwipeAction.ts 用它,
|
|
181
|
+
* swipeRelease.test.ts 直接测它。
|
|
182
|
+
*/
|
|
183
|
+
/**
|
|
184
|
+
* 松手落在哪。`travel`(px,≥ 0)和 `velocity`(px/s)是逻辑方向,朝正在露出的一侧为正。
|
|
185
|
+
* `isConfirmed`:抬起时手指在确认点外;`wasConfirmed`:这次横滑中曾经越过确认点。
|
|
186
|
+
* 确认的松手触发最外侧操作,速度不论;`commit` 下别的都不触发、也不停开;确认后退回的
|
|
187
|
+
* 横滑两种方式下都合上。其余 `reveal` 的松手:达到 `releaseVelocity` 的,往开就开、往合就合;
|
|
188
|
+
* 更慢的过开宽的 `openFraction` 就开,不到就合。
|
|
189
|
+
*/
|
|
190
|
+
function resolveRelease({ travel, velocity, openWidth, isConfirmed, wasConfirmed, behavior }) {
|
|
191
|
+
if (isConfirmed) return "perform";
|
|
192
|
+
if (behavior === "commit" || wasConfirmed) return "closed";
|
|
193
|
+
if (velocity >= swipeActions.releaseVelocity) return "open";
|
|
194
|
+
if (velocity <= -swipeActions.releaseVelocity) return "closed";
|
|
195
|
+
return travel >= swipeActions.openFraction * openWidth ? "open" : "closed";
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* 全滑确认的位置:从开宽往确认偏移走 `confirmFraction` 的路,且不短于开宽。
|
|
199
|
+
* 确认偏移是行宽减 `confirmInset`。
|
|
200
|
+
*/
|
|
201
|
+
function confirmPoint(openWidth, rowWidth) {
|
|
202
|
+
const confirmAt = rowWidth - swipeActions.confirmInset;
|
|
203
|
+
return Math.max(openWidth, openWidth + (confirmAt - openWidth) * swipeActions.confirmFraction);
|
|
204
|
+
}
|
|
205
|
+
/** 全滑确认后行的偏移(UIKit 的 `confirmationThreshold`)。 */
|
|
206
|
+
function confirmedOffset(rowWidth) {
|
|
207
|
+
return rowWidth - swipeActions.confirmInset;
|
|
208
|
+
}
|
|
209
|
+
const IDLE_STATE = Object.freeze({
|
|
210
|
+
cover: null,
|
|
211
|
+
isArmed: false,
|
|
212
|
+
phase: "idle",
|
|
213
|
+
side: "leading"
|
|
214
|
+
});
|
|
215
|
+
/**
|
|
216
|
+
* 行是开着的:停开,或正在落向停开。UIKit 从让行停开的那次松手起就算开着,不等它停稳。
|
|
217
|
+
* 开着的行在点它的内容、指针落在外面、滚动或按 Escape 时合上;它的根不接按压。
|
|
218
|
+
*/
|
|
219
|
+
function isSwipeOpen(state) {
|
|
220
|
+
return state.phase === "resting" || state.phase === "settling" && state.landing === "resting";
|
|
221
|
+
}
|
|
222
|
+
/** 行的位移(物理 px),写在根上,每个部件都读它。 */
|
|
223
|
+
const SWIPE_TRAVEL_PROPERTY = "--_item-swipe-travel";
|
|
224
|
+
/** 全滑确认了多少(0 到 1),写在根上。 */
|
|
225
|
+
const SWIPE_CONFIRM_PROPERTY = "--_item-swipe-confirm";
|
|
226
|
+
/**
|
|
227
|
+
* 一侧的几何,拖动开始时写在这一侧的窗口上:操作贴着轨道的位置(物理 px,让它们停在外缘)、
|
|
228
|
+
* 这一侧的物理符号(在左边是 +1)、开宽(px),以及确认的全滑里最外侧操作的滑动量(物理 px)。
|
|
229
|
+
*/
|
|
230
|
+
const SWIPE_PIN_PROPERTY = "--_item-swipe-pin";
|
|
231
|
+
const SWIPE_SIGN_PROPERTY = "--_item-swipe-sign";
|
|
232
|
+
const SWIPE_OPEN_PROPERTY = "--_item-swipe-open";
|
|
233
|
+
const SWIPE_SLIDE_PROPERTY = "--_item-swipe-slide";
|
|
234
|
+
/** 从合着的行开始的拖动露出哪一侧:朝行内末尾是 leading。 */
|
|
235
|
+
function sideFor(dx, inlineSign) {
|
|
236
|
+
return dx * inlineSign > 0 ? "leading" : "trailing";
|
|
237
|
+
}
|
|
238
|
+
/** 这一侧的面板在物理左边是 +1,在右边是 −1。 */
|
|
239
|
+
function physicalSign(side, inlineSign) {
|
|
240
|
+
return side === "leading" ? inlineSign : inlineSign === 1 ? -1 : 1;
|
|
241
|
+
}
|
|
242
|
+
/** 操作触发、行离开时行滑出多远(逻辑 px)。 */
|
|
243
|
+
function outTravel(layout) {
|
|
244
|
+
return layout.rowWidth + swipeActions.slideOutOvershoot;
|
|
245
|
+
}
|
|
246
|
+
function stopValue(layout, stop) {
|
|
247
|
+
const sign = physicalSign(layout.side, layout.inlineSign);
|
|
248
|
+
if (stop === "rest") return 0;
|
|
249
|
+
return stop === "open" ? sign * layout.openWidth : sign * outTravel(layout);
|
|
250
|
+
}
|
|
251
|
+
/** 一侧的停靠点,物理 px,升序:原位、开宽、滑出行边之外(全滑)。 */
|
|
252
|
+
function stopsOf(layout) {
|
|
253
|
+
return [
|
|
254
|
+
"rest",
|
|
255
|
+
"open",
|
|
256
|
+
"out"
|
|
257
|
+
].map((stop) => stopValue(layout, stop)).sort((a, b) => a - b);
|
|
258
|
+
}
|
|
259
|
+
function stopIndex(layout, stop) {
|
|
260
|
+
return stopsOf(layout).indexOf(stopValue(layout, stop));
|
|
261
|
+
}
|
|
262
|
+
function stopAt(layout, index) {
|
|
263
|
+
const value = stopsOf(layout)[index] ?? 0;
|
|
264
|
+
if (value === 0) return "rest";
|
|
265
|
+
return Math.abs(value) === layout.openWidth ? "open" : "out";
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* 某个位移(物理 px)下全滑的确认进度:确认点之前是 0,到确认偏移是 1,中间和行同步。
|
|
269
|
+
* 所以行跑到前面时最外侧操作盖满空出来的地方,行退回时又让出来。
|
|
270
|
+
*/
|
|
271
|
+
function confirmProgress(layout, x) {
|
|
272
|
+
const travel = x * physicalSign(layout.side, layout.inlineSign);
|
|
273
|
+
const from = confirmPoint(layout.openWidth, layout.rowWidth);
|
|
274
|
+
const to = confirmedOffset(layout.rowWidth);
|
|
275
|
+
if (to <= from) return travel >= to ? 1 : 0;
|
|
276
|
+
return Math.min(1, Math.max(0, (travel - from) / (to - from)));
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/Swipe/swipeDom.ts
|
|
280
|
+
/** 行里一侧的面板;这一侧没有操作时返回 null。 */
|
|
281
|
+
function sidePanelOf(root, side) {
|
|
282
|
+
const frame = root.querySelector(`:scope > [data-swipe-panel="${side}"]`);
|
|
283
|
+
const track = frame?.firstElementChild;
|
|
284
|
+
if (frame == null || !(track instanceof HTMLElement)) return null;
|
|
285
|
+
return {
|
|
286
|
+
window: frame,
|
|
287
|
+
track,
|
|
288
|
+
entries: Array.from(track.children).filter((child) => child instanceof HTMLElement)
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/** 操作的自然宽度之和(含最外侧):行开多宽。 */
|
|
292
|
+
function openWidthOf(panel) {
|
|
293
|
+
return panel?.entries.reduce((width, entry) => width + entry.offsetWidth, 0) ?? 0;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* 行的各个移动部件,以及每个部件在某个位移下的偏移:根和轨道跟着位移走,窗口反着走(留在原位),
|
|
297
|
+
* 操作在开宽之前贴着外缘、过了开宽跟着行走,最外侧的在确认点和确认偏移之间再滑到行边。
|
|
298
|
+
* `layout` 是最近一次移动的那一侧,`confirmOf` 是确认进度。
|
|
299
|
+
*/
|
|
300
|
+
function settleParts(root, layout, confirmOf) {
|
|
301
|
+
const parts = [{
|
|
302
|
+
element: root,
|
|
303
|
+
offset: (travel) => travel
|
|
304
|
+
}];
|
|
305
|
+
for (const side of ["leading", "trailing"]) {
|
|
306
|
+
const panel = sidePanelOf(root, side);
|
|
307
|
+
if (panel == null) continue;
|
|
308
|
+
const read = (name, fallback) => {
|
|
309
|
+
const value = Number.parseFloat(panel.window.style.getPropertyValue(name));
|
|
310
|
+
return Number.isNaN(value) ? fallback : value;
|
|
311
|
+
};
|
|
312
|
+
const pin = read(SWIPE_PIN_PROPERTY, 0);
|
|
313
|
+
const sign = read(SWIPE_SIGN_PROPERTY, 1);
|
|
314
|
+
const open = read(SWIPE_OPEN_PROPERTY, 0);
|
|
315
|
+
const slide = read(SWIPE_SLIDE_PROPERTY, 0);
|
|
316
|
+
const entryX = (travel) => pin - sign * Math.min(sign * travel, open);
|
|
317
|
+
const confirmBends = layout == null || layout.side !== side ? [] : [sign * confirmPoint(layout.openWidth, layout.rowWidth), sign * confirmedOffset(layout.rowWidth)];
|
|
318
|
+
parts.push({
|
|
319
|
+
element: panel.window,
|
|
320
|
+
offset: (travel) => -travel
|
|
321
|
+
}, {
|
|
322
|
+
element: panel.track,
|
|
323
|
+
offset: (travel) => travel
|
|
324
|
+
});
|
|
325
|
+
panel.entries.forEach((entry, index) => {
|
|
326
|
+
const isOuter = index === panel.entries.length - 1;
|
|
327
|
+
parts.push({
|
|
328
|
+
element: entry,
|
|
329
|
+
offset: isOuter ? (travel) => entryX(travel) + slide * confirmOf(travel) : entryX,
|
|
330
|
+
bends: isOuter ? [sign * open, ...confirmBends] : [sign * open]
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return parts;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* 订阅开着的行的合上时机。指针落在行外任何地方都会合上它(拖邻居的行也就合上了它),
|
|
338
|
+
* 所以同一时间只有一行停开,不用共享状态。任何带着它移动的滚动(列表、页面)也会合上它,
|
|
339
|
+
* 就像 UIKit 的表格滚动时行会合上。从行本身开始的滚动不会在行外落指针。返回取消订阅。
|
|
340
|
+
*/
|
|
341
|
+
function subscribeOpenRowCloses(root, openSide, close) {
|
|
342
|
+
const view = root.ownerDocument.defaultView;
|
|
343
|
+
if (view == null) return () => {};
|
|
344
|
+
const onOutside = (event) => {
|
|
345
|
+
if (event.target instanceof Node && !root.contains(event.target)) close("next-frame");
|
|
346
|
+
};
|
|
347
|
+
const onScroll = (event) => {
|
|
348
|
+
const { target } = event;
|
|
349
|
+
if (!(target === view.document || target instanceof Element && target.contains(root))) return;
|
|
350
|
+
const side = openSide();
|
|
351
|
+
if ((side == null ? null : root.querySelector(`[data-swipe-panel="${side}"]`))?.contains(view.document.activeElement) !== true) close();
|
|
352
|
+
};
|
|
353
|
+
const stops = [subscribeInput(view, "pointerdown", onOutside), subscribeInput(view, "scroll", onScroll)];
|
|
354
|
+
return () => {
|
|
355
|
+
for (const stop of stops) stop();
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
/** 行里横滑面板之外第一个能聚焦的东西:停开的面板在焦点底下合上时,焦点落到它上面。 */
|
|
359
|
+
function focusRowContent(root) {
|
|
360
|
+
const candidates = root.querySelectorAll("button, a[href], input, [tabindex]:not([tabindex=\"-1\"])");
|
|
361
|
+
for (const element of candidates) if (element.closest("[data-swipe-panel]") == null) {
|
|
362
|
+
element.focus();
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
const active = root.ownerDocument.activeElement;
|
|
366
|
+
const view = root.ownerDocument.defaultView;
|
|
367
|
+
if (view != null && active instanceof view.HTMLElement) active.blur();
|
|
368
|
+
}
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/Swipe/swipeDragModel.ts
|
|
371
|
+
/** 手指的横滑从按下算起走过这么远才开始:行对这次触摸的认领。从这里起行就在手指的位移上。 */
|
|
372
|
+
const FINGER_SWIPE_START = swipeActions.claim;
|
|
373
|
+
/** 飞行中的领先量离目标多近算长好了(px)。 */
|
|
374
|
+
const LEAD_REST = .25;
|
|
375
|
+
/** 手指在 `now` 时的领先量:长好了的,或飞行中的。 */
|
|
376
|
+
function leadNow(drag, now) {
|
|
377
|
+
const motion = drag.leadMotion;
|
|
378
|
+
if (motion == null) return drag.lead;
|
|
379
|
+
const t = (now - motion.start) / 1e3;
|
|
380
|
+
return t < motion.curve.settleTime(LEAD_REST) ? motion.curve.value(t) : drag.lead;
|
|
381
|
+
}
|
|
382
|
+
/** 手指的领先量在 `now` 时动得多快(px/s)。 */
|
|
383
|
+
function leadVelocity(drag, now) {
|
|
384
|
+
const motion = drag.leadMotion;
|
|
385
|
+
return motion == null ? 0 : motion.curve.velocity((now - motion.start) / 1e3);
|
|
386
|
+
}
|
|
387
|
+
/** 把一侧的几何写在它的窗口上,让操作贴着外缘。 */
|
|
388
|
+
function writeSideGeometry(root, layout) {
|
|
389
|
+
const frame = sidePanelOf(root, layout.side)?.window;
|
|
390
|
+
if (frame == null) return;
|
|
391
|
+
const sign = physicalSign(layout.side, layout.inlineSign);
|
|
392
|
+
frame.style.setProperty(SWIPE_PIN_PROPERTY, `${sign * layout.openWidth}px`);
|
|
393
|
+
frame.style.setProperty(SWIPE_SIGN_PROPERTY, String(sign));
|
|
394
|
+
frame.style.setProperty(SWIPE_OPEN_PROPERTY, `${layout.openWidth}px`);
|
|
395
|
+
frame.style.setProperty(SWIPE_SLIDE_PROPERTY, `${sign * (layout.openWidth - layout.outerWidth)}px`);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* 横滑的拖动模型。拖动停在它的一侧:同一次手势里开着的行只会合上,不会越过原位到另一侧。
|
|
399
|
+
*
|
|
400
|
+
* - 触控板的横向滑动从越过 pan 的 8 px 起一比一跟随,松手按位置和速度落到最近的停靠点。
|
|
401
|
+
* - 手指或笔的拖动从行的 8 px 认领开始,之后行一直在手指从按下算起的位移上。全滑按 UIKit 的
|
|
402
|
+
* 量法、从 UIKit 的 25 px 死区算起确认;确认后行在 UIKit 的 tracking 弹簧上跑到确认偏移并
|
|
403
|
+
* 保持领先。松手按 resolveRelease,在 UIKit 的 settle 弹簧上从行自己的速度出发。
|
|
404
|
+
*
|
|
405
|
+
* 减少动效下拖动本身仍一比一跟随,但确认和退回改成淡入淡出。
|
|
406
|
+
*/
|
|
407
|
+
function createSwipeDragModel(host) {
|
|
408
|
+
let drag = null;
|
|
409
|
+
let leadFrame = null;
|
|
410
|
+
const coverOf = (side) => host.options().sides[side] - 1;
|
|
411
|
+
const stopLeadFrames = () => {
|
|
412
|
+
if (leadFrame != null) {
|
|
413
|
+
cancelAnimationFrame(leadFrame);
|
|
414
|
+
leadFrame = null;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
const drawLeadFrame = () => {
|
|
418
|
+
leadFrame = null;
|
|
419
|
+
const snap = host.snap();
|
|
420
|
+
if (drag?.leadMotion == null || snap == null) return;
|
|
421
|
+
const { layout, leadMotion } = drag;
|
|
422
|
+
const now = performance.now();
|
|
423
|
+
const sign = physicalSign(layout.side, layout.inlineSign);
|
|
424
|
+
snap.animator.set({ x: sign * (drag.held + leadNow(drag, now)) });
|
|
425
|
+
if ((now - leadMotion.start) / 1e3 < leadMotion.curve.settleTime(LEAD_REST)) leadFrame = requestAnimationFrame(drawLeadFrame);
|
|
426
|
+
else drag.leadMotion = null;
|
|
427
|
+
};
|
|
428
|
+
const begin = (move) => {
|
|
429
|
+
const root = host.root();
|
|
430
|
+
if (root == null) return false;
|
|
431
|
+
const inlineSign = isRtlElement(root) ? -1 : 1;
|
|
432
|
+
const side = Math.abs(move.start) > .5 ? move.start * inlineSign > 0 ? "leading" : "trailing" : sideFor(move.total, inlineSign);
|
|
433
|
+
const panel = sidePanelOf(root, side);
|
|
434
|
+
const layout = {
|
|
435
|
+
inlineSign,
|
|
436
|
+
openWidth: openWidthOf(panel),
|
|
437
|
+
outerWidth: panel?.entries.at(-1)?.offsetWidth ?? 0,
|
|
438
|
+
rowWidth: root.clientWidth,
|
|
439
|
+
side
|
|
440
|
+
};
|
|
441
|
+
writeSideGeometry(root, layout);
|
|
442
|
+
host.setLayout(layout);
|
|
443
|
+
host.snap()?.setSnapPoints(stopsOf(layout));
|
|
444
|
+
const current = host.state();
|
|
445
|
+
const { sides, canConfirm } = host.options();
|
|
446
|
+
const isDeliberate = move.input !== "scroll" && host.landedOn() === side || current.side === side && (isSwipeOpen(current) || current.cover === coverOf(side));
|
|
447
|
+
drag = {
|
|
448
|
+
baseTravel: 0,
|
|
449
|
+
canConfirm: canConfirm(side) && (sides[side] < 2 || isDeliberate),
|
|
450
|
+
confirmAt: confirmPoint(layout.openWidth, layout.rowWidth),
|
|
451
|
+
isArmed: false,
|
|
452
|
+
isScroll: move.input === "scroll",
|
|
453
|
+
raw: 0,
|
|
454
|
+
held: 0,
|
|
455
|
+
lead: 0,
|
|
456
|
+
leadMotion: null,
|
|
457
|
+
started: false,
|
|
458
|
+
startSign: 1,
|
|
459
|
+
wasConfirmed: false,
|
|
460
|
+
layout
|
|
461
|
+
};
|
|
462
|
+
return true;
|
|
463
|
+
};
|
|
464
|
+
const track = (move) => {
|
|
465
|
+
if (drag == null) return null;
|
|
466
|
+
const { layout } = drag;
|
|
467
|
+
const sign = physicalSign(layout.side, layout.inlineSign);
|
|
468
|
+
if (!drag.started) {
|
|
469
|
+
if (!drag.isScroll && Math.abs(move.total) < FINGER_SWIPE_START) return null;
|
|
470
|
+
drag.started = true;
|
|
471
|
+
drag.startSign = Math.sign(move.total * sign) || 1;
|
|
472
|
+
drag.baseTravel = host.travelNow(layout);
|
|
473
|
+
host.setState({
|
|
474
|
+
cover: drag.isArmed ? coverOf(layout.side) : null,
|
|
475
|
+
isArmed: drag.isArmed,
|
|
476
|
+
phase: "dragging",
|
|
477
|
+
side: layout.side
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
const swipe = drag.isScroll ? move.translation * sign : move.total * sign - drag.startSign * swipeActions.hysteresis;
|
|
481
|
+
const raw = Math.max(0, drag.baseTravel + swipe);
|
|
482
|
+
drag.raw = raw;
|
|
483
|
+
const held = drag.isScroll ? raw : Math.max(0, drag.baseTravel + move.total * sign);
|
|
484
|
+
drag.held = held;
|
|
485
|
+
const isArmed = drag.canConfirm && raw >= drag.confirmAt;
|
|
486
|
+
const flipped = isArmed !== drag.isArmed;
|
|
487
|
+
const root = host.root();
|
|
488
|
+
const fade = reducedMotionFade(root);
|
|
489
|
+
const now = performance.now();
|
|
490
|
+
if (flipped) {
|
|
491
|
+
const from = leadNow(drag, now);
|
|
492
|
+
const velocity = leadVelocity(drag, now);
|
|
493
|
+
drag.lead = isArmed ? Math.max(0, confirmedOffset(layout.rowWidth) - held) : 0;
|
|
494
|
+
drag.leadMotion = drag.isScroll || fade != null ? null : {
|
|
495
|
+
curve: solveSpring(toSpring(resolveMotion(root, swipeActions.tracking)), {
|
|
496
|
+
from,
|
|
497
|
+
to: drag.lead,
|
|
498
|
+
velocity
|
|
499
|
+
}),
|
|
500
|
+
start: now
|
|
501
|
+
};
|
|
502
|
+
if (drag.leadMotion != null && leadFrame == null) leadFrame = requestAnimationFrame(drawLeadFrame);
|
|
503
|
+
drag.isArmed = isArmed;
|
|
504
|
+
drag.wasConfirmed ||= isArmed;
|
|
505
|
+
host.setState({
|
|
506
|
+
cover: isArmed ? coverOf(layout.side) : null,
|
|
507
|
+
isArmed,
|
|
508
|
+
phase: "dragging",
|
|
509
|
+
side: layout.side
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
const offset = sign * (drag.isScroll ? isArmed ? Math.max(raw, confirmedOffset(layout.rowWidth)) : raw : held + leadNow(drag, now));
|
|
513
|
+
if (fade == null) return drag.isScroll && flipped ? {
|
|
514
|
+
offset,
|
|
515
|
+
spring: swipeActions.tracking
|
|
516
|
+
} : { offset };
|
|
517
|
+
if (flipped) {
|
|
518
|
+
drag.dipUntil = now + fade.duration;
|
|
519
|
+
return {
|
|
520
|
+
offset,
|
|
521
|
+
spring: swipeActions.tracking
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
if (drag.dipUntil != null && now < drag.dipUntil) return null;
|
|
525
|
+
drag.dipUntil = void 0;
|
|
526
|
+
return { offset };
|
|
527
|
+
};
|
|
528
|
+
const release = (end) => {
|
|
529
|
+
const ended = drag;
|
|
530
|
+
drag = null;
|
|
531
|
+
stopLeadFrames();
|
|
532
|
+
if (ended == null || !ended.started) return null;
|
|
533
|
+
const { layout } = ended;
|
|
534
|
+
const sign = physicalSign(layout.side, layout.inlineSign);
|
|
535
|
+
const velocity = end.velocity * sign;
|
|
536
|
+
const cause = end.input === "touch" ? "release" : "other";
|
|
537
|
+
const { behavior } = host.options();
|
|
538
|
+
let landing;
|
|
539
|
+
if (ended.isScroll) {
|
|
540
|
+
if (ended.isArmed) landing = "perform";
|
|
541
|
+
else {
|
|
542
|
+
const { index } = resolveSnapPoint({
|
|
543
|
+
points: behavior === "commit" ? [0] : [0, layout.openWidth],
|
|
544
|
+
position: ended.raw,
|
|
545
|
+
velocity,
|
|
546
|
+
flickThreshold: DEFAULT_FLICK_THRESHOLD,
|
|
547
|
+
start: ended.baseTravel
|
|
548
|
+
});
|
|
549
|
+
landing = index === 1 ? "open" : "closed";
|
|
550
|
+
}
|
|
551
|
+
} else landing = resolveRelease({
|
|
552
|
+
behavior,
|
|
553
|
+
isConfirmed: ended.isArmed,
|
|
554
|
+
openWidth: layout.openWidth,
|
|
555
|
+
travel: ended.held,
|
|
556
|
+
velocity,
|
|
557
|
+
wasConfirmed: ended.wasConfirmed
|
|
558
|
+
});
|
|
559
|
+
const motion = {
|
|
560
|
+
velocity: end.velocity,
|
|
561
|
+
spring: ended.isScroll ? void 0 : swipeActions.settle
|
|
562
|
+
};
|
|
563
|
+
if (landing === "perform") host.slideOutAndFire(layout, cause, motion);
|
|
564
|
+
else if (landing === "open") host.settle(layout, "open", "resting", {
|
|
565
|
+
cause,
|
|
566
|
+
...motion
|
|
567
|
+
});
|
|
568
|
+
else host.settle(layout, "rest", "idle", {
|
|
569
|
+
cause,
|
|
570
|
+
...motion
|
|
571
|
+
});
|
|
572
|
+
return null;
|
|
573
|
+
};
|
|
574
|
+
const cancel = () => {
|
|
575
|
+
const ended = drag;
|
|
576
|
+
drag = null;
|
|
577
|
+
stopLeadFrames();
|
|
578
|
+
if (ended != null && ended.started) host.settle(ended.layout, "rest", "idle", {
|
|
579
|
+
cause: "release",
|
|
580
|
+
spring: ended.isScroll ? void 0 : swipeActions.settle
|
|
581
|
+
});
|
|
582
|
+
return null;
|
|
583
|
+
};
|
|
584
|
+
return {
|
|
585
|
+
begin,
|
|
586
|
+
move: track,
|
|
587
|
+
release,
|
|
588
|
+
cancel,
|
|
589
|
+
dispose: stopLeadFrames
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
//#endregion
|
|
593
|
+
//#region src/Swipe/useSwipeAction.ts
|
|
594
|
+
/**
|
|
595
|
+
* 行的横滑跑在所有跟手平移共用的拖动通道上:触控板分流、pan、吸附拖动和动画器。
|
|
596
|
+
* 行按侧声明它的停靠点(原位、开宽、全滑时滑出行边之外)和它的操作。拖动把行的位移画进根上的
|
|
597
|
+
* 一个 CSS 自定义属性,面板的每个部件都读它(SwipeActionsLayer);落位把终点立即写进去,各部件
|
|
598
|
+
* 在合成器上沿同一个时钟走过去。
|
|
599
|
+
*
|
|
600
|
+
* 拖过确认点、且这一侧的最外侧操作能触发时,全滑确认:行跑到 UIKit 的确认偏移,最外侧操作盖满
|
|
601
|
+
* 空出来的地方(面板从第二个属性「确认进度」读到它),退回就撤销。确认状态下抬起,行滑出并触发
|
|
602
|
+
* 最外侧操作,速度不论;单靠速度永远不触发,所以全滑是一甩唯一到不了的停靠点。行滑出时(全滑,
|
|
603
|
+
* 或点了带 `hasRemoval` 的操作),等行的内容离开原来的盒子才触发,然后行弹回,或在操作带
|
|
604
|
+
* `hasRemoval` 时停在外面。
|
|
605
|
+
*
|
|
606
|
+
* 鼠标拖动和鼠标滚轮的刻度永远不横滑行:pan 只接触摸、笔和触控板滚动。另一根手指按着时
|
|
607
|
+
* (不论在不在这一行上)落下的手指不会开始 pan:页面去缩放。
|
|
608
|
+
*
|
|
609
|
+
* 开着的行在指针落在它外面时合上。从让它停开的那次松手起就算开着。焦点不在开着的面板里时,
|
|
610
|
+
* 带着它的任何滚动也会合上它;焦点在行里时 Escape 合上它。在它自己的内容上轻点也会合上它,
|
|
611
|
+
* 且不激活行上的任何东西;鼠标和笔的按下照常到达行。
|
|
612
|
+
*
|
|
613
|
+
* 减少动效下,拖动本身是直接操作,一比一跟随;但松手、确认、合上开始的东西不移动也不回弹。
|
|
614
|
+
* 手指松手后行在不透明度低谷处落位;笔和触控板的在细指针上立即落位。
|
|
615
|
+
*
|
|
616
|
+
* 方向是逻辑的:`leading` 由朝行内末尾的拖动露出,位于行内开头;`trailing` 相反。
|
|
617
|
+
* 都在拖动开始时按根的计算 `direction` 读。
|
|
618
|
+
*/
|
|
619
|
+
function useSwipeAction(root, options) {
|
|
620
|
+
const state = shallowRef(IDLE_STATE);
|
|
621
|
+
/** 最近移动那一侧的几何:行在哪、怎么移动它。 */
|
|
622
|
+
let layout = null;
|
|
623
|
+
let snap = null;
|
|
624
|
+
let stopCloses = null;
|
|
625
|
+
/** 最近一次按下落在哪一侧的最外侧操作上(行正开在那一侧时)。 */
|
|
626
|
+
let landedOn = null;
|
|
627
|
+
let close = () => {};
|
|
628
|
+
const isOpen = () => isSwipeOpen(state.value);
|
|
629
|
+
const setState = (next) => {
|
|
630
|
+
const wasOpen = isOpen();
|
|
631
|
+
const willOpen = isSwipeOpen(next);
|
|
632
|
+
state.value = next;
|
|
633
|
+
if (wasOpen === willOpen) return;
|
|
634
|
+
stopCloses?.();
|
|
635
|
+
stopCloses = null;
|
|
636
|
+
const element = root();
|
|
637
|
+
if (element == null) return;
|
|
638
|
+
setPressHeld(element, willOpen);
|
|
639
|
+
if (willOpen) stopCloses = subscribeOpenRowCloses(element, () => layout?.side, (start) => close(start));
|
|
640
|
+
};
|
|
641
|
+
/** 行现在在屏幕上的位移,物理 px。 */
|
|
642
|
+
const presentedX = () => snap?.position() ?? 0;
|
|
643
|
+
/**
|
|
644
|
+
* 某个位移(物理 px)下全滑的确认进度。只有最外侧操作盖满面板时才动它;不能确认的拖动
|
|
645
|
+
* 让每个操作都留在原处。它和位移在同一个动画里画出(共享拖动的伴随属性),不会和行错开。
|
|
646
|
+
*/
|
|
647
|
+
const confirmOf = (x) => {
|
|
648
|
+
const current = state.value;
|
|
649
|
+
if (layout == null || current.side !== layout.side || current.cover !== options().sides[layout.side] - 1 || !options().canConfirm(layout.side)) return 0;
|
|
650
|
+
return confirmProgress(layout, x);
|
|
651
|
+
};
|
|
652
|
+
/** 共享拖动停在了某个停靠点上:行在那里落定。 */
|
|
653
|
+
const landed = (index) => {
|
|
654
|
+
if (layout == null) return;
|
|
655
|
+
const stop = stopAt(layout, index);
|
|
656
|
+
if (stop === "out") {
|
|
657
|
+
if (state.value.phase === "settling") setState({
|
|
658
|
+
cover: state.value.cover,
|
|
659
|
+
isArmed: false,
|
|
660
|
+
phase: "held",
|
|
661
|
+
side: layout.side
|
|
662
|
+
});
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
setState(stop === "rest" ? IDLE_STATE : {
|
|
666
|
+
cover: null,
|
|
667
|
+
isArmed: false,
|
|
668
|
+
phase: "resting",
|
|
669
|
+
side: layout.side
|
|
670
|
+
});
|
|
671
|
+
};
|
|
672
|
+
/**
|
|
673
|
+
* 让行落在一个停靠点上,落定时进入 `phase`。除非被打断(拖动接住了行,或另一次落位开始),
|
|
674
|
+
* 共享拖动会报告落定(onSettle)。
|
|
675
|
+
*/
|
|
676
|
+
const settle = (target, stop, phase, settleOptions = {}) => {
|
|
677
|
+
if (snap == null) return null;
|
|
678
|
+
layout = target;
|
|
679
|
+
setState({
|
|
680
|
+
cover: settleOptions.cover ?? null,
|
|
681
|
+
isArmed: false,
|
|
682
|
+
landing: phase,
|
|
683
|
+
phase: "settling",
|
|
684
|
+
side: target.side
|
|
685
|
+
});
|
|
686
|
+
const spring = "spring" in settleOptions ? settleOptions.spring : swipeActions.settle;
|
|
687
|
+
snap.setSnapPoints(stopsOf(target));
|
|
688
|
+
return snap.settleTo(stopIndex(target, stop), {
|
|
689
|
+
spring,
|
|
690
|
+
touchRelease: settleOptions.cause === "release",
|
|
691
|
+
...settleOptions.velocity != null ? { velocity: settleOptions.velocity } : {},
|
|
692
|
+
...settleOptions.onPass != null ? { onPass: settleOptions.onPass } : {},
|
|
693
|
+
...settleOptions.start != null ? { start: settleOptions.start } : {}
|
|
694
|
+
});
|
|
695
|
+
};
|
|
696
|
+
/**
|
|
697
|
+
* 把行朝它走的方向滑出,等内容离开原来的盒子再触发。UIKit 在抬起或点按时就调用处理函数;
|
|
698
|
+
* 等内容离开再触发,应用立即删掉的行就不会在滑到一半时消失。共享拖动在落位曲线第一次把行
|
|
699
|
+
* 带过行边的那一帧回调;减少动效下是它在淡入淡出低谷处落到盒子外的那一帧。先被别的落位或
|
|
700
|
+
* 拖动替换掉的滑出什么都不触发。
|
|
701
|
+
*/
|
|
702
|
+
const slideOutThenFire = (target, fire, settleOptions) => {
|
|
703
|
+
const sign = physicalSign(target.side, target.inlineSign);
|
|
704
|
+
settle(target, "out", "held", {
|
|
705
|
+
...settleOptions,
|
|
706
|
+
onPass: {
|
|
707
|
+
offset: sign * target.rowWidth,
|
|
708
|
+
direction: sign,
|
|
709
|
+
call: () => {
|
|
710
|
+
if (fire()) snap?.finishSettle();
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
};
|
|
715
|
+
/** 确认的全滑:最外侧操作盖着行原来的位置滑出,行离开时触发,然后停在外面或弹回。 */
|
|
716
|
+
const slideOutAndFire = (target, cause, motion = {}) => {
|
|
717
|
+
const cover = options().sides[target.side] - 1;
|
|
718
|
+
slideOutThenFire(target, () => {
|
|
719
|
+
if (options().fireOutermost(target.side)) return true;
|
|
720
|
+
settle(target, "rest", "idle", {
|
|
721
|
+
cause,
|
|
722
|
+
...motion,
|
|
723
|
+
cover
|
|
724
|
+
});
|
|
725
|
+
return false;
|
|
726
|
+
}, {
|
|
727
|
+
cause,
|
|
728
|
+
...motion,
|
|
729
|
+
cover
|
|
730
|
+
});
|
|
731
|
+
};
|
|
732
|
+
const blurIntoContent = () => {
|
|
733
|
+
const element = root();
|
|
734
|
+
if (element != null && element.contains(element.ownerDocument.activeElement)) focusRowContent(element);
|
|
735
|
+
};
|
|
736
|
+
/**
|
|
737
|
+
* 合上开着的行。在输入事件自己的任务里请求时(按键、按下、轻点)传 `'next-frame'`:
|
|
738
|
+
* 合上从那个任务之后的第一帧开始,同一事件后面占住主线程的监听器只会推迟它,不会让它跳进曲线中途。
|
|
739
|
+
*/
|
|
740
|
+
close = (start) => {
|
|
741
|
+
if (!isOpen() || layout == null) return;
|
|
742
|
+
blurIntoContent();
|
|
743
|
+
settle(layout, "rest", "idle", start != null ? { start } : {});
|
|
744
|
+
};
|
|
745
|
+
const activateEntry = (fire, holdsOut, cover) => {
|
|
746
|
+
if (!isOpen() || layout == null) return;
|
|
747
|
+
blurIntoContent();
|
|
748
|
+
if (holdsOut) {
|
|
749
|
+
slideOutThenFire(layout, () => {
|
|
750
|
+
fire();
|
|
751
|
+
return true;
|
|
752
|
+
}, {
|
|
753
|
+
cause: "other",
|
|
754
|
+
start: "next-frame",
|
|
755
|
+
cover
|
|
756
|
+
});
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
fire();
|
|
760
|
+
settle(layout, "rest", "idle", {
|
|
761
|
+
start: "next-frame",
|
|
762
|
+
cover
|
|
763
|
+
});
|
|
764
|
+
};
|
|
765
|
+
const model = createSwipeDragModel({
|
|
766
|
+
root,
|
|
767
|
+
snap: () => snap,
|
|
768
|
+
options,
|
|
769
|
+
state: () => state.value,
|
|
770
|
+
setState,
|
|
771
|
+
setLayout: (next) => {
|
|
772
|
+
layout = next;
|
|
773
|
+
},
|
|
774
|
+
landedOn: () => landedOn,
|
|
775
|
+
travelNow: (target) => Math.max(0, presentedX() * physicalSign(target.side, target.inlineSign)),
|
|
776
|
+
settle,
|
|
777
|
+
slideOutAndFire
|
|
778
|
+
});
|
|
779
|
+
watch(root, (element, _previous, onCleanup) => {
|
|
780
|
+
if (element == null) return;
|
|
781
|
+
const drag = createSnapDrag(element, {
|
|
782
|
+
axis: "x",
|
|
783
|
+
snapPoints: [0],
|
|
784
|
+
customProperty: {
|
|
785
|
+
name: SWIPE_TRAVEL_PROPERTY,
|
|
786
|
+
syntax: "<length>",
|
|
787
|
+
companion: {
|
|
788
|
+
name: SWIPE_CONFIRM_PROPERTY,
|
|
789
|
+
syntax: "<number>",
|
|
790
|
+
map: confirmOf
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
compositorParts: () => settleParts(element, layout, confirmOf),
|
|
794
|
+
onSettle: landed,
|
|
795
|
+
pan: {
|
|
796
|
+
allowedPointerTypes: ["touch", "pen"],
|
|
797
|
+
allowedScrollTypes: ["continuous"],
|
|
798
|
+
hysteresis: swipeActions.claim,
|
|
799
|
+
maximumNumberOfTouches: 1,
|
|
800
|
+
name: "Item.swipe",
|
|
801
|
+
selectionLock: lockSelection,
|
|
802
|
+
shouldReceiveTouch: (_pan, touch) => {
|
|
803
|
+
const current = state.value;
|
|
804
|
+
const { target } = touch;
|
|
805
|
+
const outer = sidePanelOf(element, current.side)?.entries.at(-1);
|
|
806
|
+
landedOn = touch.scrollType == null && isSwipeOpen(current) && target instanceof Node && outer?.contains(target) === true ? current.side : null;
|
|
807
|
+
return true;
|
|
808
|
+
},
|
|
809
|
+
shouldBegin: (pan) => {
|
|
810
|
+
if (getGestureHost(element.ownerDocument).fingersDown() > 1) return false;
|
|
811
|
+
if (state.value.phase === "held") return false;
|
|
812
|
+
const inlineSign = isRtlElement(element) ? -1 : 1;
|
|
813
|
+
return Math.abs(presentedX()) > .5 || options().sides[sideFor(pan.totalTranslation().x, inlineSign)] > 0;
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
model: {
|
|
817
|
+
begin: model.begin,
|
|
818
|
+
move: model.move,
|
|
819
|
+
release: model.release,
|
|
820
|
+
cancel: model.cancel
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
snap = drag;
|
|
824
|
+
onCleanup(() => {
|
|
825
|
+
snap = null;
|
|
826
|
+
drag.destroy();
|
|
827
|
+
element.style.removeProperty(SWIPE_TRAVEL_PROPERTY);
|
|
828
|
+
element.style.removeProperty(SWIPE_CONFIRM_PROPERTY);
|
|
829
|
+
});
|
|
830
|
+
}, {
|
|
831
|
+
immediate: true,
|
|
832
|
+
flush: "post"
|
|
833
|
+
});
|
|
834
|
+
useGestureRecognizer(root, () => new TapGestureRecognizer({
|
|
835
|
+
name: "item-swipe-dismiss",
|
|
836
|
+
allowedPointerTypes: ["touch"],
|
|
837
|
+
shouldReceiveTouch: (_tap, touch) => isOpen() && !(touch.target instanceof Element && touch.target.closest("[data-swipe-panel]") != null)
|
|
838
|
+
}), (tap) => {
|
|
839
|
+
if (tap.state === "ended") close("next-frame");
|
|
840
|
+
});
|
|
841
|
+
const onKeyDown = (event) => {
|
|
842
|
+
if (event.key === "Escape" && isOpen()) {
|
|
843
|
+
event.stopPropagation();
|
|
844
|
+
close("next-frame");
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
onScopeDispose(() => {
|
|
848
|
+
stopCloses?.();
|
|
849
|
+
stopCloses = null;
|
|
850
|
+
model.dispose();
|
|
851
|
+
const element = root();
|
|
852
|
+
if (element != null) setPressHeld(element, false);
|
|
853
|
+
});
|
|
854
|
+
return {
|
|
855
|
+
state,
|
|
856
|
+
activateEntry,
|
|
857
|
+
close: (start) => close(start),
|
|
858
|
+
onKeyDown
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/Swipe/SwipeActionsLayer.vue
|
|
863
|
+
const _hoisted_1$1 = [
|
|
864
|
+
"data-swipe-panel",
|
|
865
|
+
"inert",
|
|
866
|
+
"aria-hidden"
|
|
867
|
+
];
|
|
868
|
+
const _hoisted_2$1 = [
|
|
869
|
+
"data-side",
|
|
870
|
+
"data-covered",
|
|
871
|
+
"data-fill"
|
|
872
|
+
];
|
|
873
|
+
const _hoisted_3$1 = ["data-variant", "data-disabled"];
|
|
874
|
+
const _hoisted_4 = [
|
|
875
|
+
"data-variant",
|
|
876
|
+
"data-disabled",
|
|
877
|
+
"aria-disabled",
|
|
878
|
+
"onClick"
|
|
879
|
+
];
|
|
880
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
881
|
+
name: "AstryxSwipeActionsLayer",
|
|
882
|
+
__name: "SwipeActionsLayer",
|
|
883
|
+
props: {
|
|
884
|
+
leading: {},
|
|
885
|
+
trailing: {},
|
|
886
|
+
behavior: {},
|
|
887
|
+
itemKey: {}
|
|
888
|
+
},
|
|
889
|
+
setup(__props, { expose: __expose }) {
|
|
890
|
+
/**
|
|
891
|
+
* 有横滑操作的行的横滑那一半:两侧的面板,渲染进行自己的根里,以及驱动这个根的手势。
|
|
892
|
+
*
|
|
893
|
+
* 行的根还是行的:它带上横滑的根样式(`astryx-item--swipe`),并把按键事件转给这一层暴露的
|
|
894
|
+
* `onKeyDown`。手势挂在根本身上,行开着时这一层按住根的按压。这一层把两个面板渲染成根的
|
|
895
|
+
* 脱离文档流的子元素,所以行里不为横滑多包任何元素。
|
|
896
|
+
*
|
|
897
|
+
* 一个面板是两个盒子加操作本身,都由读根上位移的 transform 移动(见 useSwipeAction)。
|
|
898
|
+
* 窗口盖在行的静止盒子上、读位移的相反数,裁到那个盒子。窗口里的轨道跟着行走,把操作裁到行
|
|
899
|
+
* 空出来的地方。每个操作从这一侧的钉位往回平移,所以在行把它们全露出来之前一直贴在外缘,之后
|
|
900
|
+
* 跟着行走。过了开宽,画在最外侧操作旁边的同色块把剩下的地方一直填到外缘;确认的全滑里它滑到
|
|
901
|
+
* 行边。某个操作盖满面板时,轨道铺满它的颜色、别的操作隐藏,所以操作的颜色不会在别的操作后面
|
|
902
|
+
* 或中间露出来。
|
|
903
|
+
*/
|
|
904
|
+
const props = __props;
|
|
905
|
+
const windows = {
|
|
906
|
+
leading: shallowRef(null),
|
|
907
|
+
trailing: shallowRef(null)
|
|
908
|
+
};
|
|
909
|
+
/** 行根:面板窗口的父元素。 */
|
|
910
|
+
const root = computed(() => (windows.leading.value ?? windows.trailing.value)?.parentElement ?? null);
|
|
911
|
+
function entriesOf(side) {
|
|
912
|
+
return side === "leading" ? props.leading : props.trailing;
|
|
913
|
+
}
|
|
914
|
+
function outermostOf(side) {
|
|
915
|
+
return entriesOf(side).at(-1);
|
|
916
|
+
}
|
|
917
|
+
function fire(entry) {
|
|
918
|
+
entry.onActivate({
|
|
919
|
+
id: entry.id ?? "",
|
|
920
|
+
itemKey: props.itemKey
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
const swipe = useSwipeAction(() => root.value, () => ({
|
|
924
|
+
behavior: props.behavior,
|
|
925
|
+
sides: {
|
|
926
|
+
leading: props.leading.length,
|
|
927
|
+
trailing: props.trailing.length
|
|
928
|
+
},
|
|
929
|
+
canConfirm: (side) => outermostOf(side) != null && outermostOf(side)?.isDisabled !== true,
|
|
930
|
+
fireOutermost: (side) => {
|
|
931
|
+
const entry = outermostOf(side);
|
|
932
|
+
if (entry == null || entry.isDisabled === true) return false;
|
|
933
|
+
fire(entry);
|
|
934
|
+
return entry.hasRemoval === true;
|
|
935
|
+
}
|
|
936
|
+
}));
|
|
937
|
+
const idsKey = computed(() => {
|
|
938
|
+
const ids = (entries) => entries.map((entry) => entry.id ?? "").join("\0");
|
|
939
|
+
return `${ids(props.leading)}\u0001${ids(props.trailing)}`;
|
|
940
|
+
});
|
|
941
|
+
watch(idsKey, () => swipe.close());
|
|
942
|
+
const isOpen = computed(() => isSwipeOpen(swipe.state.value));
|
|
943
|
+
const isCommit = computed(() => props.behavior === "commit");
|
|
944
|
+
const sides = computed(() => ["leading", "trailing"].map((side) => ({
|
|
945
|
+
side,
|
|
946
|
+
entries: entriesOf(side)
|
|
947
|
+
})).filter(({ entries }) => entries.length > 0));
|
|
948
|
+
/** 盖满这一侧面板的操作的序号;没有就是 null。 */
|
|
949
|
+
function coverIndex(side, count) {
|
|
950
|
+
const { cover } = swipe.state.value;
|
|
951
|
+
return swipe.state.value.side === side && cover != null && cover < count ? cover : null;
|
|
952
|
+
}
|
|
953
|
+
/** 面板只在行开在它这一侧时进入无障碍树和 Tab 顺序,所以行只有一个 Tab 停靠点。 */
|
|
954
|
+
function isLive(side) {
|
|
955
|
+
return isOpen.value && swipe.state.value.side === side && !isCommit.value;
|
|
956
|
+
}
|
|
957
|
+
function trackFill(side, entries) {
|
|
958
|
+
const index = coverIndex(side, entries.length);
|
|
959
|
+
return (index != null ? entries[index] : entries.at(-1))?.variant ?? "accent";
|
|
960
|
+
}
|
|
961
|
+
function entryClass(side, entries, index) {
|
|
962
|
+
const cover = coverIndex(side, entries.length);
|
|
963
|
+
return {
|
|
964
|
+
"astryx-item__swipe-entry--covered": cover != null && index !== cover,
|
|
965
|
+
"astryx-item__swipe-entry--outer": index === entries.length - 1
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
function activate(entry, index) {
|
|
969
|
+
swipe.activateEntry(() => fire(entry), entry.hasRemoval === true, index);
|
|
970
|
+
}
|
|
971
|
+
function setWindow(side, element) {
|
|
972
|
+
windows[side].value = element instanceof HTMLElement ? element : null;
|
|
973
|
+
}
|
|
974
|
+
__expose({
|
|
975
|
+
onKeyDown: swipe.onKeyDown,
|
|
976
|
+
state: swipe.state
|
|
977
|
+
});
|
|
978
|
+
return (_ctx, _cache) => {
|
|
979
|
+
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" eslint-disable-next-line vue-a11y/no-aria-hidden-on-focusable -- commit 下窗口始终 inert,里面的操作只是展示,不可聚焦。 "), (openBlock(true), createElementBlock(Fragment, null, renderList(sides.value, ({ side, entries }) => {
|
|
980
|
+
return openBlock(), createElementBlock("div", {
|
|
981
|
+
key: side,
|
|
982
|
+
ref_for: true,
|
|
983
|
+
ref: (element) => setWindow(side, element),
|
|
984
|
+
class: "astryx-item__swipe-window",
|
|
985
|
+
"data-swipe-panel": side,
|
|
986
|
+
inert: isLive(side) ? void 0 : true,
|
|
987
|
+
"aria-hidden": isCommit.value ? true : void 0
|
|
988
|
+
}, [createElementVNode("div", {
|
|
989
|
+
class: "astryx-item__swipe-track astryx-item-swipe-panel",
|
|
990
|
+
"data-side": side,
|
|
991
|
+
"data-covered": coverIndex(side, entries.length) != null || void 0,
|
|
992
|
+
"data-fill": trackFill(side, entries)
|
|
993
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(entries, (entry, index) => {
|
|
994
|
+
return openBlock(), createElementBlock(Fragment, { key: entry.id ?? entry.label }, [isCommit.value ? (openBlock(), createElementBlock("span", {
|
|
995
|
+
key: 0,
|
|
996
|
+
class: normalizeClass(["astryx-item__swipe-entry astryx-item-swipe-action", entryClass(side, entries, index)]),
|
|
997
|
+
"data-variant": entry.variant ?? "accent",
|
|
998
|
+
"data-disabled": entry.isDisabled || void 0
|
|
999
|
+
}, [entry.icon ? (openBlock(), createBlock(resolveDynamicComponent(entry.icon), {
|
|
1000
|
+
key: 0,
|
|
1001
|
+
"aria-hidden": "true"
|
|
1002
|
+
})) : createCommentVNode("v-if", true), createElementVNode("span", null, toDisplayString(entry.label), 1)], 10, _hoisted_3$1)) : (openBlock(), createElementBlock("button", mergeProps({
|
|
1003
|
+
key: 1,
|
|
1004
|
+
type: "button",
|
|
1005
|
+
class: ["astryx-item__swipe-entry astryx-item-swipe-action", entryClass(side, entries, index)],
|
|
1006
|
+
"data-variant": entry.variant ?? "accent",
|
|
1007
|
+
"data-disabled": entry.isDisabled || void 0,
|
|
1008
|
+
"aria-disabled": entry.isDisabled || void 0
|
|
1009
|
+
}, { ref_for: true }, entry.isDisabled ? unref(disabledInteractionProps)() : {}, { onClick: withModifiers(($event) => entry.isDisabled ? void 0 : activate(entry, index), ["stop"]) }), [entry.icon ? (openBlock(), createBlock(resolveDynamicComponent(entry.icon), {
|
|
1010
|
+
key: 0,
|
|
1011
|
+
"aria-hidden": "true"
|
|
1012
|
+
})) : createCommentVNode("v-if", true), createElementVNode("span", null, toDisplayString(entry.label), 1)], 16, _hoisted_4))], 64);
|
|
1013
|
+
}), 128))], 8, _hoisted_2$1)], 8, _hoisted_1$1);
|
|
1014
|
+
}), 128))], 2112);
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region src/List/itemSwipe.ts
|
|
1020
|
+
/**
|
|
1021
|
+
* 行实际跑的横滑:`swipe`(createSwipe 造的)优先,否则是已弃用的 `swipeActions` 和
|
|
1022
|
+
* `swipeBehavior`。两条路用同一套规则和面板。横滑不服务这一行(role 不允许、禁用、
|
|
1023
|
+
* 放大点击区、没有操作)时是 null。
|
|
1024
|
+
*/
|
|
1025
|
+
function useItemSwipeHost(props, facts) {
|
|
1026
|
+
const legacyHost = computed(() => {
|
|
1027
|
+
if (props.swipe != null || props.swipeActions == null) return null;
|
|
1028
|
+
return createSwipeHost(props.swipeActions.leading ?? [], props.swipeActions.trailing ?? [], props.swipeBehavior ?? "reveal");
|
|
1029
|
+
});
|
|
1030
|
+
useDevWarning("Item", "`swipeBehavior=\"commit\"` fires no entry on a side with two or more entries. Give a committing side one entry, or use `swipeBehavior=\"reveal\"`.", () => {
|
|
1031
|
+
const host = legacyHost.value;
|
|
1032
|
+
return host != null && host.behavior === "commit" && (host.leading.length > 1 || host.trailing.length > 1);
|
|
1033
|
+
});
|
|
1034
|
+
useDevWarning("Item", "`swipe` is set, so the deprecated `swipeActions` and `swipeBehavior` are ignored.", () => props.swipe != null && (props.swipeActions != null || props.swipeBehavior != null));
|
|
1035
|
+
return computed(() => {
|
|
1036
|
+
const host = props.swipe != null ? swipeHostOf(props.swipe) : legacyHost.value;
|
|
1037
|
+
if (host == null || !host.serves(facts())) return null;
|
|
1038
|
+
return host.itemKey == null && props.itemKey != null ? {
|
|
1039
|
+
...host,
|
|
1040
|
+
itemKey: props.itemKey
|
|
1041
|
+
} : host;
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
//#endregion
|
|
1045
|
+
//#region src/List/useDelegatedControl.ts
|
|
1046
|
+
/**
|
|
1047
|
+
* 转发点击的行写在被转发控件上的属性。控件就是行自己的动作,按它照样是按这一行,
|
|
1048
|
+
* 所以带上按压标记;行选中时写 `aria-current`(控件自己有标记就不动)。
|
|
1049
|
+
* 清理时只撤掉行自己写的值。
|
|
1050
|
+
*/
|
|
1051
|
+
function useDelegatedControl(options) {
|
|
1052
|
+
watchEffect((onCleanup) => {
|
|
1053
|
+
const control = options.control();
|
|
1054
|
+
if (control == null) return;
|
|
1055
|
+
for (const [name, value] of Object.entries(options.pressAttributes)) control.setAttribute(name, value);
|
|
1056
|
+
onCleanup(() => {
|
|
1057
|
+
for (const name of Object.keys(options.pressAttributes)) control.removeAttribute(name);
|
|
1058
|
+
});
|
|
1059
|
+
});
|
|
1060
|
+
watchEffect((onCleanup) => {
|
|
1061
|
+
const control = options.control();
|
|
1062
|
+
const value = options.current();
|
|
1063
|
+
if (control == null || value === void 0 || control.hasAttribute("aria-current")) return;
|
|
1064
|
+
const written = String(value);
|
|
1065
|
+
control.setAttribute("aria-current", written);
|
|
1066
|
+
onCleanup(() => {
|
|
1067
|
+
if (control.getAttribute("aria-current") === written) control.removeAttribute("aria-current");
|
|
1068
|
+
});
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
//#endregion
|
|
1072
|
+
//#region src/List/Item.vue
|
|
1073
|
+
const _hoisted_1 = {
|
|
1074
|
+
key: 0,
|
|
1075
|
+
class: "astryx-item__start"
|
|
1076
|
+
};
|
|
1077
|
+
const _hoisted_2 = ["id"];
|
|
1078
|
+
const _hoisted_3 = {
|
|
1079
|
+
key: 1,
|
|
1080
|
+
class: "astryx-item__end"
|
|
1081
|
+
};
|
|
1082
|
+
const NATIVE_CONTROL_SELECTOR = "button, a, input, select, textarea";
|
|
1083
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
1084
|
+
name: "AstryxItem",
|
|
1085
|
+
inheritAttrs: false,
|
|
1086
|
+
__name: "Item",
|
|
1087
|
+
props: {
|
|
1088
|
+
as: { default: "div" },
|
|
1089
|
+
layout: { default: "stacked" },
|
|
1090
|
+
labelLines: {},
|
|
1091
|
+
descriptionLines: {},
|
|
1092
|
+
isHighlighted: {
|
|
1093
|
+
type: Boolean,
|
|
1094
|
+
default: false
|
|
1095
|
+
},
|
|
1096
|
+
align: { default: "center" },
|
|
1097
|
+
label: {},
|
|
1098
|
+
description: {},
|
|
1099
|
+
density: { default: "balanced" },
|
|
1100
|
+
onClick: {},
|
|
1101
|
+
interactiveRef: {},
|
|
1102
|
+
href: {},
|
|
1103
|
+
target: {},
|
|
1104
|
+
rel: {},
|
|
1105
|
+
isDisabled: {
|
|
1106
|
+
type: Boolean,
|
|
1107
|
+
default: false
|
|
1108
|
+
},
|
|
1109
|
+
isSelected: {
|
|
1110
|
+
type: Boolean,
|
|
1111
|
+
default: false
|
|
1112
|
+
},
|
|
1113
|
+
itemKey: {},
|
|
1114
|
+
swipe: {},
|
|
1115
|
+
swipeActions: {},
|
|
1116
|
+
swipeBehavior: {}
|
|
1117
|
+
},
|
|
1118
|
+
setup(__props, { expose: __expose }) {
|
|
1119
|
+
const props = __props;
|
|
1120
|
+
const linkComponent = useLinkComponent();
|
|
1121
|
+
const ARIA_SELECTED_ROLES = /* @__PURE__ */ new Set([
|
|
1122
|
+
"option",
|
|
1123
|
+
"tab",
|
|
1124
|
+
"row",
|
|
1125
|
+
"gridcell",
|
|
1126
|
+
"columnheader",
|
|
1127
|
+
"rowheader",
|
|
1128
|
+
"treeitem"
|
|
1129
|
+
]);
|
|
1130
|
+
const INTERACTIVE_SELECTOR = [
|
|
1131
|
+
"button",
|
|
1132
|
+
"a",
|
|
1133
|
+
"input",
|
|
1134
|
+
"select",
|
|
1135
|
+
"textarea",
|
|
1136
|
+
"[role=\"button\"]",
|
|
1137
|
+
"[role=\"link\"]",
|
|
1138
|
+
"[role=\"checkbox\"]",
|
|
1139
|
+
"[role=\"radio\"]",
|
|
1140
|
+
"[role=\"switch\"]",
|
|
1141
|
+
"[role=\"tab\"]",
|
|
1142
|
+
"[role=\"menuitem\"]",
|
|
1143
|
+
"[role=\"option\"]",
|
|
1144
|
+
"[role=\"combobox\"]",
|
|
1145
|
+
"[role=\"listbox\"]",
|
|
1146
|
+
"[role=\"slider\"]",
|
|
1147
|
+
"[role=\"spinbutton\"]"
|
|
1148
|
+
].join(",");
|
|
1149
|
+
const CONTROLLED_ATTRS = /* @__PURE__ */ new Set([
|
|
1150
|
+
"class",
|
|
1151
|
+
"style",
|
|
1152
|
+
"role",
|
|
1153
|
+
"aria-current",
|
|
1154
|
+
"aria-disabled",
|
|
1155
|
+
"aria-selected"
|
|
1156
|
+
]);
|
|
1157
|
+
const attrs = useAttrs();
|
|
1158
|
+
const slots = useSlots();
|
|
1159
|
+
const root = useTemplateRef("root");
|
|
1160
|
+
function isRenderable(value) {
|
|
1161
|
+
return value != null && value !== "";
|
|
1162
|
+
}
|
|
1163
|
+
function isInteractiveElement(element) {
|
|
1164
|
+
return element.matches(INTERACTIVE_SELECTOR) && !element.matches("[aria-readonly=\"true\"]");
|
|
1165
|
+
}
|
|
1166
|
+
function toElement(value) {
|
|
1167
|
+
if (value == null) return null;
|
|
1168
|
+
if (value instanceof HTMLElement) return value;
|
|
1169
|
+
return value.$el instanceof HTMLElement ? value.$el : null;
|
|
1170
|
+
}
|
|
1171
|
+
const element = computed(() => toElement(root.value));
|
|
1172
|
+
const descriptionIdBase = `astryx-item-description-${useId()}`;
|
|
1173
|
+
const hasDescription = computed(() => slots.description != null || isRenderable(props.description));
|
|
1174
|
+
const hasLabel = computed(() => slots.label != null || isRenderable(props.label));
|
|
1175
|
+
const { trailing, shownLabelId } = useItemSlotsFromWrapper(`astryx-item-label-${useId()}`, hasLabel);
|
|
1176
|
+
const listRow = readLayerScoped(itemListRowKey);
|
|
1177
|
+
const isListRow = listRow != null;
|
|
1178
|
+
provide(itemListRowKey, null);
|
|
1179
|
+
provide(itemDescriptionContextKey, computed(() => hasDescription.value ? descriptionIdBase : null));
|
|
1180
|
+
const role = computed(() => attrs.role);
|
|
1181
|
+
const hasParentRole = computed(() => role.value != null);
|
|
1182
|
+
const allowsAriaSelected = computed(() => role.value != null && ARIA_SELECTED_ROLES.has(role.value));
|
|
1183
|
+
const ariaCurrent = computed(() => attrs["aria-current"] ?? (props.isSelected && !allowsAriaSelected.value ? true : void 0));
|
|
1184
|
+
const isDelegate = computed(() => props.interactiveRef != null);
|
|
1185
|
+
/** `javascript:` 这类地址不交给浏览器,行也就不是链接。 */
|
|
1186
|
+
const safeHref = computed(() => {
|
|
1187
|
+
const href = props.href;
|
|
1188
|
+
return href != null && href !== "" && isSafeUrl(href) ? href : void 0;
|
|
1189
|
+
});
|
|
1190
|
+
const isInteractive = computed(() => props.onClick != null || safeHref.value != null || isDelegate.value);
|
|
1191
|
+
/** 链接内容用的根组件:`as` 写了组件就用它,否则用 LinkProvider 给的默认值。 */
|
|
1192
|
+
/**
|
|
1193
|
+
* 读屏器在拿到焦点的元素上念「当前」标记。可点的行里那是行自己的按钮、链接,
|
|
1194
|
+
* 或它转发点击的控件;根元素自己拿焦点的行(带父级角色)把标记留在根上。
|
|
1195
|
+
*/
|
|
1196
|
+
const currentOnFocusTarget = computed(() => !hasParentRole.value && (isDelegate.value || safeHref.value != null || props.onClick != null));
|
|
1197
|
+
/** 控件上不写 `false`。 */
|
|
1198
|
+
const controlCurrent = computed(() => {
|
|
1199
|
+
const value = ariaCurrent.value;
|
|
1200
|
+
return value === false || value === "false" ? void 0 : value;
|
|
1201
|
+
});
|
|
1202
|
+
const customLink = computed(() => typeof props.as === "string" ? linkComponent.value : props.as);
|
|
1203
|
+
const isLinkContent = computed(() => safeHref.value != null && customLink.value != null);
|
|
1204
|
+
const { pressActionProps } = usePressFeedback({
|
|
1205
|
+
hasOverlay: false,
|
|
1206
|
+
isContainer: true
|
|
1207
|
+
});
|
|
1208
|
+
const pressable = computed(() => isInteractive.value && !props.isDisabled);
|
|
1209
|
+
/**
|
|
1210
|
+
* 行自己有动作(点击、链接、或把点击转给嵌套控件)时,它是可按容器:
|
|
1211
|
+
* 手指按在行里别的控件上,那一下不执行行的动作,行就不亮。带父级角色的行(选项、菜单项)整行就是动作。
|
|
1212
|
+
*/
|
|
1213
|
+
const isPressContainer = computed(() => pressable.value && (isDelegate.value || !hasParentRole.value));
|
|
1214
|
+
const resolvedTarget = computed(() => props.target);
|
|
1215
|
+
const resolvedRel = computed(() => {
|
|
1216
|
+
const tokens = new Set((props.rel ?? "").split(/\s+/).filter(Boolean));
|
|
1217
|
+
if (resolvedTarget.value === "_blank") {
|
|
1218
|
+
tokens.add("noopener");
|
|
1219
|
+
tokens.add("noreferrer");
|
|
1220
|
+
}
|
|
1221
|
+
return tokens.size > 0 ? [...tokens].join(" ") : void 0;
|
|
1222
|
+
});
|
|
1223
|
+
const isInline = computed(() => props.layout === "inline" && hasDescription.value);
|
|
1224
|
+
function clampClass(lines) {
|
|
1225
|
+
if (lines === 1) return "astryx-item__ellipsis";
|
|
1226
|
+
return lines > 1 ? "astryx-item__clamp" : void 0;
|
|
1227
|
+
}
|
|
1228
|
+
function clampStyle(lines) {
|
|
1229
|
+
return lines > 1 ? { "--astryx-item-clamp-lines": String(lines) } : void 0;
|
|
1230
|
+
}
|
|
1231
|
+
const labelClamp = computed(() => props.labelLines ?? (typeof props.label === "string" ? 1 : 0));
|
|
1232
|
+
const descriptionClamp = computed(() => {
|
|
1233
|
+
if (props.descriptionLines != null) return props.descriptionLines;
|
|
1234
|
+
return typeof props.description === "string" || isInline.value ? 1 : 0;
|
|
1235
|
+
});
|
|
1236
|
+
const labelClasses = computed(() => clampClass(labelClamp.value));
|
|
1237
|
+
const labelStyle = computed(() => clampStyle(labelClamp.value));
|
|
1238
|
+
const descriptionClasses = computed(() => clampClass(descriptionClamp.value));
|
|
1239
|
+
const descriptionStyle = computed(() => clampStyle(descriptionClamp.value));
|
|
1240
|
+
useFocusAcrossSwap(() => element.value, ".astryx-item__content", () => props.isDisabled);
|
|
1241
|
+
const contentRole = useInteractiveRole({
|
|
1242
|
+
href: () => hasParentRole.value || isDelegate.value ? void 0 : safeHref.value,
|
|
1243
|
+
hasOnClick: () => !hasParentRole.value && !isDelegate.value && props.onClick != null
|
|
1244
|
+
});
|
|
1245
|
+
const contentTag = computed(() => {
|
|
1246
|
+
if (contentRole.role.value === "link") return isLinkContent.value && !props.isDisabled ? toRaw(customLink.value) : "a";
|
|
1247
|
+
return contentRole.role.value === "button" ? "button" : "span";
|
|
1248
|
+
});
|
|
1249
|
+
function handleContentClick(event) {
|
|
1250
|
+
props.onClick?.(event);
|
|
1251
|
+
}
|
|
1252
|
+
const baseContentAttrs = computed(() => {
|
|
1253
|
+
const href = safeHref.value;
|
|
1254
|
+
if (href != null && !hasParentRole.value && !isDelegate.value) {
|
|
1255
|
+
if (props.isDisabled) return {
|
|
1256
|
+
"role": "link",
|
|
1257
|
+
"aria-disabled": true,
|
|
1258
|
+
"tabindex": 0,
|
|
1259
|
+
...pressActionProps
|
|
1260
|
+
};
|
|
1261
|
+
return {
|
|
1262
|
+
href,
|
|
1263
|
+
to: isLinkContent.value ? href : void 0,
|
|
1264
|
+
rel: resolvedRel.value,
|
|
1265
|
+
target: resolvedTarget.value,
|
|
1266
|
+
...pressActionProps
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
if (contentTag.value === "button") {
|
|
1270
|
+
if (props.isDisabled) return {
|
|
1271
|
+
"type": "button",
|
|
1272
|
+
"aria-disabled": true,
|
|
1273
|
+
...disabledInteractionProps(),
|
|
1274
|
+
...pressActionProps
|
|
1275
|
+
};
|
|
1276
|
+
return {
|
|
1277
|
+
type: "button",
|
|
1278
|
+
onClick: handleContentClick,
|
|
1279
|
+
...pressActionProps
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
return {};
|
|
1283
|
+
});
|
|
1284
|
+
const contentAttrs = computed(() => {
|
|
1285
|
+
const current = currentOnFocusTarget.value && !isDelegate.value ? { "aria-current": controlCurrent.value } : {};
|
|
1286
|
+
return {
|
|
1287
|
+
...baseContentAttrs.value,
|
|
1288
|
+
...current
|
|
1289
|
+
};
|
|
1290
|
+
});
|
|
1291
|
+
function hasTextSelection(node) {
|
|
1292
|
+
const selection = node.ownerDocument.getSelection?.();
|
|
1293
|
+
return selection != null && !selection.isCollapsed && selection.anchorNode != null && node.contains(selection.anchorNode);
|
|
1294
|
+
}
|
|
1295
|
+
function hasInteractiveAncestor(target, container) {
|
|
1296
|
+
let current = target;
|
|
1297
|
+
while (current != null && current !== container && current !== container.ownerDocument.body) {
|
|
1298
|
+
if (isInteractiveElement(current) || isLayerSurface(current)) return true;
|
|
1299
|
+
current = current.parentElement;
|
|
1300
|
+
}
|
|
1301
|
+
return false;
|
|
1302
|
+
}
|
|
1303
|
+
/** 点按落在行的内边距或粗指针的热区上时,转给行里的链接(带着修饰键,Cmd/Ctrl 点击照样新开标签页)。 */
|
|
1304
|
+
function followRowLink(event) {
|
|
1305
|
+
const row = event.currentTarget;
|
|
1306
|
+
const anchor = row.querySelector("a.astryx-item__content, .astryx-item__content[role=\"link\"]");
|
|
1307
|
+
if (anchor == null || event.target !== row || event.detail === 0) return;
|
|
1308
|
+
const box = row.getBoundingClientRect();
|
|
1309
|
+
if (!(event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom) && !isCoarsePointer(row.ownerDocument.defaultView)) return;
|
|
1310
|
+
anchor.dispatchEvent(new MouseEvent("click", {
|
|
1311
|
+
altKey: event.altKey,
|
|
1312
|
+
bubbles: true,
|
|
1313
|
+
button: event.button,
|
|
1314
|
+
cancelable: true,
|
|
1315
|
+
ctrlKey: event.ctrlKey,
|
|
1316
|
+
metaKey: event.metaKey,
|
|
1317
|
+
shiftKey: event.shiftKey
|
|
1318
|
+
}));
|
|
1319
|
+
}
|
|
1320
|
+
function handleContainerClick(event) {
|
|
1321
|
+
if (props.isDisabled) return;
|
|
1322
|
+
const target = event.target;
|
|
1323
|
+
if (isListRow && props.onClick == null && safeHref.value != null) {
|
|
1324
|
+
followRowLink(event);
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
if (target instanceof HTMLElement && target.closest(NATIVE_CONTROL_SELECTOR) != null) return;
|
|
1328
|
+
if (target instanceof Element && isInLayerSurface(target, event.currentTarget)) return;
|
|
1329
|
+
props.onClick?.(event);
|
|
1330
|
+
}
|
|
1331
|
+
function handleDelegatedClick(event) {
|
|
1332
|
+
if (props.isDisabled) return;
|
|
1333
|
+
const container = element.value;
|
|
1334
|
+
const target = event.target;
|
|
1335
|
+
if (container == null || !(target instanceof HTMLElement)) return;
|
|
1336
|
+
if (hasTextSelection(container)) return;
|
|
1337
|
+
if (target !== event.currentTarget && hasInteractiveAncestor(target, container)) return;
|
|
1338
|
+
const control = toValue(props.interactiveRef);
|
|
1339
|
+
if (control == null) return;
|
|
1340
|
+
control.dispatchEvent(new MouseEvent("click", {
|
|
1341
|
+
altKey: event.altKey,
|
|
1342
|
+
bubbles: event.bubbles,
|
|
1343
|
+
button: event.button,
|
|
1344
|
+
cancelable: event.cancelable,
|
|
1345
|
+
ctrlKey: event.ctrlKey,
|
|
1346
|
+
metaKey: event.metaKey,
|
|
1347
|
+
shiftKey: event.shiftKey
|
|
1348
|
+
}));
|
|
1349
|
+
event.stopPropagation();
|
|
1350
|
+
}
|
|
1351
|
+
useDelegatedControl({
|
|
1352
|
+
control: () => isDelegate.value ? toValue(props.interactiveRef) : null,
|
|
1353
|
+
current: () => currentOnFocusTarget.value ? controlCurrent.value : void 0,
|
|
1354
|
+
pressAttributes: pressActionProps
|
|
1355
|
+
});
|
|
1356
|
+
const swipeHost = useItemSwipeHost(props, () => ({
|
|
1357
|
+
role: role.value,
|
|
1358
|
+
isDisabled: props.isDisabled,
|
|
1359
|
+
isDelegate: isDelegate.value
|
|
1360
|
+
}));
|
|
1361
|
+
const swipeLayer = useTemplateRef("swipeLayer");
|
|
1362
|
+
function handleKeydown(event) {
|
|
1363
|
+
swipeLayer.value?.onKeyDown(event);
|
|
1364
|
+
}
|
|
1365
|
+
/** 有序列表的行把标记之外的内容收进同一格,列表据此让所有行共用一列标记。 */
|
|
1366
|
+
const MarkerCell = (_, { slots: inner }) => listRow?.isNumbered.value === true && slots.marker != null ? h("span", { class: "astryx-item__marker-content" }, inner.default?.()) : inner.default?.();
|
|
1367
|
+
const rootClick = computed(() => {
|
|
1368
|
+
if (isDelegate.value) return handleDelegatedClick;
|
|
1369
|
+
if (hasParentRole.value) return props.onClick;
|
|
1370
|
+
return isInteractive.value ? handleContainerClick : void 0;
|
|
1371
|
+
});
|
|
1372
|
+
const rootClass = computed(() => [
|
|
1373
|
+
"astryx-item",
|
|
1374
|
+
swipeHost.value != null && "astryx-item--swipe",
|
|
1375
|
+
isDelegate.value && "astryx-item--delegate",
|
|
1376
|
+
attrs.class
|
|
1377
|
+
]);
|
|
1378
|
+
const forwardedAttrs = computed(() => Object.fromEntries(Object.entries(attrs).filter(([key]) => !CONTROLLED_ATTRS.has(key))));
|
|
1379
|
+
function focus(options) {
|
|
1380
|
+
(element.value?.querySelector("a[href], button:not([disabled])"))?.focus(options);
|
|
1381
|
+
}
|
|
1382
|
+
function blur() {
|
|
1383
|
+
const active = element.value?.ownerDocument.activeElement;
|
|
1384
|
+
if (active instanceof HTMLElement && element.value?.contains(active)) active.blur();
|
|
1385
|
+
}
|
|
1386
|
+
__expose({
|
|
1387
|
+
element,
|
|
1388
|
+
focus,
|
|
1389
|
+
blur
|
|
1390
|
+
});
|
|
1391
|
+
return (_ctx, _cache) => {
|
|
1392
|
+
return openBlock(), createBlock(resolveDynamicComponent(__props.as), mergeProps({
|
|
1393
|
+
ref_key: "root",
|
|
1394
|
+
ref: root
|
|
1395
|
+
}, forwardedAttrs.value, {
|
|
1396
|
+
"aria-current": currentOnFocusTarget.value ? void 0 : ariaCurrent.value,
|
|
1397
|
+
"aria-disabled": __props.isDisabled || void 0,
|
|
1398
|
+
"aria-selected": allowsAriaSelected.value && __props.isSelected ? true : void 0,
|
|
1399
|
+
class: rootClass.value,
|
|
1400
|
+
"data-align": __props.align,
|
|
1401
|
+
"data-density": __props.density,
|
|
1402
|
+
"data-disabled": __props.isDisabled || void 0,
|
|
1403
|
+
"data-highlighted": __props.isHighlighted || void 0,
|
|
1404
|
+
"data-inert": __props.isDisabled && !hasParentRole.value ? true : void 0,
|
|
1405
|
+
"data-interactive": isInteractive.value || void 0,
|
|
1406
|
+
"data-selected": __props.isSelected || void 0,
|
|
1407
|
+
"data-astryx-pressable": pressable.value ? "" : void 0,
|
|
1408
|
+
"data-astryx-press-container": isPressContainer.value ? "" : void 0,
|
|
1409
|
+
role: role.value,
|
|
1410
|
+
style: unref(attrs).style,
|
|
1411
|
+
onKeydown: handleKeydown,
|
|
1412
|
+
onClick: rootClick.value
|
|
1413
|
+
}), {
|
|
1414
|
+
default: withCtx(() => [
|
|
1415
|
+
unref(swipeHost) ? (openBlock(), createBlock(_sfc_main$1, {
|
|
1416
|
+
key: 0,
|
|
1417
|
+
ref_key: "swipeLayer",
|
|
1418
|
+
ref: swipeLayer,
|
|
1419
|
+
leading: unref(swipeHost).leading,
|
|
1420
|
+
trailing: unref(swipeHost).trailing,
|
|
1421
|
+
behavior: unref(swipeHost).behavior,
|
|
1422
|
+
"item-key": unref(swipeHost).itemKey
|
|
1423
|
+
}, null, 8, [
|
|
1424
|
+
"leading",
|
|
1425
|
+
"trailing",
|
|
1426
|
+
"behavior",
|
|
1427
|
+
"item-key"
|
|
1428
|
+
])) : createCommentVNode("v-if", true),
|
|
1429
|
+
renderSlot(_ctx.$slots, "marker"),
|
|
1430
|
+
createVNode(MarkerCell, null, {
|
|
1431
|
+
default: withCtx(() => [
|
|
1432
|
+
_ctx.$slots.startContent ? (openBlock(), createElementBlock("span", _hoisted_1, [renderSlot(_ctx.$slots, "startContent")])) : createCommentVNode("v-if", true),
|
|
1433
|
+
(openBlock(), createBlock(resolveDynamicComponent(contentTag.value), mergeProps(contentAttrs.value, { class: ["astryx-item__content", { "astryx-item__content--inline": isInline.value }] }), {
|
|
1434
|
+
default: withCtx(() => [hasLabel.value ? (openBlock(), createElementBlock("span", {
|
|
1435
|
+
key: 0,
|
|
1436
|
+
id: unref(shownLabelId) ?? void 0,
|
|
1437
|
+
class: normalizeClass(["astryx-item__label", labelClasses.value]),
|
|
1438
|
+
style: normalizeStyle(labelStyle.value)
|
|
1439
|
+
}, [renderSlot(_ctx.$slots, "label", {}, () => [createTextVNode(toDisplayString(__props.label), 1)])], 14, _hoisted_2)) : createCommentVNode("v-if", true), hasDescription.value ? (openBlock(), createElementBlock("span", {
|
|
1440
|
+
key: 1,
|
|
1441
|
+
id: descriptionIdBase,
|
|
1442
|
+
class: normalizeClass(["astryx-item__description", descriptionClasses.value]),
|
|
1443
|
+
style: normalizeStyle(descriptionStyle.value)
|
|
1444
|
+
}, [renderSlot(_ctx.$slots, "description", {}, () => [createTextVNode(toDisplayString(__props.description), 1)])], 6)) : createCommentVNode("v-if", true)]),
|
|
1445
|
+
_: 3
|
|
1446
|
+
}, 16, ["class"])),
|
|
1447
|
+
_ctx.$slots.endContent ? (openBlock(), createElementBlock("span", _hoisted_3, [renderSlot(_ctx.$slots, "endContent")])) : createCommentVNode("v-if", true),
|
|
1448
|
+
unref(trailing) ? (openBlock(), createBlock(resolveDynamicComponent(unref(trailing)), { key: 2 })) : createCommentVNode("v-if", true)
|
|
1449
|
+
]),
|
|
1450
|
+
_: 3
|
|
1451
|
+
})
|
|
1452
|
+
]),
|
|
1453
|
+
_: 3
|
|
1454
|
+
}, 16, [
|
|
1455
|
+
"aria-current",
|
|
1456
|
+
"aria-disabled",
|
|
1457
|
+
"aria-selected",
|
|
1458
|
+
"class",
|
|
1459
|
+
"data-align",
|
|
1460
|
+
"data-density",
|
|
1461
|
+
"data-disabled",
|
|
1462
|
+
"data-highlighted",
|
|
1463
|
+
"data-inert",
|
|
1464
|
+
"data-interactive",
|
|
1465
|
+
"data-selected",
|
|
1466
|
+
"data-astryx-pressable",
|
|
1467
|
+
"data-astryx-press-container",
|
|
1468
|
+
"role",
|
|
1469
|
+
"style",
|
|
1470
|
+
"onClick"
|
|
1471
|
+
]);
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
//#endregion
|
|
1476
|
+
export { _sfc_main as t };
|