UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 4.86 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, ExtractPropTypes, ExtractPublicPropTypes } from 'vue'\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 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\nexport type ButtonProps = ExtractPropTypes<typeof buttonProps>\nexport type ButtonPropsPublic = ExtractPublicPropTypes<typeof buttonProps>\nexport type ButtonEmits = typeof buttonEmits\n\nexport type ButtonType = ButtonProps['type']\nexport type ButtonNativeType = ButtonProps['nativeType']\n\nexport interface ButtonConfigContext {\n type?: string\n plain?: boolean\n text?: boolean\n round?: boolean\n autoInsertSpace?: boolean\n}\n"],"names":[],"mappings":";;;;;AAMO,MAAM,WAAc,GAAA;AAAA,EACzB,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EAKA,MAAA;AAAA,EACA,EAAA;AACF,EAAA;AACO,MAAM,iBAAoB,GAAA,CAAC,QAAU,EAAA,QAAA,EAAU,OAAO,EAAA;AAEtD,MAAM,cAAc,UAAW,CAAA;AAAA,EAIpC,IAAM,EAAA,WAAA;AAAA,EAIN,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA,CAAA;AAAA,GACX;AAAA,EAIA,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,MAAA;AAAA,IACN,MAAQ,EAAA,WAAA;AAAA,IACR,OAAS,EAAA,EAAA;AAAA,GACX;AAAA,EAIA,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,YAAA;AAAA,GACR;AAAA,EAIA,UAAY,EAAA;AAAA,IACV,IAAM,EAAA,MAAA;AAAA,IACN,MAAQ,EAAA,iBAAA;AAAA,IACR,OAAS,EAAA,QAAA;AAAA,GACX;AAAA,EAIA,OAAS,EAAA,OAAA;AAAA,EAIT,WAAa,EAAA;AAAA,IACX,IAAM,EAAA,YAAA;AA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