441 lines
13 KiB
JavaScript
441 lines
13 KiB
JavaScript
import {
|
|
CHANGE_EVENT,
|
|
UPDATE_MODEL_EVENT,
|
|
useAriaProps
|
|
} from "./chunk-6VHTGKN7.js";
|
|
import {
|
|
useDeprecated
|
|
} from "./chunk-HYWPQNOB.js";
|
|
import {
|
|
useFormItem,
|
|
useFormItemInputId,
|
|
useId
|
|
} from "./chunk-DIGHH22S.js";
|
|
import {
|
|
useFormDisabled,
|
|
useFormSize,
|
|
useSizeProp
|
|
} from "./chunk-FYPMSKES.js";
|
|
import {
|
|
debugWarn,
|
|
isBoolean,
|
|
isNumber,
|
|
isPropAbsent
|
|
} from "./chunk-UFIWN4M6.js";
|
|
import {
|
|
_export_sfc
|
|
} from "./chunk-MUJDDH7P.js";
|
|
import {
|
|
buildProps,
|
|
definePropType,
|
|
isEqual_default,
|
|
omit_default,
|
|
useNamespace,
|
|
withInstall,
|
|
withNoopInstall
|
|
} from "./chunk-R2OGZABH.js";
|
|
import {
|
|
Fragment,
|
|
computed,
|
|
createBaseVNode,
|
|
createBlock,
|
|
createElementBlock,
|
|
createTextVNode,
|
|
defineComponent,
|
|
inject,
|
|
isRef,
|
|
mergeProps,
|
|
nextTick,
|
|
onMounted,
|
|
openBlock,
|
|
provide,
|
|
reactive,
|
|
ref,
|
|
renderList,
|
|
renderSlot,
|
|
resolveDynamicComponent,
|
|
toRefs,
|
|
unref,
|
|
vModelRadio,
|
|
watch,
|
|
withDirectives,
|
|
withModifiers
|
|
} from "./chunk-AAHVYXXY.js";
|
|
import {
|
|
init_shared_esm_bundler,
|
|
isString,
|
|
normalizeClass,
|
|
normalizeStyle,
|
|
toDisplayString
|
|
} from "./chunk-OWZYVOTZ.js";
|
|
|
|
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/components/radio/src/radio.mjs
|
|
init_shared_esm_bundler();
|
|
var radioPropsBase = buildProps({
|
|
modelValue: {
|
|
type: [String, Number, Boolean],
|
|
default: void 0
|
|
},
|
|
size: useSizeProp,
|
|
disabled: Boolean,
|
|
label: {
|
|
type: [String, Number, Boolean],
|
|
default: void 0
|
|
},
|
|
value: {
|
|
type: [String, Number, Boolean],
|
|
default: void 0
|
|
},
|
|
name: {
|
|
type: String,
|
|
default: void 0
|
|
}
|
|
});
|
|
var radioProps = buildProps({
|
|
...radioPropsBase,
|
|
border: Boolean
|
|
});
|
|
var radioEmits = {
|
|
[UPDATE_MODEL_EVENT]: (val) => isString(val) || isNumber(val) || isBoolean(val),
|
|
[CHANGE_EVENT]: (val) => isString(val) || isNumber(val) || isBoolean(val)
|
|
};
|
|
|
|
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/components/radio/src/constants.mjs
|
|
var radioGroupKey = Symbol("radioGroupKey");
|
|
|
|
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/components/radio/src/use-radio.mjs
|
|
var useRadio = (props, emit) => {
|
|
const radioRef = ref();
|
|
const radioGroup = inject(radioGroupKey, void 0);
|
|
const isGroup = computed(() => !!radioGroup);
|
|
const actualValue = computed(() => {
|
|
if (!isPropAbsent(props.value)) {
|
|
return props.value;
|
|
}
|
|
return props.label;
|
|
});
|
|
const modelValue = computed({
|
|
get() {
|
|
return isGroup.value ? radioGroup.modelValue : props.modelValue;
|
|
},
|
|
set(val) {
|
|
if (isGroup.value) {
|
|
radioGroup.changeEvent(val);
|
|
} else {
|
|
emit && emit(UPDATE_MODEL_EVENT, val);
|
|
}
|
|
radioRef.value.checked = props.modelValue === actualValue.value;
|
|
}
|
|
});
|
|
const size = useFormSize(computed(() => radioGroup == null ? void 0 : radioGroup.size));
|
|
const disabled = useFormDisabled(computed(() => radioGroup == null ? void 0 : radioGroup.disabled));
|
|
const focus = ref(false);
|
|
const tabIndex = computed(() => {
|
|
return disabled.value || isGroup.value && modelValue.value !== actualValue.value ? -1 : 0;
|
|
});
|
|
useDeprecated({
|
|
from: "label act as value",
|
|
replacement: "value",
|
|
version: "3.0.0",
|
|
scope: "el-radio",
|
|
ref: "https://element-plus.org/en-US/component/radio.html"
|
|
}, computed(() => isGroup.value && isPropAbsent(props.value)));
|
|
return {
|
|
radioRef,
|
|
isGroup,
|
|
radioGroup,
|
|
focus,
|
|
size,
|
|
disabled,
|
|
tabIndex,
|
|
modelValue,
|
|
actualValue
|
|
};
|
|
};
|
|
|
|
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/components/radio/src/radio2.mjs
|
|
var __default__ = defineComponent({
|
|
name: "ElRadio"
|
|
});
|
|
var _sfc_main = defineComponent({
|
|
...__default__,
|
|
props: radioProps,
|
|
emits: radioEmits,
|
|
setup(__props, { emit }) {
|
|
const props = __props;
|
|
const ns = useNamespace("radio");
|
|
const { radioRef, radioGroup, focus, size, disabled, modelValue, actualValue } = useRadio(props, emit);
|
|
function handleChange() {
|
|
nextTick(() => emit(CHANGE_EVENT, modelValue.value));
|
|
}
|
|
return (_ctx, _cache) => {
|
|
var _a;
|
|
return openBlock(), createElementBlock("label", {
|
|
class: normalizeClass([
|
|
unref(ns).b(),
|
|
unref(ns).is("disabled", unref(disabled)),
|
|
unref(ns).is("focus", unref(focus)),
|
|
unref(ns).is("bordered", _ctx.border),
|
|
unref(ns).is("checked", unref(modelValue) === unref(actualValue)),
|
|
unref(ns).m(unref(size))
|
|
])
|
|
}, [
|
|
createBaseVNode("span", {
|
|
class: normalizeClass([
|
|
unref(ns).e("input"),
|
|
unref(ns).is("disabled", unref(disabled)),
|
|
unref(ns).is("checked", unref(modelValue) === unref(actualValue))
|
|
])
|
|
}, [
|
|
withDirectives(createBaseVNode("input", {
|
|
ref_key: "radioRef",
|
|
ref: radioRef,
|
|
"onUpdate:modelValue": ($event) => isRef(modelValue) ? modelValue.value = $event : null,
|
|
class: normalizeClass(unref(ns).e("original")),
|
|
value: unref(actualValue),
|
|
name: _ctx.name || ((_a = unref(radioGroup)) == null ? void 0 : _a.name),
|
|
disabled: unref(disabled),
|
|
checked: unref(modelValue) === unref(actualValue),
|
|
type: "radio",
|
|
onFocus: ($event) => focus.value = true,
|
|
onBlur: ($event) => focus.value = false,
|
|
onChange: handleChange,
|
|
onClick: withModifiers(() => {
|
|
}, ["stop"])
|
|
}, null, 42, ["onUpdate:modelValue", "value", "name", "disabled", "checked", "onFocus", "onBlur", "onClick"]), [
|
|
[vModelRadio, unref(modelValue)]
|
|
]),
|
|
createBaseVNode("span", {
|
|
class: normalizeClass(unref(ns).e("inner"))
|
|
}, null, 2)
|
|
], 2),
|
|
createBaseVNode("span", {
|
|
class: normalizeClass(unref(ns).e("label")),
|
|
onKeydown: withModifiers(() => {
|
|
}, ["stop"])
|
|
}, [
|
|
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
createTextVNode(toDisplayString(_ctx.label), 1)
|
|
])
|
|
], 42, ["onKeydown"])
|
|
], 2);
|
|
};
|
|
}
|
|
});
|
|
var Radio = _export_sfc(_sfc_main, [["__file", "radio.vue"]]);
|
|
|
|
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/components/radio/src/radio-button.mjs
|
|
var radioButtonProps = buildProps({
|
|
...radioPropsBase
|
|
});
|
|
|
|
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/components/radio/src/radio-button2.mjs
|
|
var __default__2 = defineComponent({
|
|
name: "ElRadioButton"
|
|
});
|
|
var _sfc_main2 = defineComponent({
|
|
...__default__2,
|
|
props: radioButtonProps,
|
|
setup(__props) {
|
|
const props = __props;
|
|
const ns = useNamespace("radio");
|
|
const { radioRef, focus, size, disabled, modelValue, radioGroup, actualValue } = useRadio(props);
|
|
const activeStyle = computed(() => {
|
|
return {
|
|
backgroundColor: (radioGroup == null ? void 0 : radioGroup.fill) || "",
|
|
borderColor: (radioGroup == null ? void 0 : radioGroup.fill) || "",
|
|
boxShadow: (radioGroup == null ? void 0 : radioGroup.fill) ? `-1px 0 0 0 ${radioGroup.fill}` : "",
|
|
color: (radioGroup == null ? void 0 : radioGroup.textColor) || ""
|
|
};
|
|
});
|
|
return (_ctx, _cache) => {
|
|
var _a;
|
|
return openBlock(), createElementBlock("label", {
|
|
class: normalizeClass([
|
|
unref(ns).b("button"),
|
|
unref(ns).is("active", unref(modelValue) === unref(actualValue)),
|
|
unref(ns).is("disabled", unref(disabled)),
|
|
unref(ns).is("focus", unref(focus)),
|
|
unref(ns).bm("button", unref(size))
|
|
])
|
|
}, [
|
|
withDirectives(createBaseVNode("input", {
|
|
ref_key: "radioRef",
|
|
ref: radioRef,
|
|
"onUpdate:modelValue": ($event) => isRef(modelValue) ? modelValue.value = $event : null,
|
|
class: normalizeClass(unref(ns).be("button", "original-radio")),
|
|
value: unref(actualValue),
|
|
type: "radio",
|
|
name: _ctx.name || ((_a = unref(radioGroup)) == null ? void 0 : _a.name),
|
|
disabled: unref(disabled),
|
|
onFocus: ($event) => focus.value = true,
|
|
onBlur: ($event) => focus.value = false,
|
|
onClick: withModifiers(() => {
|
|
}, ["stop"])
|
|
}, null, 42, ["onUpdate:modelValue", "value", "name", "disabled", "onFocus", "onBlur", "onClick"]), [
|
|
[vModelRadio, unref(modelValue)]
|
|
]),
|
|
createBaseVNode("span", {
|
|
class: normalizeClass(unref(ns).be("button", "inner")),
|
|
style: normalizeStyle(unref(modelValue) === unref(actualValue) ? unref(activeStyle) : {}),
|
|
onKeydown: withModifiers(() => {
|
|
}, ["stop"])
|
|
}, [
|
|
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
createTextVNode(toDisplayString(_ctx.label), 1)
|
|
])
|
|
], 46, ["onKeydown"])
|
|
], 2);
|
|
};
|
|
}
|
|
});
|
|
var RadioButton = _export_sfc(_sfc_main2, [["__file", "radio-button.vue"]]);
|
|
|
|
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/components/radio/src/radio-group.mjs
|
|
var radioGroupProps = buildProps({
|
|
id: {
|
|
type: String,
|
|
default: void 0
|
|
},
|
|
size: useSizeProp,
|
|
disabled: Boolean,
|
|
modelValue: {
|
|
type: [String, Number, Boolean],
|
|
default: void 0
|
|
},
|
|
fill: {
|
|
type: String,
|
|
default: ""
|
|
},
|
|
textColor: {
|
|
type: String,
|
|
default: ""
|
|
},
|
|
name: {
|
|
type: String,
|
|
default: void 0
|
|
},
|
|
validateEvent: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
options: {
|
|
type: definePropType(Array)
|
|
},
|
|
props: {
|
|
type: definePropType(Object),
|
|
default: () => radioDefaultProps
|
|
},
|
|
type: {
|
|
type: String,
|
|
values: ["radio", "button"],
|
|
default: "radio"
|
|
},
|
|
...useAriaProps(["ariaLabel"])
|
|
});
|
|
var radioGroupEmits = radioEmits;
|
|
var radioDefaultProps = {
|
|
label: "label",
|
|
value: "value",
|
|
disabled: "disabled"
|
|
};
|
|
|
|
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/components/radio/src/radio-group2.mjs
|
|
var __default__3 = defineComponent({
|
|
name: "ElRadioGroup"
|
|
});
|
|
var _sfc_main3 = defineComponent({
|
|
...__default__3,
|
|
props: radioGroupProps,
|
|
emits: radioGroupEmits,
|
|
setup(__props, { emit }) {
|
|
const props = __props;
|
|
const ns = useNamespace("radio");
|
|
const radioId = useId();
|
|
const radioGroupRef = ref();
|
|
const { formItem } = useFormItem();
|
|
const { inputId: groupId, isLabeledByFormItem } = useFormItemInputId(props, {
|
|
formItemContext: formItem
|
|
});
|
|
const changeEvent = (value) => {
|
|
emit(UPDATE_MODEL_EVENT, value);
|
|
nextTick(() => emit(CHANGE_EVENT, value));
|
|
};
|
|
onMounted(() => {
|
|
const radios = radioGroupRef.value.querySelectorAll("[type=radio]");
|
|
const firstLabel = radios[0];
|
|
if (!Array.from(radios).some((radio) => radio.checked) && firstLabel) {
|
|
firstLabel.tabIndex = 0;
|
|
}
|
|
});
|
|
const name = computed(() => {
|
|
return props.name || radioId.value;
|
|
});
|
|
const aliasProps = computed(() => ({
|
|
...radioDefaultProps,
|
|
...props.props
|
|
}));
|
|
const getOptionProps = (option) => {
|
|
const { label, value, disabled } = aliasProps.value;
|
|
const base = {
|
|
label: option[label],
|
|
value: option[value],
|
|
disabled: option[disabled]
|
|
};
|
|
return { ...omit_default(option, [label, value, disabled]), ...base };
|
|
};
|
|
const optionComponent = computed(() => props.type === "button" ? RadioButton : Radio);
|
|
provide(radioGroupKey, reactive({
|
|
...toRefs(props),
|
|
changeEvent,
|
|
name
|
|
}));
|
|
watch(() => props.modelValue, (newVal, oldValue) => {
|
|
if (props.validateEvent && !isEqual_default(newVal, oldValue)) {
|
|
formItem == null ? void 0 : formItem.validate("change").catch((err) => debugWarn(err));
|
|
}
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return openBlock(), createElementBlock("div", {
|
|
id: unref(groupId),
|
|
ref_key: "radioGroupRef",
|
|
ref: radioGroupRef,
|
|
class: normalizeClass(unref(ns).b("group")),
|
|
role: "radiogroup",
|
|
"aria-label": !unref(isLabeledByFormItem) ? _ctx.ariaLabel || "radio-group" : void 0,
|
|
"aria-labelledby": unref(isLabeledByFormItem) ? unref(formItem).labelId : void 0
|
|
}, [
|
|
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.options, (item, index) => {
|
|
return openBlock(), createBlock(resolveDynamicComponent(unref(optionComponent)), mergeProps({ key: index }, getOptionProps(item)), null, 16);
|
|
}), 128))
|
|
])
|
|
], 10, ["id", "aria-label", "aria-labelledby"]);
|
|
};
|
|
}
|
|
});
|
|
var RadioGroup = _export_sfc(_sfc_main3, [["__file", "radio-group.vue"]]);
|
|
|
|
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/components/radio/index.mjs
|
|
var ElRadio = withInstall(Radio, {
|
|
RadioButton,
|
|
RadioGroup
|
|
});
|
|
var ElRadioGroup = withNoopInstall(RadioGroup);
|
|
var ElRadioButton = withNoopInstall(RadioButton);
|
|
|
|
export {
|
|
radioPropsBase,
|
|
radioProps,
|
|
radioEmits,
|
|
radioGroupKey,
|
|
radioButtonProps,
|
|
radioGroupProps,
|
|
radioGroupEmits,
|
|
radioDefaultProps,
|
|
ElRadio,
|
|
ElRadioGroup,
|
|
ElRadioButton
|
|
};
|
|
//# sourceMappingURL=chunk-SE2XFLE7.js.map
|