@fountain-ui/core 2.0.0-beta.37 → 2.0.0-beta.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,8 +43,11 @@ const useStyles = function () {
43
43
  function Image(props) {
44
44
  const {
45
45
  alt,
46
+ disableDrag,
47
+ disableLongClick,
46
48
  disableOutline,
47
49
  disablePlaceholder,
50
+ failDependency = [],
48
51
  loading = 'lazy',
49
52
  overlaidChildren,
50
53
  resizeMode = 'cover',
@@ -85,14 +88,18 @@ function Image(props) {
85
88
  uri: size ? `${source.uri}?size=${size}` : source.uri
86
89
  };
87
90
  (0, _react.useEffect)(() => {
88
- setFailed(false);
89
- }, [sourceWithSizeParam.uri]);
91
+ if (failed !== false) {
92
+ setFailed(false);
93
+ }
94
+ }, [...failDependency]);
90
95
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({
91
96
  style: (0, _styles.css)([styles.root, !disableOutline ? styles.outlined : undefined, !disablePlaceholder ? styles.placeholder : undefined, !square ? styles.rounded : undefined, style])
92
97
  }, otherProps), /*#__PURE__*/_react.default.createElement(Placeholder, {
93
98
  failed: failed
94
99
  }, !failed ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ImageCore.default, {
95
100
  alt: alt,
101
+ disableDrag: disableDrag,
102
+ disableLongClick: disableLongClick,
96
103
  height: '100%',
97
104
  loading: loading,
98
105
  onError: handleError,
@@ -1 +1 @@
1
- {"version":3,"names":["useStyles","theme","useTheme","root","rounded","borderRadius","shape","roundness","overflow","placeholder","backgroundColor","palette","paper","grey","outlined","borderWidth","StyleSheet","hairlineWidth","borderStyle","borderColor","Image","props","alt","disableOutline","disablePlaceholder","loading","overlaidChildren","resizeMode","source","style","square","size","onLoad","onError","Placeholder","PlaceholderComponent","otherProps","failed","setFailed","React","useState","styles","handleError","children","sourceWithSizeParam","uri","useEffect","css","undefined","absoluteFill"],"sources":["Image.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { View } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport ImageCore from '../ImageCore';\nimport { css, StyleSheet, useTheme } from '../styles';\nimport type ImageProps from './ImageProps';\nimport { PlaceholderProps } from './ImageProps';\n\ntype ImageStyleKeys =\n | 'root'\n | 'rounded'\n | 'placeholder'\n | 'outlined';\n\ntype ImageStyles = NamedStylesStringUnion<ImageStyleKeys>;\n\nconst useStyles: UseStyles<ImageStyles> = function (): ImageStyles {\n const theme = useTheme();\n\n return {\n root: {},\n rounded: {\n borderRadius: theme.shape.roundness,\n overflow: 'hidden',\n },\n placeholder: {\n backgroundColor: theme.palette.paper.grey,\n },\n outlined: {\n borderWidth: StyleSheet.hairlineWidth,\n borderStyle: 'solid',\n borderColor: theme.palette.paper.grey,\n },\n };\n};\n\nexport default function Image(props: ImageProps) {\n const {\n alt,\n disableOutline,\n disablePlaceholder,\n loading = 'lazy',\n overlaidChildren,\n resizeMode = 'cover',\n source,\n style,\n square = false,\n size,\n onLoad,\n onError,\n Placeholder: PlaceholderComponent,\n ...otherProps\n } = props;\n\n const [failed, setFailed] = React.useState(false);\n\n const styles = useStyles();\n\n const handleError = () => {\n if (onError) {\n onError();\n }\n\n setFailed(true);\n };\n\n const Placeholder = ({\n failed,\n children,\n }: PlaceholderProps) => PlaceholderComponent ? (\n <PlaceholderComponent\n children={children}\n failed={failed}\n />\n ) : children;\n\n const sourceWithSizeParam = {\n ...source,\n uri: size ? `${source.uri}?size=${size}` : source.uri,\n };\n\n useEffect(() => {\n setFailed(false);\n }, [sourceWithSizeParam.uri]);\n\n return (\n <View\n style={css([\n styles.root,\n !disableOutline ? styles.outlined : undefined,\n !disablePlaceholder ? styles.placeholder : undefined,\n !square ? styles.rounded : undefined,\n style,\n ])}\n {...otherProps}\n >\n <Placeholder failed={failed}>\n {!failed ? (\n <React.Fragment>\n <ImageCore\n alt={alt}\n height={'100%'}\n loading={loading}\n onError={handleError}\n onLoad={onLoad}\n resizeMode={resizeMode}\n source={sourceWithSizeParam}\n width={'100%'}\n />\n\n {overlaidChildren ? (\n <View style={StyleSheet.absoluteFill}>\n {overlaidChildren}\n </View>\n ) : null}\n </React.Fragment>\n ) : null}\n </Placeholder>\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;;;;;AAYA,MAAMA,SAAiC,GAAG,YAAyB;EAC/D,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE,EADH;IAEHC,OAAO,EAAE;MACLC,YAAY,EAAEJ,KAAK,CAACK,KAAN,CAAYC,SADrB;MAELC,QAAQ,EAAE;IAFL,CAFN;IAMHC,WAAW,EAAE;MACTC,eAAe,EAAET,KAAK,CAACU,OAAN,CAAcC,KAAd,CAAoBC;IAD5B,CANV;IASHC,QAAQ,EAAE;MACNC,WAAW,EAAEC,kBAAA,CAAWC,aADlB;MAENC,WAAW,EAAE,OAFP;MAGNC,WAAW,EAAElB,KAAK,CAACU,OAAN,CAAcC,KAAd,CAAoBC;IAH3B;EATP,CAAP;AAeH,CAlBD;;AAoBe,SAASO,KAAT,CAAeC,KAAf,EAAkC;EAC7C,MAAM;IACFC,GADE;IAEFC,cAFE;IAGFC,kBAHE;IAIFC,OAAO,GAAG,MAJR;IAKFC,gBALE;IAMFC,UAAU,GAAG,OANX;IAOFC,MAPE;IAQFC,KARE;IASFC,MAAM,GAAG,KATP;IAUFC,IAVE;IAWFC,MAXE;IAYFC,OAZE;IAaFC,WAAW,EAAEC,oBAbX;IAcF,GAAGC;EAdD,IAeFf,KAfJ;;EAiBA,MAAM,CAACgB,MAAD,EAASC,SAAT,IAAsBC,cAAA,CAAMC,QAAN,CAAe,KAAf,CAA5B;;EAEA,MAAMC,MAAM,GAAGzC,SAAS,EAAxB;;EAEA,MAAM0C,WAAW,GAAG,MAAM;IACtB,IAAIT,OAAJ,EAAa;MACTA,OAAO;IACV;;IAE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;EAAxB,GACKvB,gBADL,CADa,GAIb,IAhBR,CADH,GAmBG,IApBR,CAVJ,CADJ;AAmCH;;AAAA"}
1
+ {"version":3,"names":["useStyles","theme","useTheme","root","rounded","borderRadius","shape","roundness","overflow","placeholder","backgroundColor","palette","paper","grey","outlined","borderWidth","StyleSheet","hairlineWidth","borderStyle","borderColor","Image","props","alt","disableDrag","disableLongClick","disableOutline","disablePlaceholder","failDependency","loading","overlaidChildren","resizeMode","source","style","square","size","onLoad","onError","Placeholder","PlaceholderComponent","otherProps","failed","setFailed","React","useState","styles","handleError","children","sourceWithSizeParam","uri","useEffect","css","undefined","absoluteFill"],"sources":["Image.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { View } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport ImageCore from '../ImageCore';\nimport { css, StyleSheet, useTheme } from '../styles';\nimport type ImageProps from './ImageProps';\nimport { PlaceholderProps } from './ImageProps';\n\ntype ImageStyleKeys =\n | 'root'\n | 'rounded'\n | 'placeholder'\n | 'outlined';\n\ntype ImageStyles = NamedStylesStringUnion<ImageStyleKeys>;\n\nconst useStyles: UseStyles<ImageStyles> = function (): ImageStyles {\n const theme = useTheme();\n\n return {\n root: {},\n rounded: {\n borderRadius: theme.shape.roundness,\n overflow: 'hidden',\n },\n placeholder: {\n backgroundColor: theme.palette.paper.grey,\n },\n outlined: {\n borderWidth: StyleSheet.hairlineWidth,\n borderStyle: 'solid',\n borderColor: theme.palette.paper.grey,\n },\n };\n};\n\nexport default function Image(props: ImageProps) {\n const {\n alt,\n disableDrag,\n disableLongClick,\n disableOutline,\n disablePlaceholder,\n failDependency = [],\n loading = 'lazy',\n overlaidChildren,\n resizeMode = 'cover',\n source,\n style,\n square = false,\n size,\n onLoad,\n onError,\n Placeholder: PlaceholderComponent,\n ...otherProps\n } = props;\n\n const [failed, setFailed] = React.useState(false);\n\n const styles = useStyles();\n\n const handleError = () => {\n if (onError) {\n onError();\n }\n\n setFailed(true);\n };\n\n const Placeholder = ({\n failed,\n children,\n }: PlaceholderProps) => PlaceholderComponent ? (\n <PlaceholderComponent\n children={children}\n failed={failed}\n />\n ) : children;\n\n const sourceWithSizeParam = {\n ...source,\n uri: size ? `${source.uri}?size=${size}` : source.uri,\n };\n\n useEffect(() => {\n if (failed !== false) {\n setFailed(false);\n }\n }, [...failDependency]);\n\n return (\n <View\n style={css([\n styles.root,\n !disableOutline ? styles.outlined : undefined,\n !disablePlaceholder ? styles.placeholder : undefined,\n !square ? styles.rounded : undefined,\n style,\n ])}\n {...otherProps}\n >\n <Placeholder failed={failed}>\n {!failed ? (\n <React.Fragment>\n <ImageCore\n alt={alt}\n disableDrag={disableDrag}\n disableLongClick={disableLongClick}\n height={'100%'}\n loading={loading}\n onError={handleError}\n onLoad={onLoad}\n resizeMode={resizeMode}\n source={sourceWithSizeParam}\n width={'100%'}\n />\n\n {overlaidChildren ? (\n <View style={StyleSheet.absoluteFill}>\n {overlaidChildren}\n </View>\n ) : null}\n </React.Fragment>\n ) : null}\n </Placeholder>\n </View>\n );\n};"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;;;;;AAYA,MAAMA,SAAiC,GAAG,YAAyB;EAC/D,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE,EADH;IAEHC,OAAO,EAAE;MACLC,YAAY,EAAEJ,KAAK,CAACK,KAAN,CAAYC,SADrB;MAELC,QAAQ,EAAE;IAFL,CAFN;IAMHC,WAAW,EAAE;MACTC,eAAe,EAAET,KAAK,CAACU,OAAN,CAAcC,KAAd,CAAoBC;IAD5B,CANV;IASHC,QAAQ,EAAE;MACNC,WAAW,EAAEC,kBAAA,CAAWC,aADlB;MAENC,WAAW,EAAE,OAFP;MAGNC,WAAW,EAAElB,KAAK,CAACU,OAAN,CAAcC,KAAd,CAAoBC;IAH3B;EATP,CAAP;AAeH,CAlBD;;AAoBe,SAASO,KAAT,CAAeC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AC9B,QAAzB,GAAoCqC,SAF7B,EAGP,CAACzB,kBAAD,GAAsBkB,MAAM,CAACnC,WAA7B,GAA2C0C,SAHpC,EAIP,CAAClB,MAAD,GAAUW,MAAM,CAACxC,OAAjB,GAA2B+C,SAJpB,EAKPnB,KALO,CAAJ;EADX,GAQQO,UARR,gBAUI,6BAAC,WAAD;IAAa,MAAM,EAAEC;EAArB,GACK,CAACA,MAAD,gBACG,6BAAC,cAAD,CAAO,QAAP,qBACI,6BAAC,kBAAD;IACI,GAAG,EAAElB,GADT;IAEI,WAAW,EAAEC,WAFjB;IAGI,gBAAgB,EAAEC,gBAHtB;IAII,MAAM,EAAE,MAJZ;IAKI,OAAO,EAAEI,OALb;IAMI,OAAO,EAAEiB,WANb;IAOI,MAAM,EAAEV,MAPZ;IAQI,UAAU,EAAEL,UARhB;IASI,MAAM,EAAEiB,mBATZ;IAUI,KAAK,EAAE;EAVX,EADJ,EAcKlB,gBAAgB,gBACb,6BAAC,iBAAD;IAAM,KAAK,EAAEb,kBAAA,CAAWoC;EAAxB,GACKvB,gBADL,CADa,GAIb,IAlBR,CADH,GAqBG,IAtBR,CAVJ,CADJ;AAqCH;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["ImageProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\nimport type { ImageSource, Loading, ResizeMode } from '../ImageCore';\n\nexport interface PlaceholderProps {\n failed: boolean;\n children: React.ReactElement | null;\n}\n\nexport default interface ImageProps extends OverridableComponentProps<ViewProps, {\n /**\n * Indicating the alternate fallback content to be displayed\n * if the image has not been loaded.\n */\n alt?: string;\n\n /**\n * If `true`, the image outline is not rendered.\n * @default false\n */\n disableOutline?: boolean;\n\n /**\n * If `true`, the placeholder is not rendered.\n * @default false\n */\n disablePlaceholder?: boolean;\n\n /**\n * Web only. Loading the document by determining whether to load\n * the image immediately (`eager`) or on an as-needed basis (`lazy`).\n * On React Native, it always works as `lazy`.\n * @default 'lazy'\n */\n loading?: Loading;\n\n /**\n * error event handler\n */\n onError?: () => void;\n\n /**\n * image loaded event handler\n */\n onLoad?: () => void;\n\n /**\n * The children on top this image.\n */\n overlaidChildren?: React.ReactNode;\n\n /**\n * Determines how to resize the image when the frame doesn't match the raw image dimensions.\n * @default 'cover'\n */\n resizeMode?: ResizeMode;\n\n /**\n * The image source.\n */\n source: ImageSource;\n\n /**\n * If `true`, rounded corners are disabled.\n * @default false\n */\n square?: boolean;\n\n /**\n * Image file size.\n * Request image by query string.\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * The Custom image placeholder component with condition.\n */\n Placeholder?: (props: PlaceholderProps) => JSX.Element | null;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["ImageProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\nimport type { ImageSource, Loading, ResizeMode } from '../ImageCore';\n\nexport interface PlaceholderProps {\n failed: boolean;\n children: React.ReactElement | null;\n}\n\nexport default interface ImageProps extends OverridableComponentProps<ViewProps, {\n /**\n * Indicating the alternate fallback content to be displayed\n * if the image has not been loaded.\n */\n alt?: string;\n\n /**\n * Disable drag event for web.\n * @default false\n */\n disableDrag?: boolean,\n\n /**\n * Disable Long click event for web.\n * @default false\n */\n disableLongClick?: boolean,\n\n /**\n * If `true`, the image outline is not rendered.\n * @default false\n */\n disableOutline?: boolean;\n\n /**\n * If `true`, the placeholder is not rendered.\n * @default false\n */\n disablePlaceholder?: boolean;\n\n /**\n * Web only. Loading the document by determining whether to load\n * the image immediately (`eager`) or on an as-needed basis (`lazy`).\n * On React Native, it always works as `lazy`.\n * @default 'lazy'\n */\n loading?: Loading;\n\n /**\n * error event handler\n */\n onError?: () => void;\n\n /**\n * image loaded event handler\n */\n onLoad?: () => void;\n\n /**\n * The children on top this image.\n */\n overlaidChildren?: React.ReactNode;\n\n /**\n * Determines how to resize the image when the frame doesn't match the raw image dimensions.\n * @default 'cover'\n */\n resizeMode?: ResizeMode;\n\n /**\n * The image source.\n */\n source: ImageSource;\n\n /**\n * If `true`, rounded corners are disabled.\n * @default false\n */\n square?: boolean;\n\n /**\n * Image file size.\n * Request image by query string.\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * The Custom image placeholder component with condition.\n */\n Placeholder?: (props: PlaceholderProps) => JSX.Element | null;\n\n /**\n * Dependency array for reset failed value to false.\n * @default []\n */\n failDependency?: Array<any>;\n}> {}"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["ImageCoreProps.ts"],"sourcesContent":["export interface ImageSource {\n uri: string;\n}\n\nexport type ResizeMode = 'cover' | 'contain';\n\nexport type Loading = 'lazy' | 'eager';\n\nexport default interface ImageCoreProps extends Readonly<{\n alt?: string;\n height?: number | string;\n loading: Loading;\n onError?: () => void;\n onLoad?: () => void;\n resizeMode: ResizeMode;\n source: ImageSource;\n width?: number | string;\n}> {}"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["ImageCoreProps.ts"],"sourcesContent":["export interface ImageSource {\n uri: string;\n}\n\nexport type ResizeMode = 'cover' | 'contain';\n\nexport type Loading = 'lazy' | 'eager';\n\nexport default interface ImageCoreProps extends Readonly<{\n alt?: string;\n disableDrag?: boolean,\n disableLongClick?: boolean,\n height?: number | string;\n loading: Loading;\n onError?: () => void;\n onLoad?: () => void;\n resizeMode: ResizeMode;\n source: ImageSource;\n width?: number | string;\n}> {}"],"mappings":""}
@@ -9,9 +9,19 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
+ const preventDragging = () => false;
13
+
14
+ const preventMouseDown = event => {
15
+ if (event.preventDefault) {
16
+ event.preventDefault();
17
+ }
18
+ };
19
+
12
20
  function ImageCore(props) {
13
21
  const {
14
22
  alt,
23
+ disableDrag = false,
24
+ disableLongClick = false,
15
25
  height,
16
26
  loading,
17
27
  onError,
@@ -20,13 +30,20 @@ function ImageCore(props) {
20
30
  source,
21
31
  width
22
32
  } = props;
33
+ const disableLongClickStyle = disableLongClick ? {
34
+ '-webkit-user-select': 'none',
35
+ '-webkit-touch-callout': 'none'
36
+ } : {};
23
37
  const style = {
24
- objectFit: resizeMode
38
+ objectFit: resizeMode,
39
+ ...disableLongClickStyle
25
40
  };
26
41
  return /*#__PURE__*/_react.default.createElement("img", {
27
42
  alt: alt,
28
43
  height: height,
29
44
  loading: loading,
45
+ onDragStart: disableDrag ? preventDragging : undefined,
46
+ onMouseDown: disableDrag ? preventMouseDown : undefined,
30
47
  onError: onError,
31
48
  onLoad: onLoad,
32
49
  src: source.uri,
@@ -1 +1 @@
1
- {"version":3,"names":["ImageCore","props","alt","height","loading","onError","onLoad","resizeMode","source","width","style","objectFit","uri"],"sources":["ImageCoreWeb.tsx"],"sourcesContent":["import React from 'react';\nimport type ImageCoreProps from './ImageCoreProps';\n\nexport default function ImageCore(props: ImageCoreProps) {\n const {\n alt,\n height,\n loading,\n onError,\n onLoad,\n resizeMode,\n source,\n width,\n } = props;\n\n const style = { objectFit: resizeMode };\n\n return (\n <img\n alt={alt}\n height={height}\n loading={loading}\n onError={onError}\n onLoad={onLoad}\n src={source.uri}\n style={style}\n width={width}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;;;AAGe,SAASA,SAAT,CAAmBC,KAAnB,EAA0C;EACrD,MAAM;IACFC,GADE;IAEFC,MAFE;IAGFC,OAHE;IAIFC,OAJE;IAKFC,MALE;IAMFC,UANE;IAOFC,MAPE;IAQFC;EARE,IASFR,KATJ;EAWA,MAAMS,KAAK,GAAG;IAAEC,SAAS,EAAEJ;EAAb,CAAd;EAEA,oBACI;IACI,GAAG,EAAEL,GADT;IAEI,MAAM,EAAEC,MAFZ;IAGI,OAAO,EAAEC,OAHb;IAII,OAAO,EAAEC,OAJb;IAKI,MAAM,EAAEC,MALZ;IAMI,GAAG,EAAEE,MAAM,CAACI,GANhB;IAOI,KAAK,EAAEF,KAPX;IAQI,KAAK,EAAED;EARX,EADJ;AAYH;;AAAA"}
1
+ {"version":3,"names":["preventDragging","preventMouseDown","event","preventDefault","ImageCore","props","alt","disableDrag","disableLongClick","height","loading","onError","onLoad","resizeMode","source","width","disableLongClickStyle","style","objectFit","undefined","uri"],"sources":["ImageCoreWeb.tsx"],"sourcesContent":["import React, { MouseEventHandler } from 'react';\nimport type ImageCoreProps from './ImageCoreProps';\n\nconst preventDragging = () => false;\n\nconst preventMouseDown: MouseEventHandler<HTMLImageElement> = (event) => {\n if (event.preventDefault) {\n event.preventDefault();\n }\n};\n\nexport default function ImageCore(props: ImageCoreProps) {\n const {\n alt,\n disableDrag = false,\n disableLongClick = false,\n height,\n loading,\n onError,\n onLoad,\n resizeMode,\n source,\n width,\n } = props;\n\n const disableLongClickStyle = disableLongClick\n ? {\n '-webkit-user-select': 'none',\n '-webkit-touch-callout': 'none',\n }\n : {};\n\n const style = {\n objectFit: resizeMode,\n ...disableLongClickStyle,\n };\n\n return (\n <img\n alt={alt}\n height={height}\n loading={loading}\n onDragStart={disableDrag ? preventDragging : undefined}\n onMouseDown={disableDrag ? preventMouseDown : undefined}\n onError={onError}\n onLoad={onLoad}\n src={source.uri}\n style={style}\n width={width}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;;;AAGA,MAAMA,eAAe,GAAG,MAAM,KAA9B;;AAEA,MAAMC,gBAAqD,GAAIC,KAAD,IAAW;EACrE,IAAIA,KAAK,CAACC,cAAV,EAA0B;IACtBD,KAAK,CAACC,cAAN;EACH;AACJ,CAJD;;AAMe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;EACrD,MAAM;IACFC,GADE;IAEFC,WAAW,GAAG,KAFZ;IAGFC,gBAAgB,GAAG,KAHjB;IAIFC,MAJE;IAKFC,OALE;IAMFC,OANE;IAOFC,MAPE;IAQFC,UARE;IASFC,MATE;IAUFC;EAVE,IAWFV,KAXJ;EAaA,MAAMW,qBAAqB,GAAGR,gBAAgB,GACxC;IACE,uBAAuB,MADzB;IAEE,yBAAyB;EAF3B,CADwC,GAKxC,EALN;EAOA,MAAMS,KAAK,GAAG;IACVC,SAAS,EAAEL,UADD;IAEV,GAAGG;EAFO,CAAd;EAKA,oBACI;IACI,GAAG,EAAEV,GADT;IAEI,MAAM,EAAEG,MAFZ;IAGI,OAAO,EAAEC,OAHb;IAII,WAAW,EAAEH,WAAW,GAAGP,eAAH,GAAqBmB,SAJjD;IAKI,WAAW,EAAEZ,WAAW,GAAGN,gBAAH,GAAsBkB,SALlD;IAMI,OAAO,EAAER,OANb;IAOI,MAAM,EAAEC,MAPZ;IAQI,GAAG,EAAEE,MAAM,CAACM,GARhB;IASI,KAAK,EAAEH,KATX;IAUI,KAAK,EAAEF;EAVX,EADJ;AAcH;;AAAA"}
@@ -27,8 +27,11 @@ const useStyles = function () {
27
27
  export default function Image(props) {
28
28
  const {
29
29
  alt,
30
+ disableDrag,
31
+ disableLongClick,
30
32
  disableOutline,
31
33
  disablePlaceholder,
34
+ failDependency = [],
32
35
  loading = 'lazy',
33
36
  overlaidChildren,
34
37
  resizeMode = 'cover',
@@ -67,14 +70,18 @@ export default function Image(props) {
67
70
  uri: size ? `${source.uri}?size=${size}` : source.uri
68
71
  };
69
72
  useEffect(() => {
70
- setFailed(false);
71
- }, [sourceWithSizeParam.uri]);
73
+ if (failed !== false) {
74
+ setFailed(false);
75
+ }
76
+ }, [...failDependency]);
72
77
  return /*#__PURE__*/React.createElement(View, _extends({
73
78
  style: css([styles.root, !disableOutline ? styles.outlined : undefined, !disablePlaceholder ? styles.placeholder : undefined, !square ? styles.rounded : undefined, style])
74
79
  }, otherProps), /*#__PURE__*/React.createElement(Placeholder, {
75
80
  failed: failed
76
81
  }, !failed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ImageCore, {
77
82
  alt: alt,
83
+ disableDrag: disableDrag,
84
+ disableLongClick: disableLongClick,
78
85
  height: '100%',
79
86
  loading: loading,
80
87
  onError: handleError,
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","View","ImageCore","css","StyleSheet","useTheme","useStyles","theme","root","rounded","borderRadius","shape","roundness","overflow","placeholder","backgroundColor","palette","paper","grey","outlined","borderWidth","hairlineWidth","borderStyle","borderColor","Image","props","alt","disableOutline","disablePlaceholder","loading","overlaidChildren","resizeMode","source","style","square","size","onLoad","onError","Placeholder","PlaceholderComponent","otherProps","failed","setFailed","useState","styles","handleError","children","sourceWithSizeParam","uri","undefined","absoluteFill"],"sources":["Image.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { View } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport ImageCore from '../ImageCore';\nimport { css, StyleSheet, useTheme } from '../styles';\nimport type ImageProps from './ImageProps';\nimport { PlaceholderProps } from './ImageProps';\n\ntype ImageStyleKeys =\n | 'root'\n | 'rounded'\n | 'placeholder'\n | 'outlined';\n\ntype ImageStyles = NamedStylesStringUnion<ImageStyleKeys>;\n\nconst useStyles: UseStyles<ImageStyles> = function (): ImageStyles {\n const theme = useTheme();\n\n return {\n root: {},\n rounded: {\n borderRadius: theme.shape.roundness,\n overflow: 'hidden',\n },\n placeholder: {\n backgroundColor: theme.palette.paper.grey,\n },\n outlined: {\n borderWidth: StyleSheet.hairlineWidth,\n borderStyle: 'solid',\n borderColor: theme.palette.paper.grey,\n },\n };\n};\n\nexport default function Image(props: ImageProps) {\n const {\n alt,\n disableOutline,\n disablePlaceholder,\n loading = 'lazy',\n overlaidChildren,\n resizeMode = 'cover',\n source,\n style,\n square = false,\n size,\n onLoad,\n onError,\n Placeholder: PlaceholderComponent,\n ...otherProps\n } = props;\n\n const [failed, setFailed] = React.useState(false);\n\n const styles = useStyles();\n\n const handleError = () => {\n if (onError) {\n onError();\n }\n\n setFailed(true);\n };\n\n const Placeholder = ({\n failed,\n children,\n }: PlaceholderProps) => PlaceholderComponent ? (\n <PlaceholderComponent\n children={children}\n failed={failed}\n />\n ) : children;\n\n const sourceWithSizeParam = {\n ...source,\n uri: size ? `${source.uri}?size=${size}` : source.uri,\n };\n\n useEffect(() => {\n setFailed(false);\n }, [sourceWithSizeParam.uri]);\n\n return (\n <View\n style={css([\n styles.root,\n !disableOutline ? styles.outlined : undefined,\n !disablePlaceholder ? styles.placeholder : undefined,\n !square ? styles.rounded : undefined,\n style,\n ])}\n {...otherProps}\n >\n <Placeholder failed={failed}>\n {!failed ? (\n <React.Fragment>\n <ImageCore\n alt={alt}\n height={'100%'}\n loading={loading}\n onError={handleError}\n onLoad={onLoad}\n resizeMode={resizeMode}\n source={sourceWithSizeParam}\n width={'100%'}\n />\n\n {overlaidChildren ? (\n <View style={StyleSheet.absoluteFill}>\n {overlaidChildren}\n </View>\n ) : null}\n </React.Fragment>\n ) : null}\n </Placeholder>\n </View>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,OAAOC,SAAP,MAAsB,cAAtB;AACA,SAASC,GAAT,EAAcC,UAAd,EAA0BC,QAA1B,QAA0C,WAA1C;;AAYA,MAAMC,SAAiC,GAAG,YAAyB;EAC/D,MAAMC,KAAK,GAAGF,QAAQ,EAAtB;EAEA,OAAO;IACHG,IAAI,EAAE,EADH;IAEHC,OAAO,EAAE;MACLC,YAAY,EAAEH,KAAK,CAACI,KAAN,CAAYC,SADrB;MAELC,QAAQ,EAAE;IAFL,CAFN;IAMHC,WAAW,EAAE;MACTC,eAAe,EAAER,KAAK,CAACS,OAAN,CAAcC,KAAd,CAAoBC;IAD5B,CANV;IASHC,QAAQ,EAAE;MACNC,WAAW,EAAEhB,UAAU,CAACiB,aADlB;MAENC,WAAW,EAAE,OAFP;MAGNC,WAAW,EAAEhB,KAAK,CAACS,OAAN,CAAcC,KAAd,CAAoBC;IAH3B;EATP,CAAP;AAeH,CAlBD;;AAoBA,eAAe,SAASM,KAAT,CAAeC,KAAf,E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,GAAUU,MAAM,CAACnC,OAAjB,GAA2BwC,SAJpB,EAKPhB,KALO,CAAD;EADd,GAQQO,UARR,gBAUI,oBAAC,WAAD;IAAa,MAAM,EAAEC;EAArB,GACK,CAACA,MAAD,gBACG,oBAAC,KAAD,CAAO,QAAP,qBACI,oBAAC,SAAD;IACI,GAAG,EAAEf,GADT;IAEI,MAAM,EAAE,MAFZ;IAGI,OAAO,EAAEG,OAHb;IAII,OAAO,EAAEgB,WAJb;IAKI,MAAM,EAAET,MALZ;IAMI,UAAU,EAAEL,UANhB;IAOI,MAAM,EAAEgB,mBAPZ;IAQI,KAAK,EAAE;EARX,EADJ,EAYKjB,gBAAgB,gBACb,oBAAC,IAAD;IAAM,KAAK,EAAE1B,UAAU,CAAC8C;EAAxB,GACKpB,gBADL,CADa,GAIb,IAhBR,CADH,GAmBG,IApBR,CAVJ,CADJ;AAmCH;AAAA"}
1
+ {"version":3,"names":["React","useEffect","View","ImageCore","css","StyleSheet","useTheme","useStyles","theme","root","rounded","borderRadius","shape","roundness","overflow","placeholder","backgroundColor","palette","paper","grey","outlined","borderWidth","hairlineWidth","borderStyle","borderColor","Image","props","alt","disableDrag","disableLongClick","disableOutline","disablePlaceholder","failDependency","loading","overlaidChildren","resizeMode","source","style","square","size","onLoad","onError","Placeholder","PlaceholderComponent","otherProps","failed","setFailed","useState","styles","handleError","children","sourceWithSizeParam","uri","undefined","absoluteFill"],"sources":["Image.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { View } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport ImageCore from '../ImageCore';\nimport { css, StyleSheet, useTheme } from '../styles';\nimport type ImageProps from './ImageProps';\nimport { PlaceholderProps } from './ImageProps';\n\ntype ImageStyleKeys =\n | 'root'\n | 'rounded'\n | 'placeholder'\n | 'outlined';\n\ntype ImageStyles = NamedStylesStringUnion<ImageStyleKeys>;\n\nconst useStyles: UseStyles<ImageStyles> = function (): ImageStyles {\n const theme = useTheme();\n\n return {\n root: {},\n rounded: {\n borderRadius: theme.shape.roundness,\n overflow: 'hidden',\n },\n placeholder: {\n backgroundColor: theme.palette.paper.grey,\n },\n outlined: {\n borderWidth: StyleSheet.hairlineWidth,\n borderStyle: 'solid',\n borderColor: theme.palette.paper.grey,\n },\n };\n};\n\nexport default function Image(props: ImageProps) {\n const {\n alt,\n disableDrag,\n disableLongClick,\n disableOutline,\n disablePlaceholder,\n failDependency = [],\n loading = 'lazy',\n overlaidChildren,\n resizeMode = 'cover',\n source,\n style,\n square = false,\n size,\n onLoad,\n onError,\n Placeholder: PlaceholderComponent,\n ...otherProps\n } = props;\n\n const [failed, setFailed] = React.useState(false);\n\n const styles = useStyles();\n\n const handleError = () => {\n if (onError) {\n onError();\n }\n\n setFailed(true);\n };\n\n const Placeholder = ({\n failed,\n children,\n }: PlaceholderProps) => PlaceholderComponent ? (\n <PlaceholderComponent\n children={children}\n failed={failed}\n />\n ) : children;\n\n const sourceWithSizeParam = {\n ...source,\n uri: size ? `${source.uri}?size=${size}` : source.uri,\n };\n\n useEffect(() => {\n if (failed !== false) {\n setFailed(false);\n }\n }, [...failDependency]);\n\n return (\n <View\n style={css([\n styles.root,\n !disableOutline ? styles.outlined : undefined,\n !disablePlaceholder ? styles.placeholder : undefined,\n !square ? styles.rounded : undefined,\n style,\n ])}\n {...otherProps}\n >\n <Placeholder failed={failed}>\n {!failed ? (\n <React.Fragment>\n <ImageCore\n alt={alt}\n disableDrag={disableDrag}\n disableLongClick={disableLongClick}\n height={'100%'}\n loading={loading}\n onError={handleError}\n onLoad={onLoad}\n resizeMode={resizeMode}\n source={sourceWithSizeParam}\n width={'100%'}\n />\n\n {overlaidChildren ? (\n <View style={StyleSheet.absoluteFill}>\n {overlaidChildren}\n </View>\n ) : null}\n </React.Fragment>\n ) : null}\n </Placeholder>\n </View>\n );\n};"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,IAAT,QAAq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UAAU,CAACiD;EAAxB,GACKpB,gBADL,CADa,GAIb,IAlBR,CADH,GAqBG,IAtBR,CAVJ,CADJ;AAqCH;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["ImageProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\nimport type { ImageSource, Loading, ResizeMode } from '../ImageCore';\n\nexport interface PlaceholderProps {\n failed: boolean;\n children: React.ReactElement | null;\n}\n\nexport default interface ImageProps extends OverridableComponentProps<ViewProps, {\n /**\n * Indicating the alternate fallback content to be displayed\n * if the image has not been loaded.\n */\n alt?: string;\n\n /**\n * If `true`, the image outline is not rendered.\n * @default false\n */\n disableOutline?: boolean;\n\n /**\n * If `true`, the placeholder is not rendered.\n * @default false\n */\n disablePlaceholder?: boolean;\n\n /**\n * Web only. Loading the document by determining whether to load\n * the image immediately (`eager`) or on an as-needed basis (`lazy`).\n * On React Native, it always works as `lazy`.\n * @default 'lazy'\n */\n loading?: Loading;\n\n /**\n * error event handler\n */\n onError?: () => void;\n\n /**\n * image loaded event handler\n */\n onLoad?: () => void;\n\n /**\n * The children on top this image.\n */\n overlaidChildren?: React.ReactNode;\n\n /**\n * Determines how to resize the image when the frame doesn't match the raw image dimensions.\n * @default 'cover'\n */\n resizeMode?: ResizeMode;\n\n /**\n * The image source.\n */\n source: ImageSource;\n\n /**\n * If `true`, rounded corners are disabled.\n * @default false\n */\n square?: boolean;\n\n /**\n * Image file size.\n * Request image by query string.\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * The Custom image placeholder component with condition.\n */\n Placeholder?: (props: PlaceholderProps) => JSX.Element | null;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["ImageProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\nimport type { ImageSource, Loading, ResizeMode } from '../ImageCore';\n\nexport interface PlaceholderProps {\n failed: boolean;\n children: React.ReactElement | null;\n}\n\nexport default interface ImageProps extends OverridableComponentProps<ViewProps, {\n /**\n * Indicating the alternate fallback content to be displayed\n * if the image has not been loaded.\n */\n alt?: string;\n\n /**\n * Disable drag event for web.\n * @default false\n */\n disableDrag?: boolean,\n\n /**\n * Disable Long click event for web.\n * @default false\n */\n disableLongClick?: boolean,\n\n /**\n * If `true`, the image outline is not rendered.\n * @default false\n */\n disableOutline?: boolean;\n\n /**\n * If `true`, the placeholder is not rendered.\n * @default false\n */\n disablePlaceholder?: boolean;\n\n /**\n * Web only. Loading the document by determining whether to load\n * the image immediately (`eager`) or on an as-needed basis (`lazy`).\n * On React Native, it always works as `lazy`.\n * @default 'lazy'\n */\n loading?: Loading;\n\n /**\n * error event handler\n */\n onError?: () => void;\n\n /**\n * image loaded event handler\n */\n onLoad?: () => void;\n\n /**\n * The children on top this image.\n */\n overlaidChildren?: React.ReactNode;\n\n /**\n * Determines how to resize the image when the frame doesn't match the raw image dimensions.\n * @default 'cover'\n */\n resizeMode?: ResizeMode;\n\n /**\n * The image source.\n */\n source: ImageSource;\n\n /**\n * If `true`, rounded corners are disabled.\n * @default false\n */\n square?: boolean;\n\n /**\n * Image file size.\n * Request image by query string.\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * The Custom image placeholder component with condition.\n */\n Placeholder?: (props: PlaceholderProps) => JSX.Element | null;\n\n /**\n * Dependency array for reset failed value to false.\n * @default []\n */\n failDependency?: Array<any>;\n}> {}"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["ImageCoreProps.ts"],"sourcesContent":["export interface ImageSource {\n uri: string;\n}\n\nexport type ResizeMode = 'cover' | 'contain';\n\nexport type Loading = 'lazy' | 'eager';\n\nexport default interface ImageCoreProps extends Readonly<{\n alt?: string;\n height?: number | string;\n loading: Loading;\n onError?: () => void;\n onLoad?: () => void;\n resizeMode: ResizeMode;\n source: ImageSource;\n width?: number | string;\n}> {}"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["ImageCoreProps.ts"],"sourcesContent":["export interface ImageSource {\n uri: string;\n}\n\nexport type ResizeMode = 'cover' | 'contain';\n\nexport type Loading = 'lazy' | 'eager';\n\nexport default interface ImageCoreProps extends Readonly<{\n alt?: string;\n disableDrag?: boolean,\n disableLongClick?: boolean,\n height?: number | string;\n loading: Loading;\n onError?: () => void;\n onLoad?: () => void;\n resizeMode: ResizeMode;\n source: ImageSource;\n width?: number | string;\n}> {}"],"mappings":""}
@@ -1,7 +1,18 @@
1
1
  import React from 'react';
2
+
3
+ const preventDragging = () => false;
4
+
5
+ const preventMouseDown = event => {
6
+ if (event.preventDefault) {
7
+ event.preventDefault();
8
+ }
9
+ };
10
+
2
11
  export default function ImageCore(props) {
3
12
  const {
4
13
  alt,
14
+ disableDrag = false,
15
+ disableLongClick = false,
5
16
  height,
6
17
  loading,
7
18
  onError,
@@ -10,13 +21,20 @@ export default function ImageCore(props) {
10
21
  source,
11
22
  width
12
23
  } = props;
24
+ const disableLongClickStyle = disableLongClick ? {
25
+ '-webkit-user-select': 'none',
26
+ '-webkit-touch-callout': 'none'
27
+ } : {};
13
28
  const style = {
14
- objectFit: resizeMode
29
+ objectFit: resizeMode,
30
+ ...disableLongClickStyle
15
31
  };
16
32
  return /*#__PURE__*/React.createElement("img", {
17
33
  alt: alt,
18
34
  height: height,
19
35
  loading: loading,
36
+ onDragStart: disableDrag ? preventDragging : undefined,
37
+ onMouseDown: disableDrag ? preventMouseDown : undefined,
20
38
  onError: onError,
21
39
  onLoad: onLoad,
22
40
  src: source.uri,
@@ -1 +1 @@
1
- {"version":3,"names":["React","ImageCore","props","alt","height","loading","onError","onLoad","resizeMode","source","width","style","objectFit","uri"],"sources":["ImageCoreWeb.tsx"],"sourcesContent":["import React from 'react';\nimport type ImageCoreProps from './ImageCoreProps';\n\nexport default function ImageCore(props: ImageCoreProps) {\n const {\n alt,\n height,\n loading,\n onError,\n onLoad,\n resizeMode,\n source,\n width,\n } = props;\n\n const style = { objectFit: resizeMode };\n\n return (\n <img\n alt={alt}\n height={height}\n loading={loading}\n onError={onError}\n onLoad={onLoad}\n src={source.uri}\n style={style}\n width={width}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,eAAe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;EACrD,MAAM;IACFC,GADE;IAEFC,MAFE;IAGFC,OAHE;IAIFC,OAJE;IAKFC,MALE;IAMFC,UANE;IAOFC,MAPE;IAQFC;EARE,IASFR,KATJ;EAWA,MAAMS,KAAK,GAAG;IAAEC,SAAS,EAAEJ;EAAb,CAAd;EAEA,oBACI;IACI,GAAG,EAAEL,GADT;IAEI,MAAM,EAAEC,MAFZ;IAGI,OAAO,EAAEC,OAHb;IAII,OAAO,EAAEC,OAJb;IAKI,MAAM,EAAEC,MALZ;IAMI,GAAG,EAAEE,MAAM,CAACI,GANhB;IAOI,KAAK,EAAEF,KAPX;IAQI,KAAK,EAAED;EARX,EADJ;AAYH;AAAA"}
1
+ {"version":3,"names":["React","preventDragging","preventMouseDown","event","preventDefault","ImageCore","props","alt","disableDrag","disableLongClick","height","loading","onError","onLoad","resizeMode","source","width","disableLongClickStyle","style","objectFit","undefined","uri"],"sources":["ImageCoreWeb.tsx"],"sourcesContent":["import React, { MouseEventHandler } from 'react';\nimport type ImageCoreProps from './ImageCoreProps';\n\nconst preventDragging = () => false;\n\nconst preventMouseDown: MouseEventHandler<HTMLImageElement> = (event) => {\n if (event.preventDefault) {\n event.preventDefault();\n }\n};\n\nexport default function ImageCore(props: ImageCoreProps) {\n const {\n alt,\n disableDrag = false,\n disableLongClick = false,\n height,\n loading,\n onError,\n onLoad,\n resizeMode,\n source,\n width,\n } = props;\n\n const disableLongClickStyle = disableLongClick\n ? {\n '-webkit-user-select': 'none',\n '-webkit-touch-callout': 'none',\n }\n : {};\n\n const style = {\n objectFit: resizeMode,\n ...disableLongClickStyle,\n };\n\n return (\n <img\n alt={alt}\n height={height}\n loading={loading}\n onDragStart={disableDrag ? preventDragging : undefined}\n onMouseDown={disableDrag ? preventMouseDown : undefined}\n onError={onError}\n onLoad={onLoad}\n src={source.uri}\n style={style}\n width={width}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAyC,OAAzC;;AAGA,MAAMC,eAAe,GAAG,MAAM,KAA9B;;AAEA,MAAMC,gBAAqD,GAAIC,KAAD,IAAW;EACrE,IAAIA,KAAK,CAACC,cAAV,EAA0B;IACtBD,KAAK,CAACC,cAAN;EACH;AACJ,CAJD;;AAMA,eAAe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;EACrD,MAAM;IACFC,GADE;IAEFC,WAAW,GAAG,KAFZ;IAGFC,gBAAgB,GAAG,KAHjB;IAIFC,MAJE;IAKFC,OALE;IAMFC,OANE;IAOFC,MAPE;IAQFC,UARE;IASFC,MATE;IAUFC;EAVE,IAWFV,KAXJ;EAaA,MAAMW,qBAAqB,GAAGR,gBAAgB,GACxC;IACE,uBAAuB,MADzB;IAEE,yBAAyB;EAF3B,CADwC,GAKxC,EALN;EAOA,MAAMS,KAAK,GAAG;IACVC,SAAS,EAAEL,UADD;IAEV,GAAGG;EAFO,CAAd;EAKA,oBACI;IACI,GAAG,EAAEV,GADT;IAEI,MAAM,EAAEG,MAFZ;IAGI,OAAO,EAAEC,OAHb;IAII,WAAW,EAAEH,WAAW,GAAGP,eAAH,GAAqBmB,SAJjD;IAKI,WAAW,EAAEZ,WAAW,GAAGN,gBAAH,GAAsBkB,SALlD;IAMI,OAAO,EAAER,OANb;IAOI,MAAM,EAAEC,MAPZ;IAQI,GAAG,EAAEE,MAAM,CAACM,GARhB;IASI,KAAK,EAAEH,KATX;IAUI,KAAK,EAAEF;EAVX,EADJ;AAcH;AAAA"}
@@ -12,6 +12,16 @@ export default interface ImageProps extends OverridableComponentProps<ViewProps,
12
12
  * if the image has not been loaded.
13
13
  */
14
14
  alt?: string;
15
+ /**
16
+ * Disable drag event for web.
17
+ * @default false
18
+ */
19
+ disableDrag?: boolean;
20
+ /**
21
+ * Disable Long click event for web.
22
+ * @default false
23
+ */
24
+ disableLongClick?: boolean;
15
25
  /**
16
26
  * If `true`, the image outline is not rendered.
17
27
  * @default false
@@ -64,5 +74,10 @@ export default interface ImageProps extends OverridableComponentProps<ViewProps,
64
74
  * The Custom image placeholder component with condition.
65
75
  */
66
76
  Placeholder?: (props: PlaceholderProps) => JSX.Element | null;
77
+ /**
78
+ * Dependency array for reset failed value to false.
79
+ * @default []
80
+ */
81
+ failDependency?: Array<any>;
67
82
  }> {
68
83
  }
@@ -5,6 +5,8 @@ export declare type ResizeMode = 'cover' | 'contain';
5
5
  export declare type Loading = 'lazy' | 'eager';
6
6
  export default interface ImageCoreProps extends Readonly<{
7
7
  alt?: string;
8
+ disableDrag?: boolean;
9
+ disableLongClick?: boolean;
8
10
  height?: number | string;
9
11
  loading: Loading;
10
12
  onError?: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fountain-ui/core",
3
- "version": "2.0.0-beta.37",
3
+ "version": "2.0.0-beta.39",
4
4
  "author": "Fountain-UI Team",
5
5
  "description": "React components that implement Tappytoon's Fountain Design.",
6
6
  "license": "MIT",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "0c9f01b22179356577219f06bc6a21f6eb3f554c"
70
+ "gitHead": "44aa49c39c8a9f0986b9d12e06a8a2cfc3766ed9"
71
71
  }
@@ -37,8 +37,11 @@ const useStyles: UseStyles<ImageStyles> = function (): ImageStyles {
37
37
  export default function Image(props: ImageProps) {
38
38
  const {
39
39
  alt,
40
+ disableDrag,
41
+ disableLongClick,
40
42
  disableOutline,
41
43
  disablePlaceholder,
44
+ failDependency = [],
42
45
  loading = 'lazy',
43
46
  overlaidChildren,
44
47
  resizeMode = 'cover',
@@ -80,8 +83,10 @@ export default function Image(props: ImageProps) {
80
83
  };
81
84
 
82
85
  useEffect(() => {
83
- setFailed(false);
84
- }, [sourceWithSizeParam.uri]);
86
+ if (failed !== false) {
87
+ setFailed(false);
88
+ }
89
+ }, [...failDependency]);
85
90
 
86
91
  return (
87
92
  <View
@@ -99,6 +104,8 @@ export default function Image(props: ImageProps) {
99
104
  <React.Fragment>
100
105
  <ImageCore
101
106
  alt={alt}
107
+ disableDrag={disableDrag}
108
+ disableLongClick={disableLongClick}
102
109
  height={'100%'}
103
110
  loading={loading}
104
111
  onError={handleError}
@@ -118,4 +125,4 @@ export default function Image(props: ImageProps) {
118
125
  </Placeholder>
119
126
  </View>
120
127
  );
121
- };
128
+ };
@@ -15,6 +15,18 @@ export default interface ImageProps extends OverridableComponentProps<ViewProps,
15
15
  */
16
16
  alt?: string;
17
17
 
18
+ /**
19
+ * Disable drag event for web.
20
+ * @default false
21
+ */
22
+ disableDrag?: boolean,
23
+
24
+ /**
25
+ * Disable Long click event for web.
26
+ * @default false
27
+ */
28
+ disableLongClick?: boolean,
29
+
18
30
  /**
19
31
  * If `true`, the image outline is not rendered.
20
32
  * @default false
@@ -77,4 +89,10 @@ export default interface ImageProps extends OverridableComponentProps<ViewProps,
77
89
  * The Custom image placeholder component with condition.
78
90
  */
79
91
  Placeholder?: (props: PlaceholderProps) => JSX.Element | null;
80
- }> {}
92
+
93
+ /**
94
+ * Dependency array for reset failed value to false.
95
+ * @default []
96
+ */
97
+ failDependency?: Array<any>;
98
+ }> {}
@@ -8,6 +8,8 @@ export type Loading = 'lazy' | 'eager';
8
8
 
9
9
  export default interface ImageCoreProps extends Readonly<{
10
10
  alt?: string;
11
+ disableDrag?: boolean,
12
+ disableLongClick?: boolean,
11
13
  height?: number | string;
12
14
  loading: Loading;
13
15
  onError?: () => void;
@@ -1,9 +1,19 @@
1
- import React from 'react';
1
+ import React, { MouseEventHandler } from 'react';
2
2
  import type ImageCoreProps from './ImageCoreProps';
3
3
 
4
+ const preventDragging = () => false;
5
+
6
+ const preventMouseDown: MouseEventHandler<HTMLImageElement> = (event) => {
7
+ if (event.preventDefault) {
8
+ event.preventDefault();
9
+ }
10
+ };
11
+
4
12
  export default function ImageCore(props: ImageCoreProps) {
5
13
  const {
6
14
  alt,
15
+ disableDrag = false,
16
+ disableLongClick = false,
7
17
  height,
8
18
  loading,
9
19
  onError,
@@ -13,13 +23,25 @@ export default function ImageCore(props: ImageCoreProps) {
13
23
  width,
14
24
  } = props;
15
25
 
16
- const style = { objectFit: resizeMode };
26
+ const disableLongClickStyle = disableLongClick
27
+ ? {
28
+ '-webkit-user-select': 'none',
29
+ '-webkit-touch-callout': 'none',
30
+ }
31
+ : {};
32
+
33
+ const style = {
34
+ objectFit: resizeMode,
35
+ ...disableLongClickStyle,
36
+ };
17
37
 
18
38
  return (
19
39
  <img
20
40
  alt={alt}
21
41
  height={height}
22
42
  loading={loading}
43
+ onDragStart={disableDrag ? preventDragging : undefined}
44
+ onMouseDown={disableDrag ? preventMouseDown : undefined}
23
45
  onError={onError}
24
46
  onLoad={onLoad}
25
47
  src={source.uri}