@hero-design/rn 8.12.0 → 8.12.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.
Files changed (34) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/es/index.js +42 -9
  3. package/lib/index.js +42 -9
  4. package/package.json +5 -5
  5. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +17 -3
  6. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +17 -3
  7. package/src/components/List/BasicListItem.tsx +6 -0
  8. package/src/components/List/ListItem.tsx +6 -0
  9. package/src/components/List/StyledBasicListItem.tsx +2 -2
  10. package/src/components/List/StyledListItem.tsx +2 -2
  11. package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +22 -18
  12. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +32 -28
  13. package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +44 -36
  14. package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +50 -46
  15. package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +22 -18
  16. package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +33 -27
  17. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +4 -0
  18. package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +11 -9
  19. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +132 -108
  20. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +232 -139
  21. package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +11 -9
  22. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +132 -108
  23. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +232 -139
  24. package/src/components/TextInput/StyledTextInput.tsx +3 -0
  25. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +466 -28
  26. package/src/components/TextInput/__tests__/index.spec.tsx +32 -0
  27. package/src/components/TextInput/index.tsx +32 -4
  28. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +34 -6
  29. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +34 -6
  30. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +1 -0
  31. package/src/theme/components/textInput.ts +1 -0
  32. package/types/components/List/StyledBasicListItem.d.ts +3 -3
  33. package/types/components/List/StyledListItem.d.ts +3 -3
  34. package/types/theme/components/textInput.d.ts +1 -0
@@ -380,6 +380,38 @@ describe('TextInput', () => {
380
380
  });
381
381
  });
382
382
 
