ferns-ui 0.36.4 → 0.36.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/package.json +3 -4
  2. package/src/ActionSheet.tsx +1231 -0
  3. package/src/Avatar.tsx +317 -0
  4. package/src/Badge.tsx +65 -0
  5. package/src/Banner.tsx +124 -0
  6. package/src/BlurBox.native.tsx +40 -0
  7. package/src/BlurBox.tsx +31 -0
  8. package/src/Body.tsx +32 -0
  9. package/src/Box.tsx +308 -0
  10. package/src/Button.tsx +219 -0
  11. package/src/Card.tsx +23 -0
  12. package/src/CheckBox.tsx +118 -0
  13. package/src/Common.ts +2743 -0
  14. package/src/Constants.ts +53 -0
  15. package/src/CustomSelect.tsx +85 -0
  16. package/src/DateTimeActionSheet.tsx +409 -0
  17. package/src/DateTimeField.android.tsx +101 -0
  18. package/src/DateTimeField.ios.tsx +83 -0
  19. package/src/DateTimeField.tsx +69 -0
  20. package/src/DecimalRangeActionSheet.tsx +113 -0
  21. package/src/ErrorBoundary.tsx +37 -0
  22. package/src/ErrorPage.tsx +44 -0
  23. package/src/FernsProvider.tsx +21 -0
  24. package/src/Field.tsx +299 -0
  25. package/src/FieldWithLabels.tsx +36 -0
  26. package/src/FlatList.tsx +2 -0
  27. package/src/Form.tsx +182 -0
  28. package/src/HeaderButtons.tsx +107 -0
  29. package/src/Heading.tsx +53 -0
  30. package/src/HeightActionSheet.tsx +104 -0
  31. package/src/Hyperlink.tsx +181 -0
  32. package/src/Icon.tsx +24 -0
  33. package/src/IconButton.tsx +165 -0
  34. package/src/Image.tsx +50 -0
  35. package/src/ImageBackground.tsx +14 -0
  36. package/src/InfoTooltipButton.tsx +23 -0
  37. package/src/Layer.tsx +17 -0
  38. package/src/Link.tsx +17 -0
  39. package/src/Mask.tsx +21 -0
  40. package/src/MediaQuery.ts +46 -0
  41. package/src/Meta.tsx +9 -0
  42. package/src/Modal.tsx +248 -0
  43. package/src/ModalSheet.tsx +58 -0
  44. package/src/NumberPickerActionSheet.tsx +66 -0
  45. package/src/Page.tsx +133 -0
  46. package/src/Permissions.ts +44 -0
  47. package/src/PickerSelect.tsx +553 -0
  48. package/src/Pill.tsx +24 -0
  49. package/src/Pog.tsx +87 -0
  50. package/src/ProgressBar.tsx +55 -0
  51. package/src/ScrollView.tsx +2 -0
  52. package/src/SegmentedControl.tsx +102 -0
  53. package/src/SelectList.tsx +89 -0
  54. package/src/SideDrawer.tsx +62 -0
  55. package/src/Spinner.tsx +20 -0
  56. package/src/SplitPage.native.tsx +160 -0
  57. package/src/SplitPage.tsx +302 -0
  58. package/src/Switch.tsx +19 -0
  59. package/src/Table.tsx +87 -0
  60. package/src/TableHeader.tsx +36 -0
  61. package/src/TableHeaderCell.tsx +76 -0
  62. package/src/TableRow.tsx +87 -0
  63. package/src/TapToEdit.tsx +221 -0
  64. package/src/Text.tsx +131 -0
  65. package/src/TextArea.tsx +16 -0
  66. package/src/TextField.tsx +401 -0
  67. package/src/TextFieldNumberActionSheet.tsx +61 -0
  68. package/src/Toast.tsx +106 -0
  69. package/src/Tooltip.tsx +269 -0
  70. package/src/UnifiedScreens.ts +24 -0
  71. package/src/Unifier.ts +371 -0
  72. package/src/Utilities.tsx +159 -0
  73. package/src/WithLabel.tsx +57 -0
  74. package/src/dayjsExtended.ts +10 -0
  75. package/src/index.tsx +1346 -0
  76. package/src/polyfill.d.ts +11 -0
  77. package/src/tableContext.tsx +80 -0
