@cognite/aura 0.3.4 → 0.3.5

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 CHANGED
@@ -159,6 +159,33 @@ Some Aura entry points require optional peer dependencies that consumers must in
159
159
  </ChartContainer>
160
160
  ```
161
161
 
162
+ - `@cognite/aura/data-grid` requires `@tanstack/react-table >=8.7` and `@tanstack/react-virtual >=3.10`. Add them to your app:
163
+
164
+ ```sh
165
+ pnpm add @tanstack/react-table @tanstack/react-virtual
166
+ ```
167
+
168
+ The DataGrid is a virtualised table with client/server sorting, column pinning, and
169
+ expandable rows. Pass `columns` and `data` from your own TanStack column definitions.
170
+ Header chrome, pagination, selection, search, filters, and loading states are landing in
171
+ follow-up PRs.
172
+
173
+ ```tsx
174
+ import type { ColumnDef } from '@tanstack/react-table';
175
+ import { DataGrid } from '@cognite/aura/data-grid';
176
+
177
+ type Row = { id: string; name: string };
178
+ const columns: ColumnDef<Row>[] = [{ accessorKey: 'name', header: 'Name' }];
179
+
180
+ <DataGrid
181
+ data={rows}
182
+ columns={columns}
183
+ getRowId={(row) => row.id}
184
+ enableSorting
185
+ aria-label="Assets"
186
+ />;
187
+ ```
188
+
162
189
  ## Versioning
163
190
 
164
191
  ### Before releasing
@@ -0,0 +1,23 @@
1
+ import { cn as e } from "../../../../lib/utils.js";
2
+ import { forwardRef as t } from "react";
3
+ import { jsx as n } from "react/jsx-runtime";
4
+ //#region libs/aura/src/components/ui/core/data-grid/data-grid-cell.tsx
5
+ var r = t(function({ className: t, children: r, isPinned: i, isLastPinned: a, colIndex: o, textValue: s, truncate: c = !0, style: l, ...u }, d) {
6
+ return /* @__PURE__ */ n("div", {
7
+ ref: d,
8
+ "data-slot": "data-grid-cell",
9
+ role: "cell",
10
+ "aria-colindex": o,
11
+ title: s,
12
+ className: e("flex items-center pr-3 text-sm font-normal", o === 1 ? "pl-4" : "pl-3", "min-w-0", i && "sticky z-10 bg-inherit", a && "shadow-pinned-column", t),
13
+ style: l,
14
+ ...u,
15
+ children: c && s !== void 0 ? /* @__PURE__ */ n("span", {
16
+ className: "block min-w-0 flex-1 truncate",
17
+ children: s
18
+ }) : r
19
+ });
20
+ });
21
+ r.displayName = "DataGridCell";
22
+ //#endregion
23
+ export { r as DataGridCell };
@@ -0,0 +1,56 @@
1
+ import { cn as e } from "../../../../lib/utils.js";
2
+ import { getAriaSort as t } from "./data-grid.utils.js";
3
+ import { IconArrowDown as n } from "@tabler/icons-react";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ import { flexRender as a } from "@tanstack/react-table";
6
+ //#region libs/aura/src/components/ui/core/data-grid/data-grid-header-row.tsx
7
+ function o({ headerGroup: o, headerRowIndex: s, resolvedHeaderHeight: c, gridTemplateColumns: l, pinnedColumnIds: u, lastPinnedColumnId: d, pinnedLeftByColumnId: f }) {
8
+ return /* @__PURE__ */ r("div", {
9
+ "data-slot": "data-grid-header-row",
10
+ role: "row",
11
+ "aria-rowindex": s + 1,
12
+ className: e("sticky z-20 grid bg-background", s === 0 ? "border-y" : "border-b"),
13
+ style: {
14
+ top: s * c,
15
+ gridTemplateColumns: l,
16
+ minHeight: c
17
+ },
18
+ children: o.headers.map((o) => {
19
+ let s = o.colSpan === 1, c = s && u.has(o.column.id), l = c && d === o.column.id, p = o.column.getIsSorted(), m = s && o.column.getCanSort(), h = o.colSpan > 1, g = o.isPlaceholder ? null : a(o.column.columnDef.header, o.getContext()), _ = typeof g == "string" || typeof g == "number";
20
+ return /* @__PURE__ */ r("div", {
21
+ "data-slot": "data-grid-column-header",
22
+ role: "columnheader",
23
+ "aria-colindex": o.index + 1,
24
+ "aria-colspan": o.colSpan > 1 ? o.colSpan : void 0,
25
+ "aria-sort": t(p, m),
26
+ className: e("flex items-center pr-3 text-left text-sm font-medium text-muted-foreground", o.index === 0 ? "pl-4" : "pl-3", h && "justify-center text-base font-semibold text-foreground/70", o.isPlaceholder && "pointer-events-none", c && "sticky left-0 z-10 bg-background", l && "shadow-pinned-column", m && e("cursor-pointer select-none hover:bg-muted/60", "focus-visible:shadow-focus-ring focus-visible:bg-background focus-visible:border-transparent focus-visible:text-foreground outline-none")),
27
+ tabIndex: m ? 0 : void 0,
28
+ style: {
29
+ gridColumn: `span ${o.colSpan} / span ${o.colSpan}`,
30
+ ...c ? {
31
+ position: "sticky",
32
+ left: f.get(o.column.id) ?? 0,
33
+ zIndex: 10
34
+ } : {}
35
+ },
36
+ onClick: m ? o.column.getToggleSortingHandler() : void 0,
37
+ onKeyDown: m ? (e) => {
38
+ e.key !== "Enter" && e.key !== " " || (e.preventDefault(), o.column.toggleSorting(void 0, e.shiftKey));
39
+ } : void 0,
40
+ children: /* @__PURE__ */ i("div", {
41
+ className: "flex min-w-0 flex-1 items-center gap-1",
42
+ children: [_ ? /* @__PURE__ */ r("span", {
43
+ className: "block min-w-0 truncate",
44
+ children: g
45
+ }) : g, (p === "asc" || p === "desc") && /* @__PURE__ */ r("span", {
46
+ "aria-hidden": "true",
47
+ className: "inline-flex size-4 shrink-0 items-center justify-center",
48
+ children: /* @__PURE__ */ r(n, { className: e("size-3.5 shrink-0", p === "asc" && "rotate-180") })
49
+ })]
50
+ })
51
+ }, o.id);
52
+ })
53
+ });
54
+ }
55
+ //#endregion
56
+ export { o as DataGridHeaderRow };
@@ -0,0 +1,77 @@
1
+ import { cn as e } from "../../../../lib/utils.js";
2
+ import { Button as t } from "../button/button.js";
3
+ import { getTextValue as n, isAccessorColumn as r, isFromExpandToggleTarget as i, isFromIgnoredCellTarget as a } from "./data-grid.utils.js";
4
+ import { DataGridCell as o } from "./data-grid-cell.js";
5
+ import { IconChevronRight as s } from "@tabler/icons-react";
6
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
7
+ import { flexRender as u } from "@tanstack/react-table";
8
+ //#region libs/aura/src/components/ui/core/data-grid/data-grid-row.tsx
9
+ function d({ row: d, virtualRow: f, headerGroupCount: p, gridTemplateColumns: m, pinnedColumnIds: h, lastPinnedColumnId: g, pinnedLeftByColumnId: _, customCellColumnIds: v, maxDepth: y, hasExpanding: b, onRowClick: x }) {
10
+ let S = d.getCanExpand(), C = x !== void 0, w = C ? (e) => {
11
+ a(e) || i(e) || x?.(d);
12
+ } : void 0, T = d.getVisibleCells(), E = T.findIndex((e) => r(e.column.columnDef)), D = E >= 0 ? E : 0;
13
+ return /* @__PURE__ */ c("div", {
14
+ "data-slot": "data-grid-row",
15
+ role: "row",
16
+ "aria-rowindex": f.index + 1 + p,
17
+ "aria-expanded": S ? d.getIsExpanded() : void 0,
18
+ className: e("group absolute left-0 right-0 grid border-b bg-background transition-colors", "hover:bg-active-muted-background", C && e("cursor-pointer focus-visible:bg-active-muted-background", "focus-visible:shadow-focus-ring focus-visible:bg-background focus-visible:border-transparent focus-visible:text-foreground outline-none")),
19
+ style: {
20
+ gridTemplateColumns: m,
21
+ height: f.size,
22
+ transform: `translateY(${f.start}px)`
23
+ },
24
+ tabIndex: C ? 0 : void 0,
25
+ onClick: w ? (e) => w(e.target) : void 0,
26
+ onKeyDown: w ? (e) => {
27
+ e.key !== "Enter" && e.key !== " " || a(e.target) || i(e.target) || (e.preventDefault(), w(e.target));
28
+ } : void 0,
29
+ children: T.map((i, a) => {
30
+ let f = h.has(i.column.id), p = f && g === i.column.id, m = u(i.column.columnDef.cell, i.getContext()), x = v.has(i.column.id), C = n(m), w = n(i.getValue()), T = C ?? (x ? void 0 : w), E = a === D, O = Math.min(d.depth, y), k = E && O > 0 ? O * 16 : 0, A = E && S, j = E && b && !S && O > 0, M = f ? {
31
+ position: "sticky",
32
+ left: _.get(i.column.id) ?? 0,
33
+ zIndex: 10
34
+ } : void 0, N = k > 0 || M ? {
35
+ ...M,
36
+ ...k > 0 ? { paddingInlineStart: `${k + 12}px` } : {}
37
+ } : void 0, P = A || j;
38
+ return /* @__PURE__ */ l(o, {
39
+ "data-row-activation": r(i.column.columnDef) ? void 0 : "ignore",
40
+ isPinned: f,
41
+ isLastPinned: p,
42
+ colIndex: a + 1,
43
+ textValue: T,
44
+ truncate: !P && T !== void 0,
45
+ style: N,
46
+ children: [
47
+ A && /* @__PURE__ */ c(t, {
48
+ size: "icon-sm",
49
+ variant: "ghost",
50
+ className: "mr-2",
51
+ "data-row-expand-toggle": "true",
52
+ onClick: (e) => {
53
+ e.stopPropagation(), d.toggleExpanded();
54
+ },
55
+ "aria-label": d.getIsExpanded() ? "Collapse row" : "Expand row",
56
+ children: /* @__PURE__ */ c(s, {
57
+ width: 5,
58
+ height: 8,
59
+ className: e(d.getIsExpanded() && "rotate-90"),
60
+ "aria-hidden": "true"
61
+ })
62
+ }),
63
+ j && /* @__PURE__ */ c("span", {
64
+ className: "mr-2 inline-block h-7 w-7 shrink-0",
65
+ "aria-hidden": "true"
66
+ }),
67
+ P && T !== void 0 ? /* @__PURE__ */ c("span", {
68
+ className: "block min-w-0 flex-1 truncate",
69
+ children: T
70
+ }) : m
71
+ ]
72
+ }, i.id);
73
+ })
74
+ });
75
+ }
76
+ //#endregion
77
+ export { d as DataGridRow };
@@ -0,0 +1,134 @@
1
+ import { cn as e } from "../../../../lib/utils.js";
2
+ import { useControllableState as t } from "../../../../lib/use-controllable-state.js";
3
+ import { collectCustomCellColumnIds as n } from "./data-grid.utils.js";
4
+ import { DataGridHeaderRow as r } from "./data-grid-header-row.js";
5
+ import { DataGridRow as i } from "./data-grid-row.js";
6
+ import { useEffect as a, useImperativeHandle as o, useMemo as s, useRef as c } from "react";
7
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
8
+ import { getCoreRowModel as ee, getExpandedRowModel as te, getFilteredRowModel as ne, getSortedRowModel as re, useReactTable as ie } from "@tanstack/react-table";
9
+ import { useVirtualizer as ae } from "@tanstack/react-virtual";
10
+ //#region libs/aura/src/components/ui/core/data-grid/data-grid.tsx
11
+ var oe = [], d = 120, f = {
12
+ default: 36,
13
+ compact: 32
14
+ }, p = {
15
+ default: 36,
16
+ compact: 32
17
+ };
18
+ function m({ data: m, columns: h, getRowId: se, rowCount: g, globalFilterFn: _ = "auto", enableSorting: v = !1, manualSorting: y = !1, sorting: ce, defaultSorting: le, onSortingChange: ue, getSubRows: b, expanded: de, defaultExpanded: x, onExpandedChange: S, getRowCanExpand: C, maxDepth: w = 5, pinnedColumns: T = oe, gridRef: E, size: D = "default", children: O, className: k, onRowClick: A, rowHeight: j, headerHeight: M, "aria-label": N, "aria-labelledby": P }) {
19
+ let F = c(null), [fe, I] = t({
20
+ prop: ce,
21
+ defaultProp: le ?? [],
22
+ onChange: ue
23
+ }), L = b !== void 0, [R, z] = t({
24
+ prop: de,
25
+ defaultProp: x ?? {},
26
+ onChange: S
27
+ }), B = v && !y, V = s(() => ({
28
+ left: T,
29
+ right: []
30
+ }), [T]), H = s(() => new Set(T), [T]), U = T[T.length - 1], pe = s(() => n(h), [h]), W = ie({
31
+ data: m,
32
+ columns: h,
33
+ state: {
34
+ columnPinning: V,
35
+ sorting: fe,
36
+ ...L ? { expanded: R } : {}
37
+ },
38
+ onSortingChange: I,
39
+ ...L ? { onExpandedChange: z } : {},
40
+ autoResetExpanded: !1,
41
+ enableSorting: v,
42
+ manualSorting: y,
43
+ getCoreRowModel: ee(),
44
+ getFilteredRowModel: ne(),
45
+ globalFilterFn: _,
46
+ ...B ? { getSortedRowModel: re() } : {},
47
+ ...L ? { getExpandedRowModel: te() } : {},
48
+ getRowId: se,
49
+ getSubRows: b,
50
+ getRowCanExpand: C
51
+ }), { rows: G } = W.getRowModel(), K = W.getHeaderGroups(), q = W.getAllColumns(), J = W.getVisibleFlatColumns(), Y = j ?? f[D], me = M ?? p[D], X = m.length === 0, Z = ae({
52
+ count: G.length,
53
+ getScrollElement: () => F.current,
54
+ estimateSize: () => Y,
55
+ overscan: 10
56
+ }), he = {
57
+ "--data-grid-body-height": `${Z.getTotalSize()}px`,
58
+ "--data-grid-body-min-height": `${Y * 4}px`
59
+ };
60
+ o(E, () => ({
61
+ scrollToRow: (e) => Z.scrollToIndex(e),
62
+ resetSorting: () => I([])
63
+ })), a(() => {
64
+ for (let e of T) {
65
+ let t = q.find((t) => t.id === e);
66
+ t && t.columnDef.size === void 0 && console.warn(`[Aura DataGrid] Pinned column "${e}" has no \`size\` set. Pinned columns must declare an explicit \`size\` to keep the sticky offset aligned with the rendered column width.`);
67
+ }
68
+ }, [T, q]);
69
+ let Q = s(() => {
70
+ let e = J.some((e) => e.columnDef.size === void 0 && !H.has(e.id));
71
+ return J.map((t, n) => {
72
+ let r = t.columnDef.size, i = n === J.length - 1;
73
+ return H.has(t.id) ? `${r ?? d}px` : r === void 0 ? `minmax(${d}px, 1fr)` : !e && i ? `minmax(${r}px, 1fr)` : `${r}px`;
74
+ }).join(" ");
75
+ }, [J, H]), $ = s(() => {
76
+ let e = /* @__PURE__ */ new Map(), t = 0;
77
+ for (let n of T) {
78
+ let r = J.find((e) => e.id === n);
79
+ r && (e.set(n, t), t += r.columnDef.size ?? d);
80
+ }
81
+ return e;
82
+ }, [J, T]);
83
+ return /* @__PURE__ */ u("div", {
84
+ "data-slot": "data-grid",
85
+ className: e("relative flex h-full min-h-0 w-full flex-col overflow-clip rounded-xl bg-default text-sm", k),
86
+ children: [O, /* @__PURE__ */ l("div", {
87
+ ref: F,
88
+ "data-slot": "data-grid-scroll-container",
89
+ className: "relative order-2 h-full min-h-0 w-full flex-1 overflow-auto",
90
+ role: "table",
91
+ "aria-rowcount": (g ?? G.length) + K.length,
92
+ "aria-colcount": J.length,
93
+ "aria-label": N,
94
+ "aria-labelledby": P,
95
+ children: /* @__PURE__ */ u("div", {
96
+ className: "min-w-fit w-full",
97
+ children: [/* @__PURE__ */ l("div", {
98
+ role: "rowgroup",
99
+ "data-slot": "data-grid-header-group",
100
+ className: "contents",
101
+ children: K.map((e, t) => /* @__PURE__ */ l(r, {
102
+ headerGroup: e,
103
+ headerRowIndex: t,
104
+ resolvedHeaderHeight: me,
105
+ gridTemplateColumns: Q,
106
+ pinnedColumnIds: H,
107
+ lastPinnedColumnId: U,
108
+ pinnedLeftByColumnId: $
109
+ }, e.id))
110
+ }), /* @__PURE__ */ l("div", {
111
+ role: "rowgroup",
112
+ "data-slot": "data-grid-body",
113
+ className: e("relative min-h-(--data-grid-body-min-height)", !X && "h-(--data-grid-body-height)"),
114
+ style: he,
115
+ children: !X && Z.getVirtualItems().map((e) => /* @__PURE__ */ l(i, {
116
+ row: G[e.index],
117
+ virtualRow: e,
118
+ headerGroupCount: K.length,
119
+ gridTemplateColumns: Q,
120
+ pinnedColumnIds: H,
121
+ lastPinnedColumnId: U,
122
+ pinnedLeftByColumnId: $,
123
+ customCellColumnIds: pe,
124
+ maxDepth: w,
125
+ hasExpanding: L,
126
+ onRowClick: A
127
+ }, G[e.index].id))
128
+ })]
129
+ })
130
+ })]
131
+ });
132
+ }
133
+ //#endregion
134
+ export { m as DataGrid };
@@ -0,0 +1,40 @@
1
+ //#region libs/aura/src/components/ui/core/data-grid/data-grid.utils.ts
2
+ function e(e, t) {
3
+ return e === "asc" ? "ascending" : e === "desc" ? "descending" : t ? "none" : void 0;
4
+ }
5
+ function t(e) {
6
+ if (typeof e == "string" || typeof e == "number") return String(e);
7
+ }
8
+ function n(e) {
9
+ let t = "accessorKey" in e && e.accessorKey !== void 0, n = "accessorFn" in e && e.accessorFn !== void 0;
10
+ return t || n;
11
+ }
12
+ function r(e) {
13
+ return e instanceof Element && !!e.closest("[data-row-activation=\"ignore\"]");
14
+ }
15
+ function i(e) {
16
+ return e instanceof Element && !!e.closest("[data-row-expand-toggle=\"true\"]");
17
+ }
18
+ function a(e) {
19
+ let t = /* @__PURE__ */ new Set(), n = (e) => {
20
+ for (let r of e) {
21
+ if (o(r)) {
22
+ n(r.columns);
23
+ continue;
24
+ }
25
+ if (Object.prototype.hasOwnProperty.call(r, "cell")) {
26
+ if ("id" in r && typeof r.id == "string") {
27
+ t.add(r.id);
28
+ continue;
29
+ }
30
+ "accessorKey" in r && typeof r.accessorKey == "string" && t.add(r.accessorKey);
31
+ }
32
+ }
33
+ };
34
+ return n(e), t;
35
+ }
36
+ function o(e) {
37
+ return "columns" in e && Array.isArray(e.columns);
38
+ }
39
+ //#endregion
40
+ export { a as collectCustomCellColumnIds, e as getAriaSort, t as getTextValue, n as isAccessorColumn, i as isFromExpandToggleTarget, r as isFromIgnoredCellTarget };
@@ -0,0 +1 @@
1
+ export { DataGrid, type DataGridHandle } from './data-grid';
@@ -0,0 +1,2 @@
1
+ import { DataGrid as e } from "./data-grid.js";
2
+ export { e as DataGrid };
@@ -1,20 +1,26 @@
1
- import { ReactNode } from 'react';
1
+ import { ComponentProps, ReactNode } from 'react';
2
2
  import { Tabs as TabsPrimitive } from '@base-ui/react/tabs';
