完全跑通1.0版本

This commit is contained in:
2026-05-26 12:56:03 +08:00
parent 2ece5174a7
commit 93c714a93b
11557 changed files with 1648225 additions and 36 deletions

View File

@@ -0,0 +1,14 @@
import { SFCWithInstall } from "../../utils/vue/typescript.js";
import { ButtonConfigContext, ButtonEmits, ButtonNativeType, ButtonProps, ButtonPropsPublic, ButtonType, buttonEmits, buttonNativeTypes, buttonProps, buttonTypes } from "./src/button.js";
import _default from "./src/button.vue.js";
import _default$1 from "./src/button-group.vue.js";
import { ButtonGroupContext, buttonGroupContextKey } from "./src/constants.js";
import { ButtonGroupInstance, ButtonInstance } from "./src/instance.js";
//#region ../../packages/components/button/index.d.ts
declare const ElButton: SFCWithInstall<typeof _default> & {
ButtonGroup: typeof _default$1;
};
declare const ElButtonGroup: SFCWithInstall<typeof _default$1>;
//#endregion
export { ButtonConfigContext, ButtonEmits, ButtonGroupContext, type ButtonGroupInstance, type ButtonInstance, ButtonNativeType, ButtonProps, ButtonPropsPublic, ButtonType, ElButton, ElButton as default, ElButtonGroup, buttonEmits, buttonGroupContextKey, buttonNativeTypes, buttonProps, buttonTypes };

View File

@@ -0,0 +1,23 @@
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
const require_install = require("../../utils/vue/install.js");
const require_button = require("./src/button.js");
const require_constants = require("./src/constants.js");
const require_button$1 = require("./src/button2.js");
const require_button_group = require("./src/button-group2.js");
//#region ../../packages/components/button/index.ts
const ElButton = require_install.withInstall(require_button$1.default, { ButtonGroup: require_button_group.default });
const ElButtonGroup = require_install.withNoopInstall(require_button_group.default);
//#endregion
exports.ElButton = ElButton;
exports.default = ElButton;
exports.ElButtonGroup = ElButtonGroup;
exports.buttonEmits = require_button.buttonEmits;
exports.buttonGroupContextKey = require_constants.buttonGroupContextKey;
exports.buttonNativeTypes = require_button.buttonNativeTypes;
exports.buttonProps = require_button.buttonProps;
exports.buttonTypes = require_button.buttonTypes;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":["withInstall","Button","withNoopInstall","ButtonGroup"],"sources":["../../../../../packages/components/button/index.ts"],"sourcesContent":["import { withInstall, withNoopInstall } from '@element-plus/utils'\nimport Button from './src/button.vue'\nimport ButtonGroup from './src/button-group.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElButton: SFCWithInstall<typeof Button> & {\n ButtonGroup: typeof ButtonGroup\n} = withInstall(Button, {\n ButtonGroup,\n})\nexport const ElButtonGroup: SFCWithInstall<typeof ButtonGroup> =\n withNoopInstall(ButtonGroup)\nexport default ElButton\n\nexport * from './src/button'\nexport * from './src/constants'\nexport type { ButtonInstance, ButtonGroupInstance } from './src/instance'\n"],"mappings":";;;;;;;;;;AAMA,MAAa,WAETA,gBAAAA,YAAYC,iBAAAA,SAAQ,EACtB,aAAA,qBAAA,SACD,CAAC;AACF,MAAa,gBACXC,gBAAAA,gBAAgBC,qBAAAA,QAAY"}

View File

@@ -0,0 +1,9 @@
import { ButtonProps } from "./button.js";
import * as _$vue from "vue";
import { TinyColor } from "@ctrl/tinycolor";
//#region ../../packages/components/button/src/button-custom.d.ts
declare function darken(color: TinyColor, amount?: number): string;
declare function useButtonCustomStyle(props: ButtonProps): _$vue.ComputedRef<Record<string, string>>;
//#endregion
export { darken, useButtonCustomStyle };

View File

