element-plus
Version:
A Component Library for Vue 3
1 lines • 4.23 kB
Source Map (JSON)
{"version":3,"file":"segmented.mjs","names":[],"sources":["../../../../../../packages/components/segmented/src/segmented.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isBoolean,\n isNumber,\n isString,\n} from '@element-plus/utils'\nimport { useAriaProps, useSizeProp } from '@element-plus/hooks'\nimport { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\n\nimport type { Option } from './types'\nimport type { ComponentInstance, ExtractPublicPropTypes } from 'vue'\nimport type { ComponentExposed } from 'vue-component-type-helpers'\nimport type { ComponentSize } from '@element-plus/constants'\nimport type Segmented from './segmented.vue'\n\nexport interface Props {\n label?: string\n value?: string\n disabled?: string\n}\n\nexport const defaultProps: Required<Props> = {\n label: 'label',\n value: 'value',\n disabled: 'disabled',\n}\n\nexport interface SegmentedProps<T extends Option = Option> {\n direction?: 'vertical' | 'horizontal'\n /**\n * @description options of segmented\n */\n options?: T[]\n /**\n * @description binding value\n */\n modelValue?: string | number | boolean\n /**\n * @description configuration options, see the following table\n */\n props?: Props\n /**\n * @description fit width of parent content\n */\n block?: boolean\n /**\n * @description size of component\n */\n size?: ComponentSize\n /**\n * @description whether segmented is disabled\n */\n disabled?: boolean\n /**\n * @description whether to trigger form validation\n */\n validateEvent?: boolean\n /**\n * @description native input id\n */\n id?: string\n /**\n * @description native `name` attribute\n */\n name?: string\n /**\n * @description native `aria-label` attribute\n */\n ariaLabel?: string\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `SegmentedProps` instead.\n */\nexport const segmentedProps = buildProps({\n direction: {\n type: definePropType<'vertical' | 'horizontal'>(String),\n default: 'horizontal',\n },\n /**\n * @description options of segmented\n */\n options: {\n type: definePropType<Option[]>(Array),\n default: () => [],\n },\n /**\n * @description binding value\n */\n modelValue: {\n type: [String, Number, Boolean],\n default: undefined,\n },\n /**\n * @description configuration options, see the following table\n */\n props: {\n type: definePropType<Props>(Object),\n default: () => defaultProps,\n },\n /**\n * @description fit width of parent content\n */\n block: Boolean,\n /**\n * @description size of component\n */\n size: useSizeProp,\n /**\n * @description whether segmented is disabled\n */\n disabled: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description whether to trigger form validation\n */\n validateEvent: {\n type: Boolean,\n default: true,\n },\n /**\n * @description native input id\n */\n id: String,\n /**\n * @description native `name` attribute\n */\n name: String,\n ...useAriaProps(['ariaLabel']),\n})\n\n/**\n * @deprecated Removed after 3.0.0, Use `SegmentedProps` instead.\n */\nexport type SegmentedPropsPublic = ExtractPublicPropTypes<typeof segmentedProps>\n\nexport const segmentedEmits = {\n [UPDATE_MODEL_EVENT]: (val: any) =>\n isString(val) || isNumber(val) || isBoolean(val),\n [CHANGE_EVENT]: (val: any) =>\n isString(val) || isNumber(val) || isBoolean(val),\n}\nexport type SegmentedEmits = typeof segmentedEmits\n\nexport type SegmentedInstance = ComponentInstance<typeof Segmented> &\n ComponentExposed<typeof Segmented>\n"],"mappings":";;;;;;;AAsBA,MAAa,eAAgC;CAC3C,OAAO;CACP,OAAO;CACP,UAAU;CACX;;;;AAiDD,MAAa,iBAAiB,WAAW;CACvC,WAAW;EACT,MAAM,eAA0C,OAAO;EACvD,SAAS;EACV;CAID,SAAS;EACP,MAAM,eAAyB,MAAM;EACrC,eAAe,EAAE;EAClB;CAID,YAAY;EACV,MAAM;GAAC;GAAQ;GAAQ;GAAQ;EAC/B,SAAS;EACV;CAID,OAAO;EACL,MAAM,eAAsB,OAAO;EACnC,eAAe;EAChB;CAID,OAAO;CAIP,MAAM;CAIN,UAAU;EACR,MAAM;EACN,SAAS;EACV;CAID,eAAe;EACb,MAAM;EACN,SAAS;EACV;CAID,IAAI;CAIJ,MAAM;CACN,GAAG,aAAa,CAAC,YAAY,CAAC;CAC/B,CAAC;AAOF,MAAa,iBAAiB;EAC3B,sBAAsB,QACrB,SAAS,IAAI,IAAI,SAAS,IAAI,IAAI,UAAU,IAAI;EACjD,gBAAgB,QACf,SAAS,IAAI,IAAI,SAAS,IAAI,IAAI,UAAU,IAAI;CACnD"}