This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
import type { InjectionKey } from 'vue';
import type { RadioGroupProps } from './radio-group';
export interface RadioGroupContext extends RadioGroupProps {
changeEvent: (val: RadioGroupProps['modelValue']) => void;
}
export declare const radioGroupKey: InjectionKey<RadioGroupContext>;

View File

@@ -0,0 +1,8 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const radioGroupKey = Symbol("radioGroupKey");
exports.radioGroupKey = radioGroupKey;
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sources":["../../../../../../packages/components/radio/src/constants.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { RadioGroupProps } from './radio-group'\n\nexport interface RadioGroupContext extends RadioGroupProps {\n changeEvent: (val: RadioGroupProps['modelValue']) => void\n}\n\nexport const radioGroupKey: InjectionKey<RadioGroupContext> =\n Symbol('radioGroupKey')\n"],"names":[],"mappings":";;;;AAAY,MAAC,aAAa,GAAG,MAAM,CAAC,eAAe;;;;"}

View File

@@ -0,0 +1,18 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type RadioButton from './radio-button.vue';
export declare const radioButtonProps: {
readonly modelValue: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly disabled: BooleanConstructor;
readonly label: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly value: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
};
export type RadioButtonProps = ExtractPropTypes<typeof radioButtonProps>;
export type RadioButtonPropsPublic = __ExtractPublicPropTypes<typeof radioButtonProps>;
export type RadioButtonInstance = InstanceType<typeof RadioButton> & unknown;

View File

@@ -0,0 +1,13 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var radio = require('./radio2.js');
var runtime = require('../../../utils/vue/props/runtime.js');
const radioButtonProps = runtime.buildProps({
...radio.radioPropsBase
});
exports.radioButtonProps = radioButtonProps;
//# sourceMappingURL=radio-button.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"radio-button.js","sources":["../../../../../../packages/components/radio/src/radio-button.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils'\nimport { radioPropsBase } from './radio'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\nimport type RadioButton from './radio-button.vue'\n\nexport const radioButtonProps = buildProps({\n ...radioPropsBase,\n} as const)\n\nexport type RadioButtonProps = ExtractPropTypes<typeof radioButtonProps>\nexport type RadioButtonPropsPublic = __ExtractPublicPropTypes<\n typeof radioButtonProps\n>\nexport type RadioButtonInstance = InstanceType<typeof RadioButton> & unknown\n"],"names":["buildProps","radioPropsBase"],"mappings":";;;;;;;AAEY,MAAC,gBAAgB,GAAGA,kBAAU,CAAC;AAC3C,EAAE,GAAGC,oBAAc;AACnB,CAAC;;;;"}

View File

@@ -0,0 +1,41 @@
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly modelValue: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly disabled: BooleanConstructor;
readonly label: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly value: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly modelValue: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly disabled: BooleanConstructor;
readonly label: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly value: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
}>>, {
readonly label: import("element-plus/es/utils").EpPropMergeType<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>;
readonly disabled: boolean;
readonly value: import("element-plus/es/utils").EpPropMergeType<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>;
readonly name: string;
readonly modelValue: import("element-plus/es/utils").EpPropMergeType<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>;
}>;
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
export default _default;
type __VLS_WithTemplateSlots<T, S> = T & {
new (): {
$slots: S;
};
};

View File

