@jirawatpyk/aura-react 4.5.0 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/aura.bundle.js +2518 -2028
- package/dist/cjs/index.cjs +2516 -2028
- package/dist/esm/Button.js +9 -9
- package/dist/esm/Checkbox.js +41 -33
- package/dist/esm/Combobox.js +143 -125
- package/dist/esm/DataTable.js +629 -495
- package/dist/esm/DatePicker.js +378 -305
- package/dist/esm/Dialog.js +48 -59
- package/dist/esm/DropdownMenu.js +9 -12
- package/dist/esm/FileUpload.js +91 -73
- package/dist/esm/Icon.js +27 -22
- package/dist/esm/IconButton.js +13 -9
- package/dist/esm/Menu.js +78 -66
- package/dist/esm/Stat.js +9 -26
- package/dist/esm/StatusPill.js +12 -13
- package/dist/esm/Surface.js +17 -13
- package/dist/esm/ThemeStyle.js +9 -5
- package/dist/esm/TimePicker.js +155 -127
- package/dist/esm/extra.js +270 -186
- package/dist/esm/feedback.js +112 -84
- package/dist/esm/forms.js +144 -113
- package/dist/esm/internal.js +33 -23
- package/dist/esm/layout.js +113 -128
- package/dist/esm/layout2.js +67 -45
- package/dist/esm/locale.js +15 -9
- package/dist/esm/overlay.js +21 -18
- package/dist/esm/theme.js +101 -49
- package/dist/index.d.ts +6 -6
- package/package.json +5 -3
package/dist/esm/DataTable.js
CHANGED
|
@@ -7,98 +7,114 @@ import { IconButton } from "./IconButton.js";
|
|
|
7
7
|
import { Checkbox } from "./Checkbox.js";
|
|
8
8
|
import { Menu } from "./Menu.js";
|
|
9
9
|
import { StatusPill, toneFor, TONE_ORDER } from "./StatusPill.js";
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
var DEFAULT_COLUMNS = [
|
|
10
|
+
const BP = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
11
|
+
const DEFAULT_COLUMNS = [
|
|
13
12
|
{ key: "id", label: "ID", width: 96, mono: true },
|
|
14
13
|
{ key: "name", label: "NAME", width: 160 },
|
|
15
14
|
{ key: "status", label: "STATUS", width: 112, pill: true },
|
|
16
15
|
{ key: "owner", label: "OWNER" }
|
|
17
16
|
];
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const SKELETON_WIDTHS = ["72%", "56%", "84%", "44%", "64%"];
|
|
18
|
+
const ROW_H = 48, OVERSCAN = 8, FLEX_MIN = 160;
|
|
20
19
|
const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const t = useStrings();
|
|
21
|
+
const columns = props.columns || DEFAULT_COLUMNS;
|
|
22
|
+
const byKey = {};
|
|
24
23
|
columns.forEach(function(c) {
|
|
25
24
|
byKey[c.key] = c;
|
|
26
25
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
26
|
+
const rows = props.rows || [];
|
|
27
|
+
const rowKey = props.rowKey || columns[0].key;
|
|
28
|
+
const loading = !!props.loading;
|
|
29
|
+
const selectable = !!props.selectable;
|
|
30
|
+
const reorderable = props.reorderable !== false && !!props.columnControls;
|
|
31
|
+
const controls = !!props.columnControls;
|
|
32
|
+
const sortState = useMaybeControlled(props.sort, props.defaultSort || null, props.onSortChange);
|
|
33
|
+
const sort = sortState[0], setSort = sortState[1];
|
|
34
|
+
const selState = useMaybeControlled(props.selected, props.defaultSelected || [], props.onSelectionChange);
|
|
35
|
+
const selected = selState[0], setSelected = selState[1];
|
|
36
|
+
const pageState = useMaybeControlled(props.page, props.defaultPage || 1, props.onPageChange);
|
|
37
|
+
const orderState = useMaybeControlled(
|
|
38
|
+
props.columnOrder,
|
|
39
|
+
columns.map(function(c) {
|
|
40
|
+
return c.key;
|
|
41
|
+
}),
|
|
42
|
+
props.onColumnOrderChange
|
|
43
|
+
);
|
|
44
|
+
const hiddenState = useMaybeControlled(
|
|
45
|
+
props.hiddenColumns,
|
|
46
|
+
columns.filter(function(c) {
|
|
47
|
+
return c.hidden;
|
|
48
|
+
}).map(function(c) {
|
|
49
|
+
return c.key;
|
|
50
|
+
}),
|
|
51
|
+
props.onHiddenColumnsChange
|
|
52
|
+
);
|
|
53
|
+
const pinState = useMaybeControlled(
|
|
54
|
+
props.pinnedColumns,
|
|
55
|
+
columns.filter(function(c) {
|
|
56
|
+
return c.pinned;
|
|
57
|
+
}).map(function(c) {
|
|
58
|
+
return c.key;
|
|
59
|
+
}),
|
|
60
|
+
props.onPinnedColumnsChange
|
|
61
|
+
);
|
|
62
|
+
const widthState = React.useState({});
|
|
63
|
+
const widths = widthState[0], setWidths = widthState[1];
|
|
64
|
+
const activeState = React.useState({ r: 1, c: 0 });
|
|
65
|
+
const scrollState = React.useState(0);
|
|
66
|
+
const scrollTop = scrollState[0], setScrollTop = scrollState[1];
|
|
67
|
+
const scrolledX = React.useState(false);
|
|
68
|
+
const menuState = React.useState(null);
|
|
69
|
+
const menu = menuState[0], setMenu = menuState[1];
|
|
70
|
+
const dragState = React.useState(null);
|
|
71
|
+
const drag = dragState[0], setDrag = dragState[1];
|
|
72
|
+
const gridRef = React.useRef(null);
|
|
73
|
+
const wrapRef = React.useRef(null), wrapMerged = useMergedRef(ref, wrapRef);
|
|
74
|
+
const boxWidth = React.useState(null);
|
|
75
|
+
const measure = !!props.stackBelow || columns.some(function(c) {
|
|
65
76
|
return c.hideBelow != null;
|
|
66
77
|
});
|
|
67
|
-
React.useEffect(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
React.useEffect(
|
|
79
|
+
function() {
|
|
80
|
+
if (!measure || !wrapRef.current || typeof ResizeObserver === "undefined") return;
|
|
81
|
+
const ro = new ResizeObserver(function(en) {
|
|
82
|
+
boxWidth[1](en[0].contentRect.width);
|
|
83
|
+
});
|
|
84
|
+
ro.observe(wrapRef.current);
|
|
85
|
+
return function() {
|
|
86
|
+
ro.disconnect();
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
[measure]
|
|
90
|
+
);
|
|
91
|
+
const stacked = !!props.stackBelow && boxWidth[0] != null && boxWidth[0] < props.stackBelow;
|
|
78
92
|
function tooNarrow(c) {
|
|
79
93
|
if (c.hideBelow == null || boxWidth[0] == null || stacked) return false;
|
|
80
|
-
|
|
94
|
+
const px = typeof c.hideBelow === "number" ? c.hideBelow : BP[c.hideBelow];
|
|
81
95
|
return px != null && boxWidth[0] < px;
|
|
82
96
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
97
|
+
const scrollRef = React.useRef(null);
|
|
98
|
+
const pending = React.useRef(null);
|
|
99
|
+
const resizing = React.useRef(false);
|
|
86
100
|
useIsoLayoutEffect(function() {
|
|
87
101
|
if (stacked || !gridRef.current) return;
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
const els = gridRef.current.querySelectorAll(
|
|
103
|
+
'.aura-table__td button, .aura-table__td a[href], .aura-table__td input, .aura-table__td select, .aura-table__td textarea, .aura-table__td [tabindex="0"]'
|
|
104
|
+
);
|
|
105
|
+
for (let i = 0; i < els.length; i++) if (els[i].tabIndex !== -1) els[i].tabIndex = -1;
|
|
90
106
|
});
|
|
91
107
|
function widthOf(c) {
|
|
92
108
|
return widths[c.key] != null ? widths[c.key] : c.width;
|
|
93
109
|
}
|
|
94
|
-
|
|
110
|
+
const order = orderState[0].filter(function(k) {
|
|
95
111
|
return byKey[k];
|
|
96
112
|
});
|
|
97
113
|
columns.forEach(function(c) {
|
|
98
114
|
if (order.indexOf(c.key) < 0) order.push(c.key);
|
|
99
115
|
});
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
const hidden = hiddenState[0], pinnedKeys = pinState[0];
|
|
117
|
+
const shown = order.filter(function(k) {
|
|
102
118
|
return hidden.indexOf(k) < 0;
|
|
103
119
|
}).map(function(k) {
|
|
104
120
|
return byKey[k];
|
|
@@ -108,84 +124,89 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
108
124
|
function isPinned(c) {
|
|
109
125
|
return pinnedKeys.indexOf(c.key) >= 0 && c.width != null;
|
|
110
126
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
127
|
+
const vis = shown.filter(isPinned).concat(
|
|
128
|
+
shown.filter(function(c) {
|
|
129
|
+
return !isPinned(c);
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
const nPinned = vis.filter(isPinned).length;
|
|
133
|
+
const hasFlex = vis.some(function(c) {
|
|
116
134
|
return widthOf(c) == null;
|
|
117
135
|
});
|
|
118
|
-
|
|
136
|
+
let fixedSum = 0;
|
|
119
137
|
vis.forEach(function(c) {
|
|
120
138
|
fixedSum += widthOf(c) != null ? widthOf(c) : FLEX_MIN;
|
|
121
139
|
});
|
|
122
|
-
|
|
140
|
+
let pinOffsets = {}, acc = 0;
|
|
123
141
|
vis.forEach(function(c) {
|
|
124
142
|
if (isPinned(c)) {
|
|
125
143
|
pinOffsets[c.key] = acc;
|
|
126
144
|
acc += widthOf(c);
|
|
127
145
|
}
|
|
128
146
|
});
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
function cellStyle(c,
|
|
133
|
-
|
|
147
|
+
const selW = selectable ? " + var(--aura-table-select-width)" : "";
|
|
148
|
+
const gutterR = controls ? "var(--aura-space-12)" : "var(--aura-space-6)";
|
|
149
|
+
const rowMinWidth = "calc(" + fixedSum + "px + var(--aura-space-6) + " + gutterR + selW + ")";
|
|
150
|
+
function cellStyle(c, i) {
|
|
151
|
+
let w = widthOf(c), s;
|
|
134
152
|
if (w == null) s = { flex: "1 1 0", minWidth: (c.minWidth || FLEX_MIN) + "px" };
|
|
135
|
-
else if (!hasFlex &&
|
|
153
|
+
else if (!hasFlex && i === vis.length - 1) s = { flex: "1 0 auto", width: w + "px" };
|
|
136
154
|
else s = { width: w + "px", flex: "none" };
|
|
137
155
|
if (isPinned(c)) s.left = "calc(var(--aura-space-6)" + selW + " + " + pinOffsets[c.key] + "px)";
|
|
138
156
|
return s;
|
|
139
157
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
158
|
+
const view = React.useMemo(
|
|
159
|
+
function() {
|
|
160
|
+
if (!sort || !sort.key || !byKey[sort.key]) return rows;
|
|
161
|
+
const col = byKey[sort.key];
|
|
162
|
+
const val = col.sortValue || (col.pill ? function(r) {
|
|
163
|
+
return TONE_ORDER[col.tones && col.tones[r[col.key]] || toneFor(r[col.key])];
|
|
164
|
+
} : function(r) {
|
|
165
|
+
return r[col.key];
|
|
166
|
+
});
|
|
167
|
+
const dir = sort.dir === "desc" ? -1 : 1;
|
|
168
|
+
return rows.map(function(r, i) {
|
|
169
|
+
return [r, i];
|
|
170
|
+
}).sort(function(a, b) {
|
|
171
|
+
return compare(val(a[0]), val(b[0])) * dir || a[1] - b[1];
|
|
172
|
+
}).map(function(p) {
|
|
173
|
+
return p[0];
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
[rows, sort && sort.key, sort && sort.dir]
|
|
177
|
+
);
|
|
157
178
|
function nextSort(key) {
|
|
158
179
|
if (!sort || sort.key !== key) return { key, dir: "asc" };
|
|
159
180
|
if (sort.dir === "asc") return { key, dir: "desc" };
|
|
160
181
|
return null;
|
|
161
182
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
183
|
+
const pageSize = props.pageSize || 0;
|
|
184
|
+
const pageCount = pageSize ? Math.max(1, Math.ceil(view.length / pageSize)) : 1;
|
|
185
|
+
const page = Math.min(Math.max(1, pageState[0] || 1), pageCount);
|
|
186
|
+
const first = pageSize ? (page - 1) * pageSize : 0;
|
|
187
|
+
const pageRows = pageSize ? view.slice(first, first + pageSize) : view;
|
|
167
188
|
function goPage(p, focus) {
|
|
168
|
-
|
|
189
|
+
const next = Math.min(Math.max(1, p), pageCount);
|
|
169
190
|
if (next === page) return false;
|
|
170
191
|
if (focus) pending.current = focus;
|
|
171
192
|
pageState[1](next);
|
|
172
193
|
if (scrollRef.current) scrollRef.current.scrollTop = 0;
|
|
173
194
|
return true;
|
|
174
195
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
196
|
+
const height = props.height || 0;
|
|
197
|
+
const virtual = !!height && !loading && pageRows.length > 0;
|
|
198
|
+
const bodyH = Math.max(ROW_H, height - ROW_H);
|
|
199
|
+
let start = 0, end = pageRows.length;
|
|
179
200
|
if (virtual) {
|
|
180
201
|
start = Math.max(0, Math.floor(scrollTop / ROW_H) - OVERSCAN);
|
|
181
202
|
end = Math.min(pageRows.length, Math.ceil((scrollTop + bodyH) / ROW_H) + OVERSCAN);
|
|
182
203
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
204
|
+
const visibleRows = Math.max(1, Math.floor(bodyH / ROW_H));
|
|
205
|
+
const nCols = vis.length + (selectable ? 1 : 0);
|
|
206
|
+
const nRows = loading ? 0 : pageRows.length;
|
|
207
|
+
const active = activeState[0];
|
|
208
|
+
const ar = Math.min(active.r, nRows), ac = Math.min(active.c, nCols - 1);
|
|
209
|
+
const activeRendered = ar === 0 || ar - 1 >= start && ar - 1 < end;
|
|
189
210
|
function colAt(ci) {
|
|
190
211
|
return selectable ? ci === 0 ? null : vis[ci - 1] : vis[ci];
|
|
191
212
|
}
|
|
@@ -194,17 +215,17 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
194
215
|
return r === ar && c === ac ? 0 : -1;
|
|
195
216
|
}
|
|
196
217
|
React.useEffect(function() {
|
|
197
|
-
|
|
218
|
+
const p = pending.current;
|
|
198
219
|
if (!p || !gridRef.current) return;
|
|
199
|
-
|
|
220
|
+
let c = p.c;
|
|
200
221
|
if (p.key) {
|
|
201
|
-
|
|
202
|
-
vis.forEach(function(x,
|
|
203
|
-
if (x.key === p.key) at =
|
|
222
|
+
let at = -1;
|
|
223
|
+
vis.forEach(function(x, i) {
|
|
224
|
+
if (x.key === p.key) at = i;
|
|
204
225
|
});
|
|
205
226
|
c = at >= 0 ? at + (selectable ? 1 : 0) : Math.min(p.c || 0, nCols - 1);
|
|
206
227
|
}
|
|
207
|
-
|
|
228
|
+
const el = gridRef.current.querySelector('[data-rc="' + p.r + ":" + c + '"]');
|
|
208
229
|
if (el) {
|
|
209
230
|
pending.current = null;
|
|
210
231
|
el.focus();
|
|
@@ -216,39 +237,45 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
216
237
|
activeState[1]({ r, c });
|
|
217
238
|
pending.current = { r, c };
|
|
218
239
|
if (virtual && r > 0) {
|
|
219
|
-
|
|
240
|
+
const sc = scrollRef.current, top = (r - 1) * ROW_H;
|
|
220
241
|
if (top < sc.scrollTop) sc.scrollTop = top;
|
|
221
242
|
else if (top + ROW_H > sc.scrollTop + bodyH) sc.scrollTop = top + ROW_H - bodyH;
|
|
222
243
|
setScrollTop(sc.scrollTop);
|
|
223
244
|
}
|
|
224
|
-
|
|
245
|
+
const el = gridRef.current && gridRef.current.querySelector('[data-rc="' + r + ":" + c + '"]');
|
|
225
246
|
if (el) {
|
|
226
247
|
pending.current = null;
|
|
227
248
|
el.focus();
|
|
228
249
|
}
|
|
229
250
|
}
|
|
230
|
-
|
|
251
|
+
const pageKeys = pageRows.map(function(r) {
|
|
231
252
|
return r[rowKey];
|
|
232
253
|
});
|
|
233
|
-
|
|
254
|
+
const selSet = {};
|
|
234
255
|
selected.forEach(function(k) {
|
|
235
256
|
selSet[k] = true;
|
|
236
257
|
});
|
|
237
|
-
|
|
258
|
+
const nSel = pageKeys.filter(function(k) {
|
|
238
259
|
return selSet[k];
|
|
239
260
|
}).length;
|
|
240
|
-
|
|
261
|
+
const all = nSel > 0 && nSel === pageKeys.length;
|
|
241
262
|
function toggle(k, on) {
|
|
242
|
-
setSelected(
|
|
243
|
-
|
|
244
|
-
|
|
263
|
+
setSelected(
|
|
264
|
+
on ? selected.concat([k]) : selected.filter(function(x) {
|
|
265
|
+
return x !== k;
|
|
266
|
+
})
|
|
267
|
+
);
|
|
245
268
|
}
|
|
246
269
|
function toggleAll() {
|
|
247
|
-
setSelected(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
270
|
+
setSelected(
|
|
271
|
+
all ? selected.filter(function(k) {
|
|
272
|
+
return pageKeys.indexOf(k) < 0;
|
|
273
|
+
}) : selected.concat(
|
|
274
|
+
pageKeys.filter(function(k) {
|
|
275
|
+
return !selSet[k];
|
|
276
|
+
})
|
|
277
|
+
)
|
|
278
|
+
);
|
|
252
279
|
}
|
|
253
280
|
function canResize(c) {
|
|
254
281
|
return !!props.resizable && c.resizable !== false && c.width != null;
|
|
@@ -257,9 +284,9 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
257
284
|
return Math.round(Math.min(c.maxWidth || 480, Math.max(c.minWidth || 64, w)));
|
|
258
285
|
}
|
|
259
286
|
function setW(c, w, done) {
|
|
260
|
-
|
|
287
|
+
const nw = clampW(c, w);
|
|
261
288
|
setWidths(function(prev) {
|
|
262
|
-
|
|
289
|
+
const o = Object.assign({}, prev);
|
|
263
290
|
o[c.key] = nw;
|
|
264
291
|
return o;
|
|
265
292
|
});
|
|
@@ -269,8 +296,8 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
269
296
|
e.preventDefault();
|
|
270
297
|
e.stopPropagation();
|
|
271
298
|
resizing.current = true;
|
|
272
|
-
|
|
273
|
-
|
|
299
|
+
let x0 = e.clientX, w0 = widthOf(c), last = w0;
|
|
300
|
+
const el = e.currentTarget;
|
|
274
301
|
el.classList.add("is-dragging");
|
|
275
302
|
document.body.style.cursor = "col-resize";
|
|
276
303
|
function move(ev) {
|
|
@@ -291,99 +318,148 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
291
318
|
window.addEventListener("pointerup", up);
|
|
292
319
|
}
|
|
293
320
|
function moveCol(key, delta) {
|
|
294
|
-
|
|
321
|
+
const c = byKey[key], group = vis.filter(function(x) {
|
|
295
322
|
return isPinned(x) === isPinned(c);
|
|
296
323
|
});
|
|
297
|
-
|
|
324
|
+
const gi = group.indexOf(c), target = group[gi + delta];
|
|
298
325
|
if (!target) return false;
|
|
299
|
-
|
|
300
|
-
o.splice(
|
|
301
|
-
o.splice(
|
|
326
|
+
const o = order.slice(), from = o.indexOf(key), to = o.indexOf(target.key);
|
|
327
|
+
o.splice(from, 1);
|
|
328
|
+
o.splice(to, 0, key);
|
|
302
329
|
orderState[1](o);
|
|
303
330
|
return true;
|
|
304
331
|
}
|
|
305
332
|
function dropCol(key, targetKey, after) {
|
|
306
333
|
if (key === targetKey) return;
|
|
307
|
-
|
|
334
|
+
const a = byKey[key], b = byKey[targetKey];
|
|
308
335
|
if (isPinned(a) !== isPinned(b)) return;
|
|
309
|
-
|
|
336
|
+
const o = order.slice();
|
|
310
337
|
o.splice(o.indexOf(key), 1);
|
|
311
|
-
|
|
312
|
-
o.splice(
|
|
338
|
+
const to = o.indexOf(targetKey) + (after ? 1 : 0);
|
|
339
|
+
o.splice(to, 0, key);
|
|
313
340
|
orderState[1](o);
|
|
314
341
|
}
|
|
315
342
|
function togglePin(key) {
|
|
316
|
-
pinState[1](
|
|
317
|
-
|
|
318
|
-
|
|
343
|
+
pinState[1](
|
|
344
|
+
pinnedKeys.indexOf(key) >= 0 ? pinnedKeys.filter(function(k) {
|
|
345
|
+
return k !== key;
|
|
346
|
+
}) : pinnedKeys.concat([key])
|
|
347
|
+
);
|
|
319
348
|
}
|
|
320
349
|
function setHidden(key, hide) {
|
|
321
350
|
if (hide && shown.length <= 1) return;
|
|
322
|
-
hiddenState[1](
|
|
323
|
-
|
|
324
|
-
|
|
351
|
+
hiddenState[1](
|
|
352
|
+
hide ? hidden.concat([key]) : hidden.filter(function(k) {
|
|
353
|
+
return k !== key;
|
|
354
|
+
})
|
|
355
|
+
);
|
|
325
356
|
}
|
|
326
357
|
function resetColumns() {
|
|
327
|
-
orderState[1](
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
358
|
+
orderState[1](
|
|
359
|
+
columns.map(function(c) {
|
|
360
|
+
return c.key;
|
|
361
|
+
})
|
|
362
|
+
);
|
|
363
|
+
hiddenState[1](
|
|
364
|
+
columns.filter(function(c) {
|
|
365
|
+
return c.hidden;
|
|
366
|
+
}).map(function(c) {
|
|
367
|
+
return c.key;
|
|
368
|
+
})
|
|
369
|
+
);
|
|
370
|
+
pinState[1](
|
|
371
|
+
columns.filter(function(c) {
|
|
372
|
+
return c.pinned;
|
|
373
|
+
}).map(function(c) {
|
|
374
|
+
return c.key;
|
|
375
|
+
})
|
|
376
|
+
);
|
|
340
377
|
setWidths({});
|
|
341
378
|
}
|
|
342
379
|
function columnMenuItems(c) {
|
|
343
|
-
|
|
380
|
+
const group = vis.filter(function(x) {
|
|
344
381
|
return isPinned(x) === isPinned(c);
|
|
345
382
|
}), gi = group.indexOf(c);
|
|
346
|
-
|
|
347
|
-
if (c.sortable)
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
383
|
+
const items = [];
|
|
384
|
+
if (c.sortable)
|
|
385
|
+
items.push(
|
|
386
|
+
{
|
|
387
|
+
label: t.sortAsc,
|
|
388
|
+
icon: "arrow-up",
|
|
389
|
+
onSelect: function() {
|
|
390
|
+
setSort({ key: c.key, dir: "asc" });
|
|
391
|
+
goPage(1);
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
label: t.sortDesc,
|
|
396
|
+
icon: "arrow-down",
|
|
397
|
+
onSelect: function() {
|
|
398
|
+
setSort({ key: c.key, dir: "desc" });
|
|
399
|
+
goPage(1);
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
{ separator: true }
|
|
403
|
+
);
|
|
404
|
+
if (c.width != null)
|
|
405
|
+
items.push({
|
|
406
|
+
label: isPinned(c) ? t.unpin : t.pin,
|
|
407
|
+
icon: isPinned(c) ? "pin-off" : "pin",
|
|
408
|
+
onSelect: function() {
|
|
409
|
+
togglePin(c.key);
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
if (reorderable)
|
|
413
|
+
items.push(
|
|
414
|
+
{
|
|
415
|
+
label: t.moveLeft,
|
|
416
|
+
icon: "arrow-left",
|
|
417
|
+
disabled: gi <= 0,
|
|
418
|
+
onSelect: function() {
|
|
419
|
+
moveCol(c.key, -1);
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
label: t.moveRight,
|
|
424
|
+
icon: "arrow-right",
|
|
425
|
+
disabled: gi >= group.length - 1,
|
|
426
|
+
onSelect: function() {
|
|
427
|
+
moveCol(c.key, 1);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
);
|
|
431
|
+
items.push(
|
|
432
|
+
{ separator: true },
|
|
433
|
+
{
|
|
434
|
+
label: t.hideColumn,
|
|
435
|
+
icon: "eye-off",
|
|
436
|
+
disabled: shown.length <= 1,
|
|
437
|
+
onSelect: function() {
|
|
438
|
+
setHidden(c.key, true);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
368
441
|
);
|
|
369
|
-
items.push({ separator: true }, { label: t.hideColumn, icon: "eye-off", disabled: shown.length <= 1, onSelect: function() {
|
|
370
|
-
setHidden(c.key, true);
|
|
371
|
-
} });
|
|
372
442
|
return items;
|
|
373
443
|
}
|
|
374
444
|
function pickerItems() {
|
|
375
445
|
return order.map(function(k) {
|
|
376
|
-
|
|
377
|
-
return {
|
|
378
|
-
|
|
379
|
-
|
|
446
|
+
const c = byKey[k], on = hidden.indexOf(k) < 0;
|
|
447
|
+
return {
|
|
448
|
+
label: c.label || (c.actions ? t.actions : c.key),
|
|
449
|
+
checked: on,
|
|
450
|
+
keepOpen: true,
|
|
451
|
+
disabled: on && shown.length <= 1,
|
|
452
|
+
onSelect: function() {
|
|
453
|
+
setHidden(k, on);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
380
456
|
}).concat([{ separator: true }, { label: t.resetColumns, icon: "rotate-ccw", onSelect: resetColumns }]);
|
|
381
457
|
}
|
|
382
458
|
function openMenu(kind, key, anchor, rc) {
|
|
383
459
|
setMenu({ kind, key, anchor, rc });
|
|
384
460
|
}
|
|
385
461
|
function closeMenu(restore) {
|
|
386
|
-
|
|
462
|
+
const m = menu;
|
|
387
463
|
setMenu(null);
|
|
388
464
|
if (restore && m) {
|
|
389
465
|
if (m.kind === "col") pending.current = { r: 0, key: m.key, c: m.rc ? m.rc.c : 0 };
|
|
@@ -391,24 +467,26 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
391
467
|
}
|
|
392
468
|
}
|
|
393
469
|
function onGridKey(e) {
|
|
394
|
-
|
|
470
|
+
const target = e.target;
|
|
395
471
|
if (!gridRef.current || !gridRef.current.contains(target)) return;
|
|
396
|
-
|
|
472
|
+
const rc = target.getAttribute && target.getAttribute("data-rc");
|
|
397
473
|
if (!rc) {
|
|
398
|
-
|
|
474
|
+
const cell = e.key === "Escape" && target.closest && target.closest("[data-rc]");
|
|
399
475
|
if (cell) {
|
|
400
476
|
e.preventDefault();
|
|
401
477
|
cell.focus();
|
|
402
478
|
}
|
|
403
479
|
return;
|
|
404
480
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (r === 0 && col && e.altKey && (k === "ArrowLeft" || k === "ArrowRight") && canResize(col))
|
|
481
|
+
const p = rc.split(":"), r = +p[0], c = +p[1], k = e.key, col = colAt(c);
|
|
482
|
+
const row = r > 0 ? pageRows[r - 1] : null;
|
|
483
|
+
let handled = true;
|
|
484
|
+
if (r === 0 && col && e.altKey && (k === "ArrowLeft" || k === "ArrowRight") && canResize(col))
|
|
485
|
+
setW(col, widthOf(col) + (k === "ArrowLeft" ? -1 : 1) * (e.shiftKey ? 48 : 16), true);
|
|
409
486
|
else if (r === 0 && col && e.ctrlKey && e.shiftKey && (k === "ArrowLeft" || k === "ArrowRight") && reorderable) {
|
|
410
487
|
if (moveCol(col.key, k === "ArrowLeft" ? -1 : 1)) pending.current = { r: 0, key: col.key, c };
|
|
411
|
-
} else if (r === 0 && col && (e.altKey && k === "ArrowDown" || k === "ContextMenu" || e.shiftKey && k === "F10") && controls)
|
|
488
|
+
} else if (r === 0 && col && (e.altKey && k === "ArrowDown" || k === "ContextMenu" || e.shiftKey && k === "F10") && controls)
|
|
489
|
+
openMenu("col", col.key, target, { r: 0, c });
|
|
412
490
|
else if (k === "ArrowRight") focusCell(r, c + 1);
|
|
413
491
|
else if (k === "ArrowLeft") focusCell(r, c - 1);
|
|
414
492
|
else if (k === "ArrowDown") {
|
|
@@ -428,7 +506,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
428
506
|
if (goPage(page - 1, { r: 1, c })) activeState[1]({ r: 1, c });
|
|
429
507
|
} else focusCell(Math.max(1, r - visibleRows), c);
|
|
430
508
|
} else if (k === "F2" && r > 0) {
|
|
431
|
-
|
|
509
|
+
const inner = target.querySelector("button, a[href], input, select, textarea");
|
|
432
510
|
if (inner) inner.focus();
|
|
433
511
|
else handled = false;
|
|
434
512
|
} else if (k === " " || k === "Enter") {
|
|
@@ -437,7 +515,8 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
437
515
|
setSort(nextSort(col.key));
|
|
438
516
|
goPage(1);
|
|
439
517
|
} else if (r > 0 && k === " " && selectable) toggle(row[rowKey], !selSet[row[rowKey]]);
|
|
440
|
-
else if (r > 0 && k === "Enter" && target.querySelector("button, a[href], input, select, textarea"))
|
|
518
|
+
else if (r > 0 && k === "Enter" && target.querySelector("button, a[href], input, select, textarea"))
|
|
519
|
+
target.querySelector("button, a[href], input, select, textarea").focus();
|
|
441
520
|
else if (r > 0 && k === "Enter" && props.onRowActivate) props.onRowActivate(row);
|
|
442
521
|
else handled = false;
|
|
443
522
|
} else handled = false;
|
|
@@ -446,83 +525,91 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
446
525
|
e.stopPropagation();
|
|
447
526
|
}
|
|
448
527
|
}
|
|
449
|
-
|
|
450
|
-
if (selectable)
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
label: all ? t.deselectAllRows : t.selectAllRows,
|
|
466
|
-
onChange: toggleAll
|
|
467
|
-
}) : null));
|
|
468
|
-
vis.forEach(function(c, i2) {
|
|
469
|
-
var ci = i2 + (selectable ? 1 : 0);
|
|
470
|
-
var isSorted = sort && sort.key === c.key;
|
|
471
|
-
var canSort = c.sortable && rows.length > 1 && !loading;
|
|
472
|
-
var ariaSort = isSorted && canSort ? sort.dir === "desc" ? "descending" : "ascending" : canSort ? "none" : void 0;
|
|
473
|
-
var pin = isPinned(c), edge = pin && i2 === nPinned - 1;
|
|
474
|
-
head.push(h(
|
|
475
|
-
"span",
|
|
476
|
-
{
|
|
477
|
-
key: c.key,
|
|
478
|
-
role: "columnheader",
|
|
479
|
-
"aria-sort": ariaSort,
|
|
480
|
-
"aria-colindex": ci + 1,
|
|
481
|
-
style: cellStyle(c, i2),
|
|
482
|
-
tabIndex: tabFor(0, ci),
|
|
483
|
-
"data-rc": "0:" + ci,
|
|
484
|
-
className: cx(
|
|
485
|
-
"aura-table__th",
|
|
486
|
-
pin && "is-pinned",
|
|
487
|
-
edge && "is-pin-edge",
|
|
488
|
-
drag && drag.over === c.key && (drag.after ? "is-drop-after" : "is-drop-before"),
|
|
489
|
-
drag && drag.key === c.key && "is-dragging"
|
|
490
|
-
),
|
|
491
|
-
draggable: reorderable && !loading ? true : void 0,
|
|
492
|
-
onFocus: function(e) {
|
|
493
|
-
if (e.target === e.currentTarget) activeState[1]({ r: 0, c: ci });
|
|
528
|
+
const head = [/* @__PURE__ */ React.createElement("span", { key: "__gl", className: "aura-table__gutter", "aria-hidden": true })];
|
|
529
|
+
if (selectable)
|
|
530
|
+
head.push(
|
|
531
|
+
/* @__PURE__ */ React.createElement(
|
|
532
|
+
"span",
|
|
533
|
+
{
|
|
534
|
+
key: "__sel",
|
|
535
|
+
role: "columnheader",
|
|
536
|
+
"aria-colindex": 1,
|
|
537
|
+
className: cx("aura-table__sel", nPinned && "is-pinned"),
|
|
538
|
+
tabIndex: tabFor(0, 0),
|
|
539
|
+
"data-rc": "0:0",
|
|
540
|
+
"aria-label": t.selectRows,
|
|
541
|
+
onFocus: function() {
|
|
542
|
+
activeState[1]({ r: 0, c: 0 });
|
|
543
|
+
}
|
|
494
544
|
},
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
545
|
+
nRows ? /* @__PURE__ */ React.createElement(
|
|
546
|
+
Checkbox,
|
|
547
|
+
{
|
|
548
|
+
checked: all,
|
|
549
|
+
indeterminate: nSel > 0 && !all,
|
|
550
|
+
tabIndex: -1,
|
|
551
|
+
label: all ? t.deselectAllRows : t.selectAllRows,
|
|
552
|
+
onChange: toggleAll
|
|
499
553
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
554
|
+
) : null
|
|
555
|
+
)
|
|
556
|
+
);
|
|
557
|
+
vis.forEach(function(c, i) {
|
|
558
|
+
const ci = i + (selectable ? 1 : 0);
|
|
559
|
+
const isSorted = sort && sort.key === c.key;
|
|
560
|
+
const canSort = c.sortable && rows.length > 1 && !loading;
|
|
561
|
+
const ariaSort = isSorted && canSort ? sort.dir === "desc" ? "descending" : "ascending" : canSort ? "none" : void 0;
|
|
562
|
+
const pin = isPinned(c), edge = pin && i === nPinned - 1;
|
|
563
|
+
head.push(
|
|
564
|
+
/* @__PURE__ */ React.createElement(
|
|
565
|
+
"span",
|
|
566
|
+
{
|
|
567
|
+
key: c.key,
|
|
568
|
+
role: "columnheader",
|
|
569
|
+
"aria-sort": ariaSort,
|
|
570
|
+
"aria-colindex": ci + 1,
|
|
571
|
+
style: cellStyle(c, i),
|
|
572
|
+
tabIndex: tabFor(0, ci),
|
|
573
|
+
"data-rc": "0:" + ci,
|
|
574
|
+
className: cx(
|
|
575
|
+
"aura-table__th",
|
|
576
|
+
pin && "is-pinned",
|
|
577
|
+
edge && "is-pin-edge",
|
|
578
|
+
drag && drag.over === c.key && (drag.after ? "is-drop-after" : "is-drop-before"),
|
|
579
|
+
drag && drag.key === c.key && "is-dragging"
|
|
580
|
+
),
|
|
581
|
+
draggable: reorderable && !loading ? true : void 0,
|
|
582
|
+
onFocus: function(e) {
|
|
583
|
+
if (e.target === e.currentTarget) activeState[1]({ r: 0, c: ci });
|
|
584
|
+
},
|
|
585
|
+
onDragStart: function(e) {
|
|
586
|
+
if (resizing.current) {
|
|
587
|
+
e.preventDefault();
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
e.dataTransfer.effectAllowed = "move";
|
|
591
|
+
try {
|
|
592
|
+
e.dataTransfer.setData("text/plain", c.key);
|
|
593
|
+
} catch (x) {
|
|
594
|
+
}
|
|
595
|
+
setDrag({ key: c.key });
|
|
596
|
+
},
|
|
597
|
+
onDragOver: function(e) {
|
|
598
|
+
if (!drag || drag.key === c.key || isPinned(byKey[drag.key]) !== pin) return;
|
|
599
|
+
e.preventDefault();
|
|
600
|
+
const b = e.currentTarget.getBoundingClientRect(), after = e.clientX > b.left + b.width / 2;
|
|
601
|
+
if (drag.over !== c.key || drag.after !== after) setDrag({ key: drag.key, over: c.key, after });
|
|
602
|
+
},
|
|
603
|
+
onDrop: function(e) {
|
|
604
|
+
e.preventDefault();
|
|
605
|
+
if (drag && drag.over) dropCol(drag.key, drag.over, drag.after);
|
|
606
|
+
setDrag(null);
|
|
607
|
+
},
|
|
608
|
+
onDragEnd: function() {
|
|
609
|
+
setDrag(null);
|
|
504
610
|
}
|
|
505
|
-
setDrag({ key: c.key });
|
|
506
611
|
},
|
|
507
|
-
|
|
508
|
-
if (!drag || drag.key === c.key || isPinned(byKey[drag.key]) !== pin) return;
|
|
509
|
-
e.preventDefault();
|
|
510
|
-
var b = e.currentTarget.getBoundingClientRect(), after = e.clientX > b.left + b.width / 2;
|
|
511
|
-
if (drag.over !== c.key || drag.after !== after) setDrag({ key: drag.key, over: c.key, after });
|
|
512
|
-
},
|
|
513
|
-
onDrop: function(e) {
|
|
514
|
-
e.preventDefault();
|
|
515
|
-
if (drag && drag.over) dropCol(drag.key, drag.over, drag.after);
|
|
516
|
-
setDrag(null);
|
|
517
|
-
},
|
|
518
|
-
onDragEnd: function() {
|
|
519
|
-
setDrag(null);
|
|
520
|
-
}
|
|
521
|
-
},
|
|
522
|
-
h(
|
|
523
|
-
"span",
|
|
524
|
-
{ className: "aura-table__th-inner" },
|
|
525
|
-
canSort ? h(
|
|
612
|
+
/* @__PURE__ */ React.createElement("span", { className: "aura-table__th-inner" }, canSort ? /* @__PURE__ */ React.createElement(
|
|
526
613
|
"button",
|
|
527
614
|
{
|
|
528
615
|
type: "button",
|
|
@@ -535,10 +622,8 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
535
622
|
}
|
|
536
623
|
},
|
|
537
624
|
c.label,
|
|
538
|
-
|
|
539
|
-
) :
|
|
540
|
-
pin ? h(Icon, { name: "pin", size: 12, className: "aura-table__pin-icon", label: t.pinned }) : null,
|
|
541
|
-
controls ? h(
|
|
625
|
+
/* @__PURE__ */ React.createElement(Icon, { name: isSorted ? sort.dir === "desc" ? "arrow-down" : "arrow-up" : "arrow-up-down", size: 12 })
|
|
626
|
+
) : /* @__PURE__ */ React.createElement("span", { className: cx("aura-table__th-label", !c.label && "aura-sr-only") }, c.label || (c.actions ? t.actions : c.key)), pin ? /* @__PURE__ */ React.createElement(Icon, { name: "pin", size: 12, className: "aura-table__pin-icon", label: t.pinned }) : null, controls ? /* @__PURE__ */ React.createElement(
|
|
542
627
|
"button",
|
|
543
628
|
{
|
|
544
629
|
type: "button",
|
|
@@ -552,190 +637,232 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
552
637
|
openMenu("col", c.key, e.currentTarget, { r: 0, c: ci });
|
|
553
638
|
}
|
|
554
639
|
},
|
|
555
|
-
|
|
640
|
+
/* @__PURE__ */ React.createElement(Icon, { name: "ellipsis" })
|
|
641
|
+
) : null),
|
|
642
|
+
canResize(c) ? /* @__PURE__ */ React.createElement(
|
|
643
|
+
"span",
|
|
644
|
+
{
|
|
645
|
+
className: "aura-table__resize",
|
|
646
|
+
role: "separator",
|
|
647
|
+
"aria-orientation": "vertical",
|
|
648
|
+
"aria-hidden": true,
|
|
649
|
+
onPointerDown: function(e) {
|
|
650
|
+
startResize(c, e);
|
|
651
|
+
},
|
|
652
|
+
onClick: function(e) {
|
|
653
|
+
e.stopPropagation();
|
|
654
|
+
},
|
|
655
|
+
onDoubleClick: function() {
|
|
656
|
+
setW(c, c.width, true);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
556
659
|
) : null
|
|
557
|
-
)
|
|
558
|
-
|
|
559
|
-
className: "aura-table__resize",
|
|
560
|
-
role: "separator",
|
|
561
|
-
"aria-orientation": "vertical",
|
|
562
|
-
"aria-hidden": true,
|
|
563
|
-
onPointerDown: function(e) {
|
|
564
|
-
startResize(c, e);
|
|
565
|
-
},
|
|
566
|
-
onClick: function(e) {
|
|
567
|
-
e.stopPropagation();
|
|
568
|
-
},
|
|
569
|
-
onDoubleClick: function() {
|
|
570
|
-
setW(c, c.width, true);
|
|
571
|
-
}
|
|
572
|
-
}) : null
|
|
573
|
-
));
|
|
660
|
+
)
|
|
661
|
+
);
|
|
574
662
|
});
|
|
575
|
-
head.push(
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
"aria-colindex": 1,
|
|
583
|
-
className: cx("aura-table__sel", nPinned && "is-pinned"),
|
|
584
|
-
tabIndex: tabFor(ri2, 0),
|
|
585
|
-
"data-rc": ri2 + ":0",
|
|
586
|
-
"aria-label": t.selectRow(k),
|
|
587
|
-
onFocus: function(e) {
|
|
588
|
-
if (e.target === e.currentTarget) activeState[1]({ r: ri2, c: 0 });
|
|
663
|
+
head.push(
|
|
664
|
+
/* @__PURE__ */ React.createElement(
|
|
665
|
+
"span",
|
|
666
|
+
{
|
|
667
|
+
key: "__gr",
|
|
668
|
+
className: cx("aura-table__gutter aura-table__gutter--end", controls && "has-picker"),
|
|
669
|
+
"aria-hidden": true
|
|
589
670
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
671
|
+
)
|
|
672
|
+
);
|
|
673
|
+
function rowCells(r, i, k, isSel) {
|
|
674
|
+
const ri = i + 1;
|
|
675
|
+
const cells = [/* @__PURE__ */ React.createElement("span", { key: "__gl", className: "aura-table__gutter", "aria-hidden": true })];
|
|
676
|
+
if (selectable)
|
|
677
|
+
cells.push(
|
|
678
|
+
/* @__PURE__ */ React.createElement(
|
|
679
|
+
"span",
|
|
680
|
+
{
|
|
681
|
+
key: "__sel",
|
|
682
|
+
role: "gridcell",
|
|
683
|
+
"aria-colindex": 1,
|
|
684
|
+
className: cx("aura-table__sel", nPinned && "is-pinned"),
|
|
685
|
+
tabIndex: tabFor(ri, 0),
|
|
686
|
+
"data-rc": ri + ":0",
|
|
687
|
+
"aria-label": t.selectRow(k),
|
|
688
|
+
onFocus: function(e) {
|
|
689
|
+
if (e.target === e.currentTarget) activeState[1]({ r: ri, c: 0 });
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
/* @__PURE__ */ React.createElement(
|
|
693
|
+
Checkbox,
|
|
694
|
+
{
|
|
695
|
+
checked: isSel,
|
|
696
|
+
tabIndex: -1,
|
|
697
|
+
label: t.selectRow(k),
|
|
698
|
+
onChange: function(on) {
|
|
699
|
+
toggle(k, on);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
)
|
|
703
|
+
)
|
|
704
|
+
);
|
|
593
705
|
vis.forEach(function(c, j) {
|
|
594
|
-
|
|
595
|
-
cells.push(
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
706
|
+
const ci = j + (selectable ? 1 : 0), v = r[c.key], pin = isPinned(c);
|
|
707
|
+
cells.push(
|
|
708
|
+
/* @__PURE__ */ React.createElement(
|
|
709
|
+
"span",
|
|
710
|
+
{
|
|
711
|
+
key: c.key,
|
|
712
|
+
role: "gridcell",
|
|
713
|
+
"aria-colindex": ci + 1,
|
|
714
|
+
tabIndex: tabFor(ri, ci),
|
|
715
|
+
"data-rc": ri + ":" + ci,
|
|
716
|
+
className: cx(
|
|
717
|
+
"aura-table__td",
|
|
718
|
+
c.mono && "aura-table__mono",
|
|
719
|
+
pin && "is-pinned",
|
|
720
|
+
pin && j === nPinned - 1 && "is-pin-edge"
|
|
721
|
+
),
|
|
722
|
+
style: cellStyle(c, j),
|
|
723
|
+
onFocus: function() {
|
|
724
|
+
if (activeState[0].r !== ri || activeState[0].c !== ci) activeState[1]({ r: ri, c: ci });
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
c.render ? c.render(r) : c.pill ? /* @__PURE__ */ React.createElement(StatusPill, { ...{ tone: c.tones && c.tones[v] } }, v) : v
|
|
728
|
+
)
|
|
729
|
+
);
|
|
607
730
|
});
|
|
608
|
-
cells.push(
|
|
731
|
+
cells.push(
|
|
732
|
+
/* @__PURE__ */ React.createElement(
|
|
733
|
+
"span",
|
|
734
|
+
{
|
|
735
|
+
key: "__gr",
|
|
736
|
+
className: cx("aura-table__gutter aura-table__gutter--end", controls && "has-picker"),
|
|
737
|
+
"aria-hidden": true
|
|
738
|
+
}
|
|
739
|
+
)
|
|
740
|
+
);
|
|
609
741
|
return cells;
|
|
610
742
|
}
|
|
611
|
-
|
|
612
|
-
|
|
743
|
+
let body;
|
|
744
|
+
const rowStyle = { minWidth: rowMinWidth };
|
|
613
745
|
if (loading) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
for (
|
|
617
|
-
|
|
618
|
-
if (selectable)
|
|
746
|
+
const n = pageSize || props.skeletonRows || 5;
|
|
747
|
+
const skRows = body = [];
|
|
748
|
+
for (let i = 0; i < n; i++) {
|
|
749
|
+
const sk = [/* @__PURE__ */ React.createElement("span", { key: "__gl", className: "aura-table__gutter" })];
|
|
750
|
+
if (selectable)
|
|
751
|
+
sk.push(
|
|
752
|
+
/* @__PURE__ */ React.createElement("span", { key: "__sel", className: cx("aura-table__sel", nPinned && "is-pinned") }, /* @__PURE__ */ React.createElement("span", { className: "aura-skel aura-skel--box" }))
|
|
753
|
+
);
|
|
619
754
|
vis.forEach(function(c, j) {
|
|
620
|
-
sk.push(
|
|
621
|
-
"span",
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
755
|
+
sk.push(
|
|
756
|
+
/* @__PURE__ */ React.createElement("span", { key: c.key, className: cx("aura-table__td", isPinned(c) && "is-pinned"), style: cellStyle(c, j) }, /* @__PURE__ */ React.createElement(
|
|
757
|
+
"span",
|
|
758
|
+
{
|
|
759
|
+
className: cx("aura-skel", c.pill && "aura-skel--pill"),
|
|
760
|
+
style: c.pill ? void 0 : { width: SKELETON_WIDTHS[(i + j) % SKELETON_WIDTHS.length] }
|
|
761
|
+
}
|
|
762
|
+
))
|
|
763
|
+
);
|
|
625
764
|
});
|
|
626
|
-
sk.push(
|
|
627
|
-
|
|
765
|
+
sk.push(
|
|
766
|
+
/* @__PURE__ */ React.createElement("span", { key: "__gr", className: cx("aura-table__gutter aura-table__gutter--end", controls && "has-picker") })
|
|
767
|
+
);
|
|
768
|
+
skRows.push(
|
|
769
|
+
/* @__PURE__ */ React.createElement("div", { key: "sk" + i, className: "aura-table__row aura-table__row--skeleton", "aria-hidden": true, style: rowStyle }, sk)
|
|
770
|
+
);
|
|
628
771
|
}
|
|
629
772
|
} else if (!rows.length) {
|
|
630
|
-
|
|
631
|
-
body =
|
|
632
|
-
"div",
|
|
633
|
-
{ className: "aura-table__empty", role: "row" },
|
|
634
|
-
h(
|
|
635
|
-
"div",
|
|
636
|
-
{ role: "gridcell" },
|
|
637
|
-
h("span", { className: "aura-table__empty-icon" }, h(Icon, { name: em.icon || "inbox", size: "lg" })),
|
|
638
|
-
h("p", { className: "aura-table__empty-title" }, em.title || t.empty),
|
|
639
|
-
em.description ? h("p", { className: "aura-table__empty-text" }, em.description) : null,
|
|
640
|
-
em.action ? h("div", { className: "aura-table__empty-action" }, em.action) : null
|
|
641
|
-
)
|
|
642
|
-
);
|
|
773
|
+
const em = props.empty || {};
|
|
774
|
+
body = /* @__PURE__ */ React.createElement("div", { className: "aura-table__empty", role: "row" }, /* @__PURE__ */ React.createElement("div", { role: "gridcell" }, /* @__PURE__ */ React.createElement("span", { className: "aura-table__empty-icon" }, /* @__PURE__ */ React.createElement(Icon, { name: em.icon || "inbox", size: "lg" })), /* @__PURE__ */ React.createElement("p", { className: "aura-table__empty-title" }, em.title || t.empty), em.description ? /* @__PURE__ */ React.createElement("p", { className: "aura-table__empty-text" }, em.description) : null, em.action ? /* @__PURE__ */ React.createElement("div", { className: "aura-table__empty-action" }, em.action) : null));
|
|
643
775
|
} else {
|
|
644
|
-
|
|
645
|
-
if (virtual && start > 0)
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
776
|
+
const bodyRows = body = [];
|
|
777
|
+
if (virtual && start > 0)
|
|
778
|
+
bodyRows.push(/* @__PURE__ */ React.createElement("div", { key: "__top", style: { height: start * ROW_H + "px" }, "aria-hidden": true }));
|
|
779
|
+
for (let ri = start; ri < end; ri++) {
|
|
780
|
+
(function(r, i) {
|
|
781
|
+
const k = r[rowKey], isSel = !!selSet[k];
|
|
782
|
+
bodyRows.push(
|
|
783
|
+
/* @__PURE__ */ React.createElement(
|
|
784
|
+
"div",
|
|
785
|
+
{
|
|
786
|
+
key: k,
|
|
787
|
+
role: "row",
|
|
788
|
+
"aria-rowindex": first + i + 2,
|
|
789
|
+
"aria-selected": selectable ? isSel : void 0,
|
|
790
|
+
className: cx("aura-table__row", isSel && "is-selected", props.onRowActivate && "is-actionable"),
|
|
791
|
+
style: rowStyle,
|
|
792
|
+
onClick: function(e) {
|
|
793
|
+
const el = e.target;
|
|
794
|
+
if (el.closest && el.closest(".aura-check, button, a, input")) return;
|
|
795
|
+
if (props.onRowActivate) props.onRowActivate(r);
|
|
796
|
+
}
|
|
797
|
+
},
|
|
798
|
+
rowCells(r, i, k, isSel)
|
|
799
|
+
)
|
|
800
|
+
);
|
|
662
801
|
})(pageRows[ri], ri);
|
|
663
802
|
}
|
|
664
|
-
if (virtual && end < pageRows.length)
|
|
803
|
+
if (virtual && end < pageRows.length)
|
|
804
|
+
bodyRows.push(/* @__PURE__ */ React.createElement("div", { key: "__bot", style: { height: (pageRows.length - end) * ROW_H + "px" }, "aria-hidden": true }));
|
|
665
805
|
}
|
|
666
|
-
|
|
806
|
+
let foot = null;
|
|
667
807
|
if (pageSize && (rows.length || loading)) {
|
|
668
|
-
|
|
669
|
-
foot =
|
|
670
|
-
|
|
671
|
-
{
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
h("span", null, t.page(page, pageCount)),
|
|
677
|
-
h(IconButton, { icon: "chevron-left", label: t.prevPage, disabled: loading || page <= 1, onClick: function() {
|
|
808
|
+
const from = rows.length ? first + 1 : 0, to = Math.min(first + pageSize, view.length);
|
|
809
|
+
foot = /* @__PURE__ */ React.createElement("div", { className: "aura-table__foot" }, /* @__PURE__ */ React.createElement("span", { "aria-live": "polite" }, loading ? t.loading : t.range(from, to, view.length)), /* @__PURE__ */ React.createElement("span", { className: "aura-table__pager" }, /* @__PURE__ */ React.createElement("span", null, t.page(page, pageCount)), /* @__PURE__ */ React.createElement(
|
|
810
|
+
IconButton,
|
|
811
|
+
{
|
|
812
|
+
icon: "chevron-left",
|
|
813
|
+
label: t.prevPage,
|
|
814
|
+
disabled: loading || page <= 1,
|
|
815
|
+
onClick: function() {
|
|
678
816
|
goPage(page - 1);
|
|
679
|
-
}
|
|
680
|
-
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
), /* @__PURE__ */ React.createElement(
|
|
820
|
+
IconButton,
|
|
821
|
+
{
|
|
822
|
+
icon: "chevron-right",
|
|
823
|
+
label: t.nextPage,
|
|
824
|
+
disabled: loading || page >= pageCount,
|
|
825
|
+
onClick: function() {
|
|
681
826
|
goPage(page + 1);
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
)));
|
|
685
830
|
} else if (height && rows.length && !loading) {
|
|
686
|
-
foot =
|
|
687
|
-
"div",
|
|
688
|
-
{ className: "aura-table__foot" },
|
|
689
|
-
h("span", null, t.rowCount(view.length)),
|
|
690
|
-
selectable && selected.length ? h("span", null, t.selectedCount(selected.length)) : h("span", null)
|
|
691
|
-
);
|
|
831
|
+
foot = /* @__PURE__ */ React.createElement("div", { className: "aura-table__foot" }, /* @__PURE__ */ React.createElement("span", null, t.rowCount(view.length)), selectable && selected.length ? /* @__PURE__ */ React.createElement("span", null, t.selectedCount(selected.length)) : /* @__PURE__ */ React.createElement("span", null));
|
|
692
832
|
}
|
|
693
833
|
if (stacked) {
|
|
694
|
-
|
|
834
|
+
const titleCol = vis[0], pillCol = vis.filter(function(c) {
|
|
695
835
|
return c.pill && c !== titleCol;
|
|
696
836
|
})[0];
|
|
697
|
-
|
|
837
|
+
const actionCols = vis.filter(function(c) {
|
|
698
838
|
return c.actions && c !== titleCol;
|
|
699
839
|
});
|
|
700
|
-
|
|
840
|
+
const rest = vis.filter(function(c) {
|
|
701
841
|
return c !== titleCol && c !== pillCol && !c.actions;
|
|
702
842
|
});
|
|
703
|
-
|
|
843
|
+
let cardBody;
|
|
704
844
|
if (loading) {
|
|
705
|
-
cardBody =
|
|
706
|
-
return
|
|
707
|
-
"li",
|
|
708
|
-
{ key: i2, className: "aura-table__card", "aria-hidden": true },
|
|
709
|
-
h("span", { className: "aura-skel", style: { width: "50%", height: "14px" } }),
|
|
710
|
-
h("span", { className: "aura-skel", style: { width: "80%" } }),
|
|
711
|
-
h("span", { className: "aura-skel", style: { width: "64%" } })
|
|
712
|
-
);
|
|
845
|
+
cardBody = /* @__PURE__ */ React.createElement("ul", { className: "aura-table__cards", "aria-busy": true }, [0, 1, 2].map(function(i) {
|
|
846
|
+
return /* @__PURE__ */ React.createElement("li", { key: i, className: "aura-table__card", "aria-hidden": true }, /* @__PURE__ */ React.createElement("span", { className: "aura-skel", style: { width: "50%", height: "14px" } }), /* @__PURE__ */ React.createElement("span", { className: "aura-skel", style: { width: "80%" } }), /* @__PURE__ */ React.createElement("span", { className: "aura-skel", style: { width: "64%" } }));
|
|
713
847
|
}));
|
|
714
848
|
} else if (!rows.length) {
|
|
715
|
-
|
|
716
|
-
cardBody =
|
|
717
|
-
"div",
|
|
718
|
-
null,
|
|
719
|
-
h("span", { className: "aura-table__empty-icon" }, h(Icon, { name: em2.icon || "inbox", size: "lg" })),
|
|
720
|
-
h("p", { className: "aura-table__empty-title" }, em2.title || t.empty),
|
|
721
|
-
em2.description ? h("p", { className: "aura-table__empty-text" }, em2.description) : null,
|
|
722
|
-
em2.action ? h("div", { className: "aura-table__empty-action" }, em2.action) : null
|
|
723
|
-
));
|
|
849
|
+
const em2 = props.empty || {};
|
|
850
|
+
cardBody = /* @__PURE__ */ React.createElement("div", { className: "aura-table__empty" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("span", { className: "aura-table__empty-icon" }, /* @__PURE__ */ React.createElement(Icon, { name: em2.icon || "inbox", size: "lg" })), /* @__PURE__ */ React.createElement("p", { className: "aura-table__empty-title" }, em2.title || t.empty), em2.description ? /* @__PURE__ */ React.createElement("p", { className: "aura-table__empty-text" }, em2.description) : null, em2.action ? /* @__PURE__ */ React.createElement("div", { className: "aura-table__empty-action" }, em2.action) : null));
|
|
724
851
|
} else {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
return c.render ? c.render(r) : c.pill ?
|
|
852
|
+
const cellVal = function(c, r) {
|
|
853
|
+
const v = r[c.key];
|
|
854
|
+
return c.render ? c.render(r) : c.pill ? /* @__PURE__ */ React.createElement(StatusPill, { ...{ tone: c.tones && c.tones[v] } }, v) : v;
|
|
728
855
|
};
|
|
729
|
-
cardBody =
|
|
730
|
-
|
|
731
|
-
return
|
|
856
|
+
cardBody = /* @__PURE__ */ React.createElement("ul", { className: "aura-table__cards", "aria-label": props.label }, pageRows.map(function(r) {
|
|
857
|
+
const k = r[rowKey], isSel = !!selSet[k];
|
|
858
|
+
return /* @__PURE__ */ React.createElement(
|
|
732
859
|
"li",
|
|
733
860
|
{
|
|
734
861
|
key: k,
|
|
735
862
|
className: cx("aura-table__card", isSel && "is-selected", props.onRowActivate && "is-actionable"),
|
|
736
863
|
tabIndex: props.onRowActivate ? 0 : void 0,
|
|
737
864
|
onClick: function(e) {
|
|
738
|
-
|
|
865
|
+
const el = e.target;
|
|
739
866
|
if (el.closest && el.closest(".aura-check, button, a, input")) return;
|
|
740
867
|
if (props.onRowActivate) props.onRowActivate(r);
|
|
741
868
|
},
|
|
@@ -743,90 +870,97 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
743
870
|
if (e.target === e.currentTarget && e.key === "Enter" && props.onRowActivate) props.onRowActivate(r);
|
|
744
871
|
}
|
|
745
872
|
},
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
{
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
})
|
|
757
|
-
),
|
|
758
|
-
rest.length ?
|
|
759
|
-
return
|
|
873
|
+
/* @__PURE__ */ React.createElement("div", { className: "aura-table__card-head" }, selectable ? /* @__PURE__ */ React.createElement(
|
|
874
|
+
Checkbox,
|
|
875
|
+
{
|
|
876
|
+
checked: isSel,
|
|
877
|
+
label: t.selectRow(k),
|
|
878
|
+
onChange: function(on) {
|
|
879
|
+
toggle(k, on);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
) : null, /* @__PURE__ */ React.createElement("span", { className: cx("aura-table__card-title", titleCol.mono && "aura-table__mono") }, cellVal(titleCol, r)), pillCol ? cellVal(pillCol, r) : null, actionCols.map(function(c) {
|
|
883
|
+
return /* @__PURE__ */ React.createElement("span", { key: c.key, className: "aura-table__card-actions" }, cellVal(c, r));
|
|
884
|
+
})),
|
|
885
|
+
rest.length ? /* @__PURE__ */ React.createElement("dl", { className: "aura-table__card-fields" }, rest.map(function(c) {
|
|
886
|
+
return /* @__PURE__ */ React.createElement("div", { key: c.key }, /* @__PURE__ */ React.createElement("dt", null, c.label), /* @__PURE__ */ React.createElement("dd", { className: c.mono ? "aura-table__mono" : void 0 }, cellVal(c, r)));
|
|
760
887
|
})) : null
|
|
761
888
|
);
|
|
762
889
|
}));
|
|
763
890
|
}
|
|
764
|
-
return
|
|
891
|
+
return /* @__PURE__ */ React.createElement(
|
|
765
892
|
"div",
|
|
766
|
-
{
|
|
767
|
-
|
|
768
|
-
"
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
893
|
+
{
|
|
894
|
+
ref: wrapMerged,
|
|
895
|
+
className: cx("aura-table aura-table--stacked", props.className),
|
|
896
|
+
role: "region",
|
|
897
|
+
"aria-label": props.label,
|
|
898
|
+
"aria-busy": loading || void 0
|
|
899
|
+
},
|
|
900
|
+
selectable && pageRows.length && !loading ? /* @__PURE__ */ React.createElement("div", { className: "aura-table__stack-bar" }, /* @__PURE__ */ React.createElement(
|
|
901
|
+
Checkbox,
|
|
902
|
+
{
|
|
903
|
+
checked: all,
|
|
904
|
+
indeterminate: nSel > 0 && !all,
|
|
905
|
+
label: all ? t.deselectAllRows : t.selectAllRows,
|
|
906
|
+
onChange: toggleAll
|
|
907
|
+
}
|
|
908
|
+
), /* @__PURE__ */ React.createElement("span", null, nSel ? t.selectedCount(nSel) : t.selectAll)) : null,
|
|
773
909
|
cardBody,
|
|
774
910
|
foot
|
|
775
911
|
);
|
|
776
912
|
}
|
|
777
|
-
|
|
913
|
+
const scrollStyle = {
|
|
914
|
+
scrollPaddingLeft: "calc(var(--aura-space-6)" + selW + " + " + acc + "px)",
|
|
915
|
+
scrollPaddingTop: ROW_H + "px"
|
|
916
|
+
};
|
|
778
917
|
if (height) scrollStyle.height = height + "px";
|
|
779
|
-
return
|
|
918
|
+
return /* @__PURE__ */ React.createElement("div", { ref: wrapMerged, className: cx("aura-table", scrolledX[0] && "is-scrolled-x", props.className) }, /* @__PURE__ */ React.createElement(
|
|
780
919
|
"div",
|
|
781
|
-
{
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
ref: function(el) {
|
|
786
|
-
scrollRef.current = el;
|
|
787
|
-
gridRef.current = el;
|
|
788
|
-
},
|
|
789
|
-
className: "aura-table__scroll",
|
|
790
|
-
style: scrollStyle,
|
|
791
|
-
role: "grid",
|
|
792
|
-
"aria-label": props.label,
|
|
793
|
-
"aria-busy": loading || void 0,
|
|
794
|
-
"aria-rowcount": loading ? -1 : view.length + 1,
|
|
795
|
-
"aria-colcount": nCols,
|
|
796
|
-
"aria-multiselectable": selectable || void 0,
|
|
797
|
-
onKeyDown: onGridKey,
|
|
798
|
-
onScroll: function(e) {
|
|
799
|
-
var t2 = e.currentTarget;
|
|
800
|
-
if (virtual && Math.abs(t2.scrollTop - scrollTop) >= ROW_H / 2) setScrollTop(t2.scrollTop);
|
|
801
|
-
else if (virtual && (t2.scrollTop === 0 || t2.scrollTop + t2.clientHeight >= t2.scrollHeight - 1)) setScrollTop(t2.scrollTop);
|
|
802
|
-
var sx = t2.scrollLeft > 0;
|
|
803
|
-
if (sx !== scrolledX[0]) scrolledX[1](sx);
|
|
804
|
-
}
|
|
920
|
+
{
|
|
921
|
+
ref: function(el) {
|
|
922
|
+
scrollRef.current = el;
|
|
923
|
+
gridRef.current = el;
|
|
805
924
|
},
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
"
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
925
|
+
className: "aura-table__scroll",
|
|
926
|
+
style: scrollStyle,
|
|
927
|
+
role: "grid",
|
|
928
|
+
"aria-label": props.label,
|
|
929
|
+
"aria-busy": loading || void 0,
|
|
930
|
+
"aria-rowcount": loading ? -1 : view.length + 1,
|
|
931
|
+
"aria-colcount": nCols,
|
|
932
|
+
"aria-multiselectable": selectable || void 0,
|
|
933
|
+
onKeyDown: onGridKey,
|
|
934
|
+
onScroll: function(e) {
|
|
935
|
+
const t2 = e.currentTarget;
|
|
936
|
+
if (virtual && Math.abs(t2.scrollTop - scrollTop) >= ROW_H / 2) setScrollTop(t2.scrollTop);
|
|
937
|
+
else if (virtual && (t2.scrollTop === 0 || t2.scrollTop + t2.clientHeight >= t2.scrollHeight - 1))
|
|
938
|
+
setScrollTop(t2.scrollTop);
|
|
939
|
+
const sx = t2.scrollLeft > 0;
|
|
940
|
+
if (sx !== scrolledX[0]) scrolledX[1](sx);
|
|
941
|
+
}
|
|
942
|
+
},
|
|
943
|
+
/* @__PURE__ */ React.createElement("div", { className: "aura-table__head", role: "row", "aria-rowindex": 1, style: rowStyle }, head),
|
|
944
|
+
body
|
|
945
|
+
), loading ? /* @__PURE__ */ React.createElement("span", { className: "aura-sr-only", role: "status" }, t.loadingRows) : null, controls ? /* @__PURE__ */ React.createElement("div", { className: "aura-table__picker" }, /* @__PURE__ */ React.createElement(
|
|
946
|
+
IconButton,
|
|
947
|
+
{
|
|
948
|
+
icon: "columns-3",
|
|
949
|
+
label: t.showHideColumns,
|
|
950
|
+
"aria-haspopup": "menu",
|
|
951
|
+
onClick: function(e) {
|
|
952
|
+
openMenu("picker", null, e.currentTarget);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
)) : null, foot, menu ? /* @__PURE__ */ React.createElement(
|
|
956
|
+
Menu,
|
|
957
|
+
{
|
|
824
958
|
anchor: menu.anchor,
|
|
825
959
|
onClose: closeMenu,
|
|
826
960
|
label: menu.kind === "picker" ? t.columns : t.column(byKey[menu.key] && byKey[menu.key].label),
|
|
827
961
|
items: menu.kind === "picker" ? pickerItems() : byKey[menu.key] ? columnMenuItems(byKey[menu.key]) : []
|
|
828
|
-
}
|
|
829
|
-
);
|
|
962
|
+
}
|
|
963
|
+
) : null);
|
|
830
964
|
});
|
|
831
965
|
export {
|
|
832
966
|
DataTable
|