@@ -0,0 +1,84 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../hooks/use-namespace/index.js");
const require_use_form_common_props = require("../../form/src/hooks/use-form-common-props.js");
let vue = require("vue");
let _ctrl_tinycolor = require("@ctrl/tinycolor");
//#region ../../packages/components/button/src/button-custom.ts
function darken(color, amount = 20) {
return color.mix("#141414", amount).toString();
}
function useButtonCustomStyle(props) {
const _disabled = require_use_form_common_props.useFormDisabled();
const ns = require_index.useNamespace("button");
return (0, vue.computed)(() => {
let styles = {};
let buttonColor = props.color;
if (buttonColor) {
const match = buttonColor.match(/var\((.*?)\)/);
if (match) buttonColor = window.getComputedStyle(window.document.documentElement).getPropertyValue(match[1]);
const color = new _ctrl_tinycolor.TinyColor(buttonColor);
const activeBgColor = props.dark ? color.tint(20).toString() : darken(color, 20);
if (props.plain) {
styles = ns.cssVarBlock({
"bg-color": props.dark ? darken(color, 90) : color.tint(90).toString(),
"text-color": buttonColor,
"border-color": props.dark ? darken(color, 50) : color.tint(50).toString(),
"hover-text-color": `var(${ns.cssVarName("color-white")})`,
"hover-bg-color": buttonColor,
"hover-border-color": buttonColor,
"active-bg-color": activeBgColor,
"active-text-color": `var(${ns.cssVarName("color-white")})`,
"active-border-color": activeBgColor
});
if (_disabled.value) {
styles[ns.cssVarBlockName("disabled-bg-color")] = props.dark ? darken(color, 90) : color.tint(90).toString();
styles[ns.cssVarBlockName("disabled-text-color")] = props.dark ? darken(color, 50) : color.tint(50).toString();
styles[ns.cssVarBlockName("disabled-border-color")] = props.dark ? darken(color, 80) : color.tint(80).toString();
}
} else if (props.link || props.text) {
const hoverColor = props.dark ? darken(color, 30) : color.tint(30).toString();
styles = ns.cssVarBlock({
"text-color": buttonColor,
"hover-text-color": hoverColor,
"active-text-color": activeBgColor
});
if (props.link) {
styles[ns.cssVarBlockName("hover-link-text-color")] = hoverColor;
styles[ns.cssVarBlockName("active-color")] = activeBgColor;
}
if (_disabled.value) {
const disabledColor = props.dark ? darken(color, 50) : color.tint(50).toString();
styles[ns.cssVarBlockName("disabled-bg-color")] = "transparent";
styles[ns.cssVarBlockName("disabled-text-color")] = disabledColor;
styles[ns.cssVarBlockName("disabled-border-color")] = "transparent";
}
} else {
const hoverBgColor = props.dark ? darken(color, 30) : color.tint(30).toString();
const textColor = color.isDark() ? `var(${ns.cssVarName("color-white")})` : `var(${ns.cssVarName("color-black")})`;
styles = ns.cssVarBlock({
"bg-color": buttonColor,
"text-color": textColor,
"border-color": buttonColor,
"hover-bg-color": hoverBgColor,
"hover-text-color": textColor,
"hover-border-color": hoverBgColor,
"active-bg-color": activeBgColor,
"active-border-color": activeBgColor
});
if (_disabled.value) {
const disabledButtonColor = props.dark ? darken(color, 50) : color.tint(50).toString();
styles[ns.cssVarBlockName("disabled-bg-color")] = disabledButtonColor;
styles[ns.cssVarBlockName("disabled-text-color")] = props.dark ? "rgba(255, 255, 255, 0.5)" : `var(${ns.cssVarName("color-white")})`;
styles[ns.cssVarBlockName("disabled-border-color")] = disabledButtonColor;
}
}
}
return styles;
});
}
//#endregion
exports.darken = darken;
exports.useButtonCustomStyle = useButtonCustomStyle;
//# sourceMappingURL=button-custom.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,52 @@
import { EpPropFinalized, EpPropMergeType } from "../../../utils/vue/props/types.js";
import { ButtonProps } from "./button.js";
import * as _$vue from "vue";
import { ExtractPublicPropTypes } from "vue";
//#region ../../packages/components/button/src/button-group.d.ts
interface ButtonGroupProps {
/**
* @description control the size of buttons in this button-group
*/
size?: ButtonProps['size'];
/**
* @description control the type of buttons in this button-group
*/
type?: ButtonProps['type'];
/**
* @description display direction
*/
direction?: 'horizontal' | 'vertical';
}
/**
* @deprecated Removed after 3.0.0, Use `ButtonGroupProps` instead.
*/
declare const buttonGroupProps: {
/**
* @description control the size of buttons in this button-group
*/
readonly size: {
readonly type: _$vue.PropType<EpPropMergeType<StringConstructor, "" | "default" | "small" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
/**
* @description control the type of buttons in this button-group
*/
readonly type: EpPropFinalized<StringConstructor, "" | "default" | "info" | "primary" | "success" | "warning" | "text" | "danger", unknown, "", boolean>;
/**
* @description display direction
*/
readonly direction: {
readonly type: _$vue.PropType<"horizontal" | "vertical">;
readonly values: readonly ["horizontal", "vertical"];
readonly default: "horizontal";
};
};
/**
* @deprecated Removed after 3.0.0, Use `ButtonGroupProps` instead.
*/
type ButtonGroupPropsPublic = ExtractPublicPropTypes<typeof buttonGroupProps>;
//#endregion
export { ButtonGroupProps, ButtonGroupPropsPublic, buttonGroupProps };

View File

@@ -0,0 +1,29 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_runtime = require("../../../utils/vue/props/runtime.js");
const require_button = require("./button.js");
//#region ../../packages/components/button/src/button-group.ts
/**
* @deprecated Removed after 3.0.0, Use `ButtonGroupProps` instead.
*/
const buttonGroupProps = {
/**
* @description control the size of buttons in this button-group
*/
size: require_button.buttonProps.size,
/**
* @description control the type of buttons in this button-group
*/
type: require_button.buttonProps.type,
/**
* @description display direction
*/
direction: {
type: require_runtime.definePropType(String),
values: ["horizontal", "vertical"],
default: "horizontal"
}
};
//#endregion
exports.buttonGroupProps = buttonGroupProps;
//# sourceMappingURL=button-group.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"button-group.js","names":["buttonProps","definePropType"],"sources":["../../../../../../packages/components/button/src/button-group.ts"],"sourcesContent":["import { definePropType } from '@element-plus/utils'\nimport { buttonProps } from './button'\n\nimport type { ExtractPublicPropTypes } from 'vue'\nimport type { ButtonProps } from './button'\n\nexport interface ButtonGroupProps {\n /**\n * @description control the size of buttons in this button-group\n */\n size?: ButtonProps['size']\n /**\n * @description control the type of buttons in this button-group\n */\n type?: ButtonProps['type']\n /**\n * @description display direction\n */\n direction?: 'horizontal' | 'vertical'\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `ButtonGroupProps` instead.\n */\nexport const buttonGroupProps = {\n /**\n * @description control the size of buttons in this button-group\n */\n size: buttonProps.size,\n /**\n * @description control the type of buttons in this button-group\n */\n type: buttonProps.type,\n /**\n * @description display direction\n */\n direction: {\n type: definePropType<'horizontal' | 'vertical'>(String),\n values: ['horizontal', 'vertical'],\n default: 'horizontal',\n },\n} as const\n\n/**\n * @deprecated Removed after 3.0.0, Use `ButtonGroupProps` instead.\n */\nexport type ButtonGroupPropsPublic = ExtractPublicPropTypes<\n typeof buttonGroupProps\n>\n"],"mappings":";;;;;;;AAwBA,MAAa,mBAAmB;;;;CAI9B,MAAMA,eAAAA,YAAY;;;;CAIlB,MAAMA,eAAAA,YAAY;;;;CAIlB,WAAW;EACT,MAAMC,gBAAAA,eAA0C,OAAO;EACvD,QAAQ,CAAC,cAAc,WAAW;EAClC,SAAS;EACV;CACF"}

View File

@@ -0,0 +1,21 @@
import { ButtonGroupProps } from "./button-group.js";
import * as _$vue from "vue";
//#region ../../packages/components/button/src/button-group.vue.d.ts
declare var __VLS_1: {};
type __VLS_Slots = {} & {
default?: (props: typeof __VLS_1) => any;
};
declare const __VLS_base: _$vue.DefineComponent<ButtonGroupProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<ButtonGroupProps> & Readonly<{}>, {
type: "" | "default" | "info" | "primary" | "success" | "warning" | "text" | "danger";
direction: "horizontal" | "vertical";
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
declare const _default: typeof __VLS_export;
type __VLS_WithSlots<T, S> = T & {
new (): {
$slots: S;
};
};
//#endregion
export { _default as default };

View File

@@ -0,0 +1,26 @@
require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../hooks/use-namespace/index.js");
const require_constants = require("./constants.js");
const require_button_group = require("./button-group.js");
let vue = require("vue");
//#region ../../packages/components/button/src/button-group.vue?vue&type=script&setup=true&lang.ts
var button_group_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
name: "ElButtonGroup",
__name: "button-group",
props: require_button_group.buttonGroupProps,
setup(__props) {
const props = __props;
(0, vue.provide)(require_constants.buttonGroupContextKey, (0, vue.reactive)({
size: (0, vue.toRef)(props, "size"),
type: (0, vue.toRef)(props, "type")
}));
const ns = require_index.useNamespace("button");
return (_ctx, _cache) => {
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", { class: (0, vue.normalizeClass)([(0, vue.unref)(ns).b("group"), (0, vue.unref)(ns).bm("group", props.direction)]) }, [(0, vue.renderSlot)(_ctx.$slots, "default")], 2);
};
}
});
//#endregion
exports.default = button_group_vue_vue_type_script_setup_true_lang_default;
//# sourceMappingURL=button-group.vue_vue_type_script_setup_true_lang.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"button-group.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../../../../packages/components/button/src/button-group.vue"],"sourcesContent":["<template>\n <div :class=\"[ns.b('group'), ns.bm('group', props.direction)]\">\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { provide, reactive, toRef } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { buttonGroupContextKey } from './constants'\n\nimport type { ButtonGroupProps } from './button-group'\n\ndefineOptions({\n name: 'ElButtonGroup',\n})\nconst props = withDefaults(defineProps<ButtonGroupProps>(), {\n direction: 'horizontal',\n type: '',\n})\nprovide(\n buttonGroupContextKey,\n reactive({\n size: toRef(props, 'size'),\n type: toRef(props, 'type'),\n })\n)\nconst ns = useNamespace('button')\n</script>\n"],"mappings":";;;;;;;;;;;EAgBA,MAAM,QAAQ;EAId,CAAA,GAAA,IAAA,SACE,kBAAA,wBAAA,GAAA,IAAA,UACS;GACP,OAAA,GAAA,IAAA,OAAY,OAAO,OAAO;GAC1B,OAAA,GAAA,IAAA,OAAY,OAAO,OAAO;GAC3B,CAAA,CACH;EACA,MAAM,KAAK,cAAA,aAAa,SAAQ;;4DAxBxB,OAAA,EAFA,QAAA,GAAA,IAAA,gBAAK,EAAA,GAAA,IAAA,OAAG,GAAE,CAAC,EAAC,QAAA,GAAA,GAAA,IAAA,OAAW,GAAE,CAAC,GAAE,SAAU,MAAM,UAAS,CAAA,CAAA,EAAA,EAAA,EAAA,GAAA,IAAA,YACjD,KAAA,QAAA,UAAA,CAAA,EAAA,EAAA"}

