@jirawatpyk/aura-react 5.0.1 → 5.1.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 +8 -0
- package/dist/aura.bundle.js +464 -154
- package/dist/cjs/index.cjs +464 -154
- package/dist/esm/AppShell.js +10 -2
- package/dist/esm/Avatar.js +4 -3
- package/dist/esm/BottomNav.js +2 -1
- package/dist/esm/Checkbox.js +13 -4
- package/dist/esm/Combobox.js +19 -19
- package/dist/esm/Command.js +1 -0
- package/dist/esm/DataTable.js +46 -14
- package/dist/esm/DatePicker.js +81 -18
- package/dist/esm/DropdownMenu.js +12 -0
- package/dist/esm/FileUpload.js +15 -0
- package/dist/esm/FormErrorSummary.js +19 -4
- package/dist/esm/Icon.js +1 -1
- package/dist/esm/Menu.js +20 -7
- package/dist/esm/NumberField.js +3 -1
- package/dist/esm/Pagination.js +3 -3
- package/dist/esm/Popover.js +11 -1
- package/dist/esm/RadioGroup.js +14 -1
- package/dist/esm/SideNav.js +8 -2
- package/dist/esm/StatusPill.js +1 -0
- package/dist/esm/Switch.js +1 -1
- package/dist/esm/Table.js +3 -2
- package/dist/esm/Tabs.js +11 -7
- package/dist/esm/TextField.js +2 -2
- package/dist/esm/Textarea.js +2 -2
- package/dist/esm/ThemeStyle.js +13 -3
- package/dist/esm/Toaster.js +1 -0
- package/dist/esm/Tooltip.js +54 -29
- package/dist/esm/colorScheme.js +7 -3
- package/dist/esm/colorSchemeScript.js +3 -3
- package/dist/esm/dates.js +6 -3
- package/dist/esm/internal.js +32 -7
- package/dist/esm/locale.js +6 -5
- package/dist/esm/status.js +2 -1
- package/dist/esm/theme.js +3 -1
- package/dist/esm/useModal.js +42 -9
- package/dist/index.d.cts +1508 -0
- package/dist/index.d.ts +13 -6
- package/dist/server/index.cjs +7 -4
- package/dist/server/index.d.cts +176 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +7 -4
- package/dist/styles.css +23 -3
- package/dist/styles.layer.css +23 -3
- package/package.json +19 -8
package/dist/esm/AppShell.js
CHANGED
|
@@ -17,16 +17,24 @@ const AppShell = React.forwardRef(function AppShell2(props, ref) {
|
|
|
17
17
|
[wide]
|
|
18
18
|
);
|
|
19
19
|
const navEl = props.nav && React.isValidElement(props.nav) ? props.nav : null;
|
|
20
|
+
const shared = !!navEl && navEl.props.value === void 0 && (navEl.props.defaultValue !== void 0 || navEl.props.sections !== void 0 || navEl.props.items !== void 0);
|
|
21
|
+
const navState = React.useState(navEl ? navEl.props.defaultValue : void 0);
|
|
22
|
+
function onNav(id) {
|
|
23
|
+
if (shared) navState[1](id);
|
|
24
|
+
if (navEl && navEl.props.onChange) navEl.props.onChange(id);
|
|
25
|
+
}
|
|
26
|
+
const deskNav = navEl && shared ? React.cloneElement(navEl, { value: navState[0], onChange: onNav }) : props.nav;
|
|
20
27
|
const drawerNav = navEl ? React.cloneElement(navEl, {
|
|
28
|
+
value: shared ? navState[0] : navEl.props.value,
|
|
21
29
|
onChange: function(id) {
|
|
22
|
-
|
|
30
|
+
onNav(id);
|
|
23
31
|
setOpen(false);
|
|
24
32
|
},
|
|
25
33
|
className: cx(navEl.props.className, "is-in-drawer"),
|
|
26
34
|
collapsed: false,
|
|
27
35
|
collapsible: false
|
|
28
36
|
}) : props.nav;
|
|
29
|
-
return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-shell", props.bottomNav && "aura-shell--bottomnav", props.className) }, props.nav ? /* @__PURE__ */ React.createElement("div", { className: "aura-shell__nav" },
|
|
37
|
+
return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-shell", props.bottomNav && "aura-shell--bottomnav", props.className) }, props.nav ? /* @__PURE__ */ React.createElement("div", { className: "aura-shell__nav" }, deskNav) : null, props.nav ? /* @__PURE__ */ React.createElement(
|
|
30
38
|
Drawer,
|
|
31
39
|
{
|
|
32
40
|
open,
|
package/dist/esm/Avatar.js
CHANGED
|
@@ -7,7 +7,7 @@ function initials(name) {
|
|
|
7
7
|
return ((parts[0] || "?")[0] + (parts.length > 1 ? parts[parts.length - 1][0] : parts[0][1] || "")).toUpperCase();
|
|
8
8
|
}
|
|
9
9
|
const Avatar = React.forwardRef(function Avatar2(props, ref) {
|
|
10
|
-
const size = props.size || "md", errState = React.useState(
|
|
10
|
+
const size = props.size || "md", errState = React.useState(null);
|
|
11
11
|
let hash = 0;
|
|
12
12
|
String(props.name || "").split("").forEach(function(ch) {
|
|
13
13
|
hash = hash * 31 + ch.charCodeAt(0) >>> 0;
|
|
@@ -21,13 +21,14 @@ const Avatar = React.forwardRef(function Avatar2(props, ref) {
|
|
|
21
21
|
role: "img",
|
|
22
22
|
"aria-label": props.name + (props.status ? ", " + props.status : "")
|
|
23
23
|
},
|
|
24
|
-
props.src &&
|
|
24
|
+
props.src && errState[0] !== props.src ? /* @__PURE__ */ React.createElement(
|
|
25
25
|
"img",
|
|
26
26
|
{
|
|
27
|
+
key: props.src,
|
|
27
28
|
src: props.src,
|
|
28
29
|
alt: "",
|
|
29
30
|
onError: function() {
|
|
30
|
-
errState[1](
|
|
31
|
+
errState[1](props.src || null);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
) : /* @__PURE__ */ React.createElement("span", { "aria-hidden": true }, initials(props.name)),
|
package/dist/esm/BottomNav.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Icon } from "./Icon.js";
|
|
4
|
-
import { cx, useMaybeControlled } from "./internal.js";
|
|
4
|
+
import { cx, plainClick, useMaybeControlled } from "./internal.js";
|
|
5
5
|
import { useLinkComponent, useStrings } from "./locale.js";
|
|
6
6
|
const BottomNav = React.forwardRef(function BottomNav2(props, ref) {
|
|
7
7
|
const t = useStrings();
|
|
@@ -28,6 +28,7 @@ const BottomNav = React.forwardRef(function BottomNav2(props, ref) {
|
|
|
28
28
|
"aria-current": on ? "page" : void 0,
|
|
29
29
|
onClick: function(e) {
|
|
30
30
|
if (!it.href) e.preventDefault();
|
|
31
|
+
else if (!plainClick(e)) return;
|
|
31
32
|
st[1](it.id);
|
|
32
33
|
}
|
|
33
34
|
};
|
package/dist/esm/Checkbox.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { cx, omit, useMergedRef, useMaybeControlled } from "./internal.js";
|
|
3
|
+
import { cx, devWarnOnce, omit, uid, useMergedRef, useMaybeControlled } from "./internal.js";
|
|
4
4
|
import { Icon } from "./Icon.js";
|
|
5
5
|
const Checkbox = React.forwardRef(function Checkbox2(props, ref) {
|
|
6
6
|
const own = React.useRef(null), merged = useMergedRef(ref, own);
|
|
7
7
|
const st = useMaybeControlled(props.checked, !!props.defaultChecked, props.onChange);
|
|
8
8
|
const on = !!st[0];
|
|
9
|
+
const auto = uid();
|
|
9
10
|
React.useEffect(function() {
|
|
10
11
|
if (own.current) own.current.indeterminate = !!props.indeterminate;
|
|
11
12
|
});
|
|
@@ -15,14 +16,21 @@ const Checkbox = React.forwardRef(function Checkbox2(props, ref) {
|
|
|
15
16
|
"onChange",
|
|
16
17
|
"indeterminate",
|
|
17
18
|
"label",
|
|
19
|
+
"hideLabel",
|
|
18
20
|
"children",
|
|
19
21
|
"description",
|
|
20
22
|
"className",
|
|
21
23
|
"tabIndex",
|
|
22
24
|
"disabled"
|
|
23
25
|
]);
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
+
const text = props.children;
|
|
27
|
+
const labelled = text != null && text !== "";
|
|
28
|
+
if (!labelled && props.label && !props.hideLabel)
|
|
29
|
+
devWarnOnce(
|
|
30
|
+
"checkbox-label",
|
|
31
|
+
"Checkbox `label` is only the accessible name: it is not shown. In 6.0 it will be shown beside the box, like Switch and TextField. For visible text now pass it as children; for a bare box (a table row) add `hideLabel`."
|
|
32
|
+
);
|
|
33
|
+
const descId = props.description ? (props.id || auto) + "-desc" : void 0;
|
|
26
34
|
return /* @__PURE__ */ React.createElement(
|
|
27
35
|
"label",
|
|
28
36
|
{
|
|
@@ -49,7 +57,8 @@ const Checkbox = React.forwardRef(function Checkbox2(props, ref) {
|
|
|
49
57
|
}
|
|
50
58
|
),
|
|
51
59
|
/* @__PURE__ */ React.createElement("span", { className: "aura-check__box", "aria-hidden": true }, props.indeterminate ? /* @__PURE__ */ React.createElement(Icon, { name: "minus", size: 12, strokeWidth: 3 }) : on ? /* @__PURE__ */ React.createElement(Icon, { name: "check", size: 12, strokeWidth: 3 }) : null),
|
|
52
|
-
labelled
|
|
60
|
+
!labelled && props.description ? /* @__PURE__ */ React.createElement("span", { className: "aura-sr-only", id: descId }, props.description) : null,
|
|
61
|
+
labelled ? /* @__PURE__ */ React.createElement("span", { className: "aura-check__text" }, /* @__PURE__ */ React.createElement("span", { className: "aura-check__label" }, text), props.description ? /* @__PURE__ */ React.createElement("span", { className: "aura-check__desc", id: descId }, props.description) : null) : null
|
|
53
62
|
);
|
|
54
63
|
});
|
|
55
64
|
export {
|
package/dist/esm/Combobox.js
CHANGED
|
@@ -82,7 +82,7 @@ const Combobox = React.forwardRef(
|
|
|
82
82
|
function() {
|
|
83
83
|
if (open) place();
|
|
84
84
|
},
|
|
85
|
-
[open, shown.length]
|
|
85
|
+
[open, shown.length, values.length]
|
|
86
86
|
);
|
|
87
87
|
React.useEffect(
|
|
88
88
|
function() {
|
|
@@ -114,6 +114,7 @@ const Combobox = React.forwardRef(
|
|
|
114
114
|
},
|
|
115
115
|
[activeIdx, open]
|
|
116
116
|
);
|
|
117
|
+
const live = props.loading ? [] : shown;
|
|
117
118
|
function openList() {
|
|
118
119
|
if (!open && !props.disabled && !props.readOnly) {
|
|
119
120
|
setOpen(true);
|
|
@@ -149,7 +150,7 @@ const Combobox = React.forwardRef(
|
|
|
149
150
|
if (k === "ArrowDown") {
|
|
150
151
|
e.preventDefault();
|
|
151
152
|
if (!open) openList();
|
|
152
|
-
else setActive(Math.min(activeIdx + 1,
|
|
153
|
+
else setActive(Math.max(0, Math.min(activeIdx + 1, live.length - 1)));
|
|
153
154
|
} else if (k === "ArrowUp") {
|
|
154
155
|
e.preventDefault();
|
|
155
156
|
if (!open) openList();
|
|
@@ -159,21 +160,22 @@ const Combobox = React.forwardRef(
|
|
|
159
160
|
setActive(0);
|
|
160
161
|
} else if (k === "End" && open) {
|
|
161
162
|
e.preventDefault();
|
|
162
|
-
setActive(
|
|
163
|
+
setActive(Math.max(0, live.length - 1));
|
|
163
164
|
} else if (k === "Enter") {
|
|
164
|
-
if (
|
|
165
|
+
if (e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
166
|
+
if (open && live[activeIdx]) {
|
|
165
167
|
e.preventDefault();
|
|
166
|
-
choose(
|
|
168
|
+
choose(live[activeIdx]);
|
|
167
169
|
}
|
|
168
170
|
} else if (k === "Escape") {
|
|
169
171
|
if (open) {
|
|
170
172
|
e.preventDefault();
|
|
171
173
|
e.stopPropagation();
|
|
172
174
|
close();
|
|
173
|
-
} else if (!multi && props.clearable !== false && value != null && query == null) {
|
|
175
|
+
} else if (!multi && !props.readOnly && props.clearable !== false && value != null && query == null) {
|
|
174
176
|
setValue(null);
|
|
175
177
|
}
|
|
176
|
-
} else if (k === "Backspace" && multi && !text && values.length) {
|
|
178
|
+
} else if (k === "Backspace" && multi && !props.readOnly && !text && values.length) {
|
|
177
179
|
setValues(values.slice(0, -1));
|
|
178
180
|
} else if (k === "Tab") {
|
|
179
181
|
if (open) close();
|
|
@@ -185,7 +187,7 @@ const Combobox = React.forwardRef(
|
|
|
185
187
|
return id + "-opt-" + i;
|
|
186
188
|
};
|
|
187
189
|
const list = open && mounted && posState[0] ? createPortal(
|
|
188
|
-
/* @__PURE__ */ React.createElement("div", { ref: listRef, className: "aura-combo__popover", style: posState[0] }, /* @__PURE__ */ React.createElement(
|
|
190
|
+
/* @__PURE__ */ React.createElement("div", { ref: listRef, className: "aura-combo__popover", style: posState[0] }, live.length ? /* @__PURE__ */ React.createElement(
|
|
189
191
|
"ul",
|
|
190
192
|
{
|
|
191
193
|
id: listId,
|
|
@@ -194,7 +196,7 @@ const Combobox = React.forwardRef(
|
|
|
194
196
|
"aria-multiselectable": multi || void 0,
|
|
195
197
|
className: "aura-combo__list"
|
|
196
198
|
},
|
|
197
|
-
|
|
199
|
+
live.map(function(o, i) {
|
|
198
200
|
const isSel = multi ? isPicked(o.value) : !!selected && o.value === selected.value;
|
|
199
201
|
const blocked = o.disabled || multi && full && !isSel;
|
|
200
202
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -226,9 +228,8 @@ const Combobox = React.forwardRef(
|
|
|
226
228
|
/* @__PURE__ */ React.createElement("span", { className: "aura-combo__text" }, /* @__PURE__ */ React.createElement("span", { className: "aura-combo__label" }, o.label), o.description ? /* @__PURE__ */ React.createElement("span", { className: "aura-combo__desc" }, o.description) : null),
|
|
227
229
|
isSel ? /* @__PURE__ */ React.createElement(Icon, { name: "check", className: "aura-combo__check" }) : null
|
|
228
230
|
);
|
|
229
|
-
})
|
|
230
|
-
|
|
231
|
-
)),
|
|
231
|
+
})
|
|
232
|
+
) : null, props.loading || !live.length || more ? /* @__PURE__ */ React.createElement("div", { className: "aura-combo__list", role: "status" }, props.loading ? /* @__PURE__ */ React.createElement("div", { className: "aura-combo__note" }, /* @__PURE__ */ React.createElement(Icon, { name: "loader-circle", className: "aura-spin" }), props.loadingText || t.searching) : !live.length ? /* @__PURE__ */ React.createElement("div", { className: "aura-combo__note" }, props.emptyText || t.noMatches) : /* @__PURE__ */ React.createElement("div", { className: "aura-combo__note" }, t.keepTyping((props.options || []).length))) : null),
|
|
232
233
|
document.body
|
|
233
234
|
) : null;
|
|
234
235
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -267,9 +268,9 @@ const Combobox = React.forwardRef(
|
|
|
267
268
|
));
|
|
268
269
|
})) : null, multi ? /* @__PURE__ */ React.createElement("span", { id: summaryId, className: "aura-sr-only" }, picked.length ? t.selectedCount(picked.length) + ": " + picked.map(function(o) {
|
|
269
270
|
return o.label;
|
|
270
|
-
}).join(", ") : "") : null,
|
|
271
|
+
}).join(", ") : "") : null, props.name ? multi ? values.map(function(v) {
|
|
271
272
|
return /* @__PURE__ */ React.createElement("input", { key: v, type: "hidden", name: props.name, value: v });
|
|
272
|
-
}) : null, /* @__PURE__ */ React.createElement(
|
|
273
|
+
}) : /* @__PURE__ */ React.createElement("input", { type: "hidden", name: props.name, value: value == null ? "" : value }) : null, /* @__PURE__ */ React.createElement(
|
|
273
274
|
"input",
|
|
274
275
|
{
|
|
275
276
|
ref: inputMerged,
|
|
@@ -278,17 +279,16 @@ const Combobox = React.forwardRef(
|
|
|
278
279
|
role: "combobox",
|
|
279
280
|
className: "aura-input__control",
|
|
280
281
|
autoComplete: "off",
|
|
281
|
-
"aria-expanded": open,
|
|
282
|
-
"aria-controls": listId,
|
|
282
|
+
"aria-expanded": open && live.length > 0,
|
|
283
|
+
"aria-controls": open && live.length ? listId : void 0,
|
|
283
284
|
"aria-autocomplete": "list",
|
|
284
|
-
"aria-activedescendant": open &&
|
|
285
|
+
"aria-activedescendant": open && live[activeIdx] ? optId(activeIdx) : void 0,
|
|
285
286
|
"aria-invalid": props.error ? true : void 0,
|
|
286
287
|
"aria-describedby": [props.error ? id + "-error" : props.hint ? id + "-hint" : "", multi && picked.length ? summaryId : ""].filter(Boolean).join(" ") || void 0,
|
|
287
288
|
placeholder: multi && values.length ? void 0 : props.placeholder,
|
|
288
289
|
disabled: props.disabled,
|
|
289
290
|
readOnly: props.readOnly,
|
|
290
291
|
required: props.required && (!multi || !values.length),
|
|
291
|
-
name: multi ? void 0 : props.name,
|
|
292
292
|
value: text,
|
|
293
293
|
onChange: function(e) {
|
|
294
294
|
setQuery(e.target.value);
|
|
@@ -306,7 +306,7 @@ const Combobox = React.forwardRef(
|
|
|
306
306
|
}, 0);
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
|
-
), props.clearable !== false && values.length && !props.disabled ? /* @__PURE__ */ React.createElement(
|
|
309
|
+
), props.clearable !== false && values.length && !props.disabled && !props.readOnly ? /* @__PURE__ */ React.createElement(
|
|
310
310
|
"button",
|
|
311
311
|
{
|
|
312
312
|
type: "button",
|
package/dist/esm/Command.js
CHANGED
package/dist/esm/DataTable.js
CHANGED
|
@@ -35,7 +35,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
35
35
|
byKey[c.key] = c;
|
|
36
36
|
});
|
|
37
37
|
const rows = props.rows || [];
|
|
38
|
-
const rowKey = props.rowKey || columns[0].key;
|
|
38
|
+
const rowKey = props.rowKey || (columns[0] ? columns[0].key : "id");
|
|
39
39
|
const manual = !!props.manual;
|
|
40
40
|
const Link = useLinkComponent(props.linkComponent);
|
|
41
41
|
const busy = !!props.loading;
|
|
@@ -265,6 +265,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
265
265
|
if (isPinned(c)) s["--aura-cell-left"] = "calc(var(--aura-space-6)" + selW + " + " + pinOffsets[c.key] + "px)";
|
|
266
266
|
return s;
|
|
267
267
|
}
|
|
268
|
+
const sortCol = sort && sort.key ? byKey[sort.key] : void 0;
|
|
268
269
|
const view = React.useMemo(
|
|
269
270
|
function() {
|
|
270
271
|
if (manual || !sort || !sort.key || !byKey[sort.key]) return rows;
|
|
@@ -283,7 +284,16 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
283
284
|
return p[0];
|
|
284
285
|
});
|
|
285
286
|
},
|
|
286
|
-
[
|
|
287
|
+
[
|
|
288
|
+
rows,
|
|
289
|
+
manual,
|
|
290
|
+
sort && sort.key,
|
|
291
|
+
sort && sort.dir,
|
|
292
|
+
!!sortCol,
|
|
293
|
+
sortCol && sortCol.sortValue,
|
|
294
|
+
sortCol && sortCol.pill,
|
|
295
|
+
sortCol && sortCol.tones
|
|
296
|
+
]
|
|
287
297
|
);
|
|
288
298
|
function nextSort(key) {
|
|
289
299
|
if (!sort || sort.key !== key) return { key, dir: "asc" };
|
|
@@ -292,14 +302,23 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
292
302
|
}
|
|
293
303
|
const pageSize = props.pageSize || 0;
|
|
294
304
|
const total = manual ? props.totalRows != null ? props.totalRows : (Math.max(1, pageState[0] || 1) - 1) * pageSize + rows.length + (pageSize && rows.length >= pageSize ? 1 : 0) : view.length;
|
|
295
|
-
const pageCount = pageSize ? Math.max(1, Math.ceil(total / pageSize)) : 1;
|
|
305
|
+
const pageCount = pageSize ? Math.max(1, Math.ceil(total / pageSize), manual && props.totalRows == null ? pageState[0] || 1 : 1) : 1;
|
|
296
306
|
const page = Math.min(Math.max(1, pageState[0] || 1), pageCount);
|
|
297
307
|
const first = pageSize ? (page - 1) * pageSize : 0;
|
|
298
308
|
const pageRows = pageSize && !manual ? view.slice(first, first + pageSize) : view;
|
|
299
309
|
const canSortAny = !busy && (manual ? total > 1 : rows.length > 1);
|
|
300
310
|
const shownTotal = manual && props.totalRows == null ? first + rows.length : total;
|
|
301
311
|
const linkPaging = !!props.getPageHref && !props.onPageChange && !oneCallback;
|
|
302
|
-
const prevLink = React.useRef(null), nextLink = React.useRef(null);
|
|
312
|
+
const prevLink = React.useRef(null), nextLink = React.useRef(null), jumpLink = React.useRef(null);
|
|
313
|
+
const jumpState = React.useState(null);
|
|
314
|
+
React.useEffect(
|
|
315
|
+
function() {
|
|
316
|
+
if (jumpState[0] == null) return;
|
|
317
|
+
if (jumpLink.current) jumpLink.current.click();
|
|
318
|
+
jumpState[1](null);
|
|
319
|
+
},
|
|
320
|
+
[jumpState[0]]
|
|
321
|
+
);
|
|
303
322
|
function emit(s, p) {
|
|
304
323
|
if (props.onStateChange) props.onStateChange({ sort: s, page: p });
|
|
305
324
|
}
|
|
@@ -310,6 +329,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
310
329
|
if (linkPaging) {
|
|
311
330
|
const a = next === page - 1 ? prevLink.current : next === page + 1 ? nextLink.current : null;
|
|
312
331
|
if (a) a.click();
|
|
332
|
+
else jumpState[1](next);
|
|
313
333
|
return false;
|
|
314
334
|
}
|
|
315
335
|
if (focus) pending.current = focus;
|
|
@@ -346,7 +366,8 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
346
366
|
}
|
|
347
367
|
const height = props.height || 0;
|
|
348
368
|
const virtual = !!height && !loading && pageRows.length > 0 && !stacked;
|
|
349
|
-
const
|
|
369
|
+
const stickyTotal = !!(props.footer && props.stickyFooter && rows.length && !loading);
|
|
370
|
+
const bodyH = Math.max(ROW_H, height - ROW_H - (stickyTotal ? ROW_H : 0));
|
|
350
371
|
let start = 0, end = pageRows.length;
|
|
351
372
|
if (virtual) {
|
|
352
373
|
start = Math.max(0, Math.floor(scrollTop / ROW_H) - OVERSCAN);
|
|
@@ -376,6 +397,11 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
376
397
|
});
|
|
377
398
|
c = at >= 0 ? at + (selectable ? 1 : 0) : Math.min(p.c || 0, nCols - 1);
|
|
378
399
|
}
|
|
400
|
+
const ae = document.activeElement;
|
|
401
|
+
if (ae && ae !== document.body && !gridRef.current.contains(ae)) {
|
|
402
|
+
pending.current = null;
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
379
405
|
const el = gridRef.current.querySelector('[data-rc="' + p.r + ":" + c + '"]');
|
|
380
406
|
if (el) {
|
|
381
407
|
pending.current = null;
|
|
@@ -405,26 +431,28 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
405
431
|
});
|
|
406
432
|
const selSet = {};
|
|
407
433
|
selected.forEach(function(k) {
|
|
408
|
-
selSet[k] = true;
|
|
434
|
+
selSet[String(k)] = true;
|
|
409
435
|
});
|
|
410
436
|
const nSel = pageKeys.filter(function(k) {
|
|
411
|
-
return selSet[k];
|
|
437
|
+
return selSet[String(k)];
|
|
412
438
|
}).length;
|
|
413
439
|
const all = nSel > 0 && nSel === pageKeys.length;
|
|
414
440
|
function toggle(k, on) {
|
|
415
441
|
setSelected(
|
|
416
442
|
on ? selected.concat([k]) : selected.filter(function(x) {
|
|
417
|
-
return x !== k;
|
|
443
|
+
return String(x) !== String(k);
|
|
418
444
|
})
|
|
419
445
|
);
|
|
420
446
|
}
|
|
421
447
|
function toggleAll() {
|
|
422
448
|
setSelected(
|
|
423
449
|
all ? selected.filter(function(k) {
|
|
424
|
-
return pageKeys.
|
|
450
|
+
return !pageKeys.some(function(p) {
|
|
451
|
+
return String(p) === String(k);
|
|
452
|
+
});
|
|
425
453
|
}) : selected.concat(
|
|
426
454
|
pageKeys.filter(function(k) {
|
|
427
|
-
return !selSet[k];
|
|
455
|
+
return !selSet[String(k)];
|
|
428
456
|
})
|
|
429
457
|
)
|
|
430
458
|
);
|
|
@@ -695,6 +723,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
695
723
|
nRows ? /* @__PURE__ */ React.createElement(
|
|
696
724
|
Checkbox,
|
|
697
725
|
{
|
|
726
|
+
hideLabel: true,
|
|
698
727
|
checked: all,
|
|
699
728
|
indeterminate: nSel > 0 && !all,
|
|
700
729
|
tabIndex: -1,
|
|
@@ -848,6 +877,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
848
877
|
/* @__PURE__ */ React.createElement(
|
|
849
878
|
Checkbox,
|
|
850
879
|
{
|
|
880
|
+
hideLabel: true,
|
|
851
881
|
checked: isSel,
|
|
852
882
|
tabIndex: -1,
|
|
853
883
|
label: t.selectRow(k),
|
|
@@ -1023,7 +1053,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1023
1053
|
}
|
|
1024
1054
|
);
|
|
1025
1055
|
}
|
|
1026
|
-
if (pageSize && (rows.length || busy)) {
|
|
1056
|
+
if (pageSize && (rows.length || busy || page > 1)) {
|
|
1027
1057
|
const from = rows.length ? first + 1 : 0, to = manual ? first + rows.length : Math.min(first + pageSize, view.length);
|
|
1028
1058
|
foot = /* @__PURE__ */ React.createElement("div", { className: "aura-table__foot" }, /* @__PURE__ */ React.createElement("span", { "aria-live": "polite" }, busy ? t.loading : t.range(from, to, shownTotal)), /* @__PURE__ */ React.createElement("span", { className: "aura-table__pager" }, /* @__PURE__ */ React.createElement("span", null, t.page(page, pageCount)), pagerButton(-1), pagerButton(1)));
|
|
1029
1059
|
} else if (height && rows.length && !loading) {
|
|
@@ -1074,7 +1104,8 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1074
1104
|
) : null;
|
|
1075
1105
|
const scrollStyle = {
|
|
1076
1106
|
scrollPaddingLeft: "calc(var(--aura-space-6)" + selW + " + " + acc + "px)",
|
|
1077
|
-
scrollPaddingTop: ROW_H + "px"
|
|
1107
|
+
scrollPaddingTop: ROW_H + "px",
|
|
1108
|
+
scrollPaddingBottom: stickyTotal ? ROW_H + "px" : void 0
|
|
1078
1109
|
};
|
|
1079
1110
|
if (height) scrollStyle["--aura-table-h"] = height + "px";
|
|
1080
1111
|
const gridEl = /* @__PURE__ */ React.createElement(
|
|
@@ -1108,7 +1139,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1108
1139
|
role: "grid",
|
|
1109
1140
|
"aria-label": props.label,
|
|
1110
1141
|
"aria-busy": busy || void 0,
|
|
1111
|
-
"aria-rowcount": loading ? -1 : shownTotal + 1 + (totalRow ? 1 : 0),
|
|
1142
|
+
"aria-rowcount": loading || manual && props.totalRows == null && pageSize && rows.length >= pageSize ? -1 : shownTotal + 1 + (totalRow ? 1 : 0),
|
|
1112
1143
|
"aria-colcount": nCols,
|
|
1113
1144
|
"aria-multiselectable": selectable || void 0,
|
|
1114
1145
|
onKeyDown: onGridKey,
|
|
@@ -1156,7 +1187,8 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1156
1187
|
items: menu.kind === "picker" ? pickerItems() : byKey[menu.key] ? columnMenuItems(byKey[menu.key]) : []
|
|
1157
1188
|
}
|
|
1158
1189
|
) : null,
|
|
1159
|
-
tipEl
|
|
1190
|
+
tipEl,
|
|
1191
|
+
jumpState[0] != null && props.getPageHref ? /* @__PURE__ */ React.createElement(Link, { ref: jumpLink, href: props.getPageHref(jumpState[0]), hidden: true, tabIndex: -1, "aria-hidden": true }) : null
|
|
1160
1192
|
);
|
|
1161
1193
|
if (!levels.length) return gridEl;
|
|
1162
1194
|
let out = gridEl;
|