@astryx-vue/core 0.19.1 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlertDialog/index.js +1 -1
- package/dist/{AlertDialog-CNb0dkY9.js → AlertDialog-DYYA2LOe.js} +6 -6
- package/dist/AppShell/index.js +1 -1
- package/dist/{AppShell-NvIT99xw.js → AppShell-zEXmJb1h.js} +116 -9
- 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-BXITu2pn.js → Banner-C4ZICVvW.js} +1 -1
- package/dist/BottomSheet/index.d.ts +1 -1
- package/dist/BottomSheet/index.js +2 -2
- package/dist/{BottomSheet-CCW58Kl3.js → BottomSheet-DNuzJPfQ.js} +2 -2
- package/dist/{BottomSheet-HQpcSkPH.js → BottomSheet-DV7bboru.js} +1 -1
- package/dist/Breadcrumbs/index.d.ts +1 -1
- package/dist/Breadcrumbs/index.js +2 -2
- package/dist/{Breadcrumbs-DXzBkpkd.js → Breadcrumbs-C8nA3Ft9.js} +1 -1
- package/dist/Button/index.d.ts +1 -1
- package/dist/Button/index.js +1 -1
- package/dist/{Button-BZtim0B-.js → Button-DOfigN38.js} +1 -1
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/ButtonGroup/index.js +1 -1
- package/dist/{ButtonGroup-EpWZowJP.js → ButtonGroup-BzrDhbMP.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-BaCXqtKK.js → Carousel-CRaHAUsZ.js} +1 -1
- package/dist/Chat/index.d.ts +1 -1
- package/dist/Chat/index.js +1 -1
- package/dist/{Chat-CXwXzlZ0.js → Chat-DTs843Ta.js} +1 -1
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxInput/index.js +1 -1
- package/dist/{CheckboxInput-3ONBl1AY.js → CheckboxInput-Ydl1GSBh.js} +33 -3
- package/dist/CheckboxList/index.d.ts +1 -1
- package/dist/CheckboxList/index.js +1 -1
- package/dist/{CheckboxList-CbRX5YDA.js → CheckboxList-Sn_ph-Xz.js} +64 -5
- package/dist/ClickableCard/index.d.ts +1 -1
- package/dist/Code/index.js +1 -1
- package/dist/{CodeBlock-CLVXVlB7.js → CodeBlock-DXBJEZS6.js} +1 -1
- package/dist/Collapsible/index.js +1 -1
- package/dist/{Collapsible-ExzU7vC0.js → Collapsible-BG-u5nEt.js} +2 -1
- package/dist/CommandPalette/index.js +1 -1
- package/dist/{CommandPalette-CECjNvGB.js → CommandPalette-CV7t0ouM.js} +1 -1
- package/dist/ComplexSelector/index.d.ts +1 -1
- package/dist/ComplexSelector/index.js +1 -1
- package/dist/{ComplexSelector-Dmaag1wm.js → ComplexSelector-BKjyFdHr.js} +2 -2
- package/dist/ContextMenu/index.d.ts +1 -1
- package/dist/ContextMenu/index.js +2 -2
- package/dist/{ContextMenu-CujLDt4e.js → ContextMenu-CwnY6hcJ.js} +2 -2
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-CiIWOWXM.js → DateInput-BaX40vSs.js} +4 -4
- package/dist/DateRangeInput/index.d.ts +1 -1
- package/dist/DateRangeInput/index.js +1 -1
- package/dist/{DateRangeInput-CLVQ8E0Y.js → DateRangeInput-DplhXZqK.js} +3 -3
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.js +1 -1
- package/dist/{DateTimeInput-jHSN-Dzu.js → DateTimeInput-CrD1EEfs.js} +7 -7
- package/dist/Dialog/index.js +3 -3
- package/dist/{Dialog-BQ5OBB1d.js → Dialog-B2pOTrnQ.js} +1 -1
- package/dist/{Dialog-DgdbRn2l.js → Dialog-CztWmbf8.js} +1 -1
- package/dist/{DialogHeader-D8234o9F.js → DialogHeader-CjHTNccL.js} +2 -2
- 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-Dqus7kUc.js → Drawer-DGIuMLms.js} +2 -2
- package/dist/DropdownMenu/index.js +3 -3
- package/dist/{DropdownMenu-BC_zB9le.js → DropdownMenu-l9c562oA.js} +31 -8
- package/dist/{DropdownMenu-LQsXd-_V.js → DropdownMenu-r93pI0mD.js} +4 -4
- package/dist/EmptyState/index.js +1 -1
- package/dist/{EmptyState-Bw0kWfMi.js → EmptyState-nyV5XxMA.js} +2 -2
- package/dist/Field/index.js +3 -3
- package/dist/{Field-BXkGR8H0.js → Field-CIZdFzXr.js} +1 -1
- package/dist/{FieldInfoTip-DzpUxMDh.js → FieldInfoTip-eJSORVbp.js} +1 -1
- package/dist/{FieldLabel-DI7Yqdhf.js → FieldLabel-BoMSIOLF.js} +1 -1
- package/dist/FileInput/index.d.ts +1 -1
- package/dist/FileInput/index.js +1 -1
- package/dist/{FileInput-BNHjbyQY.js → FileInput-DvGU92Sg.js} +2 -2
- package/dist/Heading/index.js +1 -1
- package/dist/{Heading-Oph-5DDq.js → Heading-Bo6A69fA.js} +1 -1
- package/dist/HoverCard/index.d.ts +1 -1
- package/dist/IconButton/index.js +1 -1
- package/dist/{IconButton-Du2XBBAX.js → IconButton-oKXLxgYb.js} +1 -1
- package/dist/InfoTip/index.d.ts +1 -1
- package/dist/InfoTip/index.js +1 -1
- package/dist/{InfoTip-Bjw1ithP.js → InfoTip-DWC-vnT5.js} +1 -1
- package/dist/{InputClearButton-CED-zP2y.js → InputClearButton-CAitWZTk.js} +1 -1
- package/dist/InputGroup/index.js +1 -1
- package/dist/{InputGroup-D5PoL4cU.js → InputGroup-CeTKqJQn.js} +1 -1
- package/dist/{Item-CNR22qzk.js → Item-BSHDEJyh.js} +18 -10
- package/dist/Lightbox/index.js +1 -1
- package/dist/{Lightbox-RN_f7zRw.js → Lightbox-CesmEisI.js} +3 -3
- package/dist/Link/index.d.ts +1 -1
- package/dist/List/index.d.ts +1 -1
- package/dist/List/index.js +2 -2
- package/dist/{ListItem-BJ6ZaKcj.js → ListItem-v1GFTbba.js} +1 -1
- package/dist/Markdown/index.d.ts +1 -1
- package/dist/Markdown/index.js +1 -1
- package/dist/{Markdown-DnnWjJGX.js → Markdown-CIA5ejYp.js} +2 -2
- package/dist/MobileNav/index.d.ts +1 -1
- package/dist/MobileNav/index.js +1 -1
- package/dist/{MobileNavToggle-DlQmYaBx.js → MobileNavToggle-CKEOroi0.js} +75 -32
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-i80Ey9vR.js → MoreMenu-DcImQxyp.js} +3 -3
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-BK6nZweN.js → MultiSelector-DedRF-RL.js} +3 -3
- package/dist/{NavHeadingSurface-C17cbKn9.js → NavHeadingSurface-DZPa2px5.js} +19 -5
- package/dist/NavItem/index.d.ts +2 -2
- package/dist/NavItem/index.js +1 -1
- package/dist/{NavItem-BAe-tUG9.js → NavItem-CcbOJNnY.js} +18 -5
- package/dist/NavMenu/index.d.ts +1 -1
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/NumberInput/index.js +1 -1
- package/dist/{NumberInput-BsWTXomE.js → NumberInput-q9HP5L_V.js} +3 -3
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/Pagination/index.d.ts +1 -1
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-DFQNX_Mb.js → Pagination-DfAHckUV.js} +1 -1
- package/dist/Popover/index.d.ts +1 -1
- package/dist/Popover/index.js +1 -1
- package/dist/{Popover-CmAEizH-.js → Popover-D0jAIXkw.js} +3 -2
- package/dist/PowerSearch/index.d.ts +1 -1
- package/dist/PowerSearch/index.js +1 -1
- package/dist/{PowerSearch-C2x4uuAM.js → PowerSearch-CU_MBQlC.js} +12 -12
- package/dist/ProgressBar/index.d.ts +1 -1
- package/dist/Radio/index.d.ts +1 -1
- package/dist/Radio/index.js +1 -1
- package/dist/{RadioGroup-FhoQMqg5.js → RadioGroup-Cm2n6M5C.js} +10 -2
- package/dist/RadioList/index.d.ts +1 -1
- package/dist/RadioList/index.js +1 -1
- package/dist/{RadioList-DK2uXQ5S.js → RadioList-B5MaynOw.js} +1 -1
- package/dist/Resizable/index.d.ts +1 -1
- package/dist/ScrollableArea/index.d.ts +1 -1
- package/dist/SegmentedControl/index.d.ts +1 -1
- package/dist/SegmentedControl/index.js +1 -1
- package/dist/{SegmentedControl-BCvscZM9.js → SegmentedControl-D--5X0eZ.js} +9 -2
- 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-Bo7qkt1P.js → Selector-wcbEB7BC.js} +2 -2
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +2 -2
- package/dist/{SideNav-CcZLUd7G.js → SideNav-CYlAzvrT.js} +512 -58
- package/dist/Slider/index.js +1 -1
- package/dist/{Slider-DIgb8ogt.js → Slider-jgmpvIDe.js} +1 -1
- package/dist/Stepper/index.d.ts +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-5toeiELX.js → Switch-YNk17Lct.js} +1 -1
- package/dist/TabList/index.d.ts +1 -1
- package/dist/Table/index.d.ts +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/{Table-o3aGMDT1.js → Table-DcFujAPW.js} +12 -10
- package/dist/Text/index.js +2 -2
- package/dist/{Text-CiSw2pOi.js → Text-Bv4urzOW.js} +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-B82oXF-m.js → TextArea-CixgkV__.js} +4 -4
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/TextInput/index.js +1 -1
- package/dist/{TextInput-_SIiqVOY.js → TextInput-Bpiq3FcP.js} +4 -4
- package/dist/Thumbnail/index.js +1 -1
- package/dist/{Thumbnail-BlueoqOH.js → Thumbnail-Bktyar_H.js} +1 -1
- package/dist/{TimeField-BM-rVFhC.js → TimeField-BtiLoHqW.js} +4 -4
- package/dist/TimeInput/index.d.ts +1 -1
- package/dist/TimeInput/index.js +1 -1
- package/dist/{TimeInput-CkZfhhAr.js → TimeInput-eyxw3KzD.js} +2 -2
- package/dist/Timer/index.d.ts +1 -1
- package/dist/Timer/index.js +1 -1
- package/dist/{Timer-DiIs5GLA.js → Timer-C-N-sElU.js} +2 -2
- package/dist/Timestamp/index.d.ts +1 -1
- package/dist/Timestamp/index.js +1 -1
- package/dist/{Timestamp-D9Jyk9sD.js → Timestamp-BTs10ZLD.js} +2 -2
- package/dist/Toast/index.js +1 -1
- package/dist/{Toast-D4Q6wvYu.js → Toast-DpMqZ72F.js} +1 -1
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/ToggleButton/index.js +1 -1
- package/dist/{ToggleButton-CO0XWWc0.js → ToggleButton-W_tpgZ8k.js} +3 -3
- package/dist/Token/index.d.ts +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-CsFiYUJ_.js → Tokenizer-Bs1VXinx.js} +2 -2
- 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-CFkThrKq.js → TopNav-CSFUTuyI.js} +3 -3
- package/dist/TreeList/index.d.ts +1 -1
- package/dist/TreeList/index.js +1 -1
- package/dist/{TreeList-ugSF9DWj.js → TreeList-B8p_lI7a.js} +18 -9
- package/dist/Typeahead/index.js +1 -1
- package/dist/{Typeahead--kEp21ut.js → Typeahead-Bh0nap5Z.js} +2 -2
- package/dist/{landing-Bs0aMIsR.js → batch-BJD6Bt-O.js} +42 -740
- package/dist/composables/index.js +4 -4
- package/dist/{composables-BgfubKnk.js → composables-CDrwFX0l.js} +2 -19
- package/dist/context-Cj_zItu2.js +729 -0
- package/dist/{dateParser-DS_a8Ej8.js → dateParser-BKoaawL9.js} +46 -2
- package/dist/edge-DIlkB7vS.js +164 -0
- package/dist/edgeRide-D0oC2JEB.js +499 -0
- package/dist/focusAcrossSwap-Casww_IY.js +19 -0
- package/dist/focusRegion-CmDg7_4b.js +81 -0
- package/dist/{handle-BPXdHbkr.js → handle-ChN2TMKH.js} +1 -1
- package/dist/{index-C93nwgTW.d.ts → index-51CkIKnI.d.ts} +1 -1
- package/dist/{index--kbwaSXW.d.ts → index-5Hrxeq2J.d.ts} +4 -4
- package/dist/{index-D-giO0SA.d.ts → index-B63NOJRc.d.ts} +8 -8
- package/dist/{index-X4S7_dmq.d.ts → index-BA8exXNP.d.ts} +1 -1
- package/dist/{index-CryFtTT6.d.ts → index-BIQZa2BD.d.ts} +1 -1
- package/dist/{index-CUCgbqBB.d.ts → index-BNtSmuWg.d.ts} +5 -5
- package/dist/{index-BO9TY87G.d.ts → index-BOCb89V9.d.ts} +3 -3
- package/dist/{index-Djf0M7PH.d.ts → index-BP2SjZiM.d.ts} +2 -2
- package/dist/{index-CdvmnNMH.d.ts → index-BaFphczL.d.ts} +1 -1
- package/dist/{index-CKUfpmFL.d.ts → index-C3FgFPrM.d.ts} +3 -1
- package/dist/{index-BeR-1LgF.d.ts → index-C5fbwY7Y.d.ts} +4 -3
- package/dist/{index-C4S65SAW.d.ts → index-CKnr0JlT.d.ts} +1 -1
- package/dist/{index-ohw86wfM.d.ts → index-CaE2cqeG.d.ts} +59 -55
- package/dist/{index-Otl047R1.d.ts → index-Cb-rvc1W.d.ts} +1 -1
- package/dist/{index-C9ZssPUV.d.ts → index-CiVrhGUJ.d.ts} +1 -1
- package/dist/{index-C8wfe0Mr.d.ts → index-D05JGsT3.d.ts} +1 -1
- package/dist/{index-B449gOMC.d.ts → index-D1JXm7Et.d.ts} +3 -3
- package/dist/{index-BL4mH8aK.d.ts → index-DMN_JVEt.d.ts} +1 -1
- package/dist/{index-aE810PYg.d.ts → index-DmAEpn5E.d.ts} +1 -1
- package/dist/{index-CfXW4km8.d.ts → index-GgHVkJtB.d.ts} +1 -1
- package/dist/{index-DdT2wE_N.d.ts → index-LaQSu7ST.d.ts} +7 -7
- package/dist/{index-eCp-ElSp.d.ts → index-MvrDMqnQ.d.ts} +1 -1
- package/dist/{index-B-3EGjfQ.d.ts → index-Q1oG9yIT.d.ts} +2 -2
- package/dist/{index-DE1genab.d.ts → index-QnlWyUxN.d.ts} +2 -2
- package/dist/{index-Dg0JsBpI.d.ts → index-Y-AmNzkO.d.ts} +2 -2
- package/dist/{index-dWlCpnua.d.ts → index-mK1ICsVg.d.ts} +1 -1
- package/dist/{index-B3yTdknp.d.ts → index-vCRf5fyK.d.ts} +3 -2
- package/dist/index.d.ts +29 -29
- package/dist/index.js +77 -77
- package/dist/landing-C7nc9JHm.js +104 -0
- package/dist/quietFinished-CKZXgsPM.js +19 -0
- package/dist/sharedMutationObserver-Dvh3N1N2.js +41 -0
- package/dist/{timeFormat-CqrwFE42.js → timeFormat-Cnd5vu5t.js} +1 -1
- package/dist/{timeParser-D9tCF_b3.js → timeParser-nVL5sIwT.js} +34 -5
- package/dist/{types-BG23kC3S.d.ts → types-C2ZuV4jf.d.ts} +7 -1
- package/dist/{useActionGroupTracking-DGeOIv3K.js → useActionGroupTracking-fwmxDcU3.js} +1 -1
- package/dist/{useFocusTrap-BUd-fvUH.js → useFocusTrap-DsYtRdmV.js} +2 -81
- package/dist/{useInputStatusIcon-ne9V7ZQC.js → useInputStatusIcon-CVGsNTi_.js} +1 -1
- package/dist/{useMenuDrillIn-BaNYxWiS.js → useMenuDrillIn-DaH0nhPa.js} +1 -1
- package/dist/{useTimeValue-CcKrnO8z.js → useTimeValue-8YfPQffv.js} +2 -2
- package/dist/{useTouchHitArea-BI-CtI7e.js → useTouchHitArea-BKZL6tHX.js} +48 -5
- package/dist/{useTruncation-C4pdlaXa.js → useTruncation-BxYAhQtF.js} +1 -40
- package/dist/{useTruncationTooltip-DwUQN7fD.js → useTruncationTooltip-DeCGRmot.js} +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
- package/styles/mobile-nav.css +4 -2
- package/styles/nav-item.css +3 -3
- package/styles/side-nav.css +36 -8
- package/styles/touch-hit-area.css +28 -0
- package/styles/tree-list.css +9 -4
- package/dist/context-ZsDEkhSF.js +0 -24
- package/dist/{index-BqhgeAT4.d.ts → index-BJ9Wim6J.d.ts} +1 -1
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
import { t as quietFinished } from "./quietFinished-CKZXgsPM.js";
|
|
2
|
+
import { r as readArea, t as areaOf } from "./handle-ChN2TMKH.js";
|
|
3
|
+
import { D as glides, _ as safeAnimate, d as layoutMotion, h as beginChange, m as sampleOver, p as sampleKeyframes, r as changeStartIn } from "./batch-BJD6Bt-O.js";
|
|
4
|
+
import { computed, inject, ref } from "vue";
|
|
5
|
+
//#region src/motion/inertClone.ts
|
|
6
|
+
/**
|
|
7
|
+
* @file inertClone.ts
|
|
8
|
+
* @input The DOM
|
|
9
|
+
* @output Exports `inertClone`, a deep clone that takes no part in the page,
|
|
10
|
+
* and `paintedBackground`, the background an element shows
|
|
11
|
+
* @position Motion foundation, internal to core. transientCopy.ts builds the
|
|
12
|
+
* swap's and the layer exit's copies on the clone, and the List reorder
|
|
13
|
+
* builds its drag preview on it
|
|
14
|
+
*/
|
|
15
|
+
/** The listed controls a form can own. */
|
|
16
|
+
const FORM_CONTROLS = "button, fieldset, input, object, output, select, textarea";
|
|
17
|
+
function isFormAssociated(node, registry) {
|
|
18
|
+
if (!node.localName.includes("-")) return false;
|
|
19
|
+
return (registry?.get(node.localName))?.formAssociated === true;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Paints `canvas` with `source`'s pixels at its own size. False when they
|
|
23
|
+
* read back empty: unreadable (a WebGL canvas without
|
|
24
|
+
* `preserveDrawingBuffer`, a tainted one) or blank.
|
|
25
|
+
*/
|
|
26
|
+
function paintCanvas(canvas, source) {
|
|
27
|
+
if (canvas.width === 0 || canvas.height === 0) return true;
|
|
28
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
29
|
+
if (context == null) return true;
|
|
30
|
+
try {
|
|
31
|
+
context.drawImage(source, 0, 0);
|
|
32
|
+
const { data } = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
33
|
+
for (let index = 3; index < data.length; index += 4) if (data[index] !== 0) return true;
|
|
34
|
+
return false;
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A deep clone of `element` that takes no part in the page. It has no ids or
|
|
41
|
+
* test ids and joins no form or radio group: a copied checked radio would
|
|
42
|
+
* uncheck the live one. No copied label names a live control, copied frames
|
|
43
|
+
* and media load nothing, and copied elements carry no anchor name. It is
|
|
44
|
+
* inert and hidden from assistive technology. Content holding a canvas whose
|
|
45
|
+
* pixels read back empty is not cloned: the result is null.
|
|
46
|
+
*/
|
|
47
|
+
function inertClone(element) {
|
|
48
|
+
const copy = element.cloneNode(true);
|
|
49
|
+
const sourceNodes = [element, ...element.querySelectorAll("*")];
|
|
50
|
+
const copyNodes = [copy, ...copy.querySelectorAll("*")];
|
|
51
|
+
for (const node of copyNodes) for (const name of [
|
|
52
|
+
"id",
|
|
53
|
+
"data-testid",
|
|
54
|
+
"name",
|
|
55
|
+
"for",
|
|
56
|
+
"autofocus"
|
|
57
|
+
]) node.removeAttribute(name);
|
|
58
|
+
const view = element.ownerDocument.defaultView;
|
|
59
|
+
sourceNodes.forEach((source, index) => {
|
|
60
|
+
const name = view?.getComputedStyle(source).getPropertyValue("anchor-name");
|
|
61
|
+
if (name != null && name !== "" && name !== "none") copyNodes[index].style?.setProperty("anchor-name", "none");
|
|
62
|
+
});
|
|
63
|
+
const registry = element.ownerDocument.defaultView?.customElements;
|
|
64
|
+
for (const node of copyNodes) if (node.matches(FORM_CONTROLS) || isFormAssociated(node, registry)) node.setAttribute("form", "");
|
|
65
|
+
for (const node of copy.querySelectorAll("iframe, video, audio, source, embed, object")) for (const name of [
|
|
66
|
+
"src",
|
|
67
|
+
"srcdoc",
|
|
68
|
+
"data",
|
|
69
|
+
"autoplay"
|
|
70
|
+
]) node.removeAttribute(name);
|
|
71
|
+
const sources = element.querySelectorAll("canvas");
|
|
72
|
+
if (!Array.from(copy.querySelectorAll("canvas")).every((canvas, index) => paintCanvas(canvas, sources[index]))) return null;
|
|
73
|
+
copy.setAttribute("aria-hidden", "true");
|
|
74
|
+
copy.setAttribute("inert", "");
|
|
75
|
+
copy.style.pointerEvents = "none";
|
|
76
|
+
return copy;
|
|
77
|
+
}
|
|
78
|
+
/** The background `element` shows: its own, or the nearest ancestor's. */
|
|
79
|
+
function paintedBackground(element) {
|
|
80
|
+
for (let node = element; node; node = node.parentElement) {
|
|
81
|
+
const color = getComputedStyle(node).backgroundColor;
|
|
82
|
+
if (color !== "transparent" && !/^rgba\(.*,\s*0\)$/.test(color)) return color;
|
|
83
|
+
}
|
|
84
|
+
return "Canvas";
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/motion/carryAnimations.ts
|
|
88
|
+
/**
|
|
89
|
+
* @file carryAnimations.ts
|
|
90
|
+
* @input The CSS animations and transitions of an element and its subtree,
|
|
91
|
+
* read before the browser starts them afresh
|
|
92
|
+
* @output Exports `saveAnimations` and `carryAnimations`, which carry them on
|
|
93
|
+
* in a clone of the element. Also `saveAnimation` and `restoreAnimations`,
|
|
94
|
+
* which put them back after a display reset
|
|
95
|
+
* @position Motion foundation; the transient copy (transientCopy.ts) and the
|
|
96
|
+
* layer runtime's re-placement (Layer/preserveAnimations.ts) use it
|
|
97
|
+
*/
|
|
98
|
+
/**
|
|
99
|
+
* Animation members written in a fixed order rather than generically: the
|
|
100
|
+
* timeline before the range that is measured on it, the rate before the
|
|
101
|
+
* time, and the start time (or, for a paused animation, the current time)
|
|
102
|
+
* last, once the play state is set. `effect` is not
|
|
103
|
+
* replaced, because a CSS animation whose effect script replaces leaves the
|
|
104
|
+
* stylesheet's control; its state is copied onto the new effect instead.
|
|
105
|
+
*/
|
|
106
|
+
const ORDERED = /* @__PURE__ */ new Set([
|
|
107
|
+
"effect",
|
|
108
|
+
"timeline",
|
|
109
|
+
"rangeStart",
|
|
110
|
+
"rangeEnd",
|
|
111
|
+
"playbackRate",
|
|
112
|
+
"startTime",
|
|
113
|
+
"currentTime"
|
|
114
|
+
]);
|
|
115
|
+
/** Every accessor with a setter on `object`'s prototype chain. */
|
|
116
|
+
function writableAccessors(object) {
|
|
117
|
+
const names = /* @__PURE__ */ new Set();
|
|
118
|
+
for (let proto = Object.getPrototypeOf(object); proto != null && proto !== Object.prototype; proto = Object.getPrototypeOf(proto)) for (const [name, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(proto))) if (descriptor.set != null) names.add(name);
|
|
119
|
+
return [...names];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* A textual form of a value that is compared by content rather than by
|
|
123
|
+
* identity: a CSS numeric value (as in a timeline range offset) through its
|
|
124
|
+
* serialization, a plain object (a range) through its members. Anything else
|
|
125
|
+
* is compared by identity (`null`).
|
|
126
|
+
*/
|
|
127
|
+
function contentOf(value) {
|
|
128
|
+
if (typeof CSSNumericValue !== "undefined" && value instanceof CSSNumericValue) return value.toString();
|
|
129
|
+
if (value != null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) return Object.entries(value).map(([key, inner]) => `${key}:${contentOf(inner) ?? String(inner)}`).join(";");
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
function differs(a, b) {
|
|
133
|
+
if (a === b) return false;
|
|
134
|
+
const textA = contentOf(a);
|
|
135
|
+
return textA == null || textA !== contentOf(b);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Reads one animation's state generically, from what the platform exposes.
|
|
139
|
+
* That is every accessor with a setter on the animation's and its effect's
|
|
140
|
+
* prototype chains, every field of the effect's timing, and its keyframes. Only values
|
|
141
|
+
* that differ from the recreated animation's are written back, so a value the
|
|
142
|
+
* stylesheet controls stays under its control. A few members are not plain
|
|
143
|
+
* state and are written in their own step (`ORDERED`). The Animation and
|
|
144
|
+
* effect objects themselves cannot be carried over: the old ones keep their
|
|
145
|
+
* listeners and promises.
|
|
146
|
+
*/
|
|
147
|
+
function saveAnimation(animation) {
|
|
148
|
+
const effect = animation.effect;
|
|
149
|
+
const values = {};
|
|
150
|
+
for (const name of writableAccessors(animation)) values[name] = animation[name];
|
|
151
|
+
const effectValues = {};
|
|
152
|
+
if (effect != null) for (const name of writableAccessors(effect)) effectValues[name] = effect[name];
|
|
153
|
+
return {
|
|
154
|
+
animation,
|
|
155
|
+
name: animation.animationName ?? "",
|
|
156
|
+
target: effect?.target ?? null,
|
|
157
|
+
pseudoElement: effect?.pseudoElement ?? null,
|
|
158
|
+
values,
|
|
159
|
+
effectValues,
|
|
160
|
+
timing: effect?.getTiming() ?? null,
|
|
161
|
+
keyframes: effect?.getKeyframes() ?? null,
|
|
162
|
+
playState: animation.playState,
|
|
163
|
+
replaceState: animation.replaceState
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function write(object, name, value) {
|
|
167
|
+
object[name] = value;
|
|
168
|
+
}
|
|
169
|
+
/** Give `next` the effect state `saved` had: every writable member. */
|
|
170
|
+
function restoreEffect(next, saved) {
|
|
171
|
+
for (const name of writableAccessors(next)) if (name in saved.effectValues && differs(saved.effectValues[name], next[name])) write(next, name, saved.effectValues[name]);
|
|
172
|
+
if (saved.timing != null) {
|
|
173
|
+
const timing = next.getTiming();
|
|
174
|
+
const changed = {};
|
|
175
|
+
for (const [field, value] of Object.entries(saved.timing)) if (differs(value, timing[field])) changed[field] = value;
|
|
176
|
+
if (Object.keys(changed).length > 0) next.updateTiming(changed);
|
|
177
|
+
}
|
|
178
|
+
if (saved.keyframes != null && JSON.stringify(saved.keyframes) !== JSON.stringify(next.getKeyframes())) next.setKeyframes(saved.keyframes);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Gives `next` the start time `original` runs on, now or, while its play is
|
|
182
|
+
* still pending, once that play starts. A pending play has no start time
|
|
183
|
+
* yet: it resolves on the frame that first draws the animation.
|
|
184
|
+
*/
|
|
185
|
+
function followStart(next, original) {
|
|
186
|
+
const take = () => {
|
|
187
|
+
if (original.startTime != null && next.playState !== "idle") next.startTime = original.startTime;
|
|
188
|
+
};
|
|
189
|
+
if (original.startTime != null) {
|
|
190
|
+
take();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
original.ready.then(take, () => void 0);
|
|
194
|
+
}
|
|
195
|
+
/** Give `next` the state `saved` had, member by member. */
|
|
196
|
+
function restore(next, saved) {
|
|
197
|
+
const effect = next.effect;
|
|
198
|
+
if (effect != null) restoreEffect(effect, saved);
|
|
199
|
+
const current = next;
|
|
200
|
+
for (const name of [
|
|
201
|
+
"timeline",
|
|
202
|
+
"rangeStart",
|
|
203
|
+
"rangeEnd"
|
|
204
|
+
]) if (name in saved.values && differs(saved.values[name], current[name])) write(next, name, saved.values[name]);
|
|
205
|
+
for (const name of writableAccessors(next)) if (!ORDERED.has(name) && name in saved.values && differs(saved.values[name], current[name])) write(next, name, saved.values[name]);
|
|
206
|
+
if (saved.replaceState === "persisted" && next.replaceState !== "persisted") next.persist();
|
|
207
|
+
const rate = saved.values.playbackRate;
|
|
208
|
+
if (typeof rate === "number" && rate !== next.playbackRate) next.playbackRate = rate;
|
|
209
|
+
if (saved.playState === "paused" && next.playState !== "paused") next.pause();
|
|
210
|
+
else if (saved.playState !== "paused" && next.playState === "paused") {
|
|
211
|
+
next.play();
|
|
212
|
+
quietFinished(next);
|
|
213
|
+
}
|
|
214
|
+
const start = saved.values.startTime;
|
|
215
|
+
const time = saved.values.currentTime;
|
|
216
|
+
if (saved.playState === "finished") next.finish();
|
|
217
|
+
else if (start != null) next.startTime = start;
|
|
218
|
+
else if (time != null) {
|
|
219
|
+
next.currentTime = time;
|
|
220
|
+
if (saved.playState === "running") followStart(next, saved.animation);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/** Resume a cancelled CSS transition with a script animation in its state. */
|
|
224
|
+
function resumeTransition(saved) {
|
|
225
|
+
if (saved.target == null || saved.keyframes == null) return;
|
|
226
|
+
restore(quietFinished(saved.target.animate(saved.keyframes, { pseudoElement: saved.pseudoElement ?? void 0 })), saved);
|
|
227
|
+
}
|
|
228
|
+
function isTransition(animation) {
|
|
229
|
+
return typeof CSSTransition !== "undefined" && animation instanceof CSSTransition;
|
|
230
|
+
}
|
|
231
|
+
function isCssAnimation(animation) {
|
|
232
|
+
return typeof CSSAnimation !== "undefined" && animation instanceof CSSAnimation;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Finishes an animation that ends: an infinite one cannot be finished, and is
|
|
236
|
+
* left as it runs.
|
|
237
|
+
*/
|
|
238
|
+
function finishIfItEnds(animation) {
|
|
239
|
+
const end = animation.effect?.getComputedTiming().endTime;
|
|
240
|
+
if (end != null && Number.isFinite(Number(end)) && animation.playbackRate !== 0) animation.finish();
|
|
241
|
+
}
|
|
242
|
+
/** The members a copy's animation does not take: its element's keep them. */
|
|
243
|
+
const IDENTITY_MEMBERS = /* @__PURE__ */ new Set([
|
|
244
|
+
"id",
|
|
245
|
+
"onfinish",
|
|
246
|
+
"oncancel",
|
|
247
|
+
"onremove"
|
|
248
|
+
]);
|
|
249
|
+
/**
|
|
250
|
+
* `saved` for an animation that carries on on the copy of its element:
|
|
251
|
+
* aimed at the copy, without the element's id and event handlers.
|
|
252
|
+
*/
|
|
253
|
+
function retarget(saved, copyOf) {
|
|
254
|
+
const target = saved.target == null ? null : copyOf(saved.target);
|
|
255
|
+
if (target == null) return null;
|
|
256
|
+
const values = Object.fromEntries(Object.entries(saved.values).filter(([name]) => !IDENTITY_MEMBERS.has(name)));
|
|
257
|
+
const effectValues = { ...saved.effectValues };
|
|
258
|
+
if ("target" in effectValues) effectValues.target = target;
|
|
259
|
+
return {
|
|
260
|
+
...saved,
|
|
261
|
+
target,
|
|
262
|
+
values,
|
|
263
|
+
effectValues
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Puts each state `saved` holds on the CSS animations and transitions of
|
|
268
|
+
* `root` and its subtree that are not among `survivors`. Each CSS animation
|
|
269
|
+
* the browser started afresh takes the state of the one it replaces. It is
|
|
270
|
+
* matched by element, pseudo-element and name, in order, and then by name
|
|
271
|
+
* alone (an effect script moved to another element or pseudo-element). Each
|
|
272
|
+
* transition whose animation no longer runs resumes as a script animation in
|
|
273
|
+
* its state. One started afresh that replaces none is finished: an entrance
|
|
274
|
+
* that had played and been dropped, or a transition from `@starting-style`.
|
|
275
|
+
* Script animations are left as they are.
|
|
276
|
+
*/
|
|
277
|
+
function restoreAnimations(root, saved, survivors) {
|
|
278
|
+
const after = root.getAnimations({ subtree: true });
|
|
279
|
+
const current = new Set(after);
|
|
280
|
+
const cancelled = [];
|
|
281
|
+
for (const state of saved) {
|
|
282
|
+
if (current.has(state.animation)) continue;
|
|
283
|
+
if (isTransition(state.animation)) resumeTransition(state);
|
|
284
|
+
else cancelled.push(state);
|
|
285
|
+
}
|
|
286
|
+
const recreated = after.filter((animation) => (isCssAnimation(animation) || isTransition(animation)) && !survivors.has(animation));
|
|
287
|
+
const unmatched = [];
|
|
288
|
+
for (const animation of recreated) {
|
|
289
|
+
const effect = animation.effect;
|
|
290
|
+
const name = animation.animationName ?? "";
|
|
291
|
+
const index = cancelled.findIndex((state) => state.name === name && state.target === (effect?.target ?? null) && state.pseudoElement === (effect?.pseudoElement ?? null));
|
|
292
|
+
if (index === -1) unmatched.push(animation);
|
|
293
|
+
else restore(animation, cancelled.splice(index, 1)[0]);
|
|
294
|
+
}
|
|
295
|
+
for (const animation of unmatched) {
|
|
296
|
+
const name = animation.animationName ?? "";
|
|
297
|
+
const index = cancelled.findIndex((state) => state.name === name);
|
|
298
|
+
if (index === -1) finishIfItEnds(animation);
|
|
299
|
+
else restore(animation, cancelled.splice(index, 1)[0]);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Reads the state of every CSS animation and transition of `root` and its
|
|
304
|
+
* subtree, for `carryAnimations` to give a copy of it.
|
|
305
|
+
*/
|
|
306
|
+
function saveAnimations(root) {
|
|
307
|
+
if (typeof root.getAnimations !== "function") return [];
|
|
308
|
+
return root.getAnimations({ subtree: true }).filter((animation) => isCssAnimation(animation) || isTransition(animation)).map(saveAnimation);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Carries on in `copy`, a clone of the root `saved` was read from, now laid
|
|
312
|
+
* out, the CSS animations and transitions its element ran. A clone starts
|
|
313
|
+
* each CSS animation again and runs no transition but a `@starting-style`
|
|
314
|
+
* one. So each CSS animation the clone started takes the state of its
|
|
315
|
+
* element's, and each transition runs on as a script animation. One the
|
|
316
|
+
* clone started that its element no longer ran is finished: an entrance that
|
|
317
|
+
* had played, or a `@starting-style` transition. `copyOf` maps each element
|
|
318
|
+
* of the cloned subtree to its copy. The element's own animations keep
|
|
319
|
+
* running, so the copy's take no id or event handler.
|
|
320
|
+
*/
|
|
321
|
+
function carryAnimations(saved, copy, copyOf) {
|
|
322
|
+
if (typeof copy.getAnimations !== "function") return;
|
|
323
|
+
restoreAnimations(copy, saved.flatMap((state) => retarget(state, copyOf) ?? []), /* @__PURE__ */ new Set());
|
|
324
|
+
}
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/motion/transientCopy.ts
|
|
327
|
+
/** Above this many elements, old content is not copied: the new one enters. */
|
|
328
|
+
const MAX_COPIED_ELEMENTS = 1500;
|
|
329
|
+
/** Whether `element` is small enough to copy. */
|
|
330
|
+
function isCopyable(element) {
|
|
331
|
+
return element.getElementsByTagName("*").length <= MAX_COPIED_ELEMENTS;
|
|
332
|
+
}
|
|
333
|
+
/** Inherited properties a copy carries when laid outside its ancestors. */
|
|
334
|
+
const INHERITED_PROPERTIES = [
|
|
335
|
+
"color",
|
|
336
|
+
"color-scheme",
|
|
337
|
+
"cursor",
|
|
338
|
+
"direction",
|
|
339
|
+
"font-family",
|
|
340
|
+
"font-feature-settings",
|
|
341
|
+
"font-size",
|
|
342
|
+
"font-stretch",
|
|
343
|
+
"font-style",
|
|
344
|
+
"font-variant",
|
|
345
|
+
"font-variation-settings",
|
|
346
|
+
"font-weight",
|
|
347
|
+
"hyphens",
|
|
348
|
+
"letter-spacing",
|
|
349
|
+
"line-height",
|
|
350
|
+
"list-style-type",
|
|
351
|
+
"overflow-wrap",
|
|
352
|
+
"tab-size",
|
|
353
|
+
"text-align",
|
|
354
|
+
"text-indent",
|
|
355
|
+
"text-shadow",
|
|
356
|
+
"text-transform",
|
|
357
|
+
"visibility",
|
|
358
|
+
"white-space",
|
|
359
|
+
"word-break",
|
|
360
|
+
"word-spacing",
|
|
361
|
+
"writing-mode"
|
|
362
|
+
];
|
|
363
|
+
/** Each copy's inherited values, read from its element when it was made. */
|
|
364
|
+
const inheritedValues = /* @__PURE__ */ new WeakMap();
|
|
365
|
+
/** A computed line-height over its font size, or null for `normal`. */
|
|
366
|
+
function lineHeightFactor(style) {
|
|
367
|
+
const lineHeight = Number.parseFloat(style.getPropertyValue("line-height"));
|
|
368
|
+
const fontSize = Number.parseFloat(style.getPropertyValue("font-size"));
|
|
369
|
+
return Number.isFinite(lineHeight) && fontSize > 0 ? Math.round(lineHeight / fontSize * 1e3) / 1e3 : null;
|
|
370
|
+
}
|
|
371
|
+
/** The element's inherited properties and custom properties, as computed. */
|
|
372
|
+
function readInherited(element) {
|
|
373
|
+
const values = /* @__PURE__ */ new Map();
|
|
374
|
+
const style = getComputedStyle(element);
|
|
375
|
+
for (const name of INHERITED_PROPERTIES) values.set(name, style.getPropertyValue(name));
|
|
376
|
+
if (typeof element.computedStyleMap === "function") {
|
|
377
|
+
const lineHeight = element.computedStyleMap().get("line-height");
|
|
378
|
+
if (lineHeight != null && "unit" in lineHeight && lineHeight.unit === "number" && "value" in lineHeight) values.set("line-height", String(lineHeight.value));
|
|
379
|
+
} else {
|
|
380
|
+
const factor = lineHeightFactor(style);
|
|
381
|
+
if (factor != null) values.set("line-height", String(factor));
|
|
382
|
+
}
|
|
383
|
+
for (let index = 0; index < style.length; index++) {
|
|
384
|
+
const name = style[index];
|
|
385
|
+
if (name.startsWith("--")) values.set(name, style.getPropertyValue(name));
|
|
386
|
+
}
|
|
387
|
+
return values;
|
|
388
|
+
}
|
|
389
|
+
/** Scroll offsets a copy restores once laid out (a clone carries none). */
|
|
390
|
+
const scrollOffsets = /* @__PURE__ */ new WeakMap();
|
|
391
|
+
/**
|
|
392
|
+
* The CSS animations and transitions a copy's element ran, and the copy of
|
|
393
|
+
* each element in the copied subtree. The copy carries them on once laid out
|
|
394
|
+
* (`placeOver`).
|
|
395
|
+
*/
|
|
396
|
+
const carriedMotion = /* @__PURE__ */ new WeakMap();
|
|
397
|
+
/**
|
|
398
|
+
* A copy that takes no part: no ids or test ids, no form or radio group (a
|
|
399
|
+
* copied checked radio would uncheck the live one), no label for a live
|
|
400
|
+
* control, and copied frames and media load nothing. Copied elements carry no
|
|
401
|
+
* anchor name. Scrolled descendants keep their offsets. The CSS animations
|
|
402
|
+
* and transitions running in it carry on from where they were, once the copy
|
|
403
|
+
* is laid out (`placeOver`).
|
|
404
|
+
*/
|
|
405
|
+
function inertCopy(element) {
|
|
406
|
+
const copy = inertClone(element);
|
|
407
|
+
if (copy == null) return null;
|
|
408
|
+
const sourceNodes = [element, ...element.querySelectorAll("*")];
|
|
409
|
+
const copyNodes = [copy, ...copy.querySelectorAll("*")];
|
|
410
|
+
const offsets = [];
|
|
411
|
+
sourceNodes.forEach((source, index) => {
|
|
412
|
+
if (source.scrollTop !== 0 || source.scrollLeft !== 0) offsets.push([
|
|
413
|
+
copyNodes[index],
|
|
414
|
+
source.scrollTop,
|
|
415
|
+
source.scrollLeft
|
|
416
|
+
]);
|
|
417
|
+
});
|
|
418
|
+
scrollOffsets.set(copy, offsets);
|
|
419
|
+
inheritedValues.set(copy, readInherited(element));
|
|
420
|
+
carriedMotion.set(copy, {
|
|
421
|
+
saved: saveAnimations(element),
|
|
422
|
+
copyOf: new Map(sourceNodes.map((node, index) => [node, copyNodes[index]]))
|
|
423
|
+
});
|
|
424
|
+
return copy;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Puts a copy's scrolled descendants, and the copy, at the offsets its element
|
|
428
|
+
* had when `inertCopy` made it. It scrolls at once, whatever their
|
|
429
|
+
* `scroll-behavior`. A box keeps no scroll position until it is laid out.
|
|
430
|
+
*/
|
|
431
|
+
function restoreScrollOffsets(copy) {
|
|
432
|
+
for (const [node, top, left] of scrollOffsets.get(copy) ?? []) if (typeof node.scrollTo === "function") node.scrollTo({
|
|
433
|
+
top,
|
|
434
|
+
left,
|
|
435
|
+
behavior: "instant"
|
|
436
|
+
});
|
|
437
|
+
else {
|
|
438
|
+
node.scrollTop = top;
|
|
439
|
+
node.scrollLeft = left;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Writes on a copy what it inherited where its element was, where its new
|
|
444
|
+
* parent `host` passes something else.
|
|
445
|
+
*/
|
|
446
|
+
function keepInherited(copy, host) {
|
|
447
|
+
const hostStyle = getComputedStyle(host);
|
|
448
|
+
for (const [name, value] of inheritedValues.get(copy) ?? []) if (value !== "" && (name === "line-height" || hostStyle.getPropertyValue(name) !== value)) copy.style.setProperty(name, value);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Lay `element` over `rect` (viewport coordinates), absolutely, as a child of
|
|
452
|
+
* `host` (before `beforeNode`, else last), wherever its containing block is:
|
|
453
|
+
* no ancestor's position changes. A copy's scrolled descendants then restore their offsets, and the
|
|
454
|
+
* CSS animations and transitions its element ran carry on in it.
|
|
455
|
+
*/
|
|
456
|
+
function placeOver(element, host, rect, beforeNode = null) {
|
|
457
|
+
Object.assign(element.style, {
|
|
458
|
+
position: "absolute",
|
|
459
|
+
boxSizing: "border-box",
|
|
460
|
+
margin: "0px",
|
|
461
|
+
left: "0px",
|
|
462
|
+
top: "0px",
|
|
463
|
+
width: `${rect.width}px`,
|
|
464
|
+
height: `${rect.height}px`
|
|
465
|
+
});
|
|
466
|
+
host.insertBefore(element, beforeNode);
|
|
467
|
+
keepInherited(element, host);
|
|
468
|
+
const origin = element.getBoundingClientRect();
|
|
469
|
+
const layoutWidth = Math.abs(element.offsetWidth - rect.width) < 1 ? rect.width : element.offsetWidth;
|
|
470
|
+
const layoutHeight = Math.abs(element.offsetHeight - rect.height) < 1 ? rect.height : element.offsetHeight;
|
|
471
|
+
const scaleX = origin.width > 0 && layoutWidth > 0 ? origin.width / layoutWidth : 1;
|
|
472
|
+
const scaleY = origin.height > 0 && layoutHeight > 0 ? origin.height / layoutHeight : 1;
|
|
473
|
+
element.style.width = `${rect.width / scaleX}px`;
|
|
474
|
+
element.style.height = `${rect.height / scaleY}px`;
|
|
475
|
+
element.style.left = `${(rect.left - origin.left) / scaleX}px`;
|
|
476
|
+
element.style.top = `${(rect.top - origin.top) / scaleY}px`;
|
|
477
|
+
restoreScrollOffsets(element);
|
|
478
|
+
const carried = carriedMotion.get(element);
|
|
479
|
+
if (carried != null) {
|
|
480
|
+
carriedMotion.delete(element);
|
|
481
|
+
carryAnimations(carried.saved, element, (node) => carried.copyOf.get(node) ?? null);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* `element`'s visible part as a copy: its content scrolled as it was, in a
|
|
486
|
+
* holder the size of the visible part (a scroll container), and where that
|
|
487
|
+
* part showed, in viewport coordinates.
|
|
488
|
+
*/
|
|
489
|
+
function visiblePartCopy(element) {
|
|
490
|
+
const content = inertCopy(element);
|
|
491
|
+
if (content == null) return null;
|
|
492
|
+
content.removeAttribute("role");
|
|
493
|
+
content.removeAttribute("tabindex");
|
|
494
|
+
Object.assign(content.style, {
|
|
495
|
+
position: "absolute",
|
|
496
|
+
top: `${-element.scrollTop}px`,
|
|
497
|
+
left: `${-element.scrollLeft}px`,
|
|
498
|
+
boxSizing: "border-box",
|
|
499
|
+
width: `${element.clientWidth}px`,
|
|
500
|
+
height: "auto",
|
|
501
|
+
padding: getComputedStyle(element).padding,
|
|
502
|
+
borderWidth: "0px",
|
|
503
|
+
margin: "0px",
|
|
504
|
+
overflow: "visible",
|
|
505
|
+
translate: "none"
|
|
506
|
+
});
|
|
507
|
+
const holder = element.ownerDocument.createElement("div");
|
|
508
|
+
holder.setAttribute("aria-hidden", "true");
|
|
509
|
+
holder.setAttribute("inert", "");
|
|
510
|
+
Object.assign(holder.style, {
|
|
511
|
+
overflow: "hidden",
|
|
512
|
+
pointerEvents: "none"
|
|
513
|
+
});
|
|
514
|
+
holder.appendChild(content);
|
|
515
|
+
scrollOffsets.set(holder, (scrollOffsets.get(content) ?? []).filter(([node]) => node !== content));
|
|
516
|
+
const values = inheritedValues.get(content);
|
|
517
|
+
if (values != null) inheritedValues.set(holder, values);
|
|
518
|
+
const carried = carriedMotion.get(content);
|
|
519
|
+
if (carried != null) {
|
|
520
|
+
carriedMotion.set(holder, carried);
|
|
521
|
+
carriedMotion.delete(content);
|
|
522
|
+
}
|
|
523
|
+
const box = element.getBoundingClientRect();
|
|
524
|
+
return {
|
|
525
|
+
copy: holder,
|
|
526
|
+
rect: DOMRect.fromRect({
|
|
527
|
+
x: box.left + element.clientLeft,
|
|
528
|
+
y: box.top + element.clientTop,
|
|
529
|
+
width: element.clientWidth,
|
|
530
|
+
height: element.clientHeight
|
|
531
|
+
})
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
const SVG = "http://www.w3.org/2000/svg";
|
|
535
|
+
/**
|
|
536
|
+
* The elements that let a copy's text fade: each run of HTML text wrapped in
|
|
537
|
+
* its own span, and each SVG `text` element as it is (a span does not render
|
|
538
|
+
* inside SVG).
|
|
539
|
+
*/
|
|
540
|
+
function wrapText(copy) {
|
|
541
|
+
const walker = copy.ownerDocument.createTreeWalker(copy, 4);
|
|
542
|
+
const texts = [];
|
|
543
|
+
while (walker.nextNode()) if (walker.currentNode.textContent?.trim()) texts.push(walker.currentNode);
|
|
544
|
+
const faded = /* @__PURE__ */ new Set();
|
|
545
|
+
for (const text of texts) {
|
|
546
|
+
const parent = text.parentElement;
|
|
547
|
+
if (parent?.closest("style, script, textarea, title, noscript") != null) continue;
|
|
548
|
+
if (parent?.namespaceURI === SVG) {
|
|
549
|
+
const svgText = parent.closest("text");
|
|
550
|
+
if (svgText != null) faded.add(svgText);
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
553
|
+
const span = copy.ownerDocument.createElement("span");
|
|
554
|
+
text.replaceWith(span);
|
|
555
|
+
span.appendChild(text);
|
|
556
|
+
faded.add(span);
|
|
557
|
+
}
|
|
558
|
+
return [...faded];
|
|
559
|
+
}
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region src/motion/layout/swap.ts
|
|
562
|
+
const NO_RIDE = {
|
|
563
|
+
x: 0,
|
|
564
|
+
y: 0
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* Before a change commits: hold `element`'s old content as one transient copy
|
|
568
|
+
* (`spec:AST-105` FR8). With `isVisiblePart`, the copy is the element's
|
|
569
|
+
* visible part, its content scrolled as it was (a scroll container). Returns
|
|
570
|
+
* null without a handle, outside its area, under an immediate change, or for
|
|
571
|
+
* content too large to copy.
|
|
572
|
+
*/
|
|
573
|
+
function holdLayoutSwap(handle, element, { isVisiblePart = false } = {}) {
|
|
574
|
+
if (handle == null || typeof element.animate !== "function") return null;
|
|
575
|
+
const area = areaOf(handle, element);
|
|
576
|
+
if (area == null || layoutMotion(area).kind === "instant" || !isCopyable(element)) return null;
|
|
577
|
+
beginChange(element.ownerDocument);
|
|
578
|
+
const box = element.getBoundingClientRect();
|
|
579
|
+
if (!isVisiblePart) {
|
|
580
|
+
const copy = inertCopy(element);
|
|
581
|
+
return copy == null ? null : {
|
|
582
|
+
area,
|
|
583
|
+
copy,
|
|
584
|
+
rect: box
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
const part = visiblePartCopy(element);
|
|
588
|
+
return part == null ? null : {
|
|
589
|
+
area,
|
|
590
|
+
...part
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* After the change commits, before paint: the copy leaves while the incoming
|
|
595
|
+
* elements enter, on FR4's one motion, every part started on the same
|
|
596
|
+
* timeline time. Under Reduce Motion with a coarse pointer, only opacity
|
|
597
|
+
* changes (`design:reduced-motion` DR2). Returns what ends the swap at once;
|
|
598
|
+
* it also ends when its motion does, and the copy is removed.
|
|
599
|
+
*/
|
|
600
|
+
function playLayoutSwap(swap, how) {
|
|
601
|
+
const motion = layoutMotion(swap.area);
|
|
602
|
+
if (motion.kind === "instant") return () => {};
|
|
603
|
+
const { copy } = swap;
|
|
604
|
+
const change = changeStartIn(swap.area, copy.ownerDocument);
|
|
605
|
+
placeOver(copy, how.host, swap.rect, how.copyBefore ?? null);
|
|
606
|
+
if (how.isOpaque === true) {
|
|
607
|
+
if (how.copyBefore == null) copy.style.zIndex = "1";
|
|
608
|
+
copy.style.backgroundColor = paintedBackground(copy);
|
|
609
|
+
}
|
|
610
|
+
const animations = [];
|
|
611
|
+
let isDone = false;
|
|
612
|
+
const end = () => {
|
|
613
|
+
if (isDone) return;
|
|
614
|
+
isDone = true;
|
|
615
|
+
animations.forEach((animation) => animation.cancel());
|
|
616
|
+
copy.remove();
|
|
617
|
+
how.onEnd?.();
|
|
618
|
+
};
|
|
619
|
+
const { copyText, rideWith } = how;
|
|
620
|
+
const fadedText = copyText != null && motion.kind === "glide" ? wrapText(copy) : [];
|
|
621
|
+
const parts = [];
|
|
622
|
+
if (motion.kind === "glide") {
|
|
623
|
+
const moves = rideWith != null && rideWith.isCopyMoved !== false;
|
|
624
|
+
parts.push([copy, (p, ride) => ({
|
|
625
|
+
...how.copy(p, ride),
|
|
626
|
+
...moves ? { translate: `${ride.x}px ${ride.y}px` } : null
|
|
627
|
+
})]);
|
|
628
|
+
for (const span of fadedText) parts.push([span, (p) => ({ opacity: copyText?.(p) ?? 1 })]);
|
|
629
|
+
for (const { element, frames } of how.incoming) parts.push([element, frames]);
|
|
630
|
+
} else {
|
|
631
|
+
parts.push([copy, (p) => ({ opacity: 1 - p })]);
|
|
632
|
+
for (const { element } of how.incoming) parts.push([element, (p) => ({ opacity: p })]);
|
|
633
|
+
}
|
|
634
|
+
const playAll = (durationMs, progressAt, rideAt, options, sample) => {
|
|
635
|
+
for (const [element, shape] of parts) {
|
|
636
|
+
const animation = safeAnimate(element, sample((t) => shape(progressAt(t), rideAt(t))), {
|
|
637
|
+
duration: durationMs,
|
|
638
|
+
fill: "both",
|
|
639
|
+
...options
|
|
640
|
+
}, change);
|
|
641
|
+
if (animation != null) animations.push(animation);
|
|
642
|
+
}
|
|
643
|
+
if (animations.length === 0) end();
|
|
644
|
+
else animations[0].addEventListener?.("finish", end);
|
|
645
|
+
};
|
|
646
|
+
if (motion.kind === "fade") {
|
|
647
|
+
playAll(motion.durationMs, (t) => t <= 0 ? 0 : 1, () => NO_RIDE, { easing: motion.easing }, (shape) => [shape(0), shape(motion.durationMs)]);
|
|
648
|
+
return end;
|
|
649
|
+
}
|
|
650
|
+
const { progress } = motion;
|
|
651
|
+
const progressAt = (t) => 1 - progress.remaining(t);
|
|
652
|
+
if (rideWith == null) {
|
|
653
|
+
playAll(progress.durationMs, progressAt, () => NO_RIDE, { easing: "linear" }, (shape) => sampleOver(progress.durationMs, shape));
|
|
654
|
+
return end;
|
|
655
|
+
}
|
|
656
|
+
queueMicrotask(() => {
|
|
657
|
+
if (isDone) return;
|
|
658
|
+
const glide = glides.get(rideWith.element);
|
|
659
|
+
const durationMs = glide?.durationMs ?? progress.durationMs;
|
|
660
|
+
const rideAt = (t) => {
|
|
661
|
+
if (glide == null) return {
|
|
662
|
+
x: -rideWith.travel.x,
|
|
663
|
+
y: -rideWith.travel.y
|
|
664
|
+
};
|
|
665
|
+
const now = glide.offsetAt(t);
|
|
666
|
+
const start = glide.shownBefore;
|
|
667
|
+
return {
|
|
668
|
+
x: now.x - start.x,
|
|
669
|
+
y: now.y - start.y
|
|
670
|
+
};
|
|
671
|
+
};
|
|
672
|
+
playAll(durationMs, progressAt, rideAt, { easing: "linear" }, (shape) => sampleOver(durationMs, shape));
|
|
673
|
+
});
|
|
674
|
+
return end;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* After a change commits, before paint: elements the page already renders
|
|
678
|
+
* play frames over the change's progress on FR4's one motion, with no copy,
|
|
679
|
+
* such as a surface reaching over a gap a glide opens. Under Reduce Motion
|
|
680
|
+
* with a coarse pointer, only opacity changes; under an immediate change,
|
|
681
|
+
* nothing plays. Returns what ends them at once.
|
|
682
|
+
*/
|
|
683
|
+
function playLayoutFrames(handle, parts) {
|
|
684
|
+
const area = handle == null ? null : readArea(handle);
|
|
685
|
+
const motion = area == null ? null : layoutMotion(area);
|
|
686
|
+
if (area == null || motion == null || motion.kind === "instant") return () => {};
|
|
687
|
+
const change = changeStartIn(area, area.ownerDocument);
|
|
688
|
+
const animations = [];
|
|
689
|
+
for (const { element, frames: shape } of parts) {
|
|
690
|
+
const animation = motion.kind === "glide" ? safeAnimate(element, sampleKeyframes(motion.progress, (remaining) => shape(1 - remaining, NO_RIDE)), {
|
|
691
|
+
duration: motion.progress.durationMs,
|
|
692
|
+
easing: "linear",
|
|
693
|
+
fill: "both"
|
|
694
|
+
}, change) : safeAnimate(element, [{ opacity: 0 }, { opacity: 1 }], {
|
|
695
|
+
duration: motion.durationMs,
|
|
696
|
+
easing: motion.easing
|
|
697
|
+
}, change);
|
|
698
|
+
if (animation != null) animations.push(animation);
|
|
699
|
+
}
|
|
700
|
+
const end = () => animations.forEach((animation) => animation.cancel());
|
|
701
|
+
animations[0]?.addEventListener?.("finish", end);
|
|
702
|
+
return end;
|
|
703
|
+
}
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/SideNav/context.ts
|
|
706
|
+
const sideNavRenderModeKey = Symbol("astryx-side-nav-render-mode");
|
|
707
|
+
const defaultRenderMode = computed(() => "default");
|
|
708
|
+
function useSideNavRenderMode() {
|
|
709
|
+
return inject(sideNavRenderModeKey, defaultRenderMode);
|
|
710
|
+
}
|
|
711
|
+
const sideNavCollapseKey = Symbol("astryx-side-nav-collapse");
|
|
712
|
+
const fallbackCollapse = {
|
|
713
|
+
isCollapsed: ref(false),
|
|
714
|
+
isCollapsible: ref(false),
|
|
715
|
+
navId: "",
|
|
716
|
+
toggle: () => {}
|
|
717
|
+
};
|
|
718
|
+
function useSideNavCollapse() {
|
|
719
|
+
return inject(sideNavCollapseKey, fallbackCollapse);
|
|
720
|
+
}
|
|
721
|
+
/** Internal nesting depth; zero for top-level rows and the first rail flyout level. */
|
|
722
|
+
const sideNavDepthKey = Symbol("astryx-side-nav-depth");
|
|
723
|
+
function useSideNavDepth() {
|
|
724
|
+
return inject(sideNavDepthKey, ref(0));
|
|
725
|
+
}
|
|
726
|
+
/** AppShell 借给里面的 SideNav:让内容区跟着侧栏的收展一起动。 */
|
|
727
|
+
const sideNavShellKey = Symbol("astryx-side-nav-shell");
|
|
728
|
+
//#endregion
|
|
729
|
+
export { useSideNavCollapse as a, holdLayoutSwap as c, sideNavShellKey as i, playLayoutFrames as l, sideNavDepthKey as n, useSideNavDepth as o, sideNavRenderModeKey as r, useSideNavRenderMode as s, sideNavCollapseKey as t, playLayoutSwap as u };
|