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

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.
Files changed (52) hide show
  1. package/build/commonjs/Image/Image.js +40 -34
  2. package/build/commonjs/Image/Image.js.map +1 -1
  3. package/build/commonjs/Image/ImageProps.js.map +1 -1
  4. package/build/commonjs/Image/index.js.map +1 -1
  5. package/build/commonjs/ImageCore/ImageCoreProps.js.map +1 -1
  6. package/build/commonjs/ImageCore/ImageCoreWeb.js +6 -5
  7. package/build/commonjs/ImageCore/ImageCoreWeb.js.map +1 -1
  8. package/build/commonjs/ImageCore/ImageFileExtensionContext.js +3 -7
  9. package/build/commonjs/ImageCore/ImageFileExtensionContext.js.map +1 -1
  10. package/build/commonjs/ImageCore/ImageFileExtensionProvider.js +2 -2
  11. package/build/commonjs/ImageCore/ImageFileExtensionProvider.js.map +1 -1
  12. package/build/commonjs/ImageCore/index.js +0 -14
  13. package/build/commonjs/ImageCore/index.js.map +1 -1
  14. package/build/commonjs/hooks/index.js +8 -0
  15. package/build/commonjs/hooks/index.js.map +1 -1
  16. package/build/commonjs/hooks/useDebounce.js +33 -0
  17. package/build/commonjs/hooks/useDebounce.js.map +1 -0
  18. package/build/module/Image/Image.js +42 -34
  19. package/build/module/Image/Image.js.map +1 -1
  20. package/build/module/Image/ImageProps.js.map +1 -1
  21. package/build/module/Image/index.js.map +1 -1
  22. package/build/module/ImageCore/ImageCoreProps.js.map +1 -1
  23. package/build/module/ImageCore/ImageCoreWeb.js +5 -5
  24. package/build/module/ImageCore/ImageCoreWeb.js.map +1 -1
  25. package/build/module/ImageCore/ImageFileExtensionContext.js +3 -3
  26. package/build/module/ImageCore/ImageFileExtensionContext.js.map +1 -1
  27. package/build/module/ImageCore/ImageFileExtensionProvider.js +2 -2
  28. package/build/module/ImageCore/ImageFileExtensionProvider.js.map +1 -1
  29. package/build/module/ImageCore/index.js +0 -1
  30. package/build/module/ImageCore/index.js.map +1 -1
  31. package/build/module/hooks/index.js +1 -0
  32. package/build/module/hooks/index.js.map +1 -1
  33. package/build/module/hooks/useDebounce.js +25 -0
  34. package/build/module/hooks/useDebounce.js.map +1 -0
  35. package/build/typescript/Image/ImageProps.d.ts +9 -14
  36. package/build/typescript/Image/index.d.ts +0 -1
  37. package/build/typescript/ImageCore/ImageCoreProps.d.ts +1 -1
  38. package/build/typescript/ImageCore/ImageFileExtensionContext.d.ts +2 -2
  39. package/build/typescript/ImageCore/index.d.ts +1 -1
  40. package/build/typescript/hooks/index.d.ts +1 -0
  41. package/build/typescript/hooks/useDebounce.d.ts +1 -0
  42. package/package.json +2 -2
  43. package/src/Image/Image.tsx +75 -52
  44. package/src/Image/ImageProps.ts +12 -17
  45. package/src/Image/index.ts +1 -2
  46. package/src/ImageCore/ImageCoreProps.ts +1 -1
  47. package/src/ImageCore/ImageCoreWeb.tsx +8 -10
  48. package/src/ImageCore/ImageFileExtensionContext.ts +4 -4
  49. package/src/ImageCore/ImageFileExtensionProvider.tsx +10 -9
  50. package/src/ImageCore/index.ts +2 -2
  51. package/src/hooks/index.ts +1 -0
  52. package/src/hooks/useDebounce.ts +23 -0
@@ -36,10 +36,22 @@ const useStyles = function () {
36
36
  borderWidth: _styles.StyleSheet.hairlineWidth,
37
37
  borderStyle: 'solid',
38
38
  borderColor: theme.palette.paper.grey
39
+ },
40
+ error: {
41
+ width: '100%',
42
+ height: '100%'
39
43
  }
40
44
  };
41
45
  };
42
46
 
