@kelvininc/ui-components
Version:
Kelvin UI Components
33 lines (28 loc) • 2.17 kB
JavaScript
'use strict';
var index = require('./index-rNNWWpit.js');
var wizard_types = require('./wizard.types-C9Yhv1tt.js');
const toggleSwitchCss = "@property --rotation{syntax:\"<angle>\";initial-value:0deg;inherits:false}@keyframes rotate-border{to{--rotation:360deg}}kv-dropdown-base:not(.hydrated)>[slot=list]{display:none}.toggle-switch-container{display:flex}.toggle-switch-container>:last-child{--border-radius-top-right:var(--toggle-radius-default);--border-radius-bottom-right:var(--toggle-radius-default)}.toggle-switch-container>:first-child{--border-radius-top-left:var(--toggle-radius-default);--border-radius-bottom-left:var(--toggle-radius-default)}.toggle-switch-container kv-toggle-button{--border-radius-top-right:0;--border-radius-bottom-right:0;--border-radius-top-left:0;--border-radius-bottom-left:0}";
const KvToggleSwitch = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
this.checkedChange = index.createEvent(this, "checkedChange", 7);
/** @inheritdoc */
this.options = [];
/** @inheritdoc */
this.disabled = false;
/** @inheritdoc */
this.size = wizard_types.EComponentSize.Small;
/** @inheritdoc */
this.selectedOption = '';
/** @inheritdoc */
this.disabledButtons = {};
}
render() {
return (index.h(index.Host, { key: '3d72ccf4578635b32fe65a1d177a006dc7945598' }, index.h("div", { key: '037f38ff83df0d9facdf303113b4b3a58a2f54f9', class: "toggle-switch-container" }, this.options.map(option => {
var _a;
return (index.h("kv-toggle-button", { part: "toggle-switch-option-container", exportparts: "toggle-button", icon: option.icon, value: option.value, label: option.label, tooltip: option.tooltip, size: (_a = this.size) !== null && _a !== void 0 ? _a : option.size, preventDefault: option.preventDefault, checked: this.selectedOption === option.value, disabled: this.disabled || this.disabledButtons[option.value] || option.disabled, customAttributes: option.customAttributes }));
}))));
}
};
KvToggleSwitch.style = toggleSwitchCss;
exports.kv_toggle_switch = KvToggleSwitch;