3
3
  import { VariantProps } from 'class-variance-authority';
4
4
  import { ClassProp } from 'class-variance-authority/types';
5
5
  declare function SegmentedControl({ className, ...props }: TabsPrimitive.Root.Props): ReactNode;
6
- interface SegmentedControlListVariantProps {
6
+ interface SegmentedControlSizeVariantProps {
7
7
  size?: 'small' | 'default' | null;
8
8
  }
9
- declare const segmentedControlListVariants: (props?: (SegmentedControlListVariantProps & ClassProp) | undefined) => string;
9
+ declare const segmentedControlListVariants: (props?: (SegmentedControlSizeVariantProps & ClassProp) | undefined) => string;
10
+ type SegmentedControlSize = NonNullable<VariantProps<typeof segmentedControlListVariants>['size']>;
10
11
  type SegmentedControlListProps = TabsPrimitive.List.Props & VariantProps<typeof segmentedControlListVariants>;
11
12
  declare function SegmentedControlList({ className, size, children, ...props }: SegmentedControlListProps): ReactNode;
12
- interface SegmentedControlButtonVariantProps {
13
- size?: 'small' | 'default' | null;
13
+ declare const segmentedControlIndicatorVariants: (props?: (SegmentedControlSizeVariantProps & ClassProp) | undefined) => string;
14
+ type SegmentedControlIndicatorProps = ComponentProps<'div'> & VariantProps<typeof segmentedControlIndicatorVariants> & {
15
+ activeSelector?: string;
16
+ };
17
+ declare function SegmentedControlIndicator({ className, size, activeSelector, style, ...props }: SegmentedControlIndicatorProps): ReactNode;
18
+ interface SegmentedControlButtonVariantProps extends SegmentedControlSizeVariantProps {
14
19
  tabContent?: 'icon-label' | 'label-only' | 'icon-only' | null;
15
20
  }
16
21
  declare const segmentedControlButtonVariants: (props?: (SegmentedControlButtonVariantProps & ClassProp) | undefined) => string;
17
22
  type SegmentedControlButtonProps = TabsPrimitive.Tab.Props & VariantProps<typeof segmentedControlButtonVariants>;
18
23
  declare function SegmentedControlButton({ className, size, tabContent, ...props }: SegmentedControlButtonProps): ReactNode;
19
24
  declare function SegmentedControlContent({ className, ...props }: TabsPrimitive.Panel.Props): ReactNode;
20
- export { SegmentedControl, SegmentedControlButton, SegmentedControlContent, SegmentedControlList, segmentedControlButtonVariants, segmentedControlListVariants, };
25
+ export { SegmentedControl, SegmentedControlButton, SegmentedControlContent, SegmentedControlIndicator, SegmentedControlList, segmentedControlButtonVariants, segmentedControlIndicatorVariants, segmentedControlListVariants, };
26
+ export type { SegmentedControlSize };
@@ -1,50 +1,92 @@
1
1
  import { cn as e } from "../../../../lib/utils.js";
2
- import { createContext as t, useContext as n } from "react";
3
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
- import { cva as a } from "class-variance-authority";
5
- import { Tabs as o } from "@base-ui/react/tabs";
2
+ import { createContext as t, useContext as n, useLayoutEffect as r, useRef as i } from "react";
3
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
4
+ import { cva as s } from "class-variance-authority";
5
+ import { Tabs as c } from "@base-ui/react/tabs";
6
6
  //#region libs/aura/src/components/ui/core/segmented-control/segmented-control.tsx
7
- function s({ className: t, ...n }) {
8
- return /* @__PURE__ */ r(o.Root, {
7
+ function l({ className: t, ...n }) {
8
+ return /* @__PURE__ */ a(c.Root, {
9
9
  "data-slot": "segmented-control",
10
10
  className: e("flex flex-col gap-2", t),
11
11
  ...n
12
12
  });
13
13
  }
14
- var c = a("bg-muted-background text-muted-foreground relative isolate inline-flex w-fit items-center justify-center gap-2 p-0.5", {
14
+ var u = s("bg-muted-background text-muted-foreground relative isolate inline-flex w-fit items-center justify-center gap-2 p-0.5", {
15
15
  variants: { size: {
16
16
  default: "h-9 rounded-lg",
17
17
  small: "h-7 rounded-md"
18
18
  } },
19
19
  defaultVariants: { size: "default" }
20
- }), l = t(void 0);
21
- function u({ className: t, size: n, children: a, ...s }) {
22
- let u = n ?? "default";
23
- return /* @__PURE__ */ r(o.List, {
20
+ }), d = t(void 0);
21
+ function f(e) {
22
+ let t = n(d);
23
+ return e ?? t ?? "default";
24
+ }
25
+ function p({ className: t, size: n, children: r, ...i }) {
26
+ let s = n ?? "default";
27
+ return /* @__PURE__ */ a(c.List, {
24
28
  "data-slot": "segmented-control-list",
25
- className: e(c({ size: n }), t),
26
- ...s,
27
- children: /* @__PURE__ */ i(l.Provider, {
28
- value: u,
29
- children: [/* @__PURE__ */ r(f, { size: u }), a]
29
+ className: e(u({ size: n }), t),
30
+ ...i,
31
+ children: /* @__PURE__ */ o(d.Provider, {
32
+ value: s,
33
+ children: [/* @__PURE__ */ a(h, {
34
+ size: s,
35
+ activeSelector: "[aria-selected=\"true\"]"
36
+ }), r]
30
37
  })
31
38
  });
32
39
  }
33
- var d = a("bg-background pointer-events-none absolute top-(--active-tab-top) left-(--active-tab-left) -z-0 h-(--active-tab-height) w-(--active-tab-width) motion-safe:transition-[top,left,width,height] motion-safe:duration-200 motion-safe:ease-out data-[activation-direction=none]:transition-none", {
40
+ var m = s("bg-background pointer-events-none absolute top-(--active-tab-top) left-(--active-tab-left) -z-0 h-(--active-tab-height) w-(--active-tab-width) motion-safe:transition-[top,left,width,height] motion-safe:duration-200 motion-safe:ease-out data-[activation-direction=none]:transition-none", {
34
41
  variants: { size: {
35
42
  default: "rounded-md",
36
43
  small: "rounded-sm"
37
44
  } },
38
45
  defaultVariants: { size: "default" }
39
46
  });
40
- function f({ className: t, size: n, ...i }) {
41
- return /* @__PURE__ */ r(o.Indicator, {
47
+ function h({ className: t, size: n, activeSelector: o = "[aria-selected=\"true\"],[data-active]", style: s, ...c }) {
48
+ let l = i(null), u = i(null);
49
+ return r(() => {
50
+ let e = l.current, t = e?.parentElement;
51
+ if (!e || !t) return;
52
+ let n = null, r = /* @__PURE__ */ new Set(), i = (e) => {
53
+ r.add(e), s.observe(e);
54
+ }, a = (r = !1) => {
55
+ let a = t.querySelector(o);
56
+ if (!a) {
57
+ e.style.opacity = "0";
58
+ return;
59
+ }
60
+ a !== n && (n && s.unobserve(n), i(a), n = a);
61
+ let c = a.offsetLeft, l = u.current, d = r || l === null || c === l ? "none" : c > l ? "right" : "left";
62
+ e.dataset.activationDirection = d, e.style.opacity = "1", e.style.setProperty("--active-tab-left", `${c}px`), e.style.setProperty("--active-tab-top", `${a.offsetTop}px`), e.style.setProperty("--active-tab-width", `${a.offsetWidth}px`), e.style.setProperty("--active-tab-height", `${a.offsetHeight}px`), u.current = c;
63
+ }, s = new ResizeObserver((e) => {
64
+ e.some((e) => r.has(e.target) ? (r.delete(e.target), !1) : !0) && a(!0);
65
+ });
66
+ i(t), a();
67
+ let c = new MutationObserver(() => a(!1));
68
+ return c.observe(t, {
69
+ attributes: !0,
70
+ attributeFilter: [
71
+ "aria-selected",
72
+ "data-active",
73
+ "class"
74
+ ],
75
+ subtree: !0,
76
+ childList: !0
77
+ }), () => {
78
+ c.disconnect(), s.disconnect();
79
+ };
80
+ }, [o]), /* @__PURE__ */ a("div", {
81
+ ref: l,
42
82
  "data-slot": "segmented-control-indicator",
43
- className: e(d({ size: n }), t),
44
- ...i
83
+ "data-activation-direction": "none",
84
+ className: e("opacity-0", m({ size: n }), t),
85
+ style: s,
86
+ ...c
45
87
  });
46
88
  }
47
- var p = a("text-sm leading-4.5 tracking-normal font-medium relative z-10 inline-flex flex-1 items-center justify-center whitespace-nowrap text-muted-foreground dark:text-muted-foreground border border-transparent transition-[color,box-shadow] duration-200 ease-out focus-visible:border-ring focus-visible:ring focus-visible:ring-ring-shadow focus-visible:outline-1 focus-visible:outline-ring [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4 data-disabled:pointer-events-none data-disabled:opacity-50 hover:text-foreground data-active:text-foreground data-active:hover:text-foreground", {
89
+ var g = s("text-sm leading-4.5 tracking-normal font-medium relative z-10 inline-flex flex-1 items-center justify-center whitespace-nowrap text-muted-foreground dark:text-muted-foreground border border-transparent transition-[color,box-shadow] duration-200 ease-out focus-visible:border-ring focus-visible:ring focus-visible:ring-ring-shadow focus-visible:outline-1 focus-visible:outline-ring [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4 data-disabled:pointer-events-none data-disabled:opacity-50 hover:text-foreground data-active:text-foreground data-active:hover:text-foreground", {
48
90
  variants: {
49
91
  size: {
50
92
  default: "rounded-md",
@@ -93,23 +135,23 @@ var p = a("text-sm leading-4.5 tracking-normal font-medium relative z-10 inline-
93
135
  tabContent: "icon-label"
94
136
  }
95
137
  });
96
- function m({ className: t, size: i, tabContent: a, ...s }) {
97
- let c = n(l), u = i ?? c;
98
- return /* @__PURE__ */ r(o.Tab, {
138
+ function _({ className: t, size: n, tabContent: r, ...i }) {
139
+ let o = f(n);
140
+ return /* @__PURE__ */ a(c.Tab, {
99
141
  "data-slot": "segmented-control-trigger",
100
- className: e(p({
101
- size: u,
102
- tabContent: a
142
+ className: e(g({
143
+ size: o,
144
+ tabContent: r
103
145
  }), t),
104
- ...s
146
+ ...i
105
147
  });
106
148
  }
107
- function h({ className: t, ...n }) {
108
- return /* @__PURE__ */ r(o.Panel, {
149
+ function v({ className: t, ...n }) {
150
+ return /* @__PURE__ */ a(c.Panel, {
109
151
  "data-slot": "segmented-control-content",
110
152
  className: e("flex-1 outline-none", t),
111
153
  ...n
112
154
  });
113
155
  }
114
156
  //#endregion
115
- export { s as SegmentedControl, m as SegmentedControlButton, h as SegmentedControlContent, u as SegmentedControlList, p as segmentedControlButtonVariants, c as segmentedControlListVariants };
157
+ export { l as SegmentedControl, _ as SegmentedControlButton, v as SegmentedControlContent, h as SegmentedControlIndicator, p as SegmentedControlList, g as segmentedControlButtonVariants, m as segmentedControlIndicatorVariants, u as segmentedControlListVariants };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognite/aura",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "**/*.scss",
@@ -227,6 +227,10 @@
227
227
  "import": "./dist/components/ui/core/chart/index.js",
228
228
  "types": "./dist/components/ui/core/chart/index.d.ts"
229
229
  },
230
+ "./data-grid": {
231
+ "import": "./dist/components/ui/core/data-grid/index.js",
232
+ "types": "./dist/components/ui/core/data-grid/index.d.ts"
233
+ },
230
234
  "./highlight-code": {
231
235
  "import": "./dist/lib/highlight-code.js",
232
236
  "types": "./dist/lib/highlight-code.d.ts"