UNPKG

@kelvininc/ui-components

Version:
48 lines (45 loc) 2.07 kB
import { a as setMode } from './index-D-JVwta2.js'; import './components-DzZLIMy0.js'; import { S as StyleMode } from './lib-config-DwRzddFC.js'; import './action-button.types-DVds6a5Z.js'; import './absolute-time-picker-dropdown.types-CojoW2Y2.js'; import './icon.types-SVedE_O8.js'; import './summary-card.types-BcMhjKoS.js'; import './toaster.types-vhHhaF4Q.js'; import './tree-item.types-CBuzk8fR.js'; import './tag-alarm.types-DHk26cGe.js'; import './wizard.types-7ioMFMb5.js'; import { D as DEFAULT_CONFIG } from './config-CJMopqu5.js'; import { g as get } from './get-CQN4erwW.js'; const initialize = (userConfig = {}) => { var _a, _b; const defaultStyleMode = get(userConfig, 'styleMode', StyleMode.Night); const { document: doc, window: win } = window; doc.body.setAttribute('mode', defaultStyleMode); const isKvElement = (elm) => elm.tagName && elm.tagName.startsWith('KV-'); const isAllowedStyleModeValue = (elmMode) => Object.values(StyleMode).includes(elmMode); setMode((elm) => { while (elm) { const elmMode = elm.mode || elm.getAttribute('mode'); if (elmMode) { if (isAllowedStyleModeValue(elmMode)) { return elmMode; } else if (isKvElement(elm)) { console.warn(`Invalid kv-component mode: ${elmMode}, expected: ${Object.values(StyleMode).join(',')}`); } } // TODO: check with more time why cant obtain the parentElement // elm = elm.parentElement; elm = doc.body; } return defaultStyleMode; }); if (typeof win === 'undefined') { return; } const instance = (win.KvUiComponents = (_a = win.KvUiComponents) !== null && _a !== void 0 ? _a : {}); const actualConfig = (instance.config = (_b = instance.config) !== null && _b !== void 0 ? _b : {}); win.KvUiComponents.config = Object.assign(Object.assign(Object.assign({}, DEFAULT_CONFIG), actualConfig), userConfig); }; export { initialize as i };