@simonbackx/vue-app-navigation 1.28.0 → 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +15 -15
- package/dist/index.js +2008 -0
- package/dist/main.css +346 -7
- package/dist/src/ComponentWithProperties.d.ts +8 -5
- package/dist/src/ComponentWithPropertiesInstance.d.ts +24 -6
- package/dist/src/FramedComponent.vue.d.ts +28 -8
- package/dist/src/HistoryManager.d.ts +1 -1
- package/dist/src/ModalMixin.d.ts +413 -12
- package/dist/src/ModalStackComponent.vue.d.ts +209 -12
- package/dist/src/ModalStackComponentFinderMixin.d.ts +5 -5
- package/dist/src/NavigationController.vue.d.ts +63 -32
- package/dist/src/NavigationMixin.d.ts +28 -47
- package/dist/src/Plugin.d.ts +5 -0
- package/dist/src/Popup.vue.d.ts +34 -14
- package/dist/src/PushOptions.d.ts +2 -1
- package/dist/src/Sheet.vue.d.ts +432 -11
- package/dist/src/SideView.vue.d.ts +432 -11
- package/dist/src/SplitViewController.vue.d.ts +190 -16
- package/dist/src/StackComponent.vue.d.ts +13 -6
- package/dist/test/index.d.ts +1 -0
- package/dist/test/vite.config.d.ts +2 -0
- package/package.json +24 -25
- package/dist/main.css.map +0 -1
- package/dist/main.js +0 -2
- package/dist/main.js.map +0 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,2008 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { inject, markRaw, proxyRefs, getCurrentInstance, provide, queuePostFlushCb, onBeforeUnmount, onActivated, onBeforeMount, onMounted, onUpdated, warn, h, setTransitionHooks, callWithAsyncErrorHandling, ErrorCodes, shallowRef, computed, unref, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, isRef, createBlock, Transition, withCtx, createCommentVNode, defineComponent, ref, onDeactivated, normalizeClass, Fragment, renderList, withModifiers } from "vue";
|
|
8
|
+
class HistoryManagerStatic {
|
|
9
|
+
constructor() {
|
|
10
|
+
// undoActions: Map<number, (animate: boolean) => void> = new Map();
|
|
11
|
+
__publicField(this, "states", []);
|
|
12
|
+
__publicField(this, "counter", 0);
|
|
13
|
+
__publicField(this, "active", false);
|
|
14
|
+
__publicField(this, "animateHistoryPop", true);
|
|
15
|
+
__publicField(this, "isAdjustingState", false);
|
|
16
|
+
__publicField(this, "manualStateAction", false);
|
|
17
|
+
// Manipulating the history is async and can cause issues when fast calls happen without awaiting the previous one
|
|
18
|
+
__publicField(this, "historyQueue", []);
|
|
19
|
+
__publicField(this, "isQueueRunning", false);
|
|
20
|
+
}
|
|
21
|
+
addToQueue(action) {
|
|
22
|
+
this.historyQueue.push(action);
|
|
23
|
+
if (!this.isQueueRunning) {
|
|
24
|
+
this.runQueue();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
runQueue() {
|
|
28
|
+
this.isQueueRunning = true;
|
|
29
|
+
const action = this.historyQueue.shift();
|
|
30
|
+
if (action) {
|
|
31
|
+
console.log("Running history queue action");
|
|
32
|
+
action().finally(() => this.runQueue()).catch(console.error);
|
|
33
|
+
} else {
|
|
34
|
+
console.log("History queue done");
|
|
35
|
+
this.isQueueRunning = false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
go(delta) {
|
|
39
|
+
this.addToQueue(async () => {
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
this.manualStateAction = true;
|
|
42
|
+
console.log("history.go", delta);
|
|
43
|
+
history.go(delta);
|
|
44
|
+
let timer = void 0;
|
|
45
|
+
const listener = () => {
|
|
46
|
+
clearTimeout(timer);
|
|
47
|
+
resolve();
|
|
48
|
+
window.removeEventListener("popstate", listener);
|
|
49
|
+
};
|
|
50
|
+
window.addEventListener("popstate", listener);
|
|
51
|
+
timer = setTimeout(() => {
|
|
52
|
+
console.warn("Timeout while waiting for history.go");
|
|
53
|
+
listener();
|
|
54
|
+
}, 200);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/// Set the current URL without modifying states
|
|
59
|
+
setUrl(url) {
|
|
60
|
+
if (!this.active) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (ComponentWithProperties.debug) {
|
|
64
|
+
console.log("Set url: " + url + ", current counter: " + this.counter);
|
|
65
|
+
}
|
|
66
|
+
const count = this.states[this.states.length - 1].index;
|
|
67
|
+
this.addToQueue(async () => {
|
|
68
|
+
if (ComponentWithProperties.debug) {
|
|
69
|
+
console.log("history.replaceState", count, url);
|
|
70
|
+
}
|
|
71
|
+
history.replaceState({ counter: count }, "", url);
|
|
72
|
+
});
|
|
73
|
+
this.states[this.states.length - 1].url = url;
|
|
74
|
+
}
|
|
75
|
+
pushState(url, undoAction, adjustHistory) {
|
|
76
|
+
if (!this.active) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
this.counter++;
|
|
80
|
+
this.states.push({
|
|
81
|
+
url,
|
|
82
|
+
index: this.counter,
|
|
83
|
+
adjustHistory,
|
|
84
|
+
undoAction
|
|
85
|
+
});
|
|
86
|
+
const c = this.counter;
|
|
87
|
+
if (adjustHistory) {
|
|
88
|
+
this.addToQueue(async () => {
|
|
89
|
+
if (ComponentWithProperties.debug) {
|
|
90
|
+
console.log("history.pushState", c, url);
|
|
91
|
+
}
|
|
92
|
+
history.pushState({ counter: c }, "", url);
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
this.addToQueue(async () => {
|
|
96
|
+
if (ComponentWithProperties.debug) {
|
|
97
|
+
console.log("history.replaceState", c, url);
|
|
98
|
+
}
|
|
99
|
+
history.replaceState({ counter: c }, "", url);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (ComponentWithProperties.debug) {
|
|
103
|
+
console.log("Push new state ", this.states[this.states.length - 1]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Return to a given history point in time, if needed
|
|
108
|
+
*/
|
|
109
|
+
returnToHistoryIndex(counter) {
|
|
110
|
+
if (ComponentWithProperties.debug) {
|
|
111
|
+
console.log("Did return to history index " + counter + ", coming from " + this.counter);
|
|
112
|
+
}
|
|
113
|
+
if (counter < this.counter) {
|
|
114
|
+
this.counter = counter;
|
|
115
|
+
const deletedStates = this.states.splice(this.counter + 1);
|
|
116
|
+
const adjustHistoryCount = deletedStates.filter((state) => state.adjustHistory).length;
|
|
117
|
+
if (adjustHistoryCount > 0) {
|
|
118
|
+
if (ComponentWithProperties.debug) {
|
|
119
|
+
console.log("Adjusting browser history state: popping " + adjustHistoryCount + " items");
|
|
120
|
+
}
|
|
121
|
+
this.go(-adjustHistoryCount);
|
|
122
|
+
}
|
|
123
|
+
if (!this.states[this.counter].adjustHistory && this.states[this.counter].url) {
|
|
124
|
+
if (ComponentWithProperties.debug) {
|
|
125
|
+
console.log("Setting manual url without history api: " + this.states[this.counter].url);
|
|
126
|
+
}
|
|
127
|
+
this.setUrl(this.states[this.counter].url);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return this.counter;
|
|
131
|
+
}
|
|
132
|
+
activate() {
|
|
133
|
+
window.addEventListener("popstate", (event) => {
|
|
134
|
+
var _a;
|
|
135
|
+
if (ComponentWithProperties.debug) {
|
|
136
|
+
console.log("HistoryManager popstate");
|
|
137
|
+
}
|
|
138
|
+
if (this.isAdjustingState) {
|
|
139
|
+
console.warn("Duplicate popstate");
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (this.manualStateAction) {
|
|
143
|
+
this.manualStateAction = false;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.isAdjustingState = true;
|
|
147
|
+
const newCounter = (_a = event.state) == null ? void 0 : _a.counter;
|
|
148
|
+
if (newCounter !== void 0) {
|
|
149
|
+
if (newCounter > this.counter) {
|
|
150
|
+
const amount = newCounter - this.counter;
|
|
151
|
+
this.go(-amount);
|
|
152
|
+
if (ComponentWithProperties.debug) {
|
|
153
|
+
console.log("Not allowed to go forward, going back " + amount + " steps");
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
const animate = this.counter - newCounter == 1 && this.animateHistoryPop;
|
|
157
|
+
this.counter = newCounter;
|
|
158
|
+
const deletedStates = this.states.splice(this.counter + 1);
|
|
159
|
+
for (const state of deletedStates.reverse()) {
|
|
160
|
+
if (state.undoAction) {
|
|
161
|
+
if (ComponentWithProperties.debug) {
|
|
162
|
+
console.log("Executing undoAction...");
|
|
163
|
+
}
|
|
164
|
+
state.undoAction(animate);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
this.isAdjustingState = false;
|
|
170
|
+
});
|
|
171
|
+
this.active = true;
|
|
172
|
+
history.replaceState({ counter: this.counter }, "");
|
|
173
|
+
this.states.push({
|
|
174
|
+
index: this.counter,
|
|
175
|
+
adjustHistory: false,
|
|
176
|
+
url: "/"
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const HistoryManager = new HistoryManagerStatic();
|
|
181
|
+
function useCurrentComponent() {
|
|
182
|
+
return inject("navigation_currentComponent");
|
|
183
|
+
}
|
|
184
|
+
function getExposeProxy(instance) {
|
|
185
|
+
if (!instance.exposed) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (instance.exposeProxy) {
|
|
189
|
+
return instance.exposeProxy;
|
|
190
|
+
}
|
|
191
|
+
const extendingProxy = instance.proxy;
|
|
192
|
+
instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
|
193
|
+
get(target, key) {
|
|
194
|
+
if (key in target) {
|
|
195
|
+
return target[key];
|
|
196
|
+
}
|
|
197
|
+
return extendingProxy[key];
|
|
198
|
+
},
|
|
199
|
+
has(target, key) {
|
|
200
|
+
return key in target || key in extendingProxy;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return instance.exposeProxy;
|
|
204
|
+
}
|
|
205
|
+
const _ComponentWithProperties = class _ComponentWithProperties {
|
|
206
|
+
constructor(component, properties = {}) {
|
|
207
|
+
/// Name of component or component Options. Currently no way to force type
|
|
208
|
+
__publicField(this, "component");
|
|
209
|
+
__publicField(this, "properties");
|
|
210
|
+
__publicField(this, "key");
|
|
211
|
+
__publicField(this, "type", null);
|
|
212
|
+
__publicField(this, "hide", false);
|
|
213
|
+
/// Saved vnode of this instance
|
|
214
|
+
__publicField(this, "vnode", null);
|
|
215
|
+
__publicField(this, "unmount", null);
|
|
216
|
+
// Keep the vnode alive when it is removed from the VDOM
|
|
217
|
+
__publicField(this, "keepAlive", false);
|
|
218
|
+
__publicField(this, "isKeptAlive", false);
|
|
219
|
+
__publicField(this, "isMounted", false);
|
|
220
|
+
/// Cover whole screen. Other style = popup
|
|
221
|
+
__publicField(this, "modalDisplayStyle", "cover");
|
|
222
|
+
// If the display animation should be animated
|
|
223
|
+
__publicField(this, "animated", true);
|
|
224
|
+
// Hisotry index
|
|
225
|
+
__publicField(this, "historyIndex", null);
|
|
226
|
+
__publicField(this, "isContainerView", false);
|
|
227
|
+
this.component = component;
|
|
228
|
+
this.properties = properties;
|
|
229
|
+
this.key = _ComponentWithProperties.keyCounter++;
|
|
230
|
+
markRaw(this);
|
|
231
|
+
}
|
|
232
|
+
clone() {
|
|
233
|
+
return new _ComponentWithProperties(this.component, this.properties);
|
|
234
|
+
}
|
|
235
|
+
beforeMount() {
|
|
236
|
+
if (_ComponentWithProperties.debug)
|
|
237
|
+
console.log("Before mount: " + this.component.name);
|
|
238
|
+
if (this.vnode) {
|
|
239
|
+
if (this.isKeptAlive) {
|
|
240
|
+
this.isKeptAlive = false;
|
|
241
|
+
_ComponentWithProperties.keepAliveCounter--;
|
|
242
|
+
if (_ComponentWithProperties.debug)
|
|
243
|
+
console.log("Total components kept alive: " + _ComponentWithProperties.keepAliveCounter);
|
|
244
|
+
} else {
|
|
245
|
+
if (_ComponentWithProperties.debug)
|
|
246
|
+
console.warn("About to mount a component that was not destroyed properly " + this.component.name);
|
|
247
|
+
this.destroy(this.vnode);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (this.isContainerView) {
|
|
251
|
+
if (this.historyIndex === null) {
|
|
252
|
+
this.historyIndex = HistoryManager.counter;
|
|
253
|
+
}
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (this.modalDisplayStyle == "overlay") {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
this.assignHistoryIndex();
|
|
260
|
+
}
|
|
261
|
+
getHistoryIndex() {
|
|
262
|
+
if (this.component)
|
|
263
|
+
return this.historyIndex;
|
|
264
|
+
}
|
|
265
|
+
mounted() {
|
|
266
|
+
if (_ComponentWithProperties.debug)
|
|
267
|
+
console.log("Component mounted: " + this.component.name);
|
|
268
|
+
this.isMounted = true;
|
|
269
|
+
_ComponentWithProperties.ignoreActivate = this;
|
|
270
|
+
}
|
|
271
|
+
onMountedChildComponent(child) {
|
|
272
|
+
this.isContainerView = true;
|
|
273
|
+
if (_ComponentWithProperties.debug)
|
|
274
|
+
console.log("Container mounted child component: " + this.component.name + " got " + child.component.name);
|
|
275
|
+
}
|
|
276
|
+
onActivatedChildComponent(child) {
|
|
277
|
+
this.isContainerView = true;
|
|
278
|
+
if (_ComponentWithProperties.debug)
|
|
279
|
+
console.log("Container got activated child component: " + this.component.name + " got " + child.component.name);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Call this method to assign a history index to this component (you should only call this when you want to assign a history index to this component that will not get mounted already)
|
|
283
|
+
*/
|
|
284
|
+
assignHistoryIndex() {
|
|
285
|
+
if (!HistoryManager.active) {
|
|
286
|
+
console.warn("HistoryManager is disabled.");
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (this.historyIndex == null) {
|
|
290
|
+
if (_ComponentWithProperties.debug)
|
|
291
|
+
console.log("Assigned history index: " + this.component.name + " = " + HistoryManager.counter);
|
|
292
|
+
this.historyIndex = HistoryManager.counter;
|
|
293
|
+
} else {
|
|
294
|
+
this.historyIndex = HistoryManager.returnToHistoryIndex(this.historyIndex);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
activated() {
|
|
298
|
+
if (_ComponentWithProperties.debug)
|
|
299
|
+
console.log("Component activated: " + this.component.name);
|
|
300
|
+
if (_ComponentWithProperties.ignoreActivate === this) {
|
|
301
|
+
if (_ComponentWithProperties.debug)
|
|
302
|
+
console.log("Ignore component activation: " + this.component.name);
|
|
303
|
+
_ComponentWithProperties.ignoreActivate = null;
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
_ComponentWithProperties.ignoreActivate = null;
|
|
307
|
+
if (this.isContainerView) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (this.modalDisplayStyle == "overlay") {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (!HistoryManager.active) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (this.historyIndex !== null) {
|
|
317
|
+
this.historyIndex = HistoryManager.returnToHistoryIndex(this.historyIndex);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
componentInstance() {
|
|
321
|
+
var _a, _b, _c, _d;
|
|
322
|
+
if (!((_a = this.vnode) == null ? void 0 : _a.component)) {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
return getExposeProxy((_b = this.vnode) == null ? void 0 : _b.component) || ((_d = (_c = this.vnode) == null ? void 0 : _c.component) == null ? void 0 : _d.proxy);
|
|
326
|
+
}
|
|
327
|
+
async shouldNavigateAway() {
|
|
328
|
+
const instance = this.componentInstance();
|
|
329
|
+
if (instance && instance.shouldNavigateAway) {
|
|
330
|
+
const promise = instance.shouldNavigateAway();
|
|
331
|
+
if (typeof promise === "boolean") {
|
|
332
|
+
if (!promise) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
} else if (promise.then && promise.catch) {
|
|
336
|
+
const r = await promise;
|
|
337
|
+
if (!r) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
destroy(vnode) {
|
|
345
|
+
this.isMounted = false;
|
|
346
|
+
if (this.vnode) {
|
|
347
|
+
if (vnode !== this.vnode) {
|
|
348
|
+
console.warn("Received destroy event from old/different vnode", this.vnode, vnode);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (this.keepAlive) {
|
|
352
|
+
this.keepAlive = false;
|
|
353
|
+
if (!this.isKeptAlive) {
|
|
354
|
+
this.isKeptAlive = true;
|
|
355
|
+
_ComponentWithProperties.keepAliveCounter++;
|
|
356
|
+
if (_ComponentWithProperties.debug)
|
|
357
|
+
console.log("Kept component alive " + this.component.name);
|
|
358
|
+
if (_ComponentWithProperties.debug)
|
|
359
|
+
console.log("Total components kept alive: " + _ComponentWithProperties.keepAliveCounter);
|
|
360
|
+
}
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (this.isKeptAlive) {
|
|
364
|
+
this.isKeptAlive = false;
|
|
365
|
+
_ComponentWithProperties.keepAliveCounter--;
|
|
366
|
+
if (_ComponentWithProperties.debug)
|
|
367
|
+
console.log("Freed component from alive stack " + this.component.name);
|
|
368
|
+
if (_ComponentWithProperties.debug)
|
|
369
|
+
console.log("Total components kept alive: " + _ComponentWithProperties.keepAliveCounter);
|
|
370
|
+
}
|
|
371
|
+
if (_ComponentWithProperties.debug)
|
|
372
|
+
console.log("Destroyed component " + this.component.name, this.vnode);
|
|
373
|
+
if (this.unmount) {
|
|
374
|
+
this.unmount(this.vnode);
|
|
375
|
+
this.unmount = null;
|
|
376
|
+
} else {
|
|
377
|
+
console.error("No unmount function for component " + this.vnode);
|
|
378
|
+
}
|
|
379
|
+
this.vnode = null;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
setDisplayStyle(style) {
|
|
383
|
+
this.modalDisplayStyle = style;
|
|
384
|
+
return this;
|
|
385
|
+
}
|
|
386
|
+
setAnimated(animated) {
|
|
387
|
+
this.animated = animated;
|
|
388
|
+
return this;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
// Counter for debugging. Count of components that are kept alive but are not mounted.
|
|
392
|
+
__publicField(_ComponentWithProperties, "keepAliveCounter", 0);
|
|
393
|
+
__publicField(_ComponentWithProperties, "keyCounter", 0);
|
|
394
|
+
__publicField(_ComponentWithProperties, "debug", false);
|
|
395
|
+
__publicField(_ComponentWithProperties, "ignoreActivate", null);
|
|
396
|
+
let ComponentWithProperties = _ComponentWithProperties;
|
|
397
|
+
/**
|
|
398
|
+
* @vue/shared v3.4.25
|
|
399
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
400
|
+
* @license MIT
|
|
401
|
+
**/
|
|
402
|
+
!!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
|
|
403
|
+
!!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
|
|
404
|
+
const invokeArrayFns = (fns, arg) => {
|
|
405
|
+
for (let i = 0; i < fns.length; i++) {
|
|
406
|
+
fns[i](arg);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
const ShapeFlags = {
|
|
410
|
+
"ELEMENT": 1,
|
|
411
|
+
"1": "ELEMENT",
|
|
412
|
+
"FUNCTIONAL_COMPONENT": 2,
|
|
413
|
+
"2": "FUNCTIONAL_COMPONENT",
|
|
414
|
+
"STATEFUL_COMPONENT": 4,
|
|
415
|
+
"4": "STATEFUL_COMPONENT",
|
|
416
|
+
"TEXT_CHILDREN": 8,
|
|
417
|
+
"8": "TEXT_CHILDREN",
|
|
418
|
+
"ARRAY_CHILDREN": 16,
|
|
419
|
+
"16": "ARRAY_CHILDREN",
|
|
420
|
+
"SLOTS_CHILDREN": 32,
|
|
421
|
+
"32": "SLOTS_CHILDREN",
|
|
422
|
+
"TELEPORT": 64,
|
|
423
|
+
"64": "TELEPORT",
|
|
424
|
+
"SUSPENSE": 128,
|
|
425
|
+
"128": "SUSPENSE",
|
|
426
|
+
"COMPONENT_SHOULD_KEEP_ALIVE": 256,
|
|
427
|
+
"256": "COMPONENT_SHOULD_KEEP_ALIVE",
|
|
428
|
+
"COMPONENT_KEPT_ALIVE": 512,
|
|
429
|
+
"512": "COMPONENT_KEPT_ALIVE",
|
|
430
|
+
"COMPONENT": 6,
|
|
431
|
+
"6": "COMPONENT"
|
|
432
|
+
};
|
|
433
|
+
function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
|
434
|
+
callWithAsyncErrorHandling(hook, instance, ErrorCodes.VNODE_HOOK, [
|
|
435
|
+
vnode,
|
|
436
|
+
prevVNode
|
|
437
|
+
]);
|
|
438
|
+
}
|
|
439
|
+
function getInnerChild(vnode) {
|
|
440
|
+
return vnode.shapeFlag & ShapeFlags.SUSPENSE ? vnode.ssContent : vnode;
|
|
441
|
+
}
|
|
442
|
+
function resetShapeFlag(vnode) {
|
|
443
|
+
vnode.shapeFlag &= ~ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE;
|
|
444
|
+
vnode.shapeFlag &= ~ShapeFlags.COMPONENT_KEPT_ALIVE;
|
|
445
|
+
}
|
|
446
|
+
function makeProvidesParentReactive(instance) {
|
|
447
|
+
var _a;
|
|
448
|
+
const reactiveInstance = shallowRef(instance);
|
|
449
|
+
const originalProvides = instance.provides;
|
|
450
|
+
const ownProvides = instance.provides === ((_a = instance.parent) == null ? void 0 : _a.provides) ? [] : Object.getOwnPropertyNames(originalProvides);
|
|
451
|
+
const proxyProvider = new Proxy({}, {
|
|
452
|
+
get(_target, key) {
|
|
453
|
+
if (typeof key !== "string" || !key.startsWith("reactive_")) {
|
|
454
|
+
return originalProvides[key];
|
|
455
|
+
}
|
|
456
|
+
if (key in ownProvides) {
|
|
457
|
+
return originalProvides[key];
|
|
458
|
+
}
|
|
459
|
+
return computed(() => {
|
|
460
|
+
var _a2;
|
|
461
|
+
return unref((_a2 = reactiveInstance.value.parent) == null ? void 0 : _a2.provides[key]);
|
|
462
|
+
});
|
|
463
|
+
},
|
|
464
|
+
// Vue valides keys using 'a' in obj, so we need to handle this correctly
|
|
465
|
+
has(target, key) {
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
instance.provides = Object.create(proxyProvider);
|
|
470
|
+
return reactiveInstance;
|
|
471
|
+
}
|
|
472
|
+
const ComponentWithPropertiesInstance = {
|
|
473
|
+
props: {
|
|
474
|
+
component: {
|
|
475
|
+
type: ComponentWithProperties,
|
|
476
|
+
required: true
|
|
477
|
+
},
|
|
478
|
+
customProvide: {
|
|
479
|
+
required: false,
|
|
480
|
+
type: Object,
|
|
481
|
+
default: null
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
__isKeepAlive: true,
|
|
485
|
+
setup(props) {
|
|
486
|
+
const instance = getCurrentInstance();
|
|
487
|
+
const sharedContext = instance.ctx;
|
|
488
|
+
const reactiveInstance = makeProvidesParentReactive(instance);
|
|
489
|
+
if (props.customProvide) {
|
|
490
|
+
for (const key in props.customProvide) {
|
|
491
|
+
provide(key, props.customProvide[key]);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
provide("navigation_currentComponent", props.component);
|
|
495
|
+
const {
|
|
496
|
+
renderer: {
|
|
497
|
+
//p: patch,
|
|
498
|
+
m: move,
|
|
499
|
+
um: _unmount,
|
|
500
|
+
o: { createElement }
|
|
501
|
+
}
|
|
502
|
+
} = sharedContext;
|
|
503
|
+
const storageContainer = createElement("div");
|
|
504
|
+
const parentSuspense = instance.suspense;
|
|
505
|
+
sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
|
|
506
|
+
const instance2 = vnode.component;
|
|
507
|
+
move(vnode, container, anchor, 0, parentSuspense);
|
|
508
|
+
queuePostFlushCb(() => {
|
|
509
|
+
instance2.isDeactivated = false;
|
|
510
|
+
if (instance2.a) {
|
|
511
|
+
invokeArrayFns(instance2.a);
|
|
512
|
+
}
|
|
513
|
+
const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
|
|
514
|
+
if (vnodeHook) {
|
|
515
|
+
invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
};
|
|
519
|
+
sharedContext.deactivate = (vnode) => {
|
|
520
|
+
const instance2 = vnode.component;
|
|
521
|
+
move(vnode, storageContainer, null, 1, parentSuspense);
|
|
522
|
+
queuePostFlushCb(() => {
|
|
523
|
+
if (instance2.da) {
|
|
524
|
+
invokeArrayFns(instance2.da);
|
|
525
|
+
}
|
|
526
|
+
const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
|
|
527
|
+
if (vnodeHook) {
|
|
528
|
+
invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
|
529
|
+
}
|
|
530
|
+
instance2.isDeactivated = true;
|
|
531
|
+
});
|
|
532
|
+
};
|
|
533
|
+
function unmount(vnode) {
|
|
534
|
+
if (current) {
|
|
535
|
+
const { subTree } = instance;
|
|
536
|
+
const _innerVnode = getInnerChild(subTree);
|
|
537
|
+
if (vnode.type === _innerVnode.type && vnode.key === _innerVnode.key) {
|
|
538
|
+
resetShapeFlag(_innerVnode);
|
|
539
|
+
const da = _innerVnode.component.da;
|
|
540
|
+
da && queuePostFlushCb(da);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
resetShapeFlag(vnode);
|
|
545
|
+
_unmount(vnode, instance, parentSuspense, true);
|
|
546
|
+
}
|
|
547
|
+
let current = null;
|
|
548
|
+
function getChildVNode() {
|
|
549
|
+
var _a, _b, _c, _d;
|
|
550
|
+
return (_d = (_c = (_b = (_a = instance.vnode) == null ? void 0 : _a.component) == null ? void 0 : _b.subTree) == null ? void 0 : _c.component) == null ? void 0 : _d.vnode;
|
|
551
|
+
}
|
|
552
|
+
onBeforeUnmount(() => {
|
|
553
|
+
if (!current) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const child = getChildVNode();
|
|
557
|
+
if (!child) {
|
|
558
|
+
console.error("No child found in ComponentWithPropertiesInstance.beforeUnmount");
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (props.component.unmount === unmount) {
|
|
562
|
+
props.component.destroy(getChildVNode());
|
|
563
|
+
} else {
|
|
564
|
+
console.warn("ComponentWithPropertiesInstance unmount called with different unmount function");
|
|
565
|
+
}
|
|
566
|
+
current = null;
|
|
567
|
+
});
|
|
568
|
+
onActivated(() => {
|
|
569
|
+
props.component.activated();
|
|
570
|
+
});
|
|
571
|
+
onBeforeMount(() => {
|
|
572
|
+
props.component.beforeMount();
|
|
573
|
+
});
|
|
574
|
+
let pendingCacheKey = null;
|
|
575
|
+
const cacheSubtree = () => {
|
|
576
|
+
if (current && pendingCacheKey != null) {
|
|
577
|
+
const child = getChildVNode();
|
|
578
|
+
if (!child) {
|
|
579
|
+
console.error("No child found in ComponentWithPropertiesInstance.cacheSubtree");
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
props.component.vnode = child;
|
|
583
|
+
props.component.unmount = unmount;
|
|
584
|
+
child._reactiveInstance = reactiveInstance;
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
onMounted(cacheSubtree);
|
|
588
|
+
onUpdated(cacheSubtree);
|
|
589
|
+
return () => {
|
|
590
|
+
pendingCacheKey = null;
|
|
591
|
+
if (!props.component) {
|
|
592
|
+
warn("No component provided to ComponentWithPropertiesInstance");
|
|
593
|
+
current = null;
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
const vnode = h(props.component.component, props.component.properties);
|
|
597
|
+
const comp = vnode.type;
|
|
598
|
+
const key = vnode.key == null ? comp : vnode.key;
|
|
599
|
+
pendingCacheKey = key;
|
|
600
|
+
if (props.component.vnode) {
|
|
601
|
+
const cachedVNode = props.component.vnode;
|
|
602
|
+
const parent = instance;
|
|
603
|
+
vnode.el = cachedVNode.el;
|
|
604
|
+
vnode.component = cachedVNode.component;
|
|
605
|
+
if (!cachedVNode._reactiveInstance) {
|
|
606
|
+
console.warn("Missing _reactiveInstance on vnode");
|
|
607
|
+
} else {
|
|
608
|
+
cachedVNode._reactiveInstance.value = parent;
|
|
609
|
+
}
|
|
610
|
+
if (vnode.transition) {
|
|
611
|
+
setTransitionHooks(vnode, vnode.transition);
|
|
612
|
+
}
|
|
613
|
+
vnode.shapeFlag |= ShapeFlags.COMPONENT_KEPT_ALIVE;
|
|
614
|
+
}
|
|
615
|
+
vnode.shapeFlag |= ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE;
|
|
616
|
+
current = vnode;
|
|
617
|
+
return vnode;
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
const _sfc_main$4 = {
|
|
622
|
+
components: {
|
|
623
|
+
ComponentWithPropertiesInstance
|
|
624
|
+
},
|
|
625
|
+
provide() {
|
|
626
|
+
return {
|
|
627
|
+
...this.customProvide ?? {}
|
|
628
|
+
};
|
|
629
|
+
},
|
|
630
|
+
props: {
|
|
631
|
+
root: {
|
|
632
|
+
type: ComponentWithProperties,
|
|
633
|
+
required: true
|
|
634
|
+
},
|
|
635
|
+
customProvide: {
|
|
636
|
+
type: Object,
|
|
637
|
+
default: null
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
emits: ["show", "push", "pop"]
|
|
641
|
+
};
|
|
642
|
+
const _export_sfc = (sfc, props) => {
|
|
643
|
+
const target = sfc.__vccOpts || sfc;
|
|
644
|
+
for (const [key, val] of props) {
|
|
645
|
+
target[key] = val;
|
|
646
|
+
}
|
|
647
|
+
return target;
|
|
648
|
+
};
|
|
649
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
650
|
+
const _component_ComponentWithPropertiesInstance = resolveComponent("ComponentWithPropertiesInstance");
|
|
651
|
+
return openBlock(), createElementBlock("div", null, [
|
|
652
|
+
createElementVNode("div", null, [
|
|
653
|
+
createVNode(_component_ComponentWithPropertiesInstance, { component: $props.root }, null, 8, ["component"])
|
|
654
|
+
])
|
|
655
|
+
]);
|
|
656
|
+
}
|
|
657
|
+
const FramedComponent = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$6]]);
|
|
658
|
+
function usePop() {
|
|
659
|
+
const rawPop = inject("reactive_navigation_pop", null);
|
|
660
|
+
return (options) => {
|
|
661
|
+
const pop = unref(rawPop);
|
|
662
|
+
if (!pop) {
|
|
663
|
+
console.warn("Failed to perform pop");
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
return pop(options);
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
function useShowDetail() {
|
|
670
|
+
const rawShowDetail = inject("reactive_navigation_show_detail");
|
|
671
|
+
return (options) => {
|
|
672
|
+
const showDetail = unref(rawShowDetail);
|
|
673
|
+
if (!showDetail) {
|
|
674
|
+
console.warn("Failed to perform showDetail");
|
|
675
|
+
return Promise.resolve();
|
|
676
|
+
}
|
|
677
|
+
if (!options.components) {
|
|
678
|
+
return showDetail({ components: [options] });
|
|
679
|
+
}
|
|
680
|
+
return showDetail(options);
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
function useShow() {
|
|
684
|
+
const rawShow = inject("reactive_navigation_show");
|
|
685
|
+
return (options) => {
|
|
686
|
+
const show = unref(rawShow);
|
|
687
|
+
if (!show) {
|
|
688
|
+
console.warn("Failed to perform show");
|
|
689
|
+
return Promise.resolve();
|
|
690
|
+
}
|
|
691
|
+
if (!options.components) {
|
|
692
|
+
return show({ components: [options] });
|
|
693
|
+
}
|
|
694
|
+
return show(options);
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
function usePresent() {
|
|
698
|
+
const rawPresent = inject("reactive_navigation_present", null);
|
|
699
|
+
return (options) => {
|
|
700
|
+
const present = unref(rawPresent);
|
|
701
|
+
if (!present) {
|
|
702
|
+
console.warn("Failed to perform present");
|
|
703
|
+
return Promise.resolve();
|
|
704
|
+
}
|
|
705
|
+
if (!options.components) {
|
|
706
|
+
return present({ components: [options] });
|
|
707
|
+
}
|
|
708
|
+
return present(options);
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function useDismiss() {
|
|
712
|
+
const rawDismiss = inject("reactive_navigation_dismiss");
|
|
713
|
+
return (options) => {
|
|
714
|
+
const dismiss = unref(rawDismiss);
|
|
715
|
+
if (!dismiss) {
|
|
716
|
+
console.warn("Failed to perform dismiss");
|
|
717
|
+
return Promise.resolve();
|
|
718
|
+
}
|
|
719
|
+
return dismiss(options);
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
function useCanPop() {
|
|
723
|
+
const rawPop = inject("reactive_navigation_pop", null);
|
|
724
|
+
return computed(() => {
|
|
725
|
+
return !!unref(rawPop);
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
function useCanDismiss() {
|
|
729
|
+
const rawDismiss = inject("reactive_navigation_dismiss", null);
|
|
730
|
+
return computed(() => !!unref(rawDismiss));
|
|
731
|
+
}
|
|
732
|
+
function useFocused() {
|
|
733
|
+
return inject("reactive_navigation_focused", true);
|
|
734
|
+
}
|
|
735
|
+
function usePopup() {
|
|
736
|
+
return inject("reactive_popup", null);
|
|
737
|
+
}
|
|
738
|
+
const NavigationMixin = {
|
|
739
|
+
created() {
|
|
740
|
+
const definitions = {
|
|
741
|
+
pop: usePop(),
|
|
742
|
+
showDetail: useShowDetail(),
|
|
743
|
+
show: useShow(),
|
|
744
|
+
present: usePresent(),
|
|
745
|
+
dismiss: useDismiss(),
|
|
746
|
+
canPop: useCanPop(),
|
|
747
|
+
canDismiss: useCanDismiss(),
|
|
748
|
+
isFocused: useFocused(),
|
|
749
|
+
emitParents: () => {
|
|
750
|
+
throw new Error("emitParents has been removed and should no longer be needed");
|
|
751
|
+
},
|
|
752
|
+
popup: usePopup()
|
|
753
|
+
};
|
|
754
|
+
const ctx = this.$.ctx;
|
|
755
|
+
for (const key in definitions) {
|
|
756
|
+
if (!isRef(definitions[key])) {
|
|
757
|
+
ctx[key] = definitions[key];
|
|
758
|
+
} else {
|
|
759
|
+
const val = definitions[key];
|
|
760
|
+
Object.defineProperty(ctx, key, {
|
|
761
|
+
enumerable: true,
|
|
762
|
+
configurable: true,
|
|
763
|
+
get: () => {
|
|
764
|
+
return val.value;
|
|
765
|
+
},
|
|
766
|
+
set: () => {
|
|
767
|
+
warn(`Cannot assign to '${key}' of navigation mixin. This is a read-only property.`);
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
return definitions;
|
|
773
|
+
}
|
|
774
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
775
|
+
};
|
|
776
|
+
const _sfc_main$3 = {
|
|
777
|
+
components: {
|
|
778
|
+
FramedComponent
|
|
779
|
+
},
|
|
780
|
+
inject: {
|
|
781
|
+
reactive_navigation_pop: {
|
|
782
|
+
default: null
|
|
783
|
+
}
|
|
784
|
+
},
|
|
785
|
+
provide() {
|
|
786
|
+
let extra = {};
|
|
787
|
+
if (this.animationType === "modal") {
|
|
788
|
+
extra = {
|
|
789
|
+
reactive_navigation_dismiss: computed(() => this.components.length > 1 ? this.pop : this.reactive_navigation_pop)
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
return {
|
|
793
|
+
reactive_navigation_show: this.push,
|
|
794
|
+
reactive_navigation_pop: computed(() => this.components.length > 1 ? this.pop : this.reactive_navigation_pop),
|
|
795
|
+
...extra,
|
|
796
|
+
...this.customProvide ?? {}
|
|
797
|
+
};
|
|
798
|
+
},
|
|
799
|
+
props: {
|
|
800
|
+
root: {
|
|
801
|
+
required: true,
|
|
802
|
+
type: ComponentWithProperties
|
|
803
|
+
},
|
|
804
|
+
initialComponents: {
|
|
805
|
+
default: null,
|
|
806
|
+
type: Object
|
|
807
|
+
},
|
|
808
|
+
animationType: {
|
|
809
|
+
default: "default",
|
|
810
|
+
type: String
|
|
811
|
+
},
|
|
812
|
+
customProvide: {
|
|
813
|
+
type: Object,
|
|
814
|
+
default: null
|
|
815
|
+
}
|
|
816
|
+
},
|
|
817
|
+
emits: ["didPush", "didPop", "showDetail", "present"],
|
|
818
|
+
setup() {
|
|
819
|
+
return {
|
|
820
|
+
originalPop: usePop()
|
|
821
|
+
};
|
|
822
|
+
},
|
|
823
|
+
data() {
|
|
824
|
+
const savedInternalScrollPositions = [];
|
|
825
|
+
const savedScrollPositions = [];
|
|
826
|
+
const components = [];
|
|
827
|
+
return {
|
|
828
|
+
components,
|
|
829
|
+
mainComponent: null,
|
|
830
|
+
transitionName: "none",
|
|
831
|
+
savedScrollPositions,
|
|
832
|
+
nextScrollPosition: 0,
|
|
833
|
+
previousScrollPosition: 0,
|
|
834
|
+
nextInternalScrollPosition: 0,
|
|
835
|
+
savedInternalScrollPositions
|
|
836
|
+
};
|
|
837
|
+
},
|
|
838
|
+
beforeMount() {
|
|
839
|
+
if (this.initialComponents && this.initialComponents.length > 0) {
|
|
840
|
+
this.mainComponent = this.initialComponents[this.initialComponents.length - 1];
|
|
841
|
+
this.components = this.initialComponents.slice(0);
|
|
842
|
+
this.initialComponents.splice(0, this.initialComponents.length);
|
|
843
|
+
} else {
|
|
844
|
+
this.mainComponent = this.root;
|
|
845
|
+
this.components = [this.root];
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
beforeUnmount() {
|
|
849
|
+
for (const component of this.components) {
|
|
850
|
+
if (component.isKeptAlive && component.vnode) {
|
|
851
|
+
component.destroy(component.vnode);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
this.components = [];
|
|
855
|
+
this.mainComponent = null;
|
|
856
|
+
},
|
|
857
|
+
methods: {
|
|
858
|
+
freezeSize() {
|
|
859
|
+
const el = this.$el;
|
|
860
|
+
const w = el.offsetWidth;
|
|
861
|
+
const h2 = el.offsetHeight;
|
|
862
|
+
el.style.width = w + "px";
|
|
863
|
+
el.style.height = h2 + "px";
|
|
864
|
+
},
|
|
865
|
+
growSize(width, height) {
|
|
866
|
+
const el = this.$el;
|
|
867
|
+
el.style.height = height + "px";
|
|
868
|
+
el.style.width = width + "px";
|
|
869
|
+
},
|
|
870
|
+
unfreezeSize() {
|
|
871
|
+
const el = this.$el;
|
|
872
|
+
el.style.width = "";
|
|
873
|
+
el.style.height = "";
|
|
874
|
+
},
|
|
875
|
+
getInternalScrollElement(element = null) {
|
|
876
|
+
const mightBe = (element ?? this.$el).querySelector("main");
|
|
877
|
+
return mightBe ? mightBe : null;
|
|
878
|
+
},
|
|
879
|
+
getScrollElement(element = null) {
|
|
880
|
+
return document.documentElement;
|
|
881
|
+
},
|
|
882
|
+
shouldAnimate() {
|
|
883
|
+
return this.$el.offsetWidth <= 1e3 && !window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
884
|
+
},
|
|
885
|
+
async push(options) {
|
|
886
|
+
var _a;
|
|
887
|
+
if (options.components.length == 0) {
|
|
888
|
+
console.error("Missing component when pushing");
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
(_a = document.activeElement) == null ? void 0 : _a.blur();
|
|
892
|
+
const components = options.components;
|
|
893
|
+
const component = components[components.length - 1];
|
|
894
|
+
const destroy = options.destroy ?? true;
|
|
895
|
+
const force = options.force ?? false;
|
|
896
|
+
const animated = this.shouldAnimate() ? options.animated === void 0 ? component.animated : options.animated : false;
|
|
897
|
+
let replace = options.replace ?? 0;
|
|
898
|
+
if (replace > this.components.length) {
|
|
899
|
+
replace = this.components.length;
|
|
900
|
+
}
|
|
901
|
+
if (ComponentWithProperties.debug)
|
|
902
|
+
console.log("Pushing new component on navigation controller: " + component.component.name);
|
|
903
|
+
if (replace > 0) {
|
|
904
|
+
if (destroy && !force) {
|
|
905
|
+
for (let index = this.components.length - 1; index >= this.components.length - replace; index--) {
|
|
906
|
+
const component2 = this.components[index];
|
|
907
|
+
const r = await component2.shouldNavigateAway();
|
|
908
|
+
if (!r) {
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
if (!animated) {
|
|
915
|
+
this.transitionName = "none";
|
|
916
|
+
} else {
|
|
917
|
+
this.transitionName = this.animationType == "modal" ? "modal-push" : options.reverse ? "pop" : "push";
|
|
918
|
+
}
|
|
919
|
+
const internalScrollElement = this.getInternalScrollElement();
|
|
920
|
+
const scrollElement = this.getScrollElement();
|
|
921
|
+
const w = window;
|
|
922
|
+
let clientHeight = scrollElement.clientHeight;
|
|
923
|
+
if (scrollElement === document.documentElement && w.visualViewport) {
|
|
924
|
+
clientHeight = w.visualViewport.height;
|
|
925
|
+
}
|
|
926
|
+
const internalClientHeight = internalScrollElement == null ? void 0 : internalScrollElement.clientHeight;
|
|
927
|
+
this.previousScrollPosition = 0;
|
|
928
|
+
this.savedScrollPositions.push(this.previousScrollPosition + clientHeight);
|
|
929
|
+
this.savedInternalScrollPositions.push(((internalScrollElement == null ? void 0 : internalScrollElement.scrollTop) ?? 0) + (internalClientHeight ?? 0));
|
|
930
|
+
this.nextScrollPosition = 0;
|
|
931
|
+
this.nextInternalScrollPosition = 0;
|
|
932
|
+
if (animated) {
|
|
933
|
+
this.freezeSize();
|
|
934
|
+
}
|
|
935
|
+
if (replace > 0) {
|
|
936
|
+
const popped = this.components.splice(this.components.length - replace, replace, ...components);
|
|
937
|
+
if (!destroy) {
|
|
938
|
+
for (const comp of popped) {
|
|
939
|
+
comp.keepAlive = true;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
} else {
|
|
943
|
+
this.components.push(...components);
|
|
944
|
+
}
|
|
945
|
+
if (this.mainComponent) {
|
|
946
|
+
this.mainComponent.keepAlive = !replace;
|
|
947
|
+
}
|
|
948
|
+
this.mainComponent = component;
|
|
949
|
+
this.$emit("didPush");
|
|
950
|
+
if (replace == 0 && this) {
|
|
951
|
+
for (let index = 0; index < components.length; index++) {
|
|
952
|
+
HistoryManager.pushState(options == null ? void 0 : options.url, (canAnimate) => {
|
|
953
|
+
this.pop({ animated: animated && canAnimate });
|
|
954
|
+
}, (options == null ? void 0 : options.adjustHistory) ?? true);
|
|
955
|
+
if (index < components.length - 1) {
|
|
956
|
+
components[index].assignHistoryIndex();
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
async shouldNavigateAway() {
|
|
962
|
+
for (let index = this.components.length - 1; index >= 0; index--) {
|
|
963
|
+
const component = this.components[index];
|
|
964
|
+
const r = await component.shouldNavigateAway();
|
|
965
|
+
if (!r) {
|
|
966
|
+
return false;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return true;
|
|
970
|
+
},
|
|
971
|
+
popToRoot(options = {}) {
|
|
972
|
+
options.count = this.components.length - 1;
|
|
973
|
+
return this.pop(options);
|
|
974
|
+
},
|
|
975
|
+
getPoppableParent() {
|
|
976
|
+
let prev = this.$;
|
|
977
|
+
let start = this.$.parent;
|
|
978
|
+
while (start) {
|
|
979
|
+
if (prev.props.onPop) {
|
|
980
|
+
return prev;
|
|
981
|
+
}
|
|
982
|
+
prev = start;
|
|
983
|
+
start = start.parent;
|
|
984
|
+
}
|
|
985
|
+
return null;
|
|
986
|
+
},
|
|
987
|
+
async pop(options = {}) {
|
|
988
|
+
var _a;
|
|
989
|
+
(_a = document.activeElement) == null ? void 0 : _a.blur();
|
|
990
|
+
const animated = this.shouldAnimate() ? options.animated ?? true : false;
|
|
991
|
+
const destroy = options.destroy ?? true;
|
|
992
|
+
const count = options.count ?? 1;
|
|
993
|
+
const force = options.force ?? false;
|
|
994
|
+
if (this.components.length <= count) {
|
|
995
|
+
const parent = this.getPoppableParent();
|
|
996
|
+
options.count = 1;
|
|
997
|
+
if (!parent) {
|
|
998
|
+
console.error("Tried to pop an empty navigation controller, but couldn't find a parent to pop");
|
|
999
|
+
this.$.emit("pop", options);
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
parent.emit("pop", options);
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
if (count === 0) {
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
if (destroy && !force) {
|
|
1009
|
+
for (let index = this.components.length - 1; index >= this.components.length - count; index--) {
|
|
1010
|
+
const component = this.components[index];
|
|
1011
|
+
const r = await component.shouldNavigateAway();
|
|
1012
|
+
if (!r) {
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
this.previousScrollPosition = 0;
|
|
1018
|
+
if (!animated) {
|
|
1019
|
+
this.transitionName = "none";
|
|
1020
|
+
} else {
|
|
1021
|
+
this.transitionName = this.animationType == "modal" ? "modal-pop" : "pop";
|
|
1022
|
+
this.freezeSize();
|
|
1023
|
+
}
|
|
1024
|
+
const popped = this.components.splice(this.components.length - count, count);
|
|
1025
|
+
if (!destroy) {
|
|
1026
|
+
for (const comp of popped) {
|
|
1027
|
+
comp.keepAlive = true;
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
this.nextScrollPosition = 0;
|
|
1031
|
+
this.nextInternalScrollPosition = Math.max(0, this.savedInternalScrollPositions.pop() ?? 0);
|
|
1032
|
+
this.mainComponent = this.components[this.components.length - 1];
|
|
1033
|
+
this.$emit("didPop");
|
|
1034
|
+
return popped;
|
|
1035
|
+
},
|
|
1036
|
+
beforeEnter(insertedElement) {
|
|
1037
|
+
if (this.transitionName == "none") {
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
insertedElement.className = this.transitionName + "-enter-active " + this.transitionName + "-enter";
|
|
1041
|
+
},
|
|
1042
|
+
beforeLeave(_element) {
|
|
1043
|
+
if (this.transitionName == "none") {
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
},
|
|
1047
|
+
beforeBeforeEnterAnimation() {
|
|
1048
|
+
if (this.mainComponent) {
|
|
1049
|
+
const instance = this.mainComponent.componentInstance();
|
|
1050
|
+
if (instance && instance.beforeBeforeEnterAnimation) {
|
|
1051
|
+
instance.beforeBeforeEnterAnimation();
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
},
|
|
1055
|
+
finishedEnterAnimation() {
|
|
1056
|
+
if (this.mainComponent) {
|
|
1057
|
+
const instance = this.mainComponent.componentInstance();
|
|
1058
|
+
if (instance && instance.finishedEnterAnimation) {
|
|
1059
|
+
instance.finishedEnterAnimation();
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
enter(element, done) {
|
|
1064
|
+
if (this.transitionName == "none") {
|
|
1065
|
+
this.getScrollElement().scrollTop = this.nextScrollPosition;
|
|
1066
|
+
const internal = this.getInternalScrollElement(element);
|
|
1067
|
+
if (internal) {
|
|
1068
|
+
internal.scrollTop = Math.max(0, this.nextInternalScrollPosition - internal.clientHeight);
|
|
1069
|
+
}
|
|
1070
|
+
done();
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
requestAnimationFrame(() => {
|
|
1074
|
+
const w = element.firstElementChild.firstElementChild.offsetWidth;
|
|
1075
|
+
const h2 = element.firstElementChild.offsetHeight;
|
|
1076
|
+
const internal = this.getInternalScrollElement(element);
|
|
1077
|
+
let nextInternal = this.nextInternalScrollPosition;
|
|
1078
|
+
if (internal) {
|
|
1079
|
+
nextInternal = Math.max(0, this.nextInternalScrollPosition - internal.clientHeight);
|
|
1080
|
+
const scrollOuterHeight = this.getScrollOuterHeight(internal);
|
|
1081
|
+
const h22 = internal.scrollHeight;
|
|
1082
|
+
if (nextInternal > h22 - scrollOuterHeight) {
|
|
1083
|
+
nextInternal = Math.max(0, h22 - scrollOuterHeight);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
const childElement = element.firstElementChild;
|
|
1087
|
+
let transitionDuration = 300;
|
|
1088
|
+
if (this.transitionName === "pop" || this.transitionName == "modal-pop") {
|
|
1089
|
+
transitionDuration = 250;
|
|
1090
|
+
}
|
|
1091
|
+
if (this.transitionName == "push" || this.transitionName == "pop" || this.transitionName == "modal-push") {
|
|
1092
|
+
childElement.style.willChange = "transform";
|
|
1093
|
+
}
|
|
1094
|
+
if (internal) {
|
|
1095
|
+
internal.style.willChange = "scroll-position";
|
|
1096
|
+
}
|
|
1097
|
+
this.growSize(w, h2);
|
|
1098
|
+
requestAnimationFrame(() => {
|
|
1099
|
+
if (internal) {
|
|
1100
|
+
internal.scrollTop = nextInternal;
|
|
1101
|
+
}
|
|
1102
|
+
element.className = this.transitionName + "-enter-active " + this.transitionName + "-enter-to";
|
|
1103
|
+
setTimeout(() => {
|
|
1104
|
+
element.style.willChange = "";
|
|
1105
|
+
childElement.style.willChange = "";
|
|
1106
|
+
if (internal) {
|
|
1107
|
+
internal.style.willChange = "";
|
|
1108
|
+
}
|
|
1109
|
+
done();
|
|
1110
|
+
}, transitionDuration + 25);
|
|
1111
|
+
});
|
|
1112
|
+
});
|
|
1113
|
+
},
|
|
1114
|
+
getScrollOuterHeight(scrollElement) {
|
|
1115
|
+
let h2 = scrollElement.clientHeight;
|
|
1116
|
+
if (scrollElement === document.documentElement) {
|
|
1117
|
+
const w = window;
|
|
1118
|
+
if (w.visualViewport) {
|
|
1119
|
+
h2 = w.visualViewport.height;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
return h2;
|
|
1123
|
+
},
|
|
1124
|
+
leave(element, done) {
|
|
1125
|
+
if (this.transitionName == "none") {
|
|
1126
|
+
done();
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
const childElement = element.firstElementChild;
|
|
1130
|
+
childElement.style.willChange = "transform";
|
|
1131
|
+
let transitionDuration = 300;
|
|
1132
|
+
if (this.transitionName === "pop" || this.transitionName == "modal-pop") {
|
|
1133
|
+
transitionDuration = 250;
|
|
1134
|
+
}
|
|
1135
|
+
requestAnimationFrame(() => {
|
|
1136
|
+
const h2 = this.$el.offsetHeight;
|
|
1137
|
+
const w = this.$el.offsetWidth;
|
|
1138
|
+
const height = h2 + "px";
|
|
1139
|
+
const width = w + "px";
|
|
1140
|
+
element.className = this.transitionName + "-leave-active " + this.transitionName + "-leave";
|
|
1141
|
+
element.style.top = "0px";
|
|
1142
|
+
element.style.height = height;
|
|
1143
|
+
element.style.width = width;
|
|
1144
|
+
element.style.bottom = "auto";
|
|
1145
|
+
element.style.overflow = "hidden";
|
|
1146
|
+
childElement.style.overflow = "hidden";
|
|
1147
|
+
childElement.style.height = height;
|
|
1148
|
+
childElement.style.width = width;
|
|
1149
|
+
requestAnimationFrame(() => {
|
|
1150
|
+
element.className = this.transitionName + "-leave-active " + this.transitionName + "-leave-to";
|
|
1151
|
+
setTimeout(() => {
|
|
1152
|
+
element.style.overflow = "";
|
|
1153
|
+
element.style.top = "";
|
|
1154
|
+
element.style.height = "";
|
|
1155
|
+
element.style.bottom = "";
|
|
1156
|
+
childElement.style.overflow = "";
|
|
1157
|
+
childElement.style.willChange = "";
|
|
1158
|
+
done();
|
|
1159
|
+
}, transitionDuration + 25);
|
|
1160
|
+
});
|
|
1161
|
+
});
|
|
1162
|
+
},
|
|
1163
|
+
afterLeave(element) {
|
|
1164
|
+
if (this.transitionName == "none") {
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
element.className = "";
|
|
1168
|
+
},
|
|
1169
|
+
afterEnter(element) {
|
|
1170
|
+
if (this.transitionName == "none") {
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
this.unfreezeSize();
|
|
1174
|
+
element.className = "";
|
|
1175
|
+
},
|
|
1176
|
+
enterCancelled(_element) {
|
|
1177
|
+
this.unfreezeSize();
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
const _hoisted_1$3 = { class: "navigation-controller" };
|
|
1182
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1183
|
+
const _component_FramedComponent = resolveComponent("FramedComponent");
|
|
1184
|
+
return openBlock(), createElementBlock("div", _hoisted_1$3, [
|
|
1185
|
+
$data.mainComponent ? (openBlock(), createBlock(Transition, {
|
|
1186
|
+
key: 0,
|
|
1187
|
+
css: false,
|
|
1188
|
+
onBeforeEnter: $options.beforeEnter,
|
|
1189
|
+
onBeforeLeave: $options.beforeLeave,
|
|
1190
|
+
onEnter: $options.enter,
|
|
1191
|
+
onLeave: $options.leave,
|
|
1192
|
+
onAfterLeave: $options.afterLeave,
|
|
1193
|
+
onAfterEnter: $options.afterEnter,
|
|
1194
|
+
onEnterCancelled: $options.enterCancelled
|
|
1195
|
+
}, {
|
|
1196
|
+
default: withCtx(() => [
|
|
1197
|
+
(openBlock(), createBlock(_component_FramedComponent, {
|
|
1198
|
+
key: $data.mainComponent.key,
|
|
1199
|
+
ref: "child",
|
|
1200
|
+
root: $data.mainComponent,
|
|
1201
|
+
onPush: $options.push,
|
|
1202
|
+
onShow: $options.push,
|
|
1203
|
+
onPop: $options.pop
|
|
1204
|
+
}, null, 8, ["root", "onPush", "onShow", "onPop"]))
|
|
1205
|
+
]),
|
|
1206
|
+
_: 1
|
|
1207
|
+
}, 8, ["onBeforeEnter", "onBeforeLeave", "onEnter", "onLeave", "onAfterLeave", "onAfterEnter", "onEnterCancelled"])) : createCommentVNode("", true)
|
|
1208
|
+
]);
|
|
1209
|
+
}
|
|
1210
|
+
const NavigationController = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$5]]);
|
|
1211
|
+
const _hoisted_1$2 = { class: "scrollable-container" };
|
|
1212
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
1213
|
+
__name: "Popup",
|
|
1214
|
+
props: {
|
|
1215
|
+
root: {},
|
|
1216
|
+
className: { default: "popup" }
|
|
1217
|
+
},
|
|
1218
|
+
setup(__props, { expose: __expose }) {
|
|
1219
|
+
const instance = getCurrentInstance();
|
|
1220
|
+
const Popup = instance.type;
|
|
1221
|
+
const props = __props;
|
|
1222
|
+
const shouldAppear = props.root.animated;
|
|
1223
|
+
const modalStackComponent = useModalStackComponent();
|
|
1224
|
+
const pop = usePop();
|
|
1225
|
+
const mainContent = ref(null);
|
|
1226
|
+
const component = useCurrentComponent();
|
|
1227
|
+
provide("reactive_navigation_dismiss", async (options) => {
|
|
1228
|
+
return await dismiss(options);
|
|
1229
|
+
});
|
|
1230
|
+
provide("reactive_navigation_pop", async (options) => {
|
|
1231
|
+
console.warn("Using .pop() inside a Popup without a NavigationController dismisses the Popup. It is recommended to use .dismiss() instead.");
|
|
1232
|
+
return await dismiss(options);
|
|
1233
|
+
});
|
|
1234
|
+
provide("reactive_popup", instance == null ? void 0 : instance.proxy);
|
|
1235
|
+
const pushDown = computed(() => {
|
|
1236
|
+
var _a;
|
|
1237
|
+
const popups = ((_a = modalStackComponent.value.stackComponent) == null ? void 0 : _a.components.filter((c) => c.component === Popup && (c.properties.className ?? "popup") === (props.className ?? "popup"))) ?? [];
|
|
1238
|
+
if (popups.length > 0 && popups[popups.length - 1] !== component) {
|
|
1239
|
+
if (popups.length > 1 && popups[popups.length - 2] === component) {
|
|
1240
|
+
return 1;
|
|
1241
|
+
}
|
|
1242
|
+
return 2;
|
|
1243
|
+
}
|
|
1244
|
+
return 0;
|
|
1245
|
+
});
|
|
1246
|
+
const buildClass = computed(() => {
|
|
1247
|
+
const vvv = { "push-down": pushDown.value == 1, "push-down-full": pushDown.value > 1 };
|
|
1248
|
+
const j = Object.keys(vvv).filter((p) => !!vvv[p]).join(" ");
|
|
1249
|
+
return j + (j ? " " : "") + (props.className ? props.className : "popup");
|
|
1250
|
+
});
|
|
1251
|
+
const isFocused = computed(() => {
|
|
1252
|
+
var _a;
|
|
1253
|
+
const popups = ((_a = modalStackComponent.value.stackComponent) == null ? void 0 : _a.components) ?? [];
|
|
1254
|
+
if (popups.length > 0 && popups[popups.length - 1] !== component) {
|
|
1255
|
+
return false;
|
|
1256
|
+
}
|
|
1257
|
+
return true;
|
|
1258
|
+
});
|
|
1259
|
+
provide("reactive_navigation_focused", isFocused);
|
|
1260
|
+
const onKey = (event) => {
|
|
1261
|
+
if (event.defaultPrevented || event.repeat) {
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
if (!isFocused.value) {
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
const key = event.key || event.keyCode;
|
|
1268
|
+
if (key === "Escape" || key === "Esc" || key === 27) {
|
|
1269
|
+
dismiss().catch(console.error);
|
|
1270
|
+
event.preventDefault();
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
const shouldNavigateAway = () => {
|
|
1274
|
+
return props.root.shouldNavigateAway();
|
|
1275
|
+
};
|
|
1276
|
+
const dismiss = async (options) => {
|
|
1277
|
+
var _a;
|
|
1278
|
+
if (!(options == null ? void 0 : options.force)) {
|
|
1279
|
+
const r = await shouldNavigateAway();
|
|
1280
|
+
if (!r) {
|
|
1281
|
+
return false;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
const popups = ((_a = modalStackComponent.value.stackComponent) == null ? void 0 : _a.components.filter((c) => c.modalDisplayStyle !== "overlay")) ?? [];
|
|
1285
|
+
if (popups.length === 0 || popups[popups.length - 1] === component) {
|
|
1286
|
+
const index = props.root.getHistoryIndex();
|
|
1287
|
+
if (index !== null && index !== void 0) {
|
|
1288
|
+
HistoryManager.returnToHistoryIndex(index - 1);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
pop(options);
|
|
1292
|
+
};
|
|
1293
|
+
const onClick = (event) => {
|
|
1294
|
+
if (mainContent.value && !mainContent.value.contains(event.target) && document.body.contains(event.target)) {
|
|
1295
|
+
dismiss().catch(console.error);
|
|
1296
|
+
event.preventDefault();
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1299
|
+
onActivated(() => {
|
|
1300
|
+
document.addEventListener("keydown", onKey);
|
|
1301
|
+
});
|
|
1302
|
+
onDeactivated(() => {
|
|
1303
|
+
document.removeEventListener("keydown", onKey);
|
|
1304
|
+
});
|
|
1305
|
+
__expose({
|
|
1306
|
+
dismiss: shallowRef(dismiss),
|
|
1307
|
+
pop: shallowRef(dismiss)
|
|
1308
|
+
});
|
|
1309
|
+
return (_ctx, _cache) => {
|
|
1310
|
+
return openBlock(), createBlock(Transition, {
|
|
1311
|
+
appear: unref(shouldAppear),
|
|
1312
|
+
name: "fade",
|
|
1313
|
+
duration: 300
|
|
1314
|
+
}, {
|
|
1315
|
+
default: withCtx(() => [
|
|
1316
|
+
createElementVNode("div", {
|
|
1317
|
+
class: normalizeClass(buildClass.value),
|
|
1318
|
+
onClick
|
|
1319
|
+
}, [
|
|
1320
|
+
createElementVNode("div", {
|
|
1321
|
+
ref_key: "mainContent",
|
|
1322
|
+
ref: mainContent
|
|
1323
|
+
}, [
|
|
1324
|
+
createElementVNode("div", _hoisted_1$2, [
|
|
1325
|
+
(openBlock(), createBlock(unref(ComponentWithPropertiesInstance), {
|
|
1326
|
+
key: _ctx.root.key,
|
|
1327
|
+
component: _ctx.root,
|
|
1328
|
+
onPop: dismiss
|
|
1329
|
+
}, null, 8, ["component"]))
|
|
1330
|
+
])
|
|
1331
|
+
], 512)
|
|
1332
|
+
], 2)
|
|
1333
|
+
]),
|
|
1334
|
+
_: 1
|
|
1335
|
+
}, 8, ["appear"]);
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
const StackComponent$1 = defineComponent({
|
|
1340
|
+
components: {
|
|
1341
|
+
ComponentWithPropertiesInstance
|
|
1342
|
+
},
|
|
1343
|
+
emits: ["present"],
|
|
1344
|
+
data() {
|
|
1345
|
+
return {
|
|
1346
|
+
components: []
|
|
1347
|
+
};
|
|
1348
|
+
},
|
|
1349
|
+
beforeUnmount() {
|
|
1350
|
+
this.components = [];
|
|
1351
|
+
},
|
|
1352
|
+
methods: {
|
|
1353
|
+
getCustomProvide(index, key) {
|
|
1354
|
+
return {
|
|
1355
|
+
reactive_navigation_pop: () => {
|
|
1356
|
+
this.removeAt(index, key);
|
|
1357
|
+
},
|
|
1358
|
+
reactive_navigation_dismiss: () => {
|
|
1359
|
+
console.warn("Avoid calling dismiss in components on the StackComponent, since options are not supported here");
|
|
1360
|
+
this.removeAt(index, key);
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
},
|
|
1364
|
+
show(component) {
|
|
1365
|
+
this.components.push(component);
|
|
1366
|
+
},
|
|
1367
|
+
removeAt(index, key) {
|
|
1368
|
+
if (!this.components[index]) {
|
|
1369
|
+
for (const [i, comp] of this.components.entries()) {
|
|
1370
|
+
if (comp.key === key) {
|
|
1371
|
+
console.warn("Corrected index from " + index + " to " + i);
|
|
1372
|
+
index = i;
|
|
1373
|
+
break;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
if (this.components[index] !== void 0 && this.components[index].key === key) {
|
|
1378
|
+
this.components.splice(index, 1);
|
|
1379
|
+
} else {
|
|
1380
|
+
console.warn("Expected component with key " + key + " at index" + index);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1386
|
+
const _component_ComponentWithPropertiesInstance = resolveComponent("ComponentWithPropertiesInstance");
|
|
1387
|
+
return openBlock(), createElementBlock("div", null, [
|
|
1388
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.components, (component, index) => {
|
|
1389
|
+
return openBlock(), createBlock(_component_ComponentWithPropertiesInstance, {
|
|
1390
|
+
key: component.key,
|
|
1391
|
+
ref_for: true,
|
|
1392
|
+
ref: "children",
|
|
1393
|
+
component,
|
|
1394
|
+
"custom-provide": _ctx.getCustomProvide(index, component.key),
|
|
1395
|
+
onPop: ($event) => _ctx.removeAt(index, component.key)
|
|
1396
|
+
}, null, 8, ["component", "custom-provide", "onPop"]);
|
|
1397
|
+
}), 128))
|
|
1398
|
+
]);
|
|
1399
|
+
}
|
|
1400
|
+
const StackComponent = /* @__PURE__ */ _export_sfc(StackComponent$1, [["render", _sfc_render$4]]);
|
|
1401
|
+
function useModalStackComponent() {
|
|
1402
|
+
const c = inject("reactive_modalStackComponent");
|
|
1403
|
+
return shallowRef(c);
|
|
1404
|
+
}
|
|
1405
|
+
const ModalStackComponent$1 = defineComponent({
|
|
1406
|
+
components: {
|
|
1407
|
+
"NavigationController": NavigationController,
|
|
1408
|
+
"StackComponent": StackComponent
|
|
1409
|
+
},
|
|
1410
|
+
provide() {
|
|
1411
|
+
return {
|
|
1412
|
+
reactive_modalStackComponent: this,
|
|
1413
|
+
reactive_navigation_present: this.present
|
|
1414
|
+
};
|
|
1415
|
+
},
|
|
1416
|
+
props: {
|
|
1417
|
+
root: {
|
|
1418
|
+
required: true,
|
|
1419
|
+
type: Object
|
|
1420
|
+
},
|
|
1421
|
+
initialComponents: {
|
|
1422
|
+
default: null,
|
|
1423
|
+
type: Object
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
computed: {
|
|
1427
|
+
stackComponent() {
|
|
1428
|
+
return this.$refs["stackComponent"];
|
|
1429
|
+
},
|
|
1430
|
+
navigationController() {
|
|
1431
|
+
return this.$refs["navigationController"];
|
|
1432
|
+
}
|
|
1433
|
+
},
|
|
1434
|
+
//extends: NavigationMixin,
|
|
1435
|
+
methods: {
|
|
1436
|
+
present(options) {
|
|
1437
|
+
console.log("ModalStackComponent.present", options, this.$el, this.$el.offsetWidth);
|
|
1438
|
+
const component = options.components[options.components.length - 1];
|
|
1439
|
+
if (options.animated !== void 0) {
|
|
1440
|
+
component.animated = options.animated;
|
|
1441
|
+
}
|
|
1442
|
+
const style = options.modalDisplayStyle ?? component.modalDisplayStyle ?? "cover";
|
|
1443
|
+
component.setDisplayStyle(style);
|
|
1444
|
+
if ((style === "popup" || style === "sheet" || style === "side-view") && this.$el.offsetWidth > 800 || style === "sheet" && this.$el.offsetWidth > 700) {
|
|
1445
|
+
const c = new ComponentWithProperties(_sfc_main$2, { root: component, className: options.modalClass ?? style });
|
|
1446
|
+
HistoryManager.pushState(options == null ? void 0 : options.url, (canAnimate) => {
|
|
1447
|
+
var _a;
|
|
1448
|
+
console.log(c.componentInstance());
|
|
1449
|
+
(_a = c.componentInstance()) == null ? void 0 : _a.pop({ animated: canAnimate });
|
|
1450
|
+
}, (options == null ? void 0 : options.adjustHistory) ?? true);
|
|
1451
|
+
this.stackComponent.show(c);
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
if (style === "overlay") {
|
|
1455
|
+
this.stackComponent.show(component);
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
this.navigationController.push(options);
|
|
1459
|
+
},
|
|
1460
|
+
replace(component, animated = true) {
|
|
1461
|
+
const nav = this.navigationController;
|
|
1462
|
+
nav.push({ components: [component], animated, replace: nav.components.length });
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1467
|
+
const _component_NavigationController = resolveComponent("NavigationController");
|
|
1468
|
+
const _component_StackComponent = resolveComponent("StackComponent");
|
|
1469
|
+
return openBlock(), createElementBlock("div", null, [
|
|
1470
|
+
createVNode(_component_NavigationController, {
|
|
1471
|
+
ref: "navigationController",
|
|
1472
|
+
"animation-type": "modal",
|
|
1473
|
+
root: _ctx.root,
|
|
1474
|
+
"initial-components": _ctx.initialComponents,
|
|
1475
|
+
onPresent: _ctx.present
|
|
1476
|
+
}, null, 8, ["root", "initial-components", "onPresent"]),
|
|
1477
|
+
createVNode(_component_StackComponent, {
|
|
1478
|
+
ref: "stackComponent",
|
|
1479
|
+
onPresent: _ctx.present
|
|
1480
|
+
}, null, 8, ["onPresent"])
|
|
1481
|
+
]);
|
|
1482
|
+
}
|
|
1483
|
+
const ModalStackComponent = /* @__PURE__ */ _export_sfc(ModalStackComponent$1, [["render", _sfc_render$3]]);
|
|
1484
|
+
const ModalStackComponentFinderMixin = defineComponent({
|
|
1485
|
+
computed: {
|
|
1486
|
+
modalStackComponent() {
|
|
1487
|
+
let start = this.$parent;
|
|
1488
|
+
while (start) {
|
|
1489
|
+
if (start instanceof ModalStackComponent) {
|
|
1490
|
+
return start;
|
|
1491
|
+
}
|
|
1492
|
+
start = start.$parent;
|
|
1493
|
+
}
|
|
1494
|
+
return null;
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
});
|
|
1498
|
+
const ModalMixin = defineComponent({
|
|
1499
|
+
extends: ModalStackComponentFinderMixin,
|
|
1500
|
+
methods: {
|
|
1501
|
+
pop(options = {}) {
|
|
1502
|
+
const nav = this.getPoppableParent();
|
|
1503
|
+
if (nav) {
|
|
1504
|
+
if (nav.props.onPop) {
|
|
1505
|
+
nav.emit("pop", options);
|
|
1506
|
+
} else {
|
|
1507
|
+
console.error("Couldn't pop. Failed");
|
|
1508
|
+
}
|
|
1509
|
+
} else {
|
|
1510
|
+
console.warn("No navigation controller to pop");
|
|
1511
|
+
}
|
|
1512
|
+
},
|
|
1513
|
+
getPoppableParent() {
|
|
1514
|
+
let prev = this.$;
|
|
1515
|
+
let start = this.$.parent;
|
|
1516
|
+
while (start) {
|
|
1517
|
+
if (prev.props.onPop) {
|
|
1518
|
+
return prev;
|
|
1519
|
+
}
|
|
1520
|
+
prev = start;
|
|
1521
|
+
start = start.parent;
|
|
1522
|
+
}
|
|
1523
|
+
return null;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
const _sfc_main$1 = defineComponent({
|
|
1528
|
+
components: {
|
|
1529
|
+
ComponentWithPropertiesInstance
|
|
1530
|
+
},
|
|
1531
|
+
extends: ModalMixin,
|
|
1532
|
+
props: {
|
|
1533
|
+
root: {
|
|
1534
|
+
required: true,
|
|
1535
|
+
type: Object
|
|
1536
|
+
}
|
|
1537
|
+
},
|
|
1538
|
+
computed: {
|
|
1539
|
+
shouldAppear() {
|
|
1540
|
+
return this.root.animated;
|
|
1541
|
+
},
|
|
1542
|
+
isFocused() {
|
|
1543
|
+
var _a, _b;
|
|
1544
|
+
const popups = ((_b = (_a = this.modalStackComponent) == null ? void 0 : _a.stackComponent) == null ? void 0 : _b.components) ?? [];
|
|
1545
|
+
if (popups.length > 0 && popups[popups.length - 1].componentInstance() !== this) {
|
|
1546
|
+
return false;
|
|
1547
|
+
}
|
|
1548
|
+
return true;
|
|
1549
|
+
}
|
|
1550
|
+
},
|
|
1551
|
+
activated() {
|
|
1552
|
+
document.addEventListener("keydown", this.onKey);
|
|
1553
|
+
},
|
|
1554
|
+
deactivated() {
|
|
1555
|
+
document.removeEventListener("keydown", this.onKey);
|
|
1556
|
+
},
|
|
1557
|
+
methods: {
|
|
1558
|
+
onClick(event) {
|
|
1559
|
+
const mainContent = this.$refs.mainContent;
|
|
1560
|
+
if (mainContent && !mainContent.contains(event.target) && document.body.contains(event.target)) {
|
|
1561
|
+
this.dismiss().catch(console.error);
|
|
1562
|
+
event.preventDefault();
|
|
1563
|
+
}
|
|
1564
|
+
},
|
|
1565
|
+
async dismiss(options) {
|
|
1566
|
+
var _a, _b;
|
|
1567
|
+
if (!(options == null ? void 0 : options.force)) {
|
|
1568
|
+
const r = await this.shouldNavigateAway();
|
|
1569
|
+
if (!r) {
|
|
1570
|
+
return false;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
const popups = ((_b = (_a = this.modalStackComponent) == null ? void 0 : _a.stackComponent) == null ? void 0 : _b.components.filter((c) => c.modalDisplayStyle !== "overlay")) ?? [];
|
|
1574
|
+
if (popups.length === 0 || popups[popups.length - 1].componentInstance() === this) {
|
|
1575
|
+
const index = this.root.getHistoryIndex();
|
|
1576
|
+
if (index !== null && index !== void 0) {
|
|
1577
|
+
HistoryManager.returnToHistoryIndex(index - 1);
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
this.pop(options);
|
|
1581
|
+
},
|
|
1582
|
+
onKey(event) {
|
|
1583
|
+
if (event.defaultPrevented || event.repeat) {
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
if (!this.isFocused) {
|
|
1587
|
+
return;
|
|
1588
|
+
}
|
|
1589
|
+
const key = event.key || event.keyCode;
|
|
1590
|
+
if (key === "Escape" || key === "Esc" || key === 27) {
|
|
1591
|
+
this.dismiss().catch(console.error);
|
|
1592
|
+
event.preventDefault();
|
|
1593
|
+
}
|
|
1594
|
+
},
|
|
1595
|
+
shouldNavigateAway() {
|
|
1596
|
+
return this.root.shouldNavigateAway();
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
});
|
|
1600
|
+
const _hoisted_1$1 = { ref: "mainContent" };
|
|
1601
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1602
|
+
const _component_ComponentWithPropertiesInstance = resolveComponent("ComponentWithPropertiesInstance");
|
|
1603
|
+
return openBlock(), createBlock(Transition, {
|
|
1604
|
+
appear: _ctx.shouldAppear,
|
|
1605
|
+
name: "fade",
|
|
1606
|
+
duration: 300
|
|
1607
|
+
}, {
|
|
1608
|
+
default: withCtx(() => [
|
|
1609
|
+
createElementVNode("div", {
|
|
1610
|
+
class: "sheet",
|
|
1611
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
1612
|
+
}, [
|
|
1613
|
+
createElementVNode("div", _hoisted_1$1, [
|
|
1614
|
+
(openBlock(), createBlock(_component_ComponentWithPropertiesInstance, {
|
|
1615
|
+
key: _ctx.root.key,
|
|
1616
|
+
component: _ctx.root,
|
|
1617
|
+
onPop: _ctx.dismiss
|
|
1618
|
+
}, null, 8, ["component", "onPop"]))
|
|
1619
|
+
], 512)
|
|
1620
|
+
])
|
|
1621
|
+
]),
|
|
1622
|
+
_: 1
|
|
1623
|
+
}, 8, ["appear"]);
|
|
1624
|
+
}
|
|
1625
|
+
const Sheet = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$2]]);
|
|
1626
|
+
const visualViewport = window.visualViewport;
|
|
1627
|
+
const SideView$1 = defineComponent({
|
|
1628
|
+
components: {
|
|
1629
|
+
ComponentWithPropertiesInstance
|
|
1630
|
+
},
|
|
1631
|
+
extends: ModalMixin,
|
|
1632
|
+
props: {
|
|
1633
|
+
root: {
|
|
1634
|
+
required: true,
|
|
1635
|
+
type: Object
|
|
1636
|
+
}
|
|
1637
|
+
},
|
|
1638
|
+
computed: {
|
|
1639
|
+
shouldAppear() {
|
|
1640
|
+
return this.root.animated;
|
|
1641
|
+
},
|
|
1642
|
+
pushDown() {
|
|
1643
|
+
var _a, _b;
|
|
1644
|
+
const sideViews = ((_b = (_a = this.modalStackComponent) == null ? void 0 : _a.stackComponent) == null ? void 0 : _b.components.filter((c) => c.component === SideView$1)) ?? [];
|
|
1645
|
+
if (sideViews.length > 0 && sideViews[sideViews.length - 1].componentInstance() !== this) {
|
|
1646
|
+
if (sideViews.length > 1 && sideViews[sideViews.length - 2].componentInstance() === this) {
|
|
1647
|
+
return 1;
|
|
1648
|
+
}
|
|
1649
|
+
return 2;
|
|
1650
|
+
}
|
|
1651
|
+
return 0;
|
|
1652
|
+
},
|
|
1653
|
+
isFocused() {
|
|
1654
|
+
var _a, _b;
|
|
1655
|
+
const sideViews = ((_b = (_a = this.modalStackComponent) == null ? void 0 : _a.stackComponent) == null ? void 0 : _b.components) ?? [];
|
|
1656
|
+
if (sideViews.length > 0 && sideViews[sideViews.length - 1].componentInstance() !== this) {
|
|
1657
|
+
return false;
|
|
1658
|
+
}
|
|
1659
|
+
return true;
|
|
1660
|
+
}
|
|
1661
|
+
},
|
|
1662
|
+
activated() {
|
|
1663
|
+
document.addEventListener("keydown", this.onKey);
|
|
1664
|
+
this.resize();
|
|
1665
|
+
if (visualViewport) {
|
|
1666
|
+
visualViewport.addEventListener("resize", this.resize);
|
|
1667
|
+
}
|
|
1668
|
+
},
|
|
1669
|
+
deactivated() {
|
|
1670
|
+
document.removeEventListener("keydown", this.onKey);
|
|
1671
|
+
if (visualViewport) {
|
|
1672
|
+
visualViewport.removeEventListener("resize", this.resize);
|
|
1673
|
+
}
|
|
1674
|
+
},
|
|
1675
|
+
methods: {
|
|
1676
|
+
async dismiss(options) {
|
|
1677
|
+
var _a, _b;
|
|
1678
|
+
if (!(options == null ? void 0 : options.force)) {
|
|
1679
|
+
const r = await this.shouldNavigateAway();
|
|
1680
|
+
if (!r) {
|
|
1681
|
+
return false;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
const sideViews = ((_b = (_a = this.modalStackComponent) == null ? void 0 : _a.stackComponent) == null ? void 0 : _b.components.filter((c) => c.modalDisplayStyle !== "overlay")) ?? [];
|
|
1685
|
+
if (sideViews.length === 0 || sideViews[sideViews.length - 1].componentInstance() === this) {
|
|
1686
|
+
const index = this.root.getHistoryIndex();
|
|
1687
|
+
if (index !== null && index !== void 0) {
|
|
1688
|
+
HistoryManager.returnToHistoryIndex(index - 1);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
this.pop(options);
|
|
1692
|
+
},
|
|
1693
|
+
resize() {
|
|
1694
|
+
if (!visualViewport) {
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
},
|
|
1698
|
+
onKey(event) {
|
|
1699
|
+
if (event.defaultPrevented || event.repeat) {
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1702
|
+
if (!this.isFocused) {
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
const key = event.key || event.keyCode;
|
|
1706
|
+
if (key === "Escape" || key === "Esc" || key === 27) {
|
|
1707
|
+
this.dismiss().catch(console.error);
|
|
1708
|
+
event.preventDefault();
|
|
1709
|
+
}
|
|
1710
|
+
},
|
|
1711
|
+
shouldNavigateAway() {
|
|
1712
|
+
return this.root.shouldNavigateAway();
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
});
|
|
1716
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1717
|
+
const _component_ComponentWithPropertiesInstance = resolveComponent("ComponentWithPropertiesInstance");
|
|
1718
|
+
return openBlock(), createBlock(Transition, {
|
|
1719
|
+
appear: _ctx.shouldAppear,
|
|
1720
|
+
name: "fade"
|
|
1721
|
+
}, {
|
|
1722
|
+
default: withCtx(() => [
|
|
1723
|
+
createElementVNode("div", {
|
|
1724
|
+
class: normalizeClass(["side-view", { "push-down": _ctx.pushDown == 1, "push-down-full": _ctx.pushDown > 1 }]),
|
|
1725
|
+
onMousedown: _cache[2] || (_cache[2] = ($event) => _ctx.dismiss()),
|
|
1726
|
+
onTouchdown: _cache[3] || (_cache[3] = ($event) => _ctx.dismiss())
|
|
1727
|
+
}, [
|
|
1728
|
+
createElementVNode("div", {
|
|
1729
|
+
onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
1730
|
+
}, ["stop"])),
|
|
1731
|
+
onTouchdown: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
1732
|
+
}, ["stop"]))
|
|
1733
|
+
}, [
|
|
1734
|
+
(openBlock(), createBlock(_component_ComponentWithPropertiesInstance, {
|
|
1735
|
+
key: _ctx.root.key,
|
|
1736
|
+
component: _ctx.root,
|
|
1737
|
+
onPop: _ctx.dismiss
|
|
1738
|
+
}, null, 8, ["component", "onPop"]))
|
|
1739
|
+
], 32)
|
|
1740
|
+
], 34)
|
|
1741
|
+
]),
|
|
1742
|
+
_: 1
|
|
1743
|
+
}, 8, ["appear"]);
|
|
1744
|
+
}
|
|
1745
|
+
const SideView = /* @__PURE__ */ _export_sfc(SideView$1, [["render", _sfc_render$1]]);
|
|
1746
|
+
const throttle = (func, limit) => {
|
|
1747
|
+
let lastFunc;
|
|
1748
|
+
let lastRan;
|
|
1749
|
+
return function() {
|
|
1750
|
+
const context = this;
|
|
1751
|
+
const args = arguments;
|
|
1752
|
+
if (!lastRan) {
|
|
1753
|
+
func.apply(context, args);
|
|
1754
|
+
lastRan = Date.now();
|
|
1755
|
+
} else {
|
|
1756
|
+
clearTimeout(lastFunc);
|
|
1757
|
+
lastFunc = setTimeout(function() {
|
|
1758
|
+
if (Date.now() - lastRan >= limit) {
|
|
1759
|
+
func.apply(context, args);
|
|
1760
|
+
lastRan = Date.now();
|
|
1761
|
+
}
|
|
1762
|
+
}, limit - (Date.now() - lastRan));
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
};
|
|
1766
|
+
const _sfc_main = defineComponent({
|
|
1767
|
+
components: {
|
|
1768
|
+
NavigationController,
|
|
1769
|
+
FramedComponent
|
|
1770
|
+
},
|
|
1771
|
+
provide() {
|
|
1772
|
+
return {
|
|
1773
|
+
reactive_navigation_show_detail: this.showDetail
|
|
1774
|
+
};
|
|
1775
|
+
},
|
|
1776
|
+
props: {
|
|
1777
|
+
root: {
|
|
1778
|
+
required: true,
|
|
1779
|
+
type: Object
|
|
1780
|
+
},
|
|
1781
|
+
rootDetail: {
|
|
1782
|
+
default: null,
|
|
1783
|
+
type: Object
|
|
1784
|
+
},
|
|
1785
|
+
detailWidth: {
|
|
1786
|
+
default: null,
|
|
1787
|
+
type: String
|
|
1788
|
+
}
|
|
1789
|
+
},
|
|
1790
|
+
data() {
|
|
1791
|
+
var _a;
|
|
1792
|
+
return {
|
|
1793
|
+
detail: this.rootDetail,
|
|
1794
|
+
detailKey: ((_a = this.rootDetail) == null ? void 0 : _a.key) ?? null
|
|
1795
|
+
};
|
|
1796
|
+
},
|
|
1797
|
+
computed: {
|
|
1798
|
+
lastIsDetail() {
|
|
1799
|
+
var _a, _b;
|
|
1800
|
+
return this.detailKey != null && ((_b = (_a = this.navigationController) == null ? void 0 : _a.mainComponent) == null ? void 0 : _b.key) == this.detailKey;
|
|
1801
|
+
},
|
|
1802
|
+
navigationController() {
|
|
1803
|
+
return this.$refs["navigationController"];
|
|
1804
|
+
},
|
|
1805
|
+
masterElement() {
|
|
1806
|
+
return this.$refs["masterElement"];
|
|
1807
|
+
}
|
|
1808
|
+
},
|
|
1809
|
+
mounted() {
|
|
1810
|
+
if (this.detailWidth) {
|
|
1811
|
+
this.$el.style.setProperty("--split-view-width", this.detailWidth);
|
|
1812
|
+
}
|
|
1813
|
+
},
|
|
1814
|
+
activated() {
|
|
1815
|
+
this.listener = throttle(this.onResize, 100);
|
|
1816
|
+
window.addEventListener("resize", this.listener, { passive: true });
|
|
1817
|
+
this.onResize();
|
|
1818
|
+
},
|
|
1819
|
+
deactivated() {
|
|
1820
|
+
window.removeEventListener("resize", this.listener, { passive: true });
|
|
1821
|
+
},
|
|
1822
|
+
methods: {
|
|
1823
|
+
onResize() {
|
|
1824
|
+
if (this.shouldCollapse()) {
|
|
1825
|
+
if (this.detail) {
|
|
1826
|
+
this.collapse();
|
|
1827
|
+
}
|
|
1828
|
+
} else {
|
|
1829
|
+
if (this.canExpand()) {
|
|
1830
|
+
this.expand().catch(console.error);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
},
|
|
1834
|
+
getScrollElement(element = null) {
|
|
1835
|
+
if (!element) {
|
|
1836
|
+
element = this.$el;
|
|
1837
|
+
}
|
|
1838
|
+
const style = window.getComputedStyle(element);
|
|
1839
|
+
if (style.overflowY == "scroll" || style.overflow == "scroll" || style.overflow == "auto" || style.overflowY == "auto") {
|
|
1840
|
+
return element;
|
|
1841
|
+
} else {
|
|
1842
|
+
if (!element.parentElement) {
|
|
1843
|
+
return document.documentElement;
|
|
1844
|
+
}
|
|
1845
|
+
return this.getScrollElement(element.parentElement);
|
|
1846
|
+
}
|
|
1847
|
+
},
|
|
1848
|
+
async shouldNavigateAway() {
|
|
1849
|
+
if (this.detail) {
|
|
1850
|
+
const r = await this.detail.shouldNavigateAway();
|
|
1851
|
+
if (!r) {
|
|
1852
|
+
return false;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
if (this.navigationController) {
|
|
1856
|
+
return await this.navigationController.shouldNavigateAway();
|
|
1857
|
+
}
|
|
1858
|
+
return true;
|
|
1859
|
+
},
|
|
1860
|
+
async showDetail(options) {
|
|
1861
|
+
const component = options.components[options.components.length - 1];
|
|
1862
|
+
this.detailKey = component.key;
|
|
1863
|
+
if (this.shouldCollapse()) {
|
|
1864
|
+
if (this.lastIsDetail || this.detail) {
|
|
1865
|
+
console.error("Pusing a detail when a detail is already presented is not allowed");
|
|
1866
|
+
return false;
|
|
1867
|
+
}
|
|
1868
|
+
this.navigationController.push(options);
|
|
1869
|
+
} else {
|
|
1870
|
+
if (this.detail) {
|
|
1871
|
+
const r = await this.detail.shouldNavigateAway();
|
|
1872
|
+
if (!r) {
|
|
1873
|
+
return false;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
this.getScrollElement().scrollTop = 0;
|
|
1877
|
+
this.detail = component;
|
|
1878
|
+
}
|
|
1879
|
+
return true;
|
|
1880
|
+
},
|
|
1881
|
+
shouldCollapse() {
|
|
1882
|
+
return this.$el.offsetWidth < 850;
|
|
1883
|
+
},
|
|
1884
|
+
collapse() {
|
|
1885
|
+
if (!this.navigationController) {
|
|
1886
|
+
console.error("Cannot collapse without navigation controller");
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
if (this.lastIsDetail) {
|
|
1890
|
+
console.error("Cannot collapse when the detail is already collaped");
|
|
1891
|
+
return;
|
|
1892
|
+
}
|
|
1893
|
+
if (!this.detail) {
|
|
1894
|
+
console.error("Cannot collapse without detail");
|
|
1895
|
+
return;
|
|
1896
|
+
}
|
|
1897
|
+
this.detail.keepAlive = true;
|
|
1898
|
+
const detail = this.detail;
|
|
1899
|
+
this.detail = null;
|
|
1900
|
+
this.navigationController.push({ components: [detail], animated: false });
|
|
1901
|
+
},
|
|
1902
|
+
canExpand() {
|
|
1903
|
+
if (!this.navigationController) {
|
|
1904
|
+
return false;
|
|
1905
|
+
}
|
|
1906
|
+
if (this.detail) {
|
|
1907
|
+
return false;
|
|
1908
|
+
}
|
|
1909
|
+
if (!this.lastIsDetail) {
|
|
1910
|
+
if (!this.rootDetail) {
|
|
1911
|
+
return false;
|
|
1912
|
+
}
|
|
1913
|
+
return true;
|
|
1914
|
+
}
|
|
1915
|
+
return true;
|
|
1916
|
+
},
|
|
1917
|
+
async expand() {
|
|
1918
|
+
if (!this.navigationController) {
|
|
1919
|
+
console.error("Cannot expand without navigation controller");
|
|
1920
|
+
return;
|
|
1921
|
+
}
|
|
1922
|
+
if (this.detail) {
|
|
1923
|
+
console.error("Cannot expand when detail is already visible");
|
|
1924
|
+
return;
|
|
1925
|
+
}
|
|
1926
|
+
if (!this.lastIsDetail) {
|
|
1927
|
+
if (!this.rootDetail) {
|
|
1928
|
+
console.error("Cannot expand with rootDetail when there is no rootDetail");
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
console.log("pushing root detail", this.rootDetail);
|
|
1932
|
+
this.detail = this.rootDetail.clone();
|
|
1933
|
+
this.detailKey = this.detail.key;
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
const popped = await this.navigationController.pop({
|
|
1937
|
+
animated: false,
|
|
1938
|
+
destroy: false
|
|
1939
|
+
});
|
|
1940
|
+
if (!popped || popped.length == 0) {
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
await this.$nextTick();
|
|
1944
|
+
this.detailKey = popped[0].key;
|
|
1945
|
+
this.detail = popped[0];
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
});
|
|
1949
|
+
const _hoisted_1 = ["data-has-detail"];
|
|
1950
|
+
const _hoisted_2 = {
|
|
1951
|
+
ref: "masterElement",
|
|
1952
|
+
class: "master"
|
|
1953
|
+
};
|
|
1954
|
+
const _hoisted_3 = {
|
|
1955
|
+
key: 0,
|
|
1956
|
+
class: "detail"
|
|
1957
|
+
};
|
|
1958
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1959
|
+
const _component_NavigationController = resolveComponent("NavigationController");
|
|
1960
|
+
const _component_FramedComponent = resolveComponent("FramedComponent");
|
|
1961
|
+
return openBlock(), createElementBlock("div", {
|
|
1962
|
+
class: "split-view-controller",
|
|
1963
|
+
"data-has-detail": _ctx.detail ? "true" : "false"
|
|
1964
|
+
}, [
|
|
1965
|
+
createElementVNode("div", _hoisted_2, [
|
|
1966
|
+
createVNode(_component_NavigationController, {
|
|
1967
|
+
ref: "navigationController",
|
|
1968
|
+
root: _ctx.root,
|
|
1969
|
+
"custom-provide": { isMaster: true, isDetail: false },
|
|
1970
|
+
onShowDetail: _ctx.showDetail
|
|
1971
|
+
}, null, 8, ["root", "onShowDetail"])
|
|
1972
|
+
], 512),
|
|
1973
|
+
_ctx.detail ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
1974
|
+
(openBlock(), createBlock(_component_FramedComponent, {
|
|
1975
|
+
ref: "detailFrame",
|
|
1976
|
+
key: _ctx.detail.key,
|
|
1977
|
+
root: _ctx.detail,
|
|
1978
|
+
"custom-provide": { isDetail: true, isMaster: false }
|
|
1979
|
+
}, null, 8, ["root"]))
|
|
1980
|
+
])) : createCommentVNode("", true)
|
|
1981
|
+
], 8, _hoisted_1);
|
|
1982
|
+
}
|
|
1983
|
+
const SplitViewController = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
1984
|
+
export {
|
|
1985
|
+
ComponentWithProperties,
|
|
1986
|
+
ComponentWithPropertiesInstance,
|
|
1987
|
+
FramedComponent,
|
|
1988
|
+
HistoryManager,
|
|
1989
|
+
ModalStackComponent,
|
|
1990
|
+
ModalStackComponentFinderMixin,
|
|
1991
|
+
NavigationController,
|
|
1992
|
+
NavigationMixin,
|
|
1993
|
+
_sfc_main$2 as Popup,
|
|
1994
|
+
Sheet,
|
|
1995
|
+
SideView,
|
|
1996
|
+
SplitViewController,
|
|
1997
|
+
StackComponent,
|
|
1998
|
+
useCanDismiss,
|
|
1999
|
+
useCanPop,
|
|
2000
|
+
useCurrentComponent,
|
|
2001
|
+
useDismiss,
|
|
2002
|
+
useFocused,
|
|
2003
|
+
usePop,
|
|
2004
|
+
usePopup,
|
|
2005
|
+
usePresent,
|
|
2006
|
+
useShow,
|
|
2007
|
+
useShowDetail
|
|
2008
|
+
};
|