@@ -0,0 +1,73 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var useRadio = require('./use-radio.js');
var radioButton = require('./radio-button.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
const __default__ = vue.defineComponent({
name: "ElRadioButton"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: radioButton.radioButtonProps,
setup(__props) {
const props = __props;
const ns = index.useNamespace("radio");
const { radioRef, focus, size, disabled, modelValue, radioGroup, actualValue } = useRadio.useRadio(props);
const activeStyle = vue.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 vue.openBlock(), vue.createElementBlock("label", {
class: vue.normalizeClass([
vue.unref(ns).b("button"),
vue.unref(ns).is("active", vue.unref(modelValue) === vue.unref(actualValue)),
vue.unref(ns).is("disabled", vue.unref(disabled)),
vue.unref(ns).is("focus", vue.unref(focus)),
vue.unref(ns).bm("button", vue.unref(size))
])
}, [
vue.withDirectives(vue.createElementVNode("input", {
ref_key: "radioRef",
ref: radioRef,
"onUpdate:modelValue": ($event) => vue.isRef(modelValue) ? modelValue.value = $event : null,
class: vue.normalizeClass(vue.unref(ns).be("button", "original-radio")),
value: vue.unref(actualValue),
type: "radio",
name: _ctx.name || ((_a = vue.unref(radioGroup)) == null ? void 0 : _a.name),
disabled: vue.unref(disabled),
onFocus: ($event) => focus.value = true,
onBlur: ($event) => focus.value = false,
onClick: vue.withModifiers(() => {
}, ["stop"])
}, null, 42, ["onUpdate:modelValue", "value", "name", "disabled", "onFocus", "onBlur", "onClick"]), [
[vue.vModelRadio, vue.unref(modelValue)]
]),
vue.createElementVNode("span", {
class: vue.normalizeClass(vue.unref(ns).be("button", "inner")),
style: vue.normalizeStyle(vue.unref(modelValue) === vue.unref(actualValue) ? vue.unref(activeStyle) : {}),
onKeydown: vue.withModifiers(() => {
}, ["stop"])
}, [
vue.renderSlot(_ctx.$slots, "default", {}, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.label), 1)
])
], 46, ["onKeydown"])
], 2);
};
}
});
var RadioButton = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "radio-button.vue"]]);
exports["default"] = RadioButton;
//# sourceMappingURL=radio-button2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"radio-button2.js","sources":["../../../../../../packages/components/radio/src/radio-button.vue"],"sourcesContent":["<template>\n <label\n :class=\"[\n ns.b('button'),\n ns.is('active', modelValue === actualValue),\n ns.is('disabled', disabled),\n ns.is('focus', focus),\n ns.bm('button', size),\n ]\"\n >\n <input\n ref=\"radioRef\"\n v-model=\"modelValue\"\n :class=\"ns.be('button', 'original-radio')\"\n :value=\"actualValue\"\n type=\"radio\"\n :name=\"name || radioGroup?.name\"\n :disabled=\"disabled\"\n @focus=\"focus = true\"\n @blur=\"focus = false\"\n @click.stop\n />\n <span\n :class=\"ns.be('button', 'inner')\"\n :style=\"modelValue === actualValue ? activeStyle : {}\"\n @keydown.stop\n >\n <slot>\n {{ label }}\n </slot>\n </span>\n </label>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { useRadio } from './use-radio'\nimport { radioButtonProps } from './radio-button'\n\nimport type { CSSProperties } from 'vue'\n\ndefineOptions({\n name: 'ElRadioButton',\n})\n\nconst props = defineProps(radioButtonProps)\n\nconst ns = useNamespace('radio')\nconst { radioRef, focus, size, disabled, modelValue, radioGroup, actualValue } =\n useRadio(props)\n\nconst activeStyle = computed<CSSProperties>(() => {\n return {\n backgroundColor: radioGroup?.fill || '',\n borderColor: radioGroup?.fill || '',\n boxShadow: radioGroup?.fill ? `-1px 0 0 0 ${radioGroup.fill}` : '',\n color: radioGroup?.textColor || '',\n }\n})\n</script>\n"],"names":["useNamespace","useRadio","computed"],"mappings":";;;;;;;;;;uCA0Cc,CAAA;AAAA,EACZ,IAAM,EAAA,eAAA;AACR,CAAA,CAAA,CAAA;;;;;;AAIA,IAAM,MAAA,EAAA,GAAKA,mBAAa,OAAO,CAAA,CAAA;AAC/B,IAAM,MAAA,EAAE,QAAU,EAAA,KAAA,EAAO,IAAM,EAAA,QAAA,EAAU,YAAY,UAAY,EAAA,WAAA,EAC/D,GAAAC,iBAAA,CAAS,KAAK,CAAA,CAAA;AAEhB,IAAM,MAAA,WAAA,GAAcC,aAAwB,MAAM;AAChD,MAAO,OAAA;AAAA,QACL,eAAA,EAAiB,eAAoB,IAAA,GAAA,KAAA,CAAA,GAAA,UAAA,CAAA,IAAA,KAAA,EAAA;AAAA,QACrC,WAAA,EAAa,eAAoB,IAAA,GAAA,KAAA,CAAA,GAAA,UAAA,CAAA,IAAA,KAAA,EAAA;AAAA,QACjC,WAAW,CAAY,UAAA,IAAA,IAAO,GAAc,KAAA,CAAA,GAAA,UAAA,CAAA,QAAoB,CAAA,WAAA,EAAA,UAAA,CAAA,IAAA,CAAA,CAAA,GAAA,EAAA;AAAA,QAChE,KAAA,EAAO,eAAyB,IAAA,GAAA,KAAA,CAAA,GAAA,UAAA,CAAA,SAAA,KAAA,EAAA;AAAA,OAClC,CAAA;AAAA,KACD,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,41 @@
import type { RadioPropsPublic } from './radio';
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type RadioGroup from './radio-group.vue';
export declare const radioGroupProps: {
readonly ariaLabel: StringConstructor;
readonly id: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly disabled: BooleanConstructor;
readonly modelValue: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor, BooleanConstructor], unknown, unknown, undefined, boolean>;
readonly fill: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly textColor: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
readonly validateEvent: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly options: {
readonly type: import("vue").PropType<radioOption[]>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly props: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => radioOptionProp) | (() => radioOptionProp) | ((new (...args: any[]) => radioOptionProp) | (() => radioOptionProp))[], unknown, unknown, () => Required<radioOptionProp>, boolean>;
};
export type RadioGroupProps = ExtractPropTypes<typeof radioGroupProps>;
export type RadioGroupPropsPublic = __ExtractPublicPropTypes<typeof radioGroupProps>;
export declare const radioGroupEmits: {
"update:modelValue": (val: string | number | boolean | undefined) => val is string | number | boolean;
change: (val: string | number | boolean | undefined) => val is string | number | boolean;
};
export type RadioGroupEmits = typeof radioGroupEmits;
export type RadioGroupInstance = InstanceType<typeof RadioGroup> & unknown;
export type radioOption = RadioPropsPublic & Record<string, any>;
export declare const radioDefaultProps: Required<radioOptionProp>;
export type radioOptionProp = {
value?: string;
label?: string;
disabled?: string;
};

