@alea-design/ui 0.7.0 → 0.7.2

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,82 +1,83 @@
1
1
  "use client";
2
- import { jsx as t, jsxs as h } from "react/jsx-runtime";
3
- import { useContext as A, createContext as S, useRef as D, useEffect as F } from "react";
4
- import { Cell as u, Column as b, useTableOptions as x, Row as M, Collection as R, Table as O, Virtualizer as W, TableLayout as E, ResizableTableContainer as P, TableBody as j, TableFooter as V, TableHeader as L, TableColumnResizeStateContext as U, ColumnResizer as q, Checkbox as G } from "react-aria-components";
5
- import { ArrowUp as I, Minus as J, Check as K } from "lucide-react";
6
- import { surfaceAttrs as T } from "../surface/Surface.js";
7
- import { withBase as m, cx as f } from "../../utils/cx.js";
8
- import { DragHandle as Q } from "../list/List.js";
9
- import { useStrings as X } from "../../i18n/strings.js";
10
- import { renamedValue as Y } from "../../utils/vocabulary.js";
11
- import { useAnimatedRows as Z } from "../../utils/animateRows.js";
12
- function k({ slot: a }) {
13
- return /* @__PURE__ */ t(G, { slot: a, className: "alea-check alea-table-check", children: ({ isIndeterminate: r }) => /* @__PURE__ */ t("span", { className: "alea-check-box", "aria-hidden": "true", children: r ? /* @__PURE__ */ t(J, { size: 14, strokeWidth: 3 }) : /* @__PURE__ */ t(K, { size: 14, strokeWidth: 3 }) }) });
2
+ import { jsx as t, jsxs as f } from "react/jsx-runtime";
3
+ import { useContext as T, createContext as E, useRef as F, useEffect as M } from "react";
4
+ import { Cell as b, Column as h, useTableOptions as C, Row as O, Collection as A, Table as P, Virtualizer as W, TableLayout as j, ResizableTableContainer as V, TableBody as L, TableFooter as U, TableHeader as q, TableColumnResizeStateContext as G, ColumnResizer as I, Checkbox as J } from "react-aria-components";
5
+ import { ArrowUp as K, Minus as Q, Check as X } from "lucide-react";
6
+ import { surfaceAttrs as Y } from "../surface/Surface.js";
7
+ import { withBase as u, cx as p } from "../../utils/cx.js";
8
+ import { DragHandle as Z } from "../list/List.js";
9
+ import { useStrings as _ } from "../../i18n/strings.js";
10
+ import { renamedValue as ee } from "../../utils/vocabulary.js";
11
+ import { useAnimatedRows as te } from "../../utils/animateRows.js";
12
+ import { useScrollEdges as ae } from "../../utils/scrollEdges.js";
13
+ function x({ slot: a }) {
14
+ return /* @__PURE__ */ t(J, { slot: a, className: "alea-check alea-table-check", children: ({ isIndeterminate: r }) => /* @__PURE__ */ t("span", { className: "alea-check-box", "aria-hidden": "true", children: r ? /* @__PURE__ */ t(Q, { size: 14, strokeWidth: 3 }) : /* @__PURE__ */ t(X, { size: 14, strokeWidth: 3 }) }) });
14
15
  }
15
- function _(a) {
16
- const r = D(null);
17
- return F(() => {
16
+ function re(a) {
17
+ const r = F(null);
18
+ return M(() => {
18
19
  const e = r.current;
19
20
  if (!a || !e) return;
20
- const o = () => {
21
+ const l = () => {
21
22
  e.scrollWidth > e.clientWidth + 1 ? (e.setAttribute("role", "region"), e.setAttribute("aria-label", a), e.setAttribute("tabindex", "0")) : (e.removeAttribute("role"), e.removeAttribute("aria-label"), e.removeAttribute("tabindex"));
22
23
  };
23
- if (o(), typeof ResizeObserver > "u") return () => {
24
+ if (l(), typeof ResizeObserver > "u") return () => {
24
25
  e.removeAttribute("role"), e.removeAttribute("aria-label"), e.removeAttribute("tabindex");
25
26
  };
26
- const l = new ResizeObserver(o);
27
- return l.observe(e), e.firstElementChild && l.observe(e.firstElementChild), () => {
28
- l.disconnect(), e.removeAttribute("role"), e.removeAttribute("aria-label"), e.removeAttribute("tabindex");
27
+ const o = new ResizeObserver(l);
28
+ return o.observe(e), e.firstElementChild && o.observe(e.firstElementChild), () => {
29
+ o.disconnect(), e.removeAttribute("role"), e.removeAttribute("aria-label"), e.removeAttribute("tabindex");
29
30
  };
30
31
  }, [a]), r;
31
32
  }
32
- function ue({ stickyHeader: a, density: r = "comfy", maxHeight: e, resizable: o, variant: l = "default", stackBelow: n, stackHideEmpty: i, stickyFooter: d, scrollLabel: s, noWrap: p, virtualized: c, surface: v, radius: g, className: $, ...B }) {
33
- const H = Y("Table", "density", r, { comfortable: "comfy" }) === "compact" ? "compact" : "comfy", y = /* @__PURE__ */ t(O, { ...B, className: m("alea-table", $), "data-density": H, "data-sticky": a || c ? !0 : void 0, "data-variant": l !== "default" ? l : void 0, "data-stack": n, "data-stack-hide-empty": n && i ? !0 : void 0, "data-sticky-footer": d ? !0 : void 0, "data-virtualized": c ? !0 : void 0, "data-nowrap": p || void 0 }), N = c ? /* @__PURE__ */ t(W, { layout: E, layoutOptions: { rowHeight: c.rowHeight, headingHeight: c.headingHeight ?? 44 }, children: y }) : y, w = e ? { maxHeight: e, ...c ? { height: e } : {} } : void 0, C = _(s);
34
- return o ? /* @__PURE__ */ t(P, { ref: C, className: "alea-table-wrap", style: w, ...T({ surface: v, radius: g }), children: N }) : /* @__PURE__ */ t("div", { ref: C, className: "alea-table-wrap", style: w, ...T({ surface: v, radius: g }), children: N });
33
+ function ve({ stickyHeader: a, density: r = "comfy", maxHeight: e, resizable: l, variant: o = "default", stackBelow: n, stackHideEmpty: s, stickyFooter: d, stickyColumns: i, scrollLabel: v, noWrap: k, virtualized: c, surface: z, radius: $, className: B, ...H }) {
34
+ const S = ee("Table", "density", r, { comfortable: "comfy" }) === "compact" ? "compact" : "comfy", g = /* @__PURE__ */ t(P, { ...H, className: u("alea-table", B), "data-density": S, "data-sticky": a || c ? !0 : void 0, "data-variant": o !== "default" ? o : void 0, "data-stack": n, "data-stack-hide-empty": n && s ? !0 : void 0, "data-sticky-footer": d ? !0 : void 0, "data-pin": i, "data-virtualized": c ? !0 : void 0, "data-nowrap": k || void 0 }), y = c ? /* @__PURE__ */ t(W, { layout: j, layoutOptions: { rowHeight: c.rowHeight, headingHeight: c.headingHeight ?? 44 }, children: g }) : g, D = e ? { maxHeight: e, ...c ? { height: e } : {} } : void 0, m = re(v), { edges: N } = ae(m, "", !!i), w = { className: "alea-table-wrap", style: D, "data-scrolled-start": N.start || void 0, "data-scrolled-end": N.end || void 0, ...Y({ surface: z, radius: $ }) };
35
+ return l ? /* @__PURE__ */ t(V, { ref: m, ...w, children: y }) : /* @__PURE__ */ t("div", { ref: m, ...w, children: y });
35
36
  }
36
- function be({ columns: a, children: r, className: e, ...o }) {
37
- const l = X(), { selectionBehavior: n, selectionMode: i, allowsDragging: d } = x();
38
- return /* @__PURE__ */ h(L, { ...o, className: f("alea-thead", e), children: [
39
- d && /* @__PURE__ */ t(b, { className: "alea-th alea-th-narrow", children: /* @__PURE__ */ t("span", { className: "alea-visually-hidden", children: l.dragToMove }) }),
40
- n === "toggle" && /* @__PURE__ */ t(b, { className: "alea-th alea-th-narrow", children: i === "multiple" && /* @__PURE__ */ t(k, { slot: "selection" }) }),
41
- /* @__PURE__ */ t(R, { items: a, children: r })
37
+ function ge({ columns: a, children: r, className: e, ...l }) {
38
+ const o = _(), { selectionBehavior: n, selectionMode: s, allowsDragging: d } = C();
39
+ return /* @__PURE__ */ f(q, { ...l, className: p("alea-thead", e), children: [
40
+ d && /* @__PURE__ */ t(h, { className: "alea-th alea-th-narrow", children: /* @__PURE__ */ t("span", { className: "alea-visually-hidden", children: o.dragToMove }) }),
41
+ n === "toggle" && /* @__PURE__ */ t(h, { className: "alea-th alea-th-narrow", children: s === "multiple" && /* @__PURE__ */ t(x, { slot: "selection" }) }),
42
+ /* @__PURE__ */ t(A, { items: a, children: r })
42
43
  ] });
43
44
  }
44
- function he({ children: a, align: r = "start", className: e, ...o }) {
45
- return /* @__PURE__ */ t(b, { ...o, className: m("alea-th", e), "data-align": r, children: ({ allowsSorting: l, sortDirection: n }) => /* @__PURE__ */ h("div", { className: "alea-th-inner", children: [
45
+ function ye({ children: a, align: r = "start", className: e, ...l }) {
46
+ return /* @__PURE__ */ t(h, { ...l, className: u("alea-th", e), "data-align": r, children: ({ allowsSorting: o, sortDirection: n }) => /* @__PURE__ */ f("div", { className: "alea-th-inner", children: [
46
47
  /* @__PURE__ */ t("span", { className: "alea-th-label", children: a }),
47
- l && /* @__PURE__ */ t(I, { size: 14, "aria-hidden": "true", className: "alea-sort", "data-direction": n }),
48
- /* @__PURE__ */ t(ee, {})
48
+ o && /* @__PURE__ */ t(K, { size: 14, "aria-hidden": "true", className: "alea-sort", "data-direction": n }),
49
+ /* @__PURE__ */ t(oe, {})
49
50
  ] }) });
50
51
  }
51
- function ee() {
52
- return A(U) ? /* @__PURE__ */ t(q, { className: "alea-col-resizer" }) : null;
52
+ function oe() {
53
+ return T(G) ? /* @__PURE__ */ t(I, { className: "alea-col-resizer" }) : null;
53
54
  }
54
- function fe({ className: a, animateRows: r, items: e, children: o, dependencies: l, ...n }) {
55
- const i = Z(e, o, r);
56
- return /* @__PURE__ */ t(j, { ...n, items: i.items, dependencies: i.dependencies ? [...l ?? [], ...i.dependencies] : l, className: f("alea-tbody", a), children: i.children });
55
+ function Ne({ className: a, animateRows: r, items: e, children: l, dependencies: o, ...n }) {
56
+ const s = te(e, l, r);
57
+ return /* @__PURE__ */ t(L, { ...n, items: s.items, dependencies: s.dependencies ? [...o ?? [], ...s.dependencies] : o, className: p("alea-tbody", a), children: s.children });
57
58
  }
58
- const z = S(!1);
59
- function pe({ className: a, children: r, ...e }) {
60
- return /* @__PURE__ */ t(V, { ...e, className: f("alea-tfoot", a), children: /* @__PURE__ */ t(z.Provider, { value: !0, children: r }) });
59
+ const R = E(!1);
60
+ function we({ className: a, children: r, ...e }) {
61
+ return /* @__PURE__ */ t(U, { ...e, className: p("alea-tfoot", a), children: /* @__PURE__ */ t(R.Provider, { value: !0, children: r }) });
61
62
  }
62
- function ve({ id: a, columns: r, children: e, className: o, ...l }) {
63
- const { selectionBehavior: n, allowsDragging: i, selectionMode: d } = x(), s = A(z);
64
- return /* @__PURE__ */ h(M, { id: a, ...s && d !== "none" ? { isDisabled: !0 } : {}, ...l, className: m("alea-tr", o), "data-footer": s ? !0 : void 0, children: [
65
- i && /* @__PURE__ */ t(u, { className: "alea-td alea-td-narrow", children: s ? null : /* @__PURE__ */ t(Q, {}) }),
66
- n === "toggle" && /* @__PURE__ */ t(u, { className: "alea-td alea-td-narrow", children: s ? null : /* @__PURE__ */ t(k, { slot: "selection" }) }),
67
- /* @__PURE__ */ t(R, { items: r, dependencies: l.dependencies, children: e })
63
+ function Te({ id: a, columns: r, children: e, className: l, ...o }) {
64
+ const { selectionBehavior: n, allowsDragging: s, selectionMode: d } = C(), i = T(R);
65
+ return /* @__PURE__ */ f(O, { id: a, ...i && d !== "none" ? { isDisabled: !0 } : {}, ...o, className: u("alea-tr", l), "data-footer": i ? !0 : void 0, children: [
66
+ s && /* @__PURE__ */ t(b, { className: "alea-td alea-td-narrow", children: i ? null : /* @__PURE__ */ t(Z, {}) }),
67
+ n === "toggle" && /* @__PURE__ */ t(b, { className: "alea-td alea-td-narrow", children: i ? null : /* @__PURE__ */ t(x, { slot: "selection" }) }),
68
+ /* @__PURE__ */ t(A, { items: r, dependencies: o.dependencies, children: e })
68
69
  ] });
69
70
  }
70
- function ge({ className: a, ...r }) {
71
- const { align: e, label: o, ...l } = r;
72
- return /* @__PURE__ */ t(u, { ...l, "data-align": e, "data-label": o, className: m("alea-td", a) });
71
+ function Ce({ className: a, ...r }) {
72
+ const { align: e, label: l, ...o } = r;
73
+ return /* @__PURE__ */ t(b, { ...o, "data-align": e, "data-label": l, className: u("alea-td", a) });
73
74
  }
74
75
  export {
75
- ge as Cell,
76
- he as Column,
77
- ve as Row,
78
- ue as Table,
79
- fe as TableBody,
80
- pe as TableFooter,
81
- be as TableHeader
76
+ Ce as Cell,
77
+ ye as Column,
78
+ Te as Row,
79
+ ve as Table,
80
+ Ne as TableBody,
81
+ we as TableFooter,
82
+ ge as TableHeader
82
83
  };