UNPKG

7.82 kBJavaScriptView Raw
1/*!
2 * (C) Ionic http://ionicframework.com - MIT License
3 */
4import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
5import { b as getIonMode } from './ionic-global.js';
6import { c as createColorClasses } from './theme.js';
7
8const tabBarIosCss = ":host{padding-left:var(--ion-safe-area-left);padding-right:var(--ion-safe-area-right);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:auto;padding-bottom:var(--ion-safe-area-bottom, 0);border-top:var(--border);background:var(--background);color:var(--color);text-align:center;contain:strict;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:10;-webkit-box-sizing:content-box !important;box-sizing:content-box !important}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){:host{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--ion-safe-area-left);padding-inline-start:var(--ion-safe-area-left);-webkit-padding-end:var(--ion-safe-area-right);padding-inline-end:var(--ion-safe-area-right)}}:host(.ion-color) ::slotted(ion-tab-button){--background-focused:var(--ion-color-shade);--color-selected:var(--ion-color-contrast)}:host(.ion-color) ::slotted(.tab-selected){color:var(--ion-color-contrast)}:host(.ion-color),:host(.ion-color) ::slotted(ion-tab-button){color:rgba(var(--ion-color-contrast-rgb), 0.7)}:host(.ion-color),:host(.ion-color) ::slotted(ion-tab-button){background:var(--ion-color-base)}:host(.ion-color) ::slotted(ion-tab-button.ion-focused),:host(.tab-bar-translucent) ::slotted(ion-tab-button.ion-focused){background:var(--background-focused)}:host(.tab-bar-translucent) ::slotted(ion-tab-button){background:transparent}:host([slot=top]){padding-top:var(--ion-safe-area-top, 0);padding-bottom:0;border-top:0;border-bottom:var(--border)}:host(.tab-bar-hidden){display:none !important}:host{--background:var(--ion-tab-bar-background, var(--ion-color-step-50, #f7f7f7));--background-focused:var(--ion-tab-bar-background-focused, #e0e0e0);--border:0.55px solid var(--ion-tab-bar-border-color, var(--ion-border-color, var(--ion-color-step-150, rgba(0, 0, 0, 0.2))));--color:var(--ion-tab-bar-color, var(--ion-color-step-400, #999999));--color-selected:var(--ion-tab-bar-color-selected, var(--ion-color-primary, #3880ff));height:50px}@supports ((-webkit-backdrop-filter: blur(0)) or (backdrop-filter: blur(0))){:host(.tab-bar-translucent){--background:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.8);-webkit-backdrop-filter:saturate(210%) blur(20px);backdrop-filter:saturate(210%) blur(20px)}:host(.ion-color.tab-bar-translucent){background:rgba(var(--ion-color-base-rgb), 0.8)}:host(.tab-bar-translucent) ::slotted(ion-tab-button.ion-focused){background:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.6)}}";
9
10const tabBarMdCss = ":host{padding-left:var(--ion-safe-area-left);padding-right:var(--ion-safe-area-right);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:auto;padding-bottom:var(--ion-safe-area-bottom, 0);border-top:var(--border);background:var(--background);color:var(--color);text-align:center;contain:strict;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:10;-webkit-box-sizing:content-box !important;box-sizing:content-box !important}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){:host{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--ion-safe-area-left);padding-inline-start:var(--ion-safe-area-left);-webkit-padding-end:var(--ion-safe-area-right);padding-inline-end:var(--ion-safe-area-right)}}:host(.ion-color) ::slotted(ion-tab-button){--background-focused:var(--ion-color-shade);--color-selected:var(--ion-color-contrast)}:host(.ion-color) ::slotted(.tab-selected){color:var(--ion-color-contrast)}:host(.ion-color),:host(.ion-color) ::slotted(ion-tab-button){color:rgba(var(--ion-color-contrast-rgb), 0.7)}:host(.ion-color),:host(.ion-color) ::slotted(ion-tab-button){background:var(--ion-color-base)}:host(.ion-color) ::slotted(ion-tab-button.ion-focused),:host(.tab-bar-translucent) ::slotted(ion-tab-button.ion-focused){background:var(--background-focused)}:host(.tab-bar-translucent) ::slotted(ion-tab-button){background:transparent}:host([slot=top]){padding-top:var(--ion-safe-area-top, 0);padding-bottom:0;border-top:0;border-bottom:var(--border)}:host(.tab-bar-hidden){display:none !important}:host{--background:var(--ion-tab-bar-background, var(--ion-background-color, #fff));--background-focused:var(--ion-tab-bar-background-focused, #e0e0e0);--border:1px solid var(--ion-tab-bar-border-color, var(--ion-border-color, var(--ion-color-step-150, rgba(0, 0, 0, 0.07))));--color:var(--ion-tab-bar-color, var(--ion-color-step-600, #666666));--color-selected:var(--ion-tab-bar-color-selected, var(--ion-color-primary, #3880ff));height:56px}";
11
12const TabBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
13 constructor() {
14 super();
15 this.__registerHost();
16 this.__attachShadow();
17 this.ionTabBarChanged = createEvent(this, "ionTabBarChanged", 7);
18 this.keyboardVisible = false;
19 /**
20 * If `true`, the tab bar will be translucent.
21 * Only applies when the mode is `"ios"` and the device supports
22 * [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
23 */
24 this.translucent = false;
25 }
26 selectedTabChanged() {
27 if (this.selectedTab !== undefined) {
28 this.ionTabBarChanged.emit({
29 tab: this.selectedTab
30 });
31 }
32 }
33 componentWillLoad() {
34 this.selectedTabChanged();
35 }
36 connectedCallback() {
37 if (typeof window !== 'undefined') {
38 this.keyboardWillShowHandler = () => {
39 if (this.el.getAttribute('slot') !== 'top') {
40 this.keyboardVisible = true;
41 }
42 };
43 this.keyboardWillHideHandler = () => {
44 setTimeout(() => this.keyboardVisible = false, 50);
45 };
46 window.addEventListener('keyboardWillShow', this.keyboardWillShowHandler);
47 window.addEventListener('keyboardWillHide', this.keyboardWillHideHandler);
48 }
49 }
50 disconnectedCallback() {
51 if (typeof window !== 'undefined') {
52 window.removeEventListener('keyboardWillShow', this.keyboardWillShowHandler);
53 window.removeEventListener('keyboardWillHide', this.keyboardWillHideHandler);
54 this.keyboardWillShowHandler = this.keyboardWillHideHandler = undefined;
55 }
56 }
57 render() {
58 const { color, translucent, keyboardVisible } = this;
59 const mode = getIonMode(this);
60 return (h(Host, { role: "tablist", "aria-hidden": keyboardVisible ? 'true' : null, class: createColorClasses(color, {
61 [mode]: true,
62 'tab-bar-translucent': translucent,
63 'tab-bar-hidden': keyboardVisible,
64 }) }, h("slot", null)));
65 }
66 get el() { return this; }
67 static get watchers() { return {
68 "selectedTab": ["selectedTabChanged"]
69 }; }
70 static get style() { return {
71 ios: tabBarIosCss,
72 md: tabBarMdCss
73 }; }
74}, [33, "ion-tab-bar", {
75 "color": [513],
76 "selectedTab": [1, "selected-tab"],
77 "translucent": [4],
78 "keyboardVisible": [32]
79 }]);
80function defineCustomElement$1() {
81 if (typeof customElements === "undefined") {
82 return;
83 }
84 const components = ["ion-tab-bar"];
85 components.forEach(tagName => { switch (tagName) {
86 case "ion-tab-bar":
87 if (!customElements.get(tagName)) {
88 customElements.define(tagName, TabBar);
89 }
90 break;
91 } });
92}
93
94const IonTabBar = TabBar;
95const defineCustomElement = defineCustomElement$1;
96
97export { IonTabBar, defineCustomElement };