@rdlabo/ionic-theme-ios27 1.2.0-3 → 1.2.0-4

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 (175) hide show
  1. package/README.md +15 -2
  2. package/dist/_virtual/_rolldown/runtime.js +13 -0
  3. package/dist/css/ionic-theme-ios27.css +1 -1
  4. package/dist/css/vertical-bars.css +1 -1
  5. package/dist/focus-controller/index.d.ts +4 -2
  6. package/dist/focus-controller/index.d.ts.map +1 -1
  7. package/dist/focus-controller/index.js +100 -57
  8. package/dist/focus-controller/index.js.map +1 -0
  9. package/dist/index.d.ts +10 -8
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +54 -60
  12. package/dist/index.js.map +1 -0
  13. package/dist/native/components/index.d.ts +13 -10
  14. package/dist/native/components/index.d.ts.map +1 -1
  15. package/dist/native/components/index.js +39 -41
  16. package/dist/native/components/index.js.map +1 -0
  17. package/dist/native/components/ion-back-button.d.ts +6 -1
  18. package/dist/native/components/ion-back-button.d.ts.map +1 -1
  19. package/dist/native/components/ion-back-button.js +19 -13
  20. package/dist/native/components/ion-back-button.js.map +1 -0
  21. package/dist/native/components/ion-button.d.ts +8 -2
  22. package/dist/native/components/ion-button.d.ts.map +1 -1
  23. package/dist/native/components/ion-button.js +22 -17
  24. package/dist/native/components/ion-button.js.map +1 -0
  25. package/dist/native/components/ion-buttons.d.ts +8 -2
  26. package/dist/native/components/ion-buttons.d.ts.map +1 -1
  27. package/dist/native/components/ion-buttons.js +29 -33
  28. package/dist/native/components/ion-buttons.js.map +1 -0
  29. package/dist/native/components/ion-fab.d.ts +6 -1
  30. package/dist/native/components/ion-fab.d.ts.map +1 -1
  31. package/dist/native/components/ion-fab.js +131 -151
  32. package/dist/native/components/ion-fab.js.map +1 -0
  33. package/dist/native/components/ion-menu-button.d.ts +8 -2
  34. package/dist/native/components/ion-menu-button.d.ts.map +1 -1
  35. package/dist/native/components/ion-menu-button.js +29 -19
  36. package/dist/native/components/ion-menu-button.js.map +1 -0
  37. package/dist/native/components/ion-segment.d.ts +6 -1
  38. package/dist/native/components/ion-segment.d.ts.map +1 -1
  39. package/dist/native/components/ion-segment.js +29 -23
  40. package/dist/native/components/ion-segment.js.map +1 -0
  41. package/dist/native/components/ion-tab-bar.d.ts +6 -1
  42. package/dist/native/components/ion-tab-bar.d.ts.map +1 -1
  43. package/dist/native/components/ion-tab-bar.js +49 -40
  44. package/dist/native/components/ion-tab-bar.js.map +1 -0
  45. package/dist/native/components/searchable-tabs.d.ts +17 -15
  46. package/dist/native/components/searchable-tabs.d.ts.map +1 -1
  47. package/dist/native/components/searchable-tabs.js +382 -434
  48. package/dist/native/components/searchable-tabs.js.map +1 -0
  49. package/dist/native/definitions.d.ts +118 -111
  50. package/dist/native/definitions.d.ts.map +1 -1
  51. package/dist/native/definitions.js +0 -1
  52. package/dist/native/foldable/fold-state.d.ts +5 -0
  53. package/dist/native/foldable/fold-state.d.ts.map +1 -0
  54. package/dist/native/foldable/fold-state.js +14 -0
  55. package/dist/native/foldable/fold-state.js.map +1 -0
  56. package/dist/native/foldable/types.d.ts +12 -0
  57. package/dist/native/foldable/types.d.ts.map +1 -0
  58. package/dist/native/foldable/types.js +0 -0
  59. package/dist/native/index.d.ts +6 -3
  60. package/dist/native/index.d.ts.map +1 -1
  61. package/dist/native/index.js +228 -204
  62. package/dist/native/index.js.map +1 -0
  63. package/dist/native/prehide.d.ts +4 -2
  64. package/dist/native/prehide.d.ts.map +1 -1
  65. package/dist/native/prehide.js +220 -242
  66. package/dist/native/prehide.js.map +1 -0
  67. package/dist/native/runtime.d.ts +3 -1
  68. package/dist/native/runtime.d.ts.map +1 -1
  69. package/dist/native/runtime.js +626 -730
  70. package/dist/native/runtime.js.map +1 -0
  71. package/dist/native/shared/candidate.d.ts +16 -11
  72. package/dist/native/shared/candidate.d.ts.map +1 -1
  73. package/dist/native/shared/candidate.js +96 -95
  74. package/dist/native/shared/candidate.js.map +1 -0
  75. package/dist/native/shared/crossfade.d.ts +6 -4
  76. package/dist/native/shared/crossfade.d.ts.map +1 -1
  77. package/dist/native/shared/crossfade.js +49 -45
  78. package/dist/native/shared/crossfade.js.map +1 -0
  79. package/dist/native/shared/dom.d.ts +7 -5
  80. package/dist/native/shared/dom.d.ts.map +1 -1
  81. package/dist/native/shared/dom.js +163 -211
  82. package/dist/native/shared/dom.js.map +1 -0
  83. package/dist/native/shared/events.d.ts +8 -6
  84. package/dist/native/shared/events.d.ts.map +1 -1
  85. package/dist/native/shared/events.js +12 -7
  86. package/dist/native/shared/events.js.map +1 -0
  87. package/dist/native/shared/icons.d.ts +4 -2
  88. package/dist/native/shared/icons.d.ts.map +1 -1
  89. package/dist/native/shared/icons.js +59 -53
  90. package/dist/native/shared/icons.js.map +1 -0
  91. package/dist/native/shared/modal.d.ts +3 -1
  92. package/dist/native/shared/modal.d.ts.map +1 -1
  93. package/dist/native/shared/modal.js +156 -139
  94. package/dist/native/shared/modal.js.map +1 -0
  95. package/dist/native/vertical-bars-web.d.ts +3 -1
  96. package/dist/native/vertical-bars-web.d.ts.map +1 -1
  97. package/dist/native/vertical-bars-web.js +332 -346
  98. package/dist/native/vertical-bars-web.js.map +1 -0
  99. package/dist/native-integration/index.d.ts +10 -8
  100. package/dist/native-integration/index.d.ts.map +1 -1
  101. package/dist/native-integration/index.js +102 -100
  102. package/dist/native-integration/index.js.map +1 -0
  103. package/dist/native-integration/transition.d.ts +3 -1
  104. package/dist/native-integration/transition.d.ts.map +1 -1
  105. package/dist/native-integration/transition.js +15 -6
  106. package/dist/native-integration/transition.js.map +1 -0
  107. package/dist/searchbar/index.d.ts +4 -2
  108. package/dist/searchbar/index.d.ts.map +1 -1
  109. package/dist/searchbar/index.js +64 -56
  110. package/dist/searchbar/index.js.map +1 -0
  111. package/dist/segment/index.d.ts +3 -1
  112. package/dist/segment/index.d.ts.map +1 -1
  113. package/dist/segment/index.js +465 -324
  114. package/dist/segment/index.js.map +1 -0
  115. package/dist/sheets-of-glass/animations.d.ts +13 -12
  116. package/dist/sheets-of-glass/animations.d.ts.map +1 -1
  117. package/dist/sheets-of-glass/animations.js +496 -306
  118. package/dist/sheets-of-glass/animations.js.map +1 -0
  119. package/dist/sheets-of-glass/index.d.ts +3 -1
  120. package/dist/sheets-of-glass/index.d.ts.map +1 -1
  121. package/dist/sheets-of-glass/index.js +294 -357
  122. package/dist/sheets-of-glass/index.js.map +1 -0
  123. package/dist/sheets-of-glass/interfaces.d.ts +11 -9
  124. package/dist/sheets-of-glass/interfaces.d.ts.map +1 -1
  125. package/dist/sheets-of-glass/interfaces.js +0 -1
  126. package/dist/tab-bar-searchable/animations/enter.d.ts +4 -2
  127. package/dist/tab-bar-searchable/animations/enter.d.ts.map +1 -1
  128. package/dist/tab-bar-searchable/animations/enter.js +50 -69
  129. package/dist/tab-bar-searchable/animations/enter.js.map +1 -0
  130. package/dist/tab-bar-searchable/animations/leave.d.ts +4 -2
  131. package/dist/tab-bar-searchable/animations/leave.d.ts.map +1 -1
  132. package/dist/tab-bar-searchable/animations/leave.js +48 -62
  133. package/dist/tab-bar-searchable/animations/leave.js.map +1 -0
  134. package/dist/tab-bar-searchable/index.d.ts +5 -3
  135. package/dist/tab-bar-searchable/index.d.ts.map +1 -1
  136. package/dist/tab-bar-searchable/index.js +123 -135
  137. package/dist/tab-bar-searchable/index.js.map +1 -0
  138. package/dist/transition/index.d.ts +9 -8
  139. package/dist/transition/index.d.ts.map +1 -1
  140. package/dist/transition/index.js +203 -192
  141. package/dist/transition/index.js.map +1 -0
  142. package/dist/transition/ios.transition.d.ts +7 -5
  143. package/dist/transition/ios.transition.d.ts.map +1 -1
  144. package/dist/transition/ios.transition.js +15 -11
  145. package/dist/transition/ios.transition.js.map +1 -0
  146. package/dist/utils.d.ts +10 -8
  147. package/dist/utils.d.ts.map +1 -1
  148. package/dist/utils.js +58 -66
  149. package/dist/utils.js.map +1 -0
  150. package/dist/vertical-bars.d.ts +5 -4
  151. package/dist/vertical-bars.js +4 -2
  152. package/docs/iphone-duo-with-original-theme.md +18 -29
  153. package/docs/iphone-duo.md +44 -204
  154. package/docs/native-ui-shell.md +10 -8
  155. package/docs/special-markup.md +2 -0
  156. package/docs/vertical-bars.md +283 -0
  157. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellVerticalBars.swift +34 -14
  158. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellSnapshot.swift +2 -0
  159. package/ios/Tests/IonicNativeUIShellPluginTests/ShellSnapshotTests.swift +3 -0
  160. package/package.json +9 -6
  161. package/src/native/components/index.ts +3 -2
  162. package/src/native/components/ion-button.ts +3 -2
  163. package/src/native/components/ion-buttons.ts +4 -3
  164. package/src/native/components/ion-menu-button.ts +3 -2
  165. package/src/native/definitions.ts +22 -1
  166. package/src/native/foldable/fold-state.ts +9 -0
  167. package/src/native/foldable/types.ts +4 -0
  168. package/src/native/index.ts +17 -3
  169. package/src/native/prehide.ts +3 -1
  170. package/src/native/runtime.ts +2 -2
  171. package/src/native/shared/candidate.ts +39 -10
  172. package/src/native/shared/dom.ts +4 -4
  173. package/src/styles/vertical-bars.scss +4 -2
  174. package/src/vertical-bars.ts +9 -1
  175. package/dist/vertical-bars.d.ts.map +0 -1