383
+ describe('backgroundColor', () => {
384
+ it('renders correctly', () => {
385
+ const wrapper = renderWithTheme(
386
+ <TextInput
387
+ label="Amount (AUD)"
388
+ prefix="dollar-sign"
389
+ required
390
+ helpText="This is helper text"
391
+ placeholder="Enter Amount"
392
+ defaultValue="1000"
393
+ value="2000"
394
+ maxLength={255}
395
+ style={{ backgroundColor: theme.colors.neutralGlobalSurface }}
396
+ />
397
+ );
398
+
399
+ expect(wrapper.toJSON()).toMatchSnapshot();
400
+ expect(wrapper.getByTestId('text-input')).toHaveStyle({
401
+ backgroundColor: theme.colors.neutralGlobalSurface,
402
+ });
403
+ expect(wrapper.getByTestId('text-input-border')).toHaveStyle({
404
+ backgroundColor: theme.colors.neutralGlobalSurface,
405
+ });
406
+ expect(wrapper.getByTestId('label-container')).toHaveStyle({
407
+ backgroundColor: theme.colors.neutralGlobalSurface,
408
+ });
409
+ expect(wrapper.getByText('Amount (AUD)')).toHaveStyle({
410
+ backgroundColor: theme.colors.neutralGlobalSurface,
411
+ });
412
+ });
413
+ });
414
+
383
415
  describe('ref', () => {
384
416
  it('ref methods work correctly', () => {
385
417
  const mockChildMethod = jest.fn();
@@ -217,9 +217,31 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
217
217
  };
218
218
  }, [textStyle]);
219
219
 
220
+ const { backgroundColor, styleWithoutBackgroundColor } = useMemo(() => {
221
+ if (!style) {
222
+ return {
223
+ backgroundColor: theme.__hd__.textInput.colors.containerBackground,
224
+ };
225
+ }
226
+
227
+ const flattenTextStyle = StyleSheet.flatten(style);
228
+ return {
229
+ backgroundColor:
230
+ flattenTextStyle.backgroundColor ??
231
+ theme.__hd__.textInput.colors.containerBackground,
232
+ styleWithoutBackgroundColor: omit(
233
+ ['backgroundColor'],
234
+ flattenTextStyle
235
+ ),
236
+ };
237
+ }, [style, theme]);
238
+
220
239
  const nativeInputProps: NativeTextInputProps = {
221
240
  style: StyleSheet.flatten([
222
- { color: theme.__hd__.textInput.colors.text },
241
+ {
242
+ backgroundColor,
243
+ color: theme.__hd__.textInput.colors.text,
244
+ },
223
245
  textStyleWithoutBorderStyle,
224
246
  ]),
225
247
  testID: 'text-input',
@@ -253,7 +275,7 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
253
275
 
254
276
  return (
255
277
  <StyledContainer
256
- style={style}
278
+ style={styleWithoutBackgroundColor}
257
279
  pointerEvents={
258
280
  variant === 'disabled' || variant === 'readonly' ? 'none' : 'auto'
259
281
  }
@@ -263,10 +285,15 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
263
285
  <StyledBorderBackDrop
264
286
  themeFocused={isFocused}
265
287
  themeVariant={variant}
266
- style={borderStyle}
288
+ testID="text-input-border"
289
+ style={[{ backgroundColor }, borderStyle]}
267
290
  />
268
291
  {(isFocused || (label && !isEmptyValue)) && (
269
- <StyledLabelContainer pointerEvents="none">
292
+ <StyledLabelContainer
293
+ pointerEvents="none"
294
+ testID="label-container"
295
+ style={{ backgroundColor }}
296
+ >
270
297
  {required && (
271
298
  <StyledAsteriskLabel themeVariant={variant} fontSize="small">
272
299
  *
@@ -278,6 +305,7 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
278
305
  testID="input-label"
279
306
  fontSize="small"
280
307
  themeVariant={variant}
308
+ style={{ backgroundColor }}
281
309
  >
282
310
  {label}
283
311
  </StyledLabel>
@@ -44,6 +44,8 @@ exports[`TimePickerAndroid renders correct with hide suffix 1`] = `
44
44
  Array [
45
45
  Object {
46
46
  "alignItems": "center",
47
+ "backgroundColor": "#ffffff",
48
+ "borderRadius": 8,
47
49
  "flexDirection": "row",
48
50
  "padding": 16,
49
51
  },
@@ -64,9 +66,15 @@ exports[`TimePickerAndroid renders correct with hide suffix 1`] = `
64
66
  "right": 0,
65
67
  "top": 0,
66
68
  },
67
- undefined,
69
+ Array [
70
+ Object {
71
+ "backgroundColor": "#ffffff",
72
+ },
73
+ undefined,
74
+ ],
68
75
  ]
69
76
  }
77
+ testID="text-input-border"
70
78
  themeFocused={false}
71
79
  themeVariant="filled"
72
80
  />
@@ -83,9 +91,12 @@ exports[`TimePickerAndroid renders correct with hide suffix 1`] = `
83
91
  "top": -10,
84
92
  "zIndex": 1,
85
93
  },
86
- undefined,
94
+ Object {
95
+ "backgroundColor": "#ffffff",
96
+ },
87
97
  ]
88
98
  }
99
+ testID="label-container"
89
100
  >
90
101
  <Text
91
102
  style={
@@ -101,7 +112,9 @@ exports[`TimePickerAndroid renders correct with hide suffix 1`] = `
101
112
  Object {
102
113
  "color": "#001f23",
103
114
  },
104
- undefined,
115
+ Object {
116
+ "backgroundColor": "#ffffff",
117
+ },
105
118
  ],
106
119
  ]
107
120
  }
@@ -151,6 +164,7 @@ exports[`TimePickerAndroid renders correct with hide suffix 1`] = `
151
164
  "textAlignVertical": "center",
152
165
  },
153
166
  Object {
167
+ "backgroundColor": "#ffffff",
154
168
  "color": "#001f23",
155
169
  },
156
170
  ]
@@ -258,6 +272,8 @@ exports[`TimePickerAndroid renders correctly 1`] = `
258
272
  Array [
259
273
  Object {
260
274
  "alignItems": "center",
275
+ "backgroundColor": "#ffffff",
276
+ "borderRadius": 8,
261
277
  "flexDirection": "row",
262
278
  "padding": 16,
263
279
  },
@@ -278,9 +294,15 @@ exports[`TimePickerAndroid renders correctly 1`] = `
278
294
  "right": 0,
279
295
  "top": 0,
280
296
  },
281
- undefined,
297
+ Array [
298
+ Object {
299
+ "backgroundColor": "#ffffff",
300
+ },
301
+ undefined,
302
+ ],
282
303
  ]
283
304
  }
305
+ testID="text-input-border"
284
306
  themeFocused={false}
285
307
  themeVariant="filled"
286
308
  />
@@ -297,9 +319,12 @@ exports[`TimePickerAndroid renders correctly 1`] = `
297
319
  "top": -10,
298
320
  "zIndex": 1,
299
321
  },
300
- undefined,
322
+ Object {
323
+ "backgroundColor": "#ffffff",
324
+ },
301
325
  ]
