@draftbit/core 46.7.3 → 46.7.5

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 (174) hide show
  1. package/lib/commonjs/components/Accordion/AccordionItem.js +4 -23
  2. package/lib/commonjs/components/AnimatedCircularProgress.js +1 -12
  3. package/lib/commonjs/components/AvatarEdit.js +4 -15
  4. package/lib/commonjs/components/Button.js +12 -35
  5. package/lib/commonjs/components/Checkbox/Checkbox.js +4 -22
  6. package/lib/commonjs/components/Container.js +4 -15
  7. package/lib/commonjs/components/DeprecatedButton.js +3 -20
  8. package/lib/commonjs/components/DeprecatedCardWrapper.js +1 -15
  9. package/lib/commonjs/components/Elevation.js +14 -2
  10. package/lib/commonjs/components/IconButton.js +4 -2
  11. package/lib/commonjs/components/Image.js +2 -17
  12. package/lib/commonjs/components/NumberInput.js +1 -1
  13. package/lib/commonjs/components/Picker/Picker.js +4 -9
  14. package/lib/commonjs/components/Portal/PortalHost.js +15 -44
  15. package/lib/commonjs/components/Portal/PortalManager.js +8 -34
  16. package/lib/commonjs/components/Pressable.js +2 -2
  17. package/lib/commonjs/components/ProgressBar.js +7 -37
  18. package/lib/commonjs/components/Slider.js +4 -21
  19. package/lib/commonjs/components/Surface.js +2 -14
  20. package/lib/commonjs/components/TextField.js +28 -76
  21. package/lib/commonjs/components/Touchable.js +4 -17
  22. package/lib/commonjs/constants.js +1 -1
  23. package/lib/commonjs/hooks.js +2 -1
  24. package/lib/commonjs/index.js +0 -56
  25. package/lib/commonjs/mappings/Button.js +2 -2
  26. package/lib/commonjs/mappings/FlashList.js +28 -0
  27. package/lib/commonjs/mappings/FlatList.js +14 -0
  28. package/lib/commonjs/mappings/IconButton.js +4 -6
  29. package/lib/commonjs/mappings/MapView.js +3 -1
  30. package/lib/commonjs/mappings/ScrollView.js +7 -1
  31. package/lib/commonjs/mappings/Touchable.js +9 -2
  32. package/lib/commonjs/styles/overlay.js +1 -3
  33. package/lib/commonjs/utilities.js +2 -1
  34. package/lib/module/components/Button.js +12 -35
  35. package/lib/module/components/Checkbox/CheckboxGroupRow.js +5 -24
  36. package/lib/module/components/Checkbox/context.js +1 -1
  37. package/lib/module/components/CircleImage.js +1 -16
  38. package/lib/module/components/DeprecatedCardWrapper.js +1 -18
  39. package/lib/module/components/Divider.js +1 -18
  40. package/lib/module/components/Elevation.js +2 -14
  41. package/lib/module/components/FieldSearchBarFull.js +2 -1
  42. package/lib/module/components/FormRow.js +2 -17
  43. package/lib/module/components/IconButton.js +4 -2
  44. package/lib/module/components/Image.js +2 -18
  45. package/lib/module/components/Layout.js +21 -42
  46. package/lib/module/components/NumberInput.js +4 -13
  47. package/lib/module/components/Picker/PickerComponent.ios.js +11 -36
  48. package/lib/module/components/Portal/PortalConsumer.js +7 -22
  49. package/lib/module/components/Pressable.js +2 -2
  50. package/lib/module/components/RadioButton/RadioButton.js +1 -13
  51. package/lib/module/components/RadioButton/RadioButtonGroup.js +2 -16
  52. package/lib/module/components/RadioButton/RadioButtonRow.js +5 -24
  53. package/lib/module/components/Slider.js +4 -21
  54. package/lib/module/components/StepIndicator.js +18 -58
  55. package/lib/module/components/TextField.js +28 -78
  56. package/lib/module/components/ToggleButton.js +2 -16
  57. package/lib/module/components/Touchable.js +4 -17
  58. package/lib/module/constants.js +2 -1
  59. package/lib/module/index.js +0 -8
  60. package/lib/module/mappings/Button.js +2 -2
  61. package/lib/module/mappings/FieldSearchBarFull.js +1 -4
  62. package/lib/module/mappings/FlashList.js +29 -1
  63. package/lib/module/mappings/FlatList.js +15 -1
  64. package/lib/module/mappings/IconButton.js +5 -7
  65. package/lib/module/mappings/MapView.js +3 -1
  66. package/lib/module/mappings/ScrollView.js +8 -2
  67. package/lib/module/mappings/Touchable.js +10 -3
  68. package/lib/module/styles/overlay.js +3 -1
  69. package/lib/module/utilities.js +2 -1
  70. package/lib/typescript/src/components/IconButton.d.ts +2 -0
  71. package/lib/typescript/src/components/IconButton.d.ts.map +1 -1
  72. package/lib/typescript/src/components/Pressable.d.ts.map +1 -1
  73. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  74. package/lib/typescript/src/index.d.ts +0 -8
  75. package/lib/typescript/src/index.d.ts.map +1 -1
  76. package/lib/typescript/src/mappings/FlashList.d.ts +60 -0
  77. package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
  78. package/lib/typescript/src/mappings/FlatList.d.ts +30 -0
  79. package/lib/typescript/src/mappings/FlatList.d.ts.map +1 -1
  80. package/lib/typescript/src/mappings/IconButton.d.ts +20 -10
  81. package/lib/typescript/src/mappings/IconButton.d.ts.map +1 -1
  82. package/lib/typescript/src/mappings/MapView.d.ts +2 -0
  83. package/lib/typescript/src/mappings/MapView.d.ts.map +1 -1
  84. package/lib/typescript/src/mappings/ScrollView.d.ts +21 -0
  85. package/lib/typescript/src/mappings/ScrollView.d.ts.map +1 -1
  86. package/lib/typescript/src/mappings/Touchable.d.ts +20 -0
  87. package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -1
  88. package/package.json +3 -3
  89. package/src/components/Button.js +1 -1
  90. package/src/components/Button.tsx +2 -2
  91. package/src/components/IconButton.js +2 -2
  92. package/src/components/IconButton.tsx +6 -2
  93. package/src/components/NumberInput.js +1 -1
  94. package/src/components/NumberInput.tsx +1 -1
  95. package/src/components/Pressable.js +1 -1
  96. package/src/components/Pressable.tsx +2 -2
  97. package/src/components/Touchable.js +1 -1
  98. package/src/components/Touchable.tsx +2 -2
  99. package/src/index.js +0 -8
  100. package/src/index.tsx +0 -8
  101. package/src/mappings/Button.js +2 -2
  102. package/src/mappings/Button.ts +2 -2
  103. package/src/mappings/FlashList.js +29 -1
  104. package/src/mappings/FlashList.ts +33 -0
  105. package/src/mappings/FlatList.js +15 -1
  106. package/src/mappings/FlatList.ts +17 -0
  107. package/src/mappings/IconButton.js +5 -7
  108. package/src/mappings/IconButton.ts +5 -7
  109. package/src/mappings/MapView.js +2 -0
  110. package/src/mappings/MapView.ts +2 -0
  111. package/src/mappings/ScrollView.js +8 -2
  112. package/src/mappings/ScrollView.ts +10 -1
  113. package/src/mappings/Touchable.js +10 -3
  114. package/src/mappings/Touchable.ts +12 -2
  115. package/lib/commonjs/components/CardBlock.js +0 -115
  116. package/lib/commonjs/components/CardContainer.js +0 -138
  117. package/lib/commonjs/components/CardContainerRating.js +0 -133
  118. package/lib/commonjs/components/CardContainerShortImage.js +0 -84
  119. package/lib/commonjs/components/CardInline.js +0 -91
  120. package/lib/commonjs/components/Carousel.js +0 -130
  121. package/lib/commonjs/components/Header.js +0 -82
  122. package/lib/commonjs/components/HeaderLarge.js +0 -38
  123. package/lib/commonjs/components/HeaderMedium.js +0 -38
  124. package/lib/commonjs/components/HeaderOverline.js +0 -39
  125. package/lib/module/components/CardBlock.js +0 -108
  126. package/lib/module/components/CardContainer.js +0 -121
  127. package/lib/module/components/CardContainerRating.js +0 -135
  128. package/lib/module/components/CardContainerShortImage.js +0 -90
  129. package/lib/module/components/CardInline.js +0 -82
  130. package/lib/module/components/Carousel.js +0 -120
  131. package/lib/module/components/Header.js +0 -72
  132. package/lib/module/components/HeaderLarge.js +0 -28
  133. package/lib/module/components/HeaderMedium.js +0 -28
  134. package/lib/module/components/HeaderOverline.js +0 -29
  135. package/lib/typescript/src/components/CardBlock.d.ts +0 -21
  136. package/lib/typescript/src/components/CardBlock.d.ts.map +0 -1
  137. package/lib/typescript/src/components/CardContainer.d.ts +0 -23
  138. package/lib/typescript/src/components/CardContainer.d.ts.map +0 -1
  139. package/lib/typescript/src/components/CardContainerRating.d.ts +0 -24
  140. package/lib/typescript/src/components/CardContainerRating.d.ts.map +0 -1
  141. package/lib/typescript/src/components/CardContainerShortImage.d.ts +0 -19
  142. package/lib/typescript/src/components/CardContainerShortImage.d.ts.map +0 -1
  143. package/lib/typescript/src/components/CardInline.d.ts +0 -20
  144. package/lib/typescript/src/components/CardInline.d.ts.map +0 -1
  145. package/lib/typescript/src/components/Carousel.d.ts +0 -15
  146. package/lib/typescript/src/components/Carousel.d.ts.map +0 -1
  147. package/lib/typescript/src/components/Header.d.ts +0 -20
  148. package/lib/typescript/src/components/Header.d.ts.map +0 -1
  149. package/lib/typescript/src/components/HeaderLarge.d.ts +0 -17
  150. package/lib/typescript/src/components/HeaderLarge.d.ts.map +0 -1
  151. package/lib/typescript/src/components/HeaderMedium.d.ts +0 -17
  152. package/lib/typescript/src/components/HeaderMedium.d.ts.map +0 -1
  153. package/lib/typescript/src/components/HeaderOverline.d.ts +0 -17
  154. package/lib/typescript/src/components/HeaderOverline.d.ts.map +0 -1
  155. package/src/components/CardBlock.js +0 -54
  156. package/src/components/CardBlock.tsx +0 -127
  157. package/src/components/CardContainer.js +0 -69
  158. package/src/components/CardContainer.tsx +0 -165
  159. package/src/components/CardContainerRating.js +0 -79
  160. package/src/components/CardContainerRating.tsx +0 -175
  161. package/src/components/CardContainerShortImage.js +0 -33
  162. package/src/components/CardContainerShortImage.tsx +0 -101
  163. package/src/components/CardInline.js +0 -36
  164. package/src/components/CardInline.tsx +0 -93
  165. package/src/components/Carousel.js +0 -68
  166. package/src/components/Carousel.tsx +0 -134
  167. package/src/components/Header.js +0 -44
  168. package/src/components/Header.tsx +0 -105
  169. package/src/components/HeaderLarge.js +0 -7
  170. package/src/components/HeaderLarge.tsx +0 -40
  171. package/src/components/HeaderMedium.js +0 -7
  172. package/src/components/HeaderMedium.tsx +0 -41
  173. package/src/components/HeaderOverline.js +0 -7
  174. package/src/components/HeaderOverline.tsx +0 -42
