@draftbit/core 46.11.0 → 46.11.1-0339d0.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 (82) hide show
  1. package/lib/commonjs/components/Accordion/AccordionItem.js +4 -22
  2. package/lib/commonjs/components/Accordion/AccordionItem.js.map +1 -1
  3. package/lib/commonjs/components/Card.js.map +1 -1
  4. package/lib/commonjs/components/Checkbox/CheckboxGroup.js +3 -16
  5. package/lib/commonjs/components/Checkbox/CheckboxGroup.js.map +1 -1
  6. package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +5 -22
  7. package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js.map +1 -1
  8. package/lib/commonjs/components/Surface.js +1 -1
  9. package/lib/commonjs/components/Surface.js.map +1 -1
  10. package/lib/commonjs/components/SwipeableView/SwipeableView.js +155 -0
  11. package/lib/commonjs/components/SwipeableView/SwipeableView.js.map +1 -0
  12. package/lib/commonjs/components/SwipeableView/SwipeableViewButton.js +13 -0
  13. package/lib/commonjs/components/SwipeableView/SwipeableViewButton.js.map +1 -0
  14. package/lib/commonjs/components/SwipeableView/SwipeableViewSwipeHandler.js +13 -0
  15. package/lib/commonjs/components/SwipeableView/SwipeableViewSwipeHandler.js.map +1 -0
  16. package/lib/commonjs/components/SwipeableView/index.js +28 -0
  17. package/lib/commonjs/components/SwipeableView/index.js.map +1 -0
  18. package/lib/commonjs/index.js +19 -0
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/mappings/NativeBase/Layout.js +1 -1
  21. package/lib/commonjs/mappings/NativeBase/Layout.js.map +1 -1
  22. package/lib/commonjs/mappings/SwipeableView.js +182 -0
  23. package/lib/commonjs/mappings/SwipeableView.js.map +1 -0
  24. package/lib/commonjs/mappings/Table.js +3 -3
  25. package/lib/commonjs/mappings/Table.js.map +1 -1
  26. package/lib/commonjs/utilities.js +35 -2
  27. package/lib/commonjs/utilities.js.map +1 -1
  28. package/lib/module/components/Surface.js +1 -1
  29. package/lib/module/components/Surface.js.map +1 -1
  30. package/lib/module/components/SwipeableView/SwipeableView.js +147 -0
  31. package/lib/module/components/SwipeableView/SwipeableView.js.map +1 -0
  32. package/lib/module/components/SwipeableView/SwipeableViewButton.js +6 -0
  33. package/lib/module/components/SwipeableView/SwipeableViewButton.js.map +1 -0
  34. package/lib/module/components/SwipeableView/SwipeableViewSwipeHandler.js +6 -0
  35. package/lib/module/components/SwipeableView/SwipeableViewSwipeHandler.js.map +1 -0
  36. package/lib/module/components/SwipeableView/index.js +4 -0
  37. package/lib/module/components/SwipeableView/index.js.map +1 -0
  38. package/lib/module/index.js +1 -0
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/mappings/NativeBase/Layout.js +1 -1
  41. package/lib/module/mappings/NativeBase/Layout.js.map +1 -1
  42. package/lib/module/mappings/SwipeableView.js +175 -0
  43. package/lib/module/mappings/SwipeableView.js.map +1 -0
  44. package/lib/module/mappings/Table.js +3 -3
  45. package/lib/module/mappings/Table.js.map +1 -1
  46. package/lib/module/utilities.js +24 -0
  47. package/lib/module/utilities.js.map +1 -1
  48. package/lib/typescript/src/components/SwipeableView/SwipeableView.d.ts +29 -0
  49. package/lib/typescript/src/components/SwipeableView/SwipeableView.d.ts.map +1 -0
  50. package/lib/typescript/src/components/SwipeableView/SwipeableViewButton.d.ts +13 -0
  51. package/lib/typescript/src/components/SwipeableView/SwipeableViewButton.d.ts.map +1 -0
  52. package/lib/typescript/src/components/SwipeableView/SwipeableViewSwipeHandler.d.ts +13 -0
  53. package/lib/typescript/src/components/SwipeableView/SwipeableViewSwipeHandler.d.ts.map +1 -0
  54. package/lib/typescript/src/components/SwipeableView/index.d.ts +4 -0
  55. package/lib/typescript/src/components/SwipeableView/index.d.ts.map +1 -0
  56. package/lib/typescript/src/index.d.ts +1 -0
  57. package/lib/typescript/src/index.d.ts.map +1 -1
  58. package/lib/typescript/src/mappings/SwipeableView.d.ts +371 -0
  59. package/lib/typescript/src/mappings/SwipeableView.d.ts.map +1 -0
  60. package/lib/typescript/src/utilities.d.ts +8 -0
  61. package/lib/typescript/src/utilities.d.ts.map +1 -1
  62. package/package.json +4 -3
  63. package/src/components/Surface.js +1 -1
  64. package/src/components/Surface.tsx +1 -1
  65. package/src/components/SwipeableView/SwipeableView.js +117 -0
  66. package/src/components/SwipeableView/SwipeableView.tsx +299 -0
  67. package/src/components/SwipeableView/SwipeableViewButton.js +5 -0
  68. package/src/components/SwipeableView/SwipeableViewButton.tsx +18 -0
  69. package/src/components/SwipeableView/SwipeableViewSwipeHandler.js +5 -0
  70. package/src/components/SwipeableView/SwipeableViewSwipeHandler.tsx +20 -0
  71. package/src/components/SwipeableView/index.js +3 -0
  72. package/src/components/SwipeableView/index.tsx +3 -0
  73. package/src/index.js +1 -0
  74. package/src/index.tsx +6 -0
  75. package/src/mappings/NativeBase/Layout.js +1 -1
  76. package/src/mappings/NativeBase/Layout.ts +1 -1
  77. package/src/mappings/SwipeableView.js +181 -0
  78. package/src/mappings/SwipeableView.ts +210 -0
  79. package/src/mappings/Table.js +3 -3
  80. package/src/mappings/Table.ts +3 -3
  81. package/src/utilities.js +50 -0
  82. package/src/utilities.ts +90 -0
