UNPKG

@ray-js/components

Version:

Ray basic components

44 lines 1.32 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; const _excluded = ["style", "className", "onClick", "onLongClick", "onTouchCancel", "onTouchEnd", "onTouchMove", "onTouchStart", "onLoad", "onError", "mode"]; import clsx from 'clsx'; import * as React from 'react'; import { inlineStyle, useTouch } from '@ray-js/framework-shared'; import { Image as RemaxImage } from '@ray-core/wechat'; const Image = props => { const { style, className, onClick, onLongClick, onTouchCancel, onTouchEnd, onTouchMove, onTouchStart, onLoad, onError, mode = 'scaleToFill' } = props, restProps = _objectWithoutProperties(props, _excluded); const [touching, handlers] = useTouch({ onLongClick, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, onClick }); return /*#__PURE__*/React.createElement(RemaxImage, _extends({ style: inlineStyle(style), className: clsx('ray-image', className), mode: mode, onLoad: e => { onLoad === null || onLoad === void 0 || onLoad({ width: e.detail.width, height: e.detail.height, origin: e }); } }, handlers, restProps)); }; export default Image;