@freshworks/crayons
Version:
Crayons Web Components library
120 lines (116 loc) • 4.71 kB
JavaScript
import { attachShadow, h, proxyCustomElement } from '@stencil/core/internal/client';
import { a as hasSlot } from './index2.js';
import { i as i18n } from './Translation.js';
import { d as defineCustomElement$4 } from './button.js';
import { d as defineCustomElement$1, a as defineCustomElement$3 } from './icon.js';
import { d as defineCustomElement$2 } from './spinner.js';
const modalFooterCss = ":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-footer-container{padding:12px 16px;-webkit-box-sizing:border-box;box-sizing:border-box;height:56px;background-color:#f3f5f7;border-radius:0 0 4px 4px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:end;justify-content:flex-end;-ms-flex:none;flex:none}.modal-footer-container fw-button{margin-left:12px}";
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let ModalFooter = class extends HTMLElement {
constructor() {
super();
this.__registerHost();
attachShadow(this);
/**
* The text for the submit button
*/
this.submitText = '';
/**
* The text for the cancel button
*/
this.cancelText = '';
/**
* Default state of submit button
*/
this.submitDisabled = false;
/**
* The color of submit button
*/
this.submitColor = 'primary';
/**
* Set to true if we want to render slot instead of default footer
*/
this.custom = null;
/**
* Function to call on submit of modal
*/
// eslint-disable-next-line @typescript-eslint/no-empty-function
this.submit = () => { };
/**
* Function to call on close of modal
*/
// eslint-disable-next-line @typescript-eslint/no-empty-function
this.close = () => { };
}
/**
* lifecycle event, called once just after the component is first connected to the DOM
*/
componentWillLoad() {
if (this.custom === null) {
this.custom = hasSlot(this.el);
}
}
/**
* render slot when custom attribute is passed, else renders the default footer with submit and cancel buttons
* @returns {JSX.Element}
*/
render() {
return (h("div", { class: 'modal-footer-container' }, h("div", { class: 'modal-footer' }, this.custom ? (h("slot", null)) : (h("span", null, h("fw-button", { color: 'secondary', onClick: () => this.close() }, this.cancelText), h("fw-button", { color: this.submitColor, disabled: this.submitDisabled, onClick: () => this.submit() }, this.submitText))))));
}
get el() { return this; }
static get style() { return modalFooterCss; }
};
__decorate([
i18n({ keyName: 'modal.ok' })
], ModalFooter.prototype, "submitText", void 0);
__decorate([
i18n({ keyName: 'modal.cancel' })
], ModalFooter.prototype, "cancelText", void 0);
ModalFooter = /*@__PURE__*/ proxyCustomElement(ModalFooter, [1, "fw-modal-footer", {
"submitText": [1025, "submit-text"],
"cancelText": [1025, "cancel-text"],
"submitDisabled": [4, "submit-disabled"],
"submitColor": [1, "submit-color"],
"submit": [8],
"close": [8]
}]);
function defineCustomElement() {
const components = ["fw-modal-footer", "fw-button", "fw-icon", "fw-spinner", "fw-toast-message"];
components.forEach(tagName => { switch (tagName) {
case "fw-modal-footer":
if (!customElements.get(tagName)) {
customElements.define(tagName, ModalFooter);
}
break;
case "fw-button":
if (!customElements.get(tagName)) {
defineCustomElement$4();
}
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 { ModalFooter as M, defineCustomElement as d };