302
326
  }
327
+ testID="label-container"
303
328
  >
304
329
  <Text
305
330
  style={
@@ -315,7 +340,9 @@ exports[`TimePickerAndroid renders correctly 1`] = `
315
340
  Object {
316
341
  "color": "#001f23",
317
342
  },
318
- undefined,
343
+ Object {
344
+ "backgroundColor": "#ffffff",
345
+ },
319
346
  ],
320
347
  ]
321
348
  }
@@ -365,6 +392,7 @@ exports[`TimePickerAndroid renders correctly 1`] = `
365
392
  "textAlignVertical": "center",
366
393
  },
367
394
  Object {
395
+ "backgroundColor": "#ffffff",
368
396
  "color": "#001f23",
369
397
  },
370
398
  ]
@@ -44,6 +44,8 @@ exports[`TimePickerIOS renders correct with hide suffix 1`] = `
44
44
  Array [
45
45
  Object {
46
46
  "alignItems": "center",
47
+ "backgroundColor": "#ffffff",
48
+ "borderRadius": 8,
47
49
  "flexDirection": "row",
48
50
  "padding": 16,
49
51
  },
@@ -64,9 +66,15 @@ exports[`TimePickerIOS renders correct with hide suffix 1`] = `
64
66
  "right": 0,
65
67
  "top": 0,
66
68
  },
67
- undefined,
69
+ Array [
70
+ Object {
71
+ "backgroundColor": "#ffffff",
72
+ },
73
+ undefined,
74
+ ],
68
75
  ]
69
76
  }
77
+ testID="text-input-border"
70
78
  themeFocused={false}
71
79
  themeVariant="filled"
72
80
  />
@@ -83,9 +91,12 @@ exports[`TimePickerIOS renders correct with hide suffix 1`] = `
83
91
  "top": -10,
84
92
  "zIndex": 1,
85
93
  },
86
- undefined,
94
+ Object {
95
+ "backgroundColor": "#ffffff",
96
+ },
87
97
  ]
88
98
  }
99
+ testID="label-container"
89
100
  >
90
101
  <Text
91
102
  style={
@@ -101,7 +112,9 @@ exports[`TimePickerIOS renders correct with hide suffix 1`] = `
101
112
  Object {
102
113
  "color": "#001f23",
103
114
  },
104
- undefined,
115
+ Object {
116
+ "backgroundColor": "#ffffff",
117
+ },
105
118
  ],
106
119
  ]
107
120
  }
@@ -151,6 +164,7 @@ exports[`TimePickerIOS renders correct with hide suffix 1`] = `
151
164
  "textAlignVertical": "center",
152
165
  },
153
166
  Object {
167
+ "backgroundColor": "#ffffff",
154
168
  "color": "#001f23",
155
169
  },
156
170
  ]
@@ -258,6 +272,8 @@ exports[`TimePickerIOS renders correctly 1`] = `
258
272
  Array [
259
273
  Object {
260
274
  "alignItems": "center",
275
+ "backgroundColor": "#ffffff",
276
+ "borderRadius": 8,
261
277
  "flexDirection": "row",
262
278
  "padding": 16,
263
279
  },
@@ -278,9 +294,15 @@ exports[`TimePickerIOS renders correctly 1`] = `
278
294
  "right": 0,
279
295
  "top": 0,
280
296
  },
281
- undefined,
297
+ Array [
298
+ Object {
299
+ "backgroundColor": "#ffffff",
300
+ },
301
+ undefined,
302
+ ],
282
303
  ]
283
304
  }
305
+ testID="text-input-border"
284
306
  themeFocused={false}
285
307
  themeVariant="filled"
286
308
  />
@@ -297,9 +319,12 @@ exports[`TimePickerIOS renders correctly 1`] = `
297
319
  "top": -10,
298
320
  "zIndex": 1,
299
321
  },
300
- undefined,
322
+ Object {
323
+ "backgroundColor": "#ffffff",
324
+ },
301
325
  ]
302
326
  }
327
+ testID="label-container"
303
328
  >
304
329
  <Text
