@utilitywarehouse/hearth-react-native 0.27.2 → 0.28.0-testid-fix-1
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/.turbo/turbo-build.log +5 -4
- package/.turbo/turbo-lint.log +70 -69
- package/CHANGELOG.md +149 -0
- package/build/components/Button/ButtonRoot.js +8 -0
- package/build/components/Combobox/Combobox.context.d.ts +13 -0
- package/build/components/Combobox/Combobox.context.js +9 -0
- package/build/components/Combobox/Combobox.d.ts +6 -0
- package/build/components/Combobox/Combobox.js +246 -0
- package/build/components/Combobox/Combobox.props.d.ts +180 -0
- package/build/components/Combobox/Combobox.props.js +1 -0
- package/build/components/Combobox/ComboboxOption.d.ts +6 -0
- package/build/components/Combobox/ComboboxOption.js +56 -0
- package/build/components/Combobox/index.d.ts +4 -0
- package/build/components/Combobox/index.js +3 -0
- package/build/components/DatePicker/TimePicker.d.ts +3 -0
- package/build/components/DatePicker/TimePicker.js +84 -0
- package/build/components/DatePicker/time-picker/animated-math.d.ts +4 -0
- package/build/components/DatePicker/time-picker/animated-math.js +19 -0
- package/build/components/DatePicker/time-picker/period-native.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-native.js +17 -0
- package/build/components/DatePicker/time-picker/period-picker.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-picker.js +10 -0
- package/build/components/DatePicker/time-picker/period-web.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-web.js +21 -0
- package/build/components/DatePicker/time-picker/wheel-native.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel-native.js +19 -0
- package/build/components/DatePicker/time-picker/wheel-picker/index.d.ts +2 -0
- package/build/components/DatePicker/time-picker/wheel-picker/index.js +2 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.d.ts +16 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.js +97 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.d.ts +21 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.js +88 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.d.ts +23 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.js +21 -0
- package/build/components/DatePicker/time-picker/wheel-web.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel-web.js +146 -0
- package/build/components/DatePicker/time-picker/wheel.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel.js +10 -0
- package/build/components/List/List.js +2 -2
- package/build/components/Modal/Modal.js +31 -42
- package/build/components/Modal/Modal.web.js +3 -3
- package/build/components/Pagination/Pagination.d.ts +6 -0
- package/build/components/Pagination/Pagination.js +125 -0
- package/build/components/Pagination/Pagination.props.d.ts +26 -0
- package/build/components/Pagination/Pagination.props.js +1 -0
- package/build/components/Pagination/Pagination.utils.d.ts +2 -0
- package/build/components/Pagination/Pagination.utils.js +20 -0
- package/build/components/Pagination/Pagination.utils.test.d.ts +1 -0
- package/build/components/Pagination/Pagination.utils.test.js +16 -0
- package/build/components/Pagination/index.d.ts +2 -0
- package/build/components/Pagination/index.js +1 -0
- package/build/components/SafeAreaView/SafeAreaView.d.ts +5 -0
- package/build/components/SafeAreaView/SafeAreaView.js +117 -0
- package/build/components/SafeAreaView/SafeAreaView.props.d.ts +17 -0
- package/build/components/SafeAreaView/SafeAreaView.props.js +1 -0
- package/build/components/SafeAreaView/index.d.ts +2 -0
- package/build/components/SafeAreaView/index.js +1 -0
- package/build/components/Select/Select.d.ts +1 -1
- package/build/components/Select/Select.js +6 -5
- package/build/components/Select/Select.props.d.ts +4 -0
- package/build/components/Select/SelectOption.d.ts +1 -1
- package/build/components/Select/SelectOption.js +2 -2
- package/build/components/Table/Table.context.d.ts +12 -0
- package/build/components/Table/Table.context.js +9 -0
- package/build/components/Table/Table.d.ts +6 -0
- package/build/components/Table/Table.js +71 -0
- package/build/components/Table/Table.props.d.ts +56 -0
- package/build/components/Table/Table.props.js +1 -0
- package/build/components/Table/Table.utils.d.ts +5 -0
- package/build/components/Table/Table.utils.js +48 -0
- package/build/components/Table/Table.utils.test.d.ts +1 -0
- package/build/components/Table/Table.utils.test.js +71 -0
- package/build/components/Table/TableBody.d.ts +6 -0
- package/build/components/Table/TableBody.js +16 -0
- package/build/components/Table/TableCell.d.ts +10 -0
- package/build/components/Table/TableCell.js +44 -0
- package/build/components/Table/TableHeader.d.ts +6 -0
- package/build/components/Table/TableHeader.js +24 -0
- package/build/components/Table/TableHeaderCell.d.ts +10 -0
- package/build/components/Table/TableHeaderCell.js +97 -0
- package/build/components/Table/TablePagination.d.ts +6 -0
- package/build/components/Table/TablePagination.js +7 -0
- package/build/components/Table/TableRow.d.ts +8 -0
- package/build/components/Table/TableRow.js +25 -0
- package/build/components/Table/index.d.ts +8 -0
- package/build/components/Table/index.js +7 -0
- package/build/components/Timeline/Timeline.d.ts +6 -0
- package/build/components/Timeline/Timeline.js +34 -0
- package/build/components/Timeline/Timeline.props.d.ts +47 -0
- package/build/components/Timeline/Timeline.props.js +1 -0
- package/build/components/Timeline/TimelineItem.d.ts +6 -0
- package/build/components/Timeline/TimelineItem.js +235 -0
- package/build/components/Timeline/index.d.ts +3 -0
- package/build/components/Timeline/index.js +2 -0
- package/build/components/VerificationInput/VerificationInput.js +3 -3
- package/build/components/index.d.ts +5 -0
- package/build/components/index.js +5 -0
- package/build/tokens/components/dark/timeline.d.ts +2 -2
- package/build/tokens/components/dark/timeline.js +2 -2
- package/docs/components/AllComponents.web.tsx +106 -23
- package/docs/llm-docs/unistyles-llms-full.txt +1132 -534
- package/docs/llm-docs/unistyles-llms-small.txt +37 -37
- package/package.json +4 -4
- package/src/components/Button/Button.stories.tsx +43 -7
- package/src/components/Button/ButtonRoot.tsx +8 -0
- package/src/components/Combobox/Combobox.context.ts +26 -0
- package/src/components/Combobox/Combobox.docs.mdx +277 -0
- package/src/components/Combobox/Combobox.figma.tsx +60 -0
- package/src/components/Combobox/Combobox.props.ts +187 -0
- package/src/components/Combobox/Combobox.stories.tsx +233 -0
- package/src/components/Combobox/Combobox.tsx +446 -0
- package/src/components/Combobox/ComboboxOption.tsx +100 -0
- package/src/components/Combobox/index.ts +9 -0
- package/src/components/List/List.tsx +5 -4
- package/src/components/Modal/Modal.tsx +67 -74
- package/src/components/Modal/Modal.web.tsx +3 -3
- package/src/components/Pagination/Pagination.docs.mdx +99 -0
- package/src/components/Pagination/Pagination.figma.tsx +20 -0
- package/src/components/Pagination/Pagination.props.ts +28 -0
- package/src/components/Pagination/Pagination.stories.tsx +88 -0
- package/src/components/Pagination/Pagination.tsx +248 -0
- package/src/components/Pagination/Pagination.utils.test.ts +20 -0
- package/src/components/Pagination/Pagination.utils.ts +37 -0
- package/src/components/Pagination/index.ts +2 -0
- package/src/components/SafeAreaView/SafeAreaView.props.ts +20 -0
- package/src/components/SafeAreaView/SafeAreaView.tsx +173 -0
- package/src/components/SafeAreaView/index.ts +2 -0
- package/src/components/Select/Select.props.ts +4 -0
- package/src/components/Select/Select.tsx +35 -28
- package/src/components/Select/SelectOption.tsx +2 -0
- package/src/components/Table/Table.context.tsx +23 -0
- package/src/components/Table/Table.docs.mdx +239 -0
- package/src/components/Table/Table.figma.tsx +65 -0
- package/src/components/Table/Table.props.ts +65 -0
- package/src/components/Table/Table.stories.tsx +399 -0
- package/src/components/Table/Table.tsx +127 -0
- package/src/components/Table/Table.utils.test.ts +82 -0
- package/src/components/Table/Table.utils.ts +72 -0
- package/src/components/Table/TableBody.tsx +25 -0
- package/src/components/Table/TableCell.tsx +67 -0
- package/src/components/Table/TableHeader.tsx +41 -0
- package/src/components/Table/TableHeaderCell.tsx +136 -0
- package/src/components/Table/TablePagination.tsx +10 -0
- package/src/components/Table/TableRow.tsx +42 -0
- package/src/components/Table/index.ts +16 -0
- package/src/components/Timeline/Timeline.docs.mdx +177 -0
- package/src/components/Timeline/Timeline.figma.tsx +89 -0
- package/src/components/Timeline/Timeline.props.ts +51 -0
- package/src/components/Timeline/Timeline.stories.tsx +102 -0
- package/src/components/Timeline/Timeline.tsx +48 -0
- package/src/components/Timeline/TimelineItem.tsx +293 -0
- package/src/components/Timeline/index.ts +9 -0
- package/src/components/VerificationInput/VerificationInput.tsx +3 -0
- package/src/components/index.ts +5 -0
- package/src/tokens/components/dark/timeline.ts +2 -2
|
@@ -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,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,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,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;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ViewProps } from 'react-native';
|
|
2
|
+
export type TimelineVariant = 'static' | 'progress';
|
|
3
|
+
export type TimelineItemState = 'complete' | 'active' | 'incomplete';
|
|
4
|
+
export type TimelineItemPosition = 'single' | 'start' | 'middle' | 'end';
|
|
5
|
+
export interface TimelineProps extends ViewProps {
|
|
6
|
+
/**
|
|
7
|
+
* Child TimelineItem components.
|
|
8
|
+
*/
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Controls the indicator style used by all child timeline items.
|
|
12
|
+
* @default 'static'
|
|
13
|
+
*/
|
|
14
|
+
variant?: TimelineVariant;
|
|
15
|
+
}
|
|
16
|
+
export interface TimelineItemProps extends ViewProps {
|
|
17
|
+
/**
|
|
18
|
+
* The primary label for the timeline item.
|
|
19
|
+
*/
|
|
20
|
+
label: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional supporting text displayed beneath the label.
|
|
23
|
+
*/
|
|
24
|
+
helperText?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Visual state for progress timelines.
|
|
27
|
+
* @default 'incomplete'
|
|
28
|
+
*/
|
|
29
|
+
state?: TimelineItemState;
|
|
30
|
+
/**
|
|
31
|
+
* Optional custom content rendered beneath the text content.
|
|
32
|
+
*/
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* The timeline variant used when the item is rendered standalone.
|
|
36
|
+
* Items inside Timeline receive this automatically.
|
|
37
|
+
* @default 'static'
|
|
38
|
+
*/
|
|
39
|
+
variant?: TimelineVariant;
|
|
40
|
+
/**
|
|
41
|
+
* The item's position in the timeline used to draw connectors.
|
|
42
|
+
* Items inside Timeline receive this automatically.
|
|
43
|
+
* @default 'single'
|
|
44
|
+
*/
|
|
45
|
+
position?: TimelineItemPosition;
|
|
46
|
+
}
|
|
47
|
+
export default TimelineProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TimelineItemProps } from './Timeline.props';
|
|
2
|
+
declare const TimelineItem: {
|
|
3
|
+
({ children, helperText, label, position, state, style, variant, accessibilityLabel: accessibilityLabelProp, accessible: accessibleProp, ...rest }: TimelineItemProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export default TimelineItem;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TickSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import { BodyText } from '../BodyText';
|
|
6
|
+
import { Icon } from '../Icon';
|
|
7
|
+
const TimelineItem = ({ children, helperText, label, position = 'single', state = 'incomplete', style, variant = 'static', accessibilityLabel: accessibilityLabelProp, accessible: accessibleProp, ...rest }) => {
|
|
8
|
+
styles.useVariants({ position, state, variant });
|
|
9
|
+
const hasCustomContent = Boolean(children);
|
|
10
|
+
const computedAccessibilityLabel = [
|
|
11
|
+
label,
|
|
12
|
+
helperText,
|
|
13
|
+
variant === 'progress' ? `Step ${state}` : undefined,
|
|
14
|
+
]
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.join(', ');
|
|
17
|
+
return (_jsxs(View, { style: [styles.item, style], ...rest, accessible: accessibleProp ?? !hasCustomContent, accessibilityLabel: (accessibleProp ?? !hasCustomContent)
|
|
18
|
+
? (accessibilityLabelProp ?? computedAccessibilityLabel)
|
|
19
|
+
: undefined, children: [_jsxs(View, { style: styles.indicatorColumn, children: [(position === 'middle' || position === 'end') && _jsx(View, { style: styles.topConnector }), _jsx(View, { style: styles.circle, children: variant === 'progress' && state === 'complete' ? (_jsx(Icon, { as: TickSmallIcon, width: 20, height: 20, style: styles.completeIcon })) : variant === 'progress' && state === 'active' ? (_jsx(View, { style: styles.activeInnerDot })) : null }), (position === 'start' || position === 'middle') && _jsx(View, { style: styles.bottomConnector })] }), _jsxs(View, { style: styles.content, children: [_jsxs(View, { style: styles.textContent, accessible: hasCustomContent, accessibilityLabel: hasCustomContent ? (accessibilityLabelProp ?? computedAccessibilityLabel) : undefined, children: [_jsx(BodyText, { size: "md", weight: "semibold", style: styles.label, children: label }), helperText ? (_jsx(BodyText, { size: "md", style: styles.helperText, children: helperText })) : null] }), children ? _jsx(View, { style: styles.customContent, children: children }) : null] })] }));
|
|
20
|
+
};
|
|
21
|
+
TimelineItem.displayName = 'TimelineItem';
|
|
22
|
+
const styles = StyleSheet.create(theme => ({
|
|
23
|
+
item: {
|
|
24
|
+
flexDirection: 'row',
|
|
25
|
+
gap: theme.components.timeline.gap,
|
|
26
|
+
width: '100%',
|
|
27
|
+
},
|
|
28
|
+
indicatorColumn: {
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
variants: {
|
|
31
|
+
variant: {
|
|
32
|
+
static: {
|
|
33
|
+
width: theme.components.timeline.static.circle.width,
|
|
34
|
+
},
|
|
35
|
+
progress: {
|
|
36
|
+
width: theme.components.timeline.progress.circle.width,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
topConnector: {
|
|
42
|
+
width: theme.components.timeline.bar.width,
|
|
43
|
+
variants: {
|
|
44
|
+
variant: {
|
|
45
|
+
static: {
|
|
46
|
+
height: theme.components.timeline.static.circle.height / 2,
|
|
47
|
+
backgroundColor: theme.color.surface.brand.default,
|
|
48
|
+
},
|
|
49
|
+
progress: {
|
|
50
|
+
height: 0,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
state: {
|
|
54
|
+
complete: {},
|
|
55
|
+
active: {},
|
|
56
|
+
incomplete: {},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
compoundVariants: [
|
|
60
|
+
{
|
|
61
|
+
variant: 'progress',
|
|
62
|
+
state: 'complete',
|
|
63
|
+
styles: {
|
|
64
|
+
backgroundColor: theme.color.surface.brand.default,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
variant: 'progress',
|
|
69
|
+
state: 'active',
|
|
70
|
+
styles: {
|
|
71
|
+
backgroundColor: theme.color.surface.brand.default,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
variant: 'progress',
|
|
76
|
+
state: 'incomplete',
|
|
77
|
+
styles: {
|
|
78
|
+
backgroundColor: theme.color.border.subtle,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
bottomConnector: {
|
|
84
|
+
flex: 1,
|
|
85
|
+
minHeight: theme.components.timeline.content.paddingBottom,
|
|
86
|
+
width: theme.components.timeline.bar.width,
|
|
87
|
+
variants: {
|
|
88
|
+
variant: {
|
|
89
|
+
static: {
|
|
90
|
+
backgroundColor: theme.color.surface.brand.default,
|
|
91
|
+
},
|
|
92
|
+
progress: {},
|
|
93
|
+
},
|
|
94
|
+
state: {
|
|
95
|
+
complete: {},
|
|
96
|
+
active: {},
|
|
97
|
+
incomplete: {},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
compoundVariants: [
|
|
101
|
+
{
|
|
102
|
+
variant: 'progress',
|
|
103
|
+
state: 'complete',
|
|
104
|
+
styles: {
|
|
105
|
+
backgroundColor: theme.color.surface.brand.default,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
variant: 'progress',
|
|
110
|
+
state: 'active',
|
|
111
|
+
styles: {
|
|
112
|
+
backgroundColor: theme.color.border.subtle,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
variant: 'progress',
|
|
117
|
+
state: 'incomplete',
|
|
118
|
+
styles: {
|
|
119
|
+
backgroundColor: theme.color.border.subtle,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
circle: {
|
|
125
|
+
borderRadius: theme.borderRadius.full,
|
|
126
|
+
alignItems: 'center',
|
|
127
|
+
justifyContent: 'center',
|
|
128
|
+
padding: 2,
|
|
129
|
+
variants: {
|
|
130
|
+
variant: {
|
|
131
|
+
static: {
|
|
132
|
+
width: theme.components.timeline.static.circle.width,
|
|
133
|
+
height: theme.components.timeline.static.circle.height,
|
|
134
|
+
backgroundColor: theme.color.surface.brand.default,
|
|
135
|
+
},
|
|
136
|
+
progress: {
|
|
137
|
+
width: theme.components.timeline.progress.circle.width,
|
|
138
|
+
height: theme.components.timeline.progress.circle.height,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
state: {
|
|
142
|
+
complete: {},
|
|
143
|
+
active: {},
|
|
144
|
+
incomplete: {},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
compoundVariants: [
|
|
148
|
+
{
|
|
149
|
+
variant: 'progress',
|
|
150
|
+
state: 'complete',
|
|
151
|
+
styles: {
|
|
152
|
+
backgroundColor: theme.color.surface.brand.default,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
variant: 'progress',
|
|
157
|
+
state: 'active',
|
|
158
|
+
styles: {
|
|
159
|
+
backgroundColor: theme.color.surface.neutral.subtle,
|
|
160
|
+
borderWidth: theme.borderWidth[2],
|
|
161
|
+
borderColor: theme.color.surface.brand.default,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
variant: 'progress',
|
|
166
|
+
state: 'incomplete',
|
|
167
|
+
styles: {
|
|
168
|
+
backgroundColor: theme.color.surface.neutral.subtle,
|
|
169
|
+
borderWidth: theme.borderWidth[2],
|
|
170
|
+
borderColor: theme.color.border.subtle,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
activeInnerDot: {
|
|
176
|
+
width: '100%',
|
|
177
|
+
height: '100%',
|
|
178
|
+
borderRadius: theme.borderRadius.full,
|
|
179
|
+
backgroundColor: theme.color.surface.brand.default,
|
|
180
|
+
},
|
|
181
|
+
completeIcon: {
|
|
182
|
+
color: theme.color.text.inverted,
|
|
183
|
+
},
|
|
184
|
+
content: {
|
|
185
|
+
flex: 1,
|
|
186
|
+
minWidth: 0,
|
|
187
|
+
gap: theme.components.timeline.content.gap,
|
|
188
|
+
variants: {
|
|
189
|
+
position: {
|
|
190
|
+
single: {
|
|
191
|
+
paddingBottom: 0,
|
|
192
|
+
},
|
|
193
|
+
start: {
|
|
194
|
+
paddingBottom: theme.components.timeline.content.paddingBottom,
|
|
195
|
+
},
|
|
196
|
+
middle: {
|
|
197
|
+
paddingBottom: theme.components.timeline.content.paddingBottom,
|
|
198
|
+
},
|
|
199
|
+
end: {
|
|
200
|
+
paddingBottom: 0,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
variant: {
|
|
204
|
+
static: {
|
|
205
|
+
paddingTop: 0,
|
|
206
|
+
},
|
|
207
|
+
progress: {
|
|
208
|
+
paddingTop: theme.components.timeline.content.paddingTop,
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
compoundVariants: [
|
|
213
|
+
{
|
|
214
|
+
position: 'start',
|
|
215
|
+
variant: 'static',
|
|
216
|
+
styles: {
|
|
217
|
+
marginTop: -6,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
textContent: {
|
|
223
|
+
width: '100%',
|
|
224
|
+
},
|
|
225
|
+
label: {
|
|
226
|
+
color: theme.color.text.primary,
|
|
227
|
+
},
|
|
228
|
+
helperText: {
|
|
229
|
+
color: theme.color.text.secondary,
|
|
230
|
+
},
|
|
231
|
+
customContent: {
|
|
232
|
+
width: '100%',
|
|
233
|
+
},
|
|
234
|
+
}));
|
|
235
|
+
export default TimelineItem;
|
|
@@ -5,7 +5,7 @@ import { StyleSheet } from 'react-native-unistyles';
|
|
|
5
5
|
import { FormField } from '../FormField';
|
|
6
6
|
import { getNextIndexFromValueChange } from './VerificationInput.utils';
|
|
7
7
|
import { VerificationInputSlot } from './VerificationInputSlot';
|
|
8
|
-
const VerificationInput = forwardRef(({ value = '', onChangeText, label, labelVariant = 'body', helperText, helperIcon, validationStatus = 'initial', validText, invalidText, disabled = false, readonly = false, secureTextEntry = false, autoFocus = false, style, ...props }, ref) => {
|
|
8
|
+
const VerificationInput = forwardRef(({ value = '', onChangeText, label, labelVariant = 'body', helperText, helperIcon, validationStatus = 'initial', validText, invalidText, disabled = false, readonly = false, secureTextEntry = false, autoFocus = false, style, testID, ...props }, ref) => {
|
|
9
9
|
const length = 6;
|
|
10
10
|
const inputRef = useRef(null);
|
|
11
11
|
const latestValueRef = useRef(value);
|
|
@@ -160,7 +160,7 @@ const VerificationInput = forwardRef(({ value = '', onChangeText, label, labelVa
|
|
|
160
160
|
latestSelectionRef.current = nextSelection;
|
|
161
161
|
setSelection(nextSelection);
|
|
162
162
|
setFocusedIndex(Math.min(nextSelection.start, length - 1));
|
|
163
|
-
}, onFocus: handleFocus, onBlur: handleBlur, selection: selection, keyboardType: "number-pad", textContentType: "oneTimeCode", autoComplete: "sms-otp", secureTextEntry: secureTextEntry, maxLength: length, caretHidden: true, style: styles.hiddenInput }), slots.map(index => {
|
|
163
|
+
}, onFocus: handleFocus, onBlur: handleBlur, selection: selection, keyboardType: "number-pad", textContentType: "oneTimeCode", autoComplete: "sms-otp", secureTextEntry: secureTextEntry, maxLength: length, caretHidden: true, style: styles.hiddenInput, testID: testID }), slots.map(index => {
|
|
164
164
|
const char = displayValue[index] || '';
|
|
165
165
|
const isActive = focusedIndex === index;
|
|
166
166
|
const displayChar = secureTextEntry && char ? '*' : char;
|
|
@@ -168,7 +168,7 @@ const VerificationInput = forwardRef(({ value = '', onChangeText, label, labelVa
|
|
|
168
168
|
pendingFocusIndexRef.current = index;
|
|
169
169
|
inputRef.current?.focus();
|
|
170
170
|
setSelectionIndex(index);
|
|
171
|
-
} }, index));
|
|
171
|
+
}, testID: testID ? `${testID}-${index}` : undefined }, index));
|
|
172
172
|
})] }) }));
|
|
173
173
|
});
|
|
174
174
|
const styles = StyleSheet.create(theme => ({
|