ferns-ui 0.36.4 → 0.37.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 (87) hide show
  1. package/dist/Banner.d.ts +6 -16
  2. package/dist/Banner.js +52 -43
  3. package/dist/Banner.js.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +1 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/useStoredState.d.ts +1 -0
  8. package/dist/useStoredState.js +33 -0
  9. package/dist/useStoredState.js.map +1 -0
  10. package/package.json +55 -56
  11. package/src/ActionSheet.tsx +1231 -0
  12. package/src/Avatar.tsx +317 -0
  13. package/src/Badge.tsx +65 -0
  14. package/src/Banner.tsx +149 -0
  15. package/src/BlurBox.native.tsx +40 -0
  16. package/src/BlurBox.tsx +31 -0
  17. package/src/Body.tsx +32 -0
  18. package/src/Box.tsx +308 -0
  19. package/src/Button.tsx +219 -0
  20. package/src/Card.tsx +23 -0
  21. package/src/CheckBox.tsx +118 -0
  22. package/src/Common.ts +2743 -0
  23. package/src/Constants.ts +53 -0
  24. package/src/CustomSelect.tsx +85 -0
  25. package/src/DateTimeActionSheet.tsx +409 -0
  26. package/src/DateTimeField.android.tsx +101 -0
  27. package/src/DateTimeField.ios.tsx +83 -0
  28. package/src/DateTimeField.tsx +69 -0
  29. package/src/DecimalRangeActionSheet.tsx +113 -0
  30. package/src/ErrorBoundary.tsx +37 -0
  31. package/src/ErrorPage.tsx +44 -0
  32. package/src/FernsProvider.tsx +21 -0
  33. package/src/Field.tsx +299 -0
  34. package/src/FieldWithLabels.tsx +36 -0
  35. package/src/FlatList.tsx +2 -0
  36. package/src/Form.tsx +182 -0
  37. package/src/HeaderButtons.tsx +107 -0
  38. package/src/Heading.tsx +53 -0
  39. package/src/HeightActionSheet.tsx +104 -0
  40. package/src/Hyperlink.tsx +181 -0
  41. package/src/Icon.tsx +24 -0
  42. package/src/IconButton.tsx +165 -0
  43. package/src/Image.tsx +50 -0
  44. package/src/ImageBackground.tsx +14 -0
  45. package/src/InfoTooltipButton.tsx +23 -0
  46. package/src/Layer.tsx +17 -0
  47. package/src/Link.tsx +17 -0
  48. package/src/Mask.tsx +21 -0
  49. package/src/MediaQuery.ts +46 -0
  50. package/src/Meta.tsx +9 -0
  51. package/src/Modal.tsx +248 -0
  52. package/src/ModalSheet.tsx +58 -0
  53. package/src/NumberPickerActionSheet.tsx +66 -0
  54. package/src/Page.tsx +133 -0
  55. package/src/Permissions.ts +44 -0
  56. package/src/PickerSelect.tsx +553 -0
  57. package/src/Pill.tsx +24 -0
  58. package/src/Pog.tsx +87 -0
  59. package/src/ProgressBar.tsx +55 -0
  60. package/src/ScrollView.tsx +2 -0
  61. package/src/SegmentedControl.tsx +102 -0
  62. package/src/SelectList.tsx +89 -0
  63. package/src/SideDrawer.tsx +62 -0
  64. package/src/Spinner.tsx +20 -0
  65. package/src/SplitPage.native.tsx +160 -0
  66. package/src/SplitPage.tsx +302 -0
  67. package/src/Switch.tsx +19 -0
  68. package/src/Table.tsx +87 -0
  69. package/src/TableHeader.tsx +36 -0
  70. package/src/TableHeaderCell.tsx +76 -0
  71. package/src/TableRow.tsx +87 -0
  72. package/src/TapToEdit.tsx +221 -0
  73. package/src/Text.tsx +131 -0
  74. package/src/TextArea.tsx +16 -0
  75. package/src/TextField.tsx +401 -0
  76. package/src/TextFieldNumberActionSheet.tsx +61 -0
  77. package/src/Toast.tsx +106 -0
  78. package/src/Tooltip.tsx +269 -0
  79. package/src/UnifiedScreens.ts +24 -0
  80. package/src/Unifier.ts +371 -0
  81. package/src/Utilities.tsx +159 -0
  82. package/src/WithLabel.tsx +57 -0
  83. package/src/dayjsExtended.ts +10 -0
  84. package/src/index.tsx +1347 -0
  85. package/src/polyfill.d.ts +11 -0
  86. package/src/tableContext.tsx +80 -0
  87. package/src/useStoredState.ts +39 -0
