@sendbird/uikit-react-native-foundation 3.6.0 → 3.7.1
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.
- package/lib/commonjs/components/Image/Image.fastimage.js +3 -3
- package/lib/commonjs/components/Image/Image.fastimage.js.map +1 -1
- package/lib/commonjs/components/ImageWithPlaceholder/index.js.map +1 -1
- package/lib/commonjs/styles/createStyleSheet.js +33 -26
- package/lib/commonjs/styles/createStyleSheet.js.map +1 -1
- package/lib/module/components/Image/Image.fastimage.js +3 -3
- package/lib/module/components/Image/Image.fastimage.js.map +1 -1
- package/lib/module/components/ImageWithPlaceholder/index.js.map +1 -1
- package/lib/module/styles/createStyleSheet.js +34 -26
- package/lib/module/styles/createStyleSheet.js.map +1 -1
- package/lib/typescript/src/components/ImageWithPlaceholder/index.d.ts +2 -2
- package/lib/typescript/src/styles/createStyleSheet.d.ts +1 -1
- package/lib/typescript/src/ui/Avatar/index.d.ts +1 -1
- package/package.json +7 -7
- package/src/components/Image/Image.fastimage.tsx +3 -3
- package/src/components/ImageWithPlaceholder/index.tsx +2 -2
- package/src/styles/createStyleSheet.ts +42 -27
|
@@ -26,9 +26,9 @@ function convertSource(source) {
|
|
|
26
26
|
return source;
|
|
27
27
|
}
|
|
28
28
|
return {
|
|
29
|
-
uri: source.uri,
|
|
30
|
-
headers: source.headers,
|
|
31
|
-
cache: convertCache(source.cache) //'immutable' | 'web' | 'cacheOnly'
|
|
29
|
+
uri: source === null || source === void 0 ? void 0 : source.uri,
|
|
30
|
+
headers: source === null || source === void 0 ? void 0 : source.headers,
|
|
31
|
+
cache: convertCache(source === null || source === void 0 ? void 0 : source.cache) //'immutable' | 'web' | 'cacheOnly'
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_FastImageInternal","obj","__esModule","default","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","convertCache","cache","convertSource","Array","isArray","uri","headers","convertDefaultSource","undefined","convertResizeMode","mode","Image_FastImage","_ref","defaultSource","resizeMode","onLoad","onError","style","tintColor","disableFastImage","props","createElement","Image","e","nativeEvent","_default","exports"],"sources":["Image.fastimage.tsx"],"sourcesContent":["import React from 'react';\nimport { Image } from 'react-native';\nimport type { FastImageProps, ResizeMode, Source } from 'react-native-fast-image';\n\nimport FastImageInternal from './FastImageInternal';\nimport type { SendbirdImageComponent, SendbirdImageProps } from './index';\n\nfunction convertCache(\n cache?: 'default' | 'reload' | 'force-cache' | 'only-if-cached' | undefined,\n): 'immutable' | 'web' | 'cacheOnly' {\n switch (cache) {\n case 'force-cache':\n case 'only-if-cached':\n return 'cacheOnly';\n default:\n return 'immutable';\n }\n}\n\nfunction convertSource(source: SendbirdImageProps['source']): Source | number {\n if (Array.isArray(source)) {\n return convertSource(source[0]);\n }\n\n if (typeof source === 'number') {\n return source;\n }\n\n return {\n uri: source
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_FastImageInternal","obj","__esModule","default","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","convertCache","cache","convertSource","Array","isArray","uri","headers","convertDefaultSource","undefined","convertResizeMode","mode","Image_FastImage","_ref","defaultSource","resizeMode","onLoad","onError","style","tintColor","disableFastImage","props","createElement","Image","e","nativeEvent","_default","exports"],"sources":["Image.fastimage.tsx"],"sourcesContent":["import React from 'react';\nimport { Image } from 'react-native';\nimport type { FastImageProps, ResizeMode, Source } from 'react-native-fast-image';\n\nimport FastImageInternal from './FastImageInternal';\nimport type { SendbirdImageComponent, SendbirdImageProps } from './index';\n\nfunction convertCache(\n cache?: 'default' | 'reload' | 'force-cache' | 'only-if-cached' | undefined,\n): 'immutable' | 'web' | 'cacheOnly' {\n switch (cache) {\n case 'force-cache':\n case 'only-if-cached':\n return 'cacheOnly';\n default:\n return 'immutable';\n }\n}\n\nfunction convertSource(source: SendbirdImageProps['source']): Source | number {\n if (Array.isArray(source)) {\n return convertSource(source[0]);\n }\n\n if (typeof source === 'number') {\n return source;\n }\n\n return {\n uri: source?.uri,\n headers: source?.headers,\n cache: convertCache(source?.cache), //'immutable' | 'web' | 'cacheOnly'\n };\n}\nfunction convertDefaultSource(source?: SendbirdImageProps['defaultSource']): number | undefined {\n if (typeof source === 'number') {\n return source;\n }\n\n return undefined;\n}\n\nfunction convertResizeMode(mode?: SendbirdImageProps['resizeMode']): ResizeMode | undefined {\n switch (mode) {\n case 'center':\n return 'center';\n case 'contain':\n return 'contain';\n case 'cover':\n return 'cover';\n case 'stretch':\n return 'stretch';\n default:\n return undefined;\n }\n}\n\nconst Image_FastImage: SendbirdImageComponent = ({\n source,\n defaultSource,\n resizeMode,\n onLoad,\n onError,\n style,\n tintColor,\n disableFastImage = false,\n ...props\n}) => {\n if (disableFastImage) {\n return (\n <Image\n {...props}\n source={source}\n style={[style, { tintColor }]}\n onError={onError && ((e) => onError(e.nativeEvent))}\n onLoad={onLoad && ((e) => onLoad(e.nativeEvent.source))}\n />\n );\n }\n return (\n <FastImageInternal\n {...props}\n onLoad={onLoad && ((e) => onLoad(e.nativeEvent))}\n onError={onError && (() => onError({}))}\n style={style as FastImageProps['style']}\n source={convertSource(source)}\n defaultSource={convertDefaultSource(defaultSource)}\n resizeMode={convertResizeMode(resizeMode)}\n />\n );\n};\n\nexport default Image_FastImage;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAGA,IAAAE,kBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAoD,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,SAAA,IAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,C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A,GAEad,eAAe;AAAAe,OAAA,CAAAzC,OAAA,GAAAwC,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_uikitUtils","_createStyleSheet","_interopRequireDefault","_useUIKitTheme","_Box","_Icon","_Image","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","useRetry","hasError","retryCount","arguments","length","undefined","Platform","OS","forceUpdate","useForceUpdate","retryCountRef","useRef","retryTimeoutRef","useEffect","reloadReservation","current","setTimeout","clearTimeout","ImageWithPlaceholder","props","palette","select","colors","useUIKitTheme","imageNotFound","setImageNotFound","useState","createElement","style","overflow","width","height","backgroundColor","dark","background400","light","background100","source","StyleSheet","absoluteFill","styles","hide","resizeMode","resizeMethod","onError","onLoad","containerStyle","icon","size","color","onBackground02","createStyleSheet","display","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Platform, StyleProp, StyleSheet, ViewStyle } from 'react-native';\n\nimport { useForceUpdate } from '@sendbird/uikit-utils';\n\nimport createStyleSheet from '../../styles/createStyleSheet';\nimport useUIKitTheme from '../../theme/useUIKitTheme';\nimport Box from '../Box';\nimport Icon from '../Icon';\nimport Image from '../Image';\n\nconst useRetry = (hasError: boolean, retryCount = 5) => {\n // NOTE: Glide(fast-image) will retry automatically on Android\n if (Platform.OS === 'android') return '';\n\n const forceUpdate = useForceUpdate();\n const retryCountRef = useRef(1);\n const retryTimeoutRef = useRef<NodeJS.Timeout>();\n\n useEffect(() => {\n if (hasError) {\n const reloadReservation = () => {\n if (retryCountRef.current < retryCount) {\n retryTimeoutRef.current = setTimeout(() => {\n retryCountRef.current++;\n reloadReservation();\n forceUpdate();\n }, retryCountRef.current * 5000);\n }\n };\n\n return reloadReservation();\n } else {\n return clearTimeout(retryTimeoutRef.current);\n }\n }, [hasError]);\n\n return retryCountRef.current;\n};\n\ntype Props = {\n source: number | { uri: string };\n width?: number |
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_uikitUtils","_createStyleSheet","_interopRequireDefault","_useUIKitTheme","_Box","_Icon","_Image","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","useRetry","hasError","retryCount","arguments","length","undefined","Platform","OS","forceUpdate","useForceUpdate","retryCountRef","useRef","retryTimeoutRef","useEffect","reloadReservation","current","setTimeout","clearTimeout","ImageWithPlaceholder","props","palette","select","colors","useUIKitTheme","imageNotFound","setImageNotFound","useState","createElement","style","overflow","width","height","backgroundColor","dark","background400","light","background100","source","StyleSheet","absoluteFill","styles","hide","resizeMode","resizeMethod","onError","onLoad","containerStyle","icon","size","color","onBackground02","createStyleSheet","display","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Platform, StyleProp, StyleSheet, ViewStyle } from 'react-native';\n\nimport { useForceUpdate } from '@sendbird/uikit-utils';\n\nimport createStyleSheet from '../../styles/createStyleSheet';\nimport useUIKitTheme from '../../theme/useUIKitTheme';\nimport Box from '../Box';\nimport Icon from '../Icon';\nimport Image from '../Image';\n\nconst useRetry = (hasError: boolean, retryCount = 5) => {\n // NOTE: Glide(fast-image) will retry automatically on Android\n if (Platform.OS === 'android') return '';\n\n const forceUpdate = useForceUpdate();\n const retryCountRef = useRef(1);\n const retryTimeoutRef = useRef<NodeJS.Timeout>();\n\n useEffect(() => {\n if (hasError) {\n const reloadReservation = () => {\n if (retryCountRef.current < retryCount) {\n retryTimeoutRef.current = setTimeout(() => {\n retryCountRef.current++;\n reloadReservation();\n forceUpdate();\n }, retryCountRef.current * 5000);\n }\n };\n\n return reloadReservation();\n } else {\n return clearTimeout(retryTimeoutRef.current);\n }\n }, [hasError]);\n\n return retryCountRef.current;\n};\n\ntype Props = {\n source: number | { uri: string };\n width?: number | `${number}%`;\n height?: number | `${number}%`;\n style?: StyleProp<ViewStyle>;\n};\nconst ImageWithPlaceholder = (props: Props) => {\n const { palette, select, colors } = useUIKitTheme();\n const [imageNotFound, setImageNotFound] = useState(false);\n\n const key = useRetry(imageNotFound);\n return (\n <Box\n style={[{ overflow: 'hidden', width: props.width, height: props.height }, props.style]}\n backgroundColor={select({ dark: palette.background400, light: palette.background100 })}\n >\n <Image\n key={key}\n source={props.source}\n style={[StyleSheet.absoluteFill, imageNotFound && styles.hide]}\n resizeMode={'cover'}\n resizeMethod={'resize'}\n onError={() => setImageNotFound(true)}\n onLoad={() => setImageNotFound(false)}\n />\n {imageNotFound && (\n <Icon\n containerStyle={StyleSheet.absoluteFill}\n icon={'thumbnail-none'}\n size={48}\n color={colors.onBackground02}\n />\n )}\n </Box>\n );\n};\n\nconst styles = createStyleSheet({\n hide: {\n display: 'none',\n },\n});\n\nexport default ImageWithPlaceholder;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,IAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,KAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,MAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AAA6B,SAAAI,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OA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EAAEX,MAAM,CAAC;MAAEY,IAAI,EAAEb,OAAO,CAACc,aAAa;MAAEC,KAAK,EAAEf,OAAO,CAACgB;IAAc,CAAC;EAAE,gBAEvFrE,MAAA,CAAAa,OAAA,CAAA+C,aAAA,CAAClD,MAAA,CAAAG,OAAK;IACJc,GAAG,EAAEA,GAAI;IACT2C,MAAM,EAAElB,KAAK,CAACkB,MAAO;IACrBT,KAAK,EAAE,CAACU,uBAAU,CAACC,YAAY,EAAEf,aAAa,IAAIgB,MAAM,CAACC,IAAI,CAAE;IAC/DC,UAAU,EAAE,OAAQ;IACpBC,YAAY,EAAE,QAAS;IACvBC,OAAO,EAAEA,CAAA,KAAMnB,gBAAgB,CAAC,IAAI,CAAE;IACtCoB,MAAM,EAAEA,CAAA,KAAMpB,gBAAgB,CAAC,KAAK;EAAE,EACtC,EACDD,aAAa,iBACZzD,MAAA,CAAAa,OAAA,CAAA+C,aAAA,CAACnD,KAAA,CAAAI,OAAI;IACHkE,cAAc,EAAER,uBAAU,CAACC,YAAa;IACxCQ,IAAI,EAAE,gBAAiB;IACvBC,IAAI,EAAE,EAAG;IACTC,KAAK,EAAE3B,MAAM,CAAC4B;EAAe,EAEhC,CACG;AAEV,CAAC;AAED,MAAMV,MAAM,GAAG,IAAAW,yBAAgB,EAAC;EAC9BV,IAAI,EAAE;IACJW,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAEYnC,oBAAoB;AAAAoC,OAAA,CAAA1E,OAAA,GAAAyE,QAAA"}
|
|
@@ -6,35 +6,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _createScaleFactor = require("./createScaleFactor");
|
|
9
|
-
const
|
|
9
|
+
const SCALE_FACTOR_WITH_DIMENSION_VALUE = val => {
|
|
10
|
+
return typeof val === 'number' ? (0, _createScaleFactor.DEFAULT_SCALE_FACTOR)(val) : val;
|
|
11
|
+
};
|
|
12
|
+
const DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE = val => {
|
|
13
|
+
return typeof val === 'number' ? (0, _createScaleFactor.DEFAULT_SCALE_FACTOR)(val) : val;
|
|
14
|
+
};
|
|
10
15
|
const preProcessor = {
|
|
11
16
|
'fontSize': _createScaleFactor.DEFAULT_SCALE_FACTOR,
|
|
12
17
|
'lineHeight': _createScaleFactor.DEFAULT_SCALE_FACTOR,
|
|
13
|
-
'borderRadius':
|
|
14
|
-
'minWidth':
|
|
15
|
-
'maxWidth':
|
|
16
|
-
'minHeight':
|
|
17
|
-
'maxHeight':
|
|
18
|
-
'height':
|
|
19
|
-
'width':
|
|
20
|
-
'padding':
|
|
21
|
-
'paddingVertical':
|
|
22
|
-
'paddingHorizontal':
|
|
23
|
-
'paddingTop':
|
|
24
|
-
'paddingBottom':
|
|
25
|
-
'paddingLeft':
|
|
26
|
-
'paddingRight':
|
|
27
|
-
'margin':
|
|
28
|
-
'marginVertical':
|
|
29
|
-
'marginHorizontal':
|
|
30
|
-
'marginTop':
|
|
31
|
-
'marginBottom':
|
|
32
|
-
'marginLeft':
|
|
33
|
-
'marginRight':
|
|
34
|
-
'left':
|
|
35
|
-
'right':
|
|
36
|
-
'top':
|
|
37
|
-
'bottom':
|
|
18
|
+
'borderRadius': DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE,
|
|
19
|
+
'minWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
20
|
+
'maxWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
21
|
+
'minHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
22
|
+
'maxHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
23
|
+
'height': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
24
|
+
'width': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
25
|
+
'padding': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
26
|
+
'paddingVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
27
|
+
'paddingHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
28
|
+
'paddingTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
29
|
+
'paddingBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
30
|
+
'paddingLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
31
|
+
'paddingRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
32
|
+
'margin': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
33
|
+
'marginVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
34
|
+
'marginHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
35
|
+
'marginTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
36
|
+
'marginBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
37
|
+
'marginLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
38
|
+
'marginRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
39
|
+
'left': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
40
|
+
'right': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
41
|
+
'top': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
42
|
+
'bottom': SCALE_FACTOR_WITH_DIMENSION_VALUE
|
|
38
43
|
};
|
|
39
44
|
const preProcessorKeys = Object.keys(preProcessor);
|
|
40
45
|
const preProcessorLen = preProcessorKeys.length;
|
|
@@ -45,6 +50,7 @@ const preProcessorLen = preProcessorKeys.length;
|
|
|
45
50
|
* @param styles
|
|
46
51
|
* @returns StyleSheet
|
|
47
52
|
* */
|
|
53
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
48
54
|
const createStyleSheet = styles => {
|
|
49
55
|
Object.values(styles).forEach(style => {
|
|
50
56
|
// @ts-ignore
|
|
@@ -58,6 +64,7 @@ const createStyleSheet = styles => {
|
|
|
58
64
|
});
|
|
59
65
|
return _reactNative.StyleSheet.create(styles);
|
|
60
66
|
};
|
|
67
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
61
68
|
var _default = createStyleSheet;
|
|
62
69
|
exports.default = _default;
|
|
63
70
|
//# sourceMappingURL=createStyleSheet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_createScaleFactor","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_createScaleFactor","SCALE_FACTOR_WITH_DIMENSION_VALUE","val","DEFAULT_SCALE_FACTOR","DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE","preProcessor","preProcessorKeys","Object","keys","preProcessorLen","length","createStyleSheet","styles","values","forEach","style","styleKeys","styleLen","key","StyleSheet","create","_default","exports","default"],"sources":["createStyleSheet.ts"],"sourcesContent":["import { ImageStyle, StyleSheet, TextStyle, ViewStyle } from 'react-native';\nimport { AnimatableNumericValue, DimensionValue } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\n\nimport { DEFAULT_SCALE_FACTOR } from './createScaleFactor';\n\ntype Styles = ViewStyle | TextStyle | ImageStyle;\ntype StylePreprocessor<T extends Styles = Styles> = { [key in keyof T]: (val: NonNullable<T[key]>) => typeof val };\n\nconst SCALE_FACTOR_WITH_DIMENSION_VALUE = (\n val: NonNullable<DimensionValue | undefined>,\n): NonNullable<DimensionValue | undefined> => {\n return typeof val === 'number' ? DEFAULT_SCALE_FACTOR(val) : val;\n};\n\nconst DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE = (\n val: NonNullable<AnimatableNumericValue | undefined>,\n): NonNullable<AnimatableNumericValue | undefined> => {\n return typeof val === 'number' ? DEFAULT_SCALE_FACTOR(val) : val;\n};\n\nconst preProcessor: Partial<StylePreprocessor> = {\n 'fontSize': DEFAULT_SCALE_FACTOR,\n 'lineHeight': DEFAULT_SCALE_FACTOR,\n 'borderRadius': DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE,\n 'minWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'maxWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'minHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'maxHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'height': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'width': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'padding': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'margin': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'left': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'right': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'top': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'bottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n};\n\nconst preProcessorKeys = Object.keys(preProcessor);\nconst preProcessorLen = preProcessorKeys.length;\n\n/**\n * Create StyleSheet with customized pre-processor\n * Return a StyleSheet that pre-processed\n * @param styles\n * @returns StyleSheet\n * */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nconst createStyleSheet = <T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>>(\n styles: T & StyleSheet.NamedStyles<any>,\n): T => {\n Object.values(styles).forEach((style) => {\n // @ts-ignore\n const styleKeys = Object.keys(style);\n const styleLen = styleKeys.length;\n\n const keys = styleLen < preProcessorLen ? styleKeys : preProcessorKeys;\n keys.forEach((key) => {\n // @ts-ignore\n if (preProcessor[key] && typeof style[key] !== 'undefined') style[key] = preProcessor[key](style[key]);\n });\n });\n\n return StyleSheet.create<T>(styles);\n};\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\nexport default createStyleSheet;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,kBAAA,GAAAD,OAAA;AAKA,MAAME,iCAAiC,GACrCC,GAA4C,IACA;EAC5C,OAAO,OAAOA,GAAG,KAAK,QAAQ,GAAG,IAAAC,uCAAoB,EAACD,GAAG,CAAC,GAAGA,GAAG;AAClE,CAAC;AAED,MAAME,uCAAuC,GAC3CF,GAAoD,IACA;EACpD,OAAO,OAAOA,GAAG,KAAK,QAAQ,GAAG,IAAAC,uCAAoB,EAACD,GAAG,CAAC,GAAGA,GAAG;AAClE,CAAC;AAED,MAAMG,YAAwC,GAAG;EAC/C,UAAU,EAAEF,uCAAoB;EAChC,YAAY,EAAEA,uCAAoB;EAClC,cAAc,EAAEC,uCAAuC;EACvD,UAAU,EAAEH,iCAAiC;EAC7C,UAAU,EAAEA,iCAAiC;EAC7C,WAAW,EAAEA,iCAAiC;EAC9C,WAAW,EAAEA,iCAAiC;EAC9C,QAAQ,EAAEA,iCAAiC;EAC3C,OAAO,EAAEA,iCAAiC;EAC1C,SAAS,EAAEA,iCAAiC;EAC5C,iBAAiB,EAAEA,iCAAiC;EACpD,mBAAmB,EAAEA,iCAAiC;EACtD,YAAY,EAAEA,iCAAiC;EAC/C,eAAe,EAAEA,iCAAiC;EAClD,aAAa,EAAEA,iC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,9 +19,9 @@ function convertSource(source) {
|
|
|
19
19
|
return source;
|
|
20
20
|
}
|
|
21
21
|
return {
|
|
22
|
-
uri: source.uri,
|
|
23
|
-
headers: source.headers,
|
|
24
|
-
cache: convertCache(source.cache) //'immutable' | 'web' | 'cacheOnly'
|
|
22
|
+
uri: source === null || source === void 0 ? void 0 : source.uri,
|
|
23
|
+
headers: source === null || source === void 0 ? void 0 : source.headers,
|
|
24
|
+
cache: convertCache(source === null || source === void 0 ? void 0 : source.cache) //'immutable' | 'web' | 'cacheOnly'
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Image","FastImageInternal","convertCache","cache","convertSource","source","Array","isArray","uri","headers","convertDefaultSource","undefined","convertResizeMode","mode","Image_FastImage","_ref","defaultSource","resizeMode","onLoad","onError","style","tintColor","disableFastImage","props","createElement","_extends","e","nativeEvent"],"sources":["Image.fastimage.tsx"],"sourcesContent":["import React from 'react';\nimport { Image } from 'react-native';\nimport type { FastImageProps, ResizeMode, Source } from 'react-native-fast-image';\n\nimport FastImageInternal from './FastImageInternal';\nimport type { SendbirdImageComponent, SendbirdImageProps } from './index';\n\nfunction convertCache(\n cache?: 'default' | 'reload' | 'force-cache' | 'only-if-cached' | undefined,\n): 'immutable' | 'web' | 'cacheOnly' {\n switch (cache) {\n case 'force-cache':\n case 'only-if-cached':\n return 'cacheOnly';\n default:\n return 'immutable';\n }\n}\n\nfunction convertSource(source: SendbirdImageProps['source']): Source | number {\n if (Array.isArray(source)) {\n return convertSource(source[0]);\n }\n\n if (typeof source === 'number') {\n return source;\n }\n\n return {\n uri: source
|
|
1
|
+
{"version":3,"names":["React","Image","FastImageInternal","convertCache","cache","convertSource","source","Array","isArray","uri","headers","convertDefaultSource","undefined","convertResizeMode","mode","Image_FastImage","_ref","defaultSource","resizeMode","onLoad","onError","style","tintColor","disableFastImage","props","createElement","_extends","e","nativeEvent"],"sources":["Image.fastimage.tsx"],"sourcesContent":["import React from 'react';\nimport { Image } from 'react-native';\nimport type { FastImageProps, ResizeMode, Source } from 'react-native-fast-image';\n\nimport FastImageInternal from './FastImageInternal';\nimport type { SendbirdImageComponent, SendbirdImageProps } from './index';\n\nfunction convertCache(\n cache?: 'default' | 'reload' | 'force-cache' | 'only-if-cached' | undefined,\n): 'immutable' | 'web' | 'cacheOnly' {\n switch (cache) {\n case 'force-cache':\n case 'only-if-cached':\n return 'cacheOnly';\n default:\n return 'immutable';\n }\n}\n\nfunction convertSource(source: SendbirdImageProps['source']): Source | number {\n if (Array.isArray(source)) {\n return convertSource(source[0]);\n }\n\n if (typeof source === 'number') {\n return source;\n }\n\n return {\n uri: source?.uri,\n headers: source?.headers,\n cache: convertCache(source?.cache), //'immutable' | 'web' | 'cacheOnly'\n };\n}\nfunction convertDefaultSource(source?: SendbirdImageProps['defaultSource']): number | undefined {\n if (typeof source === 'number') {\n return source;\n }\n\n return undefined;\n}\n\nfunction convertResizeMode(mode?: SendbirdImageProps['resizeMode']): ResizeMode | undefined {\n switch (mode) {\n case 'center':\n return 'center';\n case 'contain':\n return 'contain';\n case 'cover':\n return 'cover';\n case 'stretch':\n return 'stretch';\n default:\n return undefined;\n }\n}\n\nconst Image_FastImage: SendbirdImageComponent = ({\n source,\n defaultSource,\n resizeMode,\n onLoad,\n onError,\n style,\n tintColor,\n disableFastImage = false,\n ...props\n}) => {\n if (disableFastImage) {\n return (\n <Image\n {...props}\n source={source}\n style={[style, { tintColor }]}\n onError={onError && ((e) => onError(e.nativeEvent))}\n onLoad={onLoad && ((e) => onLoad(e.nativeEvent.source))}\n />\n );\n }\n return (\n <FastImageInternal\n {...props}\n onLoad={onLoad && ((e) => onLoad(e.nativeEvent))}\n onError={onError && (() => onError({}))}\n style={style as FastImageProps['style']}\n source={convertSource(source)}\n defaultSource={convertDefaultSource(defaultSource)}\n resizeMode={convertResizeMode(resizeMode)}\n />\n );\n};\n\nexport default Image_FastImage;\n"],"mappings":";AAAA,OA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,SAAS;IACTC,gBAAgB,GAAG,KAAK;IACxB,GAAGC;EACL,CAAC,GAAAR,IAAA;EACC,IAAIO,gBAAgB,EAAE;IACpB,oBACEvB,KAAA,CAAAyB,aAAA,CAACxB,KAAK,EAAAyB,QAAA,KACAF,KAAK;MACTlB,MAAM,EAAEA,MAAO;MACfe,KAAK,EAAE,CAACA,KAAK,EAAE;QAAEC;MAAU,CAAC,CAAE;MAC9BF,OAAO,EAAEA,OAAO,KAAMO,CAAC,IAAKP,OAAO,CAACO,CAAC,CAACC,WAAW,CAAC,CAAE;MACpDT,MAAM,EAAEA,MAAM,KAAMQ,CAAC,IAAKR,MAAM,CAACQ,CAAC,CAACC,WAAW,CAACtB,MAAM,CAAC;IAAE,GACxD;EAEN;EACA,oBACEN,KAAA,CAAAyB,aAAA,CAACvB,iBAAiB,EAAAwB,QAAA,KACZF,KAAK;IACTL,MAAM,EAAEA,MAAM,KAAMQ,CAAC,IAAKR,MAAM,CAACQ,CAAC,CAACC,WAAW,CAAC,CAAE;IACjDR,OAAO,EAAEA,OAAO,KAAK,MAAMA,OAAO,CAAC,CAAC,CAAC,CAAC,CAAE;IACxCC,KAAK,EAAEA,KAAiC;IACxCf,MAAM,EAAED,aAAa,CAACC,MAAM,CAAE;IAC9BW,aAAa,EAAEN,oBAAoB,CAACM,aAAa,CAAE;IACnDC,UAAU,EAAEL,iBAAiB,CAACK,UAAU;EAAE,GAC1C;AAEN,CAAC;AAED,eAAeH,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","Platform","StyleSheet","useForceUpdate","createStyleSheet","useUIKitTheme","Box","Icon","Image","useRetry","hasError","retryCount","arguments","length","undefined","OS","forceUpdate","retryCountRef","retryTimeoutRef","reloadReservation","current","setTimeout","clearTimeout","ImageWithPlaceholder","props","palette","select","colors","imageNotFound","setImageNotFound","key","createElement","style","overflow","width","height","backgroundColor","dark","background400","light","background100","source","absoluteFill","styles","hide","resizeMode","resizeMethod","onError","onLoad","containerStyle","icon","size","color","onBackground02","display"],"sources":["index.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Platform, StyleProp, StyleSheet, ViewStyle } from 'react-native';\n\nimport { useForceUpdate } from '@sendbird/uikit-utils';\n\nimport createStyleSheet from '../../styles/createStyleSheet';\nimport useUIKitTheme from '../../theme/useUIKitTheme';\nimport Box from '../Box';\nimport Icon from '../Icon';\nimport Image from '../Image';\n\nconst useRetry = (hasError: boolean, retryCount = 5) => {\n // NOTE: Glide(fast-image) will retry automatically on Android\n if (Platform.OS === 'android') return '';\n\n const forceUpdate = useForceUpdate();\n const retryCountRef = useRef(1);\n const retryTimeoutRef = useRef<NodeJS.Timeout>();\n\n useEffect(() => {\n if (hasError) {\n const reloadReservation = () => {\n if (retryCountRef.current < retryCount) {\n retryTimeoutRef.current = setTimeout(() => {\n retryCountRef.current++;\n reloadReservation();\n forceUpdate();\n }, retryCountRef.current * 5000);\n }\n };\n\n return reloadReservation();\n } else {\n return clearTimeout(retryTimeoutRef.current);\n }\n }, [hasError]);\n\n return retryCountRef.current;\n};\n\ntype Props = {\n source: number | { uri: string };\n width?: number |
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","useState","Platform","StyleSheet","useForceUpdate","createStyleSheet","useUIKitTheme","Box","Icon","Image","useRetry","hasError","retryCount","arguments","length","undefined","OS","forceUpdate","retryCountRef","retryTimeoutRef","reloadReservation","current","setTimeout","clearTimeout","ImageWithPlaceholder","props","palette","select","colors","imageNotFound","setImageNotFound","key","createElement","style","overflow","width","height","backgroundColor","dark","background400","light","background100","source","absoluteFill","styles","hide","resizeMode","resizeMethod","onError","onLoad","containerStyle","icon","size","color","onBackground02","display"],"sources":["index.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Platform, StyleProp, StyleSheet, ViewStyle } from 'react-native';\n\nimport { useForceUpdate } from '@sendbird/uikit-utils';\n\nimport createStyleSheet from '../../styles/createStyleSheet';\nimport useUIKitTheme from '../../theme/useUIKitTheme';\nimport Box from '../Box';\nimport Icon from '../Icon';\nimport Image from '../Image';\n\nconst useRetry = (hasError: boolean, retryCount = 5) => {\n // NOTE: Glide(fast-image) will retry automatically on Android\n if (Platform.OS === 'android') return '';\n\n const forceUpdate = useForceUpdate();\n const retryCountRef = useRef(1);\n const retryTimeoutRef = useRef<NodeJS.Timeout>();\n\n useEffect(() => {\n if (hasError) {\n const reloadReservation = () => {\n if (retryCountRef.current < retryCount) {\n retryTimeoutRef.current = setTimeout(() => {\n retryCountRef.current++;\n reloadReservation();\n forceUpdate();\n }, retryCountRef.current * 5000);\n }\n };\n\n return reloadReservation();\n } else {\n return clearTimeout(retryTimeoutRef.current);\n }\n }, [hasError]);\n\n return retryCountRef.current;\n};\n\ntype Props = {\n source: number | { uri: string };\n width?: number | `${number}%`;\n height?: number | `${number}%`;\n style?: StyleProp<ViewStyle>;\n};\nconst ImageWithPlaceholder = (props: Props) => {\n const { palette, select, colors } = useUIKitTheme();\n const [imageNotFound, setImageNotFound] = useState(false);\n\n const key = useRetry(imageNotFound);\n return (\n <Box\n style={[{ overflow: 'hidden', width: props.width, height: props.height }, props.style]}\n backgroundColor={select({ dark: palette.background400, light: palette.background100 })}\n >\n <Image\n key={key}\n source={props.source}\n style={[StyleSheet.absoluteFill, imageNotFound && styles.hide]}\n resizeMode={'cover'}\n resizeMethod={'resize'}\n onError={() => setImageNotFound(true)}\n onLoad={() => setImageNotFound(false)}\n />\n {imageNotFound && (\n <Icon\n containerStyle={StyleSheet.absoluteFill}\n icon={'thumbnail-none'}\n size={48}\n color={colors.onBackground02}\n />\n )}\n </Box>\n );\n};\n\nconst styles = createStyleSheet({\n hide: {\n display: 'none',\n },\n});\n\nexport default ImageWithPlaceholder;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC1D,SAASC,QAAQ,EAAaC,UAAU,QAAmB,cAAc;AAEzE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|
|
2
2
|
import { DEFAULT_SCALE_FACTOR } from './createScaleFactor';
|
|
3
|
-
const
|
|
3
|
+
const SCALE_FACTOR_WITH_DIMENSION_VALUE = val => {
|
|
4
|
+
return typeof val === 'number' ? DEFAULT_SCALE_FACTOR(val) : val;
|
|
5
|
+
};
|
|
6
|
+
const DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE = val => {
|
|
7
|
+
return typeof val === 'number' ? DEFAULT_SCALE_FACTOR(val) : val;
|
|
8
|
+
};
|
|
4
9
|
const preProcessor = {
|
|
5
10
|
'fontSize': DEFAULT_SCALE_FACTOR,
|
|
6
11
|
'lineHeight': DEFAULT_SCALE_FACTOR,
|
|
7
|
-
'borderRadius':
|
|
8
|
-
'minWidth':
|
|
9
|
-
'maxWidth':
|
|
10
|
-
'minHeight':
|
|
11
|
-
'maxHeight':
|
|
12
|
-
'height':
|
|
13
|
-
'width':
|
|
14
|
-
'padding':
|
|
15
|
-
'paddingVertical':
|
|
16
|
-
'paddingHorizontal':
|
|
17
|
-
'paddingTop':
|
|
18
|
-
'paddingBottom':
|
|
19
|
-
'paddingLeft':
|
|
20
|
-
'paddingRight':
|
|
21
|
-
'margin':
|
|
22
|
-
'marginVertical':
|
|
23
|
-
'marginHorizontal':
|
|
24
|
-
'marginTop':
|
|
25
|
-
'marginBottom':
|
|
26
|
-
'marginLeft':
|
|
27
|
-
'marginRight':
|
|
28
|
-
'left':
|
|
29
|
-
'right':
|
|
30
|
-
'top':
|
|
31
|
-
'bottom':
|
|
12
|
+
'borderRadius': DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE,
|
|
13
|
+
'minWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
14
|
+
'maxWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
15
|
+
'minHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
16
|
+
'maxHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
17
|
+
'height': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
18
|
+
'width': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
19
|
+
'padding': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
20
|
+
'paddingVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
21
|
+
'paddingHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
22
|
+
'paddingTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
23
|
+
'paddingBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
24
|
+
'paddingLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
25
|
+
'paddingRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
26
|
+
'margin': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
27
|
+
'marginVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
28
|
+
'marginHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
29
|
+
'marginTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
30
|
+
'marginBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
31
|
+
'marginLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
32
|
+
'marginRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
33
|
+
'left': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
34
|
+
'right': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
35
|
+
'top': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
36
|
+
'bottom': SCALE_FACTOR_WITH_DIMENSION_VALUE
|
|
32
37
|
};
|
|
33
38
|
const preProcessorKeys = Object.keys(preProcessor);
|
|
34
39
|
const preProcessorLen = preProcessorKeys.length;
|
|
@@ -39,6 +44,7 @@ const preProcessorLen = preProcessorKeys.length;
|
|
|
39
44
|
* @param styles
|
|
40
45
|
* @returns StyleSheet
|
|
41
46
|
* */
|
|
47
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
42
48
|
const createStyleSheet = styles => {
|
|
43
49
|
Object.values(styles).forEach(style => {
|
|
44
50
|
// @ts-ignore
|
|
@@ -52,5 +58,7 @@ const createStyleSheet = styles => {
|
|
|
52
58
|
});
|
|
53
59
|
return StyleSheet.create(styles);
|
|
54
60
|
};
|
|
61
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
62
|
+
|
|
55
63
|
export default createStyleSheet;
|
|
56
64
|
//# sourceMappingURL=createStyleSheet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","DEFAULT_SCALE_FACTOR","
|
|
1
|
+
{"version":3,"names":["StyleSheet","DEFAULT_SCALE_FACTOR","SCALE_FACTOR_WITH_DIMENSION_VALUE","val","DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE","preProcessor","preProcessorKeys","Object","keys","preProcessorLen","length","createStyleSheet","styles","values","forEach","style","styleKeys","styleLen","key","create"],"sources":["createStyleSheet.ts"],"sourcesContent":["import { ImageStyle, StyleSheet, TextStyle, ViewStyle } from 'react-native';\nimport { AnimatableNumericValue, DimensionValue } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\n\nimport { DEFAULT_SCALE_FACTOR } from './createScaleFactor';\n\ntype Styles = ViewStyle | TextStyle | ImageStyle;\ntype StylePreprocessor<T extends Styles = Styles> = { [key in keyof T]: (val: NonNullable<T[key]>) => typeof val };\n\nconst SCALE_FACTOR_WITH_DIMENSION_VALUE = (\n val: NonNullable<DimensionValue | undefined>,\n): NonNullable<DimensionValue | undefined> => {\n return typeof val === 'number' ? DEFAULT_SCALE_FACTOR(val) : val;\n};\n\nconst DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE = (\n val: NonNullable<AnimatableNumericValue | undefined>,\n): NonNullable<AnimatableNumericValue | undefined> => {\n return typeof val === 'number' ? DEFAULT_SCALE_FACTOR(val) : val;\n};\n\nconst preProcessor: Partial<StylePreprocessor> = {\n 'fontSize': DEFAULT_SCALE_FACTOR,\n 'lineHeight': DEFAULT_SCALE_FACTOR,\n 'borderRadius': DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE,\n 'minWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'maxWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'minHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'maxHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'height': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'width': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'padding': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'paddingRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'margin': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'marginRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'left': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'right': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'top': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n 'bottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,\n};\n\nconst preProcessorKeys = Object.keys(preProcessor);\nconst preProcessorLen = preProcessorKeys.length;\n\n/**\n * Create StyleSheet with customized pre-processor\n * Return a StyleSheet that pre-processed\n * @param styles\n * @returns StyleSheet\n * */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nconst createStyleSheet = <T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>>(\n styles: T & StyleSheet.NamedStyles<any>,\n): T => {\n Object.values(styles).forEach((style) => {\n // @ts-ignore\n const styleKeys = Object.keys(style);\n const styleLen = styleKeys.length;\n\n const keys = styleLen < preProcessorLen ? styleKeys : preProcessorKeys;\n keys.forEach((key) => {\n // @ts-ignore\n if (preProcessor[key] && typeof style[key] !== 'undefined') style[key] = preProcessor[key](style[key]);\n });\n });\n\n return StyleSheet.create<T>(styles);\n};\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\nexport default createStyleSheet;\n"],"mappings":"AAAA,SAAqBA,UAAU,QAA8B,cAAc;AAG3E,SAASC,oBAAoB,QAAQ,qBAAqB;AAK1D,MAAMC,iCAAiC,GACrCC,GAA4C,IACA;EAC5C,OAAO,OAAOA,GAAG,KAAK,QAAQ,GAAGF,oBAAoB,CAACE,GAAG,CAAC,GAAGA,GAAG;AAClE,CAAC;AAED,MAAMC,uCAAuC,GAC3CD,GAAoD,IACA;EACpD,OAAO,OAAOA,GAAG,KAAK,QAAQ,GAAGF,oBAAoB,CAACE,GAAG,CAAC,GAAGA,GAAG;AAClE,CAAC;AAED,MAAME,YAAwC,GAAG;EAC/C,UAAU,EAAEJ,oBAAoB;EAChC,YAAY,EAAEA,oBAAoB;EAClC,cAAc,EAAEG,uCAAuC;EACvD,UAAU,EAAEF,iCAAiC;EAC7C,UAAU,EAAEA,iCAAiC;EAC7C,WAAW,EAAEA,iCAAiC;EAC9C,WAAW,EAAEA,iCAAiC;EAC9C,QAAQ,EAAEA,iCAAiC;EAC3C,OAAO,EAAEA,iCAAiC;EAC1C,SAAS,EAAEA,iCAAiC;EAC5C,iBAAiB,EAAEA,iCAAiC;EACpD,mBAAmB,EA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AACD;;AAEA,eAAeD,gBAAgB"}
|
|
@@ -4,8 +4,8 @@ type Props = {
|
|
|
4
4
|
source: number | {
|
|
5
5
|
uri: string;
|
|
6
6
|
};
|
|
7
|
-
width?: number |
|
|
8
|
-
height?: number |
|
|
7
|
+
width?: number | `${number}%`;
|
|
8
|
+
height?: number | `${number}%`;
|
|
9
9
|
style?: StyleProp<ViewStyle>;
|
|
10
10
|
};
|
|
11
11
|
declare const ImageWithPlaceholder: (props: Props) => React.JSX.Element;
|
|
@@ -5,5 +5,5 @@ import { StyleSheet } from 'react-native';
|
|
|
5
5
|
* @param styles
|
|
6
6
|
* @returns StyleSheet
|
|
7
7
|
* */
|
|
8
|
-
declare const createStyleSheet: <T extends StyleSheet.NamedStyles<T>>(styles: T
|
|
8
|
+
declare const createStyleSheet: <T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>>(styles: T & StyleSheet.NamedStyles<any>) => T;
|
|
9
9
|
export default createStyleSheet;
|
|
@@ -15,7 +15,7 @@ declare const _default: (({ uri, square, muted, size, containerStyle }: Props) =
|
|
|
15
15
|
children?: React.ReactNode;
|
|
16
16
|
}) => React.JSX.Element;
|
|
17
17
|
Icon: ({ size, icon, containerStyle, backgroundColor }: {
|
|
18
|
-
icon: "message" | "recording" | "done" | "search" | "chat-hide" | "chat-show" | "add" | "archive" | "arrow-left" | "audio-off-filled" | "audio-off" | "audio-on-filled" | "audio-on" | "ban" | "broadcast" | "camera" | "channels" | "chat-filled" | "chat" | "checkbox-off" | "checkbox-on" | "chevron-down" | "chevron-right" | "close" | "copy" | "create" | "delete" | "
|
|
18
|
+
icon: "message" | "recording" | "done" | "search" | "document" | "chat-hide" | "chat-show" | "add" | "archive" | "arrow-left" | "audio-off-filled" | "audio-off" | "audio-on-filled" | "audio-on" | "ban" | "broadcast" | "camera" | "channels" | "chat-filled" | "chat" | "checkbox-off" | "checkbox-on" | "chevron-down" | "chevron-right" | "close" | "copy" | "create" | "delete" | "done-all" | "download" | "edit" | "emoji-more" | "error" | "file-audio" | "file-document" | "freeze" | "gif" | "info" | "leave" | "members" | "moderation" | "more" | "mute" | "notifications-filled" | "notifications-off-filled" | "notifications" | "operator" | "pause" | "photo" | "play" | "plus" | "question" | "radio-off" | "radio-on" | "refresh" | "remove" | "reply-filled" | "reply" | "send" | "settings-filled" | "spinner" | "stop" | "streaming" | "supergroup" | "theme" | "thread" | "thumbnail-none" | "unarchive" | "user";
|
|
19
19
|
size?: number | undefined;
|
|
20
20
|
backgroundColor?: string | undefined;
|
|
21
21
|
containerStyle?: StyleProp<ViewStyle>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendbird/uikit-react-native-foundation",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.1",
|
|
4
4
|
"description": "A foundational UI kit for building chat-enabled React Native apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sendbird",
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@sendbird/uikit-utils": "3.
|
|
51
|
+
"@sendbird/uikit-utils": "3.7.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "*",
|
|
55
55
|
"@types/react-native": "*",
|
|
56
|
-
"react": "
|
|
57
|
-
"react-native": "0.
|
|
56
|
+
"react": "18.2.0",
|
|
57
|
+
"react-native": "0.74.3",
|
|
58
58
|
"react-native-builder-bob": "^0.18.0",
|
|
59
|
-
"react-native-fast-image": "^8.
|
|
60
|
-
"react-native-safe-area-context": "^
|
|
59
|
+
"react-native-fast-image": "^8.6.3",
|
|
60
|
+
"react-native-safe-area-context": "^4.10.8",
|
|
61
61
|
"typescript": "5.2.2"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
]
|
|
86
86
|
]
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "9d1b5148c4af415c985566bddb45a20c97b365fd"
|
|
89
89
|
}
|
|
@@ -27,9 +27,9 @@ function convertSource(source: SendbirdImageProps['source']): Source | number {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
|
-
uri: source
|
|
31
|
-
headers: source
|
|
32
|
-
cache: convertCache(source
|
|
30
|
+
uri: source?.uri,
|
|
31
|
+
headers: source?.headers,
|
|
32
|
+
cache: convertCache(source?.cache), //'immutable' | 'web' | 'cacheOnly'
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
function convertDefaultSource(source?: SendbirdImageProps['defaultSource']): number | undefined {
|
|
@@ -40,8 +40,8 @@ const useRetry = (hasError: boolean, retryCount = 5) => {
|
|
|
40
40
|
|
|
41
41
|
type Props = {
|
|
42
42
|
source: number | { uri: string };
|
|
43
|
-
width?: number |
|
|
44
|
-
height?: number |
|
|
43
|
+
width?: number | `${number}%`;
|
|
44
|
+
height?: number | `${number}%`;
|
|
45
45
|
style?: StyleProp<ViewStyle>;
|
|
46
46
|
};
|
|
47
47
|
const ImageWithPlaceholder = (props: Props) => {
|
|
@@ -1,40 +1,51 @@
|
|
|
1
1
|
import { ImageStyle, StyleSheet, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
import { AnimatableNumericValue, DimensionValue } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
|
|
2
3
|
|
|
3
4
|
import { DEFAULT_SCALE_FACTOR } from './createScaleFactor';
|
|
4
5
|
|
|
5
6
|
type Styles = ViewStyle | TextStyle | ImageStyle;
|
|
6
7
|
type StylePreprocessor<T extends Styles = Styles> = { [key in keyof T]: (val: NonNullable<T[key]>) => typeof val };
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
+
const SCALE_FACTOR_WITH_DIMENSION_VALUE = (
|
|
10
|
+
val: NonNullable<DimensionValue | undefined>,
|
|
11
|
+
): NonNullable<DimensionValue | undefined> => {
|
|
12
|
+
return typeof val === 'number' ? DEFAULT_SCALE_FACTOR(val) : val;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE = (
|
|
16
|
+
val: NonNullable<AnimatableNumericValue | undefined>,
|
|
17
|
+
): NonNullable<AnimatableNumericValue | undefined> => {
|
|
18
|
+
return typeof val === 'number' ? DEFAULT_SCALE_FACTOR(val) : val;
|
|
19
|
+
};
|
|
9
20
|
|
|
10
21
|
const preProcessor: Partial<StylePreprocessor> = {
|
|
11
22
|
'fontSize': DEFAULT_SCALE_FACTOR,
|
|
12
23
|
'lineHeight': DEFAULT_SCALE_FACTOR,
|
|
13
|
-
'borderRadius':
|
|
14
|
-
'minWidth':
|
|
15
|
-
'maxWidth':
|
|
16
|
-
'minHeight':
|
|
17
|
-
'maxHeight':
|
|
18
|
-
'height':
|
|
19
|
-
'width':
|
|
20
|
-
'padding':
|
|
21
|
-
'paddingVertical':
|
|
22
|
-
'paddingHorizontal':
|
|
23
|
-
'paddingTop':
|
|
24
|
-
'paddingBottom':
|
|
25
|
-
'paddingLeft':
|
|
26
|
-
'paddingRight':
|
|
27
|
-
'margin':
|
|
28
|
-
'marginVertical':
|
|
29
|
-
'marginHorizontal':
|
|
30
|
-
'marginTop':
|
|
31
|
-
'marginBottom':
|
|
32
|
-
'marginLeft':
|
|
33
|
-
'marginRight':
|
|
34
|
-
'left':
|
|
35
|
-
'right':
|
|
36
|
-
'top':
|
|
37
|
-
'bottom':
|
|
24
|
+
'borderRadius': DEFAULT_SCALE_FACTOR_WITH_NUMERIC_VALUE,
|
|
25
|
+
'minWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
26
|
+
'maxWidth': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
27
|
+
'minHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
28
|
+
'maxHeight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
29
|
+
'height': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
30
|
+
'width': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
31
|
+
'padding': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
32
|
+
'paddingVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
33
|
+
'paddingHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
34
|
+
'paddingTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
35
|
+
'paddingBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
36
|
+
'paddingLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
37
|
+
'paddingRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
38
|
+
'margin': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
39
|
+
'marginVertical': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
40
|
+
'marginHorizontal': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
41
|
+
'marginTop': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
42
|
+
'marginBottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
43
|
+
'marginLeft': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
44
|
+
'marginRight': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
45
|
+
'left': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
46
|
+
'right': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
47
|
+
'top': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
48
|
+
'bottom': SCALE_FACTOR_WITH_DIMENSION_VALUE,
|
|
38
49
|
};
|
|
39
50
|
|
|
40
51
|
const preProcessorKeys = Object.keys(preProcessor);
|
|
@@ -46,7 +57,10 @@ const preProcessorLen = preProcessorKeys.length;
|
|
|
46
57
|
* @param styles
|
|
47
58
|
* @returns StyleSheet
|
|
48
59
|
* */
|
|
49
|
-
|
|
60
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
61
|
+
const createStyleSheet = <T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>>(
|
|
62
|
+
styles: T & StyleSheet.NamedStyles<any>,
|
|
63
|
+
): T => {
|
|
50
64
|
Object.values(styles).forEach((style) => {
|
|
51
65
|
// @ts-ignore
|
|
52
66
|
const styleKeys = Object.keys(style);
|
|
@@ -61,5 +75,6 @@ const createStyleSheet = <T extends StyleSheet.NamedStyles<T>>(styles: T | Style
|
|
|
61
75
|
|
|
62
76
|
return StyleSheet.create<T>(styles);
|
|
63
77
|
};
|
|
78
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
64
79
|
|
|
65
80
|
export default createStyleSheet;
|