@freshworks/crayons
Version:
Crayons Web Components library
80 lines (76 loc) • 4.32 kB
JavaScript
import { attachShadow, h, proxyCustomElement } from '@stencil/core/internal/client';
import { a as hasSlot } from './index2.js';
import { d as defineCustomElement$1, a as defineCustomElement$3 } from './icon.js';
import { d as defineCustomElement$2 } from './spinner.js';
const modalTitleCss = ":host{font-family:var(--fw-font-family, -apple-system, blinkmacsystemfont, \"Segoe UI\", roboto, oxygen, ubuntu, cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-box-sizing:border-box;box-sizing:border-box}.modal-header-container{padding:32px 32px 0;position:relative;background:#fff;border-radius:4px 4px 0 0;-webkit-transition:all 0.1s linear;transition:all 0.1s linear;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex:none;flex:none}.modal-header-container .modal-header{width:100%;height:auto;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;font-size:18px;font-weight:600;line-height:24px;color:#12344d}.modal-header-container .modal-header .modal-header-body{width:100%;height:auto;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:0px}.modal-header-container .modal-header .modal-header-body .modal-title{width:100%;height:auto;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;gap:10px;color:#12344d}.modal-header-container .modal-header .modal-header-body .modal-title .modal-title-icon{width:auto;height:24px;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.modal-header-container .modal-header .modal-header-body .modal-title .title-label{font-size:18px;font-weight:600;line-height:24px}.modal-header-container .modal-header .modal-header-body .description{font-size:14px;font-weight:400;color:#475867;line-height:20px;padding:6px 0px}";
let ModalTitle = class extends HTMLElement {
constructor() {
super();
this.__registerHost();
attachShadow(this);
/**
* The icon to be displayed with the title
*/
this.icon = '';
/**
* Set to true if we want to render slot instead of default footer
*/
this.custom = null;
}
/**
* lifecycle event, called once just after the component is first connected to the DOM
*/
componentWillLoad() {
if (this.custom === null) {
this.custom = hasSlot(this.el);
}
}
/**
* renders Icon in Modal header.
* @returns {JSX.Element}
*/
renderIcon() {
return (h("span", { class: 'modal-title-icon' }, h("fw-icon", { name: this.icon, size: 16 })));
}
/**
* renders slot content when custom attribute is passed, else displays the default
* icon, title and description with close button in the header.
* @returns {JSX.Element}
*/
render() {
return (h("div", { class: 'modal-header-container' }, h("div", { class: 'modal-header' }, this.custom ? (h("slot", null)) : (h("div", { class: 'modal-header-body' }, h("div", { class: 'modal-title' }, this.icon !== '' ? this.renderIcon() : null, h("label", { class: 'title-label' }, this.titleText)), this.description && (h("label", { class: 'description' }, this.description)))))));
}
get el() { return this; }
static get style() { return modalTitleCss; }
};
ModalTitle = /*@__PURE__*/ proxyCustomElement(ModalTitle, [1, "fw-modal-title", {
"titleText": [1, "title-text"],
"description": [1],
"icon": [1]
}]);
function defineCustomElement() {
const components = ["fw-modal-title", "fw-icon", "fw-spinner", "fw-toast-message"];
components.forEach(tagName => { switch (tagName) {
case "fw-modal-title":
if (!customElements.get(tagName)) {
customElements.define(tagName, ModalTitle);
}
break;
case "fw-icon":
if (!customElements.get(tagName)) {
defineCustomElement$3();
}
break;
case "fw-spinner":
if (!customElements.get(tagName)) {
defineCustomElement$2();
}
break;
case "fw-toast-message":
if (!customElements.get(tagName)) {
defineCustomElement$1();
}
break;
} });
}
export { ModalTitle as M, defineCustomElement as d };