@lincyaw/aegis-ui 0.22.0 → 0.23.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.
@@ -1,6 +1,6 @@
1
1
  import { jsxs as d, jsx as a } from "react/jsx-runtime";
2
- import { useId as Ye, useState as H, useMemo as Je, useContext as Ze, useRef as de, Fragment as Ke } from "react";
3
- import { RightOutlined as oe } from "@ant-design/icons";
2
+ import { useId as Ye, useState as H, useMemo as Je, useContext as Ze, useRef as oe, Fragment as Ke } from "react";
3
+ import { RightOutlined as de } from "@ant-design/icons";
4
4
  import { usePrimitiveSurface as et } from "../../agent/core/usePrimitiveSurface.js";
5
5
  import { useDevelopAfterLoad as tt } from "../../hooks/useDevelopAfterLoad.js";
6
6
  import { useMediaQuery as at } from "../../hooks/useMediaQuery.js";
@@ -9,33 +9,33 @@ import { Checkbox as re } from "./Checkbox.js";
9
9
  import { EmptyState as lt } from "./EmptyState.js";
10
10
  import { Pagination as st } from "./Pagination.js";
11
11
  import { SkeletonText as it, Skeleton as nt } from "./Skeleton.js";
12
- import { SelectedRowDetailContext as dt } from "./selectedRowDetail.js";
13
- import { useColumnWidths as ot } from "./useColumnWidths.js";
12
+ import { SelectedRowDetailContext as ot } from "./selectedRowDetail.js";
13
+ import { useColumnWidths as dt } from "./useColumnWidths.js";
14
14
  import { useStrings as rt } from "../../locale/useStrings.js";
15
15
  const T = 44, z = 32, ce = 40, ct = "var(--aegis-data-table-pinned-max)", _t = "(max-width: 768px)", gt = 'a, button, input, select, textarea, label, [role="button"], [role="link"], [role="checkbox"]';
