UNPKG

digivue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

138 lines (132 loc) 4.19 kB
import { isNotEmpty } from '@digivue/utils/object'; import Ripple from 'digivue/ripple'; import BaseEditableHolder from '@digivue/core/baseeditableholder'; import ToggleButtonStyle from 'digivue/togglebutton/style'; import { resolveComponent, resolveDirective, withDirectives, createBlock, openBlock, mergeProps, withCtx, createElementVNode, renderSlot, normalizeClass, createElementBlock, createCommentVNode, toDisplayString } from 'vue'; var script$1 = { name: 'BaseToggleButton', "extends": BaseEditableHolder, props: { onIcon: String, offIcon: String, onLabel: { type: String, "default": 'Yes' }, offLabel: { type: String, "default": 'No' }, iconPos: { type: String, "default": 'left' }, readonly: { type: Boolean, "default": false }, tabindex: { type: Number, "default": null }, ariaLabelledby: { type: String, "default": null }, ariaLabel: { type: String, "default": null }, size: { type: String, "default": null } }, style: ToggleButtonStyle, provide: function provide() { return { $pcToggleButton: this, $parentInstance: this }; } }; var script = { name: 'ToggleButton', "extends": script$1, inheritAttrs: false, emits: ['change'], methods: { getPTOptions: function getPTOptions(key) { var _ptm = key === 'root' ? this.ptmi : this.ptm; return _ptm(key, { context: { active: this.active, disabled: this.disabled } }); }, onChange: function onChange(event) { if (!this.disabled && !this.readonly) { this.writeValue(!this.d_value, event); this.$emit('change', event); } }, onBlur: function onBlur(event) { var _this$formField$onBlu, _this$formField; (_this$formField$onBlu = (_this$formField = this.formField).onBlur) === null || _this$formField$onBlu === void 0 || _this$formField$onBlu.call(_this$formField, event); } }, computed: { active: function active() { return this.d_value === true; }, hasLabel: function hasLabel() { return isNotEmpty(this.onLabel) && isNotEmpty(this.offLabel); }, label: function label() { return this.hasLabel ? this.d_value ? this.onLabel : this.offLabel : "\xA0"; } }, directives: { ripple: Ripple } }; function render(_ctx, _cache, $props, $setup, $data, $options) { var _component_Button = resolveComponent("Button"); var _directive_ripple = resolveDirective("ripple"); return withDirectives((openBlock(), createBlock(_component_Button, mergeProps({ type: "button", "class": _ctx.cx('root'), tabindex: _ctx.tabindex, disabled: _ctx.disabled, "aria-pressed": _ctx.d_value, onClick: $options.onChange, onBlur: $options.onBlur }, $options.getPTOptions('root'), { "aria-labelledby": _ctx.ariaLabelledby, "data-p-checked": $options.active, "data-p-disabled": _ctx.disabled }), { "default": withCtx(function () { return [createElementVNode("span", mergeProps({ "class": _ctx.cx('content') }, $options.getPTOptions('content')), [renderSlot(_ctx.$slots, "default", {}, function () { return [renderSlot(_ctx.$slots, "icon", { value: _ctx.d_value, "class": normalizeClass(_ctx.cx('icon')) }, function () { return [_ctx.onIcon || _ctx.offIcon ? (openBlock(), createElementBlock("span", mergeProps({ key: 0, "class": [_ctx.cx('icon'), _ctx.d_value ? _ctx.onIcon : _ctx.offIcon] }, $options.getPTOptions('icon')), null, 16)) : createCommentVNode("", true)]; }), createElementVNode("span", mergeProps({ "class": _ctx.cx('label') }, $options.getPTOptions('label')), toDisplayString($options.label), 17)]; })], 16)]; }), _: 3 }, 16, ["class", "tabindex", "disabled", "aria-pressed", "onClick", "onBlur", "aria-labelledby", "data-p-checked", "data-p-disabled"])), [[_directive_ripple]]); } script.render = render; export { script as default }; //# sourceMappingURL=index.mjs.map