@datum-cloud/datum-ui 2.3.1 → 2.3.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.
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from 'react';
2
+ /**
3
+ * Height animation for a group body. Do not use Radix CollapsibleContent:
4
+ * it measures `--radix-collapsible-content-height` with getBoundingClientRect,
5
+ * and later groups inside `overflow-x-auto` often measure as 0px.
6
+ *
7
+ * Keep this node mounted. AnimatePresence exit from `height: auto` has to
8
+ * measure on the way out, which is the beat of delay after a click.
9
+ * `initial={false}` skips the enter animation for groups that start open.
10
+ *
11
+ * Overflow stays hidden. The header/body divider is a 1px rule inside this
12
+ * wrapper, not a row `border-t`, so it is not clipped.
13
+ */
14
+ export declare function GroupedCollapsibleBody({ open, reduceMotion, children, }: {
15
+ open: boolean;
16
+ reduceMotion: boolean;
17
+ children: ReactNode;
18
+ }): import("react").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { t as GroupedTable } from "../grouped-table-Dldsvwz6.mjs";
1
+ import { t as GroupedTable } from "../grouped-table-C5V8ESJe.mjs";
2
2
  export { GroupedTable };
@@ -1,7 +1,7 @@
1
1
  import { t as cn } from "./utils-Bu32wN-x.mjs";
2
2
  import { t as Button } from "./button-A1qTjZ8U.mjs";
3
3
  import { t as Icon } from "./icon-wrapper-DKfJlJd0.mjs";
4
- import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./collapsible/index.mjs";
4
+ import { Collapsible, CollapsibleTrigger } from "./collapsible/index.mjs";
5
5
  import { t as useControllableState } from "./use-controllable-state-Dna7u3r9.mjs";
6
6
  import { Skeleton } from "./skeleton/index.mjs";
7
7
  import { TableBody, TableCell, TableHead, TableHeader, TableRow } from "./table/index.mjs";
@@ -11,7 +11,46 @@ import { InputWithAddons } from "./input-with-addons/index.mjs";
11
11
  import { ChevronRight, Search, X } from "lucide-react";
12
12
  import { useCallback, useMemo, useState } from "react";
13
13
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
14
+ import { motion, useReducedMotion } from "motion/react";
14
15
  import { flexRender, useTable } from "@tanstack/react-table";
16
+ //#region src/components/features/grouped-table/components/grouped-collapsible-body.tsx
17
+ const OPEN_TRANSITION = {
18
+ duration: .18,
19
+ ease: [
20
+ .23,
21
+ 1,
22
+ .32,
23
+ 1
24
+ ]
25
+ };
26
+ const INSTANT = { duration: 0 };
27
+ /**
28
+ * Height animation for a group body. Do not use Radix CollapsibleContent:
29
+ * it measures `--radix-collapsible-content-height` with getBoundingClientRect,
30
+ * and later groups inside `overflow-x-auto` often measure as 0px.
31
+ *
32
+ * Keep this node mounted. AnimatePresence exit from `height: auto` has to
33
+ * measure on the way out, which is the beat of delay after a click.
34
+ * `initial={false}` skips the enter animation for groups that start open.
35
+ *
36
+ * Overflow stays hidden. The header/body divider is a 1px rule inside this
37
+ * wrapper, not a row `border-t`, so it is not clipped.
38
+ */
39
+ function GroupedCollapsibleBody({ open, reduceMotion, children }) {
40
+ return /* @__PURE__ */ jsxs(motion.div, {
41
+ "data-slot": "grouped-table-group-content",
42
+ initial: false,
43
+ animate: { height: open ? "auto" : 0 },
44
+ transition: reduceMotion ? INSTANT : OPEN_TRANSITION,
45
+ className: "overflow-hidden",
46
+ inert: !open,
47
+ children: [/* @__PURE__ */ jsx("div", {
48
+ "data-slot": "grouped-table-group-rule",
49
+ className: "bg-border h-px"
50
+ }), children]
51
+ });
52
+ }
53
+ //#endregion
15
54
  //#region src/components/features/grouped-table/components/grouped-skeleton.tsx
