@jirawatpyk/aura-react 4.18.0 → 4.20.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/README.md +47 -3
- package/dist/aura.bundle.js +698 -298
- package/dist/cjs/index.cjs +697 -297
- package/dist/esm/ActionBar.js +47 -0
- package/dist/esm/AppShell.js +2 -2
- package/dist/esm/BottomNav.js +45 -0
- package/dist/esm/DataTable.js +187 -114
- package/dist/esm/DatePicker.js +33 -11
- package/dist/esm/DropdownMenu.js +1 -0
- package/dist/esm/Menu.js +64 -22
- package/dist/esm/Separator.js +20 -0
- package/dist/esm/Table.js +79 -0
- package/dist/esm/Tabs.js +35 -0
- package/dist/esm/Toaster.js +23 -6
- package/dist/esm/Tooltip.js +21 -3
- package/dist/esm/dates.js +12 -1
- package/dist/esm/index.js +16 -0
- package/dist/esm/locale.js +4 -2
- package/dist/esm/strings.js +3 -0
- package/dist/index.d.ts +163 -10
- package/dist/server/index.cjs +15 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +15 -1
- package/dist/styles.css +184 -55
- package/dist/styles.layer.css +184 -55
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Button } from "./Button.js";
|
|
4
|
+
import { cx } from "./internal.js";
|
|
5
|
+
import { useStrings } from "./locale.js";
|
|
6
|
+
const ActionBar = React.forwardRef(function ActionBar2(props, ref) {
|
|
7
|
+
const t = useStrings();
|
|
8
|
+
const bulk = props.selected != null;
|
|
9
|
+
const idle = bulk && !props.selected;
|
|
10
|
+
const count = bulk && props.selected ? t.selectedCount(props.selected) : null;
|
|
11
|
+
const cameFrom = React.useRef(null);
|
|
12
|
+
const own = React.useRef(null);
|
|
13
|
+
function clear() {
|
|
14
|
+
props.onClearSelection();
|
|
15
|
+
setTimeout(function() {
|
|
16
|
+
const back = cameFrom.current;
|
|
17
|
+
const a = document.activeElement;
|
|
18
|
+
if ((!a || a === document.body || !a.isConnected) && back && back.isConnected) back.focus();
|
|
19
|
+
}, 0);
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ React.createElement(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
ref: function(el) {
|
|
25
|
+
own.current = el;
|
|
26
|
+
if (typeof ref === "function") ref(el);
|
|
27
|
+
else if (ref) ref.current = el;
|
|
28
|
+
},
|
|
29
|
+
onFocus: function(e) {
|
|
30
|
+
const from = e.relatedTarget;
|
|
31
|
+
if (from && own.current && !own.current.contains(from)) cameFrom.current = from;
|
|
32
|
+
},
|
|
33
|
+
role: "region",
|
|
34
|
+
"aria-label": props.label || t.actions,
|
|
35
|
+
className: cx(
|
|
36
|
+
"aura-actionbar",
|
|
37
|
+
"aura-actionbar--" + (props.position || "viewport"),
|
|
38
|
+
idle && "is-idle",
|
|
39
|
+
props.className
|
|
40
|
+
)
|
|
41
|
+
},
|
|
42
|
+
/* @__PURE__ */ React.createElement("div", { className: "aura-actionbar__inner" }, /* @__PURE__ */ React.createElement("div", { className: "aura-actionbar__status", role: "status" }, count, count && props.status ? " \xB7 " : null, props.status), !idle ? /* @__PURE__ */ React.createElement("div", { className: "aura-actionbar__actions" }, count && props.onClearSelection ? /* @__PURE__ */ React.createElement(Button, { variant: "ghost", size: "sm", onClick: clear }, t.clear()) : null, props.children) : null)
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
export {
|
|
46
|
+
ActionBar
|
|
47
|
+
};
|
package/dist/esm/AppShell.js
CHANGED
|
@@ -26,7 +26,7 @@ const AppShell = React.forwardRef(function AppShell2(props, ref) {
|
|
|
26
26
|
collapsed: false,
|
|
27
27
|
collapsible: false
|
|
28
28
|
}) : props.nav;
|
|
29
|
-
return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-shell", props.className) }, props.nav ? /* @__PURE__ */ React.createElement("div", { className: "aura-shell__nav" }, props.nav) : null, props.nav ? /* @__PURE__ */ React.createElement(
|
|
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" }, props.nav) : null, props.nav ? /* @__PURE__ */ React.createElement(
|
|
30
30
|
Drawer,
|
|
31
31
|
{
|
|
32
32
|
open,
|
|
@@ -51,7 +51,7 @@ const AppShell = React.forwardRef(function AppShell2(props, ref) {
|
|
|
51
51
|
},
|
|
52
52
|
"aria-expanded": open
|
|
53
53
|
}
|
|
54
|
-
) : null, /* @__PURE__ */ React.createElement("div", { className: "aura-shell__bar-content" }, props.header)) : null, /* @__PURE__ */ React.createElement("main", { className: "aura-shell__content", id: props.mainId || "main" }, props.children)));
|
|
54
|
+
) : null, /* @__PURE__ */ React.createElement("div", { className: "aura-shell__bar-content" }, props.header)) : null, /* @__PURE__ */ React.createElement("main", { className: "aura-shell__content", id: props.mainId || "main" }, props.children), props.bottomNav || null));
|
|
55
55
|
});
|
|
56
56
|
export {
|
|
57
57
|
AppShell
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Icon } from "./Icon.js";
|
|
4
|
+
import { cx, useMaybeControlled } from "./internal.js";
|
|
5
|
+
import { useLinkComponent, useStrings } from "./locale.js";
|
|
6
|
+
const BottomNav = React.forwardRef(function BottomNav2(props, ref) {
|
|
7
|
+
const t = useStrings();
|
|
8
|
+
const Link = useLinkComponent(props.linkComponent);
|
|
9
|
+
const st = useMaybeControlled(
|
|
10
|
+
props.value,
|
|
11
|
+
props.defaultValue,
|
|
12
|
+
props.onChange
|
|
13
|
+
);
|
|
14
|
+
const active = st[0];
|
|
15
|
+
const hide = props.hideFrom === false ? "always" : "below-" + (props.hideFrom || "lg");
|
|
16
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: cx("aura-bottomnav-spacer", "aura-bottomnav--" + hide), "aria-hidden": "true" }), /* @__PURE__ */ React.createElement(
|
|
17
|
+
"nav",
|
|
18
|
+
{
|
|
19
|
+
ref,
|
|
20
|
+
className: cx("aura-bottomnav", "aura-bottomnav--" + hide, props.className),
|
|
21
|
+
"aria-label": props.label || t.mainNav
|
|
22
|
+
},
|
|
23
|
+
/* @__PURE__ */ React.createElement("ul", { className: "aura-bottomnav__list" }, props.items.map(function(it) {
|
|
24
|
+
const on = active === it.id;
|
|
25
|
+
const count = it.count != null && it.count > 0 ? it.count > 99 ? "99+" : String(it.count) : null;
|
|
26
|
+
const common = {
|
|
27
|
+
className: cx("aura-bottomnav__item", on && "is-active"),
|
|
28
|
+
"aria-current": on ? "page" : void 0,
|
|
29
|
+
onClick: function(e) {
|
|
30
|
+
if (!it.href) e.preventDefault();
|
|
31
|
+
st[1](it.id);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const inner = [
|
|
35
|
+
/* @__PURE__ */ React.createElement("span", { key: "i", className: "aura-bottomnav__icon" }, /* @__PURE__ */ React.createElement(Icon, { name: it.icon, size: "md" }), count ? /* @__PURE__ */ React.createElement("span", { className: "aura-bottomnav__count", "aria-hidden": "true" }, count) : it.badge ? /* @__PURE__ */ React.createElement("span", { className: "aura-bottomnav__dot", "aria-hidden": "true" }) : null),
|
|
36
|
+
/* @__PURE__ */ React.createElement("span", { key: "l", className: "aura-bottomnav__label" }, it.label),
|
|
37
|
+
count || it.badge && it.badgeLabel ? /* @__PURE__ */ React.createElement("span", { key: "s", className: "aura-sr-only" }, " (" + (count || it.badgeLabel) + ")") : null
|
|
38
|
+
];
|
|
39
|
+
return /* @__PURE__ */ React.createElement("li", { key: it.id, className: "aura-bottomnav__cell" }, it.href ? /* @__PURE__ */ React.createElement(Link, { href: it.href, ...common }, inner) : /* @__PURE__ */ React.createElement("button", { type: "button", ...common }, inner));
|
|
40
|
+
}))
|
|
41
|
+
));
|
|
42
|
+
});
|
|
43
|
+
export {
|
|
44
|
+
BottomNav
|
|
45
|
+
};
|
package/dist/esm/DataTable.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
3
4
|
import { useStrings, useLinkComponent } from "./locale.js";
|
|
4
5
|
import { cx, useMaybeControlled, compare, useIsoLayoutEffect, useMergedRef } from "./internal.js";
|
|
5
6
|
import { Icon } from "./Icon.js";
|
|
@@ -15,7 +16,16 @@ const DEFAULT_COLUMNS = [
|
|
|
15
16
|
{ key: "owner", label: "OWNER" }
|
|
16
17
|
];
|
|
17
18
|
const SKELETON_WIDTHS = ["72%", "56%", "84%", "44%", "64%"];
|
|
18
|
-
const
|
|
19
|
+
const Q = 1e4;
|
|
20
|
+
const MAX_HIDE_LEVELS = 3;
|
|
21
|
+
function below(w, threshold) {
|
|
22
|
+
return w < threshold * (1 - 0.5 / Q);
|
|
23
|
+
}
|
|
24
|
+
function hidePx(c) {
|
|
25
|
+
if (c.hideBelow == null) return void 0;
|
|
26
|
+
const px = typeof c.hideBelow === "number" ? c.hideBelow : BP[c.hideBelow];
|
|
27
|
+
return px != null && px > 0 ? px : void 0;
|
|
28
|
+
}
|
|
19
29
|
const ROW_H_DEFAULT = 48, OVERSCAN = 8, FLEX_MIN = 160;
|
|
20
30
|
const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
21
31
|
const t = useStrings();
|
|
@@ -89,33 +99,75 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
89
99
|
const measure = !!props.stackBelow || columns.some(function(c) {
|
|
90
100
|
return c.hideBelow != null;
|
|
91
101
|
});
|
|
92
|
-
const dual = !!props.stackBelow && boxWidth[0] == null && STACK_WIDTHS.indexOf(props.stackBelow) >= 0;
|
|
93
102
|
React.useEffect(
|
|
94
103
|
function() {
|
|
95
104
|
if (!measure || !wrapRef.current || typeof ResizeObserver === "undefined") return;
|
|
96
105
|
const ro = new ResizeObserver(function(en) {
|
|
97
|
-
|
|
106
|
+
const bb = en[0].borderBoxSize && en[0].borderBoxSize[0];
|
|
107
|
+
boxWidth[1](bb ? bb.inlineSize : en[0].target.getBoundingClientRect().width);
|
|
98
108
|
});
|
|
99
109
|
ro.observe(wrapRef.current);
|
|
100
110
|
return function() {
|
|
101
111
|
ro.disconnect();
|
|
102
112
|
};
|
|
103
113
|
},
|
|
104
|
-
[measure
|
|
114
|
+
[measure]
|
|
105
115
|
);
|
|
106
|
-
const stacked = !!props.stackBelow && boxWidth[0] != null && boxWidth[0]
|
|
116
|
+
const stacked = !!props.stackBelow && boxWidth[0] != null && below(boxWidth[0], props.stackBelow);
|
|
107
117
|
useIsoLayoutEffect(
|
|
108
118
|
function() {
|
|
109
119
|
if (measure && boxWidth[0] == null && wrapRef.current) boxWidth[1](wrapRef.current.getBoundingClientRect().width);
|
|
110
120
|
},
|
|
111
121
|
[measure]
|
|
112
122
|
);
|
|
123
|
+
const hideLevels = [];
|
|
124
|
+
columns.forEach(function(c) {
|
|
125
|
+
const px = hidePx(c);
|
|
126
|
+
if (px != null && hideLevels.indexOf(px) < 0) hideLevels.push(px);
|
|
127
|
+
});
|
|
128
|
+
hideLevels.sort(function(a, b) {
|
|
129
|
+
return b - a;
|
|
130
|
+
});
|
|
131
|
+
hideLevels.length = Math.min(hideLevels.length, MAX_HIDE_LEVELS);
|
|
132
|
+
const levels = [];
|
|
133
|
+
if (props.stackBelow && props.stackBelow > 0) levels.push({ name: "stack", px: props.stackBelow });
|
|
134
|
+
hideLevels.forEach(function(px, i) {
|
|
135
|
+
levels.push({ name: "h" + (i + 1), px });
|
|
136
|
+
});
|
|
137
|
+
function hideLevel(c) {
|
|
138
|
+
const px = hidePx(c);
|
|
139
|
+
const i = px == null ? -1 : hideLevels.indexOf(px);
|
|
140
|
+
return i < 0 ? void 0 : i + 1;
|
|
141
|
+
}
|
|
113
142
|
function tooNarrow(c) {
|
|
114
143
|
if (c.hideBelow == null || boxWidth[0] == null || stacked) return false;
|
|
115
|
-
const px =
|
|
116
|
-
return px != null && boxWidth[0]
|
|
144
|
+
const px = hidePx(c);
|
|
145
|
+
return px != null && below(boxWidth[0], px);
|
|
117
146
|
}
|
|
118
147
|
const scrollRef = React.useRef(null);
|
|
148
|
+
const tipState = React.useState(null), tip = tipState[0], setTip = tipState[1];
|
|
149
|
+
function showFull(e) {
|
|
150
|
+
const el = e.target.closest ? e.target.closest(".aura-table__td") : null;
|
|
151
|
+
if (!el || el.scrollWidth <= el.clientWidth + 1 || el.querySelector("button, input, .aura-pill"))
|
|
152
|
+
return setTip(null);
|
|
153
|
+
const r = el.getBoundingClientRect();
|
|
154
|
+
setTip({ text: (el.textContent || "").trim(), left: r.left, top: r.top });
|
|
155
|
+
}
|
|
156
|
+
function hideFull() {
|
|
157
|
+
setTip(null);
|
|
158
|
+
}
|
|
159
|
+
const tipEl = tip && typeof document !== "undefined" ? createPortal(
|
|
160
|
+
/* @__PURE__ */ React.createElement(
|
|
161
|
+
"div",
|
|
162
|
+
{
|
|
163
|
+
className: "aura-tooltip aura-tooltip--above",
|
|
164
|
+
"aria-hidden": "true",
|
|
165
|
+
style: { left: tip.left, top: tip.top - 6 }
|
|
166
|
+
},
|
|
167
|
+
tip.text
|
|
168
|
+
),
|
|
169
|
+
document.body
|
|
170
|
+
) : null;
|
|
119
171
|
const rowH = React.useState(ROW_H_DEFAULT);
|
|
120
172
|
const ROW_H = rowH[0];
|
|
121
173
|
useIsoLayoutEffect(function() {
|
|
@@ -127,7 +179,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
127
179
|
const pending = React.useRef(null);
|
|
128
180
|
const resizing = React.useRef(false);
|
|
129
181
|
useIsoLayoutEffect(function() {
|
|
130
|
-
if (
|
|
182
|
+
if (!gridRef.current) return;
|
|
131
183
|
const els = gridRef.current.querySelectorAll(
|
|
132
184
|
'.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"]'
|
|
133
185
|
);
|
|
@@ -159,12 +211,31 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
159
211
|
})
|
|
160
212
|
);
|
|
161
213
|
const nPinned = vis.filter(isPinned).length;
|
|
214
|
+
const pillKey = (vis.filter(function(c, i) {
|
|
215
|
+
return i > 0 && c.pill;
|
|
216
|
+
})[0] || { key: "" }).key;
|
|
217
|
+
function cardPart(c, i) {
|
|
218
|
+
return i === 0 ? "title" : c.key === pillKey ? "pill" : c.actions ? "actions" : "field";
|
|
219
|
+
}
|
|
220
|
+
function cardAttrs(c, i) {
|
|
221
|
+
const part = cardPart(c, i), lv = hideLevel(c);
|
|
222
|
+
return {
|
|
223
|
+
"data-card": part,
|
|
224
|
+
"data-label": part === "field" ? c.label || void 0 : void 0,
|
|
225
|
+
"data-hide": lv ? String(lv) : void 0
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
const hasFields = vis.some(function(c, i) {
|
|
229
|
+
return cardPart(c, i) === "field";
|
|
230
|
+
});
|
|
162
231
|
const hasFlex = vis.some(function(c) {
|
|
163
232
|
return widthOf(c) == null;
|
|
164
233
|
});
|
|
165
|
-
let fixedSum = 0;
|
|
234
|
+
let fixedSum = 0, hideTerms = "";
|
|
166
235
|
vis.forEach(function(c) {
|
|
167
|
-
|
|
236
|
+
const w = widthOf(c) != null ? widthOf(c) : FLEX_MIN, lv = hideLevel(c);
|
|
237
|
+
if (lv && boxWidth[0] == null) hideTerms += " + " + w + "px * var(--aura-h" + lv + "-on, 1)";
|
|
238
|
+
else fixedSum += w;
|
|
168
239
|
});
|
|
169
240
|
let pinOffsets = {}, acc = 0;
|
|
170
241
|
vis.forEach(function(c) {
|
|
@@ -175,13 +246,17 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
175
246
|
});
|
|
176
247
|
const selW = selectable ? " + var(--aura-table-select-width)" : "";
|
|
177
248
|
const gutterR = controls ? "var(--aura-space-12)" : "var(--aura-space-6)";
|
|
178
|
-
const rowMinWidth = "calc(" + fixedSum + "px + var(--aura-space-6) + " + gutterR + selW + ")";
|
|
249
|
+
const rowMinWidth = "calc(" + fixedSum + "px" + hideTerms + " + var(--aura-space-6) + " + gutterR + selW + ")";
|
|
179
250
|
function cellStyle(c, i) {
|
|
180
|
-
|
|
181
|
-
if (w == null)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
251
|
+
const w = widthOf(c), s = {};
|
|
252
|
+
if (w == null) {
|
|
253
|
+
s["--aura-cell-flex"] = "1 1 0";
|
|
254
|
+
s["--aura-cell-min"] = (c.minWidth || FLEX_MIN) + "px";
|
|
255
|
+
} else {
|
|
256
|
+
s["--aura-cell-flex"] = !hasFlex && i === vis.length - 1 ? "1 0 auto" : "none";
|
|
257
|
+
s["--aura-cell-w"] = w + "px";
|
|
258
|
+
}
|
|
259
|
+
if (isPinned(c)) s["--aura-cell-left"] = "calc(var(--aura-space-6)" + selW + " + " + pinOffsets[c.key] + "px)";
|
|
185
260
|
return s;
|
|
186
261
|
}
|
|
187
262
|
const view = React.useMemo(
|
|
@@ -264,7 +339,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
264
339
|
return rowHref ? /* @__PURE__ */ React.createElement(Link, { href: rowHref(r), className: "aura-table__row-link" }, content) : content;
|
|
265
340
|
}
|
|
266
341
|
const height = props.height || 0;
|
|
267
|
-
const virtual = !!height && !loading && pageRows.length > 0;
|
|
342
|
+
const virtual = !!height && !loading && pageRows.length > 0 && !stacked;
|
|
268
343
|
const bodyH = Math.max(ROW_H, height - ROW_H);
|
|
269
344
|
let start = 0, end = pageRows.length;
|
|
270
345
|
if (virtual) {
|
|
@@ -619,7 +694,8 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
619
694
|
label: all ? t.deselectAllRows : t.selectAllRows,
|
|
620
695
|
onChange: toggleAll
|
|
621
696
|
}
|
|
622
|
-
) : null
|
|
697
|
+
) : null,
|
|
698
|
+
nRows ? /* @__PURE__ */ React.createElement("span", { className: "aura-table__sel-text" }, nSel ? t.selectedCount(nSel) : t.selectAll) : /* @__PURE__ */ React.createElement("span", { className: "aura-sr-only" }, t.selectRows)
|
|
623
699
|
)
|
|
624
700
|
);
|
|
625
701
|
vis.forEach(function(c, i) {
|
|
@@ -637,6 +713,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
637
713
|
"aria-sort": ariaSort,
|
|
638
714
|
"aria-colindex": ci + 1,
|
|
639
715
|
style: cellStyle(c, i),
|
|
716
|
+
"data-hide": hideLevel(c) ? String(hideLevel(c)) : void 0,
|
|
640
717
|
tabIndex: tabFor(0, ci),
|
|
641
718
|
"data-rc": "0:" + ci,
|
|
642
719
|
className: cx(
|
|
@@ -793,6 +870,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
793
870
|
pin && j === nPinned - 1 && "is-pin-edge"
|
|
794
871
|
),
|
|
795
872
|
style: cellStyle(c, j),
|
|
873
|
+
...cardAttrs(c, j),
|
|
796
874
|
onFocus: function() {
|
|
797
875
|
if (activeState[0].r !== ri || activeState[0].c !== ci) activeState[1]({ r: ri, c: ci });
|
|
798
876
|
}
|
|
@@ -801,6 +879,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
801
879
|
)
|
|
802
880
|
);
|
|
803
881
|
});
|
|
882
|
+
if (hasFields) cells.push(/* @__PURE__ */ React.createElement("span", { key: "__br", className: "aura-table__break", "aria-hidden": true }));
|
|
804
883
|
cells.push(
|
|
805
884
|
/* @__PURE__ */ React.createElement(
|
|
806
885
|
"span",
|
|
@@ -814,7 +893,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
814
893
|
return cells;
|
|
815
894
|
}
|
|
816
895
|
let body;
|
|
817
|
-
const rowStyle = {
|
|
896
|
+
const rowStyle = { ["--aura-row-min"]: rowMinWidth };
|
|
818
897
|
if (loading) {
|
|
819
898
|
const n = pageSize || props.skeletonRows || 5;
|
|
820
899
|
const skRows = body = [];
|
|
@@ -831,7 +910,9 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
831
910
|
{
|
|
832
911
|
key: c.key,
|
|
833
912
|
className: cx("aura-table__td", c.align === "end" && "is-end", isPinned(c) && "is-pinned"),
|
|
834
|
-
style: cellStyle(c, j)
|
|
913
|
+
style: cellStyle(c, j),
|
|
914
|
+
...cardAttrs(c, j),
|
|
915
|
+
"data-label": void 0
|
|
835
916
|
},
|
|
836
917
|
/* @__PURE__ */ React.createElement(
|
|
837
918
|
"span",
|
|
@@ -843,6 +924,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
843
924
|
)
|
|
844
925
|
);
|
|
845
926
|
});
|
|
927
|
+
if (hasFields) sk.push(/* @__PURE__ */ React.createElement("span", { key: "__br", className: "aura-table__break" }));
|
|
846
928
|
sk.push(
|
|
847
929
|
/* @__PURE__ */ React.createElement("span", { key: "__gr", className: cx("aura-table__gutter aura-table__gutter--end", controls && "has-picker") })
|
|
848
930
|
);
|
|
@@ -928,103 +1010,67 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
928
1010
|
} else if (height && rows.length && !loading) {
|
|
929
1011
|
foot = /* @__PURE__ */ React.createElement("div", { className: "aura-table__foot" }, /* @__PURE__ */ React.createElement("span", null, t.rowCount(shownTotal)), selectable && selected.length ? /* @__PURE__ */ React.createElement("span", null, t.selectedCount(selected.length)) : /* @__PURE__ */ React.createElement("span", null));
|
|
930
1012
|
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
})
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
} else if (!rows.length) {
|
|
947
|
-
const em2 = props.empty || {};
|
|
948
|
-
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));
|
|
949
|
-
} else {
|
|
950
|
-
const cellVal = cellContent;
|
|
951
|
-
cardBody = /* @__PURE__ */ React.createElement("ul", { className: "aura-table__cards", "aria-label": props.label }, pageRows.map(function(r) {
|
|
952
|
-
const k = r[rowKey], isSel = !!selSet[k];
|
|
953
|
-
return /* @__PURE__ */ React.createElement(
|
|
954
|
-
"li",
|
|
955
|
-
{
|
|
956
|
-
key: k,
|
|
957
|
-
className: cx(
|
|
958
|
-
"aura-table__card",
|
|
959
|
-
isSel && "is-selected",
|
|
960
|
-
(props.onRowActivate || rowHref) && "is-actionable"
|
|
961
|
-
),
|
|
962
|
-
tabIndex: props.onRowActivate && !rowHref ? 0 : void 0,
|
|
963
|
-
onClick: function(e) {
|
|
964
|
-
const el = e.target;
|
|
965
|
-
if (el.closest && el.closest(".aura-check, button, a, input")) return;
|
|
966
|
-
if (rowHref) followRow(e.currentTarget, e);
|
|
967
|
-
else if (props.onRowActivate) props.onRowActivate(r);
|
|
968
|
-
},
|
|
969
|
-
onKeyDown: function(e) {
|
|
970
|
-
if (e.target === e.currentTarget && e.key === "Enter" && props.onRowActivate && !rowHref)
|
|
971
|
-
props.onRowActivate(r);
|
|
972
|
-
}
|
|
973
|
-
},
|
|
974
|
-
/* @__PURE__ */ React.createElement("div", { className: "aura-table__card-head" }, selectable ? /* @__PURE__ */ React.createElement(
|
|
975
|
-
Checkbox,
|
|
976
|
-
{
|
|
977
|
-
checked: isSel,
|
|
978
|
-
label: t.selectRow(k),
|
|
979
|
-
onChange: function(on) {
|
|
980
|
-
toggle(k, on);
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
) : null, /* @__PURE__ */ React.createElement("span", { className: cx("aura-table__card-title", titleCol.mono && "aura-table__mono") }, rowLinkWrap(r, cellVal(titleCol, r))), pillCol ? cellVal(pillCol, r) : null, actionCols.map(function(c) {
|
|
984
|
-
return /* @__PURE__ */ React.createElement("span", { key: c.key, className: "aura-table__card-actions" }, cellVal(c, r));
|
|
985
|
-
})),
|
|
986
|
-
rest.length ? /* @__PURE__ */ React.createElement("dl", { className: "aura-table__card-fields" }, rest.map(function(c) {
|
|
987
|
-
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)));
|
|
988
|
-
})) : null
|
|
989
|
-
);
|
|
990
|
-
}));
|
|
991
|
-
}
|
|
992
|
-
return /* @__PURE__ */ React.createElement(
|
|
993
|
-
"div",
|
|
994
|
-
{
|
|
995
|
-
ref: wrapRefArg,
|
|
996
|
-
"data-density": props.density,
|
|
997
|
-
className: cx("aura-table aura-table--stacked", refreshing && "is-refreshing", props.className),
|
|
998
|
-
role: "region",
|
|
999
|
-
"aria-label": props.label,
|
|
1000
|
-
"aria-busy": busy || void 0
|
|
1001
|
-
},
|
|
1002
|
-
refreshing ? /* @__PURE__ */ React.createElement("span", { className: "aura-table__busy-bar", "aria-hidden": true }) : null,
|
|
1003
|
-
selectable && pageRows.length && !busy ? /* @__PURE__ */ React.createElement("div", { className: "aura-table__stack-bar" }, /* @__PURE__ */ React.createElement(
|
|
1004
|
-
Checkbox,
|
|
1013
|
+
const totalRow = props.footer && rows.length && !loading ? /* @__PURE__ */ React.createElement(
|
|
1014
|
+
"div",
|
|
1015
|
+
{
|
|
1016
|
+
role: "row",
|
|
1017
|
+
"aria-rowindex": shownTotal + 2,
|
|
1018
|
+
"aria-label": t.totals,
|
|
1019
|
+
className: cx("aura-table__row aura-table__total", props.stickyFooter && "is-sticky"),
|
|
1020
|
+
style: rowStyle
|
|
1021
|
+
},
|
|
1022
|
+
/* @__PURE__ */ React.createElement("span", { className: "aura-table__gutter", "aria-hidden": true }),
|
|
1023
|
+
selectable ? /* @__PURE__ */ React.createElement("span", { className: cx("aura-table__sel", nPinned && "is-pinned"), "aria-hidden": true }) : null,
|
|
1024
|
+
vis.map(function(c, j) {
|
|
1025
|
+
const pin = isPinned(c);
|
|
1026
|
+
return /* @__PURE__ */ React.createElement(
|
|
1027
|
+
"span",
|
|
1005
1028
|
{
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1029
|
+
key: c.key,
|
|
1030
|
+
role: "gridcell",
|
|
1031
|
+
"aria-colindex": j + (selectable ? 2 : 1),
|
|
1032
|
+
className: cx(
|
|
1033
|
+
"aura-table__td",
|
|
1034
|
+
c.mono && "aura-table__mono",
|
|
1035
|
+
c.align === "end" && "is-end",
|
|
1036
|
+
pin && "is-pinned",
|
|
1037
|
+
pin && j === nPinned - 1 && "is-pin-edge",
|
|
1038
|
+
props.footer[c.key] == null && "is-blank"
|
|
1039
|
+
),
|
|
1040
|
+
style: cellStyle(c, j),
|
|
1041
|
+
...cardAttrs(c, j),
|
|
1042
|
+
"data-label": j === 0 ? void 0 : c.label || t.totals
|
|
1043
|
+
},
|
|
1044
|
+
props.footer[c.key]
|
|
1045
|
+
);
|
|
1046
|
+
}),
|
|
1047
|
+
hasFields ? /* @__PURE__ */ React.createElement("span", { className: "aura-table__break", "aria-hidden": true }) : null,
|
|
1048
|
+
/* @__PURE__ */ React.createElement(
|
|
1049
|
+
"span",
|
|
1050
|
+
{
|
|
1051
|
+
className: cx("aura-table__gutter aura-table__gutter--end", controls && "has-picker"),
|
|
1052
|
+
"aria-hidden": true
|
|
1053
|
+
}
|
|
1054
|
+
)
|
|
1055
|
+
) : null;
|
|
1017
1056
|
const scrollStyle = {
|
|
1018
1057
|
scrollPaddingLeft: "calc(var(--aura-space-6)" + selW + " + " + acc + "px)",
|
|
1019
1058
|
scrollPaddingTop: ROW_H + "px"
|
|
1020
1059
|
};
|
|
1021
|
-
if (height) scrollStyle
|
|
1060
|
+
if (height) scrollStyle["--aura-table-h"] = height + "px";
|
|
1022
1061
|
const gridEl = /* @__PURE__ */ React.createElement(
|
|
1023
1062
|
"div",
|
|
1024
1063
|
{
|
|
1025
|
-
ref:
|
|
1064
|
+
ref: levels.length ? wrapRef : wrapMerged,
|
|
1026
1065
|
"data-density": props.density,
|
|
1027
|
-
className: cx(
|
|
1066
|
+
className: cx(
|
|
1067
|
+
"aura-table",
|
|
1068
|
+
stacked && "aura-table--stacked",
|
|
1069
|
+
scrolledX[0] && "is-scrolled-x",
|
|
1070
|
+
refreshing && "is-refreshing",
|
|
1071
|
+
!levels.length && props.className
|
|
1072
|
+
),
|
|
1073
|
+
style: levels.length ? { ["--aura-q-back"]: String(levels[levels.length - 1].px / Q) } : void 0
|
|
1028
1074
|
},
|
|
1029
1075
|
refreshing ? /* @__PURE__ */ React.createElement("span", { className: "aura-table__busy-bar", "aria-hidden": true }) : null,
|
|
1030
1076
|
/* @__PURE__ */ React.createElement(
|
|
@@ -1035,11 +1081,15 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1035
1081
|
gridRef.current = el;
|
|
1036
1082
|
},
|
|
1037
1083
|
className: "aura-table__scroll",
|
|
1084
|
+
onMouseOver: showFull,
|
|
1085
|
+
onMouseLeave: hideFull,
|
|
1086
|
+
onFocus: showFull,
|
|
1087
|
+
onBlur: hideFull,
|
|
1038
1088
|
style: scrollStyle,
|
|
1039
1089
|
role: "grid",
|
|
1040
1090
|
"aria-label": props.label,
|
|
1041
1091
|
"aria-busy": busy || void 0,
|
|
1042
|
-
"aria-rowcount": loading ? -1 : shownTotal + 1,
|
|
1092
|
+
"aria-rowcount": loading ? -1 : shownTotal + 1 + (totalRow ? 1 : 0),
|
|
1043
1093
|
"aria-colcount": nCols,
|
|
1044
1094
|
"aria-multiselectable": selectable || void 0,
|
|
1045
1095
|
onKeyDown: onGridKey,
|
|
@@ -1052,8 +1102,18 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1052
1102
|
if (sx !== scrolledX[0]) scrolledX[1](sx);
|
|
1053
1103
|
}
|
|
1054
1104
|
},
|
|
1055
|
-
/* @__PURE__ */ React.createElement(
|
|
1056
|
-
|
|
1105
|
+
/* @__PURE__ */ React.createElement(
|
|
1106
|
+
"div",
|
|
1107
|
+
{
|
|
1108
|
+
className: cx("aura-table__head", selectable && nRows > 0 && !busy && "has-select-all"),
|
|
1109
|
+
role: "row",
|
|
1110
|
+
"aria-rowindex": 1,
|
|
1111
|
+
style: rowStyle
|
|
1112
|
+
},
|
|
1113
|
+
head
|
|
1114
|
+
),
|
|
1115
|
+
body,
|
|
1116
|
+
totalRow
|
|
1057
1117
|
),
|
|
1058
1118
|
busy ? /* @__PURE__ */ React.createElement("span", { className: "aura-sr-only", role: "status" }, t.loadingRows) : null,
|
|
1059
1119
|
controls ? /* @__PURE__ */ React.createElement("div", { className: "aura-table__picker" }, /* @__PURE__ */ React.createElement(
|
|
@@ -1076,10 +1136,23 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1076
1136
|
label: menu.kind === "picker" ? t.columns : t.column(byKey[menu.key] && byKey[menu.key].label),
|
|
1077
1137
|
items: menu.kind === "picker" ? pickerItems() : byKey[menu.key] ? columnMenuItems(byKey[menu.key]) : []
|
|
1078
1138
|
}
|
|
1079
|
-
) : null
|
|
1139
|
+
) : null,
|
|
1140
|
+
tipEl
|
|
1080
1141
|
);
|
|
1081
|
-
if (!
|
|
1082
|
-
|
|
1142
|
+
if (!levels.length) return gridEl;
|
|
1143
|
+
let out = gridEl;
|
|
1144
|
+
for (let i = levels.length - 1; i >= 0; i--) {
|
|
1145
|
+
const prev = i === 0 ? Q : levels[i - 1].px;
|
|
1146
|
+
out = /* @__PURE__ */ React.createElement(
|
|
1147
|
+
"div",
|
|
1148
|
+
{
|
|
1149
|
+
className: cx("aura-table-q", "aura-table-q--" + levels[i].name),
|
|
1150
|
+
style: { ["--aura-q-scale"]: String(prev / levels[i].px) }
|
|
1151
|
+
},
|
|
1152
|
+
out
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-table-box", props.className) }, out);
|
|
1083
1156
|
});
|
|
1084
1157
|
export {
|
|
1085
1158
|
DataTable
|