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 16.5 kB
{"version":3,"file":"index.mjs","sources":["../../src/selectbutton/BaseSelectButton.vue","../../src/selectbutton/SelectButton.vue","../../src/selectbutton/SelectButton.vue?vue&type=template&id=d83aac12&lang.js"],"sourcesContent":["<script>\nimport BaseEditableHolder from '@primevue/core/baseeditableholder';\nimport SelectButtonStyle from 'primevue/selectbutton/style';\n\nexport default {\n name: 'BaseSelectButton',\n extends: BaseEditableHolder,\n props: {\n options: Array,\n optionLabel: null,\n optionValue: null,\n optionDisabled: null,\n multiple: Boolean,\n allowEmpty: {\n type: Boolean,\n default: true\n },\n dataKey: null,\n ariaLabelledby: {\n type: String,\n default: null\n },\n size: {\n type: String,\n default: null\n }\n },\n style: SelectButtonStyle,\n provide() {\n return {\n $pcSelectButton: this,\n $parentInstance: this\n };\n }\n};\n</script>\n","<template>\n <div :class=\"cx('root')\" role=\"group\" :aria-labelledby=\"ariaLabelledby\" v-bind=\"ptmi('root')\" :data-p=\"dataP\">\n <template v-for=\"(option, index) of options\" :key=\"getOptionRenderKey(option)\">\n <ToggleButton\n :modelValue=\"isSelected(option)\"\n :onLabel=\"getOptionLabel(option)\"\n :offLabel=\"getOptionLabel(option)\"\n :disabled=\"disabled || isOptionDisabled(option)\"\n :unstyled=\"unstyled\"\n :size=\"size\"\n :readonly=\"isOptionReadonly(option)\"\n @change=\"onOptionSelect($event, option, index)\"\n :pt=\"ptm('pcToggleButton')\"\n >\n <template v-if=\"$slots.option\" #default>\n <slot name=\"option\" :option=\"option\" :index=\"index\">\n <span v-bind=\"ptm('pcToggleButton')['label']\">{{ getOptionLabel(option) }}</span>\n </slot>\n </template>\n </ToggleButton>\n </template>\n </div>\n</template>\n\n<script>\nimport { cn } from '@primeuix/utils';\nimport { equals, resolveFieldData } from '@primeuix/utils/object';\nimport Ripple from 'primevue/ripple';\nimport ToggleButton from 'primevue/togglebutton';\nimport BaseSelectButton from './BaseSelectButton.vue';\n\nexport default {\n name: 'SelectButton',\n extends: BaseSelectButton,\n inheritAttrs: false,\n emits: ['change'],\n methods: {\n getOptionLabel(option) {\n return this.optionLabel ? resolveFieldData(option, this.optionLabel) : option;\n },\n getOptionValue(option) {\n return this.optionValue ? resolveFieldData(option, this.optionValue) : option;\n },\n getOptionRenderKey(option) {\n return this.dataKey ? resolveFieldData(option, this.dataKey) : this.getOptionLabel(option);\n },\n isOptionDisabled(option) {\n return this.optionDisabled ? resolveFieldData(option, this.optionDisabled) : false;\n },\n isOptionReadonly(option) {\n if (this.allowEmpty) return false;\n\n let selected = this.isSelected(option);\n\n if (this.multiple) {\n return selected && this.d_value.length === 1;\n } else {\n return selected;\n }\n },\n onOptionSelect(event, option, index) {\n if (this.disabled || this.isOptionDisabled(option) || this.isOptionReadonly(option)) {\n return;\n }\n\n let selected = this.isSelected(option);\n let optionValue = this.getOptionValue(option);\n let newValue;\n\n if (this.multiple) {\n if (selected) {\n newValue = this.d_value.filter((val) => !equals(val, optionValue, this.equalityKey));\n if (!this.allowEmpty && newValue.length === 0) return;\n } else {\n newValue = this.d_value ? [...this.d_value, optionValue] : [optionValue];\n }\n } else {\n if (selected && !this.allowEmpty) return;\n newValue = selected ? null : optionValue;\n }\n\n this.writeValue(newValue, event);\n this.$emit('change', { event: event, value: newValue });\n },\n isSelected(option) {\n let selected = false;\n let optionValue = this.getOptionValue(option);\n\n if (this.multiple) {\n if (this.d_value) {\n for (let val of this.d_value) {\n if (equals(val, optionValue, this.equalityKey)) {\n selected = true;\n break;\n }\n }\n }\n } else {\n selected = equals(this.d_value, optionValue, this.equalityKey);\n }\n\n return selected;\n }\n },\n computed: {\n equalityKey() {\n return this.optionValue ? null : this.dataKey;\n },\n dataP() {\n return cn({\n invalid: this.$invalid\n });\n }\n },\n directives: {\n ripple: Ripple\n },\n components: {\n ToggleButton\n }\n};\n</script>\n","<template>\n <div :class=\"cx('root')\" role=\"group\" :aria-labelledby=\"ariaLabelledby\" v-bind=\"ptmi('root')\" :data-p=\"dataP\">\n <template v-for=\"(option, index) of options\" :key=\"getOptionRenderKey(option)\">\n <ToggleButton\n :modelValue=\"isSelected(option)\"\n :onLabel=\"getOptionLabel(option)\"\n :offLabel=\"getOptionLabel(option)\"\n :disabled=\"disabled || isOptionDisabled(option)\"\n :unstyled=\"unstyled\"\n :size=\"size\"\n :readonly=\"isOptionReadonly(option)\"\n @change=\"onOptionSelect($event, option, index)\"\n :pt=\"ptm('pcToggleButton')\"\n >\n <template v-if=\"$slots.option\" #default>\n <slot name=\"option\" :option=\"option\" :index=\"index\">\n <span v-bind=\"ptm('pcToggleButton')['label']\">{{ getOptionLabel(option) }}</span>\n </slot>\n </template>\n </ToggleButton>\n </template>\n </div>\n</template>\n\n<script>\nimport { cn } from '@primeuix/utils';\nimport { equals, resolveFieldData } from '@primeuix/utils/object';\nimport Ripple from 'primevue/ripple';\nimport ToggleButton from 'primevue/togglebutton';\nimport BaseSelectButton from './BaseSelectButton.vue';\n\nexport default {\n name: 'SelectButton',\n extends: BaseSelectButton,\n inheritAttrs: false,\n emits: ['change'],\n methods: {\n getOptionLabel(option) {\n return this.optionLabel ? resolveFieldData(option, this.optionLabel) : option;\n },\n getOptionValue(option) {\n return this.optionValue ? resolveFieldData(option, this.optionValue) : option;\n },\n getOptionRenderKey(option) {\n return this.dataKey ? resolveFieldData(option, this.dataKey) : this.getOptionLabel(option);\n },\n isOptionDisabled(option) {\n return this.optionDisabled ? resolveFieldData(option, this.optionDisabled) : false;\n },\n isOptionReadonly(option) {\n if (this.allowEmpty) return false;\n\n let selected = this.isSelected(option);\n\n if (this.multiple) {\n return selected && this.d_value.length === 1;\n } else {\n return selected;\n }\n },\n onOptionSelect(event, option, index) {\n if (this.disabled || this.isOptionDisabled(option) || this.isOptionReadonly(option)) {\n return;\n }\n\n let selected = this.isSelected(option);\n let optionValue = this.getOptionValue(option);\n let newValue;\n\n if (this.multiple) {\n if (selected) {\n newValue = this.d_value.filter((val) => !equals(val, optionValue, this.equalityKey));\n if (!this.allowEmpty && newValue.length === 0) return;\n } else {\n newValue = this.d_value ? [...this.d_value, optionValue] : [optionValue];\n }\n } else {\n if (selected && !this.allowEmpty) return;\n newValue = selected ? null : optionValue;\n }\n\n this.writeValue(newValue, event);\n this.$emit('change', { event: event, value: newValue });\n },\n isSelected(option) {\n let selected = false;\n let optionValue = this.getOptionValue(option);\n\n if (this.multiple) {\n if (this.d_value) {\n for (let val of this.d_value) {\n if (equals(val, optionValue, this.equalityKey)) {\n selected = true;\n break;\n }\n }\n }\n } else {\n selected = equals(this.d_value, optionValue, this.equalityKey);\n }\n\n return selected;\n }\n },\n computed: {\n equalityKey() {\n return this.optionValue ? null : this.dataKey;\n },\n dataP() {\n return cn({\n invalid: this.$invalid\n });\n }\n },\n directives: {\n ripple: Ripple\n },\n components: {\n ToggleButton\n }\n};\n</script>\n"],"names":["name","BaseEditableHolder","props","options","Array","optionLabel","optionValue","optionDisabled","multiple","Boolean","allowEmpty","type","dataKey","ariaLabelledby","String","size","style","SelectButtonStyle","provide","$pcSelectButton","$parentInstance","BaseSelectButton","inheritAttrs","emits","methods","getOptionLabel","option","resolveFieldData","getOptionValue","getOptionRenderKey","isOptionDisabled","isOptionReadonly","selected","isSelected","d_value","length","onOptionSelect","event","index","_this","disabled","newValue","filter","val","equals","equalityKey","concat","_toConsumableArray","writeValue","$emit","value","_iterator","_createForOfIteratorHelper","_step","s","n","done","err","e","f","computed","dataP","cn","invalid","$invalid","directives","ripple","Ripple","components","ToggleButton","_openBlock","_createElementBlock","_mergeProps","_ctx","cx","role","ptmi","$options","_Fragment","_renderList","_createBlock","_component_ToggleButton","key","modelValue","onLabel","offLabel","unstyled","readonly","onChange","$event","pt","ptm","$slots","_renderSlot","_createElementVNode","ref_for","_toDisplayString"],"mappings":";;;;;;;;AAIA,eAAe;AACXA,EAAAA,IAAI,EAAE,kBAAkB;AACxB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