16
- function ht(s) {
16
+ function ut(s) {
17
17
  if (window.getSelection()?.type === "Range")
18
18
  return !0;
19
- const g = s.target;
20
- if (!(g instanceof Element))
19
+ const u = s.target;
20
+ if (!(u instanceof Element))
21
21
  return !1;
22
- const y = g.closest(gt);
22
+ const y = u.closest(gt);
23
23
  return y !== null && s.currentTarget.contains(y);
24
24
  }
25
- function ut(s, g, y) {
26
- const $ = g?.sortValue;
25
+ function ht(s, u, y) {
26
+ const $ = u?.sortValue;
27
27
  if (!$)
28
28
  return s;
29
29
  const k = y === "asc" ? 1 : -1;
30
- return s.map((i, o) => {
31
- const p = $(i);
32
- return { row: i, index: o, v: typeof p == "number" && isNaN(p) ? null : p };
33
- }).sort((i, o) => {
34
- if (i.v === null || o.v === null)
35
- return i.v === o.v ? i.index - o.index : i.v === null ? 1 : -1;
36
- const p = typeof i.v == "number" && typeof o.v == "number" ? i.v - o.v : String(i.v).localeCompare(String(o.v));
37
- return p === 0 ? i.index - o.index : p * k;
38
- }).map((i) => i.row);
30
+ return s.map((n, r) => {
31
+ const p = $(n);
32
+ return { row: n, index: r, v: typeof p == "number" && isNaN(p) ? null : p };
33
+ }).sort((n, r) => {
34
+ if (n.v === null || r.v === null)
35
+ return n.v === r.v ? n.index - r.index : n.v === null ? 1 : -1;
36
+ const p = typeof n.v == "number" && typeof r.v == "number" ? n.v - r.v : String(n.v).localeCompare(String(r.v));
37
+ return p === 0 ? n.index - r.index : p * k;
38
+ }).map((n) => n.row);
39
39
  }
40
40
  function bt({
41
41
  direction: s
@@ -67,23 +67,23 @@ function bt({
67
67
  }
68
68
  function Dt({
69
69
  columns: s,
70
- data: g,
70
+ data: u,
71
71
  rowKey: y,
72
72
  ariaLabel: $,
73
73
  loading: k = !1,
74
- emptyTitle: i,
75
- emptyDescription: o,
74
+ emptyTitle: n,
75
+ emptyDescription: r,
76
76
  emptyAction: p,
77
77
  className: _e,
78
78
  framed: ge = !0,
79
- density: he = "default",
79
+ density: ue = "default",
80
80
  header: U = "filled",
81
- appearance: ue = "table",
81
+ appearance: he = "table",
82
82
  blockSeparator: be = "gap",
83
83
  rowTone: me,
84
84
  persistKey: pe,
85
85
  pagination: V,
86
- selectable: r = !1,
86
+ selectable: c = !1,
87
87
  selectedKeys: q,
88
88
  onSelectedKeysChange: G,
89
89
  renderExpanded: Q,
@@ -99,16 +99,16 @@ function Dt({
99
99
  onSortChange: ke,
100
100
  surface: we
101
101
  }) {
102
- const w = rt(), Ce = at(_t), Se = Ye(), n = ue === "blocks", f = X !== void 0 && Ce && !n, xe = tt(k), [Re, $e] = H(Ne ?? null), h = j === void 0 ? Re : j, J = s.find((e) => e.key === h?.key), I = Je(
103
- () => ut(g, J, h?.direction ?? "asc"),
104
- [g, J, h?.direction]
102
+ const w = rt(), Ce = at(_t), Se = Ye(), i = he === "blocks", f = X !== void 0 && Ce && !i, xe = tt(k), [Re, $e] = H(Ne ?? null), h = j === void 0 ? Re : j, J = s.find((e) => e.key === h?.key), I = Je(
103
+ () => ht(u, J, h?.direction ?? "asc"),
104
+ [u, J, h?.direction]
105
105
  ), Ee = (e) => {
106
106
  const t = e.firstSortDirection ?? (e.numeric ? "desc" : "asc"), l = {
107
107
  key: e.key,
108
108
  direction: h?.key === e.key ? h.direction === "asc" ? "desc" : "asc" : t
109
109
  };
110
110
  j === void 0 && $e(l), ke?.(l);
111
- }, C = q ?? [], N = I.map((e, t) => y(e, t)), M = Ze(dt), Z = N.find((e) => C.includes(e)), A = N.filter((e) => C.includes(e)).length, De = (e, t) => {
111
+ }, C = q ?? [], N = I.map((e, t) => y(e, t)), M = Ze(ot), Z = N.find((e) => C.includes(e)), A = N.filter((e) => C.includes(e)).length, De = (e, t) => {
112
112
  G?.(
113
113
  t ? [...C, e] : C.filter((l) => l !== e)
114
114
  );
@@ -127,7 +127,7 @@ function Dt({
127
127
  const Me = (e) => {
128
128
  const t = v.includes(e) ? v.filter((l) => l !== e) : [...v, e];
129
129
  F === void 0 && je(t), ve?.(t);
130
- }, ee = de(null), te = de(null), Ae = et(we, g, "table", te), u = Q !== void 0, c = O !== void 0, E = (r ? T : 0) + (u ? z : 0), Be = c ? ce : 0, R = ye && !f, S = ot({
130
+ }, ee = oe(null), te = oe(null), Ae = et(we, u, "table", te), b = Q !== void 0, _ = O !== void 0, E = (c ? T : 0) + (b ? z : 0), Be = _ ? ce : 0, R = ye && !f, S = dt({
131
131
  columns: s,
132
132
  persistKey: pe,
133
133
  leadWidth: E,
@@ -137,14 +137,14 @@ function Dt({
137
137
  }), Pe = [
138
138
  "aegis-data-table",
139
139
  ge ? "aegis-data-table--framed" : "",
140
- he === "compact" ? "aegis-data-table--compact" : "",
140
+ ue === "compact" ? "aegis-data-table--compact" : "",
141
141
  U === "plain" ? "aegis-data-table--plain-header" : "",
142
- U === "hidden" || n ? "aegis-data-table--hidden-header" : "",
143
- n ? "aegis-data-table--blocks" : "",
144
- n && be === "rule" ? "aegis-data-table--block-rule" : "",
142
+ U === "hidden" || i ? "aegis-data-table--hidden-header" : "",
143
+ i ? "aegis-data-table--blocks" : "",
144
+ i && be === "rule" ? "aegis-data-table--block-rule" : "",
145
145
  Y ? "aegis-data-table--stale" : "",
146
146
  _e ?? ""
147
- ].filter(Boolean).join(" "), D = S.sized && !f && !n, L = D && S.fillerStyle !== void 0, ae = (f ? 1 : s.length) + (L ? 1 : 0) + (c ? 1 : 0), We = ae + (r ? 1 : 0) + (u ? 1 : 0), He = r ? T : 0, x = (e, t) => ({
147
+ ].filter(Boolean).join(" "), D = S.sized && !f && !i, L = D && S.fillerStyle !== void 0, ae = (f ? 1 : s.length) + (L ? 1 : 0) + (_ ? 1 : 0), We = ae + (c ? 1 : 0) + (b ? 1 : 0), He = c ? T : 0, x = (e, t) => ({
148
148
  className: [
149
149
  `aegis-data-table__${t}`,
150
150
  `aegis-data-table__${e}-cell`,
@@ -155,13 +155,13 @@ function Dt({
155
155
  left: R ? e === "select" ? 0 : He : void 0
156
156
  }
157
157
  }), P = (e, t, l) => {
158
- const _ = `aegis-data-table__${e}`, b = [_];
159
- R && t === 0 && b.push(`${_}--sticky`, `${_}--pinned`);
158
+ const g = `aegis-data-table__${e}`, o = [g];
159
+ R && t === 0 && o.push(`${g}--sticky`, `${g}--pinned`);
160
160
  const m = s[t]?.block;
161
- return n && m !== void 0 && m !== "inline" && b.push(`${_}--${m}`), l !== void 0 && (b.push(
161
+ return i && m !== void 0 && m !== "inline" && o.push(`${g}--${m}`), l !== void 0 && (o.push(
162
162
  "aegis-data-table__td--tone",
163
163
  `aegis-data-table__td--tone-${l.tone}`
164
- ), l.step !== void 0 && l.step > 1 && b.push(`aegis-data-table__td--step-${String(l.step)}`)), b.join(" ");
164
+ ), l.step !== void 0 && l.step > 1 && o.push(`aegis-data-table__td--step-${String(l.step)}`)), o.join(" ");
165
165
  }, le = (e) => e.kind === "actions" || e.numeric === !0 ? "right" : e.align ?? "left", W = (e, t) => ({
166
166
  textAlign: le(e),
167
167
  left: R && t === 0 ? E : void 0
@@ -171,19 +171,22 @@ function Dt({
171
171
  `aegis-data-table__cell--${le(e)}`
172
172
  ];
173
173
  return e.numeric && l.push("aegis-data-table__cell--numeric"), e.kind === "actions" ? l.push("aegis-data-table__cell--actions") : (e.truncate ?? !0) && l.push("aegis-data-table__cell--truncate"), /* @__PURE__ */ a("div", { className: l.join(" "), children: t });
174
- }, ze = (e, t) => f ? /* @__PURE__ */ a("td", { className: "aegis-data-table__td aegis-data-table__card-cell", children: X(e, t) }) : s.map((l, _) => /* @__PURE__ */ d(
175
- "td",
176
- {
177
- role: n ? "cell" : void 0,
178
- className: P("td", _, l.cellTone?.(e, t)),
179
- style: W(l, _),
180
- children: [
181
- n && l.blockLabel ? /* @__PURE__ */ a("span", { className: "aegis-data-table__block-label", "aria-hidden": !0, children: l.header }) : null,
182
- se(l, l.render(e, t))
183
- ]
184
- },
185
- l.key
186
- )), Ue = () => f ? /* @__PURE__ */ a("td", { className: "aegis-data-table__td aegis-data-table__card-cell", children: /* @__PURE__ */ a(it, { lines: 2 }) }) : s.map((e, t) => /* @__PURE__ */ a(
174
+ }, ze = (e, t) => f ? /* @__PURE__ */ a("td", { className: "aegis-data-table__td aegis-data-table__card-cell", children: X(e, t) }) : s.map((l, g) => {
175
+ const o = l.render(e, t);
176
+ return i && o == null ? null : /* @__PURE__ */ d(
177
+ "td",
178
+ {
179
+ role: i ? "cell" : void 0,
180
+ className: P("td", g, l.cellTone?.(e, t)),
181
+ style: W(l, g),
182
+ children: [
183
+ i && l.blockLabel ? /* @__PURE__ */ a("span", { className: "aegis-data-table__block-label", "aria-hidden": !0, children: l.header }) : null,
184
+ se(l, o)
185
+ ]
186
+ },
187
+ l.key
188
+ );
189
+ }), Ue = () => f ? /* @__PURE__ */ a("td", { className: "aegis-data-table__td aegis-data-table__card-cell", children: /* @__PURE__ */ a(it, { lines: 2 }) }) : s.map((e, t) => /* @__PURE__ */ a(
187
190
  "td",
188
191
  {
189
192
  className: P("td", t),
@@ -194,12 +197,12 @@ function Dt({
194
197
  )
195
198
  },
196
199
  e.key
197
- )), ie = L && /* @__PURE__ */ a("td", { className: "aegis-data-table__td aegis-data-table__filler", "aria-hidden": !0 }), Ve = c && /* @__PURE__ */ a(
200
+ )), ie = L && /* @__PURE__ */ a("td", { className: "aegis-data-table__td aegis-data-table__filler", "aria-hidden": !0 }), Ve = _ && /* @__PURE__ */ a(
198
201
  "td",
199
202
  {
200
203
  className: "aegis-data-table__td aegis-data-table__chevron-cell",
201
204
  "aria-hidden": !0,
202
- children: /* @__PURE__ */ a(oe, { className: "aegis-data-table__chevron", "aria-hidden": !0 })
205
+ children: /* @__PURE__ */ a(de, { className: "aegis-data-table__chevron", "aria-hidden": !0 })
203
206
  }
204
207
  ), qe = (e, t) => {
205
208
  const l = v.includes(e);
@@ -214,7 +217,7 @@ function Dt({
214
217
  onClick: () => {
215
218
  Me(e);
216
219
  },
217
- children: /* @__PURE__ */ a(oe, { className: "aegis-data-table__toggle-icon", "aria-hidden": !0 })
220
+ children: /* @__PURE__ */ a(de, { className: "aegis-data-table__toggle-icon", "aria-hidden": !0 })
218
221
  }
219
222
  );
220
223
  }, ne = (e, t, l) => /* @__PURE__ */ d(
@@ -222,8 +225,8 @@ function Dt({
222
225
  {
223
226
  className: e ? "aegis-data-table__detail-row aegis-data-table__detail-row--open" : "aegis-data-table__detail-row",
224
227
  children: [
225
- r && /* @__PURE__ */ a("td", { className: "aegis-data-table__detail-cell" }),
226
- u && /* @__PURE__ */ a("td", { className: "aegis-data-table__detail-cell" }),
228
+ c && /* @__PURE__ */ a("td", { className: "aegis-data-table__detail-cell" }),
229
+ b && /* @__PURE__ */ a("td", { className: "aegis-data-table__detail-cell" }),
227
230
  /* @__PURE__ */ a(
228
231
  "td",
229
232
  {
@@ -246,14 +249,14 @@ function Dt({
246
249
  ]
247
250
  }
248
251
  ), Ge = (e, t, l) => {
249
- ht(e) || O?.(t, l);
252
+ ut(e) || O?.(t, l);
250
253
  }, Qe = (e, t, l) => {
251
254
  e.key === "Enter" && e.target === e.currentTarget && (e.preventDefault(), O?.(t, l));
252
255
  }, Fe = (e, t) => [
253
256
  "aegis-data-table__row",
254
- n && t !== void 0 ? `aegis-data-table__row--tone-${t}` : "",
255
- c ? "aegis-data-table__row--clickable" : "",
256
- u ? "aegis-data-table__row--expandable" : "",
257
+ i && t !== void 0 ? `aegis-data-table__row--tone-${t}` : "",
258
+ _ ? "aegis-data-table__row--clickable" : "",
259
+ b ? "aegis-data-table__row--expandable" : "",
257
260
  e ? "aegis-data-table__row--selected" : ""
258
261
  ].filter(Boolean).join(" "), Xe = [
259
262
  "aegis-data-table__table",
@@ -272,14 +275,14 @@ function Dt({
272
275
  "table",
273
276
  {
274
277
  ref: ee,
275
- role: n ? "table" : void 0,
278
+ role: i ? "table" : void 0,
276
279
  "aria-label": $,
277
280
  className: Xe,
278
281
  style: D ? S.tableStyle : void 0,
279
282
  children: [
280
283
  D && /* @__PURE__ */ d("colgroup", { children: [
281
- r && /* @__PURE__ */ a("col", { style: { width: T } }, "__select"),
282
- u && /* @__PURE__ */ a("col", { style: { width: z } }, "__toggle"),
284
+ c && /* @__PURE__ */ a("col", { style: { width: T } }, "__select"),
285
+ b && /* @__PURE__ */ a("col", { style: { width: z } }, "__toggle"),
283
286
  s.map((e, t) => {
284
287
  const l = S.widths[t];
285
288
  return /* @__PURE__ */ a(
@@ -299,10 +302,10 @@ function Dt({
299
302
  },
300
303
  "__filler"
301
304
  ),
302
- c && /* @__PURE__ */ a("col", { style: { width: ce } }, "__chevron")
305
+ _ && /* @__PURE__ */ a("col", { style: { width: ce } }, "__chevron")
303
306
  ] }),
304
- (!f || r) && /* @__PURE__ */ a("thead", { role: n ? "rowgroup" : void 0, children: /* @__PURE__ */ d("tr", { role: n ? "row" : void 0, children: [
305
- r && /* @__PURE__ */ a(
307
+ (!f || c) && /* @__PURE__ */ a("thead", { role: i ? "rowgroup" : void 0, children: /* @__PURE__ */ d("tr", { role: i ? "row" : void 0, children: [
308
+ c && /* @__PURE__ */ a(
306
309
  "th",
307
310
  {
308
311
  scope: "col",
@@ -319,7 +322,7 @@ function Dt({
319
322
  },
320
323
  "__select"
321
324
  ),
322
- u && /* @__PURE__ */ a(
325
+ b && /* @__PURE__ */ a(
323
326
  "th",
324
327
  {
325
328
  scope: "col",
@@ -331,7 +334,7 @@ function Dt({
331
334
  "th",
332
335
  {
333
336
  scope: "col",
334
- role: n ? "columnheader" : void 0,
337
+ role: i ? "columnheader" : void 0,
335
338
  "data-column-key": e.key,
336
339
  className: P("th", t),
337
340
  style: W(e, t),
@@ -382,7 +385,7 @@ function Dt({
382
385
  "aria-hidden": !0
383
386
  }
384
387
  ),
385
- c && /* @__PURE__ */ a(
388
+ _ && /* @__PURE__ */ a(
386
389
  "th",
387
390
  {
388
391
  scope: "col",
@@ -394,14 +397,14 @@ function Dt({
394
397
  /* @__PURE__ */ a(
395
398
  "tbody",
396
399
  {
397
- role: n ? "rowgroup" : void 0,
400
+ role: i ? "rowgroup" : void 0,
398
401
  "data-aegis-develop": xe || void 0,
399
402
  children: k ? Array.from({ length: 5 }).map((e, t) => /* @__PURE__ */ d("tr", { className: "aegis-data-table__row", children: [
400
- r && /* @__PURE__ */ a("td", { ...x("select", "td") }, "__select"),
401
- u && /* @__PURE__ */ a("td", { ...x("toggle", "td") }, "__toggle"),
403
+ c && /* @__PURE__ */ a("td", { ...x("select", "td") }, "__select"),
404
+ b && /* @__PURE__ */ a("td", { ...x("toggle", "td") }, "__toggle"),
402
405
  Ue(),
403
406
  ie,
404
- c && /* @__PURE__ */ a("td", { className: "aegis-data-table__td", "aria-hidden": !0 })
407
+ _ && /* @__PURE__ */ a("td", { className: "aegis-data-table__td", "aria-hidden": !0 })
405
408
  ] }, `sk-${t}`)) : I.length === 0 ? (
406
409
  // Not a data row, so an empty table has no rows to read.
407
410
  /* @__PURE__ */ a("tr", { role: "presentation", children: /* @__PURE__ */ a(
@@ -412,35 +415,35 @@ function Dt({
412
415
  children: /* @__PURE__ */ a("div", { className: "aegis-data-table__empty", children: /* @__PURE__ */ a(
413
416
  lt,
414
417
  {
415
- title: i ?? w.noData,
416
- description: o,
418
+ title: n ?? w.noData,
419
+ description: r,
417
420
  action: p
418
421
  }
419
422
  ) })
420
423
  }
421
424
  ) })
422
425
  ) : I.map((e, t) => {
423
- const l = y(e, t), _ = `${Se}-detail-${String(t)}`, b = C.includes(l);
426
+ const l = y(e, t), g = `${Se}-detail-${String(t)}`, o = C.includes(l);
424
427
  return /* @__PURE__ */ d(Ke, { children: [
425
428
  /* @__PURE__ */ d(
426
429
  "tr",
427
430
  {
428
431
  ref: l === Z ? M?.placeRow : void 0,
429
- role: n ? "row" : void 0,
430
- className: Fe(b, me?.(e, t)),
431
- "aria-selected": r || q !== void 0 ? b : void 0,
432
- tabIndex: c ? 0 : void 0,
433
- onClick: c ? (m) => {
432
+ role: i ? "row" : void 0,
433
+ className: Fe(o, me?.(e, t)),
434
+ "aria-selected": c || q !== void 0 ? o : void 0,
435
+ tabIndex: _ ? 0 : void 0,
436
+ onClick: _ ? (m) => {
434
437
  Ge(m, e, t);
435
438
  } : void 0,
436
- onKeyDown: c ? (m) => {
439
+ onKeyDown: _ ? (m) => {
437
440
  Qe(m, e, t);
438
441
  } : void 0,
439
442
  children: [
440
- r && /* @__PURE__ */ a("td", { ...x("select", "td"), children: Te(b, (m) => {
443
+ c && /* @__PURE__ */ a("td", { ...x("select", "td"), children: Te(o, (m) => {
441
444
  De(l, m);
442
445
  }) }),
443
- u && /* @__PURE__ */ a("td", { ...x("toggle", "td"), children: qe(l, _) }),
446
+ b && /* @__PURE__ */ a("td", { ...x("toggle", "td"), children: qe(l, g) }),
444
447
  ze(e, t),
445
448
  ie,
446
449
  Ve
@@ -448,10 +451,10 @@ function Dt({
448
451
  }
449
452
  ),
450
453
  l === Z && M?.inline ? ne(!0, M.inline) : null,
451
- u && ne(
454
+ b && ne(
452
455
  v.includes(l),
453
456
  /* @__PURE__ */ a("div", { className: "aegis-data-table__detail-clip", children: /* @__PURE__ */ a("div", { className: "aegis-data-table__detail-body", children: (v.includes(l) || B.includes(l)) && Q(e, t) }) }),
454
- _
457
+ g
455
458
  )
456
459
  ] }, l);
457
460
  })
@@ -464,7 +467,7 @@ function Dt({
464
467
  st,
465
468
  {
466
469
  ...V,
467
- pageRowCount: g.length,
470
+ pageRowCount: u.length,
468
471
  disabled: k,
469
472
  className: "aegis-data-table__footer"
470
473
  }