ferns-ui 0.32.3 → 0.34.0

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 (73) hide show
  1. package/dist/ActionSheet.d.ts +6 -6
  2. package/dist/ActionSheet.js +2 -2
  3. package/dist/ActionSheet.js.map +1 -1
  4. package/dist/Banner.d.ts +1 -1
  5. package/dist/BlurBox.d.ts +1 -1
  6. package/dist/BlurBox.native.d.ts +2 -2
  7. package/dist/Body.d.ts +2 -2
  8. package/dist/Box.d.ts +1 -1
  9. package/dist/Box.js +2 -2
  10. package/dist/Box.js.map +1 -1
  11. package/dist/Button.d.ts +1 -1
  12. package/dist/Button.js +2 -2
  13. package/dist/Button.js.map +1 -1
  14. package/dist/Card.d.ts +1 -1
  15. package/dist/Common.d.ts +3 -0
  16. package/dist/Common.js.map +1 -1
  17. package/dist/DateTimeActionSheet.d.ts +1 -1
  18. package/dist/DecimalRangeActionSheet.d.ts +1 -1
  19. package/dist/ErrorBoundary.d.ts +1 -1
  20. package/dist/ErrorPage.d.ts +1 -1
  21. package/dist/Field.d.ts +2 -2
  22. package/dist/FieldWithLabels.d.ts +2 -2
  23. package/dist/Form.d.ts +6 -6
  24. package/dist/HeaderButtons.d.ts +7 -7
  25. package/dist/Heading.d.ts +1 -1
  26. package/dist/HeightActionSheet.d.ts +1 -1
  27. package/dist/Hyperlink.d.ts +1 -1
  28. package/dist/IconButton.js +2 -2
  29. package/dist/IconButton.js.map +1 -1
  30. package/dist/Image.d.ts +1 -1
  31. package/dist/ImageBackground.d.ts +1 -1
  32. package/dist/Link.d.ts +1 -1
  33. package/dist/Meta.d.ts +1 -1
  34. package/dist/NumberPickerActionSheet.d.ts +1 -1
  35. package/dist/Page.d.ts +2 -2
  36. package/dist/PickerSelect.d.ts +4 -4
  37. package/dist/PickerSelect.js +5 -5
  38. package/dist/PickerSelect.js.map +1 -1
  39. package/dist/Pill.d.ts +1 -1
  40. package/dist/Pog.d.ts +2 -2
  41. package/dist/ProgressBar.d.ts +1 -1
  42. package/dist/SegmentedControl.d.ts +2 -2
  43. package/dist/SelectList.d.ts +2 -2
  44. package/dist/SideDrawer.d.ts +13 -0
  45. package/dist/SideDrawer.js +22 -0
  46. package/dist/SideDrawer.js.map +1 -0
  47. package/dist/SplitPage.d.ts +2 -2
  48. package/dist/SplitPage.js +1 -1
  49. package/dist/SplitPage.js.map +1 -1
  50. package/dist/SplitPage.native.d.ts +2 -2
  51. package/dist/Switch.d.ts +1 -1
  52. package/dist/Table.d.ts +2 -1
  53. package/dist/Table.js.map +1 -1
  54. package/dist/TextArea.d.ts +1 -1
  55. package/dist/TextFieldNumberActionSheet.d.ts +1 -1
  56. package/dist/Tooltip.d.ts +1 -1
  57. package/dist/Tooltip.js +12 -18
  58. package/dist/Tooltip.js.map +1 -1
  59. package/dist/index.d.ts +1 -0
  60. package/dist/index.js +1 -0
  61. package/dist/index.js.map +1 -1
  62. package/package.json +36 -30
  63. package/src/ActionSheet.tsx +2 -2
  64. package/src/Box.tsx +3 -3
  65. package/src/Button.tsx +3 -3
  66. package/src/Common.ts +3 -0
  67. package/src/IconButton.tsx +3 -3
  68. package/src/PickerSelect.tsx +8 -7
  69. package/src/SideDrawer.tsx +62 -0
  70. package/src/SplitPage.tsx +1 -1
  71. package/src/Table.tsx +4 -3
  72. package/src/Tooltip.tsx +16 -21
  73. package/src/index.tsx +1 -0
package/src/Button.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import debounce from "lodash/debounce";
2
2
  import React, {useState} from "react";
3
- import {ActivityIndicator, TouchableOpacity, View} from "react-native";
3
+ import {ActivityIndicator, Pressable, View} from "react-native";
4
4
 
5
5
  import {Box} from "./Box";
6
6
  import {ButtonColor, Color, IconName, IconPrefix, TooltipDirection, UnifiedTheme} from "./Common";
