UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

125 lines (120 loc) 4.43 kB
/*! * KoliBri - The accessible HTML-Standard */ import { r as registerInstance, h, g as getElement } from './index-BQlHOxik.js'; import { K as KolAlertFc } from './Alert-BP_7bRZF.js'; import { b as watchValidator, e as watchBoolean, s as setState } from './common-Cx_AGO_M.js'; import { v as validateHasCloser } from './has-closer-B8w7bVjx.js'; import { v as validateLabel } from './label-Fyi30H9j.js'; import { d as dispatchDomEvent, K as KolEvent } from './events-VVvk1win.js'; import { w as watchHeadingLevel } from './validation-D6nATCh8.js'; import './tslib.es6-QNbPBOk5.js'; import './clsx-COFh-Vc8.js'; import './component-names-Dy77vq43.js'; import './i18n-Br16IAnY.js'; import './i18n-B2d_exHc.js'; import './bem-registry-CWvl2xho.js'; import './component-DzaT2WlJ.js'; import './Heading-q2Ue3Ixd.js'; import './level-1jyaYIAE.js'; import './normalizers-m3s9sgmq.js'; import './_Uint8Array-kJHDjtoP.js'; import './isArray-CcrBs4JM.js'; const alertTypeOptions = ['default', 'info', 'success', 'warning', 'error']; const isAlertTypePropType = (value) => { return typeof value === 'string' && alertTypeOptions.includes(value); }; const validateAlertType = (component, value) => { watchValidator(component, '_type', isAlertTypePropType, new Set(alertTypeOptions), value); }; const alertVariantOptions = ['card', 'msg']; const isAlertVariantPropType = (value) => { return typeof value === 'string' && alertVariantOptions.includes(value); }; const validateAlertVariant = (component, value) => { watchValidator(component, '_variant', isAlertVariantPropType, new Set(alertVariantOptions), value); }; const KolAlertWc = class { constructor(hostRef) { registerInstance(this, hostRef); this.close = () => { var _a, _b; (_b = (_a = this._on) === null || _a === void 0 ? void 0 : _a.onClose) === null || _b === void 0 ? void 0 : _b.call(_a, new Event('Close')); if (this.host) { dispatchDomEvent(this.host, KolEvent.close); } }; this.handleAlertTimeout = () => { this.validateAlert(false); }; this._alert = false; this._hasCloser = false; this._level = 0; this._type = 'default'; this._variant = 'msg'; this.state = { _level: 0, }; this.validateOnValue = (value) => typeof value === 'object' && value !== null && typeof value.onClose === 'function'; } render() { const { _alert, _hasCloser, _label, _level, _type, _variant } = this.state; const props = { alert: _alert, hasCloser: _hasCloser, label: _label, level: _level, type: _type, variant: _variant, onCloserClick: this.close, onAlertTimeout: this.handleAlertTimeout, }; return (h(KolAlertFc, Object.assign({ key: 'ab90b52cbda1d61514c3acd292d0bd6d91f0c9d5' }, props), h("slot", { key: '6a7e2a89cfabde71c1140d4cf5de28e99bc09ef4' }))); } validateAlert(value) { watchBoolean(this, '_alert', value); } validateHasCloser(value) { validateHasCloser(this, value); } validateLabel(value) { validateLabel(this, value); } validateLevel(value) { watchHeadingLevel(this, value); } validateOn(value) { if (this.validateOnValue(value)) { setState(this, '_on', { onClose: value.onClose, }); } } validateType(value) { validateAlertType(this, value); } validateVariant(value) { validateAlertVariant(this, value); } componentWillLoad() { this.validateAlert(this._alert); this.validateHasCloser(this._hasCloser); this.validateLabel(this._label); this.validateLevel(this._level); this.validateOn(this._on); this.validateType(this._type); this.validateVariant(this._variant); } get host() { return getElement(this); } static get watchers() { return { "_alert": ["validateAlert"], "_hasCloser": ["validateHasCloser"], "_label": ["validateLabel"], "_level": ["validateLevel"], "_on": ["validateOn"], "_type": ["validateType"], "_variant": ["validateVariant"] }; } }; export { KolAlertWc as kol_alert_wc }; //# sourceMappingURL=kol-alert-wc.entry.js.map