View File

@@ -0,0 +1,10 @@
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
//#region ../../packages/components/button/src/button-group.vue
var button_group_default = require("./button-group.vue_vue_type_script_setup_true_lang.js").default;
//#endregion
exports.default = button_group_default;
//# sourceMappingURL=button-group2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"button-group2.js","names":[],"sources":["../../../../../../packages/components/button/src/button-group.vue"],"sourcesContent":["<template>\n <div :class=\"[ns.b('group'), ns.bm('group', props.direction)]\">\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { provide, reactive, toRef } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { buttonGroupContextKey } from './constants'\n\nimport type { ButtonGroupProps } from './button-group'\n\ndefineOptions({\n name: 'ElButtonGroup',\n})\nconst props = withDefaults(defineProps<ButtonGroupProps>(), {\n direction: 'horizontal',\n type: '',\n})\nprovide(\n buttonGroupContextKey,\n reactive({\n size: toRef(props, 'size'),\n type: toRef(props, 'type'),\n })\n)\nconst ns = useNamespace('button')\n</script>\n"],"mappings":""}

View File

@@ -0,0 +1,141 @@
import { IconPropType } from "../../../utils/vue/icon.js";
import { EpPropFinalized, EpPropMergeType } from "../../../utils/vue/props/types.js";
import { ComponentSize } from "../../../constants/size.js";
import * as _$vue from "vue";
import { Component, ExtractPublicPropTypes } from "vue";
//#region ../../packages/components/button/src/button.d.ts
declare const buttonTypes: readonly ["default", "primary", "success", "warning", "info", "danger", "text", ""];
declare const buttonNativeTypes: readonly ["button", "submit", "reset"];
type ButtonType = (typeof buttonTypes)[number];
type ButtonNativeType = (typeof buttonNativeTypes)[number];
interface ButtonProps {
/**
* @description button size
*/
size?: ComponentSize;
/**
* @description disable the button
*/
disabled?: boolean;
/**
* @description button type
*/
type?: ButtonType;
/**
* @description icon component
*/
icon?: IconPropType;
/**
* @description native button type
*/
nativeType?: ButtonNativeType;
/**
* @description determine whether it's loading
*/
loading?: boolean;
/**
* @description customize loading icon component
*/
loadingIcon?: IconPropType;
/**
* @description determine whether it's a plain button
*/
plain?: boolean;
/**
* @description determine whether it's a text button
*/
text?: boolean;
/**
* @description determine whether it's a link button
*/
link?: boolean;
/**
* @description determine whether the text button background color is always on
*/
bg?: boolean;
/**
* @description native button autofocus
*/
autofocus?: boolean;
/**
* @description determine whether it's a round button
*/
round?: boolean;
/**
* @description determine whether it's a circle button
*/
circle?: boolean;
/**
* @description determine whether it's a dashed button
*/
dashed?: boolean;
/**
* @description custom button color, automatically calculate `hover` and `active` color
*/
color?: string;
/**
* @description dark mode, which automatically converts `color` to dark mode colors
*/
dark?: boolean;
/**
* @description automatically insert a space between two chinese characters
*/
autoInsertSpace?: boolean;
/**
* @description custom element tag
*/
tag?: string | Component;
}
/**
* @deprecated Removed after 3.0.0, Use `ButtonProps` instead.
*/
declare const buttonProps: {
readonly size: {
readonly type: _$vue.PropType<EpPropMergeType<StringConstructor, "" | "default" | "small" | "large", never>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly disabled: EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
readonly type: EpPropFinalized<StringConstructor, "" | "default" | "info" | "primary" | "success" | "warning" | "text" | "danger", unknown, "", boolean>;
readonly icon: {
readonly type: _$vue.PropType<EpPropMergeType<(new (...args: any[]) => (string | Component) & {}) | (() => string | Component) | (((new (...args: any[]) => (string | Component) & {}) | (() => string | Component)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly nativeType: EpPropFinalized<StringConstructor, "button" | "reset" | "submit", unknown, "button", boolean>;
readonly loading: BooleanConstructor;
readonly loadingIcon: EpPropFinalized<(new (...args: any[]) => (string | Component) & {}) | (() => string | Component) | (((new (...args: any[]) => (string | Component) & {}) | (() => string | Component)) | null)[], unknown, unknown, () => _$vue.DefineComponent<{}, void, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>, boolean>;
readonly plain: EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
readonly text: EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
readonly link: BooleanConstructor;
readonly bg: BooleanConstructor;
readonly autofocus: BooleanConstructor;
readonly round: EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
readonly circle: BooleanConstructor;
readonly dashed: EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
readonly color: StringConstructor;
readonly dark: BooleanConstructor;
readonly autoInsertSpace: EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
readonly tag: EpPropFinalized<(new (...args: any[]) => (string | Component) & {}) | (() => string | Component) | (((new (...args: any[]) => (string | Component) & {}) | (() => string | Component)) | null)[], unknown, unknown, "button", boolean>;
};
declare const buttonEmits: {
click: (evt: MouseEvent) => boolean;
};
/**
* @deprecated Removed after 3.0.0, Use `ButtonProps` instead.
*/
type ButtonPropsPublic = ExtractPublicPropTypes<typeof buttonProps>;
type ButtonEmits = typeof buttonEmits;
interface ButtonConfigContext {
type?: ButtonProps['type'];
plain?: ButtonProps['plain'];
text?: ButtonProps['text'];
round?: ButtonProps['round'];
dashed?: ButtonProps['dashed'];
autoInsertSpace?: ButtonProps['autoInsertSpace'];
}
//#endregion
export { ButtonConfigContext, ButtonEmits, ButtonNativeType, ButtonProps, ButtonPropsPublic, ButtonType, buttonEmits, buttonNativeTypes, buttonProps, buttonTypes };

View File

@@ -0,0 +1,143 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../../_virtual/_rolldown/runtime.js");
const require_runtime$1 = require("../../../utils/vue/props/runtime.js");
const require_icon = require("../../../utils/vue/icon.js");
const require_index = require("../../../hooks/use-size/index.js");
let _element_plus_icons_vue = require("@element-plus/icons-vue");
//#region ../../packages/components/button/src/button.ts
const buttonTypes = [
"default",
"primary",
"success",
"warning",
"info",
"danger",
"text",
""
];
const buttonNativeTypes = [
"button",
"submit",
"reset"
];
/**
* @deprecated Removed after 3.0.0, Use `ButtonProps` instead.
*/
const buttonProps = require_runtime$1.buildProps({
/**
* @description button size
*/
size: require_index.useSizeProp,
/**
* @description disable the button
*/
disabled: {
type: Boolean,
default: void 0
},
/**
* @description button type
*/
type: {
type: String,
values: buttonTypes,
default: ""
},
/**
* @description icon component
*/
icon: { type: require_icon.iconPropType },
/**
* @description native button type
*/
nativeType: {
type: String,
values: buttonNativeTypes,
default: "button"
},
/**
* @description determine whether it's loading
*/
loading: Boolean,
/**
* @description customize loading icon component
*/
loadingIcon: {
type: require_icon.iconPropType,
default: () => _element_plus_icons_vue.Loading
},
/**
* @description determine whether it's a plain button
*/
plain: {
type: Boolean,
default: void 0
},
/**
* @description determine whether it's a text button
*/
text: {
type: Boolean,
default: void 0
},
/**
* @description determine whether it's a link button
*/
link: Boolean,
/**
* @description determine whether the text button background color is always on
*/
bg: Boolean,
/**
* @description native button autofocus
*/
autofocus: Boolean,
/**
* @description determine whether it's a round button
*/
round: {
type: Boolean,
default: void 0
},
/**
* @description determine whether it's a circle button
*/
circle: Boolean,
/**
* @description determine whether it's a dashed button
*/
dashed: {
type: Boolean,
default: void 0
},
/**
* @description custom button color, automatically calculate `hover` and `active` color
*/
color: String,
/**
* @description dark mode, which automatically converts `color` to dark mode colors
*/
dark: Boolean,
/**
* @description automatically insert a space between two chinese characters
*/
autoInsertSpace: {
type: Boolean,
default: void 0
},
/**
* @description custom element tag
*/
tag: {
type: require_runtime$1.definePropType([String, Object]),
default: "button"
}
});
const buttonEmits = { click: (evt) => evt instanceof MouseEvent };
//#endregion
exports.buttonEmits = buttonEmits;
exports.buttonNativeTypes = buttonNativeTypes;
exports.buttonProps = buttonProps;
exports.buttonTypes = buttonTypes;
//# sourceMappingURL=button.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,44 @@
import { IconPropType } from "../../../utils/vue/icon.js";
import { ButtonNativeType, ButtonProps, ButtonType } from "./button.js";
import * as _$vue from "vue";
//#region ../../packages/components/button/src/button.vue.d.ts
declare var __VLS_11: {}, __VLS_35: {}, __VLS_37: {};
type __VLS_Slots = {} & {
loading?: (props: typeof __VLS_11) => any;
} & {
icon?: (props: typeof __VLS_35) => any;
} & {
default?: (props: typeof __VLS_37) => any;
};
declare const __VLS_base: _$vue.DefineComponent<ButtonProps, {
/** @description button html element */ref: _$vue.Ref<HTMLButtonElement | undefined, HTMLButtonElement | undefined>; /** @description button size */
size: _$vue.ComputedRef<"" | "default" | "small" | "large">; /** @description button type */
type: _$vue.ComputedRef<"" | "default" | "info" | "primary" | "success" | "warning" | "text" | "danger">; /** @description button disabled */
disabled: _$vue.ComputedRef<boolean>; /** @description whether adding space */
shouldAddSpace: _$vue.ComputedRef<boolean>;
}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
click: (evt: MouseEvent) => void;
}, string, _$vue.PublicProps, Readonly<ButtonProps> & Readonly<{
onClick?: ((evt: MouseEvent) => any) | undefined;
}>, {
tag: string | _$vue.Component;
type: ButtonType;
disabled: boolean;
text: boolean;
round: boolean;
dashed: boolean;
plain: boolean;
nativeType: ButtonNativeType;
loadingIcon: IconPropType;
autoInsertSpace: boolean;
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
declare const _default: typeof __VLS_export;
type __VLS_WithSlots<T, S> = T & {
new (): {
$slots: S;
};
};
//#endregion
export { _default as default };

View File

@@ -0,0 +1,80 @@
require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../hooks/use-namespace/index.js");
const require_index$1 = require("../../icon/index.js");
const require_button = require("./button.js");
const require_use_button = require("./use-button.js");
const require_button_custom = require("./button-custom.js");
let vue = require("vue");
//#region ../../packages/components/button/src/button.vue?vue&type=script&setup=true&lang.ts
var button_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
name: "ElButton",
__name: "button",
props: require_button.buttonProps,
emits: require_button.buttonEmits,
setup(__props, { expose: __expose, emit: __emit }) {
const props = __props;
const emit = __emit;
const buttonStyle = require_button_custom.useButtonCustomStyle(props);
const ns = require_index.useNamespace("button");
const { _ref, _size, _type, _disabled, _props, _plain, _round, _text, _dashed, shouldAddSpace, handleClick } = require_use_button.useButton(props, emit);
const buttonKls = (0, vue.computed)(() => [
ns.b(),
ns.m(_type.value),
ns.m(_size.value),
ns.is("disabled", _disabled.value),
ns.is("loading", props.loading),
ns.is("plain", _plain.value),
ns.is("round", _round.value),
ns.is("circle", props.circle),
ns.is("text", _text.value),
ns.is("dashed", _dashed.value),
ns.is("link", props.link),
ns.is("has-bg", props.bg)
]);
__expose({
/** @description button html element */
ref: _ref,
/** @description button size */
size: _size,
/** @description button type */
type: _type,
/** @description button disabled */
disabled: _disabled,
/** @description whether adding space */
shouldAddSpace
});
return (_ctx, _cache) => {
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(__props.tag), (0, vue.mergeProps)({
ref_key: "_ref",
ref: _ref
}, (0, vue.unref)(_props), {
class: buttonKls.value,
style: (0, vue.unref)(buttonStyle),
onClick: (0, vue.unref)(handleClick)
}), {
default: (0, vue.withCtx)(() => [__props.loading ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 0 }, [_ctx.$slots.loading ? (0, vue.renderSlot)(_ctx.$slots, "loading", { key: 0 }) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(require_index$1.ElIcon), {
key: 1,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).is("loading"))
}, {
default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(__props.loadingIcon)))]),
_: 1
}, 8, ["class"]))], 64)) : __props.icon || _ctx.$slots.icon ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(require_index$1.ElIcon), { key: 1 }, {
default: (0, vue.withCtx)(() => [__props.icon ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(__props.icon), { key: 0 })) : (0, vue.renderSlot)(_ctx.$slots, "icon", { key: 1 })]),
_: 3
})) : (0, vue.createCommentVNode)("v-if", true), _ctx.$slots.default ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
key: 2,
class: (0, vue.normalizeClass)({ [(0, vue.unref)(ns).em("text", "expand")]: (0, vue.unref)(shouldAddSpace) })
}, [(0, vue.renderSlot)(_ctx.$slots, "default")], 2)) : (0, vue.createCommentVNode)("v-if", true)]),
_: 3
}, 16, [
"class",
"style",
"onClick"
]);
};
}
});
//#endregion
exports.default = button_vue_vue_type_script_setup_true_lang_default;
//# sourceMappingURL=button.vue_vue_type_script_setup_true_lang.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"button.vue_vue_type_script_setup_true_lang.js","names":["$slots"],"sources":["../../../../../../packages/components/button/src/button.vue"],"sourcesContent":["<template>\n <component\n :is=\"tag\"\n ref=\"_ref\"\n v-bind=\"_props\"\n :class=\"buttonKls\"\n :style=\"buttonStyle\"\n @click=\"handleClick\"\n >\n <template v-if=\"loading\">\n <slot v-if=\"$slots.loading\" name=\"loading\" />\n <el-icon v-else :class=\"ns.is('loading')\">\n <component :is=\"loadingIcon\" />\n </el-icon>\n </template>\n <el-icon v-else-if=\"icon || $slots.icon\">\n <component :is=\"icon\" v-if=\"icon\" />\n <slot v-else name=\"icon\" />\n </el-icon>\n <span\n v-if=\"$slots.default\"\n :class=\"{ [ns.em('text', 'expand')]: shouldAddSpace }\"\n >\n <slot />\n </span>\n </component>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, markRaw } from 'vue'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { Loading } from '@element-plus/icons-vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { useButton } from './use-button'\nimport { buttonEmits } from './button'\nimport { useButtonCustomStyle } from './button-custom'\n\nimport type { ButtonProps } from './button'\n\ndefineOptions({\n name: 'ElButton',\n})\n\nconst props = withDefaults(defineProps<ButtonProps>(), {\n disabled: undefined,\n type: '',\n nativeType: 'button',\n loadingIcon: markRaw(Loading),\n plain: undefined,\n text: undefined,\n round: undefined,\n dashed: undefined,\n autoInsertSpace: undefined,\n tag: 'button',\n})\n\nconst emit = defineEmits(buttonEmits)\n\nconst buttonStyle = useButtonCustomStyle(props)\nconst ns = useNamespace('button')\nconst {\n _ref,\n _size,\n _type,\n _disabled,\n _props,\n _plain,\n _round,\n _text,\n _dashed,\n shouldAddSpace,\n handleClick,\n} = useButton(props, emit)\nconst buttonKls = computed(() => [\n ns.b(),\n ns.m(_type.value),\n ns.m(_size.value),\n ns.is('disabled', _disabled.value),\n ns.is('loading', props.loading),\n ns.is('plain', _plain.value),\n ns.is('round', _round.value),\n ns.is('circle', props.circle),\n ns.is('text', _text.value),\n ns.is('dashed', _dashed.value),\n ns.is('link', props.link),\n ns.is('has-bg', props.bg),\n])\n\ndefineExpose({\n /** @description button html element */\n ref: _ref,\n /** @description button size */\n size: _size,\n /** @description button type */\n type: _type,\n /** @description button disabled */\n disabled: _disabled,\n /** @description whether adding space */\n shouldAddSpace,\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;EA2CA,MAAM,QAAQ;EAad,MAAM,OAAO;EAEb,MAAM,cAAc,sBAAA,qBAAqB,MAAK;EAC9C,MAAM,KAAK,cAAA,aAAa,SAAQ;EAChC,MAAM,EACJ,MACA,OACA,OACA,WACA,QACA,QACA,QACA,OACA,SACA,gBACA,gBACE,mBAAA,UAAU,OAAO,KAAI;EACzB,MAAM,aAAA,GAAA,IAAA,gBAA2B;GAC/B,GAAG,GAAG;GACN,GAAG,EAAE,MAAM,MAAM;GACjB,GAAG,EAAE,MAAM,MAAM;GACjB,GAAG,GAAG,YAAY,UAAU,MAAM;GAClC,GAAG,GAAG,WAAW,MAAM,QAAQ;GAC/B,GAAG,GAAG,SAAS,OAAO,MAAM;GAC5B,GAAG,GAAG,SAAS,OAAO,MAAM;GAC5B,GAAG,GAAG,UAAU,MAAM,OAAO;GAC7B,GAAG,GAAG,QAAQ,MAAM,MAAM;GAC1B,GAAG,GAAG,UAAU,QAAQ,MAAM;GAC9B,GAAG,GAAG,QAAQ,MAAM,KAAK;GACzB,GAAG,GAAG,UAAU,MAAM,GAAG;GAC1B,CAAA;EAED,SAAa;;GAEX,KAAK;;GAEL,MAAM;;GAEN,MAAM;;GAEN,UAAU;;GAEV;GACD,CAAA;;sFAjGQ,QAAA,IAAG,GAAA,GAAA,IAAA,YAuBE;aAtBN;IAAJ,KAAI;qBACI,OAAM,EAAA;IACb,OAAO,UAAA;IACP,QAAA,GAAA,IAAA,OAAO,YAAW;IAClB,UAAA,GAAA,IAAA,OAAO,YAAA;;oCAOG,CALK,QAAA,YAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAKL,IAAA,UAAA,EAAA,KAAA,GAAA,EAAA,CAJGA,KAAAA,OAAO,WAAA,GAAA,IAAA,YAA0B,KAAA,QAAA,WAAA,EAAA,KAAA,GAAA,CAAA,KAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,cAAA,GAAA,IAAA,OAGnC,gBAAA,OAAA,EAAA;;KAFO,QAAA,GAAA,IAAA,iBAAA,GAAA,IAAA,OAAO,GAAE,CAAC,GAAE,UAAA,CAAA;;qCACI,GAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,cAAA,GAAA,IAAA,yBAAf,QAAA,YAAW,CAAA,EAAA,CAAA;;+BAGX,QAAA,QAAQA,KAAAA,OAAO,SAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,cAAA,GAAA,IAAA,OAGzB,gBAAA,OAAA,EAAA,EAAA,KAAA,GAAA,EAAA;qCAF4B,CAAR,QAAA,SAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,cAAA,GAAA,IAAA,yBAAZ,QAAA,KAAI,EAAA,EAAA,KAAA,GAAA,CAAA,KAAA,GAAA,IAAA,YACO,KAAA,QAAA,QAAA,EAAA,KAAA,GAAA,CAAA,CAAA,CAAA;;qDAGrBA,KAAAA,OAAO,YAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAIR,QAAA;;KAHJ,QAAA,GAAA,IAAA,gBAAK,IAAA,GAAA,IAAA,OAAK,GAAE,CAAC,GAAE,QAAA,SAAA,IAAA,GAAA,IAAA,OAAqB,eAAc,EAAA,CAAA;4BAE3C,KAAA,QAAA,UAAA,CAAA,EAAA,EAAA,KAAA,GAAA,IAAA,oBAAA,QAAA,KAAA,CAAA,CAAA"}