@@ -1,435 +1,383 @@
1
- import { getNativeSearchBindings, requestNativeSearch } from '../../native-integration';
2
- import { excluded, inFixedToolbar, isShellDisabled, marker, text, visible } from '../shared/dom';
3
- import { iconSource } from '../shared/icons';
4
- export const createSearchSupport = (doc, id, schedule) => {
5
- const states = new Map();
6
- let keyboardVisible = false;
7
- let heldKeyboardResize = null;
8
- let keyboardResizeGeneration = 0;
9
- const keyboardPlugin = () => doc.defaultView?.Capacitor?.Plugins?.Keyboard;
10
- const projected = (binding) => binding.footer.hasAttribute(marker);
11
- const holdKeyboardResize = () => {
12
- const keyboard = keyboardPlugin();
13
- if (!keyboard?.setResizeMode || heldKeyboardResize !== null)
14
- return;
15
- const setResizeMode = keyboard.setResizeMode.bind(keyboard);
16
- const generation = ++keyboardResizeGeneration;
17
- heldKeyboardResize = 'native';
18
- void (async () => {
19
- let restoreMode = 'native';
20
- try {
21
- const current = await keyboard.getResizeMode?.();
22
- if (typeof current?.mode === 'string')
23
- restoreMode = current.mode;
24
- }
25
- catch {
26
- }
27
- if (generation !== keyboardResizeGeneration)
28
- return;
29
- heldKeyboardResize = restoreMode;
30
- try {
31
- await setResizeMode({ mode: 'none' });
32
- }
33
- catch {
34
- if (generation === keyboardResizeGeneration)
35
- heldKeyboardResize = null;
36
- return;
37
- }
38
- if (generation !== keyboardResizeGeneration)
39
- void setResizeMode({ mode: restoreMode }).catch(() => undefined);
40
- })();
41
- };
42
- const hasActiveProjection = () => [...states.keys()].some((binding) => binding.active && projected(binding));
43
- const releaseKeyboardResize = () => {
44
- if (hasActiveProjection())
45
- return;
46
- keyboardResizeGeneration++;
47
- const mode = heldKeyboardResize;
48
- heldKeyboardResize = null;
49
- if (!mode)
50
- return;
51
- void keyboardPlugin()?.setResizeMode?.({ mode });
52
- };
53
- const isCurrent = (state) => state.bar.isConnected &&
54
- state.binding.footer.querySelector('ion-searchbar') === state.bar &&
55
- state.bar.querySelector('input.searchbar-input') === state.input;
56
- const install = (binding, bar, input) => {
57
- const originalFocus = bar.setFocus;
58
- const ownValue = Object.getOwnPropertyDescriptor(bar, 'value');
59
- let owner = bar;
60
- let value = ownValue;
61
- while (!value && (owner = Object.getPrototypeOf(owner)))
62
- value = Object.getOwnPropertyDescriptor(owner, 'value');
63
- const focus = async () => {
64
- if (projected(binding) && (await requestNativeSearch(binding, true, true)))
65
- return;
66
- await originalFocus.call(bar);
67
- };
68
- bar.setFocus = focus;
69
- let wrapped;
70
- if (value?.get && value.set && ownValue?.configurable !== false) {
71
- const descriptor = value;
72
- wrapped = {
73
- configurable: true,
74
- enumerable: value.enumerable,
75
- get: () => descriptor.get.call(bar),
76
- set: (next) => {
77
- if (state.applyingInput)
78
- state.applyingInput = false;
79
- else
80
- state.valueVersion++;
81
- descriptor.set.call(bar, next);
82
- schedule();
83
- },
84
- };
85
- Object.defineProperty(bar, 'value', wrapped);
86
- }
87
- const state = {
88
- binding,
89
- bar,
90
- input,
91
- editSequence: 0,
92
- composing: false,
93
- focused: false,
94
- minimumRevision: 0,
95
- valueVersion: 0,
96
- applyingInput: false,
97
- restore: () => {
98
- if (bar.setFocus === focus)
99
- bar.setFocus = originalFocus;
100
- if (wrapped && Object.getOwnPropertyDescriptor(bar, 'value')?.set === wrapped.set) {
101
- if (ownValue)
102
- Object.defineProperty(bar, 'value', ownValue);
103
- else
104
- Reflect.deleteProperty(bar, 'value');
105
- }
106
- binding.active = binding.focused = false;
107
- },
108
- };
109
- states.set(binding, state);
110
- return state;
111
- };
112
- const readIcon = (element, owner, candidate) => {
113
- const style = getComputedStyle(element);
114
- const rect = element.getBoundingClientRect();
115
- const item = {
116
- id: id(owner),
117
- x: rect.x,
118
- y: rect.y,
119
- width: rect.width,
120
- height: rect.height,
121
- label: text(element),
122
- accessibilityLabel: owner.getAttribute('aria-label') ?? text(element),
123
- disabled: false,
124
- selected: false,
125
- fontSize: parseFloat(style.fontSize),
126
- fontWeight: parseInt(style.fontWeight, 10) || 400,
127
- color: style.color,
128
- };
129
- const icon = element.matches('ion-icon') ? element : element.querySelector('ion-icon');
130
- const svg = icon?.shadowRoot?.querySelector('svg') ?? element.querySelector('svg');
131
- if (svg) {
132
- const source = iconSource(svg);
133
- if (!source)
134
- return;
135
- const iconStyle = getComputedStyle(icon ?? svg);
136
- item.iconWidth = parseFloat(iconStyle.width);
137
- item.iconHeight = parseFloat(iconStyle.height);
138
- const box = svg.viewBox?.baseVal;
139
- if (box?.width && box.height && svg.getAttribute('preserveAspectRatio') !== 'none') {
140
- const scale = Math.min(item.iconWidth / box.width, item.iconHeight / box.height);
141
- item.iconWidth = box.width * scale;
142
- item.iconHeight = box.height * scale;
143
- }
144
- candidate.icons.push({ item, source });
145
- }
146
- else if (!item.label)
147
- return;
148
- return item;
149
- };
150
- return {
151
- keyboard(visible) {
152
- keyboardVisible = visible;
153
- if (!visible) {
154
- for (const [binding, state] of states) {
155
- if (state.keyboardHidden)
156
- binding.tabBar.classList.remove('tab-bar-hidden');
157
- state.keyboardHidden = false;
158
- }
159
- releaseKeyboardResize();
160
- }
161
- schedule();
162
- },
163
- keepSearchTabsVisible() {
164
- if (!keyboardVisible)
165
- return;
166
- for (const [binding, state] of states) {
167
- if (binding.active && projected(binding) && binding.tabBar.classList.contains('tab-bar-hidden')) {
168
- state.keyboardHidden = true;
169
- binding.tabBar.classList.remove('tab-bar-hidden');
170
- }
171
- }
172
- },
173
- decorate(candidates, blocked) {
174
- var _a;
175
- const bindings = getNativeSearchBindings(doc);
176
- for (const [binding, state] of states) {
177
- if (!bindings.includes(binding) || !isCurrent(state)) {
178
- this.retire(binding);
179
- state.restore();
180
- states.delete(binding);
181
- }
182
- }
183
- const inactive = [];
184
- const pageHidden = (element) => !!element.closest('.ion-page-hidden, .ion-page-invisible');
185
- const retainInactive = (candidate, state, keepAvailable = false) => {
186
- if (state?.last)
187
- inactive.push([candidate, { ...state.last, active: false, available: keepAvailable, focused: false }]);
188
- };
189
- for (const binding of bindings) {
190
- const candidate = candidates.find((c) => c.element === binding.tabBar);
191
- if (!candidate || candidate.control.search || binding.tabBar.getAttribute('slot') !== 'bottom')
192
- continue;
193
- const fab = binding.trigger.parentElement;
194
- if (!fab?.matches('ion-fab[slot="fixed"]') ||
195
- !(fab.parentElement?.matches('ion-content') || (fab.parentElement?.matches('.ion-page') && !fab.closest('ion-content'))))
196
- continue;
197
- if (isShellDisabled(fab) || isShellDisabled(binding.footer))
198
- continue;
199
- const pageUnavailable = blocked(binding.footer) || !!binding.footer.closest(excluded);
200
- const existing = states.get(binding);
201
- if (pageUnavailable) {
202
- retainInactive(candidate, existing, !!existing?.last?.available && !pageHidden(binding.footer));
203
- if (existing?.last)
204
- continue;
205
- }
206
- if (binding.active && existing && isCurrent(existing) && existing.last && !pageUnavailable) {
207
- const back = binding.footer.querySelector('ion-buttons[slot=start] ion-button');
208
- if (back && !back.disabled && !back.closest(excluded)) {
209
- candidate.control.search = {
210
- ...existing.last,
211
- active: true,
212
- available: true,
213
- focused: binding.focused,
214
- value: existing.bar.value ?? '',
215
- placeholder: existing.bar.placeholder ?? '',
216
- disabled: existing.bar.disabled,
217
- editSequence: existing.editSequence,
218
- valueVersion: existing.valueVersion,
219
- };
220
- existing.last = candidate.control.search;
221
- candidate.sources = [binding.tabBar, binding.trigger.closest('ion-fab') ?? binding.trigger, binding.footer];
222
- candidate.actions.set(existing.last.trigger.id, binding.trigger);
223
- candidate.actions.set(existing.last.closeId, back);
224
- continue;
225
- }
226
- }
227
- if (!visible(binding.trigger) && !pageUnavailable) {
228
- retainInactive(candidate, existing);
229
- continue;
230
- }
231
- const bar = binding.footer.querySelector('ion-searchbar');
232
- const input = bar?.querySelector('input.searchbar-input');
233
- const back = binding.footer.querySelector('ion-buttons[slot=start] ion-button');
234
- if (!bar ||
235
- !input ||
236
- !back ||
237
- !binding.footer.matches('ion-footer') ||
238
- !inFixedToolbar(bar) ||
239
- !inFixedToolbar(back) ||
240
- (!pageUnavailable && bar.closest(excluded)) ||
241
- !bar.classList.contains('ios') ||
242
- bar.classList.contains('searchbar-classic')) {
243
- retainInactive(candidate, existing);
244
- continue;
245
- }
246
- if (bar.color ||
247
- back.fill !== 'default' ||
248
- back.color ||
249
- bar.maxlength != null ||
250
- bar.minlength != null ||
251
- bar.inputmode ||
252
- bar.enterkeyhint ||
253
- !['off', 'none'].includes(bar.autocapitalize) ||
254
- bar.autocomplete !== 'off' ||
255
- ![false, 'off', undefined].includes(bar.autocorrect) ||
256
- bar.spellcheck ||
257
- bar.showClearButton !== 'always' ||
258
- bar.clearIcon) {
259
- retainInactive(candidate, existing);
260
- continue;
261
- }
262
- if (bar.showCancelButton !== 'never' || bar.type !== 'search' || !getComputedStyle(input).backdropFilter.includes('blur')) {
263
- retainInactive(candidate, existing);
264
- continue;
265
- }
266
- const fabButton = binding.trigger;
267
- const nativeTrigger = fabButton.shadowRoot?.querySelector('[part=native]');
268
- if ((!pageUnavailable && binding.trigger.closest(excluded)) ||
269
- (!pageUnavailable && back.closest(excluded)) ||
270
- back.disabled ||
271
- fabButton.disabled ||
272
- fabButton.color ||
273
- fabButton.type !== 'button' ||
274
- fabButton.href ||
275
- !nativeTrigger ||
276
- getComputedStyle(fabButton).backgroundColor !== 'rgba(0, 0, 0, 0)' ||
277
- !getComputedStyle(nativeTrigger).backdropFilter.includes('blur')) {
278
- retainInactive(candidate, existing);
279
- continue;
280
- }
281
- const state = existing ?? install(binding, bar, input);
282
- const trigger = readIcon(binding.trigger, binding.trigger, candidate);
283
- const searchIcon = bar.querySelector('.searchbar-search-icon');
284
- const field = searchIcon && readIcon(searchIcon, bar, candidate);
285
- if (!trigger || !field) {
286
- retainInactive(candidate, state);
287
- continue;
288
- }
289
- field.label = '';
290
- field.accessibilityLabel = bar.getAttribute('aria-label') ?? input.getAttribute('aria-label') ?? 'Search';
291
- if (!trigger.accessibilityLabel)
292
- trigger.accessibilityLabel = field.accessibilityLabel;
293
- state.layout = JSON.stringify([
294
- innerWidth,
295
- innerHeight,
296
- candidate.control.x,
297
- candidate.control.y,
298
- candidate.control.width,
299
- candidate.control.height,
300
- candidate.control.rtl,
301
- trigger.x,
302
- trigger.y,
303
- trigger.width,
304
- trigger.height,
305
- candidate.control.items,
306
- candidate.icons.map(({ source }) => source),
307
- field,
308
- trigger,
309
- bar.placeholder,
310
- bar.disabled,
311
- ]);
312
- if (state.rejectedLayout === state.layout) {
313
- retainInactive(candidate, state);
314
- continue;
315
- }
316
- const available = !pageUnavailable && visible(binding.trigger);
317
- candidate.control.search = {
318
- id: id(input),
319
- field,
320
- trigger,
321
- closeId: id(back),
322
- active: available && binding.active,
323
- available,
324
- focused: available && binding.focused,
325
- value: bar.value ?? '',
326
- placeholder: bar.placeholder ?? '',
327
- disabled: bar.disabled,
328
- editSequence: state.editSequence,
329
- valueVersion: state.valueVersion,
330
- };
331
- state.last = candidate.control.search;
332
- if (available) {
333
- candidate.sources = [binding.tabBar, binding.trigger.closest('ion-fab') ?? binding.trigger, binding.footer];
334
- candidate.actions.set(id(binding.trigger), binding.trigger);
335
- candidate.actions.set(id(back), back);
336
- }
337
- }
338
- for (const [candidate, configuration] of inactive)
339
- (_a = candidate.control).search ?? (_a.search = configuration);
340
- const groups = candidates.filter((c) => c.control.search);
341
- return candidates.filter((c) => !groups.some((group) => group !== c && group.sources?.some((source) => source.contains(c.element))));
342
- },
343
- projected,
344
- hasActive() {
345
- for (const [binding] of states)
346
- if (binding.active && projected(binding))
347
- return true;
348
- return false;
349
- },
350
- begin(binding, revision) {
351
- const state = states.get(binding);
352
- if (state)
353
- state.minimumRevision = revision;
354
- },
355
- setStatus(binding, active, focused = false) {
356
- if (!active) {
357
- this.retire(binding);
358
- return;
359
- }
360
- binding.active = true;
361
- binding.focused = focused;
362
- holdKeyboardResize();
363
- },
364
- release(element) {
365
- for (const binding of states.keys())
366
- if (binding.footer === element)
367
- this.retire(binding);
368
- },
369
- reject(ids) {
370
- states.forEach((state) => {
371
- if (ids.includes(id(state.binding.tabBar))) {
372
- state.rejectedLayout = state.layout;
373
- state.last = undefined;
374
- }
375
- });
376
- },
377
- event(event) {
378
- const state = Array.from(states.values()).find((s) => id(s.input) === event.id && projected(s.binding) && isCurrent(s));
379
- if (!state ||
380
- !state.binding.active ||
381
- ((event.phase === 'input' || event.phase === 'clear') && event.valueVersion !== state.valueVersion) ||
382
- event.revision < state.minimumRevision ||
383
- event.sequence <= state.editSequence ||
384
- state.bar.disabled)
385
- return;
386
- state.editSequence = event.sequence;
387
- const { input, binding } = state;
388
- if (event.phase === 'input') {
389
- if (state.composing !== event.composing)
390
- input.dispatchEvent(new CompositionEvent(event.composing ? 'compositionstart' : 'compositionend', { bubbles: true, data: event.value }));
391
- state.composing = event.composing;
392
- input.value = event.value;
393
- state.applyingInput = true;
394
- try {
395
- input.dispatchEvent(new InputEvent('input', { bubbles: true, composed: true, isComposing: event.composing }));
396
- }
397
- finally {
398
- state.applyingInput = false;
399
- }
400
- }
401
- else if (event.phase === 'clear') {
402
- state.bar.querySelector('.searchbar-clear-button')?.click();
403
- }
404
- else if (event.phase === 'commit') {
405
- input.dispatchEvent(new Event('change', { bubbles: true }));
406
- }
407
- else {
408
- if (state.focused === (event.phase === 'focus'))
409
- return;
410
- state.focused = binding.focused = event.phase === 'focus';
411
- input.dispatchEvent(new FocusEvent(event.phase, { composed: true }));
412
- }
413
- schedule();
414
- },
415
- retire(binding) {
416
- const state = states.get(binding);
417
- if (state?.keyboardHidden && keyboardVisible)
418
- binding.tabBar.classList.add('tab-bar-hidden');
419
- if (state?.focused) {
420
- state.focused = false;
421
- state.input.dispatchEvent(new FocusEvent('blur'));
422
- }
423
- binding.active = binding.focused = false;
424
- releaseKeyboardResize();
425
- },
426
- destroy() {
427
- states.forEach((state) => {
428
- this.retire(state.binding);
429
- state.restore();
430
- });
431
- states.clear();
432
- releaseKeyboardResize();
433
- },
434
- };
1
+ import { getNativeSearchBindings, requestNativeSearch } from "../../native-integration/index.js";
2
+ import { excluded, inFixedToolbar, isShellDisabled, marker, text, visible } from "../shared/dom.js";
3
+ import { iconSource } from "../shared/icons.js";
4
+ //#region src/native/components/searchable-tabs.ts
5
+ const createSearchSupport = (doc, id, schedule) => {
6
+ const states = /* @__PURE__ */ new Map();
7
+ let keyboardVisible = false;
8
+ let heldKeyboardResize = null;
9
+ let keyboardResizeGeneration = 0;
10
+ const keyboardPlugin = () => doc.defaultView?.Capacitor?.Plugins?.Keyboard;
11
+ const projected = (binding) => binding.footer.hasAttribute(marker);
12
+ const holdKeyboardResize = () => {
13
+ const keyboard = keyboardPlugin();
14
+ if (!keyboard?.setResizeMode || heldKeyboardResize !== null) return;
15
+ const setResizeMode = keyboard.setResizeMode.bind(keyboard);
16
+ const generation = ++keyboardResizeGeneration;
17
+ heldKeyboardResize = "native";
18
+ (async () => {
19
+ let restoreMode = "native";
20
+ try {
21
+ const current = await keyboard.getResizeMode?.();
22
+ if (typeof current?.mode === "string") restoreMode = current.mode;
23
+ } catch {}
24
+ if (generation !== keyboardResizeGeneration) return;
25
+ heldKeyboardResize = restoreMode;
26
+ try {
27
+ await setResizeMode({ mode: "none" });
28
+ } catch {
29
+ if (generation === keyboardResizeGeneration) heldKeyboardResize = null;
30
+ return;
31
+ }
32
+ if (generation !== keyboardResizeGeneration) setResizeMode({ mode: restoreMode }).catch(() => void 0);
33
+ })();
34
+ };
35
+ const hasActiveProjection = () => [...states.keys()].some((binding) => binding.active && projected(binding));
36
+ const releaseKeyboardResize = () => {
37
+ if (hasActiveProjection()) return;
38
+ keyboardResizeGeneration++;
39
+ const mode = heldKeyboardResize;
40
+ heldKeyboardResize = null;
41
+ if (!mode) return;
42
+ keyboardPlugin()?.setResizeMode?.({ mode });
43
+ };
44
+ const isCurrent = (state) => state.bar.isConnected && state.binding.footer.querySelector("ion-searchbar") === state.bar && state.bar.querySelector("input.searchbar-input") === state.input;
45
+ const install = (binding, bar, input) => {
46
+ const originalFocus = bar.setFocus;
47
+ const ownValue = Object.getOwnPropertyDescriptor(bar, "value");
48
+ let owner = bar;
49
+ let value = ownValue;
50
+ while (!value && (owner = Object.getPrototypeOf(owner))) value = Object.getOwnPropertyDescriptor(owner, "value");
51
+ const focus = async () => {
52
+ if (projected(binding) && await requestNativeSearch(binding, true, true)) return;
53
+ await originalFocus.call(bar);
54
+ };
55
+ bar.setFocus = focus;
56
+ let wrapped;
57
+ if (value?.get && value.set && ownValue?.configurable !== false) {
58
+ const descriptor = value;
59
+ wrapped = {
60
+ configurable: true,
61
+ enumerable: value.enumerable,
62
+ get: () => descriptor.get.call(bar),
63
+ set: (next) => {
64
+ if (state.applyingInput) state.applyingInput = false;
65
+ else state.valueVersion++;
66
+ descriptor.set.call(bar, next);
67
+ schedule();
68
+ }
69
+ };
70
+ Object.defineProperty(bar, "value", wrapped);
71
+ }
72
+ const state = {
73
+ binding,
74
+ bar,
75
+ input,
76
+ editSequence: 0,
77
+ composing: false,
78
+ focused: false,
79
+ minimumRevision: 0,
80
+ valueVersion: 0,
81
+ applyingInput: false,
82
+ restore: () => {
83
+ if (bar.setFocus === focus) bar.setFocus = originalFocus;
84
+ if (wrapped && Object.getOwnPropertyDescriptor(bar, "value")?.set === wrapped.set) {
85
+ if (ownValue) Object.defineProperty(bar, "value", ownValue);
86
+ else Reflect.deleteProperty(bar, "value");
87
+ }
88
+ binding.active = binding.focused = false;
89
+ }
90
+ };
91
+ states.set(binding, state);
92
+ return state;
93
+ };
94
+ const readIcon = (element, owner, candidate) => {
95
+ const style = getComputedStyle(element);
96
+ const rect = element.getBoundingClientRect();
97
+ const item = {
98
+ id: id(owner),
99
+ x: rect.x,
100
+ y: rect.y,
101
+ width: rect.width,
102
+ height: rect.height,
103
+ label: text(element),
104
+ accessibilityLabel: owner.getAttribute("aria-label") ?? text(element),
105
+ disabled: false,
106
+ selected: false,
107
+ fontSize: parseFloat(style.fontSize),
108
+ fontWeight: parseInt(style.fontWeight, 10) || 400,
109
+ color: style.color
110
+ };
111
+ const icon = element.matches("ion-icon") ? element : element.querySelector("ion-icon");
112
+ const svg = icon?.shadowRoot?.querySelector("svg") ?? element.querySelector("svg");
113
+ if (svg) {
114
+ const source = iconSource(svg);
115
+ if (!source) return;
116
+ const iconStyle = getComputedStyle(icon ?? svg);
117
+ item.iconWidth = parseFloat(iconStyle.width);
118
+ item.iconHeight = parseFloat(iconStyle.height);
119
+ const box = svg.viewBox?.baseVal;
120
+ if (box?.width && box.height && svg.getAttribute("preserveAspectRatio") !== "none") {
121
+ const scale = Math.min(item.iconWidth / box.width, item.iconHeight / box.height);
122
+ item.iconWidth = box.width * scale;
123
+ item.iconHeight = box.height * scale;
124
+ }
125
+ candidate.icons.push({
126
+ item,
127
+ source
128
+ });
129
+ } else if (!item.label) return;
130
+ return item;
131
+ };
132
+ return {
133
+ keyboard(visible) {
134
+ keyboardVisible = visible;
135
+ if (!visible) {
136
+ for (const [binding, state] of states) {
137
+ if (state.keyboardHidden) binding.tabBar.classList.remove("tab-bar-hidden");
138
+ state.keyboardHidden = false;
139
+ }
140
+ releaseKeyboardResize();
141
+ }
142
+ schedule();
143
+ },
144
+ keepSearchTabsVisible() {
145
+ if (!keyboardVisible) return;
146
+ for (const [binding, state] of states) if (binding.active && projected(binding) && binding.tabBar.classList.contains("tab-bar-hidden")) {
147
+ state.keyboardHidden = true;
148
+ binding.tabBar.classList.remove("tab-bar-hidden");
149
+ }
150
+ },
151
+ decorate(candidates, blocked) {
152
+ var _candidate$control;
153
+ const bindings = getNativeSearchBindings(doc);
154
+ for (const [binding, state] of states) if (!bindings.includes(binding) || !isCurrent(state)) {
155
+ this.retire(binding);
156
+ state.restore();
157
+ states.delete(binding);
158
+ }
159
+ const inactive = [];
160
+ const pageHidden = (element) => !!element.closest(".ion-page-hidden, .ion-page-invisible");
161
+ const retainInactive = (candidate, state, keepAvailable = false) => {
162
+ if (state?.last) inactive.push([candidate, {
163
+ ...state.last,
164
+ active: false,
165
+ available: keepAvailable,
166
+ focused: false
167
+ }]);
168
+ };
169
+ for (const binding of bindings) {
170
+ const candidate = candidates.find((c) => c.element === binding.tabBar);
171
+ if (!candidate || candidate.control.search || binding.tabBar.getAttribute("slot") !== "bottom") continue;
172
+ const fab = binding.trigger.parentElement;
173
+ if (!fab?.matches("ion-fab[slot=\"fixed\"]") || !(fab.parentElement?.matches("ion-content") || fab.parentElement?.matches(".ion-page") && !fab.closest("ion-content"))) continue;
174
+ if (isShellDisabled(fab) || isShellDisabled(binding.footer)) continue;
175
+ const pageUnavailable = blocked(binding.footer) || !!binding.footer.closest(excluded);
176
+ const existing = states.get(binding);
177
+ if (pageUnavailable) {
178
+ retainInactive(candidate, existing, !!existing?.last?.available && !pageHidden(binding.footer));
179
+ if (existing?.last) continue;
180
+ }
181
+ if (binding.active && existing && isCurrent(existing) && existing.last && !pageUnavailable) {
182
+ const back = binding.footer.querySelector("ion-buttons[slot=start] ion-button");
183
+ if (back && !back.disabled && !back.closest(excluded)) {
184
+ candidate.control.search = {
185
+ ...existing.last,
186
+ active: true,
187
+ available: true,
188
+ focused: binding.focused,
189
+ value: existing.bar.value ?? "",
190
+ placeholder: existing.bar.placeholder ?? "",
191
+ disabled: existing.bar.disabled,
192
+ editSequence: existing.editSequence,
193
+ valueVersion: existing.valueVersion
194
+ };
195
+ existing.last = candidate.control.search;
196
+ candidate.sources = [
197
+ binding.tabBar,
198
+ binding.trigger.closest("ion-fab") ?? binding.trigger,
199
+ binding.footer
200
+ ];
201
+ candidate.actions.set(existing.last.trigger.id, binding.trigger);
202
+ candidate.actions.set(existing.last.closeId, back);
203
+ continue;
204
+ }
205
+ }
206
+ if (!visible(binding.trigger) && !pageUnavailable) {
207
+ retainInactive(candidate, existing);
208
+ continue;
209
+ }
210
+ const bar = binding.footer.querySelector("ion-searchbar");
211
+ const input = bar?.querySelector("input.searchbar-input");
212
+ const back = binding.footer.querySelector("ion-buttons[slot=start] ion-button");
213
+ if (!bar || !input || !back || !binding.footer.matches("ion-footer") || !inFixedToolbar(bar) || !inFixedToolbar(back) || !pageUnavailable && bar.closest(excluded) || !bar.classList.contains("ios") || bar.classList.contains("searchbar-classic")) {
214
+ retainInactive(candidate, existing);
215
+ continue;
216
+ }
217
+ if (bar.color || back.fill !== "default" || back.color || bar.maxlength != null || bar.minlength != null || bar.inputmode || bar.enterkeyhint || !["off", "none"].includes(bar.autocapitalize) || bar.autocomplete !== "off" || ![
218
+ false,
219
+ "off",
220
+ void 0
221
+ ].includes(bar.autocorrect) || bar.spellcheck || bar.showClearButton !== "always" || bar.clearIcon) {
222
+ retainInactive(candidate, existing);
223
+ continue;
224
+ }
225
+ if (bar.showCancelButton !== "never" || bar.type !== "search" || !getComputedStyle(input).backdropFilter.includes("blur")) {
226
+ retainInactive(candidate, existing);
227
+ continue;
228
+ }
229
+ const fabButton = binding.trigger;
230
+ const nativeTrigger = fabButton.shadowRoot?.querySelector("[part=native]");
231
+ if (!pageUnavailable && binding.trigger.closest(excluded) || !pageUnavailable && back.closest(excluded) || back.disabled || fabButton.disabled || fabButton.color || fabButton.type !== "button" || fabButton.href || !nativeTrigger || getComputedStyle(fabButton).backgroundColor !== "rgba(0, 0, 0, 0)" || !getComputedStyle(nativeTrigger).backdropFilter.includes("blur")) {
232
+ retainInactive(candidate, existing);
233
+ continue;
234
+ }
235
+ const state = existing ?? install(binding, bar, input);
236
+ const trigger = readIcon(binding.trigger, binding.trigger, candidate);
237
+ const searchIcon = bar.querySelector(".searchbar-search-icon");
238
+ const field = searchIcon && readIcon(searchIcon, bar, candidate);
239
+ if (!trigger || !field) {
240
+ retainInactive(candidate, state);
241
+ continue;
242
+ }
243
+ field.label = "";
244
+ field.accessibilityLabel = bar.getAttribute("aria-label") ?? input.getAttribute("aria-label") ?? "Search";
245
+ if (!trigger.accessibilityLabel) trigger.accessibilityLabel = field.accessibilityLabel;
246
+ state.layout = JSON.stringify([
247
+ innerWidth,
248
+ innerHeight,
249
+ candidate.control.x,
250
+ candidate.control.y,
251
+ candidate.control.width,
252
+ candidate.control.height,
253
+ candidate.control.rtl,
254
+ trigger.x,
255
+ trigger.y,
256
+ trigger.width,
257
+ trigger.height,
258
+ candidate.control.items,
259
+ candidate.icons.map(({ source }) => source),
260
+ field,
261
+ trigger,
262
+ bar.placeholder,
263
+ bar.disabled
264
+ ]);
265
+ if (state.rejectedLayout === state.layout) {
266
+ retainInactive(candidate, state);
267
+ continue;
268
+ }
269
+ const available = !pageUnavailable && visible(binding.trigger);
270
+ candidate.control.search = {
271
+ id: id(input),
272
+ field,
273
+ trigger,
274
+ closeId: id(back),
275
+ active: available && binding.active,
276
+ available,
277
+ focused: available && binding.focused,
278
+ value: bar.value ?? "",
279
+ placeholder: bar.placeholder ?? "",
280
+ disabled: bar.disabled,
281
+ editSequence: state.editSequence,
282
+ valueVersion: state.valueVersion
283
+ };
284
+ state.last = candidate.control.search;
285
+ if (available) {
286
+ candidate.sources = [
287
+ binding.tabBar,
288
+ binding.trigger.closest("ion-fab") ?? binding.trigger,
289
+ binding.footer
290
+ ];
291
+ candidate.actions.set(id(binding.trigger), binding.trigger);
292
+ candidate.actions.set(id(back), back);
293
+ }
294
+ }
295
+ for (const [candidate, configuration] of inactive) (_candidate$control = candidate.control).search ?? (_candidate$control.search = configuration);
296
+ const groups = candidates.filter((c) => c.control.search);
297
+ return candidates.filter((c) => !groups.some((group) => group !== c && group.sources?.some((source) => source.contains(c.element))));
298
+ },
299
+ projected,
300
+ hasActive() {
301
+ for (const [binding] of states) if (binding.active && projected(binding)) return true;
302
+ return false;
303
+ },
304
+ begin(binding, revision) {
305
+ const state = states.get(binding);
306
+ if (state) state.minimumRevision = revision;
307
+ },
308
+ /** Enter / focus / leave. `focused` is ignored when leaving. */
309
+ setStatus(binding, active, focused = false) {
310
+ if (!active) {
311
+ this.retire(binding);
312
+ return;
313
+ }
314
+ binding.active = true;
315
+ binding.focused = focused;
316
+ holdKeyboardResize();
317
+ },
318
+ release(element) {
319
+ for (const binding of states.keys()) if (binding.footer === element) this.retire(binding);
320
+ },
321
+ reject(ids) {
322
+ states.forEach((state) => {
323
+ if (ids.includes(id(state.binding.tabBar))) {
324
+ state.rejectedLayout = state.layout;
325
+ state.last = void 0;
326
+ }
327
+ });
328
+ },
329
+ event(event) {
330
+ const state = Array.from(states.values()).find((s) => id(s.input) === event.id && projected(s.binding) && isCurrent(s));
331
+ if (!state || !state.binding.active || (event.phase === "input" || event.phase === "clear") && event.valueVersion !== state.valueVersion || event.revision < state.minimumRevision || event.sequence <= state.editSequence || state.bar.disabled) return;
332
+ state.editSequence = event.sequence;
333
+ const { input, binding } = state;
334
+ if (event.phase === "input") {
335
+ if (state.composing !== event.composing) input.dispatchEvent(new CompositionEvent(event.composing ? "compositionstart" : "compositionend", {
336
+ bubbles: true,
337
+ data: event.value
338
+ }));
339
+ state.composing = event.composing;
340
+ input.value = event.value;
341
+ state.applyingInput = true;
342
+ try {
343
+ input.dispatchEvent(new InputEvent("input", {
344
+ bubbles: true,
345
+ composed: true,
346
+ isComposing: event.composing
347
+ }));
348
+ } finally {
349
+ state.applyingInput = false;
350
+ }
351
+ } else if (event.phase === "clear") state.bar.querySelector(".searchbar-clear-button")?.click();
352
+ else if (event.phase === "commit") input.dispatchEvent(new Event("change", { bubbles: true }));
353
+ else {
354
+ if (state.focused === (event.phase === "focus")) return;
355
+ state.focused = binding.focused = event.phase === "focus";
356
+ input.dispatchEvent(new FocusEvent(event.phase, { composed: true }));
357
+ }
358
+ schedule();
359
+ },
360
+ retire(binding) {
361
+ const state = states.get(binding);
362
+ if (state?.keyboardHidden && keyboardVisible) binding.tabBar.classList.add("tab-bar-hidden");
363
+ if (state?.focused) {
364
+ state.focused = false;
365
+ state.input.dispatchEvent(new FocusEvent("blur"));
366
+ }
367
+ binding.active = binding.focused = false;
368
+ releaseKeyboardResize();
369
+ },
370
+ destroy() {
371
+ states.forEach((state) => {
372
+ this.retire(state.binding);
373
+ state.restore();
374
+ });
375
+ states.clear();
376
+ releaseKeyboardResize();
377
+ }
378
+ };
435
379
  };
380
+ //#endregion
381
+ export { createSearchSupport };
382
+
383
+ //# sourceMappingURL=searchable-tabs.js.map