element-plus
Version:
A Component Library for Vue 3
1 lines • 8.92 kB
Source Map (JSON)
{"version":3,"file":"rate.mjs","sources":["../../../../../../packages/components/rate/src/rate.ts"],"sourcesContent":["import { Star, StarFilled } from '@element-plus/icons-vue'\nimport { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport {\n buildProps,\n definePropType,\n iconPropType,\n isNumber,\n mutable,\n} from '@element-plus/utils'\nimport { useAriaProps, useSizeProp } from '@element-plus/hooks'\n\nimport type { Component, ExtractPublicPropTypes } from 'vue'\nimport type { ComponentSize } from '@element-plus/constants'\nimport type Rate from './rate.vue'\n\nexport interface RateProps {\n /**\n * @description binding value\n */\n modelValue?: number\n /**\n * @description native `id` attribute\n */\n id?: string\n /**\n * @description threshold value between low and medium level. The value itself will be included in low level\n */\n lowThreshold?: number\n /**\n * @description threshold value between medium and high level. The value itself will be included in high level\n */\n highThreshold?: number\n /**\n * @description max rating score\n */\n max?: number\n /**\n * @description colors for icons. If array, it should have 3 elements, each of which corresponds with a score level, else if object, the key should be threshold value between two levels, and the value should be corresponding color\n */\n colors?: string[] | Record<number, string>\n /**\n * @description color of unselected icons\n */\n voidColor?: string\n /**\n * @description color of unselected read-only icons\n */\n disabledVoidColor?: string\n /**\n * @description icon components. If array, it should have 3 elements, each of which corresponds with a score level, else if object, the key should be threshold value between two levels, and the value should be corresponding icon component\n */\n icons?: Array<string | Component> | Record<number, string | Component>\n /**\n * @description component of unselected icons\n */\n voidIcon?: string | Component\n /**\n * @description component of unselected read-only icons\n */\n disabledVoidIcon?: string | Component\n /**\n * @description whether Rate is read-only\n */\n disabled?: boolean\n /**\n * @description whether picking half start is allowed\n */\n allowHalf?: boolean\n /**\n * @description whether to display texts\n */\n showText?: boolean\n /**\n * @description whether to display current score. show-score and show-text cannot be true at the same time\n */\n showScore?: boolean\n /**\n * @description color of texts\n */\n textColor?: string\n /**\n * @description text array\n */\n texts?: string[]\n /**\n * @description score template\n */\n scoreTemplate?: string\n /**\n * @description size of Rate\n */\n size?: ComponentSize\n /**\n * @description whether value can be reset to `0`\n */\n clearable?: boolean\n /**\n * @description native `aria-label` attribute\n */\n ariaLabel?: string\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `RateProps` instead.\n */\nexport const rateProps = buildProps({\n /**\n * @description binding value\n */\n modelValue: {\n type: Number,\n default: 0,\n },\n /**\n * @description native `id` attribute\n */\n id: {\n type: String,\n default: undefined,\n },\n /**\n * @description threshold value between low and medium level. The value itself will be included in low level\n */\n lowThreshold: {\n type: Number,\n default: 2,\n },\n /**\n * @description threshold value between medium and high level. The value itself will be included in high level\n */\n highThreshold: {\n type: Number,\n default: 4,\n },\n /**\n * @description max rating score\n */\n max: {\n type: Number,\n default: 5,\n },\n /**\n * @description colors for icons. If array, it should have 3 elements, each of which corresponds with a score level, else if object, the key should be threshold value between two levels, and the value should be corresponding color\n */\n colors: {\n type: definePropType<string[] | Record<number, string>>([Array, Object]),\n default: () => mutable(['', '', ''] as const),\n },\n /**\n * @description color of unselected icons\n */\n voidColor: {\n type: String,\n default: '',\n },\n /**\n * @description color of unselected read-only icons\n */\n disabledVoidColor: {\n type: String,\n default: '',\n },\n /**\n * @description icon components. If array, it should have 3 elements, each of which corresponds with a score level, else if object, the key should be threshold value between two levels, and the value should be corresponding icon component\n */\n icons: {\n type: definePropType<\n Array<string | Component> | Record<number, string | Component>\n >([Array, Object]),\n default: () =>\n [StarFilled, StarFilled, StarFilled] as [Component, Component, Component],\n },\n /**\n * @description component of unselected icons\n */\n voidIcon: {\n type: iconPropType,\n default: () => Star as Component,\n },\n /**\n * @description component of unselected read-only icons\n */\n disabledVoidIcon: {\n type: iconPropType,\n default: () => StarFilled as Component,\n },\n /**\n * @description whether Rate is read-only\n */\n disabled: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description whether picking half start is allowed\n */\n allowHalf: Boolean,\n /**\n * @description whether to display texts\n */\n showText: Boolean,\n /**\n * @description whether to display current score. show-score and show-text cannot be true at the same time\n */\n showScore: Boolean,\n /**\n * @description color of texts\n */\n textColor: {\n type: String,\n default: '',\n },\n /**\n * @description text array\n */\n texts: {\n type: definePropType<string[]>(Array),\n default: () =>\n mutable([\n 'Extremely bad',\n 'Disappointed',\n 'Fair',\n 'Satisfied',\n 'Surprise',\n ] as const),\n },\n /**\n * @description score template\n */\n scoreTemplate: {\n type: String,\n default: '{value}',\n },\n /**\n * @description size of Rate\n */\n size: useSizeProp,\n /**\n * @description whether value can be reset to `0`\n */\n clearable: Boolean,\n ...useAriaProps(['ariaLabel']),\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `RateProps` instead.\n */\nexport type RatePropsPublic = ExtractPublicPropTypes<typeof rateProps>\n\nexport const rateEmits = {\n [CHANGE_EVENT]: (value: number) => isNumber(value),\n [UPDATE_MODEL_EVENT]: (value: number) => isNumber(value),\n}\nexport type RateEmits = typeof rateEmits\n\nexport type RateInstance = InstanceType<typeof Rate> & unknown\n"],"names":[],"mappings":";;;;;;;;;AAyGO,MAAM,YAAY,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAIlC,UAAA,EAAY;AAAA,IACV,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,EAAA,EAAI;AAAA,IACF,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,YAAA,EAAc;AAAA,IACZ,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,aAAA,EAAe;AAAA,IACb,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,GAAA,EAAK;AAAA,IACH,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,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