305
330
  style={
@@ -315,7 +340,9 @@ exports[`TimePickerIOS renders correctly 1`] = `
315
340
  Object {
316
341
  "color": "#001f23",
317
342
  },
318
- undefined,
343
+ Object {
344
+ "backgroundColor": "#ffffff",
345
+ },
319
346
  ],
320
347
  ]
321
348
  }
@@ -365,6 +392,7 @@ exports[`TimePickerIOS renders correctly 1`] = `
365
392
  "textAlignVertical": "center",
366
393
  },
367
394
  Object {
395
+ "backgroundColor": "#ffffff",
368
396
  "color": "#001f23",
369
397
  },
370
398
  ]
@@ -829,6 +829,7 @@ Object {
829
829
  "filled": "#001f23",
830
830
  "readonly": "#808f91",
831
831
  },
832
+ "containerBackground": "#ffffff",
832
833
  "error": "#de350b",
833
834
  "labelBackground": "#ffffff",
834
835
  "labels": Object {
@@ -3,6 +3,7 @@ import type { GlobalTheme } from '../global';
3
3
  const getTextInputTheme = (theme: GlobalTheme) => {
4
4
  const colors = {
5
5
  labelBackground: theme.colors.defaultGlobalSurface,
6
+ containerBackground: theme.colors.defaultGlobalSurface,
6
7
  asterisks: {
7
8
  default: theme.colors.onErrorSurface,
8
9
  error: theme.colors.onErrorSurface,
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { TouchableOpacity, View } from 'react-native';
2
+ import { TouchableHighlight, View } from 'react-native';
3
3
  declare const StyledPrefixContainer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
4
4
  theme?: import("@emotion/react").Theme | undefined;
5
5
  as?: import("react").ElementType<any> | undefined;
@@ -18,13 +18,13 @@ declare const StyledTitleContainer: import("@emotion/native").StyledComponent<im
18
18
  }, {}, {
19
19
  ref?: import("react").Ref<View> | undefined;
20
20
  }>;
21
- declare const StyledListItemContainer: import("@emotion/native").StyledComponent<import("react-native").TouchableOpacityProps & {
21
+ declare const StyledListItemContainer: import("@emotion/native").StyledComponent<import("react-native").TouchableHighlightProps & {
22
22
  theme?: import("@emotion/react").Theme | undefined;
23
23
  as?: import("react").ElementType<any> | undefined;
24
24
  } & {
25
25
  themeSelected?: boolean | undefined;
26
26
  themeDisabled?: boolean | undefined;
27
27
  }, {}, {
28
- ref?: import("react").Ref<TouchableOpacity> | undefined;
28
+ ref?: import("react").Ref<TouchableHighlight> | undefined;
29
29
  }>;
30
30
  export { StyledListItemContainer, StyledPrefixContainer, StyledTitleContainer, StyledSuffixContainer, };
@@ -1,15 +1,15 @@
1
1
  /// <reference types="react" />
2
- import { TouchableOpacity, View } from 'react-native';
2
+ import { TouchableHighlight, View } from 'react-native';
3
3
  export declare type Variant = 'full-width' | 'card';
4
4
  export declare type LeadingStatusIntent = 'success' | 'warning' | 'danger' | 'info' | 'archived';
5
- declare const StyledListItemContainer: import("@emotion/native").StyledComponent<import("react-native").TouchableOpacityProps & {
5
+ declare const StyledListItemContainer: import("@emotion/native").StyledComponent<import("react-native").TouchableHighlightProps & {
6
6
  theme?: import("@emotion/react").Theme | undefined;
7
7
  as?: import("react").ElementType<any> | undefined;
8
8
  } & {
9
9
  themeSelected?: boolean | undefined;
10
10
  themeVariant?: Variant | undefined;
11
11
  }, {}, {
12
- ref?: import("react").Ref<TouchableOpacity> | undefined;
12
+ ref?: import("react").Ref<TouchableHighlight> | undefined;
13
13
  }>;
14
14
  declare const StyledContentContainer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
15
15
  theme?: import("@emotion/react").Theme | undefined;
@@ -2,6 +2,7 @@ import type { GlobalTheme } from '../global';
2
2
  declare const getTextInputTheme: (theme: GlobalTheme) => {
3
3
  colors: {
4
4
  labelBackground: string;
5
+ containerBackground: string;
5
6
  asterisks: {
6
7
  default: string;
7
8
  error: string;