UNPKG

@seniorsistemas/tecnologia-webcomponents

Version:

A webcomponents library for Senior Sistemas - Suite BPM products.

89 lines (83 loc) 11.3 kB
import { r as registerInstance, f as createEvent, h, e as Host, g as getElement } from './index-ce5716ba.js'; import { d as defaultTheme } from './defaultTheme-cf9ab925.js'; var TecAlign; (function (TecAlign) { TecAlign["left"] = "left"; TecAlign["center"] = "center"; TecAlign["right"] = "right"; })(TecAlign || (TecAlign = {})); var TecSize; (function (TecSize) { TecSize["tiny"] = "tiny"; TecSize["small"] = "small"; TecSize["medium"] = "medium"; TecSize["large"] = "large"; TecSize["giant"] = "giant"; })(TecSize || (TecSize = {})); const tecModalCss = "@import url(https://fonts.googleapis.com/css2?family=Almarai:wght@300;400;700;800&family=Inter:wght@300;400;500;600;700;800&family=Roboto:wght@300;400;500;700;900&display=swap);@import url(https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Volkhov:wght@400;700&display=swap);@import url(https://fonts.googleapis.com/css2?family=Fira+Mono:wght@400;500;700&family=Oxygen+Mono&family=Roboto+Mono:wght@300;400;500;600;700&display=swap);.bg-default{background:#f6f8fa}.text-xs{font-size:.75rem;line-height:1rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-2x1{font-size:1.5rem;line-height:2rem}.text-3x1{font-size:1.875rem;line-height:2.25rem}.text-4x1{font-size:2.25rem;line-height:2.5rem}.text-5x1{font-size:3rem;line-height:3rem}.text-6x1{font-size:3.75rem;line-height:3.75rem}.text-7x1{font-size:4.5rem;line-height:4.5rem}.text-8x1{font-size:6rem;line-height:6rem}.text-9x1{font-size:8rem;line-height:8rem}.text-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Roboto,Almarai,Inter,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.text-serif{font-family:ui-serif,Volkhov,Libre Baskerville,Georgia,serif,serif}.text-mono{font-family:ui-monospace,Fira Mono,Roboto Mono,Oxygen Mono,Consolas,monospace,monospace}.text-title{font-family:Inter,sans-serif}@import url(\"https://fonts.googleapis.com/css2?family=Inter:wght@500;700&family=Open+Sans:wght@400;600&display=swap\"); *{-webkit-box-sizing:border-box;box-sizing:border-box}:host([hidden]){display:none}:host([theme=light]){--tecnologia-color-primary:#3c9bec;--tecnologia-color-secondary:#cbd0d8;--tecnologia-color-danger:#ec3c43;--tecnologia-color-success:#00c99a;--tecnologia-color-warning:#ff9800}:host([theme=light]) .bg-primary{background-color:#3c9bec}:host([theme=light]) .bg-secondary{background-color:#cbd0d8}:host([theme=light]) .bg-danger{background-color:#ec3c43}:host([theme=light]) .bg-success{background-color:#00c99a}:host([theme=light]) .bg-warning{background-color:#ff9800}:host([theme=dark]){--tecnologia-color-primary:#7dbcf2;--tecnologia-color-secondary:#cbd0d8;--tecnologia-color-danger:#ec3c43;--tecnologia-color-success:#00c99a;--tecnologia-color-warning:#ff9800}:host([theme=dark]) .bg-primary{background-color:#7dbcf2}:host([theme=dark]) .bg-secondary{background-color:#cbd0d8}:host([theme=dark]) .bg-danger{background-color:#ec3c43}:host([theme=dark]) .bg-success{background-color:#00c99a}:host([theme=dark]) .bg-warning{background-color:#ff9800}:host{display:block}:host body{overflow:hidden !important}:host([theme=light]) .modal .modal-content{background:#ffffff;color:#434548}:host([theme=dark]) .modal .modal-content{background:#434548;color:#f6f8fa;border:none}:host([theme=dark]) .modal .modal-content .modal-title{border-bottom:1px solid #5a5c60 !important}:host([theme=dark]) .modal .modal-content .modal-title h1{color:#f6f8fa !important}:host([theme=dark]) .modal .modal-content .footer{border-top:1px solid #5a5c60 !important}:host([size=tiny]) .modal-content{width:20%}:host([size=small]) .modal-content{width:30%}:host([size=medium]) .modal-content{width:40%}:host([size=large]) .modal-content{width:50%}:host([size=giant]) .modal-content{width:60%}.modal{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;align-items:center;position:fixed;z-index:100;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:black;background-color:rgba(0, 0, 0, 0.6)}.modal.remove-background{-webkit-animation:remove-brackground 100ms forwards;animation:remove-brackground 100ms forwards}.modal.show-background{-webkit-animation:show-background 100ms forwards;animation:show-background 100ms forwards}.modal-content{border-radius:5px;background-color:#fefefe;border:1px solid #858585;width:30%}.modal-content.full-width{width:100% !important;border:none !important}.modal-content.open-animation{-webkit-animation:open-fade 100ms forwards;animation:open-fade 100ms forwards}.modal-content.close-animation{-webkit-animation:close-fade 100ms forwards;animation:close-fade 100ms forwards}.modal-content .modal-title{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-bottom:1px solid #d3d3d3;padding:0 1rem}.modal-content .modal-title h1{color:#212121}.modal-content .modal-title .close-container{margin-left:auto;border-radius:100%;min-width:28px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-webkit-transition:150ms;transition:150ms;cursor:pointer}.modal-content .modal-title .close-container:hover{background-color:#e4e4e4}.modal-content .modal-title .close-container .close{color:#646464;font-size:22px;font-weight:bold;padding-bottom:0.125rem}.modal-content .modal-title .close-container .close:hover,.modal-content .modal-title .close-container .close:focus{text-decoration:none}.modal-content .content{padding:1rem;overflow:auto;max-height:70vh}.modal-content .footer{padding:0.7rem 1rem;border-top:1px solid #d3d3d3}.modal-content .footer.center,.modal-content .footer.left,.modal-content .footer.right{display:-ms-flexbox;display:flex}.modal-content .footer.center{-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.modal-content .footer.left .footer-content{margin-right:auto}.modal-content .footer.right .footer-content{margin-left:auto}@media (max-width: 1536px){.responsive{width:40%}:host([size=tiny]) .modal-content{width:30%}:host([size=small]) .modal-content{width:40%}:host([size=medium]) .modal-content{width:40%}:host([size=large]) .modal-content{width:50%}:host([size=giant]) .modal-content{width:60%}}@media (max-width: 1280px){.responsive{width:45%}:host([size=tiny]) .responsive{width:30%}:host([size=small]) .responsive{width:45%}:host([size=medium]) .responsive{width:55%}:host([size=large]) .responsive{width:65%}:host([size=giant]) .responsive{width:75%}}@media (max-width: 1024px){.responsive{width:50%}:host([size=tiny]) .responsive{width:40%}:host([size=small]) .responsive{width:50%}:host([size=medium]) .responsive{width:60%}:host([size=large]) .responsive{width:70%}:host([size=giant]) .responsive{width:80%}}@media (max-width: 768px){.responsive{width:60%}:host([size=tiny]) .responsive{width:50%}:host([size=small]) .responsive{width:60%}:host([size=medium]) .responsive{width:70%}:host([size=large]) .responsive{width:80%}:host([size=giant]) .responsive{width:90%}}@media (max-width: 640px){.responsive{width:70%}:host([size=tiny]) .responsive{width:70%}:host([size=small]) .responsive{width:85%}:host([size=medium]) .responsive{width:90%}:host([size=large]) .responsive{width:95%}:host([size=giant]) .responsive{width:98%}}@-webkit-keyframes open-fade{from{top:10rem;-webkit-transform:scale(0.9);transform:scale(0.9);opacity:0;z-index:1}to{top:inherit;-webkit-transform:scale(1);transform:scale(1);opacity:1;z-index:100}}@keyframes open-fade{from{top:10rem;-webkit-transform:scale(0.9);transform:scale(0.9);opacity:0;z-index:1}to{top:inherit;-webkit-transform:scale(1);transform:scale(1);opacity:1;z-index:100}}@-webkit-keyframes close-fade{from{-webkit-transform:scale(1);transform:scale(1);opacity:1;z-index:100}to{-webkit-transform:scale(0.9);transform:scale(0.9);opacity:0;z-index:1}}@keyframes close-fade{from{-webkit-transform:scale(1);transform:scale(1);opacity:1;z-index:100}to{-webkit-transform:scale(0.9);transform:scale(0.9);opacity:0;z-index:1}}@-webkit-keyframes remove-brackground{from{opacity:1}to{display:none;opacity:0}}@keyframes remove-brackground{from{opacity:1}to{display:none;opacity:0}}@-webkit-keyframes show-background{from{display:none;opacity:0}to{display:hidden;opacity:1}}@keyframes show-background{from{display:none;opacity:0}to{display:hidden;opacity:1}}"; const TecModal = class { constructor(hostRef) { registerInstance(this, hostRef); this.hidden = createEvent(this, "hidden", 7); this.clickWasInside = false; this.hasFooterContent = false; this.openedAuxiliary = false; this.theme = defaultTheme; this.opened = false; this.showCloseIcon = true; this.dismissOnBackdrop = true; this.size = TecSize.small; this.fullWidth = false; this.closeOnEscape = true; this.blockBodyScroll = true; this.responsive = true; this.footerAlign = TecAlign.right; this.handleClick = (event) => { if (!this.clickWasInside && this.dismissOnBackdrop) this.closeModal(event); this.clickWasInside = false; }; this.closeModal = (event) => { this.opened = false; this.handleParentOverflow(); this.hidden.emit(event); }; this.handleKeyDown = (event) => { if (this.opened && event.key === 'Escape') this.closeModal(); }; } watchOpened(newValue) { if (!newValue) { setTimeout(() => this.openedAuxiliary = false, 200); } else { this.handleParentOverflow(); this.openedAuxiliary = true; } } componentWillLoad() { this.hasFooterContent = !!this.hostElement.querySelector('[slot="footer"]'); if (this.opened) this.handleParentOverflow(); this.openedAuxiliary = this.opened; if (this.closeOnEscape) document.addEventListener('keydown', this.handleKeyDown); } handleParentOverflow() { const property = this.opened && this.blockBodyScroll ? 'hidden' : 'inherit'; this.hostElement.parentElement.style.overflow = property; } setClickWasInside(wasInside) { return () => this.clickWasInside = wasInside; } render() { return (this.openedAuxiliary && (h(Host, null, h("div", { class: `modal ${this.opened && 'show-background'} ${!this.opened && 'remove-background'}`, onClick: this.handleClick }, h("div", { class: `modal-content ${this.fullWidth && 'full-width'} ${this.opened && 'open-animation'} ${!this.opened && 'close-animation'} ${this.responsive && 'responsive'}`, onClick: this.setClickWasInside(true) }, h("div", { class: "modal-title text-title" }, h("h1", { class: "text-2x1" }, this.modalTitle), this.showCloseIcon && (h("div", { class: "close-container", onClick: this.closeModal }, h("span", { class: "close" }, h("span", null, "\u00D7"))))), h("div", { class: "content" }, h("slot", { name: "content" })), this.hasFooterContent && (h("div", { class: `footer ${this.footerAlign}` }, h("div", { class: "footer-content" }, h("slot", { name: "footer" }))))))))); } get hostElement() { return getElement(this); } static get watchers() { return { "opened": ["watchOpened"] }; } }; TecModal.style = tecModalCss; export { TecModal as tec_modal };