@hero-design/rn 8.81.0 → 8.81.1-alpha.0

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.
@@ -1,15 +1,15 @@
1
- import React from 'react';
1
+ import React, { ReactNode, useMemo } from 'react';
2
2
  import { ViewProps } from 'react-native';
3
3
  import Box from '../Box';
4
- import Icon, { IconName } from '../Icon';
4
+ import { IconName } from '../Icon';
5
5
  import Typography from '../Typography';
6
- import { StyledChipWrapper } from './StyledChip';
6
+ import { StyledChipIcon, StyledChipWrapper } from './StyledChip';
7
7
 
8
8
  export interface ChipProps extends ViewProps {
9
9
  /**
10
10
  * The label of the chip.
11
11
  */
12
- label: string;
12
+ label: string | ReactNode;
13
13
  /**
14
14
  * Variant of the chip.
15
15
  */
@@ -32,6 +32,14 @@ export interface ChipProps extends ViewProps {
32
32
  showSelectedIcon?: boolean;
33
33
  }
34
34
 
35
+ const getChipLabel = (label: string | ReactNode) => {
36
+ if (typeof label === 'string') {
37
+ return <Typography.Body variant="small">{label}</Typography.Body>;
38
+ }
39
+
40
+ return label;
41
+ };
42
+
35
43
  const Chip = ({
36
44
  label,
37
45
  variant = 'outlined',
@@ -42,7 +50,11 @@ const Chip = ({
42
50
  ...otherProps
43
51
  }: ChipProps) => {
44
52
  const shouldShowSelectedIcon =
45
- variant === 'outlined' && selected && showSelectedIcon;
53
+ (variant === 'outlined' || variant === 'compact-outlined') &&
54
+ selected &&
55
+ showSelectedIcon;
56
+
57
+ const chipLabel = useMemo(() => getChipLabel(label), [label]);
46
58
 
47
59
  return (
48
60
  <StyledChipWrapper
@@ -53,19 +65,15 @@ const Chip = ({
53
65
  >
54
66
  {icon && (
55
67
  <Box marginRight="small">
56
- <Icon size="xsmall" icon={icon} testID={`chip-icon-${icon}`} />
68
+ <StyledChipIcon icon={icon} testID={`chip-icon-${icon}`} />
57
69
  </Box>
58
70
  )}
59
71
 
60
- <Typography.Body>{label}</Typography.Body>
72
+ {chipLabel}
61
73
 
62
74
  {shouldShowSelectedIcon && (
63
75
  <Box marginLeft="small">
64
- <Icon
65
- size="xsmall"
66
- icon="cancel"
67
- testID="selected-chip-icon-cancel"
68
- />
76
+ <StyledChipIcon icon="cancel" testID="selected-chip-icon-cancel" />
69
77
  </Box>
70
78
  )}
71
79
  </StyledChipWrapper>
@@ -1,5 +1,5 @@
1
1
  import DateTimePicker from '@react-native-community/datetimepicker';
2
- import React, { useState } from 'react';
2
+ import React, { useEffect, useState } from 'react';
3
3
  import { TouchableOpacity, View } from 'react-native';
4
4
  import formatTime from 'date-fns/fp/format';
5
5
 
@@ -33,6 +33,10 @@ const TimePickerIOS = ({
33
33
  const displayValue = value ? formatTime(displayFormat, value) : '';
34
34
  const theme = useTheme();
35
35
 
36
+ useEffect(() => {
37
+ setSelectingDate(value || new Date());
38
+ }, [value]);
39
+
36
40
  return (
37
41
  <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
38
42
  <View pointerEvents="none" testID="timePickerInputIOS">
@@ -401,6 +401,9 @@ exports[`theme returns correct theme object 1`] = `
401
401
  "secondaryBackground": "#ece8ef",
402
402
  "wrapperSelectedBorder": "transparent",
403
403
  },
404
+ "fontSizes": {
405
+ "icon": 12,
406
+ },
404
407
  "radii": {
405
408
  "wrapper": 999,
406
409
  },
@@ -33,12 +33,17 @@ const getChipTheme = (theme: GlobalTheme) => {
33
33
  filledWrapper: theme.shadows.default,
34
34
  };
35
35
 
36
+ const fontSizes = {
37
+ icon: theme.fontSizes.small,
38
+ };
39
+
36
40
  return {
37
41
  colors,
38
42
  space,
39
43
  radii,
40
44
  borderWidths,
41
45
  shadows,
46
+ fontSizes,
42
47
  };
43
48
  };
44
49