@draftbit/core 46.10.3-7db6c9.2 → 46.10.3-84bbff.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.
- package/lib/commonjs/components/AnimatedCircularProgress.js +12 -1
- package/lib/commonjs/components/Banner.js +23 -4
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +22 -4
- package/lib/commonjs/components/BottomSheet/BottomSheetComponent.js +127 -111
- package/lib/commonjs/components/Button.js +33 -10
- package/lib/commonjs/components/Checkbox/Checkbox.js +3 -4
- package/lib/commonjs/components/Checkbox/context.js +1 -1
- package/lib/commonjs/components/DeckSwiper/DeckSwiper.js +1 -4
- package/lib/commonjs/components/DeprecatedCardWrapper.js +15 -1
- package/lib/commonjs/components/Divider.js +14 -1
- package/lib/commonjs/components/FAB.js +18 -4
- package/lib/commonjs/components/Layout.js +40 -19
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +36 -11
- package/lib/commonjs/components/Portal/Portal.js +27 -3
- package/lib/commonjs/components/Portal/PortalConsumer.js +22 -7
- package/lib/commonjs/components/Pressable.js +15 -2
- package/lib/commonjs/components/ScreenContainer.js +24 -6
- package/lib/commonjs/components/Shadow.js +15 -2
- package/lib/commonjs/components/Slider.js +21 -4
- package/lib/commonjs/components/Switch.js +19 -10
- package/lib/commonjs/components/TabView/TabView.js +13 -7
- package/lib/commonjs/components/Table/Table.js +123 -0
- package/lib/commonjs/components/Table/TableCell.js +49 -0
- package/lib/commonjs/components/Table/TableCommon.js +30 -0
- package/lib/commonjs/components/Table/TableRow.js +60 -0
- package/lib/commonjs/components/Table/index.js +27 -0
- package/lib/commonjs/components/Text.js +50 -4
- package/lib/commonjs/components/TextField.js +76 -28
- package/lib/commonjs/components/ToggleButton.js +15 -2
- package/lib/commonjs/components/Touchable.js +15 -2
- package/lib/commonjs/constants.js +1 -1
- package/lib/commonjs/index.js +19 -7
- package/lib/commonjs/mappings/FieldSearchBarFull.js +3 -1
- package/lib/commonjs/mappings/NativeBase/Layout.js +2 -11
- package/lib/commonjs/mappings/StarRating.js +6 -2
- package/lib/commonjs/mappings/Table.js +140 -0
- package/lib/commonjs/styles/overlay.js +1 -3
- package/lib/module/components/Accordion/AccordionItem.js +25 -4
- package/lib/module/components/AnimatedCircularProgress.js +13 -1
- package/lib/module/components/AspectRatio.js +18 -1
- package/lib/module/components/AvatarEdit.js +15 -4
- package/lib/module/components/BottomSheet/BottomSheetComponent.js +124 -111
- package/lib/module/components/Checkbox/CheckboxGroup.js +16 -2
- package/lib/module/components/DeprecatedButton.js +21 -3
- package/lib/module/components/DeprecatedCardWrapper.js +18 -1
- package/lib/module/components/Picker/PickerComponent.android.js +21 -3
- package/lib/module/components/Picker/PickerComponent.ios.js +36 -11
- package/lib/module/components/Portal/PortalHost.js +45 -15
- package/lib/module/components/RadioButton/RadioButton.js +13 -1
- package/lib/module/components/RadioButton/RadioButtonGroup.js +16 -2
- package/lib/module/components/RadioButton/RadioButtonRow.js +24 -5
- package/lib/module/components/Surface.js +15 -1
- package/lib/module/components/TabView/TabView.js +17 -7
- package/lib/module/components/Table/Table.js +114 -0
- package/lib/module/components/Table/TableCell.js +41 -0
- package/lib/module/components/Table/TableCommon.js +21 -0
- package/lib/module/components/Table/TableRow.js +53 -0
- package/lib/module/components/Table/index.js +3 -0
- package/lib/module/components/Touchable.js +15 -2
- package/lib/module/constants.js +1 -0
- package/lib/module/hooks.js +1 -2
- package/lib/module/index.js +1 -1
- package/lib/module/mappings/NativeBase/Layout.js +3 -12
- package/lib/module/mappings/Table.js +133 -0
- package/lib/typescript/src/components/Table/Table.d.ts +19 -0
- package/lib/typescript/src/components/Table/Table.d.ts.map +1 -0
- package/lib/typescript/src/components/Table/TableCell.d.ts +9 -0
- package/lib/typescript/src/components/Table/TableCell.d.ts.map +1 -0
- package/lib/typescript/src/components/Table/TableCommon.d.ts +20 -0
- package/lib/typescript/src/components/Table/TableCommon.d.ts.map +1 -0
- package/lib/typescript/src/components/Table/TableRow.d.ts +14 -0
- package/lib/typescript/src/components/Table/TableRow.d.ts.map +1 -0
- package/lib/typescript/src/components/Table/index.d.ts +4 -0
- package/lib/typescript/src/components/Table/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts +4 -27
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Table.d.ts +337 -0
- package/lib/typescript/src/mappings/Table.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/Table/Table.js +93 -0
- package/src/components/Table/Table.tsx +176 -0
- package/src/components/Table/TableCell.js +31 -0
- package/src/components/Table/TableCell.tsx +63 -0
- package/src/components/Table/TableCommon.js +12 -0
- package/src/components/Table/TableCommon.ts +40 -0
- package/src/components/Table/TableRow.js +37 -0
- package/src/components/Table/TableRow.tsx +77 -0
- package/src/components/Table/index.js +3 -0
- package/src/components/Table/index.tsx +3 -0
- package/src/index.js +1 -1
- package/src/index.tsx +2 -1
- package/src/mappings/NativeBase/Layout.js +9 -11
- package/src/mappings/NativeBase/Layout.ts +8 -11
- package/src/mappings/Table.js +150 -0
- package/src/mappings/Table.ts +170 -0
- package/lib/commonjs/components/Container.js +0 -93
- package/lib/module/components/Container.js +0 -83
- package/lib/typescript/src/components/Container.d.ts +0 -21
- package/lib/typescript/src/components/Container.d.ts.map +0 -1
- package/src/components/Container.js +0 -43
- package/src/components/Container.tsx +0 -116
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
1
|
import * as React from "react";
|
|
5
2
|
import { View, StyleSheet } from "react-native";
|
|
6
3
|
import PortalManager from "./PortalManager";
|
|
7
4
|
export const PortalContext = /*#__PURE__*/React.createContext(null);
|
|
8
|
-
|
|
9
5
|
/**
|
|
10
6
|
* Portal host renders all of its children `Portal` elements.
|
|
11
7
|
* For example, you can wrap a screen in `Portal.Host` to render items above the screen.
|
|
@@ -33,10 +29,10 @@ export const PortalContext = /*#__PURE__*/React.createContext(null);
|
|
|
33
29
|
export default class PortalHost extends React.Component {
|
|
34
30
|
constructor() {
|
|
35
31
|
super(...arguments);
|
|
36
|
-
|
|
32
|
+
this.setManager = manager => {
|
|
37
33
|
this.manager = manager;
|
|
38
|
-
}
|
|
39
|
-
|
|
34
|
+
};
|
|
35
|
+
this.mount = children => {
|
|
40
36
|
const key = this.nextKey++;
|
|
41
37
|
if (this.manager) {
|
|
42
38
|
this.manager.mount(key, children);
|
|
@@ -48,8 +44,8 @@ export default class PortalHost extends React.Component {
|
|
|
48
44
|
});
|
|
49
45
|
}
|
|
50
46
|
return key;
|
|
51
|
-
}
|
|
52
|
-
|
|
47
|
+
};
|
|
48
|
+
this.update = (key, children) => {
|
|
53
49
|
if (this.manager) {
|
|
54
50
|
this.manager.update(key, children);
|
|
55
51
|
} else {
|
|
@@ -66,8 +62,8 @@ export default class PortalHost extends React.Component {
|
|
|
66
62
|
this.queue.push(op);
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
65
|
+
};
|
|
66
|
+
this.unmount = key => {
|
|
71
67
|
if (this.manager) {
|
|
72
68
|
this.manager.unmount(key);
|
|
73
69
|
} else {
|
|
@@ -76,10 +72,9 @@ export default class PortalHost extends React.Component {
|
|
|
76
72
|
key
|
|
77
73
|
});
|
|
78
74
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
_defineProperty(this, "manager", void 0);
|
|
75
|
+
};
|
|
76
|
+
this.nextKey = 0;
|
|
77
|
+
this.queue = [];
|
|
83
78
|
}
|
|
84
79
|
componentDidMount() {
|
|
85
80
|
const manager = this.manager;
|
|
@@ -117,6 +112,41 @@ export default class PortalHost extends React.Component {
|
|
|
117
112
|
}));
|
|
118
113
|
}
|
|
119
114
|
}
|
|
115
|
+
PortalHost.displayName = "Portal.Host";
|
|
116
|
+
const styles = StyleSheet.create({
|
|
117
|
+
container: {
|
|
118
|
+
flex: 1
|
|
119
|
+
}
|
|
120
|
+
}); switch (action.type) {
|
|
121
|
+
case "mount":
|
|
122
|
+
manager.mount(action.key, action.children);
|
|
123
|
+
break;
|
|
124
|
+
case "update":
|
|
125
|
+
manager.update(action.key, action.children);
|
|
126
|
+
break;
|
|
127
|
+
case "unmount":
|
|
128
|
+
manager.unmount(action.key);
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
render() {
|
|
135
|
+
return /*#__PURE__*/React.createElement(PortalContext.Provider, {
|
|
136
|
+
value: {
|
|
137
|
+
mount: this.mount,
|
|
138
|
+
update: this.update,
|
|
139
|
+
unmount: this.unmount
|
|
140
|
+
}
|
|
141
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
142
|
+
style: styles.container,
|
|
143
|
+
collapsable: false,
|
|
144
|
+
pointerEvents: "box-none"
|
|
145
|
+
}, this.props.children), /*#__PURE__*/React.createElement(PortalManager, {
|
|
146
|
+
ref: this.setManager
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
120
150
|
_defineProperty(PortalHost, "displayName", "Portal.Host");
|
|
121
151
|
const styles = StyleSheet.create({
|
|
122
152
|
container: {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import Config from "../Config";
|
|
4
3
|
import IconButton from "../IconButton";
|
|
@@ -30,6 +29,19 @@ const RadioButton = _ref => {
|
|
|
30
29
|
onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
|
|
31
30
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
32
31
|
};
|
|
32
|
+
return /*#__PURE__*/React.createElement(IconButton, {
|
|
33
|
+
Icon: Icon,
|
|
34
|
+
icon: isSelected ? selectedIcon : unselectedIcon,
|
|
35
|
+
color: isSelected ? color : unselectedColor,
|
|
36
|
+
disabled: disabled,
|
|
37
|
+
onPress: handlePress,
|
|
38
|
+
size: size,
|
|
39
|
+
style: style,
|
|
40
|
+
...rest
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export default RadioButton;: onValueChange(realValue);
|
|
44
|
+
};
|
|
33
45
|
return /*#__PURE__*/React.createElement(IconButton, _extends({
|
|
34
46
|
Icon: Icon,
|
|
35
47
|
icon: isSelected ? selectedIcon : unselectedIcon,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import { View } from "react-native";
|
|
4
3
|
import { getValueForRadioButton } from "../../utilities";
|
|
@@ -42,7 +41,22 @@ const RadioButtonGroup = _ref => {
|
|
|
42
41
|
alignItems: "center"
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
|
-
return /*#__PURE__*/React.createElement(View,
|
|
44
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
45
|
+
style: [{
|
|
46
|
+
minHeight: 40
|
|
47
|
+
}, style],
|
|
48
|
+
...rest
|
|
49
|
+
}, /*#__PURE__*/React.createElement(Provider, {
|
|
50
|
+
value: {
|
|
51
|
+
value: internalValue,
|
|
52
|
+
onValueChange: handleValueChange,
|
|
53
|
+
direction
|
|
54
|
+
}
|
|
55
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
56
|
+
style: _containerStyle
|
|
57
|
+
}, children)));
|
|
58
|
+
};
|
|
59
|
+
export default RadioButtonGroup;xtends({
|
|
46
60
|
style: [{
|
|
47
61
|
minHeight: 40
|
|
48
62
|
}, style]
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import { StyleSheet, View, Platform } from "react-native";
|
|
4
3
|
import RadioButton from "./RadioButton";
|
|
@@ -7,7 +6,7 @@ import { useRadioButtonGroupContext } from "./context";
|
|
|
7
6
|
import { Direction as GroupDirection } from "./context";
|
|
8
7
|
import Touchable from "../Touchable";
|
|
9
8
|
import { extractStyles, getValueForRadioButton } from "../../utilities";
|
|
10
|
-
export
|
|
9
|
+
export var Direction;
|
|
11
10
|
(function (Direction) {
|
|
12
11
|
Direction["Row"] = "row";
|
|
13
12
|
Direction["RowReverse"] = "row-reverse";
|
|
@@ -63,13 +62,14 @@ const RadioButtonRow = _ref => {
|
|
|
63
62
|
textStyles,
|
|
64
63
|
viewStyles
|
|
65
64
|
} = extractStyles(style);
|
|
66
|
-
return /*#__PURE__*/React.createElement(Touchable,
|
|
65
|
+
return /*#__PURE__*/React.createElement(Touchable, {
|
|
67
66
|
onPress: handlePress,
|
|
68
67
|
style: [styles.mainParent, {
|
|
69
68
|
flexDirection: direction
|
|
70
69
|
}, viewStyles],
|
|
71
|
-
disabled: disabled
|
|
72
|
-
|
|
70
|
+
disabled: disabled,
|
|
71
|
+
...rest
|
|
72
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
73
73
|
style: [styles.label, {
|
|
74
74
|
alignItems: direction === Direction.Row ? "flex-start" : "flex-end"
|
|
75
75
|
}, labelContainerStyle]
|
|
@@ -106,4 +106,23 @@ const styles = StyleSheet.create({
|
|
|
106
106
|
flex: 3
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
|
+
export default RadioButtonRow;.create({
|
|
110
|
+
mainParent: {
|
|
111
|
+
alignItems: "center",
|
|
112
|
+
justifyContent: "space-around",
|
|
113
|
+
paddingStart: 20,
|
|
114
|
+
minHeight: 50,
|
|
115
|
+
paddingEnd: 20,
|
|
116
|
+
display: "flex",
|
|
117
|
+
...Platform.select({
|
|
118
|
+
web: {
|
|
119
|
+
cursor: "pointer",
|
|
120
|
+
userSelect: "none"
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
},
|
|
124
|
+
label: {
|
|
125
|
+
flex: 3
|
|
126
|
+
}
|
|
127
|
+
});
|
|
109
128
|
export default RadioButtonRow;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
/* Copied from https://github.com/callstack/react-native-paper/blob/main/src/components/Surface.tsx */
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
import { Animated, StyleSheet } from "react-native";
|
|
@@ -34,6 +33,21 @@ const Surface = _ref => {
|
|
|
34
33
|
return colors.surface;
|
|
35
34
|
}
|
|
36
35
|
};
|
|
36
|
+
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
37
|
+
...rest,
|
|
38
|
+
style: [{
|
|
39
|
+
backgroundColor: getBackgroundColor(),
|
|
40
|
+
elevation,
|
|
41
|
+
...evalationStyles,
|
|
42
|
+
...restStyle
|
|
43
|
+
}]
|
|
44
|
+
}, children);
|
|
45
|
+
};
|
|
46
|
+
export default withTheme(Surface);erlay(elevation, colors.surface);
|
|
47
|
+
} else {
|
|
48
|
+
return colors.surface;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
37
51
|
return /*#__PURE__*/React.createElement(Animated.View, _extends({}, rest, {
|
|
38
52
|
style: [{
|
|
39
53
|
backgroundColor: getBackgroundColor(),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import { TabView, TabBar, SceneMap } from "react-native-tab-view";
|
|
4
3
|
import { withTheme } from "../../theming";
|
|
@@ -28,13 +27,11 @@ const TabViewComponent = _ref => {
|
|
|
28
27
|
textStyles,
|
|
29
28
|
viewStyles
|
|
30
29
|
} = extractStyles(style);
|
|
31
|
-
|
|
32
30
|
//Check type of child using props
|
|
33
31
|
//Regular '.type' cannot work because Draftbit strips the type in Draft view
|
|
34
32
|
const instanceOfTabViewItemProps = object => {
|
|
35
33
|
return "title" in object;
|
|
36
34
|
};
|
|
37
|
-
|
|
38
35
|
//Populate routes and scenes based on children
|
|
39
36
|
React.useEffect(() => {
|
|
40
37
|
const newRoutes = [];
|
|
@@ -60,7 +57,8 @@ const TabViewComponent = _ref => {
|
|
|
60
57
|
}
|
|
61
58
|
};
|
|
62
59
|
const renderTabBar = props => {
|
|
63
|
-
return /*#__PURE__*/React.createElement(TabBar,
|
|
60
|
+
return /*#__PURE__*/React.createElement(TabBar, {
|
|
61
|
+
...props,
|
|
64
62
|
activeColor: activeColor || theme.colors.primary,
|
|
65
63
|
inactiveColor: inactiveColor || theme.colors.divider,
|
|
66
64
|
pressColor: pressColor || theme.colors.primary,
|
|
@@ -74,7 +72,7 @@ const TabViewComponent = _ref => {
|
|
|
74
72
|
route,
|
|
75
73
|
color
|
|
76
74
|
} = _ref2;
|
|
77
|
-
return route
|
|
75
|
+
return (route === null || route === void 0 ? void 0 : route.icon) ? /*#__PURE__*/React.createElement(Icon, {
|
|
78
76
|
name: route.icon,
|
|
79
77
|
color: color,
|
|
80
78
|
size: 16
|
|
@@ -83,9 +81,8 @@ const TabViewComponent = _ref => {
|
|
|
83
81
|
style: {
|
|
84
82
|
backgroundColor: tabsBackgroundColor || theme.colors.background
|
|
85
83
|
}
|
|
86
|
-
})
|
|
84
|
+
});
|
|
87
85
|
};
|
|
88
|
-
|
|
89
86
|
//Cannot render TabView without at least one tab
|
|
90
87
|
if (!routes.length) {
|
|
91
88
|
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
@@ -104,4 +101,17 @@ const TabViewComponent = _ref => {
|
|
|
104
101
|
swipeEnabled: swipeEnabled
|
|
105
102
|
});
|
|
106
103
|
};
|
|
104
|
+
export default withTheme(TabViewComponent);tyles],
|
|
105
|
+
navigationState: {
|
|
106
|
+
index,
|
|
107
|
+
routes
|
|
108
|
+
},
|
|
109
|
+
renderScene: SceneMap(tabScenes),
|
|
110
|
+
renderTabBar: renderTabBar,
|
|
111
|
+
onIndexChange: indexChangeHandler,
|
|
112
|
+
tabBarPosition: tabBarPosition,
|
|
113
|
+
keyboardDismissMode: keyboardDismissMode,
|
|
114
|
+
swipeEnabled: swipeEnabled
|
|
115
|
+
});
|
|
116
|
+
};
|
|
107
117
|
export default withTheme(TabViewComponent);
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ScrollView, View, StyleSheet } from "react-native";
|
|
3
|
+
import { withTheme } from "../../theming";
|
|
4
|
+
import { generateBorderStyles, TableStyleContext } from "./TableCommon";
|
|
5
|
+
const Table = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
theme,
|
|
8
|
+
borderWidth = 1,
|
|
9
|
+
borderColor = theme.colors.divider,
|
|
10
|
+
borderStyle = "solid",
|
|
11
|
+
drawTopBorder = true,
|
|
12
|
+
drawBottomBorder = false,
|
|
13
|
+
drawStartBorder = false,
|
|
14
|
+
drawEndBorder = false,
|
|
15
|
+
cellVerticalPadding = 10,
|
|
16
|
+
cellHorizontalPadding = 10,
|
|
17
|
+
data,
|
|
18
|
+
keyExtractor,
|
|
19
|
+
renderItem,
|
|
20
|
+
children: childrenProp,
|
|
21
|
+
style,
|
|
22
|
+
...rest
|
|
23
|
+
} = _ref;
|
|
24
|
+
//Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
|
|
25
|
+
if (data && !renderItem || renderItem && !data) {
|
|
26
|
+
throw new Error("'renderItem' and 'data' need to both be provided to render from 'data'. Either remove them entirley or include both");
|
|
27
|
+
}
|
|
28
|
+
if (data && renderItem && childrenProp) {
|
|
29
|
+
console.warn("'children' of Table ignored due to usage of 'data' and 'renderItem'");
|
|
30
|
+
}
|
|
31
|
+
const isTableHeader = React.useCallback(object => {
|
|
32
|
+
return object.isTableHeader;
|
|
33
|
+
}, []);
|
|
34
|
+
const isRenderItem = data && renderItem;
|
|
35
|
+
|
|
36
|
+
//Uses 'renderItem' and 'data' to create an array of children
|
|
37
|
+
const dataAsChildren = React.useMemo(() => {
|
|
38
|
+
if (!isRenderItem) return [];
|
|
39
|
+
return data.map((item, index) => {
|
|
40
|
+
const component = renderItem({
|
|
41
|
+
item,
|
|
42
|
+
index
|
|
43
|
+
});
|
|
44
|
+
if (!component) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const key = keyExtractor ? keyExtractor(item, index) : index.toString();
|
|
48
|
+
return /*#__PURE__*/React.cloneElement(component, {
|
|
49
|
+
key
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}, [data, renderItem, keyExtractor, isRenderItem]);
|
|
53
|
+
const children = isRenderItem ? dataAsChildren : React.Children.toArray(childrenProp);
|
|
54
|
+
const validChildren = React.useMemo(() => children.filter(item => /*#__PURE__*/React.isValidElement(item)), [children]);
|
|
55
|
+
const childrenWithoutHeader = React.useMemo(() => {
|
|
56
|
+
const flattenedWithoutNestedHeaders = validChildren.map(item => {
|
|
57
|
+
const nestedChildren = React.Children.toArray(item.props.children);
|
|
58
|
+
//Header can be nested in React.Fragment when in renderItem
|
|
59
|
+
const nestedHeaders = nestedChildren.filter(child => isTableHeader(child.props));
|
|
60
|
+
if (nestedHeaders !== null && nestedHeaders !== void 0 && nestedHeaders.length) {
|
|
61
|
+
//New element excluding header children
|
|
62
|
+
return /*#__PURE__*/React.cloneElement(item, {
|
|
63
|
+
children: nestedChildren.filter(child => !isTableHeader(child.props))
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return item;
|
|
67
|
+
});
|
|
68
|
+
return flattenedWithoutNestedHeaders.filter(item => !isTableHeader(item.props));
|
|
69
|
+
}, [validChildren, isTableHeader]);
|
|
70
|
+
const header = React.useMemo(() => {
|
|
71
|
+
const flattenedPossibleHeaders = validChildren.map(item => {
|
|
72
|
+
const nestedChildren = React.Children.toArray(item.props.children);
|
|
73
|
+
//Header can be nested in React.Fragment when in renderItem
|
|
74
|
+
const nestedHeaders = nestedChildren.filter(child => isTableHeader(child.props));
|
|
75
|
+
if (nestedHeaders !== null && nestedHeaders !== void 0 && nestedHeaders.length) {
|
|
76
|
+
return nestedHeaders[0];
|
|
77
|
+
}
|
|
78
|
+
return item;
|
|
79
|
+
});
|
|
80
|
+
const allHeaders = flattenedPossibleHeaders.filter(item => isTableHeader(item.props));
|
|
81
|
+
if (allHeaders.length) {
|
|
82
|
+
return allHeaders[0]; //Only 1 header taken
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return null;
|
|
86
|
+
}, [validChildren, isTableHeader]);
|
|
87
|
+
const contextValue = {
|
|
88
|
+
borderColor,
|
|
89
|
+
borderStyle,
|
|
90
|
+
borderWidth,
|
|
91
|
+
cellHorizontalPadding,
|
|
92
|
+
cellVerticalPadding
|
|
93
|
+
};
|
|
94
|
+
const borderViewStyle = generateBorderStyles({
|
|
95
|
+
borderColor,
|
|
96
|
+
borderWidth,
|
|
97
|
+
borderStyle,
|
|
98
|
+
drawTopBorder,
|
|
99
|
+
drawBottomBorder,
|
|
100
|
+
drawStartBorder,
|
|
101
|
+
drawEndBorder
|
|
102
|
+
});
|
|
103
|
+
return /*#__PURE__*/React.createElement(TableStyleContext.Provider, {
|
|
104
|
+
value: contextValue
|
|
105
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
106
|
+
style: [styles.container, borderViewStyle, style]
|
|
107
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, header), /*#__PURE__*/React.createElement(ScrollView, rest, childrenWithoutHeader)));
|
|
108
|
+
};
|
|
109
|
+
const styles = StyleSheet.create({
|
|
110
|
+
container: {
|
|
111
|
+
flex: 1
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
export default withTheme(Table);rt default withTheme(Table);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { generateBorderStyles, TableStyleContext } from "./TableCommon";
|
|
4
|
+
const TableCell = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
borderWidth,
|
|
7
|
+
borderColor,
|
|
8
|
+
borderStyle,
|
|
9
|
+
drawTopBorder = false,
|
|
10
|
+
drawBottomBorder = false,
|
|
11
|
+
drawStartBorder = false,
|
|
12
|
+
drawEndBorder = true,
|
|
13
|
+
cellVerticalPadding,
|
|
14
|
+
cellHorizontalPadding,
|
|
15
|
+
children,
|
|
16
|
+
style
|
|
17
|
+
} = _ref;
|
|
18
|
+
const parentContextValue = React.useContext(TableStyleContext);
|
|
19
|
+
const borderViewStyle = generateBorderStyles({
|
|
20
|
+
borderColor: borderColor || parentContextValue.borderColor,
|
|
21
|
+
borderWidth: borderWidth || parentContextValue.borderWidth,
|
|
22
|
+
borderStyle: borderStyle || parentContextValue.borderStyle,
|
|
23
|
+
drawTopBorder,
|
|
24
|
+
drawBottomBorder,
|
|
25
|
+
drawStartBorder,
|
|
26
|
+
drawEndBorder
|
|
27
|
+
});
|
|
28
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
29
|
+
style: [styles.cellContainer, borderViewStyle, {
|
|
30
|
+
paddingVertical: cellVerticalPadding || parentContextValue.cellVerticalPadding,
|
|
31
|
+
paddingHorizontal: cellHorizontalPadding || parentContextValue.cellHorizontalPadding
|
|
32
|
+
}, style]
|
|
33
|
+
}, children);
|
|
34
|
+
};
|
|
35
|
+
const styles = StyleSheet.create({
|
|
36
|
+
cellContainer: {
|
|
37
|
+
flex: 1,
|
|
38
|
+
flexDirection: "row"
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
export default TableCell;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const TableStyleContext = /*#__PURE__*/React.createContext({});
|
|
3
|
+
export function generateBorderStyles(_ref) {
|
|
4
|
+
let {
|
|
5
|
+
borderColor,
|
|
6
|
+
borderWidth,
|
|
7
|
+
borderStyle,
|
|
8
|
+
drawTopBorder,
|
|
9
|
+
drawBottomBorder,
|
|
10
|
+
drawStartBorder,
|
|
11
|
+
drawEndBorder
|
|
12
|
+
} = _ref;
|
|
13
|
+
return {
|
|
14
|
+
borderColor,
|
|
15
|
+
borderStyle,
|
|
16
|
+
borderTopWidth: drawTopBorder ? borderWidth : 0,
|
|
17
|
+
borderBottomWidth: drawBottomBorder ? borderWidth : 0,
|
|
18
|
+
borderStartWidth: drawStartBorder ? borderWidth : 0,
|
|
19
|
+
borderEndWidth: drawEndBorder ? borderWidth : 0
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { generateBorderStyles, TableStyleContext } from "./TableCommon";
|
|
4
|
+
import { withTheme } from "../../theming";
|
|
5
|
+
const TableRow = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
borderWidth,
|
|
8
|
+
borderColor,
|
|
9
|
+
borderStyle,
|
|
10
|
+
drawTopBorder = false,
|
|
11
|
+
drawBottomBorder = true,
|
|
12
|
+
drawStartBorder = true,
|
|
13
|
+
drawEndBorder = false,
|
|
14
|
+
cellVerticalPadding,
|
|
15
|
+
cellHorizontalPadding,
|
|
16
|
+
isTableHeader = false,
|
|
17
|
+
children,
|
|
18
|
+
style,
|
|
19
|
+
theme
|
|
20
|
+
} = _ref;
|
|
21
|
+
const parentContextValue = React.useContext(TableStyleContext);
|
|
22
|
+
|
|
23
|
+
//Create context to use and pass to children based on own props or fall back to parent provided context
|
|
24
|
+
const contextValue = {
|
|
25
|
+
borderColor: borderColor || parentContextValue.borderColor,
|
|
26
|
+
borderStyle: borderStyle || parentContextValue.borderStyle,
|
|
27
|
+
borderWidth: borderWidth || parentContextValue.borderWidth,
|
|
28
|
+
cellHorizontalPadding: cellHorizontalPadding || parentContextValue.cellHorizontalPadding,
|
|
29
|
+
cellVerticalPadding: cellVerticalPadding || parentContextValue.cellVerticalPadding
|
|
30
|
+
};
|
|
31
|
+
const borderViewStyle = generateBorderStyles({
|
|
32
|
+
borderColor: contextValue.borderColor,
|
|
33
|
+
borderWidth: contextValue.borderWidth,
|
|
34
|
+
borderStyle: contextValue.borderStyle,
|
|
35
|
+
drawTopBorder,
|
|
36
|
+
drawBottomBorder,
|
|
37
|
+
drawStartBorder,
|
|
38
|
+
drawEndBorder
|
|
39
|
+
});
|
|
40
|
+
return /*#__PURE__*/React.createElement(TableStyleContext.Provider, {
|
|
41
|
+
value: contextValue
|
|
42
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
43
|
+
style: [borderViewStyle, isTableHeader ? {
|
|
44
|
+
backgroundColor: theme.colors.primary
|
|
45
|
+
} : {}, style, styles.cellsContainer]
|
|
46
|
+
}, children));
|
|
47
|
+
};
|
|
48
|
+
const styles = StyleSheet.create({
|
|
49
|
+
cellsContainer: {
|
|
50
|
+
flexDirection: "row"
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
export default withTheme(TableRow);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { Pressable } from "react-native";
|
|
4
3
|
export default function Touchable(_ref) {
|
|
@@ -13,8 +12,22 @@ export default function Touchable(_ref) {
|
|
|
13
12
|
style,
|
|
14
13
|
...props
|
|
15
14
|
} = _ref;
|
|
16
|
-
return /*#__PURE__*/React.createElement(Pressable,
|
|
15
|
+
return /*#__PURE__*/React.createElement(Pressable, {
|
|
17
16
|
disabled: disabled,
|
|
17
|
+
onPress: onPress,
|
|
18
|
+
delayLongPress: delayLongPress ? delayLongPress : 500,
|
|
19
|
+
hitSlop: hitSlop ? hitSlop : 8,
|
|
20
|
+
style: _ref2 => {
|
|
21
|
+
let {
|
|
22
|
+
pressed
|
|
23
|
+
} = _ref2;
|
|
24
|
+
return [{
|
|
25
|
+
opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1
|
|
26
|
+
}, style];
|
|
27
|
+
},
|
|
28
|
+
...props
|
|
29
|
+
}, children);
|
|
30
|
+
} disabled: disabled,
|
|
18
31
|
onPress: onPress,
|
|
19
32
|
delayLongPress: delayLongPress ? delayLongPress : 500,
|
|
20
33
|
hitSlop: hitSlop ? hitSlop : 8,
|
package/lib/module/constants.js
CHANGED
package/lib/module/hooks.js
CHANGED
|
@@ -3,12 +3,11 @@ export function usePrevious(value) {
|
|
|
3
3
|
// The ref object is a generic container whose current property is mutable
|
|
4
4
|
// and can hold any value, similar to an instance property on a class
|
|
5
5
|
const ref = React.useRef();
|
|
6
|
-
|
|
7
6
|
// Store current value in ref
|
|
8
7
|
React.useEffect(() => {
|
|
9
8
|
ref.current = value;
|
|
10
9
|
}, [value]);
|
|
11
|
-
|
|
12
10
|
// Return previous value (happens before update in useEffect above)
|
|
13
11
|
return ref.current;
|
|
12
|
+
}
|
|
14
13
|
}
|
package/lib/module/index.js
CHANGED
|
@@ -10,7 +10,6 @@ export { default as AvatarEdit } from "./components/AvatarEdit";
|
|
|
10
10
|
export { default as Card } from "./components/Card";
|
|
11
11
|
export { Checkbox, CheckboxGroup, CheckboxRow } from "./components/Checkbox";
|
|
12
12
|
export { default as CircleImage } from "./components/CircleImage";
|
|
13
|
-
export { default as Container } from "./components/Container";
|
|
14
13
|
export { default as Divider } from "./components/Divider";
|
|
15
14
|
export { default as FAB } from "./components/FAB";
|
|
16
15
|
export { default as FieldSearchBarFull } from "./components/FieldSearchBarFull";
|
|
@@ -37,6 +36,7 @@ export { TabView, TabViewItem } from "./components/TabView";
|
|
|
37
36
|
export { default as Markdown } from "./components/Markdown";
|
|
38
37
|
export { BottomSheet } from "./components/BottomSheet";
|
|
39
38
|
export { YoutubePlayer } from "./components/YoutubePlayer";
|
|
39
|
+
export { Table, TableRow, TableCell } from "./components/Table";
|
|
40
40
|
|
|
41
41
|
/* Deprecated: Fix or Delete! */
|
|
42
42
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPONENT_TYPES,
|
|
1
|
+
import { COMPONENT_TYPES, createBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, createStaticNumberProp, StylesPanelSections, createStaticBoolProp } from "@draftbit/types";
|
|
2
2
|
const SHARED_SEED_DATA = {
|
|
3
3
|
category: COMPONENT_TYPES.layout,
|
|
4
4
|
packageName: "native-base",
|
|
@@ -16,7 +16,8 @@ export const SEED_DATA = [{
|
|
|
16
16
|
description: "The aspect ratio of the container in decimal format (ex: 3/4 -> 1.33)",
|
|
17
17
|
defaultValue: 1.33
|
|
18
18
|
})
|
|
19
|
-
}
|
|
19
|
+
},
|
|
20
|
+
stylesPanelSections: [StylesPanelSections.Background, StylesPanelSections.Size, StylesPanelSections.Margins, StylesPanelSections.Position, StylesPanelSections.Borders, StylesPanelSections.Effects]
|
|
20
21
|
}, {
|
|
21
22
|
name: "Box",
|
|
22
23
|
tag: "Box",
|
|
@@ -77,16 +78,6 @@ export const SEED_DATA = [{
|
|
|
77
78
|
description: "Stack aligns items vertically or horizontally based on the direction prop",
|
|
78
79
|
...SHARED_SEED_DATA,
|
|
79
80
|
props: {
|
|
80
|
-
direction: createTextEnumProp({
|
|
81
|
-
label: "Direction",
|
|
82
|
-
description: "The direction of the Stack",
|
|
83
|
-
options: ["row", "column"],
|
|
84
|
-
defaultValue: "column"
|
|
85
|
-
}),
|
|
86
|
-
reversed: createBoolProp({
|
|
87
|
-
label: "Reversed",
|
|
88
|
-
description: "Determines whether to reverse the direction of items"
|
|
89
|
-
}),
|
|
90
81
|
isDisabled: createBoolProp({
|
|
91
82
|
label: "Disabled",
|
|
92
83
|
description: "If true, the Stack will be disabled"
|