element-plus
Version:
A Component Library for Vue 3
1 lines • 7.86 kB
Source Map (JSON)
{"version":3,"file":"image.mjs","sources":["../../../../../../packages/components/image/src/image.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isNumber,\n mutable,\n} from '@element-plus/utils'\n\nimport type { ExtractPublicPropTypes } from 'vue'\nimport type Image from './image.vue'\n\nexport type ImageFitType =\n | ''\n | 'contain'\n | 'cover'\n | 'fill'\n | 'none'\n | 'scale-down'\nexport type ImageCrossorigin = 'anonymous' | 'use-credentials' | ''\n\nexport interface ImageProps {\n /**\n * @description when enabling preview, use this flag to control whether clicking on backdrop can exit preview mode.\n */\n hideOnClickModal?: boolean\n /**\n * @description image source, same as native.\n */\n src?: string\n /**\n * @description indicate how the image should be resized to fit its container, same as [object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit).\n */\n fit?: ImageFitType\n /**\n * @description Indicates how the browser should load the image, same as [native](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#loading)\n */\n loading?: 'eager' | 'lazy'\n /**\n * @description whether to use lazy load.\n */\n lazy?: boolean\n /**\n * @description the container to add scroll listener when using lazy load.\n */\n scrollContainer?: string | HTMLElement\n /**\n * @description allow big image preview.\n */\n previewSrcList?: string[]\n /**\n * @description whether to append image-viewer to body. A nested parent element attribute transform should have this attribute set to `true`.\n */\n previewTeleported?: boolean\n /**\n * @description set image preview z-index.\n */\n zIndex?: number\n /**\n * @description initial preview image index, less than the length of `url-list`.\n */\n initialIndex?: number\n /**\n * @description whether the viewer preview is infinite.\n */\n infinite?: boolean\n /**\n * @description whether the image-viewer can be closed by pressing ESC.\n */\n closeOnPressEscape?: boolean\n /**\n * @description the zoom rate of the image viewer zoom event\n */\n zoomRate?: number\n /**\n * @description preview image scale.\n */\n scale?: number\n /**\n * @description the min scale of the image viewer zoom event.\n */\n minScale?: number\n /**\n * @description the max scale of the image viewer zoom event.\n */\n maxScale?: number\n /**\n * @description show preview image progress content.\n */\n showProgress?: boolean\n /**\n * @description set HTML attribute: crossorigin.\n */\n crossorigin?: ImageCrossorigin\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `ImageProps` instead.\n */\nexport const imageProps = buildProps({\n /**\n * @description when enabling preview, use this flag to control whether clicking on backdrop can exit preview mode.\n */\n hideOnClickModal: Boolean,\n /**\n * @description image source, same as native.\n */\n src: {\n type: String,\n default: '',\n },\n /**\n * @description indicate how the image should be resized to fit its container, same as [object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit).\n */\n fit: {\n type: String,\n values: ['', 'contain', 'cover', 'fill', 'none', 'scale-down'],\n default: '',\n },\n /**\n * @description Indicates how the browser should load the image, same as [native](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#loading)\n */\n loading: {\n type: String,\n values: ['eager', 'lazy'],\n },\n /**\n * @description whether to use lazy load.\n */\n lazy: Boolean,\n /**\n * @description the container to add scroll listener when using lazy load.\n */\n scrollContainer: {\n type: definePropType<string | HTMLElement | undefined>([String, Object]),\n },\n /**\n * @description allow big image preview.\n */\n previewSrcList: {\n type: definePropType<string[]>(Array),\n default: () => mutable([] as const),\n },\n /**\n * @description whether to append image-viewer to body. A nested parent element attribute transform should have this attribute set to `true`.\n */\n previewTeleported: Boolean,\n /**\n * @description set image preview z-index.\n */\n zIndex: {\n type: Number,\n },\n /**\n * @description initial preview image index, less than the length of `url-list`.\n */\n initialIndex: {\n type: Number,\n default: 0,\n },\n /**\n * @description whether the viewer preview is infinite.\n */\n infinite: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether the image-viewer can be closed by pressing ESC.\n */\n closeOnPressEscape: {\n type: Boolean,\n default: true,\n },\n /**\n * @description the zoom rate of the image viewer zoom event\n */\n zoomRate: {\n type: Number,\n default: 1.2,\n },\n /**\n * @description preview image scale.\n */\n scale: {\n type: Number,\n default: 1,\n },\n /**\n * @description the min scale of the image viewer zoom event.\n */\n minScale: {\n type: Number,\n default: 0.2,\n },\n /**\n * @description the max scale of the image viewer zoom event.\n */\n maxScale: {\n type: Number,\n default: 7,\n },\n /**\n * @description show preview image progress content.\n */\n showProgress: Boolean,\n /**\n * @description set HTML attribute: crossorigin.\n */\n crossorigin: {\n type: definePropType<ImageCrossorigin>(String),\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `ImageProps` instead.\n */\nexport type ImagePropsPublic = ExtractPublicPropTypes<typeof imageProps>\n\nexport const imageEmits = {\n load: (evt: Event) => evt instanceof Event,\n error: (evt: Event) => evt instanceof Event,\n switch: (val: number) => isNumber(val),\n close: () => true,\n show: () => true,\n}\nexport type ImageEmits = typeof imageEmits\nexport type ImageInstance = InstanceType<typeof Image> & unknown\n"],"names":[],"mappings":";;;;AAiGO,MAAM,aAAa,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAInC,gBAAA,EAAkB,OAAA;AAAA;AAAA;AAAA;AAAA,EAIlB,GAAA,EAAK;AAAA,IACH,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,GAAA,EAAK;AAAA,IACH,IAAA,EAAM,MAAA;AAAA,IACN,QAAQ,CAAC,EAAA,EAAI,WAAW,OAAA,EAAS,MAAA,EAAQ,QAAQ,YAAY,CAAA;AAAA,IAC7D,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,MAAA;AAAA,IACN,MAAA,EAAQ,CAAC,OAAA,EAAS,MAAM;AAAA,GAC1B;AAAA;AAAA;AAAA;AAAA,EAIA,IAAA,EAAM,OAAA;AAAA;AAAA;AAAA;AAAA,EAIN,eAAA,EAAiB;AAAA,IACf,IAAA,EAAM,cAAA,CAAiD,CAAC,MAAA,EAAQ,MAAM,CAAC;AAAA,GACzE;AAAA;AAAA;AAAA;AAAA,EAIA,cAAA,EAAgB;AAAA,IACd,IAAA,EAAM,eAAyB,KAAK,CAAA;AAAA,IACpC,OAAA,EAAS,M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