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.4 kB
{"version":3,"file":"index.mjs","sources":["../../src/toggleswitch/BaseToggleSwitch.vue","../../src/toggleswitch/ToggleSwitch.vue","../../src/toggleswitch/ToggleSwitch.vue?vue&type=template&id=b155e212&lang.js"],"sourcesContent":["<script>\nimport BaseEditableHolder from '@primevue/core/baseeditableholder';\nimport ToggleSwitchStyle from 'primevue/toggleswitch/style';\n\nexport default {\n name: 'BaseToggleSwitch',\n extends: BaseEditableHolder,\n props: {\n trueValue: {\n type: null,\n default: true\n },\n falseValue: {\n type: null,\n default: false\n },\n readonly: {\n type: Boolean,\n default: false\n },\n tabindex: {\n type: Number,\n default: null\n },\n inputId: {\n type: String,\n default: null\n },\n inputClass: {\n type: [String, Object],\n default: null\n },\n inputStyle: {\n type: Object,\n default: null\n },\n ariaLabelledby: {\n type: String,\n default: null\n },\n ariaLabel: {\n type: String,\n default: null\n }\n },\n style: ToggleSwitchStyle,\n provide() {\n return {\n $pcToggleSwitch: this,\n $parentInstance: this\n };\n }\n};\n</script>\n","<template>\n <div :class=\"cx('root')\" :style=\"sx('root')\" v-bind=\"getPTOptions('root')\" :data-p-checked=\"checked\" :data-p-disabled=\"disabled\" :data-p=\"dataP\">\n <input\n :id=\"inputId\"\n type=\"checkbox\"\n role=\"switch\"\n :class=\"[cx('input'), inputClass]\"\n :style=\"inputStyle\"\n :checked=\"checked\"\n :tabindex=\"tabindex\"\n :disabled=\"disabled\"\n :readonly=\"readonly\"\n :aria-checked=\"checked\"\n :aria-labelledby=\"ariaLabelledby\"\n :aria-label=\"ariaLabel\"\n :aria-invalid=\"invalid || undefined\"\n @focus=\"onFocus\"\n @blur=\"onBlur\"\n @change=\"onChange\"\n v-bind=\"getPTOptions('input')\"\n />\n <div :class=\"cx('slider')\" v-bind=\"getPTOptions('slider')\" :data-p=\"dataP\">\n <div :class=\"cx('handle')\" v-bind=\"getPTOptions('handle')\" :data-p=\"dataP\">\n <slot name=\"handle\" :checked=\"checked\" />\n </div>\n </div>\n </div>\n</template>\n\n<script>\nimport { cn } from '@primeuix/utils';\nimport BaseToggleSwitch from './BaseToggleSwitch.vue';\n\nexport default {\n name: 'ToggleSwitch',\n extends: BaseToggleSwitch,\n inheritAttrs: false,\n emits: ['change', 'focus', 'blur'],\n methods: {\n getPTOptions(key) {\n const _ptm = key === 'root' ? this.ptmi : this.ptm;\n\n return _ptm(key, {\n context: {\n checked: this.checked,\n disabled: this.disabled\n }\n });\n },\n onChange(event) {\n if (!this.disabled && !this.readonly) {\n const newValue = this.checked ? this.falseValue : this.trueValue;\n\n this.writeValue(newValue, event);\n this.$emit('change', event);\n }\n },\n onFocus(event) {\n this.$emit('focus', event);\n },\n onBlur(event) {\n this.$emit('blur', event);\n this.formField.onBlur?.(event);\n }\n },\n computed: {\n checked() {\n return this.d_value === this.trueValue;\n },\n dataP() {\n return cn({\n checked: this.checked,\n disabled: this.disabled,\n invalid: this.$invalid\n });\n }\n }\n};\n</script>\n","<template>\n <div :class=\"cx('root')\" :style=\"sx('root')\" v-bind=\"getPTOptions('root')\" :data-p-checked=\"checked\" :data-p-disabled=\"disabled\" :data-p=\"dataP\">\n <input\n :id=\"inputId\"\n type=\"checkbox\"\n role=\"switch\"\n :class=\"[cx('input'), inputClass]\"\n :style=\"inputStyle\"\n :checked=\"checked\"\n :tabindex=\"tabindex\"\n :disabled=\"disabled\"\n :readonly=\"readonly\"\n :aria-checked=\"checked\"\n :aria-labelledby=\"ariaLabelledby\"\n :aria-label=\"ariaLabel\"\n :aria-invalid=\"invalid || undefined\"\n @focus=\"onFocus\"\n @blur=\"onBlur\"\n @change=\"onChange\"\n v-bind=\"getPTOptions('input')\"\n />\n <div :class=\"cx('slider')\" v-bind=\"getPTOptions('slider')\" :data-p=\"dataP\">\n <div :class=\"cx('handle')\" v-bind=\"getPTOptions('handle')\" :data-p=\"dataP\">\n <slot name=\"handle\" :checked=\"checked\" />\n </div>\n </div>\n </div>\n</template>\n\n<script>\nimport { cn } from '@primeuix/utils';\nimport BaseToggleSwitch from './BaseToggleSwitch.vue';\n\nexport default {\n name: 'ToggleSwitch',\n extends: BaseToggleSwitch,\n inheritAttrs: false,\n emits: ['change', 'focus', 'blur'],\n methods: {\n getPTOptions(key) {\n const _ptm = key === 'root' ? this.ptmi : this.ptm;\n\n return _ptm(key, {\n context: {\n checked: this.checked,\n disabled: this.disabled\n }\n });\n },\n onChange(event) {\n if (!this.disabled && !this.readonly) {\n const newValue = this.checked ? this.falseValue : this.trueValue;\n\n this.writeValue(newValue, event);\n this.$emit('change', event);\n }\n },\n onFocus(event) {\n this.$emit('focus', event);\n },\n onBlur(event) {\n this.$emit('blur', event);\n this.formField.onBlur?.(event);\n }\n },\n computed: {\n checked() {\n return this.d_value === this.trueValue;\n },\n dataP() {\n return cn({\n checked: this.checked,\n disabled: this.disabled,\n invalid: this.$invalid\n });\n }\n }\n};\n</script>\n"],"names":["name","BaseEditableHolder","props","trueValue","type","falseValue","readonly","Boolean","tabindex","Number","inputId","String","inputClass","Object","inputStyle","ariaLabelledby","ariaLabel","style","ToggleSwitchStyle","provide","$pcToggleSwitch","$parentInstance","BaseToggleSwitch","inheritAttrs","emits","methods","getPTOptions","key","_ptm","ptmi","ptm","context","checked","disabled","onChange","event","newValue","writeValue","$emit","onFocus","onBlur","_this$formField$onBlu","_this$formField","formField","call","computed","d_value","dataP","cn","invalid","$invalid","_openBlock","_createElementBlock","_mergeProps","_ctx","cx","sx","$options","_createElementVNode","id","role","undefined","apply","arguments","_hoisted_2","_renderSlot","$slots"],"mappings":";;;;;AAIA,eAAe;AACXA,EAAAA,IAAI,EAAE,kBAAkB;AACxB,EAAA,SAAA,EAASC,kBAAkB;AAC3BC,EAAAA,KAAK,EAAE;AACHC,IAAAA,SAAS,EAAE;AACPC,MAAAA,IAAI,EAAE,IAAI;MACV,SAAS,EA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