View File

@@ -0,0 +1,56 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var radio = require('./radio2.js');
var runtime = require('../../../utils/vue/props/runtime.js');
var index = require('../../../hooks/use-size/index.js');
var index$1 = require('../../../hooks/use-aria/index.js');
const radioGroupProps = runtime.buildProps({
id: {
type: String,
default: void 0
},
size: index.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: runtime.definePropType(Array)
},
props: {
type: runtime.definePropType(Object),
default: () => radioDefaultProps
},
...index$1.useAriaProps(["ariaLabel"])
});
const radioGroupEmits = radio.radioEmits;
const radioDefaultProps = {
label: "label",
value: "value",
disabled: "disabled"
};
exports.radioDefaultProps = radioDefaultProps;
exports.radioGroupEmits = radioGroupEmits;
exports.radioGroupProps = radioGroupProps;
//# sourceMappingURL=radio-group.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"radio-group.js","sources":["../../../../../../packages/components/radio/src/radio-group.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils'\nimport { useAriaProps, useSizeProp } from '@element-plus/hooks'\nimport { radioEmits } from './radio'\n\nimport type { RadioPropsPublic } from './radio'\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\nimport type RadioGroup from './radio-group.vue'\n\nexport const radioGroupProps = buildProps({\n /**\n * @description native `id` attribute\n */\n id: {\n type: String,\n default: undefined,\n },\n /**\n * @description the size of radio buttons or bordered radios\n */\n size: useSizeProp,\n /**\n * @description whether the nesting radios are disabled\n */\n disabled: Boolean,\n /**\n * @description binding value\n */\n modelValue: {\n type: [String, Number, Boolean],\n default: undefined,\n },\n /**\n * @description border and background color when button is active\n */\n fill: {\n type: String,\n default: '',\n },\n /**\n * @description font color when button is active\n */\n textColor: {\n type: String,\n default: '',\n },\n /**\n * @description native `name` attribute\n */\n name: {\n type: String,\n default: undefined,\n },\n /**\n * @description whether to trigger form validation\n */\n validateEvent: {\n type: Boolean,\n default: true,\n },\n options: {\n type: definePropType<radioOption[]>(Array),\n },\n props: {\n type: definePropType<radioOptionProp>(Object),\n default: () => radioDefaultProps,\n },\n ...useAriaProps(['ariaLabel']),\n} as const)\nexport type RadioGroupProps = ExtractPropTypes<typeof radioGroupProps>\nexport type RadioGroupPropsPublic = __ExtractPublicPropTypes<\n typeof radioGroupProps\n>\n\nexport const radioGroupEmits = radioEmits\nexport type RadioGroupEmits = typeof radioGroupEmits\nexport type RadioGroupInstance = InstanceType<typeof RadioGroup> & unknown\n\nexport type radioOption = RadioPropsPublic & Record<string, any>\n\nexport const radioDefaultProps: Required<radioOptionProp> = {\n label: 'label',\n value: 'value',\n disabled: 'disabled',\n}\nexport type radioOptionProp = {\n value?: string\n label?: string\n disabled?: string\n}\n"],"names":["buildProps","useSizeProp","definePropType","useAriaProps","radioEmits"],"mappings":";;;;;;;;;AAGY,MAAC,eAAe,GAAGA,kBAAU,CAAC;AAC1C,EAAE,EAAE,EAAE;AACN,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,KAAK,CAAC;AACnB,GAAG;AACH,EAAE,IAAI,EAAEC,iBAAW;AACnB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;AACnC,IAAI,OAAO,EAAE,KAAK,CAAC;AACnB,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,SAAS,EAAE;AACb,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,KAAK,CAAC;AACnB,GAAG;AACH,EAAE,aAAa,EAAE;AACjB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAEC,sBAAc,CAAC,KAAK,CAAC;AAC/B,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAEA,sBAAc,CAAC,MAAM,CAAC;AAChC,IAAI,OAAO,EAAE,MAAM,iBAAiB;AACpC,GAAG;AACH,EAAE,GAAGC,oBAAY,CAAC,CAAC,WAAW,CAAC,CAAC;AAChC,CAAC,EAAE;AACS,MAAC,eAAe,GAAGC,iBAAW;AAC9B,MAAC,iBAAiB,GAAG;AACjC,EAAE,KAAK,EAAE,OAAO;AAChB,EAAE,KAAK,EAAE,OAAO;AAChB,EAAE,QAAQ,EAAE,UAAU;AACtB;;;;;;"}

View File

