@jirawatpyk/aura-react 4.19.0 → 5.0.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 +30 -6
- package/dist/aura.bundle.js +383 -276
- package/dist/cjs/index.cjs +382 -275
- package/dist/esm/DataTable.js +119 -125
- package/dist/esm/DatePicker.js +7 -7
- package/dist/esm/Separator.js +20 -0
- package/dist/esm/Table.js +79 -0
- package/dist/esm/Tooltip.js +21 -3
- package/dist/esm/dates.js +1 -1
- package/dist/esm/index.js +10 -0
- package/dist/index.d.ts +57 -5
- package/dist/server/index.cjs +2 -9
- package/dist/server/index.d.ts +5 -4
- package/dist/server/index.js +2 -9
- package/dist/styles.css +104 -57
- package/dist/styles.layer.css +104 -57
- package/package.json +1 -1
package/dist/esm/DataTable.js
CHANGED
|
@@ -16,7 +16,16 @@ const DEFAULT_COLUMNS = [
|
|
|
16
16
|
{ key: "owner", label: "OWNER" }
|
|
17
17
|
];
|
|
18
18
|
const SKELETON_WIDTHS = ["72%", "56%", "84%", "44%", "64%"];
|
|
19
|
-
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
|
+
}
|
|
20
29
|
const ROW_H_DEFAULT = 48, OVERSCAN = 8, FLEX_MIN = 160;
|
|
21
30
|
const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
22
31
|
const t = useStrings();
|
|
@@ -90,36 +99,55 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
90
99
|
const measure = !!props.stackBelow || columns.some(function(c) {
|
|
91
100
|
return c.hideBelow != null;
|
|
92
101
|
});
|
|
93
|
-
const dual = !!props.stackBelow && boxWidth[0] == null && STACK_WIDTHS.indexOf(props.stackBelow) >= 0;
|
|
94
102
|
React.useEffect(
|
|
95
103
|
function() {
|
|
96
104
|
if (!measure || !wrapRef.current || typeof ResizeObserver === "undefined") return;
|
|
97
105
|
const ro = new ResizeObserver(function(en) {
|
|
98
|
-
|
|
106
|
+
const bb = en[0].borderBoxSize && en[0].borderBoxSize[0];
|
|
107
|
+
boxWidth[1](bb ? bb.inlineSize : en[0].target.getBoundingClientRect().width);
|
|
99
108
|
});
|
|
100
109
|
ro.observe(wrapRef.current);
|
|
101
110
|
return function() {
|
|
102
111
|
ro.disconnect();
|
|
103
112
|
};
|
|
104
113
|
},
|
|
105
|
-
[measure
|
|
114
|
+
[measure]
|
|
106
115
|
);
|
|
107
|
-
const stacked = !!props.stackBelow && boxWidth[0] != null && boxWidth[0]
|
|
116
|
+
const stacked = !!props.stackBelow && boxWidth[0] != null && below(boxWidth[0], props.stackBelow);
|
|
108
117
|
useIsoLayoutEffect(
|
|
109
118
|
function() {
|
|
110
119
|
if (measure && boxWidth[0] == null && wrapRef.current) boxWidth[1](wrapRef.current.getBoundingClientRect().width);
|
|
111
120
|
},
|
|
112
121
|
[measure]
|
|
113
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
|
+
}
|
|
114
142
|
function tooNarrow(c) {
|
|
115
143
|
if (c.hideBelow == null || boxWidth[0] == null || stacked) return false;
|
|
116
|
-
const px =
|
|
117
|
-
return px != null && boxWidth[0]
|
|
144
|
+
const px = hidePx(c);
|
|
145
|
+
return px != null && below(boxWidth[0], px);
|
|
118
146
|
}
|
|
119
147
|
const scrollRef = React.useRef(null);
|
|
120
148
|
const tipState = React.useState(null), tip = tipState[0], setTip = tipState[1];
|
|
121
149
|
function showFull(e) {
|
|
122
|
-
const el = e.target.closest ? e.target.closest(".aura-table__td
|
|
150
|
+
const el = e.target.closest ? e.target.closest(".aura-table__td") : null;
|
|
123
151
|
if (!el || el.scrollWidth <= el.clientWidth + 1 || el.querySelector("button, input, .aura-pill"))
|
|
124
152
|
return setTip(null);
|
|
125
153
|
const r = el.getBoundingClientRect();
|
|
@@ -151,7 +179,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
151
179
|
const pending = React.useRef(null);
|
|
152
180
|
const resizing = React.useRef(false);
|
|
153
181
|
useIsoLayoutEffect(function() {
|
|
154
|
-
if (
|
|
182
|
+
if (!gridRef.current) return;
|
|
155
183
|
const els = gridRef.current.querySelectorAll(
|
|
156
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"]'
|
|
157
185
|
);
|
|
@@ -183,12 +211,31 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
183
211
|
})
|
|
184
212
|
);
|
|
185
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
|
+
});
|
|
186
231
|
const hasFlex = vis.some(function(c) {
|
|
187
232
|
return widthOf(c) == null;
|
|
188
233
|
});
|
|
189
|
-
let fixedSum = 0;
|
|
234
|
+
let fixedSum = 0, hideTerms = "";
|
|
190
235
|
vis.forEach(function(c) {
|
|
191
|
-
|
|
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;
|
|
192
239
|
});
|
|
193
240
|
let pinOffsets = {}, acc = 0;
|
|
194
241
|
vis.forEach(function(c) {
|
|
@@ -199,13 +246,17 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
199
246
|
});
|
|
200
247
|
const selW = selectable ? " + var(--aura-table-select-width)" : "";
|
|
201
248
|
const gutterR = controls ? "var(--aura-space-12)" : "var(--aura-space-6)";
|
|
202
|
-
const rowMinWidth = "calc(" + fixedSum + "px + var(--aura-space-6) + " + gutterR + selW + ")";
|
|
249
|
+
const rowMinWidth = "calc(" + fixedSum + "px" + hideTerms + " + var(--aura-space-6) + " + gutterR + selW + ")";
|
|
203
250
|
function cellStyle(c, i) {
|
|
204
|
-
|
|
205
|
-
if (w == null)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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)";
|
|
209
260
|
return s;
|
|
210
261
|
}
|
|
211
262
|
const view = React.useMemo(
|
|
@@ -288,7 +339,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
288
339
|
return rowHref ? /* @__PURE__ */ React.createElement(Link, { href: rowHref(r), className: "aura-table__row-link" }, content) : content;
|
|
289
340
|
}
|
|
290
341
|
const height = props.height || 0;
|
|
291
|
-
const virtual = !!height && !loading && pageRows.length > 0;
|
|
342
|
+
const virtual = !!height && !loading && pageRows.length > 0 && !stacked;
|
|
292
343
|
const bodyH = Math.max(ROW_H, height - ROW_H);
|
|
293
344
|
let start = 0, end = pageRows.length;
|
|
294
345
|
if (virtual) {
|
|
@@ -643,7 +694,8 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
643
694
|
label: all ? t.deselectAllRows : t.selectAllRows,
|
|
644
695
|
onChange: toggleAll
|
|
645
696
|
}
|
|
646
|
-
) : 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)
|
|
647
699
|
)
|
|
648
700
|
);
|
|
649
701
|
vis.forEach(function(c, i) {
|
|
@@ -661,6 +713,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
661
713
|
"aria-sort": ariaSort,
|
|
662
714
|
"aria-colindex": ci + 1,
|
|
663
715
|
style: cellStyle(c, i),
|
|
716
|
+
"data-hide": hideLevel(c) ? String(hideLevel(c)) : void 0,
|
|
664
717
|
tabIndex: tabFor(0, ci),
|
|
665
718
|
"data-rc": "0:" + ci,
|
|
666
719
|
className: cx(
|
|
@@ -817,6 +870,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
817
870
|
pin && j === nPinned - 1 && "is-pin-edge"
|
|
818
871
|
),
|
|
819
872
|
style: cellStyle(c, j),
|
|
873
|
+
...cardAttrs(c, j),
|
|
820
874
|
onFocus: function() {
|
|
821
875
|
if (activeState[0].r !== ri || activeState[0].c !== ci) activeState[1]({ r: ri, c: ci });
|
|
822
876
|
}
|
|
@@ -825,6 +879,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
825
879
|
)
|
|
826
880
|
);
|
|
827
881
|
});
|
|
882
|
+
if (hasFields) cells.push(/* @__PURE__ */ React.createElement("span", { key: "__br", className: "aura-table__break", "aria-hidden": true }));
|
|
828
883
|
cells.push(
|
|
829
884
|
/* @__PURE__ */ React.createElement(
|
|
830
885
|
"span",
|
|
@@ -838,7 +893,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
838
893
|
return cells;
|
|
839
894
|
}
|
|
840
895
|
let body;
|
|
841
|
-
const rowStyle = {
|
|
896
|
+
const rowStyle = { ["--aura-row-min"]: rowMinWidth };
|
|
842
897
|
if (loading) {
|
|
843
898
|
const n = pageSize || props.skeletonRows || 5;
|
|
844
899
|
const skRows = body = [];
|
|
@@ -855,7 +910,9 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
855
910
|
{
|
|
856
911
|
key: c.key,
|
|
857
912
|
className: cx("aura-table__td", c.align === "end" && "is-end", isPinned(c) && "is-pinned"),
|
|
858
|
-
style: cellStyle(c, j)
|
|
913
|
+
style: cellStyle(c, j),
|
|
914
|
+
...cardAttrs(c, j),
|
|
915
|
+
"data-label": void 0
|
|
859
916
|
},
|
|
860
917
|
/* @__PURE__ */ React.createElement(
|
|
861
918
|
"span",
|
|
@@ -867,6 +924,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
867
924
|
)
|
|
868
925
|
);
|
|
869
926
|
});
|
|
927
|
+
if (hasFields) sk.push(/* @__PURE__ */ React.createElement("span", { key: "__br", className: "aura-table__break" }));
|
|
870
928
|
sk.push(
|
|
871
929
|
/* @__PURE__ */ React.createElement("span", { key: "__gr", className: cx("aura-table__gutter aura-table__gutter--end", controls && "has-picker") })
|
|
872
930
|
);
|
|
@@ -952,102 +1010,6 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
952
1010
|
} else if (height && rows.length && !loading) {
|
|
953
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));
|
|
954
1012
|
}
|
|
955
|
-
function renderStacked(wrapRefArg) {
|
|
956
|
-
const titleCol = vis[0], pillCol = vis.filter(function(c) {
|
|
957
|
-
return c.pill && c !== titleCol;
|
|
958
|
-
})[0];
|
|
959
|
-
const actionCols = vis.filter(function(c) {
|
|
960
|
-
return c.actions && c !== titleCol;
|
|
961
|
-
});
|
|
962
|
-
const rest = vis.filter(function(c) {
|
|
963
|
-
return c !== titleCol && c !== pillCol && !c.actions;
|
|
964
|
-
});
|
|
965
|
-
let cardBody;
|
|
966
|
-
if (loading) {
|
|
967
|
-
cardBody = /* @__PURE__ */ React.createElement("ul", { className: "aura-table__cards", "aria-busy": true }, [0, 1, 2].map(function(i) {
|
|
968
|
-
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%" } }));
|
|
969
|
-
}));
|
|
970
|
-
} else if (!rows.length) {
|
|
971
|
-
const em2 = props.empty || {};
|
|
972
|
-
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));
|
|
973
|
-
} else {
|
|
974
|
-
const cellVal = cellContent;
|
|
975
|
-
cardBody = /* @__PURE__ */ React.createElement("ul", { className: "aura-table__cards", "aria-label": props.label }, pageRows.map(function(r) {
|
|
976
|
-
const k = r[rowKey], isSel = !!selSet[k];
|
|
977
|
-
return /* @__PURE__ */ React.createElement(
|
|
978
|
-
"li",
|
|
979
|
-
{
|
|
980
|
-
key: k,
|
|
981
|
-
className: cx(
|
|
982
|
-
"aura-table__card",
|
|
983
|
-
isSel && "is-selected",
|
|
984
|
-
(props.onRowActivate || rowHref) && "is-actionable"
|
|
985
|
-
),
|
|
986
|
-
tabIndex: props.onRowActivate && !rowHref ? 0 : void 0,
|
|
987
|
-
onClick: function(e) {
|
|
988
|
-
const el = e.target;
|
|
989
|
-
if (el.closest && el.closest(".aura-check, button, a, input")) return;
|
|
990
|
-
if (rowHref) followRow(e.currentTarget, e);
|
|
991
|
-
else if (props.onRowActivate) props.onRowActivate(r);
|
|
992
|
-
},
|
|
993
|
-
onKeyDown: function(e) {
|
|
994
|
-
if (e.target === e.currentTarget && e.key === "Enter" && props.onRowActivate && !rowHref)
|
|
995
|
-
props.onRowActivate(r);
|
|
996
|
-
}
|
|
997
|
-
},
|
|
998
|
-
/* @__PURE__ */ React.createElement("div", { className: "aura-table__card-head" }, selectable ? /* @__PURE__ */ React.createElement(
|
|
999
|
-
Checkbox,
|
|
1000
|
-
{
|
|
1001
|
-
checked: isSel,
|
|
1002
|
-
label: t.selectRow(k),
|
|
1003
|
-
onChange: function(on) {
|
|
1004
|
-
toggle(k, on);
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
) : 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) {
|
|
1008
|
-
return /* @__PURE__ */ React.createElement("span", { key: c.key, className: "aura-table__card-actions" }, cellVal(c, r));
|
|
1009
|
-
})),
|
|
1010
|
-
rest.length ? /* @__PURE__ */ React.createElement("dl", { className: "aura-table__card-fields" }, rest.map(function(c) {
|
|
1011
|
-
return /* @__PURE__ */ React.createElement("div", { key: c.key }, /* @__PURE__ */ React.createElement("dt", null, c.label), /* @__PURE__ */ React.createElement("dd", { className: cx(c.mono && "aura-table__mono", c.align === "end" && "is-end") }, cellVal(c, r)));
|
|
1012
|
-
})) : null
|
|
1013
|
-
);
|
|
1014
|
-
}));
|
|
1015
|
-
}
|
|
1016
|
-
return /* @__PURE__ */ React.createElement(
|
|
1017
|
-
"div",
|
|
1018
|
-
{
|
|
1019
|
-
ref: wrapRefArg,
|
|
1020
|
-
"data-density": props.density,
|
|
1021
|
-
className: cx("aura-table aura-table--stacked", refreshing && "is-refreshing", props.className),
|
|
1022
|
-
onMouseOver: showFull,
|
|
1023
|
-
onMouseLeave: hideFull,
|
|
1024
|
-
onFocus: showFull,
|
|
1025
|
-
onBlur: hideFull,
|
|
1026
|
-
role: "region",
|
|
1027
|
-
"aria-label": props.label,
|
|
1028
|
-
"aria-busy": busy || void 0
|
|
1029
|
-
},
|
|
1030
|
-
refreshing ? /* @__PURE__ */ React.createElement("span", { className: "aura-table__busy-bar", "aria-hidden": true }) : null,
|
|
1031
|
-
selectable && pageRows.length && !busy ? /* @__PURE__ */ React.createElement("div", { className: "aura-table__stack-bar" }, /* @__PURE__ */ React.createElement(
|
|
1032
|
-
Checkbox,
|
|
1033
|
-
{
|
|
1034
|
-
checked: all,
|
|
1035
|
-
indeterminate: nSel > 0 && !all,
|
|
1036
|
-
label: all ? t.deselectAllRows : t.selectAllRows,
|
|
1037
|
-
onChange: toggleAll
|
|
1038
|
-
}
|
|
1039
|
-
), /* @__PURE__ */ React.createElement("span", null, nSel ? t.selectedCount(nSel) : t.selectAll)) : null,
|
|
1040
|
-
cardBody,
|
|
1041
|
-
props.footer && rows.length && !loading ? /* @__PURE__ */ React.createElement("div", { className: "aura-table__card aura-table__card--total", role: "group", "aria-label": t.totals }, /* @__PURE__ */ React.createElement("dl", { className: "aura-table__card-fields" }, vis.filter(function(c) {
|
|
1042
|
-
return props.footer[c.key] != null;
|
|
1043
|
-
}).map(function(c) {
|
|
1044
|
-
return /* @__PURE__ */ React.createElement("div", { key: c.key }, /* @__PURE__ */ React.createElement("dt", null, c.label || t.totals), /* @__PURE__ */ React.createElement("dd", { className: cx(c.mono && "aura-table__mono", c.align === "end" && "is-end") }, props.footer[c.key]));
|
|
1045
|
-
}))) : null,
|
|
1046
|
-
foot,
|
|
1047
|
-
tipEl
|
|
1048
|
-
);
|
|
1049
|
-
}
|
|
1050
|
-
if (stacked) return renderStacked(wrapMerged);
|
|
1051
1013
|
const totalRow = props.footer && rows.length && !loading ? /* @__PURE__ */ React.createElement(
|
|
1052
1014
|
"div",
|
|
1053
1015
|
{
|
|
@@ -1072,13 +1034,17 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1072
1034
|
c.mono && "aura-table__mono",
|
|
1073
1035
|
c.align === "end" && "is-end",
|
|
1074
1036
|
pin && "is-pinned",
|
|
1075
|
-
pin && j === nPinned - 1 && "is-pin-edge"
|
|
1037
|
+
pin && j === nPinned - 1 && "is-pin-edge",
|
|
1038
|
+
props.footer[c.key] == null && "is-blank"
|
|
1076
1039
|
),
|
|
1077
|
-
style: cellStyle(c, j)
|
|
1040
|
+
style: cellStyle(c, j),
|
|
1041
|
+
...cardAttrs(c, j),
|
|
1042
|
+
"data-label": j === 0 ? void 0 : c.label || t.totals
|
|
1078
1043
|
},
|
|
1079
1044
|
props.footer[c.key]
|
|
1080
1045
|
);
|
|
1081
1046
|
}),
|
|
1047
|
+
hasFields ? /* @__PURE__ */ React.createElement("span", { className: "aura-table__break", "aria-hidden": true }) : null,
|
|
1082
1048
|
/* @__PURE__ */ React.createElement(
|
|
1083
1049
|
"span",
|
|
1084
1050
|
{
|
|
@@ -1091,13 +1057,20 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1091
1057
|
scrollPaddingLeft: "calc(var(--aura-space-6)" + selW + " + " + acc + "px)",
|
|
1092
1058
|
scrollPaddingTop: ROW_H + "px"
|
|
1093
1059
|
};
|
|
1094
|
-
if (height) scrollStyle
|
|
1060
|
+
if (height) scrollStyle["--aura-table-h"] = height + "px";
|
|
1095
1061
|
const gridEl = /* @__PURE__ */ React.createElement(
|
|
1096
1062
|
"div",
|
|
1097
1063
|
{
|
|
1098
|
-
ref:
|
|
1064
|
+
ref: levels.length ? wrapRef : wrapMerged,
|
|
1099
1065
|
"data-density": props.density,
|
|
1100
|
-
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
|
|
1101
1074
|
},
|
|
1102
1075
|
refreshing ? /* @__PURE__ */ React.createElement("span", { className: "aura-table__busy-bar", "aria-hidden": true }) : null,
|
|
1103
1076
|
/* @__PURE__ */ React.createElement(
|
|
@@ -1129,7 +1102,16 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1129
1102
|
if (sx !== scrolledX[0]) scrolledX[1](sx);
|
|
1130
1103
|
}
|
|
1131
1104
|
},
|
|
1132
|
-
/* @__PURE__ */ React.createElement(
|
|
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
|
+
),
|
|
1133
1115
|
body,
|
|
1134
1116
|
totalRow
|
|
1135
1117
|
),
|
|
@@ -1157,8 +1139,20 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1157
1139
|
) : null,
|
|
1158
1140
|
tipEl
|
|
1159
1141
|
);
|
|
1160
|
-
if (!
|
|
1161
|
-
|
|
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);
|
|
1162
1156
|
});
|
|
1163
1157
|
export {
|
|
1164
1158
|
DataTable
|
package/dist/esm/DatePicker.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
dateText,
|
|
14
14
|
defaultCalendar,
|
|
15
15
|
fmt,
|
|
16
|
-
formatDate,
|
|
16
|
+
formatDate as formatDateBase,
|
|
17
17
|
fromISO,
|
|
18
18
|
localeTag,
|
|
19
19
|
parseDate,
|
|
@@ -21,13 +21,13 @@ import {
|
|
|
21
21
|
toISO,
|
|
22
22
|
todayIn
|
|
23
23
|
} from "./dates.js";
|
|
24
|
-
import { formatDate
|
|
24
|
+
import { formatDate, parseDate as parseDate2 } from "./dates.js";
|
|
25
25
|
function useFormatDate() {
|
|
26
26
|
const ctx = useAuraLocale(), locale = ctx.locale || "en", calendar = ctx.calendar;
|
|
27
27
|
return React.useCallback(
|
|
28
28
|
function(iso, opts) {
|
|
29
29
|
const o = opts || {}, loc = o.locale || locale;
|
|
30
|
-
return
|
|
30
|
+
return formatDateBase(
|
|
31
31
|
iso,
|
|
32
32
|
Object.assign({}, o, {
|
|
33
33
|
locale: loc,
|
|
@@ -459,7 +459,7 @@ const DatePicker = React.forwardRef(function DatePicker2(props, ref) {
|
|
|
459
459
|
boxRef,
|
|
460
460
|
inputRef: inputMerged,
|
|
461
461
|
open: pop.open,
|
|
462
|
-
display:
|
|
462
|
+
display: formatDateBase(st[0], { locale, calendar }),
|
|
463
463
|
placeholder: props.placeholder || dt.datePlaceholder,
|
|
464
464
|
hasValue: st[0] != null,
|
|
465
465
|
clearable: props.clearable,
|
|
@@ -493,8 +493,8 @@ const DateRangePicker = React.forwardRef(
|
|
|
493
493
|
const o = { locale, calendar };
|
|
494
494
|
function show(r) {
|
|
495
495
|
if (!r.start) return "";
|
|
496
|
-
if (!r.end) return
|
|
497
|
-
return
|
|
496
|
+
if (!r.end) return formatDateBase(r.start, o) + " \u2013";
|
|
497
|
+
return formatDateBase(r.start, o) + " \u2013 " + formatDateBase(r.end, o);
|
|
498
498
|
}
|
|
499
499
|
function commit(text) {
|
|
500
500
|
const parts = String(text).split(/\s[–-]\s|\s*–\s*/);
|
|
@@ -599,7 +599,7 @@ export {
|
|
|
599
599
|
Calendar,
|
|
600
600
|
DatePicker,
|
|
601
601
|
DateRangePicker,
|
|
602
|
-
|
|
602
|
+
formatDate,
|
|
603
603
|
parseDate2 as parseDate,
|
|
604
604
|
useFormatDate
|
|
605
605
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cx } from "./internal.js";
|
|
4
|
+
const Separator = React.forwardRef(function Separator2(props, ref) {
|
|
5
|
+
const vertical = props.orientation === "vertical";
|
|
6
|
+
const decorative = props.decorative !== false;
|
|
7
|
+
return /* @__PURE__ */ React.createElement(
|
|
8
|
+
"div",
|
|
9
|
+
{
|
|
10
|
+
ref,
|
|
11
|
+
className: cx("aura-separator", vertical && "aura-separator--vertical", props.className),
|
|
12
|
+
role: decorative ? "none" : "separator",
|
|
13
|
+
"aria-orientation": !decorative && vertical ? "vertical" : void 0,
|
|
14
|
+
style: props.spacing != null ? { ["--aura-separator-space"]: "var(--aura-space-" + props.spacing + ")" } : void 0
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
Separator
|
|
20
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cx, uid, useIsoLayoutEffect } from "./internal.js";
|
|
4
|
+
const Table = React.forwardRef(function Table2(props, ref) {
|
|
5
|
+
const { caption, captionHidden, density, className, children, ...rest } = props;
|
|
6
|
+
const capId = uid();
|
|
7
|
+
const wrap = React.useRef(null);
|
|
8
|
+
const sc = React.useState(false), scrolls = sc[0];
|
|
9
|
+
useIsoLayoutEffect(function() {
|
|
10
|
+
const el = wrap.current;
|
|
11
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
12
|
+
function check() {
|
|
13
|
+
sc[1](el.scrollWidth > el.clientWidth + 1);
|
|
14
|
+
}
|
|
15
|
+
check();
|
|
16
|
+
const ro = new ResizeObserver(check);
|
|
17
|
+
ro.observe(el);
|
|
18
|
+
return function() {
|
|
19
|
+
ro.disconnect();
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
return /* @__PURE__ */ React.createElement(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
ref: wrap,
|
|
26
|
+
className: "aura-tbl-wrap",
|
|
27
|
+
"data-density": density,
|
|
28
|
+
tabIndex: scrolls ? 0 : void 0,
|
|
29
|
+
role: scrolls ? "region" : void 0,
|
|
30
|
+
"aria-labelledby": scrolls && caption != null ? capId : void 0
|
|
31
|
+
},
|
|
32
|
+
/* @__PURE__ */ React.createElement("table", { ref, className: cx("aura-tbl", className), ...rest }, caption != null ? /* @__PURE__ */ React.createElement("caption", { id: capId, className: cx("aura-tbl__caption", captionHidden && "aura-sr-only") }, caption) : null, children)
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
function section(tag, cls) {
|
|
36
|
+
const C = React.forwardRef(function TableSection(props, ref) {
|
|
37
|
+
const { className, ...rest } = props;
|
|
38
|
+
return React.createElement(tag, Object.assign({ ref, className: cx(cls, className) }, rest));
|
|
39
|
+
});
|
|
40
|
+
return C;
|
|
41
|
+
}
|
|
42
|
+
const THead = section("thead", "aura-tbl__head");
|
|
43
|
+
THead.displayName = "THead";
|
|
44
|
+
const TBody = section("tbody", "aura-tbl__body");
|
|
45
|
+
TBody.displayName = "TBody";
|
|
46
|
+
const TFoot = section("tfoot", "aura-tbl__foot");
|
|
47
|
+
TFoot.displayName = "TFoot";
|
|
48
|
+
const Tr = React.forwardRef(function Tr2(props, ref) {
|
|
49
|
+
const { className, ...rest } = props;
|
|
50
|
+
return /* @__PURE__ */ React.createElement("tr", { ref, className: cx("aura-tbl__row", className), ...rest });
|
|
51
|
+
});
|
|
52
|
+
function cellClass(base, p) {
|
|
53
|
+
const align = p.align || (p.numeric ? "end" : void 0);
|
|
54
|
+
return cx(
|
|
55
|
+
base,
|
|
56
|
+
align === "end" && "is-end",
|
|
57
|
+
align === "center" && "is-center",
|
|
58
|
+
p.numeric && "is-numeric",
|
|
59
|
+
p.mono && "aura-table__mono",
|
|
60
|
+
p.className
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
const Th = React.forwardRef(function Th2(props, ref) {
|
|
64
|
+
const { align, numeric, mono, className, scope, ...rest } = props;
|
|
65
|
+
return /* @__PURE__ */ React.createElement("th", { ref, scope: scope || "col", className: cellClass("aura-tbl__th", props), ...rest });
|
|
66
|
+
});
|
|
67
|
+
const Td = React.forwardRef(function Td2(props, ref) {
|
|
68
|
+
const { align, numeric, mono, className, scope, ...rest } = props;
|
|
69
|
+
return /* @__PURE__ */ React.createElement("td", { ref, className: cellClass("aura-tbl__td", props), ...rest });
|
|
70
|
+
});
|
|
71
|
+
export {
|
|
72
|
+
TBody,
|
|
73
|
+
TFoot,
|
|
74
|
+
THead,
|
|
75
|
+
Table,
|
|
76
|
+
Td,
|
|
77
|
+
Th,
|
|
78
|
+
Tr
|
|
79
|
+
};
|
package/dist/esm/Tooltip.js
CHANGED
|
@@ -23,9 +23,27 @@ const Tooltip = React.forwardRef(function Tooltip2(props, ref) {
|
|
|
23
23
|
function() {
|
|
24
24
|
if (!open || !anchor.current || !tip.current) return;
|
|
25
25
|
const r = anchor.current.getBoundingClientRect(), t = tip.current.getBoundingClientRect();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const vw = window.innerWidth, vh = window.innerHeight, gap = 8, m = 8;
|
|
27
|
+
let side = props.side || "top";
|
|
28
|
+
if (side === "top" && r.top - t.height - gap < m && r.bottom + gap + t.height <= vh - m) side = "bottom";
|
|
29
|
+
else if (side === "bottom" && r.bottom + gap + t.height > vh - m && r.top - t.height - gap >= m) side = "top";
|
|
30
|
+
else if (side === "left" && r.left - t.width - gap < m && r.right + gap + t.width <= vw - m) side = "right";
|
|
31
|
+
else if (side === "right" && r.right + gap + t.width > vw - m && r.left - t.width - gap >= m) side = "left";
|
|
32
|
+
const clampX = function(x) {
|
|
33
|
+
return Math.max(m, Math.min(x, vw - t.width - m));
|
|
34
|
+
};
|
|
35
|
+
const clampY = function(y) {
|
|
36
|
+
return Math.max(m, Math.min(y, vh - t.height - m));
|
|
37
|
+
};
|
|
38
|
+
let top, left;
|
|
39
|
+
if (side === "top" || side === "bottom") {
|
|
40
|
+
top = side === "top" ? r.top - t.height - gap : r.bottom + gap;
|
|
41
|
+
left = clampX(r.left + r.width / 2 - t.width / 2);
|
|
42
|
+
} else {
|
|
43
|
+
left = side === "left" ? r.left - t.width - gap : r.right + gap;
|
|
44
|
+
left = clampX(left);
|
|
45
|
+
top = clampY(r.top + r.height / 2 - t.height / 2);
|
|
46
|
+
}
|
|
29
47
|
pos[1]({ top, left });
|
|
30
48
|
},
|
|
31
49
|
[open]
|
package/dist/esm/dates.js
CHANGED
|
@@ -101,7 +101,7 @@ function formatDate(iso, opts) {
|
|
|
101
101
|
const o = opts || {}, d = fromISO(iso);
|
|
102
102
|
if (!d) return "";
|
|
103
103
|
const f = typeof o.format === "object" ? o.format : PRESETS[o.format || "short"];
|
|
104
|
-
const loc = o.locale || "
|
|
104
|
+
const loc = o.locale || "en";
|
|
105
105
|
return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
|
|
106
106
|
}
|
|
107
107
|
let MONTHS = null;
|
package/dist/esm/index.js
CHANGED
|
@@ -34,6 +34,8 @@ import { Grid } from "./Grid.js";
|
|
|
34
34
|
import { Container } from "./Container.js";
|
|
35
35
|
import { AppShell } from "./AppShell.js";
|
|
36
36
|
import { ActionBar } from "./ActionBar.js";
|
|
37
|
+
import { Separator } from "./Separator.js";
|
|
38
|
+
import { Table, THead, TBody, TFoot, Tr, Th, Td } from "./Table.js";
|
|
37
39
|
import { BottomNav } from "./BottomNav.js";
|
|
38
40
|
import { useBreakpoint, useResponsive, breakpoints } from "./responsive.js";
|
|
39
41
|
import { Surface } from "./Surface.js";
|
|
@@ -99,6 +101,7 @@ export {
|
|
|
99
101
|
STRINGS,
|
|
100
102
|
SegmentedControl,
|
|
101
103
|
Select,
|
|
104
|
+
Separator,
|
|
102
105
|
SideNav,
|
|
103
106
|
Skeleton,
|
|
104
107
|
Stack,
|
|
@@ -107,14 +110,21 @@ export {
|
|
|
107
110
|
Stepper,
|
|
108
111
|
Surface,
|
|
109
112
|
Switch,
|
|
113
|
+
TBody,
|
|
114
|
+
TFoot,
|
|
115
|
+
THead,
|
|
116
|
+
Table,
|
|
110
117
|
Tabs,
|
|
111
118
|
Tag,
|
|
119
|
+
Td,
|
|
112
120
|
TextField,
|
|
113
121
|
Textarea,
|
|
122
|
+
Th,
|
|
114
123
|
ThemeStyle,
|
|
115
124
|
TimePicker,
|
|
116
125
|
Toaster,
|
|
117
126
|
Tooltip,
|
|
127
|
+
Tr,
|
|
118
128
|
scale as brandScale,
|
|
119
129
|
breakpoints,
|
|
120
130
|
colorSchemeScript,
|