@widergy/mobile-ui 1.32.13 → 1.32.15

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.32.15](https://github.com/widergy/mobile-ui/compare/v1.32.14...v1.32.15) (2025-01-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * [EVE-4361] bottom sheet actions ([#389](https://github.com/widergy/mobile-ui/issues/389)) ([97ed997](https://github.com/widergy/mobile-ui/commit/97ed997423209b0901c061abc82ea4656d210b91))
7
+
8
+ ## [1.32.14](https://github.com/widergy/mobile-ui/compare/v1.32.13...v1.32.14) (2025-01-02)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * [EVE-4365] status message header ([#400](https://github.com/widergy/mobile-ui/issues/400)) ([dee9119](https://github.com/widergy/mobile-ui/commit/dee9119464bf4583eee62bafdc3dd8e42581d369))
14
+
1
15
  ## [1.32.13](https://github.com/widergy/mobile-ui/compare/v1.32.12...v1.32.13) (2024-12-20)
2
16
 
3
17
 
@@ -6,15 +6,35 @@
6
6
 
7
7
  ## Props
8
8
 
9
- | Name | Type | Default | Description |
10
- | ----------- | ------ | ------- | ----------------------------------------------------------------------- |
11
- | buttonText | string | | Text for the button that appears in the top right corner of the header. |
12
- | description | string | | Description that appears below the title in the header. |
13
- | onClose | func | | Function called when the bottom sheet is closed. |
14
- | required | bool | | Indicates if the field is required, showing an asterisk in the title. |
15
- | title | string | | Title that appears in the bottom sheet header. |
16
- | visible | bool | | Controls the visibility of the bottom sheet. |
17
- | scrolleable | bool | false | Determines if the content inside the bottom sheet should be scrollable. |
9
+ | Name | Type | Default | Description |
10
+ | ------------------------- | -------- | ----------- | --------------------------------------------------------------------------- |
11
+ | `buttonText` | `string` | | Text for the button that appears in the top right corner of the header. |
12
+ | `description` | `string` | | Description that appears below the title in the header. |
13
+ | `onClose` | `func` | | Function called when the bottom sheet is closed. |
14
+ | `required` | `bool` | | Indicates if the field is required, showing an asterisk in the title. |
15
+ | `title` | `string` | | Title that appears in the bottom sheet header. |
16
+ | `visible` | `bool` | | Controls the visibility of the bottom sheet. |
17
+ | `scrolleable` | `bool` | `false` | Determines if the content inside the bottom sheet should be scrollable. |
18
+ | `actionAlignment` | `string` | | Aligns the actions. |
19
+ | `onCloseProps` | `object` | | Additional props passed to the `onClose` function (optional). |
20
+ | `primaryAction` | `func` | | Callback for the primary action button. |
21
+ | `primaryActionProps` | `object` | | Props for the primary action button. |
22
+ | `primaryActionText` | `string` | | Text for the primary action button. |
23
+ | `secondaryAction` | `func` | | Callback for the secondary action button. |
24
+ | `secondaryActionProps` | `object` | | Props for the secondary action button. |
25
+ | `secondaryActionText` | `string` | | Text for the secondary action button. |
26
+ | `tertiaryAction` | `func` | | Callback for the tertiary action button. |
27
+ | `tertiaryActionProps` | `object` | | Props for the tertiary action button . |
28
+ | `tertiaryActionText` | `string` | | Text for the tertiary action button. |
29
+
30
+ ### actionAlignment
31
+
32
+ The value of `actionAlignment` must be one of the following:
33
+
34
+ - `horizontal`
35
+ - `vertical`
36
+
37
+ By default, actions are aligned horizontally if there are two, and vertically otherwise.
18
38
 
19
39
  ## Example
20
40
 
@@ -0,0 +1,4 @@
1
+ export const ACTION_ALIGNMENTS = {
2
+ HORIZONTAL: 'horizontal',
3
+ VERTICAL: 'vertical'
4
+ };
@@ -1,7 +1,7 @@
1
1
  import React, { useRef, useState, useEffect, useCallback, useMemo } from 'react';
2
2
  import { SafeAreaView, View, PanResponder, Animated, Dimensions, ScrollView, Keyboard } from 'react-native';
3
3
  import Modal from 'react-native-modal';
4
- import { bool, func, string } from 'prop-types';
4
+ import { bool, func, object, string } from 'prop-types';
5
5
 
6
6
  import { useTheme } from '../../theming';
7
7
  import UTButton from '../UTButton';
@@ -9,16 +9,28 @@ import UTFieldLabel from '../UTFieldLabel';
9
9
  import UTLabel from '../UTLabel';
10
10
 
11
11
  import styles from './styles';
12
+ import { ACTION_ALIGNMENTS } from './constants';
12
13
 
13
14
  const screenHeight = Dimensions.get('window').height;
14
15
 
15
16
  const UTBottomSheet = ({
17
+ actionAlignment: actionAlignment_,
16
18
  buttonText,
17
19
  children,
18
20
  description,
19
21
  onClose,
22
+ onCloseProps = {},
23
+ primaryAction,
24
+ primaryActionProps = {},
25
+ primaryActionText,
20
26
  required,
21
27
  scrolleable,
28
+ secondaryAction,
29
+ secondaryActionProps = {},
30
+ secondaryActionText,
31
+ tertiaryAction,
32
+ tertiaryActionProps = {},
33
+ tertiaryActionText,
22
34
  title,
23
35
  visible
24
36
  }) => {
@@ -76,6 +88,11 @@ const UTBottomSheet = ({
76
88
 
77
89
  const ChildrenContainer = scrolleable ? ScrollView : View;
78
90
 
91
+ const actionAlignment =
92
+ actionAlignment_ || [primaryAction, secondaryAction, tertiaryAction].filter(Boolean).length === 2
93
+ ? ACTION_ALIGNMENTS.HORIZONTAL
94
+ : ACTION_ALIGNMENTS.VERTICAL;
95
+
79
96
  return (
80
97
  <Modal
81
98
  animationIn="slideInUp"
@@ -101,7 +118,12 @@ const UTBottomSheet = ({
101
118
  {title}
102
119
  </UTFieldLabel>
103
120
  {buttonText && (
104
- <UTButton colorTheme="primary" onPress={onClose} variant="semitransparent">
121
+ <UTButton
122
+ colorTheme="primary"
123
+ onPress={onClose}
124
+ variant="semitransparent"
125
+ {...onCloseProps}
126
+ >
105
127
  {buttonText}
106
128
  </UTButton>
107
129
  )}
@@ -116,6 +138,43 @@ const UTBottomSheet = ({
116
138
  {children}
117
139
  </ChildrenContainer>
118
140
  </View>
141
+ <View style={styles.actions(actionAlignment)}>
142
+ {[
143
+ {
144
+ key: 'primaryAction',
145
+ onPress: primaryAction,
146
+ text: primaryActionText,
147
+ ...primaryActionProps
148
+ },
149
+ {
150
+ key: 'secondaryAction',
151
+ onPress: secondaryAction,
152
+ text: secondaryActionText,
153
+ variant: 'semitransparent',
154
+ ...secondaryActionProps
155
+ },
156
+ {
157
+ key: 'tertiaryAction',
158
+ onPress: tertiaryAction,
159
+ text: tertiaryActionText,
160
+ variant: 'text',
161
+ ...tertiaryActionProps
162
+ }
163
+ ].map(
164
+ ({ text, key, onPress, ...actionProps }) =>
165
+ onPress && (
166
+ <UTButton
167
+ key={key}
168
+ onPress={onPress}
169
+ size="large"
170
+ style={styles.action(actionAlignment)}
171
+ {...actionProps}
172
+ >
173
+ {text}
174
+ </UTButton>
175
+ )
176
+ )}
177
+ </View>
119
178
  </SafeAreaView>
120
179
  </Animated.View>
121
180
  </Modal>
@@ -127,11 +186,22 @@ UTBottomSheet.defaultProps = {
127
186
  };
128
187
 
129
188
  UTBottomSheet.propTypes = {
189
+ actionAlignment: string,
130
190
  buttonText: string,
131
191
  description: string,
132
192
  onClose: func,
193
+ onCloseProps: object,
194
+ primaryAction: func,
195
+ primaryActionProps: object,
196
+ primaryActionText: string,
133
197
  required: bool,
134
198
  scrolleable: bool,
199
+ secondaryAction: func,
200
+ secondaryActionProps: object,
201
+ secondaryActionText: string,
202
+ tertiaryAction: func,
203
+ tertiaryActionProps: object,
204
+ tertiaryActionText: string,
135
205
  title: string,
136
206
  visible: bool
137
207
  };
@@ -1,5 +1,7 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
+ import { ACTION_ALIGNMENTS } from './constants';
4
+
3
5
  const styles = StyleSheet.create({
4
6
  animatedContainer: {
5
7
  backgroundColor: 'white', // When the component is standardized, should change to palette color
@@ -44,7 +46,32 @@ const styles = StyleSheet.create({
44
46
  },
45
47
  title: {
46
48
  flex: 1
47
- }
49
+ },
50
+ action: actionAlignment => ({
51
+ root: {
52
+ display: 'flex',
53
+ alignItems: 'center',
54
+ flexGrow: 1,
55
+ borderRadius: {
56
+ [ACTION_ALIGNMENTS.VERTICAL]: 4,
57
+ [ACTION_ALIGNMENTS.HORIZONTAL]: 0
58
+ }[actionAlignment]
59
+ }
60
+ }),
61
+ actions: actionAlignment => ({
62
+ display: 'flex',
63
+ ...{
64
+ [ACTION_ALIGNMENTS.VERTICAL]: {
65
+ flexDirection: 'coloumn',
66
+ paddingHorizontal: 16,
67
+ gap: 8,
68
+ paddingBottom: 16
69
+ },
70
+ [ACTION_ALIGNMENTS.HORIZONTAL]: {
71
+ flexDirection: 'row'
72
+ }
73
+ }[actionAlignment]
74
+ })
48
75
  });
49
76
 
50
77
  export default styles;
@@ -7,15 +7,15 @@ The purpose of this component, as its name indicates, is to communicate a messag
7
7
  | Name | Type | Default | Description |
8
8
  | --------------------- | --------- | ------- | -------------------------------------------------------------------------------------------------------- |
9
9
  | children | element | | The content to be rendered inside the component. |
10
- | style | object | | Custom styles for styling the component. |
10
+ | style | object | | Custom styles for styling the component. |
11
11
  | colorTheme | string | default | Defines the color theme for the component. |
12
12
  | description | string | | Description text providing additional context or information. |
13
13
  | descriptionProps | object | | Props to be applied to the description UTLabel. |
14
14
  | helpText | string | | Help text displayed to guide the user. |
15
15
  | helpTextProps | object | | Props to be applied to the help text UTLabel. |
16
16
  | icon | string | | Icon to be displayed in the header. |
17
- | iconProps | object | | Props to be applied to the UTIcon |
18
- | image | string | | URL of an image to be displayed in the header, replacing the icon. |
17
+ | iconProps | object | | Props to be applied to the UTIcon |
18
+ | HeaderComponent | element | | Component to be displayed in the header, replacing the icon. |
19
19
  | loading | bool | false | Indicates whether the component is in a loading state. Replaces the header. |
20
20
  | primaryAction | func | | Callback function for the primary action. |
21
21
  | primaryActionProps | object | | Props to be applied to the primary action UTButton. |
@@ -7,7 +7,6 @@ import UTButton from '../UTButton';
7
7
  import UTIcon from '../UTIcon';
8
8
  import UTLabel from '../UTLabel';
9
9
  import UTLoading from '../UTLoading';
10
- import UTImage from '../UTImage';
11
10
  import { withTheme } from '../../theming';
12
11
 
13
12
  import { ICON_COLOR_THEMES, COLOR_THEMES } from './constants';
@@ -18,11 +17,11 @@ const UTStatusMessage = ({
18
17
  colorTheme = COLOR_THEMES.DEFAULT,
19
18
  description,
20
19
  descriptionProps,
20
+ HeaderComponent,
21
21
  helpText,
22
22
  helpTextProps,
23
23
  icon = 'IconInfoCircle',
24
24
  iconProps = {},
25
- image,
26
25
  loading,
27
26
  primaryAction,
28
27
  primaryActionProps,
@@ -52,8 +51,8 @@ const UTStatusMessage = ({
52
51
  style={[ownStyles.banner(theme, colorTheme, showBanner), style.banner]}
53
52
  useAngle
54
53
  >
55
- {image ? (
56
- <UTImage source={image} style={{ ...style.image }} />
54
+ {HeaderComponent ? (
55
+ <HeaderComponent />
57
56
  ) : (
58
57
  <IconContainer
59
58
  angle={45}
@@ -111,11 +110,11 @@ UTStatusMessage.propTypes = {
111
110
  colorTheme: string,
112
111
  description: string,
113
112
  descriptionProps: object,
113
+ HeaderComponent: element,
114
114
  helpText: string,
115
115
  helpTextProps: object,
116
116
  icon: string,
117
117
  iconProps: object,
118
- image: string,
119
118
  loading: bool,
120
119
  primaryAction: func,
121
120
  primaryActionProps: object,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@widergy/mobile-ui",
3
3
  "description": "Widergy Mobile Components",
4
4
  "author": "widergy",
5
- "version": "1.32.13",
5
+ "version": "1.32.15",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [