@momo-kits/suggest-action 0.80.9 → 0.81.2

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 (3) hide show
  1. package/index.tsx +34 -27
  2. package/package.json +1 -1
  3. package/types.ts +5 -12
package/index.tsx CHANGED
@@ -17,24 +17,6 @@ import {
17
17
  } from '@momo-kits/foundation';
18
18
  import styles from './styles';
19
19
 
20
- const contents = {
21
- addToFavorite: {
22
- prefix: 'Thêm',
23
- postfix: 'vào dịch vụ yêu thích',
24
- buttonTitle: 'Thêm ngay',
25
- },
26
- addToDevice: {
27
- prefix: 'Thêm',
28
- postfix: 'ra ngoài màn hình thiết bị',
29
- buttonTitle: 'Thêm ngay',
30
- },
31
- share: {
32
- prefix: 'Chia sẻ',
33
- postfix: 'với người khác ngay',
34
- buttonTitle: 'Chia sẻ',
35
- },
36
- };
37
-
38
20
  const DURATION = 200;
39
21
 
40
22
  const SuggestAction: ForwardRefRenderFunction<
@@ -44,10 +26,11 @@ const SuggestAction: ForwardRefRenderFunction<
44
26
  {
45
27
  image,
46
28
  onPressButton = () => {},
47
- name,
48
29
  onClose,
49
- type = 'addToFavorite',
50
30
  bottom = 72,
31
+ message = 'Message',
32
+ buttonTitle = 'Button',
33
+ boldMessage,
51
34
  },
52
35
  ref,
53
36
  ) => {
@@ -82,6 +65,34 @@ const SuggestAction: ForwardRefRenderFunction<
82
65
  hide();
83
66
  };
84
67
 
68
+ const renderMessage = () => {
69
+ if (!!boldMessage) {
70
+ let splitMessage = [];
71
+ let index = message.toLowerCase().indexOf(boldMessage.toLowerCase());
72
+ if (index !== -1) {
73
+ splitMessage = [
74
+ message.substring(0, index),
75
+ boldMessage,
76
+ message.substring(index + boldMessage.length),
77
+ ];
78
+
79
+ return (
80
+ <Text style={styles.content} typography={'paragraph_default'}>
81
+ {splitMessage[0]}
82
+ <Text typography={'action_s'}>{splitMessage[1]}</Text>
83
+ {splitMessage[2]}
84
+ </Text>
85
+ );
86
+ }
87
+ }
88
+
89
+ return (
90
+ <Text style={styles.content} typography={'description_s'}>
91
+ {message}
92
+ </Text>
93
+ );
94
+ };
95
+
85
96
  return (
86
97
  <Animated.View
87
98
  style={[
@@ -93,15 +104,11 @@ const SuggestAction: ForwardRefRenderFunction<
93
104
  },
94
105
  Shadow.Light,
95
106
  ]}>
96
- <Image source={{uri: image}} style={styles.image} />
97
- <Text style={styles.content} typography={'description_s'}>
98
- {contents[type].prefix}
99
- <Text typography={'action_xs'}>{` ${name} `}</Text>
100
- {contents[type].postfix}
101
- </Text>
107
+ {!!image && <Image source={{uri: image}} style={styles.image} />}
108
+ {renderMessage()}
102
109
  <Button
103
110
  type="tonal"
104
- title={contents[type].buttonTitle}
111
+ title={buttonTitle}
105
112
  onPress={handleButtonPress}
106
113
  size={'small'}
107
114
  full={false}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/suggest-action",
3
- "version": "0.80.9",
3
+ "version": "0.81.2",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "dependencies": {},
package/types.ts CHANGED
@@ -1,9 +1,4 @@
1
1
  export type SuggestActionProps = {
2
- /**
3
- * The name of the action to be displayed.
4
- */
5
- name: string;
6
-
7
2
  /**
8
3
  * Optional. A callback function that is triggered when the action suggestion is closed.
9
4
  */
@@ -17,18 +12,16 @@ export type SuggestActionProps = {
17
12
  /**
18
13
  * The image associated with the action, typically displayed as part of the suggestion.
19
14
  */
20
- image: string;
21
-
22
- /**
23
- * Optional. Specifies the type of the action, such as adding to favorites, adding to device, or sharing.
24
- * Can be one of 'addToFavorite', 'addToDevice', or 'share'.
25
- */
26
- type?: 'addToFavorite' | 'addToDevice' | 'share';
15
+ image?: string;
27
16
 
28
17
  /**
29
18
  * Optional. Specifies the bottom margin for the component. Useful for positioning or spacing within a layout.
30
19
  */
31
20
  bottom?: number;
21
+
22
+ message: string;
23
+ buttonTitle: string;
24
+ boldMessage?: string;
32
25
  };
33
26
 
34
27
  /**