UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 7.25 kB
{"version":3,"file":"color-picker.mjs","sources":["../../../../../../packages/components/color-picker/src/color-picker.ts"],"sourcesContent":["import { isNil } from 'lodash-unified'\nimport { buildProps, definePropType, isString } from '@element-plus/utils'\nimport {\n useAriaProps,\n useEmptyValuesProps,\n useSizeProp,\n} from '@element-plus/hooks'\nimport { useTooltipContentProps } from '@element-plus/components/tooltip'\nimport { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\n\nimport type { ExtractPublicPropTypes } from 'vue'\nimport type ColorPicker from './color-picker.vue'\nimport type { AriaProps, UseEmptyValuesProps } from '@element-plus/hooks'\nimport type { ComponentSize } from '@element-plus/constants'\nimport type { ElTooltipContentProps } from '@element-plus/components/tooltip'\n\nexport interface ColorPickerProps\n extends UseEmptyValuesProps, Pick<AriaProps, 'ariaLabel'> {\n /**\n * @description when color-picker inactive and persistent is false, the color panel will be destroyed\n */\n persistent?: boolean\n /**\n * @description binding value\n */\n modelValue?: string | null\n /**\n * @description ColorPicker id\n */\n id?: string\n /**\n * @description whether to display the alpha slider\n */\n showAlpha?: boolean\n /**\n * @description color format of v-model\n */\n colorFormat?: string\n /**\n * @description whether to disable the ColorPicker\n */\n disabled?: boolean\n /**\n * @description whether to show clear button\n */\n clearable?: boolean\n /**\n * @description size of ColorPicker\n */\n size?: ComponentSize\n /**\n * @description custom class name for ColorPicker's dropdown\n */\n popperClass?: ElTooltipContentProps['popperClass']\n /**\n * @description custom style for ColorPicker's dropdown\n */\n popperStyle?: ElTooltipContentProps['popperStyle']\n /**\n * @description ColorPicker tabindex\n */\n tabindex?: string | number\n /**\n * @description whether color-picker popper is teleported to the body\n */\n teleported?: ElTooltipContentProps['teleported']\n /**\n * @description which color-picker panel appends to\n */\n appendTo?: ElTooltipContentProps['appendTo']\n /**\n * @description predefined color options\n */\n predefine?: string[]\n /**\n * @description whether to trigger form validation\n */\n validateEvent?: boolean\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `ColorPickerProps` instead.\n */\nexport const colorPickerProps = buildProps({\n /**\n * @description when color-picker inactive and persistent is false, the color panel will be destroyed\n */\n persistent: {\n type: Boolean,\n default: true,\n },\n /**\n * @description binding value\n */\n modelValue: {\n type: definePropType<string | null>(String),\n default: undefined,\n },\n /**\n * @description ColorPicker id\n */\n id: String,\n /**\n * @description whether to display the alpha slider\n */\n showAlpha: Boolean,\n /**\n * @description color format of v-model\n */\n colorFormat: String,\n /**\n * @description whether to disable the ColorPicker\n */\n disabled: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description whether to show clear button\n */\n clearable: {\n type: Boolean,\n default: true,\n },\n /**\n * @description size of ColorPicker\n */\n size: useSizeProp,\n /**\n * @description custom class name for ColorPicker's dropdown\n */\n popperClass: useTooltipContentProps.popperClass,\n /**\n * @description custom style for ColorPicker's dropdown\n */\n popperStyle: useTooltipContentProps.popperStyle,\n /**\n * @description ColorPicker tabindex\n */\n tabindex: {\n type: [String, Number],\n default: 0,\n },\n /**\n * @description whether color-picker popper is teleported to the body\n */\n teleported: useTooltipContentProps.teleported,\n /**\n * @description which color-picker panel appends to\n */\n appendTo: useTooltipContentProps.appendTo,\n /**\n * @description predefined color options\n */\n predefine: {\n type: definePropType<string[]>(Array),\n },\n /**\n * @description whether to trigger form validation\n */\n validateEvent: {\n type: Boolean,\n default: true,\n },\n ...useEmptyValuesProps,\n ...useAriaProps(['ariaLabel']),\n} as const)\nexport const colorPickerEmits = {\n [UPDATE_MODEL_EVENT]: (val: string | null) => isString(val) || isNil(val),\n [CHANGE_EVENT]: (val: string | null) => isString(val) || isNil(val),\n activeChange: (val: string | null) => isString(val) || isNil(val),\n focus: (evt: FocusEvent) => evt instanceof FocusEvent,\n blur: (evt: FocusEvent) => evt instanceof FocusEvent,\n clear: () => true,\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `ColorPickerProps` instead.\n */\nexport type ColorPickerPropsPublic = ExtractPublicPropTypes<\n typeof colorPickerProps\n>\nexport type ColorPickerEmits = typeof colorPickerEmits\nexport type ColorPickerInstance = InstanceType<typeof ColorPicker> & unknown\n\n/**\n * @description default values for ColorPickerProps, used in components that extend ColorPickerProps\n */\nexport const colorPickerPropsDefaults = {\n persistent: true,\n modelValue: undefined,\n disabled: undefined,\n clearable: true,\n popperStyle: undefined,\n tabindex: 0,\n teleported: true,\n validateEvent: true,\n valueOnClear: undefined,\n} as const\n"],"names":[],"mappings":";;;;;;;;;AAmFO,MAAM,mBAAmB,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAIzC,UAAA,EAAY;AAAA,IACV,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,UAAA,EAAY;AAAA,IACV,IAAA,EAAM,eAA8B,MAAM,CAAA;AAAA,IAC1C,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,EAAA,EAAI,MAAA;AAAA;AAAA;AAAA;AAAA,EAIJ,SAAA,EAAW,OAAA;AAAA;AAAA;AAAA;AAAA,EAIX,WAAA,EAAa,MAAA;AAAA;AAAA;AAAA;AAAA,EAIb,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,SAAA,EAAW;AAAA,IACT,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,IAAA,EAAM,WAAA;AAAA;AAAA;AAAA;AAAA,EAIN,aAAa,sBAAA,CAAuB,WAAA;AAAA;AAAA;AAAA;AAAA,EAIpC,aAAa,sBAAA,CAAuB,WAAA;AAAA;AAAA;AAAA;AAAA,EAIpC,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,IACrB,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,YAA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