@draftbit/core 47.0.1-ad0ed2.2 → 47.0.1-b3708e.2

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 (86) hide show
  1. package/lib/commonjs/components/AvatarEdit.js +15 -4
  2. package/lib/commonjs/components/Button.js +3 -3
  3. package/lib/commonjs/components/Checkbox/Checkbox.js +3 -1
  4. package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +2 -1
  5. package/lib/commonjs/components/Checkbox/CheckboxRow.js +2 -1
  6. package/lib/commonjs/components/DeprecatedButton.js +27 -3
  7. package/lib/commonjs/components/DeprecatedFAB.js +2 -1
  8. package/lib/commonjs/components/Swiper/Swiper.js +2 -0
  9. package/lib/commonjs/components/Touchable.js +3 -8
  10. package/lib/commonjs/mappings/Button.js +9 -27
  11. package/lib/commonjs/mappings/FlashList.js +45 -2
  12. package/lib/commonjs/mappings/FlatList.js +12 -0
  13. package/lib/commonjs/mappings/Swiper.js +2 -0
  14. package/lib/commonjs/mappings/Touchable.js +7 -39
  15. package/lib/module/components/AnimatedCircularProgress.js +13 -1
  16. package/lib/module/components/Button.js +3 -3
  17. package/lib/module/components/Checkbox/Checkbox.js +3 -2
  18. package/lib/module/components/Checkbox/CheckboxGroupRow.js +3 -2
  19. package/lib/module/components/Checkbox/CheckboxRow.js +3 -2
  20. package/lib/module/components/DeprecatedButton.js +28 -4
  21. package/lib/module/components/DeprecatedFAB.js +3 -2
  22. package/lib/module/components/Picker/PickerComponent.web.js +21 -3
  23. package/lib/module/components/Portal/PortalManager.js +33 -7
  24. package/lib/module/components/Swiper/Swiper.js +2 -0
  25. package/lib/module/components/Touchable.js +3 -8
  26. package/lib/module/mappings/Button.js +10 -28
  27. package/lib/module/mappings/FlashList.js +46 -3
  28. package/lib/module/mappings/FlatList.js +13 -1
  29. package/lib/module/mappings/Swiper.js +3 -1
  30. package/lib/module/mappings/Touchable.js +9 -41
  31. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  32. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
  33. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  34. package/lib/typescript/src/components/Checkbox/CheckboxGroupRow.d.ts.map +1 -1
  35. package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts.map +1 -1
  36. package/lib/typescript/src/components/DeprecatedButton.d.ts +2 -2
  37. package/lib/typescript/src/components/DeprecatedButton.d.ts.map +1 -1
  38. package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
  39. package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
  40. package/lib/typescript/src/components/Swiper/Swiper.d.ts +2 -1
  41. package/lib/typescript/src/components/Swiper/Swiper.d.ts.map +1 -1
  42. package/lib/typescript/src/components/Touchable.d.ts +2 -7
  43. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  44. package/lib/typescript/src/mappings/Button.d.ts +4 -93
  45. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  46. package/lib/typescript/src/mappings/FlashList.d.ts +112 -2
  47. package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
  48. package/lib/typescript/src/mappings/FlatList.d.ts +42 -0
  49. package/lib/typescript/src/mappings/FlatList.d.ts.map +1 -1
  50. package/lib/typescript/src/mappings/Swiper.d.ts +11 -0
  51. package/lib/typescript/src/mappings/Swiper.d.ts.map +1 -1
  52. package/lib/typescript/src/mappings/Touchable.d.ts +5 -59
  53. package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -1
  54. package/package.json +3 -3
  55. package/src/components/Button.js +3 -3
  56. package/src/components/Button.tsx +4 -14
  57. package/src/components/Checkbox/Checkbox.js +3 -2
  58. package/src/components/Checkbox/Checkbox.tsx +7 -5
  59. package/src/components/Checkbox/CheckboxGroupRow.js +3 -2
  60. package/src/components/Checkbox/CheckboxGroupRow.tsx +3 -3
  61. package/src/components/Checkbox/CheckboxRow.js +3 -2
  62. package/src/components/Checkbox/CheckboxRow.tsx +3 -3
  63. package/src/components/DeprecatedButton.js +16 -4
  64. package/src/components/DeprecatedButton.tsx +31 -7
  65. package/src/components/DeprecatedFAB.js +3 -2
  66. package/src/components/DeprecatedFAB.tsx +5 -5
  67. package/src/components/Swiper/Swiper.js +2 -2
  68. package/src/components/Swiper/Swiper.tsx +3 -0
  69. package/src/components/Touchable.js +3 -3
  70. package/src/components/Touchable.tsx +4 -14
  71. package/src/mappings/Button.js +9 -27
  72. package/src/mappings/Button.ts +9 -29
  73. package/src/mappings/FlashList.js +77 -31
  74. package/src/mappings/FlashList.ts +82 -30
  75. package/src/mappings/FlatList.js +13 -1
  76. package/src/mappings/FlatList.ts +16 -0
  77. package/src/mappings/Swiper.js +3 -1
  78. package/src/mappings/Swiper.ts +4 -0
  79. package/src/mappings/Touchable.js +7 -42
  80. package/src/mappings/Touchable.ts +6 -46
  81. package/lib/commonjs/components/Pressable.js +0 -37
  82. package/lib/module/components/Pressable.js +0 -30
  83. package/lib/typescript/src/components/Pressable.d.ts +0 -16
  84. package/lib/typescript/src/components/Pressable.d.ts.map +0 -1
  85. package/src/components/Pressable.js +0 -12
  86. package/src/components/Pressable.tsx +0 -50