47
+ function determinePlaceholderMode(props) {
48
+ if (props.disablePlaceholder) {
49
+ return 'none';
50
+ }
51
+
52
+ return props.placeholder ? 'custom' : 'default';
53
+ }
54
+
43
55
  function Image(props) {
44
56
  const {
45
57
  alt,
@@ -47,69 +59,63 @@ function Image(props) {
47
59
  disableLongClick,
48
60
  disableOutline,
49
61
  disablePlaceholder,
50
- failDependency = [],
62
+ error,
51
63
  loading = 'lazy',
64
+ onError: onErrorProp,
65
+ onLoad: onLoadProp,
52
66
  overlaidChildren,
67
+ placeholder,
53
68
  resizeMode = 'cover',
54
69
  source,
55
70
  style,
56
71
  square = false,
57
72
  size,
58
- onLoad,
59
- onError,
60
- Placeholder: PlaceholderComponent,
61
73
  ...otherProps
62
74
  } = props;
63
-
64
- const [failed, setFailed] = _react.default.useState(false);
65
-
75
+ const [failed, setFailed] = (0, _react.useState)(false);
66
76
  const styles = useStyles();
67
77
 
68
- const handleError = () => {
69
- if (onError) {
70
- onError();
71
- }
72
-
73
- setFailed(true);
78
+ const onLoad = () => {
79
+ setFailed(false);
80
+ onLoadProp === null || onLoadProp === void 0 ? void 0 : onLoadProp();
74
81
  };
75
82
 
76
- const Placeholder = _ref => {
77
- let {
78
- failed,
79
- children
80
- } = _ref;
81
- return PlaceholderComponent ? /*#__PURE__*/_react.default.createElement(PlaceholderComponent, {
82
- children: children,
83
- failed: failed
84
- }) : children;
83
+ const onError = () => {
84
+ setFailed(true);
85
+ onErrorProp === null || onErrorProp === void 0 ? void 0 : onErrorProp();
85
86
  };
86
87
 
87
88
  const sourceWithSizeParam = { ...source,
88
89
  uri: size ? `${source.uri}?size=${size}` : source.uri
89
90
  };
91
+ const placeholderMode = determinePlaceholderMode(props);
90
92
  (0, _react.useEffect)(() => {
91
- if (failed !== false) {
92
- setFailed(false);
93
- }
94
- }, [...failDependency]);
93
+ setFailed(false);
94
+ }, [sourceWithSizeParam.uri]);
95
95
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({
96
- style: (0, _styles.css)([styles.root, !disableOutline ? styles.outlined : undefined, !disablePlaceholder ? styles.placeholder : undefined, !square ? styles.rounded : undefined, style])
97
- }, otherProps), /*#__PURE__*/_react.default.createElement(Placeholder, {
98
- failed: failed
99
- }, !failed ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ImageCore.default, {
100
- alt: alt,
96
+ style: (0, _styles.css)([styles.root, !disableOutline ? styles.outlined : undefined, !square ? styles.rounded : undefined, placeholderMode === 'default' ? styles.placeholder : undefined, style])
97
+ }, otherProps), placeholderMode === 'custom' ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
98
+ style: (0, _styles.css)([_styles.StyleSheet.absoluteFill, {
99
+ zIndex: -1
100
+ }])
101
+ }, placeholder) : null, failed ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
102
+ style: styles.error
103
+ }, error ?? /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
104
+ children: alt
105
+ })) : sourceWithSizeParam.uri ? /*#__PURE__*/_react.default.createElement(_ImageCore.default, {
106
+ alt: sourceWithSizeParam.uri,
101
107
  disableDrag: disableDrag,
102
108
  disableLongClick: disableLongClick,
103
109
  height: '100%',
104
110
  loading: loading,
105
- onError: handleError,
111
+ onError: onError,
106
112
  onLoad: onLoad,
107
113
  resizeMode: resizeMode,
108
114
  source: sourceWithSizeParam,
109
115
  width: '100%'
110
- }), overlaidChildren ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
116
+ }) : null, overlaidChildren ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
111
117
  style: _styles.StyleSheet.absoluteFill
112
- }, overlaidChildren) : null) : null));
118
+ }, overlaidChildren) : null);
113
119
  }
114
120
 
115
121
  ;