@@ -0,0 +1,70 @@
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly ariaLabel: StringConstructor;
readonly id: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly disabled: BooleanConstructor;
readonly modelValue: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor, BooleanConstructor], unknown, unknown, undefined, boolean>;
readonly fill: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly textColor: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
readonly validateEvent: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly options: {
readonly type: import("vue").PropType<import("./radio-group").radioOption[]>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly props: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("./radio-group").radioOptionProp) | (() => import("./radio-group").radioOptionProp) | ((new (...args: any[]) => import("./radio-group").radioOptionProp) | (() => import("./radio-group").radioOptionProp))[], unknown, unknown, () => Required<import("./radio-group").radioOptionProp>, boolean>;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
"update:modelValue": (val: string | number | boolean | undefined) => void;
change: (val: string | number | boolean | undefined) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly ariaLabel: StringConstructor;
readonly id: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly disabled: BooleanConstructor;
readonly modelValue: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor, BooleanConstructor], unknown, unknown, undefined, boolean>;
readonly fill: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly textColor: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
readonly validateEvent: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly options: {
readonly type: import("vue").PropType<import("./radio-group").radioOption[]>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly props: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("./radio-group").radioOptionProp) | (() => import("./radio-group").radioOptionProp) | ((new (...args: any[]) => import("./radio-group").radioOptionProp) | (() => import("./radio-group").radioOptionProp))[], unknown, unknown, () => Required<import("./radio-group").radioOptionProp>, boolean>;
}>> & {
"onUpdate:modelValue"?: ((val: string | number | boolean | undefined) => any) | undefined;
onChange?: ((val: string | number | boolean | undefined) => any) | undefined;
}, {
readonly disabled: boolean;
readonly fill: string;
readonly id: string;
readonly props: import("./radio-group").radioOptionProp;
readonly name: string;
readonly modelValue: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor, BooleanConstructor], unknown, unknown>;
readonly validateEvent: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;
readonly textColor: string;
}>;
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
export default _default;
type __VLS_WithTemplateSlots<T, S> = T & {
new (): {
$slots: S;
};
};

View File

@@ -0,0 +1,91 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var radioGroup = require('./radio-group.js');
var constants = require('./constants.js');
var lodashUnified = require('lodash-unified');
var radio = require('./radio.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
var index$1 = require('../../../hooks/use-id/index.js');
var useFormItem = require('../../form/src/hooks/use-form-item.js');
var error = require('../../../utils/error.js');
var event = require('../../../constants/event.js');
const __default__ = vue.defineComponent({
name: "ElRadioGroup"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: radioGroup.radioGroupProps,
emits: radioGroup.radioGroupEmits,
setup(__props, { emit }) {
const props = __props;
const ns = index.useNamespace("radio");
const radioId = index$1.useId();
const radioGroupRef = vue.ref();
const { formItem } = useFormItem.useFormItem();
const { inputId: groupId, isLabeledByFormItem } = useFormItem.useFormItemInputId(props, {
formItemContext: formItem
});
const changeEvent = (value) => {
emit(event.UPDATE_MODEL_EVENT, value);
vue.nextTick(() => emit(event.CHANGE_EVENT, value));
};
vue.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 = vue.computed(() => {
return props.name || radioId.value;
});
const aliasProps = vue.computed(() => ({
...radioGroup.radioDefaultProps,
...props.props
}));
const getOptionProps = (option) => {
const base = {
label: option[aliasProps.value.label],
value: option[aliasProps.value.value],
disabled: option[aliasProps.value.disabled]
};
return { ...option, ...base };
};
vue.provide(constants.radioGroupKey, vue.reactive({
...vue.toRefs(props),
changeEvent,
name
}));
vue.watch(() => props.modelValue, (newVal, oldValue) => {
if (props.validateEvent && !lodashUnified.isEqual(newVal, oldValue)) {
formItem == null ? void 0 : formItem.validate("change").catch((err) => error.debugWarn());
}
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
id: vue.unref(groupId),
ref_key: "radioGroupRef",
ref: radioGroupRef,
class: vue.normalizeClass(vue.unref(ns).b("group")),
role: "radiogroup",
"aria-label": !vue.unref(isLabeledByFormItem) ? _ctx.ariaLabel || "radio-group" : void 0,
"aria-labelledby": vue.unref(isLabeledByFormItem) ? vue.unref(formItem).labelId : void 0
}, [
vue.renderSlot(_ctx.$slots, "default", {}, () => [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(props.options, (item, index) => {
return vue.openBlock(), vue.createBlock(radio["default"], vue.mergeProps({ key: index }, getOptionProps(item)), null, 16);
}), 128))
])
], 10, ["id", "aria-label", "aria-labelledby"]);
};
}
});
var RadioGroup = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "radio-group.vue"]]);
exports["default"] = RadioGroup;
//# sourceMappingURL=radio-group2.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type Radio from './radio.vue';
export declare const radioPropsBase: {
modelValue: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
disabled: BooleanConstructor;
label: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
value: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
};
export declare const radioProps: {
readonly border: BooleanConstructor;
readonly modelValue: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly disabled: BooleanConstructor;
readonly label: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly value: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
};
export declare const radioEmits: {
"update:modelValue": (val: string | number | boolean | undefined) => val is string | number | boolean;
change: (val: string | number | boolean | undefined) => val is string | number | boolean;
};
export type RadioProps = ExtractPropTypes<typeof radioProps>;
export type RadioPropsPublic = __ExtractPublicPropTypes<typeof radioProps>;
export type RadioEmits = typeof radioEmits;
export type RadioInstance = InstanceType<typeof Radio> & unknown;

