@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,239 @@
1
+ import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
2
+ import {
3
+ Box,
4
+ Center,
5
+ Table,
6
+ TableBody,
7
+ TableCell,
8
+ TableHeader,
9
+ TableHeaderCell,
10
+ TablePagination,
11
+ TableRow,
12
+ } from '../..';
13
+ import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
14
+ import * as Stories from './Table.stories';
15
+
16
+ <Meta title="Components / Table" />
17
+
18
+ <BackToTopButton />
19
+
20
+ <ViewFigmaButton url="https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=6403-17515&t=pZwKJYFo1y1QRQD1-4" />
21
+
22
+ # Table
23
+
24
+ Table arranges structured data into rows and columns, with optional pagination beneath the rows. The React Native version uses horizontal scrolling automatically when the columns need more space than the viewport allows.
25
+
26
+ - [Playground](#playground)
27
+ - [Usage](#usage)
28
+ - [Props](#props)
29
+ - [Examples](#examples)
30
+
31
+ ## Playground
32
+
33
+ <Canvas of={Stories.Playground} />
34
+
35
+ <Controls of={Stories.Playground} />
36
+
37
+ ## Usage
38
+
39
+ <UsageWrap>
40
+ <Center>
41
+ <Box style={{ width: 520, maxWidth: '100%' }}>
42
+ <Table container="subtle">
43
+ <TableHeader color="purple">
44
+ <TableHeaderCell>Name</TableHeaderCell>
45
+ <TableHeaderCell>Email</TableHeaderCell>
46
+ <TableHeaderCell>City</TableHeaderCell>
47
+ </TableHeader>
48
+ <TableBody>
49
+ <TableRow>
50
+ <TableHeaderCell row>Alex Morgan</TableHeaderCell>
51
+ <TableCell>alex@example.com</TableCell>
52
+ <TableCell>London</TableCell>
53
+ </TableRow>
54
+ </TableBody>
55
+ </Table>
56
+ </Box>
57
+ </Center>
58
+ </UsageWrap>
59
+
60
+ ```tsx
61
+ import {
62
+ Table,
63
+ TableBody,
64
+ TableCell,
65
+ TableHeader,
66
+ TableHeaderCell,
67
+ TableRow,
68
+ } from '@utilitywarehouse/hearth-react-native';
69
+
70
+ const MyComponent = () => (
71
+ <Table container="subtle">
72
+ <TableHeader color="purple">
73
+ <TableHeaderCell>Name</TableHeaderCell>
74
+ <TableHeaderCell>Email</TableHeaderCell>
75
+ <TableHeaderCell>City</TableHeaderCell>
76
+ </TableHeader>
77
+ <TableBody>
78
+ <TableRow>
79
+ <TableHeaderCell row>Alex Morgan</TableHeaderCell>
80
+ <TableCell>alex@example.com</TableCell>
81
+ <TableCell>London</TableCell>
82
+ </TableRow>
83
+ </TableBody>
84
+ </Table>
85
+ );
86
+ ```
87
+
88
+ ## Props
89
+
90
+ ### Table Props
91
+
92
+ | Property | Type | Description | Default |
93
+ | -------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ----------- |
94
+ | `container` | `'none' \| 'subtle' \| 'emphasis'` | Applies the List-style outer container wrapping. | `'none'` |
95
+ | `columnWidths` | `(number \| '${number}fr' \| { flex: number })[]` | Optional per-column sizing. Use numbers for fixed widths and `'2fr'`-style values for flexible columns. | `undefined` |
96
+ | `pagination` | `ReactNode` | Optional pagination content rendered below the rows. | `undefined` |
97
+
98
+ ### TableHeader Props
99
+
100
+ | Property | Type | Description | Default |
101
+ | -------- | --------------------- | ------------------------------------------------- | ---------- |
102
+ | `color` | `'purple' \| 'white'` | Controls the header background and text contrast. | `'purple'` |
103
+
104
+ ### TableHeaderCell Props
105
+
106
+ | Property | Type | Description | Default |
107
+ | ----------------- | ----------- | ---------------------------------------------------------- | ----------- |
108
+ | `row` | `boolean` | Uses body-row header styling for the first cell in a row. | `false` |
109
+ | `trailingContent` | `ReactNode` | Optional content aligned to the trailing edge of the cell. | `undefined` |
110
+
111
+ ## Examples
112
+
113
+ ### Containers
114
+
115
+ <Canvas of={Stories.Variants} />
116
+
117
+ ```tsx
118
+ <Table container="subtle">
119
+ <TableHeader color="purple">
120
+ <TableHeaderCell>Name</TableHeaderCell>
121
+ <TableHeaderCell>Plan</TableHeaderCell>
122
+ <TableHeaderCell>Status</TableHeaderCell>
123
+ </TableHeader>
124
+ <TableBody>
125
+ <TableRow>
126
+ <TableHeaderCell row>Alex Morgan</TableHeaderCell>
127
+ <TableCell>Full Fibre 900</TableCell>
128
+ <TableCell>Active</TableCell>
129
+ </TableRow>
130
+ </TableBody>
131
+ </Table>
132
+ ```
133
+
134
+ ### With pagination
135
+
136
+ <Canvas of={Stories.WithPagination} />
137
+
138
+ ```tsx
139
+ const [currentPage, setCurrentPage] = useState(1);
140
+
141
+ <Table
142
+ container="subtle"
143
+ pagination={
144
+ <TablePagination currentPage={currentPage} onPageChange={setCurrentPage} totalPages={10} />
145
+ }
146
+ >
147
+ <TableHeader color="purple">
148
+ <TableHeaderCell>Name</TableHeaderCell>
149
+ <TableHeaderCell>Email</TableHeaderCell>
150
+ <TableHeaderCell>City</TableHeaderCell>
151
+ </TableHeader>
152
+ <TableBody>{/* paged rows */}</TableBody>
153
+ </Table>;
154
+ ```
155
+
156
+ ### Narrow viewport
157
+
158
+ <Canvas of={Stories.NarrowViewport} />
159
+
160
+ ```tsx
161
+ <Box style={{ width: 320 }}>
162
+ <Table container="subtle">
163
+ <TableHeader color="purple">
164
+ <TableHeaderCell>Account</TableHeaderCell>
165
+ <TableHeaderCell>Type</TableHeaderCell>
166
+ <TableHeaderCell>Monthly cost</TableHeaderCell>
167
+ <TableHeaderCell>Renewal</TableHeaderCell>
168
+ </TableHeader>
169
+ <TableBody>{/* rows */}</TableBody>
170
+ </Table>
171
+ </Box>
172
+ ```
173
+
174
+ ### Configured column widths
175
+
176
+ <Canvas of={Stories.ConfiguredColumnWidths} />
177
+
178
+ ```tsx
179
+ <Table columnWidths={[180, '2fr', '1fr', 140]} container="subtle">
180
+ <TableHeader color="purple">
181
+ <TableHeaderCell>Name</TableHeaderCell>
182
+ <TableHeaderCell>Email</TableHeaderCell>
183
+ <TableHeaderCell>Plan</TableHeaderCell>
184
+ <TableHeaderCell>Status</TableHeaderCell>
185
+ </TableHeader>
186
+ <TableBody>{/* rows */}</TableBody>
187
+ </Table>
188
+ ```
189
+
190
+ ### Custom sort function
191
+
192
+ <Canvas of={Stories.WithCustomSortFunction} />
193
+
194
+ ```tsx
195
+ const statusOrder = {
196
+ Active: 0,
197
+ Pending: 1,
198
+ Paused: 2,
199
+ Cancelled: 3,
200
+ } as const;
201
+
202
+ const sortRowsByStatus = (items, direction = 'asc') => {
203
+ const multiplier = direction === 'asc' ? 1 : -1;
204
+
205
+ return [...items].sort((left, right) => {
206
+ const statusDifference = (statusOrder[left.status] - statusOrder[right.status]) * multiplier;
207
+
208
+ if (statusDifference !== 0) {
209
+ return statusDifference;
210
+ }
211
+
212
+ return left.customer.localeCompare(right.customer) * multiplier;
213
+ });
214
+ };
215
+
216
+ const [direction, setDirection] = useState<'asc' | 'desc'>('asc');
217
+ const sortedRows = sortRowsByStatus(rows, direction);
218
+
219
+ <Table columnWidths={[180, '2fr', 120]} container="subtle">
220
+ <TableHeader color="purple">
221
+ <TableHeaderCell>Customer</TableHeaderCell>
222
+ <TableHeaderCell>Plan</TableHeaderCell>
223
+ <TableHeaderCell
224
+ trailingContent={
225
+ <UnstyledIconButton
226
+ accessibilityLabel="Sort by custom status order"
227
+ icon={ExpandSmallIcon}
228
+ inverted
229
+ onPress={() => setDirection(current => (current === 'asc' ? 'desc' : 'asc'))}
230
+ size="sm"
231
+ />
232
+ }
233
+ >
234
+ Status
235
+ </TableHeaderCell>
236
+ </TableHeader>
237
+ <TableBody>{/* sortedRows */}</TableBody>
238
+ </Table>;
239
+ ```
@@ -0,0 +1,65 @@
1
+ import figma from '@figma/code-connect';
2
+ import { ExpandSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
3
+ import { UnstyledIconButton } from '../UnstyledIconButton';
4
+ import { Table, TableBody, TableCell, TableHeader, TableHeaderCell, TableRow } from './';
5
+
6
+ figma.connect(
7
+ Table,
8
+ 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=6403-17515&t=pZwKJYFo1y1QRQD1-4',
9
+ {
10
+ props: {},
11
+ example: () => (
12
+ <Table container="subtle">
13
+ <TableHeader color="purple">
14
+ <TableHeaderCell
15
+ trailingContent={
16
+ <UnstyledIconButton
17
+ accessibilityLabel="Sort"
18
+ icon={ExpandSmallIcon}
19
+ inverted
20
+ size="sm"
21
+ />
22
+ }
23
+ >
24
+ Header
25
+ </TableHeaderCell>
26
+ <TableHeaderCell
27
+ trailingContent={
28
+ <UnstyledIconButton
29
+ accessibilityLabel="Sort"
30
+ icon={ExpandSmallIcon}
31
+ inverted
32
+ size="sm"
33
+ />
34
+ }
35
+ >
36
+ Header
37
+ </TableHeaderCell>
38
+ </TableHeader>
39
+ <TableBody>
40
+ <TableRow>
41
+ <TableHeaderCell row>Row title</TableHeaderCell>
42
+ <TableCell>Value</TableCell>
43
+ </TableRow>
44
+ </TableBody>
45
+ </Table>
46
+ ),
47
+ }
48
+ );
49
+
50
+ figma.connect(
51
+ TableHeaderCell,
52
+ 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=6414-6728&t=pZwKJYFo1y1QRQD1-4',
53
+ {
54
+ props: {},
55
+ example: () => (
56
+ <TableHeaderCell
57
+ trailingContent={
58
+ <UnstyledIconButton accessibilityLabel="Sort" icon={ExpandSmallIcon} size="sm" />
59
+ }
60
+ >
61
+ Header
62
+ </TableHeaderCell>
63
+ ),
64
+ }
65
+ );
@@ -0,0 +1,65 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ViewProps } from 'react-native';
3
+ import type PaginationProps from '../Pagination/Pagination.props';
4
+
5
+ export interface TableFlexibleColumnWidth {
6
+ flex: number;
7
+ }
8
+
9
+ export type TableColumnWidth = number | `${number}fr` | TableFlexibleColumnWidth;
10
+
11
+ export interface TableProps extends ViewProps {
12
+ /**
13
+ * Controls whether the table is wrapped in a card container.
14
+ * @default 'none'
15
+ */
16
+ container?: 'emphasis' | 'subtle' | 'none';
17
+ /**
18
+ * Optional per-column sizing using fixed pixel widths or flexible fractions.
19
+ * Use numbers for fixed widths and values like `'2fr'` for flexible columns.
20
+ * Objects like `{ flex: 2 }` are also supported internally.
21
+ * Unspecified columns default to `1fr`.
22
+ */
23
+ columnWidths?: TableColumnWidth[];
24
+ /**
25
+ * Optional pagination controls rendered beneath the rows.
26
+ */
27
+ pagination?: React.ReactElement<PaginationProps> | ReactNode;
28
+ }
29
+
30
+ export interface TableBodyProps extends ViewProps {
31
+ children: ReactNode;
32
+ }
33
+
34
+ export interface TableHeaderProps extends ViewProps {
35
+ children: ReactNode;
36
+ /**
37
+ * Visual style for header cells.
38
+ * @default 'purple'
39
+ */
40
+ color?: 'purple' | 'white';
41
+ }
42
+
43
+ export interface TableRowProps extends ViewProps {
44
+ children: ReactNode;
45
+ }
46
+
47
+ export interface TableCellProps extends ViewProps {
48
+ children?: ReactNode;
49
+ }
50
+
51
+ export interface TableHeaderCellProps extends ViewProps {
52
+ children?: ReactNode;
53
+ color?: 'purple' | 'white';
54
+ /**
55
+ * Renders the header cell as a row header within the body.
56
+ * @default false
57
+ */
58
+ row?: boolean;
59
+ /**
60
+ * Optional content aligned to the end of a header cell.
61
+ */
62
+ trailingContent?: ReactNode;
63
+ }
64
+
65
+ export type TablePaginationProps = PaginationProps;