@utilitywarehouse/hearth-react-native 0.27.3 → 0.28.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 (118) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-lint.log +18 -19
  3. package/CHANGELOG.md +110 -0
  4. package/build/components/Combobox/Combobox.context.d.ts +13 -0
  5. package/build/components/Combobox/Combobox.context.js +9 -0
  6. package/build/components/Combobox/Combobox.d.ts +6 -0
  7. package/build/components/Combobox/Combobox.js +246 -0
  8. package/build/components/Combobox/Combobox.props.d.ts +180 -0
  9. package/build/components/Combobox/Combobox.props.js +1 -0
  10. package/build/components/Combobox/ComboboxOption.d.ts +6 -0
  11. package/build/components/Combobox/ComboboxOption.js +56 -0
  12. package/build/components/Combobox/index.d.ts +4 -0
  13. package/build/components/Combobox/index.js +3 -0
  14. package/build/components/Modal/Modal.js +26 -42
  15. package/build/components/Modal/Modal.web.js +3 -3
  16. package/build/components/Pagination/Pagination.d.ts +6 -0
  17. package/build/components/Pagination/Pagination.js +125 -0
  18. package/build/components/Pagination/Pagination.props.d.ts +26 -0
  19. package/build/components/Pagination/Pagination.props.js +1 -0
  20. package/build/components/Pagination/Pagination.utils.d.ts +2 -0
  21. package/build/components/Pagination/Pagination.utils.js +20 -0
  22. package/build/components/Pagination/Pagination.utils.test.d.ts +1 -0
  23. package/build/components/Pagination/Pagination.utils.test.js +16 -0
  24. package/build/components/Pagination/index.d.ts +2 -0
  25. package/build/components/Pagination/index.js +1 -0
  26. package/build/components/SafeAreaView/SafeAreaView.d.ts +5 -0
  27. package/build/components/SafeAreaView/SafeAreaView.js +117 -0
  28. package/build/components/SafeAreaView/SafeAreaView.props.d.ts +17 -0
  29. package/build/components/SafeAreaView/SafeAreaView.props.js +1 -0
  30. package/build/components/SafeAreaView/index.d.ts +2 -0
  31. package/build/components/SafeAreaView/index.js +1 -0
  32. package/build/components/Select/Select.js +3 -2
  33. package/build/components/Table/Table.context.d.ts +12 -0
  34. package/build/components/Table/Table.context.js +9 -0
  35. package/build/components/Table/Table.d.ts +6 -0
  36. package/build/components/Table/Table.js +71 -0
  37. package/build/components/Table/Table.props.d.ts +56 -0
  38. package/build/components/Table/Table.props.js +1 -0
  39. package/build/components/Table/Table.utils.d.ts +5 -0
  40. package/build/components/Table/Table.utils.js +48 -0
  41. package/build/components/Table/Table.utils.test.d.ts +1 -0
  42. package/build/components/Table/Table.utils.test.js +71 -0
  43. package/build/components/Table/TableBody.d.ts +6 -0
  44. package/build/components/Table/TableBody.js +16 -0
  45. package/build/components/Table/TableCell.d.ts +10 -0
  46. package/build/components/Table/TableCell.js +44 -0
  47. package/build/components/Table/TableHeader.d.ts +6 -0
  48. package/build/components/Table/TableHeader.js +24 -0
  49. package/build/components/Table/TableHeaderCell.d.ts +10 -0
  50. package/build/components/Table/TableHeaderCell.js +97 -0
  51. package/build/components/Table/TablePagination.d.ts +6 -0
  52. package/build/components/Table/TablePagination.js +7 -0
  53. package/build/components/Table/TableRow.d.ts +8 -0
  54. package/build/components/Table/TableRow.js +25 -0
  55. package/build/components/Table/index.d.ts +8 -0
  56. package/build/components/Table/index.js +7 -0
  57. package/build/components/Timeline/Timeline.d.ts +6 -0
  58. package/build/components/Timeline/Timeline.js +34 -0
  59. package/build/components/Timeline/Timeline.props.d.ts +47 -0
  60. package/build/components/Timeline/Timeline.props.js +1 -0
  61. package/build/components/Timeline/TimelineItem.d.ts +6 -0
  62. package/build/components/Timeline/TimelineItem.js +235 -0
  63. package/build/components/Timeline/index.d.ts +3 -0
  64. package/build/components/Timeline/index.js +2 -0
  65. package/build/components/index.d.ts +5 -0
  66. package/build/components/index.js +5 -0
  67. package/build/tokens/components/dark/timeline.d.ts +2 -2
  68. package/build/tokens/components/dark/timeline.js +2 -2
  69. package/docs/components/AllComponents.web.tsx +106 -23
  70. package/docs/llm-docs/unistyles-llms-full.txt +1132 -534
  71. package/docs/llm-docs/unistyles-llms-small.txt +37 -37
  72. package/package.json +2 -2
  73. package/src/components/Combobox/Combobox.context.ts +26 -0
  74. package/src/components/Combobox/Combobox.docs.mdx +277 -0
  75. package/src/components/Combobox/Combobox.figma.tsx +60 -0
  76. package/src/components/Combobox/Combobox.props.ts +187 -0
  77. package/src/components/Combobox/Combobox.stories.tsx +233 -0
  78. package/src/components/Combobox/Combobox.tsx +446 -0
  79. package/src/components/Combobox/ComboboxOption.tsx +100 -0
  80. package/src/components/Combobox/index.ts +9 -0
  81. package/src/components/Modal/Modal.tsx +52 -74
  82. package/src/components/Modal/Modal.web.tsx +3 -3
  83. package/src/components/Pagination/Pagination.docs.mdx +99 -0
  84. package/src/components/Pagination/Pagination.figma.tsx +20 -0
  85. package/src/components/Pagination/Pagination.props.ts +28 -0
  86. package/src/components/Pagination/Pagination.stories.tsx +88 -0
  87. package/src/components/Pagination/Pagination.tsx +248 -0
  88. package/src/components/Pagination/Pagination.utils.test.ts +20 -0
  89. package/src/components/Pagination/Pagination.utils.ts +37 -0
  90. package/src/components/Pagination/index.ts +2 -0
  91. package/src/components/SafeAreaView/SafeAreaView.props.ts +20 -0
  92. package/src/components/SafeAreaView/SafeAreaView.tsx +173 -0
  93. package/src/components/SafeAreaView/index.ts +2 -0
  94. package/src/components/Select/Select.tsx +30 -27
  95. package/src/components/Table/Table.context.tsx +23 -0
  96. package/src/components/Table/Table.docs.mdx +239 -0
  97. package/src/components/Table/Table.figma.tsx +65 -0
  98. package/src/components/Table/Table.props.ts +65 -0
  99. package/src/components/Table/Table.stories.tsx +399 -0
  100. package/src/components/Table/Table.tsx +127 -0
  101. package/src/components/Table/Table.utils.test.ts +82 -0
  102. package/src/components/Table/Table.utils.ts +72 -0
  103. package/src/components/Table/TableBody.tsx +25 -0
  104. package/src/components/Table/TableCell.tsx +67 -0
  105. package/src/components/Table/TableHeader.tsx +41 -0
  106. package/src/components/Table/TableHeaderCell.tsx +136 -0
  107. package/src/components/Table/TablePagination.tsx +10 -0
  108. package/src/components/Table/TableRow.tsx +42 -0
  109. package/src/components/Table/index.ts +16 -0
  110. package/src/components/Timeline/Timeline.docs.mdx +177 -0
  111. package/src/components/Timeline/Timeline.figma.tsx +89 -0
  112. package/src/components/Timeline/Timeline.props.ts +51 -0
  113. package/src/components/Timeline/Timeline.stories.tsx +102 -0
  114. package/src/components/Timeline/Timeline.tsx +48 -0
  115. package/src/components/Timeline/TimelineItem.tsx +293 -0
  116. package/src/components/Timeline/index.ts +9 -0
  117. package/src/components/index.ts +5 -0
  118. package/src/tokens/components/dark/timeline.ts +2 -2
