@hero-design/rn 8.4.0 → 8.5.0-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.
Files changed (40) hide show
  1. package/.turbo/turbo-build.log +66 -9
  2. package/assets/fonts/hero-icons-mobile.ttf +0 -0
  3. package/es/index.js +818 -485
  4. package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
  5. package/lib/index.js +818 -485
  6. package/package.json +5 -7
  7. package/rollup.config.js +0 -1
  8. package/src/components/Carousel/CarouselItem.tsx +3 -1
  9. package/src/components/Carousel/StyledCarousel.tsx +2 -0
  10. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +18 -15
  11. package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
  12. package/src/components/Icon/IconList.ts +2 -0
  13. package/src/components/List/ListItem.tsx +1 -5
  14. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +8 -8
  15. package/src/components/Select/BaseOptionList.tsx +5 -12
  16. package/src/components/Select/MultiSelect/OptionList.tsx +6 -6
  17. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  18. package/src/components/Select/MultiSelect/index.tsx +9 -0
  19. package/src/components/Select/SingleSelect/OptionList.tsx +5 -3
  20. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +24 -4
  21. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +21 -3
  22. package/src/components/Select/SingleSelect/index.tsx +8 -0
  23. package/src/components/Swipeable/Buttons.tsx +65 -0
  24. package/src/components/Swipeable/StyledSwipeable.tsx +14 -2
  25. package/src/components/Swipeable/SwipeableAction.tsx +15 -7
  26. package/src/components/Swipeable/index.tsx +531 -136
  27. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +1 -1
  28. package/src/theme/components/carousel.ts +1 -1
  29. package/types/components/Calendar/helpers.d.ts +2 -2
  30. package/types/components/Icon/IconList.d.ts +1 -1
  31. package/types/components/Icon/index.d.ts +1 -1
  32. package/types/components/Icon/utils.d.ts +1 -1
  33. package/types/components/Select/helpers.d.ts +1 -1
  34. package/types/components/Swipeable/Buttons.d.ts +15 -0
  35. package/types/components/Swipeable/StyledSwipeable.d.ts +15 -2
  36. package/types/components/Swipeable/SwipeableAction.d.ts +10 -6
  37. package/types/components/Swipeable/index.d.ts +24 -41
  38. package/types/components/Toolbar/index.d.ts +2 -3
  39. package/types/testHelpers/renderWithTheme.d.ts +1 -1
  40. package/.turbo/turbo-publish:npm.log +0 -0
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import { Animated, StyleProp, StyleSheet, ViewStyle } from 'react-native';
3
+
4
+ type Props = {
5
+ buttons?: React.ReactNode[];
6
+ isLeftButtons: boolean;
7
+ leftButtonContainerStyle?: StyleProp<ViewStyle>;
8
+ rightButtonContainerStyle?: StyleProp<ViewStyle>;
9
+ panAnimatedValue: Animated.ValueXY;
10
+ width: number;
11
+ canSwipeLeft?: boolean;
12
+ canSwipeRight?: boolean;
13
+ buttonWidth: number;
14
+ };
15
+
16
+ const Buttons = ({
17
+ buttons,
18
+ isLeftButtons,
19
+ leftButtonContainerStyle,
20
+ rightButtonContainerStyle,
21
+ panAnimatedValue,
22
+ width,
23
+ canSwipeLeft,
24
+ canSwipeRight,
25
+ buttonWidth,
26
+ }: Props): JSX.Element => {
27
+ const count = buttons?.length ?? 0;
28
+ const leftEnd = canSwipeLeft ? -width : 0;
29
+ const rightEnd = canSwipeRight ? width : 0;
30
+ const inputRange = isLeftButtons ? [0, rightEnd] : [leftEnd, 0];
31
+
32
+ return (
33
+ <>
34
+ {buttons?.map((buttonContent, index) => {
35
+ const outputMultiplier = -index / count;
36
+ const outputRange = isLeftButtons
37
+ ? [0, rightEnd * outputMultiplier]
38
+ : [leftEnd * outputMultiplier, 0];
39
+
40
+ const transform = [
41
+ {
42
+ translateX: panAnimatedValue.x.interpolate({
43
+ inputRange,
44
+ outputRange,
45
+ extrapolate: 'clamp',
46
+ }),
47
+ },
48
+ ];
49
+ const buttonStyle = [
50
+ StyleSheet.absoluteFill,
51
+ { width: buttonWidth, transform },
52
+ isLeftButtons ? leftButtonContainerStyle : rightButtonContainerStyle,
53
+ ];
54
+
55
+ return (
56
+ <Animated.View key={index} style={buttonStyle}>
57
+ {buttonContent}
58
+ </Animated.View>
59
+ );
60
+ })}
61
+ </>
62
+ );
63
+ };
64
+
65
+ export default Buttons;
@@ -1,11 +1,23 @@
1
1
  import styled from '@emotion/native';
2
- import { TouchableOpacity } from 'react-native';
2
+ import { Animated, TouchableOpacity, View } from 'react-native';
3
3
 
4
4
  export type ActionIntent = 'primary' | 'success' | 'danger';
5
5
 
6
- export const StyledRectButton = styled(TouchableOpacity)<{
6
+ const StyledRectButton = styled(TouchableOpacity)<{
7
7
  themeIntent: ActionIntent;
8
8
  }>(({ theme, themeIntent }) => ({
9
9
  flex: 1,
10
10
  backgroundColor: theme.__hd__.swipeable.colors[themeIntent],
11
+ alignItems: 'center',
12
+ justifyContent: 'center',
11
13
  }));
14
+
15
+ const StyledWrapper = styled(View)<{}>(() => ({
16
+ flexDirection: 'row',
17
+ }));
18
+
19
+ const StyledContent = styled(Animated.View)<{}>(() => ({
20
+ flex: 1,
21
+ }));
22
+
23
+ export { StyledRectButton, StyledWrapper, StyledContent };
@@ -1,5 +1,7 @@
1
- import React, { ReactNode } from 'react';
1
+ import React from 'react';
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
+ import Icon, { IconName } from '../Icon';
4
+ import Typography from '../Typography';
3
5
  import { ActionIntent, StyledRectButton } from './StyledSwipeable';
4
6
 
5
7
  export interface SwipeableActionProps {
@@ -11,10 +13,6 @@ export interface SwipeableActionProps {
11
13
  * Callback when the action button is pressed.
12
14
  */
13
15
  onPress?: () => void;
14
- /**
15
- * Action button's content
16
- */
17
- children?: ReactNode;
18
16
  /**
19
17
  * Additional style.
20
18
  */
@@ -23,14 +21,23 @@ export interface SwipeableActionProps {
23
21
  * Testing id of the component.
24
22
  */
25
23
  testID?: string;
24
+ /**
25
+ * Name of the Icon.
26
+ */
27
+ icon: IconName;
28
+ /**
29
+ * Action label of the component.
30
+ */
31
+ label: string;
26
32
  }
27
33
 
28
34
  const SwipeableAction = ({
29
35
  intent = 'primary',
30
36
  onPress,
31
37
  style,
32
- children,
33
38
  testID,
39
+ label,
40
+ icon,
34
41
  }: SwipeableActionProps) => (
35
42
  <StyledRectButton
36
43
  onPress={onPress}
@@ -38,7 +45,8 @@ const SwipeableAction = ({
38
45
  style={style}
39
46
  testID={testID}
40
47
  >
41
- {children}
48
+ <Icon icon={icon} size="xsmall" />
49
+ <Typography.Text fontSize="small">{label}</Typography.Text>
42
50
  </StyledRectButton>
43
51
  );
44
52