@astryx-vue/core 0.19.1 → 0.20.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.
Files changed (151) hide show
  1. package/dist/AlertDialog/index.js +1 -1
  2. package/dist/{AlertDialog-CNb0dkY9.js → AlertDialog-Dbg8L2oy.js} +1 -1
  3. package/dist/AppShell/index.js +1 -1
  4. package/dist/{AppShell-NvIT99xw.js → AppShell-zEXmJb1h.js} +116 -9
  5. package/dist/AvatarGroup/index.d.ts +1 -1
  6. package/dist/Banner/index.d.ts +1 -1
  7. package/dist/BottomSheet/index.d.ts +1 -1
  8. package/dist/BottomSheet/index.js +2 -2
  9. package/dist/{BottomSheet-CCW58Kl3.js → BottomSheet-DNuzJPfQ.js} +2 -2
  10. package/dist/{BottomSheet-HQpcSkPH.js → BottomSheet-DV7bboru.js} +1 -1
  11. package/dist/Breadcrumbs/index.d.ts +1 -1
  12. package/dist/Breadcrumbs/index.js +1 -1
  13. package/dist/{Breadcrumbs-DXzBkpkd.js → Breadcrumbs-yB6yZCuZ.js} +1 -1
  14. package/dist/ButtonGroup/index.d.ts +1 -1
  15. package/dist/Calendar/index.d.ts +1 -1
  16. package/dist/Carousel/index.d.ts +1 -1
  17. package/dist/Chat/index.d.ts +1 -1
  18. package/dist/CheckboxInput/index.d.ts +1 -1
  19. package/dist/CheckboxList/index.d.ts +1 -1
  20. package/dist/ClickableCard/index.d.ts +1 -1
  21. package/dist/Collapsible/index.js +1 -1
  22. package/dist/{Collapsible-ExzU7vC0.js → Collapsible-BG-u5nEt.js} +2 -1
  23. package/dist/CommandPalette/index.js +1 -1
  24. package/dist/{CommandPalette-CECjNvGB.js → CommandPalette-CV7t0ouM.js} +1 -1
  25. package/dist/ComplexSelector/index.js +1 -1
  26. package/dist/{ComplexSelector-Dmaag1wm.js → ComplexSelector-BOACo2vq.js} +1 -1
  27. package/dist/ContextMenu/index.d.ts +1 -1
  28. package/dist/ContextMenu/index.js +1 -1
  29. package/dist/{ContextMenu-CujLDt4e.js → ContextMenu-_cj8wRB6.js} +1 -1
  30. package/dist/DateInput/index.d.ts +1 -1
  31. package/dist/DateInput/index.js +1 -1
  32. package/dist/{DateInput-CiIWOWXM.js → DateInput-DrMqXWSj.js} +2 -2
  33. package/dist/DateRangeInput/index.d.ts +1 -1
  34. package/dist/DateRangeInput/index.js +1 -1
  35. package/dist/{DateRangeInput-CLVQ8E0Y.js → DateRangeInput-BZuyhf-w.js} +1 -1
  36. package/dist/DateTimeInput/index.d.ts +1 -1
  37. package/dist/DateTimeInput/index.js +1 -1
  38. package/dist/{DateTimeInput-jHSN-Dzu.js → DateTimeInput-DhB2gzx5.js} +3 -3
  39. package/dist/Dialog/index.d.ts +1 -1
  40. package/dist/Dialog/index.js +3 -3
  41. package/dist/{Dialog-BQ5OBB1d.js → Dialog-B2pOTrnQ.js} +1 -1
  42. package/dist/{Dialog-DgdbRn2l.js → Dialog-CztWmbf8.js} +1 -1
  43. package/dist/{DialogHeader-D8234o9F.js → DialogHeader-5A5BUTTB.js} +1 -1
  44. package/dist/Drawer/index.d.ts +1 -1
  45. package/dist/Drawer/index.js +1 -1
  46. package/dist/{Drawer-Dqus7kUc.js → Drawer-Dt6paoDZ.js} +2 -2
  47. package/dist/DropdownMenu/index.js +2 -2
  48. package/dist/{DropdownMenu-LQsXd-_V.js → DropdownMenu-CFX1k1Ib.js} +1 -1
  49. package/dist/{DropdownMenu-BC_zB9le.js → DropdownMenu-D8s058G5.js} +1 -1
  50. package/dist/FileInput/index.d.ts +1 -1
  51. package/dist/InfoTip/index.d.ts +1 -1
  52. package/dist/InputGroup/index.d.ts +1 -1
  53. package/dist/Lightbox/index.js +1 -1
  54. package/dist/{Lightbox-RN_f7zRw.js → Lightbox-D8kFIbPj.js} +1 -1
  55. package/dist/Link/index.d.ts +1 -1
  56. package/dist/List/index.d.ts +1 -1
  57. package/dist/MobileNav/index.d.ts +1 -1
  58. package/dist/MobileNav/index.js +1 -1
  59. package/dist/{MobileNavToggle-DlQmYaBx.js → MobileNavToggle-CKEOroi0.js} +75 -32
  60. package/dist/MoreMenu/index.d.ts +1 -1
  61. package/dist/MultiSelector/index.d.ts +1 -1
  62. package/dist/MultiSelector/index.js +1 -1
  63. package/dist/{MultiSelector-BK6nZweN.js → MultiSelector-CkAhUYdn.js} +1 -1
  64. package/dist/{NavHeadingSurface-C17cbKn9.js → NavHeadingSurface-DZPa2px5.js} +19 -5
  65. package/dist/NavItem/index.d.ts +2 -2
  66. package/dist/NavItem/index.js +1 -1
  67. package/dist/{NavItem-BAe-tUG9.js → NavItem-CcbOJNnY.js} +18 -5
  68. package/dist/NavMenu/index.d.ts +1 -1
  69. package/dist/NumberInput/index.d.ts +1 -1
  70. package/dist/OverflowList/index.d.ts +1 -1
  71. package/dist/Pagination/index.d.ts +1 -1
  72. package/dist/Pagination/index.js +1 -1
  73. package/dist/{Pagination-DFQNX_Mb.js → Pagination-C0oI5FRP.js} +1 -1
  74. package/dist/Popover/index.js +1 -1
  75. package/dist/{Popover-CmAEizH-.js → Popover-Cl4gQQZq.js} +2 -1
  76. package/dist/PowerSearch/index.d.ts +1 -1
  77. package/dist/PowerSearch/index.js +1 -1
  78. package/dist/{PowerSearch-C2x4uuAM.js → PowerSearch-CPgbhvEL.js} +6 -6
  79. package/dist/ProgressBar/index.d.ts +1 -1
  80. package/dist/Radio/index.d.ts +1 -1
  81. package/dist/RadioList/index.d.ts +1 -1
  82. package/dist/ScrollableArea/index.d.ts +1 -1
  83. package/dist/SelectableCard/index.d.ts +1 -1
  84. package/dist/Selector/index.d.ts +1 -1
  85. package/dist/Selector/index.js +1 -1
  86. package/dist/{Selector-Bo7qkt1P.js → Selector-CUTnAjq-.js} +1 -1
  87. package/dist/SideNav/index.d.ts +1 -1
  88. package/dist/SideNav/index.js +2 -2
  89. package/dist/{SideNav-CcZLUd7G.js → SideNav-5yLlEOdD.js} +511 -57
  90. package/dist/Stepper/index.d.ts +1 -1
  91. package/dist/Switch/index.d.ts +1 -1
  92. package/dist/TabList/index.d.ts +1 -1
  93. package/dist/Table/index.d.ts +1 -1
  94. package/dist/Table/index.js +1 -1
  95. package/dist/{Table-o3aGMDT1.js → Table-Eok91IcO.js} +8 -6
  96. package/dist/TextArea/index.d.ts +1 -1
  97. package/dist/TextInput/index.d.ts +1 -1
  98. package/dist/{TimeField-BM-rVFhC.js → TimeField-jfhGVEyI.js} +1 -1
  99. package/dist/TimeInput/index.d.ts +1 -1
  100. package/dist/TimeInput/index.js +1 -1
  101. package/dist/{TimeInput-CkZfhhAr.js → TimeInput-CvFcN4nl.js} +1 -1
  102. package/dist/Timer/index.d.ts +1 -1
  103. package/dist/Timestamp/index.d.ts +1 -1
  104. package/dist/ToggleButton/index.d.ts +1 -1
  105. package/dist/Token/index.d.ts +1 -1
  106. package/dist/Toolbar/index.d.ts +1 -1
  107. package/dist/TopNav/index.d.ts +1 -1
  108. package/dist/TopNav/index.js +1 -1
  109. package/dist/{TopNav-CFkThrKq.js → TopNav-CSFUTuyI.js} +3 -3
  110. package/dist/TreeList/index.d.ts +1 -1
  111. package/dist/TreeList/index.js +1 -1
  112. package/dist/{TreeList-ugSF9DWj.js → TreeList-B33huihx.js} +2 -1
  113. package/dist/{landing-Bs0aMIsR.js → batch-BJD6Bt-O.js} +42 -740
  114. package/dist/composables/index.js +2 -2
  115. package/dist/{composables-BgfubKnk.js → composables-CDrwFX0l.js} +2 -19
  116. package/dist/context-Cj_zItu2.js +729 -0
  117. package/dist/edge-DIlkB7vS.js +164 -0
  118. package/dist/edgeRide-D0oC2JEB.js +499 -0
  119. package/dist/focusRegion-CmDg7_4b.js +81 -0
  120. package/dist/{handle-BPXdHbkr.js → handle-ChN2TMKH.js} +1 -1
  121. package/dist/{index-X4S7_dmq.d.ts → index-BA8exXNP.d.ts} +1 -1
  122. package/dist/{index-CryFtTT6.d.ts → index-BIQZa2BD.d.ts} +1 -1
  123. package/dist/{index-CEjvYAUZ.d.ts → index-BvWBeoa8.d.ts} +1 -1
  124. package/dist/{index-BeR-1LgF.d.ts → index-C5fbwY7Y.d.ts} +4 -3
  125. package/dist/{index-CbA8rR_b.d.ts → index-CBOv5j3c.d.ts} +1 -1
  126. package/dist/{index-D-giO0SA.d.ts → index-CHLLk77c.d.ts} +1 -1
  127. package/dist/{index-C4S65SAW.d.ts → index-CKnr0JlT.d.ts} +1 -1
  128. package/dist/{index-B-3EGjfQ.d.ts → index-CO9GW-ik.d.ts} +1 -1
  129. package/dist/{index-CdvmnNMH.d.ts → index-COgrQZIL.d.ts} +1 -1
  130. package/dist/{index-B449gOMC.d.ts → index-Cy1rEWC-.d.ts} +2 -2
  131. package/dist/{index-BO9TY87G.d.ts → index-DFLPv9io.d.ts} +1 -1
  132. package/dist/{index-ohw86wfM.d.ts → index-DbfcTFO6.d.ts} +37 -33
  133. package/dist/{index-Dg0JsBpI.d.ts → index-DoSTYXsP.d.ts} +2 -2
  134. package/dist/{index-CfXW4km8.d.ts → index-GgHVkJtB.d.ts} +1 -1
  135. package/dist/{index-aE810PYg.d.ts → index-Xhq1E7WZ.d.ts} +2 -2
  136. package/dist/{index-B3yTdknp.d.ts → index-ZKBj_1nu.d.ts} +3 -2
  137. package/dist/{index-CUCgbqBB.d.ts → index-gxuXI7KD.d.ts} +4 -4
  138. package/dist/{index-dWlCpnua.d.ts → index-mK1ICsVg.d.ts} +1 -1
  139. package/dist/{index-DdT2wE_N.d.ts → index-mPBIdznc.d.ts} +5 -5
  140. package/dist/index.d.ts +21 -21
  141. package/dist/index.js +34 -34
  142. package/dist/landing-C7nc9JHm.js +104 -0
  143. package/dist/quietFinished-CKZXgsPM.js +19 -0
  144. package/dist/{types-BG23kC3S.d.ts → types-C2ZuV4jf.d.ts} +7 -1
  145. package/dist/{useFocusTrap-BUd-fvUH.js → useFocusTrap-DsYtRdmV.js} +2 -81
  146. package/package.json +1 -1
  147. package/styles/mobile-nav.css +4 -2
  148. package/styles/nav-item.css +3 -3
  149. package/styles/side-nav.css +36 -8
  150. package/dist/context-ZsDEkhSF.js +0 -24
  151. package/dist/{index-BqhgeAT4.d.ts → index-CHx33xGa.d.ts} +2 -2
@@ -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 };