@kanso-labs/react-native-kanso-ui 0.10.0 → 0.11.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.
Files changed (46) hide show
  1. package/dist/collection/index.js +107 -80
  2. package/dist/collection/index.js.map +1 -1
  3. package/dist/components/chip/index.d.ts +4 -1
  4. package/dist/components/chip/index.js +229 -161
  5. package/dist/components/chip/index.js.map +1 -1
  6. package/dist/components/dialog/index.d.ts +5 -5
  7. package/dist/components/dialog/index.js +5 -5
  8. package/dist/components/dialog/index.js.map +1 -1
  9. package/dist/components/drop-zone/index.d.ts +3 -3
  10. package/dist/components/drop-zone/index.js +2 -2
  11. package/dist/components/drop-zone/index.js.map +1 -1
  12. package/dist/components/menu/index.d.ts +3 -3
  13. package/dist/components/menu/index.js +3 -3
  14. package/dist/components/menu/index.js.map +1 -1
  15. package/dist/components/popover/index.d.ts +2 -2
  16. package/dist/components/popover/index.js +2 -2
  17. package/dist/components/popover/index.js.map +1 -1
  18. package/dist/components/search-view/index.d.ts +3 -2
  19. package/dist/components/search-view/index.js +3 -2
  20. package/dist/components/search-view/index.js.map +1 -1
  21. package/dist/components/sheet/index.d.ts +16 -7
  22. package/dist/components/sheet/index.js +157 -152
  23. package/dist/components/sheet/index.js.map +1 -1
  24. package/dist/components/table/index.d.ts +391 -0
  25. package/dist/components/table/index.js +1708 -0
  26. package/dist/components/table/index.js.map +1 -0
  27. package/dist/components/token-field/index.d.ts +105 -0
  28. package/dist/components/token-field/index.js +574 -0
  29. package/dist/components/token-field/index.js.map +1 -0
  30. package/dist/components/tooltip/index.d.ts +2 -1
  31. package/dist/components/tooltip/index.js.map +1 -1
  32. package/dist/field/index.js +50 -1
  33. package/dist/field/index.js.map +1 -1
  34. package/dist/field/styles.js +9 -1
  35. package/dist/field/styles.js.map +1 -1
  36. package/dist/glyphs/index.js +37 -1
  37. package/dist/glyphs/index.js.map +1 -1
  38. package/dist/i18n/index.js +17 -1
  39. package/dist/i18n/index.js.map +1 -1
  40. package/dist/i18n/messages.js +340 -0
  41. package/dist/i18n/messages.js.map +1 -1
  42. package/dist/index.d.ts +4 -2
  43. package/dist/index.js +4 -2
  44. package/dist/slider/index.js +1 -1
  45. package/dist/slider/index.js.map +1 -1
  46. package/package.json +6 -6