@@ -134,7 +134,7 @@ export function Button({
134
134
  const renderButton = () => {
135
135
  return (
136
136
  <View>
137
- <TouchableOpacity
137
+ <Pressable
138
138
  disabled={disabled || loading}
139
139
  style={{
140
140
  alignSelf: inline === true ? undefined : "stretch",
@@ -201,7 +201,7 @@ export function Button({
201
201
  <ActivityIndicator color={getTextColor(color as Color)} size="small" />
202
202
  </Box>
203
203
  )}
204
- </TouchableOpacity>
204
+ </Pressable>
205
205
  {Boolean(withConfirmation) && renderConfirmation()}
206
206
  </View>
207
207
  );
package/src/Common.ts CHANGED
@@ -1974,6 +1974,7 @@ export type DrawerDirection = "left" | "right" | "bottom" | "top";
1974
1974
 
1975
1975
  export interface ErrorBoundaryProps {
1976
1976
  onError?: (error: Error, stack: any) => void;
1977
+ children?: ReactNode;
1977
1978
  }
1978
1979
 
1979
1980
  export interface FaceBookButtonProps {
@@ -2140,6 +2141,7 @@ export interface MetaProps {
2140
2141
  itemType?: string;
2141
2142
  key?: string;
2142
2143
  property?: string;
2144
+ children?: ReactNode;
2143
2145
  }
2144
2146
 
2145
2147
  export interface ImageProps {
@@ -2195,6 +2197,7 @@ export interface BodyProps {
2195
2197
  padding?: UnsignedUpTo12;
2196
2198
  height?: number | string;
2197
2199
  avoidKeyboard?: boolean; // default true
2200
+ children?: ReactNode;
2198
2201
  }
2199
2202
 
2200
2203
  export interface ChatPaneProps {
@@ -1,5 +1,5 @@
1
1
  import React, {forwardRef, useState} from "react";
2
- import {Platform, TouchableOpacity} from "react-native";
2
+ import {Platform, Pressable} from "react-native";
3
3
 
4
4
  import {
5
5
  ButtonColor,
@@ -90,7 +90,7 @@ export const IconButton = forwardRef(
90
90
  function renderIconButton(): React.ReactElement {
91
91
  return (
92
92
  <>
93
- <TouchableOpacity
93
+ <Pressable
94
94
  ref={ref as any}
95
95
  hitSlop={{top: 10, left: 10, bottom: 10, right: 10}}
96
96
  style={{
@@ -117,7 +117,7 @@ export const IconButton = forwardRef(
117
117
  }}
118
118
  >
119
119
  <Icon color={iconColor} name={icon} prefix={prefix || "fas"} size={size} />
120
- </TouchableOpacity>
120
+ </Pressable>
121
121
  {Boolean(withConfirmation) && renderConfirmation()}
122
122
  </>
123
123
  );
@@ -30,6 +30,7 @@ import {
30
30
  Keyboard,
31
31
  Modal,
32
32
  Platform,
33
+ Pressable,
33
34
  StyleSheet,
34
35
  Text,
35
36
  TextInput,
@@ -191,7 +192,7 @@ export function RNPickerSelect({
191
192
  }, [items, placeholder]);
192
193
 
193
194
  const getSelectedItem = useCallback(
194
- (key, val) => {
195
+ (key: any, val: any) => {
195
196
  let idx = options.findIndex((item: any) => {
196
197
  if (item.key && key) {
197
198
  return isEqual(item.key, key);
@@ -326,7 +327,7 @@ export function RNPickerSelect({
326
327
  />
327
328
  </TouchableOpacity>
328
329
  </View>
329
- <TouchableOpacity
330
+ <Pressable
330
331
  hitSlop={{top: 4, right: 4, bottom: 4, left: 4}}
331
332
  testID="done_button"
332
333
  onPress={() => {
@@ -353,7 +354,7 @@ export function RNPickerSelect({
353
354
  {doneText}
354
355
  </Text>
355
356
  </View>
356
- </TouchableOpacity>
357
+ </Pressable>
357
358
  </View>
358
359
  );
359
360
  };
@@ -406,7 +407,7 @@ export function RNPickerSelect({
406
407
  const renderIOS = () => {
407
408
  return (
408
409
  <View style={[defaultStyles.viewContainer, style.viewContainer]}>
409
- <TouchableOpacity
410
+ <Pressable
410
411
  activeOpacity={1}
411
412
  style={{
412
413
  flexDirection: "row",
@@ -422,7 +423,7 @@ export function RNPickerSelect({
422
423
  {...touchableWrapperProps}
423
424
  >
424
425
  {renderTextInputOrChildren()}
425
- </TouchableOpacity>
426
+ </Pressable>
426
427
  <Modal
427
428
  animationType={animationType}
428
429
  supportedOrientations={["portrait", "landscape"]}
@@ -432,7 +433,7 @@ export function RNPickerSelect({
432
433
  onOrientationChange={onOrientationChange}
433
434
  {...modalProps}
434
435
  >
435
- <TouchableOpacity
436
+ <Pressable
436
437
  style={[defaultStyles.modalViewTop, style.modalViewTop]}
437
438
  testID="ios_modal_top"
438
439
  onPress={() => {
@@ -462,7 +463,7 @@ export function RNPickerSelect({
462
463
  };
463
464
 
464
465
  const renderAndroidHeadless = () => {
465
- const Component: any = fixAndroidTouchableBug ? View : TouchableOpacity;
466
+ const Component: any = fixAndroidTouchableBug ? View : Pressable;
466
467
  return (
467
468
  <Component
468
469
  activeOpacity={1}
@@ -0,0 +1,62 @@
1
+ import React, {ReactElement} from "react";
2
+ import {Platform, SafeAreaView, StyleProp, ViewStyle} from "react-native";
3
+ import {Drawer} from "react-native-drawer-layout";
4
+
5
+ import {isMobileDevice} from "./MediaQuery";
6
+
7
+ export interface SideDrawerProps {
8
+ // Position of the drawer relative to the child
9
+ position?: "right" | "left";
10
+ // Used to open/hide drawer. Use the onClose and onOpen props to control state
11
+ isOpen: boolean;
12
+ // Content within the drawer
13
+ renderContent: () => ReactElement | ReactElement[];
14
+ // TODO: Allow the hardware back button on Android to close the SideDrawer
15
+ onClose?: () => void;
16
+ onOpen?: () => void;
17
+ drawerType?: "front" | "back" | "slide" | "permanent";
18
+ // Content that is wrapped by the drawer. The drawer will use the height of the child it wraps. Can be overwritten via styles prop
19
+ children?: ReactElement;
20
+ drawerStyles?: StyleProp<ViewStyle>;
21
+ }
22
+
23
+ const DEFAULT_STYLES: StyleProp<ViewStyle> = {
24
+ width: Platform.OS === "web" ? "40%" : "95%",
25
+ backgroundColor: "lightgray",
26
+ borderWidth: 1,
27
+ borderColor: "gray",
28
+ overflow: isMobileDevice() ? undefined : "scroll",
29
+ };
30
+
31
+ export const SideDrawer = ({
32
+ position = "left",
33
+ isOpen,
34
+ renderContent,
35
+ onClose = () => {},
36
+ onOpen = () => {},
37
+ drawerType = "front",
38
+ children,
39
+ drawerStyles = {},
40
+ }: SideDrawerProps): ReactElement => {
41
+ const renderDrawerContent = (): ReactElement => {
42
+ return <SafeAreaView>{renderContent()}</SafeAreaView>;
43
+ };
44
+
45
+ return (
46
+ <Drawer
47
+ drawerPosition={position}
48
+ drawerStyle={[
49
+ DEFAULT_STYLES,
50
+ drawerStyles,
51
+ {display: Platform.OS === "web" && !isOpen ? "none" : "flex"},
52
+ ]}
53
+ drawerType={drawerType}
54
+ open={isOpen}
55
+ renderDrawerContent={renderDrawerContent}
56
+ onClose={onClose}
57
+ onOpen={onOpen}
58
+ >
59
+ {children}
60
+ </Drawer>
61
+ );
62
+ };
package/src/SplitPage.tsx CHANGED
@@ -256,7 +256,7 @@ export const SplitPage = ({
256
256
  style={{
257
257
  width: width - 8,
258
258
  padding: 4,
259
- height: elementArray.length > 1 ? "90vh" : "100vh",
259
+ height: elementArray.length > 1 ? "90%" : "100%",
260
260
  paddingBottom: bottomNavBarHeight,
261
261
  }}
262
262
  >
package/src/Table.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  import React, {Children, ReactElement} from "react";
2
+ import {DimensionValue} from "react-native/Libraries/StyleSheet/StyleSheetTypes";
2
3
 
3
4
  import {ScrollView} from "./ScrollView";
4
5
  import {ColumnSortInterface, TableContextProvider} from "./tableContext";
@@ -19,7 +20,7 @@ interface TableProps {
19
20
  /**
20
21
  * Use numbers for pixels: `maxHeight={100}` and strings for percentages: `maxHeight="100%"`.
21
22
  */
22
- maxHeight?: number | string;
23
+ maxHeight?: DimensionValue;
23
24
  /**
24
25
  * If true, the header will stick to the top of the table when scrolling. Defaults to true.
25
26
  */
@@ -47,11 +48,11 @@ export function Table({
47
48
  });
48
49
 
49
50
  // Calculate the total width of the table. If the table has only number widths, calculate a width. Otherwise use 100%.
50
- let width: string | number;
51
+ let width: DimensionValue;
51
52
  if (columns.every((column) => typeof column === "number")) {
52
53
  width = columns.reduce((acc, curr) => {
53
54
  return (acc as number) + (curr as number);
54
- }, 0);
55
+ }, 0) as number;
55
56
  if (hasDrawerContents) {
56
57
  width = (width as number) + 30;
57
58
  }
package/src/Tooltip.tsx CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
- import {forwardRef} from "react";
3
2
  import {
4
3
  Dimensions,
5
4
  LayoutChangeEvent,
@@ -124,8 +123,7 @@ interface TooltipProps {
124
123
  bgColor?: "white" | "lightGray" | "gray" | "darkGray";
125
124
  }
126
125
 
127
- // eslint-disable-next-line react/display-name
128
- export const Tooltip = forwardRef((props: TooltipProps, _ref: any) => {
126
+ export const Tooltip = (props: TooltipProps) => {
129
127
  const {text, children, bgColor, idealDirection} = props;
130
128
  const hoverDelay = 500;
131
129
  const hoverEndDelay = 1500;
@@ -180,7 +178,7 @@ export const Tooltip = forwardRef((props: TooltipProps, _ref: any) => {
180
178
  showTooltipTimer.current = setTimeout(() => {
181
179
  touched.current = true;
182
180
  setVisible(true);
183
- }, 100) as unknown as NodeJS.Timeout;
181
+ }, 100);
184
182
  };
185
183
 
186
184
  const handleHoverIn = () => {
@@ -191,7 +189,7 @@ export const Tooltip = forwardRef((props: TooltipProps, _ref: any) => {
191
189
  showTooltipTimer.current = setTimeout(() => {
192
190
  touched.current = true;
193
191
  setVisible(true);
194
- }, hoverDelay) as unknown as NodeJS.Timeout;
192
+ }, hoverDelay);
195
193
  };
196
194
 
197
195
  const handleHoverOut = () => {
@@ -203,7 +201,7 @@ export const Tooltip = forwardRef((props: TooltipProps, _ref: any) => {
203
201
  hideTooltipTimer.current = setTimeout(() => {
204
202
  setVisible(false);
205
203
  setMeasurement({children: {}, tooltip: {}, measured: false});
206
- }, hoverEndDelay) as unknown as NodeJS.Timeout;
204
+ }, hoverEndDelay);
207
205
  };
208
206
 
209
207
  const mobilePressProps = {
@@ -216,17 +214,6 @@ export const Tooltip = forwardRef((props: TooltipProps, _ref: any) => {
216
214
  }, [children.props]),
217
215
  };
218
216
 
219
- const webPressProps = {
220
- onHoverIn: () => {
221
- handleHoverIn();
222
- children.props.onHoverIn?.();
223
- },
224
- onHoverOut: () => {
225
- handleHoverOut();
226
- children.props.onHoverOut?.();
227
- },
228
- };
229
-
230
217
  return (
231
218
  <>
232
219
  {visible && (
@@ -255,13 +242,21 @@ export const Tooltip = forwardRef((props: TooltipProps, _ref: any) => {
255
242
  </Pressable>
256
243
  </Portal>
257
244
  )}
258
- <Pressable
245
+ <View
259
246
  ref={childrenWrapperRef}
247
+ onPointerEnter={() => {
248
+ handleHoverIn();
249
+ children.props.onHoverIn?.();
250
+ }}
251
+ onPointerLeave={() => {
252
+ handleHoverOut();
253
+ children.props.onHoverOut?.();
254
+ }}
260
255
  onTouchStart={handleTouchStart}
261
- {...(isWeb ? webPressProps : mobilePressProps)}
256
+ {...(!isWeb && mobilePressProps)}
262
257
  >
263
258
  {children}
264
- </Pressable>
259
+ </View>
265
260
  </>
266
261
  );
267
- });
262
+ };
package/src/index.tsx CHANGED
@@ -56,6 +56,7 @@ export * from "./NumberPickerActionSheet";
56
56
  export * from "./ModalSheet";
57
57
  export * from "./ProgressBar";
58
58
  export * from "./DateTimeField";
59
+ export * from "./SideDrawer";
59
60
  export * from "./Table";
60
61
  export * from "./TableHeader";
61
62
  export * from "./TableHeaderCell";