@flamingo-stack/openframe-frontend-core 0.0.608 → 0.0.609-2113.5913.1

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.
Files changed (125) hide show
  1. package/dist/{chunk-4ZBC4YSQ.cjs → chunk-2JKZKICA.cjs} +33 -33
  2. package/dist/{chunk-4ZBC4YSQ.cjs.map → chunk-2JKZKICA.cjs.map} +1 -1
  3. package/dist/{chunk-FK5WVAC3.js → chunk-34BA57EO.js} +2 -2
  4. package/dist/{chunk-JZBRMXB7.cjs → chunk-3KC4YVCJ.cjs} +17 -17
  5. package/dist/{chunk-JZBRMXB7.cjs.map → chunk-3KC4YVCJ.cjs.map} +1 -1
  6. package/dist/{chunk-4Y7LBWRN.cjs → chunk-4BUYTRP6.cjs} +288 -276
  7. package/dist/chunk-4BUYTRP6.cjs.map +1 -0
  8. package/dist/{chunk-IK2MM26F.js → chunk-4LVCITQG.js} +5 -5
  9. package/dist/{chunk-L77QUPE5.cjs → chunk-4PDLKBUA.cjs} +4 -4
  10. package/dist/{chunk-L77QUPE5.cjs.map → chunk-4PDLKBUA.cjs.map} +1 -1
  11. package/dist/{chunk-LJMTURDD.cjs → chunk-5QFWF6QN.cjs} +4 -4
  12. package/dist/{chunk-LJMTURDD.cjs.map → chunk-5QFWF6QN.cjs.map} +1 -1
  13. package/dist/{chunk-4LGYBV7U.js → chunk-63SY2DW3.js} +5 -5
  14. package/dist/{chunk-XATCZQGR.js → chunk-6DUHRCDQ.js} +2 -2
  15. package/dist/{chunk-6T3252KL.cjs → chunk-6LRBV2MA.cjs} +34 -34
  16. package/dist/{chunk-6T3252KL.cjs.map → chunk-6LRBV2MA.cjs.map} +1 -1
  17. package/dist/{chunk-PLPRL4YX.js → chunk-D36QAZEX.js} +2 -2
  18. package/dist/{chunk-ORGNII3T.js → chunk-DPMZASCC.js} +4 -4
  19. package/dist/{chunk-UCKFVNYV.js → chunk-FJM3UV2Z.js} +4 -4
  20. package/dist/{chunk-BEAO6SUX.cjs → chunk-GIOP6KQD.cjs} +50 -50
  21. package/dist/{chunk-BEAO6SUX.cjs.map → chunk-GIOP6KQD.cjs.map} +1 -1
  22. package/dist/{chunk-WZROKAJT.cjs → chunk-GXN4OKUQ.cjs} +17 -17
  23. package/dist/{chunk-WZROKAJT.cjs.map → chunk-GXN4OKUQ.cjs.map} +1 -1
  24. package/dist/{chunk-WHHA3LVL.js → chunk-H4ZECYZH.js} +2 -2
  25. package/dist/{chunk-FRRNSQOG.cjs → chunk-HMBYQ7WU.cjs} +18 -18
  26. package/dist/{chunk-FRRNSQOG.cjs.map → chunk-HMBYQ7WU.cjs.map} +1 -1
  27. package/dist/{chunk-5QHY4HCC.js → chunk-I5TRPSEK.js} +99 -87
  28. package/dist/chunk-I5TRPSEK.js.map +1 -0
  29. package/dist/{chunk-YTXKRN6K.cjs → chunk-I67XY2UV.cjs} +3 -3
  30. package/dist/{chunk-YTXKRN6K.cjs.map → chunk-I67XY2UV.cjs.map} +1 -1
  31. package/dist/{chunk-C3FIMKT7.cjs → chunk-IVLODGRR.cjs} +3 -3
  32. package/dist/{chunk-C3FIMKT7.cjs.map → chunk-IVLODGRR.cjs.map} +1 -1
  33. package/dist/{chunk-JIPSQ4P7.cjs → chunk-JYCVC6OX.cjs} +10 -10
  34. package/dist/{chunk-JIPSQ4P7.cjs.map → chunk-JYCVC6OX.cjs.map} +1 -1
  35. package/dist/{chunk-BKZCYRGG.js → chunk-KKQ4FI43.js} +2 -2
  36. package/dist/{chunk-7EETXACY.cjs → chunk-LBIE5HAR.cjs} +13 -13
  37. package/dist/{chunk-7EETXACY.cjs.map → chunk-LBIE5HAR.cjs.map} +1 -1
  38. package/dist/{chunk-RN3DBEWX.js → chunk-MYTBZRRX.js} +2 -2
  39. package/dist/{chunk-MDXSLZML.js → chunk-OYHHBSJU.js} +2 -2
  40. package/dist/{chunk-N25MIHYE.cjs → chunk-TXTSCXZZ.cjs} +3 -3
  41. package/dist/{chunk-N25MIHYE.cjs.map → chunk-TXTSCXZZ.cjs.map} +1 -1
  42. package/dist/{chunk-AQGQVYDC.js → chunk-X5PUF7LB.js} +2 -2
  43. package/dist/{chunk-7ADEWG65.cjs → chunk-XJ3CHQXO.cjs} +3 -3
  44. package/dist/{chunk-7ADEWG65.cjs.map → chunk-XJ3CHQXO.cjs.map} +1 -1
  45. package/dist/{chunk-HONE2UX4.js → chunk-XKWNSPN4.js} +2 -2
  46. package/dist/{chunk-N6GFOA4J.js → chunk-YFF2NLYR.js} +3 -3
  47. package/dist/components/case-studies/index.cjs +8 -8
  48. package/dist/components/case-studies/index.js +2 -2
  49. package/dist/components/contact/index.cjs +3 -3
  50. package/dist/components/contact/index.js +2 -2
  51. package/dist/components/docs/index.cjs +6 -6
  52. package/dist/components/docs/index.js +5 -5
  53. package/dist/components/embeds/index.cjs +3 -3
  54. package/dist/components/embeds/index.js +2 -2
  55. package/dist/components/faq/index.cjs +3 -3
  56. package/dist/components/faq/index.js +2 -2
  57. package/dist/components/features/index.cjs +2 -2
  58. package/dist/components/features/index.js +1 -1
  59. package/dist/components/help-center-pages/index.cjs +22 -22
  60. package/dist/components/help-center-pages/index.js +13 -13
  61. package/dist/components/index.cjs +31 -31
  62. package/dist/components/index.js +12 -12
  63. package/dist/components/layout/list-page-layout.d.ts +1 -1
  64. package/dist/components/layout/list-page-layout.d.ts.map +1 -1
  65. package/dist/components/meeting-scheduler/index.cjs +21 -21
  66. package/dist/components/meeting-scheduler/index.js +1 -1
  67. package/dist/components/navigation/index.cjs +5 -5
  68. package/dist/components/navigation/index.js +4 -4
  69. package/dist/components/onboarding-guides/index.cjs +5 -5
  70. package/dist/components/onboarding-guides/index.js +4 -4
  71. package/dist/components/tickets/index.cjs +6 -6
  72. package/dist/components/tickets/index.js +5 -5
  73. package/dist/components/ui/data-table/data-table-body.d.ts +20 -1
  74. package/dist/components/ui/data-table/data-table-body.d.ts.map +1 -1
  75. package/dist/components/ui/data-table/data-table-row.d.ts +11 -2
  76. package/dist/components/ui/data-table/data-table-row.d.ts.map +1 -1
  77. package/dist/components/ui/data-table/index.d.ts +2 -2
  78. package/dist/components/ui/data-table/index.d.ts.map +1 -1
  79. package/dist/components/ui/data-table/types.d.ts +9 -0
  80. package/dist/components/ui/data-table/types.d.ts.map +1 -1
  81. package/dist/components/ui/data-table/use-table-motion.d.ts.map +1 -0
  82. package/dist/components/ui/filter-modal.d.ts +1 -1
  83. package/dist/components/ui/filter-modal.d.ts.map +1 -1
  84. package/dist/components/ui/index.cjs +2 -2
  85. package/dist/components/ui/index.js +1 -1
  86. package/dist/components/ui/query-report-table/query-report-table.d.ts.map +1 -1
  87. package/dist/components/ui/table/table.d.ts.map +1 -1
  88. package/dist/components/ui/table/types.d.ts +2 -5
  89. package/dist/components/ui/table/types.d.ts.map +1 -1
  90. package/dist/index.cjs +6 -6
  91. package/dist/index.js +5 -5
  92. package/package.json +1 -1
  93. package/src/components/layout/list-page-layout.tsx +1 -1
  94. package/src/components/ui/data-table/data-table-body.tsx +53 -18
  95. package/src/components/ui/data-table/data-table-row.tsx +26 -3
  96. package/src/components/ui/data-table/index.ts +1 -1
  97. package/src/components/ui/data-table/types.ts +10 -0
  98. package/src/components/ui/filter-modal.tsx +1 -1
  99. package/src/components/ui/query-report-table/query-report-table.tsx +6 -2
  100. package/src/components/ui/table/table.tsx +1 -1
  101. package/src/components/ui/table/types.ts +4 -5
  102. package/src/stories/DataTable.stories.tsx +95 -0
  103. package/src/stories/FilterModal.stories.tsx +1 -1
  104. package/src/stories/ListPageLayout.stories.tsx +191 -112
  105. package/src/stories/PageLayout.stories.tsx +21 -7
  106. package/dist/chunk-4Y7LBWRN.cjs.map +0 -1
  107. package/dist/chunk-5QHY4HCC.js.map +0 -1
  108. package/dist/components/ui/table/use-table-motion.d.ts.map +0 -1
  109. /package/dist/{chunk-FK5WVAC3.js.map → chunk-34BA57EO.js.map} +0 -0
  110. /package/dist/{chunk-IK2MM26F.js.map → chunk-4LVCITQG.js.map} +0 -0
  111. /package/dist/{chunk-4LGYBV7U.js.map → chunk-63SY2DW3.js.map} +0 -0
  112. /package/dist/{chunk-XATCZQGR.js.map → chunk-6DUHRCDQ.js.map} +0 -0
  113. /package/dist/{chunk-PLPRL4YX.js.map → chunk-D36QAZEX.js.map} +0 -0
  114. /package/dist/{chunk-ORGNII3T.js.map → chunk-DPMZASCC.js.map} +0 -0
  115. /package/dist/{chunk-UCKFVNYV.js.map → chunk-FJM3UV2Z.js.map} +0 -0
  116. /package/dist/{chunk-WHHA3LVL.js.map → chunk-H4ZECYZH.js.map} +0 -0
  117. /package/dist/{chunk-BKZCYRGG.js.map → chunk-KKQ4FI43.js.map} +0 -0
  118. /package/dist/{chunk-RN3DBEWX.js.map → chunk-MYTBZRRX.js.map} +0 -0
  119. /package/dist/{chunk-MDXSLZML.js.map → chunk-OYHHBSJU.js.map} +0 -0
  120. /package/dist/{chunk-AQGQVYDC.js.map → chunk-X5PUF7LB.js.map} +0 -0
  121. /package/dist/{chunk-HONE2UX4.js.map → chunk-XKWNSPN4.js.map} +0 -0
  122. /package/dist/{chunk-N6GFOA4J.js.map → chunk-YFF2NLYR.js.map} +0 -0
  123. /package/dist/components/ui/{table → data-table}/use-table-motion.d.ts +0 -0
  124. /package/src/components/ui/{table → data-table}/.use-table-motion.md +0 -0
  125. /package/src/components/ui/{table → data-table}/use-table-motion.ts +0 -0
