@cdx-ui/components 0.0.1-beta.184 → 0.0.1-beta.186
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/coverage.svg +1 -1
- package/lib/commonjs/components/Chip/styles.js +1 -1
- package/lib/commonjs/components/Chip/styles.js.map +1 -1
- package/lib/commonjs/components/Table/index.js +389 -0
- package/lib/commonjs/components/Table/index.js.map +1 -0
- package/lib/commonjs/components/Table/index.web.js +329 -0
- package/lib/commonjs/components/Table/index.web.js.map +1 -0
- package/lib/commonjs/components/Table/styles.js +111 -0
- package/lib/commonjs/components/Table/styles.js.map +1 -0
- package/lib/commonjs/components/Table/types.js +6 -0
- package/lib/commonjs/components/Table/types.js.map +1 -0
- package/lib/commonjs/components/Table/useTableStyleContext.js +28 -0
- package/lib/commonjs/components/Table/useTableStyleContext.js.map +1 -0
- package/lib/commonjs/components/TablePagination/TablePaginationContext.js +31 -0
- package/lib/commonjs/components/TablePagination/TablePaginationContext.js.map +1 -0
- package/lib/commonjs/components/TablePagination/getTablePaginationItems.js +50 -0
- package/lib/commonjs/components/TablePagination/getTablePaginationItems.js.map +1 -0
- package/lib/commonjs/components/TablePagination/index.js +395 -0
- package/lib/commonjs/components/TablePagination/index.js.map +1 -0
- package/lib/commonjs/components/TablePagination/styles.js +13 -0
- package/lib/commonjs/components/TablePagination/styles.js.map +1 -0
- package/lib/commonjs/components/index.js +24 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/styles.css +1 -0
- package/lib/module/components/Chip/styles.js +1 -1
- package/lib/module/components/Chip/styles.js.map +1 -1
- package/lib/module/components/Table/index.js +385 -0
- package/lib/module/components/Table/index.js.map +1 -0
- package/lib/module/components/Table/index.web.js +325 -0
- package/lib/module/components/Table/index.web.js.map +1 -0
- package/lib/module/components/Table/styles.js +107 -0
- package/lib/module/components/Table/styles.js.map +1 -0
- package/lib/module/components/Table/types.js +4 -0
- package/lib/module/components/Table/types.js.map +1 -0
- package/lib/module/components/Table/useTableStyleContext.js +17 -0
- package/lib/module/components/Table/useTableStyleContext.js.map +1 -0
- package/lib/module/components/TablePagination/TablePaginationContext.js +25 -0
- package/lib/module/components/TablePagination/TablePaginationContext.js.map +1 -0
- package/lib/module/components/TablePagination/getTablePaginationItems.js +46 -0
- package/lib/module/components/TablePagination/getTablePaginationItems.js.map +1 -0
- package/lib/module/components/TablePagination/index.js +386 -0
- package/lib/module/components/TablePagination/index.js.map +1 -0
- package/lib/module/components/TablePagination/styles.js +9 -0
- package/lib/module/components/TablePagination/styles.js.map +1 -0
- package/lib/module/components/index.js +2 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/styles.css +1 -0
- package/lib/typescript/components/Table/index.d.ts +23 -0
- package/lib/typescript/components/Table/index.d.ts.map +1 -0
- package/lib/typescript/components/Table/index.web.d.ts +22 -0
- package/lib/typescript/components/Table/index.web.d.ts.map +1 -0
- package/lib/typescript/components/Table/styles.d.ts +36 -0
- package/lib/typescript/components/Table/styles.d.ts.map +1 -0
- package/lib/typescript/components/Table/types.d.ts +51 -0
- package/lib/typescript/components/Table/types.d.ts.map +1 -0
- package/lib/typescript/components/Table/useTableStyleContext.d.ts +11 -0
- package/lib/typescript/components/Table/useTableStyleContext.d.ts.map +1 -0
- package/lib/typescript/components/TablePagination/TablePaginationContext.d.ts +20 -0
- package/lib/typescript/components/TablePagination/TablePaginationContext.d.ts.map +1 -0
- package/lib/typescript/components/TablePagination/getTablePaginationItems.d.ts +7 -0
- package/lib/typescript/components/TablePagination/getTablePaginationItems.d.ts.map +1 -0
- package/lib/typescript/components/TablePagination/index.d.ts +74 -0
- package/lib/typescript/components/TablePagination/index.d.ts.map +1 -0
- package/lib/typescript/components/TablePagination/styles.d.ts +8 -0
- package/lib/typescript/components/TablePagination/styles.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +2 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/components/Chip/styles.ts +1 -1
- package/src/components/Table/index.tsx +459 -0
- package/src/components/Table/index.web.tsx +395 -0
- package/src/components/Table/styles.ts +143 -0
- package/src/components/Table/types.ts +57 -0
- package/src/components/Table/useTableStyleContext.ts +14 -0
- package/src/components/TablePagination/TablePaginationContext.tsx +37 -0
- package/src/components/TablePagination/getTablePaginationItems.ts +62 -0
- package/src/components/TablePagination/index.tsx +498 -0
- package/src/components/TablePagination/styles.ts +15 -0
- package/src/components/index.ts +2 -0
- package/src/styles.css +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface TablePaginationContextValue {
|
|
3
|
+
page: number;
|
|
4
|
+
count: number;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
goToPage: (page: number) => void;
|
|
7
|
+
pageSize?: number;
|
|
8
|
+
pageSizeOptions: readonly (number | {
|
|
9
|
+
value: number;
|
|
10
|
+
label: string;
|
|
11
|
+
})[];
|
|
12
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function TablePaginationProvider({ value, children, }: {
|
|
15
|
+
value: TablePaginationContextValue;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function useTablePaginationContext(): TablePaginationContextValue | null;
|
|
19
|
+
export declare function useRequiredTablePaginationContext(): TablePaginationContextValue;
|
|
20
|
+
//# sourceMappingURL=TablePaginationContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TablePaginationContext.d.ts","sourceRoot":"","sources":["../../../../src/components/TablePagination/TablePaginationContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,SAAS,CAAC,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IACxE,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C;AAID,wBAAgB,uBAAuB,CAAC,EACtC,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,2BAA2B,CAAC;IACnC,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAIA;AAED,wBAAgB,yBAAyB,IAAI,2BAA2B,GAAG,IAAI,CAE9E;AAED,wBAAgB,iCAAiC,IAAI,2BAA2B,CAM/E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type TablePaginationItemToken = number | 'ellipsis';
|
|
2
|
+
/**
|
|
3
|
+
* Compact pager window: first, last, current ± siblings, with ellipses in the gaps.
|
|
4
|
+
* Matches the common MUI / HeroUI compact algorithm (`siblingCount` default 1).
|
|
5
|
+
*/
|
|
6
|
+
export declare function getTablePaginationItems(page: number, count: number, siblingCount?: number): TablePaginationItemToken[];
|
|
7
|
+
//# sourceMappingURL=getTablePaginationItems.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTablePaginationItems.d.ts","sourceRoot":"","sources":["../../../../src/components/TablePagination/getTablePaginationItems.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,UAAU,CAAC;AAS3D;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,YAAY,SAAI,GACf,wBAAwB,EAAE,CA4C5B"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { View, type PressableProps, type ViewProps } from 'react-native';
|
|
3
|
+
export { getTablePaginationItems } from './getTablePaginationItems';
|
|
4
|
+
export type { TablePaginationItemToken } from './getTablePaginationItems';
|
|
5
|
+
export type TablePaginationPageSizeOption = number | {
|
|
6
|
+
value: number;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
export interface TablePaginationProps extends ViewProps {
|
|
10
|
+
asChild?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
/** 1-based current page. Controlled when set. */
|
|
14
|
+
page?: number;
|
|
15
|
+
defaultPage?: number;
|
|
16
|
+
/** Total page count. When set with no children, items are generated. */
|
|
17
|
+
count?: number;
|
|
18
|
+
onPageChange?: (page: number) => void;
|
|
19
|
+
siblingCount?: number;
|
|
20
|
+
pageSize?: number;
|
|
21
|
+
pageSizeOptions?: readonly TablePaginationPageSizeOption[];
|
|
22
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
'aria-label'?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TablePaginationItemProps extends ViewProps {
|
|
27
|
+
asChild?: boolean;
|
|
28
|
+
className?: string;
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
page?: number;
|
|
31
|
+
current?: boolean;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
onPress?: PressableProps['onPress'];
|
|
34
|
+
}
|
|
35
|
+
export interface TablePaginationControlProps extends ViewProps {
|
|
36
|
+
asChild?: boolean;
|
|
37
|
+
className?: string;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
onPress?: PressableProps['onPress'];
|
|
41
|
+
}
|
|
42
|
+
export interface TablePaginationEllipsisProps extends ViewProps {
|
|
43
|
+
asChild?: boolean;
|
|
44
|
+
className?: string;
|
|
45
|
+
children?: ReactNode;
|
|
46
|
+
}
|
|
47
|
+
export interface TablePaginationStatusProps extends ViewProps {
|
|
48
|
+
asChild?: boolean;
|
|
49
|
+
className?: string;
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
export interface TablePaginationPageSizeProps extends ViewProps {
|
|
53
|
+
asChild?: boolean;
|
|
54
|
+
className?: string;
|
|
55
|
+
children?: ReactNode;
|
|
56
|
+
'aria-label'?: string;
|
|
57
|
+
}
|
|
58
|
+
declare const TablePaginationRoot: import("react").ForwardRefExoticComponent<TablePaginationProps & import("react").RefAttributes<View>>;
|
|
59
|
+
declare const TablePaginationItem: import("react").ForwardRefExoticComponent<TablePaginationItemProps & import("react").RefAttributes<View>>;
|
|
60
|
+
declare const TablePaginationPrevious: import("react").ForwardRefExoticComponent<TablePaginationControlProps & import("react").RefAttributes<View>>;
|
|
61
|
+
declare const TablePaginationNext: import("react").ForwardRefExoticComponent<TablePaginationControlProps & import("react").RefAttributes<View>>;
|
|
62
|
+
declare const TablePaginationEllipsis: import("react").ForwardRefExoticComponent<TablePaginationEllipsisProps & import("react").RefAttributes<View>>;
|
|
63
|
+
declare const TablePaginationStatus: import("react").ForwardRefExoticComponent<TablePaginationStatusProps & import("react").RefAttributes<View>>;
|
|
64
|
+
declare const TablePaginationPageSize: import("react").ForwardRefExoticComponent<TablePaginationPageSizeProps & import("react").RefAttributes<View>>;
|
|
65
|
+
type TablePaginationCompoundComponent = typeof TablePaginationRoot & {
|
|
66
|
+
Previous: typeof TablePaginationPrevious;
|
|
67
|
+
Next: typeof TablePaginationNext;
|
|
68
|
+
Item: typeof TablePaginationItem;
|
|
69
|
+
Ellipsis: typeof TablePaginationEllipsis;
|
|
70
|
+
Status: typeof TablePaginationStatus;
|
|
71
|
+
PageSize: typeof TablePaginationPageSize;
|
|
72
|
+
};
|
|
73
|
+
export declare const TablePagination: TablePaginationCompoundComponent;
|
|
74
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/TablePagination/index.tsx"],"names":[],"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OAAO,mBAAmB,CAAC;IACjC,IAAI,EAAE,OAAO,mBAAmB,CAAC;IACjC,QAAQ,EAAE,OAAO,uBAAuB,CAAC;IACzC,MAAM,EAAE,OAAO,qBAAqB,CAAC;IACrC,QAAQ,EAAE,OAAO,uBAAuB,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,eAAe,EAOtB,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type VariantProps } from '@cdx-ui/utils';
|
|
2
|
+
export declare const tablePaginationRootVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
|
+
export declare const tablePaginationItemVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
4
|
+
export declare const tablePaginationEllipsisVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
5
|
+
export declare const tablePaginationStatusVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
6
|
+
export declare const tablePaginationPageSizeVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
7
|
+
export type TablePaginationVariantProps = VariantProps<typeof tablePaginationRootVariants>;
|
|
8
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/TablePagination/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAEvD,eAAO,MAAM,2BAA2B,oFAA+C,CAAC;AAExF,eAAO,MAAM,2BAA2B,oFAA0B,CAAC;AAEnE,eAAO,MAAM,+BAA+B,oFAE3C,CAAC;AAEF,eAAO,MAAM,6BAA6B,oFAAsD,CAAC;AAEjG,eAAO,MAAM,+BAA+B,oFAAuB,CAAC;AAEpE,MAAM,MAAM,2BAA2B,GAAG,YAAY,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -29,6 +29,7 @@ export * from './Image';
|
|
|
29
29
|
export * from './InsuranceDisclosure';
|
|
30
30
|
export * from './Input';
|
|
31
31
|
export * from './OtpInput';
|
|
32
|
+
export * from './TablePagination';
|
|
32
33
|
export * from './Link';
|
|
33
34
|
export * from './ListItem';
|
|
34
35
|
export * from './Accordion';
|
|
@@ -45,6 +46,7 @@ export * from './Slider';
|
|
|
45
46
|
export * from './VirtualizedList';
|
|
46
47
|
export * from './Switch';
|
|
47
48
|
export * from './Tabs';
|
|
49
|
+
export * from './Table';
|
|
48
50
|
export * from './Textarea';
|
|
49
51
|
export * from './Tile';
|
|
50
52
|
export * from './Toast';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AAC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ta.186",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
"@marceloterreiro/flash-calendar": "2.0.0",
|
|
82
82
|
"react-native-reanimated-carousel": "5.0.0-beta.5",
|
|
83
83
|
"uniwind": "1.10.0",
|
|
84
|
-
"@cdx-ui/formatters": "0.0.1-beta.
|
|
85
|
-
"@cdx-ui/
|
|
86
|
-
"@cdx-ui/
|
|
87
|
-
"@cdx-ui/
|
|
84
|
+
"@cdx-ui/formatters": "0.0.1-beta.186",
|
|
85
|
+
"@cdx-ui/utils": "0.0.1-beta.186",
|
|
86
|
+
"@cdx-ui/icons": "0.0.1-beta.186",
|
|
87
|
+
"@cdx-ui/primitives": "0.0.1-beta.186"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@react-navigation/bottom-tabs": "*",
|
|
@@ -16,7 +16,7 @@ const chipInteractiveRoot = [
|
|
|
16
16
|
];
|
|
17
17
|
|
|
18
18
|
export const chipRootVariants = cva(
|
|
19
|
-
['flex-row items-center justify-center
|
|
19
|
+
['flex-row items-center justify-center overflow-hidden web:inline-flex', ...chipInteractiveRoot],
|
|
20
20
|
{
|
|
21
21
|
variants: {
|
|
22
22
|
variant: {
|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
createContext,
|
|
4
|
+
forwardRef,
|
|
5
|
+
isValidElement,
|
|
6
|
+
useCallback,
|
|
7
|
+
useContext,
|
|
8
|
+
useId,
|
|
9
|
+
useLayoutEffect,
|
|
10
|
+
useMemo,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
type ReactElement,
|
|
14
|
+
type ReactNode,
|
|
15
|
+
} from 'react';
|
|
16
|
+
import { ScrollView, Text, View, type LayoutChangeEvent } from 'react-native';
|
|
17
|
+
import { Slot, dataAttributes, mergeDataAttributes } from '@cdx-ui/primitives';
|
|
18
|
+
import { cn } from '@cdx-ui/utils';
|
|
19
|
+
import {
|
|
20
|
+
tableNativeCaptionVariants,
|
|
21
|
+
tableContainerVariants,
|
|
22
|
+
tableNativeCellVariants,
|
|
23
|
+
tableNativeCellTextVariants,
|
|
24
|
+
tableNativeFooterVariants,
|
|
25
|
+
tableNativeHeadVariants,
|
|
26
|
+
tableNativeHeadTextVariants,
|
|
27
|
+
tableNativeRootVariants,
|
|
28
|
+
tableNativeRowVariants,
|
|
29
|
+
} from './styles';
|
|
30
|
+
import type {
|
|
31
|
+
TableCaptionProps,
|
|
32
|
+
TableCellProps,
|
|
33
|
+
TableHeadProps,
|
|
34
|
+
TableProps,
|
|
35
|
+
TableRowProps,
|
|
36
|
+
TableSectionProps,
|
|
37
|
+
} from './types';
|
|
38
|
+
import {
|
|
39
|
+
ParentContext,
|
|
40
|
+
useTableStyleContext,
|
|
41
|
+
useTableVariantContext,
|
|
42
|
+
} from './useTableStyleContext';
|
|
43
|
+
|
|
44
|
+
export type {
|
|
45
|
+
TableAlignment,
|
|
46
|
+
TableCaptionProps,
|
|
47
|
+
TableCellProps,
|
|
48
|
+
TableHeadProps,
|
|
49
|
+
TableProps,
|
|
50
|
+
TableRowProps,
|
|
51
|
+
TableSectionProps,
|
|
52
|
+
} from './types';
|
|
53
|
+
export type { TableVariantProps } from './styles';
|
|
54
|
+
|
|
55
|
+
const NATIVE_COL_MIN_WIDTH = 96;
|
|
56
|
+
|
|
57
|
+
interface TableLayoutValue {
|
|
58
|
+
tableWidth: number;
|
|
59
|
+
columnCount: number;
|
|
60
|
+
registerRowColumnCount: (rowId: string, count: number) => void;
|
|
61
|
+
unregisterRowColumnCount: (rowId: string) => void;
|
|
62
|
+
setViewportWidth: (width: number) => void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const TableLayoutContext = createContext<TableLayoutValue>({
|
|
66
|
+
tableWidth: 0,
|
|
67
|
+
columnCount: 0,
|
|
68
|
+
registerRowColumnCount: () => {},
|
|
69
|
+
unregisterRowColumnCount: () => {},
|
|
70
|
+
setViewportWidth: () => {},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const useTableLayout = () => useContext(TableLayoutContext);
|
|
74
|
+
|
|
75
|
+
const nativeColumnStyle = (span: number, tableWidth: number, columnCount: number) => {
|
|
76
|
+
if (tableWidth <= 0 || columnCount <= 0) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
width: (span / columnCount) * tableWidth,
|
|
82
|
+
flexGrow: 0,
|
|
83
|
+
flexShrink: 0,
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const isTableColumnChild = (child: ReactNode): child is ReactElement<{ colSpan?: number }> =>
|
|
88
|
+
isValidElement(child) &&
|
|
89
|
+
['Table.Head', 'Table.Cell'].includes((child.type as { displayName?: string }).displayName ?? '');
|
|
90
|
+
|
|
91
|
+
const countRowColumns = (children: ReactNode): number =>
|
|
92
|
+
Children.toArray(children).reduce<number>((total, child) => {
|
|
93
|
+
if (!isTableColumnChild(child)) {
|
|
94
|
+
return total;
|
|
95
|
+
}
|
|
96
|
+
const span = child.props.colSpan;
|
|
97
|
+
return total + (span && span > 1 ? span : 1);
|
|
98
|
+
}, 0);
|
|
99
|
+
|
|
100
|
+
const columnSpan = (colSpan?: number) => (colSpan && colSpan > 1 ? colSpan : 1);
|
|
101
|
+
|
|
102
|
+
const isCaptionChild = (child: ReactNode): child is ReactElement =>
|
|
103
|
+
isValidElement(child) && (child.type as { displayName?: string }).displayName === 'Table.Caption';
|
|
104
|
+
|
|
105
|
+
const isTextChild = (child: ReactNode): child is string | number =>
|
|
106
|
+
typeof child === 'string' || typeof child === 'number';
|
|
107
|
+
|
|
108
|
+
const renderNativeTableTextContent = (children: ReactNode, textClassName: string): ReactNode => {
|
|
109
|
+
if (isTextChild(children)) {
|
|
110
|
+
return (
|
|
111
|
+
<Text numberOfLines={1} ellipsizeMode="tail" className={textClassName}>
|
|
112
|
+
{children}
|
|
113
|
+
</Text>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const childList = Children.toArray(children);
|
|
118
|
+
|
|
119
|
+
if (childList.length === 0) {
|
|
120
|
+
return children;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (childList.every(isTextChild)) {
|
|
124
|
+
return (
|
|
125
|
+
<Text numberOfLines={1} ellipsizeMode="tail" className={textClassName}>
|
|
126
|
+
{childList}
|
|
127
|
+
</Text>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (!childList.some(isTextChild)) {
|
|
132
|
+
return children;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return Children.map(children, (child, index) => {
|
|
136
|
+
if (!isTextChild(child)) {
|
|
137
|
+
return child;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<Text
|
|
142
|
+
key={`table-text-${index.toString()}`}
|
|
143
|
+
numberOfLines={1}
|
|
144
|
+
ellipsizeMode="tail"
|
|
145
|
+
className={textClassName}
|
|
146
|
+
>
|
|
147
|
+
{child}
|
|
148
|
+
</Text>
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const TableRoot = forwardRef<View, TableProps>(
|
|
154
|
+
({ asChild, className, containerStyle, children, style, fullBleed = false, ...props }, ref) => {
|
|
155
|
+
const ctx = useTableVariantContext(fullBleed);
|
|
156
|
+
const computedClassName = cn(tableContainerVariants(), className);
|
|
157
|
+
const [viewportWidth, setViewportWidth] = useState(0);
|
|
158
|
+
const [columnCount, setColumnCount] = useState(0);
|
|
159
|
+
const rowColumnCountsRef = useRef(new Map<string, number>());
|
|
160
|
+
const syncColumnCount = useCallback(() => {
|
|
161
|
+
let max = 0;
|
|
162
|
+
for (const count of rowColumnCountsRef.current.values()) {
|
|
163
|
+
if (count > max) {
|
|
164
|
+
max = count;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
setColumnCount((prev) => (prev === max ? prev : max));
|
|
168
|
+
}, []);
|
|
169
|
+
const registerRowColumnCount = useCallback(
|
|
170
|
+
(rowId: string, count: number) => {
|
|
171
|
+
rowColumnCountsRef.current.set(rowId, count);
|
|
172
|
+
syncColumnCount();
|
|
173
|
+
},
|
|
174
|
+
[syncColumnCount],
|
|
175
|
+
);
|
|
176
|
+
const unregisterRowColumnCount = useCallback(
|
|
177
|
+
(rowId: string) => {
|
|
178
|
+
if (rowColumnCountsRef.current.delete(rowId)) {
|
|
179
|
+
syncColumnCount();
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
[syncColumnCount],
|
|
183
|
+
);
|
|
184
|
+
const tableWidth = Math.max(viewportWidth, columnCount * NATIVE_COL_MIN_WIDTH);
|
|
185
|
+
const layout = useMemo(
|
|
186
|
+
() => ({
|
|
187
|
+
tableWidth,
|
|
188
|
+
columnCount,
|
|
189
|
+
registerRowColumnCount,
|
|
190
|
+
unregisterRowColumnCount,
|
|
191
|
+
setViewportWidth,
|
|
192
|
+
}),
|
|
193
|
+
[tableWidth, columnCount, registerRowColumnCount, unregisterRowColumnCount],
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const handleViewportLayout = (event: LayoutChangeEvent) => {
|
|
197
|
+
const nextWidth = event.nativeEvent.layout.width;
|
|
198
|
+
setViewportWidth((prev) => (prev === nextWidth ? prev : nextWidth));
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
if (asChild) {
|
|
202
|
+
const Comp = Slot;
|
|
203
|
+
return (
|
|
204
|
+
<ParentContext.Provider value={ctx}>
|
|
205
|
+
<TableLayoutContext.Provider value={layout}>
|
|
206
|
+
<Comp
|
|
207
|
+
ref={ref}
|
|
208
|
+
className={computedClassName}
|
|
209
|
+
style={style}
|
|
210
|
+
{...props}
|
|
211
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'table' }))}
|
|
212
|
+
>
|
|
213
|
+
{children}
|
|
214
|
+
</Comp>
|
|
215
|
+
</TableLayoutContext.Provider>
|
|
216
|
+
</ParentContext.Provider>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const childList = Children.toArray(children);
|
|
221
|
+
const captions = childList.filter(isCaptionChild);
|
|
222
|
+
const tableChildren = childList.filter((child) => !isCaptionChild(child));
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<ParentContext.Provider value={ctx}>
|
|
226
|
+
<TableLayoutContext.Provider value={layout}>
|
|
227
|
+
<ScrollView
|
|
228
|
+
horizontal
|
|
229
|
+
showsHorizontalScrollIndicator
|
|
230
|
+
className={computedClassName}
|
|
231
|
+
style={[containerStyle, style]}
|
|
232
|
+
onLayout={handleViewportLayout}
|
|
233
|
+
>
|
|
234
|
+
<View
|
|
235
|
+
ref={ref}
|
|
236
|
+
className={tableNativeRootVariants()}
|
|
237
|
+
style={tableWidth > 0 ? { width: tableWidth } : undefined}
|
|
238
|
+
accessibilityRole="none"
|
|
239
|
+
{...props}
|
|
240
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'table' }))}
|
|
241
|
+
>
|
|
242
|
+
{tableChildren}
|
|
243
|
+
{captions}
|
|
244
|
+
</View>
|
|
245
|
+
</ScrollView>
|
|
246
|
+
</TableLayoutContext.Provider>
|
|
247
|
+
</ParentContext.Provider>
|
|
248
|
+
);
|
|
249
|
+
},
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
TableRoot.displayName = 'Table';
|
|
253
|
+
|
|
254
|
+
const TableCaption = forwardRef<Text, TableCaptionProps>(
|
|
255
|
+
({ asChild, className, children, style, ...props }, ref) => {
|
|
256
|
+
const computedClassName = cn(tableNativeCaptionVariants(), className);
|
|
257
|
+
const Comp = asChild ? Slot : Text;
|
|
258
|
+
const { tableWidth } = useTableLayout();
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<Comp
|
|
262
|
+
ref={ref}
|
|
263
|
+
className={computedClassName}
|
|
264
|
+
style={[tableWidth > 0 ? { width: tableWidth } : null, style]}
|
|
265
|
+
accessibilityRole="text"
|
|
266
|
+
{...props}
|
|
267
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'table-caption' }))}
|
|
268
|
+
>
|
|
269
|
+
{children}
|
|
270
|
+
</Comp>
|
|
271
|
+
);
|
|
272
|
+
},
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
TableCaption.displayName = 'Table.Caption';
|
|
276
|
+
|
|
277
|
+
const TableHeader = forwardRef<View, TableSectionProps>(
|
|
278
|
+
({ asChild, className, children, style, ...props }, ref) => {
|
|
279
|
+
const Comp = asChild ? Slot : View;
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<Comp
|
|
283
|
+
ref={ref}
|
|
284
|
+
className={className}
|
|
285
|
+
style={style}
|
|
286
|
+
accessibilityRole="header"
|
|
287
|
+
{...props}
|
|
288
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'table-header' }))}
|
|
289
|
+
>
|
|
290
|
+
{children}
|
|
291
|
+
</Comp>
|
|
292
|
+
);
|
|
293
|
+
},
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
TableHeader.displayName = 'Table.Header';
|
|
297
|
+
|
|
298
|
+
const TableBody = forwardRef<View, TableSectionProps>(
|
|
299
|
+
({ asChild, className, children, style, ...props }, ref) => {
|
|
300
|
+
const Comp = asChild ? Slot : View;
|
|
301
|
+
|
|
302
|
+
return (
|
|
303
|
+
<Comp
|
|
304
|
+
ref={ref}
|
|
305
|
+
className={className}
|
|
306
|
+
style={style}
|
|
307
|
+
{...props}
|
|
308
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'table-body' }))}
|
|
309
|
+
>
|
|
310
|
+
{children}
|
|
311
|
+
</Comp>
|
|
312
|
+
);
|
|
313
|
+
},
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
TableBody.displayName = 'Table.Body';
|
|
317
|
+
|
|
318
|
+
const TableFooter = forwardRef<View, TableSectionProps>(
|
|
319
|
+
({ asChild, className, children, style, ...props }, ref) => {
|
|
320
|
+
const computedClassName = cn(tableNativeFooterVariants(), className);
|
|
321
|
+
const Comp = asChild ? Slot : View;
|
|
322
|
+
|
|
323
|
+
return (
|
|
324
|
+
<Comp
|
|
325
|
+
ref={ref}
|
|
326
|
+
className={computedClassName}
|
|
327
|
+
style={style}
|
|
328
|
+
accessibilityRole="summary"
|
|
329
|
+
{...props}
|
|
330
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'table-footer' }))}
|
|
331
|
+
>
|
|
332
|
+
{children}
|
|
333
|
+
</Comp>
|
|
334
|
+
);
|
|
335
|
+
},
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
TableFooter.displayName = 'Table.Footer';
|
|
339
|
+
|
|
340
|
+
const TableRow = forwardRef<View, TableRowProps>(
|
|
341
|
+
({ asChild, className, children, style, ...props }, ref) => {
|
|
342
|
+
const computedClassName = cn(tableNativeRowVariants(), className);
|
|
343
|
+
const Comp = asChild ? Slot : View;
|
|
344
|
+
const rowId = useId();
|
|
345
|
+
const { tableWidth, registerRowColumnCount, unregisterRowColumnCount } = useTableLayout();
|
|
346
|
+
const columnCount = countRowColumns(children);
|
|
347
|
+
|
|
348
|
+
useLayoutEffect(() => {
|
|
349
|
+
if (columnCount > 0) {
|
|
350
|
+
registerRowColumnCount(rowId, columnCount);
|
|
351
|
+
} else {
|
|
352
|
+
unregisterRowColumnCount(rowId);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return () => {
|
|
356
|
+
unregisterRowColumnCount(rowId);
|
|
357
|
+
};
|
|
358
|
+
}, [rowId, columnCount, registerRowColumnCount, unregisterRowColumnCount]);
|
|
359
|
+
|
|
360
|
+
return (
|
|
361
|
+
<Comp
|
|
362
|
+
ref={ref}
|
|
363
|
+
className={computedClassName}
|
|
364
|
+
style={[tableWidth > 0 ? { width: tableWidth } : null, style]}
|
|
365
|
+
accessibilityRole="none"
|
|
366
|
+
{...props}
|
|
367
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'table-row' }))}
|
|
368
|
+
>
|
|
369
|
+
{children}
|
|
370
|
+
</Comp>
|
|
371
|
+
);
|
|
372
|
+
},
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
TableRow.displayName = 'Table.Row';
|
|
376
|
+
|
|
377
|
+
const TableHead = forwardRef<View, TableHeadProps>(
|
|
378
|
+
(
|
|
379
|
+
{
|
|
380
|
+
asChild,
|
|
381
|
+
align = 'start',
|
|
382
|
+
className,
|
|
383
|
+
children,
|
|
384
|
+
style,
|
|
385
|
+
colSpan,
|
|
386
|
+
rowSpan: _rowSpan,
|
|
387
|
+
scope: _scope,
|
|
388
|
+
...props
|
|
389
|
+
},
|
|
390
|
+
ref,
|
|
391
|
+
) => {
|
|
392
|
+
const { fullBleed } = useTableStyleContext();
|
|
393
|
+
const { tableWidth, columnCount } = useTableLayout();
|
|
394
|
+
const computedClassName = cn(tableNativeHeadVariants({ fullBleed, align }), className);
|
|
395
|
+
const Comp = asChild ? Slot : View;
|
|
396
|
+
|
|
397
|
+
return (
|
|
398
|
+
<Comp
|
|
399
|
+
ref={ref}
|
|
400
|
+
className={computedClassName}
|
|
401
|
+
style={[nativeColumnStyle(columnSpan(colSpan), tableWidth, columnCount), style]}
|
|
402
|
+
accessibilityRole="header"
|
|
403
|
+
{...props}
|
|
404
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'table-head' }))}
|
|
405
|
+
>
|
|
406
|
+
{renderNativeTableTextContent(children, tableNativeHeadTextVariants({ align }))}
|
|
407
|
+
</Comp>
|
|
408
|
+
);
|
|
409
|
+
},
|
|
410
|
+
);
|
|
411
|
+
|
|
412
|
+
TableHead.displayName = 'Table.Head';
|
|
413
|
+
|
|
414
|
+
const TableCell = forwardRef<View, TableCellProps>(
|
|
415
|
+
(
|
|
416
|
+
{ asChild, align = 'start', className, children, style, colSpan, rowSpan: _rowSpan, ...props },
|
|
417
|
+
ref,
|
|
418
|
+
) => {
|
|
419
|
+
const { fullBleed } = useTableStyleContext();
|
|
420
|
+
const { tableWidth, columnCount } = useTableLayout();
|
|
421
|
+
const computedClassName = cn(tableNativeCellVariants({ fullBleed, align }), className);
|
|
422
|
+
const Comp = asChild ? Slot : View;
|
|
423
|
+
|
|
424
|
+
return (
|
|
425
|
+
<Comp
|
|
426
|
+
ref={ref}
|
|
427
|
+
className={computedClassName}
|
|
428
|
+
style={[nativeColumnStyle(columnSpan(colSpan), tableWidth, columnCount), style]}
|
|
429
|
+
accessibilityRole="text"
|
|
430
|
+
{...props}
|
|
431
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'table-cell' }))}
|
|
432
|
+
>
|
|
433
|
+
{renderNativeTableTextContent(children, tableNativeCellTextVariants({ align }))}
|
|
434
|
+
</Comp>
|
|
435
|
+
);
|
|
436
|
+
},
|
|
437
|
+
);
|
|
438
|
+
|
|
439
|
+
TableCell.displayName = 'Table.Cell';
|
|
440
|
+
|
|
441
|
+
type TableCompoundComponent = typeof TableRoot & {
|
|
442
|
+
Caption: typeof TableCaption;
|
|
443
|
+
Header: typeof TableHeader;
|
|
444
|
+
Body: typeof TableBody;
|
|
445
|
+
Footer: typeof TableFooter;
|
|
446
|
+
Row: typeof TableRow;
|
|
447
|
+
Head: typeof TableHead;
|
|
448
|
+
Cell: typeof TableCell;
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
export const Table = Object.assign(TableRoot, {
|
|
452
|
+
Caption: TableCaption,
|
|
453
|
+
Header: TableHeader,
|
|
454
|
+
Body: TableBody,
|
|
455
|
+
Footer: TableFooter,
|
|
456
|
+
Row: TableRow,
|
|
457
|
+
Head: TableHead,
|
|
458
|
+
Cell: TableCell,
|
|
459
|
+
}) as TableCompoundComponent;
|