123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.82
- */
- import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
- import { g as guid } from './guid.js';
- import { t as toAriaBoolean, n as nodeListToArray } from './dom.js';
- const tabCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([active]) section{display:block}:host{display:none;height:100%;width:100%}:host([active]){display:block;height:100%;width:100%;overflow:auto}section{display:none;height:100%;width:100%}:host([scale=s]){padding-top:0.25rem;padding-bottom:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]){padding-top:0.5rem;padding-bottom:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]){padding-top:0.75rem;padding-bottom:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}";
- const Tab = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteTabRegister = createEvent(this, "calciteTabRegister", 7);
- /**
- * Show this tab
- */
- this.active = false;
- /** @internal Parent tabs component scale value */
- this.scale = "m";
- this.guid = `calcite-tab-title-${guid()}`;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- render() {
- const id = this.el.id || this.guid;
- return (h(Host, { "aria-expanded": toAriaBoolean(this.active), "aria-labelledby": this.labeledBy, id: id, role: "tabpanel" }, h("section", null, h("slot", null))));
- }
- connectedCallback() {
- this.parentTabsEl = this.el.closest("calcite-tabs");
- }
- componentDidLoad() {
- this.calciteTabRegister.emit();
- }
- componentWillRender() {
- var _a;
- this.scale = (_a = this.parentTabsEl) === null || _a === void 0 ? void 0 : _a.scale;
- }
- disconnectedCallback() {
- var _a;
- // Dispatching to body in order to be listened by other elements that are still connected to the DOM.
- (_a = document.body) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new CustomEvent("calciteTabUnregister", {
- detail: this.el
- }));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- internalTabChangeHandler(event) {
- const targetTabsEl = event
- .composedPath()
- .find((el) => el.tagName === "CALCITE-TABS");
- // to allow `<calcite-tabs>` to be nested we need to make sure this
- // `calciteTabChange` event was actually fired from a within the same
- // `<calcite-tabs>` that is the a parent of this tab.
- if (targetTabsEl !== this.parentTabsEl) {
- return;
- }
- if (this.tab) {
- this.active = this.tab === event.detail.tab;
- }
- else {
- this.getTabIndex().then((index) => {
- this.active = index === event.detail.tab;
- });
- }
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /**
- * Return the index of this tab within the tab array
- */
- async getTabIndex() {
- return Array.prototype.indexOf.call(nodeListToArray(this.el.parentElement.children).filter((e) => e.matches("calcite-tab")), this.el);
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- /**
- * @internal
- */
- async updateAriaInfo(tabIds = [], titleIds = []) {
- this.labeledBy = titleIds[tabIds.indexOf(this.el.id)] || null;
- }
- get el() { return this; }
- static get style() { return tabCss; }
- }, [1, "calcite-tab", {
- "tab": [513],
- "active": [1540],
- "scale": [1537],
- "labeledBy": [32],
- "getTabIndex": [64],
- "updateAriaInfo": [64]
- }, [[16, "calciteInternalTabChange", "internalTabChangeHandler"]]]);
- function defineCustomElement() {
- if (typeof customElements === "undefined") {
- return;
- }
- const components = ["calcite-tab"];
- components.forEach(tagName => { switch (tagName) {
- case "calcite-tab":
- if (!customElements.get(tagName)) {
- customElements.define(tagName, Tab);
- }
- break;
- } });
- }
- defineCustomElement();
- export { Tab as T, defineCustomElement as d };
|