@rdlabo/capacitor-native-ui 0.0.0-stage → 2.0.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/Package.swift +23 -0
- package/README.md +66 -2
- package/RdlaboCapacitorNativeUi.podspec +17 -0
- package/android/build.gradle +69 -0
- package/android/proguard-rules.pro +0 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/dev/rdlabo/capacitor/nativeui/NativeUI.kt +51 -0
- package/android/src/main/java/dev/rdlabo/capacitor/nativeui/NativeUIPlugin.kt +192 -0
- package/android/src/main/java/dev/rdlabo/capacitor/nativeui/NativeUISnapshot.kt +57 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/core.d.ts +4 -0
- package/dist/core.js +3 -0
- package/dist/native/activation.d.ts +14 -0
- package/dist/native/activation.d.ts.map +1 -0
- package/dist/native/activation.js +305 -0
- package/dist/native/activation.js.map +1 -0
- package/dist/native/components/index.d.ts +19 -0
- package/dist/native/components/index.d.ts.map +1 -0
- package/dist/native/components/index.js +38 -0
- package/dist/native/components/index.js.map +1 -0
- package/dist/native/components/ion-back-button.d.ts +10 -0
- package/dist/native/components/ion-back-button.d.ts.map +1 -0
- package/dist/native/components/ion-back-button.js +21 -0
- package/dist/native/components/ion-back-button.js.map +1 -0
- package/dist/native/components/ion-button.d.ts +10 -0
- package/dist/native/components/ion-button.d.ts.map +1 -0
- package/dist/native/components/ion-button.js +25 -0
- package/dist/native/components/ion-button.js.map +1 -0
- package/dist/native/components/ion-buttons.d.ts +11 -0
- package/dist/native/components/ion-buttons.d.ts.map +1 -0
- package/dist/native/components/ion-buttons.js +30 -0
- package/dist/native/components/ion-buttons.js.map +1 -0
- package/dist/native/components/ion-fab.d.ts +10 -0
- package/dist/native/components/ion-fab.d.ts.map +1 -0
- package/dist/native/components/ion-fab.js +132 -0
- package/dist/native/components/ion-fab.js.map +1 -0
- package/dist/native/components/ion-menu-button.d.ts +13 -0
- package/dist/native/components/ion-menu-button.d.ts.map +1 -0
- package/dist/native/components/ion-menu-button.js +44 -0
- package/dist/native/components/ion-menu-button.js.map +1 -0
- package/dist/native/components/ion-segment.d.ts +11 -0
- package/dist/native/components/ion-segment.d.ts.map +1 -0
- package/dist/native/components/ion-segment.js +30 -0
- package/dist/native/components/ion-segment.js.map +1 -0
- package/dist/native/components/ion-tab-bar.d.ts +11 -0
- package/dist/native/components/ion-tab-bar.d.ts.map +1 -0
- package/dist/native/components/ion-tab-bar.js +50 -0
- package/dist/native/components/ion-tab-bar.js.map +1 -0
- package/dist/native/components/searchable-tabs.d.ts +20 -0
- package/dist/native/components/searchable-tabs.d.ts.map +1 -0
- package/dist/native/components/searchable-tabs.js +413 -0
- package/dist/native/components/searchable-tabs.js.map +1 -0
- package/dist/native/definitions.d.ts +237 -0
- package/dist/native/definitions.d.ts.map +1 -0
- package/dist/native/definitions.js +0 -0
- package/dist/native/extensions.d.ts +31 -0
- package/dist/native/extensions.d.ts.map +1 -0
- package/dist/native/extensions.js +122 -0
- package/dist/native/extensions.js.map +1 -0
- package/dist/native/foldable/fold-state.d.ts +5 -0
- package/dist/native/foldable/fold-state.d.ts.map +1 -0
- package/dist/native/foldable/fold-state.js +15 -0
- package/dist/native/foldable/fold-state.js.map +1 -0
- package/dist/native/foldable/types.d.ts +12 -0
- package/dist/native/foldable/types.d.ts.map +1 -0
- package/dist/native/foldable/types.js +0 -0
- package/dist/native/html.d.ts +9 -0
- package/dist/native/html.d.ts.map +1 -0
- package/dist/native/html.js +197 -0
- package/dist/native/html.js.map +1 -0
- package/dist/native/index.d.ts +10 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native/index.js +19 -0
- package/dist/native/index.js.map +1 -0
- package/dist/native/legacy-layout.d.ts +5 -0
- package/dist/native/legacy-layout.d.ts.map +1 -0
- package/dist/native/legacy-layout.js +27 -0
- package/dist/native/legacy-layout.js.map +1 -0
- package/dist/native/overlays/content.d.ts +4 -0
- package/dist/native/overlays/content.d.ts.map +1 -0
- package/dist/native/overlays/content.js +51 -0
- package/dist/native/overlays/content.js.map +1 -0
- package/dist/native/overlays/controller.d.ts +8 -0
- package/dist/native/overlays/controller.d.ts.map +1 -0
- package/dist/native/overlays/controller.js +285 -0
- package/dist/native/overlays/controller.js.map +1 -0
- package/dist/native/overlays/dialog-animation.d.ts +9 -0
- package/dist/native/overlays/dialog-animation.d.ts.map +1 -0
- package/dist/native/overlays/dialog-animation.js +53 -0
- package/dist/native/overlays/dialog-animation.js.map +1 -0
- package/dist/native/overlays/dismiss-animation.d.ts +4 -0
- package/dist/native/overlays/dismiss-animation.d.ts.map +1 -0
- package/dist/native/overlays/dismiss-animation.js +18 -0
- package/dist/native/overlays/dismiss-animation.js.map +1 -0
- package/dist/native/overlays/focus.d.ts +5 -0
- package/dist/native/overlays/focus.d.ts.map +1 -0
- package/dist/native/overlays/focus.js +59 -0
- package/dist/native/overlays/focus.js.map +1 -0
- package/dist/native/overlays/popover.d.ts +12 -0
- package/dist/native/overlays/popover.d.ts.map +1 -0
- package/dist/native/overlays/popover.js +110 -0
- package/dist/native/overlays/popover.js.map +1 -0
- package/dist/native/overlays/styles.d.ts +11 -0
- package/dist/native/overlays/styles.d.ts.map +1 -0
- package/dist/native/overlays/styles.js +167 -0
- package/dist/native/overlays/styles.js.map +1 -0
- package/dist/native/prehide.d.ts +8 -0
- package/dist/native/prehide.d.ts.map +1 -0
- package/dist/native/prehide.js +238 -0
- package/dist/native/prehide.js.map +1 -0
- package/dist/native/runtime.d.ts +7 -0
- package/dist/native/runtime.d.ts.map +1 -0
- package/dist/native/runtime.js +776 -0
- package/dist/native/runtime.js.map +1 -0
- package/dist/native/shared/bridge.d.ts +6 -0
- package/dist/native/shared/bridge.d.ts.map +1 -0
- package/dist/native/shared/bridge.js +18 -0
- package/dist/native/shared/bridge.js.map +1 -0
- package/dist/native/shared/candidate.d.ts +25 -0
- package/dist/native/shared/candidate.d.ts.map +1 -0
- package/dist/native/shared/candidate.js +106 -0
- package/dist/native/shared/candidate.js.map +1 -0
- package/dist/native/shared/clipping.d.ts +5 -0
- package/dist/native/shared/clipping.d.ts.map +1 -0
- package/dist/native/shared/clipping.js +26 -0
- package/dist/native/shared/clipping.js.map +1 -0
- package/dist/native/shared/control-options.d.ts +6 -0
- package/dist/native/shared/control-options.d.ts.map +1 -0
- package/dist/native/shared/control-options.js +17 -0
- package/dist/native/shared/control-options.js.map +1 -0
- package/dist/native/shared/crossfade.d.ts +12 -0
- package/dist/native/shared/crossfade.d.ts.map +1 -0
- package/dist/native/shared/crossfade.js +67 -0
- package/dist/native/shared/crossfade.js.map +1 -0
- package/dist/native/shared/diagnostics.d.ts +4 -0
- package/dist/native/shared/diagnostics.d.ts.map +1 -0
- package/dist/native/shared/diagnostics.js +18 -0
- package/dist/native/shared/diagnostics.js.map +1 -0
- package/dist/native/shared/dom.d.ts +46 -0
- package/dist/native/shared/dom.d.ts.map +1 -0
- package/dist/native/shared/dom.js +180 -0
- package/dist/native/shared/dom.js.map +1 -0
- package/dist/native/shared/events.d.ts +15 -0
- package/dist/native/shared/events.d.ts.map +1 -0
- package/dist/native/shared/events.js +17 -0
- package/dist/native/shared/events.js.map +1 -0
- package/dist/native/shared/icons.d.ts +8 -0
- package/dist/native/shared/icons.d.ts.map +1 -0
- package/dist/native/shared/icons.js +61 -0
- package/dist/native/shared/icons.js.map +1 -0
- package/dist/native/shared/modal.d.ts +10 -0
- package/dist/native/shared/modal.d.ts.map +1 -0
- package/dist/native/shared/modal.js +160 -0
- package/dist/native/shared/modal.js.map +1 -0
- package/dist/native/shared/projection-id.d.ts +4 -0
- package/dist/native/shared/projection-id.d.ts.map +1 -0
- package/dist/native/shared/projection-id.js +7 -0
- package/dist/native/shared/projection-id.js.map +1 -0
- package/dist/native/shared/toolbar-options.d.ts +13 -0
- package/dist/native/shared/toolbar-options.d.ts.map +1 -0
- package/dist/native/shared/toolbar-options.js +28 -0
- package/dist/native/shared/toolbar-options.js.map +1 -0
- package/dist/native/shared/vertical-bars-geometry.d.ts +10 -0
- package/dist/native/shared/vertical-bars-geometry.d.ts.map +1 -0
- package/dist/native/shared/vertical-bars-geometry.js +85 -0
- package/dist/native/shared/vertical-bars-geometry.js.map +1 -0
- package/dist/native/startup.d.ts +8 -0
- package/dist/native/startup.d.ts.map +1 -0
- package/dist/native/startup.js +70 -0
- package/dist/native/startup.js.map +1 -0
- package/dist/native/vertical-bars-web-search.d.ts +10 -0
- package/dist/native/vertical-bars-web-search.d.ts.map +1 -0
- package/dist/native/vertical-bars-web-search.js +90 -0
- package/dist/native/vertical-bars-web-search.js.map +1 -0
- package/dist/native/vertical-bars-web.d.ts +5 -0
- package/dist/native/vertical-bars-web.d.ts.map +1 -0
- package/dist/native/vertical-bars-web.js +422 -0
- package/dist/native/vertical-bars-web.js.map +1 -0
- package/dist/native-integration/index.d.ts +25 -0
- package/dist/native-integration/index.d.ts.map +1 -0
- package/dist/native-integration/index.js +33 -0
- package/dist/native-integration/index.js.map +1 -0
- package/dist/vertical-bars.d.ts +6 -0
- package/dist/vertical-bars.js +5 -0
- package/docs/appearance.md +45 -0
- package/docs/configuration.md +219 -0
- package/docs/framework-independent.md +107 -0
- package/docs/ionic-vertical-bars.md +173 -0
- package/docs/migration.md +184 -0
- package/docs/native-ui-extensions.md +394 -0
- package/docs/native-ui.md +528 -0
- package/docs/setup.md +224 -0
- package/docs/vertical-bars.md +431 -0
- package/ios/Sources/NativeUIPlugin/Components/NativeUIButton.swift +71 -0
- package/ios/Sources/NativeUIPlugin/Components/NativeUIButtons.swift +24 -0
- package/ios/Sources/NativeUIPlugin/Components/NativeUIComponents.swift +19 -0
- package/ios/Sources/NativeUIPlugin/Components/NativeUIFab.swift +80 -0
- package/ios/Sources/NativeUIPlugin/Components/NativeUISearchController.swift +439 -0
- package/ios/Sources/NativeUIPlugin/Components/NativeUISegment.swift +91 -0
- package/ios/Sources/NativeUIPlugin/Components/NativeUITabBar.swift +218 -0
- package/ios/Sources/NativeUIPlugin/Components/NativeUIVerticalBars.swift +590 -0
- package/ios/Sources/NativeUIPlugin/Components/NativeUIVerticalSearch.swift +118 -0
- package/ios/Sources/NativeUIPlugin/Extensions/NativeUI.swift +178 -0
- package/ios/Sources/NativeUIPlugin/Extensions/NativeUIRendering.swift +38 -0
- package/ios/Sources/NativeUIPlugin/NativeUIPlugin.swift +615 -0
- package/ios/Sources/NativeUIPlugin/Overlays/NativeUIOverlayController.swift +119 -0
- package/ios/Sources/NativeUIPlugin/Overlays/NativeUIOverlayHost.swift +75 -0
- package/ios/Sources/NativeUIPlugin/Shared/NativeUIControlRendering.swift +21 -0
- package/ios/Sources/NativeUIPlugin/Shared/NativeUICrossfade.swift +35 -0
- package/ios/Sources/NativeUIPlugin/Shared/NativeUIHost.swift +8 -0
- package/ios/Sources/NativeUIPlugin/Shared/NativeUISnapshot.swift +161 -0
- package/ios/Sources/NativeUIPlugin/Shared/NativeUIVerticalBarsGeometry.swift +52 -0
- package/ios/Tests/NativeUIPluginTests/NativeUIExtensionTests.swift +165 -0
- package/ios/Tests/NativeUIPluginTests/NativeUISnapshotTests.swift +805 -0
- package/package.json +89 -4
- package/src/core.ts +14 -0
- package/src/native/activation.ts +385 -0
- package/src/native/components/index.ts +45 -0
- package/src/native/components/ion-back-button.ts +22 -0
- package/src/native/components/ion-button.ts +25 -0
- package/src/native/components/ion-buttons.ts +37 -0
- package/src/native/components/ion-fab.ts +151 -0
- package/src/native/components/ion-menu-button.ts +37 -0
- package/src/native/components/ion-segment.ts +27 -0
- package/src/native/components/ion-tab-bar.ts +50 -0
- package/src/native/components/searchable-tabs.ts +499 -0
- package/src/native/definitions.ts +274 -0
- package/src/native/extensions.ts +176 -0
- package/src/native/foldable/fold-state.ts +10 -0
- package/src/native/foldable/types.ts +4 -0
- package/src/native/html.ts +199 -0
- package/src/native/index.ts +32 -0
- package/src/native/legacy-layout.ts +21 -0
- package/src/native/overlays/content.ts +51 -0
- package/src/native/overlays/controller.ts +349 -0
- package/src/native/overlays/dialog-animation.ts +53 -0
- package/src/native/overlays/dismiss-animation.ts +15 -0
- package/src/native/overlays/focus.ts +64 -0
- package/src/native/overlays/popover.ts +120 -0
- package/src/native/overlays/styles.ts +181 -0
- package/src/native/prehide.ts +285 -0
- package/src/native/runtime.ts +979 -0
- package/src/native/shared/bridge.ts +18 -0
- package/src/native/shared/candidate.ts +162 -0
- package/src/native/shared/clipping.ts +24 -0
- package/src/native/shared/control-options.ts +20 -0
- package/src/native/shared/crossfade.ts +67 -0
- package/src/native/shared/diagnostics.ts +13 -0
- package/src/native/shared/dom.ts +304 -0
- package/src/native/shared/events.ts +14 -0
- package/src/native/shared/icons.ts +57 -0
- package/src/native/shared/modal.ts +157 -0
- package/src/native/shared/projection-id.ts +2 -0
- package/src/native/shared/toolbar-options.ts +49 -0
- package/src/native/shared/vertical-bars-geometry.ts +80 -0
- package/src/native/startup.ts +68 -0
- package/src/native/vertical-bars-web-search.ts +86 -0
- package/src/native/vertical-bars-web.ts +500 -0
- package/src/native-integration/index.ts +49 -0
- package/src/vertical-bars.ts +12 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { isExcluded, isNativeUIDisabled, isPermanentlyExcluded } from "../shared/dom.js";
|
|
2
|
+
import { bounded, boundedListener } from "../shared/bridge.js";
|
|
3
|
+
import { relayLayoutSupported, relayStyles } from "./styles.js";
|
|
4
|
+
import { moveContent } from "./content.js";
|
|
5
|
+
import { popoverPresentation, relayPopover, verticalBarsPopoverAnchor } from "./popover.js";
|
|
6
|
+
import { validVerticalBarFrame } from "../shared/vertical-bars-geometry.js";
|
|
7
|
+
import { activeElement, trapFocus } from "./focus.js";
|
|
8
|
+
import { nativeDialogAnimation } from "./dialog-animation.js";
|
|
9
|
+
//#region src/native/overlays/controller.ts
|
|
10
|
+
const lifecycle = (overlay, phase) => `ion${overlay.localName.slice(4, 5).toUpperCase()}${overlay.localName.slice(5)}${phase}`;
|
|
11
|
+
/** Ionic owns lifecycle and dismissal; only one overlay is relayed at a time. */
|
|
12
|
+
const createOverlayController = async (doc, plugin, options, retainProjection, nativeVerticalBars) => {
|
|
13
|
+
let current;
|
|
14
|
+
let opening = Promise.resolve();
|
|
15
|
+
let sequence = 0;
|
|
16
|
+
let stopped = false;
|
|
17
|
+
const suspensions = /* @__PURE__ */ new Set();
|
|
18
|
+
const events = [
|
|
19
|
+
"Modal",
|
|
20
|
+
"Popover",
|
|
21
|
+
"Alert",
|
|
22
|
+
"ActionSheet",
|
|
23
|
+
"Loading",
|
|
24
|
+
"Picker",
|
|
25
|
+
"Toast"
|
|
26
|
+
].map((name) => `ion${name}WillPresent`);
|
|
27
|
+
const cleanup = async (connection) => {
|
|
28
|
+
const stage = async (label, run) => {
|
|
29
|
+
try {
|
|
30
|
+
await bounded(Promise.resolve(run?.()));
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error(`Native overlay teardown failed at ${label}; continuing cleanup anyway.`, error);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
await stage("events", connection.stopEvents);
|
|
37
|
+
await stage("lifecycle", connection.stopLifecycle);
|
|
38
|
+
await stage("childEvents", connection.stopChildEvents);
|
|
39
|
+
await stage("exclusions", connection.stopExclusions);
|
|
40
|
+
await stage("focus", connection.stopFocus);
|
|
41
|
+
await connection.nativeClosing?.catch((error) => {
|
|
42
|
+
console.error("Native overlay dismissal did not complete; restoring the Web content anyway.", error);
|
|
43
|
+
});
|
|
44
|
+
await stage("content", connection.stopContent);
|
|
45
|
+
await stage("animation", connection.stopAnimation);
|
|
46
|
+
await stage("styles", connection.stopStyles);
|
|
47
|
+
await stage("close", () => bounded(plugin.closeOverlay({ id: connection.id })));
|
|
48
|
+
} finally {
|
|
49
|
+
connection.releaseProjection?.();
|
|
50
|
+
connection.releaseProjection = void 0;
|
|
51
|
+
try {
|
|
52
|
+
connection.win?.close();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error("Native overlay window was already gone.", error);
|
|
55
|
+
}
|
|
56
|
+
if (current === connection) current = void 0;
|
|
57
|
+
const focus = connection.focus;
|
|
58
|
+
if (focus?.isConnected && focus.tabIndex >= 0) focus.focus({ preventScroll: true });
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const release = (connection) => connection.closing ?? (connection.closing = cleanup(connection));
|
|
62
|
+
const restoreWeb = async () => {
|
|
63
|
+
if (current) await release(current);
|
|
64
|
+
};
|
|
65
|
+
const excluded = (overlay) => isPermanentlyExcluded(overlay) || isExcluded(overlay) || isNativeUIDisabled(overlay);
|
|
66
|
+
const connect = async (connection, ready, presentation) => {
|
|
67
|
+
const { overlay } = connection;
|
|
68
|
+
const gone = () => current !== connection || stopped || suspensions.size || connection.dismissed || !overlay.isConnected || !nativeVerticalBars() || excluded(overlay);
|
|
69
|
+
connection.hideAnimation?.();
|
|
70
|
+
try {
|
|
71
|
+
const staging = (async () => {
|
|
72
|
+
await bounded(plugin.prepareOverlay({ id: connection.id }));
|
|
73
|
+
if (gone()) return void 0;
|
|
74
|
+
const win = doc.defaultView.open(`about:blank#${connection.id}`, "_blank");
|
|
75
|
+
if (!win) throw new Error("Native overlay window unavailable");
|
|
76
|
+
connection.win = win;
|
|
77
|
+
if (decodeURIComponent(win.document.URL) !== `about:blank#${connection.id}` || win.document.readyState !== "complete") await bounded(new Promise((resolve) => win.addEventListener("load", () => resolve(), { once: true })));
|
|
78
|
+
if (gone()) return void 0;
|
|
79
|
+
win.document.open();
|
|
80
|
+
win.document.write("<!doctype html><html><head></head><body></body></html>");
|
|
81
|
+
win.document.close();
|
|
82
|
+
connection.stopChildEvents = observe(win.document);
|
|
83
|
+
const environment = relayStyles(doc, win.document, overlay, () => {
|
|
84
|
+
if (connection.stopContent) release(connection).catch(console.error);
|
|
85
|
+
});
|
|
86
|
+
connection.stopStyles = environment.stop;
|
|
87
|
+
await bounded(environment.ready);
|
|
88
|
+
if (gone()) return void 0;
|
|
89
|
+
return {
|
|
90
|
+
destination: environment.destination,
|
|
91
|
+
win
|
|
92
|
+
};
|
|
93
|
+
})();
|
|
94
|
+
staging.catch(() => {});
|
|
95
|
+
await bounded(ready);
|
|
96
|
+
await bounded(new Promise((resolve) => doc.defaultView.requestAnimationFrame(() => resolve())));
|
|
97
|
+
const staged = await staging;
|
|
98
|
+
if (gone() || !staged) {
|
|
99
|
+
await release(connection);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const focused = activeElement(doc);
|
|
103
|
+
const nativePresentation = popoverPresentation(overlay);
|
|
104
|
+
const content = relayPopover(overlay, staged.destination);
|
|
105
|
+
connection.stopContent = content.stop;
|
|
106
|
+
if (!relayLayoutSupported(overlay) || !content.matchesSourceAppearance()) {
|
|
107
|
+
await release(connection);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
connection.hideAnimation?.();
|
|
111
|
+
const exclusions = new MutationObserver(() => {
|
|
112
|
+
if (!overlay.isConnected || !nativeVerticalBars() || excluded(overlay) || isNativeUIDisabled(content.root)) release(connection).catch(console.error);
|
|
113
|
+
});
|
|
114
|
+
const attributes = {
|
|
115
|
+
attributes: true,
|
|
116
|
+
attributeFilter: [
|
|
117
|
+
"class",
|
|
118
|
+
"data-native-ui",
|
|
119
|
+
"hidden",
|
|
120
|
+
"inert"
|
|
121
|
+
]
|
|
122
|
+
};
|
|
123
|
+
for (let node = overlay; node; node = node.parentElement) {
|
|
124
|
+
exclusions.observe(node, attributes);
|
|
125
|
+
exclusions.observe(node, { childList: true });
|
|
126
|
+
}
|
|
127
|
+
exclusions.observe(content.root, {
|
|
128
|
+
...attributes,
|
|
129
|
+
subtree: true
|
|
130
|
+
});
|
|
131
|
+
connection.stopExclusions = () => exclusions.disconnect();
|
|
132
|
+
connection.stopFocus = trapFocus(content.root, () => !connection.dismissed && (!("focusTrap" in overlay) || overlay.focusTrap !== false) && !overlay.classList.contains("ion-disable-focus-trap"));
|
|
133
|
+
const close = () => {
|
|
134
|
+
release(connection).catch(console.error);
|
|
135
|
+
};
|
|
136
|
+
const escape = (event) => {
|
|
137
|
+
if (event.key === "Escape" && overlay.backdropDismiss) overlay.dismiss(void 0, "backdrop");
|
|
138
|
+
};
|
|
139
|
+
staged.win.document.addEventListener("keydown", escape);
|
|
140
|
+
overlay.addEventListener(lifecycle(overlay, "DidDismiss"), close, { once: true });
|
|
141
|
+
connection.stopEvents = () => {
|
|
142
|
+
staged.win.document.removeEventListener("keydown", escape);
|
|
143
|
+
overlay.removeEventListener(lifecycle(overlay, "DidDismiss"), close);
|
|
144
|
+
};
|
|
145
|
+
await bounded(plugin.presentOverlay({
|
|
146
|
+
id: connection.id,
|
|
147
|
+
presentation: {
|
|
148
|
+
...nativePresentation,
|
|
149
|
+
animated: presentation.animated
|
|
150
|
+
}
|
|
151
|
+
}));
|
|
152
|
+
(focused?.isConnected && focused.ownerDocument === staged.win.document ? focused : content.root).focus({ preventScroll: true });
|
|
153
|
+
} catch (error) {
|
|
154
|
+
await release(connection);
|
|
155
|
+
console.error("Native overlay projection failed; keeping Ionic content in the source WebView.", error);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const present = (event) => {
|
|
159
|
+
const overlay = event.target;
|
|
160
|
+
if (current) {
|
|
161
|
+
const connection = current;
|
|
162
|
+
const fromChild = overlay.ownerDocument === connection.win?.document;
|
|
163
|
+
if (fromChild) moveContent([overlay], doc.querySelector("ion-app") ?? doc.body);
|
|
164
|
+
current = void 0;
|
|
165
|
+
opening = opening.then(() => release(connection)).catch(console.error);
|
|
166
|
+
if (fromChild) doc.dispatchEvent(new CustomEvent("nativeUIOverlayAdopted", { detail: overlay }));
|
|
167
|
+
if (!connection.dismissed) return;
|
|
168
|
+
connection.stopAnimation?.();
|
|
169
|
+
connection.stopAnimation = void 0;
|
|
170
|
+
}
|
|
171
|
+
const enabled = overlay.localName === "ion-popover" && overlay.mode !== "md" && !overlay.classList.contains("md") && options.ionic?.verticalBars?.popover === true && nativeVerticalBars() && verticalBarsPopoverAnchor(overlay) !== void 0;
|
|
172
|
+
if (stopped || suspensions.size || !enabled || excluded(overlay)) {
|
|
173
|
+
opening = opening.then(restoreWeb).catch(console.error);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const connection = {
|
|
177
|
+
id: `ios-theme-overlay-${++sequence}`,
|
|
178
|
+
overlay,
|
|
179
|
+
dismissed: false,
|
|
180
|
+
focus: activeElement(doc)
|
|
181
|
+
};
|
|
182
|
+
const presentation = {
|
|
183
|
+
kind: "popover",
|
|
184
|
+
animated: overlay.animated
|
|
185
|
+
};
|
|
186
|
+
current = connection;
|
|
187
|
+
const anchorId = verticalBarsPopoverAnchor(overlay);
|
|
188
|
+
connection.releaseProjection = retainProjection((id) => id === anchorId && current === connection && !!connection.nativeClosing && !stopped && !suspensions.size && nativeVerticalBars() && !excluded(overlay));
|
|
189
|
+
const closed = () => {
|
|
190
|
+
connection.dismissed = true;
|
|
191
|
+
};
|
|
192
|
+
overlay.addEventListener(lifecycle(overlay, "DidDismiss"), closed, { once: true });
|
|
193
|
+
let resolveReady;
|
|
194
|
+
const readyPromise = new Promise((resolve) => {
|
|
195
|
+
resolveReady = resolve;
|
|
196
|
+
});
|
|
197
|
+
const ready = () => {
|
|
198
|
+
resolveReady();
|
|
199
|
+
};
|
|
200
|
+
const closeNative = () => connection.nativeClosing ?? (connection.nativeClosing = bounded(plugin.dismissOverlay({
|
|
201
|
+
id: connection.id,
|
|
202
|
+
animated: presentation.animated
|
|
203
|
+
})));
|
|
204
|
+
const viewport = `${win.innerWidth}:${win.innerHeight}`;
|
|
205
|
+
const anchor = bounded(plugin.getVerticalBarsGeometry({
|
|
206
|
+
viewportWidth: win.innerWidth,
|
|
207
|
+
ids: [anchorId]
|
|
208
|
+
})).then(({ items }) => {
|
|
209
|
+
const frame = items[anchorId];
|
|
210
|
+
return frame && validVerticalBarFrame(frame) && viewport === `${win.innerWidth}:${win.innerHeight}` ? frame : void 0;
|
|
211
|
+
}).catch(() => void 0);
|
|
212
|
+
const animation = nativeDialogAnimation(overlay, closeNative, anchor);
|
|
213
|
+
connection.stopAnimation = animation.stop;
|
|
214
|
+
connection.hideAnimation = animation.hide;
|
|
215
|
+
animation.hide();
|
|
216
|
+
overlay.addEventListener(lifecycle(overlay, "DidPresent"), ready, { once: true });
|
|
217
|
+
connection.stopLifecycle = () => overlay.removeEventListener(lifecycle(overlay, "DidDismiss"), closed);
|
|
218
|
+
opening = opening.then(() => connect(connection, readyPromise, presentation)).catch(console.error).finally(() => {
|
|
219
|
+
overlay.removeEventListener(lifecycle(overlay, "DidPresent"), ready);
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
const menuOpen = (event) => {
|
|
223
|
+
if (!event.composedPath().some((node) => node instanceof HTMLElement && node.matches("ion-menu"))) return;
|
|
224
|
+
const connection = current;
|
|
225
|
+
current = void 0;
|
|
226
|
+
if (connection) opening = opening.then(() => release(connection)).catch(console.error);
|
|
227
|
+
};
|
|
228
|
+
const observe = (target) => {
|
|
229
|
+
for (const name of events) target.addEventListener(name, present);
|
|
230
|
+
target.addEventListener("ionWillOpen", menuOpen);
|
|
231
|
+
return () => {
|
|
232
|
+
for (const name of events) target.removeEventListener(name, present);
|
|
233
|
+
target.removeEventListener("ionWillOpen", menuOpen);
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
const invalidate = () => {
|
|
237
|
+
const connection = current;
|
|
238
|
+
current = void 0;
|
|
239
|
+
if (connection) opening = opening.then(() => release(connection)).catch(console.error);
|
|
240
|
+
};
|
|
241
|
+
const win = doc.defaultView;
|
|
242
|
+
const visibility = () => {
|
|
243
|
+
if (doc.hidden) invalidate();
|
|
244
|
+
};
|
|
245
|
+
const listener = await boundedListener(plugin.addListener("overlay", (event) => {
|
|
246
|
+
if (event.id !== current?.id) return;
|
|
247
|
+
if (event.action === "dismiss" && current.overlay.backdropDismiss) current.overlay.dismiss(void 0, "backdrop").catch(console.error);
|
|
248
|
+
}));
|
|
249
|
+
win.addEventListener("resize", invalidate);
|
|
250
|
+
doc.addEventListener("ionViewWillLeave", invalidate);
|
|
251
|
+
doc.addEventListener("visibilitychange", visibility);
|
|
252
|
+
const stopEvents = observe(doc);
|
|
253
|
+
return {
|
|
254
|
+
async suspend() {
|
|
255
|
+
const lease = Symbol();
|
|
256
|
+
suspensions.add(lease);
|
|
257
|
+
await opening;
|
|
258
|
+
await restoreWeb();
|
|
259
|
+
return () => {
|
|
260
|
+
suspensions.delete(lease);
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
async destroy() {
|
|
264
|
+
stopped = true;
|
|
265
|
+
stopEvents();
|
|
266
|
+
win.removeEventListener("resize", invalidate);
|
|
267
|
+
doc.removeEventListener("ionViewWillLeave", invalidate);
|
|
268
|
+
doc.removeEventListener("visibilitychange", visibility);
|
|
269
|
+
try {
|
|
270
|
+
await opening;
|
|
271
|
+
await restoreWeb();
|
|
272
|
+
} finally {
|
|
273
|
+
try {
|
|
274
|
+
await bounded(plugin.stopOverlays());
|
|
275
|
+
} finally {
|
|
276
|
+
await bounded(listener.remove());
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
//#endregion
|
|
283
|
+
export { createOverlayController };
|
|
284
|
+
|
|
285
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","names":[],"sources":["../../../src/native/overlays/controller.ts"],"sourcesContent":["import type { NativeUIOptions, NativeUIPlugin } from '../definitions';\nimport { bounded, boundedListener } from '../shared/bridge';\nimport { isExcluded, isPermanentlyExcluded, isNativeUIDisabled } from '../shared/dom';\nimport { activeElement, trapFocus } from './focus';\nimport { relayPopover, popoverPresentation, verticalBarsPopoverAnchor } from './popover';\nimport { nativeDialogAnimation } from './dialog-animation';\nimport { relayLayoutSupported, relayStyles } from './styles';\nimport { moveContent } from './content';\nimport { validVerticalBarFrame } from '../shared/vertical-bars-geometry';\n\ntype Presentation = { kind: 'popover'; animated: boolean };\ntype Overlay = HTMLIonPopoverElement;\nconst lifecycle = (overlay: Overlay, phase: string) =>\n `ion${overlay.localName.slice(4, 5).toUpperCase()}${overlay.localName.slice(5)}${phase}`;\n\ninterface Connection {\n id: string;\n overlay: Overlay;\n dismissed: boolean;\n win?: Window;\n focus: Element | null;\n stopStyles?: () => void;\n releaseProjection?: () => void;\n stopContent?: () => void;\n stopFocus?: () => void;\n stopEvents?: () => void;\n stopChildEvents?: () => void;\n stopExclusions?: () => void;\n closing?: Promise<void>;\n nativeClosing?: Promise<void>;\n stopAnimation?: () => void;\n hideAnimation?: () => void;\n stopLifecycle?: () => void;\n}\n\n/** Ionic owns lifecycle and dismissal; only one overlay is relayed at a time. */\nexport const createOverlayController = async (\n doc: Document,\n plugin: NativeUIPlugin,\n options: NativeUIOptions,\n retainProjection: (deferActivation?: (id: string) => boolean) => () => void,\n nativeVerticalBars: () => boolean,\n) => {\n let current: Connection | undefined;\n let opening = Promise.resolve();\n let sequence = 0;\n let stopped = false;\n const suspensions = new Set<symbol>();\n const events = ['Modal', 'Popover', 'Alert', 'ActionSheet', 'Loading', 'Picker', 'Toast'].map((name) => `ion${name}WillPresent`);\n const cleanup = async (connection: Connection) => {\n // Every teardown step is isolated and bounded: a throwing or hanging step\n // must not strand the retained page projections or the child window.\n const stage = async (label: string, run?: () => void | Promise<void>) => {\n try {\n await bounded(Promise.resolve(run?.()));\n } catch (error) {\n console.error(`Native overlay teardown failed at ${label}; continuing cleanup anyway.`, error);\n }\n };\n try {\n await stage('events', connection.stopEvents);\n await stage('lifecycle', connection.stopLifecycle);\n await stage('childEvents', connection.stopChildEvents);\n await stage('exclusions', connection.stopExclusions);\n await stage('focus', connection.stopFocus);\n // A timed-out dismissal must not strand the relayed content in the child window.\n await connection.nativeClosing?.catch((error) => {\n console.error('Native overlay dismissal did not complete; restoring the Web content anyway.', error);\n });\n await stage('content', connection.stopContent);\n await stage('animation', connection.stopAnimation);\n await stage('styles', connection.stopStyles);\n await stage('close', () => bounded(plugin.closeOverlay({ id: connection.id })));\n } finally {\n // The page projections must be released even if teardown throws above.\n connection.releaseProjection?.();\n connection.releaseProjection = undefined;\n try {\n connection.win?.close();\n } catch (error) {\n console.error('Native overlay window was already gone.', error);\n }\n if (current === connection) current = undefined;\n const focus = connection.focus as HTMLElement | null;\n if (focus?.isConnected && focus.tabIndex >= 0) focus.focus({ preventScroll: true });\n }\n };\n const release = (connection: Connection): Promise<void> => (connection.closing ??= cleanup(connection));\n const restoreWeb = async () => {\n if (current) await release(current);\n };\n const excluded = (overlay: HTMLElement) => isPermanentlyExcluded(overlay) || isExcluded(overlay) || isNativeUIDisabled(overlay);\n const connect = async (connection: Connection, ready: Promise<void>, presentation: Presentation) => {\n const { overlay } = connection;\n const gone = () =>\n current !== connection ||\n stopped ||\n suspensions.size ||\n connection.dismissed ||\n !overlay.isConnected ||\n !nativeVerticalBars() ||\n excluded(overlay);\n // Keep the source invisible while the native toolbar prepares its popover.\n connection.hideAnimation?.();\n try {\n // Prepare the child window concurrently with Ionic's content initialization.\n const staging = (async () => {\n await bounded(\n plugin.prepareOverlay({\n id: connection.id,\n }),\n );\n if (gone()) return undefined;\n const win = doc.defaultView!.open(`about:blank#${connection.id}`, '_blank');\n if (!win) throw new Error('Native overlay window unavailable');\n connection.win = win;\n // The requested blank page replaces the initial document created by window.open.\n // WebKit percent-encodes the '#' marker in the popup URL; compare decoded.\n // Adopt nodes only after that navigation; otherwise WebKit discards the relay.\n if (decodeURIComponent(win.document.URL) !== `about:blank#${connection.id}` || win.document.readyState !== 'complete')\n await bounded(new Promise<void>((resolve) => win.addEventListener('load', () => resolve(), { once: true })));\n if (gone()) return undefined;\n // about:blank is a quirks-mode document in WebKit. Initialize standards\n // mode before adopting live content: otherwise percentage button heights\n // can resolve against the entire popover viewport.\n win.document.open();\n win.document.write('<!doctype html><html><head></head><body></body></html>');\n win.document.close();\n connection.stopChildEvents = observe(win.document);\n const environment = relayStyles(doc, win.document, overlay, () => {\n if (connection.stopContent) void release(connection).catch(console.error);\n });\n connection.stopStyles = environment.stop;\n await bounded(environment.ready);\n if (gone()) return undefined;\n return { destination: environment.destination, win };\n })();\n // The staging join is awaited below; settle early rejections quietly.\n staging.catch(() => {});\n // Ionic initializes its gestures after didPresent. Let that turn finish before adopting their content.\n // A stalled presentation must not park the opening queue forever.\n await bounded(ready);\n // Placement is captured after Ionic has laid out the overlay.\n await bounded(new Promise<void>((resolve) => doc.defaultView!.requestAnimationFrame(() => resolve())));\n const staged = await staging;\n if (gone() || !staged) {\n await release(connection);\n return;\n }\n const focused = activeElement(doc) as HTMLElement | null;\n const nativePresentation = popoverPresentation(overlay);\n const content = relayPopover(overlay, staged.destination);\n connection.stopContent = content.stop;\n if (!relayLayoutSupported(overlay) || !content.matchesSourceAppearance()) {\n await release(connection);\n return;\n }\n connection.hideAnimation?.();\n // Ionic does not dismiss a presented overlay when its page is hidden or\n // destroyed; without this a popover could retain the page projections\n // forever and freeze every later control update.\n const exclusions = new MutationObserver(() => {\n if (!overlay.isConnected || !nativeVerticalBars() || excluded(overlay) || isNativeUIDisabled(content.root))\n void release(connection).catch(console.error);\n });\n const attributes = { attributes: true, attributeFilter: ['class', 'data-native-ui', 'hidden', 'inert'] };\n for (let node: HTMLElement | null = overlay; node; node = node.parentElement) {\n exclusions.observe(node, attributes);\n exclusions.observe(node, { childList: true });\n }\n exclusions.observe(content.root, { ...attributes, subtree: true });\n connection.stopExclusions = () => exclusions.disconnect();\n connection.stopFocus = trapFocus(\n content.root,\n () =>\n !connection.dismissed &&\n (!('focusTrap' in overlay) || overlay.focusTrap !== false) &&\n !overlay.classList.contains('ion-disable-focus-trap'),\n );\n const close = () => {\n void release(connection).catch(console.error);\n };\n const escape = (event: KeyboardEvent) => {\n if (event.key === 'Escape' && overlay.backdropDismiss) void overlay.dismiss(undefined, 'backdrop');\n };\n staged.win.document.addEventListener('keydown', escape);\n overlay.addEventListener(lifecycle(overlay, 'DidDismiss'), close, { once: true });\n connection.stopEvents = () => {\n staged.win.document.removeEventListener('keydown', escape);\n overlay.removeEventListener(lifecycle(overlay, 'DidDismiss'), close);\n };\n // SwiftUI owns the only visible presentation animation.\n await bounded(\n plugin.presentOverlay({\n id: connection.id,\n presentation: { ...nativePresentation, animated: presentation.animated },\n }),\n );\n (focused?.isConnected && focused.ownerDocument === staged.win.document ? focused : content.root).focus({ preventScroll: true });\n } catch (error) {\n await release(connection);\n console.error('Native overlay projection failed; keeping Ionic content in the source WebView.', error);\n }\n };\n const present = (event: Event) => {\n const overlay = event.target as Overlay;\n if (current) {\n const connection = current;\n const fromChild = overlay.ownerDocument === connection.win?.document;\n if (fromChild) {\n // A child-document overlay may be a sibling of the relayed content.\n // Move it before cleanup closes that document; keep the live node,\n // component handlers and adopted shadow styles in the source WebView.\n moveContent([overlay], doc.querySelector<HTMLElement>('ion-app') ?? doc.body);\n }\n current = undefined;\n opening = opening.then(() => release(connection)).catch(console.error);\n // The original event path still belongs to the child document. Let the\n // source runtime observe presentation before releasing retained controls.\n if (fromChild) doc.dispatchEvent(new CustomEvent('nativeUIOverlayAdopted', { detail: overlay }));\n if (!connection.dismissed) return;\n // A didDismiss handler may immediately open the next popover while SwiftUI is still closing this one.\n connection.stopAnimation?.();\n connection.stopAnimation = undefined;\n }\n const enabled =\n overlay.localName === 'ion-popover' &&\n overlay.mode !== 'md' &&\n !overlay.classList.contains('md') &&\n options.ionic?.verticalBars?.popover === true &&\n nativeVerticalBars() &&\n verticalBarsPopoverAnchor(overlay) !== undefined;\n if (stopped || suspensions.size || !enabled || excluded(overlay)) {\n opening = opening.then(restoreWeb).catch(console.error);\n return;\n }\n const connection: Connection = { id: `ios-theme-overlay-${++sequence}`, overlay, dismissed: false, focus: activeElement(doc) };\n const presentation: Presentation = { kind: 'popover', animated: overlay.animated };\n current = connection;\n // Retain synchronously, before the scheduled projection update can retire the rail.\n const anchorId = verticalBarsPopoverAnchor(overlay);\n connection.releaseProjection = retainProjection(\n (id) =>\n id === anchorId &&\n current === connection &&\n !!connection.nativeClosing &&\n !stopped &&\n !suspensions.size &&\n nativeVerticalBars() &&\n !excluded(overlay),\n );\n const closed = () => {\n connection.dismissed = true;\n };\n overlay.addEventListener(lifecycle(overlay, 'DidDismiss'), closed, { once: true });\n let resolveReady!: () => void;\n const readyPromise = new Promise<void>((resolve) => {\n resolveReady = resolve;\n });\n const ready = () => {\n resolveReady();\n };\n const closeNative = () =>\n (connection.nativeClosing ??= bounded(plugin.dismissOverlay({ id: connection.id, animated: presentation.animated })));\n const viewport = `${win.innerWidth}:${win.innerHeight}`;\n const anchor = bounded(plugin.getVerticalBarsGeometry({ viewportWidth: win.innerWidth, ids: [anchorId!] }))\n .then(({ items }) => {\n const frame = items[anchorId!];\n return frame && validVerticalBarFrame(frame) && viewport === `${win.innerWidth}:${win.innerHeight}` ? frame : undefined;\n })\n .catch(() => undefined);\n const animation = nativeDialogAnimation(overlay, closeNative, anchor);\n connection.stopAnimation = animation.stop;\n connection.hideAnimation = animation.hide;\n animation.hide();\n overlay.addEventListener(lifecycle(overlay, 'DidPresent'), ready, { once: true });\n connection.stopLifecycle = () => overlay.removeEventListener(lifecycle(overlay, 'DidDismiss'), closed);\n opening = opening\n .then(() => connect(connection, readyPromise, presentation))\n .catch(console.error)\n .finally(() => {\n overlay.removeEventListener(lifecycle(overlay, 'DidPresent'), ready);\n });\n };\n const menuOpen = (event: Event) => {\n if (!event.composedPath().some((node): node is HTMLElement => node instanceof HTMLElement && node.matches('ion-menu'))) return;\n // Menus render in the source document below the native overlay; release the relay.\n const connection = current;\n current = undefined;\n if (connection) opening = opening.then(() => release(connection)).catch(console.error);\n };\n const observe = (target: Document) => {\n for (const name of events) target.addEventListener(name, present);\n target.addEventListener('ionWillOpen', menuOpen);\n return () => {\n for (const name of events) target.removeEventListener(name, present);\n target.removeEventListener('ionWillOpen', menuOpen);\n };\n };\n const invalidate = () => {\n const connection = current;\n current = undefined;\n if (connection) opening = opening.then(() => release(connection)).catch(console.error);\n };\n // Retention must not freeze an obsolete layout or a departed page.\n const win = doc.defaultView!;\n const visibility = () => {\n if (doc.hidden) invalidate();\n };\n const listener = await boundedListener(\n plugin.addListener('overlay', (event) => {\n if (event.id !== current?.id) return;\n if (event.action === 'dismiss' && current.overlay.backdropDismiss)\n void current.overlay.dismiss(undefined, 'backdrop').catch(console.error);\n }),\n );\n win.addEventListener('resize', invalidate);\n doc.addEventListener('ionViewWillLeave', invalidate);\n doc.addEventListener('visibilitychange', visibility);\n const stopEvents = observe(doc);\n return {\n async suspend() {\n const lease = Symbol();\n suspensions.add(lease);\n await opening;\n await restoreWeb();\n return () => {\n suspensions.delete(lease);\n };\n },\n async destroy() {\n stopped = true;\n stopEvents();\n win.removeEventListener('resize', invalidate);\n doc.removeEventListener('ionViewWillLeave', invalidate);\n doc.removeEventListener('visibilitychange', visibility);\n try {\n await opening;\n await restoreWeb();\n } finally {\n try {\n await bounded(plugin.stopOverlays());\n } finally {\n await bounded(listener.remove());\n }\n }\n },\n };\n};\n"],"mappings":";;;;;;;;;AAYA,MAAM,aAAa,SAAkB,UACnC,MAAM,QAAQ,UAAU,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,QAAQ,UAAU,MAAM,CAAC,IAAI;;AAuBnF,MAAa,0BAA0B,OACrC,KACA,QACA,SACA,kBACA,uBACG;CACH,IAAI;CACJ,IAAI,UAAU,QAAQ,QAAQ;CAC9B,IAAI,WAAW;CACf,IAAI,UAAU;CACd,MAAM,8BAAc,IAAI,IAAY;CACpC,MAAM,SAAS;EAAC;EAAS;EAAW;EAAS;EAAe;EAAW;EAAU;CAAO,CAAC,CAAC,KAAK,SAAS,MAAM,KAAK,YAAY;CAC/H,MAAM,UAAU,OAAO,eAA2B;EAGhD,MAAM,QAAQ,OAAO,OAAe,QAAqC;GACvE,IAAI;IACF,MAAM,QAAQ,QAAQ,QAAQ,MAAM,CAAC,CAAC;GACxC,SAAS,OAAO;IACd,QAAQ,MAAM,qCAAqC,MAAM,+BAA+B,KAAK;GAC/F;EACF;EACA,IAAI;GACF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1B;EACF;EACA,MAAM,UAAU;GACd,UAAU;GACV,WAAW;GACX,IAAI,oBAAoB,UAAU,UAAU;GAC5C,IAAI,oBAAoB,oBAAoB,UAAU;GACtD,IAAI,oBAAoB,oBAAoB,UAAU;GACtD,IAAI;IACF,MAAM;IACN,MAAM,WAAW;GACnB,UAAU;IACR,IAAI;KACF,MAAM,QAAQ,OAAO,aAAa,CAAC;IACrC,UAAU;KACR,MAAM,QAAQ,SAAS,OAAO,CAAC;IACjC;GACF;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Frame } from "../definitions.js";
|
|
2
|
+
//#region src/native/overlays/dialog-animation.d.ts
|
|
3
|
+
export type Dialog = HTMLIonPopoverElement;
|
|
4
|
+
export declare const nativeDialogAnimation: (overlay: Dialog, close: () => Promise<void>, anchor: Promise<Frame | undefined>) => {
|
|
5
|
+
hide(): void;
|
|
6
|
+
stop(): void;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=dialog-animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog-animation.d.ts","names":[],"sources":["../../../src/native/overlays/dialog-animation.ts"],"mappings":";;YAMY,SAAS;qBAGR,wBAAyB,SAAS,QAAQ,aAAa,eAAe,QAAQ,QAAQ"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { dismissAnimation } from "./dismiss-animation.js";
|
|
2
|
+
import { createAnimation } from "@ionic/core/components/index.js";
|
|
3
|
+
import { iosPopoverEnterAnimation } from "@rdlabo/ionic-theme-utils";
|
|
4
|
+
//#region src/native/overlays/dialog-animation.ts
|
|
5
|
+
/** Prepare the source's final layout while SwiftUI owns visible motion. */
|
|
6
|
+
const nativeDialogAnimation = (overlay, close, anchor) => {
|
|
7
|
+
const enterAnimation = overlay.enterAnimation;
|
|
8
|
+
const builder = enterAnimation ?? iosPopoverEnterAnimation;
|
|
9
|
+
overlay.enterAnimation = (base, options) => {
|
|
10
|
+
const animation = createAnimation();
|
|
11
|
+
const play = animation.play;
|
|
12
|
+
animation.play = async () => {
|
|
13
|
+
const frame = await anchor;
|
|
14
|
+
const proxy = overlay.ownerDocument.createElement("ion-button");
|
|
15
|
+
if (frame) proxy.getBoundingClientRect = () => new DOMRect(frame.x, frame.y, frame.width, frame.height);
|
|
16
|
+
const positioned = frame ? {
|
|
17
|
+
...options,
|
|
18
|
+
trigger: proxy
|
|
19
|
+
} : options;
|
|
20
|
+
animation.addAnimation(builder(base, positioned));
|
|
21
|
+
const finishWithoutMotion = (item) => {
|
|
22
|
+
item.duration(0).delay(0);
|
|
23
|
+
item.childAnimations.forEach(finishWithoutMotion);
|
|
24
|
+
};
|
|
25
|
+
finishWithoutMotion(animation);
|
|
26
|
+
await play({ sync: true });
|
|
27
|
+
};
|
|
28
|
+
return animation;
|
|
29
|
+
};
|
|
30
|
+
const leaveAnimation = overlay.leaveAnimation;
|
|
31
|
+
const opacity = overlay.style.opacity;
|
|
32
|
+
const event = "ionPopoverWillDismiss";
|
|
33
|
+
const dismiss = () => {
|
|
34
|
+
const closing = close();
|
|
35
|
+
overlay.leaveAnimation = () => dismissAnimation(closing);
|
|
36
|
+
};
|
|
37
|
+
overlay.addEventListener(event, dismiss);
|
|
38
|
+
return {
|
|
39
|
+
hide() {
|
|
40
|
+
overlay.style.opacity = "0";
|
|
41
|
+
},
|
|
42
|
+
stop() {
|
|
43
|
+
overlay.removeEventListener(event, dismiss);
|
|
44
|
+
overlay.enterAnimation = enterAnimation;
|
|
45
|
+
overlay.leaveAnimation = leaveAnimation;
|
|
46
|
+
overlay.style.opacity = opacity;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { nativeDialogAnimation };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=dialog-animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog-animation.js","names":[],"sources":["../../../src/native/overlays/dialog-animation.ts"],"sourcesContent":["import type { Animation } from '@ionic/core';\nimport { createAnimation } from '@ionic/core/components/index.js';\nimport { iosPopoverEnterAnimation } from '@rdlabo/ionic-theme-utils';\nimport type { Frame } from '../definitions';\nimport { dismissAnimation } from './dismiss-animation';\n\nexport type Dialog = HTMLIonPopoverElement;\n\n/** Prepare the source's final layout while SwiftUI owns visible motion. */\nexport const nativeDialogAnimation = (overlay: Dialog, close: () => Promise<void>, anchor: Promise<Frame | undefined>) => {\n const enterAnimation = overlay.enterAnimation;\n const builder = enterAnimation ?? iosPopoverEnterAnimation;\n overlay.enterAnimation = (base, options) => {\n const animation = createAnimation();\n const play = animation.play;\n animation.play = async () => {\n const frame = await anchor;\n const proxy = overlay.ownerDocument.createElement('ion-button');\n if (frame) proxy.getBoundingClientRect = () => new DOMRect(frame.x, frame.y, frame.width, frame.height);\n // The real trigger is display:none while projected. Use only a detached\n // measurement proxy; never replace or mutate the application's button.\n const positioned = frame ? { ...options, trigger: proxy } : options;\n animation.addAnimation(builder(base, positioned));\n const finishWithoutMotion = (item: Animation) => {\n item.duration(0).delay(0);\n item.childAnimations.forEach(finishWithoutMotion);\n };\n finishWithoutMotion(animation);\n // Ionic owns this wrapper and destroys its children on dismissal.\n await play({ sync: true });\n };\n return animation;\n };\n const leaveAnimation = overlay.leaveAnimation;\n const opacity = overlay.style.opacity;\n const event = 'ionPopoverWillDismiss';\n const dismiss = () => {\n const closing = close();\n overlay.leaveAnimation = () => dismissAnimation(closing);\n };\n overlay.addEventListener(event, dismiss);\n return {\n hide() {\n overlay.style.opacity = '0';\n },\n stop() {\n overlay.removeEventListener(event, dismiss);\n overlay.enterAnimation = enterAnimation;\n overlay.leaveAnimation = leaveAnimation;\n overlay.style.opacity = opacity;\n },\n };\n};\n"],"mappings":";;;;;AASA,MAAa,yBAAyB,SAAiB,OAA4B,WAAuC;CACxH,MAAM,iBAAiB,QAAQ;CAC/B,MAAM,UAAU,kBAAkB;CAClC,QAAQ,kBAAkB,MAAM,YAAY;EAC1C,MAAM,YAAY,gBAAgB;EAClC,MAAM,OAAO,UAAU;EACvB,UAAU,OAAO,YAAY;GAC3B,MAAM,QAAQ,MAAM;GACpB,MAAM,QAAQ,QAAQ,cAAc,cAAc,YAAY;GAC9D,IAAI,OAAO,MAAM,8BAA8B,IAAI,QAAQ,MAAM,GAAG,MAAM,GAAG,MAAM,OAAO,MAAM,MAAM;GAGtG,MAAM,aAAa,QAAQ;IAAE,GAAG;IAAS,SAAS;GAAM,IAAI;GAC5D,UAAU,aAAa,QAAQ,MAAM,UAAU,CAAC;GAChD,MAAM,uBAAuB,SAAoB;IAC/C,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IACxB,KAAK,gBAAgB,QAAQ,mBAAmB;GAClD;GACA,oBAAoB,SAAS;GAE7B,MAAM,KAAK,EAAE,MAAM,KAAK,CAAC;EAC3B;EACA,OAAO;CACT;CACA,MAAM,iBAAiB,QAAQ;CAC/B,MAAM,UAAU,QAAQ,MAAM;CAC9B,MAAM,QAAQ;CACd,MAAM,gBAAgB;EACpB,MAAM,UAAU,MAAM;EACtB,QAAQ,uBAAuB,iBAAiB,OAAO;CACzD;CACA,QAAQ,iBAAiB,OAAO,OAAO;CACvC,OAAO;EACL,OAAO;GACL,QAAQ,MAAM,UAAU;EAC1B;EACA,OAAO;GACL,QAAQ,oBAAoB,OAAO,OAAO;GAC1C,QAAQ,iBAAiB;GACzB,QAAQ,iBAAiB;GACzB,QAAQ,MAAM,UAAU;EAC1B;CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dismiss-animation.d.ts","names":[],"sources":["../../../src/native/overlays/dismiss-animation.ts"],"mappings":";qBAGa,mBAAoB,SAAS,wCAAa"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createAnimation } from "@ionic/core/components/index.js";
|
|
2
|
+
//#region src/native/overlays/dismiss-animation.ts
|
|
3
|
+
/** Let Ionic finish dismissal after the native presentation has closed. */
|
|
4
|
+
const dismissAnimation = (closing) => {
|
|
5
|
+
const animation = createAnimation();
|
|
6
|
+
const play = animation.play;
|
|
7
|
+
animation.play = async (options) => {
|
|
8
|
+
await closing.catch((error) => {
|
|
9
|
+
console.error("Native popover dismissal failed; completing the Ionic lifecycle.", error);
|
|
10
|
+
});
|
|
11
|
+
await play(options);
|
|
12
|
+
};
|
|
13
|
+
return animation;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { dismissAnimation };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=dismiss-animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dismiss-animation.js","names":[],"sources":["../../../src/native/overlays/dismiss-animation.ts"],"sourcesContent":["import { createAnimation } from '@ionic/core/components/index.js';\n\n/** Let Ionic finish dismissal after the native presentation has closed. */\nexport const dismissAnimation = (closing: Promise<void>) => {\n const animation = createAnimation();\n const play = animation.play;\n animation.play = async (options) => {\n // A native failure must not suppress Ionic's didDismiss event/data.\n await closing.catch((error) => {\n console.error('Native popover dismissal failed; completing the Ionic lifecycle.', error);\n });\n await play(options);\n };\n return animation;\n};\n"],"mappings":";;;AAGA,MAAa,oBAAoB,YAA2B;CAC1D,MAAM,YAAY,gBAAgB;CAClC,MAAM,OAAO,UAAU;CACvB,UAAU,OAAO,OAAO,YAAY;EAElC,MAAM,QAAQ,OAAO,UAAU;GAC7B,QAAQ,MAAM,oEAAoE,KAAK;EACzF,CAAC;EACD,MAAM,KAAK,OAAO;CACpB;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.d.ts","names":[],"sources":["../../../src/native/overlays/focus.ts"],"mappings":";qBAAa,gBAAiB,KAAK,aAAW;qBAiCjC,YAAa,MAAM,aAAa"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region src/native/overlays/focus.ts
|
|
2
|
+
const activeElement = (doc) => {
|
|
3
|
+
let element = doc.activeElement;
|
|
4
|
+
while (element?.shadowRoot?.activeElement) element = element.shadowRoot.activeElement;
|
|
5
|
+
return element;
|
|
6
|
+
};
|
|
7
|
+
const focusableElements = (root) => {
|
|
8
|
+
const elements = [];
|
|
9
|
+
const win = root.ownerDocument.defaultView;
|
|
10
|
+
const collect = (scope) => {
|
|
11
|
+
for (const node of Array.from(scope.querySelectorAll("*"))) {
|
|
12
|
+
if (node.inert || node.closest("[inert]") || node.disabled) continue;
|
|
13
|
+
const before = elements.length;
|
|
14
|
+
if (node.shadowRoot) collect(node.shadowRoot);
|
|
15
|
+
const css = win.getComputedStyle(node);
|
|
16
|
+
if (elements.length === before && node.tabIndex >= 0 && !node.hidden && css.display !== "none" && css.visibility !== "hidden" && node.getClientRects().length) elements.push(node);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
collect(root);
|
|
20
|
+
return elements.map((element, index) => ({
|
|
21
|
+
element,
|
|
22
|
+
index
|
|
23
|
+
})).sort((a, b) => (a.element.tabIndex || Infinity) - (b.element.tabIndex || Infinity) || a.index - b.index).map(({ element }) => element);
|
|
24
|
+
};
|
|
25
|
+
const trapFocus = (root, enabled) => {
|
|
26
|
+
const doc = root.ownerDocument;
|
|
27
|
+
const previous = root.getAttribute("tabindex");
|
|
28
|
+
root.tabIndex = -1;
|
|
29
|
+
let last;
|
|
30
|
+
const onFocus = (event) => {
|
|
31
|
+
if (!enabled()) return;
|
|
32
|
+
if (event.composedPath().includes(root)) {
|
|
33
|
+
last = activeElement(doc);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const elements = focusableElements(root);
|
|
37
|
+
(elements.find((element) => element === last) ?? elements[0] ?? root).focus({ preventScroll: true });
|
|
38
|
+
};
|
|
39
|
+
const onKey = (event) => {
|
|
40
|
+
if (event.key !== "Tab" || event.altKey || event.ctrlKey || event.metaKey || !enabled()) return;
|
|
41
|
+
const elements = focusableElements(root);
|
|
42
|
+
const index = elements.findIndex((element) => element === activeElement(doc));
|
|
43
|
+
const next = event.shiftKey ? index <= 0 ? elements.length - 1 : index - 1 : (index + 1) % elements.length;
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
(elements[next] ?? root).focus();
|
|
46
|
+
};
|
|
47
|
+
doc.addEventListener("focusin", onFocus, true);
|
|
48
|
+
doc.addEventListener("keydown", onKey, true);
|
|
49
|
+
return () => {
|
|
50
|
+
doc.removeEventListener("focusin", onFocus, true);
|
|
51
|
+
doc.removeEventListener("keydown", onKey, true);
|
|
52
|
+
if (previous === null) root.removeAttribute("tabindex");
|
|
53
|
+
else root.setAttribute("tabindex", previous);
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { activeElement, trapFocus };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.js","names":[],"sources":["../../../src/native/overlays/focus.ts"],"sourcesContent":["export const activeElement = (doc: Document): Element | null => {\n let element = doc.activeElement;\n while (element?.shadowRoot?.activeElement) element = element.shadowRoot.activeElement;\n return element;\n};\n\nconst focusableElements = (root: HTMLElement): HTMLElement[] => {\n const elements: HTMLElement[] = [];\n const win = root.ownerDocument.defaultView!;\n const collect = (scope: HTMLElement | ShadowRoot) => {\n for (const node of Array.from(scope.querySelectorAll<HTMLElement>('*'))) {\n if (node.inert || node.closest('[inert]') || (node as HTMLButtonElement).disabled) continue;\n const before = elements.length;\n if (node.shadowRoot) collect(node.shadowRoot);\n const css = win.getComputedStyle(node);\n if (\n elements.length === before &&\n node.tabIndex >= 0 &&\n !node.hidden &&\n css.display !== 'none' &&\n css.visibility !== 'hidden' &&\n node.getClientRects().length\n )\n elements.push(node);\n }\n };\n collect(root);\n return elements\n .map((element, index) => ({ element, index }))\n .sort((a, b) => (a.element.tabIndex || Infinity) - (b.element.tabIndex || Infinity) || a.index - b.index)\n .map(({ element }) => element);\n};\n\nexport const trapFocus = (root: HTMLElement, enabled: () => boolean): (() => void) => {\n const doc = root.ownerDocument;\n const previous = root.getAttribute('tabindex');\n root.tabIndex = -1;\n let last: Element | null;\n const onFocus = (event: FocusEvent) => {\n if (!enabled()) return;\n if (event.composedPath().includes(root)) {\n last = activeElement(doc);\n return;\n }\n const elements = focusableElements(root);\n (elements.find((element) => element === last) ?? elements[0] ?? root).focus({ preventScroll: true });\n };\n const onKey = (event: KeyboardEvent) => {\n if (event.key !== 'Tab' || event.altKey || event.ctrlKey || event.metaKey || !enabled()) return;\n const elements = focusableElements(root);\n const index = elements.findIndex((element) => element === activeElement(doc));\n const next = event.shiftKey ? (index <= 0 ? elements.length - 1 : index - 1) : (index + 1) % elements.length;\n event.preventDefault();\n (elements[next] ?? root).focus();\n };\n doc.addEventListener('focusin', onFocus, true);\n doc.addEventListener('keydown', onKey, true);\n return () => {\n doc.removeEventListener('focusin', onFocus, true);\n doc.removeEventListener('keydown', onKey, true);\n if (previous === null) root.removeAttribute('tabindex');\n else root.setAttribute('tabindex', previous);\n };\n};\n"],"mappings":";AAAA,MAAa,iBAAiB,QAAkC;CAC9D,IAAI,UAAU,IAAI;CAClB,OAAO,SAAS,YAAY,eAAe,UAAU,QAAQ,WAAW;CACxE,OAAO;AACT;AAEA,MAAM,qBAAqB,SAAqC;CAC9D,MAAM,WAA0B,CAAC;CACjC,MAAM,MAAM,KAAK,cAAc;CAC/B,MAAM,WAAW,UAAoC;EACnD,KAAK,MAAM,QAAQ,MAAM,KAAK,MAAM,iBAA8B,GAAG,CAAC,GAAG;GACvE,IAAI,KAAK,SAAS,KAAK,QAAQ,SAAS,KAAM,KAA2B,UAAU;GACnF,MAAM,SAAS,SAAS;GACxB,IAAI,KAAK,YAAY,QAAQ,KAAK,UAAU;GAC5C,MAAM,MAAM,IAAI,iBAAiB,IAAI;GACrC,IACE,SAAS,WAAW,UACpB,KAAK,YAAY,KACjB,CAAC,KAAK,UACN,IAAI,YAAY,UAChB,IAAI,eAAe,YACnB,KAAK,eAAe,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a,MAAM,KAAK,gBAAgB,UAAU;OACjD,KAAK,aAAa,YAAY,QAAQ;CAC7C;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NativeUIPopoverPresentation } from "../definitions.js";
|
|
2
|
+
//#region src/native/overlays/popover.d.ts
|
|
3
|
+
export declare const popoverTrigger: (overlay: HTMLIonPopoverElement) => Element | undefined;
|
|
4
|
+
export declare const verticalBarsPopoverAnchor: (overlay: HTMLIonPopoverElement) => string | undefined;
|
|
5
|
+
export declare const popoverPresentation: (overlay: HTMLIonPopoverElement) => NativeUIPopoverPresentation;
|
|
6
|
+
export declare const relayPopover: (overlay: HTMLIonPopoverElement, destination: HTMLElement) => {
|
|
7
|
+
root: HTMLIonPopoverElement;
|
|
8
|
+
matchesSourceAppearance(): boolean;
|
|
9
|
+
stop(): void;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
//# sourceMappingURL=popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.d.ts","names":[],"sources":["../../../src/native/overlays/popover.ts"],"mappings":";;qBAMa,iBAAkB,SAAS,0BAAwB;qBAOnD,4BAA6B,SAAS;qBAWtC,sBAAuB,SAAS,0BAAwB;qBAiBxD,eAAgB,SAAS,uBAAuB,aAAa"}
|