UNPKG

@postnord/web-components

Version:

PostNord Web Components

74 lines (68 loc) 5.06 kB
/*! * Built with Stencil * By PostNord. */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-ec4ed1cc.js'); const helpers = require('./helpers-bff6a1c2.js'); const alert_exclamation_circle = require('./alert_exclamation_circle-7e28124d.js'); const alert_info_circle = require('./alert_info_circle-f2dd1d7d.js'); const pnFieldsetCss = "pn-fieldset{display:inline-block}pn-fieldset .pn-fieldset{border:0;padding:0;margin:0;color:#2d2013;display:flex;flex-direction:column;font-size:1em}pn-fieldset .pn-fieldset-legend{float:left;font-weight:500;line-height:1.4;padding:0}pn-fieldset .pn-fieldset-helpertext{color:#5e554a;margin:0}pn-fieldset .pn-fieldset-items{padding:0.75em 0;display:flex;flex-direction:column;gap:0.75em}pn-fieldset .pn-fieldset-message-wrapper{display:flex;gap:0.75em;color:#2d2013;line-height:1.4;font-weight:400}pn-fieldset .pn-fieldset-message-wrapper[hidden]{display:none}pn-fieldset .pn-fieldset-message{margin:0}pn-fieldset .pn-fieldset[aria-invalid=true]>.pn-fieldset-legend,pn-fieldset .pn-fieldset[aria-invalid=true]>.pn-fieldset-helpertext,pn-fieldset .pn-fieldset[aria-invalid=true]>.pn-fieldset-message-wrapper{color:#a70707}pn-fieldset .pn-fieldset[aria-invalid=true]>.pn-fieldset-legend>pn-icon .pn-icon-svg>path,pn-fieldset .pn-fieldset[aria-invalid=true]>.pn-fieldset-helpertext>pn-icon .pn-icon-svg>path,pn-fieldset .pn-fieldset[aria-invalid=true]>.pn-fieldset-message-wrapper>pn-icon .pn-icon-svg>path{fill:#a70707}pn-fieldset .pn-fieldset:disabled>.pn-fieldset-legend,pn-fieldset .pn-fieldset:disabled>.pn-fieldset-helpertext,pn-fieldset .pn-fieldset:disabled>.pn-fieldset-message,pn-fieldset .pn-fieldset:disabled>.pn-fieldset-message-wrapper{color:#2d2013}pn-fieldset .pn-fieldset:disabled>.pn-fieldset-legend>pn-icon .pn-icon-svg>path,pn-fieldset .pn-fieldset:disabled>.pn-fieldset-helpertext>pn-icon .pn-icon-svg>path,pn-fieldset .pn-fieldset:disabled>.pn-fieldset-message>pn-icon .pn-icon-svg>path,pn-fieldset .pn-fieldset:disabled>.pn-fieldset-message-wrapper>pn-icon .pn-icon-svg>path{fill:#2d2013}"; const PnFieldsetStyle0 = pnFieldsetCss; const PnFieldset = class { constructor(hostRef) { index.registerInstance(this, hostRef); this.legend = undefined; this.helpertext = undefined; this.fieldsetId = this.id; this.form = undefined; this.name = undefined; this.disabled = false; this.invalid = false; this.error = undefined; } mo; id = `pn-fieldset-${helpers.uuidv4()}`; idHelpertext = `${this.id}-helpertext`; get hostElement() { return index.getElement(this); } handleId() { this.idHelpertext = `${this.fieldsetId}-helpertext`; } componentWillLoad() { this.handleId(); } componentDidLoad() { if (this.mo) this.mo.disconnect(); this.mo = new MutationObserver(() => index.forceUpdate(this.hostElement)); this.mo.observe(this.hostElement.querySelector('.pn-fieldset'), { childList: true, subtree: true }); } componentDidRender() { /** * Stencil has a known problem about rendering the `form` attribute. * Setting it via setAttribute solves it for now. * https://github.com/ionic-team/stencil/issues/2703 **/ if (this.form) { this.hostElement.querySelector('fieldset')?.setAttribute('form', this.form); } } hasError() { return this.invalid || !!this.error; } getSymbol() { if (this.disabled) return alert_info_circle.alert_info_circle; return alert_exclamation_circle.alert_exclamation_circle; } render() { return (index.h(index.Host, { key: 'e22e77e7d49f4dd10607f1fc2cb500d3b63ee4f2' }, index.h("fieldset", { key: 'c6cb9c43620b223e69c5814446e26678c83d0fa3', id: this.fieldsetId, class: "pn-fieldset", disabled: this.disabled, "aria-describedby": this.helpertext && this.idHelpertext, "aria-invalid": this.hasError().toString() }, index.h("legend", { key: 'ec669e86d003bd11db387c0e6e9619b792175c72', class: "pn-fieldset-legend" }, this.legend), this.helpertext && (index.h("p", { key: '60cf8252ec833d0db9620cab9e57a5dbd2212a5e', id: this.idHelpertext, class: "pn-fieldset-helpertext" }, this.helpertext)), index.h("div", { key: '38191db1e9344469e37132c4b90c6197e1ba59d9', class: "pn-fieldset-items" }, index.h("slot", { key: '8c4048eaea924b96d9fd4d95e64d96ef6b42e058' })), index.h("div", { key: 'f2b627b8155e94cdeb681f9405601b480a8d7a1f', class: "pn-fieldset-message-wrapper", role: "alert", hidden: !this.error }, index.h("pn-icon", { key: 'fcd13f423dcd055821c7d0854b34b4babad17ad8', icon: this.getSymbol() }), index.h("p", { key: 'e620363bcdca770ebc01d3190a9588f4f0a1f21e', class: "pn-fieldset-message" }, this.error))))); } static get watchers() { return { "fieldsetId": ["handleId"] }; } }; PnFieldset.style = PnFieldsetStyle0; exports.pn_fieldset = PnFieldset; //# sourceMappingURL=pn-fieldset.cjs.entry.js.map