@@ -0,0 +1,12 @@
1
+ import type { TableProps } from './Table.props';
2
+ type TableContainer = TableProps['container'];
3
+ type TableColumnWidths = NonNullable<TableProps['columnWidths']>;
4
+ interface TableContextValue {
5
+ columnWidths: TableColumnWidths;
6
+ container: TableContainer;
7
+ columnCount: number;
8
+ hasPagination: boolean;
9
+ }
10
+ export declare const TableContextProvider: import("react").Provider<TableContextValue>;
11
+ export declare const useTableContext: () => TableContextValue;
12
+ export {};
@@ -0,0 +1,9 @@
1
+ import { createContext, useContext } from 'react';
2
+ const TableContext = createContext({
3
+ columnWidths: [],
4
+ container: 'none',
5
+ columnCount: 1,
6
+ hasPagination: false,
7
+ });
8
+ export const TableContextProvider = TableContext.Provider;
9
+ export const useTableContext = () => useContext(TableContext);
@@ -0,0 +1,6 @@
1
+ import type { TableProps } from './Table.props';
2
+ declare const Table: {
3
+ ({ children, columnWidths, container, pagination, style, ...props }: TableProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string;
5
+ };
6
+ export default Table;
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Children, isValidElement, useState } from 'react';
3
+ import { View } from 'react-native';
4
+ import { ScrollView } from 'react-native-gesture-handler';
5
+ import { StyleSheet } from 'react-native-unistyles';
6
+ import { Card } from '../Card';
7
+ import { TableContextProvider } from './Table.context';
8
+ import { getMinTableWidth } from './Table.utils';
9
+ const MIN_COLUMN_WIDTH = 120;
10
+ const getChildCount = (node) => {
11
+ if (!isValidElement(node)) {
12
+ return 0;
13
+ }
14
+ const childProps = node.props;
15
+ return Children.count(childProps.children);
16
+ };
17
+ const getMaxColumnCount = (children) => {
18
+ let maxColumns = 1;
19
+ Children.forEach(children, child => {
20
+ if (!isValidElement(child)) {
21
+ return;
22
+ }
23
+ const childType = child.type;
24
+ const childProps = child.props;
25
+ if (childType.displayName === 'TableHeader') {
26
+ maxColumns = Math.max(maxColumns, getChildCount(child));
27
+ return;
28
+ }
29
+ if (childType.displayName === 'TableBody') {
30
+ Children.forEach(childProps.children, rowChild => {
31
+ maxColumns = Math.max(maxColumns, getChildCount(rowChild));
32
+ });
33
+ }
34
+ });
35
+ return maxColumns;
36
+ };
37
+ const Table = ({ children, columnWidths = [], container = 'none', pagination, style, ...props }) => {
38
+ const [containerWidth, setContainerWidth] = useState(0);
39
+ const columnCount = getMaxColumnCount(children);
40
+ const minTableWidth = getMinTableWidth(columnCount, columnWidths, MIN_COLUMN_WIDTH);
41
+ const tableWidth = Math.max(containerWidth, minTableWidth);
42
+ const isScrollable = tableWidth > containerWidth + 1;
43
+ const handleLayout = (event) => {
44
+ const nextWidth = event.nativeEvent.layout.width;
45
+ setContainerWidth(currentWidth => (currentWidth === nextWidth ? currentWidth : nextWidth));
46
+ };
47
+ const content = (_jsxs(View, { onLayout: handleLayout, style: styles.wrapper, children: [_jsx(ScrollView, { alwaysBounceHorizontal: false, alwaysBounceVertical: false, bounces: false, canCancelContentTouches: true, contentContainerStyle: styles.scrollContent, horizontal: true, keyboardShouldPersistTaps: "handled", nestedScrollEnabled: true, overScrollMode: "never", scrollEnabled: isScrollable, scrollEventThrottle: 16, showsHorizontalScrollIndicator: true, children: _jsx(View, { style: [styles.content, { width: tableWidth || minTableWidth }], children: children }) }), pagination ? _jsx(View, { style: styles.pagination, children: pagination }) : null] }));
48
+ const hasPagination = Boolean(pagination);
49
+ return (_jsx(TableContextProvider, { value: { columnCount, columnWidths, container, hasPagination }, children: container !== 'none' ? (_jsx(Card, { ...props, colorScheme: "neutralStrong", noPadding: true, style: style, variant: container, children: content })) : (_jsx(View, { ...props, style: [styles.plainTable, style], children: content })) }));
50
+ };
51
+ Table.displayName = 'Table';
52
+ const styles = StyleSheet.create(theme => ({
53
+ wrapper: {
54
+ width: '100%',
55
+ },
56
+ plainTable: {
57
+ width: '100%',
58
+ overflow: 'hidden',
59
+ },
60
+ scrollContent: {
61
+ minWidth: '100%',
62
+ },
63
+ content: {
64
+ alignSelf: 'flex-start',
65
+ },
66
+ pagination: {
67
+ paddingHorizontal: theme.components.table.cell.padding,
68
+ paddingVertical: theme.space[200],
69
+ },
70
+ }));
71
+ export default Table;
@@ -0,0 +1,56 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ViewProps } from 'react-native';
3
+ import type PaginationProps from '../Pagination/Pagination.props';
4
+ export interface TableFlexibleColumnWidth {
5
+ flex: number;
6
+ }
7
+ export type TableColumnWidth = number | `${number}fr` | TableFlexibleColumnWidth;
8
+ export interface TableProps extends ViewProps {
9
+ /**
10
+ * Controls whether the table is wrapped in a card container.
11
+ * @default 'none'
12
+ */
13
+ container?: 'emphasis' | 'subtle' | 'none';
14
+ /**
15
+ * Optional per-column sizing using fixed pixel widths or flexible fractions.
16
+ * Use numbers for fixed widths and values like `'2fr'` for flexible columns.
17
+ * Objects like `{ flex: 2 }` are also supported internally.
18
+ * Unspecified columns default to `1fr`.
19
+ */
20
+ columnWidths?: TableColumnWidth[];
21
+ /**
22
+ * Optional pagination controls rendered beneath the rows.
23
+ */
24
+ pagination?: React.ReactElement<PaginationProps> | ReactNode;
25
+ }
26
+ export interface TableBodyProps extends ViewProps {
27
+ children: ReactNode;
28
+ }
29
+ export interface TableHeaderProps extends ViewProps {
30
+ children: ReactNode;
31
+ /**
32
+ * Visual style for header cells.
33
+ * @default 'purple'
34
+ */
35
+ color?: 'purple' | 'white';
36
+ }
37
+ export interface TableRowProps extends ViewProps {
38
+ children: ReactNode;
39
+ }
40
+ export interface TableCellProps extends ViewProps {
41
+ children?: ReactNode;
42
+ }
43
+ export interface TableHeaderCellProps extends ViewProps {
44
+ children?: ReactNode;
45
+ color?: 'purple' | 'white';
46
+ /**
47
+ * Renders the header cell as a row header within the body.
48
+ * @default false
49
+ */
50
+ row?: boolean;
51
+ /**
52
+ * Optional content aligned to the end of a header cell.
53
+ */
54
+ trailingContent?: ReactNode;
55
+ }
56
+ export type TablePaginationProps = PaginationProps;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { ViewStyle } from 'react-native';
2
+ import type { TableColumnWidth } from './Table.props';
3
+ export declare const getColumnMinWidth: (columnWidth: TableColumnWidth | undefined, minColumnWidth: number) => number;
4
+ export declare const getMinTableWidth: (columnCount: number, columnWidths: TableColumnWidth[], minColumnWidth: number) => number;
5
+ export declare const getColumnStyle: (columnWidth: TableColumnWidth | undefined, minColumnWidth: number) => ViewStyle;
@@ -0,0 +1,48 @@
1
+ const FR_UNIT_PATTERN = /^(\d*\.?\d+)fr$/;
2
+ const parseFractionUnit = (columnWidth) => {
3
+ if (typeof columnWidth !== 'string') {
4
+ return null;
5
+ }
6
+ const match = columnWidth.match(FR_UNIT_PATTERN);
7
+ if (!match) {
8
+ return null;
9
+ }
10
+ const parsedValue = Number(match[1]);
11
+ return Number.isFinite(parsedValue) && parsedValue > 0 ? parsedValue : null;
12
+ };
13
+ const getFlexGrow = (columnWidth) => {
14
+ if (!columnWidth || typeof columnWidth === 'number') {
15
+ return 1;
16
+ }
17
+ if (typeof columnWidth === 'string') {
18
+ return parseFractionUnit(columnWidth) ?? 1;
19
+ }
20
+ return Number.isFinite(columnWidth.flex) && columnWidth.flex > 0 ? columnWidth.flex : 1;
21
+ };
22
+ export const getColumnMinWidth = (columnWidth, minColumnWidth) => {
23
+ if (typeof columnWidth === 'number') {
24
+ return Math.max(columnWidth, minColumnWidth);
25
+ }
26
+ return minColumnWidth;
27
+ };
28
+ export const getMinTableWidth = (columnCount, columnWidths, minColumnWidth) => {
29
+ return Array.from({ length: columnCount }).reduce((totalWidth, _, index) => {
30
+ return totalWidth + getColumnMinWidth(columnWidths[index], minColumnWidth);
31
+ }, 0);
32
+ };
33
+ export const getColumnStyle = (columnWidth, minColumnWidth) => {
34
+ if (typeof columnWidth === 'number') {
35
+ return {
36
+ width: columnWidth,
37
+ minWidth: columnWidth,
38
+ flexGrow: 0,
39
+ flexShrink: 0,
40
+ };
41
+ }
42
+ return {
43
+ minWidth: minColumnWidth,
44
+ flexBasis: 0,
45
+ flexGrow: getFlexGrow(columnWidth),
46
+ flexShrink: 0,
47
+ };
48
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,71 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { getColumnMinWidth, getColumnStyle, getMinTableWidth } from './Table.utils';
3
+ describe('getColumnMinWidth', () => {
4
+ it('returns the configured fixed width when it is larger than the minimum', () => {
5
+ expect(getColumnMinWidth(180, 120)).toBe(180);
6
+ });
7
+ it('clamps fixed widths to the minimum column width', () => {
8
+ expect(getColumnMinWidth(80, 120)).toBe(120);
9
+ });
10
+ it('returns the minimum width for flexible and unspecified columns', () => {
11
+ expect(getColumnMinWidth('2fr', 120)).toBe(120);
12
+ expect(getColumnMinWidth({ flex: 3 }, 120)).toBe(120);
13
+ expect(getColumnMinWidth(undefined, 120)).toBe(120);
14
+ });
15
+ });
16
+ describe('getMinTableWidth', () => {
17
+ it('adds fixed widths and minimum widths for flexible columns', () => {
18
+ expect(getMinTableWidth(4, [180, '2fr', { flex: 3 }], 120)).toBe(540);
19
+ });
20
+ it('uses the minimum width for unspecified trailing columns', () => {
21
+ expect(getMinTableWidth(3, [200], 120)).toBe(440);
22
+ });
23
+ });
24
+ describe('getColumnStyle', () => {
25
+ it('returns a fixed-width style for numeric column widths', () => {
26
+ expect(getColumnStyle(180, 120)).toEqual({
27
+ width: 180,
28
+ minWidth: 180,
29
+ flexGrow: 0,
30
+ flexShrink: 0,
31
+ });
32
+ });
33
+ it('maps fr values to flexGrow', () => {
34
+ expect(getColumnStyle('2fr', 120)).toEqual({
35
+ minWidth: 120,
36
+ flexBasis: 0,
37
+ flexGrow: 2,
38
+ flexShrink: 0,
39
+ });
40
+ });
41
+ it('supports fractional fr values', () => {
42
+ expect(getColumnStyle('0.5fr', 120)).toEqual({
43
+ minWidth: 120,
44
+ flexBasis: 0,
45
+ flexGrow: 0.5,
46
+ flexShrink: 0,
47
+ });
48
+ });
49
+ it('uses flex weights from object column widths', () => {
50
+ expect(getColumnStyle({ flex: 3 }, 120)).toEqual({
51
+ minWidth: 120,
52
+ flexBasis: 0,
53
+ flexGrow: 3,
54
+ flexShrink: 0,
55
+ });
56
+ });
57
+ it('falls back to a single flexible column for invalid flexible values', () => {
58
+ expect(getColumnStyle('invalid', 120)).toEqual({
59
+ minWidth: 120,
60
+ flexBasis: 0,
61
+ flexGrow: 1,
62
+ flexShrink: 0,
63
+ });
64
+ expect(getColumnStyle({ flex: 0 }, 120)).toEqual({
65
+ minWidth: 120,
66
+ flexBasis: 0,
67
+ flexGrow: 1,
68
+ flexShrink: 0,
69
+ });
70
+ });
71
+ });
@@ -0,0 +1,6 @@
1
+ import { TableBodyProps } from './Table.props';
2
+ declare const TableBody: {
3
+ ({ children, ...props }: TableBodyProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string;
5
+ };
6
+ export default TableBody;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Children, cloneElement, isValidElement } from 'react';
3
+ import { View } from 'react-native';
4
+ const TableBody = ({ children, ...props }) => {
5
+ const items = Children.toArray(children);
6
+ return (_jsx(View, { ...props, children: items.map((child, index) => {
7
+ if (!isValidElement(child)) {
8
+ return child;
9
+ }
10
+ return cloneElement(child, {
11
+ isLastRow: index === items.length - 1,
12
+ });
13
+ }) }));
14
+ };
15
+ TableBody.displayName = 'TableBody';
16
+ export default TableBody;
@@ -0,0 +1,10 @@
1
+ import { TableCellProps } from './Table.props';
2
+ declare const TableCell: {
3
+ ({ children, style, ...props }: TableCellProps & {
4
+ columnIndex?: number;
5
+ isLast?: boolean;
6
+ isLastRow?: boolean;
7
+ }): import("react/jsx-runtime").JSX.Element;
8
+ displayName: string;
9
+ };
10
+ export default TableCell;
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { StyleSheet } from 'react-native-unistyles';
4
+ import { BodyText } from '../BodyText';
5
+ import { useTableContext } from './Table.context';
6
+ import { getColumnStyle } from './Table.utils';
7
+ const renderContent = (children, weight = 'regular') => {
8
+ if (typeof children === 'string' || typeof children === 'number') {
9
+ return (_jsx(BodyText, { size: "md", weight: weight, children: children }));
10
+ }
11
+ return children;
12
+ };
13
+ const TableCell = ({ children, style, ...props }) => {
14
+ const { columnWidths, container, hasPagination } = useTableContext();
15
+ const { columnIndex = 0, isLast, isLastRow, ...rest } = props;
16
+ const removeBottomBorder = Boolean(isLastRow && container !== 'none' && !hasPagination);
17
+ const columnStyle = getColumnStyle(columnWidths[columnIndex], 120);
18
+ return (_jsx(View, { ...rest, style: [
19
+ styles.cell,
20
+ columnStyle,
21
+ isLast && styles.lastCell,
22
+ removeBottomBorder && styles.lastRowCell,
23
+ style,
24
+ ], children: renderContent(children) }));
25
+ };
26
+ TableCell.displayName = 'TableCell';
27
+ const styles = StyleSheet.create(theme => ({
28
+ cell: {
29
+ minHeight: theme.components.table.cell.minHeight,
30
+ justifyContent: 'center',
31
+ padding: theme.components.table.cell.padding,
32
+ borderRightWidth: theme.components.table.cell.borderWidth,
33
+ borderBottomWidth: theme.components.table.cell.borderWidth,
34
+ borderColor: theme.color.border.subtle,
35
+ backgroundColor: theme.color.surface.neutral.strong,
36
+ },
37
+ lastCell: {
38
+ borderRightWidth: 0,
39
+ },
40
+ lastRowCell: {
41
+ borderBottomWidth: 0,
42
+ },
43
+ }));
44
+ export default TableCell;
@@ -0,0 +1,6 @@
1
+ import { TableHeaderProps } from './Table.props';
2
+ declare const TableHeader: {
3
+ ({ children, color, style, ...props }: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string;
5
+ };
6
+ export default TableHeader;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Children, cloneElement, isValidElement } from 'react';
3
+ import { View } from 'react-native';
4
+ const TableHeader = ({ children, color = 'purple', style, ...props }) => {
5
+ const items = Children.toArray(children);
6
+ return (_jsx(View, { ...props, style: [styles.header, style], children: items.map((child, index) => {
7
+ if (!isValidElement(child)) {
8
+ return child;
9
+ }
10
+ return cloneElement(child, {
11
+ color,
12
+ columnIndex: index,
13
+ isLast: index === items.length - 1,
14
+ });
15
+ }) }));
16
+ };
17
+ TableHeader.displayName = 'TableHeader';
18
+ const styles = {
19
+ header: {
20
+ flexDirection: 'row',
21
+ width: '100%',
22
+ },
23
+ };
24
+ export default TableHeader;
@@ -0,0 +1,10 @@
1
+ import type { TableHeaderCellProps } from './Table.props';
2
+ declare const TableHeaderCell: {
3
+ ({ children, color, row, style, trailingContent, ...props }: TableHeaderCellProps & {
4
+ columnIndex?: number;
5
+ isLast?: boolean;
6
+ isLastRow?: boolean;
7
+ }): import("react/jsx-runtime").JSX.Element;
8
+ displayName: string;
9
+ };
10
+ export default TableHeaderCell;
@@ -0,0 +1,97 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cloneElement, isValidElement } from 'react';
3
+ import { View } from 'react-native';
4
+ import { StyleSheet } from 'react-native-unistyles';
5
+ import { BodyText } from '../BodyText';
6
+ import { useTableContext } from './Table.context';
7
+ import { getColumnStyle } from './Table.utils';
8
+ const renderContent = (children, weight = 'semibold', color = 'white') => {
9
+ if (typeof children === 'string' || typeof children === 'number') {
10
+ return (_jsx(BodyText, { size: "md", weight: weight, style: styles.text, inverted: color === 'purple', children: children }));
11
+ }
12
+ return children;
13
+ };
14
+ const TableHeaderCell = ({ children, color = 'white', row = false, style, trailingContent, ...props }) => {
15
+ const { columnWidths, container, hasPagination } = useTableContext();
16
+ const { columnIndex = 0, isLast, isLastRow, ...rest } = props;
17
+ const removeBottomBorder = Boolean(row && isLastRow && container !== 'none' && !hasPagination);
18
+ const columnStyle = getColumnStyle(columnWidths[columnIndex], 120);
19
+ styles.useVariants({ color, row });
20
+ const trailingElement = trailingContent && isValidElement(trailingContent)
21
+ ? trailingContent
22
+ : null;
23
+ const resolvedTrailingContent = trailingElement && !row && 'inverted' in (trailingElement.props ?? {})
24
+ ? cloneElement(trailingElement, {
25
+ inverted: color === 'purple',
26
+ })
27
+ : trailingContent;
28
+ return (_jsx(View, { ...rest, style: [
29
+ styles.cell,
30
+ columnStyle,
31
+ isLast && styles.lastCell,
32
+ removeBottomBorder && styles.lastRowCell,
33
+ style,
34
+ ], children: _jsxs(View, { style: styles.content, children: [renderContent(children, 'semibold', color), resolvedTrailingContent ? (_jsx(View, { style: styles.trailing, children: resolvedTrailingContent })) : null] }) }));
35
+ };
36
+ TableHeaderCell.displayName = 'TableHeaderCell';
37
+ const styles = StyleSheet.create(theme => ({
38
+ cell: {
39
+ minHeight: theme.components.table.headerCell.height,
40
+ justifyContent: 'center',
41
+ paddingHorizontal: theme.components.table.headerCell.paddingHorizontal,
42
+ paddingVertical: theme.components.table.headerCell.paddingVertical,
43
+ borderRightWidth: theme.components.table.headerCell.borderWidth,
44
+ borderBottomWidth: theme.components.table.headerCell.borderWidth,
45
+ borderColor: theme.color.border.subtle,
46
+ backgroundColor: theme.color.surface.neutral.strong,
47
+ variants: {
48
+ color: {
49
+ purple: {
50
+ borderColor: theme.color.interactive.brand.foreground.strong,
51
+ backgroundColor: theme.color.surface.brand.default,
52
+ },
53
+ white: {
54
+ borderColor: theme.color.border.subtle,
55
+ backgroundColor: theme.color.surface.neutral.strong,
56
+ },
57
+ },
58
+ row: {
59
+ true: {
60
+ minHeight: theme.components.table.cell.minHeight,
61
+ paddingHorizontal: theme.components.table.cell.padding,
62
+ paddingVertical: theme.components.table.cell.padding,
63
+ borderRightWidth: theme.components.table.cell.borderWidth,
64
+ borderBottomWidth: theme.components.table.cell.borderWidth,
65
+ borderColor: theme.color.border.subtle,
66
+ backgroundColor: theme.color.surface.neutral.strong,
67
+ },
68
+ },
69
+ },
70
+ },
71
+ lastCell: {
72
+ borderRightWidth: 0,
73
+ },
74
+ lastRowCell: {
75
+ borderBottomWidth: 0,
76
+ },
77
+ content: {
78
+ flexDirection: 'row',
79
+ alignItems: 'center',
80
+ justifyContent: 'space-between',
81
+ gap: theme.components.table.headerCell.gap,
82
+ },
83
+ trailing: {
84
+ flexShrink: 0,
85
+ },
86
+ text: {
87
+ flexShrink: 1,
88
+ variants: {
89
+ row: {
90
+ true: {
91
+ color: theme.color.text.primary,
92
+ },
93
+ },
94
+ },
95
+ },
96
+ }));
97
+ export default TableHeaderCell;
@@ -0,0 +1,6 @@
1
+ import type { TablePaginationProps } from './Table.props';
2
+ declare const TablePagination: {
3
+ (props: TablePaginationProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string;
5
+ };
6
+ export default TablePagination;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Pagination } from '../Pagination';
3
+ const TablePagination = (props) => {
4
+ return _jsx(Pagination, { ...props });
5
+ };
6
+ TablePagination.displayName = 'TablePagination';
7
+ export default TablePagination;
@@ -0,0 +1,8 @@
1
+ import { TableRowProps } from './Table.props';
2
+ declare const TableRow: {
3
+ ({ children, ...props }: TableRowProps & {
4
+ isLastRow?: boolean;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ displayName: string;
7
+ };
8
+ export default TableRow;
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Children, cloneElement, isValidElement } from 'react';
3
+ import { View } from 'react-native';
4
+ const TableRow = ({ children, ...props }) => {
5
+ const items = Children.toArray(children);
6
+ const { isLastRow = false, ...rest } = props;
7
+ return (_jsx(View, { ...rest, style: [styles.row, rest.style], children: items.map((child, index) => {
8
+ if (!isValidElement(child)) {
9
+ return child;
10
+ }
11
+ return cloneElement(child, {
12
+ isLast: index === items.length - 1,
13
+ columnIndex: index,
14
+ isLastRow,
15
+ });
16
+ }) }));
17
+ };
18
+ TableRow.displayName = 'TableRow';
19
+ const styles = {
20
+ row: {
21
+ flexDirection: 'row',
22
+ width: '100%',
23
+ },
24
+ };
25
+ export default TableRow;
@@ -0,0 +1,8 @@
1
+ export { default as Table } from './Table';
2
+ export type { TableBodyProps, TableCellProps, TableHeaderCellProps, TableHeaderProps, TablePaginationProps, TableProps, TableRowProps, } from './Table.props';
3
+ export { default as TableBody } from './TableBody';
4
+ export { default as TableCell } from './TableCell';
5
+ export { default as TableHeader } from './TableHeader';
6
+ export { default as TableHeaderCell } from './TableHeaderCell';
7
+ export { default as TablePagination } from './TablePagination';
8
+ export { default as TableRow } from './TableRow';
@@ -0,0 +1,7 @@
1
+ export { default as Table } from './Table';
2
+ export { default as TableBody } from './TableBody';
3
+ export { default as TableCell } from './TableCell';
4
+ export { default as TableHeader } from './TableHeader';
5
+ export { default as TableHeaderCell } from './TableHeaderCell';
6
+ export { default as TablePagination } from './TablePagination';
7
+ export { default as TableRow } from './TableRow';
@@ -0,0 +1,6 @@
1
+ import type { TimelineProps } from './Timeline.props';
2
+ declare const Timeline: {
3
+ ({ children, variant, style, ...rest }: TimelineProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string;
5
+ };
6
+ export default Timeline;
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { View } from 'react-native';
4
+ import { StyleSheet } from 'react-native-unistyles';
5
+ const getItemPosition = (index, count) => {
6
+ if (count <= 1) {
7
+ return 'single';
8
+ }
9
+ if (index === 0) {
10
+ return 'start';
11
+ }
12
+ if (index === count - 1) {
13
+ return 'end';
14
+ }
15
+ return 'middle';
16
+ };
17
+ const Timeline = ({ children, variant = 'static', style, ...rest }) => {
18
+ const childElements = React.Children.toArray(children).filter(React.isValidElement);
19
+ return (_jsx(View, { accessibilityRole: "list", style: [styles.root, style], ...rest, children: childElements.map((child, index) => {
20
+ const position = getItemPosition(index, childElements.length);
21
+ return React.cloneElement(child, {
22
+ key: child.key ?? `timeline-item-${index}`,
23
+ position,
24
+ variant,
25
+ });
26
+ }) }));
27
+ };
28
+ Timeline.displayName = 'Timeline';
29
+ const styles = StyleSheet.create(() => ({
30
+ root: {
31
+ width: '100%',
32
+ },
33
+ }));
34
+ export default Timeline;