123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import { mergeProps as _mergeProps, resolveDirective as _resolveDirective, createVNode as _createVNode, Fragment as _Fragment } from "vue";
- // Styles
- import "./VRadioGroup.css";
- // Components
- import { makeVInputProps, VInput } from "../VInput/VInput.mjs";
- import { VLabel } from "../VLabel/index.mjs";
- import { VSelectionControl } from "../VSelectionControl/index.mjs";
- import { makeSelectionControlGroupProps, VSelectionControlGroup } from "../VSelectionControlGroup/VSelectionControlGroup.mjs"; // Composables
- import { IconValue } from "../../composables/icons.mjs";
- import { useProxiedModel } from "../../composables/proxiedModel.mjs"; // Utilities
- import { computed } from 'vue';
- import { filterInputAttrs, genericComponent, getUid, omit, propsFactory, useRender } from "../../util/index.mjs"; // Types
- export const makeVRadioGroupProps = propsFactory({
- height: {
- type: [Number, String],
- default: 'auto'
- },
- ...makeVInputProps(),
- ...omit(makeSelectionControlGroupProps(), ['multiple']),
- trueIcon: {
- type: IconValue,
- default: '$radioOn'
- },
- falseIcon: {
- type: IconValue,
- default: '$radioOff'
- },
- type: {
- type: String,
- default: 'radio'
- }
- }, 'VRadioGroup');
- export const VRadioGroup = genericComponent()({
- name: 'VRadioGroup',
- inheritAttrs: false,
- props: makeVRadioGroupProps(),
- emits: {
- 'update:modelValue': value => true
- },
- setup(props, _ref) {
- let {
- attrs,
- slots
- } = _ref;
- const uid = getUid();
- const id = computed(() => props.id || `radio-group-${uid}`);
- const model = useProxiedModel(props, 'modelValue');
- useRender(() => {
- const [rootAttrs, controlAttrs] = filterInputAttrs(attrs);
- const inputProps = VInput.filterProps(props);
- const controlProps = VSelectionControl.filterProps(props);
- const label = slots.label ? slots.label({
- label: props.label,
- props: {
- for: id.value
- }
- }) : props.label;
- return _createVNode(VInput, _mergeProps({
- "class": ['v-radio-group', props.class],
- "style": props.style
- }, rootAttrs, inputProps, {
- "modelValue": model.value,
- "onUpdate:modelValue": $event => model.value = $event,
- "id": id.value
- }), {
- ...slots,
- default: _ref2 => {
- let {
- id,
- messagesId,
- isDisabled,
- isReadonly
- } = _ref2;
- return _createVNode(_Fragment, null, [label && _createVNode(VLabel, {
- "id": id.value
- }, {
- default: () => [label]
- }), _createVNode(VSelectionControlGroup, _mergeProps(controlProps, {
- "id": id.value,
- "aria-describedby": messagesId.value,
- "defaultsTarget": "VRadio",
- "trueIcon": props.trueIcon,
- "falseIcon": props.falseIcon,
- "type": props.type,
- "disabled": isDisabled.value,
- "readonly": isReadonly.value,
- "aria-labelledby": label ? id.value : undefined,
- "multiple": false
- }, controlAttrs, {
- "modelValue": model.value,
- "onUpdate:modelValue": $event => model.value = $event
- }), slots)]);
- }
- });
- });
- return {};
- }
- });
- //# sourceMappingURL=VRadioGroup.mjs.map
|