@@ -1,175 +0,0 @@
1
- import React from "react";
2
- import {
3
- View,
4
- ImageSourcePropType,
5
- Text,
6
- StyleProp,
7
- ViewStyle,
8
- } from "react-native";
9
- import color from "color";
10
- import Image from "./Image";
11
- import Card from "./DeprecatedCardWrapper";
12
- import Elevation from "./Elevation";
13
- import StarRating from "./StarRating";
14
- import { withTheme } from "../theming";
15
- import type { Theme } from "../styles/DefaultTheme";
16
- import type { IconSlot } from "../interfaces/Icon";
17
-
18
- import Config from "./Config";
19
-
20
- const ICON_CONTAINER_SIZE = Config.cardIconSize * 2;
21
- const ICON_CONTAINER_PADDING = Config.cardIconSize / 2 - 1;
22
-
23
- type Props = {
24
- image?: string | ImageSourcePropType;
25
- title?: string;
26
- leftDescription?: string;
27
- rightDescription?: string;
28
- textCentered: boolean;
29
- icon?: string;
30
- rating: number;
31
- aspectRatio?: number;
32
- elevation?: number;
33
- numColumns?: number;
34
- theme: Theme;
35
- style?: StyleProp<ViewStyle>;
36
- onPress: () => void;
37
- } & IconSlot;
38
-
39
- const CardContainerRating: React.FC<React.PropsWithChildren<Props>> = ({
40
- Icon,
41
- icon,
42
- image = Config.cardImageUrl,
43
- title,
44
- leftDescription,
45
- rightDescription,
46
- rating,
47
- aspectRatio = 1.5,
48
- elevation = 2,
49
- numColumns = 3,
50
- theme: { colors, roundness, typography },
51
- style,
52
- onPress,
53
- ...rest
54
- }) => {
55
- let titleStyle, rightDescriptionStyle;
56
- switch (numColumns) {
57
- case 2:
58
- titleStyle = typography.headline6;
59
- rightDescriptionStyle = typography.body2;
60
- break;
61
- case 3:
62
- titleStyle = typography.headline5;
63
- rightDescriptionStyle = typography.caption;
64
- break;
65
- }
66
-
67
- return (
68
- <Card style={style} onPress={onPress} numColumns={numColumns} {...rest}>
69
- <Elevation style={{ elevation, borderRadius: roundness }}>
70
- <View
71
- style={{
72
- borderRadius: roundness,
73
- overflow: "hidden",
74
- backgroundColor: colors.background,
75
- //background color is needed for bug on android 9 - https://github.com/facebook/react-native/issues/25093
76
- }}
77
- >
78
- <Image
79
- style={{ aspectRatio }}
80
- source={typeof image === "string" ? { uri: image } : image}
81
- resizeMode="cover"
82
- />
83
- <View
84
- style={{
85
- padding: numColumns === 1 ? 8 : 16,
86
- }}
87
- >
88
- {title ? (
89
- <View
90
- style={{
91
- flexDirection: "row",
92
- alignItems: "center",
93
- justifyContent: "space-between",
94
- }}
95
- >
96
- <Text
97
- numberOfLines={1}
98
- style={[titleStyle, { color: colors.strong }]}
99
- >
100
- {title}
101
- </Text>
102
- </View>
103
- ) : null}
104
- {leftDescription ? (
105
- <Text
106
- numberOfLines={1}
107
- style={[
108
- typography.body2,
109
- {
110
- color: colors.medium,
111
- marginTop: numColumns === 3 ? 4 : 4 / 2,
112
- },
113
- ]}
114
- >
115
- {leftDescription}
116
- </Text>
117
- ) : null}
118
- <View
119
- style={{
120
- flexDirection: "row",
121
- justifyContent: "space-between",
122
- alignItems: "center",
123
- marginTop: numColumns === 3 ? 16 : 12,
124
- }}
125
- >
126
- <StarRating
127
- Icon={Icon}
128
- starSize={numColumns === 1 ? 10 : 16}
129
- rating={rating}
130
- />
131
- <Text
132
- style={[
133
- rightDescriptionStyle,
134
- {
135
- color: colors.medium,
136
- marginLeft: 8,
137
- },
138
- ]}
139
- numberOfLines={1}
140
- >
141
- {rightDescription}
142
- </Text>
143
- </View>
144
- </View>
145
- {icon ? (
146
- <Elevation
147
- style={{
148
- elevation: Config.cardIconElevation,
149
- position: "absolute",
150
- top: 12,
151
- right: 12,
152
- width: ICON_CONTAINER_SIZE,
153
- height: ICON_CONTAINER_SIZE,
154
- padding: ICON_CONTAINER_PADDING,
155
- borderRadius: ICON_CONTAINER_SIZE,
156
- backgroundColor: color(colors.strong)
157
- .alpha(Config.cardIconBackgroundOpacity)
158
- .rgb()
159
- .string(),
160
- }}
161
- >
162
- <Icon
163
- name={icon}
164
- size={Config.cardIconSize}
165
- color={colors.surface}
166
- />
167
- </Elevation>
168
- ) : null}
169
- </View>
170
- </Elevation>
171
- </Card>
172
- );
173
- };
174
-
175
- export default withTheme(CardContainerRating);
@@ -1,33 +0,0 @@
1
- import React from "react";
2
- import { View, Text, } from "react-native";
3
- import Image from "./Image";
4
- import Card from "./DeprecatedCardWrapper";
5
- import Elevation from "./Elevation";
6
- import { withTheme } from "../theming";
7
- import Config from "./Config";
8
- const CardContainerShortImage = ({ image = Config.squareImageUrl, title, subtitle, mode = "left", aspectRatio = 1, elevation = 2, theme: { colors, roundness, typography }, style, onPress, ...rest }) => {
9
- return (React.createElement(Card, { style: style, onPress: onPress, ...rest },
10
- React.createElement(Elevation, { style: {
11
- elevation,
12
- borderRadius: roundness,
13
- } },
14
- React.createElement(View, { style: {
15
- overflow: "hidden",
16
- flexDirection: "row",
17
- justifyContent: mode === "right" ? "space-between" : "flex-start",
18
- borderRadius: roundness,
19
- } },
20
- mode === "left" && (React.createElement(Image, { style: { aspectRatio }, source: typeof image === "string" ? { uri: image } : image, resizeMode: "cover" })),
21
- React.createElement(View, { style: {
22
- padding: 16,
23
- backgroundColor: colors.surface,
24
- flex: 1,
25
- } },
26
- React.createElement(Text, { numberOfLines: 1, style: [typography.headline5, { color: colors.strong }] }, title),
27
- subtitle ? (React.createElement(Text, { numberOfLines: 1, style: [
28
- typography.body2,
29
- { color: colors.medium, marginTop: 4 },
30
- ] }, subtitle)) : null),
31
- mode === "right" && (React.createElement(Image, { style: { aspectRatio }, source: typeof image === "string" ? { uri: image } : image, resizeMode: "cover" }))))));
32
- };
33
- export default withTheme(CardContainerShortImage);
@@ -1,101 +0,0 @@
1
- import React from "react";
2
- import {
3
- View,
4
- Text,
5
- ImageSourcePropType,
6
- StyleProp,
7
- ViewStyle,
8
- } from "react-native";
9
- import Image from "./Image";
10
- import Card from "./DeprecatedCardWrapper";
11
- import Elevation from "./Elevation";
12
- import { withTheme } from "../theming";
13
- import Config from "./Config";
14
- import theme from "../styles/DefaultTheme";
15
-
16
- type Props = {
17
- image?: string | ImageSourcePropType;
18
- title?: string;
19
- subtitle?: string;
20
- mode?: "right" | "left";
21
- aspectRatio?: number;
22
- elevation?: number;
23
- theme: typeof theme;
24
- style?: StyleProp<ViewStyle>;
25
- onPress: () => void;
26
- };
27
-
28
- const CardContainerShortImage: React.FC<React.PropsWithChildren<Props>> = ({
29
- image = Config.squareImageUrl,
30
- title,
31
- subtitle,
32
- mode = "left",
33
- aspectRatio = 1,
34
- elevation = 2,
35
- theme: { colors, roundness, typography },
36
- style,
37
- onPress,
38
- ...rest
39
- }) => {
40
- return (
41
- <Card style={style} onPress={onPress} {...rest}>
42
- <Elevation
43
- style={{
44
- elevation,
45
- borderRadius: roundness,
46
- }}
47
- >
48
- <View
49
- style={{
50
- overflow: "hidden",
51
- flexDirection: "row",
52
- justifyContent: mode === "right" ? "space-between" : "flex-start",
53
- borderRadius: roundness,
54
- }}
55
- >
56
- {mode === "left" && (
57
- <Image
58
- style={{ aspectRatio }}
59
- source={typeof image === "string" ? { uri: image } : image}
60
- resizeMode="cover"
61
- />
62
- )}
63
- <View
64
- style={{
65
- padding: 16,
66
- backgroundColor: colors.surface,
67
- flex: 1,
68
- }}
69
- >
70
- <Text
71
- numberOfLines={1}
72
- style={[typography.headline5, { color: colors.strong }]}
73
- >
74
- {title}
75
- </Text>
76
- {subtitle ? (
77
- <Text
78
- numberOfLines={1}
79
- style={[
80
- typography.body2,
81
- { color: colors.medium, marginTop: 4 },
82
- ]}
83
- >
84
- {subtitle}
85
- </Text>
86
- ) : null}
87
- </View>
88
- {mode === "right" && (
89
- <Image
90
- style={{ aspectRatio }}
91
- source={typeof image === "string" ? { uri: image } : image}
92
- resizeMode="cover"
93
- />
94
- )}
95
- </View>
96
- </Elevation>
97
- </Card>
98
- );
99
- };
100
-
101
- export default withTheme(CardContainerShortImage);
@@ -1,36 +0,0 @@
1
- // @ts-nocheck
2
- import React from "react";
3
- import { Pressable, View, StyleSheet, } from "react-native";
4
- import { Title, Subtitle } from "./Typography";
5
- import Image from "./Image";
6
- import Surface from "./Surface";
7
- import Config from "./Config";
8
- import { withTheme } from "../theming";
9
- const CardInline = ({ image = Config.cardImageUrl, title, subtitle, aspectRatio = 1.5, elevation = 2, style, titleStyle, subtitleStyle, onPress, }) => {
10
- const { alignItems, justifyContent, width, height } = StyleSheet.flatten(style || {});
11
- const imageStyles = width && height ? { width, height } : { aspectRatio };
12
- return (React.createElement(Surface, { style: [{ elevation }, style] },
13
- React.createElement(Pressable, { disabled: !onPress, onPress: onPress, style: ({ pressed }) => {
14
- return [
15
- {
16
- opacity: pressed ? 0.8 : 1,
17
- },
18
- ];
19
- } },
20
- React.createElement(Image, { style: imageStyles, source: typeof image === "string" ? { uri: image } : image, resizeMode: "cover" }),
21
- React.createElement(View, { style: [styles.overlay, { justifyContent, alignItems }] },
22
- title ? (React.createElement(Title, { style: [{ color: "white" }, titleStyle], text: title })) : null,
23
- subtitle ? (React.createElement(Subtitle, { style: [{ color: "rgba(255, 255, 255, 0.7)" }, subtitleStyle], text: subtitle })) : null))));
24
- };
25
- const styles = StyleSheet.create({
26
- overlay: {
27
- position: "absolute",
28
- top: 0,
29
- bottom: 0,
30
- left: 0,
31
- right: 0,
32
- padding: 16,
33
- backgroundColor: "rgba(0, 0, 0, 0.2)",
34
- },
35
- });
36
- export default withTheme(CardInline);
@@ -1,93 +0,0 @@
1
- // @ts-nocheck
2
- import React from "react";
3
- import {
4
- Pressable,
5
- View,
6
- ImageSourcePropType,
7
- StyleProp,
8
- ViewStyle,
9
- TextStyle,
10
- StyleSheet,
11
- } from "react-native";
12
- import { Title, Subtitle } from "./Typography";
13
- import Image from "./Image";
14
- import Surface from "./Surface";
15
- import Config from "./Config";
16
- import { withTheme } from "../theming";
17
- import theme from "../styles/DefaultTheme";
18
-
19
- type Props = {
20
- image?: string | ImageSourcePropType;
21
- title?: string;
22
- subtitle?: string;
23
- aspectRatio?: number;
24
- elevation?: number;
25
- theme: typeof theme;
26
- style?: StyleProp<ViewStyle>;
27
- titleStyle?: StyleProp<TextStyle>;
28
- subtitleStyle?: StyleProp<TextStyle>;
29
- onPress: () => void;
30
- };
31
-
32
- const CardInline: React.FC<React.PropsWithChildren<Props>> = ({
33
- image = Config.cardImageUrl,
34
- title,
35
- subtitle,
36
- aspectRatio = 1.5,
37
- elevation = 2,
38
- style,
39
- titleStyle,
40
- subtitleStyle,
41
- onPress,
42
- }) => {
43
- const { alignItems, justifyContent, width, height } = StyleSheet.flatten(
44
- style || {}
45
- );
46
- const imageStyles = width && height ? { width, height } : { aspectRatio };
47
- return (
48
- <Surface style={[{ elevation }, style]}>
49
- <Pressable
50
- disabled={!onPress}
51
- onPress={onPress}
52
- style={({ pressed }) => {
53
- return [
54
- {
55
- opacity: pressed ? 0.8 : 1,
56
- },
57
- ];
58
- }}
59
- >
60
- <Image
61
- style={imageStyles}
62
- source={typeof image === "string" ? { uri: image } : image}
63
- resizeMode="cover"
64
- />
65
- <View style={[styles.overlay, { justifyContent, alignItems }]}>
66
- {title ? (
67
- <Title style={[{ color: "white" }, titleStyle]} text={title} />
68
- ) : null}
69
- {subtitle ? (
70
- <Subtitle
71
- style={[{ color: "rgba(255, 255, 255, 0.7)" }, subtitleStyle]}
72
- text={subtitle}
73
- />
74
- ) : null}
75
- </View>
76
- </Pressable>
77
- </Surface>
78
- );
79
- };
80
-
81
- const styles = StyleSheet.create({
82
- overlay: {
83
- position: "absolute",
84
- top: 0,
85
- bottom: 0,
86
- left: 0,
87
- right: 0,
88
- padding: 16,
89
- backgroundColor: "rgba(0, 0, 0, 0.2)",
90
- },
91
- });
92
-
93
- export default withTheme(CardInline);
@@ -1,68 +0,0 @@
1
- import * as React from "react";
2
- import { withTheme } from "../theming";
3
- import { ScrollView, View, StyleSheet, Dimensions, } from "react-native";
4
- import Image from "./Image";
5
- const screenWidth = Dimensions.get("window").width;
6
- function Pager({ color, index, length, }) {
7
- return (React.createElement(View, { style: styles.pager }, Array.from({ length }).map((_, i) => {
8
- const current = index === i;
9
- const opacity = current ? 1 : 0.5;
10
- const size = current ? 10 : 8;
11
- return (React.createElement(View, { key: i, style: [
12
- styles.bullet,
13
- { backgroundColor: color, opacity, width: size, height: size },
14
- ] }));
15
- })));
16
- }
17
- function Carousel({ data, children, dotColor = "strong", style, ...rest }) {
18
- var _a;
19
- const [index, setIndex] = React.useState(0);
20
- const length = React.Children.count(children);
21
- const itemsLength = ((_a = data === null || data === void 0 ? void 0 : data.length) !== null && _a !== void 0 ? _a : 0) + length;
22
- const slides = Array.isArray(data) ? data : [];
23
- const { width, height } = StyleSheet.flatten(style || {});
24
- const slideWidth = width || screenWidth;
25
- const slideHeight = height || 250;
26
- return (React.createElement(View, { style: [styles.container, style], ...rest },
27
- React.createElement(ScrollView, { pagingEnabled: true, horizontal: true, decelerationRate: "fast", scrollEventThrottle: 200, showsHorizontalScrollIndicator: false, onScroll: ({ nativeEvent }) => {
28
- const layoutWidth = nativeEvent.layoutMeasurement.width;
29
- const offset = nativeEvent.contentOffset.x;
30
- const currentIndex = Math.ceil(offset / layoutWidth);
31
- setIndex(currentIndex);
32
- } },
33
- slides.length > 0
34
- ? slides.map((item, i) => {
35
- return (React.createElement(Image, { key: i, resizeMode: "cover", source: typeof item === "string" ? { uri: item } : item, style: [{ width: slideWidth, height: slideHeight }] }));
36
- })
37
- : null,
38
- React.Children.map(children, (child) => {
39
- var _a;
40
- const s = ((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.style) || {};
41
- return (React.createElement(View, { style: { width: slideWidth } }, React.cloneElement(child, {
42
- style: { ...s, width: slideWidth },
43
- })));
44
- })),
45
- React.createElement(Pager, { color: dotColor, index: index, length: itemsLength })));
46
- }
47
- const styles = StyleSheet.create({
48
- container: {
49
- backgroundColor: "#eee",
50
- },
51
- pager: {
52
- position: "absolute",
53
- bottom: 12,
54
- left: 0,
55
- right: 0,
56
- flexDirection: "row",
57
- justifyContent: "center",
58
- alignItems: "center",
59
- },
60
- bullet: {
61
- marginHorizontal: 2,
62
- width: 10,
63
- height: 10,
64
- borderRadius: 20,
65
- backgroundColor: "#000",
66
- },
67
- });
68
- export default withTheme(Carousel);
@@ -1,134 +0,0 @@
1
- import * as React from "react";
2
- import { withTheme } from "../theming";
3
- import {
4
- ScrollView,
5
- View,
6
- StyleSheet,
7
- Dimensions,
8
- StyleProp,
9
- ViewStyle,
10
- } from "react-native";
11
- import Image from "./Image";
12
-
13
- const screenWidth = Dimensions.get("window").width;
14
-
15
- type Props = {
16
- data?: any[];
17
- children?: React.ReactNode;
18
- style?: StyleProp<ViewStyle>;
19
- dotColor?: string;
20
- theme: any;
21
- };
22
-
23
- function Pager({
24
- color,
25
- index,
26
- length,
27
- }: {
28
- color: string;
29
- index: number;
30
- length: number;
31
- }) {
32
- return (
33
- <View style={styles.pager}>
34
- {Array.from({ length }).map((_, i) => {
35
- const current = index === i;
36
- const opacity = current ? 1 : 0.5;
37
- const size = current ? 10 : 8;
38
- return (
39
- <View
40
- key={i}
41
- style={[
42
- styles.bullet,
43
- { backgroundColor: color, opacity, width: size, height: size },
44
- ]}
45
- />
46
- );
47
- })}
48
- </View>
49
- );
50
- }
51
-
52
- function Carousel({
53
- data,
54
- children,
55
- dotColor = "strong",
56
- style,
57
- ...rest
58
- }: React.PropsWithChildren<Props>) {
59
- const [index, setIndex] = React.useState(0);
60
-
61
- const length = React.Children.count(children);
62
- const itemsLength = (data?.length ?? 0) + length;
63
- const slides = Array.isArray(data) ? data : [];
64
-
65
- const { width, height } = StyleSheet.flatten(style || {});
66
- const slideWidth = width || screenWidth;
67
- const slideHeight = height || 250;
68
-
69
- return (
70
- <View style={[styles.container, style]} {...rest}>
71
- <ScrollView
72
- pagingEnabled
73
- horizontal
74
- decelerationRate="fast"
75
- scrollEventThrottle={200}
76
- showsHorizontalScrollIndicator={false}
77
- onScroll={({ nativeEvent }) => {
78
- const layoutWidth = nativeEvent.layoutMeasurement.width;
79
- const offset = nativeEvent.contentOffset.x;
80
- const currentIndex = Math.ceil(offset / layoutWidth);
81
- setIndex(currentIndex);
82
- }}
83
- >
84
- {slides.length > 0
85
- ? slides.map((item, i) => {
86
- return (
87
- <Image
88
- key={i}
89
- resizeMode="cover"
90
- source={typeof item === "string" ? { uri: item } : item}
91
- style={[{ width: slideWidth, height: slideHeight }]}
92
- />
93
- );
94
- })
95
- : null}
96
- {React.Children.map(children, (child: any) => {
97
- const s = child?.props?.style || {};
98
- return (
99
- <View style={{ width: slideWidth }}>
100
- {React.cloneElement(child, {
101
- style: { ...s, width: slideWidth },
102
- })}
103
- </View>
104
- );
105
- })}
106
- </ScrollView>
107
- <Pager color={dotColor} index={index} length={itemsLength} />
108
- </View>
109
- );
110
- }
111
-
112
- const styles = StyleSheet.create({
113
- container: {
114
- backgroundColor: "#eee",
115
- },
116
- pager: {
117
- position: "absolute",
118
- bottom: 12,
119
- left: 0,
120
- right: 0,
121
- flexDirection: "row",
122
- justifyContent: "center",
123
- alignItems: "center",
124
- },
125
- bullet: {
126
- marginHorizontal: 2,
127
- width: 10,
128
- height: 10,
129
- borderRadius: 20,
130
- backgroundColor: "#000",
131
- },
132
- });
133
-
134
- export default withTheme(Carousel);
@@ -1,44 +0,0 @@
1
- import * as React from "react";
2
- import { View, Text, StyleSheet, } from "react-native";
3
- import { withTheme } from "../theming";
4
- import Divider from "./Divider";
5
- import Touchable from "./Touchable";
6
- import Config from "./Config";
7
- const Header = ({ Icon, titleTypeStyle, titleColor, title, buttonText, dividerTopMargin, icon, onPress, style, theme: { colors, typography }, }) => {
8
- return (React.createElement(View, { style: [styles.container, style] },
9
- React.createElement(View, { style: styles.topContainer },
10
- React.createElement(Text, { style: [
11
- titleTypeStyle,
12
- {
13
- color: titleColor,
14
- flex: 1,
15
- },
16
- ], numberOfLines: 1 }, title),
17
- onPress && (React.createElement(Touchable, { style: { alignSelf: "center", marginLeft: 12 }, onPress: onPress },
18
- React.createElement(View, { style: styles.buttonContainer },
19
- React.createElement(Text, { style: [
20
- typography.subtitle2,
21
- {
22
- color: colors.light,
23
- marginRight: 8,
24
- },
25
- ], numberOfLines: 1 }, buttonText),
26
- React.createElement(Icon, { name: icon, size: Config.headerIconSize, color: colors.light }))))),
27
- React.createElement(Divider, { style: { marginTop: dividerTopMargin || 16 } })));
28
- };
29
- const styles = StyleSheet.create({
30
- container: {
31
- alignSelf: "stretch",
32
- },
33
- topContainer: {
34
- flexDirection: "row",
35
- justifyContent: "space-between",
36
- alignItems: "center",
37
- },
38
- buttonContainer: {
39
- flexDirection: "row",
40
- justifyContent: "center",
41
- alignItems: "center",
42
- },
43
- });
44
- export default withTheme(Header);