@kanso-labs/react-native-kanso-ui 0.10.0 → 0.11.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.
- package/dist/collection/index.js +107 -80
- package/dist/collection/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +4 -1
- package/dist/components/chip/index.js +229 -161
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +5 -5
- package/dist/components/dialog/index.js +5 -5
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/drop-zone/index.d.ts +3 -3
- package/dist/components/drop-zone/index.js +2 -2
- package/dist/components/drop-zone/index.js.map +1 -1
- package/dist/components/menu/index.d.ts +3 -3
- package/dist/components/menu/index.js +3 -3
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/search-view/index.d.ts +3 -2
- package/dist/components/search-view/index.js +3 -2
- package/dist/components/search-view/index.js.map +1 -1
- package/dist/components/sheet/index.d.ts +16 -7
- package/dist/components/sheet/index.js +157 -152
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/table/index.d.ts +391 -0
- package/dist/components/table/index.js +1708 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/token-field/index.d.ts +105 -0
- package/dist/components/token-field/index.js +574 -0
- package/dist/components/token-field/index.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +2 -1
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/field/index.js +50 -1
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +9 -1
- package/dist/field/styles.js.map +1 -1
- package/dist/glyphs/index.js +37 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +17 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +340 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/slider/index.js +1 -1
- package/dist/slider/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,1708 @@
|
|
|
1
|
+
import { IconStyleContext } from "../../glyphs/icon-style.js";
|
|
2
|
+
import { useTheme } from "../../theme/scope.js";
|
|
3
|
+
import { composeStyles, themedStyles } from "../../theme/styles.js";
|
|
4
|
+
import { usePressFeedback } from "../../press/index.js";
|
|
5
|
+
import { useTypeRole } from "../../typography/roles.js";
|
|
6
|
+
import { rowContentColor, rowStyles } from "../../row/styles.js";
|
|
7
|
+
import { columnSizeFor, sortedFor } from "../../i18n/index.js";
|
|
8
|
+
import { useLocaleOf, useMessages } from "../../i18n/provider.js";
|
|
9
|
+
import { ArrowDownwardGlyph, ArrowUpwardGlyph } from "../../glyphs/index.js";
|
|
10
|
+
import { useOpenLink } from "../../router/index.js";
|
|
11
|
+
import { toggleState } from "../../button/index.js";
|
|
12
|
+
import { Checkbox } from "../checkbox/index.js";
|
|
13
|
+
import { ADJUSTABLE, SLOP_RANGE } from "../../slider/index.js";
|
|
14
|
+
import { LoadingRow, SelectBox, Status, accessibilityActionOf, childElementsOf, loadMoreOf, noop, pressThen } from "../../collection/index.js";
|
|
15
|
+
import { c } from "react/compiler-runtime";
|
|
16
|
+
import { FlatList, I18nManager, Pressable, ScrollView, StyleSheet, Text, View, useWindowDimensions } from "react-native";
|
|
17
|
+
import { useSharedValue } from "react-native-reanimated";
|
|
18
|
+
import { Children, createContext, isValidElement, use, useState } from "react";
|
|
19
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
import { Gesture, GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler";
|
|
21
|
+
import { useTableColumnResizeState, useTableState } from "react-stately/useTableState";
|
|
22
|
+
//#region src/components/table/index.tsx
|
|
23
|
+
const ROW_HEIGHT = 52;
|
|
24
|
+
const ARROW_SIZE = 18;
|
|
25
|
+
const HANDLE = 24;
|
|
26
|
+
const RESIZE_STEP = 10;
|
|
27
|
+
const FLEXIBLE = "1fr";
|
|
28
|
+
const MIN_WIDTH = 75;
|
|
29
|
+
const styles = StyleSheet.create({
|
|
30
|
+
grid: { flexDirection: "column" },
|
|
31
|
+
handle: {
|
|
32
|
+
bottom: 0,
|
|
33
|
+
position: "absolute",
|
|
34
|
+
top: 0,
|
|
35
|
+
width: HANDLE
|
|
36
|
+
},
|
|
37
|
+
handleLast: { width: HANDLE / 2 },
|
|
38
|
+
handles: {
|
|
39
|
+
bottom: 0,
|
|
40
|
+
left: 0,
|
|
41
|
+
pointerEvents: "box-none",
|
|
42
|
+
position: "absolute",
|
|
43
|
+
right: 0,
|
|
44
|
+
top: 0
|
|
45
|
+
},
|
|
46
|
+
rule: {
|
|
47
|
+
bottom: 0,
|
|
48
|
+
end: HANDLE / 2,
|
|
49
|
+
position: "absolute",
|
|
50
|
+
top: 0,
|
|
51
|
+
width: 1
|
|
52
|
+
},
|
|
53
|
+
ruleLast: { end: 0 },
|
|
54
|
+
selection: { alignItems: "center" }
|
|
55
|
+
});
|
|
56
|
+
const stylesOf = themedStyles(({ colors, sizing, spacing }) => StyleSheet.create({
|
|
57
|
+
cell: {
|
|
58
|
+
justifyContent: "center",
|
|
59
|
+
paddingHorizontal: spacing.lg
|
|
60
|
+
},
|
|
61
|
+
empty: {
|
|
62
|
+
alignItems: "center",
|
|
63
|
+
paddingHorizontal: spacing.lg,
|
|
64
|
+
paddingVertical: spacing.xxl
|
|
65
|
+
},
|
|
66
|
+
emptyText: {
|
|
67
|
+
color: colors.onSurfaceVariant,
|
|
68
|
+
textAlign: "center"
|
|
69
|
+
},
|
|
70
|
+
footer: {
|
|
71
|
+
borderTopColor: colors.outlineVariant,
|
|
72
|
+
borderTopWidth: 1
|
|
73
|
+
},
|
|
74
|
+
footerText: { color: colors.onSurfaceVariant },
|
|
75
|
+
header: {
|
|
76
|
+
borderBottomColor: colors.outlineVariant,
|
|
77
|
+
borderBottomWidth: 1,
|
|
78
|
+
flexDirection: "row",
|
|
79
|
+
minHeight: sizing.rowSm
|
|
80
|
+
},
|
|
81
|
+
headerContent: {
|
|
82
|
+
alignItems: "center",
|
|
83
|
+
flexDirection: "row",
|
|
84
|
+
gap: spacing.sm
|
|
85
|
+
},
|
|
86
|
+
headerText: {
|
|
87
|
+
color: colors.onSurfaceVariant,
|
|
88
|
+
flexShrink: 1
|
|
89
|
+
},
|
|
90
|
+
loading: { minHeight: ROW_HEIGHT },
|
|
91
|
+
row: {
|
|
92
|
+
flexDirection: "row",
|
|
93
|
+
minHeight: ROW_HEIGHT
|
|
94
|
+
},
|
|
95
|
+
rowRule: {
|
|
96
|
+
borderTopColor: colors.outlineVariant,
|
|
97
|
+
borderTopWidth: 1
|
|
98
|
+
},
|
|
99
|
+
ruleLine: { backgroundColor: colors.outlineVariant },
|
|
100
|
+
ruleResizing: {
|
|
101
|
+
backgroundColor: colors.primary,
|
|
102
|
+
width: 2
|
|
103
|
+
},
|
|
104
|
+
selected: { backgroundColor: colors.primaryContainer }
|
|
105
|
+
}));
|
|
106
|
+
const TableContext = createContext(null);
|
|
107
|
+
/**
|
|
108
|
+
* A cell of a body row, its column's width or the columns' it spans: its
|
|
109
|
+
* text in body medium and the row's content colour, or what it was given,
|
|
110
|
+
* with an icon in it drawn in that colour, or the row's checkbox.
|
|
111
|
+
*/
|
|
112
|
+
function BodyCell(t0) {
|
|
113
|
+
const $ = c(18);
|
|
114
|
+
const { cell, color, isDisabled, isSelected, onSelect } = t0;
|
|
115
|
+
const own = stylesOf(useTheme());
|
|
116
|
+
const table = useTable();
|
|
117
|
+
const text = useTypeRole("bodyMedium");
|
|
118
|
+
let t1;
|
|
119
|
+
if ($[0] !== color) {
|
|
120
|
+
t1 = {
|
|
121
|
+
color,
|
|
122
|
+
size: 24
|
|
123
|
+
};
|
|
124
|
+
$[0] = color;
|
|
125
|
+
$[1] = t1;
|
|
126
|
+
} else t1 = $[1];
|
|
127
|
+
const icon = t1;
|
|
128
|
+
const { selection: t2, style, testID } = cell.props;
|
|
129
|
+
const selection = t2 === void 0 ? false : t2;
|
|
130
|
+
const width = spanWidthOf(table, cell);
|
|
131
|
+
if (selection) {
|
|
132
|
+
let t3;
|
|
133
|
+
if ($[2] !== isDisabled || $[3] !== isSelected || $[4] !== onSelect) {
|
|
134
|
+
t3 = /* @__PURE__ */ jsx(SelectBox, {
|
|
135
|
+
isDisabled,
|
|
136
|
+
isSelected,
|
|
137
|
+
onPress: onSelect
|
|
138
|
+
});
|
|
139
|
+
$[2] = isDisabled;
|
|
140
|
+
$[3] = isSelected;
|
|
141
|
+
$[4] = onSelect;
|
|
142
|
+
$[5] = t3;
|
|
143
|
+
} else t3 = $[5];
|
|
144
|
+
return /* @__PURE__ */ jsx(View, {
|
|
145
|
+
style: composeStyles(own.cell, styles.selection, { width }, style),
|
|
146
|
+
testID,
|
|
147
|
+
children: t3
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const T0 = View;
|
|
151
|
+
const t3 = composeStyles(own.cell, { width }, style);
|
|
152
|
+
let t4;
|
|
153
|
+
if ($[6] !== cell.rendered || $[7] !== color || $[8] !== text) {
|
|
154
|
+
t4 = isTextual(cell.rendered) ? /* @__PURE__ */ jsx(Text, {
|
|
155
|
+
style: composeStyles(text, { color }),
|
|
156
|
+
children: cell.rendered
|
|
157
|
+
}) : cell.rendered;
|
|
158
|
+
$[6] = cell.rendered;
|
|
159
|
+
$[7] = color;
|
|
160
|
+
$[8] = text;
|
|
161
|
+
$[9] = t4;
|
|
162
|
+
} else t4 = $[9];
|
|
163
|
+
let t5;
|
|
164
|
+
if ($[10] !== icon || $[11] !== t4) {
|
|
165
|
+
t5 = /* @__PURE__ */ jsx(IconStyleContext, {
|
|
166
|
+
value: icon,
|
|
167
|
+
children: t4
|
|
168
|
+
});
|
|
169
|
+
$[10] = icon;
|
|
170
|
+
$[11] = t4;
|
|
171
|
+
$[12] = t5;
|
|
172
|
+
} else t5 = $[12];
|
|
173
|
+
let t6;
|
|
174
|
+
if ($[13] !== T0 || $[14] !== t3 || $[15] !== t5 || $[16] !== testID) {
|
|
175
|
+
t6 = /* @__PURE__ */ jsx(T0, {
|
|
176
|
+
style: t3,
|
|
177
|
+
testID,
|
|
178
|
+
children: t5
|
|
179
|
+
});
|
|
180
|
+
$[13] = T0;
|
|
181
|
+
$[14] = t3;
|
|
182
|
+
$[15] = t5;
|
|
183
|
+
$[16] = testID;
|
|
184
|
+
$[17] = t6;
|
|
185
|
+
} else t6 = $[17];
|
|
186
|
+
return t6;
|
|
187
|
+
}
|
|
188
|
+
function* bodyNode(props) {
|
|
189
|
+
const { children, items } = props;
|
|
190
|
+
yield {
|
|
191
|
+
*childNodes() {
|
|
192
|
+
if (typeof children === "function") {
|
|
193
|
+
for (const value of items ?? []) yield {
|
|
194
|
+
renderer: children,
|
|
195
|
+
type: "item",
|
|
196
|
+
value
|
|
197
|
+
};
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
for (const element of childElementsOf(children)) if (!isLoadMore(element)) yield {
|
|
201
|
+
element,
|
|
202
|
+
type: "item"
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
hasChildNodes: true,
|
|
206
|
+
props,
|
|
207
|
+
type: "body"
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* A row of the body: the state layer, the ripple and the focus ring over its
|
|
212
|
+
* cells, on primary container while selected and faded while disabled. A row
|
|
213
|
+
* with nothing to do on a press, in a table that neither selects nor acts, is
|
|
214
|
+
* a `View` that only presents.
|
|
215
|
+
*/
|
|
216
|
+
function BodyRow(t0) {
|
|
217
|
+
const $ = c(52);
|
|
218
|
+
const { index, node } = t0;
|
|
219
|
+
const theme = useTheme();
|
|
220
|
+
const own = stylesOf(theme);
|
|
221
|
+
const table = useTable();
|
|
222
|
+
const openLink = useOpenLink();
|
|
223
|
+
let href;
|
|
224
|
+
let onAction;
|
|
225
|
+
let onBlur;
|
|
226
|
+
let onFocus;
|
|
227
|
+
let onHoverIn;
|
|
228
|
+
let onHoverOut;
|
|
229
|
+
let onLongPress;
|
|
230
|
+
let onPress;
|
|
231
|
+
let onPressIn;
|
|
232
|
+
let onPressOut;
|
|
233
|
+
let props;
|
|
234
|
+
let ref;
|
|
235
|
+
let style;
|
|
236
|
+
if ($[0] !== node.props) {
|
|
237
|
+
const { children: _children, href: t1, id: _id, isDisabled: _isDisabled, onAction: t2, onBlur: t3, onFocus: t4, onHoverIn: t5, onHoverOut: t6, onLongPress: t7, onPress: t8, onPressIn: t9, onPressOut: t10, ref: t11, style: t12, textValue: _textValue, value: _value, ...t13 } = node.props;
|
|
238
|
+
href = t1;
|
|
239
|
+
onAction = t2;
|
|
240
|
+
onBlur = t3;
|
|
241
|
+
onFocus = t4;
|
|
242
|
+
onHoverIn = t5;
|
|
243
|
+
onHoverOut = t6;
|
|
244
|
+
onLongPress = t7;
|
|
245
|
+
onPress = t8;
|
|
246
|
+
onPressIn = t9;
|
|
247
|
+
onPressOut = t10;
|
|
248
|
+
ref = t11;
|
|
249
|
+
style = t12;
|
|
250
|
+
props = t13;
|
|
251
|
+
$[0] = node.props;
|
|
252
|
+
$[1] = href;
|
|
253
|
+
$[2] = onAction;
|
|
254
|
+
$[3] = onBlur;
|
|
255
|
+
$[4] = onFocus;
|
|
256
|
+
$[5] = onHoverIn;
|
|
257
|
+
$[6] = onHoverOut;
|
|
258
|
+
$[7] = onLongPress;
|
|
259
|
+
$[8] = onPress;
|
|
260
|
+
$[9] = onPressIn;
|
|
261
|
+
$[10] = onPressOut;
|
|
262
|
+
$[11] = props;
|
|
263
|
+
$[12] = ref;
|
|
264
|
+
$[13] = style;
|
|
265
|
+
} else {
|
|
266
|
+
href = $[1];
|
|
267
|
+
onAction = $[2];
|
|
268
|
+
onBlur = $[3];
|
|
269
|
+
onFocus = $[4];
|
|
270
|
+
onHoverIn = $[5];
|
|
271
|
+
onHoverOut = $[6];
|
|
272
|
+
onLongPress = $[7];
|
|
273
|
+
onPress = $[8];
|
|
274
|
+
onPressIn = $[9];
|
|
275
|
+
onPressOut = $[10];
|
|
276
|
+
props = $[11];
|
|
277
|
+
ref = $[12];
|
|
278
|
+
style = $[13];
|
|
279
|
+
}
|
|
280
|
+
const { selectionManager } = table.state;
|
|
281
|
+
const { key } = node;
|
|
282
|
+
const disabled = selectionManager.isDisabled(key);
|
|
283
|
+
const checks = selectionManager.selectionMode !== "none";
|
|
284
|
+
let t1;
|
|
285
|
+
if ($[14] !== key || $[15] !== selectionManager) {
|
|
286
|
+
t1 = selectionManager.canSelectItem(key);
|
|
287
|
+
$[14] = key;
|
|
288
|
+
$[15] = selectionManager;
|
|
289
|
+
$[16] = t1;
|
|
290
|
+
} else t1 = $[16];
|
|
291
|
+
const selectable = t1;
|
|
292
|
+
const selected = checks && selectionManager.isSelected(key);
|
|
293
|
+
const marked = selected && !disabled;
|
|
294
|
+
const rowAction = table.onRowAction;
|
|
295
|
+
let t2;
|
|
296
|
+
if ($[17] !== href || $[18] !== key || $[19] !== onAction || $[20] !== openLink || $[21] !== rowAction) {
|
|
297
|
+
t2 = onAction ?? (href === void 0 ? rowAction === void 0 ? void 0 : () => {
|
|
298
|
+
rowAction(key);
|
|
299
|
+
} : () => {
|
|
300
|
+
openLink(href);
|
|
301
|
+
});
|
|
302
|
+
$[17] = href;
|
|
303
|
+
$[18] = key;
|
|
304
|
+
$[19] = onAction;
|
|
305
|
+
$[20] = openLink;
|
|
306
|
+
$[21] = rowAction;
|
|
307
|
+
$[22] = t2;
|
|
308
|
+
} else t2 = $[22];
|
|
309
|
+
const action = t2;
|
|
310
|
+
const acts = action !== void 0 && (!selectable || selectionManager.isEmpty);
|
|
311
|
+
let t3;
|
|
312
|
+
if ($[23] !== key || $[24] !== selectionManager) {
|
|
313
|
+
t3 = () => {
|
|
314
|
+
selectionManager.select(key);
|
|
315
|
+
};
|
|
316
|
+
$[23] = key;
|
|
317
|
+
$[24] = selectionManager;
|
|
318
|
+
$[25] = t3;
|
|
319
|
+
} else t3 = $[25];
|
|
320
|
+
const select = t3;
|
|
321
|
+
const content = rowContentColor(theme, {
|
|
322
|
+
isDisabled: disabled,
|
|
323
|
+
isSelected: marked
|
|
324
|
+
});
|
|
325
|
+
const feedback = usePressFeedback({
|
|
326
|
+
color: content,
|
|
327
|
+
disabled,
|
|
328
|
+
onBlur,
|
|
329
|
+
onFocus,
|
|
330
|
+
onHoverIn,
|
|
331
|
+
onHoverOut,
|
|
332
|
+
onPressIn,
|
|
333
|
+
onPressOut
|
|
334
|
+
});
|
|
335
|
+
const cells = [...table.state.collection.getChildren?.(key) ?? []].map((cell) => /* @__PURE__ */ jsx(BodyCell, {
|
|
336
|
+
cell,
|
|
337
|
+
color: content,
|
|
338
|
+
isDisabled: disabled,
|
|
339
|
+
isSelected: selected,
|
|
340
|
+
onSelect: acts && selectable ? select : void 0
|
|
341
|
+
}, cell.key));
|
|
342
|
+
const rowStyle = composeStyles(own.row, index > 0 ? own.rowRule : void 0, marked ? own.selected : void 0);
|
|
343
|
+
if (!checks && action === void 0 && onPress === void 0) return /* @__PURE__ */ jsx(View, {
|
|
344
|
+
"aria-disabled": disabled || void 0,
|
|
345
|
+
ref,
|
|
346
|
+
style: composeStyles(rowStyle, style),
|
|
347
|
+
testID: props.testID,
|
|
348
|
+
children: cells
|
|
349
|
+
});
|
|
350
|
+
const T0 = Pressable;
|
|
351
|
+
const t4 = href === void 0 ? "button" : "link";
|
|
352
|
+
const t5 = checks ? toggleState(selected) : void 0;
|
|
353
|
+
let t6;
|
|
354
|
+
if ($[26] !== select || $[27] !== selectable || $[28] !== table.selectLabel) {
|
|
355
|
+
t6 = selectable ? {
|
|
356
|
+
accessibilityActions: [{
|
|
357
|
+
label: table.selectLabel,
|
|
358
|
+
name: "select"
|
|
359
|
+
}],
|
|
360
|
+
onAccessibilityAction: accessibilityActionOf({
|
|
361
|
+
collapse: void 0,
|
|
362
|
+
expand: void 0,
|
|
363
|
+
select
|
|
364
|
+
})
|
|
365
|
+
} : void 0;
|
|
366
|
+
$[26] = select;
|
|
367
|
+
$[27] = selectable;
|
|
368
|
+
$[28] = table.selectLabel;
|
|
369
|
+
$[29] = t6;
|
|
370
|
+
} else t6 = $[29];
|
|
371
|
+
const t7 = feedback.handlers;
|
|
372
|
+
let t8;
|
|
373
|
+
if ($[30] !== action || $[31] !== onLongPress || $[32] !== select || $[33] !== selectable) {
|
|
374
|
+
t8 = action !== void 0 && selectable ? pressThen(onLongPress, select) : onLongPress;
|
|
375
|
+
$[30] = action;
|
|
376
|
+
$[31] = onLongPress;
|
|
377
|
+
$[32] = select;
|
|
378
|
+
$[33] = selectable;
|
|
379
|
+
$[34] = t8;
|
|
380
|
+
} else t8 = $[34];
|
|
381
|
+
const t9 = acts ? action : selectable ? select : noop;
|
|
382
|
+
let t10;
|
|
383
|
+
if ($[35] !== onPress || $[36] !== t9) {
|
|
384
|
+
t10 = pressThen(onPress, t9);
|
|
385
|
+
$[35] = onPress;
|
|
386
|
+
$[36] = t9;
|
|
387
|
+
$[37] = t10;
|
|
388
|
+
} else t10 = $[37];
|
|
389
|
+
const t11 = composeStyles(rowStyle, feedback.ring, feedback.ring === void 0 ? void 0 : rowStyles.ring, style);
|
|
390
|
+
let t12;
|
|
391
|
+
if ($[38] !== T0 || $[39] !== cells || $[40] !== disabled || $[41] !== feedback.handlers || $[42] !== feedback.layer || $[43] !== props || $[44] !== ref || $[45] !== t10 || $[46] !== t11 || $[47] !== t4 || $[48] !== t5 || $[49] !== t6 || $[50] !== t8) {
|
|
392
|
+
t12 = /* @__PURE__ */ jsxs(T0, {
|
|
393
|
+
role: t4,
|
|
394
|
+
...props,
|
|
395
|
+
...t5,
|
|
396
|
+
...t6,
|
|
397
|
+
...t7,
|
|
398
|
+
disabled,
|
|
399
|
+
onLongPress: t8,
|
|
400
|
+
onPress: t10,
|
|
401
|
+
ref,
|
|
402
|
+
style: t11,
|
|
403
|
+
children: [feedback.layer, cells]
|
|
404
|
+
});
|
|
405
|
+
$[38] = T0;
|
|
406
|
+
$[39] = cells;
|
|
407
|
+
$[40] = disabled;
|
|
408
|
+
$[41] = feedback.handlers;
|
|
409
|
+
$[42] = feedback.layer;
|
|
410
|
+
$[43] = props;
|
|
411
|
+
$[44] = ref;
|
|
412
|
+
$[45] = t10;
|
|
413
|
+
$[46] = t11;
|
|
414
|
+
$[47] = t4;
|
|
415
|
+
$[48] = t5;
|
|
416
|
+
$[49] = t6;
|
|
417
|
+
$[50] = t8;
|
|
418
|
+
$[51] = t12;
|
|
419
|
+
} else t12 = $[51];
|
|
420
|
+
return t12;
|
|
421
|
+
}
|
|
422
|
+
function* cellNode(props) {
|
|
423
|
+
yield {
|
|
424
|
+
hasChildNodes: false,
|
|
425
|
+
props,
|
|
426
|
+
rendered: props.children,
|
|
427
|
+
textValue: props.textValue ?? (typeof props.children === "string" ? props.children : ""),
|
|
428
|
+
type: "cell"
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* A column's header: its name in label large and the muted role, with the
|
|
433
|
+
* arrow after it while the rows are sorted by it, as a button that sorts
|
|
434
|
+
* where the column allows it, or the select-all checkbox.
|
|
435
|
+
*/
|
|
436
|
+
function ColumnHeader(t0) {
|
|
437
|
+
const $ = c(23);
|
|
438
|
+
const { column } = t0;
|
|
439
|
+
const theme = useTheme();
|
|
440
|
+
const own = stylesOf(theme);
|
|
441
|
+
const table = useTable();
|
|
442
|
+
const messages = useMessages();
|
|
443
|
+
const label = useTypeRole("labelLarge");
|
|
444
|
+
const { selectionManager } = table.state;
|
|
445
|
+
const { allowsSorting: t1, selection: t2, style, testID } = column.props;
|
|
446
|
+
const allowsSorting = t1 === void 0 ? false : t1;
|
|
447
|
+
const selection = t2 === void 0 ? false : t2;
|
|
448
|
+
const { sortDescriptor } = table.state;
|
|
449
|
+
const direction = sortDescriptor?.column === column.key ? sortDescriptor.direction : void 0;
|
|
450
|
+
let t3;
|
|
451
|
+
if ($[0] !== theme.colors.onSurface) {
|
|
452
|
+
t3 = { color: theme.colors.onSurface };
|
|
453
|
+
$[0] = theme.colors.onSurface;
|
|
454
|
+
$[1] = t3;
|
|
455
|
+
} else t3 = $[1];
|
|
456
|
+
const feedback = usePressFeedback(t3);
|
|
457
|
+
const cellStyle = composeStyles(own.cell, { width: table.layout.getColumnWidth(column.key) });
|
|
458
|
+
if (selection) {
|
|
459
|
+
const mode = selectionManager.selectionMode;
|
|
460
|
+
const t4 = composeStyles(cellStyle, styles.selection, style);
|
|
461
|
+
const t5 = table.selectAllLabel ?? (mode === "single" ? messages.select : messages.table.selectAll);
|
|
462
|
+
const t6 = mode !== "multiple" || table.state.collection.size === 0;
|
|
463
|
+
const t7 = !selectionManager.isEmpty && !selectionManager.isSelectAll;
|
|
464
|
+
const t8 = selectionManager.isSelectAll;
|
|
465
|
+
let t9;
|
|
466
|
+
if ($[2] !== table.state) {
|
|
467
|
+
t9 = selectAllOf(table.state);
|
|
468
|
+
$[2] = table.state;
|
|
469
|
+
$[3] = t9;
|
|
470
|
+
} else t9 = $[3];
|
|
471
|
+
let t10;
|
|
472
|
+
if ($[4] !== selectionManager.isSelectAll || $[5] !== t5 || $[6] !== t6 || $[7] !== t7 || $[8] !== t9) {
|
|
473
|
+
t10 = /* @__PURE__ */ jsx(Checkbox, {
|
|
474
|
+
"aria-label": t5,
|
|
475
|
+
isDisabled: t6,
|
|
476
|
+
isIndeterminate: t7,
|
|
477
|
+
isSelected: t8,
|
|
478
|
+
onChange: t9
|
|
479
|
+
});
|
|
480
|
+
$[4] = selectionManager.isSelectAll;
|
|
481
|
+
$[5] = t5;
|
|
482
|
+
$[6] = t6;
|
|
483
|
+
$[7] = t7;
|
|
484
|
+
$[8] = t9;
|
|
485
|
+
$[9] = t10;
|
|
486
|
+
} else t10 = $[9];
|
|
487
|
+
return /* @__PURE__ */ jsx(View, {
|
|
488
|
+
style: t4,
|
|
489
|
+
testID,
|
|
490
|
+
children: t10
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
const arrowColor = theme.colors.onSurfaceVariant;
|
|
494
|
+
let t4;
|
|
495
|
+
if ($[10] !== arrowColor || $[11] !== direction) {
|
|
496
|
+
t4 = direction === void 0 ? null : direction === "ascending" ? /* @__PURE__ */ jsx(ArrowUpwardGlyph, {
|
|
497
|
+
color: arrowColor,
|
|
498
|
+
size: ARROW_SIZE
|
|
499
|
+
}) : /* @__PURE__ */ jsx(ArrowDownwardGlyph, {
|
|
500
|
+
color: arrowColor,
|
|
501
|
+
size: ARROW_SIZE
|
|
502
|
+
});
|
|
503
|
+
$[10] = arrowColor;
|
|
504
|
+
$[11] = direction;
|
|
505
|
+
$[12] = t4;
|
|
506
|
+
} else t4 = $[12];
|
|
507
|
+
const name = /* @__PURE__ */ jsxs(View, {
|
|
508
|
+
style: own.headerContent,
|
|
509
|
+
children: [isTextual(column.rendered) ? /* @__PURE__ */ jsx(Text, {
|
|
510
|
+
style: composeStyles(label, own.headerText),
|
|
511
|
+
children: column.rendered
|
|
512
|
+
}) : column.rendered, t4]
|
|
513
|
+
});
|
|
514
|
+
if (!allowsSorting) return /* @__PURE__ */ jsx(View, {
|
|
515
|
+
style: composeStyles(cellStyle, style),
|
|
516
|
+
testID,
|
|
517
|
+
children: name
|
|
518
|
+
});
|
|
519
|
+
let t5;
|
|
520
|
+
if ($[13] !== direction || $[14] !== messages.table) {
|
|
521
|
+
t5 = direction === void 0 ? [] : [messages.table[direction]];
|
|
522
|
+
$[13] = direction;
|
|
523
|
+
$[14] = messages.table;
|
|
524
|
+
$[15] = t5;
|
|
525
|
+
} else t5 = $[15];
|
|
526
|
+
let t6;
|
|
527
|
+
if ($[16] !== column.textValue || $[17] !== messages.table.sortable || $[18] !== t5) {
|
|
528
|
+
t6 = [
|
|
529
|
+
column.textValue,
|
|
530
|
+
messages.table.sortable,
|
|
531
|
+
...t5
|
|
532
|
+
];
|
|
533
|
+
$[16] = column.textValue;
|
|
534
|
+
$[17] = messages.table.sortable;
|
|
535
|
+
$[18] = t5;
|
|
536
|
+
$[19] = t6;
|
|
537
|
+
} else t6 = $[19];
|
|
538
|
+
const t7 = t6.join(", ");
|
|
539
|
+
const t8 = feedback.handlers;
|
|
540
|
+
let t9;
|
|
541
|
+
if ($[20] !== column.key || $[21] !== table.state) {
|
|
542
|
+
t9 = sortOf(table.state, column.key);
|
|
543
|
+
$[20] = column.key;
|
|
544
|
+
$[21] = table.state;
|
|
545
|
+
$[22] = t9;
|
|
546
|
+
} else t9 = $[22];
|
|
547
|
+
return /* @__PURE__ */ jsxs(Pressable, {
|
|
548
|
+
"aria-label": t7,
|
|
549
|
+
role: "button",
|
|
550
|
+
...t8,
|
|
551
|
+
onPress: t9,
|
|
552
|
+
style: composeStyles(cellStyle, feedback.ring, feedback.ring === void 0 ? void 0 : rowStyles.ring, style),
|
|
553
|
+
testID,
|
|
554
|
+
children: [feedback.layer, name]
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
function* columnNode(props, context) {
|
|
558
|
+
const nodes = yield {
|
|
559
|
+
hasChildNodes: false,
|
|
560
|
+
key: props.id,
|
|
561
|
+
props,
|
|
562
|
+
rendered: props.children,
|
|
563
|
+
shouldInvalidate(next) {
|
|
564
|
+
next.columns.push(...nodes);
|
|
565
|
+
return false;
|
|
566
|
+
},
|
|
567
|
+
textValue: props.textValue ?? (typeof props.children === "string" ? props.children : ""),
|
|
568
|
+
type: "column"
|
|
569
|
+
};
|
|
570
|
+
context.columns.push(...nodes);
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* The widths a column takes before anything says otherwise: React Stately's
|
|
574
|
+
* own, and a checkbox's column as wide as its box and its padding, which it
|
|
575
|
+
* keeps, since it holds one control and should not take a column of data's
|
|
576
|
+
* room.
|
|
577
|
+
*/
|
|
578
|
+
function defaultsOf(selectionWidth) {
|
|
579
|
+
return {
|
|
580
|
+
getDefaultMinWidth: (node) => isSelection(node) ? selectionWidth : MIN_WIDTH,
|
|
581
|
+
getDefaultWidth: (node) => isSelection(node) ? selectionWidth : FLEXIBLE
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* What the body shows in place of rows, from its `renderEmptyState`, as the
|
|
586
|
+
* component `ListEmptyComponent` takes.
|
|
587
|
+
*/
|
|
588
|
+
function EmptyBody() {
|
|
589
|
+
const $ = c(4);
|
|
590
|
+
const own = stylesOf(useTheme());
|
|
591
|
+
const text = useTypeRole("bodyMedium");
|
|
592
|
+
const shown = useTable().renderEmptyState?.();
|
|
593
|
+
const T0 = View;
|
|
594
|
+
const t0 = isTextual(shown) ? /* @__PURE__ */ jsx(Text, {
|
|
595
|
+
style: composeStyles(text, own.emptyText),
|
|
596
|
+
children: shown
|
|
597
|
+
}) : shown;
|
|
598
|
+
let t1;
|
|
599
|
+
if ($[0] !== T0 || $[1] !== own || $[2] !== t0) {
|
|
600
|
+
t1 = /* @__PURE__ */ jsx(T0, {
|
|
601
|
+
style: own.empty,
|
|
602
|
+
children: t0
|
|
603
|
+
});
|
|
604
|
+
$[0] = T0;
|
|
605
|
+
$[1] = own;
|
|
606
|
+
$[2] = t0;
|
|
607
|
+
$[3] = t1;
|
|
608
|
+
} else t1 = $[3];
|
|
609
|
+
return t1;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Where each column ends, from the table's start, which is where its resize
|
|
613
|
+
* handle is centred.
|
|
614
|
+
*/
|
|
615
|
+
function endsOf(table) {
|
|
616
|
+
const ends = [];
|
|
617
|
+
let end = 0;
|
|
618
|
+
for (const column of table.columns) {
|
|
619
|
+
end += table.layout.getColumnWidth(column.key);
|
|
620
|
+
ends.push(end);
|
|
621
|
+
}
|
|
622
|
+
return ends;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* The rows under the body, in label large and the muted role, under a rule
|
|
626
|
+
* of their own, each cell its column's width or the columns' it spans. They
|
|
627
|
+
* take no press and no selection, as React Aria keeps a footer out of both.
|
|
628
|
+
*/
|
|
629
|
+
function FooterRows() {
|
|
630
|
+
const $ = c(5);
|
|
631
|
+
const own = stylesOf(useTheme());
|
|
632
|
+
const table = useTable();
|
|
633
|
+
const label = useTypeRole("labelLarge");
|
|
634
|
+
const { footer } = table;
|
|
635
|
+
if (footer === void 0) return null;
|
|
636
|
+
const T0 = View;
|
|
637
|
+
const t0 = composeStyles(own.footer, footer.style);
|
|
638
|
+
const t1 = footer.testID;
|
|
639
|
+
const t2 = childElementsOf(footer.children).map((row, rowIndex) => {
|
|
640
|
+
if (!isValidElement(row)) return null;
|
|
641
|
+
let start = 0;
|
|
642
|
+
const cells = childElementsOf(typeof row.props.children === "function" ? null : row.props.children).map((cell, cellIndex) => {
|
|
643
|
+
if (!isValidElement(cell)) return null;
|
|
644
|
+
const span = cell.props.colSpan ?? 1;
|
|
645
|
+
const width = widthAcross(table, start, span);
|
|
646
|
+
start = start + span;
|
|
647
|
+
return /* @__PURE__ */ jsx(View, {
|
|
648
|
+
style: composeStyles(own.cell, { width }, cell.props.style),
|
|
649
|
+
testID: cell.props.testID,
|
|
650
|
+
children: isTextual(cell.props.children) ? /* @__PURE__ */ jsx(Text, {
|
|
651
|
+
style: composeStyles(label, own.footerText),
|
|
652
|
+
children: cell.props.children
|
|
653
|
+
}) : cell.props.children
|
|
654
|
+
}, cell.key ?? cellIndex);
|
|
655
|
+
});
|
|
656
|
+
return /* @__PURE__ */ jsx(View, {
|
|
657
|
+
style: composeStyles(own.row, rowIndex > 0 ? own.rowRule : void 0, row.props.style),
|
|
658
|
+
testID: row.props.testID,
|
|
659
|
+
children: cells
|
|
660
|
+
}, row.key ?? rowIndex);
|
|
661
|
+
});
|
|
662
|
+
let t3;
|
|
663
|
+
if ($[0] !== T0 || $[1] !== footer.testID || $[2] !== t0 || $[3] !== t2) {
|
|
664
|
+
t3 = /* @__PURE__ */ jsx(T0, {
|
|
665
|
+
style: t0,
|
|
666
|
+
testID: t1,
|
|
667
|
+
children: t2
|
|
668
|
+
});
|
|
669
|
+
$[0] = T0;
|
|
670
|
+
$[1] = footer.testID;
|
|
671
|
+
$[2] = t0;
|
|
672
|
+
$[3] = t2;
|
|
673
|
+
$[4] = t3;
|
|
674
|
+
} else t3 = $[4];
|
|
675
|
+
return t3;
|
|
676
|
+
}
|
|
677
|
+
function* headerNodes(props, context) {
|
|
678
|
+
const { children, columns } = props;
|
|
679
|
+
context.columns = [];
|
|
680
|
+
if (typeof children === "function") {
|
|
681
|
+
for (const value of columns ?? []) yield {
|
|
682
|
+
renderer: children,
|
|
683
|
+
type: "column",
|
|
684
|
+
value
|
|
685
|
+
};
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
for (const element of childElementsOf(children)) yield {
|
|
689
|
+
element,
|
|
690
|
+
type: "column"
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* The header row: each column's header, its column's width, and the resize
|
|
695
|
+
* handles over them in a table that resizes.
|
|
696
|
+
*/
|
|
697
|
+
function HeaderRow() {
|
|
698
|
+
const $ = c(10);
|
|
699
|
+
const own = stylesOf(useTheme());
|
|
700
|
+
const table = useTable();
|
|
701
|
+
const { header } = table;
|
|
702
|
+
const T0 = View;
|
|
703
|
+
const t0 = composeStyles(own.header, header.style);
|
|
704
|
+
const t1 = header.testID;
|
|
705
|
+
let t2;
|
|
706
|
+
if ($[0] !== table.columns) {
|
|
707
|
+
t2 = table.columns.map(_temp);
|
|
708
|
+
$[0] = table.columns;
|
|
709
|
+
$[1] = t2;
|
|
710
|
+
} else t2 = $[1];
|
|
711
|
+
let t3;
|
|
712
|
+
if ($[2] !== table.resizable) {
|
|
713
|
+
t3 = table.resizable ? /* @__PURE__ */ jsx(ResizeHandles, {}) : null;
|
|
714
|
+
$[2] = table.resizable;
|
|
715
|
+
$[3] = t3;
|
|
716
|
+
} else t3 = $[3];
|
|
717
|
+
let t4;
|
|
718
|
+
if ($[4] !== T0 || $[5] !== header.testID || $[6] !== t0 || $[7] !== t2 || $[8] !== t3) {
|
|
719
|
+
t4 = /* @__PURE__ */ jsxs(T0, {
|
|
720
|
+
style: t0,
|
|
721
|
+
testID: t1,
|
|
722
|
+
children: [t2, t3]
|
|
723
|
+
});
|
|
724
|
+
$[4] = T0;
|
|
725
|
+
$[5] = header.testID;
|
|
726
|
+
$[6] = t0;
|
|
727
|
+
$[7] = t2;
|
|
728
|
+
$[8] = t3;
|
|
729
|
+
$[9] = t4;
|
|
730
|
+
} else t4 = $[9];
|
|
731
|
+
return t4;
|
|
732
|
+
}
|
|
733
|
+
function _temp(column) {
|
|
734
|
+
return /* @__PURE__ */ jsx(ColumnHeader, { column }, column.key);
|
|
735
|
+
}
|
|
736
|
+
function isLoadMore(element) {
|
|
737
|
+
return isValidElement(element) && element.type === TableLoadMore;
|
|
738
|
+
}
|
|
739
|
+
function isSelection(node) {
|
|
740
|
+
return node.props?.selection === true;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Whether what a cell holds is text alone, which it sets in its own type
|
|
744
|
+
* role, as React Native draws text only inside a Text.
|
|
745
|
+
*/
|
|
746
|
+
function isTextual(node) {
|
|
747
|
+
const parts = Children.toArray(node);
|
|
748
|
+
return parts.length > 0 && parts.every((part) => typeof part === "string" || typeof part === "number");
|
|
749
|
+
}
|
|
750
|
+
function keyOf(node) {
|
|
751
|
+
return String(node.key);
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* The part `type` of the table's children, or what is left out: the header,
|
|
755
|
+
* the body and the footer are each read off their own part.
|
|
756
|
+
*/
|
|
757
|
+
function partOf(children, type) {
|
|
758
|
+
return childElementsOf(children).find((child) => isValidElement(child) && child.type === type);
|
|
759
|
+
}
|
|
760
|
+
function renderRow({ index, item }) {
|
|
761
|
+
return /* @__PURE__ */ jsx(BodyRow, {
|
|
762
|
+
index,
|
|
763
|
+
node: item
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* A column's resize handle: a target centred on its trailing edge holding
|
|
768
|
+
* the divider's rule, which a drag along the header moves, and a slider to a
|
|
769
|
+
* screen reader, stepped by `RESIZE_STEP`. A drag starting on it holds the
|
|
770
|
+
* table's sideways scroll still.
|
|
771
|
+
*/
|
|
772
|
+
function ResizeHandle(t0) {
|
|
773
|
+
const $ = c(36);
|
|
774
|
+
const { column, end, isLast } = t0;
|
|
775
|
+
const own = stylesOf(useTheme());
|
|
776
|
+
const table = useTable();
|
|
777
|
+
const locale = useLocaleOf(void 0);
|
|
778
|
+
const { layout, native, onResize, onResizeEnd } = table;
|
|
779
|
+
const { key } = column;
|
|
780
|
+
const from = useSharedValue(-1);
|
|
781
|
+
const last = useSharedValue(0);
|
|
782
|
+
let t1;
|
|
783
|
+
if ($[0] !== key || $[1] !== layout) {
|
|
784
|
+
t1 = layout.getColumnWidth(key);
|
|
785
|
+
$[0] = key;
|
|
786
|
+
$[1] = layout;
|
|
787
|
+
$[2] = t1;
|
|
788
|
+
} else t1 = $[2];
|
|
789
|
+
const width = t1;
|
|
790
|
+
const resizing = layout.resizingColumn === key;
|
|
791
|
+
const begin = function begin() {
|
|
792
|
+
from.set(layout.getColumnWidth(key));
|
|
793
|
+
last.set(layout.getColumnWidth(key));
|
|
794
|
+
layout.startResize(key);
|
|
795
|
+
};
|
|
796
|
+
const move = function move(translation) {
|
|
797
|
+
const start = from.get();
|
|
798
|
+
if (start < 0) return;
|
|
799
|
+
const next = start + (I18nManager.isRTL ? -translation : translation);
|
|
800
|
+
last.set(next);
|
|
801
|
+
onResize?.(layout.updateResizedColumns(key, next));
|
|
802
|
+
};
|
|
803
|
+
const finish = function finish() {
|
|
804
|
+
if (from.get() < 0) return;
|
|
805
|
+
from.set(-1);
|
|
806
|
+
const sizes = layout.updateResizedColumns(key, last.get());
|
|
807
|
+
layout.endResize();
|
|
808
|
+
onResizeEnd?.(sizes);
|
|
809
|
+
};
|
|
810
|
+
const drag = Gesture.Pan().activeOffsetX(SLOP_RANGE).failOffsetY(SLOP_RANGE).runOnJS(true).onStart((t2) => {
|
|
811
|
+
const { translationX } = t2;
|
|
812
|
+
begin();
|
|
813
|
+
move(translationX);
|
|
814
|
+
}).onUpdate((t3) => {
|
|
815
|
+
const { translationX: translationX_0 } = t3;
|
|
816
|
+
move(translationX_0);
|
|
817
|
+
}).onFinalize(() => {
|
|
818
|
+
finish();
|
|
819
|
+
});
|
|
820
|
+
const held = native === void 0 ? drag : drag.blocksExternalGesture(native);
|
|
821
|
+
const pan = table.testID === void 0 ? held : held.withTestId(`${table.testID}-resize-${String(key)}`);
|
|
822
|
+
const T0 = GestureDetector;
|
|
823
|
+
const T1 = View;
|
|
824
|
+
const t4 = ADJUSTABLE;
|
|
825
|
+
const t5 = true;
|
|
826
|
+
const t6 = `${table.resizeLabel} ${column.textValue}`;
|
|
827
|
+
let t7;
|
|
828
|
+
if ($[3] !== key || $[4] !== layout) {
|
|
829
|
+
t7 = layout.getColumnMaxWidth(key);
|
|
830
|
+
$[3] = key;
|
|
831
|
+
$[4] = layout;
|
|
832
|
+
$[5] = t7;
|
|
833
|
+
} else t7 = $[5];
|
|
834
|
+
const t8 = Math.floor(t7);
|
|
835
|
+
let t9;
|
|
836
|
+
if ($[6] !== key || $[7] !== layout) {
|
|
837
|
+
t9 = layout.getColumnMinWidth(key);
|
|
838
|
+
$[6] = key;
|
|
839
|
+
$[7] = layout;
|
|
840
|
+
$[8] = t9;
|
|
841
|
+
} else t9 = $[8];
|
|
842
|
+
const t10 = Math.floor(t9);
|
|
843
|
+
const t11 = Math.floor(width);
|
|
844
|
+
const t12 = Math.floor(width);
|
|
845
|
+
let t13;
|
|
846
|
+
if ($[9] !== locale || $[10] !== t12) {
|
|
847
|
+
t13 = columnSizeFor(t12, locale);
|
|
848
|
+
$[9] = locale;
|
|
849
|
+
$[10] = t12;
|
|
850
|
+
$[11] = t13;
|
|
851
|
+
} else t13 = $[11];
|
|
852
|
+
let t14;
|
|
853
|
+
if ($[12] !== key || $[13] !== table) {
|
|
854
|
+
t14 = stepOf(table, key);
|
|
855
|
+
$[12] = key;
|
|
856
|
+
$[13] = table;
|
|
857
|
+
$[14] = t14;
|
|
858
|
+
} else t14 = $[14];
|
|
859
|
+
const t15 = "slider";
|
|
860
|
+
const t16 = isLast ? styles.handleLast : void 0;
|
|
861
|
+
const t17 = end - HANDLE / 2;
|
|
862
|
+
let t18;
|
|
863
|
+
if ($[15] !== t16 || $[16] !== t17) {
|
|
864
|
+
t18 = composeStyles(styles.handle, t16, { start: t17 });
|
|
865
|
+
$[15] = t16;
|
|
866
|
+
$[16] = t17;
|
|
867
|
+
$[17] = t18;
|
|
868
|
+
} else t18 = $[17];
|
|
869
|
+
const T2 = View;
|
|
870
|
+
const t19 = composeStyles(styles.rule, isLast ? styles.ruleLast : void 0, own.ruleLine, resizing ? own.ruleResizing : void 0);
|
|
871
|
+
let t20;
|
|
872
|
+
if ($[18] !== T2 || $[19] !== t19) {
|
|
873
|
+
t20 = /* @__PURE__ */ jsx(T2, { style: t19 });
|
|
874
|
+
$[18] = T2;
|
|
875
|
+
$[19] = t19;
|
|
876
|
+
$[20] = t20;
|
|
877
|
+
} else t20 = $[20];
|
|
878
|
+
let t21;
|
|
879
|
+
if ($[21] !== T1 || $[22] !== t10 || $[23] !== t11 || $[24] !== t13 || $[25] !== t14 || $[26] !== t18 || $[27] !== t20 || $[28] !== t4 || $[29] !== t6 || $[30] !== t8) {
|
|
880
|
+
t21 = /* @__PURE__ */ jsx(T1, {
|
|
881
|
+
accessibilityActions: t4,
|
|
882
|
+
accessible: t5,
|
|
883
|
+
"aria-label": t6,
|
|
884
|
+
"aria-valuemax": t8,
|
|
885
|
+
"aria-valuemin": t10,
|
|
886
|
+
"aria-valuenow": t11,
|
|
887
|
+
"aria-valuetext": t13,
|
|
888
|
+
onAccessibilityAction: t14,
|
|
889
|
+
role: t15,
|
|
890
|
+
style: t18,
|
|
891
|
+
children: t20
|
|
892
|
+
});
|
|
893
|
+
$[21] = T1;
|
|
894
|
+
$[22] = t10;
|
|
895
|
+
$[23] = t11;
|
|
896
|
+
$[24] = t13;
|
|
897
|
+
$[25] = t14;
|
|
898
|
+
$[26] = t18;
|
|
899
|
+
$[27] = t20;
|
|
900
|
+
$[28] = t4;
|
|
901
|
+
$[29] = t6;
|
|
902
|
+
$[30] = t8;
|
|
903
|
+
$[31] = t21;
|
|
904
|
+
} else t21 = $[31];
|
|
905
|
+
let t22;
|
|
906
|
+
if ($[32] !== T0 || $[33] !== pan || $[34] !== t21) {
|
|
907
|
+
t22 = /* @__PURE__ */ jsx(T0, {
|
|
908
|
+
gesture: pan,
|
|
909
|
+
children: t21
|
|
910
|
+
});
|
|
911
|
+
$[32] = T0;
|
|
912
|
+
$[33] = pan;
|
|
913
|
+
$[34] = t21;
|
|
914
|
+
$[35] = t22;
|
|
915
|
+
} else t22 = $[35];
|
|
916
|
+
return t22;
|
|
917
|
+
}
|
|
918
|
+
function ResizeHandles() {
|
|
919
|
+
const $ = c(11);
|
|
920
|
+
const table = useTable();
|
|
921
|
+
let t0;
|
|
922
|
+
if ($[0] !== table) {
|
|
923
|
+
t0 = endsOf(table);
|
|
924
|
+
$[0] = table;
|
|
925
|
+
$[1] = t0;
|
|
926
|
+
} else t0 = $[1];
|
|
927
|
+
const ends = t0;
|
|
928
|
+
const lastIndex = table.columns.length - 1;
|
|
929
|
+
let t1;
|
|
930
|
+
if ($[2] !== ends || $[3] !== lastIndex || $[4] !== table.columns) {
|
|
931
|
+
let t2;
|
|
932
|
+
if ($[6] !== ends || $[7] !== lastIndex) {
|
|
933
|
+
t2 = (column, index) => column.props?.resizable === true ? /* @__PURE__ */ jsx(ResizeHandle, {
|
|
934
|
+
column,
|
|
935
|
+
end: ends[index] ?? 0,
|
|
936
|
+
isLast: index === lastIndex
|
|
937
|
+
}, column.key) : null;
|
|
938
|
+
$[6] = ends;
|
|
939
|
+
$[7] = lastIndex;
|
|
940
|
+
$[8] = t2;
|
|
941
|
+
} else t2 = $[8];
|
|
942
|
+
t1 = table.columns.map(t2);
|
|
943
|
+
$[2] = ends;
|
|
944
|
+
$[3] = lastIndex;
|
|
945
|
+
$[4] = table.columns;
|
|
946
|
+
$[5] = t1;
|
|
947
|
+
} else t1 = $[5];
|
|
948
|
+
let t2;
|
|
949
|
+
if ($[9] !== t1) {
|
|
950
|
+
t2 = /* @__PURE__ */ jsx(View, {
|
|
951
|
+
style: styles.handles,
|
|
952
|
+
children: t1
|
|
953
|
+
});
|
|
954
|
+
$[9] = t1;
|
|
955
|
+
$[10] = t2;
|
|
956
|
+
} else t2 = $[10];
|
|
957
|
+
return t2;
|
|
958
|
+
}
|
|
959
|
+
function* rowNode(props, context) {
|
|
960
|
+
const { children } = props;
|
|
961
|
+
yield {
|
|
962
|
+
"aria-label": props["aria-label"],
|
|
963
|
+
*childNodes() {
|
|
964
|
+
if (typeof children === "function") {
|
|
965
|
+
for (const column of context.columns) yield {
|
|
966
|
+
element: children(column.key),
|
|
967
|
+
key: column.key,
|
|
968
|
+
type: "cell"
|
|
969
|
+
};
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
const cells = childElementsOf(children);
|
|
973
|
+
const count = cells.reduce((sum, cell) => sum + spanOf(cell), 0);
|
|
974
|
+
if (count !== context.columns.length) throw new Error(`Cell count must match column count. Found ${count} cells and ${context.columns.length} columns.`);
|
|
975
|
+
for (const element of cells) yield {
|
|
976
|
+
element,
|
|
977
|
+
type: "cell"
|
|
978
|
+
};
|
|
979
|
+
},
|
|
980
|
+
hasChildNodes: true,
|
|
981
|
+
key: props.id,
|
|
982
|
+
props,
|
|
983
|
+
shouldInvalidate(next) {
|
|
984
|
+
return next.columns.length !== context.columns.length || next.columns.some((column, index) => column.key !== context.columns[index]?.key);
|
|
985
|
+
},
|
|
986
|
+
textValue: props.textValue,
|
|
987
|
+
type: "item"
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
function selectAllOf(state) {
|
|
991
|
+
return () => {
|
|
992
|
+
state.selectionManager.toggleSelectAll();
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* What the table says once its rows are sorted, as React Aria says it, and
|
|
997
|
+
* nothing for a table that sorts by nothing.
|
|
998
|
+
*/
|
|
999
|
+
function sortMessageOf(state, locale) {
|
|
1000
|
+
const { sortDescriptor } = state;
|
|
1001
|
+
if (sortDescriptor === null) return "";
|
|
1002
|
+
const column = state.collection.columns.find((each) => each.key === sortDescriptor.column);
|
|
1003
|
+
return sortedFor(sortDescriptor.direction, column?.textValue ?? String(sortDescriptor.column), locale);
|
|
1004
|
+
}
|
|
1005
|
+
function sortOf(state, key) {
|
|
1006
|
+
return () => {
|
|
1007
|
+
state.sort(key);
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
function spanOf(cell) {
|
|
1011
|
+
return isValidElement(cell) ? cell.props.colSpan ?? 1 : 1;
|
|
1012
|
+
}
|
|
1013
|
+
function spanWidthOf(table, cell) {
|
|
1014
|
+
return widthAcross(table, cell.colIndex ?? cell.index, cell.colSpan ?? 1);
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Runs the step a screen reader asks a handle for, as a drag that starts and
|
|
1018
|
+
* ends at once, so `onResizeEnd` comes once as it does for a key on web.
|
|
1019
|
+
*/
|
|
1020
|
+
function stepOf(table, key) {
|
|
1021
|
+
return (event) => {
|
|
1022
|
+
const { actionName } = event.nativeEvent;
|
|
1023
|
+
if (actionName !== "increment" && actionName !== "decrement") return;
|
|
1024
|
+
const { layout } = table;
|
|
1025
|
+
const step = actionName === "increment" ? RESIZE_STEP : -10;
|
|
1026
|
+
layout.startResize(key);
|
|
1027
|
+
const sizes = layout.updateResizedColumns(key, layout.getColumnWidth(key) + step);
|
|
1028
|
+
table.onResize?.(sizes);
|
|
1029
|
+
layout.endResize();
|
|
1030
|
+
table.onResizeEnd?.(sizes);
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* A grid of rows and columns. Sorting and selection are React Stately's, as
|
|
1035
|
+
* web's are React Aria's: pass `sortDescriptor` with `onSortChange` and mark
|
|
1036
|
+
* the sortable columns `allowsSorting`, and set `selectionMode` to `single`
|
|
1037
|
+
* or `multiple` with `selectedKeys` and `onSelectionChange`, or
|
|
1038
|
+
* `defaultSelectedKeys`.
|
|
1039
|
+
*
|
|
1040
|
+
* ```tsx
|
|
1041
|
+
* <Table aria-label="Label" selectionMode="multiple">
|
|
1042
|
+
* <Table.Header>
|
|
1043
|
+
* <Table.Column id="colSelect" selection />
|
|
1044
|
+
* <Table.Column id="colName" isRowHeader>Label</Table.Column>
|
|
1045
|
+
* </Table.Header>
|
|
1046
|
+
* <Table.Body>
|
|
1047
|
+
* <Table.Row id="first">
|
|
1048
|
+
* <Table.Cell selection />
|
|
1049
|
+
* <Table.Cell>First item</Table.Cell>
|
|
1050
|
+
* </Table.Row>
|
|
1051
|
+
* </Table.Body>
|
|
1052
|
+
* </Table>
|
|
1053
|
+
* ```
|
|
1054
|
+
*
|
|
1055
|
+
* Composed from parts, since a cell takes any content: `Table.Header`,
|
|
1056
|
+
* `Table.Column`, `Table.Body`, `Table.Row`, `Table.Cell`, `Table.LoadMore`
|
|
1057
|
+
* and `Table.Footer`, which the table draws from their props, so none of them
|
|
1058
|
+
* renders anything on its own. A column's `id` and a row's share one
|
|
1059
|
+
* namespace, so keep the two sets apart, as `col`-prefixed column ids do.
|
|
1060
|
+
* Name the table with `aria-label`.
|
|
1061
|
+
*
|
|
1062
|
+
* The columns fill the table's width, `1fr` each unless `defaultWidth` or
|
|
1063
|
+
* `width` says otherwise, and the table scrolls sideways once they are wider
|
|
1064
|
+
* than it is. The rows scroll by themselves, so a table on a page that
|
|
1065
|
+
* scrolls takes `scrollEnabled={false}` and is laid out at its full length,
|
|
1066
|
+
* and one with `stickyHeader` wants a height to fill. `style` lands on the
|
|
1067
|
+
* box the table is drawn in, and `ref`, `aria-label`, `testID` and the
|
|
1068
|
+
* scroll props on the `FlatList` that holds the rows.
|
|
1069
|
+
*
|
|
1070
|
+
* The rows take focus while they run past the table's height, as web's grid
|
|
1071
|
+
* is a tab stop, so a keyboard can scroll them whatever they hold, and the
|
|
1072
|
+
* sideways scroll does while the columns are wider than the table; a call
|
|
1073
|
+
* site's own `focusable` still wins for the rows.
|
|
1074
|
+
*/
|
|
1075
|
+
function Table(t0) {
|
|
1076
|
+
const $ = c(45);
|
|
1077
|
+
let children;
|
|
1078
|
+
let defaultSelectedKeys;
|
|
1079
|
+
let disabledKeys;
|
|
1080
|
+
let disallowEmptySelection;
|
|
1081
|
+
let onSelectionChange;
|
|
1082
|
+
let onSortChange;
|
|
1083
|
+
let props;
|
|
1084
|
+
let selectedKeys;
|
|
1085
|
+
let sortDescriptor;
|
|
1086
|
+
let t1;
|
|
1087
|
+
let t2;
|
|
1088
|
+
if ($[0] !== t0) {
|
|
1089
|
+
({children, defaultSelectedKeys, disabledBehavior: t1, disabledKeys, disallowEmptySelection, onSelectionChange, onSortChange, selectedKeys, selectionMode: t2, sortDescriptor, ...props} = t0);
|
|
1090
|
+
$[0] = t0;
|
|
1091
|
+
$[1] = children;
|
|
1092
|
+
$[2] = defaultSelectedKeys;
|
|
1093
|
+
$[3] = disabledKeys;
|
|
1094
|
+
$[4] = disallowEmptySelection;
|
|
1095
|
+
$[5] = onSelectionChange;
|
|
1096
|
+
$[6] = onSortChange;
|
|
1097
|
+
$[7] = props;
|
|
1098
|
+
$[8] = selectedKeys;
|
|
1099
|
+
$[9] = sortDescriptor;
|
|
1100
|
+
$[10] = t1;
|
|
1101
|
+
$[11] = t2;
|
|
1102
|
+
} else {
|
|
1103
|
+
children = $[1];
|
|
1104
|
+
defaultSelectedKeys = $[2];
|
|
1105
|
+
disabledKeys = $[3];
|
|
1106
|
+
disallowEmptySelection = $[4];
|
|
1107
|
+
onSelectionChange = $[5];
|
|
1108
|
+
onSortChange = $[6];
|
|
1109
|
+
props = $[7];
|
|
1110
|
+
selectedKeys = $[8];
|
|
1111
|
+
sortDescriptor = $[9];
|
|
1112
|
+
t1 = $[10];
|
|
1113
|
+
t2 = $[11];
|
|
1114
|
+
}
|
|
1115
|
+
const disabledBehavior = t1 === void 0 ? "all" : t1;
|
|
1116
|
+
const selectionMode = t2 === void 0 ? "none" : t2;
|
|
1117
|
+
const theme = useTheme();
|
|
1118
|
+
const window = useWindowDimensions();
|
|
1119
|
+
const [measured, setMeasured] = useState(null);
|
|
1120
|
+
let t3;
|
|
1121
|
+
if ($[12] !== children) {
|
|
1122
|
+
t3 = partOf(children, TableHeader);
|
|
1123
|
+
$[12] = children;
|
|
1124
|
+
$[13] = t3;
|
|
1125
|
+
} else t3 = $[13];
|
|
1126
|
+
const header = t3;
|
|
1127
|
+
let t4;
|
|
1128
|
+
if ($[14] !== children) {
|
|
1129
|
+
t4 = partOf(children, TableBody);
|
|
1130
|
+
$[14] = children;
|
|
1131
|
+
$[15] = t4;
|
|
1132
|
+
} else t4 = $[15];
|
|
1133
|
+
const body = t4;
|
|
1134
|
+
let t5;
|
|
1135
|
+
if ($[16] !== children) {
|
|
1136
|
+
t5 = partOf(children, TableFooter);
|
|
1137
|
+
$[16] = children;
|
|
1138
|
+
$[17] = t5;
|
|
1139
|
+
} else t5 = $[17];
|
|
1140
|
+
const footer = t5;
|
|
1141
|
+
if (header === void 0 || body === void 0) throw new Error("A Table holds a Table.Header and a Table.Body.");
|
|
1142
|
+
let t6;
|
|
1143
|
+
if ($[18] !== body || $[19] !== header) {
|
|
1144
|
+
t6 = [header, body];
|
|
1145
|
+
$[18] = body;
|
|
1146
|
+
$[19] = header;
|
|
1147
|
+
$[20] = t6;
|
|
1148
|
+
} else t6 = $[20];
|
|
1149
|
+
const t7 = t6;
|
|
1150
|
+
let t8;
|
|
1151
|
+
if ($[21] !== defaultSelectedKeys || $[22] !== disabledBehavior || $[23] !== disabledKeys || $[24] !== disallowEmptySelection || $[25] !== onSelectionChange || $[26] !== onSortChange || $[27] !== selectedKeys || $[28] !== selectionMode || $[29] !== sortDescriptor || $[30] !== t7) {
|
|
1152
|
+
t8 = {
|
|
1153
|
+
children: t7,
|
|
1154
|
+
defaultSelectedKeys,
|
|
1155
|
+
disabledBehavior,
|
|
1156
|
+
disabledKeys,
|
|
1157
|
+
disallowEmptySelection,
|
|
1158
|
+
onSelectionChange,
|
|
1159
|
+
onSortChange,
|
|
1160
|
+
selectedKeys,
|
|
1161
|
+
selectionMode,
|
|
1162
|
+
sortDescriptor
|
|
1163
|
+
};
|
|
1164
|
+
$[21] = defaultSelectedKeys;
|
|
1165
|
+
$[22] = disabledBehavior;
|
|
1166
|
+
$[23] = disabledKeys;
|
|
1167
|
+
$[24] = disallowEmptySelection;
|
|
1168
|
+
$[25] = onSelectionChange;
|
|
1169
|
+
$[26] = onSortChange;
|
|
1170
|
+
$[27] = selectedKeys;
|
|
1171
|
+
$[28] = selectionMode;
|
|
1172
|
+
$[29] = sortDescriptor;
|
|
1173
|
+
$[30] = t7;
|
|
1174
|
+
$[31] = t8;
|
|
1175
|
+
} else t8 = $[31];
|
|
1176
|
+
const state = useTableState(t8);
|
|
1177
|
+
const selectionWidth = 2 * theme.spacing.lg + 40;
|
|
1178
|
+
let t9;
|
|
1179
|
+
if ($[32] !== selectionWidth) {
|
|
1180
|
+
t9 = defaultsOf(selectionWidth);
|
|
1181
|
+
$[32] = selectionWidth;
|
|
1182
|
+
$[33] = t9;
|
|
1183
|
+
} else t9 = $[33];
|
|
1184
|
+
const defaults = t9;
|
|
1185
|
+
const width = measured ?? window.width;
|
|
1186
|
+
let t10;
|
|
1187
|
+
if ($[34] !== defaults || $[35] !== width) {
|
|
1188
|
+
t10 = {
|
|
1189
|
+
...defaults,
|
|
1190
|
+
tableWidth: width
|
|
1191
|
+
};
|
|
1192
|
+
$[34] = defaults;
|
|
1193
|
+
$[35] = width;
|
|
1194
|
+
$[36] = t10;
|
|
1195
|
+
} else t10 = $[36];
|
|
1196
|
+
const layout = useTableColumnResizeState(t10, state);
|
|
1197
|
+
const t11 = footer?.props;
|
|
1198
|
+
let t12;
|
|
1199
|
+
if ($[37] !== body.props || $[38] !== header.props || $[39] !== layout || $[40] !== props || $[41] !== state || $[42] !== t11 || $[43] !== width) {
|
|
1200
|
+
t12 = /* @__PURE__ */ jsx(TableView, {
|
|
1201
|
+
...props,
|
|
1202
|
+
body: body.props,
|
|
1203
|
+
footer: t11,
|
|
1204
|
+
header: header.props,
|
|
1205
|
+
layout,
|
|
1206
|
+
onWidth: setMeasured,
|
|
1207
|
+
state,
|
|
1208
|
+
width
|
|
1209
|
+
});
|
|
1210
|
+
$[37] = body.props;
|
|
1211
|
+
$[38] = header.props;
|
|
1212
|
+
$[39] = layout;
|
|
1213
|
+
$[40] = props;
|
|
1214
|
+
$[41] = state;
|
|
1215
|
+
$[42] = t11;
|
|
1216
|
+
$[43] = width;
|
|
1217
|
+
$[44] = t12;
|
|
1218
|
+
} else t12 = $[44];
|
|
1219
|
+
return t12;
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* The rows. `renderEmptyState` is what the table shows when there are none,
|
|
1223
|
+
* and a `Table.LoadMore` after them is the row it shows while fetching
|
|
1224
|
+
* more. The table draws it from its props, so it renders nothing on its
|
|
1225
|
+
* own.
|
|
1226
|
+
*/
|
|
1227
|
+
function TableBody(_props) {
|
|
1228
|
+
return null;
|
|
1229
|
+
}
|
|
1230
|
+
TableBody.getCollectionNode = bodyNode;
|
|
1231
|
+
/**
|
|
1232
|
+
* One cell. `selection` draws this row's checkbox in place of whatever else
|
|
1233
|
+
* the cell would hold. `style` and `testID` land on the cell.
|
|
1234
|
+
*/
|
|
1235
|
+
function TableCell(_props) {
|
|
1236
|
+
return null;
|
|
1237
|
+
}
|
|
1238
|
+
TableCell.getCollectionNode = cellNode;
|
|
1239
|
+
/**
|
|
1240
|
+
* One column. `allowsSorting` makes the header itself the control that
|
|
1241
|
+
* sorts; the arrow appears on the column the `sortDescriptor` names.
|
|
1242
|
+
* `selection` draws the select-all checkbox in place of a name. `style` and
|
|
1243
|
+
* `testID` land on the column's header.
|
|
1244
|
+
*
|
|
1245
|
+
* Its `id` shares a namespace with the rows', so give the two sets values
|
|
1246
|
+
* that cannot meet: a column and a row with one id between them leaves the
|
|
1247
|
+
* table with no columns at all.
|
|
1248
|
+
*/
|
|
1249
|
+
function TableColumn(_props) {
|
|
1250
|
+
return null;
|
|
1251
|
+
}
|
|
1252
|
+
TableColumn.getCollectionNode = columnNode;
|
|
1253
|
+
function TableEnd() {
|
|
1254
|
+
const $ = c(3);
|
|
1255
|
+
const own = stylesOf(useTheme());
|
|
1256
|
+
const { loadMore } = useTable();
|
|
1257
|
+
const t0 = loadMore === void 0 ? null : /* @__PURE__ */ jsx(LoadingRow, {
|
|
1258
|
+
...loadMore,
|
|
1259
|
+
style: composeStyles(loadMore.isLoading === true ? own.loading : void 0, loadMore.style)
|
|
1260
|
+
});
|
|
1261
|
+
let t1;
|
|
1262
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1263
|
+
t1 = /* @__PURE__ */ jsx(FooterRows, {});
|
|
1264
|
+
$[0] = t1;
|
|
1265
|
+
} else t1 = $[0];
|
|
1266
|
+
let t2;
|
|
1267
|
+
if ($[1] !== t0) {
|
|
1268
|
+
t2 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t0, t1] });
|
|
1269
|
+
$[1] = t0;
|
|
1270
|
+
$[2] = t2;
|
|
1271
|
+
} else t2 = $[2];
|
|
1272
|
+
return t2;
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Rows under the body, for totals and the like, ruled off from it. They are
|
|
1276
|
+
* not part of the selection and take no press, as React Aria keeps a footer
|
|
1277
|
+
* out of both. `style` and `testID` land on the footer.
|
|
1278
|
+
*/
|
|
1279
|
+
function TableFooter(_props) {
|
|
1280
|
+
return null;
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* The header row, holding the columns, and the rule drawn under it. `style`
|
|
1284
|
+
* and `testID` land on the row.
|
|
1285
|
+
*/
|
|
1286
|
+
function TableHeader(_props) {
|
|
1287
|
+
return null;
|
|
1288
|
+
}
|
|
1289
|
+
TableHeader.getCollectionNode = headerNodes;
|
|
1290
|
+
/**
|
|
1291
|
+
* The row shown while more rows are being fetched. `onLoadMore` is called
|
|
1292
|
+
* as the reader nears the end of the table, and the ring is drawn only while
|
|
1293
|
+
* `isLoading`, in a live region, so a screen reader hears it arrive. It goes
|
|
1294
|
+
* inside `Table.Body`, after the rows.
|
|
1295
|
+
*/
|
|
1296
|
+
function TableLoadMore(_props) {
|
|
1297
|
+
return null;
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* One row. Give every row an `id`, which is the key selection is reported
|
|
1301
|
+
* by, and keep it apart from every column's. `onAction` runs when a press
|
|
1302
|
+
* runs the row's action, and `href` goes to that route. `style`, `ref` and
|
|
1303
|
+
* `testID` land on the row.
|
|
1304
|
+
*/
|
|
1305
|
+
function TableRow(_props) {
|
|
1306
|
+
return null;
|
|
1307
|
+
}
|
|
1308
|
+
TableRow.getCollectionNode = rowNode;
|
|
1309
|
+
function contentTo(set, then) {
|
|
1310
|
+
return (width, height) => {
|
|
1311
|
+
set(height);
|
|
1312
|
+
then?.(width, height);
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
function roomTo(set, then) {
|
|
1316
|
+
return (event) => {
|
|
1317
|
+
set(event.nativeEvent.layout.height);
|
|
1318
|
+
then?.(event);
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* What a `Table` draws once it has its state and its columns' widths: the
|
|
1323
|
+
* header, the rows and the footer, as wide as the columns together, in a
|
|
1324
|
+
* box that scrolls sideways once they are wider than it is.
|
|
1325
|
+
*/
|
|
1326
|
+
function TableView(t0) {
|
|
1327
|
+
const $ = c(126);
|
|
1328
|
+
let body;
|
|
1329
|
+
let footer;
|
|
1330
|
+
let header;
|
|
1331
|
+
let layout;
|
|
1332
|
+
let onContentSizeChange;
|
|
1333
|
+
let onLayout;
|
|
1334
|
+
let onResize;
|
|
1335
|
+
let onResizeEnd;
|
|
1336
|
+
let onRowAction;
|
|
1337
|
+
let onWidth;
|
|
1338
|
+
let props;
|
|
1339
|
+
let ref;
|
|
1340
|
+
let resizeLabel;
|
|
1341
|
+
let selectAllLabel;
|
|
1342
|
+
let selectLabel;
|
|
1343
|
+
let state;
|
|
1344
|
+
let style;
|
|
1345
|
+
let t1;
|
|
1346
|
+
let t2;
|
|
1347
|
+
let width;
|
|
1348
|
+
if ($[0] !== t0) {
|
|
1349
|
+
({body, footer, header, layout, onContentSizeChange, onLayout, onResize, onResizeEnd, onRowAction, onWidth, ref, resizable: t1, resizeLabel, selectAllLabel, selectLabel, state, stickyHeader: t2, style, width, ...props} = t0);
|
|
1350
|
+
$[0] = t0;
|
|
1351
|
+
$[1] = body;
|
|
1352
|
+
$[2] = footer;
|
|
1353
|
+
$[3] = header;
|
|
1354
|
+
$[4] = layout;
|
|
1355
|
+
$[5] = onContentSizeChange;
|
|
1356
|
+
$[6] = onLayout;
|
|
1357
|
+
$[7] = onResize;
|
|
1358
|
+
$[8] = onResizeEnd;
|
|
1359
|
+
$[9] = onRowAction;
|
|
1360
|
+
$[10] = onWidth;
|
|
1361
|
+
$[11] = props;
|
|
1362
|
+
$[12] = ref;
|
|
1363
|
+
$[13] = resizeLabel;
|
|
1364
|
+
$[14] = selectAllLabel;
|
|
1365
|
+
$[15] = selectLabel;
|
|
1366
|
+
$[16] = state;
|
|
1367
|
+
$[17] = style;
|
|
1368
|
+
$[18] = t1;
|
|
1369
|
+
$[19] = t2;
|
|
1370
|
+
$[20] = width;
|
|
1371
|
+
} else {
|
|
1372
|
+
body = $[1];
|
|
1373
|
+
footer = $[2];
|
|
1374
|
+
header = $[3];
|
|
1375
|
+
layout = $[4];
|
|
1376
|
+
onContentSizeChange = $[5];
|
|
1377
|
+
onLayout = $[6];
|
|
1378
|
+
onResize = $[7];
|
|
1379
|
+
onResizeEnd = $[8];
|
|
1380
|
+
onRowAction = $[9];
|
|
1381
|
+
onWidth = $[10];
|
|
1382
|
+
props = $[11];
|
|
1383
|
+
ref = $[12];
|
|
1384
|
+
resizeLabel = $[13];
|
|
1385
|
+
selectAllLabel = $[14];
|
|
1386
|
+
selectLabel = $[15];
|
|
1387
|
+
state = $[16];
|
|
1388
|
+
style = $[17];
|
|
1389
|
+
t1 = $[18];
|
|
1390
|
+
t2 = $[19];
|
|
1391
|
+
width = $[20];
|
|
1392
|
+
}
|
|
1393
|
+
const resizable = t1 === void 0 ? false : t1;
|
|
1394
|
+
const stickyHeader = t2 === void 0 ? false : t2;
|
|
1395
|
+
const messages = useMessages();
|
|
1396
|
+
const locale = useLocaleOf(void 0);
|
|
1397
|
+
const [content, setContent] = useState(0);
|
|
1398
|
+
const [room, setRoom] = useState(0);
|
|
1399
|
+
const { columns } = state.collection;
|
|
1400
|
+
let Root;
|
|
1401
|
+
let T0;
|
|
1402
|
+
let T1;
|
|
1403
|
+
let isLoading;
|
|
1404
|
+
let loadMore;
|
|
1405
|
+
let native;
|
|
1406
|
+
let renderEmptyState;
|
|
1407
|
+
let rows;
|
|
1408
|
+
let t3;
|
|
1409
|
+
let t4;
|
|
1410
|
+
let t5;
|
|
1411
|
+
let t6;
|
|
1412
|
+
let t7;
|
|
1413
|
+
let value;
|
|
1414
|
+
if ($[21] !== body || $[22] !== columns || $[23] !== footer || $[24] !== header || $[25] !== layout || $[26] !== messages || $[27] !== onResize || $[28] !== onResizeEnd || $[29] !== onRowAction || $[30] !== props || $[31] !== resizable || $[32] !== resizeLabel || $[33] !== selectAllLabel || $[34] !== selectLabel || $[35] !== state || $[36] !== width) {
|
|
1415
|
+
let t8;
|
|
1416
|
+
if ($[51] !== layout) {
|
|
1417
|
+
t8 = (sum, column) => sum + layout.getColumnWidth(column.key);
|
|
1418
|
+
$[51] = layout;
|
|
1419
|
+
$[52] = t8;
|
|
1420
|
+
} else t8 = $[52];
|
|
1421
|
+
const total = columns.reduce(t8, 0);
|
|
1422
|
+
let t9;
|
|
1423
|
+
if ($[53] !== state.collection) {
|
|
1424
|
+
t9 = [...state.collection];
|
|
1425
|
+
$[53] = state.collection;
|
|
1426
|
+
$[54] = t9;
|
|
1427
|
+
} else t9 = $[54];
|
|
1428
|
+
rows = t9;
|
|
1429
|
+
({renderEmptyState} = body);
|
|
1430
|
+
let t10;
|
|
1431
|
+
if ($[55] !== body.children) {
|
|
1432
|
+
t10 = childElementsOf(typeof body.children === "function" ? null : body.children).find(isLoadMore)?.props;
|
|
1433
|
+
$[55] = body.children;
|
|
1434
|
+
$[56] = t10;
|
|
1435
|
+
} else t10 = $[56];
|
|
1436
|
+
loadMore = t10;
|
|
1437
|
+
isLoading = loadMore?.isLoading ?? false;
|
|
1438
|
+
let t11;
|
|
1439
|
+
if ($[57] !== resizable) {
|
|
1440
|
+
t11 = resizable ? Gesture.Native() : void 0;
|
|
1441
|
+
$[57] = resizable;
|
|
1442
|
+
$[58] = t11;
|
|
1443
|
+
} else t11 = $[58];
|
|
1444
|
+
native = t11;
|
|
1445
|
+
const { testID } = props;
|
|
1446
|
+
const t12 = resizeLabel ?? messages.table.resizer;
|
|
1447
|
+
const t13 = selectLabel ?? messages.select;
|
|
1448
|
+
let t14;
|
|
1449
|
+
if ($[59] !== columns || $[60] !== footer || $[61] !== header || $[62] !== layout || $[63] !== loadMore || $[64] !== native || $[65] !== onResize || $[66] !== onResizeEnd || $[67] !== onRowAction || $[68] !== renderEmptyState || $[69] !== resizable || $[70] !== selectAllLabel || $[71] !== state || $[72] !== t12 || $[73] !== t13 || $[74] !== testID) {
|
|
1450
|
+
t14 = {
|
|
1451
|
+
columns,
|
|
1452
|
+
footer,
|
|
1453
|
+
header,
|
|
1454
|
+
layout,
|
|
1455
|
+
loadMore,
|
|
1456
|
+
native,
|
|
1457
|
+
onResize,
|
|
1458
|
+
onResizeEnd,
|
|
1459
|
+
onRowAction,
|
|
1460
|
+
renderEmptyState,
|
|
1461
|
+
resizable,
|
|
1462
|
+
resizeLabel: t12,
|
|
1463
|
+
selectAllLabel,
|
|
1464
|
+
selectLabel: t13,
|
|
1465
|
+
state,
|
|
1466
|
+
testID
|
|
1467
|
+
};
|
|
1468
|
+
$[59] = columns;
|
|
1469
|
+
$[60] = footer;
|
|
1470
|
+
$[61] = header;
|
|
1471
|
+
$[62] = layout;
|
|
1472
|
+
$[63] = loadMore;
|
|
1473
|
+
$[64] = native;
|
|
1474
|
+
$[65] = onResize;
|
|
1475
|
+
$[66] = onResizeEnd;
|
|
1476
|
+
$[67] = onRowAction;
|
|
1477
|
+
$[68] = renderEmptyState;
|
|
1478
|
+
$[69] = resizable;
|
|
1479
|
+
$[70] = selectAllLabel;
|
|
1480
|
+
$[71] = state;
|
|
1481
|
+
$[72] = t12;
|
|
1482
|
+
$[73] = t13;
|
|
1483
|
+
$[74] = testID;
|
|
1484
|
+
$[75] = t14;
|
|
1485
|
+
} else t14 = $[75];
|
|
1486
|
+
value = t14;
|
|
1487
|
+
Root = resizable ? GestureHandlerRootView : View;
|
|
1488
|
+
T1 = ScrollView;
|
|
1489
|
+
t4 = total > width;
|
|
1490
|
+
t5 = true;
|
|
1491
|
+
t6 = total > width;
|
|
1492
|
+
t7 = total > width;
|
|
1493
|
+
T0 = View;
|
|
1494
|
+
t3 = composeStyles(styles.grid, { width: total });
|
|
1495
|
+
$[21] = body;
|
|
1496
|
+
$[22] = columns;
|
|
1497
|
+
$[23] = footer;
|
|
1498
|
+
$[24] = header;
|
|
1499
|
+
$[25] = layout;
|
|
1500
|
+
$[26] = messages;
|
|
1501
|
+
$[27] = onResize;
|
|
1502
|
+
$[28] = onResizeEnd;
|
|
1503
|
+
$[29] = onRowAction;
|
|
1504
|
+
$[30] = props;
|
|
1505
|
+
$[31] = resizable;
|
|
1506
|
+
$[32] = resizeLabel;
|
|
1507
|
+
$[33] = selectAllLabel;
|
|
1508
|
+
$[34] = selectLabel;
|
|
1509
|
+
$[35] = state;
|
|
1510
|
+
$[36] = width;
|
|
1511
|
+
$[37] = Root;
|
|
1512
|
+
$[38] = T0;
|
|
1513
|
+
$[39] = T1;
|
|
1514
|
+
$[40] = isLoading;
|
|
1515
|
+
$[41] = loadMore;
|
|
1516
|
+
$[42] = native;
|
|
1517
|
+
$[43] = renderEmptyState;
|
|
1518
|
+
$[44] = rows;
|
|
1519
|
+
$[45] = t3;
|
|
1520
|
+
$[46] = t4;
|
|
1521
|
+
$[47] = t5;
|
|
1522
|
+
$[48] = t6;
|
|
1523
|
+
$[49] = t7;
|
|
1524
|
+
$[50] = value;
|
|
1525
|
+
} else {
|
|
1526
|
+
Root = $[37];
|
|
1527
|
+
T0 = $[38];
|
|
1528
|
+
T1 = $[39];
|
|
1529
|
+
isLoading = $[40];
|
|
1530
|
+
loadMore = $[41];
|
|
1531
|
+
native = $[42];
|
|
1532
|
+
renderEmptyState = $[43];
|
|
1533
|
+
rows = $[44];
|
|
1534
|
+
t3 = $[45];
|
|
1535
|
+
t4 = $[46];
|
|
1536
|
+
t5 = $[47];
|
|
1537
|
+
t6 = $[48];
|
|
1538
|
+
t7 = $[49];
|
|
1539
|
+
value = $[50];
|
|
1540
|
+
}
|
|
1541
|
+
let t8;
|
|
1542
|
+
if ($[76] !== stickyHeader) {
|
|
1543
|
+
t8 = stickyHeader ? /* @__PURE__ */ jsx(HeaderRow, {}) : null;
|
|
1544
|
+
$[76] = stickyHeader;
|
|
1545
|
+
$[77] = t8;
|
|
1546
|
+
} else t8 = $[77];
|
|
1547
|
+
const t9 = content > room;
|
|
1548
|
+
const t10 = isLoading || renderEmptyState === void 0 ? void 0 : EmptyBody;
|
|
1549
|
+
const t11 = stickyHeader ? void 0 : HeaderRow;
|
|
1550
|
+
let t12;
|
|
1551
|
+
if ($[78] !== onContentSizeChange) {
|
|
1552
|
+
t12 = contentTo(setContent, onContentSizeChange);
|
|
1553
|
+
$[78] = onContentSizeChange;
|
|
1554
|
+
$[79] = t12;
|
|
1555
|
+
} else t12 = $[79];
|
|
1556
|
+
let t13;
|
|
1557
|
+
if ($[80] !== loadMore) {
|
|
1558
|
+
t13 = loadMore === void 0 ? void 0 : loadMoreOf(loadMore);
|
|
1559
|
+
$[80] = loadMore;
|
|
1560
|
+
$[81] = t13;
|
|
1561
|
+
} else t13 = $[81];
|
|
1562
|
+
const t14 = loadMore?.scrollOffset ?? 1;
|
|
1563
|
+
let t15;
|
|
1564
|
+
if ($[82] !== onLayout) {
|
|
1565
|
+
t15 = roomTo(setRoom, onLayout);
|
|
1566
|
+
$[82] = onLayout;
|
|
1567
|
+
$[83] = t15;
|
|
1568
|
+
} else t15 = $[83];
|
|
1569
|
+
let t16;
|
|
1570
|
+
if ($[84] !== props || $[85] !== ref || $[86] !== rows || $[87] !== t10 || $[88] !== t11 || $[89] !== t12 || $[90] !== t13 || $[91] !== t14 || $[92] !== t15 || $[93] !== t9) {
|
|
1571
|
+
t16 = /* @__PURE__ */ jsx(FlatList, {
|
|
1572
|
+
focusable: t9,
|
|
1573
|
+
...props,
|
|
1574
|
+
data: rows,
|
|
1575
|
+
keyExtractor: keyOf,
|
|
1576
|
+
ListEmptyComponent: t10,
|
|
1577
|
+
ListFooterComponent: TableEnd,
|
|
1578
|
+
ListHeaderComponent: t11,
|
|
1579
|
+
onContentSizeChange: t12,
|
|
1580
|
+
onEndReached: t13,
|
|
1581
|
+
onEndReachedThreshold: t14,
|
|
1582
|
+
onLayout: t15,
|
|
1583
|
+
ref,
|
|
1584
|
+
renderItem: renderRow
|
|
1585
|
+
});
|
|
1586
|
+
$[84] = props;
|
|
1587
|
+
$[85] = ref;
|
|
1588
|
+
$[86] = rows;
|
|
1589
|
+
$[87] = t10;
|
|
1590
|
+
$[88] = t11;
|
|
1591
|
+
$[89] = t12;
|
|
1592
|
+
$[90] = t13;
|
|
1593
|
+
$[91] = t14;
|
|
1594
|
+
$[92] = t15;
|
|
1595
|
+
$[93] = t9;
|
|
1596
|
+
$[94] = t16;
|
|
1597
|
+
} else t16 = $[94];
|
|
1598
|
+
let t17;
|
|
1599
|
+
if ($[95] !== T0 || $[96] !== t16 || $[97] !== t3 || $[98] !== t8) {
|
|
1600
|
+
t17 = /* @__PURE__ */ jsxs(T0, {
|
|
1601
|
+
style: t3,
|
|
1602
|
+
children: [t8, t16]
|
|
1603
|
+
});
|
|
1604
|
+
$[95] = T0;
|
|
1605
|
+
$[96] = t16;
|
|
1606
|
+
$[97] = t3;
|
|
1607
|
+
$[98] = t8;
|
|
1608
|
+
$[99] = t17;
|
|
1609
|
+
} else t17 = $[99];
|
|
1610
|
+
let t18;
|
|
1611
|
+
if ($[100] !== T1 || $[101] !== t17 || $[102] !== t4 || $[103] !== t5 || $[104] !== t6 || $[105] !== t7) {
|
|
1612
|
+
t18 = /* @__PURE__ */ jsx(T1, {
|
|
1613
|
+
focusable: t4,
|
|
1614
|
+
horizontal: t5,
|
|
1615
|
+
scrollEnabled: t6,
|
|
1616
|
+
showsHorizontalScrollIndicator: t7,
|
|
1617
|
+
children: t17
|
|
1618
|
+
});
|
|
1619
|
+
$[100] = T1;
|
|
1620
|
+
$[101] = t17;
|
|
1621
|
+
$[102] = t4;
|
|
1622
|
+
$[103] = t5;
|
|
1623
|
+
$[104] = t6;
|
|
1624
|
+
$[105] = t7;
|
|
1625
|
+
$[106] = t18;
|
|
1626
|
+
} else t18 = $[106];
|
|
1627
|
+
const scroller = t18;
|
|
1628
|
+
let t19;
|
|
1629
|
+
if ($[107] !== onWidth) {
|
|
1630
|
+
t19 = widthTo(onWidth);
|
|
1631
|
+
$[107] = onWidth;
|
|
1632
|
+
$[108] = t19;
|
|
1633
|
+
} else t19 = $[108];
|
|
1634
|
+
let t20;
|
|
1635
|
+
if ($[109] !== native || $[110] !== scroller) {
|
|
1636
|
+
t20 = native === void 0 ? scroller : /* @__PURE__ */ jsx(GestureDetector, {
|
|
1637
|
+
gesture: native,
|
|
1638
|
+
children: scroller
|
|
1639
|
+
});
|
|
1640
|
+
$[109] = native;
|
|
1641
|
+
$[110] = scroller;
|
|
1642
|
+
$[111] = t20;
|
|
1643
|
+
} else t20 = $[111];
|
|
1644
|
+
let t21;
|
|
1645
|
+
if ($[112] !== locale || $[113] !== state) {
|
|
1646
|
+
t21 = sortMessageOf(state, locale);
|
|
1647
|
+
$[112] = locale;
|
|
1648
|
+
$[113] = state;
|
|
1649
|
+
$[114] = t21;
|
|
1650
|
+
} else t21 = $[114];
|
|
1651
|
+
let t22;
|
|
1652
|
+
if ($[115] !== t21) {
|
|
1653
|
+
t22 = /* @__PURE__ */ jsx(Status, { message: t21 });
|
|
1654
|
+
$[115] = t21;
|
|
1655
|
+
$[116] = t22;
|
|
1656
|
+
} else t22 = $[116];
|
|
1657
|
+
let t23;
|
|
1658
|
+
if ($[117] !== Root || $[118] !== style || $[119] !== t19 || $[120] !== t20 || $[121] !== t22) {
|
|
1659
|
+
t23 = /* @__PURE__ */ jsxs(Root, {
|
|
1660
|
+
onLayout: t19,
|
|
1661
|
+
style,
|
|
1662
|
+
children: [t20, t22]
|
|
1663
|
+
});
|
|
1664
|
+
$[117] = Root;
|
|
1665
|
+
$[118] = style;
|
|
1666
|
+
$[119] = t19;
|
|
1667
|
+
$[120] = t20;
|
|
1668
|
+
$[121] = t22;
|
|
1669
|
+
$[122] = t23;
|
|
1670
|
+
} else t23 = $[122];
|
|
1671
|
+
let t24;
|
|
1672
|
+
if ($[123] !== t23 || $[124] !== value) {
|
|
1673
|
+
t24 = /* @__PURE__ */ jsx(TableContext, {
|
|
1674
|
+
value,
|
|
1675
|
+
children: t23
|
|
1676
|
+
});
|
|
1677
|
+
$[123] = t23;
|
|
1678
|
+
$[124] = value;
|
|
1679
|
+
$[125] = t24;
|
|
1680
|
+
} else t24 = $[125];
|
|
1681
|
+
return t24;
|
|
1682
|
+
}
|
|
1683
|
+
function useTable() {
|
|
1684
|
+
const table = use(TableContext);
|
|
1685
|
+
if (table === null) throw new Error("A Table part is drawn by the Table it is in.");
|
|
1686
|
+
return table;
|
|
1687
|
+
}
|
|
1688
|
+
function widthAcross(table, start, span) {
|
|
1689
|
+
let width = 0;
|
|
1690
|
+
for (const column of table.columns.slice(start, start + span)) width += table.layout.getColumnWidth(column.key);
|
|
1691
|
+
return width;
|
|
1692
|
+
}
|
|
1693
|
+
function widthTo(set) {
|
|
1694
|
+
return ({ nativeEvent }) => {
|
|
1695
|
+
set(nativeEvent.layout.width);
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
Table.Body = TableBody;
|
|
1699
|
+
Table.Cell = TableCell;
|
|
1700
|
+
Table.Column = TableColumn;
|
|
1701
|
+
Table.Footer = TableFooter;
|
|
1702
|
+
Table.Header = TableHeader;
|
|
1703
|
+
Table.LoadMore = TableLoadMore;
|
|
1704
|
+
Table.Row = TableRow;
|
|
1705
|
+
//#endregion
|
|
1706
|
+
export { Table, TableBody, TableCell, TableColumn, TableFooter, TableHeader, TableLoadMore, TableRow };
|
|
1707
|
+
|
|
1708
|
+
//# sourceMappingURL=index.js.map
|