@@ -6,7 +6,6 @@ import {
6
6
  TextStyle,
7
7
  View,
8
8
  Platform,
9
- Pressable,
10
9
  } from "react-native";
11
10
  import { isString } from "lodash";
12
11
 
@@ -14,6 +13,7 @@ import type { IconSlot } from "../../interfaces/Icon";
14
13
  import { extractStyles } from "../../utilities";
15
14
  import { usePrevious } from "../../hooks";
16
15
  import Text from "../Text";
16
+ import Touchable from "../Touchable";
17
17
  import Checkbox, { CheckboxProps } from "./Checkbox";
18
18
 
19
19
  export enum Direction {
@@ -100,7 +100,7 @@ const CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({
100
100
  const { textStyles, viewStyles } = extractStyles(style);
101
101
 
102
102
  return (
103
- <Pressable
103
+ <Touchable
104
104
  onPress={handlePress}
105
105
  style={[viewStyles, styles.mainParent, { flexDirection: direction }]}
106
106
  disabled={disabled}
@@ -130,7 +130,7 @@ const CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({
130
130
  uncheckedIcon={uncheckedIcon}
131
131
  size={size}
132
132
  />
133
- </Pressable>
133
+ </Touchable>
134
134
  );
135
135
  };
136
136
 
@@ -1,10 +1,11 @@
1
1
  import * as React from "react";
2
- import { ActivityIndicator, View, Text, StyleSheet, Pressable, } from "react-native";
2
+ import { ActivityIndicator, View, Text, StyleSheet, } from "react-native";
3
3
  import color from "color";
4
4
  import Config from "./Config";
5
+ import Touchable from "./Touchable";
5
6
  import Elevation from "./Elevation";
6
7
  import { withTheme } from "../theming";
7
- const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false, labelColor, color: colorOverride, children, onPress, elevation = 0, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
8
+ const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false, labelColor, color: colorOverride, children, onPress, elevation = 0, style, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
8
9
  let backgroundColor, borderColor, textColor, borderWidth;
9
10
  const buttonColor = colorOverride || colors.primary;
10
11
  if (type === "solid") {
@@ -58,8 +59,19 @@ const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false,
58
59
  width: Config.buttonIconSize,
59
60
  },
60
61
  ];
61
- return (React.createElement(Elevation, { style: { elevation, alignSelf: "stretch" } },
62
- React.createElement(Pressable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: [styles.button, buttonStyle] },
62
+ const { margin, marginEnd, marginTop, marginLeft, marginRight, marginBottom, marginHorizontal, marginVertical, ...innerStyles } = StyleSheet.flatten(style || {});
63
+ const margins = {
64
+ margin,
65
+ marginEnd,
66
+ marginTop,
67
+ marginLeft,
68
+ marginRight,
69
+ marginBottom,
70
+ marginHorizontal,
71
+ marginVertical,
72
+ };
73
+ return (React.createElement(Elevation, { style: { elevation, alignSelf: "stretch", ...margins } },
74
+ React.createElement(Touchable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: [styles.button, buttonStyle, innerStyles] },
63
75
  React.createElement(View, { style: styles.content },
64
76
  icon && loading !== true ? (React.createElement(View, { style: iconStyle },
65
77
  React.createElement(Icon, { name: icon, size: Config.buttonIconSize, color: textColor }))) : null,
@@ -4,14 +4,14 @@ import {
4
4
  View,
5
5
  Text,
6
6
  StyleSheet,
7
+ TouchableHighlightProps,
7
8
  StyleProp,
8
9
  ViewStyle,
9
10
  TextStyle,
10
- Pressable,
11
- PressableProps,
12
11
  } from "react-native";
13
12
  import color from "color";
14
13
  import Config from "./Config";
14
+ import Touchable from "./Touchable";
15
15
  import Elevation from "./Elevation";
16
16
  import { withTheme } from "../theming";
17
17
 
@@ -63,7 +63,7 @@ type Props = {
63
63
  elevation?: number;
64
64
  style?: StyleProp<ViewStyle>;
65
65
  theme: Theme;
66
- } & PressableProps &
66
+ } & TouchableHighlightProps &
67
67
  IconSlot;
68
68
 
69
69
  const Button: React.FC<React.PropsWithChildren<Props>> = ({
@@ -77,6 +77,7 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
77
77
  children,
78
78
  onPress,
79
79
  elevation = 0,
80
+ style,
80
81
  theme: { colors, disabledOpacity, roundness, typography },
81
82
  ...rest
82
83
  }) => {
@@ -136,15 +137,38 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
136
137
  },
137
138
  ];
138
139
 
140
+ const {
141
+ margin,
142
+ marginEnd,
143
+ marginTop,
144
+ marginLeft,
145
+ marginRight,
146
+ marginBottom,
147
+ marginHorizontal,
148
+ marginVertical,
149
+ ...innerStyles
150
+ } = StyleSheet.flatten(style || {});
151
+
152
+ const margins = {
153
+ margin,
154
+ marginEnd,
155
+ marginTop,
156
+ marginLeft,
157
+ marginRight,
158
+ marginBottom,
159
+ marginHorizontal,
160
+ marginVertical,
161
+ };
162
+
139
163
  return (
140
- <Elevation style={{ elevation, alignSelf: "stretch" }}>
141
- <Pressable
164
+ <Elevation style={{ elevation, alignSelf: "stretch", ...margins }}>
165
+ <Touchable
142
166
  {...rest}
143
167
  onPress={onPress}
144
168
  accessibilityState={{ disabled }}
145
169
  accessibilityRole="button"
146
170
  disabled={disabled || loading}
147
- style={[styles.button, buttonStyle]}
171
+ style={[styles.button, buttonStyle, innerStyles]}
148
172
  >
149
173
  <View style={styles.content}>
150
174
  {icon && loading !== true ? (
@@ -167,7 +191,7 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
167
191
  {children}
168
192
  </Text>
169
193
  </View>
170
- </Pressable>
194
+ </Touchable>
171
195
  </Elevation>
172
196
  );
173
197
  };
@@ -1,8 +1,9 @@
1
1
  import * as React from "react";
2
- import { ActivityIndicator, View, StyleSheet, Pressable, } from "react-native";
2
+ import { ActivityIndicator, View, StyleSheet, } from "react-native";
3
3
  import color from "color";
4
4
  import Config from "./Config";
5
5
  import Text from "./Text";
6
+ import Touchable from "./Touchable";
6
7
  import Elevation from "./Elevation";
7
8
  import { withTheme } from "../theming";
8
9
  const FAB = ({ Icon, icon, disabled = false, type = "solid", loading = false, color: colorOverride, label, onPress, elevation = 0, style, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
@@ -82,7 +83,7 @@ const FAB = ({ Icon, icon, disabled = false, type = "solid", loading = false, co
82
83
  });
83
84
  }
84
85
  return (React.createElement(Elevation, { style: [{ elevation }, style] },
85
- React.createElement(Pressable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: buttonStyles },
86
+ React.createElement(Touchable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: buttonStyles },
86
87
  React.createElement(View, { style: styles.content },
87
88
  icon && loading !== true ? (React.createElement(View, { style: iconStyle },
88
89
  React.createElement(Icon, { name: icon, size: Config.buttonIconSize, color: textColor }))) : null,
@@ -3,15 +3,15 @@ import {
3
3
  ActivityIndicator,
4
4
  View,
5
5
  StyleSheet,
6
+ TouchableHighlightProps,
6
7
  StyleProp,
7
8
  ViewStyle,
8
9
  TextStyle,
9
- Pressable,
10
- PressableProps,
11
10
  } from "react-native";
12
11
  import color from "color";
13
12
  import Config from "./Config";
14
13
  import Text from "./Text";
14
+ import Touchable from "./Touchable";
15
15
  import Elevation from "./Elevation";
16
16
  import { withTheme } from "../theming";
17
17
 
@@ -65,7 +65,7 @@ type Props = {
65
65
  elevation?: number;
66
66
  theme: Theme;
67
67
  style?: StyleProp<ViewStyle>;
68
- } & PressableProps &
68
+ } & TouchableHighlightProps &
69
69
  IconSlot;
70
70
 
71
71
  const FAB: React.FC<React.PropsWithChildren<Props>> = ({
@@ -169,7 +169,7 @@ const FAB: React.FC<React.PropsWithChildren<Props>> = ({
169
169
 
170
170
  return (
171
171
  <Elevation style={[{ elevation }, style]}>
172
- <Pressable
172
+ <Touchable
173
173
  {...rest}
174
174
  onPress={onPress}
175
175
  accessibilityState={{ disabled }}
@@ -200,7 +200,7 @@ const FAB: React.FC<React.PropsWithChildren<Props>> = ({
200
200
  </Text>
201
201
  ) : null}
202
202
  </View>
203
- </Pressable>
203
+ </Touchable>
204
204
  </Elevation>
205
205
  );
206
206
  };
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
2
  import { View } from "react-native";
3
3
  import SwiperComponent from "react-native-web-swiper";
4
- const Swiper = ({ vertical = false, loop = false, timeout = 0, from = 0, prevTitle = "", nextTitle = "", prevTitleColor, nextTitleColor, dotsTouchable = true, dotColor, dotActiveColor, data, keyExtractor, renderItem, children, style, }) => (React.createElement(View, { style: style },
5
- React.createElement(SwiperComponent, { from: from, loop: loop, timeout: timeout, vertical: vertical, controlsProps: {
4
+ const Swiper = ({ vertical = false, loop = false, timeout = 0, from = 0, prevTitle = "", nextTitle = "", prevTitleColor, nextTitleColor, dotsTouchable = true, dotColor, dotActiveColor, data, keyExtractor, renderItem, children, onIndexChanged, style, }) => (React.createElement(View, { style: style },
5
+ React.createElement(SwiperComponent, { from: from, loop: loop, timeout: timeout, vertical: vertical, onIndexChanged: onIndexChanged, controlsProps: {
6
6
  prevTitle,
7
7
  nextTitle,
8
8
  prevTitleStyle: { color: prevTitleColor },
@@ -19,6 +19,7 @@ export interface SwiperProps<T> {
19
19
  keyExtractor: (item: T, index: number) => string;
20
20
  renderItem?: ({ item, index }: { item: T; index: number }) => JSX.Element;
21
21
  style?: StyleProp<ViewStyle>;
22
+ onIndexChanged?: (index: number) => void;
22
23
  }
23
24
 
24
25
  const Swiper = ({
@@ -37,6 +38,7 @@ const Swiper = ({
37
38
  keyExtractor,
38
39
  renderItem,
39
40
  children,
41
+ onIndexChanged,
40
42
  style,
41
43
  }: SwiperProps<any>) => (
42
44
  <View style={style}>
@@ -46,6 +48,7 @@ const Swiper = ({
46
48
  loop={loop}
47
49
  timeout={timeout}
48
50
  vertical={vertical}
51
+ onIndexChanged={onIndexChanged}
49
52
  controlsProps={{
50
53
  prevTitle,
51
54
  nextTitle,
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
  import { Pressable } from "react-native";
3
- export default function Touchable({ children, disabled, onPress, activeOpacity, disabledOpacity, delayLongPress, hitSlop, style, ...props }) {
4
- return (React.createElement(Pressable, { disabled: disabled, onPress: onPress, delayLongPress: delayLongPress ? delayLongPress : 500, hitSlop: hitSlop ? hitSlop : 8, style: ({ pressed }) => {
3
+ export default function Touchable({ children, disabled, onPress, style, ...props }) {
4
+ return (React.createElement(Pressable, { onPress: onPress, disabled: disabled, hitSlop: 8, style: ({ pressed }) => {
5
5
  return [
6
6
  {
7
- opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
7
+ opacity: pressed || disabled ? 0.75 : 1,
8
8
  },
9
9
  style,
10
10
  ];
@@ -1,39 +1,29 @@
1
1
  import React from "react";
2
- import { Pressable, PressableProps, ViewStyle } from "react-native";
2
+ import { Pressable, ViewStyle, PressableProps } from "react-native";
3
3
 
4
4
  type Props = {
5
5
  disabled?: boolean;
6
6
  children: React.ReactNode;
7
7
  style?: ViewStyle;
8
8
  onPress?: () => void;
9
- onLongPress?: () => void;
10
- delayLongPress?: number;
11
- hitSlop?: number;
12
- activeOpacity?: number;
13
- disabledOpacity?: number;
14
9
  } & PressableProps;
15
10
 
16
11
  export default function Touchable({
17
12
  children,
18
13
  disabled,
19
14
  onPress,
20
- activeOpacity,
21
- disabledOpacity,
22
- delayLongPress,
23
- hitSlop,
24
15
  style,
25
16
  ...props
26
17
  }: Props) {
27
18
  return (
28
19
  <Pressable
29
- disabled={disabled}
30
20
  onPress={onPress}
31
- delayLongPress={delayLongPress ? delayLongPress : 500}
32
- hitSlop={hitSlop ? hitSlop : 8}
21
+ disabled={disabled}
22
+ hitSlop={8}
33
23
  style={({ pressed }) => {
34
24
  return [
35
25
  {
36
- opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
26
+ opacity: pressed || disabled ? 0.75 : 1,
37
27
  },
38
28
  style,
39
29
  ];
@@ -1,4 +1,4 @@
1
- import { COMPONENT_TYPES, createIconProp, createTextProp, createDisabledProp, createLoadingProp, createActionProp, Triggers, StylesPanelSections, createStaticNumberProp, } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, createIconProp, createTextProp, createDisabledProp, createLoadingProp, createActionProp, Triggers, StylesPanelSections, } from "@draftbit/types";
2
2
  const SEED_DATA_TRIGGERS = [Triggers.OnPress];
3
3
  const SEED_DATA_PROPS = {
4
4
  onPress: createActionProp(),
@@ -13,26 +13,11 @@ const SEED_DATA_PROPS = {
13
13
  }),
14
14
  disabled: createDisabledProp(),
15
15
  loading: createLoadingProp(),
16
- activeOpacity: createStaticNumberProp({
17
- label: "Active Opacity",
18
- description: "Opacity of the button when active.",
19
- required: false,
20
- }),
21
- disabledOpacity: createStaticNumberProp({
22
- label: "Disabled Opacity",
23
- description: "Opacity of the button when disabled.",
24
- required: false,
25
- }),
26
- delayLongPress: createStaticNumberProp({
27
- label: "Delay Long Press",
28
- description: "Duration (in milliseconds) from onPressIn before onLongPress is called.",
29
- required: false,
30
- }),
31
- hitSlop: createStaticNumberProp({
32
- label: "Hit Slop",
33
- description: "Sets additional distance outside of element in which a press can be detected",
34
- required: false,
35
- }),
16
+ };
17
+ const LAYOUT = {
18
+ backgroundColor: "transparent",
19
+ borderRadius: 8,
20
+ fontFamily: "system-700",
36
21
  };
37
22
  export const SEED_DATA = [
38
23
  {
@@ -49,8 +34,7 @@ export const SEED_DATA = [
49
34
  StylesPanelSections.Effects,
50
35
  ],
51
36
  layout: {
52
- borderRadius: 8,
53
- fontFamily: "system-700",
37
+ ...LAYOUT,
54
38
  backgroundColor: "transparent",
55
39
  borderWidth: 1,
56
40
  textAlign: "center",
@@ -72,8 +56,7 @@ export const SEED_DATA = [
72
56
  StylesPanelSections.Effects,
73
57
  ],
74
58
  layout: {
75
- borderRadius: 8,
76
- fontFamily: "system-700",
59
+ ...LAYOUT,
77
60
  backgroundColor: "primary",
78
61
  textAlign: "center",
79
62
  },
@@ -94,8 +77,7 @@ export const SEED_DATA = [
94
77
  StylesPanelSections.Effects,
95
78
  ],
96
79
  layout: {
97
- borderRadius: 8,
98
- fontFamily: "system-700",
80
+ ...LAYOUT,
99
81
  backgroundColor: "primary",
100
82
  textAlign: "center",
101
83
  },
@@ -7,7 +7,6 @@ import {
7
7
  createActionProp,
8
8
  Triggers,
9
9
  StylesPanelSections,
10
- createStaticNumberProp,
11
10
  } from "@draftbit/types";
12
11
 
13
12
  const SEED_DATA_TRIGGERS = [Triggers.OnPress];
@@ -24,28 +23,12 @@ const SEED_DATA_PROPS = {
24
23
  }),
25
24
  disabled: createDisabledProp(),
26
25
  loading: createLoadingProp(),
27
- activeOpacity: createStaticNumberProp({
28
- label: "Active Opacity",
29
- description: "Opacity of the button when active.",
30
- required: false,
31
- }),
32
- disabledOpacity: createStaticNumberProp({
33
- label: "Disabled Opacity",
34
- description: "Opacity of the button when disabled.",
35
- required: false,
36
- }),
37
- delayLongPress: createStaticNumberProp({
38
- label: "Delay Long Press",
39
- description:
40
- "Duration (in milliseconds) from onPressIn before onLongPress is called.",
41
- required: false,
42
- }),
43
- hitSlop: createStaticNumberProp({
44
- label: "Hit Slop",
45
- description:
46
- "Sets additional distance outside of element in which a press can be detected",
47
- required: false,
48
- }),
26
+ };
27
+
28
+ const LAYOUT = {
29
+ backgroundColor: "transparent",
30
+ borderRadius: 8,
31
+ fontFamily: "system-700",
49
32
  };
50
33
 
51
34
  export const SEED_DATA = [
@@ -63,8 +46,7 @@ export const SEED_DATA = [
63
46
  StylesPanelSections.Effects,
64
47
  ],
65
48
  layout: {
66
- borderRadius: 8,
67
- fontFamily: "system-700",
49
+ ...LAYOUT,
68
50
  backgroundColor: "transparent",
69
51
  borderWidth: 1,
70
52
  textAlign: "center",
@@ -86,8 +68,7 @@ export const SEED_DATA = [
86
68
  StylesPanelSections.Effects,
87
69
  ],
88
70
  layout: {
89
- borderRadius: 8,
90
- fontFamily: "system-700",
71
+ ...LAYOUT,
91
72
  backgroundColor: "primary",
92
73
  textAlign: "center",
93
74
  },
@@ -108,8 +89,7 @@ export const SEED_DATA = [
108
89
  StylesPanelSections.Effects,
109
90
  ],
110
91
  layout: {
111
- borderRadius: 8,
112
- fontFamily: "system-700",
92
+ ...LAYOUT,
113
93
  backgroundColor: "primary",
114
94
  textAlign: "center",
115
95
  },
@@ -1,33 +1,79 @@
1
- import { COMPONENT_TYPES, createNumColumnsType, createStaticBoolProp, createNumberProp, CONTAINER_COMPONENT_STYLES_SECTIONS, GROUPS, } from "@draftbit/types";
2
- export const SEED_DATA = {
3
- name: "FlashList",
4
- tag: "FlashList",
5
- description: "Flashlist by Shopify",
6
- packageName: "@shopify/flash-list",
7
- category: COMPONENT_TYPES.data,
8
- stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
9
- layout: {
10
- flex: 1,
1
+ import { COMPONENT_TYPES, createNumColumnsType, createStaticBoolProp, createNumberProp, CONTAINER_COMPONENT_STYLES_SECTIONS, GROUPS, Triggers, createActionProp, createStaticNumberProp, } from "@draftbit/types";
2
+ export const SEED_DATA = [
3
+ {
4
+ name: "Masonry List",
5
+ tag: "MasonryFlashList",
6
+ description: "Masonry Flashlist by Shopify",
7
+ packageName: "@shopify/flash-list",
8
+ category: COMPONENT_TYPES.data,
9
+ stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
10
+ layout: {
11
+ flex: 1,
12
+ },
13
+ triggers: [Triggers.OnRefresh, Triggers.OnEndReached],
14
+ props: {
15
+ onRefresh: createActionProp(),
16
+ onEndReached: createActionProp(),
17
+ numColumns: createNumColumnsType({
18
+ editable: true,
19
+ }),
20
+ estimatedItemSize: createNumberProp({
21
+ group: GROUPS.basic,
22
+ label: "Est. Item Size",
23
+ description: "Approximate size of the items before rendering.",
24
+ defaultValue: 50,
25
+ step: 1,
26
+ precision: 0,
27
+ }),
28
+ optimizeItemArrangement: createStaticBoolProp({
29
+ label: "Optimize Item Arrangement",
30
+ description: "If enabled, MasonryFlashList will try to reduce difference in column height by modifying item order. If true, specifying overrideItemLayout is required. Default value is false.",
31
+ }),
32
+ onEndReachedThreshold: createStaticNumberProp({
33
+ label: "End Reached Threshold",
34
+ description: "How far from the end (in units of visible length of the list) the bottom edge of the list must be from the end of the content to trigger the onEndReached callback. Thus a value of 0.5 will trigger onEndReached when the end of the content is within half the visible length of the list.",
35
+ defaultValue: 0.5,
36
+ }),
37
+ },
11
38
  },
12
- props: {
13
- estimatedItemSize: createNumberProp({
14
- group: GROUPS.basic,
15
- label: "Est. Item Size",
16
- description: "Approximate size of the items before rendering.",
17
- defaultValue: 50,
18
- step: 1,
19
- precision: 0,
20
- }),
21
- horizontal: createStaticBoolProp({
22
- label: "Horizontal",
23
- description: "Render list horizontally",
24
- }),
25
- inverted: createStaticBoolProp({
26
- label: "Inverted",
27
- description: "If true, reverses the direction.",
28
- }),
29
- numColumns: createNumColumnsType({
30
- editable: true,
31
- }),
39
+ {
40
+ name: "FlashList",
41
+ tag: "FlashList",
42
+ description: "Flashlist by Shopify",
43
+ packageName: "@shopify/flash-list",
44
+ category: COMPONENT_TYPES.data,
45
+ stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
46
+ layout: {
47
+ flex: 1,
48
+ },
49
+ triggers: [Triggers.OnRefresh, Triggers.OnEndReached],
50
+ props: {
51
+ onRefresh: createActionProp(),
52
+ onEndReached: createActionProp(),
53
+ estimatedItemSize: createNumberProp({
54
+ group: GROUPS.basic,
55
+ label: "Est. Item Size",
56
+ description: "Approximate size of the items before rendering.",
57
+ defaultValue: 50,
58
+ step: 1,
59
+ precision: 0,
60
+ }),
61
+ horizontal: createStaticBoolProp({
62
+ label: "Horizontal",
63
+ description: "Render list horizontally",
64
+ }),
65
+ inverted: createStaticBoolProp({
66
+ label: "Inverted",
67
+ description: "If true, reverses the direction.",
68
+ }),
69
+ numColumns: createNumColumnsType({
70
+ editable: true,
71
+ }),
72
+ onEndReachedThreshold: createStaticNumberProp({
73
+ label: "End Reached Threshold",
74
+ description: "How far from the end (in units of visible length of the list) the bottom edge of the list must be from the end of the content to trigger the onEndReached callback. Thus a value of 0.5 will trigger onEndReached when the end of the content is within half the visible length of the list.",
75
+ defaultValue: 0.5,
76
+ }),
77
+ },
32
78
  },
33
- };
79
+ ];