16
55
  function GroupedSkeleton({ columns = 4, groups = 2, rowsPerGroup = 3 }) {
17
56
  return /* @__PURE__ */ jsx("div", {
@@ -228,6 +267,7 @@ function GroupedTable(props) {
228
267
  expanded,
229
268
  onExpandedChange
230
269
  });
270
+ const reduceMotion = Boolean(useReducedMotion());
231
271
  const resolvedColumns = useMemo(() => composeColumns(columns, {
232
272
  enableRowSelection,
233
273
  enableSorting,
@@ -249,7 +289,11 @@ function GroupedTable(props) {
249
289
  state: {
250
290
  sorting,
251
291
  rowSelection,
252
- globalFilter: search
292
+ globalFilter: search,
293
+ pagination: {
294
+ pageIndex: 0,
295
+ pageSize: Math.max(flatData.length, 1)
296
+ }
253
297
  },
254
298
  onSortingChange: setSorting,
255
299
  onRowSelectionChange: setRowSelection,
@@ -265,7 +309,7 @@ function GroupedTable(props) {
265
309
  });
266
310
  const headerGroups = table.getHeaderGroups();
267
311
  const coreRows = table.getCoreRowModel().rows;
268
- const filteredRows = table.getRowModel().rows;
312
+ const filteredRows = table.getFilteredRowModel().rows;
269
313
  const buckets = useMemo(() => bucketRows(groups, coreRows, filteredRows), [
270
314
  groups,
271
315
  coreRows,
@@ -334,8 +378,9 @@ function GroupedTable(props) {
334
378
  children: slice.meta
335
379
  })
336
380
  ]
337
- }), /* @__PURE__ */ jsx(CollapsibleContent, {
338
- "data-slot": "grouped-table-group-content",
381
+ }), /* @__PURE__ */ jsx(GroupedCollapsibleBody, {
382
+ open,
383
+ reduceMotion,
339
384
  children: /* @__PURE__ */ jsxs("table", {
340
385
  className: cn("w-full table-fixed text-sm", tableClassName),
341
386
  "aria-label": typeof slice.title === "string" ? slice.title : void 0,
@@ -350,9 +395,9 @@ function GroupedTable(props) {
350
395
  }),
351
396
  /* @__PURE__ */ jsx(TableBody, {
352
397
  className: bodyClassName,
353
- children: slice.rows.map((row, rowIndex) => /* @__PURE__ */ jsx(TableRow, {
398
+ children: slice.rows.map((row) => /* @__PURE__ */ jsx(TableRow, {
354
399
  "data-state": row.getIsSelected() ? "selected" : void 0,
355
- className: cn(rowIndex === 0 && "border-t", resolveClassName(rowClassName, row)),
400
+ className: resolveClassName(rowClassName, row),
356
401
  children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, {
357
402
  className: resolveClassName(cellClassName, cell),
358
403
  children: flexRender(cell.column.columnDef.cell, cell.getContext())
package/dist/index.mjs CHANGED
@@ -69,7 +69,7 @@ import { InputWithAddons } from "./input-with-addons/index.mjs";
69
69
  import { t as TimePicker } from "./time-picker-CFhaHTtI.mjs";
70
70
  import { t as Transfer } from "./transfer-CEq9AhL7.mjs";
71
71
  import { a as getResponsiveValue, c as GRID_COLUMNS, d as RESPONSIVE_MAP, i as getGutter, l as GRID_PREFIX, n as Row, o as registerMediaQuery, r as RowContext, s as GRID_BREAKPOINTS, t as Col, u as RESPONSIVE_ARRAY } from "./col-BYGWTB4j.mjs";
72
- import { t as GroupedTable } from "./grouped-table-Dldsvwz6.mjs";
72
+ import { t as GroupedTable } from "./grouped-table-C5V8ESJe.mjs";
73
73
  import { t as InputNumber } from "./input-number-TXmW-X9o.mjs";
74
74
  import { a as logoStyles, i as LogoFlat, n as LogoStacked, r as LogoIcon, t as LogoText } from "./logo-text-Dpm5O6Kg.mjs";
75
75
  import { t as Logo } from "./logo-C3FxD7jb.mjs";
@@ -23,7 +23,7 @@ function TableHeader({ className, ...props }) {
23
23
  function TableBody({ className, ...props }) {
24
24
  return /* @__PURE__ */ jsx("tbody", {
25
25
  "data-slot": "table-body",
26
- className: cn("[&_tr:last-child]:border-0", className),
26
+ className: cn("[&_tr:last-child]:border-b-0", className),
27
27
  ...props
28
28
  });
29
29
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@datum-cloud/datum-ui",
3
3
  "type": "module",
4
- "version": "2.3.1",
4
+ "version": "2.3.2",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "url": "https://github.com/datum-cloud/datum-ui"