@rdlabo/ionic-theme-ios27 1.2.1-beta.pr275.shad339e7688db7 → 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.
Files changed (248) hide show
  1. package/README.md +24 -280
  2. package/dist/css/components/ion-toolbar.css +1 -1
  3. package/dist/css/ionic-theme-ios27.css +1 -1
  4. package/dist/css/vertical-bars.css +1 -1
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/layout/index.d.ts +18 -0
  10. package/dist/layout/index.d.ts.map +1 -0
  11. package/dist/layout/index.js +26 -0
  12. package/dist/layout/index.js.map +1 -0
  13. package/dist/segment/index.js +3 -3
  14. package/dist/segment/index.js.map +1 -1
  15. package/dist/sheets-of-glass/index.js +7 -7
  16. package/dist/sheets-of-glass/index.js.map +1 -1
  17. package/dist/tab-bar-searchable/dismiss-button.js +53 -3
  18. package/dist/tab-bar-searchable/dismiss-button.js.map +1 -1
  19. package/dist/tab-bar-searchable/index.js +18 -3
  20. package/dist/tab-bar-searchable/index.js.map +1 -1
  21. package/dist/transition/ios.transition.d.ts.map +1 -1
  22. package/dist/transition/ios.transition.js +7 -4
  23. package/dist/transition/ios.transition.js.map +1 -1
  24. package/dist/transition/native-ui.d.ts +6 -0
  25. package/dist/transition/native-ui.d.ts.map +1 -0
  26. package/dist/{native-integration/index.js → transition/native-ui.js} +16 -30
  27. package/dist/transition/native-ui.js.map +1 -0
  28. package/docs/adaptive-themes.md +161 -0
  29. package/docs/add-native-ui.md +53 -0
  30. package/docs/animation.md +19 -3
  31. package/docs/eslint.md +3 -1
  32. package/docs/features.md +9 -5
  33. package/docs/iphone-duo.md +62 -35
  34. package/docs/migration.md +17 -26
  35. package/docs/setup.md +92 -0
  36. package/docs/special-markup.md +41 -10
  37. package/docs/using-ion-item-group.md +2 -2
  38. package/docs/vertical-bars-layout.md +67 -0
  39. package/package.json +12 -42
  40. package/src/index.ts +3 -1
  41. package/src/layout/index.ts +29 -0
  42. package/src/segment/index.ts +3 -3
  43. package/src/sheets-of-glass/index.ts +7 -7
  44. package/src/styles/components/ion-toolbar.scss +1 -1
  45. package/src/styles/vertical-bars.scss +15 -18
  46. package/src/tab-bar-searchable/dismiss-button.ts +73 -4
  47. package/src/tab-bar-searchable/index.ts +20 -3
  48. package/src/transition/ios.transition.ts +7 -4
  49. package/src/{native-integration/index.ts → transition/native-ui.ts} +17 -46
  50. package/Package.swift +0 -21
  51. package/dist/_virtual/_rolldown/runtime.js +0 -13
  52. package/dist/native/components/index.d.ts +0 -19
  53. package/dist/native/components/index.d.ts.map +0 -1
  54. package/dist/native/components/index.js +0 -40
  55. package/dist/native/components/index.js.map +0 -1
  56. package/dist/native/components/ion-back-button.d.ts +0 -9
  57. package/dist/native/components/ion-back-button.d.ts.map +0 -1
  58. package/dist/native/components/ion-back-button.js +0 -20
  59. package/dist/native/components/ion-back-button.js.map +0 -1
  60. package/dist/native/components/ion-button.d.ts +0 -10
  61. package/dist/native/components/ion-button.d.ts.map +0 -1
  62. package/dist/native/components/ion-button.js +0 -23
  63. package/dist/native/components/ion-button.js.map +0 -1
  64. package/dist/native/components/ion-buttons.d.ts +0 -11
  65. package/dist/native/components/ion-buttons.d.ts.map +0 -1
  66. package/dist/native/components/ion-buttons.js +0 -30
  67. package/dist/native/components/ion-buttons.js.map +0 -1
  68. package/dist/native/components/ion-fab.d.ts +0 -10
  69. package/dist/native/components/ion-fab.d.ts.map +0 -1
  70. package/dist/native/components/ion-fab.js +0 -132
  71. package/dist/native/components/ion-fab.js.map +0 -1
  72. package/dist/native/components/ion-menu-button.d.ts +0 -13
  73. package/dist/native/components/ion-menu-button.d.ts.map +0 -1
  74. package/dist/native/components/ion-menu-button.js +0 -31
  75. package/dist/native/components/ion-menu-button.js.map +0 -1
  76. package/dist/native/components/ion-segment.d.ts +0 -11
  77. package/dist/native/components/ion-segment.d.ts.map +0 -1
  78. package/dist/native/components/ion-segment.js +0 -30
  79. package/dist/native/components/ion-segment.js.map +0 -1
  80. package/dist/native/components/ion-tab-bar.d.ts +0 -11
  81. package/dist/native/components/ion-tab-bar.d.ts.map +0 -1
  82. package/dist/native/components/ion-tab-bar.js +0 -50
  83. package/dist/native/components/ion-tab-bar.js.map +0 -1
  84. package/dist/native/components/searchable-tabs.d.ts +0 -20
  85. package/dist/native/components/searchable-tabs.d.ts.map +0 -1
  86. package/dist/native/components/searchable-tabs.js +0 -383
  87. package/dist/native/components/searchable-tabs.js.map +0 -1
  88. package/dist/native/definitions.d.ts +0 -191
  89. package/dist/native/definitions.d.ts.map +0 -1
  90. package/dist/native/definitions.js +0 -0
  91. package/dist/native/foldable/fold-state.d.ts +0 -5
  92. package/dist/native/foldable/fold-state.d.ts.map +0 -1
  93. package/dist/native/foldable/fold-state.js +0 -14
  94. package/dist/native/foldable/fold-state.js.map +0 -1
  95. package/dist/native/foldable/types.d.ts +0 -12
  96. package/dist/native/foldable/types.d.ts.map +0 -1
  97. package/dist/native/foldable/types.js +0 -0
  98. package/dist/native/index.d.ts +0 -11
  99. package/dist/native/index.d.ts.map +0 -1
  100. package/dist/native/index.js +0 -267
  101. package/dist/native/index.js.map +0 -1
  102. package/dist/native/overlays/content.d.ts +0 -4
  103. package/dist/native/overlays/content.d.ts.map +0 -1
  104. package/dist/native/overlays/content.js +0 -51
  105. package/dist/native/overlays/content.js.map +0 -1
  106. package/dist/native/overlays/controller.d.ts +0 -8
  107. package/dist/native/overlays/controller.d.ts.map +0 -1
  108. package/dist/native/overlays/controller.js +0 -285
  109. package/dist/native/overlays/controller.js.map +0 -1
  110. package/dist/native/overlays/dialog-animation.d.ts +0 -9
  111. package/dist/native/overlays/dialog-animation.d.ts.map +0 -1
  112. package/dist/native/overlays/dialog-animation.js +0 -53
  113. package/dist/native/overlays/dialog-animation.js.map +0 -1
  114. package/dist/native/overlays/dismiss-animation.d.ts +0 -4
  115. package/dist/native/overlays/dismiss-animation.d.ts.map +0 -1
  116. package/dist/native/overlays/dismiss-animation.js +0 -18
  117. package/dist/native/overlays/dismiss-animation.js.map +0 -1
  118. package/dist/native/overlays/focus.d.ts +0 -5
  119. package/dist/native/overlays/focus.d.ts.map +0 -1
  120. package/dist/native/overlays/focus.js +0 -59
  121. package/dist/native/overlays/focus.js.map +0 -1
  122. package/dist/native/overlays/popover.d.ts +0 -12
  123. package/dist/native/overlays/popover.d.ts.map +0 -1
  124. package/dist/native/overlays/popover.js +0 -110
  125. package/dist/native/overlays/popover.js.map +0 -1
  126. package/dist/native/overlays/styles.d.ts +0 -11
  127. package/dist/native/overlays/styles.d.ts.map +0 -1
  128. package/dist/native/overlays/styles.js +0 -167
  129. package/dist/native/overlays/styles.js.map +0 -1
  130. package/dist/native/prehide.d.ts +0 -7
  131. package/dist/native/prehide.d.ts.map +0 -1
  132. package/dist/native/prehide.js +0 -230
  133. package/dist/native/prehide.js.map +0 -1
  134. package/dist/native/runtime.d.ts +0 -7
  135. package/dist/native/runtime.d.ts.map +0 -1
  136. package/dist/native/runtime.js +0 -710
  137. package/dist/native/runtime.js.map +0 -1
  138. package/dist/native/shared/bridge.d.ts +0 -6
  139. package/dist/native/shared/bridge.d.ts.map +0 -1
  140. package/dist/native/shared/bridge.js +0 -18
  141. package/dist/native/shared/bridge.js.map +0 -1
  142. package/dist/native/shared/candidate.d.ts +0 -21
  143. package/dist/native/shared/candidate.d.ts.map +0 -1
  144. package/dist/native/shared/candidate.js +0 -98
  145. package/dist/native/shared/candidate.js.map +0 -1
  146. package/dist/native/shared/crossfade.d.ts +0 -12
  147. package/dist/native/shared/crossfade.d.ts.map +0 -1
  148. package/dist/native/shared/crossfade.js +0 -67
  149. package/dist/native/shared/crossfade.js.map +0 -1
  150. package/dist/native/shared/dom.d.ts +0 -46
  151. package/dist/native/shared/dom.d.ts.map +0 -1
  152. package/dist/native/shared/dom.js +0 -172
  153. package/dist/native/shared/dom.js.map +0 -1
  154. package/dist/native/shared/events.d.ts +0 -11
  155. package/dist/native/shared/events.d.ts.map +0 -1
  156. package/dist/native/shared/events.js +0 -13
  157. package/dist/native/shared/events.js.map +0 -1
  158. package/dist/native/shared/icons.d.ts +0 -8
  159. package/dist/native/shared/icons.d.ts.map +0 -1
  160. package/dist/native/shared/icons.js +0 -61
  161. package/dist/native/shared/icons.js.map +0 -1
  162. package/dist/native/shared/modal.d.ts +0 -10
  163. package/dist/native/shared/modal.d.ts.map +0 -1
  164. package/dist/native/shared/modal.js +0 -160
  165. package/dist/native/shared/modal.js.map +0 -1
  166. package/dist/native/shared/projection-id.d.ts +0 -4
  167. package/dist/native/shared/projection-id.d.ts.map +0 -1
  168. package/dist/native/shared/projection-id.js +0 -7
  169. package/dist/native/shared/projection-id.js.map +0 -1
  170. package/dist/native/shared/vertical-bars-geometry.d.ts +0 -10
  171. package/dist/native/shared/vertical-bars-geometry.d.ts.map +0 -1
  172. package/dist/native/shared/vertical-bars-geometry.js +0 -85
  173. package/dist/native/shared/vertical-bars-geometry.js.map +0 -1
  174. package/dist/native/vertical-bars-web-search.d.ts +0 -10
  175. package/dist/native/vertical-bars-web-search.d.ts.map +0 -1
  176. package/dist/native/vertical-bars-web-search.js +0 -90
  177. package/dist/native/vertical-bars-web-search.js.map +0 -1
  178. package/dist/native/vertical-bars-web.d.ts +0 -5
  179. package/dist/native/vertical-bars-web.d.ts.map +0 -1
  180. package/dist/native/vertical-bars-web.js +0 -411
  181. package/dist/native/vertical-bars-web.js.map +0 -1
  182. package/dist/native-integration/index.d.ts +0 -23
  183. package/dist/native-integration/index.d.ts.map +0 -1
  184. package/dist/native-integration/index.js.map +0 -1
  185. package/dist/native-integration/transition.d.ts +0 -5
  186. package/dist/native-integration/transition.d.ts.map +0 -1
  187. package/dist/native-integration/transition.js +0 -16
  188. package/dist/native-integration/transition.js.map +0 -1
  189. package/dist/vertical-bars.d.ts +0 -5
  190. package/dist/vertical-bars.js +0 -4
  191. package/docs/e2e-testing.md +0 -51
  192. package/docs/feedback.md +0 -65
  193. package/docs/iphone-duo-with-original-theme.md +0 -158
  194. package/docs/native-ui-shell.md +0 -325
  195. package/docs/vertical-bars.md +0 -300
  196. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellButton.swift +0 -71
  197. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellButtons.swift +0 -24
  198. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellComponents.swift +0 -18
  199. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellFab.swift +0 -80
  200. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellSearchController.swift +0 -432
  201. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellSegment.swift +0 -91
  202. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellTabBar.swift +0 -218
  203. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellVerticalBars.swift +0 -565
  204. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellVerticalSearch.swift +0 -118
  205. package/ios/Sources/IonicNativeUIShellPlugin/IonicNativeUIShellPlugin.swift +0 -502
  206. package/ios/Sources/IonicNativeUIShellPlugin/Overlays/ShellOverlayController.swift +0 -119
  207. package/ios/Sources/IonicNativeUIShellPlugin/Overlays/ShellOverlayHost.swift +0 -75
  208. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellCrossfade.swift +0 -35
  209. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellHost.swift +0 -8
  210. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellRendering.swift +0 -27
  211. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellSnapshot.swift +0 -135
  212. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellVerticalBarsGeometry.swift +0 -52
  213. package/ios/Tests/IonicNativeUIShellPluginTests/ShellSnapshotTests.swift +0 -788
  214. package/src/native/components/index.ts +0 -53
  215. package/src/native/components/ion-back-button.ts +0 -19
  216. package/src/native/components/ion-button.ts +0 -24
  217. package/src/native/components/ion-buttons.ts +0 -38
  218. package/src/native/components/ion-fab.ts +0 -151
  219. package/src/native/components/ion-menu-button.ts +0 -24
  220. package/src/native/components/ion-segment.ts +0 -27
  221. package/src/native/components/ion-tab-bar.ts +0 -50
  222. package/src/native/components/searchable-tabs.ts +0 -459
  223. package/src/native/definitions.ts +0 -218
  224. package/src/native/foldable/fold-state.ts +0 -9
  225. package/src/native/foldable/types.ts +0 -4
  226. package/src/native/index.ts +0 -315
  227. package/src/native/overlays/content.ts +0 -51
  228. package/src/native/overlays/controller.ts +0 -349
  229. package/src/native/overlays/dialog-animation.ts +0 -53
  230. package/src/native/overlays/dismiss-animation.ts +0 -15
  231. package/src/native/overlays/focus.ts +0 -64
  232. package/src/native/overlays/popover.ts +0 -120
  233. package/src/native/overlays/styles.ts +0 -181
  234. package/src/native/prehide.ts +0 -265
  235. package/src/native/runtime.ts +0 -885
  236. package/src/native/shared/bridge.ts +0 -18
  237. package/src/native/shared/candidate.ts +0 -150
  238. package/src/native/shared/crossfade.ts +0 -67
  239. package/src/native/shared/dom.ts +0 -286
  240. package/src/native/shared/events.ts +0 -8
  241. package/src/native/shared/icons.ts +0 -57
  242. package/src/native/shared/modal.ts +0 -157
  243. package/src/native/shared/projection-id.ts +0 -2
  244. package/src/native/shared/vertical-bars-geometry.ts +0 -80
  245. package/src/native/vertical-bars-web-search.ts +0 -86
  246. package/src/native/vertical-bars-web.ts +0 -485
  247. package/src/native-integration/transition.ts +0 -15
  248. package/src/vertical-bars.ts +0 -11
