UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 6.95 kB
{"version":3,"file":"button.mjs","sources":["../../../../../../packages/components/button/src/button.ts"],"sourcesContent":["import { useSizeProp } from '@element-plus/hooks'\nimport { buildProps, definePropType, iconPropType } from '@element-plus/utils'\nimport { Loading } from '@element-plus/icons-vue'\n\nimport type { Component, ExtractPublicPropTypes } from 'vue'\nimport type { ComponentSize } from '@element-plus/constants'\n\nexport const buttonTypes = [\n 'default',\n 'primary',\n 'success',\n 'warning',\n 'info',\n 'danger',\n /**\n * @deprecated\n * Text type will be deprecated in the next major version (3.0.0)\n */\n 'text',\n '',\n] as const\nexport const buttonNativeTypes = ['button', 'submit', 'reset'] as const\n\nexport type ButtonType = (typeof buttonTypes)[number]\nexport type ButtonNativeType = (typeof buttonNativeTypes)[number]\n\nexport interface ButtonProps {\n /**\n * @description button size\n */\n size?: ComponentSize\n /**\n * @description disable the button\n */\n disabled?: boolean\n /**\n * @description button type\n */\n type?: ButtonType\n /**\n * @description icon component\n */\n icon?: string | Component\n /**\n * @description native button type\n */\n nativeType?: ButtonNativeType\n /**\n * @description determine whether it's loading\n */\n loading?: boolean\n /**\n * @description customize loading icon component\n */\n loadingIcon?: string | Component\n /**\n * @description determine whether it's a plain button\n */\n plain?: boolean\n /**\n * @description determine whether it's a text button\n */\n text?: boolean\n /**\n * @description determine whether it's a link button\n */\n link?: boolean\n /**\n * @description determine whether the text button background color is always on\n */\n bg?: boolean\n /**\n * @description native button autofocus\n */\n autofocus?: boolean\n /**\n * @description determine whether it's a round button\n */\n round?: boolean\n /**\n * @description determine whether it's a circle button\n */\n circle?: boolean\n /**\n * @description custom button color, automatically calculate `hover` and `active` color\n */\n color?: string\n /**\n * @description dark mode, which automatically converts `color` to dark mode colors\n */\n dark?: boolean\n /**\n * @description automatically insert a space between two chinese characters\n */\n autoInsertSpace?: boolean\n /**\n * @description custom element tag\n */\n tag?: string | Component\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `ButtonProps` instead.\n */\nexport const buttonProps = buildProps({\n /**\n * @description button size\n */\n size: useSizeProp,\n /**\n * @description disable the button\n */\n disabled: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description button type\n */\n type: {\n type: String,\n values: buttonTypes,\n default: '',\n },\n /**\n * @description icon component\n */\n icon: {\n type: iconPropType,\n },\n /**\n * @description native button type\n */\n nativeType: {\n type: String,\n values: buttonNativeTypes,\n default: 'button',\n },\n /**\n * @description determine whether it's loading\n */\n loading: Boolean,\n /**\n * @description customize loading icon component\n */\n loadingIcon: {\n type: iconPropType,\n default: () => Loading,\n },\n /**\n * @description determine whether it's a plain button\n */\n plain: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description determine whether it's a text button\n */\n text: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description determine whether it's a link button\n */\n link: Boolean,\n /**\n * @description determine whether the text button background color is always on\n */\n bg: Boolean,\n /**\n * @description native button autofocus\n */\n autofocus: Boolean,\n /**\n * @description determine whether it's a round button\n */\n round: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description determine whether it's a circle button\n */\n circle: Boolean,\n /**\n * @description custom button color, automatically calculate `hover` and `active` color\n */\n color: String,\n /**\n * @description dark mode, which automatically converts `color` to dark mode colors\n */\n dark: Boolean,\n /**\n * @description automatically insert a space between two chinese characters\n */\n autoInsertSpace: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description custom element tag\n */\n tag: {\n type: definePropType<string | Component>([String, Object]),\n default: 'button',\n },\n} as const)\nexport const buttonEmits = {\n click: (evt: MouseEvent) => evt instanceof MouseEvent,\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `ButtonProps` instead.\n */\nexport type ButtonPropsPublic = ExtractPublicPropTypes<typeof buttonProps>\nexport type ButtonEmits = typeof buttonEmits\n\nexport interface ButtonConfigContext {\n type?: ButtonProps['type']\n plain?: ButtonProps['plain']\n text?: ButtonProps['text']\n round?: ButtonProps['round']\n autoInsertSpace?: ButtonProps['autoInsertSpace']\n}\n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