ferns-ui 0.36.1 → 0.36.3
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/dist/ActionSheet.d.ts +492 -0
- package/dist/ActionSheet.js +649 -0
- package/dist/ActionSheet.js.map +1 -0
- package/dist/Avatar.d.ts +68 -0
- package/dist/Avatar.js +152 -0
- package/dist/Avatar.js.map +1 -0
- package/dist/Badge.d.ts +10 -0
- package/dist/Badge.js +36 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Banner.d.ts +27 -0
- package/dist/Banner.js +56 -0
- package/dist/Banner.js.map +1 -0
- package/dist/BlurBox.d.ts +5 -0
- package/dist/BlurBox.js +28 -0
- package/dist/BlurBox.js.map +1 -0
- package/dist/BlurBox.native.d.ts +6 -0
- package/dist/BlurBox.native.js +30 -0
- package/dist/BlurBox.native.js.map +1 -0
- package/dist/Body.d.ts +6 -0
- package/dist/Body.js +21 -0
- package/dist/Body.js.map +1 -0
- package/dist/Box.d.ts +3 -0
- package/dist/Box.js +251 -0
- package/dist/Box.js.map +1 -0
- package/dist/Button.d.ts +26 -0
- package/dist/Button.js +120 -0
- package/dist/Button.js.map +1 -0
- package/dist/Card.d.ts +5 -0
- package/dist/Card.js +8 -0
- package/dist/Card.js.map +1 -0
- package/dist/CheckBox.d.ts +3 -0
- package/dist/CheckBox.js +40 -0
- package/dist/CheckBox.js.map +1 -0
- package/dist/Common.d.ts +868 -0
- package/dist/Common.js +46 -0
- package/dist/Common.js.map +1 -0
- package/dist/Constants.d.ts +4 -0
- package/dist/Constants.js +54 -0
- package/dist/Constants.js.map +1 -0
- package/dist/CustomSelect.d.ts +14 -0
- package/dist/CustomSelect.js +43 -0
- package/dist/CustomSelect.js.map +1 -0
- package/dist/DateTimeActionSheet.d.ts +12 -0
- package/dist/DateTimeActionSheet.js +248 -0
- package/dist/DateTimeActionSheet.js.map +1 -0
- package/dist/DateTimeField.android.d.ts +3 -0
- package/dist/DateTimeField.android.js +66 -0
- package/dist/DateTimeField.android.js.map +1 -0
- package/dist/DateTimeField.d.ts +3 -0
- package/dist/DateTimeField.ios.d.ts +3 -0
- package/dist/DateTimeField.ios.js +48 -0
- package/dist/DateTimeField.ios.js.map +1 -0
- package/dist/DateTimeField.js +35 -0
- package/dist/DateTimeField.js.map +1 -0
- package/dist/DecimalRangeActionSheet.d.ts +18 -0
- package/dist/DecimalRangeActionSheet.js +65 -0
- package/dist/DecimalRangeActionSheet.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +19 -0
- package/dist/ErrorBoundary.js +29 -0
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/ErrorPage.d.ts +10 -0
- package/dist/ErrorPage.js +20 -0
- package/dist/ErrorPage.js.map +1 -0
- package/dist/FernsProvider.d.ts +4 -0
- package/dist/FernsProvider.js +9 -0
- package/dist/FernsProvider.js.map +1 -0
- package/dist/Field.d.ts +17 -0
- package/dist/Field.js +114 -0
- package/dist/Field.js.map +1 -0
- package/dist/FieldWithLabels.d.ts +3 -0
- package/dist/FieldWithLabels.js +8 -0
- package/dist/FieldWithLabels.js.map +1 -0
- package/dist/FlatList.d.ts +2 -0
- package/dist/FlatList.js +3 -0
- package/dist/FlatList.js.map +1 -0
- package/dist/Form.d.ts +22 -0
- package/dist/Form.js +89 -0
- package/dist/Form.js.map +1 -0
- package/dist/HeaderButtons.d.ts +31 -0
- package/dist/HeaderButtons.js +53 -0
- package/dist/HeaderButtons.js.map +1 -0
- package/dist/Heading.d.ts +11 -0
- package/dist/Heading.js +46 -0
- package/dist/Heading.js.map +1 -0
- package/dist/HeightActionSheet.d.ts +16 -0
- package/dist/HeightActionSheet.js +58 -0
- package/dist/HeightActionSheet.js.map +1 -0
- package/dist/Hyperlink.d.ts +43 -0
- package/dist/Hyperlink.js +135 -0
- package/dist/Hyperlink.js.map +1 -0
- package/dist/Icon.d.ts +4 -0
- package/dist/Icon.js +14 -0
- package/dist/Icon.js.map +1 -0
- package/dist/IconButton.d.ts +26 -0
- package/dist/IconButton.js +78 -0
- package/dist/IconButton.js.map +1 -0
- package/dist/Image.d.ts +8 -0
- package/dist/Image.js +37 -0
- package/dist/Image.js.map +1 -0
- package/dist/ImageBackground.d.ts +10 -0
- package/dist/ImageBackground.js +8 -0
- package/dist/ImageBackground.js.map +1 -0
- package/dist/InfoTooltipButton.d.ts +8 -0
- package/dist/InfoTooltipButton.js +6 -0
- package/dist/InfoTooltipButton.js.map +1 -0
- package/dist/Layer.d.ts +9 -0
- package/dist/Layer.js +12 -0
- package/dist/Layer.js.map +1 -0
- package/dist/Link.d.ts +9 -0
- package/dist/Link.js +12 -0
- package/dist/Link.js.map +1 -0
- package/dist/Mask.d.ts +2 -0
- package/dist/Mask.js +19 -0
- package/dist/Mask.js.map +1 -0
- package/dist/MediaQuery.d.ts +4 -0
- package/dist/MediaQuery.js +52 -0
- package/dist/MediaQuery.js.map +1 -0
- package/dist/Meta.d.ts +5 -0
- package/dist/Meta.js +7 -0
- package/dist/Meta.js.map +1 -0
- package/dist/Modal.d.ts +19 -0
- package/dist/Modal.js +101 -0
- package/dist/Modal.js.map +1 -0
- package/dist/ModalSheet.d.ts +7 -0
- package/dist/ModalSheet.js +42 -0
- package/dist/ModalSheet.js.map +1 -0
- package/dist/NumberPickerActionSheet.d.ts +16 -0
- package/dist/NumberPickerActionSheet.js +29 -0
- package/dist/NumberPickerActionSheet.js.map +1 -0
- package/dist/Page.d.ts +26 -0
- package/dist/Page.js +38 -0
- package/dist/Page.js.map +1 -0
- package/dist/Permissions.d.ts +2 -0
- package/dist/Permissions.js +35 -0
- package/dist/Permissions.js.map +1 -0
- package/dist/PickerSelect.d.ts +109 -0
- package/dist/PickerSelect.js +296 -0
- package/dist/PickerSelect.js.map +1 -0
- package/dist/Pill.d.ts +5 -0
- package/dist/Pill.js +10 -0
- package/dist/Pill.js.map +1 -0
- package/dist/Pog.d.ts +15 -0
- package/dist/Pog.js +48 -0
- package/dist/Pog.js.map +1 -0
- package/dist/ProgressBar.d.ts +9 -0
- package/dist/ProgressBar.js +41 -0
- package/dist/ProgressBar.js.map +1 -0
- package/dist/ScrollView.d.ts +2 -0
- package/dist/ScrollView.js +3 -0
- package/dist/ScrollView.js.map +1 -0
- package/dist/SegmentedControl.d.ts +3 -0
- package/dist/SegmentedControl.js +55 -0
- package/dist/SegmentedControl.js.map +1 -0
- package/dist/SelectList.d.ts +18 -0
- package/dist/SelectList.js +48 -0
- package/dist/SelectList.js.map +1 -0
- package/dist/SideDrawer.d.ts +13 -0
- package/dist/SideDrawer.js +22 -0
- package/dist/SideDrawer.js.map +1 -0
- package/dist/Spinner.d.ts +3 -0
- package/dist/Spinner.js +16 -0
- package/dist/Spinner.js.map +1 -0
- package/dist/SplitPage.d.ts +3 -0
- package/dist/SplitPage.js +149 -0
- package/dist/SplitPage.js.map +1 -0
- package/dist/SplitPage.native.d.ts +3 -0
- package/dist/SplitPage.native.js +79 -0
- package/dist/SplitPage.native.js.map +1 -0
- package/dist/Switch.d.ts +5 -0
- package/dist/Switch.js +10 -0
- package/dist/Switch.js.map +1 -0
- package/dist/Table.d.ts +30 -0
- package/dist/Table.js +31 -0
- package/dist/Table.js.map +1 -0
- package/dist/TableHeader.d.ts +22 -0
- package/dist/TableHeader.js +11 -0
- package/dist/TableHeader.js.map +1 -0
- package/dist/TableHeaderCell.d.ts +15 -0
- package/dist/TableHeaderCell.js +36 -0
- package/dist/TableHeaderCell.js.map +1 -0
- package/dist/TableRow.d.ts +29 -0
- package/dist/TableRow.js +30 -0
- package/dist/TableRow.js.map +1 -0
- package/dist/TapToEdit.d.ts +19 -0
- package/dist/TapToEdit.js +136 -0
- package/dist/TapToEdit.js.map +1 -0
- package/dist/Text.d.ts +19 -0
- package/dist/Text.js +91 -0
- package/dist/Text.js.map +1 -0
- package/dist/TextArea.d.ts +6 -0
- package/dist/TextArea.js +24 -0
- package/dist/TextArea.js.map +1 -0
- package/dist/TextField.d.ts +3 -0
- package/dist/TextField.js +260 -0
- package/dist/TextField.js.map +1 -0
- package/dist/TextFieldNumberActionSheet.d.ts +15 -0
- package/dist/TextFieldNumberActionSheet.js +28 -0
- package/dist/TextFieldNumberActionSheet.js.map +1 -0
- package/dist/Toast.d.ts +12 -0
- package/dist/Toast.js +46 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Tooltip.d.ts +9 -0
- package/dist/Tooltip.js +174 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/UnifiedScreens.d.ts +9 -0
- package/dist/UnifiedScreens.js +25 -0
- package/dist/UnifiedScreens.js.map +1 -0
- package/dist/Unifier.d.ts +45 -0
- package/dist/Unifier.js +291 -0
- package/dist/Unifier.js.map +1 -0
- package/dist/Utilities.d.ts +31 -0
- package/dist/Utilities.js +73 -0
- package/dist/Utilities.js.map +1 -0
- package/dist/WithLabel.d.ts +14 -0
- package/dist/WithLabel.js +15 -0
- package/dist/WithLabel.js.map +1 -0
- package/dist/dayjsExtended.d.ts +2 -0
- package/{src/dayjsExtended.ts → dist/dayjsExtended.js} +1 -2
- package/dist/dayjsExtended.js.map +1 -0
- package/dist/index.d.ts +1299 -0
- package/dist/index.js.map +1 -0
- package/dist/tableContext.d.ts +21 -0
- package/dist/tableContext.js +35 -0
- package/dist/tableContext.js.map +1 -0
- package/package.json +4 -1
- package/checkDeps.js +0 -19
- package/src/ActionSheet.tsx +0 -1231
- package/src/Avatar.tsx +0 -317
- package/src/Badge.tsx +0 -65
- package/src/Banner.tsx +0 -124
- package/src/BlurBox.native.tsx +0 -40
- package/src/BlurBox.tsx +0 -31
- package/src/Body.tsx +0 -32
- package/src/Box.tsx +0 -308
- package/src/Button.tsx +0 -219
- package/src/Card.tsx +0 -23
- package/src/CheckBox.tsx +0 -118
- package/src/Common.ts +0 -2743
- package/src/Constants.ts +0 -53
- package/src/CustomSelect.tsx +0 -85
- package/src/DateTimeActionSheet.tsx +0 -409
- package/src/DateTimeField.android.tsx +0 -101
- package/src/DateTimeField.ios.tsx +0 -83
- package/src/DateTimeField.tsx +0 -69
- package/src/DecimalRangeActionSheet.tsx +0 -113
- package/src/ErrorBoundary.tsx +0 -37
- package/src/ErrorPage.tsx +0 -44
- package/src/FernsProvider.tsx +0 -21
- package/src/Field.tsx +0 -299
- package/src/FieldWithLabels.tsx +0 -36
- package/src/FlatList.tsx +0 -2
- package/src/Form.tsx +0 -182
- package/src/HeaderButtons.tsx +0 -107
- package/src/Heading.tsx +0 -53
- package/src/HeightActionSheet.tsx +0 -104
- package/src/Hyperlink.tsx +0 -181
- package/src/Icon.tsx +0 -24
- package/src/IconButton.tsx +0 -165
- package/src/Image.tsx +0 -50
- package/src/ImageBackground.tsx +0 -14
- package/src/InfoTooltipButton.tsx +0 -23
- package/src/Layer.tsx +0 -17
- package/src/Link.tsx +0 -17
- package/src/Mask.tsx +0 -21
- package/src/MediaQuery.ts +0 -46
- package/src/Meta.tsx +0 -9
- package/src/Modal.tsx +0 -248
- package/src/ModalSheet.tsx +0 -58
- package/src/NumberPickerActionSheet.tsx +0 -66
- package/src/Page.tsx +0 -133
- package/src/Permissions.ts +0 -44
- package/src/PickerSelect.tsx +0 -553
- package/src/Pill.tsx +0 -24
- package/src/Pog.tsx +0 -87
- package/src/ProgressBar.tsx +0 -55
- package/src/ScrollView.tsx +0 -2
- package/src/SegmentedControl.tsx +0 -102
- package/src/SelectList.tsx +0 -89
- package/src/SideDrawer.tsx +0 -62
- package/src/Spinner.tsx +0 -20
- package/src/SplitPage.native.tsx +0 -160
- package/src/SplitPage.tsx +0 -302
- package/src/Switch.tsx +0 -19
- package/src/Table.tsx +0 -87
- package/src/TableHeader.tsx +0 -36
- package/src/TableHeaderCell.tsx +0 -76
- package/src/TableRow.tsx +0 -87
- package/src/TapToEdit.tsx +0 -221
- package/src/Text.tsx +0 -131
- package/src/TextArea.tsx +0 -16
- package/src/TextField.tsx +0 -401
- package/src/TextFieldNumberActionSheet.tsx +0 -61
- package/src/Toast.tsx +0 -106
- package/src/Tooltip.tsx +0 -269
- package/src/UnifiedScreens.ts +0 -24
- package/src/Unifier.ts +0 -371
- package/src/Utilities.tsx +0 -159
- package/src/WithLabel.tsx +0 -57
- package/src/index.tsx +0 -1346
- package/src/polyfill.d.ts +0 -11
- package/src/tableContext.tsx +0 -80
- package/tsconfig.json +0 -30
- package/updateDeps.js +0 -14
package/src/SplitPage.tsx
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import React, {Children, useCallback, useEffect, useState} from "react";
|
|
2
|
-
import {Dimensions, ListRenderItemInfo, ScrollView, View} from "react-native";
|
|
3
|
-
import {SwiperFlatList} from "react-native-swiper-flatlist";
|
|
4
|
-
|
|
5
|
-
import {Box} from "./Box";
|
|
6
|
-
import {SplitPageProps} from "./Common";
|
|
7
|
-
import {FlatList} from "./FlatList";
|
|
8
|
-
import {IconButton} from "./IconButton";
|
|
9
|
-
import {mediaQueryLargerThan} from "./MediaQuery";
|
|
10
|
-
import {SegmentedControl} from "./SegmentedControl";
|
|
11
|
-
import {Spinner} from "./Spinner";
|
|
12
|
-
import {Unifier} from "./Unifier";
|
|
13
|
-
|
|
14
|
-
// A component for rendering a list on one side and a details view on the right for large screens,
|
|
15
|
-
// and a scrollable list where clicking an item takes you the details view.
|
|
16
|
-
export const SplitPage = ({
|
|
17
|
-
children,
|
|
18
|
-
tabs = [],
|
|
19
|
-
loading = false,
|
|
20
|
-
color,
|
|
21
|
-
keyboardOffset,
|
|
22
|
-
renderListViewItem,
|
|
23
|
-
renderListViewHeader,
|
|
24
|
-
renderContent,
|
|
25
|
-
onSelectionChange = () => {},
|
|
26
|
-
listViewData,
|
|
27
|
-
listViewExtraData,
|
|
28
|
-
listViewWidth,
|
|
29
|
-
bottomNavBarHeight,
|
|
30
|
-
showItemList,
|
|
31
|
-
selectLimit,
|
|
32
|
-
}: SplitPageProps) => {
|
|
33
|
-
const [selectedId, setSelectedId] = useState<number | undefined>(undefined);
|
|
34
|
-
const [activeTabs, setActiveTabs] = useState<number[]>([0, 1]);
|
|
35
|
-
const {width} = Dimensions.get("window");
|
|
36
|
-
|
|
37
|
-
const isMobileDevice = !mediaQueryLargerThan("sm");
|
|
38
|
-
|
|
39
|
-
const elementArray = Children.toArray(children).filter((c) => c !== null);
|
|
40
|
-
|
|
41
|
-
const onItemSelect = useCallback(
|
|
42
|
-
(item: ListRenderItemInfo<any>) => {
|
|
43
|
-
setSelectedId(item.index);
|
|
44
|
-
onSelectionChange(item);
|
|
45
|
-
},
|
|
46
|
-
[onSelectionChange]
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const onItemDeselect = useCallback(() => {
|
|
50
|
-
setSelectedId(undefined);
|
|
51
|
-
onSelectionChange(undefined);
|
|
52
|
-
}, [onSelectionChange]);
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (showItemList) {
|
|
56
|
-
onItemDeselect();
|
|
57
|
-
}
|
|
58
|
-
}, [showItemList, onItemDeselect]);
|
|
59
|
-
|
|
60
|
-
if (!children && !renderContent) {
|
|
61
|
-
console.warn("A child node is required");
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (elementArray.length > 2 && elementArray.length !== tabs.length) {
|
|
66
|
-
console.warn("There must be a tab for each child");
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const renderItem = (itemInfo: ListRenderItemInfo<any>) => {
|
|
71
|
-
return (
|
|
72
|
-
<Box
|
|
73
|
-
onClick={() => {
|
|
74
|
-
onItemSelect(itemInfo);
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
{renderListViewItem(itemInfo)}
|
|
78
|
-
</Box>
|
|
79
|
-
);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const renderList = () => {
|
|
83
|
-
return (
|
|
84
|
-
<View
|
|
85
|
-
style={{
|
|
86
|
-
width: listViewWidth ?? 300,
|
|
87
|
-
maxWidth: listViewWidth ?? 300,
|
|
88
|
-
flexGrow: 1,
|
|
89
|
-
flexShrink: 0,
|
|
90
|
-
display: "flex",
|
|
91
|
-
flexDirection: "column",
|
|
92
|
-
}}
|
|
93
|
-
>
|
|
94
|
-
{renderListViewHeader && renderListViewHeader()}
|
|
95
|
-
<FlatList
|
|
96
|
-
data={listViewData}
|
|
97
|
-
extraData={listViewExtraData}
|
|
98
|
-
keyExtractor={(item) => item.id}
|
|
99
|
-
renderItem={renderItem}
|
|
100
|
-
/>
|
|
101
|
-
</View>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const renderListContent = () => {
|
|
106
|
-
return (
|
|
107
|
-
<Box flex="grow" padding={2}>
|
|
108
|
-
{renderContent && renderContent(selectedId)}
|
|
109
|
-
</Box>
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const renderChildrenContent = () => {
|
|
114
|
-
if (Array.isArray(children) && elementArray.length > 2) {
|
|
115
|
-
return (
|
|
116
|
-
<View
|
|
117
|
-
style={{
|
|
118
|
-
flex: 1,
|
|
119
|
-
width: "100%",
|
|
120
|
-
height: "100%",
|
|
121
|
-
alignItems: "center",
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
<Box marginBottom={4} paddingX={4} width="100%">
|
|
125
|
-
<SegmentedControl
|
|
126
|
-
items={tabs}
|
|
127
|
-
multiselect
|
|
128
|
-
selectLimit={selectLimit || tabs.length}
|
|
129
|
-
selectedItemIndexes={activeTabs}
|
|
130
|
-
onChange={(index) => {
|
|
131
|
-
setActiveTabs([...(index.activeIndex as number[])]);
|
|
132
|
-
}}
|
|
133
|
-
/>
|
|
134
|
-
</Box>
|
|
135
|
-
<Box
|
|
136
|
-
direction="row"
|
|
137
|
-
flex="grow"
|
|
138
|
-
height="100%"
|
|
139
|
-
paddingX={4}
|
|
140
|
-
width={activeTabs.length > 1 ? "100%" : "60%"}
|
|
141
|
-
>
|
|
142
|
-
{activeTabs.map((tabIndex, i) => {
|
|
143
|
-
return (
|
|
144
|
-
<ScrollView
|
|
145
|
-
key={tabIndex}
|
|
146
|
-
contentContainerStyle={{
|
|
147
|
-
flex: 1,
|
|
148
|
-
}}
|
|
149
|
-
style={{
|
|
150
|
-
flex: 1,
|
|
151
|
-
width: "60%",
|
|
152
|
-
height: "100%",
|
|
153
|
-
paddingRight: i ? 0 : 16,
|
|
154
|
-
paddingLeft: i ? 16 : 0,
|
|
155
|
-
}}
|
|
156
|
-
>
|
|
157
|
-
{elementArray[tabIndex]}
|
|
158
|
-
</ScrollView>
|
|
159
|
-
);
|
|
160
|
-
})}
|
|
161
|
-
</Box>
|
|
162
|
-
</View>
|
|
163
|
-
);
|
|
164
|
-
} else {
|
|
165
|
-
return (
|
|
166
|
-
<Box alignItems="center" direction="row" flex="grow" justifyContent="center" paddingX={2}>
|
|
167
|
-
{elementArray.map((element, index) => {
|
|
168
|
-
return (
|
|
169
|
-
<ScrollView
|
|
170
|
-
key={index}
|
|
171
|
-
contentContainerStyle={{
|
|
172
|
-
flex: 1,
|
|
173
|
-
}}
|
|
174
|
-
style={{
|
|
175
|
-
flex: 1,
|
|
176
|
-
width: "60%",
|
|
177
|
-
height: "100%",
|
|
178
|
-
}}
|
|
179
|
-
>
|
|
180
|
-
{element}
|
|
181
|
-
</ScrollView>
|
|
182
|
-
);
|
|
183
|
-
})}
|
|
184
|
-
</Box>
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
const renderMobileList = () => {
|
|
190
|
-
if (isMobileDevice && selectedId !== undefined) {
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return (
|
|
195
|
-
<View
|
|
196
|
-
style={{
|
|
197
|
-
width: "100%",
|
|
198
|
-
maxWidth: "100%",
|
|
199
|
-
height: "100%",
|
|
200
|
-
flexGrow: 1,
|
|
201
|
-
flexShrink: 0,
|
|
202
|
-
display: "flex",
|
|
203
|
-
flexDirection: "column",
|
|
204
|
-
}}
|
|
205
|
-
>
|
|
206
|
-
{renderListViewHeader && renderListViewHeader()}
|
|
207
|
-
<FlatList
|
|
208
|
-
data={listViewData}
|
|
209
|
-
extraData={listViewExtraData}
|
|
210
|
-
keyExtractor={(item) => item.id}
|
|
211
|
-
nestedScrollEnabled
|
|
212
|
-
renderItem={renderItem}
|
|
213
|
-
/>
|
|
214
|
-
</View>
|
|
215
|
-
);
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const renderMobileListContent = () => {
|
|
219
|
-
if (isMobileDevice && selectedId === undefined) {
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return (
|
|
224
|
-
<Box flex="grow" padding={2}>
|
|
225
|
-
{isMobileDevice && (
|
|
226
|
-
<Box width="100%">
|
|
227
|
-
<IconButton
|
|
228
|
-
accessibilityLabel="close"
|
|
229
|
-
icon="times"
|
|
230
|
-
iconColor="darkGray"
|
|
231
|
-
onClick={() => onItemDeselect()}
|
|
232
|
-
/>
|
|
233
|
-
</Box>
|
|
234
|
-
)}
|
|
235
|
-
{renderContent && renderContent(selectedId)}
|
|
236
|
-
</Box>
|
|
237
|
-
);
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
const renderMobileChildrenContent = () => {
|
|
241
|
-
if (selectedId === undefined) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
return (
|
|
245
|
-
<SwiperFlatList
|
|
246
|
-
nestedScrollEnabled
|
|
247
|
-
paginationStyle={{justifyContent: "center", width: "95%"}}
|
|
248
|
-
renderAll
|
|
249
|
-
showPagination
|
|
250
|
-
style={{width: "100%"}}
|
|
251
|
-
>
|
|
252
|
-
{elementArray.map((element, i) => {
|
|
253
|
-
return (
|
|
254
|
-
<View
|
|
255
|
-
key={i}
|
|
256
|
-
style={{
|
|
257
|
-
width: width - 8,
|
|
258
|
-
padding: 4,
|
|
259
|
-
height: elementArray.length > 1 ? "90%" : "100%",
|
|
260
|
-
paddingBottom: bottomNavBarHeight,
|
|
261
|
-
}}
|
|
262
|
-
>
|
|
263
|
-
{element}
|
|
264
|
-
</View>
|
|
265
|
-
);
|
|
266
|
-
})}
|
|
267
|
-
</SwiperFlatList>
|
|
268
|
-
);
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
const renderSplitPage = () => {
|
|
272
|
-
return (
|
|
273
|
-
<>
|
|
274
|
-
{renderList()}
|
|
275
|
-
{renderContent ? renderListContent() : renderChildrenContent()}
|
|
276
|
-
</>
|
|
277
|
-
);
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
const renderMobileSplitPage = () => {
|
|
281
|
-
const renderMainContent = renderContent
|
|
282
|
-
? renderMobileListContent()
|
|
283
|
-
: renderMobileChildrenContent();
|
|
284
|
-
return selectedId === undefined ? renderMobileList() : renderMainContent;
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
return (
|
|
288
|
-
<Box
|
|
289
|
-
avoidKeyboard
|
|
290
|
-
color={color || "lightGray"}
|
|
291
|
-
direction="row"
|
|
292
|
-
display="flex"
|
|
293
|
-
height="100%"
|
|
294
|
-
keyboardOffset={keyboardOffset}
|
|
295
|
-
padding={2}
|
|
296
|
-
width="100%"
|
|
297
|
-
>
|
|
298
|
-
{loading === true && <Spinner color={Unifier.theme.darkGray as any} size="md" />}
|
|
299
|
-
{Boolean(isMobileDevice) ? renderMobileSplitPage() : renderSplitPage()}
|
|
300
|
-
</Box>
|
|
301
|
-
);
|
|
302
|
-
};
|
package/src/Switch.tsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {Switch as NativeSwitch} from "react-native";
|
|
3
|
-
|
|
4
|
-
import {SwitchProps} from "./Common";
|
|
5
|
-
import {WithLabel} from "./WithLabel";
|
|
6
|
-
|
|
7
|
-
export class Switch extends React.Component<SwitchProps, {}> {
|
|
8
|
-
render() {
|
|
9
|
-
return (
|
|
10
|
-
<WithLabel labelAlignItems="center" labelInline labelJustifyContent="between" {...this.props}>
|
|
11
|
-
<NativeSwitch
|
|
12
|
-
disabled={this.props.disabled}
|
|
13
|
-
value={this.props.switched}
|
|
14
|
-
onValueChange={this.props.onChange}
|
|
15
|
-
/>
|
|
16
|
-
</WithLabel>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/Table.tsx
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React, {Children, ReactElement} from "react";
|
|
2
|
-
import {DimensionValue} from "react-native/Libraries/StyleSheet/StyleSheetTypes";
|
|
3
|
-
|
|
4
|
-
import {ScrollView} from "./ScrollView";
|
|
5
|
-
import {ColumnSortInterface, TableContextProvider} from "./tableContext";
|
|
6
|
-
|
|
7
|
-
interface TableProps {
|
|
8
|
-
/**
|
|
9
|
-
* Must be instances of TableHeader, TableRow, and/or TableFooter components.
|
|
10
|
-
*/
|
|
11
|
-
children: React.ReactNode | React.ReactNode[];
|
|
12
|
-
/**
|
|
13
|
-
* Width of columns in the table. This is used to calculate the width of each column. Can be numbers for pixels or strings for percentages.
|
|
14
|
-
*/
|
|
15
|
-
columns: Array<number | string>;
|
|
16
|
-
/**
|
|
17
|
-
* Specify a border width for Table: "sm" is 1px.
|
|
18
|
-
*/
|
|
19
|
-
borderStyle?: "sm" | "none";
|
|
20
|
-
/**
|
|
21
|
-
* Use numbers for pixels: `maxHeight={100}` and strings for percentages: `maxHeight="100%"`.
|
|
22
|
-
*/
|
|
23
|
-
maxHeight?: DimensionValue;
|
|
24
|
-
/**
|
|
25
|
-
* If true, the header will stick to the top of the table when scrolling. Defaults to true.
|
|
26
|
-
*/
|
|
27
|
-
stickyHeader?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* If true, alternate rows will have a light gray background. Defaults to true.
|
|
30
|
-
*/
|
|
31
|
-
alternateRowBackground?: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function Table({
|
|
35
|
-
children,
|
|
36
|
-
columns,
|
|
37
|
-
borderStyle,
|
|
38
|
-
alternateRowBackground = true,
|
|
39
|
-
maxHeight,
|
|
40
|
-
stickyHeader = true,
|
|
41
|
-
}: TableProps): React.ReactElement {
|
|
42
|
-
const arrayChildren = Children.toArray(children);
|
|
43
|
-
const [sortColumn, setSortColumn] = React.useState<ColumnSortInterface | undefined>(undefined);
|
|
44
|
-
|
|
45
|
-
// Check if any of the rows below have a drawerContents prop to see if we need to render space for the caret.
|
|
46
|
-
const hasDrawerContents = arrayChildren.some((child) => {
|
|
47
|
-
return (child as ReactElement).props?.drawerContents;
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// Calculate the total width of the table. If the table has only number widths, calculate a width. Otherwise use 100%.
|
|
51
|
-
let width: DimensionValue;
|
|
52
|
-
if (columns.every((column) => typeof column === "number")) {
|
|
53
|
-
width = columns.reduce((acc, curr) => {
|
|
54
|
-
return (acc as number) + (curr as number);
|
|
55
|
-
}, 0) as number;
|
|
56
|
-
if (hasDrawerContents) {
|
|
57
|
-
width = (width as number) + 30;
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
width = "100%";
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<TableContextProvider
|
|
65
|
-
alternateRowBackground={alternateRowBackground}
|
|
66
|
-
borderStyle={borderStyle}
|
|
67
|
-
columns={columns}
|
|
68
|
-
hasDrawerContents={hasDrawerContents}
|
|
69
|
-
setSortColumn={setSortColumn}
|
|
70
|
-
sortColumn={sortColumn}
|
|
71
|
-
stickyHeader={stickyHeader}
|
|
72
|
-
>
|
|
73
|
-
<ScrollView horizontal style={{width, maxWidth: "100%"}}>
|
|
74
|
-
<ScrollView
|
|
75
|
-
stickyHeaderIndices={stickyHeader ? [0] : undefined}
|
|
76
|
-
style={{width, maxWidth: "100%", flex: 1, maxHeight}}
|
|
77
|
-
>
|
|
78
|
-
{Children.map(children, (child, index) =>
|
|
79
|
-
React.cloneElement(child as any, {
|
|
80
|
-
color: index % 2 === 1 && alternateRowBackground ? "lightGray" : "white",
|
|
81
|
-
})
|
|
82
|
-
)}
|
|
83
|
-
</ScrollView>
|
|
84
|
-
</ScrollView>
|
|
85
|
-
</TableContextProvider>
|
|
86
|
-
);
|
|
87
|
-
}
|
package/src/TableHeader.tsx
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import {Box} from "./Box";
|
|
4
|
-
import {BoxColor} from "./Common";
|
|
5
|
-
import {TableRow} from "./TableRow";
|
|
6
|
-
|
|
7
|
-
interface TableHeaderProps {
|
|
8
|
-
/**
|
|
9
|
-
* Must be an instance of TableRow.
|
|
10
|
-
*/
|
|
11
|
-
children: React.ReactNode | React.ReactNode[];
|
|
12
|
-
/**
|
|
13
|
-
* Display `visuallyHidden` ensures the component is visually hidden but still is read by screen readers.
|
|
14
|
-
*/
|
|
15
|
-
display?: "tableHeaderGroup" | "visuallyHidden";
|
|
16
|
-
/**
|
|
17
|
-
* If true, the table header will be sticky and the table body will be scrollable. Not yet implemented.
|
|
18
|
-
*/
|
|
19
|
-
sticky?: boolean;
|
|
20
|
-
color?: BoxColor;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Use TableHeader to group the header content in Table.
|
|
25
|
-
*/
|
|
26
|
-
export function TableHeader({
|
|
27
|
-
children,
|
|
28
|
-
display = "tableHeaderGroup",
|
|
29
|
-
color,
|
|
30
|
-
}: TableHeaderProps): React.ReactElement {
|
|
31
|
-
return (
|
|
32
|
-
<Box color={color ?? "white"} display={display === "visuallyHidden" ? "none" : "flex"}>
|
|
33
|
-
<TableRow headerRow>{children}</TableRow>
|
|
34
|
-
</Box>
|
|
35
|
-
);
|
|
36
|
-
}
|
package/src/TableHeaderCell.tsx
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React, {ReactElement} from "react";
|
|
2
|
-
|
|
3
|
-
import {Box} from "./Box";
|
|
4
|
-
import {IconButton} from "./IconButton";
|
|
5
|
-
import {useTableContext} from "./tableContext";
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
/**
|
|
9
|
-
* The content of the table header cell.
|
|
10
|
-
*/
|
|
11
|
-
children: ReactElement;
|
|
12
|
-
index: number;
|
|
13
|
-
sortable?: boolean;
|
|
14
|
-
onSortChange?: (direction: "asc" | "desc" | undefined) => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Use TableHeaderCell to define a header cell in Table.
|
|
19
|
-
*/
|
|
20
|
-
export function TableHeaderCell({children, index, sortable, onSortChange}: Props): ReactElement {
|
|
21
|
-
const {columns, setSortColumn, sortColumn} = useTableContext();
|
|
22
|
-
const width = columns[index];
|
|
23
|
-
if (!width) {
|
|
24
|
-
console.warn(`No width defined for column ${index} in TableHeaderCell`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const onClick = () => {
|
|
28
|
-
// desc => asc => undefined
|
|
29
|
-
const newSort = sort === "desc" ? "asc" : sort === "asc" ? undefined : "desc";
|
|
30
|
-
if (setSortColumn) {
|
|
31
|
-
setSortColumn(newSort ? {column: index, direction: newSort} : undefined);
|
|
32
|
-
}
|
|
33
|
-
onSortChange && onSortChange(newSort);
|
|
34
|
-
};
|
|
35
|
-
const sort = sortColumn?.column === index ? sortColumn.direction : undefined;
|
|
36
|
-
|
|
37
|
-
if (sortable) {
|
|
38
|
-
if (!onSortChange) {
|
|
39
|
-
console.error("onSortChange is required when sortable is true");
|
|
40
|
-
}
|
|
41
|
-
return (
|
|
42
|
-
<Box
|
|
43
|
-
alignItems="center"
|
|
44
|
-
direction="row"
|
|
45
|
-
flex="grow"
|
|
46
|
-
justifyContent="between"
|
|
47
|
-
marginBottom={2}
|
|
48
|
-
marginTop={2}
|
|
49
|
-
maxWidth={width}
|
|
50
|
-
minHeight={36}
|
|
51
|
-
width={width}
|
|
52
|
-
onClick={onClick}
|
|
53
|
-
>
|
|
54
|
-
{children}
|
|
55
|
-
{Boolean(sort) && (
|
|
56
|
-
<Box paddingX={2}>
|
|
57
|
-
<IconButton
|
|
58
|
-
accessibilityLabel="sort"
|
|
59
|
-
bgColor="white"
|
|
60
|
-
icon={sort === "asc" ? "arrow-down" : "arrow-up"}
|
|
61
|
-
iconColor="darkGray"
|
|
62
|
-
size="sm"
|
|
63
|
-
onClick={() => {}}
|
|
64
|
-
/>
|
|
65
|
-
</Box>
|
|
66
|
-
)}
|
|
67
|
-
</Box>
|
|
68
|
-
);
|
|
69
|
-
} else {
|
|
70
|
-
return (
|
|
71
|
-
<Box flex="grow" justifyContent="center" marginBottom={2} marginTop={2} width={width}>
|
|
72
|
-
{children}
|
|
73
|
-
</Box>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
package/src/TableRow.tsx
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React, {Children, useRef} from "react";
|
|
2
|
-
|
|
3
|
-
import {Box} from "./Box";
|
|
4
|
-
import {BoxColor} from "./Common";
|
|
5
|
-
import {IconButton} from "./IconButton";
|
|
6
|
-
import {useTableContext} from "./tableContext";
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
/**
|
|
10
|
-
* Must be instances of TableCell or TableHeaderCell.
|
|
11
|
-
*/
|
|
12
|
-
children: React.ReactNode | React.ReactNode[];
|
|
13
|
-
/**
|
|
14
|
-
* Header rows have an extra thick bottom border.
|
|
15
|
-
*/
|
|
16
|
-
headerRow?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Whether the row should start expanded or not.
|
|
19
|
-
*/
|
|
20
|
-
expanded?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* When the row is expanded, the drawerContents are shown. If not
|
|
23
|
-
*/
|
|
24
|
-
drawerContents?: React.ReactNode | React.ReactNode[];
|
|
25
|
-
/**
|
|
26
|
-
* Background color of the row. Defaults to white.
|
|
27
|
-
*/
|
|
28
|
-
color?: BoxColor;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Use TableRow to define a row in Table.
|
|
33
|
-
*/
|
|
34
|
-
export function TableRow({
|
|
35
|
-
children,
|
|
36
|
-
headerRow = false,
|
|
37
|
-
expanded,
|
|
38
|
-
drawerContents,
|
|
39
|
-
color = "white",
|
|
40
|
-
}: Props): React.ReactElement {
|
|
41
|
-
const [isExpanded, setIsExpanded] = React.useState(expanded || false);
|
|
42
|
-
const {columns, hasDrawerContents} = useTableContext();
|
|
43
|
-
const rowRef = useRef<typeof Box>(null);
|
|
44
|
-
|
|
45
|
-
const renderCellWithColumnIndex = (child: React.ReactNode, index: number) => {
|
|
46
|
-
if (!columns[index]) {
|
|
47
|
-
console.warn(`No width defined for column ${index} in TableRow`);
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
return (
|
|
51
|
-
<Box paddingX={2} width={columns[index]}>
|
|
52
|
-
{child}
|
|
53
|
-
</Box>
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const border = {__style: {borderBottom: `${headerRow ? 2 : 1}px solid #e0e0e0`}};
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<Box ref={rowRef} color={color} dangerouslySetInlineStyle={border} width="100%">
|
|
61
|
-
<Box direction="row" paddingY={1} width="100%">
|
|
62
|
-
{Boolean(drawerContents) && (
|
|
63
|
-
<Box width={30}>
|
|
64
|
-
<IconButton
|
|
65
|
-
accessibilityLabel="expand"
|
|
66
|
-
bgColor="white"
|
|
67
|
-
icon={isExpanded ? "chevron-up" : "chevron-down"}
|
|
68
|
-
iconColor="darkGray"
|
|
69
|
-
size="sm"
|
|
70
|
-
onClick={() => {
|
|
71
|
-
setIsExpanded(!isExpanded);
|
|
72
|
-
}}
|
|
73
|
-
/>
|
|
74
|
-
</Box>
|
|
75
|
-
)}
|
|
76
|
-
{/* Still render a blank space so the columns line up. */}
|
|
77
|
-
{Boolean(hasDrawerContents && !drawerContents) && <Box width={30} />}
|
|
78
|
-
{Children.map(children, renderCellWithColumnIndex)}
|
|
79
|
-
</Box>
|
|
80
|
-
{Boolean(isExpanded) && (
|
|
81
|
-
<Box paddingX={2} width="100%">
|
|
82
|
-
{drawerContents}
|
|
83
|
-
</Box>
|
|
84
|
-
)}
|
|
85
|
-
</Box>
|
|
86
|
-
);
|
|
87
|
-
}
|