View File

@@ -0,0 +1,83 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var radio = require('./radio2.js');
var useRadio = require('./use-radio.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
var event = require('../../../constants/event.js');
const __default__ = vue.defineComponent({
name: "ElRadio"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: radio.radioProps,
emits: radio.radioEmits,
setup(__props, { emit }) {
const props = __props;
const ns = index.useNamespace("radio");
const { radioRef, radioGroup, focus, size, disabled, modelValue, actualValue } = useRadio.useRadio(props, emit);
function handleChange() {
vue.nextTick(() => emit(event.CHANGE_EVENT, modelValue.value));
}
return (_ctx, _cache) => {
var _a;
return vue.openBlock(), vue.createElementBlock("label", {
class: vue.normalizeClass([
vue.unref(ns).b(),
vue.unref(ns).is("disabled", vue.unref(disabled)),
vue.unref(ns).is("focus", vue.unref(focus)),
vue.unref(ns).is("bordered", _ctx.border),
vue.unref(ns).is("checked", vue.unref(modelValue) === vue.unref(actualValue)),
vue.unref(ns).m(vue.unref(size))
])
}, [
vue.createElementVNode("span", {
class: vue.normalizeClass([
vue.unref(ns).e("input"),
vue.unref(ns).is("disabled", vue.unref(disabled)),
vue.unref(ns).is("checked", vue.unref(modelValue) === vue.unref(actualValue))
])
}, [
vue.withDirectives(vue.createElementVNode("input", {
ref_key: "radioRef",
ref: radioRef,
"onUpdate:modelValue": ($event) => vue.isRef(modelValue) ? modelValue.value = $event : null,
class: vue.normalizeClass(vue.unref(ns).e("original")),
value: vue.unref(actualValue),
name: _ctx.name || ((_a = vue.unref(radioGroup)) == null ? void 0 : _a.name),
disabled: vue.unref(disabled),
checked: vue.unref(modelValue) === vue.unref(actualValue),
type: "radio",
onFocus: ($event) => focus.value = true,
onBlur: ($event) => focus.value = false,
onChange: handleChange,
onClick: vue.withModifiers(() => {
}, ["stop"])
}, null, 42, ["onUpdate:modelValue", "value", "name", "disabled", "checked", "onFocus", "onBlur", "onClick"]), [
[vue.vModelRadio, vue.unref(modelValue)]
]),
vue.createElementVNode("span", {
class: vue.normalizeClass(vue.unref(ns).e("inner"))
}, null, 2)
], 2),
vue.createElementVNode("span", {
class: vue.normalizeClass(vue.unref(ns).e("label")),
onKeydown: vue.withModifiers(() => {
}, ["stop"])
}, [
vue.renderSlot(_ctx.$slots, "default", {}, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.label), 1)
])
], 42, ["onKeydown"])
], 2);
};
}
});
var Radio = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "radio.vue"]]);
exports["default"] = Radio;
//# sourceMappingURL=radio.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"radio.js","sources":["../../../../../../packages/components/radio/src/radio.vue"],"sourcesContent":["<template>\n <label\n :class=\"[\n ns.b(),\n ns.is('disabled', disabled),\n ns.is('focus', focus),\n ns.is('bordered', border),\n ns.is('checked', modelValue === actualValue),\n ns.m(size),\n ]\"\n >\n <span\n :class=\"[\n ns.e('input'),\n ns.is('disabled', disabled),\n ns.is('checked', modelValue === actualValue),\n ]\"\n >\n <input\n ref=\"radioRef\"\n v-model=\"modelValue\"\n :class=\"ns.e('original')\"\n :value=\"actualValue\"\n :name=\"name || radioGroup?.name\"\n :disabled=\"disabled\"\n :checked=\"modelValue === actualValue\"\n type=\"radio\"\n @focus=\"focus = true\"\n @blur=\"focus = false\"\n @change=\"handleChange\"\n @click.stop\n />\n <span :class=\"ns.e('inner')\" />\n </span>\n <span :class=\"ns.e('label')\" @keydown.stop>\n <slot>\n {{ label }}\n </slot>\n </span>\n </label>\n</template>\n\n<script lang=\"ts\" setup>\nimport { nextTick } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { CHANGE_EVENT } from '@element-plus/constants'\nimport { radioEmits, radioProps } from './radio'\nimport { useRadio } from './use-radio'\n\ndefineOptions({\n name: 'ElRadio',\n})\n\nconst props = defineProps(radioProps)\nconst emit = defineEmits(radioEmits)\n\nconst ns = useNamespace('radio')\nconst { radioRef, radioGroup, focus, size, disabled, modelValue, actualValue } =\n useRadio(props, emit)\n\nfunction handleChange() {\n nextTick(() => emit(CHANGE_EVENT, modelValue.value))\n}\n</script>\n"],"names":["useNamespace","useRadio","nextTick","CHANGE_EVENT"],"mappings":";;;;;;;;;;;uCAiDc,CAAA;AAAA,EACZ,IAAM,EAAA,SAAA;AACR,CAAA,CAAA,CAAA;;;;;;;AAKA,IAAM,MAAA,EAAA,GAAKA,mBAAa,OAAO,CAAA,CAAA;AAC/B,IAAM,MAAA,EAAE,QAAU,EAAA,UAAA,EAAY,KAAO,EAAA,IAAA,EAAM,QAAU,EAAA,UAAA,EAAY,WAAY,EAAA,GAC3EC,iBAAS,CAAA,KAAA,EAAO,IAAI,CAAA,CAAA;AAEtB,IAAA,SAAS,YAAe,GAAA;AACtB,MAAAC,YAAA,CAAS,MAAM,IAAA,CAAKC,kBAAc,EAAA,UAAA,CAAW,KAAK,CAAC,CAAA,CAAA;AAAA,KACrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,50 @@
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly border: BooleanConstructor;
readonly modelValue: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly disabled: BooleanConstructor;
readonly label: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly value: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
"update:modelValue": (val: string | number | boolean | undefined) => void;
change: (val: string | number | boolean | undefined) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly border: BooleanConstructor;
readonly modelValue: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly disabled: BooleanConstructor;
readonly label: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly value: import("element-plus/es/utils").EpPropFinalized<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, undefined, boolean>;
}>> & {
"onUpdate:modelValue"?: ((val: string | number | boolean | undefined) => any) | undefined;
onChange?: ((val: string | number | boolean | undefined) => any) | undefined;
}, {
readonly label: import("element-plus/es/utils").EpPropMergeType<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>;
readonly disabled: boolean;
readonly border: boolean;
readonly value: import("element-plus/es/utils").EpPropMergeType<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>;
readonly name: string;
readonly modelValue: import("element-plus/es/utils").EpPropMergeType<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>;
}>;
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
export default _default;
type __VLS_WithTemplateSlots<T, S> = T & {
new (): {
$slots: S;
};
};