@@ -7,6 +7,7 @@ import { useDataTableContext } from './data-table';
7
7
  import { DataTableEmpty } from './data-table-empty';
8
8
  import { DataTableRow } from './data-table-row';
9
9
  import { DataTableSkeleton, PlaceholderRows, ReservedEmptyState } from './data-table-skeleton';
10
+ import { useTableMotion } from './use-table-motion';
10
11
 
11
12
  export interface DataTableBodyProps<T = unknown> {
12
13
  /** Show skeleton rows while `loading` is true and data is empty. */
@@ -68,6 +69,25 @@ export interface DataTableBodyProps<T = unknown> {
68
69
  * Interactive content inside must carry `data-no-row-click`.
69
70
  */
70
71
  renderSubRow?: (item: T) => ReactNode;
72
+ /**
73
+ * Opt-in: a data reorder (same row id, new order) slides rows into place via
74
+ * FLIP instead of jumping. Rows render as framer-motion `motion.div`s with
75
+ * `layout="position"`, and framer-motion is loaded lazily — its own chunk —
76
+ * ONLY when this is set, so every other table stays motion-free. Off by
77
+ * default; the first paint after enabling is non-animated and the FLIP kicks
78
+ * in once the chunk has loaded.
79
+ *
80
+ * Two things stay with the consumer:
81
+ * - pass `getRowId` to `useDataTable`. TanStack's default row id is the row
82
+ * INDEX, and an index does not move when the data does, so React would
83
+ * re-render cells in place and nothing would animate;
84
+ * - honour `prefers-reduced-motion` at the call site (pass `false` when
85
+ * reduced motion is requested) so this prop stays purely mechanical.
86
+ *
87
+ * Rows that are a whole-card `<Link>` (`rowHref` without `onRowClick`, no
88
+ * sub-row) are not animated.
89
+ */
90
+ animateRowReorder?: boolean;
71
91
  }
72
92
 
73
93
  /**
@@ -90,9 +110,13 @@ export function DataTableBody<T = unknown>({
90
110
  rowHref,
91
111
  minRows,
92
112
  renderSubRow,
113
+ animateRowReorder,
93
114
  }: DataTableBodyProps<T>) {
94
115
  const table = useDataTableContext<T>();
95
116
  const rows = table.getRowModel().rows;
117
+ // Above the early returns — hooks run unconditionally. Resolves to `null`
118
+ // (and fetches nothing) unless `animateRowReorder` is set.
119
+ const tableMotion = useTableMotion(Boolean(animateRowReorder));
96
120
 
97
121
  if (loading && rows.length === 0) {
98
122
  return (
@@ -132,26 +156,37 @@ export function DataTableBody<T = unknown>({
132
156
 
133
157
  const padCount = minRows ? Math.max(0, minRows - rows.length) : 0;
134
158
 
159
+ const rowNodes = rows.map((row, index) => {
160
+ const item = row.original;
161
+ const href = rowHref?.(item) ?? undefined;
162
+ const cls = typeof rowClassName === 'function' ? rowClassName(item, index) : rowClassName;
163
+ return (
164
+ <DataTableRow<T>
165
+ key={row.id}
166
+ row={row}
167
+ onClick={onRowClick}
168
+ href={href}
169
+ compact={compact}
170
+ autoHeight={autoHeight}
171
+ rowHeightClassName={rowHeightClassName}
172
+ className={cls}
173
+ subRow={renderSubRow?.(item)}
174
+ animateRowReorder={animateRowReorder}
175
+ motionDiv={tableMotion?.motionDiv}
176
+ />
177
+ );
178
+ });
179
+ // With `animateRowReorder` on, ONLY the real rows go inside a `LayoutGroup`
180
+ // so a reorder (same id, new order) animates via FLIP — the invisible pad
181
+ // rows below are deliberately left outside it. Until framer-motion has
182
+ // lazily resolved (and whenever the prop is off) the rows render as plain
183
+ // `<div>`s. No `AnimatePresence`: the row set is stable across a reorder
184
+ // (no enter/exit); add it if a future task animates rows being added/removed.
185
+ const LayoutGroup = tableMotion?.LayoutGroup;
186
+
135
187
  return (
136
188
  <div className={cn('flex w-full flex-col gap-[var(--spacing-system-xsf)]', className)}>
137
- {rows.map((row, index) => {
138
- const item = row.original;
139
- const href = rowHref?.(item) ?? undefined;
140
- const cls = typeof rowClassName === 'function' ? rowClassName(item, index) : rowClassName;
141
- return (
142
- <DataTableRow<T>
143
- key={row.id}
144
- row={row}
145
- onClick={onRowClick}
146
- href={href}
147
- compact={compact}
148
- autoHeight={autoHeight}
149
- rowHeightClassName={rowHeightClassName}
150
- className={cls}
151
- subRow={renderSubRow?.(item)}
152
- />
153
- );
154
- })}
189
+ {animateRowReorder && LayoutGroup ? <LayoutGroup>{rowNodes}</LayoutGroup> : rowNodes}
155
190
  {padCount > 0 && <PlaceholderRows count={padCount} rowHeightClassName={rowHeightClassName} />}
156
191
  </div>
157
192
  );
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { flexRender, type Row } from '@tanstack/react-table';
4
4
  import type React from 'react';
5
- import { memo, useCallback, useRef, type ReactNode } from 'react';
5
+ import { memo, useCallback, useRef, type ElementType, type ReactNode } from 'react';
6
6
  import Link from '../../../embed-shims/next-link';
7
7
  import { cn } from '../../../utils/cn';
8
8
  import { ROW_HEIGHT_DESKTOP, ROW_SHELL_CLASSES } from './data-table-skeleton';
@@ -35,6 +35,15 @@ export interface DataTableRowProps<T> {
35
35
  className?: string;
36
36
  /** Expandable content rendered below the cells, inside the same card. */
37
37
  subRow?: ReactNode;
38
+ /** Opt-in FLIP reorder — see `DataTableBodyProps.animateRowReorder`. Forwarded by `DataTable.Body`. */
39
+ animateRowReorder?: boolean;
40
+ /**
41
+ * Internal: the lazily-resolved framer-motion `motion.div`, injected by
42
+ * `DataTable.Body` so framer-motion stays out of the default bundle. Typed as
43
+ * a bare `ElementType` so this module never statically references
44
+ * framer-motion. Plain `<div>` is used until it's set.
45
+ */
46
+ motionDiv?: ElementType;
38
47
  }
