ferns-ui 1.2.2 → 1.2.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/Accordion.js +19 -23
- package/dist/Accordion.js.map +1 -1
- package/dist/Common.d.ts +79 -11
- package/dist/Common.js.map +1 -1
- package/dist/DataTable.d.ts +3 -0
- package/dist/DataTable.js +218 -0
- package/dist/DataTable.js.map +1 -0
- package/dist/InfoModalIcon.d.ts +3 -0
- package/dist/InfoModalIcon.js +12 -0
- package/dist/InfoModalIcon.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/Accordion.tsx +39 -58
- package/src/Common.ts +83 -13
- package/src/DataTable.tsx +662 -0
- package/src/InfoModalIcon.tsx +41 -0
- package/src/index.tsx +2 -0
package/src/Accordion.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {Pressable, View} from "react-native";
|
|
|
4
4
|
|
|
5
5
|
import {AccordionProps} from "./Common";
|
|
6
6
|
import {Heading} from "./Heading";
|
|
7
|
-
import {
|
|
7
|
+
import {InfoModalIcon} from "./InfoModalIcon";
|
|
8
8
|
import {Text} from "./Text";
|
|
9
9
|
import {useTheme} from "./Theme";
|
|
10
10
|
|
|
@@ -21,7 +21,6 @@ export const Accordion: FC<AccordionProps> = ({
|
|
|
21
21
|
}) => {
|
|
22
22
|
const {theme} = useTheme();
|
|
23
23
|
const [collapsed, setCollapsed] = useState(false);
|
|
24
|
-
const [infoModalVisibleState, setInfoModalVisibleState] = useState(false);
|
|
25
24
|
|
|
26
25
|
// The external collapse state should override the internal collapse state.
|
|
27
26
|
useEffect(() => {
|
|
@@ -29,65 +28,47 @@ export const Accordion: FC<AccordionProps> = ({
|
|
|
29
28
|
}, [isCollapsed]);
|
|
30
29
|
|
|
31
30
|
return (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
>
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
width: "100%",
|
|
53
|
-
}}
|
|
54
|
-
>
|
|
55
|
-
<View style={{flexDirection: "row", justifyContent: "space-between", alignItems: "center"}}>
|
|
56
|
-
<View style={{flexDirection: "column", gap: 4}}>
|
|
57
|
-
<View style={{flexDirection: "row", alignItems: "center"}}>
|
|
58
|
-
<Heading>{title}</Heading>
|
|
59
|
-
{includeInfoModal && infoModalTitle && (
|
|
60
|
-
<Pressable
|
|
61
|
-
aria-role="button"
|
|
62
|
-
hitSlop={{top: 10, bottom: 10, left: 10, right: 10}}
|
|
63
|
-
style={{marginLeft: 8}}
|
|
64
|
-
onPress={() => setInfoModalVisibleState(true)}
|
|
65
|
-
>
|
|
66
|
-
<Heading color="secondaryLight" size="sm">
|
|
67
|
-
ⓘ
|
|
68
|
-
</Heading>
|
|
69
|
-
</Pressable>
|
|
70
|
-
)}
|
|
71
|
-
</View>
|
|
72
|
-
{subtitle && <Text>{subtitle}</Text>}
|
|
73
|
-
</View>
|
|
74
|
-
<View>
|
|
75
|
-
<Pressable
|
|
76
|
-
aria-role="button"
|
|
77
|
-
hitSlop={{top: 20, bottom: 20, left: 20, right: 20}}
|
|
78
|
-
onPress={() => setCollapsed(!collapsed)}
|
|
79
|
-
>
|
|
80
|
-
<FontAwesome6
|
|
81
|
-
color={theme.text.link}
|
|
82
|
-
name={collapsed ? "chevron-down" : "chevron-up"}
|
|
83
|
-
selectable={undefined}
|
|
84
|
-
size={16}
|
|
31
|
+
<View
|
|
32
|
+
style={{
|
|
33
|
+
padding: 16,
|
|
34
|
+
borderBottomColor: theme.border.default,
|
|
35
|
+
borderTopColor: theme.border.default,
|
|
36
|
+
borderTopWidth: 2,
|
|
37
|
+
borderBottomWidth: 2,
|
|
38
|
+
width: "100%",
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<View style={{flexDirection: "row", justifyContent: "space-between", alignItems: "center"}}>
|
|
42
|
+
<View style={{flexDirection: "column", gap: 4}}>
|
|
43
|
+
<View style={{flexDirection: "row", alignItems: "center"}}>
|
|
44
|
+
<Heading>{title}</Heading>
|
|
45
|
+
{includeInfoModal && infoModalTitle && (
|
|
46
|
+
<InfoModalIcon
|
|
47
|
+
infoModalChildren={infoModalChildren}
|
|
48
|
+
infoModalSubtitle={infoModalSubtitle}
|
|
49
|
+
infoModalText={infoModalText}
|
|
50
|
+
infoModalTitle={infoModalTitle}
|
|
85
51
|
/>
|
|
86
|
-
|
|
52
|
+
)}
|
|
87
53
|
</View>
|
|
54
|
+
{subtitle && <Text>{subtitle}</Text>}
|
|
55
|
+
</View>
|
|
56
|
+
<View>
|
|
57
|
+
<Pressable
|
|
58
|
+
aria-role="button"
|
|
59
|
+
hitSlop={{top: 20, bottom: 20, left: 20, right: 20}}
|
|
60
|
+
onPress={() => setCollapsed(!collapsed)}
|
|
61
|
+
>
|
|
62
|
+
<FontAwesome6
|
|
63
|
+
color={theme.text.link}
|
|
64
|
+
name={collapsed ? "chevron-down" : "chevron-up"}
|
|
65
|
+
selectable={undefined}
|
|
66
|
+
size={16}
|
|
67
|
+
/>
|
|
68
|
+
</Pressable>
|
|
88
69
|
</View>
|
|
89
|
-
{collapsed ? null : <View style={{marginTop: 8}}>{children}</View>}
|
|
90
70
|
</View>
|
|
91
|
-
|
|
71
|
+
{collapsed ? null : <View style={{marginTop: 8}}>{children}</View>}
|
|
72
|
+
</View>
|
|
92
73
|
);
|
|
93
74
|
};
|
package/src/Common.ts
CHANGED
|
@@ -11,18 +11,7 @@ import {
|
|
|
11
11
|
FontAwesome6SolidNames,
|
|
12
12
|
} from "./CommonIconTypes";
|
|
13
13
|
|
|
14
|
-
export interface
|
|
15
|
-
/**
|
|
16
|
-
* The content to be displayed inside the accordion.
|
|
17
|
-
*/
|
|
18
|
-
children: React.ReactNode;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* If true, an information modal will be included.
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
includeInfoModal?: boolean;
|
|
25
|
-
|
|
14
|
+
export interface InfoModalIconProps {
|
|
26
15
|
/**
|
|
27
16
|
* The content of the information modal.
|
|
28
17
|
*/
|
|
@@ -42,6 +31,19 @@ export interface AccordionProps {
|
|
|
42
31
|
* The title of the information modal.
|
|
43
32
|
*/
|
|
44
33
|
infoModalTitle?: ModalProps["title"];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AccordionProps extends InfoModalIconProps {
|
|
37
|
+
/**
|
|
38
|
+
* The content to be displayed inside the accordion.
|
|
39
|
+
*/
|
|
40
|
+
children: React.ReactNode;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* If true, an information modal will be included.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
includeInfoModal?: boolean;
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
49
|
* If true, the accordion will be collapsed.
|
|
@@ -1916,6 +1918,69 @@ export interface PaginationProps {
|
|
|
1916
1918
|
totalPages: number;
|
|
1917
1919
|
}
|
|
1918
1920
|
|
|
1921
|
+
/**
|
|
1922
|
+
* Data Table
|
|
1923
|
+
*/
|
|
1924
|
+
export type DataTableCellData = {
|
|
1925
|
+
value: any;
|
|
1926
|
+
highlight?: SurfaceColor;
|
|
1927
|
+
textSize?: "sm" | "md" | "lg";
|
|
1928
|
+
};
|
|
1929
|
+
|
|
1930
|
+
export type DataTableCustomComponentMap = Record<
|
|
1931
|
+
string,
|
|
1932
|
+
React.ComponentType<{column: DataTableColumn; cellData: DataTableCellData}>
|
|
1933
|
+
>;
|
|
1934
|
+
export interface DataTableColumn {
|
|
1935
|
+
title: string;
|
|
1936
|
+
columnType: "text" | "number" | "date" | "boolean" | string;
|
|
1937
|
+
width: number;
|
|
1938
|
+
highlight?: SurfaceColor;
|
|
1939
|
+
sortable?: boolean;
|
|
1940
|
+
infoModalText?: string;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
export interface DataTableProps {
|
|
1944
|
+
data: {value: any; highlight?: SurfaceColor; textSize?: "sm" | "md" | "lg"}[][];
|
|
1945
|
+
columns: DataTableColumn[];
|
|
1946
|
+
alternateRowBackground?: boolean;
|
|
1947
|
+
totalPages?: number;
|
|
1948
|
+
page?: number;
|
|
1949
|
+
setPage?: (page: number) => void;
|
|
1950
|
+
pinnedColumns?: number;
|
|
1951
|
+
sortColumn?: ColumnSortInterface;
|
|
1952
|
+
setSortColumn?: (sortColumn?: ColumnSortInterface) => void;
|
|
1953
|
+
rowHeight?: number;
|
|
1954
|
+
defaultTextSize?: "sm" | "md" | "lg";
|
|
1955
|
+
/**
|
|
1956
|
+
* When tapping the eye icon, a modal is shown with more info about the row.
|
|
1957
|
+
*/
|
|
1958
|
+
moreContentComponent?: React.ComponentType<{
|
|
1959
|
+
column: DataTableColumn;
|
|
1960
|
+
rowData: any[];
|
|
1961
|
+
rowIndex: number;
|
|
1962
|
+
}>;
|
|
1963
|
+
// Extra data to pass to the more modal.
|
|
1964
|
+
moreContentExtraData?: any[];
|
|
1965
|
+
// Allows handling of custom column types.
|
|
1966
|
+
customColumnComponentMap?: DataTableCustomComponentMap;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
export interface DataTableCellProps {
|
|
1970
|
+
value: any;
|
|
1971
|
+
columnDef: DataTableColumn;
|
|
1972
|
+
colIndex: number;
|
|
1973
|
+
isPinnedHorizontal: boolean;
|
|
1974
|
+
isPinnedRow?: boolean;
|
|
1975
|
+
pinnedColumns: number;
|
|
1976
|
+
columnWidths: number[];
|
|
1977
|
+
backgroundColor: string;
|
|
1978
|
+
highlight?: SurfaceColor;
|
|
1979
|
+
customColumnComponentMap?: DataTableCustomComponentMap;
|
|
1980
|
+
height: number;
|
|
1981
|
+
textSize?: "sm" | "md" | "lg";
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1919
1984
|
export interface TableHeaderProps {
|
|
1920
1985
|
/**
|
|
1921
1986
|
* Must be an instance of TableRow.
|
|
@@ -1934,7 +1999,7 @@ export interface TableHeaderProps {
|
|
|
1934
1999
|
color?: BoxColor;
|
|
1935
2000
|
}
|
|
1936
2001
|
|
|
1937
|
-
export interface TableHeaderCellProps {
|
|
2002
|
+
export interface TableHeaderCellProps extends InfoModalIconProps {
|
|
1938
2003
|
/**
|
|
1939
2004
|
* The content of the table header cell.
|
|
1940
2005
|
*/
|
|
@@ -1953,6 +2018,11 @@ export interface TableHeaderCellProps {
|
|
|
1953
2018
|
* wrap the text yourself. Alignments will match between the cell and the title.
|
|
1954
2019
|
*/
|
|
1955
2020
|
title?: string;
|
|
2021
|
+
/**
|
|
2022
|
+
* If provided, a tooltip icon will be shown and a tooltip will be shown when hovering over the
|
|
2023
|
+
* icon.
|
|
2024
|
+
*/
|
|
2025
|
+
infoText?: string;
|
|
1956
2026
|
}
|
|
1957
2027
|
|
|
1958
2028
|
export interface TableRowProps {
|