@draftbit/core 46.9.1-b17d64.2 → 46.9.1-b92e81.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/BottomSheet/BottomSheet.js +88 -0
- package/lib/commonjs/components/BottomSheet/BottomSheetComponent.js +464 -0
- package/lib/commonjs/components/BottomSheet/index.js +13 -0
- package/lib/commonjs/components/CircleImage.js +15 -1
- package/lib/commonjs/components/Container.js +4 -15
- package/lib/commonjs/index.js +7 -19
- package/lib/commonjs/mappings/BottomSheet.js +70 -0
- package/lib/commonjs/mappings/FieldSearchBarFull.js +1 -3
- package/lib/commonjs/mappings/StarRating.js +2 -6
- package/lib/commonjs/styles/overlay.js +3 -1
- package/lib/commonjs/utilities.js +2 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +80 -0
- package/lib/module/components/BottomSheet/BottomSheetComponent.js +470 -0
- package/lib/module/components/BottomSheet/index.js +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/mappings/BottomSheet.js +63 -0
- package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts +20 -0
- package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/BottomSheet/BottomSheetComponent.d.ts +170 -0
- package/lib/typescript/src/components/BottomSheet/BottomSheetComponent.d.ts.map +1 -0
- package/lib/typescript/src/components/BottomSheet/index.d.ts +2 -0
- package/lib/typescript/src/components/BottomSheet/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/BottomSheet.d.ts +115 -0
- package/lib/typescript/src/mappings/BottomSheet.d.ts.map +1 -0
- package/package.json +5 -3
- package/src/components/BottomSheet/BottomSheet.js +56 -0
- package/src/components/BottomSheet/BottomSheet.tsx +120 -0
- package/src/components/BottomSheet/BottomSheetComponent.js +437 -0
- package/src/components/BottomSheet/BottomSheetComponent.tsx +895 -0
- package/src/components/BottomSheet/index.js +1 -0
- package/src/components/BottomSheet/index.ts +1 -0
- package/src/index.js +1 -1
- package/src/index.tsx +1 -1
- package/src/mappings/BottomSheet.js +63 -0
- package/src/mappings/BottomSheet.ts +77 -0
- package/lib/commonjs/components/Table/Table.js +0 -91
- package/lib/commonjs/components/Table/TableCell.js +0 -49
- package/lib/commonjs/components/Table/TableCommon.js +0 -30
- package/lib/commonjs/components/Table/TableRow.js +0 -61
- package/lib/commonjs/components/Table/index.js +0 -27
- package/lib/commonjs/mappings/Table.js +0 -127
- package/lib/module/components/Table/Table.js +0 -83
- package/lib/module/components/Table/TableCell.js +0 -41
- package/lib/module/components/Table/TableCommon.js +0 -21
- package/lib/module/components/Table/TableRow.js +0 -53
- package/lib/module/components/Table/index.js +0 -3
- package/lib/module/mappings/Table.js +0 -120
- package/lib/typescript/src/components/Table/Table.d.ts +0 -19
- package/lib/typescript/src/components/Table/Table.d.ts.map +0 -1
- package/lib/typescript/src/components/Table/TableCell.d.ts +0 -9
- package/lib/typescript/src/components/Table/TableCell.d.ts.map +0 -1
- package/lib/typescript/src/components/Table/TableCommon.d.ts +0 -20
- package/lib/typescript/src/components/Table/TableCommon.d.ts.map +0 -1
- package/lib/typescript/src/components/Table/TableRow.d.ts +0 -14
- package/lib/typescript/src/components/Table/TableRow.d.ts.map +0 -1
- package/lib/typescript/src/components/Table/index.d.ts +0 -4
- package/lib/typescript/src/components/Table/index.d.ts.map +0 -1
- package/lib/typescript/src/mappings/Table.d.ts +0 -327
- package/lib/typescript/src/mappings/Table.d.ts.map +0 -1
- package/src/components/Table/Table.js +0 -64
- package/src/components/Table/Table.tsx +0 -136
- package/src/components/Table/TableCell.js +0 -31
- package/src/components/Table/TableCell.tsx +0 -63
- package/src/components/Table/TableCommon.js +0 -12
- package/src/components/Table/TableCommon.ts +0 -40
- package/src/components/Table/TableRow.js +0 -37
- package/src/components/Table/TableRow.tsx +0 -77
- package/src/components/Table/index.js +0 -3
- package/src/components/Table/index.tsx +0 -3
- package/src/mappings/Table.js +0 -137
- package/src/mappings/Table.ts +0 -156
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BottomSheet } from "./BottomSheet";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BottomSheet } from "./BottomSheet";
|
package/src/index.js
CHANGED
|
@@ -35,7 +35,7 @@ export { default as Shadow } from "./components/Shadow";
|
|
|
35
35
|
export { DeckSwiper, DeckSwiperCard } from "./components/DeckSwiper";
|
|
36
36
|
export { TabView, TabViewItem } from "./components/TabView";
|
|
37
37
|
export { default as Markdown } from "./components/Markdown";
|
|
38
|
-
export {
|
|
38
|
+
export { BottomSheet } from "./components/BottomSheet";
|
|
39
39
|
/* Deprecated: Fix or Delete! */
|
|
40
40
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
41
41
|
export { default as Picker } from "./components/Picker/Picker";
|
package/src/index.tsx
CHANGED
|
@@ -58,7 +58,7 @@ export { DeckSwiper, DeckSwiperCard } from "./components/DeckSwiper";
|
|
|
58
58
|
export { TabView, TabViewItem } from "./components/TabView";
|
|
59
59
|
export { default as Markdown } from "./components/Markdown";
|
|
60
60
|
|
|
61
|
-
export {
|
|
61
|
+
export { BottomSheet } from "./components/BottomSheet";
|
|
62
62
|
|
|
63
63
|
/* Deprecated: Fix or Delete! */
|
|
64
64
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, createStaticBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, Triggers, createActionProp, createColorProp, createStaticNumberProp, createArrayProp, } from "@draftbit/types";
|
|
2
|
+
export const SEED_DATA = {
|
|
3
|
+
name: "Bottom Sheet",
|
|
4
|
+
tag: "BottomSheet",
|
|
5
|
+
description: "A draggable Bottom sheet that snaps to specific points. Renders children in ScrollView",
|
|
6
|
+
category: COMPONENT_TYPES.bottomsheet,
|
|
7
|
+
stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
|
|
8
|
+
triggers: [Triggers.OnSettle],
|
|
9
|
+
props: {
|
|
10
|
+
onSettle: createActionProp({
|
|
11
|
+
label: "On settle",
|
|
12
|
+
description: "Action to execute when sheet settles on a snap point",
|
|
13
|
+
}),
|
|
14
|
+
snapPoints: createArrayProp({
|
|
15
|
+
label: "Snap points",
|
|
16
|
+
description: "An array of numerical values (that represent distance from the top) where bottom sheet can snap to place. Accepts numbers and percentages (minimum 2 snap points)",
|
|
17
|
+
defaultValue: ["10%", "50%", "80%"],
|
|
18
|
+
}),
|
|
19
|
+
initialSnapIndex: createStaticNumberProp({
|
|
20
|
+
label: "Initial snap index",
|
|
21
|
+
description: "Index of the snap point to be used as the initial point",
|
|
22
|
+
defaultValue: 0,
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
showHandle: createStaticBoolProp({
|
|
26
|
+
label: "Show handle",
|
|
27
|
+
description: "Whether to show the top sheet handle or not",
|
|
28
|
+
defaultValue: true,
|
|
29
|
+
}),
|
|
30
|
+
handleColor: createColorProp({
|
|
31
|
+
label: "Handle color",
|
|
32
|
+
description: "Color of the top handle",
|
|
33
|
+
defaultValue: "divider",
|
|
34
|
+
}),
|
|
35
|
+
topBorderRadius: createStaticNumberProp({
|
|
36
|
+
label: "Top border radius",
|
|
37
|
+
description: "Border radius of top corners",
|
|
38
|
+
defaultValue: 20,
|
|
39
|
+
required: false,
|
|
40
|
+
}),
|
|
41
|
+
borderWidth: createStaticNumberProp({
|
|
42
|
+
label: "Border width",
|
|
43
|
+
description: "Width of bottom sheet borders",
|
|
44
|
+
defaultValue: 1,
|
|
45
|
+
required: false,
|
|
46
|
+
}),
|
|
47
|
+
borderColor: createColorProp({
|
|
48
|
+
label: "Border color",
|
|
49
|
+
description: "Color of bottom sheet borders",
|
|
50
|
+
defaultValue: "divider",
|
|
51
|
+
}),
|
|
52
|
+
showsVerticalScrollIndicator: createStaticBoolProp({
|
|
53
|
+
label: "Show Vertical Scroll Indicator",
|
|
54
|
+
description: "When true, shows a vertical scroll indicator. The default value is true.",
|
|
55
|
+
defaultValue: true,
|
|
56
|
+
}),
|
|
57
|
+
bounces: createStaticBoolProp({
|
|
58
|
+
label: "Bounce",
|
|
59
|
+
description: "When true, the scroll view bounces when it reaches the end of the content if the content is larger then the scroll view along the axis of the scroll direction.",
|
|
60
|
+
defaultValue: true,
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_TYPES,
|
|
3
|
+
createStaticBoolProp,
|
|
4
|
+
CONTAINER_COMPONENT_STYLES_SECTIONS,
|
|
5
|
+
Triggers,
|
|
6
|
+
createActionProp,
|
|
7
|
+
createColorProp,
|
|
8
|
+
createStaticNumberProp,
|
|
9
|
+
createArrayProp,
|
|
10
|
+
} from "@draftbit/types";
|
|
11
|
+
|
|
12
|
+
export const SEED_DATA = {
|
|
13
|
+
name: "Bottom Sheet",
|
|
14
|
+
tag: "BottomSheet",
|
|
15
|
+
description:
|
|
16
|
+
"A draggable Bottom sheet that snaps to specific points. Renders children in ScrollView",
|
|
17
|
+
category: COMPONENT_TYPES.bottomsheet,
|
|
18
|
+
stylesPanelSections: CONTAINER_COMPONENT_STYLES_SECTIONS,
|
|
19
|
+
triggers: [Triggers.OnSettle],
|
|
20
|
+
props: {
|
|
21
|
+
onSettle: createActionProp({
|
|
22
|
+
label: "On settle",
|
|
23
|
+
description: "Action to execute when sheet settles on a snap point",
|
|
24
|
+
}),
|
|
25
|
+
snapPoints: createArrayProp({
|
|
26
|
+
label: "Snap points",
|
|
27
|
+
description:
|
|
28
|
+
"An array of numerical values (that represent distance from the top) where bottom sheet can snap to place. Accepts numbers and percentages (minimum 2 snap points)",
|
|
29
|
+
defaultValue: ["10%", "50%", "80%"],
|
|
30
|
+
}),
|
|
31
|
+
initialSnapIndex: createStaticNumberProp({
|
|
32
|
+
label: "Initial snap index",
|
|
33
|
+
description: "Index of the snap point to be used as the initial point",
|
|
34
|
+
defaultValue: 0,
|
|
35
|
+
required: false,
|
|
36
|
+
}),
|
|
37
|
+
showHandle: createStaticBoolProp({
|
|
38
|
+
label: "Show handle",
|
|
39
|
+
description: "Whether to show the top sheet handle or not",
|
|
40
|
+
defaultValue: true,
|
|
41
|
+
}),
|
|
42
|
+
handleColor: createColorProp({
|
|
43
|
+
label: "Handle color",
|
|
44
|
+
description: "Color of the top handle",
|
|
45
|
+
defaultValue: "divider",
|
|
46
|
+
}),
|
|
47
|
+
topBorderRadius: createStaticNumberProp({
|
|
48
|
+
label: "Top border radius",
|
|
49
|
+
description: "Border radius of top corners",
|
|
50
|
+
defaultValue: 20,
|
|
51
|
+
required: false,
|
|
52
|
+
}),
|
|
53
|
+
borderWidth: createStaticNumberProp({
|
|
54
|
+
label: "Border width",
|
|
55
|
+
description: "Width of bottom sheet borders",
|
|
56
|
+
defaultValue: 1,
|
|
57
|
+
required: false,
|
|
58
|
+
}),
|
|
59
|
+
borderColor: createColorProp({
|
|
60
|
+
label: "Border color",
|
|
61
|
+
description: "Color of bottom sheet borders",
|
|
62
|
+
defaultValue: "divider",
|
|
63
|
+
}),
|
|
64
|
+
showsVerticalScrollIndicator: createStaticBoolProp({
|
|
65
|
+
label: "Show Vertical Scroll Indicator",
|
|
66
|
+
description:
|
|
67
|
+
"When true, shows a vertical scroll indicator. The default value is true.",
|
|
68
|
+
defaultValue: true,
|
|
69
|
+
}),
|
|
70
|
+
bounces: createStaticBoolProp({
|
|
71
|
+
label: "Bounce",
|
|
72
|
+
description:
|
|
73
|
+
"When true, the scroll view bounces when it reaches the end of the content if the content is larger then the scroll view along the axis of the scroll direction.",
|
|
74
|
+
defaultValue: true,
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _theming = require("../../theming");
|
|
10
|
-
var _TableCommon = require("./TableCommon");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
const Table = _ref => {
|
|
13
|
-
let {
|
|
14
|
-
theme,
|
|
15
|
-
borderWidth = 1,
|
|
16
|
-
borderColor = theme.colors.divider,
|
|
17
|
-
borderStyle = "solid",
|
|
18
|
-
drawTopBorder = true,
|
|
19
|
-
drawBottomBorder = false,
|
|
20
|
-
drawStartBorder = false,
|
|
21
|
-
drawEndBorder = false,
|
|
22
|
-
cellVerticalPadding = 10,
|
|
23
|
-
cellHorizontalPadding = 10,
|
|
24
|
-
data,
|
|
25
|
-
keyExtractor,
|
|
26
|
-
renderItem,
|
|
27
|
-
children: childrenProp,
|
|
28
|
-
style
|
|
29
|
-
} = _ref;
|
|
30
|
-
//Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
|
|
31
|
-
if (data && !renderItem || renderItem && !data) {
|
|
32
|
-
throw new Error("'renderItem' and 'data' need to both be provided to render from 'data'. Either remove them entirley or include both");
|
|
33
|
-
}
|
|
34
|
-
if (data && renderItem && childrenProp) {
|
|
35
|
-
console.warn("'children' of Table ignored due to usage of 'data' and 'renderItem'");
|
|
36
|
-
}
|
|
37
|
-
const isTableHeader = _react.default.useCallback(object => {
|
|
38
|
-
return object.isTableHeader;
|
|
39
|
-
}, []);
|
|
40
|
-
const isRenderItem = data && renderItem;
|
|
41
|
-
|
|
42
|
-
//Uses 'renderItem' and 'data' to create an array of children
|
|
43
|
-
const dataAsChildren = _react.default.useMemo(() => {
|
|
44
|
-
if (!isRenderItem) return [];
|
|
45
|
-
return data.map((item, index) => {
|
|
46
|
-
const component = renderItem({
|
|
47
|
-
item,
|
|
48
|
-
index
|
|
49
|
-
});
|
|
50
|
-
if (!component) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const key = keyExtractor ? keyExtractor(item, index) : index.toString();
|
|
54
|
-
return /*#__PURE__*/_react.default.cloneElement(component, {
|
|
55
|
-
key
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}, [data, renderItem, keyExtractor, isRenderItem]);
|
|
59
|
-
const children = isRenderItem ? dataAsChildren : _react.default.Children.toArray(childrenProp);
|
|
60
|
-
const validChildren = _react.default.useMemo(() => children.filter(item => /*#__PURE__*/_react.default.isValidElement(item)), [children]);
|
|
61
|
-
const childrenWithoutHeader = _react.default.useMemo(() => validChildren.filter(item => !isTableHeader(item.props)), [validChildren, isTableHeader]);
|
|
62
|
-
const headers = _react.default.useMemo(() => validChildren.filter(item => isTableHeader(item.props)), [validChildren, isTableHeader]);
|
|
63
|
-
const contextValue = {
|
|
64
|
-
borderColor,
|
|
65
|
-
borderStyle,
|
|
66
|
-
borderWidth,
|
|
67
|
-
cellHorizontalPadding,
|
|
68
|
-
cellVerticalPadding
|
|
69
|
-
};
|
|
70
|
-
const borderViewStyle = (0, _TableCommon.generateBorderStyles)({
|
|
71
|
-
borderColor,
|
|
72
|
-
borderWidth,
|
|
73
|
-
borderStyle,
|
|
74
|
-
drawTopBorder,
|
|
75
|
-
drawBottomBorder,
|
|
76
|
-
drawStartBorder,
|
|
77
|
-
drawEndBorder
|
|
78
|
-
});
|
|
79
|
-
return /*#__PURE__*/_react.default.createElement(_TableCommon.TableStyleContext.Provider, {
|
|
80
|
-
value: contextValue
|
|
81
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
82
|
-
style: [styles.container, borderViewStyle, style]
|
|
83
|
-
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, headers), /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, null, childrenWithoutHeader)));
|
|
84
|
-
};
|
|
85
|
-
const styles = _reactNative.StyleSheet.create({
|
|
86
|
-
container: {
|
|
87
|
-
flex: 1
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
var _default = (0, _theming.withTheme)(Table);
|
|
91
|
-
exports.default = _default;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _TableCommon = require("./TableCommon");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
const TableCell = _ref => {
|
|
12
|
-
let {
|
|
13
|
-
borderWidth,
|
|
14
|
-
borderColor,
|
|
15
|
-
borderStyle,
|
|
16
|
-
drawTopBorder = false,
|
|
17
|
-
drawBottomBorder = false,
|
|
18
|
-
drawStartBorder = false,
|
|
19
|
-
drawEndBorder = true,
|
|
20
|
-
cellVerticalPadding,
|
|
21
|
-
cellHorizontalPadding,
|
|
22
|
-
children,
|
|
23
|
-
style
|
|
24
|
-
} = _ref;
|
|
25
|
-
const parentContextValue = _react.default.useContext(_TableCommon.TableStyleContext);
|
|
26
|
-
const borderViewStyle = (0, _TableCommon.generateBorderStyles)({
|
|
27
|
-
borderColor: borderColor || parentContextValue.borderColor,
|
|
28
|
-
borderWidth: borderWidth || parentContextValue.borderWidth,
|
|
29
|
-
borderStyle: borderStyle || parentContextValue.borderStyle,
|
|
30
|
-
drawTopBorder,
|
|
31
|
-
drawBottomBorder,
|
|
32
|
-
drawStartBorder,
|
|
33
|
-
drawEndBorder
|
|
34
|
-
});
|
|
35
|
-
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
36
|
-
style: [styles.cellContainer, borderViewStyle, {
|
|
37
|
-
paddingVertical: cellVerticalPadding || parentContextValue.cellVerticalPadding,
|
|
38
|
-
paddingHorizontal: cellHorizontalPadding || parentContextValue.cellHorizontalPadding
|
|
39
|
-
}, style]
|
|
40
|
-
}, children);
|
|
41
|
-
};
|
|
42
|
-
const styles = _reactNative.StyleSheet.create({
|
|
43
|
-
cellContainer: {
|
|
44
|
-
flex: 1,
|
|
45
|
-
flexDirection: "row"
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
var _default = TableCell;
|
|
49
|
-
exports.default = _default;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TableStyleContext = void 0;
|
|
7
|
-
exports.generateBorderStyles = generateBorderStyles;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
const TableStyleContext = /*#__PURE__*/_react.default.createContext({});
|
|
11
|
-
exports.TableStyleContext = TableStyleContext;
|
|
12
|
-
function generateBorderStyles(_ref) {
|
|
13
|
-
let {
|
|
14
|
-
borderColor,
|
|
15
|
-
borderWidth,
|
|
16
|
-
borderStyle,
|
|
17
|
-
drawTopBorder,
|
|
18
|
-
drawBottomBorder,
|
|
19
|
-
drawStartBorder,
|
|
20
|
-
drawEndBorder
|
|
21
|
-
} = _ref;
|
|
22
|
-
return {
|
|
23
|
-
borderColor,
|
|
24
|
-
borderStyle,
|
|
25
|
-
borderTopWidth: drawTopBorder ? borderWidth : 0,
|
|
26
|
-
borderBottomWidth: drawBottomBorder ? borderWidth : 0,
|
|
27
|
-
borderStartWidth: drawStartBorder ? borderWidth : 0,
|
|
28
|
-
borderEndWidth: drawEndBorder ? borderWidth : 0
|
|
29
|
-
};
|
|
30
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _TableCommon = require("./TableCommon");
|
|
10
|
-
var _theming = require("../../theming");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
const TableRow = _ref => {
|
|
13
|
-
let {
|
|
14
|
-
borderWidth,
|
|
15
|
-
borderColor,
|
|
16
|
-
borderStyle,
|
|
17
|
-
drawTopBorder = false,
|
|
18
|
-
drawBottomBorder = true,
|
|
19
|
-
drawStartBorder = true,
|
|
20
|
-
drawEndBorder = false,
|
|
21
|
-
cellVerticalPadding,
|
|
22
|
-
cellHorizontalPadding,
|
|
23
|
-
isTableHeader = false,
|
|
24
|
-
children,
|
|
25
|
-
style,
|
|
26
|
-
theme
|
|
27
|
-
} = _ref;
|
|
28
|
-
const parentContextValue = _react.default.useContext(_TableCommon.TableStyleContext);
|
|
29
|
-
|
|
30
|
-
//Create context to use and pass to children based on own props or fall back to parent provided context
|
|
31
|
-
const contextValue = {
|
|
32
|
-
borderColor: borderColor || parentContextValue.borderColor,
|
|
33
|
-
borderStyle: borderStyle || parentContextValue.borderStyle,
|
|
34
|
-
borderWidth: borderWidth || parentContextValue.borderWidth,
|
|
35
|
-
cellHorizontalPadding: cellHorizontalPadding || parentContextValue.cellHorizontalPadding,
|
|
36
|
-
cellVerticalPadding: cellVerticalPadding || parentContextValue.cellVerticalPadding
|
|
37
|
-
};
|
|
38
|
-
const borderViewStyle = (0, _TableCommon.generateBorderStyles)({
|
|
39
|
-
borderColor: contextValue.borderColor,
|
|
40
|
-
borderWidth: contextValue.borderWidth,
|
|
41
|
-
borderStyle: contextValue.borderStyle,
|
|
42
|
-
drawTopBorder,
|
|
43
|
-
drawBottomBorder,
|
|
44
|
-
drawStartBorder,
|
|
45
|
-
drawEndBorder
|
|
46
|
-
});
|
|
47
|
-
return /*#__PURE__*/_react.default.createElement(_TableCommon.TableStyleContext.Provider, {
|
|
48
|
-
value: contextValue
|
|
49
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
50
|
-
style: [borderViewStyle, isTableHeader ? {
|
|
51
|
-
backgroundColor: theme.colors.primary
|
|
52
|
-
} : {}, style, styles.cellsContainer]
|
|
53
|
-
}, children));
|
|
54
|
-
};
|
|
55
|
-
const styles = _reactNative.StyleSheet.create({
|
|
56
|
-
cellsContainer: {
|
|
57
|
-
flexDirection: "row"
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
var _default = (0, _theming.withTheme)(TableRow);
|
|
61
|
-
exports.default = _default;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Table", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _Table.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "TableCell", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _TableCell.default;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "TableRow", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _TableRow.default;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
var _Table = _interopRequireDefault(require("./Table"));
|
|
25
|
-
var _TableRow = _interopRequireDefault(require("./TableRow"));
|
|
26
|
-
var _TableCell = _interopRequireDefault(require("./TableCell"));
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SEED_DATA = void 0;
|
|
7
|
-
var _types = require("@draftbit/types");
|
|
8
|
-
const SHARED_SEED_DATA_PROPS = {
|
|
9
|
-
borderWidth: (0, _types.createStaticNumberProp)({
|
|
10
|
-
label: "Border Width",
|
|
11
|
-
description: "Specifies the width of the border. Passed down to child Table(Row/Cell) components unless overridden",
|
|
12
|
-
required: false,
|
|
13
|
-
defaultValue: null
|
|
14
|
-
}),
|
|
15
|
-
borderColor: (0, _types.createColorProp)({
|
|
16
|
-
label: "Border Color",
|
|
17
|
-
description: "Specifies the color of the border. Passed down to child Table(Row/Cell) components unless overridden",
|
|
18
|
-
defaultValue: null
|
|
19
|
-
}),
|
|
20
|
-
borderStyle: (0, _types.createTextEnumProp)({
|
|
21
|
-
label: "Border Style",
|
|
22
|
-
description: "Specifies the style of the border. Passed down to child Table(Row/Cell) components unless overridden",
|
|
23
|
-
options: ["solid", "dotted", "dashed"],
|
|
24
|
-
defaultValue: null
|
|
25
|
-
}),
|
|
26
|
-
drawTopBorder: (0, _types.createStaticBoolProp)({
|
|
27
|
-
label: "Draw Top Border",
|
|
28
|
-
description: "Whether to draw the top border at this layer of the Table tree or not",
|
|
29
|
-
defaultValue: false
|
|
30
|
-
}),
|
|
31
|
-
drawBottomBorder: (0, _types.createStaticBoolProp)({
|
|
32
|
-
label: "Draw Bottom Border",
|
|
33
|
-
description: "Whether to draw the bottom border at this layer of the Table tree or not",
|
|
34
|
-
defaultValue: false
|
|
35
|
-
}),
|
|
36
|
-
drawStartBorder: (0, _types.createStaticBoolProp)({
|
|
37
|
-
label: "Draw Start Border",
|
|
38
|
-
description: "Whether to draw the start border at this layer of the Table tree or not",
|
|
39
|
-
defaultValue: false
|
|
40
|
-
}),
|
|
41
|
-
drawEndBorder: (0, _types.createStaticBoolProp)({
|
|
42
|
-
label: "Draw End Border",
|
|
43
|
-
description: "Whether to draw the end border at this layer of the Table tree or not",
|
|
44
|
-
defaultValue: false
|
|
45
|
-
}),
|
|
46
|
-
cellVerticalPadding: (0, _types.createStaticNumberProp)({
|
|
47
|
-
label: "Cell Vertical Padding",
|
|
48
|
-
description: "Specifies the vertical padding of the cell. Passed down to TableCell components unless overridden",
|
|
49
|
-
required: false,
|
|
50
|
-
defaultValue: 10
|
|
51
|
-
}),
|
|
52
|
-
cellHorizontalPadding: (0, _types.createStaticNumberProp)({
|
|
53
|
-
label: "Cell Horizontal Padding",
|
|
54
|
-
description: "Specifies the horizontal padding of the cell. Passed down to TableCell components unless overridden",
|
|
55
|
-
required: false,
|
|
56
|
-
defaultValue: 10
|
|
57
|
-
})
|
|
58
|
-
};
|
|
59
|
-
const SEED_DATA = [{
|
|
60
|
-
name: "Table",
|
|
61
|
-
tag: "Table",
|
|
62
|
-
description: "Top level table container",
|
|
63
|
-
category: _types.COMPONENT_TYPES.table,
|
|
64
|
-
stylesPanelSections: [_types.StylesPanelSections.Size, _types.StylesPanelSections.Margins, _types.StylesPanelSections.Position, _types.StylesPanelSections.Effects, _types.StylesPanelSections.Background, _types.StylesPanelSections.LayoutSelectedItem],
|
|
65
|
-
layout: {
|
|
66
|
-
flex: 1
|
|
67
|
-
},
|
|
68
|
-
props: {
|
|
69
|
-
...SHARED_SEED_DATA_PROPS,
|
|
70
|
-
borderWidth: {
|
|
71
|
-
...SHARED_SEED_DATA_PROPS.borderWidth,
|
|
72
|
-
defaultValue: 1
|
|
73
|
-
},
|
|
74
|
-
borderColor: {
|
|
75
|
-
...SHARED_SEED_DATA_PROPS.borderColor,
|
|
76
|
-
defaultValue: "divider"
|
|
77
|
-
},
|
|
78
|
-
borderStyle: {
|
|
79
|
-
...SHARED_SEED_DATA_PROPS.borderStyle,
|
|
80
|
-
defaultValue: "solid"
|
|
81
|
-
},
|
|
82
|
-
drawTopBorder: {
|
|
83
|
-
...SHARED_SEED_DATA_PROPS.drawTopBorder,
|
|
84
|
-
defaultValue: true
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
name: "Table Row",
|
|
89
|
-
tag: "TableRow",
|
|
90
|
-
description: "Table Row container",
|
|
91
|
-
category: _types.COMPONENT_TYPES.table,
|
|
92
|
-
stylesPanelSections: [_types.StylesPanelSections.Background],
|
|
93
|
-
props: {
|
|
94
|
-
...SHARED_SEED_DATA_PROPS,
|
|
95
|
-
drawStartBorder: {
|
|
96
|
-
...SHARED_SEED_DATA_PROPS.drawStartBorder,
|
|
97
|
-
defaultValue: true
|
|
98
|
-
},
|
|
99
|
-
drawBottomBorder: {
|
|
100
|
-
...SHARED_SEED_DATA_PROPS.drawBottomBorder,
|
|
101
|
-
defaultValue: true
|
|
102
|
-
},
|
|
103
|
-
isTableHeader: (0, _types.createStaticBoolProp)({
|
|
104
|
-
label: "Header",
|
|
105
|
-
description: "Whether this row is a header or not (changes background and sticks while scrolling)",
|
|
106
|
-
defaultValue: false
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
}, {
|
|
110
|
-
name: "Table Cell",
|
|
111
|
-
tag: "TableCell",
|
|
112
|
-
description: "Table Cell container",
|
|
113
|
-
category: _types.COMPONENT_TYPES.table,
|
|
114
|
-
stylesPanelSections: [_types.StylesPanelSections.LayoutFlexItems, _types.StylesPanelSections.LayoutSelectedItem, _types.StylesPanelSections.LayoutContent, _types.StylesPanelSections.Background, _types.StylesPanelSections.Size, _types.StylesPanelSections.MarginsAndPaddings, _types.StylesPanelSections.Position, _types.StylesPanelSections.Effects],
|
|
115
|
-
layout: {
|
|
116
|
-
flex: 1,
|
|
117
|
-
flexDirection: "row"
|
|
118
|
-
},
|
|
119
|
-
props: {
|
|
120
|
-
...SHARED_SEED_DATA_PROPS,
|
|
121
|
-
drawEndBorder: {
|
|
122
|
-
...SHARED_SEED_DATA_PROPS.drawEndBorder,
|
|
123
|
-
defaultValue: true
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}];
|
|
127
|
-
exports.SEED_DATA = SEED_DATA;
|
|
@@ -1,83 +0,0 @@
|
|
|
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
|
-
} = _ref;
|
|
23
|
-
//Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
|
|
24
|
-
if (data && !renderItem || renderItem && !data) {
|
|
25
|
-
throw new Error("'renderItem' and 'data' need to both be provided to render from 'data'. Either remove them entirley or include both");
|
|
26
|
-
}
|
|
27
|
-
if (data && renderItem && childrenProp) {
|
|
28
|
-
console.warn("'children' of Table ignored due to usage of 'data' and 'renderItem'");
|
|
29
|
-
}
|
|
30
|
-
const isTableHeader = React.useCallback(object => {
|
|
31
|
-
return object.isTableHeader;
|
|
32
|
-
}, []);
|
|
33
|
-
const isRenderItem = data && renderItem;
|
|
34
|
-
|
|
35
|
-
//Uses 'renderItem' and 'data' to create an array of children
|
|
36
|
-
const dataAsChildren = React.useMemo(() => {
|
|
37
|
-
if (!isRenderItem) return [];
|
|
38
|
-
return data.map((item, index) => {
|
|
39
|
-
const component = renderItem({
|
|
40
|
-
item,
|
|
41
|
-
index
|
|
42
|
-
});
|
|
43
|
-
if (!component) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
const key = keyExtractor ? keyExtractor(item, index) : index.toString();
|
|
47
|
-
return /*#__PURE__*/React.cloneElement(component, {
|
|
48
|
-
key
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}, [data, renderItem, keyExtractor, isRenderItem]);
|
|
52
|
-
const children = isRenderItem ? dataAsChildren : React.Children.toArray(childrenProp);
|
|
53
|
-
const validChildren = React.useMemo(() => children.filter(item => /*#__PURE__*/React.isValidElement(item)), [children]);
|
|
54
|
-
const childrenWithoutHeader = React.useMemo(() => validChildren.filter(item => !isTableHeader(item.props)), [validChildren, isTableHeader]);
|
|
55
|
-
const headers = React.useMemo(() => validChildren.filter(item => isTableHeader(item.props)), [validChildren, isTableHeader]);
|
|
56
|
-
const contextValue = {
|
|
57
|
-
borderColor,
|
|
58
|
-
borderStyle,
|
|
59
|
-
borderWidth,
|
|
60
|
-
cellHorizontalPadding,
|
|
61
|
-
cellVerticalPadding
|
|
62
|
-
};
|
|
63
|
-
const borderViewStyle = generateBorderStyles({
|
|
64
|
-
borderColor,
|
|
65
|
-
borderWidth,
|
|
66
|
-
borderStyle,
|
|
67
|
-
drawTopBorder,
|
|
68
|
-
drawBottomBorder,
|
|
69
|
-
drawStartBorder,
|
|
70
|
-
drawEndBorder
|
|
71
|
-
});
|
|
72
|
-
return /*#__PURE__*/React.createElement(TableStyleContext.Provider, {
|
|
73
|
-
value: contextValue
|
|
74
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
75
|
-
style: [styles.container, borderViewStyle, style]
|
|
76
|
-
}, /*#__PURE__*/React.createElement(React.Fragment, null, headers), /*#__PURE__*/React.createElement(ScrollView, null, childrenWithoutHeader)));
|
|
77
|
-
};
|
|
78
|
-
const styles = StyleSheet.create({
|
|
79
|
-
container: {
|
|
80
|
-
flex: 1
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
export default withTheme(Table);
|
|
@@ -1,41 +0,0 @@
|
|
|
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;
|