@@ -1,157 +0,0 @@
1
- import type { Frame } from '../definitions';
2
-
3
- /** Modal hosts cover the viewport even when their visible dialog is centered. */
4
- export const modalRailClass = 'ios-theme-vertical-bars-modal';
5
- const states = new WeakMap<Document, { top?: HTMLIonModalElement }>();
6
-
7
- export const topModal = (doc: Document): HTMLIonModalElement | undefined => states.get(doc)?.top;
8
- export const modalUsesVerticalBars = (element: Element): boolean => {
9
- const modal = element.closest('ion-modal');
10
- return !modal || modal.classList.contains(modalRailClass);
11
- };
12
-
13
- /** Only the foreground modal may contribute controls; never the covered page. */
14
- export const inVerticalBarsSurface = (element: Element): boolean => {
15
- const modal = topModal(element.ownerDocument);
16
- return modal ? element.closest('ion-modal') === modal && modalUsesVerticalBars(element) : !element.closest('ion-modal');
17
- };
18
-
19
- export const observeVerticalBarsModals = (doc: Document): (() => void) => {
20
- const win = doc.defaultView!;
21
- const state: { top?: HTMLIonModalElement } = {};
22
- states.set(doc, state);
23
- const presenting = new Set<HTMLIonModalElement>();
24
- const dismissed = new WeakSet<HTMLIonModalElement>();
25
- const observed = new Set<Element>();
26
- const listeners = new AbortController();
27
- let stopped = false;
28
- let frame = 0;
29
- let pointerActive = false;
30
- let bounds = '';
31
- const toolbarTop = '--ios-theme-vertical-bars-modal-offset-top';
32
- const refresh = () => {
33
- win.cancelAnimationFrame(frame);
34
- frame = 0;
35
- if (stopped) return;
36
- const app = doc.querySelector('ion-app.ios-theme-vertical-bars');
37
- const modals = Array.from(doc.querySelectorAll<HTMLIonModalElement>('ion-modal'));
38
- const active = modals.filter(
39
- (modal) => !dismissed.has(modal) && ((modal as HTMLIonModalElement & { presented?: boolean }).presented || presenting.has(modal)),
40
- );
41
- for (const modal of presenting) if (!modal.isConnected) presenting.delete(modal);
42
- const top = active.sort((a, b) => a.overlayIndex - b.overlayIndex).slice(-1)[0];
43
- let changed = state.top !== top;
44
- state.top = top;
45
- const nextBounds = top ? JSON.stringify(modalVerticalBarFrame(top)) : '';
46
- changed ||= bounds !== nextBounds;
47
- bounds = nextBounds;
48
- const wanted = new Set<Element>();
49
- for (const modal of modals) {
50
- const content = modal.shadowRoot?.querySelector<HTMLElement>('[part~="content"]');
51
- if (content) wanted.add(content);
52
- // offsetWidth is unaffected by Ionic's presentation transforms.
53
- const fullWidth = !!content && Math.abs(content.offsetWidth - win.innerWidth) <= 1 && Math.abs(content.offsetLeft) <= 1;
54
- const enabled = !!app?.contains(modal) && active.includes(modal) && fullWidth;
55
- if (enabled) {
56
- const top = modalVerticalBarFrame(modal)?.y ?? 0;
57
- const offset = `${top}px`;
58
- if (modal.style.getPropertyValue(toolbarTop) !== offset) {
59
- modal.style.setProperty(toolbarTop, offset);
60
- changed = true;
61
- }
62
- } else modal.style.removeProperty(toolbarTop);
63
- if (modal.classList.contains(modalRailClass) !== enabled) {
64
- modal.classList.toggle(modalRailClass, enabled);
65
- changed = true;
66
- }
67
- }
68
- if (wanted.size !== observed.size || [...wanted].some((element) => !observed.has(element))) {
69
- resize?.disconnect();
70
- observer.disconnect();
71
- observer.observe(doc.documentElement, observation);
72
- observed.clear();
73
- for (const element of wanted) {
74
- resize?.observe(element);
75
- observer.observe(element, { attributes: true, attributeFilter: ['style', 'class'] });
76
- observed.add(element);
77
- }
78
- }
79
- if (changed) win.dispatchEvent(new Event('nativeUIShellRefresh'));
80
- if (
81
- top &&
82
- (pointerActive ||
83
- Array.from(wanted).some((element) => element.getAnimations().some((animation) => animation.playState === 'running')))
84
- )
85
- schedule();
86
- };
87
- const schedule = () => {
88
- if (!stopped && !frame) frame = win.requestAnimationFrame(refresh);
89
- };
90
- const resize = win.ResizeObserver ? new win.ResizeObserver(schedule) : undefined;
91
- const observer = new MutationObserver(schedule);
92
- const observation = { subtree: true, childList: true, attributes: true, attributeFilter: ['class', 'style'] };
93
- observer.observe(doc.documentElement, observation);
94
- for (const name of ['ionModalWillPresent', 'ionModalDidPresent', 'ionModalWillDismiss', 'ionModalDidDismiss', 'ionBreakpointDidChange']) {
95
- doc.addEventListener(
96
- name,
97
- (event) => {
98
- const modal = event.target as HTMLIonModalElement;
99
- if (modal.localName !== 'ion-modal') return;
100
- if (name === 'ionModalDidDismiss') {
101
- presenting.delete(modal);
102
- dismissed.add(modal);
103
- } else {
104
- presenting.add(modal);
105
- dismissed.delete(modal);
106
- }
107
- refresh();
108
- },
109
- { capture: true, signal: listeners.signal },
110
- );
111
- }
112
- doc.addEventListener(
113
- 'pointerdown',
114
- (event) => {
115
- if ((event.target as Element).closest('ion-modal')) {
116
- pointerActive = true;
117
- schedule();
118
- }
119
- },
120
- { capture: true, signal: listeners.signal },
121
- );
122
- for (const name of ['pointerup', 'pointercancel'])
123
- doc.addEventListener(
124
- name,
125
- () => {
126
- pointerActive = false;
127
- schedule();
128
- },
129
- { capture: true, signal: listeners.signal },
130
- );
131
- win.addEventListener('resize', schedule, { signal: listeners.signal });
132
- win.addEventListener('nativeUIShellRefresh', schedule, { signal: listeners.signal });
133
- refresh();
134
- return () => {
135
- stopped = true;
136
- win.cancelAnimationFrame(frame);
137
- observer.disconnect();
138
- resize?.disconnect();
139
- listeners.abort();
140
- if (states.get(doc) !== state) return;
141
- states.delete(doc);
142
- doc.querySelectorAll<HTMLElement>(`.${modalRailClass}`).forEach((modal) => {
143
- modal.classList.remove(modalRailClass);
144
- modal.style.removeProperty(toolbarTop);
145
- });
146
- };
147
- };
148
-
149
- /** Visible modal bounds, clipped at the viewport for Ionic's translated sheets. */
150
- export const modalVerticalBarFrame = (modal: Element): Frame | undefined => {
151
- const rect = modal.shadowRoot?.querySelector('[part~="content"]')?.getBoundingClientRect();
152
- const win = modal.ownerDocument.defaultView!;
153
- if (!rect) return;
154
- const y = Math.max(0, rect.top);
155
- const height = Math.min(win.innerHeight, rect.bottom) - y;
156
- return height > 0 ? { x: 0, y, width: win.innerWidth, height } : undefined;
157
- };
@@ -1,2 +0,0 @@
1
- /** Internal identity used to anchor overlays to their native control. */
2
- export const projectionIds = new WeakMap<Element, string>();
@@ -1,80 +0,0 @@
1
- import type { Frame } from '../definitions';
2
-
3
- const measurements = new WeakMap<Element, { frame: Frame; viewport: string }>();
4
- const viewport = (element: Element) => {
5
- const win = element.ownerDocument.defaultView!;
6
- const classes = element.closest('ion-app')?.classList;
7
- return `${win.innerWidth}:${win.innerHeight}:${classes?.contains('ios-theme-vertical-bars')}:${classes?.contains('ios-theme-vertical-bars-left')}`;
8
- };
9
-
10
- export const validVerticalBarFrame = (frame: Frame) =>
11
- [frame.x, frame.y, frame.width, frame.height].every(Number.isFinite) && frame.width > 0 && frame.height > 0;
12
-
13
- export const forgetVerticalBarFrame = (element: Element) => measurements.delete(element);
14
-
15
- export const rememberVerticalBarFrame = (element: Element, frame: Frame) => {
16
- if (validVerticalBarFrame(frame)) measurements.set(element, { frame, viewport: viewport(element) });
17
- };
18
-
19
- export const verticalBarFrame = (element: Element): Frame | undefined => {
20
- const saved = measurements.get(element);
21
- return saved?.viewport === viewport(element) ? saved.frame : undefined;
22
- };
23
-
24
- /** Convert the native viewport rectangle into the clone's positioning container. */
25
- export const alignVerticalBarClone = (clone: HTMLElement, source: Element, parent: HTMLElement) => {
26
- const frame = verticalBarFrame(source);
27
- if (!frame) return;
28
- const origin = parent.getBoundingClientRect();
29
- Object.assign(clone.style, {
30
- position: 'absolute',
31
- left: `${frame.x - origin.left}px`,
32
- top: `${frame.y - origin.top}px`,
33
- right: 'auto',
34
- bottom: 'auto',
35
- width: `${frame.width}px`,
36
- height: `${frame.height}px`,
37
- minWidth: `${frame.width}px`,
38
- maxWidth: `${frame.width}px`,
39
- minHeight: `${frame.height}px`,
40
- maxHeight: `${frame.height}px`,
41
- margin: '0',
42
- boxSizing: 'border-box',
43
- });
44
- };
45
-
46
- export const alignVerticalTabBar = (tabBar: HTMLElement, frame: Frame, items: Map<HTMLElement, Frame>): (() => void) => {
47
- const doc = tabBar.ownerDocument;
48
- const style = doc.createElement('style');
49
- const token = `rail-${Math.random().toString(36).slice(2)}`;
50
- const selector = `[data-native-rail-geometry="${token}"]`;
51
- const origin = (tabBar.offsetParent as HTMLElement | null)?.getBoundingClientRect() ?? { left: 0, top: 0 };
52
- tabBar.setAttribute('data-native-rail-geometry', token);
53
- const box = (rect: Frame, x: number, y: number) =>
54
- `position:absolute!important;left:${rect.x - x}px!important;top:${rect.y - y}px!important;right:auto!important;bottom:auto!important;width:${rect.width}px!important;min-width:${rect.width}px!important;max-width:${rect.width}px!important;height:${rect.height}px!important;min-height:${rect.height}px!important;max-height:${rect.height}px!important;margin:0!important;padding:0!important;box-sizing:border-box!important;`;
55
- style.textContent =
56
- `${selector}{${box(frame, origin.left, origin.top)}}` +
57
- [...items]
58
- .map(([element, rect]) => {
59
- const index = Array.from(tabBar.children).indexOf(element) + 1;
60
- return `${selector}>:nth-child(${index}){${box(rect, frame.x, frame.y)}}${selector}>:nth-child(${index})::part(native){min-height:0!important}`;
61
- })
62
- .join('');
63
- doc.head.append(style);
64
- const win = doc.defaultView!;
65
- const measuredViewport = viewport(tabBar);
66
- const stop = () => {
67
- observer.disconnect();
68
- win.removeEventListener('resize', stop);
69
- style.remove();
70
- if (tabBar.getAttribute('data-native-rail-geometry') === token) tabBar.removeAttribute('data-native-rail-geometry');
71
- };
72
- const observer = new MutationObserver((records) => {
73
- if (viewport(tabBar) !== measuredViewport || records.some((record) => record.type === 'childList')) stop();
74
- });
75
- observer.observe(tabBar, { childList: true });
76
- const app = tabBar.closest('ion-app');
77
- if (app) observer.observe(app, { attributes: true, attributeFilter: ['class'] });
78
- win.addEventListener('resize', stop);
79
- return stop;
80
- };
@@ -1,86 +0,0 @@
1
- import { getNativeSearchBindings, type NativeSearchBinding } from '../native-integration';
2
- import { activateProjectedElement, marker, unprojected } from './shared/dom';
3
-
4
- export const searchProjectionClass = 'ios-theme-vertical-bars-search-projection';
5
-
6
- /** Web counterpart of the system search button above the vertical tabs, or at the rail bottom without visible tabs. */
7
- export const createVerticalBarsWebSearch = (doc: Document, eligible: (element: HTMLElement) => boolean, refresh: () => void) => {
8
- let binding: NativeSearchBinding | undefined;
9
- let projection: HTMLIonFabButtonElement | undefined;
10
- let container: HTMLIonFabElement | undefined;
11
- const iconObserver = new MutationObserver(refresh);
12
- let previousAriaHidden: string | null = null;
13
- const restore = (retire?: (surface: HTMLElement) => void) => {
14
- iconObserver.disconnect();
15
- if (container) {
16
- if (retire) retire(container);
17
- else container.remove();
18
- }
19
- container = undefined;
20
- projection = undefined;
21
- if (binding) {
22
- binding.trigger.removeAttribute(marker);
23
- if (previousAriaHidden === null) binding.trigger.removeAttribute('aria-hidden');
24
- else binding.trigger.setAttribute('aria-hidden', previousAriaHidden);
25
- }
26
- binding = undefined;
27
- };
28
- return {
29
- restore,
30
- get surface() {
31
- return container;
32
- },
33
- get source() {
34
- return binding?.trigger;
35
- },
36
- update(root: HTMLElement) {
37
- const next = unprojected(binding ? [binding.trigger] : [], () =>
38
- getNativeSearchBindings(doc).find(({ trigger, footer }) => eligible(trigger) && eligible(footer)),
39
- );
40
- if (next !== binding || container?.parentElement !== root) restore();
41
- if (!next) return;
42
- if (!projection) {
43
- binding = next;
44
- previousAriaHidden = next.trigger.getAttribute('aria-hidden');
45
- projection = next.trigger.cloneNode(true) as HTMLIonFabButtonElement;
46
- for (const name of ['id', 'slot', marker, 'aria-hidden', 'style']) projection.removeAttribute(name);
47
- container = doc.createElement('ion-fab');
48
- container.setAttribute('mode', (next.trigger as HTMLIonFabButtonElement).mode ?? 'ios');
49
- container.classList.add(searchProjectionClass, 'ion-cloned-element');
50
- projection.addEventListener(
51
- 'click',
52
- (event) => {
53
- event.preventDefault();
54
- event.stopImmediatePropagation();
55
- activateProjectedElement(next.trigger);
56
- },
57
- { capture: true },
58
- );
59
- container.append(projection);
60
- root.append(container);
61
- next.trigger.setAttribute(marker, '');
62
- next.trigger.setAttribute('aria-hidden', 'true');
63
- }
64
- projection.setAttribute(
65
- 'aria-label',
66
- next.trigger.getAttribute('aria-label') ?? next.footer.querySelector('ion-searchbar')?.getAttribute('aria-label') ?? 'Search',
67
- );
68
- const sourceIcon = next.trigger.querySelector('ion-icon');
69
- const icon = projection.querySelector('ion-icon');
70
- if (sourceIcon?.shadowRoot) iconObserver.observe(sourceIcon.shadowRoot, { subtree: true, childList: true, attributes: true });
71
- if (sourceIcon && icon) {
72
- icon.icon = sourceIcon.icon;
73
- icon.name = sourceIcon.name;
74
- icon.src = sourceIcon.src;
75
- }
76
- container!.hidden = next.trigger.style.pointerEvents === 'none';
77
- projection.disabled = (next.trigger as HTMLIonFabButtonElement).disabled;
78
- const bounds = next.tabBar.getBoundingClientRect();
79
- const tabs = bounds.width > 0 && bounds.height > 0 && getComputedStyle(next.tabBar).visibility === 'visible' ? bounds : undefined;
80
- container!.style.left = tabs ? `${tabs.left + (tabs.width - 46) / 2}px` : '';
81
- container!.style.top = tabs ? `${tabs.top - 56}px` : '';
82
- container!.style.right = tabs ? 'auto' : '';
83
- container!.style.bottom = tabs ? 'auto' : '';
84
- },
85
- };
86
- };