@@ -0,0 +1,66 @@
1
+ import {Picker} from "@react-native-picker/picker";
2
+ import range from "lodash/range";
3
+ import React from "react";
4
+
5
+ import {ActionSheet} from "./ActionSheet";
6
+ import {Box} from "./Box";
7
+ import {Button} from "./Button";
8
+ import {OnChangeCallback} from "./Common";
9
+
10
+ const PICKER_HEIGHT = 104;
11
+
12
+ interface NumberPickerActionSheetProps {
13
+ value: string;
14
+ min: number;
15
+ max: number;
16
+ onChange: OnChangeCallback;
17
+ actionSheetRef: React.RefObject<any>;
18
+ }
19
+
20
+ interface NumberPickerActionSheetState {}
21
+
22
+ export class NumberPickerActionSheet extends React.Component<
23
+ NumberPickerActionSheetProps,
24
+ NumberPickerActionSheetState
25
+ > {
26
+ constructor(props: NumberPickerActionSheetProps) {
27
+ super(props);
28
+ }
29
+
30
+ render() {
31
+ return (
32
+ <ActionSheet ref={this.props.actionSheetRef} bounceOnOpen gestureEnabled>
33
+ <Box marginBottom={8} paddingX={4} width="100%">
34
+ <Box alignItems="end" display="flex" width="100%">
35
+ <Box width="33%">
36
+ <Button
37
+ color="blue"
38
+ size="lg"
39
+ text="Close"
40
+ type="ghost"
41
+ onClick={() => {
42
+ this.props.actionSheetRef?.current?.setModalVisible(false);
43
+ }}
44
+ />
45
+ </Box>
46
+ </Box>
47
+ <Picker
48
+ itemStyle={{
49
+ height: PICKER_HEIGHT,
50
+ }}
51
+ selectedValue={String(this.props.value)}
52
+ style={{
53
+ height: PICKER_HEIGHT,
54
+ backgroundColor: "#FFFFFF",
55
+ }}
56
+ onValueChange={(itemValue) => this.props.onChange({value: String(itemValue)})}
57
+ >
58
+ {range(this.props.min, this.props.max).map((n) => (
59
+ <Picker.Item key={String(n)} label={String(n)} value={String(n)} />
60
+ ))}
61
+ </Picker>
62
+ </Box>
63
+ </ActionSheet>
64
+ );
65
+ }
66
+ }
package/src/Page.tsx ADDED
@@ -0,0 +1,133 @@
1
+ import React from "react";
2
+
3
+ import {Box} from "./Box";
4
+ import {Button} from "./Button";
5
+ import {Color, UnsignedUpTo12} from "./Common";
6
+ import {ErrorBoundary} from "./ErrorBoundary";
7
+ import {Heading} from "./Heading";
8
+ import {IconButton} from "./IconButton";
9
+ // import {KeyboardAccessoryNavigation} from "react-native-keyboard-accessory";
10
+ import {Spinner} from "./Spinner";
11
+ import {Unifier} from "./Unifier";
12
+
13
+ interface PageProps {
14
+ // TODO: figure out navigation
15
+ navigation: any;
16
+ scroll?: boolean;
17
+ loading?: boolean;
18
+ display?: "flex" | "none" | "block" | "inlineBlock";
19
+ title?: string;
20
+ backButton?: boolean;
21
+ closeButton?: boolean;
22
+ direction?: "row" | "column";
23
+ padding?: UnsignedUpTo12;
24
+ color?: Color;
25
+ maxWidth?: number | string;
26
+ keyboardOffset?: number;
27
+ footer?: any;
28
+ rightButton?: string;
29
+ rightButtonOnClick?: () => void;
30
+ children?: any;
31
+ }
32
+
33
+ export class Page extends React.Component<PageProps, {}> {
34
+ actionSheetRef: React.RefObject<any> = React.createRef();
35
+
36
+ renderHeader() {
37
+ if (!this.props.title && !this.props.backButton) {
38
+ return null;
39
+ }
40
+ return (
41
+ <Box direction="row" display="flex" width="100%">
42
+ {this.props.backButton && (
43
+ <Box alignItems="center" display="block" justifyContent="center" paddingY={3}>
44
+ <IconButton
45
+ accessibilityLabel=""
46
+ icon="chevron-left"
47
+ iconColor="darkGray"
48
+ prefix="fas"
49
+ size="md"
50
+ onClick={() => this.props.navigation.goBack()}
51
+ />
52
+ </Box>
53
+ )}
54
+ {this.props.closeButton && (
55
+ <Box alignItems="center" display="block" justifyContent="center" paddingY={3}>
56
+ <IconButton
57
+ accessibilityLabel=""
58
+ icon="times"
59
+ iconColor="darkGray"
60
+ prefix="fas"
61
+ size="md"
62
+ onClick={() => this.props.navigation.goBack()}
63
+ />
64
+ </Box>
65
+ )}
66
+ {Boolean(this.props.title) && (
67
+ <Box direction="column" display="flex" flex="grow" justifyContent="center">
68
+ <Heading align="center">{this.props.title}</Heading>
69
+ </Box>
70
+ )}
71
+ {this.props.rightButton && (
72
+ <Box alignItems="center" display="block" justifyContent="center" paddingY={3}>
73
+ <Button
74
+ color="gray"
75
+ text={this.props.rightButton}
76
+ type="ghost"
77
+ onClick={() => this.props.rightButtonOnClick && this.props.rightButtonOnClick()}
78
+ />
79
+ </Box>
80
+ )}
81
+ </Box>
82
+ );
83
+ }
84
+
85
+ render() {
86
+ return (
87
+ <ErrorBoundary>
88
+ <Box
89
+ alignSelf="center"
90
+ avoidKeyboard
91
+ color={this.props.color || "lightGray"}
92
+ direction={this.props.direction || "column"}
93
+ display={this.props.display || "flex"}
94
+ flex="grow"
95
+ keyboardOffset={this.props.keyboardOffset}
96
+ maxWidth={this.props.maxWidth || 800}
97
+ padding={this.props.padding !== undefined ? this.props.padding : 2}
98
+ scroll={this.props.scroll === undefined ? true : this.props.scroll}
99
+ width="100%"
100
+ >
101
+ {this.renderHeader()}
102
+ {this.props.loading === true && (
103
+ <Spinner color={Unifier.theme.darkGray as any} size="md" />
104
+ )}
105
+ {/* <KeyboardAccessoryNavigation
106
+ avoidKeyboard
107
+ doneButton={true}
108
+ nextButton={true}
109
+ previousButton={true}
110
+ /> */}
111
+
112
+ {this.props.children}
113
+ </Box>
114
+ {Boolean(this.props.footer) && (
115
+ <Box
116
+ alignSelf="center"
117
+ color={this.props.color || "lightGray"}
118
+ direction={this.props.direction || "column"}
119
+ display={this.props.display || "flex"}
120
+ flex="shrink"
121
+ marginBottom={8}
122
+ maxWidth={this.props.maxWidth || 800}
123
+ paddingX={this.props.padding !== undefined ? this.props.padding : 6}
124
+ paddingY={this.props.padding !== undefined ? this.props.padding : 2}
125
+ width="100%"
126
+ >
127
+ {this.props.footer}
128
+ </Box>
129
+ )}
130
+ </ErrorBoundary>
131
+ );
132
+ }
133
+ }
@@ -0,0 +1,44 @@
1
+ /* eslint-disable unused-imports/no-unused-vars */
2
+ // import {Tracking} from "./Tracking";
3
+ // import capitalize from "lodash/capitalize";
4
+ // import Permissions from "react-native-permissions";
5
+ import {PermissionKind, PermissionStatus} from "./Common";
6
+
7
+ export async function requestPermissions(kind: PermissionKind): Promise<PermissionStatus> {
8
+ return new Promise(async (resolve, reject) => {
9
+ return "denied";
10
+ });
11
+ // const userPropertyKey = `PermissionsFor${capitalize(kind)}`;
12
+
13
+ // let k = kind;
14
+ // let options: any = undefined;
15
+ // if (kind === "locationAlways") {
16
+ // k = "location";
17
+ // options = { type: "always" };
18
+ // }
19
+ // if (Platform.OS === "android" && k === "notification") {
20
+ // return;
21
+ // }
22
+
23
+ // // TODO check soft request status.
24
+
25
+ // const current = await Permissions.check(MAP[k] as any);
26
+ // // Tracking.log(`[permissions] ${k} permissions are ${current}`);
27
+ // if (current === "denied" || current === "limited") {
28
+ // // Tracking.setUserProperty(userPropertyKey, "false");
29
+ // return reject(MAP_RESULTS[current]);
30
+ // } else if (current === "granted") {
31
+ // // Tracking.setUserProperty(userPropertyKey, "true");
32
+ // return resolve("authorized");
33
+ // }
34
+
35
+ // const response = await Permissions.request(MAP[k] as any, options);
36
+ // if (response === "granted") {
37
+ // // Tracking.setUserProperty(userPropertyKey, "true");
38
+ // return resolve("authorized");
39
+ // } else {
40
+ // // Tracking.setUserProperty(userPropertyKey, "false");
41
+ // return reject(MAP_RESULTS[response]);
42
+ // }
43
+ // });
44
+ }