{"version":3,"file":"radio.cjs","names":[],"sources":["../../../components/radio/radio.vue"],"sourcesContent":["<template>\n  <div\n    :class=\"rootClass\"\n    v-bind=\"addClassStyleAttrs($attrs)\"\n  >\n    <label :class=\"['d-radio-group', { 'd-radio-group--disabled': internalDisabled }]\">\n      <div class=\"d-radio__input\">\n        <input\n          :checked=\"internalChecked\"\n          :name=\"internalName\"\n          :value=\"value\"\n          :disabled=\"internalDisabled\"\n          type=\"radio\"\n          :class=\"['d-radio', inputValidationClass, inputClass]\"\n          v-bind=\"removeClassStyleAttrs($attrs)\"\n          v-on=\"inputListeners\"\n        >\n      </div>\n      <div\n        :class=\"[labelClass, 'd-radio__copy d-radio__label']\"\n        v-bind=\"labelChildProps\"\n        data-qa=\"radio-label\"\n      >\n        <!-- @slot slot for Radio Label -->\n        <slot>{{ label }}</slot>\n      </div>\n    </label>\n    <div\n      v-if=\"$slots.description || description || hasMessages\"\n      class=\"d-radio__messages\"\n      data-qa=\"radio-description-messages\"\n    >\n      <div\n        v-if=\"$slots.description || description\"\n        :class=\"['d-description', descriptionClass]\"\n        v-bind=\"descriptionChildProps\"\n        data-qa=\"radio-description\"\n      >\n        <!-- @slot slot for Radio Description -->\n        <slot name=\"description\">\n          {{ description }}\n        </slot>\n      </div>\n      <dt-validation-messages\n        :validation-messages=\"formattedMessages\"\n        :show-messages=\"showMessages\"\n        :class=\"messagesClass\"\n        v-bind=\"messagesChildProps\"\n        data-qa=\"dt-radio-validation-messages\"\n      />\n    </div>\n  </div>\n</template>\n\n<script>\nimport {\n  InputMixin,\n  CheckableMixin,\n  GroupableMixin,\n  MessagesMixin,\n} from '@/common/mixins/input';\nimport { RADIO_INPUT_VALIDATION_CLASSES } from './radio_constants';\nimport { DtValidationMessages } from '../validation_messages';\nimport { hasSlotContent, removeClassStyleAttrs, addClassStyleAttrs } from '@/common/utils';\n\n/**\n * Radios are control elements that allow the user to make a single selection.\n * They are typically used in a Radio Group which allows the user to make a selection from a list of options.\n * @see https://dialtone.dialpad.com/components/radio.html\n */\nexport default {\n  compatConfig: { MODE: 3 },\n  name: 'DtRadio',\n\n  components: { DtValidationMessages },\n\n  mixins: [InputMixin, CheckableMixin, GroupableMixin, MessagesMixin],\n\n  inheritAttrs: false,\n\n  props: {\n    /**\n     * A provided value for the radio\n     */\n    value: {\n      type: [String, Number],\n      default: '',\n    },\n  },\n\n  emits: [\n    /**\n     * Native input event\n     *\n     * @event input\n     * @type {String | Number}\n     */\n    'input',\n    /**\n     * Event fired to sync the modelValue prop with the parent component\n     *\n     * @event input\n     * @type {String | Number}\n     */\n    'update:modelValue',\n\n    /**\n     * Native input focus event\n     *\n     * @event focus\n     * @type {FocusEvent}\n     */\n    'focus',\n\n    /**\n     * Native input focusin event\n     *\n     * @event focusin\n     * @property {FocusEvent}\n     */\n    'focusin',\n\n    /**\n     * Native input focusout event\n     *\n     * @event focusout\n     * @property {FocusEvent}\n     */\n    'focusout',\n  ],\n\n  data () {\n    return {\n      hasSlotContent,\n    };\n  },\n\n  computed: {\n    inputValidationClass () {\n      return RADIO_INPUT_VALIDATION_CLASSES[this.internalValidationState];\n    },\n\n    radioGroupValue () {\n      return this.groupContext?.selectedValue;\n    },\n\n    inputListeners () {\n      return {\n        /*\n         * Override input listener to as no-op. Prevents parent input listeners from being passed through onto the input\n         * element which will result in the handler being called twice\n         * (once on the input element and once by the emitted input event by the change listener).\n        */\n        input: () => {},\n        focusin: event => this.$emit('focusin', event),\n        focusout: event => this.$emit('focusout', event),\n        change: event => this.emitValue(event.target.value),\n      };\n    },\n\n    hasMessages () {\n      return this.formattedMessages.length && this.showMessages;\n    },\n  },\n\n  watch: {\n    radioGroupValue: {\n      immediate: true,\n      handler (newRadioGroupValue) {\n        if (this.hasGroup) {\n          // update internal value when the radio group value changes\n          this.internalChecked = newRadioGroupValue === this.value;\n        }\n      },\n    },\n  },\n\n  methods: {\n    removeClassStyleAttrs,\n    addClassStyleAttrs,\n    emitValue (value) {\n      if (value !== this.radioGroupValue) {\n        // update provided value if injected\n        this.setGroupValue(value);\n        this.$emit('input', value);\n        this.$emit('update:modelValue', value);\n      }\n    },\n  },\n};\n</script>\n"],"mappings":"4YAsEA,IAAK,EAAU,CACb,aAAc,CAAE,KAAM,EAAG,CACzB,KAAM,UAEN,WAAY,CAAE,qBAAA,EAAA,QAAsB,CAEpC,OAAQ,CAAC,EAAA,WAAY,EAAA,eAAgB,EAAA,eAAgB,EAAA,cAAc,CAEnE,aAAc,GAEd,MAAO,CAIL,MAAO,CACL,KAAM,CAAC,OAAQ,OAAO,CACtB,QAAS,GACV,CACF,CAED,MAAO,CAOL,QAOA,oBAQA,QAQA,UAQA,WACD,CAED,MAAQ,CACN,MAAO,CACL,eAAA,EAAA,eACD,EAGH,SAAU,CACR,sBAAwB,CACtB,OAAO,EAAA,+BAA+B,KAAK,0BAG7C,iBAAmB,CACjB,OAAO,KAAK,cAAc,eAG5B,gBAAkB,CAChB,MAAO,CAML,UAAa,GACb,QAAS,GAAS,KAAK,MAAM,UAAW,EAAM,CAC9C,SAAU,GAAS,KAAK,MAAM,WAAY,EAAM,CAChD,OAAQ,GAAS,KAAK,UAAU,EAAM,OAAO,MAAM,CACpD,EAGH,aAAe,CACb,OAAO,KAAK,kBAAkB,QAAU,KAAK,cAEhD,CAED,MAAO,CACL,gBAAiB,CACf,UAAW,GACX,QAAS,EAAoB,CACvB,KAAK,WAEP,KAAK,gBAAkB,IAAuB,KAAK,QAGxD,CACF,CAED,QAAS,CACP,sBAAA,EAAA,sBACA,mBAAA,EAAA,mBACA,UAAW,EAAO,CACZ,IAAU,KAAK,kBAEjB,KAAK,cAAc,EAAM,CACzB,KAAK,MAAM,QAAS,EAAM,CAC1B,KAAK,MAAM,oBAAqB,EAAM,GAG3C,CACF,IAvLU,MAAM,iBAAgB,kDAuB3B,MAAM,oBACN,UAAQ,8JAqBN,OAAA,EAAA,EAAA,YAAA,CAjDH,MAAO,EAAA,UAAS,CACT,EAAA,mBAAmB,EAAA,OAAM,CAAA,CAAA,EAAA,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