@@ -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","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,KAAf,EAAkC;EAC7C,MAAM;IACFC,GADE;IAEFC,WAFE;IAGFC,gBAHE;IAIFC,cAJE;IAKFC,kBALE;IAMFC,cAAc,GAAG,EANf;IAOFC,OAAO,GAAG,MAPR;IAQFC,gBARE;IASFC,UAAU,GAAG,OATX;IAUFC,MAVE;IAWFC,KAXE;IAYFC,MAAM,GAAG,KAZP;IAaFC,IAbE;IAcFC,MAdE;IAeFC,OAfE;IAgBFC,WAAW,EAAEC,oBAhBX;IAiBF,GAAGC;EAjBD,IAkBFlB,KAlBJ;;EAoBA,MAAM,CAACmB,MAAD,EAASC,SAAT,IAAsBC,cAAA,CAAMC,QAAN,CAAe,KAAf,CAA5B;;EAEA,MAAMC,MAAM,GAAG5C,SAAS,EAAxB;;EAEA,MAAM6C,WAAW,GAAG,MAAM;IACtB,IAAIT,OAAJ,EAAa;MACTA,OAAO;I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;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
+ {"version":3,"names":["useStyles","theme","useTheme","root","rounded","borderRadius","shape","roundness","overflow","placeholder","backgroundColor","palette","paper","grey","outlined","borderWidth","StyleSheet","hairlineWidth","borderStyle","borderColor","error","width","height","determinePlaceholderMode","props","disablePlaceholder","Image","alt","disableDrag","disableLongClick","disableOutline","loading","onError","onErrorProp","onLoad","onLoadProp","overlaidChildren","resizeMode","source","style","square","size","otherProps","failed","setFailed","useState","styles","sourceWithSizeParam","uri","placeholderMode","useEffect","css","undefined","absoluteFill","zIndex"],"sources":["Image.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { Text, View } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport type { ImageCoreProps } from '../ImageCore';\nimport ImageCore from '../ImageCore';\nimport { css, StyleSheet, useTheme } from '../styles';\nimport type ImageProps from './ImageProps';\n\ntype PlaceholderMode =\n | 'default'\n | 'custom'\n | 'none';\n\ntype ImageStyleKeys =\n | 'root'\n | 'rounded'\n | 'placeholder'\n | 'outlined'\n | 'error';\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 error: {\n width: '100%',\n height: '100%',\n },\n };\n};\n\nfunction determinePlaceholderMode(props: ImageProps): PlaceholderMode {\n if (props.disablePlaceholder) {\n return 'none';\n }\n\n return props.placeholder ? 'custom' : 'default';\n}\n\nexport default function Image(props: ImageProps) {\n const {\n alt,\n disableDrag,\n disableLongClick,\n disableOutline,\n disablePlaceholder,\n error,\n loading = 'lazy',\n onError: onErrorProp,\n onLoad: onLoadProp,\n overlaidChildren,\n placeholder,\n resizeMode = 'cover',\n source,\n style,\n square = false,\n size,\n ...otherProps\n } = props;\n\n const [failed, setFailed] = useState(false);\n\n const styles = useStyles();\n\n const onLoad: ImageCoreProps['onLoad'] = () => {\n setFailed(false);\n\n onLoadProp?.();\n };\n\n const onError: ImageCoreProps['onError'] = () => {\n setFailed(true);\n\n onErrorProp?.();\n };\n\n const sourceWithSizeParam = {\n ...source,\n uri: size ? `${source.uri}?size=${size}` : source.uri,\n };\n\n const placeholderMode = determinePlaceholderMode(props);\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 !square ? styles.rounded : undefined,\n placeholderMode === 'default' ? styles.placeholder : undefined,\n style,\n ])}\n {...otherProps}\n >\n {placeholderMode === 'custom' ? (\n <View\n style={css([\n StyleSheet.absoluteFill,\n { zIndex: -1 },\n ])}\n >\n {placeholder}\n </View>\n ) : null}\n\n {failed ? (\n <View style={styles.error}>\n {error ?? <Text children={alt}/>}\n </View>\n ) : sourceWithSizeParam.uri ? (\n <ImageCore\n alt={sourceWithSizeParam.uri}\n disableDrag={disableDrag}\n disableLongClick={disableLongClick}\n height={'100%'}\n loading={loading}\n onError={onError}\n onLoad={onLoad}\n resizeMode={resizeMode}\n source={sourceWithSizeParam}\n width={'100%'}\n />\n ) : null}\n\n {overlaidChildren ? (\n <View style={StyleSheet.absoluteFill}>\n {overlaidChildren}\n </View>\n ) : null}\n </View>\n );\n};"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;AACA;;;;;;;;;;AAiBA,MAAMA,SAAiC,GAAG,YAAyB;EAC/D,MAAMC,KAAK,GAAG,IAAAC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,GAAG,EAAED,mBAAmB,CAACC,GAD7B;IAEI,WAAW,EAAEpB,WAFjB;IAGI,gBAAgB,EAAEC,gBAHtB;IAII,MAAM,EAAE,MAJZ;IAKI,OAAO,EAAEE,OALb;IAMI,OAAO,EAAEC,OANb;IAOI,MAAM,EAAEE,MAPZ;IAQI,UAAU,EAAEG,UARhB;IASI,MAAM,EAAEU,mBATZ;IAUI,KAAK,EAAE;EAVX,EADA,GAaA,IAtCR,EAwCKX,gBAAgB,gBACb,6BAAC,iBAAD;IAAM,KAAK,EAAEpB,kBAAA,CAAWqC;EAAxB,GACKjB,gBADL,CADa,GAIb,IA5CR,CADJ;AAgDH;;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 * 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
+ {"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\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 * Custom error element. Default is simple alt text.\n */\n error?: React.ReactElement | null;\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.ReactElement;\n\n /**\n * Custom placeholder element.\n */\n placeholder?: React.ReactElement;\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"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './Image';\nexport type { default as ImageProps } from './ImageProps';\nexport type { PlaceholderProps } from './ImageProps';"],"mappings":";;;;;;;;;;;;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './Image';\nexport type { default as ImageProps } from './ImageProps';"],"mappings":";;;;;;;;;;;;AAAA"}
@@ -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 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
+ {"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,6 +9,11 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
+ const longClickDisabledStyle = {
13
+ '-webkit-user-select': 'none',
14
+ '-webkit-touch-callout': 'none'
15
+ };
16
+
12
17
  const preventDragging = () => false;
13
18
 
14
19
  const preventMouseDown = event => {
@@ -30,13 +35,9 @@ function ImageCore(props) {
30
35
  source,
31
36
  width
32
37
  } = props;
33
- const disableLongClickStyle = disableLongClick ? {
34
- '-webkit-user-select': 'none',
35
- '-webkit-touch-callout': 'none'
36
- } : {};
37
38
  const style = {
38
39
  objectFit: resizeMode,
39
- ...disableLongClickStyle
40
+ ...(disableLongClick ? longClickDisabledStyle : {})
40
41
  };
41
42
  return /*#__PURE__*/_react.default.createElement("img", {
42
43
  alt: alt,
@@ -1 +1 @@
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"}
1
+ {"version":3,"names":["longClickDisabledStyle","preventDragging","preventMouseDown","event","preventDefault","ImageCore","props","alt","disableDrag","disableLongClick","height","loading","onError","onLoad","resizeMode","source","width","style","objectFit","undefined","uri"],"sources":["ImageCoreWeb.tsx"],"sourcesContent":["import React, { DragEventHandler, MouseEventHandler } from 'react';\nimport type ImageCoreProps from './ImageCoreProps';\n\nconst longClickDisabledStyle = {\n '-webkit-user-select': 'none',\n '-webkit-touch-callout': 'none',\n};\n\nconst preventDragging: DragEventHandler<HTMLImageElement> = () => 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 style = {\n objectFit: resizeMode,\n ...(disableLongClick ? longClickDisabledStyle : {}),\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,sBAAsB,GAAG;EAC3B,uBAAuB,MADI;EAE3B,yBAAyB;AAFE,CAA/B;;AAKA,MAAMC,eAAmD,GAAG,MAAM,KAAlE;;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,KAAK,GAAG;IACVC,SAAS,EAAEJ,UADD;IAEV,IAAIL,gBAAgB,GAAGT,sBAAH,GAA4B,EAAhD;EAFU,CAAd;EAKA,oBACI;IACI,GAAG,EAAEO,GADT;IAEI,MAAM,EAAEG,MAFZ;IAGI,OAAO,EAAEC,OAHb;IAII,WAAW,EAAEH,WAAW,GAAGP,eAAH,GAAqBkB,SAJjD;IAKI,WAAW,EAAEX,WAAW,GAAGN,gBAAH,GAAsBiB,SALlD;IAMI,OAAO,EAAEP,OANb;IAOI,MAAM,EAAEC,MAPZ;IAQI,GAAG,EAAEE,MAAM,CAACK,GARhB;IASI,KAAK,EAAEH,KATX;IAUI,KAAK,EAAED;EAVX,EADJ;AAcH;;AAAA"}
@@ -5,14 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- const defaultAcceptHeader = 'image/jpg,image/png,image/*,*/*;';
13
-
14
- const ImageFileExtensionContext = /*#__PURE__*/_react.default.createContext(defaultAcceptHeader);
8
+ var _react = require("react");
15
9
 
10
+ const DEFAULT_ACCEPT_HEADER = 'image/jpg,image/png,image/*,*/*;';
11
+ const ImageFileExtensionContext = /*#__PURE__*/(0, _react.createContext)(DEFAULT_ACCEPT_HEADER);
16
12
  var _default = ImageFileExtensionContext;
17
13
  exports.default = _default;
18
14
  //# sourceMappingURL=ImageFileExtensionContext.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["defaultAcceptHeader","ImageFileExtensionContext","React","createContext"],"sources":["ImageFileExtensionContext.ts"],"sourcesContent":["import React from 'react';\n\nconst defaultAcceptHeader = 'image/jpg,image/png,image/*,*/*;';\n\nconst ImageFileExtensionContext = React.createContext<string>(defaultAcceptHeader);\n\nexport default ImageFileExtensionContext;"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,mBAAmB,GAAG,kCAA5B;;AAEA,MAAMC,yBAAyB,gBAAGC,cAAA,CAAMC,aAAN,CAA4BH,mBAA5B,CAAlC;;eAEeC,yB"}
1
+ {"version":3,"names":["DEFAULT_ACCEPT_HEADER","ImageFileExtensionContext","createContext"],"sources":["ImageFileExtensionContext.ts"],"sourcesContent":["import { createContext } from 'react';\n\nconst DEFAULT_ACCEPT_HEADER = 'image/jpg,image/png,image/*,*/*;';\n\nconst ImageFileExtensionContext = createContext<string>(DEFAULT_ACCEPT_HEADER);\n\nexport default ImageFileExtensionContext;\n"],"mappings":";;;;;;;AAAA;;AAEA,MAAMA,qBAAqB,GAAG,kCAA9B;AAEA,MAAMC,yBAAyB,gBAAG,IAAAC,oBAAA,EAAsBF,qBAAtB,CAAlC;eAEeC,yB"}
@@ -33,8 +33,8 @@ function ImageFileExtensionProvider(props) {
33
33
  children,
34
34
  extensions
35
35
  } = props;
36
- const availableAcceptHeader = R.pipe(R.map(extension => `image/${extension}`), R.join(','))(extensions);
37
- const acceptHeader = `${availableAcceptHeader},image/*,*/*;`;
36
+ const supportedMediaTypes = [...R.map(extension => `image/${extension}`, extensions), 'image/*', '*/*'];
37
+ const acceptHeader = `${R.join(',', supportedMediaTypes)};`;
38
38
  return /*#__PURE__*/_react.default.createElement(_ImageFileExtensionContext.default.Provider, {
39
39
  value: acceptHeader
40
40
  }, children);
@@ -1 +1 @@
1
- {"version":3,"names":["ImageFileExtension","ImageFileExtensionProvider","props","children","extensions","availableAcceptHeader","R","pipe","map","extension","join","acceptHeader"],"sources":["ImageFileExtensionProvider.tsx"],"sourcesContent":["import React from 'react';\nimport * as R from 'ramda';\nimport ImageFileExtensionContext from './ImageFileExtensionContext';\n\nexport enum ImageFileExtension {\n AVIF = \"avif\",\n WEBP = \"webp\",\n JPG = \"jpg\",\n PNG = \"png\",\n}\n\ninterface ImageFileExtensionProviderProps {\n children: React.ReactNode;\n extensions: ImageFileExtension[];\n}\n\nexport default function ImageFileExtensionProvider(props: ImageFileExtensionProviderProps) {\n const { children, extensions } = props;\n\n const availableAcceptHeader = R.pipe(\n R.map(extension => `image/${extension}`),\n R.join(','),\n )(extensions);\n\n const acceptHeader = `${availableAcceptHeader},image/*,*/*;`;\n\n return (\n <ImageFileExtensionContext.Provider value={acceptHeader}>\n {children}\n </ImageFileExtensionContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;;;;;;;IAEYA,kB;;;WAAAA,kB;EAAAA,kB;EAAAA,kB;EAAAA,kB;EAAAA,kB;GAAAA,kB,kCAAAA,kB;;AAYG,SAASC,0BAAT,CAAoCC,KAApC,EAA4E;EACvF,MAAM;IAAEC,QAAF;IAAYC;EAAZ,IAA2BF,KAAjC;EAEA,MAAMG,qBAAqB,GAAGC,CAAC,CAACC,IAAF,CAC1BD,CAAC,CAACE,GAAF,CAAMC,SAAS,IAAK,SAAQA,SAAU,EAAtC,CAD0B,EAE1BH,CAAC,CAACI,IAAF,CAAO,GAAP,CAF0B,EAG5BN,UAH4B,CAA9B;EAKA,MAAMO,YAAY,GAAI,GAAEN,qBAAsB,eAA9C;EAEA,oBACI,6BAAC,kCAAD,CAA2B,QAA3B;IAAoC,KAAK,EAAEM;EAA3C,GACKR,QADL,CADJ;AAKH"}
1
+ {"version":3,"names":["ImageFileExtension","ImageFileExtensionProvider","props","children","extensions","supportedMediaTypes","R","map","extension","acceptHeader","join"],"sources":["ImageFileExtensionProvider.tsx"],"sourcesContent":["import React from 'react';\nimport * as R from 'ramda';\nimport ImageFileExtensionContext from './ImageFileExtensionContext';\n\nexport enum ImageFileExtension {\n AVIF = 'avif',\n WEBP = 'webp',\n JPG = 'jpg',\n PNG = 'png',\n}\n\ninterface ImageFileExtensionProviderProps {\n children: React.ReactNode;\n extensions: ImageFileExtension[];\n}\n\nexport default function ImageFileExtensionProvider(props: ImageFileExtensionProviderProps) {\n const { children, extensions } = props;\n\n const supportedMediaTypes = [\n ...(R.map(extension => `image/${extension}`, extensions)),\n 'image/*',\n '*/*',\n ];\n\n const acceptHeader = `${R.join(',', supportedMediaTypes)};`;\n\n return (\n <ImageFileExtensionContext.Provider value={acceptHeader}>\n {children}\n </ImageFileExtensionContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;;;;;;;IAEYA,kB;;;WAAAA,kB;EAAAA,kB;EAAAA,kB;EAAAA,kB;EAAAA,kB;GAAAA,kB,kCAAAA,kB;;AAYG,SAASC,0BAAT,CAAoCC,KAApC,EAA4E;EACvF,MAAM;IAAEC,QAAF;IAAYC;EAAZ,IAA2BF,KAAjC;EAEA,MAAMG,mBAAmB,GAAG,CACxB,GAAIC,CAAC,CAACC,GAAF,CAAMC,SAAS,IAAK,SAAQA,SAAU,EAAtC,EAAyCJ,UAAzC,CADoB,EAExB,SAFwB,EAGxB,KAHwB,CAA5B;EAMA,MAAMK,YAAY,GAAI,GAAEH,CAAC,CAACI,IAAF,CAAO,GAAP,EAAYL,mBAAZ,CAAiC,GAAzD;EAEA,oBACI,6BAAC,kCAAD,CAA2B,QAA3B;IAAoC,KAAK,EAAEI;EAA3C,GACKN,QADL,CADJ;AAKH"}
@@ -21,20 +21,6 @@ Object.defineProperty(exports, "default", {
21
21
 
22
22
  var _ImageCoreWeb = _interopRequireDefault(require("./ImageCoreWeb"));
23
23
 
24
- var _ImageCoreProps = require("./ImageCoreProps");
25
-
26
- Object.keys(_ImageCoreProps).forEach(function (key) {
27
- if (key === "default" || key === "__esModule") return;
28
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
29
- if (key in exports && exports[key] === _ImageCoreProps[key]) return;
30
- Object.defineProperty(exports, key, {
31
- enumerable: true,
32
- get: function () {
33
- return _ImageCoreProps[key];
34
- }
35
- });
36
- });
37
-
38
24
  var _ImageFileExtensionProvider = _interopRequireWildcard(require("./ImageFileExtensionProvider"));
39
25
 
40
26
  Object.keys(_ImageFileExtensionProvider).forEach(function (key) {
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './ImageCoreWeb';\nexport * from './ImageCoreProps';\n\nexport { default as ImageFileExtensionProvider } from './ImageFileExtensionProvider';\nexport * from './ImageFileExtensionProvider';"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './ImageCoreWeb';\nexport type { default as ImageCoreProps, ImageSource, Loading, ResizeMode } from './ImageCoreProps';\n\nexport { default as ImageFileExtensionProvider } from './ImageFileExtensionProvider';\nexport * from './ImageFileExtensionProvider';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAGA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "useContentContainerStyle", {
27
27
  return _useContentContainerStyle.default;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "useDebounce", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _useDebounce.default;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "useElevationStyle", {
31
37
  enumerable: true,
32
38
  get: function () {
@@ -82,6 +88,8 @@ var _useSyncAnimatedValue = _interopRequireDefault(require("./useSyncAnimatedVal
82
88
 
83
89
  var _useThrottle = _interopRequireDefault(require("./useThrottle"));
84
90
 
91
+ var _useDebounce = _interopRequireDefault(require("./useDebounce"));
92
+
85
93
  var _useValidWindowDimensions = _interopRequireDefault(require("./useValidWindowDimensions"));
86
94
 
87
95
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as useAnimatedValue } from './useAnimatedValue';\nexport { default as useBreakpointUp } from './useBreakpointUp';\nexport { default as useCollapsibleAppBar } from './useCollapsibleAppBar';\nexport { default as useContentContainerStyle } from './useContentContainerStyle';\nexport { default as useElevationStyle } from './useElevationStyle';\nexport { default as useFadeInAppBar } from './useFadeInAppBar';\nexport { default as useImperativeState } from './useImperativeState';\nexport { default as useSyncAnimatedValue } from './useSyncAnimatedValue';\nexport { default as useThrottle } from './useThrottle';\nexport { default as useValidWindowDimensions } from './useValidWindowDimensions';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as useAnimatedValue } from './useAnimatedValue';\nexport { default as useBreakpointUp } from './useBreakpointUp';\nexport { default as useCollapsibleAppBar } from './useCollapsibleAppBar';\nexport { default as useContentContainerStyle } from './useContentContainerStyle';\nexport { default as useElevationStyle } from './useElevationStyle';\nexport { default as useFadeInAppBar } from './useFadeInAppBar';\nexport { default as useImperativeState } from './useImperativeState';\nexport { default as useSyncAnimatedValue } from './useSyncAnimatedValue';\nexport { default as useThrottle } from './useThrottle';\nexport { default as useDebounce } from './useDebounce';\nexport { default as useValidWindowDimensions } from './useValidWindowDimensions';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useDebounce;
7
+
8
+ var _react = require("react");
9
+
10
+ function useDebounce(callback, debounceMillis) {
11
+ const debounceTimeout = (0, _react.useRef)(null);
12
+ (0, _react.useEffect)(() => {
13
+ return () => {
14
+ debounceTimeout.current && clearTimeout(debounceTimeout.current);
15
+ };
16
+ }, []);
17
+ return (0, _react.useCallback)(function () {
18
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
19
+ args[_key] = arguments[_key];
20
+ }
21
+
22
+ if (debounceTimeout.current) {
23
+ clearTimeout(debounceTimeout.current);
24
+ }
25
+
26
+ if (callback) {
27
+ debounceTimeout.current = setTimeout(() => {
28
+ callback(...args);
29
+ }, debounceMillis);
30
+ }
31
+ }, [debounceMillis, callback]);
32
+ }
33
+ //# sourceMappingURL=useDebounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useDebounce","callback","debounceMillis","debounceTimeout","useRef","useEffect","current","clearTimeout","useCallback","args","setTimeout"],"sources":["useDebounce.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\nexport default function useDebounce(callback: (args?: any) => void, debounceMillis: number) {\n const debounceTimeout = useRef<NodeJS.Timeout | null>(null);\n\n useEffect(() => {\n return () => {\n debounceTimeout.current && clearTimeout(debounceTimeout.current);\n };\n }, []);\n\n return useCallback((...args: any[]) => {\n if (debounceTimeout.current) {\n clearTimeout(debounceTimeout.current);\n }\n\n if (callback) {\n debounceTimeout.current = setTimeout(() => {\n callback(...args);\n }, debounceMillis);\n }\n }, [debounceMillis, callback]);\n}"],"mappings":";;;;;;;AAAA;;AAEe,SAASA,WAAT,CAAqBC,QAArB,EAAqDC,cAArD,EAA6E;EACxF,MAAMC,eAAe,GAAG,IAAAC,aAAA,EAA8B,IAA9B,CAAxB;EAEA,IAAAC,gBAAA,EAAU,MAAM;IACZ,OAAO,MAAM;MACTF,eAAe,CAACG,OAAhB,IAA2BC,YAAY,CAACJ,eAAe,CAACG,OAAjB,CAAvC;IACH,CAFD;EAGH,CAJD,EAIG,EAJH;EAMA,OAAO,IAAAE,kBAAA,EAAY,YAAoB;IAAA,kCAAhBC,IAAgB;MAAhBA,IAAgB;IAAA;;IACnC,IAAIN,eAAe,CAACG,OAApB,EAA6B;MACzBC,YAAY,CAACJ,eAAe,CAACG,OAAjB,CAAZ;IACH;;IAED,IAAIL,QAAJ,EAAc;MACVE,eAAe,CAACG,OAAhB,GAA0BI,UAAU,CAAC,MAAM;QACvCT,QAAQ,CAAC,GAAGQ,IAAJ,CAAR;MACH,CAFmC,EAEjCP,cAFiC,CAApC;IAGH;EACJ,CAVM,EAUJ,CAACA,cAAD,EAAiBD,QAAjB,CAVI,CAAP;AAWH"}
@@ -1,7 +1,7 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React, { useEffect } from 'react';
4
- import { View } from 'react-native';
3
+ import React, { useEffect, useState } from 'react';
4
+ import { Text, View } from 'react-native';
5
5
  import ImageCore from '../ImageCore';
6
6
  import { css, StyleSheet, useTheme } from '../styles';
7
7
 
@@ -20,10 +20,22 @@ const useStyles = function () {
20
20
  borderWidth: StyleSheet.hairlineWidth,
21
21
  borderStyle: 'solid',
22
22
  borderColor: theme.palette.paper.grey
23
+ },
24
+ error: {
25
+ width: '100%',
26
+ height: '100%'
23
27
  }
24
28
  };
25
29
  };
26
30
 
31
+ function determinePlaceholderMode(props) {
32
+ if (props.disablePlaceholder) {
33
+ return 'none';
34
+ }
35
+
36
+ return props.placeholder ? 'custom' : 'default';
37
+ }
38
+
27
39
  export default function Image(props) {
28
40
  const {
29
41
  alt,
@@ -31,67 +43,63 @@ export default function Image(props) {
31
43
  disableLongClick,
32
44
  disableOutline,
33
45
  disablePlaceholder,
34
- failDependency = [],
46
+ error,
35
47
  loading = 'lazy',
48
+ onError: onErrorProp,
49
+ onLoad: onLoadProp,
36
50
  overlaidChildren,
51
+ placeholder,
37
52
  resizeMode = 'cover',
38
53
  source,
39
54
  style,
40
55
  square = false,
41
56
  size,
42
- onLoad,
43
- onError,
44
- Placeholder: PlaceholderComponent,
45
57
  ...otherProps
46
58
  } = props;
47
- const [failed, setFailed] = React.useState(false);
59
+ const [failed, setFailed] = useState(false);
48
60
  const styles = useStyles();
49
61
 
50
- const handleError = () => {
51
- if (onError) {
52
- onError();
53
- }
54
-
55
- setFailed(true);
62
+ const onLoad = () => {
63
+ setFailed(false);
64
+ onLoadProp === null || onLoadProp === void 0 ? void 0 : onLoadProp();
56
65
  };
57
66
 
58
- const Placeholder = _ref => {
59
- let {
60
- failed,
61
- children
62
- } = _ref;
63
- return PlaceholderComponent ? /*#__PURE__*/React.createElement(PlaceholderComponent, {
64
- children: children,
65
- failed: failed
66
- }) : children;
67
+ const onError = () => {
68
+ setFailed(true);
69
+ onErrorProp === null || onErrorProp === void 0 ? void 0 : onErrorProp();
67
70
  };
68
71
 
69
72
  const sourceWithSizeParam = { ...source,
70
73
  uri: size ? `${source.uri}?size=${size}` : source.uri
71
74
  };
75
+ const placeholderMode = determinePlaceholderMode(props);
72
76
  useEffect(() => {
73
- if (failed !== false) {
74
- setFailed(false);
75
- }
76
- }, [...failDependency]);
77
+ setFailed(false);
78
+ }, [sourceWithSizeParam.uri]);
77
79
  return /*#__PURE__*/React.createElement(View, _extends({
78
- style: css([styles.root, !disableOutline ? styles.outlined : undefined, !disablePlaceholder ? styles.placeholder : undefined, !square ? styles.rounded : undefined, style])
79
- }, otherProps), /*#__PURE__*/React.createElement(Placeholder, {
80
- failed: failed
81
- }, !failed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ImageCore, {
82
- alt: alt,
80
+ style: css([styles.root, !disableOutline ? styles.outlined : undefined, !square ? styles.rounded : undefined, placeholderMode === 'default' ? styles.placeholder : undefined, style])
81
+ }, otherProps), placeholderMode === 'custom' ? /*#__PURE__*/React.createElement(View, {
82
+ style: css([StyleSheet.absoluteFill, {
83
+ zIndex: -1
84
+ }])
85
+ }, placeholder) : null, failed ? /*#__PURE__*/React.createElement(View, {
86
+ style: styles.error
87
+ }, error ?? /*#__PURE__*/React.createElement(Text, {
88
+ children: alt
89
+ })) : sourceWithSizeParam.uri ? /*#__PURE__*/React.createElement(ImageCore, {
90
+ alt: sourceWithSizeParam.uri,
83
91
  disableDrag: disableDrag,
84
92
  disableLongClick: disableLongClick,
85
93
  height: '100%',
86
94
  loading: loading,
87
- onError: handleError,
95
+ onError: onError,
88
96
  onLoad: onLoad,
89
97
  resizeMode: resizeMode,
90
98
  source: sourceWithSizeParam,
91
99
  width: '100%'
92
- }), overlaidChildren ? /*#__PURE__*/React.createElement(View, {
100
+ }) : null, overlaidChildren ? /*#__PURE__*/React.createElement(View, {
93
101
  style: StyleSheet.absoluteFill
94
- }, overlaidChildren) : null) : null));
102
+ }, overlaidChildren) : null);
95
103
  }
96
104
  ;
97
105
  //# sourceMappingURL=Image.js.map
@@ -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","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,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,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AD;IACI,KAAK,EAAE5B,GAAG,CAAC,CACP4C,MAAM,CAACvC,IADA,EAEP,CAACqB,cAAD,GAAkBkB,MAAM,CAAC5B,QAAzB,GAAoCiC,SAF7B,EAGP,CAACtB,kBAAD,GAAsBiB,MAAM,CAACjC,WAA7B,GAA2CsC,SAHpC,EAIP,CAACf,MAAD,GAAUU,MAAM,CAACtC,OAAjB,GAA2B2C,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,EAAElB,GADT;IAEI,WAAW,EAAEC,WAFjB;IAGI,gBAAgB,EAAEC,gBAHtB;IAII,MAAM,EAAE,MAJZ;IAKI,OAAO,EAAEI,OALb;IAMI,OAAO,EAAEgB,WANb;IAOI,MAAM,EAAET,MAPZ;IAQI,UAAU,EAAEL,UARhB;IASI,MAAM,EAAEgB,mBATZ;IAUI,KAAK,EAAE;EAVX,EADJ,EAcKjB,gBAAgB,gBACb,oBAAC,IAAD;IAAM,KAAK,EAAE7B,UAAU,CAACiD;EAAxB,GACKpB,gBADL,CADa,GAIb,IAlBR,CADH,GAqBG,IAtBR,CAVJ,CADJ;AAqCH;AAAA"}
1
+ {"version":3,"names":["React","useEffect","useState","Text","View","ImageCore","css","StyleSheet","useTheme","useStyles","theme","root","rounded","borderRadius","shape","roundness","overflow","placeholder","backgroundColor","palette","paper","grey","outlined","borderWidth","hairlineWidth","borderStyle","borderColor","error","width","height","determinePlaceholderMode","props","disablePlaceholder","Image","alt","disableDrag","disableLongClick","disableOutline","loading","onError","onErrorProp","onLoad","onLoadProp","overlaidChildren","resizeMode","source","style","square","size","otherProps","failed","setFailed","styles","sourceWithSizeParam","uri","placeholderMode","undefined","absoluteFill","zIndex"],"sources":["Image.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { Text, View } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport type { ImageCoreProps } from '../ImageCore';\nimport ImageCore from '../ImageCore';\nimport { css, StyleSheet, useTheme } from '../styles';\nimport type ImageProps from './ImageProps';\n\ntype PlaceholderMode =\n | 'default'\n | 'custom'\n | 'none';\n\ntype ImageStyleKeys =\n | 'root'\n | 'rounded'\n | 'placeholder'\n | 'outlined'\n | 'error';\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 error: {\n width: '100%',\n height: '100%',\n },\n };\n};\n\nfunction determinePlaceholderMode(props: ImageProps): PlaceholderMode {\n if (props.disablePlaceholder) {\n return 'none';\n }\n\n return props.placeholder ? 'custom' : 'default';\n}\n\nexport default function Image(props: ImageProps) {\n const {\n alt,\n disableDrag,\n disableLongClick,\n disableOutline,\n disablePlaceholder,\n error,\n loading = 'lazy',\n onError: onErrorProp,\n onLoad: onLoadProp,\n overlaidChildren,\n placeholder,\n resizeMode = 'cover',\n source,\n style,\n square = false,\n size,\n ...otherProps\n } = props;\n\n const [failed, setFailed] = useState(false);\n\n const styles = useStyles();\n\n const onLoad: ImageCoreProps['onLoad'] = () => {\n setFailed(false);\n\n onLoadProp?.();\n };\n\n const onError: ImageCoreProps['onError'] = () => {\n setFailed(true);\n\n onErrorProp?.();\n };\n\n const sourceWithSizeParam = {\n ...source,\n uri: size ? `${source.uri}?size=${size}` : source.uri,\n };\n\n const placeholderMode = determinePlaceholderMode(props);\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 !square ? styles.rounded : undefined,\n placeholderMode === 'default' ? styles.placeholder : undefined,\n style,\n ])}\n {...otherProps}\n >\n {placeholderMode === 'custom' ? (\n <View\n style={css([\n StyleSheet.absoluteFill,\n { zIndex: -1 },\n ])}\n >\n {placeholder}\n </View>\n ) : null}\n\n {failed ? (\n <View style={styles.error}>\n {error ?? <Text children={alt}/>}\n </View>\n ) : sourceWithSizeParam.uri ? (\n <ImageCore\n alt={sourceWithSizeParam.uri}\n disableDrag={disableDrag}\n disableLongClick={disableLongClick}\n height={'100%'}\n loading={loading}\n onError={onError}\n onLoad={onLoad}\n resizeMode={resizeMode}\n source={sourceWithSizeParam}\n width={'100%'}\n />\n ) : null}\n\n {overlaidChildren ? (\n <View style={StyleSheet.absoluteFill}>\n {overlaidChildren}\n </View>\n ) : null}\n </View>\n );\n};"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,QAA3B,QAA2C,OAA3C;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,cAA3B;AAGA,OAAOC,SAAP,MAAsB,cAAtB;AACA,SAASC,GAAT,EAAcC,UAAd,EAA0BC,QAA1B,QAA0C,WAA1C;;AAiBA,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,CATP;IAcHM,KAAK,EAAE;MACHC,KAAK,E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ageProps.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
+ {"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\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 * Custom error element. Default is simple alt text.\n */\n error?: React.ReactElement | null;\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.ReactElement;\n\n /**\n * Custom placeholder element.\n */\n placeholder?: React.ReactElement;\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"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from './Image';\nexport type { default as ImageProps } from './ImageProps';\nexport type { PlaceholderProps } from './ImageProps';"],"mappings":"AAAA,SAASA,OAAT,QAAwB,SAAxB"}
1
+ {"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from './Image';\nexport type { default as ImageProps } from './ImageProps';"],"mappings":"AAAA,SAASA,OAAT,QAAwB,SAAxB"}
@@ -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 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
+ {"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,4 +1,8 @@
1
1
  import React from 'react';
2
+ const longClickDisabledStyle = {
3
+ '-webkit-user-select': 'none',
4
+ '-webkit-touch-callout': 'none'
5
+ };
2
6
 
3
7
  const preventDragging = () => false;
4
8
 
@@ -21,13 +25,9 @@ export default function ImageCore(props) {
21
25
  source,
22
26
  width
23
27
  } = props;
24
- const disableLongClickStyle = disableLongClick ? {
25
- '-webkit-user-select': 'none',
26
- '-webkit-touch-callout': 'none'
27
- } : {};
28
28
  const style = {
29
29
  objectFit: resizeMode,
30
- ...disableLongClickStyle
30
+ ...(disableLongClick ? longClickDisabledStyle : {})
31
31
  };
32
32
  return /*#__PURE__*/React.createElement("img", {
33
33
  alt: alt,