'use strict';

var BaseComponent = require('primevue/basecomponent');
var utils = require('primevue/utils');
var vue = require('vue');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);

var script = {
    name: 'RadioButton',
    extends: BaseComponent__default["default"],
    emits: ['click', 'update:modelValue', 'change', 'focus', 'blur'],
    props: {
        value: null,
        modelValue: null,
        name: {
            type: String,
            default: null
        },
        disabled: {
            type: Boolean,
            default: false
        },
        inputId: {
            type: String,
            default: null
        },
        inputClass: {
            type: [String, Object],
            default: null
        },
        inputStyle: {
            type: Object,
            default: null
        },
        inputProps: {
            type: null,
            default: null
        },
        'aria-labelledby': {
            type: String,
            default: null
        },
        'aria-label': {
            type: String,
            default: null
        },

        label:{
            type:String,
            default:""
        },

        leftText:{
            type:Boolean,
            default:false
        },
        tableCellEditor:{
            type:Boolean,
            default:false
        }
    },
    data() {
        return {
            focused: false
        };
    },
    methods: {
        onClick(event) {
            if (!this.disabled) {
                this.$emit('click', event);
                this.$emit('update:modelValue', this.value);
                this.$refs.input.focus();

                if (!this.checked) {
                    this.$emit('change', event);
                }
            }
        },
        onFocus(event) {
            this.focused = true;
            this.$emit('focus', event);
        },
        onBlur(event) {
            this.focused = false;
            this.$emit('blur', event);
        }
    },
    computed: {
        checked() {
            return this.modelValue != null && utils.ObjectUtils.equals(this.modelValue, this.value);
        },
        containerClass() {
            return [
                'p-radiobutton p-component',
                {
                    'p-radiobutton-checked': this.checked,
                    'p-radiobutton-disabled': this.disabled,
                    'p-radiobutton-focused': this.focused
                }
            ];
        },
        containerId(){
            return utils.UniqueComponentId();
        }
    }
};

const _hoisted_1 = ["id"];
const _hoisted_2 = ["id", "name", "checked", "disabled", "value", "aria-labelledby", "aria-label"];
const _hoisted_3 = ["for"];
const _hoisted_4 = ["for"];

function render(_ctx, _cache, $props, $setup, $data, $options) {
  return (vue.openBlock(), vue.createElementBlock("div", vue.mergeProps({
    id: $options.containerId,
    class: $options.containerClass,
    onClick: _cache[2] || (_cache[2] = $event => ($options.onClick($event)))
  }, _ctx.ptm('root')), [
    vue.createElementVNode("div", vue.mergeProps({ class: "p-hidden-accessible" }, _ctx.ptm('hiddenInputWrapper')), [
      vue.createElementVNode("input", vue.mergeProps({
        ref: "input",
        id: $props.inputId,
        type: "radio",
        class: $props.inputClass,
        style: $props.inputStyle,
        name: $props.name,
        checked: $options.checked,
        disabled: $props.disabled,
        value: $props.value,
        "aria-labelledby": _ctx.ariaLabelledby,
        "aria-label": _ctx.ariaLabel,
        onFocus: _cache[0] || (_cache[0] = (...args) => ($options.onFocus && $options.onFocus(...args))),
        onBlur: _cache[1] || (_cache[1] = (...args) => ($options.onBlur && $options.onBlur(...args)))
      }, _ctx.ptm('hiddenInput')), null, 16 /* FULL_PROPS */, _hoisted_2)
    ], 16 /* FULL_PROPS */),
    ($props.leftText)
      ? vue.renderSlot(_ctx.$slots, "label", {
          key: 0,
          checked: $options.checked,
          class: vue.normalizeClass(['p-adiobutton-label','label-position-left', $props.inputClass, { 'p-highlight': $options.checked, 'p-disabled': $props.disabled, 'p-focus': $data.focused }] )
        }, () => [
          vue.createElementVNode("label", {
            for: $options.containerId,
            class: vue.normalizeClass(['p-adiobutton-label','label-position-left', $props.inputClass, { 'p-highlight': $options.checked, 'p-disabled': $props.disabled, 'p-focus': $data.focused }] )
          }, vue.toDisplayString($props.label), 11 /* TEXT, CLASS, PROPS */, _hoisted_3)
        ])
      : vue.createCommentVNode("v-if", true),
    vue.createElementVNode("div", vue.mergeProps({
      ref: "box",
      class: ['p-radiobutton-box', { 'p-highlight': $options.checked, 'p-disabled': $props.disabled, 'p-focus': $data.focused }]
    }, { ...$props.inputProps, ..._ctx.ptm('input') }), [
      vue.createElementVNode("div", vue.mergeProps({ class: "p-radiobutton-icon" }, _ctx.ptm('icon')), null, 16 /* FULL_PROPS */)
    ], 16 /* FULL_PROPS */),
    (!$props.leftText)
      ? vue.renderSlot(_ctx.$slots, "label", {
          key: 1,
          checked: $options.checked,
          class: vue.normalizeClass(['p-adiobutton-label','label-position-right', $props.inputClass, { 'p-highlight': $options.checked, 'p-disabled': $props.disabled, 'p-focus': $data.focused }  ] )
        }, () => [
          vue.createElementVNode("label", {
            for: $options.containerId,
            class: vue.normalizeClass(['p-adiobutton-label','label-position-right', $props.inputClass, { 'p-highlight': $options.checked, 'p-disabled': $props.disabled, 'p-focus': $data.focused }  ] )
          }, vue.toDisplayString($props.label), 11 /* TEXT, CLASS, PROPS */, _hoisted_4)
        ])
      : vue.createCommentVNode("v-if", true)
  ], 16 /* FULL_PROPS */, _hoisted_1))
}

script.render = render;
script.__file = "components/lib/radiobutton/RadioButton.vue";

module.exports = script;