@@ -0,0 +1,391 @@
1
+ import { CollectionLoadMoreProps } from "../../collection/index.js";
2
+ import { FlatList, HostInstance, PressableProps, ScrollViewProps, StyleProp, ViewStyle } from "react-native";
3
+ import { ReactElement, ReactNode, Ref } from "react";
4
+ import { DisabledBehavior, Key, Node, Selection, SelectionMode, SortDescriptor } from "react-stately";
5
+ import { ColumnSize, ColumnStaticSize } from "react-stately/useTableState";
6
+ //#region src/components/table/index.d.ts
7
+ /**
8
+ * What a part's entry is built with: the columns the header has given so
9
+ * far, which a row reads its cells against.
10
+ */
11
+ type BuilderContext = {
12
+ columns: Node<unknown>[];
13
+ };
14
+ type TableBodyProps<T extends object = object> = {
15
+ /**
16
+ * The rows, each a `Table.Row`, with a `Table.LoadMore` after them. With
17
+ * `items`, a function from an item to its row, called for each in turn.
18
+ */
19
+ readonly children?: ((item: T) => ReactElement) | ReactNode;
20
+ /** The entries `children` draws a row for, when it is a function. */
21
+ readonly items?: Iterable<T>;
22
+ /**
23
+ * What the table shows in place of rows when it has none and nothing is
24
+ * loading, in a muted, padded box across its width. A string is set in
25
+ * body medium.
26
+ */
27
+ readonly renderEmptyState?: () => ReactNode;
28
+ };
29
+ type TableCellProps = {
30
+ /** What the cell holds. A string is set in body medium. */
31
+ readonly children?: ReactNode;
32
+ /**
33
+ * How many columns the cell spans, from where it sits.
34
+ * @default 1
35
+ */
36
+ readonly colSpan?: number;
37
+ /**
38
+ * Draws this row's selection checkbox instead of `children`. The row's own
39
+ * text is what names the row.
40
+ */
41
+ readonly selection?: boolean;
42
+ readonly style?: StyleProp<ViewStyle>;
43
+ readonly testID?: string;
44
+ /** The cell's text, read off `children` when they are a plain string. */
45
+ readonly textValue?: string;
46
+ };
47
+ type TableColumnProps = {
48
+ /**
49
+ * Makes the header itself the control that sorts by the column, as
50
+ * React Aria's prop does. The arrow appears on the column the table's
51
+ * `sortDescriptor` names.
52
+ * @default false
53
+ */
54
+ readonly allowsSorting?: boolean;
55
+ /** The column's name. */
56
+ readonly children?: ReactNode;
57
+ /** The width the column starts at, when the table keeps its widths. */
58
+ readonly defaultWidth?: ColumnSize | null;
59
+ /**
60
+ * The key the column is sorted and sized by. It shares a namespace with
61
+ * the rows' ids, so give the two sets values that cannot meet.
62
+ */
63
+ readonly id?: Key;
64
+ /**
65
+ * Marks the column a screen reader reads a row by on web. Kept for a call
66
+ * site written for both libraries; native reads every cell of a row.
67
+ * @default false
68
+ */
69
+ readonly isRowHeader?: boolean;
70
+ /** The widest the column is drawn. */
71
+ readonly maxWidth?: ColumnStaticSize | null;
72
+ /**
73
+ * The narrowest the column is drawn.
74
+ * @default 75
75
+ */
76
+ readonly minWidth?: ColumnStaticSize | null;
77
+ /**
78
+ * Draws a handle at the column's trailing edge that drags its width. Needs
79
+ * the table's own `resizable` as well.
80
+ * @default false
81
+ */
82
+ readonly resizable?: boolean;
83
+ /**
84
+ * Draws the select-all checkbox instead of `children`, for the column the
85
+ * rows put their own checkboxes in.
86
+ * @default false
87
+ */
88
+ readonly selection?: boolean;
89
+ readonly style?: StyleProp<ViewStyle>;
90
+ readonly testID?: string;
91
+ /** The column's name as text, read off `children` when it is a string. */
92
+ readonly textValue?: string;
93
+ /** The column's width, for a call site holding the widths itself. */
94
+ readonly width?: ColumnSize | null;
95
+ };
96
+ type TableFooterProps = {
97
+ /** The rows under the body, each a `Table.Row` of `Table.Cell`s. */
98
+ readonly children?: ReactNode;
99
+ readonly style?: StyleProp<ViewStyle>;
100
+ readonly testID?: string;
101
+ };
102
+ type TableHeaderProps<T extends object = object> = {
103
+ /**
104
+ * The columns, each a `Table.Column`. With `columns`, a function from an
105
+ * entry to its column, called for each in turn.
106
+ */
107
+ readonly children?: ((column: T) => ReactElement) | ReactNode;
108
+ /** The entries `children` draws a column for, when it is a function. */
109
+ readonly columns?: Iterable<T>;
110
+ readonly style?: StyleProp<ViewStyle>;
111
+ readonly testID?: string;
112
+ };
113
+ type TableLoadMoreProps = CollectionLoadMoreProps;
114
+ type TableProps = Omit<ScrollViewProps, 'children' | 'horizontal' | 'role' | 'stickyHeaderIndices' | 'style'> & {
115
+ /**
116
+ * The parts: a `Table.Header`, a `Table.Body` and, under them, a
117
+ * `Table.Footer`.
118
+ */
119
+ readonly children?: ReactNode;
120
+ /** The keys selected at first, when the table keeps its own selection. */
121
+ readonly defaultSelectedKeys?: 'all' | Iterable<Key>;
122
+ /**
123
+ * Whether `disabledKeys` takes every press off a row, or only its
124
+ * selection, as React Aria's prop says.
125
+ * @default 'all'
126
+ */
127
+ readonly disabledBehavior?: DisabledBehavior;
128
+ /** The keys of the rows drawn disabled. */
129
+ readonly disabledKeys?: Iterable<Key>;
130
+ /**
131
+ * Keeps the last selected row selected, so a press on it changes nothing.
132
+ * @default false
133
+ */
134
+ readonly disallowEmptySelection?: boolean;
135
+ /** Called as a column is dragged, with every column's width. */
136
+ readonly onResize?: (widths: Map<Key, ColumnSize>) => void;
137
+ /** Called once a drag ends, with every column's width. */
138
+ readonly onResizeEnd?: (widths: Map<Key, ColumnSize>) => void;
139
+ /**
140
+ * Called with a row's key when a press runs its action. A row's own
141
+ * `onAction` takes its place for that row.
142
+ */
143
+ readonly onRowAction?: (key: Key) => void;
144
+ /** Called with the selected keys whenever a press changes them. */
145
+ readonly onSelectionChange?: (keys: Selection) => void;
146
+ /** Called with the column and direction a press on a header asks for. */
147
+ readonly onSortChange?: (descriptor: SortDescriptor) => void;
148
+ readonly ref?: Ref<FlatList>;
149
+ /**
150
+ * Lets the columns marked `resizable` be dragged.
151
+ * @default false
152
+ */
153
+ readonly resizable?: boolean;
154
+ /**
155
+ * What a resize handle is called, for a screen reader, before its column's
156
+ * name. Left out, it is the word for it in the `I18nProvider`'s language,
157
+ * or the device's outside one, "Resizer" in English.
158
+ */
159
+ readonly resizeLabel?: string;
160
+ /**
161
+ * What the select-all checkbox is called, for a screen reader. Left out,
162
+ * it is the word for it in the `I18nProvider`'s language, or the device's
163
+ * outside one, "Select All" in English, or "Select" while one row at a
164
+ * time selects.
165
+ */
166
+ readonly selectAllLabel?: string;
167
+ /** The selected keys, for a call site holding the selection itself. */
168
+ readonly selectedKeys?: 'all' | Iterable<Key>;
169
+ /**
170
+ * Whether rows can be selected: one at a time, several, or none.
171
+ * @default 'none'
172
+ */
173
+ readonly selectionMode?: SelectionMode;
174
+ /**
175
+ * What selecting a row is called, for a screen reader: the accessibility
176
+ * action that selects a row. Left out, it is the word for it in the
177
+ * `I18nProvider`'s language, or the device's outside one, "Select" in
178
+ * English.
179
+ */
180
+ readonly selectLabel?: string;
181
+ /** The column the rows are sorted by, and in which direction. */
182
+ readonly sortDescriptor?: SortDescriptor;
183
+ /**
184
+ * Holds the header row in place while the rows scroll under it. Needs the
185
+ * table to have a height to scroll in.
186
+ * @default false
187
+ */
188
+ readonly stickyHeader?: boolean;
189
+ readonly style?: StyleProp<ViewStyle>;
190
+ };
191
+ type TableRowProps<T extends object = object> = Omit<PressableProps, 'children' | 'disabled' | 'id' | 'role' | 'style'> & {
192
+ /**
193
+ * The row's cells, one `Table.Cell` for each column it spans, or a
194
+ * function from a column's key to its cell.
195
+ */
196
+ readonly children?: ((columnKey: Key) => ReactElement) | ReactNode;
197
+ /** Goes to this route when a press runs the row's action. */
198
+ readonly href?: string;
199
+ /**
200
+ * The key the row is selected and reported by. Give one to every row, and
201
+ * keep it apart from every column's.
202
+ */
203
+ readonly id?: Key;
204
+ /**
205
+ * Draws the row disabled, as a key in the table's `disabledKeys` does.
206
+ * @default false
207
+ */
208
+ readonly isDisabled?: boolean;
209
+ /**
210
+ * Called when a press runs the row's action, in place of the table's
211
+ * `onRowAction` for this row.
212
+ */
213
+ readonly onAction?: () => void;
214
+ readonly ref?: Ref<HostInstance>;
215
+ readonly style?: StyleProp<ViewStyle>;
216
+ /** The row's text, for a row whose cells hold elements. */
217
+ readonly textValue?: string;
218
+ /** The entry `children` was drawn for, kept on the row's node. */
219
+ readonly value?: T;
220
+ };
221
+ declare function bodyNode(props: TableBodyProps): Generator<{
222
+ childNodes(): Generator<{
223
+ renderer: (item: object) => ReactElement;
224
+ type: string;
225
+ value: object;
226
+ element?: undefined;
227
+ } | {
228
+ element: ReactNode;
229
+ type: string;
230
+ renderer?: undefined;
231
+ value?: undefined;
232
+ }, void, unknown>;
233
+ hasChildNodes: boolean;
234
+ props: TableBodyProps<object>;
235
+ type: string;
236
+ }, void, unknown>;
237
+ declare function cellNode(props: TableCellProps): Generator<{
238
+ hasChildNodes: boolean;
239
+ props: TableCellProps;
240
+ rendered: ReactNode;
241
+ textValue: string;
242
+ type: string;
243
+ }, void, unknown>;
244
+ declare function columnNode(props: TableColumnProps, context: BuilderContext): Generator<object, void, readonly Node<unknown>[]>;
245
+ declare function headerNodes(props: TableHeaderProps, context: BuilderContext): Generator<{
246
+ renderer: (column: object) => ReactElement;
247
+ type: string;
248
+ value: object;
249
+ element?: undefined;
250
+ } | {
251
+ element: ReactNode;
252
+ type: string;
253
+ renderer?: undefined;
254
+ value?: undefined;
255
+ }, void, unknown>;
256
+ declare function rowNode(props: TableRowProps, context: BuilderContext): Generator<{
257
+ 'aria-label': string | undefined;
258
+ childNodes(): Generator<{
259
+ element: ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
260
+ key: Key;
261
+ type: string;
262
+ } | {
263
+ element: ReactNode;
264
+ type: string;
265
+ key?: undefined;
266
+ }, void, unknown>;
267
+ hasChildNodes: boolean;
268
+ key: Key | undefined;
269
+ props: TableRowProps<object>;
270
+ shouldInvalidate(next: BuilderContext): boolean;
271
+ textValue: string | undefined;
272
+ type: string;
273
+ }, void, unknown>;
274
+ /**
275
+ * A grid of rows and columns. Sorting and selection are React Stately's, as
276
+ * web's are React Aria's: pass `sortDescriptor` with `onSortChange` and mark
277
+ * the sortable columns `allowsSorting`, and set `selectionMode` to `single`
278
+ * or `multiple` with `selectedKeys` and `onSelectionChange`, or
279
+ * `defaultSelectedKeys`.
280
+ *
281
+ * ```tsx
282
+ * <Table aria-label="Label" selectionMode="multiple">
283
+ * <Table.Header>
284
+ * <Table.Column id="colSelect" selection />
285
+ * <Table.Column id="colName" isRowHeader>Label</Table.Column>
286
+ * </Table.Header>
287
+ * <Table.Body>
288
+ * <Table.Row id="first">
289
+ * <Table.Cell selection />
290
+ * <Table.Cell>First item</Table.Cell>
291
+ * </Table.Row>
292
+ * </Table.Body>
293
+ * </Table>
294
+ * ```
295
+ *
296
+ * Composed from parts, since a cell takes any content: `Table.Header`,
297
+ * `Table.Column`, `Table.Body`, `Table.Row`, `Table.Cell`, `Table.LoadMore`
298
+ * and `Table.Footer`, which the table draws from their props, so none of them
299
+ * renders anything on its own. A column's `id` and a row's share one
300
+ * namespace, so keep the two sets apart, as `col`-prefixed column ids do.
301
+ * Name the table with `aria-label`.
302
+ *
303
+ * The columns fill the table's width, `1fr` each unless `defaultWidth` or
304
+ * `width` says otherwise, and the table scrolls sideways once they are wider
305
+ * than it is. The rows scroll by themselves, so a table on a page that
306
+ * scrolls takes `scrollEnabled={false}` and is laid out at its full length,
307
+ * and one with `stickyHeader` wants a height to fill. `style` lands on the
308
+ * box the table is drawn in, and `ref`, `aria-label`, `testID` and the
309
+ * scroll props on the `FlatList` that holds the rows.
310
+ *
311
+ * The rows take focus while they run past the table's height, as web's grid
312
+ * is a tab stop, so a keyboard can scroll them whatever they hold, and the
313
+ * sideways scroll does while the columns are wider than the table; a call
314
+ * site's own `focusable` still wins for the rows.
315
+ */
316
+ declare function Table({ children, defaultSelectedKeys, disabledBehavior, disabledKeys, disallowEmptySelection, onSelectionChange, onSortChange, selectedKeys, selectionMode, sortDescriptor, ...props }: TableProps): import("react").JSX.Element;
317
+ declare namespace Table {
318
+ var Body: typeof TableBody;
319
+ var Cell: typeof TableCell;
320
+ var Column: typeof TableColumn;
321
+ var Footer: typeof TableFooter;
322
+ var Header: typeof TableHeader;
323
+ var LoadMore: typeof TableLoadMore;
324
+ var Row: typeof TableRow;
325
+ }
326
+ /**
327
+ * The rows. `renderEmptyState` is what the table shows when there are none,
328
+ * and a `Table.LoadMore` after them is the row it shows while fetching
329
+ * more. The table draws it from its props, so it renders nothing on its
330
+ * own.
331
+ */
332
+ declare function TableBody<T extends object = object>(_props: TableBodyProps<T>): null;
333
+ declare namespace TableBody {
334
+ var getCollectionNode: typeof bodyNode;
335
+ }
336
+ /**
337
+ * One cell. `selection` draws this row's checkbox in place of whatever else
338
+ * the cell would hold. `style` and `testID` land on the cell.
339
+ */
340
+ declare function TableCell(_props: TableCellProps): null;
341
+ declare namespace TableCell {
342
+ var getCollectionNode: typeof cellNode;
343
+ }
344
+ /**
345
+ * One column. `allowsSorting` makes the header itself the control that
346
+ * sorts; the arrow appears on the column the `sortDescriptor` names.
347
+ * `selection` draws the select-all checkbox in place of a name. `style` and
348
+ * `testID` land on the column's header.
349
+ *
350
+ * Its `id` shares a namespace with the rows', so give the two sets values
351
+ * that cannot meet: a column and a row with one id between them leaves the
352
+ * table with no columns at all.
353
+ */
354
+ declare function TableColumn(_props: TableColumnProps): null;
355
+ declare namespace TableColumn {
356
+ var getCollectionNode: typeof columnNode;
357
+ }
358
+ /**
359
+ * Rows under the body, for totals and the like, ruled off from it. They are
360
+ * not part of the selection and take no press, as React Aria keeps a footer
361
+ * out of both. `style` and `testID` land on the footer.
362
+ */
363
+ declare function TableFooter(_props: TableFooterProps): null;
364
+ /**
365
+ * The header row, holding the columns, and the rule drawn under it. `style`
366
+ * and `testID` land on the row.
367
+ */
368
+ declare function TableHeader<T extends object = object>(_props: TableHeaderProps<T>): null;
369
+ declare namespace TableHeader {
370
+ var getCollectionNode: typeof headerNodes;
371
+ }
372
+ /**
373
+ * The row shown while more rows are being fetched. `onLoadMore` is called
374
+ * as the reader nears the end of the table, and the ring is drawn only while
375
+ * `isLoading`, in a live region, so a screen reader hears it arrive. It goes
376
+ * inside `Table.Body`, after the rows.
377
+ */
378
+ declare function TableLoadMore(_props: TableLoadMoreProps): null;
379
+ /**
380
+ * One row. Give every row an `id`, which is the key selection is reported
381
+ * by, and keep it apart from every column's. `onAction` runs when a press
382
+ * runs the row's action, and `href` goes to that route. `style`, `ref` and
383
+ * `testID` land on the row.
384
+ */
385
+ declare function TableRow<T extends object = object>(_props: TableRowProps<T>): null;
386
+ declare namespace TableRow {
387
+ var getCollectionNode: typeof rowNode;
388
+ }
389
+ //#endregion
390
+ export { Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableColumn, type TableColumnProps, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableLoadMore, type TableLoadMoreProps, type TableProps, TableRow, type TableRowProps };
391
+ //# sourceMappingURL=index.d.ts.map