UNPKG

primevue

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

1 lines 11.2 kB
{"version":3,"file":"index.mjs","sources":["../../src/togglebutton/BaseToggleButton.vue","../../src/togglebutton/ToggleButton.vue","../../src/togglebutton/ToggleButton.vue?vue&type=template&id=7a5c1ac9&lang.js"],"sourcesContent":["<script>\nimport BaseEditableHolder from '@primevue/core/baseeditableholder';\nimport ToggleButtonStyle from 'primevue/togglebutton/style';\n\nexport default {\n name: 'BaseToggleButton',\n extends: BaseEditableHolder,\n props: {\n onIcon: String,\n offIcon: String,\n onLabel: {\n type: String,\n default: 'Yes'\n },\n offLabel: {\n type: String,\n default: 'No'\n },\n iconPos: {\n type: String,\n default: 'left'\n },\n readonly: {\n type: Boolean,\n default: false\n },\n tabindex: {\n type: Number,\n default: null\n },\n ariaLabelledby: {\n type: String,\n default: null\n },\n ariaLabel: {\n type: String,\n default: null\n },\n size: {\n type: String,\n default: null\n }\n },\n style: ToggleButtonStyle,\n provide() {\n return {\n $pcToggleButton: this,\n $parentInstance: this\n };\n }\n};\n</script>\n","<template>\n <button\n v-ripple\n type=\"button\"\n :class=\"cx('root')\"\n :tabindex=\"tabindex\"\n :disabled=\"disabled\"\n :aria-pressed=\"d_value\"\n @click=\"onChange\"\n @blur=\"onBlur\"\n v-bind=\"getPTOptions('root')\"\n :aria-label=\"ariaLabel\"\n :aria-labelledby=\"ariaLabelledby\"\n :data-p-checked=\"active\"\n :data-p-disabled=\"disabled\"\n :data-p=\"dataP\"\n >\n <span :class=\"cx('content')\" v-bind=\"getPTOptions('content')\" :data-p=\"dataP\">\n <slot>\n <slot name=\"icon\" :value=\"d_value\" :class=\"cx('icon')\">\n <span v-if=\"onIcon || offIcon\" :class=\"[cx('icon'), d_value ? onIcon : offIcon]\" v-bind=\"getPTOptions('icon')\" />\n </slot>\n <span :class=\"cx('label')\" v-bind=\"getPTOptions('label')\">{{ label }}</span>\n </slot>\n </span>\n </button>\n</template>\n\n<script>\nimport { cn } from '@primeuix/utils';\nimport { isNotEmpty } from '@primeuix/utils/object';\nimport Ripple from 'primevue/ripple';\nimport BaseToggleButton from './BaseToggleButton.vue';\n\nexport default {\n name: 'ToggleButton',\n extends: BaseToggleButton,\n inheritAttrs: false,\n emits: ['change'],\n methods: {\n getPTOptions(key) {\n const _ptm = key === 'root' ? this.ptmi : this.ptm;\n\n return _ptm(key, {\n context: {\n active: this.active,\n disabled: this.disabled\n }\n });\n },\n onChange(event) {\n if (!this.disabled && !this.readonly) {\n this.writeValue(!this.d_value, event);\n this.$emit('change', event);\n }\n },\n onBlur(event) {\n this.formField.onBlur?.(event);\n }\n },\n computed: {\n active() {\n return this.d_value === true;\n },\n hasLabel() {\n return isNotEmpty(this.onLabel) && isNotEmpty(this.offLabel);\n },\n label() {\n return this.hasLabel ? (this.d_value ? this.onLabel : this.offLabel) : '\\u00A0';\n },\n dataP() {\n return cn({\n checked: this.active,\n invalid: this.$invalid,\n [this.size]: this.size\n });\n }\n },\n directives: {\n ripple: Ripple\n }\n};\n</script>\n","<template>\n <button\n v-ripple\n type=\"button\"\n :class=\"cx('root')\"\n :tabindex=\"tabindex\"\n :disabled=\"disabled\"\n :aria-pressed=\"d_value\"\n @click=\"onChange\"\n @blur=\"onBlur\"\n v-bind=\"getPTOptions('root')\"\n :aria-label=\"ariaLabel\"\n :aria-labelledby=\"ariaLabelledby\"\n :data-p-checked=\"active\"\n :data-p-disabled=\"disabled\"\n :data-p=\"dataP\"\n >\n <span :class=\"cx('content')\" v-bind=\"getPTOptions('content')\" :data-p=\"dataP\">\n <slot>\n <slot name=\"icon\" :value=\"d_value\" :class=\"cx('icon')\">\n <span v-if=\"onIcon || offIcon\" :class=\"[cx('icon'), d_value ? onIcon : offIcon]\" v-bind=\"getPTOptions('icon')\" />\n </slot>\n <span :class=\"cx('label')\" v-bind=\"getPTOptions('label')\">{{ label }}</span>\n </slot>\n </span>\n </button>\n</template>\n\n<script>\nimport { cn } from '@primeuix/utils';\nimport { isNotEmpty } from '@primeuix/utils/object';\nimport Ripple from 'primevue/ripple';\nimport BaseToggleButton from './BaseToggleButton.vue';\n\nexport default {\n name: 'ToggleButton',\n extends: BaseToggleButton,\n inheritAttrs: false,\n emits: ['change'],\n methods: {\n getPTOptions(key) {\n const _ptm = key === 'root' ? this.ptmi : this.ptm;\n\n return _ptm(key, {\n context: {\n active: this.active,\n disabled: this.disabled\n }\n });\n },\n onChange(event) {\n if (!this.disabled && !this.readonly) {\n this.writeValue(!this.d_value, event);\n this.$emit('change', event);\n }\n },\n onBlur(event) {\n this.formField.onBlur?.(event);\n }\n },\n computed: {\n active() {\n return this.d_value === true;\n },\n hasLabel() {\n return isNotEmpty(this.onLabel) && isNotEmpty(this.offLabel);\n },\n label() {\n return this.hasLabel ? (this.d_value ? this.onLabel : this.offLabel) : '\\u00A0';\n },\n dataP() {\n return cn({\n checked: this.active,\n invalid: this.$invalid,\n [this.size]: this.size\n });\n }\n },\n directives: {\n ripple: Ripple\n }\n};\n</script>\n"],"names":["name","BaseEditableHolder","props","onIcon","String","offIcon","onLabel","type","offLabel","iconPos","readonly","Boolean","tabindex","Number","ariaLabelledby","ariaLabel","size","style","ToggleButtonStyle","provide","$pcToggleButton","$parentInstance","BaseToggleButton","inheritAttrs","emits","methods","getPTOptions","key","_ptm","ptmi","ptm","context","active","disabled","onChange","event","writeValue","d_value","$emit","onBlur","_this$formField$onBlu","_this$formField","formField","call","computed","hasLabel","isNotEmpty","label","dataP","cn","_defineProperty","checked","invalid","$invalid","directives","ripple","Ripple","_withDirectives","_openBlock","_createElementBlock","_mergeProps","_ctx","cx","onClick","$options","apply","arguments","_createElementVNode","_renderSlot","$slots","value"],"mappings":";;;;;;;AAIA,eAAe;AACXA,EAAAA,IAAI,EAAE,kBAAkB;AACxB,EAAA,SAAA,EAASC,kBAAkB;AAC3BC,EAAAA,KAAK,EAAE;AACHC,IAAAA,MAAM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