UNPKG

@public-ui/components

Version:

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

127 lines (121 loc) 4.4 kB
/*! * KoliBri - The accessible HTML-Standard */ 'use strict'; var index = require('./index-BrhW8s5h.js'); var Alert = require('./Alert-C5eDyNdi.js'); var common = require('./common-DPb6NWR4.js'); var hasCloser = require('./has-closer-DdfOvOk6.js'); var label = require('./label-8vcJJEVI.js'); var events = require('./events-Jc2wxPjR.js'); var validation = require('./validation-4QVpAFd9.js'); require('./tslib.es6-Cm0ytgPY.js'); require('./clsx-Bm_HQUnh.js'); require('./component-names-5KS_pYRF.js'); require('./i18n-Cjy0vgJA.js'); require('./i18n-CgUN6lev.js'); require('./bem-registry-DevvgGUu.js'); require('./component-CuHGwo27.js'); require('./Heading-Zb8_ekSw.js'); require('./level-DmIt1w-r.js'); require('./normalizers-BCLslVaT.js'); require('./_Uint8Array-BAQUGozM.js'); require('./isArray-BOIOdEQh.js'); const alertTypeOptions = ['default', 'info', 'success', 'warning', 'error']; const isAlertTypePropType = (value) => { return typeof value === 'string' && alertTypeOptions.includes(value); }; const validateAlertType = (component, value) => { common.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) => { common.watchValidator(component, '_variant', isAlertVariantPropType, new Set(alertVariantOptions), value); }; const KolAlertWc = class { constructor(hostRef) { index.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) { events.dispatchDomEvent(this.host, events.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 (index.h(Alert.KolAlertFc, Object.assign({ key: 'ab90b52cbda1d61514c3acd292d0bd6d91f0c9d5' }, props), index.h("slot", { key: '6a7e2a89cfabde71c1140d4cf5de28e99bc09ef4' }))); } validateAlert(value) { common.watchBoolean(this, '_alert', value); } validateHasCloser(value) { hasCloser.validateHasCloser(this, value); } validateLabel(value) { label.validateLabel(this, value); } validateLevel(value) { validation.watchHeadingLevel(this, value); } validateOn(value) { if (this.validateOnValue(value)) { common.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 index.getElement(this); } static get watchers() { return { "_alert": ["validateAlert"], "_hasCloser": ["validateHasCloser"], "_label": ["validateLabel"], "_level": ["validateLevel"], "_on": ["validateOn"], "_type": ["validateType"], "_variant": ["validateVariant"] }; } }; exports.kol_alert_wc = KolAlertWc; //# sourceMappingURL=kol-alert-wc.entry.cjs.js.map