View File

@@ -0,0 +1,10 @@
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
//#region ../../packages/components/button/src/button.vue
var button_default = require("./button.vue_vue_type_script_setup_true_lang.js").default;
//#endregion
exports.default = button_default;
//# sourceMappingURL=button2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"button2.js","names":[],"sources":["../../../../../../packages/components/button/src/button.vue"],"sourcesContent":["<template>\n <component\n :is=\"tag\"\n ref=\"_ref\"\n v-bind=\"_props\"\n :class=\"buttonKls\"\n :style=\"buttonStyle\"\n @click=\"handleClick\"\n >\n <template v-if=\"loading\">\n <slot v-if=\"$slots.loading\" name=\"loading\" />\n <el-icon v-else :class=\"ns.is('loading')\">\n <component :is=\"loadingIcon\" />\n </el-icon>\n </template>\n <el-icon v-else-if=\"icon || $slots.icon\">\n <component :is=\"icon\" v-if=\"icon\" />\n <slot v-else name=\"icon\" />\n </el-icon>\n <span\n v-if=\"$slots.default\"\n :class=\"{ [ns.em('text', 'expand')]: shouldAddSpace }\"\n >\n <slot />\n </span>\n </component>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, markRaw } from 'vue'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { Loading } from '@element-plus/icons-vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { useButton } from './use-button'\nimport { buttonEmits } from './button'\nimport { useButtonCustomStyle } from './button-custom'\n\nimport type { ButtonProps } from './button'\n\ndefineOptions({\n name: 'ElButton',\n})\n\nconst props = withDefaults(defineProps<ButtonProps>(), {\n disabled: undefined,\n type: '',\n nativeType: 'button',\n loadingIcon: markRaw(Loading),\n plain: undefined,\n text: undefined,\n round: undefined,\n dashed: undefined,\n autoInsertSpace: undefined,\n tag: 'button',\n})\n\nconst emit = defineEmits(buttonEmits)\n\nconst buttonStyle = useButtonCustomStyle(props)\nconst ns = useNamespace('button')\nconst {\n _ref,\n _size,\n _type,\n _disabled,\n _props,\n _plain,\n _round,\n _text,\n _dashed,\n shouldAddSpace,\n handleClick,\n} = useButton(props, emit)\nconst buttonKls = computed(() => [\n ns.b(),\n ns.m(_type.value),\n ns.m(_size.value),\n ns.is('disabled', _disabled.value),\n ns.is('loading', props.loading),\n ns.is('plain', _plain.value),\n ns.is('round', _round.value),\n ns.is('circle', props.circle),\n ns.is('text', _text.value),\n ns.is('dashed', _dashed.value),\n ns.is('link', props.link),\n ns.is('has-bg', props.bg),\n])\n\ndefineExpose({\n /** @description button html element */\n ref: _ref,\n /** @description button size */\n size: _size,\n /** @description button type */\n type: _type,\n /** @description button disabled */\n disabled: _disabled,\n /** @description whether adding space */\n shouldAddSpace,\n})\n</script>\n"],"mappings":""}

