@cdx-ui/components 0.0.1-beta.185 → 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 +19 -34
- package/lib/commonjs/components/Table/index.js.map +1 -1
- package/lib/commonjs/components/Table/index.web.js +40 -6
- package/lib/commonjs/components/Table/index.web.js.map +1 -1
- package/lib/commonjs/components/Table/styles.js +55 -7
- package/lib/commonjs/components/Table/styles.js.map +1 -1
- 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 +12 -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 +20 -35
- package/lib/module/components/Table/index.js.map +1 -1
- package/lib/module/components/Table/index.web.js +40 -6
- package/lib/module/components/Table/index.web.js.map +1 -1
- package/lib/module/components/Table/styles.js +54 -6
- package/lib/module/components/Table/styles.js.map +1 -1
- 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 +1 -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 +1 -1
- package/lib/typescript/components/Table/index.d.ts.map +1 -1
- package/lib/typescript/components/Table/index.web.d.ts +3 -3
- package/lib/typescript/components/Table/index.web.d.ts.map +1 -1
- package/lib/typescript/components/Table/styles.d.ts +11 -1
- package/lib/typescript/components/Table/styles.d.ts.map +1 -1
- package/lib/typescript/components/Table/types.d.ts +13 -1
- package/lib/typescript/components/Table/types.d.ts.map +1 -1
- 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 +1 -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 +28 -58
- package/src/components/Table/index.web.tsx +40 -12
- package/src/components/Table/styles.ts +56 -3
- package/src/components/Table/types.ts +14 -1
- 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 +1 -0
- package/src/styles.css +1 -0
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":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AQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/components",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.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: {
|
|
@@ -20,8 +20,10 @@ import {
|
|
|
20
20
|
tableNativeCaptionVariants,
|
|
21
21
|
tableContainerVariants,
|
|
22
22
|
tableNativeCellVariants,
|
|
23
|
+
tableNativeCellTextVariants,
|
|
23
24
|
tableNativeFooterVariants,
|
|
24
25
|
tableNativeHeadVariants,
|
|
26
|
+
tableNativeHeadTextVariants,
|
|
25
27
|
tableNativeRootVariants,
|
|
26
28
|
tableNativeRowVariants,
|
|
27
29
|
} from './styles';
|
|
@@ -40,6 +42,7 @@ import {
|
|
|
40
42
|
} from './useTableStyleContext';
|
|
41
43
|
|
|
42
44
|
export type {
|
|
45
|
+
TableAlignment,
|
|
43
46
|
TableCaptionProps,
|
|
44
47
|
TableCellProps,
|
|
45
48
|
TableHeadProps,
|
|
@@ -96,45 +99,9 @@ const countRowColumns = (children: ReactNode): number =>
|
|
|
96
99
|
|
|
97
100
|
const columnSpan = (colSpan?: number) => (colSpan && colSpan > 1 ? colSpan : 1);
|
|
98
101
|
|
|
99
|
-
const nativeCrossAxisAlign = (className?: string) => {
|
|
100
|
-
if (!className) {
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (/\btext-right\b/.test(className)) {
|
|
105
|
-
return 'items-end';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (/\btext-center\b/.test(className)) {
|
|
109
|
-
return 'items-center';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return undefined;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
102
|
const isCaptionChild = (child: ReactNode): child is ReactElement =>
|
|
116
103
|
isValidElement(child) && (child.type as { displayName?: string }).displayName === 'Table.Caption';
|
|
117
104
|
|
|
118
|
-
const nativeTextAlign = (className?: string) => {
|
|
119
|
-
if (!className) {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (/\btext-right\b/.test(className)) {
|
|
124
|
-
return 'text-right';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (/\btext-center\b/.test(className)) {
|
|
128
|
-
return 'text-center';
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (/\btext-left\b/.test(className)) {
|
|
132
|
-
return 'text-left';
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return undefined;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
105
|
const isTextChild = (child: ReactNode): child is string | number =>
|
|
139
106
|
typeof child === 'string' || typeof child === 'number';
|
|
140
107
|
|
|
@@ -161,6 +128,10 @@ const renderNativeTableTextContent = (children: ReactNode, textClassName: string
|
|
|
161
128
|
);
|
|
162
129
|
}
|
|
163
130
|
|
|
131
|
+
if (!childList.some(isTextChild)) {
|
|
132
|
+
return children;
|
|
133
|
+
}
|
|
134
|
+
|
|
164
135
|
return Children.map(children, (child, index) => {
|
|
165
136
|
if (!isTextChild(child)) {
|
|
166
137
|
return child;
|
|
@@ -180,7 +151,7 @@ const renderNativeTableTextContent = (children: ReactNode, textClassName: string
|
|
|
180
151
|
};
|
|
181
152
|
|
|
182
153
|
const TableRoot = forwardRef<View, TableProps>(
|
|
183
|
-
({ asChild, className, children, style, fullBleed = false, ...props }, ref) => {
|
|
154
|
+
({ asChild, className, containerStyle, children, style, fullBleed = false, ...props }, ref) => {
|
|
184
155
|
const ctx = useTableVariantContext(fullBleed);
|
|
185
156
|
const computedClassName = cn(tableContainerVariants(), className);
|
|
186
157
|
const [viewportWidth, setViewportWidth] = useState(0);
|
|
@@ -257,7 +228,7 @@ const TableRoot = forwardRef<View, TableProps>(
|
|
|
257
228
|
horizontal
|
|
258
229
|
showsHorizontalScrollIndicator
|
|
259
230
|
className={computedClassName}
|
|
260
|
-
style={style}
|
|
231
|
+
style={[containerStyle, style]}
|
|
261
232
|
onLayout={handleViewportLayout}
|
|
262
233
|
>
|
|
263
234
|
<View
|
|
@@ -405,16 +376,22 @@ TableRow.displayName = 'Table.Row';
|
|
|
405
376
|
|
|
406
377
|
const TableHead = forwardRef<View, TableHeadProps>(
|
|
407
378
|
(
|
|
408
|
-
{
|
|
379
|
+
{
|
|
380
|
+
asChild,
|
|
381
|
+
align = 'start',
|
|
382
|
+
className,
|
|
383
|
+
children,
|
|
384
|
+
style,
|
|
385
|
+
colSpan,
|
|
386
|
+
rowSpan: _rowSpan,
|
|
387
|
+
scope: _scope,
|
|
388
|
+
...props
|
|
389
|
+
},
|
|
409
390
|
ref,
|
|
410
391
|
) => {
|
|
411
392
|
const { fullBleed } = useTableStyleContext();
|
|
412
393
|
const { tableWidth, columnCount } = useTableLayout();
|
|
413
|
-
const computedClassName = cn(
|
|
414
|
-
tableNativeHeadVariants({ fullBleed }),
|
|
415
|
-
nativeCrossAxisAlign(className),
|
|
416
|
-
className,
|
|
417
|
-
);
|
|
394
|
+
const computedClassName = cn(tableNativeHeadVariants({ fullBleed, align }), className);
|
|
418
395
|
const Comp = asChild ? Slot : View;
|
|
419
396
|
|
|
420
397
|
return (
|
|
@@ -426,10 +403,7 @@ const TableHead = forwardRef<View, TableHeadProps>(
|
|
|
426
403
|
{...props}
|
|
427
404
|
{...mergeDataAttributes(props, dataAttributes({ slot: 'table-head' }))}
|
|
428
405
|
>
|
|
429
|
-
{renderNativeTableTextContent(
|
|
430
|
-
children,
|
|
431
|
-
cn('w-full font-medium text-content-secondary body-md', nativeTextAlign(className)),
|
|
432
|
-
)}
|
|
406
|
+
{renderNativeTableTextContent(children, tableNativeHeadTextVariants({ align }))}
|
|
433
407
|
</Comp>
|
|
434
408
|
);
|
|
435
409
|
},
|
|
@@ -438,14 +412,13 @@ const TableHead = forwardRef<View, TableHeadProps>(
|
|
|
438
412
|
TableHead.displayName = 'Table.Head';
|
|
439
413
|
|
|
440
414
|
const TableCell = forwardRef<View, TableCellProps>(
|
|
441
|
-
(
|
|
415
|
+
(
|
|
416
|
+
{ asChild, align = 'start', className, children, style, colSpan, rowSpan: _rowSpan, ...props },
|
|
417
|
+
ref,
|
|
418
|
+
) => {
|
|
442
419
|
const { fullBleed } = useTableStyleContext();
|
|
443
420
|
const { tableWidth, columnCount } = useTableLayout();
|
|
444
|
-
const computedClassName = cn(
|
|
445
|
-
tableNativeCellVariants({ fullBleed }),
|
|
446
|
-
nativeCrossAxisAlign(className),
|
|
447
|
-
className,
|
|
448
|
-
);
|
|
421
|
+
const computedClassName = cn(tableNativeCellVariants({ fullBleed, align }), className);
|
|
449
422
|
const Comp = asChild ? Slot : View;
|
|
450
423
|
|
|
451
424
|
return (
|
|
@@ -457,10 +430,7 @@ const TableCell = forwardRef<View, TableCellProps>(
|
|
|
457
430
|
{...props}
|
|
458
431
|
{...mergeDataAttributes(props, dataAttributes({ slot: 'table-cell' }))}
|
|
459
432
|
>
|
|
460
|
-
{renderNativeTableTextContent(
|
|
461
|
-
children,
|
|
462
|
-
cn('w-full body-md text-content-primary', nativeTextAlign(className)),
|
|
463
|
-
)}
|
|
433
|
+
{renderNativeTableTextContent(children, tableNativeCellTextVariants({ align }))}
|
|
464
434
|
</Comp>
|
|
465
435
|
);
|
|
466
436
|
},
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { forwardRef, type ComponentPropsWithoutRef, type CSSProperties } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
2
|
import {
|
|
4
3
|
Slot,
|
|
5
4
|
dataAttributes,
|
|
@@ -21,6 +20,7 @@ import {
|
|
|
21
20
|
tableRowVariants,
|
|
22
21
|
} from './styles';
|
|
23
22
|
import type {
|
|
23
|
+
TableAlignment,
|
|
24
24
|
TableCaptionProps,
|
|
25
25
|
TableCellProps,
|
|
26
26
|
TableHeadProps,
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
} from './useTableStyleContext';
|
|
36
36
|
|
|
37
37
|
export type {
|
|
38
|
+
TableAlignment,
|
|
38
39
|
TableCaptionProps,
|
|
39
40
|
TableCellProps,
|
|
40
41
|
TableHeadProps,
|
|
@@ -49,8 +50,8 @@ type WebTableCaptionProps = TableCaptionProps & ComponentPropsWithoutRef<'captio
|
|
|
49
50
|
type WebTableSectionProps = TableSectionProps &
|
|
50
51
|
ComponentPropsWithoutRef<'thead' | 'tbody' | 'tfoot'>;
|
|
51
52
|
type WebTableRowProps = TableRowProps & ComponentPropsWithoutRef<'tr'>;
|
|
52
|
-
type WebTableHeadProps = TableHeadProps & ComponentPropsWithoutRef<'th'>;
|
|
53
|
-
type WebTableCellProps = TableCellProps & ComponentPropsWithoutRef<'td'>;
|
|
53
|
+
type WebTableHeadProps = TableHeadProps & Omit<ComponentPropsWithoutRef<'th'>, 'align'>;
|
|
54
|
+
type WebTableCellProps = TableCellProps & Omit<ComponentPropsWithoutRef<'td'>, 'align'>;
|
|
54
55
|
|
|
55
56
|
const tableHostProps = (props: object, slot: string) => {
|
|
56
57
|
const mapped = mapViewPropsToDom(props);
|
|
@@ -65,7 +66,7 @@ const tableHostProps = (props: object, slot: string) => {
|
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
const TableRoot = forwardRef<HTMLTableElement, WebTableProps>(
|
|
68
|
-
({ asChild, className, children, style, fullBleed = false, ...props }, ref) => {
|
|
69
|
+
({ asChild, className, containerStyle, children, style, fullBleed = false, ...props }, ref) => {
|
|
69
70
|
const ctx = useTableVariantContext(fullBleed);
|
|
70
71
|
|
|
71
72
|
if (asChild) {
|
|
@@ -87,7 +88,10 @@ const TableRoot = forwardRef<HTMLTableElement, WebTableProps>(
|
|
|
87
88
|
|
|
88
89
|
return (
|
|
89
90
|
<ParentContext.Provider value={ctx}>
|
|
90
|
-
<
|
|
91
|
+
<div
|
|
92
|
+
className={tableContainerVariants()}
|
|
93
|
+
style={containerStyle as CSSProperties | undefined}
|
|
94
|
+
>
|
|
91
95
|
<table
|
|
92
96
|
ref={ref}
|
|
93
97
|
className={cn(tableRootVariants(), className)}
|
|
@@ -96,7 +100,7 @@ const TableRoot = forwardRef<HTMLTableElement, WebTableProps>(
|
|
|
96
100
|
>
|
|
97
101
|
{children}
|
|
98
102
|
</table>
|
|
99
|
-
</
|
|
103
|
+
</div>
|
|
100
104
|
</ParentContext.Provider>
|
|
101
105
|
);
|
|
102
106
|
},
|
|
@@ -274,10 +278,34 @@ const TableRow = forwardRef<HTMLTableRowElement, WebTableRowProps>(
|
|
|
274
278
|
|
|
275
279
|
TableRow.displayName = 'Table.Row';
|
|
276
280
|
|
|
281
|
+
const tableWebContentStyles: Record<TableAlignment, CSSProperties> = {
|
|
282
|
+
start: {
|
|
283
|
+
display: 'flex',
|
|
284
|
+
width: '100%',
|
|
285
|
+
flexDirection: 'row',
|
|
286
|
+
alignItems: 'center',
|
|
287
|
+
justifyContent: 'flex-start',
|
|
288
|
+
},
|
|
289
|
+
center: {
|
|
290
|
+
display: 'flex',
|
|
291
|
+
width: '100%',
|
|
292
|
+
flexDirection: 'row',
|
|
293
|
+
alignItems: 'center',
|
|
294
|
+
justifyContent: 'center',
|
|
295
|
+
},
|
|
296
|
+
end: {
|
|
297
|
+
display: 'flex',
|
|
298
|
+
width: '100%',
|
|
299
|
+
flexDirection: 'row',
|
|
300
|
+
alignItems: 'center',
|
|
301
|
+
justifyContent: 'flex-end',
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
|
|
277
305
|
const TableHead = forwardRef<HTMLTableCellElement, WebTableHeadProps>(
|
|
278
|
-
({ asChild, className, children, style, scope = 'col', ...props }, ref) => {
|
|
306
|
+
({ asChild, align = 'start', className, children, style, scope = 'col', ...props }, ref) => {
|
|
279
307
|
const { fullBleed } = useTableStyleContext();
|
|
280
|
-
const computedClassName = cn(tableHeadVariants({ fullBleed }), className);
|
|
308
|
+
const computedClassName = cn(tableHeadVariants({ fullBleed, align }), className);
|
|
281
309
|
|
|
282
310
|
if (asChild) {
|
|
283
311
|
const Comp = Slot;
|
|
@@ -303,7 +331,7 @@ const TableHead = forwardRef<HTMLTableCellElement, WebTableHeadProps>(
|
|
|
303
331
|
style={style as CSSProperties | undefined}
|
|
304
332
|
{...tableHostProps(props, 'table-head')}
|
|
305
333
|
>
|
|
306
|
-
{children}
|
|
334
|
+
{align === 'start' ? children : <div style={tableWebContentStyles[align]}>{children}</div>}
|
|
307
335
|
</th>
|
|
308
336
|
);
|
|
309
337
|
},
|
|
@@ -312,9 +340,9 @@ const TableHead = forwardRef<HTMLTableCellElement, WebTableHeadProps>(
|
|
|
312
340
|
TableHead.displayName = 'Table.Head';
|
|
313
341
|
|
|
314
342
|
const TableCell = forwardRef<HTMLTableCellElement, WebTableCellProps>(
|
|
315
|
-
({ asChild, className, children, style, ...props }, ref) => {
|
|
343
|
+
({ asChild, align = 'start', className, children, style, ...props }, ref) => {
|
|
316
344
|
const { fullBleed } = useTableStyleContext();
|
|
317
|
-
const computedClassName = cn(tableCellVariants({ fullBleed }), className);
|
|
345
|
+
const computedClassName = cn(tableCellVariants({ fullBleed, align }), className);
|
|
318
346
|
|
|
319
347
|
if (asChild) {
|
|
320
348
|
const Comp = Slot;
|
|
@@ -338,7 +366,7 @@ const TableCell = forwardRef<HTMLTableCellElement, WebTableCellProps>(
|
|
|
338
366
|
style={style as CSSProperties | undefined}
|
|
339
367
|
{...tableHostProps(props, 'table-cell')}
|
|
340
368
|
>
|
|
341
|
-
{children}
|
|
369
|
+
{align === 'start' ? children : <div style={tableWebContentStyles[align]}>{children}</div>}
|
|
342
370
|
</td>
|
|
343
371
|
);
|
|
344
372
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cva, type VariantProps } from '@cdx-ui/utils';
|
|
2
2
|
|
|
3
|
-
export const tableContainerVariants = cva('relative w-full overflow-auto');
|
|
3
|
+
export const tableContainerVariants = cva('relative w-full min-w-0 max-w-full overflow-auto');
|
|
4
4
|
|
|
5
5
|
export const tableRootVariants = cva('w-full caption-bottom body-md text-content-primary');
|
|
6
6
|
|
|
@@ -25,16 +25,22 @@ export const tableRowVariants = cva(
|
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
export const tableHeadVariants = cva(
|
|
28
|
-
'h-11 px-2
|
|
28
|
+
'h-11 bg-surface-primary px-2 align-middle font-medium text-content-secondary body-md',
|
|
29
29
|
{
|
|
30
30
|
variants: {
|
|
31
31
|
fullBleed: {
|
|
32
32
|
true: 'first:pl-0 last:pr-0',
|
|
33
33
|
false: '',
|
|
34
34
|
},
|
|
35
|
+
align: {
|
|
36
|
+
start: 'text-start',
|
|
37
|
+
center: 'text-center',
|
|
38
|
+
end: 'text-end',
|
|
39
|
+
},
|
|
35
40
|
},
|
|
36
41
|
defaultVariants: {
|
|
37
42
|
fullBleed: false,
|
|
43
|
+
align: 'start',
|
|
38
44
|
},
|
|
39
45
|
},
|
|
40
46
|
);
|
|
@@ -45,9 +51,15 @@ export const tableCellVariants = cva('p-2 align-middle body-md text-content-prim
|
|
|
45
51
|
true: 'first:pl-0 last:pr-0',
|
|
46
52
|
false: '',
|
|
47
53
|
},
|
|
54
|
+
align: {
|
|
55
|
+
start: 'text-start',
|
|
56
|
+
center: 'text-center',
|
|
57
|
+
end: 'text-end',
|
|
58
|
+
},
|
|
48
59
|
},
|
|
49
60
|
defaultVariants: {
|
|
50
61
|
fullBleed: false,
|
|
62
|
+
align: 'start',
|
|
51
63
|
},
|
|
52
64
|
});
|
|
53
65
|
|
|
@@ -63,9 +75,15 @@ export const tableNativeHeadVariants = cva(
|
|
|
63
75
|
true: 'first:pl-0 last:pr-0',
|
|
64
76
|
false: '',
|
|
65
77
|
},
|
|
78
|
+
align: {
|
|
79
|
+
start: 'items-start',
|
|
80
|
+
center: 'items-center',
|
|
81
|
+
end: 'items-end',
|
|
82
|
+
},
|
|
66
83
|
},
|
|
67
84
|
defaultVariants: {
|
|
68
85
|
fullBleed: false,
|
|
86
|
+
align: 'start',
|
|
69
87
|
},
|
|
70
88
|
},
|
|
71
89
|
);
|
|
@@ -78,13 +96,48 @@ export const tableNativeCellVariants = cva(
|
|
|
78
96
|
true: 'first:pl-0 last:pr-0',
|
|
79
97
|
false: '',
|
|
80
98
|
},
|
|
99
|
+
align: {
|
|
100
|
+
start: 'items-start',
|
|
101
|
+
center: 'items-center',
|
|
102
|
+
end: 'items-end',
|
|
103
|
+
},
|
|
81
104
|
},
|
|
82
105
|
defaultVariants: {
|
|
83
106
|
fullBleed: false,
|
|
107
|
+
align: 'start',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
export const tableNativeHeadTextVariants = cva(
|
|
113
|
+
'w-full font-medium text-content-secondary body-md',
|
|
114
|
+
{
|
|
115
|
+
variants: {
|
|
116
|
+
align: {
|
|
117
|
+
start: 'ltr:text-left rtl:text-right',
|
|
118
|
+
center: 'text-center',
|
|
119
|
+
end: 'ltr:text-right rtl:text-left',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
defaultVariants: {
|
|
123
|
+
align: 'start',
|
|
84
124
|
},
|
|
85
125
|
},
|
|
86
126
|
);
|
|
87
127
|
|
|
128
|
+
export const tableNativeCellTextVariants = cva('w-full body-md text-content-primary', {
|
|
129
|
+
variants: {
|
|
130
|
+
align: {
|
|
131
|
+
start: 'ltr:text-left rtl:text-right',
|
|
132
|
+
center: 'text-center',
|
|
133
|
+
end: 'ltr:text-right rtl:text-left',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
defaultVariants: {
|
|
137
|
+
align: 'start',
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
88
141
|
export const tableNativeFooterVariants = cva('bg-surface-secondary');
|
|
89
142
|
|
|
90
|
-
export type TableVariantProps = VariantProps<typeof tableHeadVariants>;
|
|
143
|
+
export type TableVariantProps = Pick<VariantProps<typeof tableHeadVariants>, 'fullBleed'>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { TextProps, ViewProps } from 'react-native';
|
|
2
|
+
import type { TextProps, ViewProps, ViewStyle } from 'react-native';
|
|
3
3
|
import type { TableVariantProps } from './styles';
|
|
4
4
|
|
|
5
|
+
export type TableAlignment = 'start' | 'center' | 'end';
|
|
6
|
+
|
|
5
7
|
export interface TableProps extends ViewProps, TableVariantProps {
|
|
6
8
|
asChild?: boolean;
|
|
7
9
|
className?: string;
|
|
10
|
+
containerStyle?: ViewStyle;
|
|
8
11
|
children?: ReactNode;
|
|
9
12
|
}
|
|
10
13
|
|
|
@@ -30,6 +33,11 @@ export interface TableHeadProps extends ViewProps {
|
|
|
30
33
|
asChild?: boolean;
|
|
31
34
|
className?: string;
|
|
32
35
|
children?: ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Logical horizontal alignment for text and composed content.
|
|
38
|
+
* @default 'start'
|
|
39
|
+
*/
|
|
40
|
+
align?: TableAlignment;
|
|
33
41
|
colSpan?: number;
|
|
34
42
|
rowSpan?: number;
|
|
35
43
|
scope?: 'col' | 'row' | 'colgroup' | 'rowgroup';
|
|
@@ -39,6 +47,11 @@ export interface TableCellProps extends ViewProps {
|
|
|
39
47
|
asChild?: boolean;
|
|
40
48
|
className?: string;
|
|
41
49
|
children?: ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Logical horizontal alignment for text and composed content.
|
|
52
|
+
* @default 'start'
|
|
53
|
+
*/
|
|
54
|
+
align?: TableAlignment;
|
|
42
55
|
colSpan?: number;
|
|
43
56
|
rowSpan?: number;
|
|
44
57
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createContext, useContext, type ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface TablePaginationContextValue {
|
|
4
|
+
page: number;
|
|
5
|
+
count: number;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
goToPage: (page: number) => void;
|
|
8
|
+
pageSize?: number;
|
|
9
|
+
pageSizeOptions: readonly (number | { value: number; label: string })[];
|
|
10
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const TablePaginationContext = createContext<TablePaginationContextValue | null>(null);
|
|
14
|
+
|
|
15
|
+
export function TablePaginationProvider({
|
|
16
|
+
value,
|
|
17
|
+
children,
|
|
18
|
+
}: {
|
|
19
|
+
value: TablePaginationContextValue;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}) {
|
|
22
|
+
return (
|
|
23
|
+
<TablePaginationContext.Provider value={value}>{children}</TablePaginationContext.Provider>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function useTablePaginationContext(): TablePaginationContextValue | null {
|
|
28
|
+
return useContext(TablePaginationContext);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function useRequiredTablePaginationContext(): TablePaginationContextValue {
|
|
32
|
+
const context = useTablePaginationContext();
|
|
33
|
+
if (!context) {
|
|
34
|
+
throw new Error('TablePagination compound slots must be rendered inside <TablePagination>.');
|
|
35
|
+
}
|
|
36
|
+
return context;
|
|
37
|
+
}
|