39
48
 
40
49
  /**
@@ -83,6 +92,8 @@ function DataTableRowImpl<T>({
83
92
  rowHeightClassName,
84
93
  className,
85
94
  subRow,
95
+ animateRowReorder,
96
+ motionDiv,
86
97
  }: DataTableRowProps<T>) {
87
98
  const hasSubRow = subRow != null && subRow !== false;
88
99
  // A sub-row carries its own interactive controls, so it must not live inside the
@@ -91,6 +102,17 @@ function DataTableRowImpl<T>({
91
102
  const isWholeCardLink = isLinkMode && !hasSubRow;
92
103
  const containerRef = useRef<HTMLElement | null>(null);
93
104
 
105
+ // Opt-in FLIP: the card becomes a `motion.div` that animates only its
106
+ // position (`layout="position"`), so a reorder slides the row without
107
+ // distorting the cell content inside it. Plain `<div>` when off, or until
108
+ // framer-motion has resolved — zero cost on the default path. A whole-card
109
+ // link row IS its `<Link>` and stays a plain link.
110
+ const animate = Boolean(animateRowReorder && motionDiv);
111
+ const Card: ElementType = animate && motionDiv ? motionDiv : 'div';
112
+ const motionProps = animate
113
+ ? { layout: 'position' as const, transition: { layout: { duration: 0.35, ease: [0.22, 1, 0.36, 1] as const } } }
114
+ : {};
115
+
94
116
  const handleClick = useCallback(
95
117
  (e: React.MouseEvent) => {
96
118
  const target = e.target as HTMLElement;
@@ -171,10 +193,11 @@ function DataTableRowImpl<T>({
171
193
  }
172
194
 
173
195
  return (
174
- <div
196
+ <Card
175
197
  ref={containerRef as React.RefObject<HTMLDivElement>}
176
198
  className={containerClassName}
177
199
  onClick={onClick ? handleClick : undefined}
200
+ {...motionProps}
178
201
  >
179
202
  {isLinkMode && href ? (
180
203
  <Link
@@ -192,7 +215,7 @@ function DataTableRowImpl<T>({
192
215
  cells
193
216
  )}
194
217
  {hasSubRow && subRow}
195
- </div>
218
+ </Card>
196
219
  );
197
220
  }
198
221
 
@@ -52,7 +52,7 @@ export { useDataTable } from './use-data-table';
52
52
  export { ROW_HEIGHT_DESKTOP, ROW_HEIGHT_MOBILE, ROW_SHELL_CLASSES } from './data-table-skeleton';
53
53
  export { alignJustify, getHideClasses, multiSelectFilterFn } from './utils';
54
54
 
55
- export type { DataTableFilterOption, TailwindBreakpoint } from './types';
55
+ export type { DataTableFilterOption, TableFilters, TailwindBreakpoint } from './types';
56
56
  export type { DataTableProps } from './data-table';
57
57
  export { DATA_TABLE_HEADER_LABEL_CLASS } from './data-table-header';
58
58
  export type { DataTableHeaderProps, DataTableSortState } from './data-table-header';
@@ -21,6 +21,16 @@ export interface DataTableFilterOption {
21
21
  count?: number;
22
22
  }
23
23
 
24
+ /**
25
+ * Per-column multi-select filter state: selected option ids keyed by column id,
26
+ * the shape `FiltersDropdown` / `FilterModal` emit and `ListPageLayout` passes
27
+ * back for its mobile filter. Lives here (not in the legacy `table/`) so the
28
+ * filter UI outlives that module.
29
+ */
30
+ export interface TableFilters {
31
+ [columnKey: string]: string[];
32
+ }
33
+
24
34
  declare module '@tanstack/react-table' {
25
35
  interface ColumnMeta<TData extends RowData, TValue> {
26
36
  /** Tailwind width class, e.g. `'w-40'`, `'flex-1 min-w-0'`. */
@@ -5,13 +5,13 @@ import { useEffect, useRef, useState } from 'react';
5
5
  import { cn } from '../../utils/cn';
6
6
  import { Filter02Icon } from '../icons-v2-generated/sort-and-filter/filter-02-icon';
7
7
  import { Button } from './button';
8
+ import type { TableFilters } from './data-table/types';
8
9
  import { DateFilterPanel, type DateFilterResult, type DateRange } from './date-picker';
9
10
  import { FilterCheckboxItem } from './filter-checkbox-item';
10
11
  import { ModalV2, ModalV2Content, ModalV2Footer, ModalV2Header, ModalV2Title } from './modal-v2';
11
12
  import { ScrollFadeOverlay, useScrollFade } from './scroll-fade';
12
13
  import { Skeleton } from './skeleton';
13
14
  import { SortColumnItem, type SortConfig, type SortDirection } from './sort-column-item';
14
- import type { TableFilters } from './table/types';
15
15
  import { TagKeyValueFilter, type TagKeyConfig } from './tag-key-value-filter';
16
16
 
17
17
  // Re-export sub-component types for consumers
@@ -5,7 +5,7 @@ import { useHorizontalScrollbar } from '../../../hooks/ui/use-horizontal-scrollb
5
5
  import { cn } from '../../../utils/cn';
6
6
  import { Download02Icon } from '../../icons-v2-generated/interface/download-02-icon';
7
7
  import { Button } from '../button';
8
- import { TableEmptyState } from '../table/table-empty-state';
8
+ import { DataTableEmpty } from '../data-table/data-table-empty';
9
9
  import { QueryReportTableHeader } from './query-report-table-header';
10
10
  import { QueryReportTableRow } from './query-report-table-row';
11
11
  import { QueryReportTableSkeleton } from './query-report-table-skeleton';
@@ -87,7 +87,11 @@ export function QueryReportTable({
87
87
  )}
88
88
 
89
89
  {/* Empty state */}
90
- {!loading && data.length === 0 && <TableEmptyState message={emptyMessage} />}
90
+ {/* Same two-vocabulary rule as `DataTable.Body`: a caller-supplied message is the
91
+ title and nothing else, the default keeps the generic search/filter hint. */}
92
+ {!loading &&
93
+ data.length === 0 &&
94
+ (emptyMessage != null ? <DataTableEmpty title={emptyMessage} description={undefined} /> : <DataTableEmpty />)}
91
95
 
92
96
  {/* Table content */}
93
97
  {!loading && data.length > 0 && (
@@ -7,12 +7,12 @@ import { Pagination } from '../../pagination';
7
7
  import { Button } from '../button';
8
8
  import { CursorPagination } from '../cursor-pagination';
9
9
  import { PlaceholderRows, ReservedEmptyState } from '../data-table/data-table-skeleton';
10
+ import { useTableMotion } from '../data-table/use-table-motion';
10
11
  import { TableEmptyState } from './table-empty-state';
11
12
  import { TableHeader } from './table-header';
12
13
  import { TableRow } from './table-row';
13
14
  import { COMPACT_ROW_MIN_HEIGHT, TableCardSkeleton } from './table-skeleton';
14
15
  import type { RowAction, TableColumn, TableProps, TableRowData } from './types';
15
- import { useTableMotion } from './use-table-motion';
16
16
 
17
17
  /**
18
18
  * Injects synthetic columns (row actions and/or row-level chevron link) at the end of the columns array.
@@ -1,4 +1,5 @@
1
1
  import type { ElementType, ReactNode } from 'react';
2
+ import type { TableFilters } from '../data-table/types';
2
3
  import type { NoDataProps } from '../no-data';
3
4
 
4
5
  /** @deprecated Use types from `data-table` instead. */
@@ -48,11 +49,9 @@ export interface FilterSection {
48
49
  allowSelectAll?: boolean;
49
50
  }
50
51
 
51
- /** @deprecated Use types from `data-table` instead. */
52
- export interface TableFilters {
53
- /** Selected option ids for a column — what `FiltersDropdown` emits. */
54
- [columnKey: string]: string[];
55
- }
52
+ // `TableFilters` is defined in `data-table/types` (one definition for both tables);
53
+ // re-exported so the legacy surface keeps the name until it is deleted.
54
+ export type { TableFilters };
56
55
 
57
56
  /** @deprecated Use types from `data-table` instead. */
58
57
  export interface CursorPagination {
@@ -1421,3 +1421,98 @@ export const KitchenSink: Story = {
1421
1421
  );
1422
1422
  },
1423
1423
  };
1424
+
1425
+ /** Seeded Fisher-Yates so every "Shuffle" click yields a NEW order (a plain `sort` by seed repeats). */
1426
+ function shuffle<T>(items: T[], seed: number): T[] {
1427
+ const result = [...items];
1428
+ let state = seed * 2654435761 + 1;
1429
+ for (let i = result.length - 1; i > 0; i--) {
1430
+ state = (state * 1103515245 + 12345) % 2147483648;
1431
+ const j = state % (i + 1);
1432
+ [result[i], result[j]] = [result[j] as T, result[i] as T];
1433
+ }
1434
+ return result;
1435
+ }
1436
+
1437
+ /**
1438
+ * **Row reorder animation** — opt in with `animateRowReorder` on
1439
+ * `<DataTable.Body>` and a reorder (same row id, new order) slides rows into
1440
+ * place via FLIP instead of jumping. framer-motion is loaded lazily, as its own
1441
+ * chunk, only for tables that set the prop.
1442
+ *
1443
+ * `getRowId` is mandatory here: TanStack's default row id is the row INDEX,
1444
+ * and an index does not move when the data does, so without it nothing would
1445
+ * animate. Honour `prefers-reduced-motion` at the call site (pass `false`).
1446
+ */
1447
+ export const WithRowReorderAnimation: Story = {
1448
+ render: () => {
1449
+ const [sort, setSort] = useState<DataTableSortState | null>({ id: 'hostname', desc: false });
1450
+ const [shuffleSeed, setShuffleSeed] = useState(0);
1451
+
1452
+ const handleSortChange = useCallback((columnId: string) => {
1453
+ setSort(prev => {
1454
+ if (prev?.id !== columnId) return { id: columnId, desc: false };
1455
+ if (!prev.desc) return { id: columnId, desc: true };
1456
+ return null;
1457
+ });
1458
+ }, []);
1459
+
1460
+ const orderedData = useMemo(() => {
1461
+ if (!sort) return shuffle(DEVICES_8, shuffleSeed);
1462
+ const dir = sort.desc ? -1 : 1;
1463
+ return [...DEVICES_8].sort((a, b) => {
1464
+ const av = a[sort.id as keyof Device] as string | number;
1465
+ const bv = b[sort.id as keyof Device] as string | number;
1466
+ if (av < bv) return -1 * dir;
1467
+ if (av > bv) return 1 * dir;
1468
+ return 0;
1469
+ });
1470
+ }, [sort, shuffleSeed]);
1471
+
1472
+ const columns = useMemo<ColumnDef<Device>[]>(
1473
+ () => [
1474
+ { accessorKey: 'hostname', header: 'Hostname', meta: { width: 'w-[200px]', sortable: true } },
1475
+ { accessorKey: 'ipAddress', header: 'IP', meta: { width: 'w-[140px]', sortable: true } },
1476
+ {
1477
+ accessorKey: 'status',
1478
+ header: 'Status',
1479
+ cell: ({ row }) => <StatusTag status={row.original.status} />,
1480
+ meta: { width: 'w-[140px]', sortable: true },
1481
+ },
1482
+ {
1483
+ accessorKey: 'cpuLoad',
1484
+ header: 'CPU',
1485
+ cell: ({ row }) => <LoadCell value={row.original.cpuLoad} />,
1486
+ meta: { width: 'flex-1 min-w-0', align: 'right', sortable: true },
1487
+ },
1488
+ ],
1489
+ [],
1490
+ );
1491
+
1492
+ const getRowId = useCallback((device: Device) => device.id, []);
1493
+ const table = useDataTable<Device>({ data: orderedData, columns, getRowId });
1494
+
1495
+ return (
1496
+ <div className="space-y-4">
1497
+ <div className="flex items-center gap-4">
1498
+ <Button
1499
+ variant="outline"
1500
+ onClick={() => {
1501
+ setSort(null);
1502
+ setShuffleSeed(seed => seed + 1);
1503
+ }}
1504
+ >
1505
+ Shuffle
1506
+ </Button>
1507
+ <span className="text-ods-text-secondary text-h5">
1508
+ Current sort: <code>{JSON.stringify(sort)}</code>
1509
+ </span>
1510
+ </div>
1511
+ <DataTable table={table}>
1512
+ <DataTable.Header sort={sort} onSortChange={handleSortChange} />
1513
+ <DataTable.Body animateRowReorder />
1514
+ </DataTable>
1515
+ </div>
1516
+ );
1517
+ },
1518
+ };
@@ -2,8 +2,8 @@ import type { Meta, StoryObj } from '@storybook/nextjs-vite';
2
2
  import { useState } from 'react';
3
3
  import { fn } from 'storybook/test';
4
4
  import { Button } from '../components/ui/button';
5
+ import type { TableFilters } from '../components/ui/data-table';
5
6
  import { FilterModal, type FilterGroup, type SortConfig, type TagKeyConfig } from '../components/ui/filter-modal';
6
- import type { TableFilters } from '../components/ui/table/types';
7
7
 
8
8
  const meta = {
9
9
  title: 'UI/FilterModal',