@sendbird/uikit-react-native-foundation 2.3.0 → 2.4.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/Box/index.js +46 -0
- package/lib/commonjs/components/Box/index.js.map +1 -0
- package/lib/commonjs/components/ImageWithPlaceholder/index.js +92 -0
- package/lib/commonjs/components/ImageWithPlaceholder/index.js.map +1 -0
- package/lib/commonjs/components/PressBox/index.js +60 -0
- package/lib/commonjs/components/PressBox/index.js.map +1 -0
- package/lib/commonjs/index.js +39 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/theme/DarkUIKitTheme.js +220 -179
- package/lib/commonjs/theme/DarkUIKitTheme.js.map +1 -1
- package/lib/commonjs/theme/LightUIKitTheme.js +220 -179
- package/lib/commonjs/theme/LightUIKitTheme.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui/Header/index.js +4 -2
- package/lib/commonjs/ui/Header/index.js.map +1 -1
- package/lib/commonjs/ui/OpenChannelMessage/Message.admin.js +40 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.admin.js.map +1 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.file.image.js +57 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.file.image.js.map +1 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.file.js +90 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.file.js.map +1 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.file.video.js +134 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.file.video.js.map +1 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.unknown.js +55 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.unknown.js.map +1 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.user.js +83 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.user.js.map +1 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.user.og.js +140 -0
- package/lib/commonjs/ui/OpenChannelMessage/Message.user.og.js.map +1 -0
- package/lib/commonjs/ui/OpenChannelMessage/MessageContainer.js +136 -0
- package/lib/commonjs/ui/OpenChannelMessage/MessageContainer.js.map +1 -0
- package/lib/commonjs/ui/OpenChannelMessage/index.js +35 -0
- package/lib/commonjs/ui/OpenChannelMessage/index.js.map +1 -0
- package/lib/commonjs/ui/OpenChannelPreview/index.js +134 -0
- package/lib/commonjs/ui/OpenChannelPreview/index.js.map +1 -0
- package/lib/module/components/Box/index.js +33 -0
- package/lib/module/components/Box/index.js.map +1 -0
- package/lib/module/components/ImageWithPlaceholder/index.js +71 -0
- package/lib/module/components/ImageWithPlaceholder/index.js.map +1 -0
- package/lib/module/components/PressBox/index.js +45 -0
- package/lib/module/components/PressBox/index.js.map +1 -0
- package/lib/module/index.js +6 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/theme/DarkUIKitTheme.js +220 -179
- package/lib/module/theme/DarkUIKitTheme.js.map +1 -1
- package/lib/module/theme/LightUIKitTheme.js +220 -179
- package/lib/module/theme/LightUIKitTheme.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui/Header/index.js +4 -2
- package/lib/module/ui/Header/index.js.map +1 -1
- package/lib/module/ui/OpenChannelMessage/Message.admin.js +27 -0
- package/lib/module/ui/OpenChannelMessage/Message.admin.js.map +1 -0
- package/lib/module/ui/OpenChannelMessage/Message.file.image.js +41 -0
- package/lib/module/ui/OpenChannelMessage/Message.file.image.js.map +1 -0
- package/lib/module/ui/OpenChannelMessage/Message.file.js +71 -0
- package/lib/module/ui/OpenChannelMessage/Message.file.js.map +1 -0
- package/lib/module/ui/OpenChannelMessage/Message.file.video.js +112 -0
- package/lib/module/ui/OpenChannelMessage/Message.file.video.js.map +1 -0
- package/lib/module/ui/OpenChannelMessage/Message.unknown.js +41 -0
- package/lib/module/ui/OpenChannelMessage/Message.unknown.js.map +1 -0
- package/lib/module/ui/OpenChannelMessage/Message.user.js +67 -0
- package/lib/module/ui/OpenChannelMessage/Message.user.js.map +1 -0
- package/lib/module/ui/OpenChannelMessage/Message.user.og.js +121 -0
- package/lib/module/ui/OpenChannelMessage/Message.user.og.js.map +1 -0
- package/lib/module/ui/OpenChannelMessage/MessageContainer.js +116 -0
- package/lib/module/ui/OpenChannelMessage/MessageContainer.js.map +1 -0
- package/lib/module/ui/OpenChannelMessage/index.js +18 -0
- package/lib/module/ui/OpenChannelMessage/index.js.map +1 -0
- package/lib/module/ui/OpenChannelPreview/index.js +117 -0
- package/lib/module/ui/OpenChannelPreview/index.js.map +1 -0
- package/lib/typescript/src/components/Box/index.d.ts +11 -0
- package/lib/typescript/src/components/ImageWithPlaceholder/index.d.ts +11 -0
- package/lib/typescript/src/components/PressBox/index.d.ts +16 -0
- package/lib/typescript/src/index.d.ts +8 -1
- package/lib/typescript/src/types.d.ts +21 -5
- package/lib/typescript/src/ui/Header/index.d.ts +1 -0
- package/lib/typescript/src/ui/OpenChannelMessage/Message.admin.d.ts +4 -0
- package/lib/typescript/src/ui/OpenChannelMessage/Message.file.d.ts +5 -0
- package/lib/typescript/src/ui/OpenChannelMessage/Message.file.image.d.ts +4 -0
- package/lib/typescript/src/ui/OpenChannelMessage/Message.file.video.d.ts +9 -0
- package/lib/typescript/src/ui/OpenChannelMessage/Message.unknown.d.ts +4 -0
- package/lib/typescript/src/ui/OpenChannelMessage/Message.user.d.ts +5 -0
- package/lib/typescript/src/ui/OpenChannelMessage/Message.user.og.d.ts +5 -0
- package/lib/typescript/src/ui/OpenChannelMessage/MessageContainer.d.ts +7 -0
- package/lib/typescript/src/ui/OpenChannelMessage/index.d.ts +136 -0
- package/lib/typescript/src/ui/OpenChannelPreview/index.d.ts +10 -0
- package/package.json +4 -4
- package/src/components/Box/index.tsx +65 -0
- package/src/components/ImageWithPlaceholder/index.tsx +83 -0
- package/src/components/PressBox/index.tsx +53 -0
- package/src/index.ts +8 -1
- package/src/theme/DarkUIKitTheme.ts +213 -171
- package/src/theme/LightUIKitTheme.ts +213 -171
- package/src/types.ts +41 -6
- package/src/ui/Header/index.tsx +7 -2
- package/src/ui/OpenChannelMessage/Message.admin.tsx +24 -0
- package/src/ui/OpenChannelMessage/Message.file.image.tsx +34 -0
- package/src/ui/OpenChannelMessage/Message.file.tsx +67 -0
- package/src/ui/OpenChannelMessage/Message.file.video.tsx +93 -0
- package/src/ui/OpenChannelMessage/Message.unknown.tsx +31 -0
- package/src/ui/OpenChannelMessage/Message.user.og.tsx +120 -0
- package/src/ui/OpenChannelMessage/Message.user.tsx +61 -0
- package/src/ui/OpenChannelMessage/MessageContainer.tsx +121 -0
- package/src/ui/OpenChannelMessage/index.ts +42 -0
- package/src/ui/OpenChannelPreview/index.tsx +97 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
customCover?: React.ReactElement;
|
|
4
|
+
coverUrl: string;
|
|
5
|
+
title: string;
|
|
6
|
+
participantsCount?: number;
|
|
7
|
+
frozen?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const OpenChannelPreview: ({ customCover, coverUrl, participantsCount, title, frozen }: Props) => JSX.Element;
|
|
10
|
+
export default OpenChannelPreview;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendbird/uikit-react-native-foundation",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "react-native-uikit",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@sendbird/uikit-utils": "2.
|
|
42
|
+
"@sendbird/uikit-utils": "2.4.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/react": "*",
|
|
46
46
|
"@types/react-native": "*",
|
|
47
47
|
"react": "17.0.2",
|
|
48
|
-
"react-native": "0.67.
|
|
48
|
+
"react-native": "0.67.5",
|
|
49
49
|
"react-native-builder-bob": "^0.18.0",
|
|
50
50
|
"react-native-fast-image": "^8.5.11",
|
|
51
51
|
"react-native-safe-area-context": "^3.3.2",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"readmeFile": "./README.md",
|
|
82
82
|
"displayName": "@sendbird/uikit-react-native-foundation"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "9ba7a005c941a3edd5b0f78d88d8cd1df6c280fc"
|
|
85
85
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, View, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { isFunction } from '@sendbird/uikit-utils';
|
|
5
|
+
|
|
6
|
+
import useUIKitTheme from '../../theme/useUIKitTheme';
|
|
7
|
+
import type { UIKitColors, UIKitPalette } from '../../types';
|
|
8
|
+
|
|
9
|
+
type BaseBoxProps = Pick<
|
|
10
|
+
ViewStyle,
|
|
11
|
+
| 'flex'
|
|
12
|
+
| 'flexShrink'
|
|
13
|
+
| 'flexGrow'
|
|
14
|
+
| 'flexDirection'
|
|
15
|
+
| 'alignItems'
|
|
16
|
+
| 'justifyContent'
|
|
17
|
+
| 'borderRadius'
|
|
18
|
+
| 'borderWidth'
|
|
19
|
+
| 'borderColor'
|
|
20
|
+
| 'borderBottomColor'
|
|
21
|
+
| 'borderBottomWidth'
|
|
22
|
+
| 'margin'
|
|
23
|
+
| 'marginHorizontal'
|
|
24
|
+
| 'marginVertical'
|
|
25
|
+
| 'marginLeft'
|
|
26
|
+
| 'marginRight'
|
|
27
|
+
| 'marginTop'
|
|
28
|
+
| 'marginBottom'
|
|
29
|
+
| 'padding'
|
|
30
|
+
| 'paddingHorizontal'
|
|
31
|
+
| 'paddingVertical'
|
|
32
|
+
| 'paddingLeft'
|
|
33
|
+
| 'paddingRight'
|
|
34
|
+
| 'paddingTop'
|
|
35
|
+
| 'paddingBottom'
|
|
36
|
+
| 'overflow'
|
|
37
|
+
| 'width'
|
|
38
|
+
| 'height'
|
|
39
|
+
> & {
|
|
40
|
+
backgroundColor?: string | ((theme: { colors: UIKitColors; palette: UIKitPalette }) => string);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type BoxProps = BaseBoxProps & ViewProps;
|
|
44
|
+
const Box = ({ style, children, ...props }: BoxProps) => {
|
|
45
|
+
const boxStyle = useBoxStyle(props);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<View style={[boxStyle, style]} {...props}>
|
|
49
|
+
{children}
|
|
50
|
+
</View>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const useBoxStyle = (props: BaseBoxProps): StyleProp<ViewStyle> => {
|
|
55
|
+
const theme = useUIKitTheme();
|
|
56
|
+
|
|
57
|
+
const { backgroundColor, ...rest } = props;
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
backgroundColor: isFunction(backgroundColor) ? backgroundColor(theme) : backgroundColor,
|
|
61
|
+
...rest,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default Box;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Platform, StyleProp, StyleSheet, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useForceUpdate } from '@sendbird/uikit-utils';
|
|
5
|
+
|
|
6
|
+
import createStyleSheet from '../../styles/createStyleSheet';
|
|
7
|
+
import useUIKitTheme from '../../theme/useUIKitTheme';
|
|
8
|
+
import Box from '../Box';
|
|
9
|
+
import Icon from '../Icon';
|
|
10
|
+
import Image from '../Image';
|
|
11
|
+
|
|
12
|
+
const useRetry = (hasError: boolean, retryCount = 5) => {
|
|
13
|
+
if (Platform.OS === 'android') return '';
|
|
14
|
+
|
|
15
|
+
const forceUpdate = useForceUpdate();
|
|
16
|
+
const retryCountRef = useRef(1);
|
|
17
|
+
const retryTimeoutRef = useRef<NodeJS.Timeout>();
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (hasError) {
|
|
21
|
+
const reloadReservation = () => {
|
|
22
|
+
if (retryCountRef.current < retryCount) {
|
|
23
|
+
retryTimeoutRef.current = setTimeout(() => {
|
|
24
|
+
retryCountRef.current++;
|
|
25
|
+
reloadReservation();
|
|
26
|
+
forceUpdate();
|
|
27
|
+
}, retryCountRef.current * 5000);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return reloadReservation();
|
|
32
|
+
} else {
|
|
33
|
+
return clearTimeout(retryTimeoutRef.current);
|
|
34
|
+
}
|
|
35
|
+
}, [hasError]);
|
|
36
|
+
|
|
37
|
+
return retryCountRef.current;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type Props = {
|
|
41
|
+
source: number | { uri: string };
|
|
42
|
+
width?: number | string;
|
|
43
|
+
height?: number | string;
|
|
44
|
+
style?: StyleProp<ViewStyle>;
|
|
45
|
+
};
|
|
46
|
+
const ImageWithPlaceholder = (props: Props) => {
|
|
47
|
+
const { colors } = useUIKitTheme();
|
|
48
|
+
const [imageNotFound, setImageNotFound] = useState(false);
|
|
49
|
+
|
|
50
|
+
const key = useRetry(imageNotFound);
|
|
51
|
+
return (
|
|
52
|
+
<Box
|
|
53
|
+
style={[{ overflow: 'hidden', width: props.width, height: props.height }, props.style]}
|
|
54
|
+
backgroundColor={colors.onBackground04}
|
|
55
|
+
>
|
|
56
|
+
<Image
|
|
57
|
+
key={key}
|
|
58
|
+
source={props.source}
|
|
59
|
+
style={[StyleSheet.absoluteFill, imageNotFound && styles.hide]}
|
|
60
|
+
resizeMode={'cover'}
|
|
61
|
+
resizeMethod={'resize'}
|
|
62
|
+
onError={() => setImageNotFound(true)}
|
|
63
|
+
onLoad={() => setImageNotFound(false)}
|
|
64
|
+
/>
|
|
65
|
+
{imageNotFound && (
|
|
66
|
+
<Icon
|
|
67
|
+
containerStyle={StyleSheet.absoluteFill}
|
|
68
|
+
icon={'thumbnail-none'}
|
|
69
|
+
size={48}
|
|
70
|
+
color={colors.onBackground02}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</Box>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const styles = createStyleSheet({
|
|
78
|
+
hide: {
|
|
79
|
+
display: 'none',
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export default ImageWithPlaceholder;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import type { GestureResponderEvent, StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import { Pressable, TouchableOpacity } from 'react-native';
|
|
5
|
+
|
|
6
|
+
import { isFunction } from '@sendbird/uikit-utils';
|
|
7
|
+
|
|
8
|
+
type PressBoxStateParams = {
|
|
9
|
+
pressed: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type Props = {
|
|
13
|
+
onPress?: (event: GestureResponderEvent) => void;
|
|
14
|
+
onLongPress?: (event: GestureResponderEvent) => void;
|
|
15
|
+
delayLongPress?: number;
|
|
16
|
+
activeOpacity?: number;
|
|
17
|
+
style?: StyleProp<ViewStyle> | ((state: PressBoxStateParams) => StyleProp<ViewStyle>);
|
|
18
|
+
children?: React.ReactNode | ((params: PressBoxStateParams) => React.ReactNode);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const DEFAULT_LONG_PRESS_DELAY = 350;
|
|
22
|
+
|
|
23
|
+
const PressBox = (props: Props) => {
|
|
24
|
+
if (props.activeOpacity && props.activeOpacity < 1) return <PressBoxWithTouchableOpacity {...props} />;
|
|
25
|
+
return <PressBoxWithPressable {...props} />;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const PressBoxWithPressable = ({ children, ...props }: Props) => {
|
|
29
|
+
return (
|
|
30
|
+
<Pressable disabled={!props.onPress && !props.onLongPress} delayLongPress={DEFAULT_LONG_PRESS_DELAY} {...props}>
|
|
31
|
+
{(state) => (isFunction(children) ? children(state) : children)}
|
|
32
|
+
</Pressable>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const PressBoxWithTouchableOpacity = ({ children, style, ...props }: Props) => {
|
|
37
|
+
const [pressed, setPressed] = useState(false);
|
|
38
|
+
const state: PressBoxStateParams = { pressed };
|
|
39
|
+
return (
|
|
40
|
+
<TouchableOpacity
|
|
41
|
+
disabled={!props.onPress && !props.onLongPress}
|
|
42
|
+
delayLongPress={DEFAULT_LONG_PRESS_DELAY}
|
|
43
|
+
style={isFunction(style) ? style(state) : style}
|
|
44
|
+
onPressIn={() => setPressed(true)}
|
|
45
|
+
onPressOut={() => setPressed(false)}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{isFunction(children) ? children(state) : children}
|
|
49
|
+
</TouchableOpacity>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default PressBox;
|
package/src/index.ts
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
export { default as IconAssets } from './assets/icon';
|
|
3
3
|
|
|
4
4
|
/** Component **/
|
|
5
|
+
export { default as Box } from './components/Box';
|
|
5
6
|
export { default as Divider } from './components/Divider';
|
|
6
7
|
export { default as Icon } from './components/Icon';
|
|
7
8
|
export { default as Image } from './components/Image';
|
|
9
|
+
export { default as ImageWithPlaceholder } from './components/ImageWithPlaceholder';
|
|
8
10
|
export { default as Modal } from './components/Modal';
|
|
11
|
+
export { default as PressBox } from './components/PressBox';
|
|
9
12
|
export { default as RegexText } from './components/RegexText';
|
|
10
13
|
export { default as Switch } from './components/Switch';
|
|
11
14
|
export { default as Text } from './components/Text';
|
|
@@ -24,7 +27,11 @@ export { DialogProvider, useActionMenu, useAlert, usePrompt, useBottomSheet } fr
|
|
|
24
27
|
export { default as GroupChannelPreview } from './ui/GroupChannelPreview';
|
|
25
28
|
export { default as Header } from './ui/Header';
|
|
26
29
|
export { default as LoadingSpinner } from './ui/LoadingSpinner';
|
|
27
|
-
export { default as MenuBar
|
|
30
|
+
export { default as MenuBar } from './ui/MenuBar';
|
|
31
|
+
export type { MenuBarProps } from './ui/MenuBar';
|
|
32
|
+
export { default as OpenChannelMessage } from './ui/OpenChannelMessage';
|
|
33
|
+
export type { OpenChannelMessageProps } from './ui/OpenChannelMessage';
|
|
34
|
+
export { default as OpenChannelPreview } from './ui/OpenChannelPreview';
|
|
28
35
|
export { default as OutlinedButton } from './ui/OutlinedButton';
|
|
29
36
|
export { default as Placeholder } from './ui/Placeholder';
|
|
30
37
|
export { default as ProfileCard } from './ui/ProfileCard';
|