@hero-design/rn 8.3.4 → 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 (36) 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 +473 -133
  4. package/lib/index.js +473 -133
  5. package/package.json +5 -7
  6. package/rollup.config.js +0 -1
  7. package/src/components/Carousel/CarouselItem.tsx +3 -1
  8. package/src/components/Carousel/StyledCarousel.tsx +2 -0
  9. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +18 -15
  10. package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
  11. package/src/components/Icon/IconList.ts +9 -0
  12. package/src/components/List/ListItem.tsx +1 -5
  13. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +8 -8
  14. package/src/components/Select/BaseOptionList.tsx +5 -12
  15. package/src/components/Select/MultiSelect/OptionList.tsx +6 -6
  16. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  17. package/src/components/Select/MultiSelect/index.tsx +9 -0
  18. package/src/components/Select/SingleSelect/OptionList.tsx +5 -3
  19. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +24 -4
  20. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +21 -3
  21. package/src/components/Select/SingleSelect/index.tsx +8 -0
  22. package/src/components/Swipeable/Buttons.tsx +65 -0
  23. package/src/components/Swipeable/StyledSwipeable.tsx +14 -2
  24. package/src/components/Swipeable/SwipeableAction.tsx +15 -7
  25. package/src/components/Swipeable/index.tsx +531 -136
  26. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +1 -1
  27. package/src/theme/components/carousel.ts +1 -1
  28. package/types/components/Calendar/helpers.d.ts +2 -2
  29. package/types/components/Select/helpers.d.ts +1 -1
  30. package/types/components/Swipeable/Buttons.d.ts +15 -0
  31. package/types/components/Swipeable/StyledSwipeable.d.ts +15 -2
  32. package/types/components/Swipeable/SwipeableAction.d.ts +10 -6
  33. package/types/components/Swipeable/index.d.ts +24 -41
  34. package/types/components/Toolbar/index.d.ts +2 -3
  35. package/types/testHelpers/renderWithTheme.d.ts +1 -1
  36. package/.turbo/turbo-publish:npm.log +0 -0
@@ -442,6 +442,7 @@ Array [
442
442
  onScroll={[Function]}
443
443
  onScrollBeginDrag={[Function]}
444
444
  onScrollEndDrag={[Function]}
445
+ onScrollToIndexFailed={[Function]}
445
446
  renderItem={[Function]}
446
447
  scrollEventThrottle={50}
447
448
  stickyHeaderIndices={
@@ -455,7 +456,12 @@ Array [
455
456
  Object {
456
457
  "paddingHorizontal": 12,
457
458
  },
458
- Object {},
459
+ Array [
460
+ Object {
461
+ "paddingBottom": 16,
462
+ },
463
+ undefined,
464
+ ],
459
465
  ]
460
466
  }
461
467
  >
@@ -1933,6 +1939,7 @@ Array [
1933
1939
  onScroll={[Function]}
1934
1940
  onScrollBeginDrag={[Function]}
1935
1941
  onScrollEndDrag={[Function]}
1942
+ onScrollToIndexFailed={[Function]}
1936
1943
  renderItem={[Function]}
1937
1944
  scrollEventThrottle={50}
1938
1945
  stickyHeaderIndices={
@@ -1945,7 +1952,12 @@ Array [
1945
1952
  Object {
1946
1953
  "paddingHorizontal": 12,
1947
1954
  },
1948
- Object {},
1955
+ Array [
1956
+ Object {
1957
+ "paddingBottom": 16,
1958
+ },
1959
+ undefined,
1960
+ ],
1949
1961
  ]
1950
1962
  }
1951
1963
  >
@@ -3544,6 +3556,7 @@ Array [
3544
3556
  onScroll={[Function]}
3545
3557
  onScrollBeginDrag={[Function]}
3546
3558
  onScrollEndDrag={[Function]}
3559
+ onScrollToIndexFailed={[Function]}
3547
3560
  renderItem={[Function]}
3548
3561
  scrollEventThrottle={50}
3549
3562
  stickyHeaderIndices={
@@ -3557,7 +3570,12 @@ Array [
3557
3570
  Object {
3558
3571
  "paddingHorizontal": 12,
3559
3572
  },
3560
- Object {},
3573
+ Array [
3574
+ Object {
3575
+ "paddingBottom": 16,
3576
+ },
3577
+ undefined,
3578
+ ],
3561
3579
  ]
3562
3580
  }
3563
3581
  >
@@ -134,6 +134,14 @@ const SingleSelect = <V, T extends OptionType<V>>({
134
134
  onConfirm(selectedValue);
135
135
  }}
136
136
  sectionListRef={sectionListRef}
137
+ onScrollToIndexFailed={(info) => {
138
+ setTimeout(() => {
139
+ const scrollParams = getScrollParams(value, sections);
140
+ if (scrollParams.itemIndex < info.highestMeasuredFrameIndex) {
141
+ sectionListRef.current?.scrollToLocation(scrollParams);
142
+ }
143
+ }, 500);
144
+ }}
137
145
  />
138
146
  </BottomSheet>
139
147
  </>
@@ -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