import {designComponent, getComponentCls, iMouseEvent, PropType, useModel} from "@peryl/react-compose"; import {Scroll} from "../Scroll"; import {Box} from "../Box"; import {Icon} from "../Icon"; import {Image} from "../Image"; import './image-selector.scss'; export const ImageSelector = designComponent({ name: 'image-selector', props: { modelValue: { type: [String, Number] }, selectOptions: { type: Array as PropType }, aspectRatio: { type: String, default: '3 / 4' }, imageFit: { type: String, default: 'contain' }, imagePosition: { type: String, default: 'center left' }, }, emits: { onUpdateModelValue: (val?: string | number | null | undefined) => true, onDoubleClickOption: (e: iMouseEvent) => true, }, setup({ props, event: { emit } }) { const model = useModel(() => props.modelValue, emit.onUpdateModelValue); return () => (
{props.selectOptions?.map(item => ( {model.value = item.val;}} onDoubleClick={emit.onDoubleClickOption} >
))}
); }, }); export default ImageSelector; export interface iImageSelectOption { val: string, url: string }