@@ -0,0 +1,11 @@
1
+ // export {}; // this file needs to be a module
2
+
3
+ // declare global {
4
+ // interface Array<T> {
5
+ // includes(searchElement: T): boolean;
6
+ // }
7
+
8
+ // interface Object {
9
+ // values<T>(obj: any): T[];
10
+ // }
11
+ // }
@@ -0,0 +1,80 @@
1
+ import React, {Context, createContext, useContext} from "react";
2
+
3
+ export interface ColumnSortInterface {
4
+ column: number | undefined;
5
+ direction: "asc" | "desc" | undefined;
6
+ }
7
+
8
+ interface TableContextType {
9
+ columns: Array<number | string>;
10
+ hasDrawerContents: boolean;
11
+ sortColumn?: ColumnSortInterface | undefined;
12
+ setSortColumn?: (sort: ColumnSortInterface | undefined) => void;
13
+ stickyHeader?: boolean;
14
+ borderStyle?: "sm" | "none";
15
+ alternateRowBackground?: boolean;
16
+ }
17
+
18
+ interface Props extends TableContextType {
19
+ children: React.ReactElement;
20
+ }
21
+
22
+ const TableContext: Context<TableContextType> = createContext<TableContextType>({
23
+ columns: [],
24
+ hasDrawerContents: false,
25
+ sortColumn: undefined,
26
+ setSortColumn: () => {},
27
+ stickyHeader: true,
28
+ borderStyle: "sm",
29
+ alternateRowBackground: true,
30
+ });
31
+
32
+ export const {Provider} = TableContext;
33
+
34
+ export function TableContextProvider({
35
+ children,
36
+ columns,
37
+ hasDrawerContents,
38
+ sortColumn,
39
+ setSortColumn,
40
+ stickyHeader,
41
+ borderStyle,
42
+ alternateRowBackground,
43
+ }: Props): React.ReactElement<typeof Provider> {
44
+ return (
45
+ <Provider
46
+ value={{
47
+ columns,
48
+ alternateRowBackground,
49
+ borderStyle,
50
+ hasDrawerContents,
51
+ sortColumn,
52
+ setSortColumn,
53
+ stickyHeader,
54
+ }}
55
+ >
56
+ {children}
57
+ </Provider>
58
+ );
59
+ }
60
+
61
+ export function useTableContext(): TableContextType {
62
+ const {
63
+ columns,
64
+ hasDrawerContents,
65
+ setSortColumn,
66
+ sortColumn,
67
+ stickyHeader,
68
+ alternateRowBackground,
69
+ borderStyle,
70
+ } = useContext(TableContext);
71
+ return {
72
+ columns,
73
+ hasDrawerContents,
74
+ setSortColumn,
75
+ sortColumn,
76
+ stickyHeader,
77
+ alternateRowBackground,
78
+ borderStyle,
79
+ };
80
+ }
@@ -0,0 +1,39 @@
1
+ import {useCallback, useEffect, useState} from "react";
2
+
3
+ import {Unifier} from "./Unifier";
4
+
5
+ export const useStoredState = <T>(
6
+ key: string,
7
+ initialValue?: T
8
+ ): [T | undefined | null, (value: T | undefined | null) => Promise<void>] => {
9
+ const [state, setState] = useState<T | undefined | null>(initialValue);
10
+
11
+ // Function to fetch data from AsyncStorage
12
+ const fetchData = useCallback(async (): Promise<T | undefined> => {
13
+ try {
14
+ return await Unifier.storage.getItem(key);
15
+ } catch (error) {
16
+ console.error("Error reading data from AsyncStorage:", error);
17
+ return initialValue;
18
+ }
19
+ }, [initialValue, key]);
20
+
21
+ // Fetch data when the component mounts
22
+ useEffect(() => {
23
+ fetchData().then((value) => {
24
+ setState(value);
25
+ });
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ }, []);
28
+
29
+ const setAsyncStorageState = async (newValue: T | undefined | null): Promise<void> => {
30
+ try {
31
+ await Unifier.storage.setItem(key, newValue);
32
+ setState(newValue);
33
+ } catch (error) {
34
+ console.error("Error writing data to AsyncStorage:", error);
35
+ }
36
+ };
37
+
38
+ return [state, setAsyncStorageState];
39
+ };