View File

@@ -0,0 +1,11 @@
import { ButtonProps } from "./button.js";
import { InjectionKey } from "vue";
//#region ../../packages/components/button/src/constants.d.ts
interface ButtonGroupContext {
size?: ButtonProps['size'];
type?: ButtonProps['type'];
}
declare const buttonGroupContextKey: InjectionKey<ButtonGroupContext>;
//#endregion
export { ButtonGroupContext, buttonGroupContextKey };

View File

@@ -0,0 +1,7 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
//#region ../../packages/components/button/src/constants.ts
const buttonGroupContextKey = Symbol("buttonGroupContextKey");
//#endregion
exports.buttonGroupContextKey = buttonGroupContextKey;
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","names":[],"sources":["../../../../../../packages/components/button/src/constants.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { ButtonProps } from './button'\n\nexport interface ButtonGroupContext {\n size?: ButtonProps['size']\n type?: ButtonProps['type']\n}\n\nexport const buttonGroupContextKey: InjectionKey<ButtonGroupContext> = Symbol(\n 'buttonGroupContextKey'\n)\n"],"mappings":";;AAQA,MAAa,wBAA0D,OACrE,wBACD"}

View File

@@ -0,0 +1,8 @@
import _default from "./button.vue.js";
import _default$1 from "./button-group.vue.js";
//#region ../../packages/components/button/src/instance.d.ts
type ButtonInstance = InstanceType<typeof _default> & unknown;
type ButtonGroupInstance = InstanceType<typeof _default$1> & unknown;
//#endregion
export { ButtonGroupInstance, ButtonInstance };