View File

@@ -0,0 +1,43 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var runtime = require('../../../utils/vue/props/runtime.js');
var index = require('../../../hooks/use-size/index.js');
var event = require('../../../constants/event.js');
var shared = require('@vue/shared');
var types = require('../../../utils/types.js');
const radioPropsBase = runtime.buildProps({
modelValue: {
type: [String, Number, Boolean],
default: void 0
},
size: index.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
}
});
const radioProps = runtime.buildProps({
...radioPropsBase,
border: Boolean
});
const radioEmits = {
[event.UPDATE_MODEL_EVENT]: (val) => shared.isString(val) || types.isNumber(val) || types.isBoolean(val),
[event.CHANGE_EVENT]: (val) => shared.isString(val) || types.isNumber(val) || types.isBoolean(val)
};
exports.radioEmits = radioEmits;
exports.radioProps = radioProps;
exports.radioPropsBase = radioPropsBase;
//# sourceMappingURL=radio2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"radio2.js","sources":["../../../../../../packages/components/radio/src/radio.ts"],"sourcesContent":["import { buildProps, isBoolean, isNumber, isString } from '@element-plus/utils'\nimport { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { useSizeProp } from '@element-plus/hooks'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\nimport type Radio from './radio.vue'\n\nexport const radioPropsBase = buildProps({\n /**\n * @description binding value\n */\n modelValue: {\n type: [String, Number, Boolean],\n default: undefined,\n },\n /**\n * @description size of the Radio\n */\n size: useSizeProp,\n /**\n * @description whether Radio is disabled\n */\n disabled: Boolean,\n /**\n * @description the label of Radio\n */\n label: {\n type: [String, Number, Boolean],\n default: undefined,\n },\n /**\n * @description the value of Radio\n */\n value: {\n type: [String, Number, Boolean],\n default: undefined,\n },\n /**\n * @description native `name` attribute\n */\n name: {\n type: String,\n default: undefined,\n },\n})\n\nexport const radioProps = buildProps({\n ...radioPropsBase,\n /**\n * @description whether to add a border around Radio\n */\n border: Boolean,\n} as const)\n\nexport const radioEmits = {\n [UPDATE_MODEL_EVENT]: (val: string | number | boolean | undefined) =>\n isString(val) || isNumber(val) || isBoolean(val),\n [CHANGE_EVENT]: (val: string | number | boolean | undefined) =>\n isString(val) || isNumber(val) || isBoolean(val),\n}\n\nexport type RadioProps = ExtractPropTypes<typeof radioProps>\nexport type RadioPropsPublic = __ExtractPublicPropTypes<typeof radioProps>\nexport type RadioEmits = typeof radioEmits\nexport type RadioInstance = InstanceType<typeof Radio> & unknown\n"],"names":["buildProps","useSizeProp","UPDATE_MODEL_EVENT","isString","isNumber","isBoolean","CHANGE_EVENT"],"mappings":";;;;;;;;;;AAGY,MAAC,cAAc,GAAGA,kBAAU,CAAC;AACzC,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;AACnC,IAAI,OAAO,EAAE,KAAK,CAAC;AACnB,GAAG;AACH,EAAE,IAAI,EAAEC,iBAAW;AACnB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;AACnC,IAAI,OAAO,EAAE,KAAK,CAAC;AACnB,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;AACnC,IAAI,OAAO,EAAE,KAAK,CAAC;AACnB,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,KAAK,CAAC;AACnB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,UAAU,GAAGD,kBAAU,CAAC;AACrC,EAAE,GAAG,cAAc;AACnB,EAAE,MAAM,EAAE,OAAO;AACjB,CAAC,EAAE;AACS,MAAC,UAAU,GAAG;AAC1B,EAAE,CAACE,wBAAkB,GAAG,CAAC,GAAG,KAAKC,eAAQ,CAAC,GAAG,CAAC,IAAIC,cAAQ,CAAC,GAAG,CAAC,IAAIC,eAAS,CAAC,GAAG,CAAC;AACjF,EAAE,CAACC,kBAAY,GAAG,CAAC,GAAG,KAAKH,eAAQ,CAAC,GAAG,CAAC,IAAIC,cAAQ,CAAC,GAAG,CAAC,IAAIC,eAAS,CAAC,GAAG,CAAC;AAC3E;;;;;;"}

