{"version":3,"file":"ClassicRadio-BwylgGYF.mjs","names":[],"sources":["../src/components/form/ClassicRadio.vue","../src/components/form/ClassicRadio.vue"],"sourcesContent":["<!--\n  Simple component to display radio buttons.\n\n  Available slots:\n    `label-{option.value}`: Slot to replace the label of the current option.\n                            Binding: `option`: the current option\n                                     `selected` : true if the option is selected\n    `after-{option.value}`: Slot after the radio button\n                            Binding: `option`: the current option\n                                     `selected` : true if the option is selected\n-->\n<template>\n    <div\n        role=\"radiogroup\"\n        class=\"d-flex\"\n        :class=\"isColumn !== false ? 'flex-column' : ''\"\n    >\n        <div\n            v-for=\"option in options\"\n            :key=\"option.title\"\n            class=\"octopus-form-item\"\n            :class=\"isColumn !== false ? 'd-flex flex-nowrap align-items-center' : 'me-2'\"\n        >\n            <input\n                :id=\"computedId + option.value\"\n                :checked=\"textInit === option.value\"\n                type=\"radio\"\n                :name=\"computedId\"\n                :value=\"option.value\"\n                :disabled=\"isDisabled\"\n                @input=\"onChange($event.target.value)\"\n            >\n            <label class=\"c-hand\" :for=\"computedId + option.value\">\n                <slot :name=\"'label-' + option.value\" v-bind=\"slotBindings(option)\">{{ option.title }}</slot>\n            </label>\n\n            <slot :name=\"'after-' + option.value\" v-bind=\"slotBindings(option)\" />\n        </div>\n    </div>\n</template>\n\n<script setup generic=\"T extends { title: string; value: string|undefined; }\" lang=\"ts\">\nimport { computed, getCurrentInstance } from 'vue';\n\n//Props \nconst { options, textInit, isColumn = true, idRadio } = defineProps<{\n    options: Array<T>;\n    textInit?: string;\n    idRadio?: string;\n    isDisabled?: boolean;\n    isColumn?: boolean;\n}>();\n\n//Emits\nconst emit = defineEmits<{\n    (e: 'update:textInit', value: string): void;\n    /** Emitted with update:text-init, containing the selected object */\n    (e: 'selected-item', value: T): void;\n}>();\n\nconst uid = getCurrentInstance()?.uid;\nconst computedId = computed((): string => {\n    if (idRadio !== undefined) {\n        return idRadio;\n    } else {\n        return 'classic-radio-' + uid;\n    }\n});\n\n//Methods\nfunction onChange(value: string): void {\n    emit('update:textInit', value);\n    const item = options.find(elt => elt.value === value);\n    if (item) {\n        emit('selected-item', item);\n    }\n}\n\nfunction slotBindings(option: T): { option: T; selected: boolean } {\n    return {\n        option,\n        selected: textInit === option.value\n    }\n}\n</script>\n","<!--\n  Simple component to display radio buttons.\n\n  Available slots:\n    `label-{option.value}`: Slot to replace the label of the current option.\n                            Binding: `option`: the current option\n                                     `selected` : true if the option is selected\n    `after-{option.value}`: Slot after the radio button\n                            Binding: `option`: the current option\n                                     `selected` : true if the option is selected\n-->\n<template>\n    <div\n        role=\"radiogroup\"\n        class=\"d-flex\"\n        :class=\"isColumn !== false ? 'flex-column' : ''\"\n    >\n        <div\n            v-for=\"option in options\"\n            :key=\"option.title\"\n            class=\"octopus-form-item\"\n            :class=\"isColumn !== false ? 'd-flex flex-nowrap align-items-center' : 'me-2'\"\n        >\n            <input\n                :id=\"computedId + option.value\"\n                :checked=\"textInit === option.value\"\n                type=\"radio\"\n                :name=\"computedId\"\n                :value=\"option.value\"\n                :disabled=\"isDisabled\"\n                @input=\"onChange($event.target.value)\"\n            >\n            <label class=\"c-hand\" :for=\"computedId + option.value\">\n                <slot :name=\"'label-' + option.value\" v-bind=\"slotBindings(option)\">{{ option.title }}</slot>\n            </label>\n\n            <slot :name=\"'after-' + option.value\" v-bind=\"slotBindings(option)\" />\n        </div>\n    </div>\n</template>\n\n<script setup generic=\"T extends { title: string; value: string|undefined; }\" lang=\"ts\">\nimport { computed, getCurrentInstance } from 'vue';\n\n//Props \nconst { options, textInit, isColumn = true, idRadio } = defineProps<{\n    options: Array<T>;\n    textInit?: string;\n    idRadio?: string;\n    isDisabled?: boolean;\n    isColumn?: boolean;\n}>();\n\n//Emits\nconst emit = defineEmits<{\n    (e: 'update:textInit', value: string): void;\n    /** Emitted with update:text-init, containing the selected object */\n    (e: 'selected-item', value: T): void;\n}>();\n\nconst uid = getCurrentInstance()?.uid;\nconst computedId = computed((): string => {\n    if (idRadio !== undefined) {\n        return idRadio;\n    } else {\n        return 'classic-radio-' + uid;\n    }\n});\n\n//Methods\nfunction onChange(value: string): void {\n    emit('update:textInit', value);\n    const item = options.find(elt => elt.value === value);\n    if (item) {\n        emit('selected-item', item);\n    }\n}\n\nfunction slotBindings(option: T): { option: T; selected: boolean } {\n    return {\n        option,\n        selected: textInit === option.value\n    }\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDA,MAAM,OAAO;EAMb,MAAM,MAAM,mBAAmB,GAAG;EAClC,MAAM,aAAa,eAAuB;GACtC,IAAI,QAAA,YAAY,KAAA,GACZ,OAAO,QAAA;QAEP,OAAO,mBAAmB;EAElC,CAAC;EAGD,SAAS,SAAS,OAAqB;GACnC,KAAK,mBAAmB,KAAK;GAC7B,MAAM,OAAO,QAAA,QAAQ,MAAK,QAAO,IAAI,UAAU,KAAK;GACpD,IAAI,MACA,KAAK,iBAAiB,IAAI;EAElC;EAEA,SAAS,aAAa,QAA6C;GAC/D,OAAO;IACH;IACA,UAAU,QAAA,aAAa,OAAO;GAClC;EACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;qBCvEI,mBA0BM,OAAA;EAzBF,MAAK;EACL,OAAK,eAAA,CAAC,UACE,OAAA,aAAQ,QAAA,gBAAA,EAAA,CAAA;uBAEhB,mBAoBM,UAAA,MAAA,WAnBe,OAAA,UAAV,WAAM;sBADjB,mBAoBM,OAAA;GAlBD,KAAK,OAAO;GACb,OAAK,eAAA,CAAC,qBACE,OAAA,aAAQ,QAAA,0CAAA,MAAA,CAAA;;GAEhB,mBAQC,SAAA;IAPI,IAAI,OAAA,aAAa,OAAO;IACxB,SAAS,OAAA,aAAa,OAAO;IAC9B,MAAK;IACJ,MAAM,OAAA;IACN,OAAO,OAAO;IACd,UAAU,OAAA;IACV,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,OAAA,SAAS,OAAO,OAAO,KAAK;;GAExC,mBAEQ,SAAA;IAFD,OAAM;IAAU,KAAK,OAAA,aAAa,OAAO;OAC5C,WAA6F,KAAA,QAAA,WAArE,OAAO,OAA/B,WAA6F,EAAA,SAAA,KAAA,GAA/C,OAAA,aAAa,MAAM,CAAA,SAA4B,CAAA,gBAAA,gBAAtB,OAAO,KAAK,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,GAAA,UAAA;GAGvF,WAAsE,KAAA,QAAA,WAA9C,OAAO,OAA/B,WAAsE,EAAA,SAAA,KAAA,GAAxB,OAAA,aAAa,MAAM,CAAA,CAAA"}