View File

@@ -0,0 +1 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });

View File

@@ -0,0 +1,30 @@
import { ButtonEmits, ButtonProps } from "./button.js";
import * as _$vue from "vue";
import { SetupContext } from "vue";
//#region ../../packages/components/button/src/use-button.d.ts
declare const useButton: (props: ButtonProps, emit: SetupContext<ButtonEmits>["emit"]) => {
_disabled: _$vue.ComputedRef<boolean>;
_size: _$vue.ComputedRef<"" | "default" | "small" | "large">;
_type: _$vue.ComputedRef<"" | "default" | "info" | "primary" | "success" | "warning" | "text" | "danger">;
_ref: _$vue.Ref<HTMLButtonElement | undefined, HTMLButtonElement | undefined>;
_props: _$vue.ComputedRef<{
ariaDisabled: boolean | undefined;
disabled: boolean | undefined;
autofocus: boolean | undefined;
type: "button" | "reset" | "submit" | undefined;
} | {
ariaDisabled?: undefined;
disabled?: undefined;
autofocus?: undefined;
type?: undefined;
}>;
_plain: _$vue.ComputedRef<boolean>;
_round: _$vue.ComputedRef<boolean>;
_text: _$vue.ComputedRef<boolean>;
_dashed: _$vue.ComputedRef<boolean>;
shouldAddSpace: _$vue.ComputedRef<boolean>;
handleClick: (evt: MouseEvent) => void;
};
//#endregion
export { useButton };

