@rdlabo/ionic-theme-ios27 1.2.0-beta.pr246.sha237333ceac21 → 1.2.0-beta.pr250.shad283a4c2bd44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/components/ion-menu.css +1 -1
- package/dist/css/ionic-theme-ios27.css +1 -1
- package/dist/css/utils/searchable.css +1 -1
- package/dist/css/vertical-bars.css +1 -1
- package/dist/native/components/searchable-tabs.js +1 -1
- package/dist/native/components/searchable-tabs.js.map +1 -1
- package/dist/native/vertical-bars-web-search.d.ts +9 -0
- package/dist/native/vertical-bars-web-search.d.ts.map +1 -0
- package/dist/native/vertical-bars-web-search.js +84 -0
- package/dist/native/vertical-bars-web-search.js.map +1 -0
- package/dist/native/vertical-bars-web.d.ts.map +1 -1
- package/dist/native/vertical-bars-web.js +20 -16
- package/dist/native/vertical-bars-web.js.map +1 -1
- package/dist/tab-bar-searchable/dismiss-button.d.ts +4 -0
- package/dist/tab-bar-searchable/dismiss-button.d.ts.map +1 -0
- package/dist/tab-bar-searchable/dismiss-button.js +34 -0
- package/dist/tab-bar-searchable/dismiss-button.js.map +1 -0
- package/dist/tab-bar-searchable/index.d.ts.map +1 -1
- package/dist/tab-bar-searchable/index.js +6 -0
- package/dist/tab-bar-searchable/index.js.map +1 -1
- package/docs/native-ui-shell.md +3 -3
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellSearchController.swift +65 -91
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellTabBar.swift +9 -3
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellVerticalBars.swift +13 -0
- package/package.json +1 -1
- package/src/native/components/searchable-tabs.ts +2 -2
- package/src/native/vertical-bars-web-search.ts +80 -0
- package/src/native/vertical-bars-web.ts +30 -12
- package/src/styles/components/ion-menu.scss +2 -2
- package/src/styles/ionic-theme-ios27.scss +2 -0
- package/src/styles/utils/searchable.scss +80 -0
- package/src/styles/vertical-bars.scss +32 -0
- package/src/tab-bar-searchable/dismiss-button.ts +33 -0
- package/src/tab-bar-searchable/index.ts +6 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rdlabo/ionic-theme-ios27",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.2.0-beta.
|
|
4
|
+
"version": "1.2.0-beta.pr250.shad283a4c2bd44",
|
|
5
5
|
"description": "iOS27 Theme for Ionic Framework",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -202,7 +202,7 @@ export const createSearchSupport = (doc: Document, id: (element: Element) => str
|
|
|
202
202
|
const retainInactive = (candidate: Candidate, state?: SearchState, keepAvailable = false) => {
|
|
203
203
|
// Keep ShellSearchController across page transitions instead of demoting to UITabBar.
|
|
204
204
|
// While the searchable page is only blocked mid-transition (not yet hidden), keep
|
|
205
|
-
// available:true so
|
|
205
|
+
// available:true so the system search button stays available over album content.
|
|
206
206
|
if (state?.last) inactive.push([candidate, { ...state.last, active: false, available: keepAvailable, focused: false }]);
|
|
207
207
|
};
|
|
208
208
|
for (const binding of bindings) {
|
|
@@ -226,7 +226,7 @@ export const createSearchSupport = (doc: Document, id: (element: Element) => str
|
|
|
226
226
|
if (binding.active && existing && isCurrent(existing) && existing.last && !pageUnavailable) {
|
|
227
227
|
const back = binding.footer.querySelector<HTMLIonButtonElement>('ion-buttons[slot=start] ion-button');
|
|
228
228
|
// Close must stay eligible; otherwise fall through and demote instead of caching active.
|
|
229
|
-
if (back && !back.disabled && !back.closest(excluded)) {
|
|
229
|
+
if (back && !back.disabled && !back.closest(excluded) && !existing.bar.closest(excluded)) {
|
|
230
230
|
candidate.control.search = {
|
|
231
231
|
...existing.last,
|
|
232
232
|
active: true,
|
|
@@ -0,0 +1,80 @@
|
|
|
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 = () => {
|
|
14
|
+
iconObserver.disconnect();
|
|
15
|
+
container?.remove();
|
|
16
|
+
container = undefined;
|
|
17
|
+
projection = undefined;
|
|
18
|
+
if (binding) {
|
|
19
|
+
binding.trigger.removeAttribute(marker);
|
|
20
|
+
if (previousAriaHidden === null) binding.trigger.removeAttribute('aria-hidden');
|
|
21
|
+
else binding.trigger.setAttribute('aria-hidden', previousAriaHidden);
|
|
22
|
+
}
|
|
23
|
+
binding = undefined;
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
restore,
|
|
27
|
+
get source() {
|
|
28
|
+
return binding?.trigger;
|
|
29
|
+
},
|
|
30
|
+
update(root: HTMLElement) {
|
|
31
|
+
const next = unprojected(binding ? [binding.trigger] : [], () =>
|
|
32
|
+
getNativeSearchBindings(doc).find(({ trigger, footer }) => eligible(trigger) && eligible(footer)),
|
|
33
|
+
);
|
|
34
|
+
if (next !== binding || container?.parentElement !== root) restore();
|
|
35
|
+
if (!next) return;
|
|
36
|
+
if (!projection) {
|
|
37
|
+
binding = next;
|
|
38
|
+
previousAriaHidden = next.trigger.getAttribute('aria-hidden');
|
|
39
|
+
projection = next.trigger.cloneNode(true) as HTMLIonFabButtonElement;
|
|
40
|
+
for (const name of ['id', 'slot', marker, 'aria-hidden', 'style']) projection.removeAttribute(name);
|
|
41
|
+
container = doc.createElement('ion-fab');
|
|
42
|
+
container.setAttribute('mode', (next.trigger as HTMLIonFabButtonElement).mode ?? 'ios');
|
|
43
|
+
container.classList.add(searchProjectionClass, 'ion-cloned-element');
|
|
44
|
+
projection.addEventListener(
|
|
45
|
+
'click',
|
|
46
|
+
(event) => {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
event.stopImmediatePropagation();
|
|
49
|
+
activateProjectedElement(next.trigger);
|
|
50
|
+
},
|
|
51
|
+
{ capture: true },
|
|
52
|
+
);
|
|
53
|
+
container.append(projection);
|
|
54
|
+
root.append(container);
|
|
55
|
+
next.trigger.setAttribute(marker, '');
|
|
56
|
+
next.trigger.setAttribute('aria-hidden', 'true');
|
|
57
|
+
}
|
|
58
|
+
projection.setAttribute(
|
|
59
|
+
'aria-label',
|
|
60
|
+
next.trigger.getAttribute('aria-label') ?? next.footer.querySelector('ion-searchbar')?.getAttribute('aria-label') ?? 'Search',
|
|
61
|
+
);
|
|
62
|
+
const sourceIcon = next.trigger.querySelector('ion-icon');
|
|
63
|
+
const icon = projection.querySelector('ion-icon');
|
|
64
|
+
if (sourceIcon?.shadowRoot) iconObserver.observe(sourceIcon.shadowRoot, { subtree: true, childList: true, attributes: true });
|
|
65
|
+
if (sourceIcon && icon) {
|
|
66
|
+
icon.icon = sourceIcon.icon;
|
|
67
|
+
icon.name = sourceIcon.name;
|
|
68
|
+
icon.src = sourceIcon.src;
|
|
69
|
+
}
|
|
70
|
+
container!.hidden = next.trigger.style.pointerEvents === 'none';
|
|
71
|
+
projection.disabled = (next.trigger as HTMLIonFabButtonElement).disabled;
|
|
72
|
+
const bounds = next.tabBar.getBoundingClientRect();
|
|
73
|
+
const tabs = bounds.width > 0 && bounds.height > 0 && getComputedStyle(next.tabBar).visibility === 'visible' ? bounds : undefined;
|
|
74
|
+
container!.style.left = tabs ? `${tabs.left + (tabs.width - 46) / 2}px` : '';
|
|
75
|
+
container!.style.top = tabs ? `${tabs.top - 56}px` : '';
|
|
76
|
+
container!.style.right = tabs ? 'auto' : '';
|
|
77
|
+
container!.style.bottom = tabs ? 'auto' : '';
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createVerticalBarsWebSearch, searchProjectionClass } from './vertical-bars-web-search';
|
|
1
2
|
import { inVerticalBarsSurface, topModal } from './shared/modal';
|
|
2
3
|
import type { NativeUIShellHandle, NativeUIShellOptions, NativeUIShellStatus } from './definitions';
|
|
3
4
|
import { VERTICAL_BARS_TRANSITION_CANCELED } from '../native-integration';
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
verticalBarsEnteringPage,
|
|
10
11
|
verticalBarsToolbarActions,
|
|
11
12
|
isExcluded,
|
|
13
|
+
isShellDisabled,
|
|
12
14
|
isVerticalBarsToolbarGroup,
|
|
13
15
|
preferredVerticalBarsBack,
|
|
14
16
|
verticalBarsOwned,
|
|
@@ -42,12 +44,7 @@ export const createVerticalBarsWebProjection = (
|
|
|
42
44
|
enabled: () => boolean = () => true,
|
|
43
45
|
): NativeUIShellHandle => {
|
|
44
46
|
const win = doc.defaultView!;
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
getStatus: () => ({ state: 'web', projected: 0, updates: 0 }),
|
|
48
|
-
suspend: async () => ({ resume: async () => {} }),
|
|
49
|
-
destroy: async () => {},
|
|
50
|
-
};
|
|
47
|
+
const toolbarEnabled = options.controls === undefined || options.controls.toolbar === true;
|
|
51
48
|
let root: HTMLElement | undefined;
|
|
52
49
|
let backSource: HTMLIonBackButtonElement | undefined;
|
|
53
50
|
let backProjection: HTMLIonBackButtonElement | undefined;
|
|
@@ -64,7 +61,7 @@ export const createVerticalBarsWebProjection = (
|
|
|
64
61
|
const listeners = new AbortController();
|
|
65
62
|
const verticalBarsRoot = () => doc.querySelector<HTMLElement>('ion-app.ios-theme-vertical-bars');
|
|
66
63
|
const projectedSources = () =>
|
|
67
|
-
[backSource, ...toolbarProjections.flatMap(({ actions }) => actions.map(({ source }) => source))].filter(
|
|
64
|
+
[backSource, search.source, ...toolbarProjections.flatMap(({ actions }) => actions.map(({ source }) => source))].filter(
|
|
68
65
|
(source): source is HTMLElement => !!source,
|
|
69
66
|
);
|
|
70
67
|
const isRendered = (element: HTMLElement) =>
|
|
@@ -73,6 +70,20 @@ export const createVerticalBarsWebProjection = (
|
|
|
73
70
|
const rect = element.getBoundingClientRect();
|
|
74
71
|
return element.isConnected && style.display !== 'none' && style.visibility === 'visible' && rect.width > 0 && rect.height > 0;
|
|
75
72
|
});
|
|
73
|
+
const search = createVerticalBarsWebSearch(
|
|
74
|
+
doc,
|
|
75
|
+
(element) =>
|
|
76
|
+
(options.controls === undefined || options.controls.tabs === true) &&
|
|
77
|
+
!!verticalBarsRoot()?.contains(element) &&
|
|
78
|
+
inVerticalBarsSurface(element) &&
|
|
79
|
+
!isExcluded(element, verticalBarsEnteringPage(element)) &&
|
|
80
|
+
!isShellDisabled(element) &&
|
|
81
|
+
!verticalBarsPages.isDeparted(element) &&
|
|
82
|
+
isRendered(element),
|
|
83
|
+
() => {
|
|
84
|
+
void schedule();
|
|
85
|
+
},
|
|
86
|
+
);
|
|
76
87
|
const inEligibleToolbar = (element: HTMLElement) =>
|
|
77
88
|
!!verticalBarsRoot()?.contains(element) &&
|
|
78
89
|
inVerticalBarsSurface(element) &&
|
|
@@ -108,6 +119,7 @@ export const createVerticalBarsWebProjection = (
|
|
|
108
119
|
};
|
|
109
120
|
const isCurrentToolbarAction = (source: HTMLElement) => findToolbarGroups().some(({ actions }) => actions.includes(source));
|
|
110
121
|
const restore = () => {
|
|
122
|
+
search.restore();
|
|
111
123
|
backProjection?.remove();
|
|
112
124
|
backProjection = undefined;
|
|
113
125
|
if (backSource) {
|
|
@@ -272,12 +284,15 @@ export const createVerticalBarsWebProjection = (
|
|
|
272
284
|
});
|
|
273
285
|
}
|
|
274
286
|
if (stopped || suspended || !currentRoot || !enabled()) return restore();
|
|
275
|
-
const nextBack = findBack();
|
|
276
|
-
const groups = findToolbarGroups();
|
|
277
|
-
|
|
287
|
+
const nextBack = toolbarEnabled ? findBack() : undefined;
|
|
288
|
+
const groups = toolbarEnabled ? findToolbarGroups() : [];
|
|
289
|
+
const projectionRoot = topModal(doc) ?? currentRoot;
|
|
290
|
+
search.update(projectionRoot);
|
|
291
|
+
if (!nextBack && !groups.length && !search.source) return restore();
|
|
278
292
|
if (root === (topModal(doc) ?? currentRoot) && sameSources(nextBack, groups)) return syncExisting();
|
|
279
293
|
restore();
|
|
280
294
|
project(nextBack, groups);
|
|
295
|
+
search.update(projectionRoot);
|
|
281
296
|
updates++;
|
|
282
297
|
};
|
|
283
298
|
const update = () => {
|
|
@@ -304,7 +319,9 @@ export const createVerticalBarsWebProjection = (
|
|
|
304
319
|
const element = target instanceof Element ? target : target.parentNode instanceof Element ? target.parentNode : undefined;
|
|
305
320
|
const rootNode = target.getRootNode();
|
|
306
321
|
const shadowHost = rootNode instanceof ShadowRoot ? rootNode.host : undefined;
|
|
307
|
-
return !![element, shadowHost].some((candidate) =>
|
|
322
|
+
return !![element, shadowHost].some((candidate) =>
|
|
323
|
+
candidate?.closest(`.${backProjectionClass}, .${toolbarProjectionClass}, .${searchProjectionClass}`),
|
|
324
|
+
);
|
|
308
325
|
};
|
|
309
326
|
const verticalBarsChanged = records.some(
|
|
310
327
|
(record) =>
|
|
@@ -351,7 +368,8 @@ export const createVerticalBarsWebProjection = (
|
|
|
351
368
|
return {
|
|
352
369
|
getStatus: (): NativeUIShellStatus => ({
|
|
353
370
|
state: stopped ? 'stopped' : 'web',
|
|
354
|
-
projected:
|
|
371
|
+
projected:
|
|
372
|
+
Number(!!backSource) + Number(!!search.source) + toolbarProjections.reduce((count, group) => count + group.actions.length, 0),
|
|
355
373
|
updates,
|
|
356
374
|
}),
|
|
357
375
|
async suspend() {
|
|
@@ -41,7 +41,7 @@ ion-split-pane.ios:not(.ios-theme-disabled, .ios26-disabled).split-pane-visible:
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
ion-footer ion-toolbar {
|
|
44
|
-
--padding-start: var(--ios-theme-menu-width, var(--ios26-menu-width));
|
|
44
|
+
--padding-start: calc(var(--ios-theme-menu-width, var(--ios26-menu-width)) + var(--ios-theme-searchable-padding-start, 0px));
|
|
45
45
|
}
|
|
46
46
|
ion-tab-bar.ios:not(.ios-theme-disabled, .ios26-disabled):not(:where(.ios-theme-vertical-bars *)) {
|
|
47
47
|
&[slot='bottom'] {
|
|
@@ -75,7 +75,7 @@ ion-split-pane.ios:not(.ios-theme-disabled, .ios26-disabled).split-pane-visible:
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
ion-footer ion-toolbar {
|
|
78
|
-
--padding-end: var(--ios-theme-menu-width, var(--ios26-menu-width));
|
|
78
|
+
--padding-end: calc(var(--ios-theme-menu-width, var(--ios26-menu-width)) + var(--ios-theme-searchable-padding-end, 0px));
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// UISearchTab keeps a compact selected-tab button until editing starts.
|
|
2
|
+
ion-footer.ios.ios-theme-searchable:not(.ios-theme-disabled, .ios26-disabled):has(
|
|
3
|
+
ion-searchbar.ios:not(.ios-theme-disabled, .ios26-disabled, .searchbar-classic)
|
|
4
|
+
) {
|
|
5
|
+
> ion-toolbar {
|
|
6
|
+
--ios-theme-searchable-padding-start: 16px;
|
|
7
|
+
--ios-theme-searchable-padding-end: 20px;
|
|
8
|
+
--padding-start: var(--ios-theme-searchable-padding-start);
|
|
9
|
+
--padding-end: var(--ios-theme-searchable-padding-end);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
ion-buttons[slot='start'],
|
|
13
|
+
.ios-theme-searchable-dismiss {
|
|
14
|
+
margin-inline: 0;
|
|
15
|
+
|
|
16
|
+
ion-button {
|
|
17
|
+
width: 48px;
|
|
18
|
+
height: 48px;
|
|
19
|
+
--border-radius: 50%;
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.ios-theme-searchable-editing {
|
|
25
|
+
> ion-toolbar {
|
|
26
|
+
// Searchbar padding (8px) and container margin (4px) complete the 16px tab-bar inset.
|
|
27
|
+
--ios-theme-searchable-padding-start: 4px;
|
|
28
|
+
--ios-theme-searchable-padding-end: 8px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ion-searchbar.ios:not(.ios-theme-disabled, .ios26-disabled, .searchbar-classic) {
|
|
32
|
+
padding-inline: 8px 12px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ion-buttons[slot='start'] {
|
|
36
|
+
display: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.ios-theme-searchable-dismiss {
|
|
40
|
+
display: flex !important;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ion-searchbar.ios:not(.ios-theme-disabled, .ios26-disabled, .searchbar-classic) {
|
|
45
|
+
--border-radius: 24px;
|
|
46
|
+
padding-inline: 12px;
|
|
47
|
+
|
|
48
|
+
input.searchbar-input {
|
|
49
|
+
min-height: 48px;
|
|
50
|
+
padding-inline-end: 40px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Clear edits the value; the separate close button dismisses without clearing.
|
|
54
|
+
.searchbar-clear-button {
|
|
55
|
+
position: absolute;
|
|
56
|
+
inset-inline-end: 12px;
|
|
57
|
+
width: 20px;
|
|
58
|
+
height: 20px;
|
|
59
|
+
min-width: 20px;
|
|
60
|
+
min-height: 20px;
|
|
61
|
+
background: none;
|
|
62
|
+
box-shadow: none;
|
|
63
|
+
backdrop-filter: none;
|
|
64
|
+
|
|
65
|
+
ion-icon {
|
|
66
|
+
width: 20px;
|
|
67
|
+
height: 20px;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The hidden trigger's container must not cover the focused dismissal button.
|
|
74
|
+
ion-fab.ios-theme-searchable-trigger {
|
|
75
|
+
pointer-events: none;
|
|
76
|
+
|
|
77
|
+
> ion-fab-button {
|
|
78
|
+
pointer-events: auto;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -417,3 +417,35 @@ ion-tab-button.ios.ion-cloned-element.ios27-vertical-tab-effect {
|
|
|
417
417
|
height: 100%;
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
+
|
|
421
|
+
// Search shares the Web rail before Native UI Shell takes ownership.
|
|
422
|
+
:is(ion-app.ios-theme-vertical-bars, ion-modal.ios-theme-vertical-bars-modal) > ion-fab.ios-theme-vertical-bars-search-projection {
|
|
423
|
+
position: fixed;
|
|
424
|
+
left: auto;
|
|
425
|
+
right: 25px;
|
|
426
|
+
top: auto;
|
|
427
|
+
bottom: 24px;
|
|
428
|
+
z-index: 3;
|
|
429
|
+
width: 46px;
|
|
430
|
+
height: 46px;
|
|
431
|
+
margin: 0;
|
|
432
|
+
> ion-fab-button {
|
|
433
|
+
width: 46px;
|
|
434
|
+
height: 46px;
|
|
435
|
+
margin: 0;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
ion-app.ios-theme-vertical-bars ion-fab > ion-fab-button[data-native-ui-shell] {
|
|
440
|
+
visibility: hidden !important;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.ios-theme-vertical-bars-search-projection[hidden] {
|
|
444
|
+
display: none !important;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
ion-app.ios-theme-vertical-bars-left > ion-fab.ios-theme-vertical-bars-search-projection,
|
|
448
|
+
ion-app.ios-theme-vertical-bars-left ion-modal.ios-theme-vertical-bars-modal > ion-fab.ios-theme-vertical-bars-search-projection {
|
|
449
|
+
left: 25px;
|
|
450
|
+
right: auto;
|
|
451
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { close } from 'ionicons/icons';
|
|
2
|
+
|
|
3
|
+
/** Keep the application's original dismissal handler for the focused search layout. */
|
|
4
|
+
export const addSearchDismissButton = (footer: HTMLElement): void => {
|
|
5
|
+
if (footer.querySelector('.ios-theme-searchable-dismiss')) return;
|
|
6
|
+
const original = footer.querySelector<HTMLElement>('ion-buttons[slot=start] ion-button');
|
|
7
|
+
if (!original) return;
|
|
8
|
+
const buttons = footer.ownerDocument.createElement('ion-buttons');
|
|
9
|
+
buttons.slot = 'end';
|
|
10
|
+
// Remain hidden when the full theme is absent or opted out.
|
|
11
|
+
buttons.style.display = 'none';
|
|
12
|
+
buttons.classList.add('ios-theme-searchable-dismiss', 'ios-theme-horizontal-only');
|
|
13
|
+
const button = footer.ownerDocument.createElement('ion-button');
|
|
14
|
+
button.fill = 'default';
|
|
15
|
+
button.type = 'button';
|
|
16
|
+
button.setAttribute('aria-label', original.getAttribute('aria-label') ?? 'Close');
|
|
17
|
+
// Keep the field focused until click; blur would hide this button before dismissal.
|
|
18
|
+
button.addEventListener('pointerdown', (event) => event.preventDefault());
|
|
19
|
+
button.addEventListener('click', () => original.click());
|
|
20
|
+
const icon = footer.ownerDocument.createElement('ion-icon');
|
|
21
|
+
icon.slot = 'icon-only';
|
|
22
|
+
icon.icon = close;
|
|
23
|
+
button.append(icon);
|
|
24
|
+
buttons.append(button);
|
|
25
|
+
// Keep the editing layout while focus moves from clear to the slotted close button.
|
|
26
|
+
footer.addEventListener('focusin', (event) => {
|
|
27
|
+
if ((event.target as HTMLElement).closest('ion-searchbar')) footer.classList.add('ios-theme-searchable-editing');
|
|
28
|
+
});
|
|
29
|
+
footer.addEventListener('focusout', (event) => {
|
|
30
|
+
if (!footer.contains(event.relatedTarget as Node | null)) footer.classList.remove('ios-theme-searchable-editing');
|
|
31
|
+
});
|
|
32
|
+
original.closest('ion-toolbar')?.append(buttons);
|
|
33
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAnimation } from '@ionic/core';
|
|
2
|
+
import { addSearchDismissButton } from './dismiss-button';
|
|
2
3
|
import {
|
|
3
4
|
ANIMATION_DELAY_BASE,
|
|
4
5
|
ANIMATION_DURATION,
|
|
@@ -62,6 +63,9 @@ export const attachTabBarSearchable = (
|
|
|
62
63
|
throw new Error('TabBarSearchable should be defined with props');
|
|
63
64
|
}
|
|
64
65
|
// Initialize
|
|
66
|
+
ionFooter.classList.add('ios-theme-searchable');
|
|
67
|
+
ionFabButton.closest('ion-fab')?.classList.add('ios-theme-searchable-trigger');
|
|
68
|
+
addSearchDismissButton(ionFooter);
|
|
65
69
|
ionFooter.style.pointerEvents = 'none';
|
|
66
70
|
ionFooter.style.opacity = '0';
|
|
67
71
|
// Search dismissal belongs beside the Web search field, never in the vertical rail.
|
|
@@ -191,6 +195,8 @@ const leaveEvent = async (
|
|
|
191
195
|
throw throwErrorByFailedClickElement('ion-buttons[slot=start] ion-button');
|
|
192
196
|
}
|
|
193
197
|
|
|
198
|
+
const focused = ionFooter.ownerDocument.activeElement;
|
|
199
|
+
if (focused instanceof HTMLElement && ionFooter.contains(focused)) focused.blur();
|
|
194
200
|
const references = getElementReferences(ionTabBar, ionFooter);
|
|
195
201
|
|
|
196
202
|
const tabAnimations = verticalSearch
|