@kelvininc/ui-components
Version:
Kelvin UI Components
71 lines (64 loc) • 3.51 kB
JavaScript
import { s as setMode } from './p-D6GMjtmE.js';
export { g as getAssetPath, a as setAssetPath, b as setNonce, c as setPlatformOptions } from './p-D6GMjtmE.js';
import { S as StyleMode } from './p-BRgmvbuh.js';
export { c as EAlarmSeverity, E as EAnchorTarget, a as EComponentSize, b as ETooltipPosition } from './p-BRgmvbuh.js';
export { C as CLOSE_ICON, r as EAbsoluteTimeError, o as EAbsoluteTimePickerMode, E as EActionButtonType, k as EAlertType, b as EIconName, a as EIllustrationName, c as EInputFieldType, q as EInputSource, m as ERelativeTimeComparisonConfig, p as ERelativeTimeInputMode, l as EStepState, j as ETagAlarmSize, i as ETagState, f as EToasterType, e as EToggleState, h as ETreeItemLabelSize, g as ETreeItemState, n as EUnitReference, d as EValidationState } from './p-DBphUUgi.js';
export { E as ESummaryCardType } from './p-BcMhjKoS.js';
export { E as EBadgeState } from './p-BQDwJ0uF.js';
import { D as DEFAULT_CONFIG } from './p-BEvgYojK.js';
import { g as get } from './p-CIAhob1E.js';
export { a as arraysHelper } from './p-C0GqgbWr.js';
export { c as clipboardHelper } from './p-rHmdvoey.js';
export { c as cssClassHelper } from './p-DKOxy79t.js';
export { d as dateHelper } from './p-Ba4zaTTd.js';
export { s as stringHelper } from './p-BVsEG3aJ.js';
export { f as floatingUIHelper } from './p-tvmoGbWd.js';
export { m as mouseEventHelper } from './p-Dhw0q1D8.js';
export { r as relativeTimeHelper } from './p-fPdjvgbF.js';
export { s as selectHelper } from './p-BEfnHAoy.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);
};
const globalScripts = initialize;
const searchString = (searchTerm, searchOptions) => {
if (!searchTerm || searchTerm.length <= 0) {
return searchOptions;
}
// filter by search
const lowerCaseSearchTerm = searchTerm.toLowerCase();
return searchOptions.filter(option => option.label.toLowerCase().includes(lowerCaseSearchTerm));
};
var search_helper = /*#__PURE__*/Object.freeze({
__proto__: null,
searchString: searchString
});
globalScripts();
export { StyleMode, initialize, search_helper as searchHelper };