View File

@@ -0,0 +1,76 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../hooks/use-deprecated/index.js");
const require_use_form_common_props = require("../../form/src/hooks/use-form-common-props.js");
const require_use_form_item = require("../../form/src/hooks/use-form-item.js");
const require_use_global_config = require("../../config-provider/src/hooks/use-global-config.js");
const require_constants = require("./constants.js");
let vue = require("vue");
//#region ../../packages/components/button/src/use-button.ts
const useButton = (props, emit) => {
require_index.useDeprecated({
from: "type.text",
replacement: "link",
version: "3.0.0",
scope: "props",
ref: "https://element-plus.org/en-US/component/button.html#button-attributes"
}, (0, vue.computed)(() => props.type === "text"));
const buttonGroupContext = (0, vue.inject)(require_constants.buttonGroupContextKey, void 0);
const globalConfig = require_use_global_config.useGlobalConfig("button");
const { form } = require_use_form_item.useFormItem();
const _size = require_use_form_common_props.useFormSize((0, vue.computed)(() => buttonGroupContext?.size));
const _disabled = require_use_form_common_props.useFormDisabled();
const _ref = (0, vue.ref)();
const slots = (0, vue.useSlots)();
const _type = (0, vue.computed)(() => props.type || buttonGroupContext?.type || globalConfig.value?.type || "");
const autoInsertSpace = (0, vue.computed)(() => props.autoInsertSpace ?? globalConfig.value?.autoInsertSpace ?? false);
const _plain = (0, vue.computed)(() => props.plain ?? globalConfig.value?.plain ?? false);
const _round = (0, vue.computed)(() => props.round ?? globalConfig.value?.round ?? false);
const _text = (0, vue.computed)(() => props.text ?? globalConfig.value?.text ?? false);
const _dashed = (0, vue.computed)(() => props.dashed ?? globalConfig.value?.dashed ?? false);
const _props = (0, vue.computed)(() => {
if (props.tag === "button") return {
ariaDisabled: _disabled.value || props.loading,
disabled: _disabled.value || props.loading,
autofocus: props.autofocus,
type: props.nativeType
};
return {};
});
const shouldAddSpace = (0, vue.computed)(() => {
const defaultSlot = slots.default?.();
if (autoInsertSpace.value && defaultSlot?.length === 1) {
const slot = defaultSlot[0];
if (slot?.type === vue.Text) {
const text = slot.children;
return /^\p{Unified_Ideograph}{2}$/u.test(text.trim());
}
}
return false;
});
const handleClick = (evt) => {
if (_disabled.value || props.loading) {
evt.stopPropagation();
return;
}
if (props.nativeType === "reset") form?.resetFields();
emit("click", evt);
};
return {
_disabled,
_size,
_type,
_ref,
_props,
_plain,
_round,
_text,
_dashed,
shouldAddSpace,
handleClick
};
};
//#endregion
exports.useButton = useButton;
//# sourceMappingURL=use-button.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-button.js","names":["buttonGroupContextKey","useGlobalConfig","useFormItem","useFormSize","useFormDisabled","Text"],"sources":["../../../../../../packages/components/button/src/use-button.ts"],"sourcesContent":["import { Text, computed, inject, ref, useSlots } from 'vue'\nimport {\n useFormDisabled,\n useFormItem,\n useFormSize,\n} from '@element-plus/components/form'\nimport { useGlobalConfig } from '@element-plus/components/config-provider'\nimport { useDeprecated } from '@element-plus/hooks'\nimport { buttonGroupContextKey } from './constants'\n\nimport type { SetupContext } from 'vue'\nimport type { ButtonEmits, ButtonProps } from './button'\n\nexport const useButton = (\n props: ButtonProps,\n emit: SetupContext<ButtonEmits>['emit']\n) => {\n useDeprecated(\n {\n from: 'type.text',\n replacement: 'link',\n version: '3.0.0',\n scope: 'props',\n ref: 'https://element-plus.org/en-US/component/button.html#button-attributes',\n },\n computed(() => props.type === 'text')\n )\n\n const buttonGroupContext = inject(buttonGroupContextKey, undefined)\n const globalConfig = useGlobalConfig('button')\n const { form } = useFormItem()\n const _size = useFormSize(computed(() => buttonGroupContext?.size))\n const _disabled = useFormDisabled()\n const _ref = ref<HTMLButtonElement>()\n const slots = useSlots()\n\n const _type = computed(\n () =>\n props.type || buttonGroupContext?.type || globalConfig.value?.type || ''\n )\n const autoInsertSpace = computed(\n () => props.autoInsertSpace ?? globalConfig.value?.autoInsertSpace ?? false\n )\n const _plain = computed(\n () => props.plain ?? globalConfig.value?.plain ?? false\n )\n const _round = computed(\n () => props.round ?? globalConfig.value?.round ?? false\n )\n const _text = computed(() => props.text ?? globalConfig.value?.text ?? false)\n const _dashed = computed(\n () => props.dashed ?? globalConfig.value?.dashed ?? false\n )\n\n const _props = computed(() => {\n if (props.tag === 'button') {\n return {\n ariaDisabled: _disabled.value || props.loading,\n disabled: _disabled.value || props.loading,\n autofocus: props.autofocus,\n type: props.nativeType,\n }\n }\n return {}\n })\n\n // add space between two characters in Chinese\n const shouldAddSpace = computed(() => {\n const defaultSlot = slots.default?.()\n if (autoInsertSpace.value && defaultSlot?.length === 1) {\n const slot = defaultSlot[0]\n if (slot?.type === Text) {\n const text = slot.children as string\n return /^\\p{Unified_Ideograph}{2}$/u.test(text.trim())\n }\n }\n return false\n })\n\n const handleClick = (evt: MouseEvent) => {\n if (_disabled.value || props.loading) {\n evt.stopPropagation()\n return\n }\n if (props.nativeType === 'reset') {\n form?.resetFields()\n }\n emit('click', evt)\n }\n\n return {\n _disabled,\n _size,\n _type,\n _ref,\n _props,\n _plain,\n _round,\n _text,\n _dashed,\n shouldAddSpace,\n handleClick,\n }\n}\n"],"mappings":";;;;;;;;;AAaA,MAAa,aACX,OACA,SACG;CACH,cAAA,cACE;EACE,MAAM;EACN,aAAa;EACb,SAAS;EACT,OAAO;EACP,KAAK;EACN,GAAA,GAAA,IAAA,gBACc,MAAM,SAAS,OAAO,CACtC;CAED,MAAM,sBAAA,GAAA,IAAA,QAA4BA,kBAAAA,uBAAuB,KAAA,EAAU;CACnE,MAAM,eAAeC,0BAAAA,gBAAgB,SAAS;CAC9C,MAAM,EAAE,SAASC,sBAAAA,aAAa;CAC9B,MAAM,QAAQC,8BAAAA,aAAAA,GAAAA,IAAAA,gBAA2B,oBAAoB,KAAK,CAAC;CACnE,MAAM,YAAYC,8BAAAA,iBAAiB;CACnC,MAAM,QAAA,GAAA,IAAA,MAA+B;CACrC,MAAM,SAAA,GAAA,IAAA,WAAkB;CAExB,MAAM,SAAA,GAAA,IAAA,gBAEF,MAAM,QAAQ,oBAAoB,QAAQ,aAAa,OAAO,QAAQ,GACzE;CACD,MAAM,mBAAA,GAAA,IAAA,gBACE,MAAM,mBAAmB,aAAa,OAAO,mBAAmB,MACvE;CACD,MAAM,UAAA,GAAA,IAAA,gBACE,MAAM,SAAS,aAAa,OAAO,SAAS,MACnD;CACD,MAAM,UAAA,GAAA,IAAA,gBACE,MAAM,SAAS,aAAa,OAAO,SAAS,MACnD;CACD,MAAM,SAAA,GAAA,IAAA,gBAAuB,MAAM,QAAQ,aAAa,OAAO,QAAQ,MAAM;CAC7E,MAAM,WAAA,GAAA,IAAA,gBACE,MAAM,UAAU,aAAa,OAAO,UAAU,MACrD;CAED,MAAM,UAAA,GAAA,IAAA,gBAAwB;EAC5B,IAAI,MAAM,QAAQ,UAChB,OAAO;GACL,cAAc,UAAU,SAAS,MAAM;GACvC,UAAU,UAAU,SAAS,MAAM;GACnC,WAAW,MAAM;GACjB,MAAM,MAAM;GACb;EAEH,OAAO,EAAE;GACT;CAGF,MAAM,kBAAA,GAAA,IAAA,gBAAgC;EACpC,MAAM,cAAc,MAAM,WAAW;EACrC,IAAI,gBAAgB,SAAS,aAAa,WAAW,GAAG;GACtD,MAAM,OAAO,YAAY;GACzB,IAAI,MAAM,SAASC,IAAAA,MAAM;IACvB,MAAM,OAAO,KAAK;IAClB,OAAO,8BAA8B,KAAK,KAAK,MAAM,CAAC;;;EAG1D,OAAO;GACP;CAEF,MAAM,eAAe,QAAoB;EACvC,IAAI,UAAU,SAAS,MAAM,SAAS;GACpC,IAAI,iBAAiB;GACrB;;EAEF,IAAI,MAAM,eAAe,SACvB,MAAM,aAAa;EAErB,KAAK,SAAS,IAAI;;CAGpB,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}

View File

@@ -0,0 +1,3 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../base/style/css.js");
require("element-plus/theme-chalk/el-button.css");

View File

@@ -0,0 +1,3 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../base/style/index.js");
require("element-plus/theme-chalk/src/button.scss");