@@ -0,0 +1,210 @@
1
+ import {
2
+ COMPONENT_TYPES,
3
+ createStaticNumberProp,
4
+ createStaticBoolProp,
5
+ CONTAINER_COMPONENT_STYLES_SECTIONS,
6
+ StylesPanelSections,
7
+ GROUPS,
8
+ createBoolProp,
9
+ createTextProp,
10
+ createIconProp,
11
+ createTextEnumProp,
12
+ createColorProp,
13
+ Triggers,
14
+ createActionProp,
15
+ } from "@draftbit/types";
16
+
17
+ const SHARED_SWIPEABLE_CHILDREN_PROPS = {
18
+ title: createTextProp({
19
+ label: "Title",
20
+ description: "Title of button/swipeable",
21
+ defaultValue: "Swipeable",
22
+ required: true,
23
+ group: GROUPS.basic,
24
+ }),
25
+ side: createTextEnumProp({
26
+ label: "Side",
27
+ description: "Side where button/swipeable is added",
28
+ options: ["left", "right"],
29
+ defaultValue: "left",
30
+ required: true,
31
+ }),
32
+ icon: createIconProp({
33
+ defaultValue: null,
34
+ required: false,
35
+ }),
36
+ iconSize: createStaticNumberProp({
37
+ label: "Icon size",
38
+ description: "Size of icon",
39
+ defaultValue: 25,
40
+ required: false,
41
+ }),
42
+ backgroundColor: createColorProp({
43
+ label: "Background color",
44
+ description: "Color of button/swipeable background",
45
+ defaultValue: "primary",
46
+ }),
47
+ color: createColorProp({
48
+ label: "Color",
49
+ description: "Color of text and icon of button/swipeable",
50
+ defaultValue: "surface",
51
+ }),
52
+ };
53
+
54
+ export const SEED_DATA = [
55
+ {
56
+ name: "Swipeable View",
57
+ tag: "SwipeableView",
58
+ doc_link:
59
+ "https://github.com/jemise111/react-native-swipe-list-view/blob/master/docs/SwipeRow.md",
60
+ description:
61
+ "A swipeable view that is able to show hidden buttons and/or handle swipe events",
62
+ category: COMPONENT_TYPES.view,
63
+ stylesPanelSections: [
64
+ ...CONTAINER_COMPONENT_STYLES_SECTIONS,
65
+ StylesPanelSections.Typography,
66
+ ],
67
+ layout: {
68
+ overflow: "hidden",
69
+ flexDirection: "row",
70
+ alignItems: "center",
71
+ padding: 10,
72
+ },
73
+ props: {
74
+ closeOnPress: createStaticBoolProp({
75
+ label: "Close on press",
76
+ description: "Whether the view should be closed/dismissed when pressed",
77
+ defaultValue: true,
78
+ }),
79
+ swipeActivationPercentage: createStaticNumberProp({
80
+ label: "Swipe activation percentage",
81
+ description:
82
+ "Percentage of swipe completion needed to trigger onSwipe. Overriden by 'Left activation value' and 'Right activation value'",
83
+ defaultValue: 80,
84
+ required: false,
85
+ }),
86
+ disableLeftSwipe: createBoolProp({
87
+ label: "Disable left swipe",
88
+ description: "Whether left swipe is enabled or not",
89
+ defaultValue: true,
90
+ }),
91
+ disableRightSwipe: createBoolProp({
92
+ label: "Disable right swipe",
93
+ description: "Whether right swipe is enabled or not",
94
+ defaultValue: true,
95
+ }),
96
+ leftOpenValue: createStaticNumberProp({
97
+ label: "Left open value",
98
+ description:
99
+ "The X translation value that left swipe snaps to (positive value). Defaults to half view width",
100
+ group: GROUPS.advanced,
101
+ required: false,
102
+ }),
103
+ rightOpenValue: createStaticNumberProp({
104
+ label: "Right open value",
105
+ description:
106
+ "The X translation value that right swipe snaps to (negative value). Defaults to negative half view width",
107
+ group: GROUPS.advanced,
108
+ required: false,
109
+ }),
110
+ leftActivationValue: createStaticNumberProp({
111
+ label: "Left activation value",
112
+ description:
113
+ "The X translation value that triggers onSwipe when surpassed (positive value). Defaults to 80% of half view width",
114
+ group: GROUPS.advanced,
115
+ required: false,
116
+ }),
117
+ rightActivationValue: createStaticNumberProp({
118
+ label: "Right activation value",
119
+ description:
120
+ "The X translation value that triggers onSwipe when surpassed (negative value). Defaults to negative 80% of half view width",
121
+ group: GROUPS.advanced,
122
+ required: false,
123
+ }),
124
+ stopLeftSwipe: createStaticNumberProp({
125
+ label: "Stop left swipe",
126
+ description:
127
+ "The maximum X translation value that is swipable from left (positive value). Defaults to half view width",
128
+ group: GROUPS.advanced,
129
+ required: false,
130
+ }),
131
+ stopRightSwipe: createStaticNumberProp({
132
+ label: "Stop right swipe",
133
+ description:
134
+ "The maximum X translation value that is swipable from right (negative value). Defaults to negative half view width",
135
+ group: GROUPS.advanced,
136
+ required: false,
137
+ }),
138
+ directionalDistanceChangeThreshold: createStaticNumberProp({
139
+ label: "Change threshold",
140
+ description: "Change the sensitivity of the swipe on the view",
141
+ group: GROUPS.advanced,
142
+ required: false,
143
+ }),
144
+ friction: createStaticNumberProp({
145
+ label: "Friction",
146
+ description: "Controls the 'bounciness' of the swipe animation",
147
+ defaultValue: 20,
148
+ group: GROUPS.advanced,
149
+ required: false,
150
+ }),
151
+ tension: createStaticNumberProp({
152
+ label: "Change threshold",
153
+ description: "Controls the tension/speed of the swipe animation",
154
+ group: GROUPS.advanced,
155
+ required: false,
156
+ }),
157
+ swipeToOpenVelocityContribution: createStaticNumberProp({
158
+ label: "Swipe Velocity Contribution",
159
+ description:
160
+ "Describes how much the ending velocity of the gesture affects whether the swipe will result in the item being closed or open. A velocity factor of 0 (the default) means that the velocity will have no bearing on whether the swipe settles on a closed or open position and it'll just take into consideration the swipeToOpenPercent. Ideal values for this prop tend to be between 5 and 15",
161
+ group: GROUPS.advanced,
162
+ required: false,
163
+ }),
164
+ swipeToOpenPercent: createStaticNumberProp({
165
+ label: "Swipe to open percentage",
166
+ description:
167
+ "What % of the left/right does the user need to swipe past to trigger the view opening",
168
+ group: GROUPS.advanced,
169
+ defaultValue: 50,
170
+ required: false,
171
+ }),
172
+ swipeToClosePercent: createStaticNumberProp({
173
+ label: "Swipe to close percentage",
174
+ description:
175
+ "What % of the left/right does the user need to swipe past to trigger the view closing",
176
+ group: GROUPS.advanced,
177
+ defaultValue: 50,
178
+ required: false,
179
+ }),
180
+ },
181
+ },
182
+ {
183
+ name: "Swipeable View Button",
184
+ tag: "SwipeableViewButton",
185
+ description: "Button to be rendered under a Swipeable View",
186
+ category: COMPONENT_TYPES.view,
187
+ stylesPanelSections: [],
188
+ triggers: [Triggers.OnPress],
189
+ props: {
190
+ ...SHARED_SWIPEABLE_CHILDREN_PROPS,
191
+ onPress: createActionProp(),
192
+ },
193
+ },
194
+ {
195
+ name: "Swipeable View Swipe Handler",
196
+ tag: "SwipeableViewSwipeHandler",
197
+ description: "Component that renders and handles swipe of Swipeable View",
198
+ category: COMPONENT_TYPES.view,
199
+ stylesPanelSections: [],
200
+ triggers: [Triggers.OnSwipe],
201
+ props: {
202
+ ...SHARED_SWIPEABLE_CHILDREN_PROPS,
203
+ onSwipe: createActionProp({
204
+ label: "On swipe",
205
+ description:
206
+ "Called when Swipeable View swiped in the direction this is configured to",
207
+ }),
208
+ },
209
+ },
210
+ ];
@@ -55,7 +55,7 @@ export const SEED_DATA = [
55
55
  name: "Table",
56
56
  tag: "Table",
57
57
  description: "Top level table container",
58
- category: COMPONENT_TYPES.table,
58
+ category: COMPONENT_TYPES.testing /*.table*/,
59
59
  stylesPanelSections: [
60
60
  StylesPanelSections.Size,
61
61
  StylesPanelSections.Margins,
@@ -101,7 +101,7 @@ export const SEED_DATA = [
101
101
  name: "Table Row",
102
102
  tag: "TableRow",
103
103
  description: "Table Row container",
104
- category: COMPONENT_TYPES.table,
104
+ category: COMPONENT_TYPES.testing /*.table*/,
105
105
  stylesPanelSections: [StylesPanelSections.Background],
106
106
  props: {
107
107
  ...SHARED_SEED_DATA_PROPS,
@@ -124,7 +124,7 @@ export const SEED_DATA = [
124
124
  name: "Table Cell",
125
125
  tag: "TableCell",
126
126
  description: "Table Cell container",
127
- category: COMPONENT_TYPES.table,
127
+ category: COMPONENT_TYPES.testing /*.table*/,
128
128
  stylesPanelSections: [
129
129
  StylesPanelSections.LayoutFlexItems,
130
130
  StylesPanelSections.LayoutSelectedItem,
@@ -73,7 +73,7 @@ export const SEED_DATA = [
73
73
  name: "Table",
74
74
  tag: "Table",
75
75
  description: "Top level table container",
76
- category: COMPONENT_TYPES.table,
76
+ category: COMPONENT_TYPES.testing /*.table*/,
77
77
  stylesPanelSections: [
78
78
  StylesPanelSections.Size,
79
79
  StylesPanelSections.Margins,
@@ -120,7 +120,7 @@ export const SEED_DATA = [
120
120
  name: "Table Row",
121
121
  tag: "TableRow",
122
122
  description: "Table Row container",
123
- category: COMPONENT_TYPES.table,
123
+ category: COMPONENT_TYPES.testing /*.table*/,
124
124
  stylesPanelSections: [StylesPanelSections.Background],
125
125
  props: {
126
126
  ...SHARED_SEED_DATA_PROPS,
@@ -144,7 +144,7 @@ export const SEED_DATA = [
144
144
  name: "Table Cell",
145
145
  tag: "TableCell",
146
146
  description: "Table Cell container",
147
- category: COMPONENT_TYPES.table,
147
+ category: COMPONENT_TYPES.testing /*.table*/,
148
148
  stylesPanelSections: [
149
149
  StylesPanelSections.LayoutFlexItems,
150
150
  StylesPanelSections.LayoutSelectedItem,
package/src/utilities.js CHANGED
@@ -65,6 +65,56 @@ export function extractBorderAndMarginStyles(style, additionalBorderStyles, addi
65
65
  ]), identity);
66
66
  return { borderStyles, marginStyles };
67
67
  }
68
+ export const flexItemStyleNames = [
69
+ "alignSelf",
70
+ "flexBasis",
71
+ "flexShrink",
72
+ "flexGrow",
73
+ "flex",
74
+ ];
75
+ export function extractFlexItemStyles(style, additionalFlexItemStyles) {
76
+ const flatStyle = StyleSheet.flatten(style || {});
77
+ const flexItemStyles = pickBy(pick(flatStyle, [
78
+ ...flexItemStyleNames,
79
+ ...(additionalFlexItemStyles ? additionalFlexItemStyles : []),
80
+ ]), identity);
81
+ return flexItemStyles;
82
+ }
83
+ export const positionStyleNames = [
84
+ "position",
85
+ "left",
86
+ "right",
87
+ "top",
88
+ "bottom",
89
+ "zIndex",
90
+ "overflow",
91
+ ];
92
+ export function extractPositionStyles(style, additionalPositionStyles) {
93
+ const flatStyle = StyleSheet.flatten(style || {});
94
+ const positionStyles = pickBy(pick(flatStyle, [
95
+ ...positionStyleNames,
96
+ ...(additionalPositionStyles ? additionalPositionStyles : []),
97
+ ]), identity);
98
+ return positionStyles;
99
+ }
100
+ export const effectsStyleNames = ["opacity", "elevation"];
101
+ export function extractEffectStyles(style, additionalEffectStyles) {
102
+ const flatStyle = StyleSheet.flatten(style || {});
103
+ const effectStyles = pickBy(pick(flatStyle, [
104
+ ...effectsStyleNames,
105
+ ...(additionalEffectStyles ? additionalEffectStyles : []),
106
+ ]), identity);
107
+ return effectStyles;
108
+ }
109
+ export const sizeStyleNames = ["width", "height"];
110
+ export function extractSizeStyles(style, additionalSizeStyles) {
111
+ const flatStyle = StyleSheet.flatten(style || {});
112
+ const sizeStyles = pickBy(pick(flatStyle, [
113
+ ...sizeStyleNames,
114
+ ...(additionalSizeStyles ? additionalSizeStyles : []),
115
+ ]), identity);
116
+ return sizeStyles;
117
+ }
68
118
  /**
69
119
  * Merges a style object on top of another style object. In React Native,
70
120
  * keys with undefined values in a style object will still override styles
package/src/utilities.ts CHANGED
@@ -98,6 +98,96 @@ export function extractBorderAndMarginStyles(
98
98
  return { borderStyles, marginStyles };
99
99
  }
100
100
 
101
+ export const flexItemStyleNames = [
102
+ "alignSelf",
103
+ "flexBasis",
104
+ "flexShrink",
105
+ "flexGrow",
106
+ "flex",
107
+ ];
108
+
109
+ export function extractFlexItemStyles(
110
+ style: StyleProp<any>,
111
+ additionalFlexItemStyles?: string[]
112
+ ) {
113
+ const flatStyle = StyleSheet.flatten(style || {});
114
+
115
+ const flexItemStyles = pickBy(
116
+ pick(flatStyle, [
117
+ ...flexItemStyleNames,
118
+ ...(additionalFlexItemStyles ? additionalFlexItemStyles : []),
119
+ ]),
120
+ identity
121
+ );
122
+
123
+ return flexItemStyles;
124
+ }
125
+
126
+ export const positionStyleNames = [
127
+ "position",
128
+ "left",
129
+ "right",
130
+ "top",
131
+ "bottom",
132
+ "zIndex",
133
+ "overflow",
134
+ ];
135
+
136
+ export function extractPositionStyles(
137
+ style: StyleProp<any>,
138
+ additionalPositionStyles?: string[]
139
+ ) {
140
+ const flatStyle = StyleSheet.flatten(style || {});
141
+
142
+ const positionStyles = pickBy(
143
+ pick(flatStyle, [
144
+ ...positionStyleNames,
145
+ ...(additionalPositionStyles ? additionalPositionStyles : []),
146
+ ]),
147
+ identity
148
+ );
149
+
150
+ return positionStyles;
151
+ }
152
+
153
+ export const effectsStyleNames = ["opacity", "elevation"];
154
+
155
+ export function extractEffectStyles(
156
+ style: StyleProp<any>,
157
+ additionalEffectStyles?: string[]
158
+ ) {
159
+ const flatStyle = StyleSheet.flatten(style || {});
160
+
161
+ const effectStyles = pickBy(
162
+ pick(flatStyle, [
163
+ ...effectsStyleNames,
164
+ ...(additionalEffectStyles ? additionalEffectStyles : []),
165
+ ]),
166
+ identity
167
+ );
168
+
169
+ return effectStyles;
170
+ }
171
+
172
+ export const sizeStyleNames = ["width", "height"];
173
+
174
+ export function extractSizeStyles(
175
+ style: StyleProp<any>,
176
+ additionalSizeStyles?: string[]
177
+ ) {
178
+ const flatStyle = StyleSheet.flatten(style || {});
179
+
180
+ const sizeStyles = pickBy(
181
+ pick(flatStyle, [
182
+ ...sizeStyleNames,
183
+ ...(additionalSizeStyles ? additionalSizeStyles : []),
184
+ ]),
185
+ identity
186
+ );
187
+
188
+ return sizeStyles;
189
+ }
190
+
101
191
  /**
102
192
  * Merges a style object on top of another style object. In React Native,
103
193
  * keys with undefined values in a style object will still override styles