View File

@@ -0,0 +1,14 @@
import type { RadioButtonProps } from './radio-button';
import type { SetupContext } from 'vue';
import type { RadioEmits, RadioProps } from './radio';
export declare const useRadio: (props: RadioProps | RadioButtonProps, emit?: SetupContext<RadioEmits>["emit"]) => {
radioRef: import("vue").Ref<HTMLInputElement | undefined>;
isGroup: import("vue").ComputedRef<boolean>;
radioGroup: import("./constants").RadioGroupContext | undefined;
focus: import("vue").Ref<boolean>;
size: import("vue").ComputedRef<"" | "small" | "default" | "large">;
disabled: import("vue").ComputedRef<boolean>;
tabIndex: import("vue").ComputedRef<0 | -1>;
modelValue: import("vue").WritableComputedRef<import("element-plus/es/utils").EpPropMergeType<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown> | undefined>;
actualValue: import("vue").ComputedRef<import("element-plus/es/utils").EpPropMergeType<(BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown> | undefined>;
};

View File

@@ -0,0 +1,62 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var constants = require('./constants.js');
var types = require('../../../utils/types.js');
var event = require('../../../constants/event.js');
var useFormCommonProps = require('../../form/src/hooks/use-form-common-props.js');
var index = require('../../../hooks/use-deprecated/index.js');
const useRadio = (props, emit) => {
const radioRef = vue.ref();
const radioGroup = vue.inject(constants.radioGroupKey, void 0);
const isGroup = vue.computed(() => !!radioGroup);
const actualValue = vue.computed(() => {
if (!types.isPropAbsent(props.value)) {
return props.value;
}
return props.label;
});
const modelValue = vue.computed({
get() {
return isGroup.value ? radioGroup.modelValue : props.modelValue;
},
set(val) {
if (isGroup.value) {
radioGroup.changeEvent(val);
} else {
emit && emit(event.UPDATE_MODEL_EVENT, val);
}
radioRef.value.checked = props.modelValue === actualValue.value;
}
});
const size = useFormCommonProps.useFormSize(vue.computed(() => radioGroup == null ? void 0 : radioGroup.size));
const disabled = useFormCommonProps.useFormDisabled(vue.computed(() => radioGroup == null ? void 0 : radioGroup.disabled));
const focus = vue.ref(false);
const tabIndex = vue.computed(() => {
return disabled.value || isGroup.value && modelValue.value !== actualValue.value ? -1 : 0;
});
index.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"
}, vue.computed(() => isGroup.value && types.isPropAbsent(props.value)));
return {
radioRef,
isGroup,
radioGroup,
focus,
size,
disabled,
tabIndex,
modelValue,
actualValue
};
};
exports.useRadio = useRadio;
//# sourceMappingURL=use-radio.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-radio.js","sources":["../../../../../../packages/components/radio/src/use-radio.ts"],"sourcesContent":["import { computed, inject, ref } from 'vue'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { useFormDisabled, useFormSize } from '@element-plus/components/form'\nimport { useDeprecated } from '@element-plus/hooks'\nimport { isPropAbsent } from '@element-plus/utils'\nimport { radioGroupKey } from './constants'\n\nimport type { RadioButtonProps } from './radio-button'\nimport type { SetupContext } from 'vue'\nimport type { RadioEmits, RadioProps } from './radio'\n\nexport const useRadio = (\n props: RadioProps | RadioButtonProps,\n emit?: SetupContext<RadioEmits>['emit']\n) => {\n const radioRef = ref<HTMLInputElement>()\n const radioGroup = inject(radioGroupKey, undefined)\n const isGroup = computed(() => !!radioGroup)\n const actualValue = computed(() => {\n // In version 2.x, if there's no props.value, props.label will act as props.value\n // In version 3.x, remove this computed value, use props.value instead.\n if (!isPropAbsent(props.value)) {\n return props.value\n }\n return props.label\n })\n const modelValue = computed<RadioProps['modelValue']>({\n get() {\n return isGroup.value ? radioGroup!.modelValue : props.modelValue!\n },\n set(val) {\n if (isGroup.value) {\n radioGroup!.changeEvent(val)\n } else {\n emit && emit(UPDATE_MODEL_EVENT, val)\n }\n radioRef.value!.checked = props.modelValue === actualValue.value\n },\n })\n\n const size = useFormSize(computed(() => radioGroup?.size))\n const disabled = useFormDisabled(computed(() => radioGroup?.disabled))\n const focus = ref(false)\n const tabIndex = computed(() => {\n return disabled.value ||\n (isGroup.value && modelValue.value !== actualValue.value)\n ? -1\n : 0\n })\n\n useDeprecated(\n {\n from: 'label act as value',\n replacement: 'value',\n version: '3.0.0',\n scope: 'el-radio',\n ref: 'https://element-plus.org/en-US/component/radio.html',\n },\n computed(() => isGroup.value && isPropAbsent(props.value))\n )\n\n return {\n radioRef,\n isGroup,\n radioGroup,\n focus,\n size,\n disabled,\n tabIndex,\n modelValue,\n actualValue,\n }\n}\n"],"names":["ref","inject","radioGroupKey","computed","isPropAbsent","UPDATE_MODEL_EVENT","useFormSize","useFormDisabled","useDeprecated"],"mappings":";;;;;;;;;;;AAMY,MAAC,QAAQ,GAAG,CAAC,KAAK,EAAE,IAAI,KAAK;AACzC,EAAE,MAAM,QAAQ,GAAGA,OAAG,EAAE,CAAC;AACzB,EAAE,MAAM,UAAU,GAAGC,UAAM,CAACC,uBAAa,EAAE,KAAK,CAAC,CAAC,CAAC;AACnD,EAAE,MAAM,OAAO,GAAGC,YAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;AAC/C,EAAE,MAAM,WAAW,GAAGA,YAAQ,CAAC,MAAM;AACrC,IAAI,IAAI,CAACC,kBAAY,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;AACpC,MAAM,OAAO,KAAK,CAAC,KAAK,CAAC;AACzB,KAAK;AACL,IAAI,OAAO,KAAK,CAAC,KAAK,CAAC;AACvB,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,UAAU,GAAGD,YAAQ,CAAC;AAC9B,IAAI,GAAG,GAAG;AACV,MAAM,OAAO,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;AACtE,KAAK;AACL,IAAI,GAAG,CAAC,GAAG,EAAE;AACb,MAAM,IAAI,OAAO,CAAC,KAAK,EAAE;AACzB,QAAQ,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AACpC,OAAO,MAAM;AACb,QAAQ,IAAI,IAAI,IAAI,CAACE,wBAAkB,EAAE,GAAG,CAAC,CAAC;AAC9C,OAAO;AACP,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,UAAU,KAAK,WAAW,CAAC,KAAK,CAAC;AACtE,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,IAAI,GAAGC,8BAAW,CAACH,YAAQ,CAAC,MAAM,UAAU,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1F,EAAE,MAAM,QAAQ,GAAGI,kCAAe,CAACJ,YAAQ,CAAC,MAAM,UAAU,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtG,EAAE,MAAM,KAAK,GAAGH,OAAG,CAAC,KAAK,CAAC,CAAC;AAC3B,EAAE,MAAM,QAAQ,GAAGG,YAAQ,CAAC,MAAM;AAClC,IAAI,OAAO,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,KAAK,WAAW,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAC9F,GAAG,CAAC,CAAC;AACL,EAAEK,mBAAa,CAAC;AAChB,IAAI,IAAI,EAAE,oBAAoB;AAC9B,IAAI,WAAW,EAAE,OAAO;AACxB,IAAI,OAAO,EAAE,OAAO;AACpB,IAAI,KAAK,EAAE,UAAU;AACrB,IAAI,GAAG,EAAE,qDAAqD;AAC9D,GAAG,EAAEL,YAAQ,CAAC,MAAM,OAAO,CAAC,KAAK,IAAIC,kBAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACjE,EAAE,OAAO;AACT,IAAI,QAAQ;AACZ,IAAI,OAAO;AACX,IAAI,UAAU;AACd,IAAI,KAAK;AACT,IAAI,IAAI;AACR,IAAI,QAAQ;AACZ,IAAI,QAAQ;AACZ,IAAI,UAAU;AACd,IAAI,WAAW;AACf,GAAG,CAAC;AACJ;;;;"}